Orocos Real-Time Toolkit  2.8.3
ServiceI.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: The SourceWorks Tue Sep 7 00:55:18 CEST 2010 ServiceI.cpp
3 
4  ServiceI.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 "ServiceI.h"
70 
71 using namespace RTT;
72 using namespace RTT::detail;
73 
74 // Implementation skeleton constructor
76  : RTT_corba_CConfigurationInterface_i( service.get(), PortableServer::POA::_duplicate( poa) ),
77  RTT_corba_COperationInterface_i( service.get(), PortableServer::POA::_duplicate( poa) ),
78  RTT::corba::CDataFlowInterface_i( service.get(), PortableServer::POA::_duplicate( poa) ),
79  mpoa(poa), mservice(service)
80 {
81 }
82 
83 // Implementation skeleton destructor
85 {
86 }
87 
88 PortableServer::POA_ptr RTT_corba_CService_i::_default_POA()
89 {
90  return PortableServer::POA::_duplicate(mpoa);
91 }
92 
94  void)
95 {
96  return CORBA::string_dup( mservice->getName().c_str() );
97 }
98 
100  void)
101 {
102  return CORBA::string_dup( mservice->doc().c_str() );
103 }
104 
106  void)
107 {
108  Service::ProviderNames names = mservice->getProviderNames();
109  ::RTT::corba::CService::CProviderNames_var result = new ::RTT::corba::CService::CProviderNames();
110  result->length( names.size() );
111  for (unsigned int i=0; i != names.size(); ++i )
112  result[i] = CORBA::string_dup( names[i].c_str() );
113 
114  return result._retn();
115 }
116 
117 ::RTT::corba::CService_ptr RTT_corba_CService_i::getService (
118  const char * service_name)
119 {
120  Service::shared_ptr provider = mservice->getService(service_name);
121  if ( !provider )
122  return RTT::corba::CService::_nil();
123 
124  // check for existing service
125  for(Servants::iterator it = mservs.begin(); it != mservs.end(); ++it) {
126  CORBA::String_var sname = it->first->getName();
127  if ( sname.in() == service_name )
128  return RTT::corba::CService::_duplicate( it->first.in() );
129  }
130  // not found: new service
131 
132  RTT_corba_CService_i* serv_i;
133  RTT::corba::CService_var serv;
134  serv_i = new RTT_corba_CService_i( provider, mpoa );
135  serv = serv_i->activate_this();
136  mservs.push_back( std::pair<RTT::corba::CService_var,PortableServer::ServantBase_var>( RTT::corba::CService::_duplicate(serv.in()), serv_i ) );
137  //CService_i::registerServant(serv, mtask->provides(service_name));
138  return RTT::corba::CService::_duplicate( serv.in() );
139 }
140 
142  const char * name)
143 {
144  return mservice->hasService( name );
145 }
virtual ::CORBA::Boolean hasService(const char *name)
Definition: ServiceI.cpp:141
virtual ::RTT::corba::CService_ptr getService(const char *name)
Definition: ServiceI.cpp:117
virtual char * getName(void)
Definition: ServiceI.cpp:93
std::vector< std::string > ProviderNames
Definition: Service.hpp:103
PortableServer::POA_var mpoa
Definition: ServiceI.h:95
virtual ~RTT_corba_CService_i(void)
Definition: ServiceI.cpp:84
boost::shared_ptr< Service > shared_ptr
Definition: Service.hpp:101
PortableServer::POA_ptr _default_POA()
Definition: ServiceI.cpp:88
Convenient short notation for every sub-namespace of RTT.
sequence< string > CProviderNames
Definition: Service.idl:24
RTT_corba_CService_i(RTT::ServicePtr service, PortableServer::POA_ptr poa)
Definition: ServiceI.cpp:75
RTT::Service::shared_ptr mservice
Definition: ServiceI.h:96
virtual RTT::corba::CService_ptr activate_this()
Definition: ServiceI.h:107
virtual ::RTT::corba::CService::CProviderNames * getProviderNames(void)
Definition: ServiceI.cpp:105
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:51
Represents a remote data flow interface.
Definition: DataFlowI.h:111
virtual char * getServiceDescription(void)
Definition: ServiceI.cpp:99