Main Page   Namespace List   Class Hierarchy   Alphabetical List   Data Structures   File List   Namespace Members   Data Fields   Globals  

ExManagerId Class Reference

#include <ExManagerId.h>

Inheritance diagram for ExManagerId:

ExManager

Public Methods

void Reset (void)
void Init (void)
void List (void)
ExNihilo::ExId RecordObject (ExCObject &object)
ExNihilo::ExId RecordObject (ExCObject *object)
ExNihilo::ExId GetObjectId (std::string Name, std::string Type)
std::string GetObjectName (ExNihilo::ExId id)
std::string GetObjectType (ExNihilo::ExId id)
ExCAction InputAction (ExCAction Action)

Static Public Methods

ExManagerId * CreateSingleton (void)

Private Methods

std::string GetAviableName (std::string Name, std::string Type, int occu)
 ExManagerId (void)
 ~ExManagerId (void)

Private Attributes

int m_ExIdCounter
std::map< ExNihilo::ExId,
ExNihilo::ExObjectInfo, std::less<
ExNihilo::ExId > > * 
m_MapObjectInfo
std::map< ExNihilo::ExId,
ExNihilo::ExObjectInfo, std::less<
ExNihilo::ExId > >::iterator 
m_ItMapObjectInfo

Static Private Attributes

bool m_flag = false
ExManagerId * m_instance = NULL

Constructor & Destructor Documentation

ExManagerId void    [private]
 

Definition at line 43 of file ExManagerId.cpp.

References ExManagerId(), Guard, and m_ExIdCounter.

Referenced by ExManagerId(), and ~ExManagerId().

00044 {
00045 Guard(ExManagerId::ExManagerId())
00046         m_ExIdCounter=0;
00047 UnGuard
00048 }

~ExManagerId void    [private]
 

Definition at line 50 of file ExManagerId.cpp.

References ExManagerId(), and Guard.

00051 {
00052 Guard(ExManagerId::~ExManagerId())
00053 UnGuard
00054 }


Member Function Documentation

ExManagerId * CreateSingleton void    [static]
 

Definition at line 29 of file ExManagerId.cpp.

References CreateSingleton(), Guard, m_flag, and m_instance.

Referenced by CreateSingleton(), and main().

00029                                              {
00030 Guard(ExManagerId* ExManagerId::CreateSingleton(void))
00031         if(!m_flag)
00032         {
00033                 m_flag = true; // We are creating the error log now, so set flag to true
00034                 m_instance = new ExManagerId; // Create the error log
00035         }else
00036         {
00037                 std::cout<<"Error singleton already created"<<std::endl;
00038         }
00039         return m_instance; 
00040 UnGuard
00041 }

std::string GetAviableName std::string    Name,
std::string    Type,
int    occu
[private]
 

Definition at line 75 of file ExManagerId.cpp.

References GetAviableName(), GetObjectId(), and Guard.

Referenced by GetAviableName(), and RecordObject().

00076 {
00077 Guard(std::string ExManagerId::GetAviableName(std::string Name,std::string Type,int occu))
00078         if(GetObjectId(Name,Type)==-1)//new name
00079         {
00080                 return Name;
00081         }
00082         
00083         //here code to change name
00084         if(occu>0)
00085         {
00086                 Name.erase(Name.end()-1,Name.end());
00087         }
00088         if(occu>10)
00089         {
00090                 Name.erase(Name.end()-1,Name.end());
00091         }
00092         if(occu>100)
00093         {
00094                 Name.erase(Name.end()-1,Name.end());
00095         }
00096         if(occu>1000)
00097         {
00098                 Name.erase(Name.end()-1,Name.end());
00099         }
00100         if(occu>10000)
00101         {
00102                 Name.erase(Name.end()-1,Name.end());
00103         }
00104         char buffer[255];
00105         memset(buffer,0,255);
00106         sprintf(buffer,"%s%d",Name.data(),occu);
00107 
00108         return GetAviableName(buffer,Type,occu+1);
00109         
00110 UnGuard
00111 }

ExNihilo::ExId GetObjectId std::string    Name,
std::string    Type
 

Definition at line 173 of file ExManagerId.cpp.

References GetObjectId(), Guard, m_ItMapObjectInfo, and m_MapObjectInfo.

Referenced by ExManagerTexture::CheckExist(), GetAviableName(), ExManagerObject::GetIterator(), ExManagerObject::GetObject(), GetObjectId(), ExManagerTexture::GetTextureId(), ExManagerObject::Remove(), ExManagerTexture::SetCurrentObject(), and ExManagerObject::SetCurrentObject().

