ControlTaskProxy.hpp

00001 /***************************************************************************
00002   tag: Peter Soetens  Wed Jan 18 14:09:48 CET 2006  ControlTaskProxy.hpp
00003 
00004                         ControlTaskProxy.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_PROXY_HPP
00039 #define ORO_CORBA_CONTROLTASK_PROXY_HPP
00040 
00041 
00042 #include "../rtt-config.h"
00043 #ifndef _REENTRANT
00044 #define _REENTRANT
00045 #endif
00046 #include "corba.h"
00047 #ifdef CORBA_IS_TAO
00048 #include <tao/corba.h>
00049 #else
00050 #include <omniORB4/CORBA.h>
00051 #endif
00052 
00053 #include <exception>
00054 #include "../TaskContext.hpp"
00055 #include <string>
00056 #include <map>
00057 #include "ControlTaskC.h"
00058 #include "ApplicationServer.hpp"
00059 
00060 namespace RTT
00061 {namespace Corba
00062 {
00066     struct IllegalServer
00067         : public std::exception
00068     {
00069         std::string reason;
00070         IllegalServer();
00071         ~IllegalServer() throw();
00072         const char* what() const throw();
00073     };
00074 
00081     class ControlTaskProxy
00082         : public TaskContext,
00083           public ApplicationServer
00084     {
00085     public:
00086         typedef std::map<ControlTaskProxy*, Corba::ControlTask_ptr> PMap;
00087         static PMap proxies;
00088 
00089     protected:
00094         ControlTaskProxy(std::string location, bool is_ior);
00095 
00100         ControlTaskProxy( ::RTT::Corba::ControlTask_ptr t );
00101 
00102         void synchronizeOnce();
00103         void synchronize();
00104 
00105         mutable Corba::ControlTask_var mtask;
00106 
00110         static PortableServer::POA_var proxy_poa;
00111 
00112         void fetchObjects(OperationInterface* parent, ControlObject_ptr mtask);
00113     public:
00114         ~ControlTaskProxy();
00115 
00120         static bool InitOrb(int argc, char* argv[] );
00121 
00126     static bool InitOrb(int argc, char* argv[],double orb_timeout);
00127 
00131         static void DestroyOrb();
00132 
00140         static ControlTaskProxy* Create(std::string name, bool is_ior = false);
00141 
00151         static TaskContext* Create(::RTT::Corba::ControlTask_ptr task, bool force_remote = false);
00152 
00158         Corba::ControlTask_ptr server() const;
00159 
00160         virtual bool activate();
00161 
00162         virtual bool start();
00163 
00164         virtual bool stop();
00165 
00166         virtual bool isRunning() const;
00167 
00168         virtual bool configure();
00169 
00170         virtual bool cleanup();
00171 
00172         virtual bool resetError();
00173 
00174         virtual bool isActive() const;
00175 
00176         virtual bool isConfigured() const;
00177 
00178         virtual bool inFatalError() const;
00179 
00180         virtual bool inRunTimeWarning() const;
00181 
00182         virtual bool inRunTimeError() const;
00183 
00184         virtual int getErrorCount() const;
00185 
00186         virtual int getWarningCount() const;
00187 
00188         virtual TaskState getTaskState() const;
00189 
00190         virtual void setName(const std::string& n);
00191 
00192         virtual bool addPeer( TaskContext* peer, std::string alias = "" );
00193 
00194         virtual void removePeer( const std::string& name );
00195 
00196         virtual void removePeer( TaskContext* peer );
00197 
00198         virtual bool connectPeers( TaskContext* peer );
00199 
00200         virtual void disconnectPeers( const std::string& name );
00201 
00202         virtual PeerList getPeerList() const;
00203 
00204         virtual bool hasPeer( const std::string& peer_name ) const;
00205 
00206         virtual TaskContext* getPeer(const std::string& peer_name ) const;
00207 
00208         virtual bool connectPorts( TaskContext* peer );
00209 
00210         virtual bool ready();
00214         static PortableServer::POA_ptr ProxyPOA();
00215     };
00216 }}
00217 #endif

Generated on Tue Aug 25 14:17:21 2009 for Orocos Real-Time Toolkit by  doxygen 1.5.8