Bullet Collision Detection & Physics Library
bDNA.h
Go to the documentation of this file.
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 
20 #include "bCommon.h"
21 
22 namespace bParse {
23 
24  struct bNameInfo
25  {
26  char* m_name;
28  int m_dim0;
29  int m_dim1;
30  };
31 
32  class bDNA
33  {
34  public:
35  bDNA();
36  ~bDNA();
37 
38  void init(char *data, int len, bool swap=false);
39 
40  int getArraySize(char* str);
41  int getArraySizeNew(short name)
42  {
43  const bNameInfo& nameInfo = m_Names[name];
44  return nameInfo.m_dim0*nameInfo.m_dim1;
45  }
46  int getElementSize(short type, short name)
47  {
48  const bNameInfo& nameInfo = m_Names[name];
49  int size = nameInfo.m_isPointer ? mPtrLen*nameInfo.m_dim0*nameInfo.m_dim1 : mTlens[type]*nameInfo.m_dim0*nameInfo.m_dim1;
50  return size;
51  }
52 
53  int getNumNames() const
54  {
55  return m_Names.size();
56  }
57 
58  char *getName(int ind);
59  char *getType(int ind);
60  short *getStruct(int ind);
61  short getLength(int ind);
62  int getReverseType(short type);
63  int getReverseType(const char *type);
64 
65 
66  int getNumStructs();
67 
68  //
69  bool lessThan(bDNA* other);
70 
71  void initCmpFlags(bDNA *memDNA);
72  bool flagNotEqual(int dna_nr);
73  bool flagEqual(int dna_nr);
74  bool flagNone(int dna_nr);
75 
76 
77  int getPointerSize();
78 
79  void dumpTypeDefinitions();
80 
81 
82  private:
84  {
88  };
89 
90  void initRecurseCmpFlags(int i);
91 
93 
100 
101  int mPtrLen;
102 
103 
104 
105 
106  };
107 }
108 
109 
110 #endif//__BDNA_H__
btAlignedObjectArray< int > mCMPFlags
Definition: bDNA.h:92
int getArraySizeNew(short name)
Definition: bDNA.h:41
int mPtrLen
Definition: bDNA.h:101
btAlignedObjectArray< short * > mStructs
Definition: bDNA.h:96
bool lessThan(bDNA *other)
Definition: bDNA.cpp:44
int getNumStructs()
Definition: bDNA.cpp:105
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
char * getName(int ind)
Definition: bDNA.cpp:50
void dumpTypeDefinitions()
Definition: bDNA.cpp:546
bool m_isPointer
Definition: bDNA.h:27
int getNumNames() const
Definition: bDNA.h:53
void initCmpFlags(bDNA *memDNA)
Definition: bDNA.cpp:172
btAlignedObjectArray< short > mTlens
Definition: bDNA.h:97
btAlignedObjectArray< bNameInfo > m_Names
Definition: bDNA.h:94
btHashMap< btHashInt, int > mStructReverse
Definition: bDNA.h:98
int getPointerSize()
Definition: bDNA.cpp:133
char * m_name
Definition: bDNA.h:26
int getArraySize(char *str)
Definition: bDNA.cpp:523
bool flagNotEqual(int dna_nr)
Definition: bDNA.cpp:111
FileDNAFlags
Definition: bDNA.h:83
short * getStruct(int ind)
Definition: bDNA.cpp:66
void init(char *data, int len, bool swap=false)
Definition: bDNA.cpp:348
bool flagEqual(int dna_nr)
Definition: bDNA.cpp:118
int getElementSize(short type, short name)
Definition: bDNA.h:46
void initRecurseCmpFlags(int i)
Definition: bDNA.cpp:139
btAlignedObjectArray< char * > mTypes
Definition: bDNA.h:95
btHashMap< btHashString, int > mTypeLookup
Definition: bDNA.h:99
int getReverseType(short type)
Definition: bDNA.cpp:82
short getLength(int ind)
Definition: bDNA.cpp:74
bool flagNone(int dna_nr)
Definition: bDNA.cpp:126
char * getType(int ind)
Definition: bDNA.cpp:58