ADTF  3.18.2
cDDLImporter

Concrete Factory Method for building up a DDL from a XML file. More...

Inheritance diagram for cDDLImporter:
[legend]

Public Member Functions

 cDDLImporter (bool bBasicCheck=true, bool bSorted=true)
 Default CTOR. More...
 
 cDDLImporter (const A_UTILS_NS::cFilename &strFile, bool bBasicCheck=true, bool bSorted=true)
 CTOR with file name/path. More...
 
 cDDLImporter (const char *strFile, bool bBasicCheck=true, bool bSorted=true)
 CTOR with file name/path. More...
 
 cDDLImporter (int nCreationLevel, bool bBasicCheck=true, bool bSorted=true)
 CTOR with creation level. More...
 
cDDLDescriptionGetDDL () const
 Getter for the DDL object. More...
 
tResult CreateNew (double fVersion=0)
 Method to build up a new DDL hierarchy. More...
 
void DestroyDDL ()
 Method to destroy the DDL object and all contained objects.
 
tResult BuildHeader ()
 Method to build a header object. More...
 
tResult BuildUnits ()
 Method to build a units object hierarchy. More...
 
tResult BuildDatatypes ()
 Method to build a datatypes object hierarchy. More...
 
tResult BuildStructs ()
 Method to build a structs object hierarchy. More...
 
tResult BuildStreams ()
 Method to build a streams object hierarchy. More...
 
tResult BuildEnums ()
 Method to build a enums object hierarchy. More...
 
tResult BuildStreamMetaTypes ()
 Method to build a streams object hierarchy. More...
 
void SetCreationLevel (int const nLevel=1)
 Setter for the creation level. More...
 
void SetFullCheckDescriptionMode (bool bFullCheck=false)
 Setter for the validation mode. More...
 
void SetMergeDefaults (bool bMergeDefaults=true)
 Setter to enable disable the merge of DDL defaults (units, datattypes, etc.) More...
 
void SetPreferReferenceEntities (bool bPrefereReference=true)
 Setter to switch from prefereing entities from the reference DDL, to using the reference enties only when there is no "local" aquivalent. More...
 
