TaskContextI.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: The SourceWorks Tue Sep 7 00:55:18 CEST 2010 TaskContextI.cpp
3 
4  TaskContextI.cpp - description
5  -------------------
6  begin : Tue September 07 2010
7  copyright : (C) 2010 The SourceWorks
8  email : peter@thesourceworks.com
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * Lesser General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 
39 // -*- C++ -*-
40 //
41 // $Id$
42 
43 // **** Code generated by the The ACE ORB (TAO) IDL Compiler ****
44 // TAO and the TAO IDL Compiler have been developed by:
45 // Center for Distributed Object Computing
46 // Washington University
47 // St. Louis, MO
48 // USA
49 // http://www.cs.wustl.edu/~schmidt/doc-center.html
50 // and
51 // Distributed Object Computing Laboratory
52 // University of California at Irvine
53 // Irvine, CA
54 // USA
55 // http://doc.ece.uci.edu/
56 // and
57 // Institute for Software Integrated Systems
58 // Vanderbilt University
59 // Nashville, TN
60 // USA
61 // http://www.isis.vanderbilt.edu/
62 //
63 // Information about TAO is available at:
64 // http://www.cs.wustl.edu/~schmidt/TAO.html
65 
66 // TAO_IDL - Generated from
67 // ../../../ACE_wrappers/TAO/TAO_IDL/be/be_codegen.cpp:1196
68 
69 #include "TaskContextI.h"
70 #include "TaskContextServer.hpp"
71 #include "TaskContextProxy.hpp"
72 #include "ServiceI.h"
73 #include "ServiceRequesterI.h"
74 #include "DataFlowI.h"
75 #include "../../OperationCaller.hpp"
76 #include "../../rtt-detail-fwd.hpp"
77 
78 
79 using namespace RTT;
80 using namespace RTT::detail;
81 using namespace RTT::corba;
82 
83 // Implementation skeleton constructor
85  : mpoa( PortableServer::POA::_duplicate(the_poa) )
86  , mtask( orig ), mRequest_i(0), mService_i(0)
87 {
88  // Add the corba object to the interface:
89  mtask->addOperation("shutdown", &RTT_corba_CTaskContext_i::shutdownCORBA, this).doc("Shutdown CORBA ORB. This function makes RunOrb() return.");
90 }
91 
92 // Implementation skeleton destructor
94 {
95  //CDataFlowInterface_i::deregisterServant(mtask->ports()); causes invalid read (freed already)
96 }
97 
99  TaskContextServer::ShutdownOrb(false);
100 }
101 
103  void)
104 {
105  return CORBA::string_dup( mtask->getName().c_str() );
106 }
107 
109  void)
110 {
111  return CORBA::string_dup( mtask->provides()->doc().c_str() );
112 }
113 
114 ::RTT::corba::CTaskState RTT_corba_CTaskContext_i::getTaskState (
115  void)
116 {
117  return ::RTT::corba::CTaskState(mtask->getTaskState());
118 }
119 
121  void)
122 {
123  return mtask->configure();
124 }
125 
127  void)
128 {
129  return mtask->start();
130 }
131 
133  void)
134 {
135  return mtask->activate();
136 }
137 
139  void)
140 {
141  return mtask->stop();
142 }
143 
145  void)
146 {
147  return mtask->recover();
148 }
149 
151  void)
152 {
153  return mtask->cleanup();
154 }
155 
157  void)
158 {
160  return mtask->recover();
161  return false;
162 }
163 
165  void)
166 {
167  return mtask->isActive();
168 }
169 
171  void)
172 {
173  return mtask->isRunning();
174 }
175 
177  void)
178 {
179  return mtask->isConfigured();
180 }
181 
183  void)
184 {
185  return mtask->inFatalError();
186 }
187 
189  void)
190 {
191  return mtask->inRunTimeError();
192 }
193 
195  void)
196 {
197  return mtask->inException();
198 }
199 
200 ::RTT::corba::CDataFlowInterface_ptr RTT_corba_CTaskContext_i::ports (
201  void)
202 {
203  return getProvider("this");
204 }
205 
206 ::RTT::corba::CService_ptr RTT_corba_CTaskContext_i::getProvider (
207  const char * service_name)
208 {
209  if ( mtask->provides()->hasService(service_name) == false)
210  return CService::_nil();
211  // Creates Service for "this"
212  if ( CORBA::is_nil( mService ) ) {
213  log(Debug) << "Creating CService for "<< mtask->getName()<<endlog();
215  mService_i = mserv = new RTT_corba_CService_i( mtask->provides(), mpoa );
216  mService = mserv->activate_this();
217  CDataFlowInterface_i::registerServant(CDataFlowInterface::_narrow(mService), mserv);
218  }
219  // Now the this service is available, check for the service name:
220  std::string svc(service_name);
221  if ( svc == "this" )
222  return ::RTT::corba::CService::_duplicate( mService.in() );
223  return mService->getService( service_name );
224 }
225 
226 ::RTT::corba::CServiceRequester_ptr RTT_corba_CTaskContext_i::getRequester (
227  const char * service_name)
228 {
229  std::string svc(service_name);
230  if ( mtask->requires()->requiresService(service_name) == false && svc != "this")
231  return CServiceRequester::_nil();
232  // Creates service requester for "this"
233  if ( CORBA::is_nil( mRequest ) ) {
234  log(Debug) << "Creating CServiceRequester for "<< mtask->getName()<<endlog();
237  mRequest = mserv->activate_this();
238  //CServiceRequester_i::registerServant(mRequest, mtask->requires());
239  }
240  // Now the this service is available, check for the service name:
241  if ( svc == "this" )
242  return ::RTT::corba::CServiceRequester::_duplicate( mRequest.in() );
243  return mRequest->getRequest( service_name );
244 }
245 
246 ::RTT::corba::CTaskContext::CPeerNames * RTT_corba_CTaskContext_i::getPeerList (
247  void)
248 {
250  ::RTT::corba::CTaskContext::CPeerNames_var result = new ::RTT::corba::CTaskContext::CPeerNames();
251  result->length( peers.size() );
252  for (unsigned int i=0; i != peers.size(); ++i )
253  result[i] = CORBA::string_dup( peers[i].c_str() );
254 
255  return result._retn();
256 }
257 
258 ::RTT::corba::CTaskContext_ptr RTT_corba_CTaskContext_i::getPeer (
259  const char * name)
260 {
261  std::string pname(name);
262  TaskContext* task = mtask->getPeer( pname );
263  if ( task ) {
264  // create or lookup new server for this peer.
265  // do not export it to the naming service.
266  return TaskContextServer::CreateServer( task, false );
267  }
268  return RTT::corba::CTaskContext::_nil();
269 }
270 
272  const char * name)
273 {
274  std::string mname(name);
275  return mtask->hasPeer(mname);
276 }
277 
279  ::RTT::corba::CTaskContext_ptr p,
280  const char * alias)
281 {
282  std::string malias(alias);
283  if (mtask->hasPeer(alias) == false )
284  return mtask->addPeer( TaskContextProxy::Create(p), alias );
285  return false;
286 }
287 
289  const char * name)
290 {
291  std::string mname(name);
292  mtask->removePeer( mname );
293  return true;
294 }
295 
297  ::RTT::corba::CTaskContext_ptr p)
298 {
299  TaskContext* t = TaskContextProxy::Create( p );
300  return mtask->connectPeers( t );
301 }
302 
304  const char * name)
305 {
306  std::string pname(name);
307  mtask->disconnectPeers( pname );
308  return true;
309 }
310 
312  ::RTT::corba::CTaskContext_ptr p)
313 {
314  TaskContext* t = TaskContextProxy::Create( p );
315  return mtask->connectPorts( t );
316 }
317 
319  ::RTT::corba::CTaskContext_ptr p)
320 {
321  TaskContext* t = TaskContextProxy::Create( p );
322  return mtask->connectServices( t );
323 }
324 
325 ::RTT::corba::CTaskContextDescription * RTT_corba_CTaskContext_i::getCTaskContextDescription (
326  void)
327 {
328  ::RTT::corba::CTaskContextDescription_var d = new ::RTT::corba::CTaskContextDescription();
329 
330  d->mainprovider = getProvider("this");
331  ::RTT::corba::CServiceDescription_var mainprovider_description = dynamic_cast<RTT_corba_CService_i *>(mService_i.in())->getCServiceDescription();
332  d->mainprovider_description = mainprovider_description;
333 
334  d->mainrequester = getRequester("this");
335  ::RTT::corba::CServiceRequesterDescription_var requester_description = dynamic_cast<RTT_corba_CServiceRequester_i *>(mRequest_i.in())->getCServiceRequesterDescription();
336  d->mainrequester_description = requester_description;
337 
338  return d._retn();
339 }
340 
virtual ::CORBA::Boolean cleanup(void)
virtual ::CORBA::Boolean removePeer(const char *name)
The state indicating the component encountered a C++ exception.
Definition: TaskCore.hpp:103
virtual ::CORBA::Boolean start(void)
Service::shared_ptr provides()
virtual ~RTT_corba_CTaskContext_i(void)
virtual ::CORBA::Boolean inFatalError(void)
virtual ::CORBA::Boolean inRunTimeError(void)
virtual bool stop()
PortableServer::ServantBase_var mRequest_i
Definition: TaskContextI.h:98
virtual bool recover()
Definition: TaskCore.cpp:186
virtual char * getDescription(void)
virtual ::RTT::corba::CServiceRequester_ptr getRequester(const char *service_name)
virtual ::CORBA::Boolean isConfigured(void)
virtual bool connectPeers(TaskContext *peer)
virtual char * getName(void)
virtual void removePeer(const std::string &name)
virtual ::CORBA::Boolean inException(void)
PortableServer::POA_var mpoa
Definition: TaskContextI.h:92
RTT::corba::CServiceRequester_var mRequest
Definition: TaskContextI.h:96
virtual bool isConfigured() const
Definition: TaskCore.cpp:270
virtual bool activate()
Definition: TaskCore.cpp:258
virtual ::CORBA::Boolean stop(void)
virtual bool isRunning() const
Definition: TaskCore.cpp:266
virtual bool configure()
Definition: TaskCore.cpp:96
virtual ::RTT::corba::CTaskContextDescription * getCTaskContextDescription(void)
virtual TaskContext * getPeer(const std::string &peer_name) const
virtual ::CORBA::Boolean recover(void)
virtual bool inException() const
Definition: TaskCore.cpp:278
virtual bool hasPeer(const std::string &peer_name) const
virtual ::RTT::corba::CTaskState getTaskState(void)
ServiceRequester::shared_ptr requires()
virtual ::CORBA::Boolean disconnectPeers(const char *name)
virtual ::CORBA::Boolean addPeer(::RTT::corba::CTaskContext_ptr p, const char *alias)
PortableServer::ServantBase_var mService_i
Definition: TaskContextI.h:99
virtual ::CORBA::Boolean connectServices(::RTT::corba::CTaskContext_ptr p)
virtual bool inFatalError() const
Definition: TaskCore.cpp:274
virtual ::RTT::corba::CDataFlowInterface_ptr ports(void)
virtual PeerList getPeerList() const
std::vector< std::string > PeerList
virtual ::CORBA::Boolean activate(void)
virtual void disconnectPeers(const std::string &name)
RTT_corba_CTaskContext_i(RTT::TaskContext *orig, PortableServer::POA_ptr the_poa)
virtual TaskState getTaskState() const
Definition: TaskCore.cpp:78
virtual bool isActive() const
Definition: TaskCore.cpp:286
virtual bool inRunTimeError() const
Definition: TaskCore.cpp:282
virtual RTT::corba::CServiceRequester_ptr activate_this()
virtual ::RTT::corba::CTaskContext::CPeerNames * getPeerList(void)
virtual ::RTT::corba::CTaskContext_ptr getPeer(const char *name)
virtual RTT::corba::CService_ptr activate_this()
Definition: ServiceI.h:107
virtual ::CORBA::Boolean connectPeers(::RTT::corba::CTaskContext_ptr p)
virtual ::CORBA::Boolean connectPorts(::RTT::corba::CTaskContext_ptr p)
virtual bool connectPorts(TaskContext *peer)
RTT::TaskContext * mtask
Definition: TaskContextI.h:93
virtual bool connectServices(TaskContext *peer)
static Service::shared_ptr mserv
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
virtual ::RTT::corba::CService_ptr getProvider(const char *service_name)
virtual ::CORBA::Boolean resetException(void)
virtual ::CORBA::Boolean isRunning(void)
Operation< Signature > & addOperation(Operation< Signature > &op)
virtual ::CORBA::Boolean configure(void)
static Logger & log()
Definition: Logger.hpp:350
virtual ::CORBA::Boolean isActive(void)
RTT::corba::CService_var mService
Definition: TaskContextI.h:95
static Logger::LogFunction endlog()
Definition: Logger.hpp:362
virtual bool start()
virtual bool addPeer(TaskContext *peer, std::string alias="")
virtual ::CORBA::Boolean hasPeer(const char *name)
virtual bool cleanup()
Definition: TaskCore.cpp:130
virtual const std::string & getName() const


rtt
Author(s): RTT Developers
autogenerated on Tue Jun 25 2019 19:33:37