00174 {
00175 Guard(ExNihilo::ExId    ExManagerId::GetObjectId(std::string Name,std::string Type))
00176         for(m_ItMapObjectInfo=m_MapObjectInfo->begin();m_ItMapObjectInfo!=m_MapObjectInfo->end();m_ItMapObjectInfo++)
00177         {
00178                 if(Name==m_ItMapObjectInfo->second.m_Name)//||Type==m_ItMapObjectInfo->second.m_Type)
00179                         return  m_ItMapObjectInfo->second.m_Id;
00180         }
00181         return -1;
00182 UnGuard
00183 }

std::string GetObjectName ExNihilo::ExId    id
 

Definition at line 185 of file ExManagerId.cpp.

References GetObjectName(), Guard, and m_MapObjectInfo.

Referenced by GetObjectName().

00186 {
00187 Guard(std::string               ExManagerId::GetObjectName(ExNihilo::ExId id))
00188         try
00189         {
00190                 return m_MapObjectInfo->find(id)->second.m_Name;        
00191         }
00192         catch(...)
00193         {
00194                 return "NoName";
00195         }
00196 UnGuard
00197 }

std::string GetObjectType ExNihilo::ExId    id
 

Definition at line 199 of file ExManagerId.cpp.

References GetObjectType(), Guard, and m_MapObjectInfo.

Referenced by GetObjectType().

00200 {
00201 Guard(std::string               ExManagerId::GetObjectType(ExNihilo::ExId id))
00202         try
00203         {
00204                 return m_MapObjectInfo->find(id)->second.m_Type;        
00205         }
00206         catch(...)
00207         {
00208                 return "NoName";
00209         }
00210 UnGuard
00211 }

void Init void    [virtual]
 

Reimplemented from ExManager.

Definition at line 68 of file ExManagerId.cpp.

References Guard, Init(), and m_MapObjectInfo.

Referenced by Init(), InitManager(), and Reset().

00069 {
00070 Guard(ExManagerId::Init(void))
00071         m_MapObjectInfo=new std::map<  ExNihilo::ExId   , ExNihilo::ExObjectInfo , std::less <ExNihilo::ExId  >  >;     
00072 UnGuard
00073 }

ExCAction InputAction ExCAction    Action [virtual]
 

Reimplemented from ExManager.

Definition at line 223 of file ExManagerId.cpp.

References Guard, ID_LIST, InputAction(), List(), ExCAction::m_Action, and ExCAction::m_NextAction.

Referenced by InputAction(), and ExManagerCommand::ProcesExCAction().

00224 {
00225 Guard(ExCAction ExManagerId::InputAction(ExCAction Action))
00226         switch(Action.m_Action)
00227         {
00228         case ID_LIST:
00229                 List();
00230                 break;
00231         }
00232         if(Action.m_NextAction){return *Action.m_NextAction;}
00233         else{return NOTHING;}
00234 UnGuard
00235 }

void List void   
 

Definition at line 213 of file ExManagerId.cpp.

References ExManager::Consol, Guard, List(), m_ItMapObjectInfo, and m_MapObjectInfo.

Referenced by InputAction(), and List().

00214 {
00215 Guard(void ExManagerId::List(void))
00216         for(m_ItMapObjectInfo=m_MapObjectInfo->begin();m_ItMapObjectInfo!=m_MapObjectInfo->end();m_ItMapObjectInfo++)
00217         {
00218                 *Consol<<"Id :"<<m_ItMapObjectInfo->second.m_Id<<"  For name:"<<m_ItMapObjectInfo->second.m_Name<<" Type:"<<m_ItMapObjectInfo->second.m_Type<<std::endl;
00219         }       
00220 UnGuard
00221 }

ExNihilo::ExId RecordObject ExCObject   object
 

Definition at line 146 of file ExManagerId.cpp.

References ExManager::Consol, GetAviableName(), ExCObject::GetId(), ExCObject::GetName(), ExCObject::GetType(), Guard, m_ExIdCounter, ExObjectInfo::m_Id, m_MapObjectInfo, ExObjectInfo::m_Name, ExObjectInfo::m_Type, RecordObject(), ExCObject::SetId(), ExCObject::SetName(), and ExCObject::SetType().

