ADTF  3.18.2
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 
25 namespace adtf
26 {
27 namespace mediadescription
28 {
29 namespace osborn
30 {
31 
36 {
37 public:
46  tResult IsValid() const;
47  //get legacy methods into scope
48  #ifndef NO_ADTF_MEDIA_DESCRIPTION_LEGACY
53  #endif //NO_ADTF_MEDIA_DESCRIPTION_LEGACY
59  typedef ddl::codec::DecoderElement<sample_decoder_access<const cSampleDecoderBase>> tElement;
80  tElement GetElement(const tCodecIndex& oCodecIndex) const;
88  tElement GetElement(const std::string& strElementFullName) const;
101  const tElements& GetElements() const;
109  size_t GetElementChildCount(const tCodecIndex& oCodecIndex) const;
120  std::string GetElementFullName(const tCodecIndex& oCodecIndex) const;
131  std::string GetElementName(const tCodecIndex& oCodecIndex) const;
142  const std::string& GetElementBaseName(const tCodecIndex& oCodecIndex) const;
148  size_t GetStaticBufferSize() const;
183  template<typename T>
184  T GetElementValue(const tCodecIndex& oCodecIndex) const
185  {
186  try
187  {
188  return getDecoder()->template getElementValue<T>(oCodecIndex);
189  }
190  catch (const std::exception&)
191  {
192  throw adtf::base::current_exception_to_result();
193  }
194  }
217  template<typename T>
218  T GetElementValue(const penguin::tLeafCodecIndex& oLeafCodecIndex) const
219  {
220  try
221  {
222  return getDecoder()->template getElementValue<T>(oLeafCodecIndex);
223  }
224  catch (const std::exception&)
225  {
226  throw adtf::base::current_exception_to_result();
227  }
228  }
242  void GetElementVariantValue(const tCodecIndex& oCodecIndex, a_util::variant::Variant& oValue) const;
250  std::string GetElementStringValue(const tCodecIndex& oCodecIndex) const;
251 
260  void GetElementRawValue(const tCodecIndex& oCodecIndex, void* pValue, size_t szValueSize) const;
268  const void* GetElementAddress(const tCodecIndex& oCodecIndex) const;
269 
274  void Resolve(tCodecIndex& oCodecIndex) const;
275 
276 protected:
277  void ResetFirst();
278 
279 private:
280  tElement m_oFirstElement;
281 };
282 
287 {
288 public:
292  cStaticSampleDecoder() = default;
293 
302 
307  inline const void* GetData() const
308  {
309  return m_pBuffer->GetPtr();
310  }
311 
316  inline size_t GetDataSize() const
317  {
318  return m_pBuffer->GetSize();
319  }
320 
321 private:
322  friend class cSampleCodecFactory;
326  m_oStaticDecoder(std::move(oDecoder)),
327  m_pBuffer(std::move(pBuffer))
328  {
329  cSampleDecoderBase::ResetFirst();
330  }
332  const ddl::codec::StaticDecoder* getDecoder() const override;
333 
334 private:
339 };
340 
345  public adtf_ddl_access::cCodecLegacy<ddl::codec::StaticCodec>
346 {
347 public:
360 
361  //get cSampleDecoderBase API into scope
365 
366  #ifndef NO_ADTF_MEDIA_DESCRIPTION_LEGACY
367  //gets cCodecLegacy into scope
370  #endif //NO_ADTF_MEDIA_DESCRIPTION_LEGACY
371 
398  tElement GetElement(const tCodecIndex& oCodecIndex);
406  tElement GetElement(const std::string& strElementFullName);
420 
446  template<typename T>
447  void SetElementValue(const tCodecIndex& oCodecIndex, const T& oValue)
448  {
449  try
450  {
451  getCodec()->template setElementValue<T>(oCodecIndex, oValue);
452  }
453  catch(const std::exception&)
454  {
455  throw adtf::base::current_exception_to_result();
456  }
457  }
484  template<typename T>
485  void SetElementValue(const tLeafCodecIndex& oLeafCodecIndex, const T& oValue)
486  {
487  try
488  {
489  getCodec()->template setElementValue<T>(oLeafCodecIndex, oValue);
490  }
491  catch (const std::exception&)
492  {
493  throw adtf::base::current_exception_to_result();
494  }
495  }
503  void SetElementVariantValue(const tCodecIndex& oCodecIndex, const a_util::variant::Variant& oValue);
512  void SetElementStringValue(const tCodecIndex& oCodecIndex, const std::string& strValue);
535  void SetElementRawValue(const tCodecIndex& oCodecIndex, const void* pValue, size_t szValueSize);
543  void* GetElementAddress(const tCodecIndex& oCodecIndex);
551  void* GetElementAddress(const std::string& strElementFullName);
552 
557  inline const void* GetData() const
558  {
559  return m_pBuffer->GetPtr();
560  }
565  inline void* GetData()
566  {
567  return m_pBuffer->GetPtr();
568  }
569 
574  inline size_t GetDataSize() const
575  {
576  return m_pBuffer->GetSize();
577  }
578 
579 private:
580  friend class cSampleCodecFactory;
584  m_oStaticCodec(std::move(oDecoder)),
585  m_pBuffer(std::move(pBuffer)),
586  m_oFirstElement(tCodecIndex(), *this)
587  {
588  cSampleDecoderBase::ResetFirst();
589  }
591  const ddl::codec::StaticDecoder* getDecoder() const override;
598  tElement m_oFirstElement;
599 };
600 
605 {
606 public:
610  cSampleDecoder() = default;
611 
625  size_t GetBufferSize() const;
633 
638  inline const void* GetData() const
639  {
640  return m_pBuffer->GetPtr();
641  }
642 
647  inline size_t GetDataSize() const
648  {
649  return m_pBuffer->GetSize();
650  }
651 
652 private:
653  friend class cSampleCodecFactory;
657  m_oDecoder(std::move(oDecoder)),
658  m_pBuffer(std::move(pBuffer))
659  {
660  cSampleDecoderBase::ResetFirst();
661  }
663  const ddl::codec::StaticDecoder* getDecoder() const override;
668 };
669 
674  public adtf_ddl_access::cCodecLegacy<ddl::codec::Codec>
675 {
676 public:
681 
690 
691  //gets cSampleDecoderBase into scope
695 
696  #ifndef NO_ADTF_MEDIA_DESCRIPTION_LEGACY
697  //gets cCodecLegacy into scope
700  #endif //NO_ADTF_MEDIA_DESCRIPTION_LEGACY
727  template<typename T>
728  void SetElementValue(const tCodecIndex& oCodecIndex, const T& oValue)
729  {
730  try
731  {
732  getCodec()->template setElementValue<T>(oCodecIndex, oValue);
733  }
734  catch (const std::exception&)
735  {
736  throw adtf::base::current_exception_to_result();
737  }
738  }
765  template<typename T>
766  void SetElementValue(const tLeafCodecIndex& oLeafCodecIndex, const T& oValue)
767  {
768  try
769  {
770  getCodec()->template setElementValue<T>(oLeafCodecIndex, oValue);
771  }
772  catch (const std::exception&)
773  {
774  throw adtf::base::current_exception_to_result();
775  }
776  }
784  void SetElementVariantValue(const tCodecIndex& oCodecIndex, const a_util::variant::Variant& oValue);
793  void SetElementStringValue(const tCodecIndex& oCodecIndex, const std::string& strValue);
816  void SetElementRawValue(const tCodecIndex& oCodecIndex, const void* pValue, size_t szValueSize);
823  void* GetElementAddress(const tCodecIndex& oCodecIndex);
850  tElement GetElement(const tCodecIndex& oCodecIndex);
858  tElement GetElement(const std::string& strElementFullName);
879  void* GetElementAddress(const std::string& strElementFullName);
885  size_t GetBufferSize() const;
893 
898  inline const void* GetData() const
899  {
900  return m_pBuffer->GetPtr();
901  }
906  inline void* GetData()
907  {
908  return m_pBuffer->GetPtr();
909  }
910 
915  inline size_t GetDataSize() const
916  {
917  return m_pBuffer->GetSize();
918  }
919 
920 private:
921  friend class cSampleCodecFactory;
925  m_oCodec(std::move(oDecoder)),
926  m_pBuffer(std::move(pBuffer)),
927  m_oFirstElement(tCodecIndex(), *this)
928  {
929  cSampleDecoderBase::ResetFirst();
930  }
932  const ddl::codec::StaticDecoder* getDecoder() const override;
938  tElement m_oFirstElement;
939 };
940 
941 
946 {
947 public:
953 
962  cSampleCodecFactory(const char* strStructName,
963  const char* strMediaDescription,
973  const ddl::dd::DataDefinition& oParentDD,
975 
982  cSampleCodecFactory(const std::pair<std::string, std::string>& oMDDescription,
990  cSampleCodecFactory(const ddl::DDStructure& oTypeDefinition,
1020 
1021  #ifndef NO_ADTF_MEDIA_DESCRIPTION_LEGACY
1023  #endif //NO_ADTF_MEDIA_DESCRIPTION_LEGACY
1028  tResult IsValid() const;
1037  ddl::tDataRepresentation eDataRepresentation) const;
1046  ddl::tDataRepresentation eDataRepresentation) const;
1055  ddl::tDataRepresentation eDataRepresentation) const;
1064  ddl::tDataRepresentation eDataRepresentation) const;
1078  tElement GetElement(const tCodecIndex& oCodecIndex) const;
1086  tElement GetElement(const std::string& strElementFullName) const;
1100  const tElements& GetElements() const;
1108  size_t GetElementChildCount(const tCodecIndex& oCodecIndex) const;
1119  std::string GetElementFullName(const tCodecIndex& oCodecIndex) const;
1130  std::string GetElementName(const tCodecIndex& oCodecIndex) const;
1141  const std::string& GetElementBaseName(const tCodecIndex& oCodecIndex) const;
1149 
1155 
1156 public: // convenience methods
1164  ddl::tDataRepresentation eDataRepresentation) const
1165  {
1166  return MakeStaticDecoderFor(*pSample.Get(), eDataRepresentation);
1167  }
1176  ddl::tDataRepresentation eDataRepresentation) const
1177  {
1178  return MakeDecoderFor(*pSample.Get(), eDataRepresentation);
1179  }
1187  ddl::tDataRepresentation eDataRepresentation) const
1188  {
1189  return MakeStaticCodecFor(*pSample.Get(), eDataRepresentation);
1190  }
1198  ddl::tDataRepresentation eDataRepresentation) const
1199  {
1200  return MakeCodecFor(*pSample.Get(), eDataRepresentation);
1201  }
1208  {
1210  }
1217  {
1218  return MakeDecoderFor(*pSample.Get(), m_eDefaultDataRepresentation);
1219  }
1226  {
1228  }
1235  {
1236  return MakeCodecFor(*pSample.Get(), m_eDefaultDataRepresentation);
1237  }
1245  {
1247  }
1255  {
1257  }
1265  {
1267  }
1275  {
1276  return MakeCodecFor(oSample, m_eDefaultDataRepresentation);
1277  }
1282  void Resolve(tCodecIndex& oCodecIndex) const;
1283 
1284 private:
1286  const ddl::codec::CodecFactory* getFactory() const override;
1291  tElement m_oFirstElement;
1292 };
1293 
1297 template<typename ElementsType>
1298 using element_callback = std::function<void(std::conditional_t<std::is_const<ElementsType>::value,
1299  const typename ElementsType::element_type,
1300  typename ElementsType::element_type>&)>;
1304 template<typename ElementsType>
1305 using element_control_callback = std::function<bool(std::conditional_t<std::is_const<ElementsType>::value,
1306  const typename ElementsType::element_type,
1307  typename ElementsType::element_type>&)>;
1308 
1313 template<typename ElementsType>
1314 using array_element_callback = std::function<void(std::conditional_t<std::is_const<ElementsType>::value,
1315  const typename ElementsType::element_type,
1316  typename ElementsType::element_type>&,
1317  size_t)>;
1322 template<typename ElementsType>
1323 using array_element_control_callback = std::function<bool(std::conditional_t<std::is_const<ElementsType>::value,
1324  const typename ElementsType::element_type,
1325  typename ElementsType::element_type>&,
1326  size_t)>;
1327 
1366 template<typename ElementsType>
1367 void for_each_leaf_element(ElementsType& oElements, const element_callback<ElementsType>& fnCallback)
1368 {
1369  for (auto& oCurrentElement : oElements)
1370  {
1371  if (oCurrentElement.hasChildren())
1372  {
1373  if (oCurrentElement.isArray())
1374  {
1375  for (size_t szArrayPos = 0; szArrayPos < oCurrentElement.getArraySize(); ++szArrayPos)
1376  {
1377  auto oArrayElement = oCurrentElement.getArrayElement(szArrayPos);
1378  auto& children = oArrayElement.getChildElements();
1379  for_each_leaf_element(children, fnCallback);
1380  }
1381  }
1382  else
1383  {
1384  auto& children = oCurrentElement.getChildElements();
1385  for_each_leaf_element(children, fnCallback);
1386  }
1387  }
1388  else
1389  {
1390  if (oCurrentElement.isArray())
1391  {
1392  for (size_t szArrayPos = 0; szArrayPos < oCurrentElement.getArraySize(); ++szArrayPos)
1393  {
1394  auto oArrayElement = oCurrentElement.getArrayElement(szArrayPos);
1395  fnCallback(oArrayElement);
1396  }
1397  }
1398  else
1399  {
1400  fnCallback(oCurrentElement);
1401  }
1402  }
1403  }
1404 }
1412 template<typename T>
1413 std::vector<tCodecIndex> get_codec_indices(const T& oDecoderOrFactory)
1414 {
1415  std::vector<tCodecIndex> oIndices;
1416  for_each_leaf_element(oDecoderOrFactory.GetElements(),
1417  [&oIndices](const auto& oElement) {
1418  oIndices.push_back(oElement.getIndex());
1419  });
1420  return oIndices;
1421 }
1422 
1468 template<typename ElementsType>
1469 void for_each_element(ElementsType& oElements, const element_callback<ElementsType>& fnCallback)
1470 {
1471  for (auto& oCurrentElement : oElements)
1472  {
1473  fnCallback(oCurrentElement);
1474  if (oCurrentElement.hasChildren())
1475  {
1476  for_each_element(oCurrentElement.getChildElements(), fnCallback);
1477  }
1478  }
1479 }
1480 
1491 template<typename ElementsType>
1493  ElementsType& oElements,
1494  const element_callback<ElementsType>& fnLeafCallback,
1495  const element_control_callback<ElementsType>& fnEnterMemberCallback,
1496  const element_callback<ElementsType>& fnLeaveMemberCallback,
1497  const array_element_control_callback<ElementsType>& fnEnterArrayMemberCallback,
1498  const array_element_callback<ElementsType>& fnLeaveArrayMemberCallback
1499  )
1500 {
1501  for (auto& oCurrentElement : oElements)
1502  {
1503  if (fnEnterMemberCallback(oCurrentElement))
1504  {
1505  if (oCurrentElement.hasChildren())
1506  {
1507  if (oCurrentElement.isArray())
1508  {
1509  for (size_t szArrayPos = 0; szArrayPos < oCurrentElement.getArraySize(); ++szArrayPos)
1510  {
1511  auto oArrayElement = oCurrentElement.getArrayElement(szArrayPos);
1512  if (fnEnterArrayMemberCallback(oArrayElement, szArrayPos))
1513  {
1514  auto& children = oArrayElement.getChildElements();
1515  for_each_element_infix(children, fnLeafCallback, fnEnterMemberCallback,
1516  fnLeaveMemberCallback, fnEnterArrayMemberCallback,
1517  fnLeaveArrayMemberCallback);
1518  fnLeaveArrayMemberCallback(oArrayElement, szArrayPos);
1519  }
1520  }
1521  }
1522  else
1523  {
1524  auto& children = oCurrentElement.getChildElements();
1525  for_each_element_infix(children, fnLeafCallback, fnEnterMemberCallback, fnLeaveMemberCallback,
1526  fnEnterArrayMemberCallback, fnLeaveArrayMemberCallback);
1527  }
1528  }
1529  else
1530  {
1531  if (oCurrentElement.isArray())
1532  {
1533  for (size_t szArrayPos = 0; szArrayPos < oCurrentElement.getArraySize(); ++szArrayPos)
1534  {
1535  auto oArrayElement = oCurrentElement.getArrayElement(szArrayPos);
1536  if (fnEnterArrayMemberCallback(oArrayElement, szArrayPos))
1537  {
1538  fnLeafCallback(oArrayElement);
1539  fnLeaveArrayMemberCallback(oArrayElement, szArrayPos);
1540  }
1541  }
1542  }
1543  else
1544  {
1545  fnLeafCallback(oCurrentElement);
1546  }
1547  }
1548  fnLeaveMemberCallback(oCurrentElement);
1549  }
1550  }
1551 }
1552 
1562 template<typename T>
1563 adtf_util::cVariant get_value_as_variant(const T& oDecoder, const tCodecIndex& oCodecIndex)
1564 {
1565  switch (oCodecIndex.getType())
1566  {
1568  return oDecoder.template GetElementValue<bool>(oCodecIndex);
1570  return oDecoder.template GetElementValue<tInt8>(oCodecIndex);
1572  return oDecoder.template GetElementValue<tUInt8>(oCodecIndex);
1574  return oDecoder.template GetElementValue<tInt16>(oCodecIndex);
1576  return oDecoder.template GetElementValue<tUInt16>(oCodecIndex);
1578  return oDecoder.template GetElementValue<tInt32>(oCodecIndex);
1580  return oDecoder.template GetElementValue<tUInt32>(oCodecIndex);
1582  return oDecoder.template GetElementValue<tInt64>(oCodecIndex);
1584  return oDecoder.template GetElementValue<tUInt64>(oCodecIndex);
1586  return oDecoder.template GetElementValue<tFloat32>(oCodecIndex);
1588  return oDecoder.template GetElementValue<tFloat64>(oCodecIndex);
1589  default:
1590  break;
1591  }
1592  return adtf_util::cVariant();
1593 }
1594 
1595 } //namespace osborn
1596 
1597 namespace quiet
1598 {
1599 
1603 template<typename ElementsType>
1604 using element_callback = std::function<void(std::conditional_t<std::is_const<ElementsType>::value,
1605  const typename ElementsType::element_type,
1606  typename ElementsType::element_type>&,
1611 template<typename ElementsType>
1612 using element_control_callback = std::function<bool(std::conditional_t<std::is_const<ElementsType>::value,
1613  const typename ElementsType::element_type,
1614  typename ElementsType::element_type>&,
1616 
1621 template<typename ElementsType>
1622 using array_element_callback = std::function<void(std::conditional_t<std::is_const<ElementsType>::value,
1623  const typename ElementsType::element_type,
1624  typename ElementsType::element_type>&,
1625  size_t,
1631 template<typename ElementsType>
1632 using array_element_control_callback = std::function<bool(std::conditional_t<std::is_const<ElementsType>::value,
1633  const typename ElementsType::element_type,
1634  typename ElementsType::element_type>&,
1635  size_t,
1637 
1651 template<typename ElementsType>
1653  ElementsType& oElements,
1654  const ddl::dd::datamodel::StructType::Elements& oModelElements,
1655  const ddl::dd::datamodel::DataDefinition& oDataDefinition,
1656  const element_callback<ElementsType>& fnLeafCallback,
1657  const element_control_callback<ElementsType>& fnEnterMemberCallback,
1658  const element_callback<ElementsType>& fnLeaveMemberCallback,
1659  const array_element_control_callback<ElementsType>& fnEnterArrayMemberCallback,
1660  const array_element_callback<ElementsType>& fnLeaveArrayMemberCallback
1661  );
1662 
1663 namespace detail
1664 {
1665 
1666 template<typename ElementsType>
1668  std::conditional_t<std::is_const<ElementsType>::value,
1669  const typename ElementsType::element_type,
1670  typename ElementsType::element_type>& oCurrentElement,
1671  const ddl::dd::datamodel::StructType::Element& oModelElement,
1672  const ddl::dd::datamodel::DataDefinition& oDataDefinition,
1673  const element_callback<ElementsType>& fnLeafCallback,
1674  const element_control_callback<ElementsType>& fnEnterMemberCallback,
1675  const element_callback<ElementsType>& fnLeaveMemberCallback,
1676  const array_element_control_callback<ElementsType>& fnEnterArrayMemberCallback,
1677  const array_element_callback<ElementsType>& fnLeaveArrayMemberCallback
1678  )
1679 {
1680  if (fnEnterMemberCallback(oCurrentElement, oModelElement))
1681  {
1682  if (oCurrentElement.hasChildren())
1683  {
1684  const auto& oChildModelElements = oDataDefinition.getStructTypes().get(oModelElement.getTypeName())->getElements();
1685 
1686  if (oCurrentElement.isArray())
1687  {
1688  for (size_t szArrayPos = 0; szArrayPos < oCurrentElement.getArraySize(); ++szArrayPos)
1689  {
1690  auto oArrayElement = oCurrentElement.getArrayElement(szArrayPos);
1691  if (fnEnterArrayMemberCallback(oArrayElement, szArrayPos, oModelElement))
1692  {
1693  quiet::for_each_element_infix<ElementsType>(oArrayElement.getChildElements(), oChildModelElements, oDataDefinition,
1694  fnLeafCallback, fnEnterMemberCallback,
1695  fnLeaveMemberCallback, fnEnterArrayMemberCallback,
1696  fnLeaveArrayMemberCallback);
1697 
1698  fnLeaveArrayMemberCallback(oArrayElement, szArrayPos, oModelElement);
1699  }
1700  }
1701  }
1702  else
1703  {
1704  quiet::for_each_element_infix<ElementsType>(oCurrentElement.getChildElements(), oChildModelElements, oDataDefinition,
1705  fnLeafCallback, fnEnterMemberCallback, fnLeaveMemberCallback,
1706  fnEnterArrayMemberCallback, fnLeaveArrayMemberCallback);
1707  }
1708  }
1709  else
1710  {
1711  if (oCurrentElement.isArray())
1712  {
1713  for (size_t szArrayPos = 0; szArrayPos < oCurrentElement.getArraySize(); ++szArrayPos)
1714  {
1715  auto oArrayElement = oCurrentElement.getArrayElement(szArrayPos);
1716  if (fnEnterArrayMemberCallback(oArrayElement, szArrayPos, oModelElement))
1717  {
1718  fnLeafCallback(oArrayElement, oModelElement);
1719  fnLeaveArrayMemberCallback(oArrayElement, szArrayPos, oModelElement);
1720  }
1721  }
1722  }
1723  else
1724  {
1725  fnLeafCallback(oCurrentElement, oModelElement);
1726  }
1727  }
1728  fnLeaveMemberCallback(oCurrentElement, oModelElement);
1729  }
1730 }
1731 
1732 }
1733 
1734 template<typename ElementsType>
1736  ElementsType& oElements,
1737  const ddl::dd::datamodel::StructType::Elements& oModelElements,
1738  const ddl::dd::datamodel::DataDefinition& oDataDefinition,
1739  const element_callback<ElementsType>& fnLeafCallback,
1740  const element_control_callback<ElementsType>& fnEnterMemberCallback,
1741  const element_callback<ElementsType>& fnLeaveMemberCallback,
1742  const array_element_control_callback<ElementsType>& fnEnterArrayMemberCallback,
1743  const array_element_callback<ElementsType>& fnLeaveArrayMemberCallback
1744  )
1745 {
1746  if (oElements.size() != oModelElements.getSize())
1747  {
1748  THROW_ERROR_DESC(ERR_INVALID_ARG, "The amount of the model elements does not match the amount of the codec elements.");
1749  }
1750 
1751  auto itModelElement = oModelElements.begin();
1752 
1753  for (auto& oCurrentElement : oElements)
1754  {
1755  detail::for_each_element_infix<ElementsType>(oCurrentElement, *itModelElement->get(), oDataDefinition,
1756  fnLeafCallback, fnEnterMemberCallback,
1757  fnLeaveMemberCallback, fnEnterArrayMemberCallback,
1758  fnLeaveArrayMemberCallback);
1759  ++itModelElement;
1760  }
1761 }
1762 
1763 }
1764 
1765 
1766 using osborn::cStaticSampleDecoder;
1767 using osborn::cStaticSampleCodec;
1768 using osborn::cSampleDecoder;
1769 using osborn::cSampleCodec;
1770 using osborn::cSampleCodecFactory;
1771 
1778 
1779 } //namespace mediadescription
1780 } //namespace adtf
1781 
tCodecIndex Resolve(tCodecLeafIndex nElementIndex) const
Legacy: Retrieves a codec index with element information for the given leaf index.
Legacy class for cSampleCodec and cStaticSampleCodec.
Legacy Base Class to Support adtf_ddl::access_element API.
const void * GetElementAddress(tCodecLeafIndex nElementIndex) const
Legacy: Get the Element StructElement information.
adtf_util::cVariant GetElementValue(tCodecLeafIndex nElementLeafIndex) const
Legacy: Get the Element Value.
tResult GetElement(tCodecLeafIndex nElementLeafIndex, const ddl::StructElement *&pElement) const
Get the Element StructElement information.
virtual const ddl::codec::StaticDecoder * getDecoder() const =0
Get the base ddl::Decoder.
tCodecIndex Resolve(tCodecLeafIndex nElementLeafIndex) const
Legacy: Retrieves a codec index with element information for the given leaf index.
Factory class for ddl codecs for samples.
Definition: sample_codec.h:946
const ddl::codec::CodecFactory * getFactory() const override
For internal use only.
cSampleCodecFactory & operator=(const cSampleCodecFactory &)
assignment operator
cSampleCodecFactory(const char *strStructName, const char *strMediaDescription, ddl::tDataRepresentation eDefaultDataRepresentation=ddl::tDataRepresentation::Deserialized)
Constructor that take a DDL string for initialization.
cSampleDecoder MakeDecoderFor(const adtf::streaming::ISample &oSample, ddl::tDataRepresentation eDataRepresentation) const
Creates a decoder for the given sample.
cSampleCodecFactory(cSampleCodecFactory &&)
Move constructor.
cStaticSampleCodec MakeStaticCodecFor(const adtf::ucom::iobject_ptr< adtf::streaming::ISample > &pSample) const
Creates a static codec for the given sample using the default data representation.
std::string GetElementName(const tCodecIndex &oCodecIndex) const
Retrieves the name of the element within its structured element.
cSampleDecoder MakeDecoderFor(const adtf::ucom::iobject_ptr< const adtf::streaming::ISample > &pSample, ddl::tDataRepresentation eDataRepresentation) const
Creates a decoder for the given sample.
const tElements & GetElements() const
Retrieves the elements of the factory to get element information.
cSampleCodec MakeCodecFor(adtf::streaming::ISample &oSample) const
Creates a codec for the given sample using the default data representation.
cStaticSampleCodec MakeStaticCodecFor(adtf::streaming::ISample &oSample, ddl::tDataRepresentation eDataRepresentation) const
Creates a static codec for the given sample.
cSampleCodecFactory(const ddl::DDStructure &oTypeDefinition, ddl::tDataRepresentation eDefaultDataRepresentation=ddl::tDataRepresentation::Deserialized)
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.
cStaticSampleDecoder MakeStaticDecoderFor(const adtf::ucom::iobject_ptr< const adtf::streaming::ISample > &pSample, ddl::tDataRepresentation eDataRepresentation) const
Creates a static decoder for the given sample.
tElement GetElement(const std::string &strElementFullName) const
Retrieves an element for the given name.
cStaticSampleDecoder MakeStaticDecoderFor(const adtf::streaming::ISample &oSample) const
Creates a static decoder for the given sample using the default data representation.
tElement GetElement(const tCodecIndex &oCodecIndex) const
Retrieves an element for the codec index.
cStaticSampleDecoder MakeStaticDecoderFor(const adtf::ucom::iobject_ptr< const adtf::streaming::ISample > &pSample) const
Creates a static decoder for the given sample using the default data representation.
ddl::codec::FactoryElement< sample_codec_factory_access< const cSampleCodecFactory > > tElement
Iterator value element type for the factory to get element information.
cSampleCodecFactory(const streaming::ant::IStreamType &oStreamType)
Construct a new c Sample Codec Factory.
void Resolve(tCodecIndex &oCodecIndex) const
retrieves the lyoutinformation for the given codec index.
cSampleCodecFactory(const cSampleCodecFactory &)
Copy constructor.
size_t GetElementChildCount(const tCodecIndex &oCodecIndex) const
Retrieves the amount of child elements for the given codec index.
std::string GetElementFullName(const tCodecIndex &oCodecIndex) const
Retrieves the full name of the element within its main structure.
ddl::codec::ChildElements< sample_codec_factory_access< const cSampleCodecFactory > > tElements
Iterator container to iterate all elements of the factory.
cStaticSampleCodec MakeStaticCodecFor(adtf::streaming::ISample &oSample) const
Creates a static codec for the given sample using the default data representation.
cStaticSampleCodec MakeStaticCodecFor(const adtf::ucom::iobject_ptr< adtf::streaming::ISample > &pSample, ddl::tDataRepresentation eDataRepresentation) const
Creates a static codec for the given sample.
cSampleDecoder MakeDecoderFor(const adtf::streaming::ISample &oSample) const
Creates a decoder for the given sample using the default data representation.
cSampleCodecFactory(const std::pair< std::string, std::string > &oMDDescription, ddl::tDataRepresentation eDefaultDataRepresentation=ddl::tDataRepresentation::Deserialized)
Construct a new c Sample Codec Factory.
ddl::tDataRepresentation m_eDefaultDataRepresentation
For internal use only.
cSampleCodec MakeCodecFor(adtf::streaming::ISample &oSample, ddl::tDataRepresentation eDataRepresentation) const
Creates a codec for the given sample.
cSampleCodecFactory(const ddl::dd::StructType &oStruct, const ddl::dd::DataDefinition &oParentDD, ddl::tDataRepresentation eDefaultDataRepresentation=ddl::tDataRepresentation::Deserialized)
Constructor that uses an OO-DDL struct for initialization.
cStaticSampleDecoder MakeStaticDecoderFor(const adtf::streaming::ISample &oSample, ddl::tDataRepresentation eDataRepresentation) const
Creates a static decoder for the given sample.
ddl::tDataRepresentation GetDefaultDataRepresentation() const
Returns the current default data representation whuke creating codec or decoder.
size_t GetStaticBufferSize(ddl::tDataRepresentation eRep=ddl::tDataRepresentation::Deserialized) const
Gets the static buffer size in bytes for the structure.
cSampleDecoder MakeDecoderFor(const adtf::ucom::iobject_ptr< const adtf::streaming::ISample > &pSample) const
Creates a decoder for the given sample using the default data representation.
cSampleCodecFactory(const ucom::ant::iobject_ptr< const streaming::ant::IStreamType > &pStreamType)
Construct a new c Sample Codec Factory.
cSampleCodecFactory & operator=(cSampleCodecFactory &&)
Move assignment operator.
cSampleCodec MakeCodecFor(const adtf::ucom::iobject_ptr< adtf::streaming::ISample > &pSample, ddl::tDataRepresentation eDataRepresentation) const
Creates a codec for the given sample.
ddl::codec::CodecFactory m_oFactory
For internal use only.
cSampleCodec MakeCodecFor(const adtf::ucom::iobject_ptr< adtf::streaming::ISample > &pSample) const
Creates a codec for the given sample using the default data representation.
Codec for samples with static and/or dynamic data.
Definition: sample_codec.h:675
void SetElementValue(const tLeafCodecIndex &oLeafCodecIndex, const T &oValue)
Sets the elements value from the given oValue.
Definition: sample_codec.h:766
void * GetElementAddress(const std::string &strElementFullName)
Gets the elements value memory pointer into the given data for writing access.
ddl::codec::Codec * getCodec() override
Get the Codec.
ddl::codec::ChildElements< sample_codec_access< cSampleCodec > > tElements
Iterator container to iterate all elements of the codec.
Definition: sample_codec.h:864
adtf::ucom::object_ptr_locked< adtf::streaming::ISampleBuffer > m_pBuffer
For internal use only.
Definition: sample_codec.h:937
void SetElementVariantValue(const tCodecIndex &oCodecIndex, const a_util::variant::Variant &oValue)
Sets the current value of the given element from the given variant.
size_t GetBufferSize() const
Gets the buffer size in bytes for the main structure.
void SetElementRawValue(const tCodecIndex &oCodecIndex, const void *pValue, size_t szValueSize)
Sets the elements value by copy the memory from pValue.
cSampleCodec(ddl::codec::Codec &&oDecoder, adtf::ucom::object_ptr_locked< adtf::streaming::ISampleBuffer > &&pBuffer)
For internal use only.
Definition: sample_codec.h:923
const ddl::codec::StaticDecoder * getDecoder() const override
For internal use only.
void * GetElementAddress(const tCodecIndex &oCodecIndex)
Gets the elements value memory pointer into the given data for writig access.
tElements & GetElements()
Retrieves the elements of the codec to get element information, to get and set the values.
ddl::codec::Codec m_oCodec
For internal use only.
Definition: sample_codec.h:935
ddl::codec::CodecElement< sample_codec_access< cSampleCodec > > tElement
Iterator value element type for the codec to get value, set value and get element information.
Definition: sample_codec.h:829
tElement GetElement(const tCodecIndex &oCodecIndex)
Retrieves an element for the codec index.
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)
Sets the current value of the given element from the given string.
tElement GetElement(const std::string &strElementFullName)
Retrieves an element for the given name.
size_t GetDataSize() const
Get the current data size.
Definition: sample_codec.h:915
void * GetData()
Get the current data pointer for writing access.
Definition: sample_codec.h:906
cSampleCodec(cSampleCodec &&)
Move constructor.
void SetElementValue(const tCodecIndex &oCodecIndex, const T &oValue)
Sets the elements value from the given oValue.
Definition: sample_codec.h:728
const void * GetData() const
Get the current data pointer.
Definition: sample_codec.h:898
cSampleCodec & operator=(cSampleCodec &&)
Move assignment operator.
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.
Definition: sample_codec.h:218
const tElements & GetElements() const
Retrieves the elements of the decoder to get element information and the values.
ddl::tDataRepresentation GetRepresentation() const
Returns the current data representation the decoder decodes from.
const void * GetElementAddress(const tCodecIndex &oCodecIndex) const
Gets the elements value memory pointer into the given data.
ddl::codec::ChildElements< sample_decoder_access< const cSampleDecoderBase > > tElements
Iterator container to iterate all elements of the decoder.
Definition: sample_codec.h:94
T GetElementValue(const tCodecIndex &oCodecIndex) const
Gets the elements value as value of type T.
Definition: sample_codec.h:184
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.
tElement GetElement(const std::string &strElementFullName) const
Retrieves an element for the given name.
tResult IsValid() const
Returns the validation state of the coder.
tElement GetElement(const tCodecIndex &oCodecIndex) const
Retrieves an element for the codec index.
a_util::variant::Variant GetElementVariantValue(const tCodecIndex &oCodecIndex) const
Returns the current value of the given element as a variant.
void Resolve(tCodecIndex &oCodecIndex) const
retrieves the lyoutinformation for the given codec index.
void GetElementVariantValue(const tCodecIndex &oCodecIndex, a_util::variant::Variant &oValue) const
Returns the current value of the given element as a variant.
size_t GetElementChildCount(const tCodecIndex &oCodecIndex) const
Retrieves the amount of child elements for the given codec index.
std::string GetElementFullName(const tCodecIndex &oCodecIndex) const
Retrieves the full name of the element within its main structure.
void GetElementRawValue(const tCodecIndex &oCodecIndex, void *pValue, size_t szValueSize) const
Copies the elements value to the given memory pointer in @pValue.
size_t GetStaticBufferSize(ddl::tDataRepresentation oRep) const
Gets the static buffer size in bytes for the main structure.
std::string GetElementStringValue(const tCodecIndex &oCodecIndex) const
Returns the current value of the given element as a string.
Decoder for samples with static and/or dynamic data.
Definition: sample_codec.h:605
cSampleDecoder(cSampleDecoder &&)
Move constructor.
cSampleDecoder(ddl::codec::Decoder &&oDecoder, adtf::ucom::object_ptr_shared_locked< const adtf::streaming::ISampleBuffer > &&pBuffer)
For internal use only.
Definition: sample_codec.h:655
ddl::codec::Decoder m_oDecoder
For internal use only.
Definition: sample_codec.h:665
size_t GetBufferSize() const
Gets the buffer size in bytes for the main structure.
const ddl::codec::StaticDecoder * getDecoder() const override
For internal use only.
cSampleDecoder()=default
Default constructor.
size_t GetBufferSize(ddl::tDataRepresentation eRep) const
Gets the buffer size in bytes for the main structure.
cSampleDecoder & operator=(cSampleDecoder &&)
Move assignment operator.
size_t GetDataSize() const
Get the current data size.
Definition: sample_codec.h:647
adtf::ucom::object_ptr_shared_locked< const adtf::streaming::ISampleBuffer > m_pBuffer
For internal use only.
Definition: sample_codec.h:667
const void * GetData() const
Get the current data pointer.
Definition: sample_codec.h:638
Codec for samples with static data content.
Definition: sample_codec.h:346
void SetElementValue(const tLeafCodecIndex &oLeafCodecIndex, const T &oValue)
Sets the elements value from the given oValue.
Definition: sample_codec.h:485
void * GetElementAddress(const std::string &strElementFullName)
Gets the elements value memory pointer into the given data for writing access.
adtf::ucom::object_ptr_locked< adtf::streaming::ISampleBuffer > m_pBuffer
For internal use only.
Definition: sample_codec.h:597
cStaticSampleCodec(ddl::codec::StaticCodec &&oDecoder, adtf::ucom::object_ptr_locked< adtf::streaming::ISampleBuffer > &&pBuffer)
For internal use only.
Definition: sample_codec.h:582
void SetElementVariantValue(const tCodecIndex &oCodecIndex, const a_util::variant::Variant &oValue)
Sets the current value of the given element from the given variant.
void SetElementRawValue(const tCodecIndex &oCodecIndex, const void *pValue, size_t szValueSize)
Sets the elements value by copy the memory from pValue.
const ddl::codec::StaticDecoder * getDecoder() const override
For internal use only.
ddl::codec::ChildElements< sample_codec_access< cStaticSampleCodec > > tElements
Iterator container to iterate all elements of the codec.
Definition: sample_codec.h:412
void * GetElementAddress(const tCodecIndex &oCodecIndex)
Gets the elements value memory pointer into the given data for writing access.
tElements & GetElements()
Retrieves the elements of the codec to get element information, to get and set the values.
ddl::codec::CodecElement< sample_codec_access< cStaticSampleCodec > > tElement
Iterator value element type for the codec to get value, set value and get element information.
Definition: sample_codec.h:377
tElement GetElement(const tCodecIndex &oCodecIndex)
Get a single element of the codec.
ddl::codec::StaticCodec m_oStaticCodec
For internal use only.
Definition: sample_codec.h:595
void SetElementStringValue(const tCodecIndex &oCodecIndex, const std::string &strValue)
Sets the current value of the given element from the given string.
tElement GetElement(const std::string &strElementFullName)
Retrieves an element for the given name.
size_t GetDataSize() const
Get the current data size.
Definition: sample_codec.h:574
void * GetData()
Get the current data pointer for writing access.
Definition: sample_codec.h:565
cStaticSampleCodec(cStaticSampleCodec &&)
Move constructor.
cStaticSampleCodec & operator=(cStaticSampleCodec &&)
Move assignment operator.
void SetElementValue(const tCodecIndex &oCodecIndex, const T &oValue)
Sets the elements value from the given oValue.
Definition: sample_codec.h:447
ddl::codec::StaticCodec * getCodec() override
For internal use only.
const void * GetData() const
Get the current data pointer.
Definition: sample_codec.h:557
Decoder for samples with static data content.
Definition: sample_codec.h:287
cStaticSampleDecoder & operator=(cStaticSampleDecoder &&)
Move assignment operator.
cStaticSampleDecoder(cStaticSampleDecoder &&)
Move constructor.
const ddl::codec::StaticDecoder * getDecoder() const override
For internal use only.
ddl::codec::StaticDecoder m_oStaticDecoder
For internal use only.
Definition: sample_codec.h:336
size_t GetDataSize() const
Get the current data size.
Definition: sample_codec.h:316
adtf::ucom::object_ptr_shared_locked< const adtf::streaming::ISampleBuffer > m_pBuffer
For internal use only.
Definition: sample_codec.h:338
cStaticSampleDecoder(ddl::codec::StaticDecoder &&oDecoder, adtf::ucom::object_ptr_shared_locked< const adtf::streaming::ISampleBuffer > &&pBuffer)
For internal use only.
Definition: sample_codec.h:324
const void * GetData() const
Get the current data pointer.
Definition: sample_codec.h:307
cStaticSampleDecoder()=default
Default constructor.
The ISample interface sets and retrieves properties on samples .
Definition: sample_intf.h:35
Defines access methods for the interface of a Stream Type - see also Stream Type and Stream Meta Type...
virtual T * Get() const =0
Get raw pointer to shared object.
Base object pointer to realize binary compatible reference counting in interface methods.
Implementation for a exclusive lock guard.
Implementation for a shared lock guard.
Utility class for a complete valid data definition of one StructType and its dependencies.
Definition: ddstructure.h:55
Iteratable container type for the given Element type in ElementAccessType::element_type.
A CodecElement to get and set values.
Fast Access Index Type for the coders.
Definition: codec_index.h:132
ElementType getType() const
Get the elements type if CodecIndex is valid.
The Leaf codec index is a small layout information index to access the decoders/codecs data very fast...
The Data Definiton class uses the validation model to keep a Data Definition datamodel (ddl::dd::data...
Definition: dd.h:87
DataDefinition Datamodel This datamodel is observable for any change of:
const StructTypes & getStructTypes() const
Get the Struct Types object.
observable DataDefinition object class for a Element of a StructType.
const std::string & getTypeName() const
Get the Type Name.
observable DataDefinition object class to describe StructType.
size_t getSize() const
Get the Size.
iterator begin()
the range based begin iterator
std::shared_ptr< const DDL_TYPE_TO_ACCESS > get(const std::string &type_name) const
get the item with the given name type_name
Copyright © Audi Electronics Venture GmbH.
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.
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.
adtf_util::cVariant get_value_as_variant(const T &oDecoder, const tCodecIndex &oCodecIndex)
Get value as variant.
void for_each_leaf_element(ElementsType &oElements, const element_callback< ElementsType > &fnCallback)
Iterates ALL leaf elements within ALL array elements.
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.
std::vector< tCodecIndex > get_codec_indices(const T &oDecoderOrFactory)
Get the codec indices object.
void for_each_element(ElementsType &oElements, const element_callback< ElementsType > &fnCallback)
Iterates elements without array elements (also structures).
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.
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.
ddl::codec::LeafCodecIndex tLeafCodecIndex
redefitnion for a ddl::codec::LeafCodecIndex
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.
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.
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.
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.
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.
Namespace for entire ADTF SDK.
@ cet_float
Variant type is float.
@ cet_int16
Variant type is std::int16_t.
@ cet_int8
Variant type is std::int8_t.
@ cet_uint64
Variant type is std::uint64_t.
@ cet_uint8
Variant type is std::uint8_t.
@ cet_uint32
Variant type is std::uint32_t.
@ cet_bool
Variant type is bool.
@ cet_uint16
Variant type is std::uint16_t.
@ cet_int32
Variant type is std::int32_t.
@ cet_int64
Variant type is std::int64_t.
@ cet_double
Variant type is double.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
#define THROW_ERROR_DESC(_code,...)
throws a tResult exception