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 //---------------------------------------------------------------------------
93 template < class T > class TOndemandSet : public OndemandSet
94 {
95 public:
96 //============== Konstruktoren
97 //-----------------------------------------------------------------------
107 TOndemandSet();
108 //-----------------------------------------------------------------------
120 TOndemandSet( Base & rBase );
121 //-----------------------------------------------------------------------
134 virtual ~TOndemandSet();
135 //-----------------------------------------------------------------------
136
137 private:
138 //============== Konstruktoren
139 //-----------------------------------------------------------------------
150 //-----------------------------------------------------------------------
151
152 public:
153 //============== Methoden
154 //-----------------------------------------------------------------------
170 virtual int getTypeAsString( std::string & rsTypeName ) override;
171 //-----------------------------------------------------------------------
173
204 virtual int insert( T * NewObj );
205 virtual int insert( std::shared_ptr<T> NewObj );
207 //-----------------------------------------------------------------------
209
242 virtual int remove( T * Object );
243 virtual int remove( std::shared_ptr<T> Object );
245 //-----------------------------------------------------------------------
275 virtual int get( T *& prRetVal, EnSeekMode eMode );
276 //-----------------------------------------------------------------------
278
301 virtual int get( std::shared_ptr<T> & rRetVal, EnSeekMode eMode );
302 virtual int get( TOndemand<T> & rRetVal, EnSeekMode eMode );
304 //-----------------------------------------------------------------------
340 virtual int get( glo::ObjID & rObjID, T *& prRetVal, EnSeekMode eMode );
341 //-----------------------------------------------------------------------
343
372 virtual int get( glo::ObjID & rObjID, std::shared_ptr<T> & rRetVal, EnSeekMode eMode );
373 virtual int get( glo::ObjID & rObjID, TOndemand<T> & rRetVal, EnSeekMode eMode );
375 //-----------------------------------------------------------------------
400 virtual int get( T *& prRetVal, const ObjID & rObjID );
401 //-----------------------------------------------------------------------
426 virtual int get( std::shared_ptr<T> & rRetVal, const ObjID & rObjID );
427 //-----------------------------------------------------------------------
428
429 private:
430 //============== Operatoren
431 //-----------------------------------------------------------------------
442 //-----------------------------------------------------------------------
443 };
444 //---------------------------------------------------------------------------
445 #define SUPER OndemandSet
446 //---------------------------------------------------------------------------
447 template < class T >
449 : SUPER()
450 {
451 #ifdef _DEBUG
452 m_strDebugInfo = "TOndemandSet";
453 #endif
454 }
455 //---------------------------------------------------------------------------
456 template < class T >
458 : SUPER( rBase )
459 {
460 #ifdef _DEBUG
461 m_strDebugInfo = "TOndemandSet";
462 #endif
463 }
464 //---------------------------------------------------------------------------
465 template < class T >
469 //---------------------------------------------------------------------------
470 template < class T >
471 int TOndemandSet< T >::getTypeAsString( std::string & rsTypeName )
472 {
473 std::size_t t_nCount( 0 );
474
475 rsTypeName = typeid(T).name();
476 rsTypeName.replace( t_nCount, 6, "");
477 return 0;
478 }
479 //---------------------------------------------------------------------------
480 template < class T >
481 int TOndemandSet< T >::insert( T * pNewObj )
482 {
483 return SUPER::insertPers( pNewObj );
484 }
485 //---------------------------------------------------------------------------
486 template < class T >
487 int TOndemandSet< T >::insert( std::shared_ptr<T> spNewObj )
488 {
489 return SUPER::insertPers( spNewObj.operator->() );
490 }
491 //---------------------------------------------------------------------------
492 template < class T >
493 int TOndemandSet< T >::remove( T * pObject )
494 {
495 return SUPER::removePers( pObject );
496 }
497 //---------------------------------------------------------------------------
498 template < class T >
499 int TOndemandSet< T >::remove( std::shared_ptr<T> spObject )
500 {
501 return SUPER::removePers( spObject.operator->() );
502 }
503 //---------------------------------------------------------------------------
504 template < class T >
505 int TOndemandSet< T >::get( T *& prRetVal, EnSeekMode eMode )
506 {
507 return SUPER::getPers( (BasePersistent*&) prRetVal, eMode );
508 }
509 //---------------------------------------------------------------------------
510 template < class T >
511 int TOndemandSet< T >::get( std::shared_ptr<T> & rRetVal,
512 EnSeekMode eMode )
513 {
514 T * t_pPersObject = 0;
515 int t_iErr = this->get( t_pPersObject, eMode );
516
517 if ( t_pPersObject )
518 {
519 rRetVal.reset( t_pPersObject, Forgetter<T>() );
520 }
521 return t_iErr;
522 }
523 //---------------------------------------------------------------------------
524 template < class T >
526 EnSeekMode eMode )
527 {
528 T * t_pPersObject = 0;
529 int t_iErr = this->get( t_pPersObject, eMode );
530
531 if ( t_pPersObject )
532 {
533 rRetVal.set( t_pPersObject );
534 }
535 return t_iErr;
536 }
537 //---------------------------------------------------------------------------
538 template < class T >
539 int TOndemandSet< T >::get( glo::ObjID & rObjID, T *& prRetVal, EnSeekMode eMode )
540 {
541 return SUPER::getPers( rObjID, (BasePersistent*&) prRetVal, eMode );
542 }
543 //---------------------------------------------------------------------------
544 template < class T >
546 std::shared_ptr<T> & rRetVal,
547 EnSeekMode eMode )
548 {
549 T * t_pPersObject = nullptr;
550 int t_iErr = this->get( rObjID, t_pPersObject, eMode );
551
552 if ( t_pPersObject )
553 {
554 rRetVal.reset( t_pPersObject, Forgetter<T>() );
555 }
556 return t_iErr;
557 }
558 //---------------------------------------------------------------------------
559 template < class T >
561 TOndemand<T> & rRetVal,
562 EnSeekMode eMode )
563 {
564 T * t_pPersObject = nullptr;
565 int t_iErr = this->get( rObjID, t_pPersObject, eMode );
566
567 if ( t_pPersObject )
568 {
569 rRetVal.set( t_pPersObject );
570 }
571 return t_iErr;
572 }
573 //---------------------------------------------------------------------------
574 template < class T >
575 int TOndemandSet< T >::get( T *& prRetVal, const ObjID & rObjID )
576 {
577 return SUPER::getPersistent( (BasePersistent*&) prRetVal, rObjID );
578 }
579 //---------------------------------------------------------------------------
580 template < class T >
581 int TOndemandSet< T >::get( std::shared_ptr<T> & rRetVal,
582 const ObjID & rObjID )
583 {
584 T * t_pPersObject = 0;
585 int t_iErr = this->get( t_pPersObject, rObjID );
586
587 if ( t_pPersObject )
588 {
589 rRetVal.reset( t_pPersObject, Forgetter<T>() );
590 }
591 return t_iErr;
592 }
593 //---------------------------------------------------------------------------
594 #undef SUPER
595 //---------------------------------------------------------------------------
596} // namespace glo
597#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
Ist die Basisklasse von Template-Ondemand-Set. Objekte können nur einmalig eingefügt werden.
Definition GloOndemandSet.h:71
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
Ein typsicherer Set von Referenzen auf persistente Objekte in der Datenbank (gedacht als Attribut für...
Definition GloTOndemandSet.h:94
virtual ~TOndemandSet()
Definition GloTOndemandSet.h:466
virtual int getTypeAsString(std::string &rsTypeName) override
Definition GloTOndemandSet.h:471
virtual int remove(T *Object)
Entfernt das übergebene persistentes Objekt aus dem Set.
Definition GloTOndemandSet.h:493
virtual int insert(T *NewObj)
Fügt das übergebene persistentes Objekt im Set hinter der aktuellen Position ein.
Definition GloTOndemandSet.h:481
TOndemandSet< T > & operator=(const TOndemandSet &)
TOndemandSet(const TOndemandSet &)
TOndemandSet()
Definition GloTOndemandSet.h:448
virtual int get(T *&prRetVal, EnSeekMode eMode)
Definition GloTOndemandSet.h:505
Definition GloAbstractBaseLot.h:49
EnSeekMode
Definition GloTypes.h:173