Dev Essential  1.6.3
Loading...
Searching...
No Matches
dd.h
Go to the documentation of this file.
1
14
15#ifndef DD_DD_H_INCLUDED
16#define DD_DD_H_INCLUDED
17
22
23#include <string>
24
25namespace ddl {
26
27// forward declarations
28class DDMerge;
29
30namespace dd {
31
68
86 datamodel::ModelObserver<UnitPrefix>,
90 datamodel::ModelObserver<StructType>,
91 datamodel::ModelObserver<StreamMetaType>,
93public:
135 DataDefinition(const std::shared_ptr<datamodel::DataDefinition>& datamodel);
141
147 void setModel(const std::shared_ptr<datamodel::DataDefinition>& datamodel);
153 std::shared_ptr<const datamodel::DataDefinition> getModel() const;
154
155public:
195
203 void setVersion(const Version& ddl_version);
210
218 void setHeader(const Header& header);
224 const Header& getHeader() const;
231
237 const BaseUnits& getBaseUnits() const;
244
257
263 const Units& getUnits() const;
270
276 const DataTypes& getDataTypes() const;
283
289 const EnumTypes& getEnumTypes() const;
296
309
318 bool containsType(const std::string& type_name) const;
331 TypeOfType getTypeOfType(const std::string& type_name) const;
332
341 bool containsUnit(const std::string& unit_name) const;
351 TypeOfUnit getTypeOfUnit(const std::string& unit_name) const;
352
365
371 const Streams& getStreams() const;
378
394 void validate(bool force_revalidation = false);
403 std::vector<ddl::dd::Problem> getValidationProtocol() const;
404
415 void calculatePositions(const std::string& type_name = {},
417 bool force_recalculation = false);
426 StructTypeAccess getStructTypeAccess(const std::string& type_name) const;
427
428 // merge/add
438 void add(const BaseUnit& base_unit, const DataDefinition& source_dd);
449 void add(const UnitPrefix& unit_prefix, const DataDefinition& source_dd);
461 void add(const Unit& unit, const DataDefinition& source_dd);
473 void add(const DataType& data_type, const DataDefinition& source_dd);
484 void add(const EnumType& enum_type, const DataDefinition& source_dd);
496 void add(const StructType& struct_type, const DataDefinition& source_dd);
508 void add(const StreamMetaType& stream_meta_type, const DataDefinition& source_dd);
520 void add(const Stream& stream, const DataDefinition& source_dd);
529 void add(const DataDefinition& source_dd);
530
531private:
532 friend class ddl::DDMerge;
533 std::shared_ptr<datamodel::DataDefinition> _datamodel;
534 void attachToModel();
535 void detachFromModel();
536 void modelChanged(datamodel::ModelEventCode event_code,
537 datamodel::Header& changed_subject,
538 const std::string& additional_info) override;
539 void modelChanged(datamodel::ModelEventCode event_code,
540 datamodel::BaseUnit& changed_subject,
541 const std::string& additional_info) override;
542 void modelChanged(datamodel::ModelEventCode event_code,
543 datamodel::UnitPrefix& changed_subject,
544 const std::string& additional_info) override;
545 void modelChanged(datamodel::ModelEventCode event_code,
546 datamodel::Unit& changed_subject,
547 const std::string& additional_info) override;
548 void modelChanged(datamodel::ModelEventCode event_code,
549 datamodel::DataType& changed_subject,
550 const std::string& additional_info) override;
551 void modelChanged(datamodel::ModelEventCode event_code,
552 datamodel::EnumType& changed_subject,
553 const std::string& additional_info) override;
554 void modelChanged(datamodel::ModelEventCode event_code,
555 datamodel::StructType& changed_subject,
556 const std::string& additional_info) override;
557 void modelChanged(datamodel::ModelEventCode event_code,
558 datamodel::StreamMetaType& changed_subject,
559 const std::string& additional_info) override;
560 void modelChanged(datamodel::ModelEventCode event_code,
561 datamodel::Stream& changed_subject,
562 const std::string& additional_info) override;
563
564 Version _last_known_ddl_version;
565 // this member variable must stay there for ABI compatibility!
566 // NOLINTNEXTLINE(clang-diagnostic-unused-private-field)
567 ValidationLevel _dummy_validation_level = ValidationLevel::dont_know;
568 std::unordered_map<std::string, std::string> _recursion_detection_stream_meta_types;
569 std::unordered_map<std::string, std::string> _recursion_detection_struct;
570};
571
589bool addTypeByName(const std::string& type_name,
590 const DataDefinition& source_dd,
591 DataDefinition& destination_dd);
610bool addStreamTypeByName(const std::string& stream_type_name,
611 const DataDefinition& source_dd,
612 DataDefinition& destination_dd);
626bool addUnitByName(const std::string& unit_name,
627 const DataDefinition& source_dd,
628 DataDefinition& destination_dd);
629
647std::vector<std::string> transformValidationProblemList(
648 const std::vector<ddl::dd::Problem>& problems);
649
655
656} // namespace dd
659} // namespace ddl
660
661#endif // DD_DD_H_INCLUDED
DataDefinition()
Construct a new DataDefinition object with a new datamodel::DataDefinition. The used language version...
The Data Definiton class uses the validation model to keep a Data Definition datamodel (ddl::dd::data...
Definition dd.h:92
const StructTypes & getStructTypes() const
Get the Struct Types of the datamodel.
const StreamMetaTypes & getStreamMetaTypes() const
Get the Streammeta Types of the datamodel.
virtual ~DataDefinition()
Destroy the DataDefinition object.
const UnitPrefixes & getUnitPrefixes() const
Get the Unit Prefixes of the datamodel.
void setHeader(const Header &header)
Resets the DataDefinition Header of the datamodel.
const Units & getUnits() const
Get the Units of the datamodel.
std::shared_ptr< const datamodel::DataDefinition > getModel() const
Gets the datamodel reference.
Streams & getStreams()
Get the Streams of the datamodel.
const DataTypes & getDataTypes() const
Get the Data Types of the datamodel.
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....
const EnumTypes & getEnumTypes() const
Get the Enum Types of the datamodel.
const BaseUnits & getBaseUnits() const
Get the Base Units of the datamodel.
UnitPrefixes & getUnitPrefixes()
Get the Unit Prefixes of the datamodel.
Header & getHeader()
Gets the Header of the datamodel.
StreamMetaTypes & getStreamMetaTypes()
Get the Streammeta Types of the datamodel.
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....
StructTypes & getStructTypes()
Get the Struct Types of the datamodel.
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...
std::vector< ddl::dd::Problem > getValidationProtocol() const
Gets a collection of all problems obtained while validating the DataDefinition Objects.
void add(const DataDefinition &source_dd)
Merges or add the DataDefinition objects of the given source_dd.
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....
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 t...
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....
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....
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....
DataDefinition()
Construct a new DataDefinition object with a new datamodel::DataDefinition. The used language version...
Version getVersion() const
Get the current language version set in datamodel.
const Streams & getStreams() const
Get the Streams of the datamodel.
DataDefinition(Version ddl_version)
Construct a new DataDefinition object with a new datamodel::DataDefinition.
bool containsUnit(const std::string &unit_name) const
Retrieve information if the datamodel contains a unit with the given name. Following units are cons...
StructTypeAccess getStructTypeAccess(const std::string &type_name) const
Get the Struct Type Access, where to enter the type and calculated element position information.
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....
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...
DataTypes & getDataTypes()
Get the Data Types of the datamodel.
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....
datamodel::DataDefinition::StructTypes StructTypes
Reuse of datamodel structs container - ddl::dd::datamodel::DataDefinition::StructTypes.
Definition dd.h:184
DataDefinition & operator=(const DataDefinition &other)
Assigns the DataDefinition object and copies the datamodel.
DataDefinition & operator=(DataDefinition &&other)
Assigns the DataDefinition object and moves the datamodel.
datamodel::DataDefinition::Units Units
Reuse of datamodel units container - ddl::dd::datamodel::DataDefinition::Units.
Definition dd.h:169
datamodel::DataDefinition::StreamMetaTypes StreamMetaTypes
Reuse of datamodel streammetatypes container - ddl::dd::datamodel::DataDefinition::StreamMetaTypes.
Definition dd.h:189
datamodel::DataDefinition::UnitPrefixes UnitPrefixes
Reuse of datamodel unit prefixes container - ddl::dd::datamodel::DataDefinition::BaseUnits.
Definition dd.h:165
bool containsType(const std::string &type_name) const
Retrieve information if the datamodel contains a type with the given name. Following types are cons...
bool isValid(ValidationLevel level=ValidationLevel::valid) const
Obtains if the validation level has reached at least the given level.
datamodel::DataDefinition::EnumTypes EnumTypes
Reuse of datamodel enumtypes container - ddl::dd::datamodel::DataDefinition::EnumTypes.
Definition dd.h:179
EnumTypes & getEnumTypes()
Get the Enum Types of the datamodel.
BaseUnits & getBaseUnits()
Get the Base Units of the datamodel.
DataDefinition(const std::shared_ptr< datamodel::DataDefinition > &datamodel)
Construct a new DataDefinition object and set the datamodel to the given one.
datamodel::DataDefinition::BaseUnits BaseUnits
Reuse of datamodel base unit container - ddl::dd::datamodel::DataDefinition::BaseUnits.
Definition dd.h:160
datamodel::DataDefinition::Streams Streams
Reuse of datamodel streams container - ddl::dd::datamodel::DataDefinition::Streams.
Definition dd.h:194
Units & getUnits()
Get the Units of the datamodel.
const Header & getHeader() const
Gets the Header of the datamodel.
DataDefinition(DataDefinition &&other)
Construct a new DataDefinition object and take the datamodel of the other.
void setVersion(const Version &ddl_version)
Set the language version of the containing datamodel.
datamodel::DataDefinition::DataTypes DataTypes
Reuse of datamodel datatypes container - ddl::dd::datamodel::DataDefinition::DataTypes.
Definition dd.h:174
void setModel(const std::shared_ptr< datamodel::DataDefinition > &datamodel)
Sets and references the datamodel object, that is to validate and observe.
DataDefinition(const DataDefinition &other)
Construct a new DataDefinition object and copies the datamodel.
void validate(bool force_revalidation=false)
Calculate the validation level of all DataDefinition objects that does not have a validation level ye...
Accessing class for a instance of a struct. This will calculate the byte positions can be used for se...
Definition dd_struct_access.h:598
DDL Version.
Definition dd_common_types.h:203
BaseUnit.
Definition datamodel_units.h:108
utility::TypeAccessMap< EnumType, DataDefinition > EnumTypes
container class for all EnumTypes
Definition datamodel_datadefinition.h:119
utility::TypeAccessMap< DataType, DataDefinition > DataTypes
container class for all DataTypes
Definition datamodel_datadefinition.h:117
utility::TypeAccessMap< StreamMetaType, DataDefinition > StreamMetaTypes
container class for all StreamMetaTypes
Definition datamodel_datadefinition.h:123
utility::TypeAccessMap< Stream, DataDefinition > Streams
container class for all Streams
Definition datamodel_datadefinition.h:125
utility::TypeAccessMap< StructType, DataDefinition > StructTypes
container class for all StructTypes
Definition datamodel_datadefinition.h:121
utility::TypeAccessMap< Unit, DataDefinition > Units
container class for all Units
Definition datamodel_datadefinition.h:115
utility::TypeAccessMap< UnitPrefix, DataDefinition > UnitPrefixes
container class for all UnitPrefixes
Definition datamodel_datadefinition.h:113
utility::TypeAccessMap< BaseUnit, DataDefinition > BaseUnits
container class for all BaseUnits
Definition datamodel_datadefinition.h:111
observable DataDefinition object class to describe (POD) DataType.
Definition datamodel_types.h:113
observable DataDefinition object class to describe EnumType.
Definition datamodel_types.h:320
Data Definition datamodel for the Header.
Definition datamodel_header.h:37
observable DataDefinition object class to describe StreamMetaType.
Definition datamodel_types.h:1224
observable Stream DataDefinition object.
Definition datamodel_streams.h:41
observable DataDefinition object class to describe StructType.
Definition datamodel_types.h:453
Unit Prefix - datamodel pefixes.
Definition datamodel_units.h:221
BaseUnit.
Definition datamodel_units.h:338
definition of the datamodel namespace
Definition datamodel_base.h:28
utility::ModelObserverUtility< TYPE, ModelEventCode > ModelObserver
Observer template class that observe the TYPE.
Definition datamodel_base.h:195
ModelEventCode
Model event code for the data model observer.
Definition datamodel_base.h:34
definition of the dd namespace
Definition datamodel_base.h:26
dd::DataDefinition DataDescription
Alias Name for DataDefinition, formally known as DataDescription.
Definition dd.h:654
datamodel::Stream Stream
Definition dd.h:67
bool addStreamTypeByName(const std::string &stream_type_name, const DataDefinition &source_dd, DataDefinition &destination_dd)
Merges or add the streamtype with the name of stream_type_name. If there are dependencies,...
datamodel::DataType DataType
Definition dd.h:51
ValidationLevel
Validation level.
Definition dd_infomodel_type.h:66
@ dont_know
The validation is not known. This means it is not calculated yet. Use i.e. ddl::dd::DataDefinition::v...
Definition dd_infomodel_type.h:71
@ valid
every thing is well defined.
Definition dd_infomodel_type.h:95
std::vector< std::string > transformValidationProblemList(const std::vector< ddl::dd::Problem > &problems)
transforms the validation protocol of problems to a simple vrctor of strings. Simple usage:
datamodel::EnumType EnumType
Definition dd.h:55
TypeOfUnit
Classification of unit.
Definition dd_common_types.h:76
@ base_unit
the unit is a base unit (BaseUnit)
Definition dd_common_types.h:91
@ unit
the unit is a unit (Unit)
Definition dd_common_types.h:86
datamodel::StructType StructType
Definition dd.h:59
bool addTypeByName(const std::string &type_name, const DataDefinition &source_dd, DataDefinition &destination_dd)
Helper function which merges or adds the type with the name of type_name. If there are dependencies,...
datamodel::Unit Unit
Definition dd.h:47
TypeOfType
Classification of a Type.
Definition dd_common_types.h:44
@ invalid_type
the type is unknown
Definition dd_common_types.h:49
@ struct_type
the type is a struct type (StructType)
Definition dd_common_types.h:64
@ data_type
the type is a data type (DataType)
Definition dd_common_types.h:54
@ stream_meta_type
the type is an stream meta type (StreamMetaType)
Definition dd_common_types.h:69
@ enum_type
the type is a enum type (EnumType)
Definition dd_common_types.h:59
datamodel::UnitPrefix UnitPrefix
Definition dd.h:43
datamodel::StreamMetaType StreamMetaType
Definition dd.h:63
bool addUnitByName(const std::string &unit_name, const DataDefinition &source_dd, DataDefinition &destination_dd)
Merges or add the unit with the name of unit_name. If there are dependencies, they will be retrieved ...
datamodel::Header Header
Definition dd.h:35
datamodel::BaseUnit BaseUnit
Definition dd.h:39
definiton of the unit prefixes namespace
Definition dd_predefined_units.h:61
definition of the ddl namespace
Definition codec.h:21