VR-Link API Documentation for HLA 1516
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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. More...

+ Collaboration diagram for DtEnumLoader:

Public Types

typedef DtEnumLoader *(* EnumLoaderCreator )()
 Type for the creator function for this class. See setCreator. More...
 
typedef std::list
< DtEntityTypeRange
Applicability
 Type for specifying the applicability of an enumeration. More...
 
typedef std::function< bool(const
DtFilename &, DtEnumDictionary &)> 
FileLoaderFcn
 The function prototype for loading an enumerations file. More...
 
typedef std::function
< unsigned(const DtFilename &)> 
FilePriorityReaderFcn
 The function prototype for loading an enumerations file. More...
 
typedef std::function< void(xmlNodePtr,
const Applicability
&, DtEnumDictionary &)> 
XmlEntityTypeEntryReaderFcn
 The function prototype for loading an individual entity type from an xml node. More...
 
typedef std::function< void(xmlNodePtr,
DtEnumDictionary &)> 
XmlEntryReaderFcn
 The function prototype for loading a individual enumeration from an xml node. More...
 

Public Member Functions

virtual ~DtEnumLoader ()
 Destructor. More...
 
virtual bool loadFromDirectory (const DtFilename &directory, DtEnumDictionary &dict)
 Loads all enumeration files from the given directory into the dictionary. More...
 
virtual bool loadFile (const DtFilename &file, DtEnumDictionary &dict)
 Loads the individual file. More...
 
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)
 Adds interest in a general enumeration. More...
 
virtual void addInterestInEnumRange (DtEnumUid lowerUid, DtEnumUid upperUid)
 Adds interest in a range of general enumerations. More...
 
virtual void addInterestInEntityTypeEnum (DtEnumUid uid, DtEntityTypeField)
 Adds interest in an entity type enumeration. More...
 
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)
 Registers a function to load a specific file type. More...
 
virtual void unregisterFileLoader (const DtString &fileExt)
 Remove a registered file loader. More...
 
virtual void registerFilePriorityReader (const DtString &fileExt, FilePriorityReaderFcn fcn)
 Registers a function to read the load priority from a file. More...
 
virtual void unregisterFilePriorityReader (const DtString &fileExt)
 Remove a registered priority reader. More...
 
virtual void registerUidEntryReader (DtEnumUid uid, XmlEntryReaderFcn fcn)
 Registers a reader function for an enumeration with a specific uid. More...
 
virtual void unregisterUidEntryReader (DtEnumUid uid)
 Remove a registered enumeration reader function. More...
 
virtual void registerUidRangeEntryReader (DtEnumUid lowerUid, DtEnumUid upperUid, XmlEntryReaderFcn fcn)
 Registers a reader function for enumerations with a uid within a range of uid values (exclusive of the upperId). More...
 
virtual void unregisterUidRangeEntryReader (DtEnumUid lowerUid, DtEnumUid upperUid)
 Remove a registered enumeration reader function that was defined by a range of uids. More...
 
virtual void registerEntityTypeUidEntryReader (DtEnumUid uid, XmlEntityTypeEntryReaderFcn fcn)
 Registers a reader function for an entity type enumeration with a specific uid. More...
 
virtual void unregisterEntityTypeUidEntryReader (DtEnumUid uid)
 Remove a registered entity type enumeration reader function. More...
 
virtual void registerEntityTypeFieldEntryReader (DtEntityTypeField lvl, XmlEntityTypeEntryReaderFcn fcn)
 Registers a general reader function for an entity type enumeration for a specific field level (e.g kind, domain, etc.). More...
 
virtual void unregisterEntityTypeFieldEntryReader (DtEntityTypeField lvl)
 Remove a registered entity type enumeration reader function that was defined by for a field level. More...
 

Static Public Member Functions

static DtEnumLoadercreate ()
 Creates a new DtEnumLoader using the registered creator function. More...
 
