VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes
DtEnumLoader Class Reference

Loads entity type enumerations from an XML file into a DtEnumDictionary.

Public Types

typedef DtEnumLoader *(* EnumLoaderCreator )()
 
typedef std::list
< DtEntityTypeRange
Applicability
 
typedef boost::function< bool(const
DtFilename &, DtEnumDictionary &)> 
FileLoaderFcn
 
typedef boost::function
< unsigned(const DtFilename &)> 
FilePriorityReaderFcn
 
typedef boost::function< void(xmlNodePtr,
const Applicability
&, DtEnumDictionary &)> 
XmlEntityTypeEntryReaderFcn
 
typedef boost::function< void(xmlNodePtr,
DtEnumDictionary &)> 
XmlEntryReaderFcn
 

Public Member Functions

virtual ~DtEnumLoader ()
 
virtual bool loadFromDirectory (const DtFilename &directory, DtEnumDictionary &dict)
 
virtual bool loadFile (const DtFilename &file, DtEnumDictionary &dict)
 
Add Interest in Enumerations

These methods can be used to tell the loader to read in enumerations that it does not support by default use standard formats.

virtual void addInterestInEnum (DtEnumUid uid)
 
virtual void addInterestInEnumRange (DtEnumUid lowerUid, DtEnumUid upperUid)
 
virtual void addInterestInEntityTypeEnum (DtEnumUid uid, DtEntityTypeField)
 
Registration/unregistration of Enumeration Reader Functions

These methods allow you to define custom functions for reading new file types or customizing how specific xml entries should be processed. Generally they are not needed by most users. If you wish the DtEnumLoader to read enumerations using existing functions for uids not read in by default, use #addInterestInEnumeration, addInterestInEnumRange, or addInterestInEntityTypeEnum.

virtual void registerFileLoader (const DtString &fileExt, FileLoaderFcn fcn)
 
virtual void unregisterFileLoader (const DtString &fileExt)
 
virtual void registerFilePriorityReader (const DtString &fileExt, FilePriorityReaderFcn fcn)
 
virtual void unregisterFilePriorityReader (const DtString &fileExt)
 
virtual void registerUidEntryReader (DtEnumUid uid, XmlEntryReaderFcn fcn)
 
virtual void unregisterUidEntryReader (DtEnumUid uid)
 
virtual void registerUidRangeEntryReader (DtEnumUid lowerUid, DtEnumUid upperUid, XmlEntryReaderFcn fcn)
 
virtual void unregisterUidRangeEntryReader (DtEnumUid lowerUid, DtEnumUid upperUid)
 
virtual void registerEntityTypeUidEntryReader (DtEnumUid uid, XmlEntityTypeEntryReaderFcn fcn)
 
virtual void unregisterEntityTypeUidEntryReader (DtEnumUid uid)
 
virtual void registerEntityTypeFieldEntryReader (DtEntityTypeField lvl, XmlEntityTypeEntryReaderFcn fcn)
 
virtual void unregisterEntityTypeFieldEntryReader (DtEntityTypeField lvl)
 

Static Public Member Functions

static DtEnumLoadercreate ()
 
static void setCreator (EnumLoaderCreator creator)
 

Protected Types

typedef std::map< DtString,
FileLoaderFcn
FileLoaderMap
 
typedef std::map< DtString,
FilePriorityReaderFcn
FilePriorityReaderMap
 
typedef std::map< int,
XmlEntryReaderFcn
XmlUidReaderMap
 
typedef std::pair< int, intXmlUidRange
 
typedef std::map< XmlUidRange,
XmlEntryReaderFcn
XmlUidRangeReaderMap
 
typedef std::map< int,
XmlEntityTypeEntryReaderFcn
XmlEntityTypeUidReaderMap
 
typedef std::map
< DtEntityTypeField,
XmlEntityTypeEntryReaderFcn
XmlEntityTypeLevelReaderMap
 

Protected Member Functions

 DtEnumLoader ()
 
virtual void registerDefaultLoaders ()
 
virtual bool loadFromXml (const DtFilename &fn, DtEnumDictionary &dict)
 
virtual unsigned readPriorityFromXml (const DtFilename &fn)
 
virtual DtEnumUid processSingleLevelEntry (xmlNodePtr node, DtEnumDictionary::EnumMap &enums, DtString &name) const
 
virtual void processMultiLevelEntry (xmlNodePtr node, DtEntityTypeField field, const DtEntityTypeRange &applic, DtEnumDictionary &dict, DtEnumUid parentUid) const
 
virtual void setEntityTypeLevel (unsigned lvl, int lowerVal, int upperVal, DtEntityTypeRange &etRange) const
 
virtual DtEntityTypeField parseApplicability (const xmlChar *c, std::list< DtEntityTypeRange > &applics) const
 
