ADTF
DataDefinitionfinal

The Data Definiton class uses the validation model to keep a Data Definition datamodel (ddl::dd::datamodel::DataDefinition) valid or inform about inconsitence:
See: More...

Inheritance diagram for DataDefinition:
[legend]

Public Types

using BaseUnits = datamodel::DataDefinition::BaseUnits
 Reuse of datamodel base unit container - ddl::dd::datamodel::DataDefinition::BaseUnits.
 
using UnitPrefixes = datamodel::DataDefinition::UnitPrefixes
 Reuse of datamodel unit prefixes container - ddl::dd::datamodel::DataDefinition::BaseUnits.
 
using Units = datamodel::DataDefinition::Units
 Reuse of datamodel units container - ddl::dd::datamodel::DataDefinition::Units.
 
using DataTypes = datamodel::DataDefinition::DataTypes
 Reuse of datamodel datatypes container - ddl::dd::datamodel::DataDefinition::DataTypes.
 
using EnumTypes = datamodel::DataDefinition::EnumTypes
 Reuse of datamodel enumtypes container - ddl::dd::datamodel::DataDefinition::EnumTypes.
 
using StructTypes = datamodel::DataDefinition::StructTypes
 Reuse of datamodel structs container - ddl::dd::datamodel::DataDefinition::StructTypes.
 
using StreamMetaTypes = datamodel::DataDefinition::StreamMetaTypes
 Reuse of datamodel streammetatypes container - ddl::dd::datamodel::DataDefinition::StreamMetaTypes.
 
using Streams = datamodel::DataDefinition::Streams
 Reuse of datamodel streams container - ddl::dd::datamodel::DataDefinition::Streams.
 

Public Member Functions

 DataDefinition ()
 Construct a new DataDefinition object with a new datamodel::DataDefinition. More...
 
 DataDefinition (Version ddl_version)
 Construct a new DataDefinition object with a new datamodel::DataDefinition. More...
 
 DataDefinition (const DataDefinition &other)
 Construct a new DataDefinition object and copies the datamodel. More...
 
 DataDefinition (DataDefinition &&other)
 Construct a new DataDefinition object and take the datamodel of the other. More...
 
DataDefinitionoperator= (const DataDefinition &other)
 Assigns the DataDefinition object and copies the datamodel. More...
 
DataDefinitionoperator= (DataDefinition &&other)
 Assigns the DataDefinition object and moves the datamodel. More...
 
 DataDefinition (const std::shared_ptr< datamodel::DataDefinition > &datamodel)
 Construct a new DataDefinition object and set the datamodel to the given one. More...
 
virtual ~DataDefinition ()
 Destroy the DataDefinition object.
 
void setModel (const std::shared_ptr< datamodel::DataDefinition > &datamodel)
 Sets and references the datamodel object, that is to validate and observe. More...
 
std::shared_ptr< const datamodel::DataDefinitiongetModel () const
 Gets the datamodel reference. More...
 
void setVersion (const Version &ddl_version)
 Set the language version of the containing datamodel. More...
 
Version getVersion () const
 Get the current language version set in datamodel. More...
 
void setHeader (const Header &header)
 Resets the DataDefinition Header of the datamodel. More...
 
const HeadergetHeader () const
 Gets the Header of the datamodel. More...
 
HeadergetHeader ()
 Gets the Header of the datamodel. More...
 
const BaseUnitsgetBaseUnits () const
 Get the Base Units of the datamodel. More...
 
BaseUnitsgetBaseUnits ()
 Get the Base Units of the datamodel. More...
 
const UnitPrefixesgetUnitPrefixes () const
 Get the Unit Prefixes of the datamodel. More...
 
UnitPrefixesgetUnitPrefixes ()
 Get the Unit Prefixes of the datamodel. More...
 
const UnitsgetUnits () const
 Get the Units of the datamodel. More...
 
UnitsgetUnits ()
 Get the Units of the datamodel. More...
 
const DataTypesgetDataTypes () const
 Get the Data Types of the datamodel. More...
 
