HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ObjectReader.h
Go to the documentation of this file.
1 //-*****************************************************************************
2 //
3 // Copyright (c) 2009-2013,
4 // Sony Pictures Imageworks Inc. and
5 // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd.
6 //
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are
11 // met:
12 // * Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 // * Redistributions in binary form must reproduce the above
15 // copyright notice, this list of conditions and the following disclaimer
16 // in the documentation and/or other materials provided with the
17 // distribution.
18 // * Neither the name of Sony Pictures Imageworks, nor
19 // Industrial Light & Magic, nor the names of their contributors may be used
20 // to endorse or promote products derived from this software without specific
21 // prior written permission.
22 //
23 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 //
35 //-*****************************************************************************
36 
37 #ifndef Alembic_AbcCoreAbstract_ObjectReader_h
38 #define Alembic_AbcCoreAbstract_ObjectReader_h
39 
40 #include <Alembic/Util/Export.h>
44 
45 namespace Alembic {
46 namespace AbcCoreAbstract {
47 namespace ALEMBIC_VERSION_NS {
48 
49 //-*****************************************************************************
50 //! An Object consists of a list of children objects, which may be empty,
51 //! and a single compound property which is the root of any properties
52 //! which the object may contain.
53 //! Objects have MetaData, which is identical to the MetaData of the root
54 //! Compound Property.
57 {
58 public:
59  //! Virtual destructor
60  //! ...
61  virtual ~ObjectReader();
62 
63  //-*************************************************************************
64  // NEW FUNCTIONS
65  //-*************************************************************************
66 
67  //! All objects have a header, which contains all the MetaData that was
68  //! specified upon their creation.
69  //! This function returns a constant reference to that Header.
70  virtual const ObjectHeader &getHeader() const = 0;
71 
72  //! All objects have a name. This name is unique amongst their siblings
73  //! Returned by reference, since it is guaranteed to exist and be
74  //! unchanging.
75  //! This is a convenience function which returns the header's name.
76  const std::string &getName() const
77  { return getHeader().getName(); }
78 
79  //! The full name of an object is the complete path name all the way
80  //! to the root object of the archive. It is guaranteed to be fully
81  //! unique within the entire archive.
82  //! This is a convenience function which returns the header's full name.
83  const std::string &getFullName() const
84  { return getHeader().getFullName(); }
85 
86  //! All objects have metadata. This metadata is identical to the
87  //! Metadata of the top level compoundProperty "properties".
88  //! Because the metadata must exist and be initialized in order to
89  //! bootstrap the object, it is guaranteed to exist and is returned
90  //! by reference.
91  //! This is a convenience function which returns the header's MetaData.
92  const MetaData &getMetaData() const
93  { return getHeader().getMetaData(); }
94 
95  //! All objects have a shared link to the root. This may seem
96  //! wasteful, but it is essential in order to allow for the flexible,
97  //! reference-counted autonomy of the reader objects. Alembic
98  //! allows you to keep references to readers wherever you want,
99  //! without requiring you to keep track of (or store) the parental
100  //! hierarchy directly. In order to make this possible, we have
101  //! the ability to walk upwards. This may be stored as a direct
102  //! link, or retrieved by walking up the parent chain, which is
103  //! a feature of the individual implementations. (it might not be
104  //! cheap, basically).
105  //! In order to prevent shared_ptr cycles, it is important
106  //! that objects only store their children via weak ptrs.
107  virtual ArchiveReaderPtr getArchive() = 0;
108 
109  //! All objects have a shared link to their parent. This may seem
110  //! wasteful, but it is essential in order to allow for the flexible,
111  //! reference-counted autonomy of the reader objects. Alembic
112  //! allows you to keep references to readers wherever you want,
113  //! without requiring you to keep track of (or store) the parental
114  //! hierarchy directly. In order to make this possible, we have
115  //! the ability to walk upwards.
116  //! In order to prevent shared_ptr cycles, it is important
117  //! that objects only store their children via weak ptrs.
118  virtual ObjectReaderPtr getParent() = 0;
119 
120  //! All objects have one and only one compound property which
121  //! is the root for any properties which are associated with this object.
122  //! If no properties were written to the object, this may return an
123  //! empty pointer.
124  virtual CompoundPropertyReaderPtr getProperties() = 0;
125 
126  //-*************************************************************************
127  // Children!
128  //-*************************************************************************
129 
130  //! Returns the number of objects that are contained as children.
131  //! Objects do not have to have children, this may return zero.
132  virtual size_t getNumChildren() = 0;
133 
134  //! Return the header of an object by index.
135  //! This will throw an exception on out-of-range access.
136  virtual const ObjectHeader & getChildHeader( size_t i ) = 0;
137 
138  //! Return the header of an object by name.
139  //! This will return a NULL pointer if no header by that name is found.
140  virtual const ObjectHeader *
141  getChildHeader( const std::string &iName ) = 0;
142 
143  //! Get a child object by name.
144  //! This is a convenience function that uses getChildHeader and
145  //! the various named "get" functions here.
146  virtual ObjectReaderPtr getChild( const std::string &iName ) = 0;
147 
148  //! Get a child object by index.
149  //! It is an error to call with out-of-range indices.
150  //! This is a convenience function that uses getChildHeader and
151  //! the various named "get" functions here.
152  virtual ObjectReaderPtr getChild( size_t i ) = 0;
153 
154  //-*************************************************************************
155  // Hierarchical hash stuff
156  //-*************************************************************************
157 
158  //! If an aggregated properties hash exists fill oDigest with it and
159  //! return true, if it doesn't exist return false
160  virtual bool getPropertiesHash( Util::Digest & oDigest );
161 
162  //! If an aggregated child objects hash exists fill oDigest with it and
163  //! return true, if it doesn't exist return false
164  virtual bool getChildrenHash( Util::Digest & oDigest );
165 
166  //-*************************************************************************
167  // YUP
168  //-*************************************************************************
169 
170  //! Returns shared pointer to myself.
171  //! This is non-virtual
172  virtual ObjectReaderPtr asObjectPtr() = 0;
173 };
174 
175 } // End namespace ALEMBIC_VERSION_NS
176 
177 using namespace ALEMBIC_VERSION_NS;
178 
179 } // End namespace AbcCoreAbstract
180 } // End namespace Alembic
181 
182 #endif
183 
184 
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
Alembic::Util::shared_ptr< ObjectReader > ObjectReaderPtr
#define ALEMBIC_EXPORT
Definition: Export.h:51
GU_API GA_Offset getParent(const GU_Detail *gdp, const GA_Offset &node)
Alembic::Util::shared_ptr< CompoundPropertyReader > CompoundPropertyReaderPtr
Alembic::Util::shared_ptr< ArchiveReader > ArchiveReaderPtr
Smart Ptrs to Readers.
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:88