virtual int xmlCharToInt (const xmlChar *c) const
 
Default xml reader functions.
virtual void readEntityTypeEnum (xmlNodePtr node, DtEntityTypeField field, const Applicability &applics, DtEnumDictionary &dict) const
 
virtual void readEntityTypesHierarchy (xmlNodePtr node, DtEnumDictionary &dict) const
 
virtual void readEnum (xmlNodePtr node, DtEnumDictionary &dict) const
 

Protected Attributes

bool myDefaultLoadersRegistered
 
FileLoaderMap myFileLoaders
 
FilePriorityReaderMap myFilePriorityReaders
 
XmlUidReaderMap myReadersByUid
 
XmlUidRangeReaderMap myReadersByUidRange
 
XmlEntityTypeUidReaderMap myEntityTypeReadersByUid
 
XmlEntityTypeLevelReaderMap myEntityTypeReadersByLevel
 
DtEnumDictionarymyDict
 
DtFilename myCurrFilename
 

Static Protected Attributes

static EnumLoaderCreator theCreator
 

Member Typedef Documentation

typedef DtEnumLoader*(* DtEnumLoader::EnumLoaderCreator)()

Type for the creator function for this class. See setCreator.

Type for specifying the applicability of an enumeration. This indicates what higher level entity type fields a given enumeration can be used with. DtEntityTypeRange supports a range of values within a given level, but you may need multiple different ranges, hence the list.

typedef boost::function<bool(const DtFilename&, DtEnumDictionary&)> DtEnumLoader::FileLoaderFcn

The function prototype for loading an enumerations file.

typedef boost::function<unsigned(const DtFilename&)> DtEnumLoader::FilePriorityReaderFcn

The function prototype for loading an enumerations file.

The function prototype for loading an individual entity type from an xml node.

The function prototype for loading a individual enumeration from an xml node.

typedef std::map<DtString, FileLoaderFcn> DtEnumLoader::FileLoaderMap
protected
typedef std::map<int, XmlEntryReaderFcn> DtEnumLoader::XmlUidReaderMap
protected
typedef std::pair<int, int> DtEnumLoader::XmlUidRange
protected

Constructor & Destructor Documentation

virtual DtEnumLoader::~DtEnumLoader ( )
virtual

Destructor.

DtEnumLoader::DtEnumLoader ( )
protected

Constructor is protected. Should call create() to create your loader. Ensures the registered creator function is called.

Member Function Documentation

static DtEnumLoader* DtEnumLoader::create ( )
static

Creates a new DtEnumLoader using the registered creator function.

static void DtEnumLoader::setCreator ( EnumLoaderCreator  creator)
static

Sets the creator function used by create(). Use this to override what DtEnumLoader is created by the application. This is how a user would register their own subclass that might add functions for reading new all new file types or for specific enumerations.

virtual bool DtEnumLoader::loadFromDirectory ( const DtFilename &  directory,
DtEnumDictionary dict 
)
virtual

Loads all enumeration files from the given directory into the dictionary. Returns true if successful.

virtual bool DtEnumLoader::loadFile ( const DtFilename &  file,
DtEnumDictionary dict 
)
virtual

Loads the individual file.

virtual void DtEnumLoader::addInterestInEnum ( DtEnumUid  uid)
virtual

Adds interest in a general enumeration.

virtual void DtEnumLoader::addInterestInEnumRange ( DtEnumUid  lowerUid,
DtEnumUid  upperUid 
)
virtual

Adds interest in a range of general enumerations.

virtual void DtEnumLoader::addInterestInEntityTypeEnum ( DtEnumUid  uid,
DtEntityTypeField   
)
virtual

Adds interest in an entity type enumeration.

virtual void DtEnumLoader::registerFileLoader ( const DtString fileExt,
FileLoaderFcn  fcn 
)
virtual

Registers a function to load a specific file type.

virtual void DtEnumLoader::unregisterFileLoader ( const DtString fileExt)
virtual

Remove a registered file loader.

virtual void DtEnumLoader::registerFilePriorityReader ( const DtString fileExt,
FilePriorityReaderFcn  fcn 
)
virtual

Registers a function to read the load priority from a file.

virtual void DtEnumLoader::unregisterFilePriorityReader ( const DtString fileExt)
virtual

Remove a registered priority reader.

virtual void DtEnumLoader::registerUidEntryReader ( DtEnumUid  uid,
XmlEntryReaderFcn  fcn 
)
virtual

Registers a reader function for an enumeration with a specific uid.

virtual void DtEnumLoader::unregisterUidEntryReader ( DtEnumUid  uid)
virtual

Remove a registered enumeration reader function.

virtual void DtEnumLoader::registerUidRangeEntryReader ( DtEnumUid  lowerUid,
DtEnumUid  upperUid,
XmlEntryReaderFcn  fcn 
)
virtual

