ADTF
Loading...
Searching...
No Matches
sample_codec.h
Go to the documentation of this file.
1
7#pragma once
8
9#ifdef USE_ADTF_MEDIA_DESCRIPTION_LEGACY
10 #ifndef NO_ADTF_MEDIA_DESCRIPTION_LEGACY
12 #endif
13#endif
14
20
21#include <utility>
22#include <string>
23#include <type_traits>
24#include <string_view>
25
26namespace adtf
27{
28namespace mediadescription
29{
30namespace osborn
31{
32
37{
38public:
57// get legacy methods into scope
58#ifndef NO_ADTF_MEDIA_DESCRIPTION_LEGACY
63#endif // NO_ADTF_MEDIA_DESCRIPTION_LEGACY
90 tElement GetElement(const tCodecIndex& oCodecIndex) const;
99 tElement GetElement(std::string_view strElementFullName) const;
109 tElement GetChildElement(const tCodecIndex& oCodecIndex, std::string_view strElementPath) const;
122 const tElements& GetElements() const;
130 size_t GetElementChildCount(const tCodecIndex& oCodecIndex) const;
142 std::string GetElementFullName(const tCodecIndex& oCodecIndex) const;
153 std::string GetElementName(const tCodecIndex& oCodecIndex) const;
165 const std::string& GetElementBaseName(const tCodecIndex& oCodecIndex) const;
171 size_t GetStaticBufferSize() const;
206 template<typename T>
207 T GetElementValue(const tCodecIndex& oCodecIndex) const
208 {
209 try
210 {
211 return getDecoder()->template getElementValue<T>(oCodecIndex);
212 }
213 catch (const std::exception&)
214 {
216 }
217 }
218
240 template<typename T>
241 T GetElementValue(const penguin::tLeafCodecIndex& oLeafCodecIndex) const
242 {
243 try
244 {
245 return getDecoder()->template getElementValue<T>(oLeafCodecIndex);
246 }
247 catch (const std::exception&)
248 {
250 }
251 }
252
265 void GetElementVariantValue(const tCodecIndex& oCodecIndex, a_util::variant::Variant& oValue) const;
273 std::string GetElementStringValue(const tCodecIndex& oCodecIndex) const;
274
284 void GetElementRawValue(const tCodecIndex& oCodecIndex, void* pValue, size_t szValueSize) const;
292 const void* GetElementAddress(const tCodecIndex& oCodecIndex) const;
293
298 void Resolve(tCodecIndex& oCodecIndex) const;
299
300protected:
305
306private:
307 tElement m_oFirstElement;
308};
309
314{
315public:
320
329
334 inline const void* GetData() const
335 {
336 return m_pBuffer->GetPtr();
337 }
338
343 inline size_t GetDataSize() const
344 {
345 return m_pBuffer->GetSize();
346 }
347
348private:
349 friend class cSampleCodecFactory;
353 m_oStaticDecoder(std::move(oDecoder)), m_pBuffer(std::move(pBuffer))
354 {
356 }
358 const ddl::codec::StaticDecoder* getDecoder() const override;
359
360private:
362 ddl::codec::StaticDecoder m_oStaticDecoder;
365};
366
370class cStaticSampleCodec : public cSampleDecoderBase, public adtf_ddl_access::cCodecLegacy<ddl::codec::StaticCodec>
371{
372public:
385
386 // get cSampleDecoderBase API into scope
390
391#ifndef NO_ADTF_MEDIA_DESCRIPTION_LEGACY
392 // gets cCodecLegacy into scope
395#endif // NO_ADTF_MEDIA_DESCRIPTION_LEGACY
396
423 tElement GetElement(const tCodecIndex& oCodecIndex);
432 tElement GetElement(std::string_view strElementFullName);
442 tElement GetChildElement(const tCodecIndex& oCodecIndex, std::string_view strElementPath);
456
482 template<typename T>
483 void SetElementValue(const tCodecIndex& oCodecIndex, const T& oValue)
484 {
485 try
486 {
487 getCodec()->template setElementValue<T>(oCodecIndex, oValue);
488 }
489 catch (const std::exception&)
490 {
492 }
493 }
494
521 template<typename T>
522 void SetElementValue(const tLeafCodecIndex& oLeafCodecIndex, const T& oValue)
523 {
524 try
525 {
526 getCodec()->template setElementValue<T>(oLeafCodecIndex, oValue);
527 }
528 catch (const std::exception&)
529 {
531 }
532 }
533
540 void SetElementVariantValue(const tCodecIndex& oCodecIndex, const a_util::variant::Variant& oValue);
549 void SetElementStringValue(const tCodecIndex& oCodecIndex, const std::string& strValue);
572 void SetElementRawValue(const tCodecIndex& oCodecIndex, const void* pValue, size_t szValueSize);
580 void* GetElementAddress(const tCodecIndex& oCodecIndex);
589 void* GetElementAddress(std::string_view strElementFullName);
590
595 inline const void* GetData() const
596 {
597 return m_pBuffer->GetPtr();
598 }
599
603 inline void* GetData()
604 {
605 return m_pBuffer->GetPtr();
606 }
607
612 inline size_t GetDataSize() const
613 {
614 return m_pBuffer->GetSize();
615 }
616
617private:
618 friend class cSampleCodecFactory;
622 m_oStaticCodec(std::move(oDecoder)), m_pBuffer(std::move(pBuffer)), m_oFirstElement(tCodecIndex(), *this)
623 {
625 }
627 const ddl::codec::StaticDecoder* getDecoder() const override;
629 ddl::codec::StaticCodec* getCodec() override;
631 ddl::codec::StaticCodec m_oStaticCodec;
634 tElement m_oFirstElement;
635};
636
641{
642public:
646 cSampleDecoder() = default;
647
661 size_t GetBufferSize() const;
669
674 inline const void* GetData() const
675 {
676 return m_pBuffer->GetPtr();
677 }
678
683 inline size_t GetDataSize() const
684 {
685 return m_pBuffer->GetSize();
686 }
687
688private:
689 friend class cSampleCodecFactory;
693 m_oDecoder(std::move(oDecoder)), m_pBuffer(std::move(pBuffer))
694 {
696 }
698 const ddl::codec::StaticDecoder* getDecoder() const override;
700 ddl::codec::Decoder m_oDecoder;
703};
704
708class cSampleCodec : public cSampleDecoderBase, public adtf_ddl_access::cCodecLegacy<ddl::codec::Codec>
709{
710public:
715
724
725 // gets cSampleDecoderBase into scope
729
730#ifndef NO_ADTF_MEDIA_DESCRIPTION_LEGACY
731 // gets cCodecLegacy into scope
734#endif // NO_ADTF_MEDIA_DESCRIPTION_LEGACY
761 template<typename T>
762 void SetElementValue(const tCodecIndex& oCodecIndex, const T& oValue)
763 {
764 try
765 {
766 getCodec()->template setElementValue<T>(oCodecIndex, oValue);
767 }
768 catch (const std::exception&)
769 {
771 }
772 }
773
800 template<typename T>
801 void SetElementValue(const tLeafCodecIndex& oLeafCodecIndex, const T& oValue)
802 {
803 try
804 {
805 getCodec()->template setElementValue<T>(oLeafCodecIndex, oValue);
806 }
807 catch (const std::exception&)
808 {
810 }
811 }
812
819 void SetElementVariantValue(const tCodecIndex& oCodecIndex, const a_util::variant::Variant& oValue);
828 void SetElementStringValue(const tCodecIndex& oCodecIndex, const std::string& strValue);
851 void SetElementRawValue(const tCodecIndex& oCodecIndex, const void* pValue, size_t szValueSize);
858 void* GetElementAddress(const tCodecIndex& oCodecIndex);
885 tElement GetElement(const tCodecIndex& oCodecIndex);
894 tElement GetElement(std::string_view strElementFullName);
916 void* GetElementAddress(std::string_view strElementFullName);
922 size_t GetBufferSize() const;
930
935 inline const void* GetData() const
936 {
937 return m_pBuffer->GetPtr();
938 }
939
943 inline void* GetData()
944 {
945 return m_pBuffer->GetPtr();
946 }
947
952 inline size_t GetDataSize() const
953 {
954 return m_pBuffer->GetSize();
955 }
956
957private:
958 friend class cSampleCodecFactory;
961 m_oCodec(std::move(oDecoder)), m_pBuffer(std::move(pBuffer)), m_oFirstElement(tCodecIndex(), *this)
962 {
964 }
966 const ddl::codec::StaticDecoder* getDecoder() const override;
967 ddl::codec::Codec* getCodec() override;
969 ddl::codec::Codec m_oCodec;
972 tElement m_oFirstElement;
973};
974
978class cSampleCodecFactory : public adtf_ddl_access::cCodecFactoryLegacy
979{
980public:
986
995 cSampleCodecFactory(const char* strStructName,
996 const char* strMediaDescription,
1007 const ddl::dd::DataDefinition& oParentDD,
1009
1016 cSampleCodecFactory(const std::pair<std::string, std::string>& oMDDescription,
1054
1055#ifndef NO_ADTF_MEDIA_DESCRIPTION_LEGACY
1057#endif // NO_ADTF_MEDIA_DESCRIPTION_LEGACY
1071 ddl::tDataRepresentation eDataRepresentation) const;
1080 ddl::tDataRepresentation eDataRepresentation) const;
1089 ddl::tDataRepresentation eDataRepresentation) const;
1111 tElement GetElement(const tCodecIndex& oCodecIndex) const;
1120 tElement GetElement(std::string_view strElementFullName) const;
1130 tElement GetChildElement(const tCodecIndex& oCodecIndex, std::string_view strElementPath);
1143 const tElements& GetElements() const;
1151 size_t GetElementChildCount(const tCodecIndex& oCodecIndex) const;
1163 std::string GetElementFullName(const tCodecIndex& oCodecIndex) const;
1174 std::string GetElementName(const tCodecIndex& oCodecIndex) const;
1186 const std::string& GetElementBaseName(const tCodecIndex& oCodecIndex) const;
1194
1200
1201public: // convenience methods
1210 ddl::tDataRepresentation eDataRepresentation) const
1211 {
1212 return MakeStaticDecoderFor(*pSample.Get(), eDataRepresentation);
1213 }
1214
1222 ddl::tDataRepresentation eDataRepresentation) const
1223 {
1224 return MakeDecoderFor(*pSample.Get(), eDataRepresentation);
1225 }
1226
1233 ddl::tDataRepresentation eDataRepresentation) const
1234 {
1235 return MakeStaticCodecFor(*pSample.Get(), eDataRepresentation);
1236 }
1237
1244 ddl::tDataRepresentation eDataRepresentation) const
1245 {
1246 return MakeCodecFor(*pSample.Get(), eDataRepresentation);
1247 }
1248
1255 {
1256 return MakeStaticDecoderFor(*pSample.Get(), m_eDefaultDataRepresentation);
1257 }
1258
1264 {
1265 return MakeDecoderFor(*pSample.Get(), m_eDefaultDataRepresentation);
1266 }
1267
1273 {
1274 return MakeStaticCodecFor(*pSample.Get(), m_eDefaultDataRepresentation);
1275 }
1276
1282 {
1283 return MakeCodecFor(*pSample.Get(), m_eDefaultDataRepresentation);
1284 }
1285
1292 {
1293 return MakeStaticDecoderFor(oSample, m_eDefaultDataRepresentation);
1294 }
1295
1302 {
1303 return MakeDecoderFor(oSample, m_eDefaultDataRepresentation);
1304 }
1305
1312 {
1313 return MakeStaticCodecFor(oSample, m_eDefaultDataRepresentation);
1314 }
1315
1322 {
1323 return MakeCodecFor(oSample, m_eDefaultDataRepresentation);
1324 }
1325
1329 void Resolve(tCodecIndex& oCodecIndex) const;
1330
1331private:
1333 const ddl::codec::CodecFactory* getFactory() const override;
1337 ddl::codec::CodecFactory m_oFactory;
1338 tElement m_oFirstElement;
1339};
1340
1344template<typename ElementsType>
1345using element_callback = std::function<void(std::conditional_t<std::is_const<ElementsType>::value,
1346 const typename ElementsType::element_type,
1347 typename ElementsType::element_type>&)>;
1352template<typename ElementsType>
1353using element_control_callback = std::function<bool(std::conditional_t<std::is_const<ElementsType>::value,
1354 const typename ElementsType::element_type,
1355 typename ElementsType::element_type>&)>;
1356
1361template<typename ElementsType>
1362using array_element_callback = std::function<void(std::conditional_t<std::is_const<ElementsType>::value,
1363 const typename ElementsType::element_type,
1364 typename ElementsType::element_type>&,
1365 size_t)>;
1370template<typename ElementsType>
1371using array_element_control_callback = std::function<bool(std::conditional_t<std::is_const<ElementsType>::value,
1372 const typename ElementsType::element_type,
1373 typename ElementsType::element_type>&,
1374 size_t)>;
1375
1413template<typename ElementsType>
1414void for_each_leaf_element(ElementsType& oElements, const element_callback<ElementsType>& fnCallback)
1415{
1416 for (auto& oCurrentElement : oElements)
1417 {
1418 if (oCurrentElement.hasChildren())
1419 {
1420 if (oCurrentElement.isArray())
1421 {
1422 for (size_t szArrayPos = 0; szArrayPos < oCurrentElement.getArraySize(); ++szArrayPos)
1423 {
1424 auto oArrayElement = oCurrentElement.getArrayElement(szArrayPos);
1425 auto& children = oArrayElement.getChildElements();
1426 for_each_leaf_element(children, fnCallback);
1427 }
1428 }
1429 else
1430 {
1431 auto& children = oCurrentElement.getChildElements();
1432 for_each_leaf_element(children, fnCallback);
1433 }
1434 }
1435 else
1436 {
1437 if (oCurrentElement.isArray())
1438 {
1439 for (size_t szArrayPos = 0; szArrayPos < oCurrentElement.getArraySize(); ++szArrayPos)
1440 {
1441 auto oArrayElement = oCurrentElement.getArrayElement(szArrayPos);
1442 fnCallback(oArrayElement);
1443 }
1444 }
1445 else
1446 {
1447 fnCallback(oCurrentElement);
1448 }
1449 }
1450 }
1451}
1452
1459template<typename T>
1460std::vector<tCodecIndex> get_codec_indices(const T& oDecoderOrFactory)
1461{
1462 std::vector<tCodecIndex> oIndices;
1463 for_each_leaf_element(oDecoderOrFactory.GetElements(),
1464 [&oIndices](const auto& oElement) { oIndices.push_back(oElement.getIndex()); });
1465 return oIndices;
1466}
1467
1512template<typename ElementsType>
1513void for_each_element(ElementsType& oElements, const element_callback<ElementsType>& fnCallback)
1514{
1515 for (auto& oCurrentElement : oElements)
1516 {
1517 fnCallback(oCurrentElement);
1518 if (oCurrentElement.hasChildren())
1519 {
1520 for_each_element(oCurrentElement.getChildElements(), fnCallback);
1521 }
1522 }
1523}
1524
1536template<typename ElementsType>
1537void for_each_element_infix(ElementsType& oElements,
1538 const element_callback<ElementsType>& fnLeafCallback,
1539 const element_control_callback<ElementsType>& fnEnterMemberCallback,
1540 const element_callback<ElementsType>& fnLeaveMemberCallback,
1541 const array_element_control_callback<ElementsType>& fnEnterArrayMemberCallback,
1542 const array_element_callback<ElementsType>& fnLeaveArrayMemberCallback)
1543{
1544 for (auto& oCurrentElement : oElements)
1545 {
1546 if (fnEnterMemberCallback(oCurrentElement))
1547 {
1548 if (oCurrentElement.hasChildren())
1549 {
1550 if (oCurrentElement.isArray())
1551 {
1552 for (size_t szArrayPos = 0; szArrayPos < oCurrentElement.getArraySize(); ++szArrayPos)
1553 {
1554 auto oArrayElement = oCurrentElement.getArrayElement(szArrayPos);
1555 if (fnEnterArrayMemberCallback(oArrayElement, szArrayPos))
1556 {
1557 auto& children = oArrayElement.getChildElements();
1558 for_each_element_infix(children, fnLeafCallback, fnEnterMemberCallback,
1559 fnLeaveMemberCallback, fnEnterArrayMemberCallback,
1560 fnLeaveArrayMemberCallback);
1561 fnLeaveArrayMemberCallback(oArrayElement, szArrayPos);
1562 }
1563 }
1564 }
1565 else
1566 {
1567 auto& children = oCurrentElement.getChildElements();
1568 for_each_element_infix(children, fnLeafCallback, fnEnterMemberCallback, fnLeaveMemberCallback,
1569 fnEnterArrayMemberCallback, fnLeaveArrayMemberCallback);
1570 }
1571 }
1572 else
1573 {
1574 if (oCurrentElement.isArray())
1575 {
1576 for (size_t szArrayPos = 0; szArrayPos < oCurrentElement.getArraySize(); ++szArrayPos)
1577 {
1578 auto oArrayElement = oCurrentElement.getArrayElement(szArrayPos);
1579 if (fnEnterArrayMemberCallback(oArrayElement, szArrayPos))
1580 {
1581 fnLeafCallback(oArrayElement);
1582 fnLeaveArrayMemberCallback(oArrayElement, szArrayPos);
1583 }
1584 }
1585 }
1586 else
1587 {
1588 fnLeafCallback(oCurrentElement);
1589 }
1590 }
1591 fnLeaveMemberCallback(oCurrentElement);
1592 }
1593 }
1594}
1595
1605template<typename T>
1606adtf_util::cVariant get_value_as_variant(const T& oDecoder, const tCodecIndex& oCodecIndex)
1607{
1608 switch (oCodecIndex.getType())
1609 {
1610 case ddl::codec::ElementType::cet_bool: return oDecoder.template GetElementValue<bool>(oCodecIndex);
1611 case ddl::codec::ElementType::cet_int8: return oDecoder.template GetElementValue<tInt8>(oCodecIndex);
1612 case ddl::codec::ElementType::cet_uint8: return oDecoder.template GetElementValue<tUInt8>(oCodecIndex);
1613 case ddl::codec::ElementType::cet_int16: return oDecoder.template GetElementValue<tInt16>(oCodecIndex);
1614 case ddl::codec::ElementType::cet_uint16: return oDecoder.template GetElementValue<tUInt16>(oCodecIndex);
1615 case ddl::codec::ElementType::cet_int32: return oDecoder.template GetElementValue<tInt32>(oCodecIndex);
1616 case ddl::codec::ElementType::cet_uint32: return oDecoder.template GetElementValue<tUInt32>(oCodecIndex);
1617 case ddl::codec::ElementType::cet_int64: return oDecoder.template GetElementValue<tInt64>(oCodecIndex);
1618 case ddl::codec::ElementType::cet_uint64: return oDecoder.template GetElementValue<tUInt64>(oCodecIndex);
1619 case ddl::codec::ElementType::cet_float: return oDecoder.template GetElementValue<tFloat32>(oCodecIndex);
1620 case ddl::codec::ElementType::cet_double: return oDecoder.template GetElementValue<tFloat64>(oCodecIndex);
1621 default: break;
1622 }
1623 return adtf_util::cVariant();
1624}
1625
1626} // namespace osborn
1627
1628namespace quiet
1629{
1630
1634template<typename ElementsType>
1635using element_callback = std::function<void(std::conditional_t<std::is_const<ElementsType>::value,
1636 const typename ElementsType::element_type,
1637 typename ElementsType::element_type>&,
1643template<typename ElementsType>
1644using element_control_callback = std::function<bool(std::conditional_t<std::is_const<ElementsType>::value,
1645 const typename ElementsType::element_type,
1646 typename ElementsType::element_type>&,
1648
1653template<typename ElementsType>
1654using array_element_callback = std::function<void(std::conditional_t<std::is_const<ElementsType>::value,
1655 const typename ElementsType::element_type,
1656 typename ElementsType::element_type>&,
1657 size_t,
1663template<typename ElementsType>
1664using array_element_control_callback = std::function<bool(std::conditional_t<std::is_const<ElementsType>::value,
1665 const typename ElementsType::element_type,
1666 typename ElementsType::element_type>&,
1667 size_t,
1669
1685template<typename ElementsType>
1686void for_each_element_infix(ElementsType& oElements,
1687 const ddl::dd::datamodel::StructType::Elements& oModelElements,
1688 const ddl::dd::datamodel::DataDefinition& oDataDefinition,
1689 const element_callback<ElementsType>& fnLeafCallback,
1690 const element_control_callback<ElementsType>& fnEnterMemberCallback,
1691 const element_callback<ElementsType>& fnLeaveMemberCallback,
1692 const array_element_control_callback<ElementsType>& fnEnterArrayMemberCallback,
1693 const array_element_callback<ElementsType>& fnLeaveArrayMemberCallback);
1694
1696namespace detail
1697{
1698
1699template<typename ElementsType>
1700void for_each_element_infix(std::conditional_t<std::is_const<ElementsType>::value,
1701 const typename ElementsType::element_type,
1702 typename ElementsType::element_type>& oCurrentElement,
1703 const ddl::dd::datamodel::StructType::Element& oModelElement,
1704 const ddl::dd::datamodel::DataDefinition& oDataDefinition,
1705 const element_callback<ElementsType>& fnLeafCallback,
1706 const element_control_callback<ElementsType>& fnEnterMemberCallback,
1707 const element_callback<ElementsType>& fnLeaveMemberCallback,
1708 const array_element_control_callback<ElementsType>& fnEnterArrayMemberCallback,
1709 const array_element_callback<ElementsType>& fnLeaveArrayMemberCallback)
1710{
1711 if (fnEnterMemberCallback(oCurrentElement, oModelElement))
1712 {
1713 if (oCurrentElement.hasChildren())
1714 {
1715 const auto& oChildModelElements =
1716 oDataDefinition.getStructTypes().get(oModelElement.getTypeName())->getElements();
1717
1718 if (oCurrentElement.isArray())
1719 {
1720 for (size_t szArrayPos = 0; szArrayPos < oCurrentElement.getArraySize(); ++szArrayPos)
1721 {
1722 auto oArrayElement = oCurrentElement.getArrayElement(szArrayPos);
1723 if (fnEnterArrayMemberCallback(oArrayElement, szArrayPos, oModelElement))
1724 {
1726 oArrayElement.getChildElements(), oChildModelElements, oDataDefinition, fnLeafCallback,
1727 fnEnterMemberCallback, fnLeaveMemberCallback, fnEnterArrayMemberCallback,
1728 fnLeaveArrayMemberCallback);
1729
1730 fnLeaveArrayMemberCallback(oArrayElement, szArrayPos, oModelElement);
1731 }
1732 }
1733 }
1734 else
1735 {
1736 quiet::for_each_element_infix<ElementsType>(oCurrentElement.getChildElements(), oChildModelElements,
1737 oDataDefinition, fnLeafCallback, fnEnterMemberCallback,
1738 fnLeaveMemberCallback, fnEnterArrayMemberCallback,
1739 fnLeaveArrayMemberCallback);
1740 }
1741 }
1742 else
1743 {
1744 if (oCurrentElement.isArray())
1745 {
1746 for (size_t szArrayPos = 0; szArrayPos < oCurrentElement.getArraySize(); ++szArrayPos)
1747 {
1748 auto oArrayElement = oCurrentElement.getArrayElement(szArrayPos);
1749 if (fnEnterArrayMemberCallback(oArrayElement, szArrayPos, oModelElement))
1750 {
1751 fnLeafCallback(oArrayElement, oModelElement);
1752 fnLeaveArrayMemberCallback(oArrayElement, szArrayPos, oModelElement);
1753 }
1754 }
1755 }
1756 else
1757 {
1758 fnLeafCallback(oCurrentElement, oModelElement);
1759 }
1760 }
1761 fnLeaveMemberCallback(oCurrentElement, oModelElement);
1762 }
1763}
1764
1765} // namespace detail
1767
1768template<typename ElementsType>
1769void for_each_element_infix(ElementsType& oElements,
1770 const ddl::dd::datamodel::StructType::Elements& oModelElements,
1771 const ddl::dd::datamodel::DataDefinition& oDataDefinition,
1772 const element_callback<ElementsType>& fnLeafCallback,
1773 const element_control_callback<ElementsType>& fnEnterMemberCallback,
1774 const element_callback<ElementsType>& fnLeaveMemberCallback,
1775 const array_element_control_callback<ElementsType>& fnEnterArrayMemberCallback,
1776 const array_element_callback<ElementsType>& fnLeaveArrayMemberCallback)
1777{
1778 // Opposite direction is legal - oElements may have stopped at first element with dynamic layout.
1779 if (oElements.size() > oModelElements.getSize())
1780 {
1781 THROW_ERROR_DESC(ERR_INVALID_ARG,
1782 "The amount of the model elements does not match the amount of the codec elements.");
1783 }
1784
1785 auto itModelElement = oModelElements.begin();
1786
1787 for (auto& oCurrentElement : oElements)
1788 {
1789 detail::for_each_element_infix<ElementsType>(oCurrentElement, *itModelElement->get(), oDataDefinition,
1790 fnLeafCallback, fnEnterMemberCallback, fnLeaveMemberCallback,
1791 fnEnterArrayMemberCallback, fnLeaveArrayMemberCallback);
1792 ++itModelElement;
1793 }
1794}
1795
1796} // namespace quiet
1797
1798using osborn::cStaticSampleDecoder;
1799using osborn::cStaticSampleCodec;
1800using osborn::cSampleDecoder;
1801using osborn::cSampleCodec;
1802using osborn::cSampleCodecFactory;
1803
1810
1811} // namespace mediadescription
1812} // namespace adtf
#define THROW_ERROR_DESC(_code,...)
throws a tResult exception
Definition result.h:85
#define RETHROW_CURRENT_EXCEPTION()
rethrows the current exception as a tResult, use it in a catch block.
Definition result.h:117
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:736
Definition variant.h:46
tCodecIndex Resolve(tCodecLeafIndex nElementLeafIndex) const
Legacy class for cSampleCodec and cStaticSampleCodec.
Definition sample_codec_access_legacy.h:177
Definition sample_codec_access_legacy.h:28
adtf_util::cVariant GetElementValue(tCodecLeafIndex nElementLeafIndex) const
Legacy: Get the Element Value.
const void * GetElementAddress(tCodecLeafIndex nElementLeafIndex) const
Legacy: Get the Element StructElement information.
tCodecIndex Resolve(tCodecLeafIndex nElementLeafIndex) const
virtual const ddl::codec::StaticDecoder * getDecoder() const =0
Get the base ddl::Decoder.
tResult GetElement(tCodecLeafIndex nElementLeafIndex, const ddl::StructElement *&pElement) const
Get the Element StructElement information.
cSampleCodec MakeCodecFor(adtf::streaming::ISample &oSample) const
Definition sample_codec.h:1321
cSampleCodec MakeCodecFor(const adtf::ucom::iobject_ptr< adtf::streaming::ISample > &pSample) const
Definition sample_codec.h:1281
ddl::tDataRepresentation GetDefaultDataRepresentation() const
ddl::codec::ChildElements< sample_codec_factory_access< const cSampleCodecFactory > > tElements
Definition sample_codec.h:1136
void Resolve(tCodecIndex &oCodecIndex) const
cStaticSampleDecoder MakeStaticDecoderFor(const adtf::ucom::iobject_ptr< const adtf::streaming::ISample > &pSample, ddl::tDataRepresentation eDataRepresentation) const
Definition sample_codec.h:1209
cSampleCodecFactory & operator=(const cSampleCodecFactory &)
cSampleCodecFactory(const ddl::DDStructure &oTypeDefinition, ddl::tDataRepresentation eDefaultDataRepresentation=ddl::tDataRepresentation::Deserialized)
Construct a new c Sample Codec Factory.
std::string GetElementName(const tCodecIndex &oCodecIndex) const
Retrieves the name of the element within its structured element.
cStaticSampleDecoder MakeStaticDecoderFor(const adtf::streaming::ISample &oSample) const
Definition sample_codec.h:1291
cStaticSampleDecoder MakeStaticDecoderFor(const adtf::streaming::ISample &oSample, ddl::tDataRepresentation eDataRepresentation) const
cSampleDecoder MakeDecoderFor(const adtf::ucom::iobject_ptr< const adtf::streaming::ISample > &pSample) const
Definition sample_codec.h:1263
cStaticSampleDecoder MakeStaticDecoderFor(const adtf::ucom::iobject_ptr< const adtf::streaming::ISample > &pSample) const
Definition sample_codec.h:1254
ddl::codec::FactoryElement< sample_codec_factory_access< const cSampleCodecFactory > > tElement
Definition sample_codec.h:1103
size_t GetElementChildCount(const tCodecIndex &oCodecIndex) const
cStaticSampleCodec MakeStaticCodecFor(adtf::streaming::ISample &oSample, ddl::tDataRepresentation eDataRepresentation) const
cSampleCodecFactory(const ucom::ant::iobject_ptr< const streaming::ant::IStreamType > &pStreamType)
Construct a new c Sample Codec Factory.
const std::string & GetElementBaseName(const tCodecIndex &oCodecIndex) const
Retrieves the base name of the element within its structured element.
cStaticSampleCodec MakeStaticCodecFor(const adtf::ucom::iobject_ptr< adtf::streaming::ISample > &pSample, ddl::tDataRepresentation eDataRepresentation) const
Definition sample_codec.h:1232
cSampleCodecFactory & operator=(cSampleCodecFactory &&)
cSampleDecoder MakeDecoderFor(const adtf::streaming::ISample &oSample) const
Definition sample_codec.h:1301
cSampleDecoder MakeDecoderFor(const adtf::ucom::iobject_ptr< const adtf::streaming::ISample > &pSample, ddl::tDataRepresentation eDataRepresentation) const
Definition sample_codec.h:1221
cSampleCodecFactory(const std::pair< std::string, std::string > &oMDDescription, ddl::tDataRepresentation eDefaultDataRepresentation=ddl::tDataRepresentation::Deserialized)
Construct a new c Sample Codec Factory.
cSampleCodecFactory(const cSampleCodecFactory &)
size_t GetStaticBufferSize(ddl::tDataRepresentation eRep=ddl::tDataRepresentation::Deserialized) const
Gets the static buffer size in bytes for the structure.
cStaticSampleCodec MakeStaticCodecFor(adtf::streaming::ISample &oSample) const
Definition sample_codec.h:1311
cSampleDecoder MakeDecoderFor(const adtf::streaming::ISample &oSample, ddl::tDataRepresentation eDataRepresentation) const
cSampleCodecFactory(const ddl::dd::StructType &oStruct, const ddl::dd::DataDefinition &oParentDD, ddl::tDataRepresentation eDefaultDataRepresentation=ddl::tDataRepresentation::Deserialized)
cSampleCodecFactory(const char *strStructName, const char *strMediaDescription, ddl::tDataRepresentation eDefaultDataRepresentation=ddl::tDataRepresentation::Deserialized)
tElement GetElement(const tCodecIndex &oCodecIndex) const
cSampleCodec MakeCodecFor(const adtf::ucom::iobject_ptr< adtf::streaming::ISample > &pSample, ddl::tDataRepresentation eDataRepresentation) const
Definition sample_codec.h:1243
cSampleCodecFactory(const streaming::ant::IStreamType &oStreamType)
Construct a new c Sample Codec Factory.
cSampleCodec MakeCodecFor(adtf::streaming::ISample &oSample, ddl::tDataRepresentation eDataRepresentation) const
cStaticSampleCodec MakeStaticCodecFor(const adtf::ucom::iobject_ptr< adtf::streaming::ISample > &pSample) const
Definition sample_codec.h:1272
std::string GetElementFullName(const tCodecIndex &oCodecIndex) const
Retrieves the full name of the element within its main structure.
tElement GetElement(std::string_view strElementFullName) const
tElement GetChildElement(const tCodecIndex &oCodecIndex, std::string_view strElementPath)
const void * GetData() const
Get the current data pointer.
Definition sample_codec.h:935
void * GetElementAddress(const tCodecIndex &oCodecIndex)
Gets the elements value memory pointer into the given data for writig access.
tElement GetElement(std::string_view strElementFullName)
void * GetData()
Get the current data pointer for writing access.
Definition sample_codec.h:943
ddl::codec::ChildElements< sample_codec_access< cSampleCodec > > tElements
Definition sample_codec.h:900
void * GetElementAddress(std::string_view strElementFullName)
Gets the elements value memory pointer into the given data for writing access.
void SetElementValue(const tCodecIndex &oCodecIndex, const T &oValue)
Sets the elements value from the given oValue. If this element is a enum type the enum types element ...
Definition sample_codec.h:762
void SetElementVariantValue(const tCodecIndex &oCodecIndex, const a_util::variant::Variant &oValue)
void SetElementRawValue(const tCodecIndex &oCodecIndex, const void *pValue, size_t szValueSize)
Sets the elements value by copy the memory from pValue. You may use a valid codec index retrieved by ...
ddl::codec::CodecElement< sample_codec_access< cSampleCodec > > tElement
Definition sample_codec.h:864
cSampleCodec & operator=(cSampleCodec &&)
size_t GetDataSize() const
Get the current data size.
Definition sample_codec.h:952
void SetElementValue(const tLeafCodecIndex &oLeafCodecIndex, const T &oValue)
Sets the elements value from the given oValue. If this element is a enum type the enum types element ...
Definition sample_codec.h:801
tElement GetElement(const tCodecIndex &oCodecIndex)
size_t GetBufferSize(ddl::tDataRepresentation eRep) const
Gets the buffer size in bytes for the main structure.
void SetElementStringValue(const tCodecIndex &oCodecIndex, const std::string &strValue)
size_t GetBufferSize() const
Gets the buffer size in bytes for the main structure.
tElement GetElement(std::string_view strElementFullName) const
T GetElementValue(const tCodecIndex &oCodecIndex) const
Gets the elements value as value of type T. You may use a valid codec index retrieved by the cSampleC...
Definition sample_codec.h:207
void Resolve(tCodecIndex &oCodecIndex) const
tElement GetElement(const tCodecIndex &oCodecIndex) const
std::string GetElementStringValue(const tCodecIndex &oCodecIndex) const
void GetElementRawValue(const tCodecIndex &oCodecIndex, void *pValue, size_t szValueSize) const
Copies the elements value to the given memory pointer in pValue.
tElement GetChildElement(const tCodecIndex &oCodecIndex, std::string_view strElementPath) const
ddl::codec::ChildElements< sample_decoder_access< const cSampleDecoderBase > > tElements
Definition sample_codec.h:115
size_t GetElementChildCount(const tCodecIndex &oCodecIndex) const
cSampleDecoderBase & operator=(cSampleDecoderBase &&)
ddl::codec::DecoderElement< sample_decoder_access< const cSampleDecoderBase > > tElement
Definition sample_codec.h:69
void GetElementVariantValue(const tCodecIndex &oCodecIndex, a_util::variant::Variant &oValue) const
const void * GetElementAddress(const tCodecIndex &oCodecIndex) const
Gets the elements value memory pointer into the given data.
size_t GetStaticBufferSize(ddl::tDataRepresentation eRep) const
Gets the static buffer size in bytes for the main structure.
std::string GetElementFullName(const tCodecIndex &oCodecIndex) const
Retrieves the full name of the element within its main structure.
ddl::tDataRepresentation GetRepresentation() const
std::string GetElementName(const tCodecIndex &oCodecIndex) const
Retrieves the name of the element within its structured element.
T GetElementValue(const penguin::tLeafCodecIndex &oLeafCodecIndex) const
Gets the elements value as value of type T. You may use a valid codec index retrieved by the cSampleC...
Definition sample_codec.h:241
const std::string & GetElementBaseName(const tCodecIndex &oCodecIndex) const
Retrieves the base name of the element within its structured element.
size_t GetStaticBufferSize() const
Gets the static buffer size in bytes for the main structure.
a_util::variant::Variant GetElementVariantValue(const tCodecIndex &oCodecIndex) const
size_t GetDataSize() const
Get the current data size.
Definition sample_codec.h:683
cSampleDecoder & operator=(cSampleDecoder &&)
const void * GetData() const
Get the current data pointer.
Definition sample_codec.h:674
size_t GetBufferSize(ddl::tDataRepresentation eRep) const
Gets the buffer size in bytes for the main structure.
size_t GetBufferSize() const
Gets the buffer size in bytes for the main structure.
void * GetElementAddress(std::string_view strElementFullName)
Gets the elements value memory pointer into the given data for writing access.
cStaticSampleCodec & operator=(cStaticSampleCodec &&)
ddl::codec::ChildElements< sample_codec_access< cStaticSampleCodec > > tElements
Definition sample_codec.h:448
void SetElementValue(const tLeafCodecIndex &oLeafCodecIndex, const T &oValue)
Sets the elements value from the given oValue. If this element is a enum type the enum types element ...
Definition sample_codec.h:522
void SetElementVariantValue(const tCodecIndex &oCodecIndex, const a_util::variant::Variant &oValue)
tElement GetElement(const tCodecIndex &oCodecIndex)
Get a single element of the codec. You may use a valid codec index retrieved by the cSampleCodecFacto...
void * GetElementAddress(const tCodecIndex &oCodecIndex)
Gets the elements value memory pointer into the given data for writing access.
void SetElementRawValue(const tCodecIndex &oCodecIndex, const void *pValue, size_t szValueSize)
Sets the elements value by copy the memory from pValue. You may use a valid codec index retrieved by ...
size_t GetDataSize() const
Get the current data size.
Definition sample_codec.h:612
tElement GetChildElement(const tCodecIndex &oCodecIndex, std::string_view strElementPath)
void * GetData()
Get the current data pointer for writing access.
Definition sample_codec.h:603
void SetElementValue(const tCodecIndex &oCodecIndex, const T &oValue)
Sets the elements value from the given oValue. If this element is a enum type the enum types element ...
Definition sample_codec.h:483
ddl::codec::CodecElement< sample_codec_access< cStaticSampleCodec > > tElement
Definition sample_codec.h:402
tElement GetElement(std::string_view strElementFullName)
const void * GetData() const
Get the current data pointer.
Definition sample_codec.h:595
void SetElementStringValue(const tCodecIndex &oCodecIndex, const std::string &strValue)
size_t GetDataSize() const
Get the current data size.
Definition sample_codec.h:343
const void * GetData() const
Get the current data pointer.
Definition sample_codec.h:334
cStaticSampleDecoder & operator=(cStaticSampleDecoder &&)
Definition sample_intf.h:34
Defines access methods for the interface of a Stream Type.
Definition streamtype_intf.h:96
virtual T * Get() const =0
Get raw pointer to shared object.
Base object pointer to realize binary compatible reference counting in interface methods.
Definition object_ptr_intf.h:112
Definition lockedobject_intf.h:207
Definition lockedobject_intf.h:273
Utility class for a complete valid data definition of one StructType and its dependencies....
Definition ddstructure.h:57
Iteratable container type for the given Element type in ElementAccessType::element_type.
Definition codec_iterator.h:257
A CodecElement to get and set values.
Definition codec_iterator.h:1221
Definition codec_factory.h:31
ElementType getType() const
Get the elements type if CodecIndex is valid.
Definition codec.h:164
A DecoderElement to get values.
Definition codec_iterator.h:969
Definition codec.h:30
A FactoryElement.
Definition codec_iterator.h:560
Definition static_codec.h:328
Definition static_codec.h:38
The Data Definiton class uses the validation model to keep a Data Definition datamodel (ddl::dd::data...
Definition dd.h:92
DataDefinition Datamodel This datamodel is observable for any change of:
Definition datamodel_datadefinition.h:64
const StructTypes & getStructTypes() const
Get the Struct Types object.
observable DataDefinition object class for a Element of a StructType.
Definition datamodel_types.h:736
const std::string & getTypeName() const
Get the Type Name.
utility::TypeAccessList< Element, StructType > Elements
container of elements for the StructType::Element.
Definition datamodel_types.h:1177
size_t getSize() const
Get the Size.
Definition access_list.h:504
iterator begin()
the range based begin iterator
Definition access_list.h:514
std::shared_ptr< const DDL_TYPE_TO_ACCESS > get(const std::string &type_name) const
get the item with the given name type_name
Definition access_map.h:202
ddl::codec::LeafCodecIndex tLeafCodecIndex
redefitnion for a ddl::codec::LeafCodecIndex
Definition leaf_sample_codec_access.h:21
Namespace for all functionality of the ADTF Mediadescription SDK provided since v3....
Definition codec_sample_streamer.h:24
ddl::codec::CodecIndex tCodecIndex
Definition sample_codec_access_types.h:33
void for_each_element_infix(ElementsType &oElements, const element_callback< ElementsType > &fnLeafCallback, const element_control_callback< ElementsType > &fnEnterMemberCallback, const element_callback< ElementsType > &fnLeaveMemberCallback, const array_element_control_callback< ElementsType > &fnEnterArrayMemberCallback, const array_element_callback< ElementsType > &fnLeaveArrayMemberCallback)
Iterates elements and array elements in a callback-controlled fashion.
Definition sample_codec.h:1537
adtf_util::cVariant get_value_as_variant(const T &oDecoder, const tCodecIndex &oCodecIndex)
Get value as variant. This is for your convenience!
Definition sample_codec.h:1606
void for_each_leaf_element(ElementsType &oElements, const element_callback< ElementsType > &fnCallback)
Iterates ALL leaf elements within ALL array elements.
Definition sample_codec.h:1414
std::function< void(std::conditional_t< std::is_const< ElementsType >::value, const typename ElementsType::element_type, typename ElementsType::element_type > &)> element_callback
Callback type for member elements.
Definition sample_codec.h:1345
std::function< bool(std::conditional_t< std::is_const< ElementsType >::value, const typename ElementsType::element_type, typename ElementsType::element_type > &)> element_control_callback
Callback type for member elements. The callbacks return value controls wether the member will actuall...
Definition sample_codec.h:1353
void for_each_element(ElementsType &oElements, const element_callback< ElementsType > &fnCallback)
Iterates elements without array elements (also structures).
Definition sample_codec.h:1513
std::function< bool(std::conditional_t< std::is_const< ElementsType >::value, const typename ElementsType::element_type, typename ElementsType::element_type > &, size_t)> array_element_control_callback
Callback type for array elements. The callbacks return value controls wether the member will actually...
Definition sample_codec.h:1371
std::function< void(std::conditional_t< std::is_const< ElementsType >::value, const typename ElementsType::element_type, typename ElementsType::element_type > &, size_t)> array_element_callback
Callback type for array elements. entered.
Definition sample_codec.h:1362
std::vector< tCodecIndex > get_codec_indices(const T &oDecoderOrFactory)
Get the codec indices object.
Definition sample_codec.h:1460
Namespace for all internally used functionality implemented.
Definition adtf_mediadescription_version_namespaces.dox:58
Namespace for all functionality of the ADTF Mediadescription SDK provided since v3....
Definition sample_codec.h:1629
void for_each_element_infix(ElementsType &oElements, const ddl::dd::datamodel::StructType::Elements &oModelElements, const ddl::dd::datamodel::DataDefinition &oDataDefinition, const element_callback< ElementsType > &fnLeafCallback, const element_control_callback< ElementsType > &fnEnterMemberCallback, const element_callback< ElementsType > &fnLeaveMemberCallback, const array_element_control_callback< ElementsType > &fnEnterArrayMemberCallback, const array_element_callback< ElementsType > &fnLeaveArrayMemberCallback)
Iterates elements and array elements in a callback-controlled fashion. This version also provides acc...
Definition sample_codec.h:1769
std::function< void(std::conditional_t< std::is_const< ElementsType >::value, const typename ElementsType::element_type, typename ElementsType::element_type > &, size_t, const ddl::dd::datamodel::StructType::Element &)> array_element_callback
Callback type for array elements. entered.
Definition sample_codec.h:1654
std::function< bool(std::conditional_t< std::is_const< ElementsType >::value, const typename ElementsType::element_type, typename ElementsType::element_type > &, size_t, const ddl::dd::datamodel::StructType::Element &)> array_element_control_callback
Callback type for array elements. The callbacks return value controls wether the member will actually...
Definition sample_codec.h:1664
std::function< bool(std::conditional_t< std::is_const< ElementsType >::value, const typename ElementsType::element_type, typename ElementsType::element_type > &, const ddl::dd::datamodel::StructType::Element &)> element_control_callback
Callback type for member elements. The callbacks return value controls wether the member will actuall...
Definition sample_codec.h:1644
std::function< void(std::conditional_t< std::is_const< ElementsType >::value, const typename ElementsType::element_type, typename ElementsType::element_type > &, const ddl::dd::datamodel::StructType::Element &)> element_callback
Callback type for member elements.
Definition sample_codec.h:1635
Namespace for the ADTF Mediadescription SDK.
Definition codec_sample_streamer.h:22
ant::iobject_ptr< T > iobject_ptr
Alias always bringing the latest version of ant::iobject_ptr into scope.
Definition object_ptr_intf.h:437
Namespace for all functionality provided by ADTF and its SDKs.
Definition adtf_client_connector.h:14
@ cet_float
Variant type is float.
Definition codec_type_info.h:41
@ cet_int16
Variant type is std::int16_t.
Definition codec_type_info.h:35
@ cet_int8
Variant type is std::int8_t.
Definition codec_type_info.h:33
@ cet_uint64
Variant type is std::uint64_t.
Definition codec_type_info.h:40
@ cet_uint8
Variant type is std::uint8_t.
Definition codec_type_info.h:34
@ cet_uint32
Variant type is std::uint32_t.
Definition codec_type_info.h:38
@ cet_bool
Variant type is bool.
Definition codec_type_info.h:32
@ cet_uint16
Variant type is std::uint16_t.
Definition codec_type_info.h:36
@ cet_int32
Variant type is std::int32_t.
Definition codec_type_info.h:37
@ cet_int64
Variant type is std::int64_t.
Definition codec_type_info.h:39
@ cet_double
Variant type is double.
Definition codec_type_info.h:42
datamodel::StructType StructType
Definition dd.h:59
@ Deserialized
alias names for legacy reasons
Definition data_representation.h:29
DataRepresentation tDataRepresentation
Typedef provided for compatibility reasons.
Definition data_representation.h:32