15 #ifndef DDL_CODEC_FACTORY_CLASS_HEADER
16 #define DDL_CODEC_FACTORY_CLASS_HEADER
18 #include <ddl/codec/codec.h>
21 #include <ddl/codec/static_codec.h>
66 CodecFactory(
const std::string& struct_name,
const std::string& dd_string);
297 template <
typename T>
300 return decoder_or_factory.getStaticElementCount();
355 template <
typename T>
358 std::vector<CodecIndex> indices;
359 indices.reserve(detail::getDecoderOrFactoryElementCount<T>(decoder_or_factory));
361 [&indices](
const auto& element) { indices.push_back(element.getIndex()); });
373 template <
typename T>
377 std::vector<LeafCodecIndex> indices;
378 indices.reserve(detail::getDecoderOrFactoryElementCount<T>(decoder_or_factory));
379 forEachLeafElement(decoder_or_factory.getElements(), [&indices, &rep](
const auto& element) {
380 indices.push_back(LeafCodecIndex(element.getIndex(), rep));
Implementation of legacy access_element.
A common result class usable as return value throughout.
Utility class for a complete valid data definition of one StructType and its dependencies.
Legacy helper for the ddl::StructElement.
Iteratable container type for the given Element type in ElementAccessType::element_type.
Factory class for ddl codecs.
Codec makeCodecFor(void *data, size_t data_size, DataRepresentation rep=deserialized) const
Creates a codec for the given data.
a_util::result::Result isValid() const
Check if the factory is in a valid state.
std::shared_ptr< const StructAccess > _codec_access
For internal use only.
Element _first_element
For internal use only.
Element getElement(const CodecIndex &codec_index) const
Retrieves an element instance based on the codec index of that element.
Element getElement(const std::string &full_element_name) const
Retrieves an element instance based on the full name of the element.
std::string getElementFullName(const CodecIndex &codec_index) const
Retrieves the full name of the element within its main structure.
CodecFactory & operator=(CodecFactory &&)
move assignment operator
CodecFactory(const std::string &struct_name, const std::string &dd_string)
Constructor that take a DataDefinition string for initialization.
CodecFactory(const DDStructure &dd_struct)
Constructor that uses an OO-DataDefinition struct for initialization.
StaticCodec makeStaticCodecFor(void *data, size_t data_size, DataRepresentation rep=deserialized) const
Creates a static codec for the given data.
a_util::result::Result _constructor_result
For internal use only.
const std::string & getElementBaseName(const CodecIndex &codec_index) const
Retrieves the base name of the element within its structured element.
CodecIndex resolve(size_t leaf_index) const
Legacy: Resolves given the leaf index to a codec index.
StaticDecoder makeStaticDecoderFor(const void *data, size_t data_size, DataRepresentation rep=deserialized) const
Creates a static decoder for the given data.
std::string getElementName(const CodecIndex &codec_index) const
Retrieves the name of the element within its structured element.
ddl::access_element::StructElementLegacy< const CodecFactory > _legacy_element
For internal use only.
CodecFactory & operator=(const CodecFactory &)
copy assignment operator
CodecFactory(const ddl::dd::StructTypeAccess &struct_type_access)
Constructor that uses an StructTypeAccess for initialization.
FactoryElement< FactoryElementAccess< const CodecFactory > > Element
Type of a single factory element.
Decoder makeDecoderFor(const void *data, size_t data_size, DataRepresentation rep=deserialized) const
Creates a decoder for the given data.
ChildElements< FactoryElementAccess< const CodecFactory > > Elements
Iterator container to iterate all elements of the factory.
CodecFactory(const ddl::dd::StructType &struct_type, const dd::DataDefinition &dd)
Constructor that uses an OO-DataDefinition struct for initialization.
CodecFactory(const CodecFactory &)
copy CTOR
CodecFactory()
Empty constructor.
a_util::result::Result getStaticElement(size_t leaf_index, const ddl::StructElement *&legacy_struct_element) const
Legacy: Returns the StructElement of the element with given leaf index.
size_t getElementChildCount(const CodecIndex &codec_index=CodecIndex()) const
Retrieves the amount of child elements for the given codec index.
~CodecFactory()=default
Default dtor.
const Elements & getElements() const
Retrieves the elements of the factory to get element information.
CodecIndex resolve(size_t leaf_index, std::string &full_element_name) const
Legacy: Resolves the given leaf index to a codec index and the full element name.
CodecFactory(CodecFactory &&)
move CTOR
void resolve(CodecIndex &codec_index) const
The codec index will be resolved for fast access.
size_t getStaticElementCount() const
Legacy: Returns the amount of static (leaf) elements.
size_t getStaticBufferSize(DataRepresentation rep=deserialized) const
Gets the static buffer size in bytes for the structure.
Decoder for dynamic structures defined by a DataDefinition definition.
Fast Access Index Type for the coders.
Decoder for dynamic structures defined by a DataDefinition definition.
Codec for static structures defined by a DataDefinition definition.
Decoder for static structures defined by a DataDefinition definition.
size_t getElementCount() const
is the leaf count
The Data Definiton class uses the validation model to keep a Data Definition datamodel (ddl::dd::data...
Accessing class for a instance of a struct.
observable DataDefinition object class to describe StructType.
Definition of old CodecFactory legacy header for old Codec API.
Implementation of the CodecIterator.
OO DataDefinition - Data Definition.
OO DataDefinition DDStructure Header.
OO DataDefinition DDStructureGenerator Header.
std::vector< LeafCodecIndex > getLeafCodecIndices(const T &decoder_or_factory, ddl::DataRepresentation rep)
Get the leaf indices object.
std::vector< CodecIndex > getCodecIndices(const T &decoder_or_factory)
Retrieves all codec indices for the given codec of type T.
void forEachLeafElement(ElementsType &elements, const std::function< void(std::conditional_t< std::is_const< ElementsType >::value, const typename ElementsType::element_type, typename ElementsType::element_type > &)> &func)
Iterates ALL leaf elements within ALL array elements.
@ struct_type
the type is a struct type (StructType)
definition of the ddl namespace
DataRepresentation
Enumeration for the data representation.
Information about an element accessible with a decoder or codec.
size_t getDecoderOrFactoryElementCount(const T &decoder_or_factory)
Get the Decoder or Factory leaf element count.