Registers a reader function for enumerations with a uid within a range of uid values (exclusive of the upperId). This will be used only if there is no specific uid reader specified via registerUidEntryReader.

virtual void DtEnumLoader::unregisterUidRangeEntryReader ( DtEnumUid  lowerUid,
DtEnumUid  upperUid 
)
virtual

Remove a registered enumeration reader function that was defined by a range of uids.

virtual void DtEnumLoader::registerEntityTypeUidEntryReader ( DtEnumUid  uid,
XmlEntityTypeEntryReaderFcn  fcn 
)
virtual

Registers a reader function for an entity type enumeration with a specific uid.

virtual void DtEnumLoader::unregisterEntityTypeUidEntryReader ( DtEnumUid  uid)
virtual

Remove a registered entity type enumeration reader function.

virtual void DtEnumLoader::registerEntityTypeFieldEntryReader ( DtEntityTypeField  lvl,
XmlEntityTypeEntryReaderFcn  fcn 
)
virtual

Registers a general reader function for an entity type enumeration for a specific field level (e.g kind, domain, etc.). This will be used only if there is no specific uid reader specified via registerEntityTypeUidEntryReader.

virtual void DtEnumLoader::unregisterEntityTypeFieldEntryReader ( DtEntityTypeField  lvl)
virtual

Remove a registered entity type enumeration reader function that was defined by for a field level.

virtual void DtEnumLoader::registerDefaultLoaders ( )
protectedvirtual

Registers default loader and reader functions for processing enums files. If not previously called, will be called by loadFromFiles() before starting load. Can be overridden in a subclass to provide different or additional default loaders.

virtual bool DtEnumLoader::loadFromXml ( const DtFilename &  fn,
DtEnumDictionary dict 
)
protectedvirtual

Default function used to load an xml enumerations file, such as SISO-REF-010.xml or MAK-Enums.xml.

virtual unsigned DtEnumLoader::readPriorityFromXml ( const DtFilename &  fn)
protectedvirtual

Default function used to read the priority from an xml enumerations file, such as MAK-Enums.xml. SISO-REF-010.xml is always priority 0 and is loaded first.

virtual void DtEnumLoader::readEntityTypeEnum ( xmlNodePtr  node,
DtEntityTypeField  field,
const Applicability applics,
DtEnumDictionary dict 
) const
protectedvirtual
virtual void DtEnumLoader::readEntityTypesHierarchy ( xmlNodePtr  node,
DtEnumDictionary dict 
) const
protectedvirtual
virtual void DtEnumLoader::readEnum ( xmlNodePtr  node,
DtEnumDictionary dict 
) const
protectedvirtual
virtual DtEnumUid DtEnumLoader::processSingleLevelEntry ( xmlNodePtr  node,
DtEnumDictionary::EnumMap enums,
DtString name 
) const
protectedvirtual

Processes the node, fills the enums map and name, and returns the uid of the enumeration.

virtual void DtEnumLoader::processMultiLevelEntry ( xmlNodePtr  node,
DtEntityTypeField  field,
const DtEntityTypeRange applic,
DtEnumDictionary dict,
DtEnumUid  parentUid 
) const
protectedvirtual

Processes the node, including any child nodes that also require processing, and adds all new enumerations to the dictionary.

virtual void DtEnumLoader::setEntityTypeLevel ( unsigned  lvl,
int  lowerVal,
int  upperVal,
DtEntityTypeRange etRange 
) const
protectedvirtual

Sets the range of values for the field at the specified level of the entity type.

virtual DtEntityTypeField DtEnumLoader::parseApplicability ( const xmlChar c,
std::list< DtEntityTypeRange > &  applics 
) const
protectedvirtual

Parses the applicability from the the xml text.

virtual int DtEnumLoader::xmlCharToInt ( const xmlChar c) const
protectedvirtual

Converts an xmlChar string to an integer.

Member Data Documentation

bool DtEnumLoader::myDefaultLoadersRegistered
protected
FileLoaderMap DtEnumLoader::myFileLoaders
protected
FilePriorityReaderMap DtEnumLoader::myFilePriorityReaders
protected
XmlUidReaderMap DtEnumLoader::myReadersByUid
protected
XmlUidRangeReaderMap DtEnumLoader::myReadersByUidRange
protected
XmlEntityTypeUidReaderMap DtEnumLoader::myEntityTypeReadersByUid
protected
XmlEntityTypeLevelReaderMap DtEnumLoader::myEntityTypeReadersByLevel
protected
DtEnumDictionary* DtEnumLoader::myDict
protected
DtFilename DtEnumLoader::myCurrFilename
protected
EnumLoaderCreator DtEnumLoader::theCreator
staticprotected

The documentation for this class was generated from the following file:

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)