GlobalObjects
Lade ...
Suche ...
Keine Treffer
GloTOndemandSet.h
gehe zur Dokumentation dieser Datei
1#ifndef INC_GLOTONDEMANDSET_H
2#define INC_GLOTONDEMANDSET_H
3//-----------------------------------------------------------------------------
43//-----------------------------------------------------------------------------
44#include "GloTypes.h"
45#include "GloOndemandSet.h"
46#include "GloBasePersistent.h"
47//-----------------------------------------------------------------------------
48namespace glo
49{
50 //---------------------------------------------------------------------------
92 template < class T > class TOndemandSet : public OndemandSet
93 {
94 public:
95 //============== Konstruktoren
96 //-----------------------------------------------------------------------
106 TOndemandSet();
107 //-----------------------------------------------------------------------
119 TOndemandSet( Base & rBase );
120 //-----------------------------------------------------------------------
133 virtual ~TOndemandSet();
134 //-----------------------------------------------------------------------
135
136 private:
137 //============== Konstruktoren
138 //-----------------------------------------------------------------------
149 //-----------------------------------------------------------------------
150
151 public:
152 //============== Methoden
153 //-----------------------------------------------------------------------
169 virtual int getTypeAsString( std::string & rsTypeName ) override;
170 //-----------------------------------------------------------------------
172
203 virtual int insert( T * NewObj );
204 virtual int insert( std::shared_ptr<T> NewObj );
206 //-----------------------------------------------------------------------
208
241 virtual int remove( T * Object );
242 virtual int remove( std::shared_ptr<T> Object );
244 //-----------------------------------------------------------------------
274 virtual int get( T *& prRetVal, EnSeekMode eMode );
275 //-----------------------------------------------------------------------
277
300 virtual int get( std::shared_ptr<T> & rRetVal, EnSeekMode eMode );
301 virtual int get( TOndemand<T> & rRetVal, EnSeekMode eMode );
303 //-----------------------------------------------------------------------
339 virtual int get( glo::ObjID & rObjID, T *& prRetVal, EnSeekMode eMode );
340 //-----------------------------------------------------------------------
342
371 virtual int get( glo::ObjID & rObjID, std::shared_ptr<T> & rRetVal, EnSeekMode eMode );
372 virtual int get( glo::ObjID & rObjID, TOndemand<T> & rRetVal, EnSeekMode eMode );
374 //-----------------------------------------------------------------------
399 virtual int get( T *& prRetVal, const ObjID & rObjID );
400 //-----------------------------------------------------------------------
425 virtual int get( std::shared_ptr<T> & rRetVal, const ObjID & rObjID );
426 //-----------------------------------------------------------------------
427
428 private:
429 //============== Operatoren
430 //-----------------------------------------------------------------------
441 //-----------------------------------------------------------------------
442 };
443 //---------------------------------------------------------------------------
444 #define SUPER OndemandSet
445 //---------------------------------------------------------------------------
446 template < class T >
448 : SUPER()
449 {
450 #ifdef _DEBUG
451 m_strDebugInfo = "TOndemandSet";
452 #endif
453 }
454 //---------------------------------------------------------------------------
455 template < class T >
457 : SUPER( rBase )
458 {
459 #ifdef _DEBUG
460 m_strDebugInfo = "TOndemandSet";
461 #endif
462 }
463 //---------------------------------------------------------------------------
464 template < class T >
468 //---------------------------------------------------------------------------
469 template < class T >
470 int TOndemandSet< T >::getTypeAsString( std::string & rsTypeName )
471 {
472 std::size_t t_nCount( 0 );
473
474 rsTypeName = typeid(T).name();
475 rsTypeName.replace( t_nCount, 6, "");
476 return 0;
477 }
478 //---------------------------------------------------------------------------
479 template < class T >
480 int TOndemandSet< T >::insert( T * pNewObj )
481 {
482 return SUPER::insertPers( pNewObj );
483 }
484 //---------------------------------------------------------------------------
485 template < class T >
486 int TOndemandSet< T >::insert( std::shared_ptr<T> spNewObj )
487 {
488 return SUPER::insertPers( spNewObj.operator->() );
489 }
490 //---------------------------------------------------------------------------
491 template < class T >
492 int TOndemandSet< T >::remove( T * pObject )
493 {
494 return SUPER::removePers( pObject );
495 }
496 //---------------------------------------------------------------------------
497 template < class T >
498 int TOndemandSet< T >::remove( std::shared_ptr<T> spObject )
499 {
500 return SUPER::removePers( spObject.operator->() );
501 }
502 //---------------------------------------------------------------------------
503 template < class T >
504 int TOndemandSet< T >::get( T *& prRetVal, EnSeekMode eMode )
505 {
506 return SUPER::getPers( (BasePersistent*&) prRetVal, eMode );
507 }
508 //---------------------------------------------------------------------------
509 template < class T >
510 int TOndemandSet< T >::get( std::shared_ptr<T> & rRetVal,
511 EnSeekMode eMode )
512 {
513 T * t_pPersObject = nullptr;
514 int t_iErr = this->get( t_pPersObject, eMode );
515
516 if ( t_pPersObject )
517 {
518 rRetVal.reset( t_pPersObject, Forgetter<T>() );
519 }
520 return t_iErr;
521 }
522 //---------------------------------------------------------------------------
523 template < class T >
525 EnSeekMode eMode )
526 {
527 T * t_pPersObject = nullptr;
528 int t_iErr = this->get( t_pPersObject, eMode );
529
530 if ( t_pPersObject )
531 {
532 rRetVal.set( t_pPersObject );
533 }
534 return t_iErr;
535 }
536 //---------------------------------------------------------------------------
537 template < class T >
538 int TOndemandSet< T >::get( glo::ObjID & rObjID, T *& prRetVal, EnSeekMode eMode )
539 {
540 return SUPER::getPers( rObjID, (BasePersistent*&) prRetVal, eMode );
541 }
542 //---------------------------------------------------------------------------
543 template < class T >
545 std::shared_ptr<T> & rRetVal,
546 EnSeekMode eMode )
547 {
548 T * t_pPersObject = nullptr;
549 int t_iErr = this->get( rObjID, t_pPersObject, eMode );
550
551 if ( t_pPersObject )
552 {
553 rRetVal.reset( t_pPersObject, Forgetter<T>() );
554 }
555 return t_iErr;
556 }
557 //---------------------------------------------------------------------------
558 template < class T >
560 TOndemand<T> & rRetVal,
561 EnSeekMode eMode )
562 {
563 T * t_pPersObject = nullptr;
564 int t_iErr = this->get( rObjID, t_pPersObject, eMode );
565
566 if ( t_pPersObject )
567 {
568 rRetVal.set( t_pPersObject );
569 }
570 return t_iErr;
571 }
572 //---------------------------------------------------------------------------
573 template < class T >
574 int TOndemandSet< T >::get( T *& prRetVal, const ObjID & rObjID )
575 {
576 return SUPER::getPersistent( (BasePersistent*&) prRetVal, rObjID );
577 }
578 //---------------------------------------------------------------------------
579 template < class T >
580 int TOndemandSet< T >::get( std::shared_ptr<T> & rRetVal,
581 const ObjID & rObjID )
582 {
583 T * t_pPersObject = nullptr;
584 int t_iErr = this->get( t_pPersObject, rObjID );
585
586 if ( t_pPersObject )
587 {
588 rRetVal.reset( t_pPersObject, Forgetter<T>() );
589 }
590 return t_iErr;
591 }
592 //---------------------------------------------------------------------------
593 #undef SUPER
594 //---------------------------------------------------------------------------
595} // namespace glo
596#endif
Header für BasePersistent
Header für OndemandSet
#define SUPER
Definition GloTAllSet.h:1204
Für jede Bibliothek, hier 'GlobalObjects' gibt es eine Typen-Datei.
Definition GloBase.h:263
Abstrakte Basisklasse für Persistent und die generische GenericPersistent.
Definition GloBasePersistent.h:124
std::string m_strDebugInfo
Definition GloCallBack.h:111
Speziel für GenericPersistent oder abgeleitete Klassen von Persistent die Forget-Methode für std::sha...
Definition GloTypes.h:1234
Ein Objekt-ID besteht aus der Klassen-ID, einer Datenbank-ID und der eigentlichen eindeutigen ObjektZ...
Definition GloObjID.h:84
Referenz (als Attribut) eines persistenten Objekte auf ein anderes persistentes Objekt in der Datenba...
Definition GloTOndemand.h:102
int set(const T *pObj)
Definition GloTOndemand.h:460
virtual ~TOndemandSet()
Definition GloTOndemandSet.h:465
virtual int getTypeAsString(std::string &rsTypeName) override
Definition GloTOndemandSet.h:470
virtual int remove(T *Object)
Entfernt das übergebene persistentes Objekt aus dem Set.
Definition GloTOndemandSet.h:492
virtual int insert(T *NewObj)
Fügt das übergebene persistentes Objekt im Set hinter der aktuellen Position ein.
Definition GloTOndemandSet.h:480
TOndemandSet< T > & operator=(const TOndemandSet &)
TOndemandSet(const TOndemandSet &)
TOndemandSet()
Definition GloTOndemandSet.h:447
virtual int get(T *&prRetVal, EnSeekMode eMode)
Definition GloTOndemandSet.h:504
Definition GloAbstractBaseLot.h:49
EnSeekMode
Definition GloTypes.h:173