HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ArraySampleKey.h
Go to the documentation of this file.
1 //-*****************************************************************************
2 //
3 // Copyright (c) 2009-2012,
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_ArraySampleKey_h_
38 #define _Alembic_AbcCoreAbstract_ArraySampleKey_h_
39 
42 
43 namespace Alembic {
44 namespace AbcCoreAbstract {
45 namespace ALEMBIC_VERSION_NS {
46 
47 struct ArraySampleKey : public Alembic::Util::totally_ordered<ArraySampleKey>
48 {
49  //! total number of bytes of the sample as originally stored
50  uint64_t numBytes;
51 
52  //! Original POD as stored
54 
55  //! POD used at read time
57 
58  Digest digest;
59 
60  bool operator==( const ArraySampleKey &iRhs ) const
61  {
62  return ( ( numBytes == iRhs.numBytes ) &&
63  ( origPOD == iRhs.origPOD ) &&
64  ( readPOD == iRhs.readPOD ) &&
65  ( digest == iRhs.digest ) );
66  };
67 
68  bool operator<( const ArraySampleKey &iRhs ) const
69  {
70  return ( numBytes < iRhs.numBytes ? true :
71  ( numBytes > iRhs.numBytes ? false :
72 
73  ( origPOD < iRhs.origPOD ? true :
74  ( origPOD > iRhs.origPOD ? false :
75 
76  ( readPOD < iRhs.readPOD ? true :
77  ( readPOD > iRhs.readPOD ? false :
78 
79  ( digest < iRhs.digest ) ) ) ) ) ) );
80  };
81 
82 };
83 
84 //-*****************************************************************************
85 // Equality operator.
87  public std::binary_function<ArraySampleKey,ArraySampleKey,bool>
88 {
89  bool operator()( ArraySampleKey const &a,
90  ArraySampleKey const &b ) const
91  {
92  return a == b;
93  }
94 };
95 
96 //-*****************************************************************************
97 // Hash function
98 inline size_t StdHash( ArraySampleKey const &a )
99 {
100  // Theoretically, the bits of our hash are uniformly
101  // randomly distributed, so it doesn't matter which of the 128
102  // bits we use to generate the 64 bits that we return as the hash
103  // key. So, I'll just do the simple thing.
104  return *(( const size_t * )&a.digest);
105 }
106 
107 //-*****************************************************************************
109  public std::unary_function<ArraySampleKey,size_t>
110 {
111  size_t operator()( ArraySampleKey const &a ) const
112  {
113  return StdHash( a );
114  }
115 };
116 
117 //-*****************************************************************************
118 template <class MAPPED>
120 {
121  typedef Alembic::Util::unordered_map<ArraySampleKey,
122  MAPPED,
125 };
126 
127 } // End namespace ALEMBIC_VERSION_NS
128 
129 using namespace ALEMBIC_VERSION_NS;
130 
131 } // End namespace AbcCoreAbstract
132 } // End namespace Alembic
133 
134 #endif
bool operator==(const ArraySampleKey &iRhs) const
uint64_t numBytes
total number of bytes of the sample as originally stored
PlainOldDataType origPOD
Original POD as stored.
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1221
bool operator<(const ArraySampleKey &iRhs) const
bool operator()(ArraySampleKey const &a, ArraySampleKey const &b) const
Alembic::Util::unordered_map< ArraySampleKey, MAPPED, ArraySampleKeyStdHash, ArraySampleKeyEqualTo > umap_type
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
size_t StdHash(ArraySampleKey const &a)
PlainOldDataType readPOD
POD used at read time.
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:104