![]() |
|
|
Generated: 18 Jul 2008 |
#include <KeyedObjectManager.h>
Collaboration diagram for Containers::KeyedObjectManager< SETUP >:

This class is instantiated for two container types: map and hashmap. Other typeas are possible, but currently not supported. Other implementations may be achieved by specializing the SETUP class.
As an example below the specialization for a vector like implementation is shown.
Definition at line 46 of file KeyedObjectManager.h.
Public Member Functions | |
| KeyedObjectManager () | |
| Standard Constructor. | |
| virtual | ~KeyedObjectManager () |
| Standard Destructor. | |
| void | clearDirect () |
| Clear all direct access fields. | |
| long | insertDirect (ObjectContainerBase *b, ContainedObject *c, void *o, long k) |
| Insert element into direct access map. | |
| long | isDirect () const |
| Check if the container is dirty. | |
| void * | object (long key) const |
| Retrieve object identified by a key from the container. | |
| long | insert (ObjectContainerBase *b, ContainedObject *c, void *o, long *k) |
| Insert new object into container. | |
| long | insert (ObjectContainerBase *b, ContainedObject *c, void *o, long k) |
| Insert new object into container. | |
| void * | erase (long key, const void *obj) |
| Remove object from container (very inefficient if key is invalid). | |
| long | erase (seq_type::iterator beg, seq_type::iterator end) |
| Remove object by sequential iterators. | |
| void | reserve (long size) |
| Reserve buffer space. | |
| void | clear () |
| Clear content of the vector. | |
| void | setup (void *seq, void **rndm) |
| Setup of the Map and the parent object. | |
| template<> | |
| const CLID | classID () |
| template<> | |
| const CLID | classID () |
| template<> | |
| void * | object (long value) const |
| template<> | |
| void | onDirty () const |
| template<> | |
| long | insert (ObjectContainerBase *b, ContainedObject *c, void *o, long *k) |
| template<> | |
| long | insert (ObjectContainerBase *b, ContainedObject *c, void *o, long k) |
| template<> | |
| long | insertDirect (ObjectContainerBase *b, ContainedObject *c, void *o, long k) |
| template<> | |
| void | clearDirect () |
| template<> | |
| void * | erase (long key, const void *obj) |
| template<> | |
| long | erase (seq_type::iterator beg, seq_type::iterator end) |
| template<> | |
| const CLID | classID () |
| template<> | |
| void * | object (long) const |
| template<> | |
| void | onDirty () const |
| template<> | |
| long | insert (ObjectContainerBase *b, ContainedObject *c, void *o, long *k) |
| template<> | |
| long | insert (ObjectContainerBase *b, ContainedObject *c, void *o, long k) |
| template<> | |
| long | insertDirect (ObjectContainerBase *b, ContainedObject *c, void *o, long k) |
| template<> | |
| void | clearDirect () |
| template<> | |
| void * | erase (long, const void *) |
| template<> | |
| long | erase (seq_type::iterator beg, seq_type::iterator end) |
| template<> | |
| const CLID | classID () |
Static Public Member Functions | |
| static const CLID | classID () |
| Access CLID for this type of container. | |
Private Types | |
| typedef std::vector< void * > | seq_type |
Private Member Functions | |
| void | onDirty () const |
| Callbck when the container becomes dirty. | |
Private Attributes | |
| seq_type * | m_seq |
| Container holding array like container. | |
| long | m_direct |
| Dirty flag. | |
| long | m_keyCtxt |
| union { | |
| char buffer [128] | |
| Buffer space to hold keyed container. | |
| SETUP * s | |
| } | m_setup |
typedef std::vector<void*> Containers::KeyedObjectManager< SETUP >::seq_type [private] |
Definition at line 48 of file KeyedObjectManager.h.
| Containers::KeyedObjectManager< T >::KeyedObjectManager | ( | ) |
Standard Constructor.
Definition at line 91 of file KeyedObjectManager.cpp.
References Containers::KeyedObjectManager< SETUP >::m_keyCtxt, and Containers::KeyedObjectManager< SETUP >::m_setup.
00092 : m_direct(0) 00093 { 00094 if ( sizeof(typename T::map_type) > sizeof(m_setup.buffer) ) { 00095 throw GaudiException("Basic STL contaier sizes are incompatible", 00096 "KeyedContainer", 00097 0); 00098 } 00099 m_setup.s = ::new(m_setup.buffer+sizeof(m_setup.s)) T(); 00100 m_keyCtxt = -1; 00101 }
| Containers::KeyedObjectManager< T >::~KeyedObjectManager | ( | ) | [virtual] |
Standard Destructor.
Definition at line 104 of file KeyedObjectManager.cpp.
References Containers::KeyedObjectManager< SETUP >::m_setup.
00105 { 00106 m_setup.s->~T(); 00107 }
| void Containers::KeyedObjectManager< T >::onDirty | ( | ) | const [private] |
Callbck when the container becomes dirty.
Definition at line 118 of file KeyedObjectManager.cpp.
References Containers::KeyedObjectManager< SETUP >::m_direct, and Containers::KeyedObjectManager< SETUP >::m_setup.
Referenced by Containers::KeyedObjectManager< SETUP >::erase(), Containers::KeyedObjectManager< SETUP >::insert(), Containers::KeyedObjectManager< SETUP >::insertDirect(), and Containers::KeyedObjectManager< SETUP >::object().
00118 { 00119 m_direct = 1; 00120 for(int i = 0, stop = m_setup.s->v.size(); i < stop; i++ ) { 00121 m_setup.s->insert(*(m_setup.s->v.begin()+i), i); 00122 } 00123 m_setup.s->v.clear(); 00124 }
| void Containers::KeyedObjectManager< T >::clearDirect | ( | ) |
Clear all direct access fields.
Definition at line 272 of file KeyedObjectManager.cpp.
References Containers::KeyedObjectManager< SETUP >::m_direct, Containers::KeyedObjectManager< SETUP >::m_keyCtxt, and Containers::KeyedObjectManager< SETUP >::m_setup.
Referenced by Containers::KeyedObjectManager< SETUP >::clear().
00273 { 00274 typedef typename T::map_type MTYP; 00275 switch( m_direct ) { 00276 case 1: 00277 m_setup.s->m.clear(); 00278 break; 00279 case 0: 00280 m_setup.s->v.clear(); 00281 break; 00282 default: 00283 break; 00284 } 00285 m_direct = 0; 00286 m_keyCtxt = -1; 00287 }
| long Containers::KeyedObjectManager< T >::insertDirect | ( | ObjectContainerBase * | b, | |
| ContainedObject * | c, | |||
| void * | o, | |||
| long | k | |||
| ) |
Insert element into direct access map.
Keep major key value
Definition at line 176 of file KeyedObjectManager.cpp.
References Containers::cannotInsertToContainer(), Containers::KeyedObjectManager< SETUP >::m_direct, Containers::KeyedObjectManager< SETUP >::m_keyCtxt, Containers::KeyedObjectManager< SETUP >::m_setup, Containers::OBJ_CANNOT_INSERT, Containers::OBJ_INSERTED, Containers::KeyedObjectManager< SETUP >::onDirty(), ContainedObject::parent(), and ContainedObject::setParent().
Referenced by Containers::KeyedObjectManager< SETUP >::insertDirect().
00181 { 00183 if ( key > m_keyCtxt ) { 00184 m_keyCtxt = key; 00185 } 00186 if ( 1==m_direct ) { 00187 if ( m_setup.s->insert(obj, key) ) { 00188 if ( !pObject->parent() ) { 00189 pObject->setParent(pBase); 00190 } 00191 return OBJ_INSERTED; 00192 } 00193 } 00194 else if ( key == long(m_setup.s->v.size()) ) { 00195 m_setup.s->v.push_back(obj); 00196 if ( !pObject->parent() ) { 00197 pObject->setParent(pBase); 00198 } 00199 return OBJ_INSERTED; 00200 } 00201 else { 00202 // Document is dirty now... 00203 // need to copy all pointers from the vector to the map 00204 onDirty(); 00205 return insertDirect(pBase, pObject, obj, key); 00206 } 00207 cannotInsertToContainer(); 00208 return OBJ_CANNOT_INSERT; 00209 }
| long Containers::KeyedObjectManager< SETUP >::isDirect | ( | ) | const [inline] |
Check if the container is dirty.
Definition at line 73 of file KeyedObjectManager.h.
References Containers::KeyedObjectManager< SETUP >::m_direct.
00073 { return m_direct; }
| void * Containers::KeyedObjectManager< T >::object | ( | long | key | ) | const |
Retrieve object identified by a key from the container.
Definition at line 237 of file KeyedObjectManager.cpp.
References Containers::KeyedObjectManager< SETUP >::m_direct, Containers::KeyedObjectManager< SETUP >::m_setup, and Containers::KeyedObjectManager< SETUP >::onDirty().
00238 { 00239 if ( 0 == m_direct ) { 00240 onDirty(); 00241 } 00242 typename T::map_type::const_iterator i = m_setup.s->m.find(key); 00243 if ( i != m_setup.s->m.end() ) { 00244 return (*i).second; 00245 } 00246 return 0; 00247 }
| long Containers::KeyedObjectManager< T >::insert | ( | ObjectContainerBase * | b, | |
| ContainedObject * | c, | |||
| void * | o, | |||
| long * | k | |||
| ) |
Insert new object into container.
Definition at line 127 of file KeyedObjectManager.cpp.
References Containers::KeyedObjectManager< SETUP >::m_keyCtxt.
Referenced by Containers::KeyedObjectManager< SETUP >::insert().
| long Containers::KeyedObjectManager< T >::insert | ( | ObjectContainerBase * | b, | |
| ContainedObject * | c, | |||
| void * | o, | |||
| long | k | |||
| ) |
Insert new object into container.
Keep major key value
Definition at line 138 of file KeyedObjectManager.cpp.
References Containers::cannotInsertToContainer(), Containers::KeyedObjectManager< SETUP >::insert(), Containers::KeyedObjectManager< SETUP >::m_direct, Containers::KeyedObjectManager< SETUP >::m_keyCtxt, Containers::KeyedObjectManager< SETUP >::m_seq, Containers::KeyedObjectManager< SETUP >::m_setup, Containers::OBJ_CANNOT_INSERT, Containers::OBJ_INSERTED, Containers::KeyedObjectManager< SETUP >::onDirty(), ContainedObject::parent(), std::vector< _Tp, _Alloc >::push_back(), and ContainedObject::setParent().
00143 { 00145 if ( key > m_keyCtxt ) { 00146 m_keyCtxt = key; 00147 } 00148 if ( 1==m_direct ) { 00149 if ( m_setup.s->insert(obj, key) ) { 00150 if ( !pObject->parent() ) { 00151 pObject->setParent(pBase); 00152 } 00153 m_seq->push_back(obj); 00154 return OBJ_INSERTED; 00155 } 00156 } 00157 else if ( key == long(m_setup.s->v.size()) ) { 00158 m_setup.s->v.push_back(obj); 00159 if ( !pObject->parent() ) { 00160 pObject->setParent(pBase); 00161 } 00162 m_seq->push_back(obj); 00163 return OBJ_INSERTED; 00164 } 00165 else { 00166 // Document is dirty now... 00167 // need to copy all pointers from the vector to the map 00168 onDirty(); 00169 return insert(pBase, pObject, obj, key); 00170 } 00171 cannotInsertToContainer(); 00172 return OBJ_CANNOT_INSERT; 00173 }
| void * Containers::KeyedObjectManager< T >::erase | ( | long | key, | |
| const void * | obj | |||
| ) |
Remove object from container (very inefficient if key is invalid).
Definition at line 213 of file KeyedObjectManager.cpp.
References std::vector< _Tp, _Alloc >::begin(), Containers::containerIsInconsistent(), std::vector< _Tp, _Alloc >::end(), std::vector< _Tp, _Alloc >::erase(), std::find(), std::find_if(), Gaudi::Units::m, Containers::KeyedObjectManager< SETUP >::m_direct, Containers::KeyedObjectManager< SETUP >::m_seq, Containers::KeyedObjectManager< SETUP >::m_setup, and Containers::KeyedObjectManager< SETUP >::onDirty().
Referenced by Containers::KeyedObjectManager< SETUP >::erase().
00214 { 00215 typedef typename T::map_type MTYP; 00216 typedef find<MTYP> FND; 00217 if ( 1 == m_direct ) { 00218 typename T::map_type& m = m_setup.s->m; 00219 typename T::map_type::iterator i = (0==obj) ? m_setup.s->m.find(key) 00220 : std::find_if(m.begin(),m.end(),FND(obj)); 00221 if ( i != m_setup.s->m.end() ) { 00222 void* o = (*i).second; 00223 seq_type::iterator j = std::find(m_seq->begin(),m_seq->end(),o); 00224 if ( j != m_seq->end() ) { 00225 m_seq->erase(j); 00226 m_setup.s->m.erase(i); 00227 return o; 00228 } 00229 } 00230 containerIsInconsistent(); 00231 } 00232 onDirty(); 00233 return erase(key, obj); 00234 }
| long Containers::KeyedObjectManager< T >::erase | ( | seq_type::iterator | beg, | |
| seq_type::iterator | end | |||
| ) |
Remove object by sequential iterators.
Definition at line 291 of file KeyedObjectManager.cpp.
References std::vector< _Tp, _Alloc >::begin(), Containers::KeyedObjectManager< SETUP >::clear(), Containers::containerIsInconsistent(), std::vector< _Tp, _Alloc >::end(), std::vector< _Tp, _Alloc >::erase(), Containers::KeyedObjectManager< SETUP >::erase(), std::find_if(), Gaudi::Units::m, Containers::KeyedObjectManager< SETUP >::m_direct, Containers::KeyedObjectManager< SETUP >::m_seq, Containers::KeyedObjectManager< SETUP >::m_setup, Containers::OBJ_ERASED, and Containers::KeyedObjectManager< SETUP >::onDirty().
00293 { 00294 typedef typename T::map_type MTYP; 00295 typedef find<MTYP> FND; 00296 if ( 0 == m_direct ) { 00297 onDirty(); 00298 return erase(beg, end); 00299 } 00300 if ( beg == m_seq->begin() && end == m_seq->end() ) { 00301 clear(); 00302 } 00303 else { 00304 for ( seq_type::iterator j=beg; j != end; ++j) { 00305 typename T::map_type& m = m_setup.s->m; 00306 typename T::map_type::iterator i = std::find_if(m.begin(),m.end(),FND(*j)); 00307 if ( i != m_setup.s->m.end() ) { 00308 m_setup.s->m.erase(i); 00309 continue; 00310 } 00311 containerIsInconsistent(); 00312 } 00313 m_seq->erase(beg, end); 00314 } 00315 return OBJ_ERASED; 00316 }
| void Containers::KeyedObjectManager< T >::reserve | ( | long | size | ) |
Reserve buffer space.
Definition at line 250 of file KeyedObjectManager.cpp.
References Containers::KeyedObjectManager< SETUP >::m_direct, Containers::KeyedObjectManager< SETUP >::m_seq, Containers::KeyedObjectManager< SETUP >::m_setup, and std::vector< _Tp, _Alloc >::reserve().
00251 { 00252 switch( m_direct ) { 00253 case 1: 00254 break; 00255 case 0: 00256 m_setup.s->v.reserve(len); 00257 break; 00258 default: 00259 break; 00260 } 00261 m_seq->reserve(len); 00262 }
| void Containers::KeyedObjectManager< T >::clear | ( | ) |
Clear content of the vector.
Definition at line 265 of file KeyedObjectManager.cpp.
References std::vector< _Tp, _Alloc >::clear(), Containers::KeyedObjectManager< SETUP >::clearDirect(), and Containers::KeyedObjectManager< SETUP >::m_seq.
Referenced by Containers::KeyedObjectManager< SETUP >::erase().
00266 { 00267 clearDirect(); 00268 m_seq->clear(); 00269 }
| void Containers::KeyedObjectManager< T >::setup | ( | void * | seq, | |
| void ** | rndm | |||
| ) |
Setup of the Map and the parent object.
Definition at line 111 of file KeyedObjectManager.cpp.
References Containers::KeyedObjectManager< SETUP >::m_seq, and Containers::KeyedObjectManager< SETUP >::m_setup.
| static const CLID Containers::KeyedObjectManager< SETUP >::classID | ( | ) | [static] |
Access CLID for this type of container.
| const CLID Containers::KeyedObjectManager< Containers::map >::classID | ( | ) |
Definition at line 324 of file KeyedObjectManager.cpp.
References CLID_ObjectVector.
00324 { 00325 return CLID_ObjectVector+0x00030000; 00326 }
| const CLID Containers::KeyedObjectManager< Containers::hashmap >::classID | ( | ) |
Definition at line 328 of file KeyedObjectManager.cpp.
References CLID_ObjectVector.
00328 { 00329 return CLID_ObjectVector+0x00040000; 00330 }
| void * Containers::KeyedObjectManager< __A >::object | ( | long | value | ) | const |
Definition at line 348 of file KeyedObjectManager.cpp.
References Containers::KeyedObjectManager< SETUP >::m_setup.
00349 { 00350 #ifdef CHECK_KEYED_CONTAINER 00351 unsigned long siz = m_setup.s->m_idx.size(); 00352 if ( value >= 0 && size_t(value) < siz ) { 00353 long ent = *(m_setup.s->m_idx.begin()+value); 00354 if ( ent >= 0 ) { 00355 return *(m_setup.s->v.begin() + ent); 00356 } 00357 } 00358 return 0; 00359 #else 00360 return *(m_setup.s->v.begin() + (*(m_setup.s->m_idx.begin()+value))); 00361 #endif 00362 }
| void Containers::KeyedObjectManager< __A >::onDirty | ( | ) | const |
Definition at line 365 of file KeyedObjectManager.cpp.
References Containers::containerIsInconsistent(), Containers::KeyedObjectManager< SETUP >::m_direct, and Containers::KeyedObjectManager< SETUP >::m_setup.
00365 { 00366 m_direct = 1; 00367 m_setup.s->m_idx.reserve(m_setup.s->v.size()+1); 00368 for(int i = 0, stop = m_setup.s->v.size(); i < stop; ++i) { 00369 if ( m_setup.s->v[i] == 0 ) { 00370 containerIsInconsistent(); 00371 } 00372 m_setup.s->m_idx.push_back(i); 00373 } 00374 }
| long Containers::KeyedObjectManager< __A >::insert | ( | ObjectContainerBase * | b, | |
| ContainedObject * | c, | |||
| void * | o, | |||
| long * | k | |||
| ) |
Definition at line 378 of file KeyedObjectManager.cpp.
References c, Containers::cannotInsertToContainer(), Containers::KeyedObjectManager< SETUP >::m_direct, Containers::KeyedObjectManager< SETUP >::m_keyCtxt, Containers::KeyedObjectManager< SETUP >::m_seq, Containers::KeyedObjectManager< SETUP >::m_setup, Containers::OBJ_CANNOT_INSERT, Containers::OBJ_INSERTED, and std::vector< _Tp, _Alloc >::push_back().
00382 { 00383 // auto key creation only possible for direct access! 00384 if ( 0 == m_direct ) { 00385 m_seq->push_back(o); 00386 m_setup.s->v.push_back(o); 00387 if ( !c->parent() ) c->setParent(b); 00388 *k = ++m_keyCtxt; 00389 return OBJ_INSERTED; 00390 } 00391 cannotInsertToContainer(); 00392 return OBJ_CANNOT_INSERT; 00393 }
| long Containers::KeyedObjectManager< __A >::insert | ( | ObjectContainerBase * | b, | |
| ContainedObject * | c, | |||
| void * | o, | |||
| long | k | |||
| ) |
Definition at line 397 of file KeyedObjectManager.cpp.
References c, Containers::cannotInsertToContainer(), Containers::KeyedObjectManager< SETUP >::insert(), Containers::KeyedObjectManager< SETUP >::m_direct, Containers::KeyedObjectManager< SETUP >::m_keyCtxt, Containers::KeyedObjectManager< SETUP >::m_seq, Containers::KeyedObjectManager< SETUP >::m_setup, Containers::OBJ_CANNOT_INSERT, Containers::OBJ_INSERTED, Containers::KeyedObjectManager< SETUP >::onDirty(), and std::vector< _Tp, _Alloc >::push_back().
00401 { 00402 if ( 0 == m_direct ) { 00403 if ( k == m_keyCtxt+1 ) { 00404 return insert(b, c, o, &k); 00405 } 00406 onDirty(); 00407 return insert(b, c, o, k); 00408 } 00410 if ( k > m_keyCtxt ) m_keyCtxt = k; 00412 if ( k+1 > long(m_setup.s->m_idx.size()) ) { 00413 m_setup.s->m_idx.resize(k+1, -1); 00414 } 00415 std::vector<long>::iterator idx = m_setup.s->m_idx.begin()+k; 00416 if ( *idx == -1 ) { 00417 *idx = m_setup.s->v.size(); 00418 m_setup.s->v.push_back(o); 00419 m_seq->push_back(o); 00420 if ( !c->parent() ) c->setParent(b); 00421 return OBJ_INSERTED; 00422 } 00423 cannotInsertToContainer(); 00424 return OBJ_CANNOT_INSERT; 00425 }
| long Containers::KeyedObjectManager< __A >::insertDirect | ( | ObjectContainerBase * | b, | |
| ContainedObject * | c, | |||
| void * | o, | |||
| long | k | |||
| ) |
Definition at line 429 of file KeyedObjectManager.cpp.
References c, Containers::cannotInsertToContainer(), Containers::KeyedObjectManager< SETUP >::insertDirect(), Containers::KeyedObjectManager< SETUP >::m_direct, Containers::KeyedObjectManager< SETUP >::m_keyCtxt, Containers::KeyedObjectManager< SETUP >::m_setup, Containers::OBJ_CANNOT_INSERT, Containers::OBJ_INSERTED, and Containers::KeyedObjectManager< SETUP >::onDirty().
00433 { 00434 if ( 0 == m_direct ) { 00435 if ( k == m_keyCtxt+1 ) { 00436 m_setup.s->v.push_back(o); 00437 if ( !c->parent() ) c->setParent(b); 00438 ++m_keyCtxt; 00439 return OBJ_INSERTED; 00440 } 00441 onDirty(); 00442 return insertDirect(b, c, o, k); 00443 } 00445 if ( k > m_keyCtxt ) m_keyCtxt = k; 00447 if ( k+1 > long(m_setup.s->m_idx.size()) ) { 00448 m_setup.s->m_idx.resize(k+1, -1); 00449 } 00450 std::vector<long>::iterator idx = m_setup.s->m_idx.begin()+k; 00451 if ( *idx == -1 ) { 00452 *idx = m_setup.s->v.size(); 00453 m_setup.s->v.push_back(o); 00454 if ( !c->parent() ) c->setParent(b); 00455 return OBJ_INSERTED; 00456 } 00457 cannotInsertToContainer(); 00458 return OBJ_CANNOT_INSERT; 00459 }
| void Containers::KeyedObjectManager< __A >::clearDirect | ( | ) |
Definition at line 463 of file KeyedObjectManager.cpp.
References Containers::KeyedObjectManager< SETUP >::m_direct, Containers::KeyedObjectManager< SETUP >::m_keyCtxt, and Containers::KeyedObjectManager< SETUP >::m_setup.
00463 { 00464 m_setup.s->v.clear(); 00465 m_setup.s->m_idx.clear(); 00466 m_direct = 0; 00467 m_keyCtxt = -1; 00468 }
| void * Containers::KeyedObjectManager< __A >::erase | ( | long | key, | |
| const void * | obj | |||
| ) |
Definition at line 472 of file KeyedObjectManager.cpp.
References std::vector< _Tp, _Alloc >::begin(), Containers::containerIsInconsistent(), std::vector< _Tp, _Alloc >::end(), std::vector< _Tp, _Alloc >::erase(), Containers::KeyedObjectManager< SETUP >::erase(), std::find(), std::for_each(), Containers::KeyedObjectManager< SETUP >::m_direct, Containers::KeyedObjectManager< SETUP >::m_seq, Containers::KeyedObjectManager< SETUP >::m_setup, and Containers::KeyedObjectManager< SETUP >::onDirty().
00474 { 00475 typedef std::vector<long> id_type; 00476 typedef id_type::iterator id_iter; 00477 typedef __A::map_type MTYP; 00478 typedef find<MTYP> FND; 00479 if ( 0 == m_direct ) { 00480 onDirty(); 00481 return erase(key, obj); 00482 } 00483 if ( 0 != obj ) { 00484 id_type& idx = m_setup.s->m_idx; 00485 for ( id_iter i=idx.begin(); i != idx.end(); i++ ) { 00486 seq_type::iterator j = m_setup.s->v.begin()+(*i); 00487 seq_type::iterator k = std::find(m_seq->begin(),m_seq->end(),*j); 00488 if ( *j == obj ) { 00489 void* o = *j; 00490 m_seq->erase(k); 00491 m_setup.s->v.erase(j); 00492 std::for_each(m_setup.s->m_idx.begin(), 00493 m_setup.s->m_idx.end(), 00494 array::decrement(*i)); 00495 *i = -1; 00496 return o; 00497 } 00498 } 00499 } 00500 else if ( key >= 0 && key < long(m_setup.s->m_idx.size()) ) { 00501 id_iter idx = m_setup.s->m_idx.begin()+key; 00502 if ( *idx != -1 ) { 00503 seq_type::iterator i = m_setup.s->v.begin()+(*idx); 00504 if ( i == m_setup.s->v.end() ) { 00505 containerIsInconsistent(); 00506 } 00507 void* o = *i; 00508 seq_type::iterator j=std::find(m_seq->begin(),m_seq->end(),o); 00509 if ( j == m_seq->end() ) { 00510 containerIsInconsistent(); 00511 } 00512 m_seq->erase(j); 00513 m_setup.s->v.erase(i); 00514 std::for_each(m_setup.s->m_idx.begin(), 00515 m_setup.s->m_idx.end(), 00516 array::decrement(*idx)); 00517 *idx = -1; 00518 return o; 00519 } 00520 } 00521 containerIsInconsistent(); 00522 return 0; 00523 }
| long Containers::KeyedObjectManager< __A >::erase | ( | seq_type::iterator | beg, | |
| seq_type::iterator | end | |||
| ) |
Definition at line 527 of file KeyedObjectManager.cpp.
References std::vector< _Tp, _Alloc >::begin(), Containers::KeyedObjectManager< SETUP >::clear(), Containers::containerIsInconsistent(), std::vector< _Tp, _Alloc >::end(), std::vector< _Tp, _Alloc >::erase(), Containers::KeyedObjectManager< SETUP >::erase(), std::find(), std::for_each(), Containers::invalidContainerOperation(), Containers::KeyedObjectManager< SETUP >::m_direct, Containers::KeyedObjectManager< SETUP >::m_seq, Containers::KeyedObjectManager< SETUP >::m_setup, Containers::OBJ_ERASED, and Containers::KeyedObjectManager< SETUP >::onDirty().
00529 { 00530 typedef std::vector<long> id_type; 00531 typedef id_type::iterator id_iter; 00532 if ( beg == m_seq->begin() && end == m_seq->end() ) { 00533 clear(); 00534 return OBJ_ERASED; 00535 } 00536 else if ( 0 == m_direct ) { 00537 onDirty(); 00538 return erase(beg, end); 00539 } 00540 else { 00541 long cnt = 0, nobj = end-beg; 00542 id_type& idx = m_setup.s->m_idx; 00543 for ( id_iter i=idx.begin(); i != idx.end(); i++ ) { 00544 seq_type::iterator j = m_setup.s->v.begin()+(*i); 00545 seq_type::iterator k = std::find(beg,end,*j); 00546 if ( k != end ) { 00547 m_setup.s->v.erase(j); 00548 std::for_each(m_setup.s->m_idx.begin(), 00549 m_setup.s->m_idx.end(), 00550 array::decrement(*i)); 00551 *i = -1; 00552 cnt++; 00553 if ( cnt == nobj ) break; 00554 } 00555 } 00556 m_seq->erase(beg, end); 00557 if ( cnt != nobj ) { 00558 containerIsInconsistent(); 00559 } 00560 return OBJ_ERASED; 00561 } 00562 invalidContainerOperation(); 00563 return 0; 00564 }
| const CLID Containers::KeyedObjectManager< __A >::classID | ( | ) |
Definition at line 567 of file KeyedObjectManager.cpp.
References CLID_ObjectVector.
00567 { 00568 return CLID_ObjectVector+0x00050000; 00569 }
| void * Containers::KeyedObjectManager< __V >::object | ( | long | ) | const |
Definition at line 584 of file KeyedObjectManager.cpp.
References Containers::invalidContainerOperation().
00585 { 00586 invalidContainerOperation(); 00587 return 0; 00588 }
| void Containers::KeyedObjectManager< __V >::onDirty | ( | ) | const |
Definition at line 591 of file KeyedObjectManager.cpp.
References Containers::invalidContainerOperation().
00591 { 00592 invalidContainerOperation(); 00593 }
| long Containers::KeyedObjectManager< __V >::insert | ( | ObjectContainerBase * | b, | |
| ContainedObject * | c, | |||
| void * | o, | |||
| long * | k | |||
| ) |
Definition at line 597 of file KeyedObjectManager.cpp.
References c, Containers::KeyedObjectManager< SETUP >::m_seq, Containers::KeyedObjectManager< SETUP >::m_setup, Containers::OBJ_INSERTED, and std::vector< _Tp, _Alloc >::push_back().
00601 { 00602 m_seq->push_back(o); 00603 m_setup.s->v.push_back(o); 00604 if ( !c->parent() ) c->setParent(b); 00605 *k = (m_setup.s->v.size()-1); 00606 return OBJ_INSERTED; 00607 }
| long Containers::KeyedObjectManager< __V >::insert | ( | ObjectContainerBase * | b, | |
| ContainedObject * | c, | |||
| void * | o, | |||
| long | k | |||
| ) |
Definition at line 611 of file KeyedObjectManager.cpp.
References c, Containers::cannotInsertToContainer(), Containers::KeyedObjectManager< SETUP >::insert(), Containers::KeyedObjectManager< SETUP >::m_setup, and Containers::OBJ_CANNOT_INSERT.
00615 { 00616 if ( k == long(m_setup.s->v.size()) ) { 00617 return insert(b, c, o, &k); 00618 } 00619 cannotInsertToContainer(); 00620 return OBJ_CANNOT_INSERT; 00621 }
| long Containers::KeyedObjectManager< __V >::insertDirect | ( | ObjectContainerBase * | b, | |
| ContainedObject * | c, | |||
| void * | o, | |||
| long | k | |||
| ) |
Definition at line 625 of file KeyedObjectManager.cpp.
References c, Containers::cannotInsertToContainer(), Containers::KeyedObjectManager< SETUP >::m_setup, Containers::OBJ_CANNOT_INSERT, and Containers::OBJ_INSERTED.
00629 { 00630 if ( k == long(m_setup.s->v.size()) ) { 00631 m_setup.s->v.push_back(o); 00632 if ( !c->parent() ) c->setParent(b); 00633 return OBJ_INSERTED; 00634 } 00635 cannotInsertToContainer(); 00636 return OBJ_CANNOT_INSERT; 00637 }
| void Containers::KeyedObjectManager< __V >::clearDirect | ( | ) |
Definition at line 641 of file KeyedObjectManager.cpp.
References Containers::KeyedObjectManager< SETUP >::m_direct, Containers::KeyedObjectManager< SETUP >::m_keyCtxt, and Containers::KeyedObjectManager< SETUP >::m_setup.
| void * Containers::KeyedObjectManager< __V >::erase | ( | long | , | |
| const void * | ||||
| ) |
Definition at line 649 of file KeyedObjectManager.cpp.
References Containers::invalidContainerOperation().
00651 { 00652 invalidContainerOperation(); 00653 return 0; 00654 }
| long Containers::KeyedObjectManager< __V >::erase | ( | seq_type::iterator | beg, | |
| seq_type::iterator | end | |||
| ) |
Definition at line 658 of file KeyedObjectManager.cpp.
References std::vector< _Tp, _Alloc >::begin(), Containers::KeyedObjectManager< SETUP >::clear(), std::vector< _Tp, _Alloc >::end(), Containers::invalidContainerOperation(), Containers::KeyedObjectManager< SETUP >::m_seq, and Containers::OBJ_ERASED.
00660 { 00661 if ( beg == m_seq->begin() && end == m_seq->end() ) { 00662 clear(); 00663 return OBJ_ERASED; 00664 } 00665 invalidContainerOperation(); 00666 return OBJ_ERASED; 00667 }
| const CLID Containers::KeyedObjectManager< __V >::classID | ( | ) |
Definition at line 670 of file KeyedObjectManager.cpp.
References CLID_ObjectVector.
00670 { 00671 return CLID_ObjectVector+0x00060000; 00672 }
seq_type* Containers::KeyedObjectManager< SETUP >::m_seq [private] |
Container holding array like container.
Definition at line 50 of file KeyedObjectManager.h.
Referenced by Containers::KeyedObjectManager< SETUP >::clear(), Containers::KeyedObjectManager< SETUP >::erase(), Containers::KeyedObjectManager< SETUP >::insert(), Containers::KeyedObjectManager< SETUP >::reserve(), and Containers::KeyedObjectManager< SETUP >::setup().
long Containers::KeyedObjectManager< SETUP >::m_direct [mutable, private] |
Dirty flag.
Definition at line 52 of file KeyedObjectManager.h.
Referenced by Containers::KeyedObjectManager< SETUP >::clearDirect(), Containers::KeyedObjectManager< SETUP >::erase(), Containers::KeyedObjectManager< SETUP >::insert(), Containers::KeyedObjectManager< SETUP >::insertDirect(), Containers::KeyedObjectManager< SETUP >::isDirect(), Containers::KeyedObjectManager< SETUP >::object(), Containers::KeyedObjectManager< SETUP >::onDirty(), and Containers::KeyedObjectManager< SETUP >::reserve().
long Containers::KeyedObjectManager< SETUP >::m_keyCtxt [mutable, private] |
char Containers::KeyedObjectManager< SETUP >::buffer[128] [private] |
SETUP* Containers::KeyedObjectManager< SETUP >::s [private] |
Definition at line 57 of file KeyedObjectManager.h.
union { ... } Containers::KeyedObjectManager< SETUP >::m_setup [private] |
Referenced by Containers::KeyedObjectManager< SETUP >::clearDirect(), Containers::KeyedObjectManager< SETUP >::erase(), Containers::KeyedObjectManager< SETUP >::insert(), Containers::KeyedObjectManager< SETUP >::insertDirect(), Containers::KeyedObjectManager< SETUP >::KeyedObjectManager(), Containers::KeyedObjectManager< SETUP >::object(), Containers::KeyedObjectManager< SETUP >::onDirty(), Containers::KeyedObjectManager< SETUP >::reserve(), Containers::KeyedObjectManager< SETUP >::setup(), and Containers::KeyedObjectManager< SETUP >::~KeyedObjectManager().