AGX Dynamics  2.35.0.1
SerializedFrame.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXDATA_SERIALIZEDDATA_H
18 #define AGXDATA_SERIALIZEDDATA_H
19 
20 #include <agxData/BinaryData.h>
21 #include <agxData/Buffer.h>
22 #include <agxData/EntityStorage.h>
23 #include <agxData/Frame.h>
24 #include <agx/HashVector.h>
25 #include <agx/agx_vector_types.h>
26 
27 namespace agx
28 {
29  class TiXmlElement;
30 }
31 
32 namespace agxData
33 {
34  class FrameReader;
35 
42  {
43  public:
45  {
46  INVALID=-1,
49  BINARY_HEADER
50  };
51 
52  static const agx::UInt64 DATA_SEGMENT_ALIGNMENT = 32;
53 
54  public:
57 
63  AGX_DECLARE_POINTER_TYPES(PartialBuffer);
65 
66  AGX_DECLARE_POINTER_TYPES(StorageBatchEvent);
67 
68  public:
69  SerializedFrame(const agxData::Frame* frame);
71 
72  static Frame* createFrame(const Component* root, agx::UInt index, agx::Real timeStamp, agx::Real timeStep);
73 
74  size_t getTotNumBytes() const;
75 
76  Component* getRoot();
77 
78  // For binary header, names are stored as indices, with a common name table
81 
84 
85  agx::TiXmlElement* writeXmlHeader() const;
86  // void writeJsonHeader(agxJson::Value& root) const;
87 
88  void writeDataSegment(std::ostream& binaryFile);
89 
90  static Frame* extractFrame(BinaryData* headerSegment, BinaryData* dataSegment);
91  static Frame* extractFrame(BinaryData* headerSegment, BinaryData* dataSegment, ImportNameTable& nameTable, bool clearNameTableOnKeyFrame = true, FrameReader* frameReader = nullptr);
92  static Frame* extractFrame(agx::TiXmlElement* eFrame, BinaryData* dataSegment);
93 
94 
95  static void updateNameTable(BinaryData* headerSegment, ImportNameTable& nameTable);
96 
98  {
100  BinarySegment(BinaryData* _data, size_t _offset) : data(_data), offset(_offset) {}
101 
103  size_t offset;
104  };
105 
107 
109 
110  protected:
111  virtual ~SerializedFrame();
112 
113 
114 
115  private:
116  agxData::Buffer* createCustomBuffer(const agx::Name& name, Format* format, size_t size);
117  void addChildren(Component* eParent, const agx::Component* component);
118  void add(Component* eParent, const agxData::Frame::EntityStorage* storage);
119  void add(Component* eParent, const agx::Component* component);
120  void add(Component* eParent, const agxData::Buffer* buffer);
121  void add(Component* eParent, const agxData::Frame::PartialBuffer* buffer);
122  void add(Component* eParent, const agxData::Value* value);
123 
124  void addArrayBuffer(Component* eParent, const agxData::Buffer* buffer);
125  void addPtrBuffer(Component* eParent, const agxData::Buffer* buffer);
126 
127  template <typename StringT>
128  void addStringBuffer(Component* eParent, const agxData::Buffer* buffer);
129 
130  void writeXmlEvents(agx::TiXmlElement* eParent) const;
131 
132  private:
133  static size_t createComponent(agx::Component* parent, const Component* serializedComponent);
134  static size_t createChildren(agx::Component* parent, const Component* serializedComponent);
135  static size_t createValue(agx::Component* parent, const Value* serializedValue);
136  static size_t createStorage(agx::Component* parent, const EntityStorage* serializedStorage);
137  static size_t createBuffer(agx::Component* parent, const Buffer* serializedBuffer);
138  static size_t createBuffer(agx::Component* parent, const CustomBuffer* serializedBuffer);
139  static size_t createBuffer(agx::Component* parent, const PartialBuffer* serializedBuffer);
140 
141  static agxData::Buffer* createBuffer(const Buffer* serializedBuffer);
142  static agxData::Buffer* createBuffer(const CustomBuffer* serializedBuffer);
143  static agxData::Buffer* createArrayBuffer(const CustomBuffer* serializedBuffer);
144  static agxData::Buffer* createPtrBuffer(const CustomBuffer* serializedBuffer);
145 
146  template <typename T>
147  static agxData::Buffer* createNameBuffer(const CustomBuffer* serializedBuffer);
148 
149 
150  public:
151  struct BinaryHeader;
152  struct XmlHeader;
153  struct JsonHeader;
154 
155  private:
156  const Frame* m_frame;
157  ComponentRef m_root;
158  BinarySegmentVector m_binarySegments;
159  BufferRefVector m_customBuffers;
160  size_t m_currentOffset;
161  size_t m_totNumBytes;
162  };
163 
164  //---------------------------------------------------------------
165 
166  class AGXCORE_EXPORT SerializedFrame::StorageBatchEvent : public agx::Object::Event
167  {
168  public:
169  enum Type
170  {
173  PERMUTE
174  };
175 
176  public:
177  StorageBatchEvent(Type type, agxData::EntityStorage* storage, size_t reserve = 0);
178 
179  void add(agx::UInt64 id);
180  void add(agxData::EntityRange& instances);
182  void add(agxData::Array<agx::Index>& instances);
183 
184  Type getType() const;
187 
188  private:
189  Type m_type;
190  agxData::EntityStorage* m_storage;
191  agx::UInt64Vector m_ids;
192  };
193 
194 
196  {
230 
231  struct FrameMeta
232  {
241  };
242 
243  struct Node
244  {
248  };
249 
250  struct DataNode : public Node
251  {
255  };
256 
257  struct Value : public DataNode
258  {
259  };
260 
261  struct Buffer : public DataNode
262  {
264  };
265 
266  struct Component : public Node
267  {
269  };
270 
271  struct CustomBuffer : public Component
272  {
275  };
276 
277  struct PartialBuffer : public Component
278  {
282  };
283 
284  struct EntityStorage : public Component
285  {
289  };
290 
291 
293 
294  struct Event
295  {
297  };
298 
299  struct StorageEvent : public Event
300  {
301  // NameId storagePath;
303  };
304 
306  {
307  };
308 
310  {
312  };
313 
315  {
317  };
318 
320  {
323  };
324 
326  {
329  // ... list of ids
330  };
331 
332  struct PermuteEvent : public StorageEvent
333  {
334  };
335 
336 
337 
338  // All components have an end-tag for safety, child nodes are written in-place
339  static const agx::UInt32 EndTag;
340 
341 
342  static NameId getNameId(const agx::Name& name, ExportNameTable& nameTable);
343 
345 
348 
349  static size_t calculateNameTableSize(const ExportNameTable& nameTable, size_t oldNumNames = 0);
350  static ByteStream writeNameTable(const ExportNameTable& nameTable, ByteStream stream, size_t oldNumNames = 0);
351 
352  static ByteStream extractNameTable(ByteStream headerStream, ImportNameTable& nameTable);
353 
354 
356  {
357  public:
358  FrameExtractor(BinaryData* headerSegment, BinaryData* dataSegment, ImportNameTable& nameTable, FrameReader* frameReader);
360 
361  Frame* extract(bool clearNameTableOnKeyFrame);
362 
363 
366 
367  private:
368 
369  agx::Name getName(NameId nameId);
370  agxData::Format* getFormat(NameId formatNameId);
371  agxData::EntityModel* getEntityModel(NameId entityModelNameId);
372 
373  SerializedFrame::Node* extractNode(bool skip = false);
374  SerializedFrame::Component* extractComponent(bool skip);
375  SerializedFrame::Value* extractValue(bool skip);
376  SerializedFrame::Buffer* extractBuffer(bool skip);
377  SerializedFrame::PartialBuffer* extractPartialBuffer(bool skip);
378  SerializedFrame::CustomBuffer* extractCustomBuffer(bool skip);
379  SerializedFrame::EntityStorage* extractEntityStorage(bool skip);
380  void extractChildren(bool skip, SerializedFrame::Component* parent, size_t numChildren);
381 
382  FrameExtractor& operator=(const FrameExtractor&) = delete;
383 
384  private:
385  ByteStream m_headerStream;
386  BinaryDataRef m_headerSegment;
387  BinaryDataRef m_dataSegment;
388  ImportNameTable& m_nameTable;
389  FrameReader* m_frameReader;
391  agx::Path m_nodePath;
392  };
393 
394 
395 
396  };
397 
398  //---------------------------------------------------------------
399 
401  {
402  static SerializedFrame::Node* extractNode(const agx::TiXmlElement* eNode, BinaryData* binarySegment);
403  static SerializedFrame::Component* extractComponent(const agx::TiXmlElement* eComponent, BinaryData* binarySegment);
404  static SerializedFrame::Value* extractValue(const agx::TiXmlElement* eValue, BinaryData* binarySegment);
405  static SerializedFrame::Buffer* extractBuffer(const agx::TiXmlElement* eBuffer, BinaryData* binarySegment);
406  static SerializedFrame::PartialBuffer* extractPartialBuffer(const agx::TiXmlElement* eBuffer, BinaryData* binarySegment);
407  static SerializedFrame::CustomBuffer* extractCustomBuffer(const agx::TiXmlElement* eBuffer, BinaryData* binarySegment);
408  static SerializedFrame::EntityStorage* extractEntityStorage(const agx::TiXmlElement* eStorage, BinaryData* binarySegment);
409  static void extractChildren(SerializedFrame::Component* parent, const agx::TiXmlElement* eNode, BinaryData* binarySegment);
410  static void extractFrameEvents(const agx::TiXmlElement* eFrame, Frame* frame, BinaryData *);
411  };
412 
413  //---------------------------------------------------------------
414 
416  {
417 
418  };
419 
420  //---------------------------------------------------------------
421 
422  class AGXCORE_EXPORT SerializedFrame::Node : public agx::Referenced
423  {
424  public:
425  enum Type
426  {
427  INVALID=-1,
433  ENTITY_STORAGE
434  };
435 
436  Node(const agx::Name& name, agx::Index id);
437 
438  const agx::Name& getName() const;
439  Component* getParent();
441 
442  void setId(agx::Index id);
443  agx::Index getId() const;
444 
445  Type getType() const;
446  void setType(Type type);
447 
448  const agx::Name& getTypeName() const;
449 
450  virtual size_t getBinaryHeaderNumBytes() const = 0;
453  virtual agx::TiXmlElement* writeXmlHeader(agx::TiXmlElement* eParent) = 0;
454  virtual void writeDataSegment(std::ostream& binaryFile, agx::UInt64 baseOffset) = 0;
455 
456  protected:
457  friend class Component;
458  void setParent(Component* parent);
459 
460  private:
461  Type m_type;
462  agx::Index m_id;
463  agx::Name m_name;
464  Component* m_parent;
465  };
466 
467  class AGXCORE_EXPORT SerializedFrame::Component : public Node
468  {
469  public:
471 
472  void addChild(Node* child);
473 
474  const NodeRefVector& getChildren() const;
475 
476  template <typename T>
477  T* getChild(const char* name);
478 
479  template <typename T>
480  const T* getChild(const char* name) const;
481 
482  virtual size_t getBinaryHeaderNumBytes() const override;
483  virtual ByteStream writeBinaryHeader(ByteStream stream, ExportNameTable& nameTable) override;
484 
485  template<typename ComponentT>
486  ByteStream writeBinaryHeader(ByteStream stream, ExportNameTable& nameTable, ComponentT& eComponent);
487  virtual agx::TiXmlElement* writeXmlHeader(agx::TiXmlElement* eParent) override;
488  void writeChildren(agx::TiXmlElement* eParent);
489  virtual void writeDataSegment(std::ostream& binaryFile, agx::UInt64 baseOffset) override;
490 
491  private:
492  NodeRefVector m_children;
493  };
494 
495  class AGXCORE_EXPORT SerializedFrame::DataNode : public Node
496  {
497  public:
498  DataNode(const agx::Name& name, agx::Index id, BinaryData* data, const Format* format, size_t numBytes, size_t offset);
499 
500  const Format* getFormat() const;
501  size_t getNumBytes() const;
502  size_t getOffset() const;
504  const BinaryData* getData() const;
505 
506  virtual size_t getBinaryHeaderNumBytes() const override;
507 
508  virtual ByteStream writeBinaryHeader(ByteStream stream, ExportNameTable& nameTable) override;
510  virtual void writeDataSegment(std::ostream& binaryFile, agx::UInt64 baseOffset) override;
511 
512  private:
513  FormatConstRef m_format;
514  size_t m_numBytes;
515  size_t m_offset;
516  BinaryDataRef m_data;
517  };
518 
519  class AGXCORE_EXPORT SerializedFrame::Value : public DataNode
520  {
521  public:
522  Value(const agx::Name& name, agx::Index id, BinaryData* data, const Format* format, size_t offset);
523 
524  // virtual size_t getBinaryHeaderNumBytes() const override;
525  // virtual ByteStream writeBinaryHeader(ByteStream stream, ExportNameTable& nameTable) override;
526  virtual agx::TiXmlElement* writeXmlHeader(agx::TiXmlElement* eParent) override;
527 
528  private:
529  };
530 
531  class AGXCORE_EXPORT SerializedFrame::Buffer : public DataNode
532  {
533  public:
534  Buffer(const agx::Name& name, agx::Index id, BinaryData* data, const Format* format, size_t numElements, size_t byteOffset);
535 
536  size_t getNumElements() const;
537  // size_t capacity() const;
538 
539  virtual size_t getBinaryHeaderNumBytes() const override;
540  virtual ByteStream writeBinaryHeader(ByteStream stream, ExportNameTable& nameTable) override;
541  virtual agx::TiXmlElement* writeXmlHeader(agx::TiXmlElement* eParent) override;
542 
543  private:
544  size_t m_numElements;
545  // size_t m_capacity;
546  };
547 
548  class AGXCORE_EXPORT SerializedFrame::CustomBuffer : public Component
549  {
550  public:
551  CustomBuffer(const agx::Name& name, agx::Index id, const Format* format, size_t numElements);
552 
553  const Format* getFormat() const;
554  size_t getNumElements() const;
555  // size_t capacity() const;
556 
557  virtual size_t getBinaryHeaderNumBytes() const override;
558  virtual ByteStream writeBinaryHeader(ByteStream stream, ExportNameTable& nameTable) override;
559  virtual agx::TiXmlElement* writeXmlHeader(agx::TiXmlElement* eParent) override;
560 
561  private:
562  FormatConstRef m_format;
563  size_t m_numElements;
564  // size_t m_capacity;
565  };
566 
567  class AGXCORE_EXPORT SerializedFrame::PartialBuffer : public Component
568  {
569  public:
570  PartialBuffer(agxData::Frame::PartialBuffer* buffer);
571  PartialBuffer(const agx::Name& name, agx::Index id, const Format* format, size_t numElements, size_t fullSize);
572 
573  const Format* getFormat() const;
574  size_t getNumElements() const;
575  size_t fullSize() const;
576  // size_t fullCapacity() const;
577 
578  virtual size_t getBinaryHeaderNumBytes() const override;
579  virtual ByteStream writeBinaryHeader(ByteStream stream, ExportNameTable& nameTable) override;
580  virtual agx::TiXmlElement* writeXmlHeader(agx::TiXmlElement* eParent) override;
581 
582  private:
583  FormatConstRef m_format;
584  size_t m_numElements;
585  size_t m_fullSize;
586  // size_t m_fullCapacity;
587  };
588 
589  class AGXCORE_EXPORT SerializedFrame::EntityStorage : public Component
590  {
591  public:
592  EntityStorage(const agxData::Frame::EntityStorage* storage);
593  EntityStorage(const agx::Name& name, agx::Index id, EntityModel* model, size_t numElements, size_t capacity);
594 
596  const EntityModel* getModel() const;
597  size_t getNumElements() const;
598  size_t capacity() const;
599 
600  virtual size_t getBinaryHeaderNumBytes() const override;
601  virtual ByteStream writeBinaryHeader(ByteStream stream, ExportNameTable& nameTable) override;
602  virtual agx::TiXmlElement* writeXmlHeader(agx::TiXmlElement* eParent) override;
603 
604  private:
605  EntityModelRef m_model;
606  size_t m_numElements;
607  size_t m_capacity;
608  };
609 
610 
611 
612 
613  /* Implementation */
614 
616  AGX_FORCE_INLINE SerializedFrame::Component* SerializedFrame::getRoot() { return m_root; }
617  AGX_FORCE_INLINE size_t SerializedFrame::getTotNumBytes() const { return m_totNumBytes; }
619 
620 
621  //---------------------------------------------------------------
622 
624  AGX_FORCE_INLINE const agx::Name& SerializedFrame::Node::getName() const { return m_name; }
625  AGX_FORCE_INLINE agx::Index SerializedFrame::Node::getId() const { return m_id; }
626  AGX_FORCE_INLINE SerializedFrame::Component* SerializedFrame::Node::getParent() { return m_parent; }
627  AGX_FORCE_INLINE void SerializedFrame::Node::setParent(Component* parent) { m_parent = parent; }
628 
629  //---------------------------------------------------------------
630 
631  AGX_FORCE_INLINE const Format* SerializedFrame::DataNode::getFormat() const { return m_format; }
632  AGX_FORCE_INLINE size_t SerializedFrame::DataNode::getNumBytes() const { return m_numBytes; }
633  AGX_FORCE_INLINE size_t SerializedFrame::DataNode::getOffset() const { return m_offset; }
634 
635  AGX_FORCE_INLINE BinaryData* SerializedFrame::DataNode::getData() { return m_data; }
636  AGX_FORCE_INLINE const BinaryData* SerializedFrame::DataNode::getData() const { return m_data; }
637 
638  //---------------------------------------------------------------
639 
640  AGX_FORCE_INLINE const SerializedFrame::NodeRefVector& SerializedFrame::Component::getChildren() const { return m_children; }
641 
642 
643  template <typename T>
644  AGX_FORCE_INLINE T* SerializedFrame::Component::getChild(const char* name)
645  {
646  for (size_t i = 0; i < m_children.size(); ++i)
647  {
648  if (m_children[i]->getName() == name && m_children[i]->is<T>())
649  return m_children[i]->as<T>();
650  }
651 
652  return nullptr;
653  }
654 
655  template <typename T>
656  AGX_FORCE_INLINE const T* SerializedFrame::Component::getChild(const char* name) const
657  {
658  return const_cast<SerializedFrame::Component *>(this)->getChild<T>(name);
659  }
660 
661  //---------------------------------------------------------------
662 
663  AGX_FORCE_INLINE size_t SerializedFrame::Buffer::getNumElements() const { return m_numElements; }
664  // AGX_FORCE_INLINE size_t SerializedFrame::Buffer::capacity() const { return m_capacity; }
665 
666  //---------------------------------------------------------------
667 
668  AGX_FORCE_INLINE const Format* SerializedFrame::CustomBuffer::getFormat() const { return m_format; }
669  AGX_FORCE_INLINE size_t SerializedFrame::CustomBuffer::getNumElements() const { return m_numElements; }
670  // AGX_FORCE_INLINE size_t SerializedFrame::CustomBuffer::capacity() const { return m_capacity; }
671 
672  //---------------------------------------------------------------
673 
674  AGX_FORCE_INLINE const Format* SerializedFrame::PartialBuffer::getFormat() const { return m_format; }
675  AGX_FORCE_INLINE size_t SerializedFrame::PartialBuffer::getNumElements() const { return m_numElements; }
676  AGX_FORCE_INLINE size_t SerializedFrame::PartialBuffer::fullSize() const { return m_fullSize; }
677  // AGX_FORCE_INLINE size_t SerializedFrame::PartialBuffer::fullCapacity() const { return m_fullCapacity; }
678 
679  //---------------------------------------------------------------
680 
681  AGX_FORCE_INLINE EntityModel* SerializedFrame::EntityStorage::getModel() { return m_model; }
682  AGX_FORCE_INLINE const EntityModel* SerializedFrame::EntityStorage::getModel() const { return m_model; }
683  AGX_FORCE_INLINE size_t SerializedFrame::EntityStorage::getNumElements() const { return m_numElements; }
684  AGX_FORCE_INLINE size_t SerializedFrame::EntityStorage::capacity() const { return m_capacity; }
685 
686  //---------------------------------------------------------------
687 
688  AGX_FORCE_INLINE void SerializedFrame::StorageBatchEvent::add(agx::UInt64 id) { m_ids.push_back(id); }
690 
691 }
692 
693 
694 #endif /* AGXDATA_SERIALIZEDDATA_H */
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXCORE_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: agx/Vector.h:34
#define m_capacity
Definition: agx/Vector.h:430
Type-specific Array used for fast access into the data held by a Buffer.
Definition: Array.h:107
Abstract representation of a data buffer.
Definition: Buffer.h:56
Utility class for parsing/writing a byte stream.
Definition: ByteStream.h:28
An abstract description of a data entity stored using SOA (structure of arrays) pattern in a EntitySt...
Definition: EntityModel.h:64
Data storage for a collection of entity instances of a specified EntityModel.
Definition: EntityStorage.h:73
A format is an implementation of a agxData::Type.
Definition: Format.h:64
The FrameReader reads frames from an external source.
Definition: FrameIO.h:127
Frame * extract(bool clearNameTableOnKeyFrame)
FrameExtractor(BinaryData *headerSegment, BinaryData *dataSegment, ImportNameTable &nameTable, FrameReader *frameReader)
Node(const agx::Name &name, agx::Index id)
agx::HashVector< agx::Name, agx::UInt32 > ExportNameTable
agx::Vector< NodeRef > NodeRefVector
void add(agxData::Array< agx::Index > &instances)
void addChild(Node *child)
const T * getChild(const char *name) const
static Frame * extractFrame(BinaryData *headerSegment, BinaryData *dataSegment, ImportNameTable &nameTable, bool clearNameTableOnKeyFrame=true, FrameReader *frameReader=nullptr)
BinaryData * writeBinaryHeader(ExportNameTable &nameTable) const
virtual void writeDataSegment(std::ostream &binaryFile, agx::UInt64 baseOffset) override
size_t getOffset() const
Buffer(const agx::Name &name, agx::Index id, BinaryData *data, const Format *format, size_t numElements, size_t byteOffset)
size_t capacity() const
PartialBuffer(agxData::Frame::PartialBuffer *buffer)
const NodeRefVector & getChildren() const
DataNode(const agx::Name &name, agx::Index id, BinaryData *data, const Format *format, size_t numBytes, size_t offset)
EntityStorage(const agxData::Frame::EntityStorage *storage)
StorageBatchEvent(Type type, agxData::EntityStorage *storage, size_t reserve=0)
static Frame * extractFrame(BinaryData *headerSegment, BinaryData *dataSegment)
const EntityModel * getModel() const
const BinarySegmentVector & getBinarySegments() const
void setType(Type type)
ByteStream writeBinaryHeader(ByteStream stream, ExportNameTable &nameTable, ComponentT &eComponent)
virtual agx::TiXmlElement * writeXmlHeader(agx::TiXmlElement *eParent) override
agx::TiXmlElement * writeXmlHeader() const
const agx::Name & getName() const
const agx::UInt64Vector & getIdVector() const
void add(agxData::Array< agxData::EntityPtr > &instances)
size_t fullSize() const
static void updateNameTable(BinaryData *headerSegment, ImportNameTable &nameTable)
agx::Index getId() const
size_t getNumElements() const
SerializedFrame(const agxData::Frame *frame)
void writeBinaryHeader(BinaryHeader::Node &eNode, ExportNameTable &nameTable)
static Frame * extractFrame(agx::TiXmlElement *eFrame, BinaryData *dataSegment)
void add(agx::UInt64 id)
size_t getTotNumBytes() const
EntityModel * getModel()
size_t getNumBytes() const
void add(agxData::EntityRange &instances)
Component(const agx::Name &name, agx::Index id=agx::InvalidIndex)
virtual size_t getBinaryHeaderNumBytes() const =0
virtual void writeDataSegment(std::ostream &binaryFile, agx::UInt64 baseOffset)=0
virtual agx::TiXmlElement * writeXmlHeader(agx::TiXmlElement *eParent)=0
agx::Vector< BinarySegment > BinarySegmentVector
agx::String getPath() const
const agx::Name & getTypeName() const
SerializedFrame(SerializedFrame::Component *root)
T * getChild(const char *name)
virtual ByteStream writeBinaryHeader(ByteStream stream, ExportNameTable &nameTable) override
agxData::EntityStorage * getStorage()
void writeBinaryHeader(BinaryHeader::DataNode &eNode, ExportNameTable &nameTable)
BinaryData * writeBinaryHeader() const
EntityStorage(const agx::Name &name, agx::Index id, EntityModel *model, size_t numElements, size_t capacity)
void writeDataSegment(std::ostream &binaryFile)
BinaryData * getData()
PartialBuffer(const agx::Name &name, agx::Index id, const Format *format, size_t numElements, size_t fullSize)
static Frame * createFrame(const Component *root, agx::UInt index, agx::Real timeStamp, agx::Real timeStep)
void writeChildren(agx::TiXmlElement *eParent)
void setParent(Component *parent)
CustomBuffer(const agx::Name &name, agx::Index id, const Format *format, size_t numElements)
void setId(agx::Index id)
const BinaryData * getData() const
Value(const agx::Name &name, agx::Index id, BinaryData *data, const Format *format, size_t offset)
const Format * getFormat() const
virtual size_t getBinaryHeaderNumBytes() const override
agx::HashVector< agx::UInt32, agx::Name > ImportNameTable
virtual ByteStream writeBinaryHeader(ByteStream stream, ExportNameTable &nameTable)
Abstract representation of a value.
Definition: Value.h:43
A component is an object containing other objects, enabling hierarchical structuring.
Definition: Component.h:39
Representation of a name string.
Definition: Name.h:33
Representation of a path, a list of name components.
Definition: Path.h:34
Base class providing referencing counted objects.
Definition: Referenced.h:114
Vector containing 'raw' data.
Definition: agx/Vector.h:246
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
#define AGX_FORCE_INLINE
Definition: macros.h:58
Contains classes for low level data storage for AGX.
Definition: Container.h:23
AGXCORE_EXPORT Format * getFormat(const agx::String &typeFormatName)
AGXCORE_EXPORT Type * getType(const agx::String &name)
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
double Real64
Definition: Real.h:45
uint32_t UInt32
Definition: Integer.h:40
bool Bool
Definition: Integer.h:48
uint64_t UInt64
Definition: Integer.h:41
AGXCORE_EXPORT Component * root()
uint32_t UInt
Definition: Integer.h:34
double Real
Definition: Real.h:42
AGXCORE_EXPORT const InvalidIndexStruct InvalidIndex
AGXCORE_EXPORT Model * getModel(const Path &path, const Path &_namespace=Path())
Definition: Object.h:364
UInt32 Index
Definition: Integer.h:52
static size_t calculateSerializedEventSize(const agx::Object::EventRefVector &events)
static ByteStream extractNameTable(ByteStream headerStream, ImportNameTable &nameTable)
static BinaryData * writeEvents(const agx::Object::EventRefVector &events)
static size_t calculateNameTableSize(const ExportNameTable &nameTable, size_t oldNumNames=0)
static NameId getNameId(const agx::Name &name, ExportNameTable &nameTable)
static ByteStream writeEvents(const agx::Object::EventRefVector &events, ByteStream stream, ExportNameTable &nameTable)
static ByteStream writeNameTable(const ExportNameTable &nameTable, ByteStream stream, size_t oldNumNames=0)
agx::UInt32 NameId
The binary header consist of two segments, first a name table with shared strings/names.
BinarySegment(BinaryData *_data, size_t _offset)
static SerializedFrame::Node * extractNode(const agx::TiXmlElement *eNode, BinaryData *binarySegment)
static void extractChildren(SerializedFrame::Component *parent, const agx::TiXmlElement *eNode, BinaryData *binarySegment)
static SerializedFrame::Buffer * extractBuffer(const agx::TiXmlElement *eBuffer, BinaryData *binarySegment)
static SerializedFrame::PartialBuffer * extractPartialBuffer(const agx::TiXmlElement *eBuffer, BinaryData *binarySegment)
static SerializedFrame::EntityStorage * extractEntityStorage(const agx::TiXmlElement *eStorage, BinaryData *binarySegment)
static SerializedFrame::Component * extractComponent(const agx::TiXmlElement *eComponent, BinaryData *binarySegment)
static SerializedFrame::Value * extractValue(const agx::TiXmlElement *eValue, BinaryData *binarySegment)
static void extractFrameEvents(const agx::TiXmlElement *eFrame, Frame *frame, BinaryData *)
static SerializedFrame::CustomBuffer * extractCustomBuffer(const agx::TiXmlElement *eBuffer, BinaryData *binarySegment)