Alembic 1.8.11
Loading...
Searching...
No Matches
CprImpl.h
1//-*****************************************************************************
2//
3// Copyright (c) 2016,
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_AbcCoreLayer_CprImpl_h
38#define Alembic_AbcCoreLayer_CprImpl_h
39
40#include <Alembic/AbcCoreLayer/Foundation.h>
41
42namespace Alembic {
43namespace AbcCoreLayer {
44namespace ALEMBIC_VERSION_NS {
45
46typedef Alembic::Util::shared_ptr< AbcA::PropertyHeader > PropertyHeaderPtr;
47
48//-*****************************************************************************
49class CprImpl
50 : public AbcA::CompoundPropertyReader
51 , public Alembic::Util::enable_shared_from_this< CprImpl >
52{
53public:
54
55 CprImpl( OrImplPtr iObject,
56 CompoundReaderPtrs & iCompounds );
57
58 CprImpl( CprImplPtr iParent, size_t iIndex );
59
60 virtual ~CprImpl();
61
62 //-*************************************************************************
63 // FROM ABSTRACT BasePropertyReader
64 //-*************************************************************************
65 virtual const AbcA::PropertyHeader & getHeader() const;
66
67 virtual AbcA::ObjectReaderPtr getObject();
68
69 virtual AbcA::CompoundPropertyReaderPtr getParent();
70
71 virtual AbcA::CompoundPropertyReaderPtr asCompoundPtr();
72
73 //-*************************************************************************
74 // FROM ABSTRACT CompoundPropertyReader
75 //-*************************************************************************
76 virtual size_t getNumProperties();
77
78 virtual const AbcA::PropertyHeader & getPropertyHeader( size_t i );
79
80 virtual const AbcA::PropertyHeader *
81 getPropertyHeader( const std::string &iName );
82
83 virtual AbcA::ScalarPropertyReaderPtr
84 getScalarProperty( const std::string &iName );
85
86 virtual AbcA::ArrayPropertyReaderPtr
87 getArrayProperty( const std::string &iName );
88
89 virtual AbcA::CompoundPropertyReaderPtr
90 getCompoundProperty( const std::string &iName );
91
92private:
93 void init( CompoundReaderPtrs & iCompounds );
94
95 // The parent Object
96 OrImplPtr m_object;
97
98 // Pointer to parent.
99 CprImplPtr m_parent;
100
101 size_t m_index;
102
103 // we need to own the PropertyHeader on the top compounds
104 // (which have no parents), others we can get from
105 // m_children and m_childHeaderIndex below
106 PropertyHeaderPtr m_topHeader;
107
108 // each child is made up of the original parent compound, array and scalar
109 // properties will only have 1 entry, compounds could have more
110 std::vector< CompoundReaderPtrs > m_children;
111
112 // so we don't have to copy property headers over, keep track of what
113 // index to use for the header from the appropriate parent in m_children
114 typedef std::pair< size_t, size_t > HeaderIndexPair;
115 std::vector< HeaderIndexPair > m_childHeaderIndex;
116
117 ChildNameMap m_childNameMap;
118};
119
120} // End namespace ALEMBIC_VERSION_NS
121
122using namespace ALEMBIC_VERSION_NS;
123
124} // End namespace AbcCoreLayer
125} // End namespace Alembic
126
127#endif //_Alembic_AbcCoreLayer_CprImpl_h_
128
virtual AbcA::CompoundPropertyReaderPtr asCompoundPtr()
Definition CprImpl.cpp:120
virtual AbcA::CompoundPropertyReaderPtr getParent()
Definition CprImpl.cpp:114
virtual AbcA::ObjectReaderPtr getObject()
Definition CprImpl.cpp:108
virtual AbcA::ScalarPropertyReaderPtr getScalarProperty(const std::string &iName)
Definition CprImpl.cpp:160
virtual size_t getNumProperties()
Definition CprImpl.cpp:126
virtual AbcA::CompoundPropertyReaderPtr getCompoundProperty(const std::string &iName)
Definition CprImpl.cpp:189
virtual AbcA::ArrayPropertyReaderPtr getArrayProperty(const std::string &iName)
Definition CprImpl.cpp:175
virtual const AbcA::PropertyHeader & getPropertyHeader(size_t i)
Definition CprImpl.cpp:132
virtual const AbcA::PropertyHeader & getHeader() const
Definition CprImpl.cpp:96
Alembic namespace ...
Definition ArchiveInfo.cpp:39