BankAndCustomer
Lade ...
Suche ...
Keine Treffer
GloTOndemand.h
gehe zur Dokumentation dieser Datei
1#ifndef INC_GLOTONDEMAND_H
2#define INC_GLOTONDEMAND_H
3//-----------------------------------------------------------------------------
43//-----------------------------------------------------------------------------
44#include "GloTypes.h"
45#include "GloReference.h"
46#include "GloBase.h"
47#include "GloObjID.h"
48#include "GloBasePersistent.h"
49//-----------------------------------------------------------------------------
50namespace glo
51{
52 //---------------------------------------------------------------------------
101 template < class T > class TOndemand : public Reference
102 {
103 public:
104 //============== Konstruktoren
105 //-----------------------------------------------------------------------
115 TOndemand();
116 //-----------------------------------------------------------------------
130 TOndemand( const ObjID & rObjID );
131 //-----------------------------------------------------------------------
145 TOndemand( Base & rBase );
146 //-----------------------------------------------------------------------
160 TOndemand( unsigned long ulDatabaseID );
161 //-----------------------------------------------------------------------
177 TOndemand( const ObjID & rObjID, Base & rBase );
178 //-----------------------------------------------------------------------
195 TOndemand( const ObjID & rObjID, unsigned long ulDatabaseID );
196 //-----------------------------------------------------------------------
208 TOndemand( const TOndemand & rT );
209 //-----------------------------------------------------------------------
219 virtual ~TOndemand();
220 //-----------------------------------------------------------------------
221
222 //============== Methoden
223 //-----------------------------------------------------------------------
241 int set( const T * pObj );
242 //-----------------------------------------------------------------------
260 int set( const T & rObj );
261 //-----------------------------------------------------------------------
279 int set( const std::shared_ptr<T> & spObj );
280 //-----------------------------------------------------------------------
311 int get( T *& prObj );
312 //-----------------------------------------------------------------------
332 int get( std::shared_ptr<T> & rRetVal );
333 //-----------------------------------------------------------------------
349 virtual int setReference( const ObjID & rObjID ) override;
350 //-----------------------------------------------------------------------
351
352 public:
353 //============== Operatoren
354 //-----------------------------------------------------------------------
356
367 TOndemand< T > & operator= ( const TOndemand & rT );
368 TOndemand< T > & operator= ( const Reference & rT );
370 //-----------------------------------------------------------------------
372
383 bool operator== ( const TOndemand & rT ) const;
384 bool operator!= ( const TOndemand & rT ) const;
386 //-----------------------------------------------------------------------
387 };
388 //---------------------------------------------------------------------------
389 #define SUPER Reference
390 //---------------------------------------------------------------------------
391 template < class T >
393 : SUPER()
394 {
395 #ifdef _DEBUG
396 m_strDebugInfo = "TOndemand";
397 #endif
398 }
399 //---------------------------------------------------------------------------
400 template < class T >
402 : SUPER( rObjID )
403 {
404 #ifdef _DEBUG
405 m_strDebugInfo = "TOndemand";
406 #endif
407 }
408 //---------------------------------------------------------------------------
409 template < class T >
411 : SUPER( rBase )
412 {
413 #ifdef _DEBUG
414 m_strDebugInfo = "TOndemand";
415 #endif
416 }
417 //---------------------------------------------------------------------------
418 template < class T >
419 TOndemand< T >::TOndemand( unsigned long ulDatabaseID )
420 : SUPER( ulDatabaseID )
421 {
422 #ifdef _DEBUG
423 m_strDebugInfo = "TOndemand";
424 #endif
425 }
426 //---------------------------------------------------------------------------
427 template < class T >
428 TOndemand< T >::TOndemand( const ObjID & rObjID, Base & rBase )
429 : SUPER( rObjID, rBase )
430 {
431 #ifdef _DEBUG
432 m_strDebugInfo = "TOndemand";
433 #endif
434 }
435 //---------------------------------------------------------------------------
436 template < class T >
437 TOndemand< T >::TOndemand( const ObjID & rObjID, unsigned long ulDatabaseID )
438 : SUPER( rObjID, ulDatabaseID )
439 {
440 #ifdef _DEBUG
441 m_strDebugInfo = "TOndemand";
442 #endif
443 }
444 //---------------------------------------------------------------------------
445 template < class T >
447 : SUPER( rT )
448 {
449 #ifdef _DEBUG
450 m_strDebugInfo = "TOndemand";
451 #endif
452 }
453 //---------------------------------------------------------------------------
454 template < class T >
458 //---------------------------------------------------------------------------
459 template < class T >
460 int TOndemand< T >::set( const T * pObj )
461 {
462 return SUPER::setReference( pObj );
463 }
464 //---------------------------------------------------------------------------
465 template < class T >
466 int TOndemand< T >::set( const T & rObj )
467 {
468 return SUPER::setReference( rObj );
469 }
470 //---------------------------------------------------------------------------
471 template < class T >
472 int TOndemand< T >::set( const std::shared_ptr<T> & spObj )
473 {
474 return SUPER::setReference( spObj.get() );
475 }
476 //---------------------------------------------------------------------------
477 template < class T >
478 int TOndemand< T >::get( T *& prObj )
479 {
480 int t_iErr = 0;
481 BasePersistent * t_pGetObj = 0;
482
483 t_iErr = SUPER::getReference( t_pGetObj );
484 if ( ! t_iErr )
485 {
486 prObj = dynamic_cast<T*>( t_pGetObj );
487 if ( ! prObj )
488 {
489 t_pGetObj->forget();
490 t_iErr = ERR_WRONG_TYPE;
491 }
492 }
493 else
494 {
495 prObj = nullptr;
496 }
497 return t_iErr;
498 }
499 //---------------------------------------------------------------------------
500 template < class T >
501 int TOndemand< T >::get( std::shared_ptr<T> & rRetVal )
502 {
503 T * t_pPersObject = 0;
504 int t_iErr = this->get( t_pPersObject );
505
506 if ( t_pPersObject )
507 {
508 rRetVal.reset( t_pPersObject, Forgetter<T>() );
509 }
510 else
511 {
512 rRetVal.reset();
513 }
514 return t_iErr;
515 }
516 //---------------------------------------------------------------------------
517 template < class T >
519 {
520 return SUPER::setReference( rObjID );
521 }
522 //---------------------------------------------------------------------------
523 template < class T >
525 {
526 if ( this != & rT )
527 {
528 SUPER::operator=( rT );
529 }
530 return *this;
531 }
532 //---------------------------------------------------------------------------
533 template < class T >
535 {
536 if ( this != & rT )
537 {
538 SUPER::operator=( rT );
539 }
540 return *this;
541 }
542 //---------------------------------------------------------------------------
543 template < class T >
544 bool TOndemand< T >::operator== ( const TOndemand & rT ) const
545 {
546 return SUPER::operator==( rT );
547 }
548 //---------------------------------------------------------------------------
549 template < class T >
550 bool TOndemand< T >::operator!= ( const TOndemand & rT ) const
551 {
552 if ( *this == rT )
553 {
554 return false;
555 }
556 return true;
557 }
558 //---------------------------------------------------------------------------
559 #undef SUPER
560 //---------------------------------------------------------------------------
561} // namespace glo
562#endif
Header für BasePersistent
Header für ObjID
Header für Reference
#define SUPER
Definition GloTOndemand.h:389
Abstrakte Basisklasse für Persistent und die generische GenericPersistent.
Definition GloBasePersistent.h:124
virtual unsigned int forget()
std::string m_strDebugInfo
Definition GloCallBack.h:111
Ein Objekt-ID besteht aus der Klassen-ID, einer Datenbank-ID und der eigentlichen eindeutigen ObjektZ...
Definition GloObjID.h:84
Die Basisklasse eines Referenz-Attributs von persistenten Objekten auf andere persistente Objekte in ...
Definition GloReference.h:72
friend class Base
Definition GloReference.h:82
Referenz (als Attribut) eines persistenten Objekte auf ein anderes persistentes Objekt in der Datenba...
Definition GloTOndemand.h:102
bool operator==(const TOndemand &rT) const
Vergleichsoperator.
Definition GloTOndemand.h:544
int set(const T *pObj)
Definition GloTOndemand.h:460
virtual int setReference(const ObjID &rObjID) override
Definition GloTOndemand.h:518
virtual ~TOndemand()
Definition GloTOndemand.h:455
TOndemand()
Definition GloTOndemand.h:392
bool operator!=(const TOndemand &rT) const
Vergleichsoperator.
Definition GloTOndemand.h:550
TOndemand< T > & operator=(const TOndemand &rT)
Zuweisungsoperator.
Definition GloTOndemand.h:524
int get(T *&prObj)
Definition GloTOndemand.h:478
Definition GloBasePersistent.h:60