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 #include "CorbaLib.hpp"
71 
72 using namespace RTT;
73 using namespace RTT::detail;
74 
75 // Implementation skeleton constructor
77  : RTT_corba_CConfigurationInterface_i( service.get(), PortableServer::POA::_duplicate( poa) ),
78  RTT_corba_COperationInterface_i( service.get(), PortableServer::POA::_duplicate( poa) ),
79  RTT::corba::CDataFlowInterface_i( service.get(), PortableServer::POA::_duplicate( poa) ),
80  mpoa(poa), mservice(service)
81 {
82 }
83 
84 // Implementation skeleton destructor
86 {
87 }
88 
89 PortableServer::POA_ptr RTT_corba_CService_i::_default_POA()
90 {
91  return PortableServer::POA::_duplicate(mpoa);
92 }
93 
95  void)
96 {
98  return CORBA::string_dup( service->getName().c_str() );
99 }
100 
102  void)
103 {
104  Service::shared_ptr service(mservice);
105  return CORBA::string_dup( service->doc().c_str() );
106 }
107 
108 ::RTT::corba::CService::CProviderNames * RTT_corba_CService_i::getProviderNames (
109  void)
110 {
111  Service::shared_ptr service(mservice);
112  Service::ProviderNames names = service->getProviderNames();
113  ::RTT::corba::CService::CProviderNames_var result = new ::RTT::corba::CService::CProviderNames();
114  result->length( names.size() );
115  for (unsigned int i=0; i != names.size(); ++i )
116  result[i] = CORBA::string_dup( names[i].c_str() );
117 
118  return result._retn();
119 }
120 
121 ::RTT::corba::CService_ptr RTT_corba_CService_i::getService (
122  const char * service_name)
123 {
124  std::string svc(service_name);
125  if ( svc == "this" )
126  return _this();
127 
128  Service::shared_ptr service(mservice);
129  Service::shared_ptr provider = service->getService(svc);
130  if ( !provider )
131  return RTT::corba::CService::_nil();
132 
133  // Creates service requester
134  if ( mservs.find(svc) == mservs.end() ) {
135  log(Debug) << "Creating CService for "<< service_name <<endlog();
136 
137  RTT_corba_CService_i* serv_i;
138  RTT::corba::CService_ptr serv;
139  serv_i = new RTT_corba_CService_i( provider, mpoa );
140  serv = serv_i->activate_this();
141  mservs[svc] = std::pair<RTT::corba::CService_var,PortableServer::ServantBase_var>(serv, serv_i);
142  }
143  // Now return it.
144  return RTT::corba::CService::_duplicate( mservs[svc].first.in() );
145 }
146 
148  const char * name)
149 {
150  Service::shared_ptr service(mservice);
151  return service->hasService( name );
152 }
153 
154 ::RTT::corba::CServiceDescription * RTT_corba_CService_i::getCServiceDescription (
155  void)
156 {
157  Service::shared_ptr service(mservice);
158  ::RTT::corba::CServiceDescription_var d = new ::RTT::corba::CServiceDescription;
159  unsigned int j = 0;
160 
161  d->name = getName();
162  d->description = getServiceDescription();
163 
164  ::RTT::corba::COperationInterface::COperationDescriptions_var operations = getOperations();
165  d->operations = operations;
166 
167  ::RTT::corba::CDataFlowInterface::CPortDescriptions_var ports = getPortDescriptions();
168  d->ports = ports;
169 
170  ::RTT::corba::CConfigurationInterface::CPropertyNames_var properties = getPropertyList();
171  d->properties = properties;
172 
173  ::RTT::corba::CConfigurationInterface::CAttributeNames_var attributes = getAttributeList();
174  d->attributes = attributes;
175 
176  // Child services
177  Service::ProviderNames providers = service->getProviderNames();
178  d->children.length( providers.size() );
179  d->children_descriptions.length( providers.size() );
180  j = 0;
181  for (unsigned int i=0; i != providers.size(); ++i )
182  {
183  if (providers[i] == "this") continue;
184 
185  // omit PortObject services
186  if (service->getPort(providers[i])) continue;
187 
188  ::RTT::corba::CService_ptr provider = getService(providers[i].c_str());
189  Servants::const_iterator it = mservs.find(providers[i]);
190  if (it != mservs.end()) {
191  RTT_corba_CService_i *child = dynamic_cast<RTT_corba_CService_i *>(it->second.second.in());
192  if (child) {
193  ::RTT::corba::CServiceDescription_var child_description = child->getCServiceDescription();
194  d->children[j] = provider;
195  d->children_descriptions[j] = child_description;
196  j++;
197  }
198  break;
199  }
200  }
201  d->children.length(j); // set real size
202  d->children_descriptions.length(j); // set real size
203 
204  return d._retn();
205 }
virtual ::CORBA::Boolean hasService(const char *name)
Definition: ServiceI.cpp:147
virtual ::RTT::corba::CService_ptr getService(const char *name)
Definition: ServiceI.cpp:121
def child(e, n)
Definition: svn2log.py:78
virtual char * getName(void)
Definition: ServiceI.cpp:94
virtual ::RTT::corba::CConfigurationInterface::CPropertyNames * getPropertyList(void)
virtual ::RTT::corba::CConfigurationInterface::CAttributeNames * getAttributeList(void)
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:85
boost::shared_ptr< Service > shared_ptr
Definition: Service.hpp:101
virtual RTT::corba::COperationInterface::COperationDescriptions * getOperations(void)
PortableServer::POA_ptr _default_POA()
Definition: ServiceI.cpp:89
RTT_corba_CService_i(RTT::ServicePtr service, PortableServer::POA_ptr poa)
Definition: ServiceI.cpp:76
virtual RTT::corba::CService_ptr activate_this()
Definition: ServiceI.h:107
virtual ::RTT::corba::CService::CProviderNames * getProviderNames(void)
Definition: ServiceI.cpp:108
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
static Logger & log()
Definition: Logger.hpp:350
static Logger::LogFunction endlog()
Definition: Logger.hpp:362
virtual char * getServiceDescription(void)
Definition: ServiceI.cpp:101
virtual ::RTT::corba::CServiceDescription * getCServiceDescription(void)
Definition: ServiceI.cpp:154
boost::weak_ptr< RTT::Service > mservice
Definition: ServiceI.h:96


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