|
UniSet
2.2.1
|
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 UniSetActivator_H_ 00026 #define UniSetActivator_H_ 00027 // -------------------------------------------------------------------------- 00028 #include <deque> 00029 #include <memory> 00030 #include <omniORB4/CORBA.h> 00031 #include <cc++/socket.h> 00032 #include "UniSetTypes.h" 00033 #include "UniSetObject.h" 00034 #include "UniSetManager.h" 00035 #include "OmniThreadCreator.h" 00036 //---------------------------------------------------------------------------------------- 00037 class UniSetActivator; 00038 typedef std::shared_ptr<UniSetActivator> UniSetActivatorPtr; 00039 //---------------------------------------------------------------------------------------- 00053 class UniSetActivator: 00054 public UniSetManager 00055 { 00056 public: 00057 00058 static UniSetActivatorPtr Instance( const UniSetTypes::ObjectId id = UniSetTypes::DefaultObjectId ); 00059 void Destroy(); 00060 00061 std::shared_ptr<UniSetActivator> get_aptr() 00062 { 00063 return std::dynamic_pointer_cast<UniSetActivator>(get_ptr()); 00064 } 00065 // ------------------------------------ 00066 virtual ~UniSetActivator(); 00067 00068 virtual void run(bool thread); 00069 virtual void stop(); 00070 virtual void uaDestroy(int signo = 0); 00071 00072 virtual UniSetTypes::ObjectType getType() override 00073 { 00074 return UniSetTypes::ObjectType("UniSetActivator"); 00075 } 00076 00077 typedef sigc::signal<void, int> TerminateEvent_Signal; 00078 TerminateEvent_Signal signal_terminate_event(); 00079 00080 protected: 00081 00082 virtual void work(); 00083 00084 inline CORBA::ORB_ptr getORB() 00085 { 00086 return orb; 00087 } 00088 00089 virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) override; 00090 00091 // уносим в protected, т.к. Activator должен быть только один.. 00092 UniSetActivator(); 00093 UniSetActivator( const UniSetTypes::ObjectId id ); 00094 static std::shared_ptr<UniSetActivator> inst; 00095 00096 private: 00097 friend void terminate_thread(); 00098 friend void finished_thread(); 00099 friend std::shared_ptr<UniSetTypes::Configuration> UniSetTypes::uniset_init( int argc, const char* const* argv, const std::string& xmlfile ); 00100 00101 static void terminated(int signo); 00102 static void normalexit(); 00103 static void normalterminate(); 00104 static void set_signals(bool ask); 00105 void term( int signo ); 00106 void init(); 00107 00108 std::shared_ptr< OmniThreadCreator<UniSetActivator> > orbthr; 00109 00110 CORBA::ORB_var orb; 00111 TerminateEvent_Signal s_term; 00112 00113 std::atomic_bool omDestroy; 00114 pid_t thpid; // pid orb потока 00115 }; 00116 //---------------------------------------------------------------------------------------- 00117 #endif 00118 //----------------------------------------------------------------------------------------
1.7.6.1