GlobalObjects
Loading...
Searching...
No Matches
GloTOndemandList.h
Go to the documentation of this file.
1#ifndef INC_GLOTONDEMANDLIST_H
2#define INC_GLOTONDEMANDLIST_H
3//-----------------------------------------------------------------------------
36//-----------------------------------------------------------------------------
37#include "GloTypes.h"
38#include "GloOndemandList.h"
39#include "GloBasePersistent.h"
40//-----------------------------------------------------------------------------
41namespace glo
42{
43 //---------------------------------------------------------------------------
79 template < class T > class TOndemandList : public OndemandList
80 {
81 public:
82 //============== Konstruktoren
83 //-----------------------------------------------------------------------
94 //-----------------------------------------------------------------------
106 TOndemandList( Base & rBase );
107 //-----------------------------------------------------------------------
120 virtual ~TOndemandList();
121 //-----------------------------------------------------------------------
122
123 private:
124 //============== Konstruktoren
125 //-----------------------------------------------------------------------
136 //-----------------------------------------------------------------------
137
138 public:
139 //============== Methoden
140 //-----------------------------------------------------------------------
156 virtual int getTypeAsString( std::string & rsTypeName ) override;
157 //-----------------------------------------------------------------------
159
190 virtual int insert( T * NewObj );
191 virtual int insert( std::shared_ptr<T> NewObj );
193 //-----------------------------------------------------------------------
195
226 virtual int insertBefore( T * NewObj, const T * Object );
227 virtual int insertBefore( std::shared_ptr<T> NewObj,
228 const std::shared_ptr<T> Object );
230 //-----------------------------------------------------------------------
232
261 virtual int append( T * NewObj );
262 virtual int append( std::shared_ptr<T> NewObj );
264 //-----------------------------------------------------------------------
266
299 virtual int remove( T * Object );
300 virtual int remove( std::shared_ptr<T> Object );
302 //-----------------------------------------------------------------------
324 virtual int get( T *& prRetVal, EnSeekMode eMode );
325 //-----------------------------------------------------------------------
327
344 virtual int get( std::shared_ptr<T> & rRetVal, EnSeekMode eMode );
345 virtual int get( TOndemand<T> & rRetVal, EnSeekMode eMode );
347 //-----------------------------------------------------------------------
368 virtual int get( T *& prRetVal, const ObjID & rObjID );
369 //-----------------------------------------------------------------------
390 virtual int get( std::shared_ptr<T> & rRetVal, const ObjID & rObjID );
391 //-----------------------------------------------------------------------
392
393 private:
394 //============== Operatoren
395 //-----------------------------------------------------------------------
406 //-----------------------------------------------------------------------
407 };
408 //---------------------------------------------------------------------------
409 #define SUPER OndemandList
410 //---------------------------------------------------------------------------
411 template < class T >
413 : SUPER()
414 {
415 #ifdef _DEBUG
416 m_strDebugInfo = "TOndemandList";
417 #endif
418 }
419 //---------------------------------------------------------------------------
420 template < class T >
422 : SUPER( rBase )
423 {
424 #ifdef _DEBUG
425 m_strDebugInfo = "TOndemandList";
426 #endif
427 }
428 //---------------------------------------------------------------------------
429 template < class T >
433 //---------------------------------------------------------------------------
434 template < class T >
435 int TOndemandList< T >::getTypeAsString( std::string & rsTypeName )
436 {
437 std::size_t t_nCount( 0 );
438
439 rsTypeName = typeid(T).name();
440 rsTypeName.replace( t_nCount, 6, "");
441 return 0;
442 }
443 //---------------------------------------------------------------------------
444 template < class T >
445 int TOndemandList< T >::insert( T * pNewObj )
446 {
447 return SUPER::insertPers( pNewObj );
448 }
449 //---------------------------------------------------------------------------
450 template < class T >
451 int TOndemandList< T >::insert( std::shared_ptr<T> spNewObj )
452 {
453 return SUPER::insertPers( spNewObj.operator->() );
454 }
455 //---------------------------------------------------------------------------
456 template < class T >
457 int TOndemandList< T >::insertBefore( T * pNewObj, const T * pObject )
458 {
459 return SUPER::insertPersBefore( pNewObj, pObject );
460 }
461 //---------------------------------------------------------------------------
462 template < class T >
463 int TOndemandList< T >::insertBefore( std::shared_ptr<T> spNewObj,
464 const std::shared_ptr<T> spObject )
465 {
466 return SUPER::insertPersBefore( spNewObj.operator->(), spObject.operator->() );
467 }
468 //---------------------------------------------------------------------------
469 template < class T >
470 int TOndemandList< T >::append( T * pNewObj )
471 {
472 return SUPER::appendPers( pNewObj );
473 }
474 //---------------------------------------------------------------------------
475 template < class T >
476 int TOndemandList< T >::append( std::shared_ptr<T> spNewObj )
477 {
478 return SUPER::appendPers( spNewObj.operator->() );
479 }
480 //---------------------------------------------------------------------------
481 template < class T >
482 int TOndemandList< T >::remove( T * pObject )
483 {
484 return SUPER::removePers( pObject );
485 }
486 //---------------------------------------------------------------------------
487 template < class T >
488 int TOndemandList< T >::remove( std::shared_ptr<T> spObject )
489 {
490 return SUPER::removePers( spObject.operator->() );
491 }
492 //---------------------------------------------------------------------------
493 template < class T >
494 int TOndemandList< T >::get( T *& prRetVal, EnSeekMode eMode )
495 {
496 return SUPER::getPers( (BasePersistent*&) prRetVal, eMode );
497 }
498 //---------------------------------------------------------------------------
499 template < class T >
500 int TOndemandList< T >::get( std::shared_ptr<T> & rRetVal,
501 EnSeekMode eMode )
502 {
503 T * t_pPersObject = 0;
504 int t_iErr = this->get( t_pPersObject, eMode );
505
506 if ( t_pPersObject )
507 {
508 rRetVal.reset( t_pPersObject, Forgeter<T>() );
509 }
510 return t_iErr;
511 }
512 //---------------------------------------------------------------------------
513 template < class T >
515 EnSeekMode eMode )
516 {
517 T * t_pPersObject = 0;
518 int t_iErr = this->get( t_pPersObject, eMode );
519
520 if ( t_pPersObject )
521 {
522 rRetVal.set( t_pPersObject );
523 }
524 return t_iErr;
525 }
526 //---------------------------------------------------------------------------
527 template < class T >
528 int TOndemandList< T >::get( T *& prRetVal, const ObjID & rObjID )
529 {
530 return SUPER::getPersistent( (BasePersistent*&) prRetVal, rObjID );
531 }
532 //---------------------------------------------------------------------------
533 template < class T >
534 int TOndemandList< T >::get( std::shared_ptr<T> & rRetVal,
535 const ObjID & rObjID )
536 {
537 T * t_pPersObject = 0;
538 int t_iErr = this->get( t_pPersObject, rObjID );
539
540 if ( t_pPersObject )
541 {
542 rRetVal.reset( t_pPersObject, Forgeter<T>() );
543 }
544 return t_iErr;
545 }
546 //---------------------------------------------------------------------------
547 #undef SUPER
548 //---------------------------------------------------------------------------
549} // namespace glo
550#endif
Header for BasePersistent
Header for OndemandList
#define SUPER
Definition GloTAllSet.h:1151
For each library, here 'GlobalObjects' there is a type file.
This class is the interface to the persistent objects. Here "objects" can be registered,...
Definition GloBase.h:250
Abstract base class for Persistent and the generic GenericPersistent.
Definition GloBasePersistent.h:102
std::string m_strDebugInfo
Definition GloCallBack.h:115
Especially for GenericPersistent or derived classes of Persistent the Forget method for std::shared_p...
Definition GloTypes.h:1249
An object ID consists of the class ID, a database ID and the actual unique object number (all unsigne...
Definition GloObjID.h:77
Is the base class of Template-Ondemand-List. The objects are managed in a std::list....
Definition GloOndemandList.h:66
A reference (as attribute) of a persistent object to another persistent object in the database.
Definition GloTOndemand.h:90
int set(const T *pObj)
Definition GloTOndemand.h:383
A type-safe list of references to persistent objects in the database (intended as an attribute for pe...
Definition GloTOndemandList.h:80
virtual int get(T *&prRetVal, EnSeekMode eMode)
Definition GloTOndemandList.h:494
TOndemandList(const TOndemandList &)
virtual int insert(T *NewObj)
Inserts the passed persistent object into the list behind the current position.
Definition GloTOndemandList.h:445
virtual ~TOndemandList()
Definition GloTOndemandList.h:430
TOndemandList()
Definition GloTOndemandList.h:412
virtual int insertBefore(T *NewObj, const T *Object)
Inserts a persistent object before another object in the list.
Definition GloTOndemandList.h:457
virtual int remove(T *Object)
Removes the passed persistent object from the list.
Definition GloTOndemandList.h:482
virtual int append(T *NewObj)
Appends a persistent object to the end of the list.
Definition GloTOndemandList.h:470
virtual int getTypeAsString(std::string &rsTypeName) override
Definition GloTOndemandList.h:435
TOndemandList< T > & operator=(const TOndemandList &)
Definition GloAbstractBaseLot.h:42
EnSeekMode
Definition GloTypes.h:166