My Project
AttributeProvider.h
1 #pragma once
2 #include "ic/ParaDatabase.h"
3 #include "IAttributeFields.h"
4 #include <vector>
5 #include <string>
6 namespace ParaEngine
7 {
8  using namespace std;
12  {
13  string m_sName;
14  //string m_sInstanceName;
15  int m_nType;
16  string m_sValue;
17  string m_sDescription;
18  string m_sSchematics;
19  CAttributeDbItem():m_nType(0){};
20  };
21 
33  {
34  public:
35  AttributeProvider(void);
36  ~AttributeProvider(void);
37  public:
39  // common function
40 
42  bool IsValid() {return m_pDataBase.get() !=0;};
43 
45  void Cleanup();
47  DBEntity* GetDBEntity(){return m_pDataBase.get();};
52  void SetDBEntity(const string& sConnectionstring);
53 
55  void ValidateDatabase();
56 
57 #ifdef _DEBUG
58 
59  void TestDB();
60 #endif
61 
62  public:
64  // query functions
65 
72  bool SaveAttributeObject(const char* sTableName, IAttributeFields* pAttributeObject);
73 
80  bool LoadAttributeObject(const char* sTableName, IAttributeFields* pAttributeObject);
81 
86  void SetTableName(const char* sName);
87 
92  const string& GetTableName(){return m_sCurrentTableName;};
93 
99  bool ResetTable(const char* sName);
100 
106  //void SetObjectName(const char* sName) { m_sObjectName = sName;}
107  //const string& GetObjectName() { return m_sObjectName;}
108 
115  bool DoesAttributeExists(const char* sName);
116 
123  bool GetAttribute(const char* sName, string& sOut);
124 
132  bool GetAttribute(CAttributeDbItem& inout);
133 
139  bool InsertAttribute(CAttributeDbItem& sIn);
140 
147  bool InsertAttribute(const char* sName, const char* sValue);
148 
156  bool UpdateAttribute(const char* sName, const char* sIn);
157 
163  bool DeleteAttribute(const char* sName);
164 
168  bool CreateTableIfNotExists();
169 
170  private:
172  ParaEngine::asset_ptr<DBEntity> m_pDataBase;
173  CDBRecordSet* m_pProcSelectAttribute;
174  CDBRecordSet* m_pProcAttributeExists;
175  CDBRecordSet* m_pProcUpdateAttribute;
176  CDBRecordSet* m_pProcInsertAttribute;
177  CDBRecordSet* m_pProcDeleteAttribute;
178 
182  void ReleaseStoredProcedures();
184  string m_sCurrentTableName;
187  //string m_sObjectName;
188  };
189 }
const string & GetTableName()
current attribute table name
Definition: AttributeProvider.h:92
different physics engine has different winding order.
Definition: EventBinding.h:32
DBEntity * GetDBEntity()
get the database object associated with this provider
Definition: AttributeProvider.h:47
a database record in attribute db
Definition: AttributeProvider.h:11
A common interface for all classes implementing IAttributeFields By implementing this class&#39;s virtual...
Definition: IAttributeFields.h:59
Attribute fields data provider: it is a group of attribute stored in {name, value} value pair fasion ...
Definition: AttributeProvider.h:32
a single database file.
Definition: ICDBManager.h:39
bool IsValid()
whether db is opened.
Definition: AttributeProvider.h:42
CICRecordSet is both the result and wrapper of a sql statement(procedure).
Definition: ICRecordSet.h:90