UniSet  1.4.0
ObjectsActivator.h
См. документацию.
00001 /* This file is part of the UniSet project
00002  * Copyright (c) 2002 Free Software Foundation, Inc.
00003  * Copyright (c) 2002 Pavel Vainerman
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018  */
00019 // --------------------------------------------------------------------------
00024 // -------------------------------------------------------------------------- 
00025 #ifndef ObjectsActivator_H_
00026 #define ObjectsActivator_H_
00027 // -------------------------------------------------------------------------- 
00028 #include <omniORB4/CORBA.h>
00029 #include "UniSetTypes.h"
00030 #include "UniSetObject.h"
00031 #include "ObjectsManager.h"
00032 #include "ThreadCreator.h"
00033 //#include "OmniThreadCreator.h"
00034 //----------------------------------------------------------------------------------------
00044 class ObjectsActivator: 
00045     public ObjectsManager
00046 {
00047     public:
00048     
00049         ObjectsActivator();
00050         ObjectsActivator( UniSetTypes::ObjectId id );
00051         virtual ~ObjectsActivator();
00052 
00053         virtual void run(bool thread);
00054         virtual void stop();
00055         virtual void oaDestroy(int signo=0);
00056         void waitDestroy();
00057         
00058         inline void oakill(int signo){ raise(signo);}
00059 
00060         virtual UniSetTypes::ObjectType getType(){ return UniSetTypes::getObjectType("ObjectsActivator"); }
00061 
00062         
00063     protected:
00064 
00065 
00069         enum AskSigCommand  {
00070                                 Ask,    
00071                                 Denial 
00072                             };
00073 
00082 //      void askSignal(int signo, AskSigCommand cmd=Ask);   
00083 
00084         virtual void work();
00085 
00086         inline CORBA::ORB_ptr getORB()
00087         {
00088             return orb;
00089         }
00090 
00091         virtual void processingMessage( UniSetTypes::VoidMessage *msg );    
00092         virtual void sysCommand( UniSetTypes::SystemMessage *sm );
00093 
00094     private:
00095 
00096 //      static void processingSignal(int signo);            
00097         static void terminated(int signo);
00098         static void finishterm(int signo);
00099         static void normalexit();
00100         static void normalterminate();
00101         static void set_signals(bool ask);
00102         void term( int signo );
00103         void init();
00104 
00105         friend class ThreadCreator<ObjectsActivator>;
00106         ThreadCreator<ObjectsActivator> *orbthr;
00107         
00108         CORBA::ORB_var orb;
00109         
00110         bool omDestroy;         
00111         bool sig;
00112         pid_t thpid; // pid orb потока
00113 
00114         struct Info
00115         {
00116             pid_t msgpid;   // pid порожденого потока обработки сообщений
00117         };
00118         
00119         struct OInfo:
00120             public Info
00121         {
00122             UniSetObject* obj;
00123         };
00124 
00125         struct MInfo:
00126             public Info
00127         {
00128             ObjectsManager* mnr;
00129         };
00130 
00131         std::list<OInfo> lstOInfo;
00132         std::list<MInfo> lstMInfo;
00133         void getinfo();     
00134 };
00135 
00136 /*
00137 template<class TClass>
00138 int ObjectsActivator::attach(TClass* p, void(TClass:: *f)(void*) )
00139 {
00140     if( next >= MAX_CHILD_THREAD )
00141         return -1;
00142 
00143     callpull[next] = new OmniThreadCreator<TClass>( p, f);                   
00144     next++;
00145     return 0;
00146 }
00147 */
00148 #endif