DataTypesgetDataTypes ()
 Get the Data Types of the datamodel. More...
 
const EnumTypesgetEnumTypes () const
 Get the Enum Types of the datamodel. More...
 
EnumTypesgetEnumTypes ()
 Get the Enum Types of the datamodel. More...
 
const StructTypesgetStructTypes () const
 Get the Struct Types of the datamodel. More...
 
StructTypesgetStructTypes ()
 Get the Struct Types of the datamodel. More...
 
bool containsType (const std::string &type_name) const
 Retrieve information if the datamodel contains a type with the given name. More...
 
TypeOfType getTypeOfType (const std::string &type_name) const
 Retrieve information if the datamodel contains a type with the given name and return the type of it. More...
 
bool containsUnit (const std::string &unit_name) const
 Retrieve information if the datamodel contains a unit with the given name. More...
 
TypeOfUnit getTypeOfUnit (const std::string &unit_name) const
 Retrieve information if the datamodel contains a unit with the given name and return the type of it. More...
 
const StreamMetaTypesgetStreamMetaTypes () const
 Get the Streammeta Types of the datamodel. More...
 
StreamMetaTypesgetStreamMetaTypes ()
 Get the Streammeta Types of the datamodel. More...
 
const StreamsgetStreams () const
 Get the Streams of the datamodel. More...
 
StreamsgetStreams ()
 Get the Streams of the datamodel. More...
 
bool isValid (ValidationLevel level=ValidationLevel::valid) const
 Obtains if the validation level has reached at least the given level. More...
 
void validate (bool force_revalidation=false)
 Calculate the validation level of all DataDefinition objects that does not have a validation level yet or is below ValidationLevel::valid. More...
 
std::vector< ddl::dd::ProblemgetValidationProtocol () const
 Gets a collection of all problems obtained while validating the DataDefinition Objects. More...
 
void calculatePositions (const std::string &type_name={}, TypeOfType type_of_type=TypeOfType::invalid_type, bool force_recalculation=false)
 calculates the element sizes and positions of all structs, enumtypes and datatypes or dedicated for the one given. More...
 
StructTypeAccess getStructTypeAccess (const std::string &type_name) const
 Get the Struct Type Access, where to enter the type and calculated element position information. More...
 
void add (const BaseUnit &base_unit, const DataDefinition &source_dd)
 Merges or add the given base unit. More...
 
void add (const UnitPrefix &unit_prefix, const DataDefinition &source_dd)
 Merges or add the given unit prefix. More...
 
void add (const Unit &unit, const DataDefinition &source_dd)
 Merges or add the given unit. More...
 
void add (const DataType &data_type, const DataDefinition &source_dd)
 Merges or add the given datatype. More...
 
void add (const EnumType &enum_type, const DataDefinition &source_dd)
 Merges or add the given enumtype. More...
 
void add (const StructType &struct_type, const DataDefinition &source_dd)
 Merges or add the given structtype. More...
 
void add (const StreamMetaType &stream_meta_type, const DataDefinition &source_dd)
 Merges or add the given streammetatype. More...
 
void add (const Stream &stream, const DataDefinition &source_dd)
 Merges or add the given stream. More...
 
void add (const DataDefinition &source_dd)
 Merges or add the DataDefinition objects of the given source_dd. More...
 

Private Member Functions

void attachToModel ()
 
void detachFromModel ()
 
void modelChanged (datamodel::ModelEventCode event_code, datamodel::Header &changed_subject, const std::string &additional_info) override
 
void modelChanged (datamodel::ModelEventCode event_code, datamodel::BaseUnit &changed_subject, const std::string &additional_info) override
 
void modelChanged (datamodel::ModelEventCode event_code, datamodel::UnitPrefix &changed_subject, const std::string &additional_info) override
 
void modelChanged (datamodel::ModelEventCode event_code, datamodel::Unit &changed_subject, const std::string &additional_info) override
 
void modelChanged (datamodel::ModelEventCode event_code, datamodel::DataType &changed_subject, const std::string &additional_info) override
 
