Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

IRObject.h

Go to the documentation of this file.
00001 //                            Package   : omniIFR
00002 //  IRObject.h                Created   : 2004/02/22
00003 //                            Author    : Alex Tingle
00004 //
00005 //    Copyright (C) 2004 Alex Tingle.
00006 //
00007 //    This file is part of the omniIFR application.
00008 //
00009 //    omniIFR is free software; you can redistribute it and/or
00010 //    modify it under the terms of the GNU Lesser General Public
00011 //    License as published by the Free Software Foundation; either
00012 //    version 2.1 of the License, or (at your option) any later version.
00013 //
00014 //    omniIFR is distributed in the hope that it will be useful,
00015 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 //    Lesser General Public License for more details.
00018 //
00019 //    You should have received a copy of the GNU Lesser General Public
00020 //    License along with this library; if not, write to the Free Software
00021 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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: // CORBA interface methods
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 } // end namespace Omniifr
00168 
00169 #endif // OMNIIFR__IROBJECT_H

Generated on Fri Mar 4 13:03:23 2005 for OmniIFR by  doxygen 1.4.1