Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

nvsg::SceneLoader Class Reference

Pure virtual base class for NVSG scene loader plug-ins. More...

#include <PlugInterface.h>

Inheritance diagram for nvsg::SceneLoader:

Inheritance graph
[legend]
Collaboration diagram for nvsg::SceneLoader:

Collaboration graph
[legend]
List of all members.

Public Methods

virtual NVSG_API const Sceneload (const std::string &filename, const std::vector< std::string > &searchPaths, const ViewState *&viewState)=0
 Loading a scene. More...


Protected Methods

virtual NVSG_API ~SceneLoader ()
 Protected virtual destructor. More...


Detailed Description

Pure virtual base class for NVSG scene loader plug-ins.

User defined NVSG scene loader plug-ins must provide the SceneLoader interface.

Client code that needs to utilize a certain SceneLoader interface should first query for a unique plug interface type ID through a call to nvutil::queryInterfaceType. The unique plug interface type ID for a SceneLoader will be constructed from the UPITID_SCENE_SAVER define and the actual NVSG version, which is coded in the UPITID_VERSION define, as shown in the code snippet below. A call to nvutil::queryInterfaceType returns a list of all unique interface IDs (UPIIDSs) found at given search paths.
After that, the client code can take the different UPIIDs to grab a scene loader interface through a call to nvutil::getInterface.\n After usage, the client code should release the interface through a call to nvutil::releaseInterface:

   // Example:
   // --------
   // Get a scene loader interface capable to load 'nvb' files
   
   // 
   vector<string> searchPathes;
   // Add appropriate search paths here. Not relevant for the example here.
   // ...

   // define the unique plug interface type ID for SceneLoaders
   const nvutil::UPITID PITID_SCENE_LOADER(UPITID_SCENE_LOADER, UPITID_VERSION);

   nvsg::Scene * theScene = NULL;
   nvsg::ViewState * viewState = NULL;
   nvutil::UPIID nvbLoaderInterfaceID;
   bool foundAppropriate = false;
   vector<nvutil::UPIID> piids;
   if ( nvutil::queryInterfaceType(searchPathes, PITID_SCENE_LOADER, piids) )
   {
     vector<nvutil::UPIID>::iterator it = piids.begin();
     for ( ; it != piids.end(); ++it )
     {
       if ( !stricmp((*it).getPlugSpecificIDString(), ".nvb") )
       {
         // found, copy the ID
         nvbLoaderInterfaceID = *it;
         foundAppropriate = true;
         break; // look no further
       }
     }
     if ( foundAppropriate )
     {
       nvutil::PlugIn * plug; 
       if ( nvutil::getInterface(searchPathes, nvbLoaderInterfaceID, plug) )
       {
         nvsg::SceneLoader * loader = reinterpret_cast<SceneLoader*>(plug);
         theScene = loader->load("c:\\nvb\\sample.nvb", searchPathes, viewState);
         if ( theScene ) 
         { 
           theScene->addRef();
           if ( viewState )
           {
             viewState->addRef();
           }
         }
         nvutil::releaseInterface(nvbLoaderInterfaceID);
       }
     }
   }


Constructor & Destructor Documentation

virtual NVSG_API nvsg::SceneLoader::~SceneLoader   [protected, virtual]
 

Protected virtual destructor.

Prohibits ordinary client code from

  • creating a SceneLoader derived object on stack and
  • calling delete on a pointer to SceneLoader.
Note:
This will not prohibit the client code from calling delete on a pointer to a SceneLoader derived object. Normally this is not that critical, because one almost always uses a pointer to the base class when working with SceneLoader plug-ins.

Nevertheless, it would be far less error prone if classes that inherit from SceneLoader also make their destructor protected.


Member Function Documentation

virtual NVSG_API const Scene* nvsg::SceneLoader::load const std::string &    filename,
const std::vector< std::string > &    searchPaths,
const ViewState *&    viewState
[pure virtual]
 

Loading a scene.

Loads an NVSG scene from a file specified by filename. The function tries to look up this file as follows:

  1. Looks at the specified location.
  2. Looks at the current directory.
  3. Uses the search paths stored in searchPaths to look up the file.
Returns:
A pointer to the loaded scene if successful, a null pointer otherwise.
Parameters:
filename  A string that holds the name of the scene file to be loaded.
searchPaths  A collection of search pathes used to look up the file.
viewState  If the function succeeded, this points to the optional ViewState stored with the scene.


The documentation for this class was generated from the following file:
Generated on Tue Mar 1 13:20:30 2005 for NVSGSDK by NVIDIA