GlobalObjects
Lade ...
Suche ...
Keine Treffer
GloTOndemand.h
gehe zur Dokumentation dieser Datei
1#ifndef INC_GLOTONDEMAND_H
2#define INC_GLOTONDEMAND_H
3//-----------------------------------------------------------------------------
36//-----------------------------------------------------------------------------
37#include "GloTypes.h"
38#include "GloReference.h"
39#include "GloBase.h"
40#include "GloObjID.h"
41#include "GloBasePersistent.h"
42//-----------------------------------------------------------------------------
43namespace glo
44{
45 //---------------------------------------------------------------------------
89 template < class T > class TOndemand : public Reference
90 {
91 public:
92 //============== Konstruktoren
93 //-----------------------------------------------------------------------
103 TOndemand();
104 //-----------------------------------------------------------------------
118 TOndemand( const ObjID & rObjID );
119 //-----------------------------------------------------------------------
133 TOndemand( Base & rBase );
134 //-----------------------------------------------------------------------
150 TOndemand( const ObjID & rObjID, Base & rBase );
151 //-----------------------------------------------------------------------
163 TOndemand( const TOndemand & rT );
164 //-----------------------------------------------------------------------
174 virtual ~TOndemand();
175 //-----------------------------------------------------------------------
176
177 //============== Methoden
178 //-----------------------------------------------------------------------
196 int set( const T * pObj );
197 //-----------------------------------------------------------------------
215 int set( const T & rObj );
216 //-----------------------------------------------------------------------
234 int set( const std::shared_ptr<T> & spObj );
235 //-----------------------------------------------------------------------
255 int get( T *& prObj ) const;
256 //-----------------------------------------------------------------------
272 int get( std::shared_ptr<T> & rRetVal ) const;
273 //-----------------------------------------------------------------------
289 virtual void setReference( const ObjID & rObjID );
290 //-----------------------------------------------------------------------
291
292 public:
293 //============== Operatoren
294 //-----------------------------------------------------------------------
296
307 TOndemand< T > & operator= ( const TOndemand & rT );
308 TOndemand< T > & operator= ( const Reference & rT );
310 //-----------------------------------------------------------------------
312
323 bool operator== ( const TOndemand & rT ) const;
324 bool operator!= ( const TOndemand & rT ) const;
326 //-----------------------------------------------------------------------
327 };
328 //---------------------------------------------------------------------------
329 #define SUPER Reference
330 //---------------------------------------------------------------------------
331 template < class T >
333 : SUPER()
334 {
335 #ifdef _DEBUG
336 m_strDebugInfo = "TOndemand";
337 #endif
338 }
339 //---------------------------------------------------------------------------
340 template < class T >
342 : SUPER( rObjID )
343 {
344 #ifdef _DEBUG
345 m_strDebugInfo = "TOndemand";
346 #endif
347 }
348 //---------------------------------------------------------------------------
349 template < class T >
351 : SUPER( rBase )
352 {
353 #ifdef _DEBUG
354 m_strDebugInfo = "TOndemand";
355 #endif
356 }
357 //---------------------------------------------------------------------------
358 template < class T >
360 Base & rBase )
361 : SUPER( rObjID, rBase )
362 {
363 #ifdef _DEBUG
364 m_strDebugInfo = "TOndemand";
365 #endif
366 }
367 //---------------------------------------------------------------------------
368 template < class T >
370 : SUPER( rT )
371 {
372 #ifdef _DEBUG
373 m_strDebugInfo = "TOndemand";
374 #endif
375 }
376 //---------------------------------------------------------------------------
377 template < class T >
381 //---------------------------------------------------------------------------
382 template < class T >
383 int TOndemand< T >::set( const T * pObj )
384 {
385 return SUPER::setReference( pObj );
386 }
387 //---------------------------------------------------------------------------
388 template < class T >
389 int TOndemand< T >::set( const T & rObj )
390 {
391 return SUPER::setReference( rObj );
392 }
393 //---------------------------------------------------------------------------
394 template < class T >
395 int TOndemand< T >::set( const std::shared_ptr<T> & spObj )
396 {
397 return SUPER::setReference( spObj.get() );
398 }
399 //---------------------------------------------------------------------------
400 template < class T >
401 int TOndemand< T >::get( T *& prObj ) const
402 {
403 int t_iErr = 0;
404 BasePersistent * t_pGetObj = 0;
405
406 t_iErr = SUPER::getReference( t_pGetObj );
407 if ( ! t_iErr )
408 {
409 prObj = dynamic_cast<T*>( t_pGetObj );
410 if ( ! prObj )
411 {
412 t_pGetObj->forget();
413 t_iErr = ERR_WRONG_TYPE;
414 }
415 }
416 return t_iErr;
417 }
418 //---------------------------------------------------------------------------
419 template < class T >
420 int TOndemand< T >::get( std::shared_ptr<T> & rRetVal ) const
421 {
422 T * t_pPersObject = 0;
423 int t_iErr = this->get( t_pPersObject );
424
425 if ( t_pPersObject )
426 {
427 //rRetVal = std::shared_ptr<T>( t_pPersObject, Forgeter<T>() );
428 rRetVal.reset( t_pPersObject, Forgeter<T>() );
429 }
430 return t_iErr;
431 }
432 //---------------------------------------------------------------------------
433 template < class T >
434 void TOndemand< T >::setReference( const ObjID & rObjID )
435 {
436 SUPER::setReference( rObjID );
437 }
438 //---------------------------------------------------------------------------
439 template < class T >
441 {
442 if ( this != & rT )
443 {
444 SUPER::operator=( rT );
445 }
446 return *this;
447 }
448 //---------------------------------------------------------------------------
449 template < class T >
451 {
452 if ( this != & rT )
453 {
454 SUPER::operator=( rT );
455 }
456 return *this;
457 }
458 //---------------------------------------------------------------------------
459 template < class T >
460 bool TOndemand< T >::operator== ( const TOndemand & rT ) const
461 {
462 return SUPER::operator==( rT );
463 }
464 //---------------------------------------------------------------------------
465 template < class T >
466 bool TOndemand< T >::operator!= ( const TOndemand & rT ) const
467 {
468 if ( *this == rT )
469 {
470 return false;
471 }
472 return true;
473 }
474 //---------------------------------------------------------------------------
475 #undef SUPER
476 //---------------------------------------------------------------------------
477} // namespace glo
478#endif
Header für Base
Header für BasePersistent
Header für ObjID
Header für Reference
#define SUPER
Definition GloTAllSet.h:1151
Für jede Bibliothek, hier 'GlobalObjects' gibt es eine Typen-Datei.
Diese Klasse ist die Schnittstelle zu den persistenten Objekten. Hier können "Objekte" angemeldet,...
Definition GloBase.h:250
Abstrakte Basisklasse für Persistent und die generische GenericPersistent.
Definition GloBasePersistent.h:102
virtual unsigned int forget()
std::string m_strDebugInfo
Definition GloCallBack.h:115
Speziel für GenericPersistent oder abgeleitete Klassen von Persistent die Forget-Methode für std::sha...
Definition GloTypes.h:1249
Ein Objekt-ID besteht aus der Klassen-ID, einer Datenbank-ID und der eigentlichen eindeutigen ObjektZ...
Definition GloObjID.h:77
Die Basisklasse eines Referenz-Attributs von persistenten Objekten auf andere persistente Objekte in ...
Definition GloReference.h:65
Referenz (als Attribut) eines persistenten Objekte auf ein anderes persistentes Objekt in der Datenba...
Definition GloTOndemand.h:90
bool operator==(const TOndemand &rT) const
Vergleichsoperator.
Definition GloTOndemand.h:460
int set(const T *pObj)
Definition GloTOndemand.h:383
virtual ~TOndemand()
Definition GloTOndemand.h:378
virtual void setReference(const ObjID &rObjID)
Definition GloTOndemand.h:434
TOndemand()
Definition GloTOndemand.h:332
bool operator!=(const TOndemand &rT) const
Vergleichsoperator.
Definition GloTOndemand.h:466
int get(T *&prObj) const
Definition GloTOndemand.h:401
TOndemand< T > & operator=(const TOndemand &rT)
Zuweisungsoperator.
Definition GloTOndemand.h:440
Definition GloAbstractBaseLot.h:42
@ ERR_WRONG_TYPE
Definition GloErrors.h:540