void modelChanged (datamodel::ModelEventCode event_code, datamodel::EnumType &changed_subject, const std::string &additional_info) override
 
void modelChanged (datamodel::ModelEventCode event_code, datamodel::StructType &changed_subject, const std::string &additional_info) override
 
void modelChanged (datamodel::ModelEventCode event_code, datamodel::StreamMetaType &changed_subject, const std::string &additional_info) override
 
void modelChanged (datamodel::ModelEventCode event_code, datamodel::Stream &changed_subject, const std::string &additional_info) override
 
- Private Member Functions inherited from ModelObserverUtility< MODEL_SUBJECT_T, EVENT_CODE_T >
virtual void modelChanged (event_code_type event_code, subject_type &changed_subject, const std::string &additional_info)=0
 interface function to override. More...
 
virtual ~ModelObserverUtility ()
 protected DTOR
 

Private Attributes

std::shared_ptr< datamodel::DataDefinition_datamodel
 
Version _last_known_ddl_version
 
ValidationLevel _dummy_validation_level = ValidationLevel::dont_know
 
std::unordered_map< std::string, std::string > _recursion_detection_stream_meta_types
 
std::unordered_map< std::string, std::string > _recursion_detection_struct
 

Additional Inherited Members

- Private Types inherited from ModelObserverUtility< MODEL_SUBJECT_T, EVENT_CODE_T >
typedef EVENT_CODE_T event_code_type
 local definition of the event code type
 
typedef MODEL_SUBJECT_T subject_type
 local definition of the subject code type
 

Detailed Description

The Data Definiton class uses the validation model to keep a Data Definition datamodel (ddl::dd::datamodel::DataDefinition) valid or inform about inconsitence:
See:

Additionally, it provides access to a address, offset and type information via the typeinfo model:

  • calculatePositions
  • getStructTypeAccess

There are predefined objects that can be used without adding it explicitly: see ddl::PredefinedDataTypes.

There are predefined unit objects that can be used immediatelly: see ddl::PredefinedUnits.

Definition at line 84 of file dd.h.

Constructor & Destructor Documentation

◆ DataDefinition() [1/5]

Construct a new DataDefinition object with a new datamodel::DataDefinition.

The used language version of the new datamodel is ddl::dd::Version::ddl_version_current

◆ DataDefinition() [2/5]

DataDefinition ( Version  ddl_version)

Construct a new DataDefinition object with a new datamodel::DataDefinition.

Parameters
ddl_versionThe used language version of the new datamodel.

◆ DataDefinition() [3/5]

DataDefinition ( const DataDefinition other)

Construct a new DataDefinition object and copies the datamodel.

Parameters
otherThe other data definition to copy.

◆ DataDefinition() [4/5]

Construct a new DataDefinition object and take the datamodel of the other.

Parameters
otherThe other data definition to move the model from.

◆ DataDefinition() [5/5]

DataDefinition ( const std::shared_ptr< datamodel::DataDefinition > &  datamodel)

Construct a new DataDefinition object and set the datamodel to the given one.

Parameters
datamodelthe datamodel to validate and observe.

Member Function Documentation

◆ add() [1/9]

void add ( const BaseUnit base_unit,
const DataDefinition source_dd 
)

Merges or add the given base unit.

If there are dependencies, they will be retrieved from source_dd. If there does already exist one base unit with the same name, the base unit must be equal (ddl::dd::datamodel::BaseUnit).

Parameters
base_unitthe base unit to add.
source_dddependencies will be obtained from this DataDefinition reference.
Exceptions
ddl::dd::Errorthrows if base unit already exists and is not equal to the given one.

◆ add() [2/9]

void add ( const DataDefinition source_dd)

Merges or add the DataDefinition objects of the given source_dd.

Parameters
source_ddthe data definition to add.
Exceptions
ddl::dd::Errorthrows if a DataDefinition object to add already exists and it is not equal to the given one.
See also
all other add methods.

◆ add() [3/9]

