[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-physics / third-party / bullet3 / src / Bullet3Serialize / Bullet2FileLoader / b3DNA.h
1 /*
2 bParse
3 Copyright (c) 2006-2009 Charlie C & Erwin Coumans  http://gamekit.googlecode.com
4
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15
16 #ifndef __BDNA_H__
17 #define __BDNA_H__
18
19 #include "b3Common.h"
20
21 namespace bParse
22 {
23 struct bNameInfo
24 {
25         char *m_name;
26         bool m_isPointer;
27         int m_dim0;
28         int m_dim1;
29 };
30
31 class bDNA
32 {
33 public:
34         bDNA();
35         ~bDNA();
36
37         void init(char *data, int len, bool swap = false);
38
39         int getArraySize(char *str);
40         int getArraySizeNew(short name)
41         {
42                 const bNameInfo &nameInfo = m_Names[name];
43                 return nameInfo.m_dim0 * nameInfo.m_dim1;
44         }
45         int getElementSize(short type, short name)
46         {
47                 const bNameInfo &nameInfo = m_Names[name];
48                 int size = nameInfo.m_isPointer ? mPtrLen * nameInfo.m_dim0 * nameInfo.m_dim1 : mTlens[type] * nameInfo.m_dim0 * nameInfo.m_dim1;
49                 return size;
50         }
51
52         int getNumNames() const
53         {
54                 return m_Names.size();
55         }
56
57         char *getName(int ind);
58         char *getType(int ind);
59         short *getStruct(int ind);
60         short getLength(int ind);
61         int getReverseType(short type);
62         int getReverseType(const char *type);
63
64         int getNumStructs();
65
66         //
67         bool lessThan(bDNA *other);
68
69         void initCmpFlags(bDNA *memDNA);
70         bool flagNotEqual(int dna_nr);
71         bool flagEqual(int dna_nr);
72         bool flagNone(int dna_nr);
73
74         int getPointerSize();
75
76         void dumpTypeDefinitions();
77
78 private:
79         enum FileDNAFlags
80         {
81                 FDF_NONE = 0,
82                 FDF_STRUCT_NEQU,
83                 FDF_STRUCT_EQU
84         };
85
86         void initRecurseCmpFlags(int i);
87
88         b3AlignedObjectArray<int> mCMPFlags;
89
90         b3AlignedObjectArray<bNameInfo> m_Names;
91         b3AlignedObjectArray<char *> mTypes;
92         b3AlignedObjectArray<short *> mStructs;
93         b3AlignedObjectArray<short> mTlens;
94         b3HashMap<b3HashInt, int> mStructReverse;
95         b3HashMap<b3HashString, int> mTypeLookup;
96
97         int mPtrLen;
98 };
99 }  // namespace bParse
100
101 #endif  //__BDNA_H__