#include <agent_string.h>
Inheritance diagram for NLAIAGENT::CIndexedVarName:
Nevrax France
Definition at line 261 of file agent_string.h.
Public Member Functions | |
const char * | addString (const IVarName &s) const |
Adding two string. | |
CIndexedVarName (NLMISC::IStream &is) | |
CIndexedVarName (const CIndexedVarName &name) | |
CIndexedVarName (const char *name) | |
const NLAIC::IBasicType * | clone () const |
sint32 | decRef () |
Decrement the reference of an object. | |
void | getDebugString (std::string &text) const |
const sint32 & | getIndex () const |
virtual const std::string | getInfo () |
const sint32 & | getRef () const |
get the refence count. | |
const char * | getString () const |
Get the string stored in the instance. | |
const NLAIC::CIdentType & | getType () const |
void | incRef () |
Inc a reference. We use this when we have to conserve a pointer memeory for exemple in a list. | |
void | load (NLMISC::IStream &is) |
sint32 | newIndex () |
const NLAIC::IBasicType * | newInstance () const |
IVarName & | operator+= (const IVarName &s) |
IVarName & | operator-= (const IVarName &s) |
IVarName & | operator= (const IVarName &v) |
virtual void | release () |
Release allow to release the pointer. The last release when the _Ref is nul delete the object. | |
void | save (NLMISC::IStream &os) |
virtual void | serial (NLMISC::IStream &f) throw (NLMISC::EStream) |
const char * | subString (const IVarName &s) const |
Extract an string from an ather. | |
virtual | ~CIndexedVarName () |
Static Public Member Functions | |
void | initClass () |
void | loadClass (NLMISC::IStream &is) |
void | releaseClass () |
void | saveClass (NLMISC::IStream &is) |
Static Public Attributes | |
const NLAIC::CIdentType | IdIndexedVarName |
Private Types | |
typedef std::map< CStringVarName, CNameStruc * > | TMapName |
Definition of the static std::map. | |
Private Member Functions | |
void | clear () |
Clear string from map. | |
void | insert (const CStringVarName &name) |
Insert new string. | |
Private Attributes | |
sint32 | _Index |
the index of the declared string in the table. | |
Static Private Attributes | |
const sint32 | _Bank = 256 |
sint32 | _Count = 0 |
Number of string allocated. This is the table size. | |
std::list< CNameStruc * > * | _Empty = new std::list<CIndexedVarName::CNameStruc *> |
TMapName * | _Map = new CIndexedVarName::TMapName |
Static std::map for storing string. | |
CNameStruc * | _TableName = NULL |
Table of string, this the contents of the map. |
|
Definition of the static std::map.
Definition at line 310 of file agent_string.h. Referenced by initClass(). |
|
Definition at line 152 of file agent_string.cpp. References insert(). Referenced by clone(), and newInstance().
00153 { 00154 insert(CStringVarName(name)); 00155 } |
|
Definition at line 157 of file agent_string.cpp. References _Index, _TableName, and getIndex().
00158 { 00159 TMapName::iterator i = _Map->find(*_TableName[name.getIndex()].Name); 00160 if(i != _Map->end()) 00161 { 00162 _Index = name.getIndex(); 00163 (*i).second->Count ++; 00164 } 00165 else 00166 { 00167 _Index = -1; 00168 throw NLAIE::CExceptionIndexError(); 00169 } 00170 00171 } |
|
Definition at line 173 of file agent_string.cpp. References insert().
00174 { 00175 CStringVarName str(is); 00176 insert(str); 00177 } |
|
Definition at line 179 of file agent_string.cpp. References clear().
00180 { 00181 clear(); 00182 } |
|
Adding two string.
Definition at line 80 of file agent_string.h. References NLAIAGENT::IVarName::getString(), and s. Referenced by NLAIAGENT::CStringVarName::operator+=(), and operator+=().
|
|
Clear string from map.
Definition at line 190 of file agent_string.cpp. References _Index, _TableName, NLAIAGENT::CIndexedVarName::CNameStruc::Count, and NLAIAGENT::CIndexedVarName::CNameStruc::Name. Referenced by load(), and ~CIndexedVarName().
00191 { 00192 if(_TableName && !(--_TableName[_Index].Count) ) 00193 { 00194 TMapName::iterator i = _Map->find(*_TableName[_Index].Name); 00195 if(i != _Map->end()) 00196 { 00197 _Map->erase(i); 00198 delete _TableName[_Index].Name; 00199 _TableName[_Index].Name = NULL; 00200 _Empty->push_back(&_TableName[_Index]); 00201 } 00202 } 00203 } |
|
This function allow a pointer copy, that mean that the new class have the sam attributs caracteristics as the owne. Implements NLAIC::IBasicType. Definition at line 280 of file agent_string.cpp. References CIndexedVarName(), and x.
00281 { 00282 NLAIC::IBasicInterface *x = new CIndexedVarName(*this); 00283 return x; 00284 } |
|
Decrement the reference of an object.
Definition at line 93 of file abstract_interface.h. References NLAIC::IPointerGestion::_Ref, and sint32. Referenced by NLAIC::IPointerGestion::release(), and NLAIAGENT::CAgentTimerHandle::~CAgentTimerHandle().
00094 {
00095 return --_Ref;
00096 }
|
|
Implements NLMISC::IClassable. Reimplemented in NLAIC::CIdentType. Definition at line 116 of file abstract_interface.h. Referenced by NLAISCRIPT::CAgentClass::isClassInheritedFrom().
00117 { 00118 return std::string("<unnamed>"); 00119 } |
|
This is a Debug function, text is an character pointer to receive the debug text output, the debug text containe all think sensible to interset user. Implements NLAIC::IBasicType. Definition at line 292 of file agent_string.cpp.
00293 { 00294 00295 } |
|
Definition at line 347 of file agent_string.h. References _Index, and sint32. Referenced by CIndexedVarName(), and save().
00348 { 00349 return _Index; 00350 } |
|
Definition at line 292 of file abstract_interface.h. References NLAIC::IBasicType::getDebugString(), and s.
00293 { 00294 std::string s; 00295 getDebugString(s); 00296 return s; 00297 } |
|
get the refence count.
Definition at line 99 of file abstract_interface.h. References NLAIC::IPointerGestion::_Ref, and sint32. Referenced by NLAIAGENT::CAgentTimerHandle::~CAgentTimerHandle().
00100 {
00101 return _Ref;
00102 }
|
|
Get the string stored in the instance.
Implements NLAIAGENT::IVarName. Definition at line 297 of file agent_string.cpp. References _Index, and _TableName.
00298 { 00299 return (*(_TableName + _Index)).Name->getString(); 00300 //return _TableName[_Index].Name->getString(); 00301 } |
|
getType return a unique string how represente the class, it can be the name of the class. This function is used for the sytem regstry class (see the definition of the template class Gen::CRegistry). Implements NLAIC::IBasicType. Definition at line 33 of file agent_string.cpp. References IdIndexedVarName.
00034 { 00035 00036 return IdIndexedVarName; 00037 } |
|
|
Definition at line 39 of file agent_string.cpp. References _Count, _TableName, NLAIAGENT::CIndexedVarName::CNameStruc::Count, NLAIAGENT::CIndexedVarName::CNameStruc::Index, NLAIAGENT::CIndexedVarName::CNameStruc::Name, sint32, and TMapName.
00040 { 00041 if(_Empty == NULL) 00042 { 00043 _Empty = new std::list<CIndexedVarName::CNameStruc *>; 00044 00045 } 00046 00047 if(_Map == NULL) 00048 { 00049 _Map = new CIndexedVarName::TMapName; 00050 } 00051 00052 if(_TableName != NULL) 00053 { 00054 _Map->clear(); 00055 for(sint32 i =0; i < _Count; i++) 00056 { 00057 if(_TableName[i].Name != NULL) delete _TableName[i].Name; 00058 } 00059 delete [] _TableName; 00060 } 00061 _TableName = new CNameStruc [_Bank]; 00062 _Count = _Bank; 00063 00064 for(sint32 i = 0; i < _Count; i++) 00065 { 00066 _TableName[i].Name = NULL; 00067 _TableName[i].Count = 0; 00068 _TableName[i].Index = i; 00069 _Empty->push_back(&_TableName[i]); 00070 } 00071 00072 } |
|
Insert new string.
Definition at line 206 of file agent_string.cpp. References _Index, _TableName, NLAIAGENT::CStringVarName::clone(), NLAIAGENT::CIndexedVarName::CNameStruc::Name, and newIndex(). Referenced by CIndexedVarName(), load(), operator+=(), operator-=(), and operator=().
00207 { 00208 TMapName::iterator i = _Map->find(str); 00209 if(i != _Map->end()) 00210 { 00211 _Index = (*i).second->Index; 00212 (*i).second->Count ++; 00213 } 00214 else 00215 { 00216 _Index = newIndex(); 00217 _TableName[_Index].Name = (CStringVarName *)str.clone(); 00218 _Map->insert(TMapName::value_type(*_TableName[_Index].Name, &_TableName[_Index])); 00219 } 00220 } |
|
Load the class from a stream. Implements NLAIC::IBasicInterface. Definition at line 273 of file agent_string.cpp. References clear(), and insert().
|
|
Definition at line 95 of file agent_string.cpp. References _Count, _TableName, NLAIAGENT::CIndexedVarName::CNameStruc::Count, NLAIAGENT::CIndexedVarName::CNameStruc::Index, NLAIAGENT::CIndexedVarName::CNameStruc::load(), NLAIAGENT::CIndexedVarName::CNameStruc::Name, releaseClass(), NLMISC::IStream::serial(), and sint32.
00096 { 00097 sint32 i; 00098 is.serial( i ); 00099 if(i != 0) 00100 { 00101 releaseClass(); 00102 _TableName = new CNameStruc [i]; 00103 _Count = i; 00104 sint32 k; 00105 for(i = 0;i < _Count;i ++) 00106 { 00107 is.serial( k ); 00108 if(k) 00109 { 00110 _TableName[i].load(is); 00111 _Map->insert(TMapName::value_type(*_TableName[i].Name, &_TableName[i])); 00112 } 00113 else 00114 { 00115 _TableName[i].Count = 0; 00116 _TableName[i].Index = i; 00117 _TableName[i].Name = NULL; 00118 _Empty->push_back(&_TableName[i]); 00119 } 00120 } 00121 } 00122 00123 } |
|
Definition at line 239 of file agent_string.cpp. References _Count, _TableName, NLAIAGENT::CIndexedVarName::CNameStruc::Count, NLAIAGENT::CIndexedVarName::CNameStruc::Index, NLAIAGENT::CIndexedVarName::CNameStruc::Name, and sint32. Referenced by insert().
00240 { 00241 00242 if(_Empty->size()) 00243 { 00244 CNameStruc *o = _Empty->front(); 00245 _Empty->pop_front(); 00246 o->Count++; 00247 return o->Index; 00248 } 00249 else 00250 { 00251 CNameStruc *tmp = _TableName; 00252 _TableName = new CNameStruc [_Count + _Bank]; 00253 00254 for(sint32 i = _Count; i < (_Count + _Bank); i++) 00255 { 00256 _TableName[i].Count = 0; 00257 _TableName[i].Index = i; 00258 _TableName[i].Name = NULL; 00259 _Empty->push_back(&_TableName[i]); 00260 } 00261 00262 memcpy(_TableName, tmp, _Count*sizeof(CNameStruc)); 00263 _Count += _Bank; 00264 return newIndex(); 00265 } 00266 } |
|
This function allow a new instance, that mean that the class is a class factory. Implements NLAIC::IBasicType. Definition at line 286 of file agent_string.cpp. References CIndexedVarName(), and x.
00287 { 00288 NLAIC::IBasicInterface *x = new CIndexedVarName("Inst"); 00289 return x; 00290 } |
|
Implements NLAIAGENT::IVarName. Definition at line 224 of file agent_string.cpp. References NLAIAGENT::IVarName::addString(), insert(), and s.
|
|
Implements NLAIAGENT::IVarName. Definition at line 231 of file agent_string.cpp. References insert(), s, and NLAIAGENT::IVarName::subString().
|
|
Definition at line 52 of file agent_string.h. References NLAIAGENT::IVarName::getString(), and v.
|
|
Implements NLAIAGENT::IVarName. Definition at line 184 of file agent_string.cpp.
|
|
Definition at line 69 of file agent_string.h. References NLAIAGENT::IVarName::getString(), and v.
|
|
Definition at line 60 of file agent_string.h. References NLAIAGENT::IVarName::getString(), and v.
|
|
|
Definition at line 125 of file agent_string.cpp. References _Count, _TableName, NLAIAGENT::CIndexedVarName::CNameStruc::Name, and sint32. Referenced by loadClass(), and NLAILINK::releaseIALib().
00126 { 00127 return; 00128 00129 if(_TableName != NULL) 00130 { 00131 _Map->clear(); 00132 _Empty->clear(); 00133 for(sint32 i =0; i < _Count; i++) 00134 { 00135 if(_TableName[i].Name != NULL) delete _TableName[i].Name; 00136 } 00137 delete [] _TableName; 00138 _TableName = NULL; 00139 } 00140 if(_Empty != NULL) 00141 { 00142 delete _Empty; 00143 _Empty = NULL; 00144 } 00145 if(_Map != NULL) 00146 { 00147 delete _Map; 00148 _Map = NULL; 00149 } 00150 } |
|
Save the class in a stream. Implements NLAIC::IBasicInterface. Definition at line 268 of file agent_string.cpp. References _TableName, getIndex(), and NLMISC::IStream::serial().
|
|
Definition at line 74 of file agent_string.cpp. References _Count, _TableName, count, NLAIAGENT::CIndexedVarName::CNameStruc::Name, s, NLAIAGENT::CIndexedVarName::CNameStruc::save(), NLMISC::IStream::serial(), and sint32.
00075 { 00076 sint32 count = (sint32) _Count; 00077 os.serial( count ); 00078 for(sint32 i = 0; i < count; i++) 00079 { 00080 if(_TableName[i].Name != NULL) 00081 { 00082 sint32 s = 1; 00083 os.serial( s ); 00084 _TableName[i].save(os); 00085 } 00086 else 00087 { 00088 sint32 s = 0; 00089 os.serial( s ); 00090 } 00091 } 00092 00093 } |
|
Reimplemented from NLAIC::IPointerGestion. Definition at line 328 of file abstract_interface.h. References NLAIC::IBasicInterface::load(), and NLAIC::IBasicInterface::save().
|
|
Extract an string from an ather.
Definition at line 90 of file agent_string.h. References NLAIAGENT::IVarName::getString(), s, and sint32. Referenced by NLAIAGENT::CStringVarName::operator-=(), and operator-=().
00091 { 00092 char *nameTmp,*str = (char *)s.getString(); 00093 nameTmp = (char *)getString(); 00094 00095 sint32 k = strlen(nameTmp); 00096 00097 for(sint32 i = 0; i < k; i ++) 00098 { 00099 if(!strcmp(&nameTmp[i],str)) 00100 { 00101 sint32 l,n = strlen(str); 00102 char *name = new char [(l = (k - n + 1))]; 00103 memcpy(name,nameTmp,i); 00104 memcpy(&name[i],nameTmp + n,l); 00105 return name; 00106 } 00107 } 00108 return NULL; 00109 } |
|
Actual nomber of allocation resolution in the Table. Note that when we superseded table resolution we realloc a new table with the old size add by _Bank. Definition at line 57 of file static_def_init.cpp. |
|
Number of string allocated. This is the table size.
Definition at line 58 of file static_def_init.cpp. Referenced by initClass(), loadClass(), newIndex(), releaseClass(), and saveClass(). |
|
Number of cell free in the table, not that this is very usefull because thy prevent us to realloc all time a new table. Definition at line 61 of file static_def_init.cpp. |
|
the index of the declared string in the table.
Definition at line 333 of file agent_string.h. Referenced by CIndexedVarName(), clear(), getIndex(), getString(), and insert(). |
|
Static std::map for storing string.
Definition at line 60 of file static_def_init.cpp. |
|
Table of string, this the contents of the map.
Definition at line 56 of file static_def_init.cpp. Referenced by CIndexedVarName(), clear(), getString(), initClass(), insert(), loadClass(), newIndex(), releaseClass(), save(), and saveClass(). |
|
Referenced by getType(). |