00147 {
00148 Guard(ExNihilo::ExId ExManagerId::RecordObject(ExCObject *object))
00149         object->SetId(m_ExIdCounter);m_ExIdCounter++;
00150         std::string name(object->GetType());
00151         if(name.find(" *")<name.length())
00152         {
00153                 name.erase(name.find(" *"),name.length()-name.find(" *"));
00154         }
00155         object->SetName(GetAviableName(object->GetName(),object->GetType(),0));
00156         object->SetType(name);
00157 
00158         ExNihilo::ExObjectInfo Info;
00159         Info.m_Id       = object->GetId();
00160         Info.m_Name     = object->GetName();
00161         Info.m_Type = object->GetType();
00162         
00163         std::pair<ExNihilo::ExId,ExNihilo::ExObjectInfo>  obj;
00164         obj.first=object->GetId();
00165         obj.second=Info;
00166         m_MapObjectInfo->insert(obj);
00167 
00168         *Consol<<"New Id :"<<Info.m_Id<<"  For name:"<<Info.m_Name<<" Type:"<<Info.m_Type<<std::endl;
00169         return Info.m_Id;
00170 UnGuard
00171 }

ExNihilo::ExId RecordObject ExCObject   object
 

Definition at line 113 of file ExManagerId.cpp.

References ExManager::Consol, GetAviableName(), ExCObject::GetId(), ExCObject::GetName(), ExCObject::GetType(), Guard, m_ExIdCounter, ExObjectInfo::m_Id, m_MapObjectInfo, ExObjectInfo::m_Name, ExObjectInfo::m_Type, RecordObject(), ExCObject::SetId(), ExCObject::SetName(), and ExCObject::SetType().

Referenced by ExManagerObject::Add(), ExManagerEntite::Add(), ExManagerEntite::NewObject(), and RecordObject().

00114 {
00115 Guard(ExNihilo::ExId ExManagerId::RecordObject(ExCObject &object))
00116         try
00117         {       
00118                 object.SetId(m_ExIdCounter);m_ExIdCounter++;
00119                 std::string name(object.GetType());
00120                 if(name.find(" *")<name.length())
00121                 {
00122                         name.erase(name.find(" *"),name.length()-name.find(" *"));
00123                 }
00124                 object.SetName(GetAviableName(object.GetName(),object.GetType(),0));
00125                 object.SetType(name);
00126 
00127                 ExNihilo::ExObjectInfo Info;
00128                 Info.m_Id       = object.GetId();
00129                 Info.m_Name     = object.GetName();
00130                 Info.m_Type = object.GetType();
00131                 
00132                 std::pair<ExNihilo::ExId,ExNihilo::ExObjectInfo>  obj;
00133                 obj.first=object.GetId();
00134                 obj.second=Info;
00135                 m_MapObjectInfo->insert(obj);
00136 
00137                 *Consol<<"New Id :"<<Info.m_Id<<"  For name:"<<Info.m_Name<<" Type:"<<Info.m_Type<<std::endl;
00138                 return Info.m_Id;
00139         }catch(...)
00140         {
00141                 throw ExCExpRecordObject();
00142         }
00143 UnGuard
00144 }

void Reset void    [virtual]
 

Reimplemented from ExManager.

Definition at line 58 of file ExManagerId.cpp.

References Guard, Init(), m_ExIdCounter, m_MapObjectInfo, and Reset().

Referenced by ExManagerCommand::ProcesExCAction(), and Reset().

00059 {
00060 Guard(ExManagerId::Reset(void))
00061         m_MapObjectInfo->clear();
00062         delete m_MapObjectInfo;
00063         m_ExIdCounter=0;
00064         Init();
00065 UnGuard
00066 }


Field Documentation

int m_ExIdCounter [private]
 

Definition at line 68 of file ExManagerId.h.

Referenced by ExManagerId(), RecordObject(), and Reset().

bool m_flag = false [static, private]
 

Definition at line 26 of file ExManagerId.cpp.

Referenced by CreateSingleton().

ExManagerId * m_instance = NULL [static, private]
 

Definition at line 27 of file ExManagerId.cpp.

Referenced by CreateSingleton().

std::map< ExNihilo::ExId , ExNihilo::ExObjectInfo , std::less <ExNihilo::ExId > >::iterator m_ItMapObjectInfo [private]
 

Definition at line 71 of file ExManagerId.h.

Referenced by GetObjectId(), and List().

std::map< ExNihilo::ExId , ExNihilo::ExObjectInfo , std::less <ExNihilo::ExId > >* m_MapObjectInfo [private]
 

Definition at line 70 of file ExManagerId.h.

Referenced by GetObjectId(), GetObjectName(), GetObjectType(), Init(), List(), RecordObject(), and Reset().


The documentation for this class was generated from the following files:
Generated on Tue Dec 10 18:20:39 2002 for ExNihilo by doxygen1.3-rc1