void add ( const DataType data_type,
const DataDefinition source_dd 
)

Merges or add the given datatype.

If there are dependencies, they will be retrieved from source_dd. If there does already exist one datatype with the same name, the datatype must be equal (ddl::dd::datamodel::DataType).

Parameters
data_typethe data_type to add.
source_dddependencies will be obtained from this DataDefinition reference (base units and units)
Exceptions
ddl::dd::Errorthrows if a datatype already exists and is not equal to the given one. Will also check dependencies.

◆ add() [4/9]

void add ( const EnumType enum_type,
const DataDefinition source_dd 
)

Merges or add the given enumtype.

If there are dependencies, they will be retrieved from source_dd. If there does already exist one enumtype with the same name, the enumtype must be equal (ddl::dd::datamodel::EnumType).

Parameters
enum_typethe enumtype to add.
source_dddependencies will be obtained from this DataDefinition reference (datatype)
Exceptions
ddl::dd::Errorthrows if a datatype already exists and is not equal to the given one. Will also check dependencies.

◆ add() [5/9]

void add ( const Stream stream,
const DataDefinition source_dd 
)

Merges or add the given stream.

If there are dependencies, they will be retrieved from source_dd. If there does already exist one stream with the same name, the stream must be equal (ddl::dd::datamodel::Stream).

Parameters
streamthe stream to add.
source_dddependencies will be obtained from this DataDefinition reference (streammetatype, structtype)
Exceptions
ddl::dd::Errorthrows if a Stream already exists and is not equal to the given one. Will also check dependencies.

◆ add() [6/9]

void add ( const StreamMetaType stream_meta_type,
const DataDefinition source_dd 
)

Merges or add the given streammetatype.

If there are dependencies, they will be retrieved from source_dd. If there does already exist one streammetatype with the same name, the streammetatype must be equal (ddl::dd::datamodel::StreamMetaType).

Parameters
stream_meta_typethe streammetatype to add.
source_dddependencies will be obtained from this DataDefinition reference (other streammetatype)
Exceptions
ddl::dd::Errorthrows if a streammetatype already exists and is not equal to the given one. Will also check dependencies.

◆ add() [7/9]

void add ( const StructType struct_type,
const DataDefinition source_dd 
)

Merges or add the given structtype.

If there are dependencies, they will be retrieved from source_dd. If there does already exist one structtype with the same name, the structtype must be equal (ddl::dd::datamodel::StructType).

Parameters
struct_typethe structtype to add.
source_dddependencies will be obtained from this DataDefinition reference (datatype, other structtype, enumtype, units)
Exceptions
ddl::dd::Errorthrows if a structype already exists and is not equal to the given one. Will also check dependencies.

◆ add() [8/9]

void add ( const Unit unit,
const DataDefinition source_dd 
)

Merges or add the given unit.

If there are dependencies, they will be retrieved from source_dd. If there does already exist one unit with the same name, the unit must be equal (ddl::dd::datamodel::Unit).

Parameters
unitthe unit to add.
source_dddependencies will be obtained from this DataDefinition reference (base units and unit prefixes)
Exceptions
ddl::dd::Errorthrows if a unit already exists and is not equal to the given one. Will also check dependencies.

◆ add() [9/9]

void add ( const UnitPrefix unit_prefix,
const DataDefinition source_dd 
)

Merges or add the given unit prefix.

If there are dependencies, they will be retrieved from source_dd. If there does already exist one unit prefix with the same name, the prefix must be equal (ddl::dd::datamodel::UnitPrefix).

Parameters
unit_prefixthe unit prefix to add.
source_dddependencies will be obtained from this DataDefinition reference.
Exceptions
ddl::dd::Errorthrows if a unit prefix already exists and is not equal to the given one.

◆ calculatePositions()

void calculatePositions ( const std::string &  type_name = {},
TypeOfType  type_of_type = TypeOfType::invalid_type,
bool  force_recalculation = false 
)

calculates the element sizes and positions of all structs, enumtypes and datatypes or dedicated for the one given.

