ADTF
|
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...
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... | |
DataDefinition & | operator= (const DataDefinition &other) |
Assigns the DataDefinition object and copies the datamodel. More... | |
DataDefinition & | operator= (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::DataDefinition > | getModel () 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 Header & | getHeader () const |
Gets the Header of the datamodel. More... | |
Header & | getHeader () |
Gets the Header of the datamodel. More... | |
const BaseUnits & | getBaseUnits () const |
Get the Base Units of the datamodel. More... | |
BaseUnits & | getBaseUnits () |
Get the Base Units of the datamodel. More... | |
const UnitPrefixes & | getUnitPrefixes () const |
Get the Unit Prefixes of the datamodel. More... | |
UnitPrefixes & | getUnitPrefixes () |
Get the Unit Prefixes of the datamodel. More... | |
const Units & | getUnits () const |
Get the Units of the datamodel. More... | |
Units & | getUnits () |
Get the Units of the datamodel. More... | |
const DataTypes & | getDataTypes () const |
Get the Data Types of the datamodel. More... | |
DataTypes & | getDataTypes () |
Get the Data Types of the datamodel. More... | |
const EnumTypes & | getEnumTypes () const |
Get the Enum Types of the datamodel. More... | |
EnumTypes & | getEnumTypes () |
Get the Enum Types of the datamodel. More... | |
const StructTypes & | getStructTypes () const |
Get the Struct Types of the datamodel. More... | |
StructTypes & | getStructTypes () |
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 StreamMetaTypes & | getStreamMetaTypes () const |
Get the Streammeta Types of the datamodel. More... | |
StreamMetaTypes & | getStreamMetaTypes () |
Get the Streammeta Types of the datamodel. More... | |
const Streams & | getStreams () const |
Get the Streams of the datamodel. More... | |
Streams & | getStreams () |
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::Problem > | getValidationProtocol () 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 | |
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:
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.
DataDefinition | ( | ) |
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 | ( | Version | ddl_version | ) |
Construct a new DataDefinition object with a new datamodel::DataDefinition.
ddl_version | The used language version of the new datamodel. |
DataDefinition | ( | const DataDefinition & | other | ) |
Construct a new DataDefinition object and copies the datamodel.
other | The other data definition to copy. |
DataDefinition | ( | DataDefinition && | other | ) |
Construct a new DataDefinition object and take the datamodel of the other.
other | The other data definition to move the model from. |
DataDefinition | ( | const std::shared_ptr< datamodel::DataDefinition > & | datamodel | ) |
Construct a new DataDefinition object and set the datamodel to the given one.
datamodel | the datamodel to validate and observe. |
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).
base_unit | the base unit to add. |
source_dd | dependencies will be obtained from this DataDefinition reference. |
ddl::dd::Error | throws if base unit already exists and is not equal to the given one. |
void add | ( | const DataDefinition & | source_dd | ) |
Merges or add the DataDefinition objects of the given source_dd
.
source_dd | the data definition to add. |
ddl::dd::Error | throws if a DataDefinition object to add already exists and it is not equal to the given one. |
add
methods. 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).
data_type | the data_type to add. |
source_dd | dependencies will be obtained from this DataDefinition reference (base units and units) |
ddl::dd::Error | throws if a datatype already exists and is not equal to the given one. Will also check dependencies. |
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).
enum_type | the enumtype to add. |
source_dd | dependencies will be obtained from this DataDefinition reference (datatype) |
ddl::dd::Error | throws if a datatype already exists and is not equal to the given one. Will also check dependencies. |
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).
stream | the stream to add. |
source_dd | dependencies will be obtained from this DataDefinition reference (streammetatype, structtype) |
ddl::dd::Error | throws if a Stream already exists and is not equal to the given one. Will also check dependencies. |
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).
stream_meta_type | the streammetatype to add. |
source_dd | dependencies will be obtained from this DataDefinition reference (other streammetatype) |
ddl::dd::Error | throws if a streammetatype already exists and is not equal to the given one. Will also check dependencies. |
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).
struct_type | the structtype to add. |
source_dd | dependencies will be obtained from this DataDefinition reference (datatype, other structtype, enumtype, units) |
ddl::dd::Error | throws if a structype already exists and is not equal to the given one. Will also check dependencies. |
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).
unit | the unit to add. |
source_dd | dependencies will be obtained from this DataDefinition reference (base units and unit prefixes) |
ddl::dd::Error | throws if a unit already exists and is not equal to the given one. Will also check dependencies. |
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).
unit_prefix | the unit prefix to add. |
source_dd | dependencies will be obtained from this DataDefinition reference. |
ddl::dd::Error | throws if a unit prefix already exists and is not equal to the given one. |
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.
type_name | the type name to calculate the size and type info for. if empty recalculate all, if necessary. |
type_of_type | if type name is empty, this parameter can choose the types to recalculate. |
force_recalculation | if set to true this will force the recalculation. |
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.
type_name | the name to check |
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.
unit_name | the name to check |
BaseUnits& getBaseUnits | ( | ) |
Get the Base Units of the datamodel.
const BaseUnits& getBaseUnits | ( | ) | const |
Get the Base Units of the datamodel.
DataTypes& getDataTypes | ( | ) |
Get the Data Types of the datamodel.
const DataTypes& getDataTypes | ( | ) | const |
Get the Data Types of the datamodel.
EnumTypes& getEnumTypes | ( | ) |
Get the Enum Types of the datamodel.
const EnumTypes& getEnumTypes | ( | ) | const |
Get the Enum Types of the datamodel.
Header& getHeader | ( | ) |
Gets the Header of the datamodel.
const Header& getHeader | ( | ) | const |
Gets the Header of the datamodel.
std::shared_ptr<const datamodel::DataDefinition> getModel | ( | ) | const |
Gets the datamodel reference.
StreamMetaTypes& getStreamMetaTypes | ( | ) |
Get the Streammeta Types of the datamodel.
const StreamMetaTypes& getStreamMetaTypes | ( | ) | const |
Get the Streammeta Types of the datamodel.
Streams& getStreams | ( | ) |
Get the Streams of the datamodel.
const Streams& getStreams | ( | ) | const |
Get the Streams of the datamodel.
StructTypeAccess getStructTypeAccess | ( | const std::string & | type_name | ) | const |
Get the Struct Type Access, where to enter the type and calculated element position information.
type_name | the struct type name to retrieve the structtype access for. |
Referenced by structure< T >::GetSize().
StructTypes& getStructTypes | ( | ) |
Get the Struct Types of the datamodel.
const StructTypes& getStructTypes | ( | ) | const |
Get the Struct Types of the datamodel.
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.
type_name | the name to check |
TypeOfType::invalid_type | A type with the given name does not exists. |
TypeOfType::data_type | A type with the given name is a DataType. |
TypeOfType::enum_type | A type with the given name is a EnumType. |
TypeOfType::struct_type | A type with the given name is a StructType. |
TypeOfType::streammetatype_type | A type with the given name is a StreamMetaType. |
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.
unit_name | the name to check |
TypeOfUnit::invalid_unit | A unit with the given name does not exists. |
TypeOfUnit::unit | A unit with the given name is a Unit. |
TypeOfUnit::base_unit | A unit with the given name is a BaseUnit. |
UnitPrefixes& getUnitPrefixes | ( | ) |
Get the Unit Prefixes of the datamodel.
const UnitPrefixes& getUnitPrefixes | ( | ) | const |
Get the Unit Prefixes of the datamodel.
Units& getUnits | ( | ) |
Get the Units of the datamodel.
const Units& getUnits | ( | ) | const |
Get the Units of the datamodel.
std::vector<ddl::dd::Problem> getValidationProtocol | ( | ) | const |
Gets a collection of all problems obtained while validating the DataDefinition Objects.
Version getVersion | ( | ) | const |
Get the current language version set in datamodel.
bool isValid | ( | ValidationLevel | level = ValidationLevel::valid | ) | const |
Obtains if the validation level has reached at least the given level
.
level | the level to check |
level
level
DataDefinition& operator= | ( | const DataDefinition & | other | ) |
Assigns the DataDefinition object and copies the datamodel.
other | The other data definition to copy from. |
DataDefinition& operator= | ( | DataDefinition && | other | ) |
Assigns the DataDefinition object and moves the datamodel.
other | The other data definition to move from. |
void setHeader | ( | const Header & | header | ) |
Resets the DataDefinition Header of the datamodel.
header | The header to set. |
void setModel | ( | const std::shared_ptr< datamodel::DataDefinition > & | datamodel | ) |
Sets and references the datamodel object, that is to validate and observe.
datamodel | the datamodel to validate and observe. |
void setVersion | ( | const Version & | ddl_version | ) |
Set the language version of the containing datamodel.
ddl_version | the lanuage version to set. |
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.
force_revalidation | if a validation level was already calculated to ValidationLevel::valid this will force a recalculation! |