static void setCreator (EnumLoaderCreator creator)
 Sets the creator function used by create(). More...
 

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 ()
 Constructor is protected. More...
 
virtual void registerDefaultLoaders ()
 Registers default loader and reader functions for processing enums files. More...
 
virtual bool loadFromXml (const DtFilename &fn, DtEnumDictionary &dict)
 Default function used to load an xml enumerations file, such as SISO-REF-010.xml or MAK-Enums.xml. More...
 
virtual unsigned readPriorityFromXml (const DtFilename &fn)
 Default function used to read the priority from an xml enumerations file, such as MAK-Enums.xml. More...
 
virtual DtEnumUid processSingleLevelEntry (xmlNodePtr node, DtEnumDictionary::EnumMap &enums, DtString &name) const
 Processes the node, fills the enums map and name, and returns the uid of the enumeration. More...
 
virtual void processMultiLevelEntry (xmlNodePtr node, DtEntityTypeField field, const DtEntityTypeRange &applic, DtEnumDictionary &dict, DtEnumUid parentUid) const
 Processes the node, including any child nodes that also require processing, and adds all new enumerations to the dictionary. More...
 
virtual void setEntityTypeLevel (unsigned lvl, int lowerVal, int upperVal, DtEntityTypeRange &etRange) const
 Sets the range of values for the field at the specified level of the entity type. More...
 
virtual DtEntityTypeField parseApplicability (const xmlChar *c, std::list< DtEntityTypeRange > &applics) const
 Parses the applicability from the the xml text. More...
 
virtual int xmlCharToInt (const xmlChar *c) const
 Converts an xmlChar string to an integer. More...
 
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
 

Detailed Description

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

Member Typedef Documentation

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 DtEnumLoader*(* DtEnumLoader::EnumLoaderCreator)()

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

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

The function prototype for loading an enumerations file.

typedef std::map<DtString, FileLoaderFcn> DtEnumLoader::FileLoaderMap
protected
typedef std::function<unsigned(const DtFilename&)> DtEnumLoader::FilePriorityReaderFcn

The function prototype for loading an enumerations file.

typedef std::function<void(xmlNodePtr, const Applicability&, DtEnumDictionary&)> DtEnumLoader::XmlEntityTypeEntryReaderFcn

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

typedef std::function<void(xmlNodePtr, DtEnumDictionary&)> DtEnumLoader::XmlEntryReaderFcn

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

typedef std::pair<int, int> DtEnumLoader::XmlUidRange
protected
typedef std::map<int, XmlEntryReaderFcn> DtEnumLoader::XmlUidReaderMap
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

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

Adds interest in an entity type enumeration.

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.

static DtEnumLoader* DtEnumLoader::create ( )
static

Creates a new DtEnumLoader using the registered creator function.

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

Loads the individual file.

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::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 DtEntityTypeField DtEnumLoader::parseApplicability ( const xmlChar c,
std::list< DtEntityTypeRange > &  applics 
) const
protectedvirtual

Parses the applicability from the the xml text.

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 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::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 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::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 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::registerEntityTypeUidEntryReader ( DtEnumUid  uid,
XmlEntityTypeEntryReaderFcn  fcn 
)
virtual

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

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

Registers a function to load a specific file type.

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

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

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

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

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.

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 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 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::unregisterEntityTypeUidEntryReader ( DtEnumUid  uid)
virtual

Remove a registered entity type enumeration reader function.

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

Remove a registered file loader.

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

Remove a registered priority reader.

virtual void DtEnumLoader::unregisterUidEntryReader ( DtEnumUid  uid)
virtual

Remove a registered enumeration reader function.

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

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

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

Converts an xmlChar string to an integer.

Member Data Documentation

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

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

Document ID: Generated on Thu Oct 16 00:12:25 EDT 2025 from SVN revision 280738
Copyright © 1992-2025 MAK Technologies. All Rights Reserved (www.mak.com)