TaskContextI.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002   tag: The SourceWorks  Tue Sep 7 00:55:18 CEST 2010  TaskContextI.cpp
00003 
00004                         TaskContextI.cpp -  description
00005                            -------------------
00006     begin                : Tue September 07 2010
00007     copyright            : (C) 2010 The SourceWorks
00008     email                : peter@thesourceworks.com
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 
00039 // -*- C++ -*-
00040 //
00041 // $Id$
00042 
00043 // ****  Code generated by the The ACE ORB (TAO) IDL Compiler ****
00044 // TAO and the TAO IDL Compiler have been developed by:
00045 //       Center for Distributed Object Computing
00046 //       Washington University
00047 //       St. Louis, MO
00048 //       USA
00049 //       http://www.cs.wustl.edu/~schmidt/doc-center.html
00050 // and
00051 //       Distributed Object Computing Laboratory
00052 //       University of California at Irvine
00053 //       Irvine, CA
00054 //       USA
00055 //       http://doc.ece.uci.edu/
00056 // and
00057 //       Institute for Software Integrated Systems
00058 //       Vanderbilt University
00059 //       Nashville, TN
00060 //       USA
00061 //       http://www.isis.vanderbilt.edu/
00062 //
00063 // Information about TAO is available at:
00064 //     http://www.cs.wustl.edu/~schmidt/TAO.html
00065 
00066 // TAO_IDL - Generated from
00067 // ../../../ACE_wrappers/TAO/TAO_IDL/be/be_codegen.cpp:1196
00068 
00069 #include "TaskContextI.h"
00070 #include "TaskContextServer.hpp"
00071 #include "TaskContextProxy.hpp"
00072 #include "ServiceI.h"
00073 #include "ServiceRequesterI.h"
00074 #include "DataFlowI.h"
00075 #include "../../OperationCaller.hpp"
00076 #include "../../rtt-detail-fwd.hpp"
00077 
00078 
00079 using namespace RTT;
00080 using namespace RTT::detail;
00081 using namespace RTT::corba;
00082 
00083 // Implementation skeleton constructor
00084 RTT_corba_CTaskContext_i::RTT_corba_CTaskContext_i (RTT::TaskContext* orig, PortableServer::POA_ptr the_poa)
00085     : mpoa( PortableServer::POA::_duplicate(the_poa) )
00086     , mtask( orig ), mRequest_i(0), mService_i(0)
00087 {
00088     // Add the corba object to the interface:
00089     mtask->addOperation("shutdown", &RTT_corba_CTaskContext_i::shutdownCORBA, this).doc("Shutdown CORBA ORB. This function makes RunOrb() return.");
00090 }
00091 
00092 // Implementation skeleton destructor
00093 RTT_corba_CTaskContext_i::~RTT_corba_CTaskContext_i (void)
00094 {
00095     //CDataFlowInterface_i::deregisterServant(mtask->ports()); causes invalid read (freed already)
00096 }
00097 
00098 void RTT_corba_CTaskContext_i::shutdownCORBA() {
00099     TaskContextServer::ShutdownOrb(false);
00100 }
00101 
00102 char * RTT_corba_CTaskContext_i::getName (
00103     void)
00104 {
00105     return CORBA::string_dup( mtask->getName().c_str() );
00106 }
00107 
00108 char * RTT_corba_CTaskContext_i::getDescription (
00109     void)
00110 {
00111     return CORBA::string_dup( mtask->provides()->doc().c_str() );
00112 }
00113 
00114 ::RTT::corba::CTaskState RTT_corba_CTaskContext_i::getTaskState (
00115     void)
00116 {
00117     return ::RTT::corba::CTaskState(mtask->getTaskState());
00118 }
00119 
00120 ::CORBA::Boolean RTT_corba_CTaskContext_i::configure (
00121     void)
00122 {
00123     return mtask->configure();
00124 }
00125 
00126 ::CORBA::Boolean RTT_corba_CTaskContext_i::start (
00127     void)
00128 {
00129     return mtask->start();
00130 }
00131 
00132 ::CORBA::Boolean RTT_corba_CTaskContext_i::activate (
00133     void)
00134 {
00135     return mtask->activate();
00136 }
00137 
00138 ::CORBA::Boolean RTT_corba_CTaskContext_i::stop (
00139     void)
00140 {
00141     return mtask->stop();
00142 }
00143 
00144 ::CORBA::Boolean RTT_corba_CTaskContext_i::cleanup (
00145     void)
00146 {
00147     return mtask->cleanup();
00148 }
00149 
00150 ::CORBA::Boolean RTT_corba_CTaskContext_i::resetException (
00151     void)
00152 {
00153     if (mtask->getTaskState() == RTT::TaskContext::Exception)
00154         return mtask->recover();
00155     return false;
00156 }
00157 
00158 ::CORBA::Boolean RTT_corba_CTaskContext_i::isActive (
00159     void)
00160 {
00161     return mtask->isActive();
00162 }
00163 
00164 ::CORBA::Boolean RTT_corba_CTaskContext_i::isRunning (
00165     void)
00166 {
00167     return mtask->isRunning();
00168 }
00169 
00170 ::CORBA::Boolean RTT_corba_CTaskContext_i::isConfigured (
00171     void)
00172 {
00173     return mtask->isConfigured();
00174 }
00175 
00176 ::CORBA::Boolean RTT_corba_CTaskContext_i::inFatalError (
00177     void)
00178 {
00179     return mtask->inFatalError();
00180 }
00181 
00182 ::CORBA::Boolean RTT_corba_CTaskContext_i::inRunTimeError (
00183     void)
00184 {
00185     return mtask->inRunTimeError();
00186 }
00187 
00188 ::RTT::corba::CDataFlowInterface_ptr RTT_corba_CTaskContext_i::ports (
00189     void)
00190 {
00191     return getProvider("this");
00192 }
00193 
00194 ::RTT::corba::CService_ptr RTT_corba_CTaskContext_i::getProvider (
00195     const char * service_name)
00196 {
00197     if ( mtask->provides()->hasService(service_name) == false)
00198         return CService::_nil();
00199     // Creates Service for "this"
00200     if ( CORBA::is_nil( mService ) ) {
00201         log(Debug) << "Creating CService for "<< mtask->getName()<<endlog();
00202         RTT_corba_CService_i* mserv;
00203         mService_i = mserv = new RTT_corba_CService_i( mtask->provides(), mpoa );
00204         mService = mserv->activate_this();
00205         CDataFlowInterface_i::registerServant(CDataFlowInterface::_narrow(mService), mserv);
00206     }
00207     // Now the this service is available, check for the service name:
00208     std::string svc(service_name);
00209     if ( svc == "this" )
00210         return ::RTT::corba::CService::_duplicate( mService.in() );
00211     return mService->getService( service_name );
00212 }
00213 
00214 ::RTT::corba::CServiceRequester_ptr RTT_corba_CTaskContext_i::getRequester (
00215     const char * service_name)
00216 {
00217     std::string svc(service_name);
00218     if ( mtask->requires()->requiresService(service_name) == false && svc != "this")
00219         return CServiceRequester::_nil();
00220     // Creates service requester for "this"
00221     if ( CORBA::is_nil( mRequest ) ) {
00222         log(Debug) << "Creating CServiceRequester for "<< mtask->getName()<<endlog();
00223         RTT_corba_CServiceRequester_i* mserv;
00224         mRequest_i = mserv = new RTT_corba_CServiceRequester_i( mtask->requires(), mpoa );
00225         mRequest = mserv->activate_this();
00226         //CServiceRequester_i::registerServant(mRequest, mtask->requires());
00227     }
00228     // Now the this service is available, check for the service name:
00229     if ( svc == "this" )
00230         return ::RTT::corba::CServiceRequester::_duplicate( mRequest.in() );
00231     return mRequest->getRequest( service_name );
00232 }
00233 
00234 ::RTT::corba::CTaskContext::CPeerNames * RTT_corba_CTaskContext_i::getPeerList (
00235     void)
00236 {
00237     TaskContext::PeerList peers = mtask->getPeerList();
00238     ::RTT::corba::CTaskContext::CPeerNames_var result = new ::RTT::corba::CTaskContext::CPeerNames();
00239     result->length( peers.size() );
00240     for (unsigned int i=0; i != peers.size(); ++i )
00241         result[i] = CORBA::string_dup( peers[i].c_str() );
00242 
00243     return result._retn();
00244 }
00245 
00246 ::RTT::corba::CTaskContext_ptr RTT_corba_CTaskContext_i::getPeer (
00247     const char * name)
00248 {
00249     std::string pname(name);
00250     TaskContext* task = mtask->getPeer( pname );
00251     if ( task ) {
00252         // create or lookup new server for this peer.
00253         // do not export it to the naming service.
00254         return TaskContextServer::CreateServer( task, false );
00255     }
00256     return RTT::corba::CTaskContext::_nil();
00257 }
00258 
00259 ::CORBA::Boolean RTT_corba_CTaskContext_i::hasPeer (
00260     const char * name)
00261 {
00262     std::string mname(name);
00263     return mtask->hasPeer(mname);
00264 }
00265 
00266 ::CORBA::Boolean RTT_corba_CTaskContext_i::addPeer (
00267     ::RTT::corba::CTaskContext_ptr p,
00268     const char * alias)
00269 {
00270     std::string malias(alias);
00271     if (mtask->hasPeer(alias) == false )
00272         return mtask->addPeer( TaskContextProxy::Create(p), alias );
00273     return false;
00274 }
00275 
00276 ::CORBA::Boolean RTT_corba_CTaskContext_i::removePeer (
00277     const char * name)
00278 {
00279     std::string mname(name);
00280     mtask->removePeer( mname );
00281     return true;
00282 }
00283 
00284 ::CORBA::Boolean RTT_corba_CTaskContext_i::connectPeers (
00285     ::RTT::corba::CTaskContext_ptr p)
00286 {
00287     TaskContext* t = TaskContextProxy::Create( p );
00288     return mtask->connectPeers( t );
00289 }
00290 
00291 ::CORBA::Boolean RTT_corba_CTaskContext_i::disconnectPeers (
00292     const char * name)
00293 {
00294     std::string pname(name);
00295     mtask->disconnectPeers( pname );
00296     return true;
00297 }
00298 
00299 ::CORBA::Boolean RTT_corba_CTaskContext_i::connectPorts (
00300     ::RTT::corba::CTaskContext_ptr p)
00301 {
00302     TaskContext* t = TaskContextProxy::Create( p );
00303     return mtask->connectPorts( t );
00304 }
00305 
00306 ::CORBA::Boolean RTT_corba_CTaskContext_i::connectServices (
00307     ::RTT::corba::CTaskContext_ptr p)
00308 {
00309     TaskContext* t = TaskContextProxy::Create( p );
00310     return mtask->connectServices( t );
00311 }
00312 
00313 


rtt
Author(s): RTT Developers
autogenerated on Thu Jan 2 2014 11:35:39