00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef OMNIIFR__IROBJECT_H
00024 #define OMNIIFR__IROBJECT_H
00025
00026 #ifdef HAVE_CONFIG_H
00027 # include "config.h"
00028 #endif
00029
00030 #include <omniORB4/CORBA.h>
00031
00032 #include <assert.h>
00033 #include <set>
00034
00035 #ifdef HAVE_IOSTREAM
00036 # include <iostream>
00037 #else
00038 # include <iostream.h>
00039 #endif
00040
00041 #ifdef HAVE_STD_STL
00042 using namespace std;
00043 #endif
00044
00045 #ifdef HAVE_OMNIORB4
00046 # define IFELSE_OMNIORB4(omniORB4_code,default_code) omniORB4_code
00047 #else
00048 # define IFELSE_OMNIORB4(omniORB4_code,default_code) default_code
00049 #endif
00050
00051 #define DB(l,x) {if(omniORB::trace(l)){omniORB::logger log("omniIFR: ");log<<x<<"\n";}}
00052
00054 #define getAttr(x) if(x) return x->_this(); else throw CORBA::BAD_INV_ORDER();
00055
00056 namespace Omniifr {
00057
00058 class Repository_impl;
00059 class IRObject_impl;
00060 class PersistNode;
00061
00063 class DependencyBase
00064 {
00065 public:
00066 DependencyBase(IRObject_impl* owner):_owner(owner){assert(owner);}
00067 virtual ~DependencyBase(){}
00068 inline IRObject_impl* owner() const {return _owner;}
00069 private:
00070 DependencyBase();
00071 IRObject_impl* _owner;
00072 };
00073
00074
00075 class IRObject_impl :
00076 public virtual PortableServer::RefCountServantBase,
00077 public virtual POA_CORBA::IRObject
00078 {
00079 public:
00080 virtual CORBA::DefinitionKind def_kind() =0;
00081 virtual void destroy();
00082
00083 private:
00084 multiset<const DependencyBase*> _dependencies;
00085 bool _activated;
00086
00087 public:
00088 IRObject_impl():_activated(false){}
00089 virtual ~IRObject_impl()
00090 {
00091 if(!_dependencies.empty())
00092 DB(1,"Destructed object still has dependencies. Wait for it...")
00093 }
00094
00096 void activateObject();
00097 void activateObjectWithId(const char* oidStr);
00098 void deactivateObject();
00099
00103 virtual PortableServer::POA_ptr _default_POA();
00104
00109 void depend(const DependencyBase* dependency)
00110 {
00111 _add_ref();
00112 _dependencies.insert(dependency);
00113 }
00117 void undepend(const DependencyBase* dependency)
00118 {
00119 _dependencies.erase(dependency);
00120 _remove_ref();
00121 }
00122
00126 virtual void dependentObjectSet(set<const IRObject_impl*>& result) const
00127 {
00128 for(multiset<const DependencyBase*>::const_iterator i=_dependencies.begin();
00129 i!=_dependencies.end();
00130 ++i)
00131 {
00132 result.insert((**i).owner());
00133 }
00134 }
00135
00139 virtual void containedObjectSet(set<const IRObject_impl*>& result) const
00140 {
00141 result.insert(this);
00142 }
00143
00145 virtual void uncheckedDestroy()=0;
00146
00148 virtual void reincarnate(const PersistNode& node);
00149
00151 virtual void output(ostream &os) =0;
00152
00154 void outputOid(ostream &os);
00155
00164 bool checkReadonly() const;
00165 };
00166
00167 }
00168
00169 #endif // OMNIIFR__IROBJECT_H