Parameters
type_namethe type name to calculate the size and type info for. if empty recalculate all, if necessary.
type_of_typeif type name is empty, this parameter can choose the types to recalculate.
force_recalculationif set to true this will force the recalculation.

◆ containsType()

bool containsType ( const std::string &  type_name) const

Retrieve information if the datamodel contains a type with the given name.


Following types are considered: DataType, StructType, EnumType, StreamMetaType.

Parameters
type_namethe name to check
Returns
true a type with the given name exists.
false a type with the given name does not exist.

◆ containsUnit()

bool containsUnit ( const std::string &  unit_name) const

Retrieve information if the datamodel contains a unit with the given name.


Following units are considered: BaseUnit, Unit.

Parameters
unit_namethe name to check
Returns
true a unit with the given name exists.
false a unit with the given name does not exist.

◆ getBaseUnits() [1/2]

BaseUnits& getBaseUnits ( )

Get the Base Units of the datamodel.

Returns
BaseUnits& - base units of the datamodel.

◆ getBaseUnits() [2/2]

const BaseUnits& getBaseUnits ( ) const

Get the Base Units of the datamodel.

Returns
const BaseUnits& - base units of the datamodel.

◆ getDataTypes() [1/2]

DataTypes& getDataTypes ( )

Get the Data Types of the datamodel.

Returns
DataTypes& - the datatypes of the datamodel.

◆ getDataTypes() [2/2]

const DataTypes& getDataTypes ( ) const

Get the Data Types of the datamodel.

Returns
const DataTypes& - the datatypes of the datamodel.

◆ getEnumTypes() [1/2]

EnumTypes& getEnumTypes ( )

Get the Enum Types of the datamodel.

Returns
EnumTypes& - the enumtypes of the datamodel.

◆ getEnumTypes() [2/2]

const EnumTypes& getEnumTypes ( ) const

Get the Enum Types of the datamodel.

Returns
const EnumTypes& - the enumtypes of the datamodel.

◆ getHeader() [1/2]

Header& getHeader ( )

Gets the Header of the datamodel.

Returns
Header& the header of the datamodel.

◆ getHeader() [2/2]

const Header& getHeader ( ) const

Gets the Header of the datamodel.

Returns
const Header& the header of the datamodel.

◆ getModel()

std::shared_ptr<const datamodel::DataDefinition> getModel ( ) const

Gets the datamodel reference.

Returns
std::shared_ptr<const datamodel::DataDefinition> the datamodel reference

◆ getStreamMetaTypes() [1/2]

StreamMetaTypes& getStreamMetaTypes ( )

Get the Streammeta Types of the datamodel.

Returns
const StreamMetaTypes& - the streammeta types of the datamodel.

◆ getStreamMetaTypes() [2/2]

const StreamMetaTypes& getStreamMetaTypes ( ) const

Get the Streammeta Types of the datamodel.

Returns
StreamMetaTypes& - the streammeta types of the datamodel.

◆ getStreams() [1/2]

Streams& getStreams ( )

Get the Streams of the datamodel.

Returns
Streams& - the streams of the datamodel.

◆ getStreams() [2/2]

const Streams& getStreams ( ) const

Get the Streams of the datamodel.

Returns
const Streams& - the streams of the datamodel.

◆ getStructTypeAccess()

StructTypeAccess getStructTypeAccess ( const std::string &  type_name) const

Get the Struct Type Access, where to enter the type and calculated element position information.

See also
StructTypeAccess, StructElementAccess.
Parameters
type_namethe struct type name to retrieve the structtype access for.
Returns
const StructTypeAccess

Referenced by structure< T >::GetSize().

◆ getStructTypes() [1/2]

StructTypes& getStructTypes ( )

Get the Struct Types of the datamodel.

Returns
StructTypes& - the structtypes of the datamodel.

◆ getStructTypes() [2/2]

const StructTypes& getStructTypes ( ) const

Get the Struct Types of the datamodel.

Returns
const StructTypes& - the structtypes of the datamodel.

