Orocos Real-Time Toolkit  2.6.0
TaskContextServer.hpp
00001 /***************************************************************************
00002   tag: Peter Soetens  Wed Jan 18 14:09:48 CET 2006  TaskContextServer.hpp
00003 
00004                         TaskContextServer.hpp -  description
00005                            -------------------
00006     begin                : Wed January 18 2006
00007     copyright            : (C) 2006 Peter Soetens
00008     email                : peter.soetens@fmtc.be
00009 
00010  ***************************************************************************
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU General Public                   *
00013  *   License as published by the Free Software Foundation;                 *
00014  *   version 2 of the License.                                             *
00015  *                                                                         *
00016  *   As a special exception, you may use this file as part of a free       *
00017  *   software library without restriction.  Specifically, if other files   *
00018  *   instantiate templates or use macros or inline functions from this     *
00019  *   file, or you compile this file and link it with other files to        *
00020  *   produce an executable, this file does not by itself cause the         *
00021  *   resulting executable to be covered by the GNU General Public          *
00022  *   License.  This exception does not however invalidate any other        *
00023  *   reasons why the executable file might be covered by the GNU General   *
00024  *   Public License.                                                       *
00025  *                                                                         *
00026  *   This library is distributed in the hope that it will be useful,       *
00027  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00028  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00029  *   Lesser General Public License for more details.                       *
00030  *                                                                         *
00031  *   You should have received a copy of the GNU General Public             *
00032  *   License along with this library; if not, write to the Free Software   *
00033  *   Foundation, Inc., 59 Temple Place,                                    *
00034  *   Suite 330, Boston, MA  02111-1307  USA                                *
00035  *                                                                         *
00036  ***************************************************************************/
00037 
00038 #ifndef ORO_CORBA_CONTROLTASK_SERVER_HPP
00039 #define ORO_CORBA_CONTROLTASK_SERVER_HPP
00040 
00041 #include <map>
00042 #ifndef _REENTRANT
00043 #define _REENTRANT
00044 #endif
00045 #include "corba.h"
00046 #ifdef CORBA_IS_TAO
00047 #include "TaskContextS.h"
00048 #else
00049 #include "TaskContextC.h"
00050 #endif
00051 #include "../../TaskContext.hpp"
00052 #include "ApplicationServer.hpp"
00053 #include "../../base/ActivityInterface.hpp"
00054 
00055 class RTT_corba_CTaskContext_i;
00056 namespace RTT
00057 {namespace corba
00058 {
00065     class RTT_CORBA_API TaskContextServer
00066         : public ApplicationServer
00067     {
00068     protected:
00069         friend class OrbRunner;
00070         friend class TaskContextProxy;
00071 
00072         typedef std::map<TaskContext*, TaskContextServer*> ServerMap;
00073         static ServerMap servers;
00074         static base::ActivityInterface* orbrunner;
00075         static bool is_shutdown;
00076 
00077         PortableServer::POA_var mpoa;
00078 
00079     typedef std::map<TaskContext*, std::string> IorMap;
00080     static IorMap iors;
00081 
00085         TaskContextServer(TaskContext* taskcontext, bool use_naming, bool require_name_service);
00086 
00087         PortableServer::ServantBase_var mtask_i;
00088         corba::CTaskContext_var mtask;
00089         TaskContext* mtaskcontext;
00090         bool muse_naming;
00091 
00096         static void DoShutdownOrb(bool wait_for_completion = true);
00097     public:
00098 
00103         ~TaskContextServer();
00104 
00110         static void ShutdownOrb(bool wait_for_completion = true);
00111 
00115         static void CleanupServers();
00116 
00121         static void RunOrb();
00122 
00128         static void ThreadOrb();
00129 
00133         static void DestroyOrb();
00134 
00144         static TaskContextServer* Create(TaskContext* tc, bool use_naming = true, bool require_name_service = false);
00145 
00159         static CTaskContext_ptr CreateServer(TaskContext* tc, bool use_naming = true, bool require_name_service = false);
00160 
00165         static void CleanupServer( TaskContext* tc );
00166 
00173         CTaskContext_ptr server() const;
00174 
00180     static std::string getIOR(TaskContext* tc);
00181 
00182 
00183     };
00184 }}
00185 #endif