tResult CreatePartial (const cDDLDescription *poRefDDL, double fVersion)
 Method to create a partial DDL (e.g. More...
 
tResult SetFile (A_UTILS_NS::cFilename const strFile)
 Setter for the source file. More...
 
tResult SetDOM (A_UTILS_NS::cDOM *poDOM)
 Setter for a DOM. More...
 
tResult SetXML (const A_UTILS_NS::cString &strXML)
 Setter for a XML string containing the DDL to import. More...
 
A_UTILS_NS::cString GetErrorDesc () const
 Getter for the description of the last error. More...
 
A_UTILS_NS::cString GetLastErrorDesc () const
 Getter for the most recent error description. More...
 
tImporterMsgList GetAllMessages () const
 Getter for all detected errors. More...
 
void PrintAllMessages (tImporterMsgSeverity eLeastSeverity=eImporterInfo)
 Method to log all messages which have at least the given severity to console. More...
 
- Public Member Functions inherited from IDDLFactoryMethod
virtual ~IDDLFactoryMethod ()
 DTOR.
 

Static Public Member Functions

static void DestroyDDL (cDDLDescription *poDDL)
 Static method to destroy the given DDL hierarchy. More...
 

Private Member Functions

tResult BuildSingleBaseunit (cDDLBaseunit **ppoNewBU, A_UTILS_NS::cDOMElementRef poBUElement)
 Creates a baseunit object from the given DOMElement. More...
 
tResult BuildSinglePrefix (cDDLPrefix **ppoNewPrefix, A_UTILS_NS::cDOMElementRef poPrefixElement)
 Creates a prefix object from the given DOMElement. More...
 
tResult BuildSingleUnit (cDDLUnit **ppoNewUnit, A_UTILS_NS::cDOMElementRef poUnitElement)
 Creates a unit object from the given DOMElement. More...
 
tResult BuildSingleDatatype (cDDLDataType **ppoNewDatatype, A_UTILS_NS::cDOMElement *poDTElement)
 Creates a datatype object from the given DOMElement. More...
 
tResult BuildSingleEnum (cDDLEnum **ppoNewEnum, A_UTILS_NS::cDOMElement *poEnumElement)
 Creates an enum object from the given DOMElement. More...
 
tResult BuildSingleStruct (cDDLComplex **ppoNewStruct, A_UTILS_NS::cDOMElement *poStructElement)
 Creates a struct object from the given DOMElement. More...
 
tResult BuildSingleStream (cDDLStream **ppoNewStream, A_UTILS_NS::cDOMElement *poStreamElement)
 Creates a DDL stream object from the given DOMElement. More...
 
tResult BuildSingleStreamMetaType (A_UTILS_NS::cDOMElement *poStreamMetaTypeElement, tDDLStreamMetaTypeVec &vecStreamMetaTypes)
 Creates a DDL stream object from the given DOMElement. More...
 
void PushMessage (const A_UTILS_NS::cString &strMsg, tImporterMsgSeverity eSeverity)
 Helper method to create a message and save it in the appropriate container. More...
 
template<typename T >
T * TryToFind (const A_UTILS_NS::cString &strName, cDDLContainer< T > &vecFirstData, cDDLContainer< T > &vecSecondData)
 Helper method to find specific elements inside the given vecFirstData by Name. More...
 

Private Attributes

A_UTILS_NS::cDOM m_oDOM
 
cDDLDescriptionm_poDDL
 
const cDDLDescriptionm_poCurrentRefDDL
 
tDDLUnitVec m_vecUnknownUnits
 
tDDLComplexVec m_vecUnknownStructs
 
tDDLStreamMetaTypeVec m_vecUnknownStreamMetaTypes
 
bool m_bInitFlag
 
int m_nCreationLevel
 
bool m_bFullCheck
 
tImporterMsgList m_lstErrors
 
bool m_bBasicCheck
 
bool m_bMergeDefaults
 
bool m_bSorted
 
bool m_bPrefereReference
 

Detailed Description

Concrete Factory Method for building up a DDL from a XML file.

Definition at line 44 of file ddlimporter.h.

Constructor & Destructor Documentation

◆ cDDLImporter() [1/4]

cDDLImporter ( bool  bBasicCheck = true,
bool  bSorted = true 
)

Default CTOR.

Parameters
[in]bBasicCheckPerform basic checks during Create* (unique element names etc.). For a full check use cDDLInspector.
[in]bSortedSorts all DDL items by name for better performance.

◆ cDDLImporter() [2/4]

cDDLImporter ( const A_UTILS_NS::cFilename strFile,
bool  bBasicCheck = true,
bool  bSorted = true 
)

CTOR with file name/path.

Parameters
[in]strFile- Path to file to use
[in]bBasicCheckPerform basic checks during Create* (unique element names etc.). For a full check use cDDLInspector.
[in]bSortedSorts all DDL items by name for better performance.

◆ cDDLImporter() [3/4]

cDDLImporter ( const char *  strFile,
bool  bBasicCheck = true,
bool  bSorted = true 
)

CTOR with file name/path.

Parameters
[in]strFile- Path to file to use
[in]bBasicCheckPerform basic checks during Create* (unique element names etc.). For a full check use cDDLInspector.
[in]bSortedSorts all DDL items by name for better performance.

◆ cDDLImporter() [4/4]

cDDLImporter ( int  nCreationLevel,
bool  bBasicCheck = true,
bool  bSorted = true 
)

CTOR with creation level.

Parameters
[in]nCreationLevel- Creation level
[in]bBasicCheckPerform basic checks during Create* (unique element names etc.). For a full check use cDDLInspector.
[in]bSortedSorts all DDL items by name for better performance.

Member Function Documentation

◆ BuildDatatypes()

tResult BuildDatatypes ( )
virtual

Method to build a datatypes object hierarchy.

Return values
ERR_UNKNOWN_FORMATExpected XML hierarchy not found
ERR_NO_CLASSCross reference not resolvable (e.g. unit)

Implements IDDLFactoryMethod.

◆ BuildEnums()

tResult BuildEnums ( )
virtual

Method to build a enums object hierarchy.

Return values
ERR_UNKNOWN_FORMATExpected XML hierarchy not found
ERR_NO_CLASSCross reference not resolvable (e.g. RefEnums)
ERR_UNKNOWNNot all firstly unknown structs have been resolved

Implements IDDLFactoryMethod.

◆ BuildHeader()

tResult BuildHeader ( )
virtual

Method to build a header object.

Return values
ERR_UNKNOWN_FORMATExpected XML hierarchy not found

Implements IDDLFactoryMethod.

◆ BuildSingleBaseunit()

tResult BuildSingleBaseunit ( cDDLBaseunit **  ppoNewBU,
A_UTILS_NS::cDOMElementRef  poBUElement 
)
private

Creates a baseunit object from the given DOMElement.

Parameters
[out]ppoNewBU- Pointer to pointer to the newly created baseunit object
[in]poBUElement- Pointer to the DOMElement with the information
Return values
ERR_UNKNOWN_FORMATExpected XML hierarchy not found
ERR_NO_CLASSCross reference not resolvable

◆ BuildSingleDatatype()

tResult BuildSingleDatatype ( cDDLDataType **  ppoNewDatatype,
A_UTILS_NS::cDOMElement poDTElement 
)
private

Creates a datatype object from the given DOMElement.

Parameters
[out]ppoNewDatatype- Pointer to pointer to the newly created datatype object
[in]poDTElement- Pointer to the DOMElement with the information
Return values
ERR_UNKNOWN_FORMATExpected XML hierarchy not found
ERR_NO_CLASSCross reference not resolvable (e.g. unit)

◆ BuildSingleEnum()

tResult BuildSingleEnum ( cDDLEnum **  ppoNewEnum,
A_UTILS_NS::cDOMElement poEnumElement 
)
private

Creates an enum object from the given DOMElement.

Parameters
[out]ppoNewEnum- Pointer to pointer to the newly created enum object
[in]poEnumElement- Pointer to the DOMElement with the information
Return values
ERR_UNKNOWN_FORMATExpected XML hierarchy not found
ERR_NO_CLASSCross reference not resolvable (e.g. unit)

◆ BuildSinglePrefix()

tResult BuildSinglePrefix ( cDDLPrefix **  ppoNewPrefix,
A_UTILS_NS::cDOMElementRef  poPrefixElement 
)
private

Creates a prefix object from the given DOMElement.

Parameters
[out]ppoNewPrefix- Pointer to pointer to the newly created prefix object
[in]poPrefixElement- Pointer to the DOMElement with the information
Return values
ERR_UNKNOWN_FORMATExpected XML hierarchy not found
ERR_NO_CLASSCross reference not resolvable

◆ BuildSingleStream()

tResult BuildSingleStream ( cDDLStream **  ppoNewStream,
A_UTILS_NS::cDOMElement poStreamElement 
)
private

Creates a DDL stream object from the given DOMElement.

Parameters
[out]ppoNewStream- Pointer to pointer to the newly created stream object
[in]poStreamElement- Pointer to the DOMElement with the information
Return values
ERR_UNKNOWN_FORMATExpected XML hierarchy not found
ERR_NO_CLASSCross reference not resolvable (e.g. struct)

◆ BuildSingleStreamMetaType()

tResult BuildSingleStreamMetaType ( A_UTILS_NS::cDOMElement poStreamMetaTypeElement,
tDDLStreamMetaTypeVec vecStreamMetaTypes 
)
private

Creates a DDL stream object from the given DOMElement.

Parameters
[out]poStreamMetaTypeElement
[in]vecStreamMetaTypes
Return values
ERR_UNKNOWN_FORMATExpected XML hierarchy not found
ERR_NO_CLASSCross reference not resolvable (e.g. struct)

◆ BuildSingleStruct()

tResult BuildSingleStruct ( cDDLComplex **  ppoNewStruct,
A_UTILS_NS::cDOMElement poStructElement 
)
private

Creates a struct object from the given DOMElement.

Parameters
[out]ppoNewStruct- Pointer to pointer to the newly created struct object
[in]poStructElement- Pointer to the DOMElement with the information
Return values
ERR_UNKNOWN_FORMATExpected XML hierarchy not found
ERR_NO_CLASSCross reference not resolvable (e.g. datatype)
ERR_UNKNOWNNot all firstly unknown structs have been resolved

◆ BuildSingleUnit()

tResult BuildSingleUnit ( cDDLUnit **  ppoNewUnit,
A_UTILS_NS::cDOMElementRef  poUnitElement 
)
private

Creates a unit object from the given DOMElement.

Parameters
[out]ppoNewUnit- Pointer to pointer to the newly created unit object
[in]poUnitElement- Pointer to the DOMElement with the information
Return values
ERR_UNKNOWN_FORMATExpected XML hierarchy not found
ERR_NO_CLASSCross reference not resolvable

◆ BuildStreamMetaTypes()

tResult BuildStreamMetaTypes ( )
virtual

Method to build a streams object hierarchy.

Return values
ERR_UNKNOWN_FORMATExpected XML hierarchy not found
ERR_NO_CLASSCross reference not resolvable (e.g. struct)

Implements IDDLFactoryMethod.

◆ BuildStreams()

tResult BuildStreams ( )
virtual

Method to build a streams object hierarchy.

Return values
ERR_UNKNOWN_FORMATExpected XML hierarchy not found
ERR_NO_CLASSCross reference not resolvable (e.g. struct)

Implements IDDLFactoryMethod.

◆ BuildStructs()

tResult BuildStructs ( )
virtual

Method to build a structs object hierarchy.

Return values
ERR_UNKNOWN_FORMATExpected XML hierarchy not found
ERR_NO_CLASSCross reference not resolvable (e.g. datatype)
ERR_UNKNOWNNot all firstly unknown structs have been resolved

Implements IDDLFactoryMethod.

◆ BuildUnits()

tResult BuildUnits ( )
virtual

Method to build a units object hierarchy.

Return values
ERR_UNKNOWN_FORMATExpected XML hierarchy not found
ERR_NO_CLASSCross reference not resolvable (e.g. refUnit)
ERR_UNKNOWNNot all firstly unknown units have been resolved

Implements IDDLFactoryMethod.

◆ CreateNew()

tResult CreateNew ( double  fVersion = 0)
virtual

Method to build up a new DDL hierarchy.

Parameters
[in]fVersionThe version of the DDL hierarchy to be created. 0 Means newest version.
Return values
ERR_NOT_INITIALIZEDNot yet initialized (see setter methods in concrete classes, e.g. cDDLImporter::SetFile())
ERR_UNKNOWN_FORMATExpected XML hierarchy not found
ERR_NO_CLASSCross reference not resolvable (e.g. refUnit)
ERR_UNKNOWNCross reference has not been resolved
ERR_NOT_FOUNDAt least one mandatory element (e.g. header) was not found.
Remarks
If an error occurs, a list of detailed error descriptions can be obtained using GetAllErrors().

Implements IDDLFactoryMethod.

◆ CreatePartial()

tResult CreatePartial ( const cDDLDescription poRefDDL,
double  fVersion 
)

Method to create a partial DDL (e.g.

streams only).

Parameters
[in]poRefDDL- Reference DDL object to be used for resolving matters
[in]fVersionThe version the newly created description will have. Set 0 for newst version.
Return values
ERR_POINTERNull-pointer committed
ERR_NOT_INITIALIZEDNot yet initialized (see setter methods in concrete classes, e.g. cDDLImporter::SetFile())
ERR_UNKNOWN_FORMATExpected XML hierarchy not found
ERR_NO_CLASSCross reference not resolvable (e.g. refUnit)
ERR_UNKNOWNCross reference has not been resolved

◆ DestroyDDL()

static void DestroyDDL ( cDDLDescription poDDL)
static

Static method to destroy the given DDL hierarchy.

Parameters
[in]poDDL- Pointer to the DDL hierarchy which should be destroyed.
Returns
void

◆ GetAllMessages()

tImporterMsgList GetAllMessages ( ) const

Getter for all detected errors.

Returns
A list of all detected errors.

◆ GetDDL()

cDDLDescription* GetDDL ( ) const
virtual

Getter for the DDL object.

Returns
the DDL object
Attention
The caller/user has the responsibility for the created DDL object! Especially take this aspect into consideration in matters of the deallocation of memory!

Implements IDDLFactoryMethod.

◆ GetErrorDesc()

A_UTILS_NS::cString GetErrorDesc ( ) const

Getter for the description of the last error.

Returns
the error description

◆ GetLastErrorDesc()

A_UTILS_NS::cString GetLastErrorDesc ( ) const

Getter for the most recent error description.

Returns
The error description or A_UTILS_NS::cString::Empty if there was none.
Remarks
This method indeed returns the last error message (message with severity eImporterError).

◆ PrintAllMessages()

void PrintAllMessages ( tImporterMsgSeverity  eLeastSeverity = eImporterInfo)

Method to log all messages which have at least the given severity to console.

Parameters
[in]eLeastSeverity- Minimum severity level (optional)
Returns
void

◆ PushMessage()

void PushMessage ( const A_UTILS_NS::cString strMsg,
tImporterMsgSeverity  eSeverity 
)
private

Helper method to create a message and save it in the appropriate container.

Parameters
[in]strMsg- Message text
[in]eSeverity- Message severity
Returns
void

◆ SetCreationLevel()

void SetCreationLevel ( int const  nLevel = 1)

Setter for the creation level.

Parameters
[in]nLevel- Creation level to use
Returns
void

◆ SetDOM()

tResult SetDOM ( A_UTILS_NS::cDOM poDOM)

Setter for a DOM.

Parameters
[in]poDOM- Pointer to DOM
Return values
ERR_POINTERNull-pointer committed

◆ SetFile()

tResult SetFile ( A_UTILS_NS::cFilename const  strFile)

Setter for the source file.

Parameters
[in]strFile- Path to file to use
Return values
ERR_OPEN_FAILEDReading process failed
ERR_UNEXPECTEDInvalid XML tag

◆ SetFullCheckDescriptionMode()

void SetFullCheckDescriptionMode ( bool  bFullCheck = false)

Setter for the validation mode.

Parameters
[in]bFullCheck- Validation mode to use. Set true for full description check. Set false for description check until first error.
Returns
void

◆ SetMergeDefaults()

void SetMergeDefaults ( bool  bMergeDefaults = true)

Setter to enable disable the merge of DDL defaults (units, datattypes, etc.)

Parameters
[in]bMergeDefaultsSee description
Returns
void

◆ SetPreferReferenceEntities()

void SetPreferReferenceEntities ( bool  bPrefereReference = true)

Setter to switch from prefereing entities from the reference DDL, to using the reference enties only when there is no "local" aquivalent.

Mind that reference entities are not cloned but only referenced. They are also not included into the containers.

Parameters
[in]bPrefereReferenceSee description
Returns
void

◆ SetXML()

tResult SetXML ( const A_UTILS_NS::cString strXML)

Setter for a XML string containing the DDL to import.

Parameters
[in]strXML- String containing the DDL
Return values
ERR_UNEXPECTEDInvalid XML tag

◆ TryToFind()

T* TryToFind ( const A_UTILS_NS::cString strName,
cDDLContainer< T > &  vecFirstData,
cDDLContainer< T > &  vecSecondData 
)
private

Helper method to find specific elements inside the given vecFirstData by Name.

If not found there have a look in vecSecondData.

Template Parameters
T- Representation object type (e.g. cDDLDataType)
Parameters
[in]strName- Name of the element to find
[in]vecFirstData- Vector of representation objects to search through
[in]vecSecondData- second Vector of representation objects to search through
Returns
pointer to the found element or NULL if not found