My Project
ICConfigManager.h
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2004 - 2006 ParaEngine Dev Studio, All Rights Reserved.
3 // Date: 2006.3
4 // Description: API for configuration manager.
5 //-----------------------------------------------------------------------------
6 #pragma once
7 #include <map>
8 #include <vector>
9 #include <boost/thread/mutex.hpp>
10 #include "util/mutex.h"
11 using namespace std;
12 using namespace ParaEngine;
13 namespace ParaInfoCenter
14 {
15  enum IC_CONFIG_TYPE{
16  IC_CONFIG_INT,IC_CONFIG_FLOAT,IC_CONFIG_TEXT
17  };
22  class PE_CORE_DECL CICConfigItem
23  {
24  public:
25  ~CICConfigItem();
26  friend class CICConfigManager;
27  protected:
28  CICConfigItem(int value);
29  CICConfigItem(double value);
30  CICConfigItem(const char* value);
31  int GetType(){return etype;}
32  void SetValue(const char* value);
33  union{
34  int iData;
35  double fData;
36  char *sData;
37  };
38  int etype;
39  };
41  {
42  public:
43  ~CICConfigItems();
44  std::vector<CICConfigItem*> items;
45  };
63  {
64  public:
67 
69  PE_CORE_DECL static CICConfigManager* GetInstance();
80  PE_CORE_DECL HRESULT LoadFromFile(const char* szFilename=NULL,bool bOverwrite=true);
92  PE_CORE_DECL HRESULT SaveToFile(const char* szFilename=NULL,bool bOverwrite=true);
93 
104  PE_CORE_DECL HRESULT GetSize(const char* szName, DWORD *nSize);
115  PE_CORE_DECL HRESULT GetIntValue(const char* szName,int *value, int index=0);
116 
127  PE_CORE_DECL HRESULT GetDoubleValue(const char* szName,double *value, int index=0);
128 
138  PE_CORE_DECL HRESULT GetTextValue(const char* szName,string &value, int index=0);
139 
153  PE_CORE_DECL HRESULT SetIntValue(const char* szName,int value, int index=0);
154 
165  PE_CORE_DECL HRESULT AppendIntValue(const char* szName,int value);
177  PE_CORE_DECL HRESULT SetDoubleValue(const char* szName,double value, int index=0);
188  PE_CORE_DECL HRESULT AppendDoubleValue(const char* szName,double value);
199  PE_CORE_DECL HRESULT SetTextValue(const char* szName,const char *value, int index=0);
210  PE_CORE_DECL HRESULT AppendTextValue(const char* szName,const char* value);
211 
217  PE_CORE_DECL void Lock();
218 
222  PE_CORE_DECL void UnLock();
223 #ifdef _DEBUG
224  static void test();
225 #endif
226  private:
227  map<string, CICConfigItems*> m_items;
228  bool m_bLocked;
229  bool m_bOverwrite;
230  ParaEngine::mutex m_csLock;
231  ParaEngine::mutex m_csFunc;
232  };
233 }
Definition: ICConfigManager.h:40
Definition: Mutex.h:14
different physics engine has different winding order.
Definition: EventBinding.h:32
The CICConfigManager manages the global configurations of the program.
Definition: ICConfigManager.h:62
Definition: enum_maker.hpp:46
Definition: PEtypes.h:503
This class is not thread-safe.
Definition: ICConfigManager.h:22
cross platform mutex
Definition: mutex.h:95