AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
RestoreObjects.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#pragma once
18
19
21
22namespace agxStream
23{
24 template<typename T>
26 {
27 public:
28 typedef T ObjectType;
29 typedef T* ObjectPtrType;
31
32 RestoreObjects(agxStream::InputArchive& archive, const char* collectionTitle, const char* elementTitle) :
33 m_archive(archive),
34 m_collectionTitle(collectionTitle),
35 m_elementTitle(elementTitle)
36 {
38 size_t size;
39 m_archive.getAttribute("size", size);
40 m_objects.resize(size);
41 for(size_t i = 0; i < size; i++)
42 {
44 if (m_archive.eof())
45 {
46 std::stringstream str;
47 str << "Reached EOF while restoring " << m_collectionTitle << ". " <<
48 "There should be " << size << " RigidBodies, reached eof after restoring " << i;
50 }
51 }
53 }
54
55
57 {
58 return m_objects.begin();
59 }
60
62 {
63 return m_objects.end();
64 }
65
67 {
68 return m_objects;
69 }
70
71 protected:
73
75 const char* m_collectionTitle;
76 const char*m_elementTitle;
77
78
79 private:
80 RestoreObjects& operator =(const RestoreObjects&)
81 {
82 return *this;
83 }
84 };
85}
86
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
virtual void getAttribute(const char *name, double &value)
virtual void endSection(const char *title) override
virtual void beginSection(const char *title) override
ObjectPtrVectorType::iterator end()
const agx::Vector< T * > & getObjects()
RestoreObjects(agxStream::InputArchive &archive, const char *collectionTitle, const char *elementTitle)
agx::Vector< T * > ObjectPtrVectorType
agxStream::InputArchive & m_archive
const char * m_collectionTitle
ObjectPtrVectorType::iterator begin()
ObjectPtrVectorType m_objects
Templated vector class.
Definition: agx/Vector.h:53
iterator end()
Definition: agx/Vector.h:1044
void resize(size_t size)
Resize the vector, which then enables direct addressing using the bracket '[]' operator.
Definition: agx/Vector.h:540
iterator begin()
Definition: agx/Vector.h:1041
#define agxThrow
Definition: debug.h:109
This namespace contain classes for streaming classes into archives, ASCII, binary for storage (serial...
InputRef< T > in(const char *name, T &obj)
Create an object with a name and a reference to the object that should be restored (usually a pointer...
Definition: InputArchive.h:401