◆ getTypeOfType()

TypeOfType getTypeOfType ( const std::string &  type_name) const

Retrieve information if the datamodel contains a type with the given name and return the type of it.


Following types are considered: DataType, StructType, EnumType, StreamMetaType.

Parameters
type_namethe name to check
Return values
TypeOfType::invalid_typeA type with the given name does not exists.
TypeOfType::data_typeA type with the given name is a DataType.
TypeOfType::enum_typeA type with the given name is a EnumType.
TypeOfType::struct_typeA type with the given name is a StructType.
TypeOfType::streammetatype_typeA type with the given name is a StreamMetaType.

◆ getTypeOfUnit()

TypeOfUnit getTypeOfUnit ( const std::string &  unit_name) const

Retrieve information if the datamodel contains a unit with the given name and return the type of it.


Following units are considered: BaseUnit, Unit.

Parameters
unit_namethe name to check
Return values
TypeOfUnit::invalid_unitA unit with the given name does not exists.
TypeOfUnit::unitA unit with the given name is a Unit.
TypeOfUnit::base_unitA unit with the given name is a BaseUnit.

◆ getUnitPrefixes() [1/2]

UnitPrefixes& getUnitPrefixes ( )

Get the Unit Prefixes of the datamodel.

Returns
UnitPrefixes& - the prefixes of the datamodel.

◆ getUnitPrefixes() [2/2]

const UnitPrefixes& getUnitPrefixes ( ) const

Get the Unit Prefixes of the datamodel.

Returns
const UnitPrefixes& - prefixes of the datamodel.

◆ getUnits() [1/2]

Units& getUnits ( )

Get the Units of the datamodel.

Returns
Units& - the units of the datamodel.

◆ getUnits() [2/2]

const Units& getUnits ( ) const

Get the Units of the datamodel.

Returns
const Units& - the units of the datamodel.

◆ getValidationProtocol()

std::vector<ddl::dd::Problem> getValidationProtocol ( ) const

Gets a collection of all problems obtained while validating the DataDefinition Objects.

Returns
std::vector<ValidationInfo::Problem> the collection of problems
Remarks
to print or flatten the protocol consider ddl::dd::transformValidationProblemList.

◆ getVersion()

Version getVersion ( ) const

Get the current language version set in datamodel.

Returns
Version - the current language version.

◆ isValid()

bool isValid ( ValidationLevel  level = ValidationLevel::valid) const

Obtains if the validation level has reached at least the given level.

Parameters
levelthe level to check
Returns
true the level is at least level
false the level is below level

◆ operator=() [1/2]

DataDefinition& operator= ( const DataDefinition other)

Assigns the DataDefinition object and copies the datamodel.

Parameters
otherThe other data definition to copy from.
Returns
the resulting data definition.

◆ operator=() [2/2]

DataDefinition& operator= ( DataDefinition &&  other)

Assigns the DataDefinition object and moves the datamodel.

Parameters
otherThe other data definition to move from.
Returns
the resulting data definition.

◆ setHeader()

void setHeader ( const Header header)

Resets the DataDefinition Header of the datamodel.

Parameters
headerThe header to set.
Remarks
This will recalculate the structure sizes if necessary, because the alignment of structs are version dependent.

◆ setModel()

void setModel ( const std::shared_ptr< datamodel::DataDefinition > &  datamodel)

Sets and references the datamodel object, that is to validate and observe.

Parameters
datamodelthe datamodel to validate and observe.

◆ setVersion()

void setVersion ( const Version ddl_version)

Set the language version of the containing datamodel.

Remarks
This will recalculate the structure sizes if necessary, because the alignment of structs are version dependent.
Parameters
ddl_versionthe lanuage version to set.

◆ validate()

void validate ( bool  force_revalidation = false)

Calculate the validation level of all DataDefinition objects that does not have a validation level yet or is below ValidationLevel::valid.

Parameters
force_revalidationif a validation level was already calculated to ValidationLevel::valid this will force a recalculation!