ServiceRequester.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: The SourceWorks Tue Sep 7 00:55:18 CEST 2010 ServiceRequester.hpp
3 
4  ServiceRequester.hpp - 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 #ifndef ORO_SERVICEREQUESTER_HPP_
40 #define ORO_SERVICEREQUESTER_HPP_
41 
42 #include "rtt-config.h"
43 #include "rtt-fwd.hpp"
45 #include "Service.hpp"
46 #include <map>
47 #include <vector>
48 #include <string>
49 
50 #include <boost/enable_shared_from_this.hpp>
51 #if BOOST_VERSION >= 104000 && BOOST_VERSION < 105300
52 #include <boost/smart_ptr/enable_shared_from_this2.hpp>
53 #endif
54 #if BOOST_VERSION >= 105300
55 #include <boost/smart_ptr/enable_shared_from_raw.hpp>
56 #endif
57 
58 namespace RTT
59 {
72  class RTT_API ServiceRequester :
73 #if BOOST_VERSION >= 104000
74 #if BOOST_VERSION < 105300
75  public boost::enable_shared_from_this2<ServiceRequester>
76 #else
77  public boost::enable_shared_from_raw
78 #endif
79 #else
80  public boost::enable_shared_from_this<ServiceRequester>
81 #endif
82 
83  {
84  public:
85  typedef std::vector<std::string> RequesterNames;
86  typedef std::vector<std::string> OperationCallerNames;
87  typedef boost::shared_ptr<ServiceRequester> shared_ptr;
88  typedef boost::shared_ptr<const ServiceRequester> shared_constptr;
89 
90 #if BOOST_VERSION >= 105300
91  ServiceRequester::shared_ptr shared_from_this() { return boost::shared_from_raw(this); }
92  ServiceRequester::shared_constptr shared_from_this() const { return boost::shared_from_raw(this); }
93 #endif
94 
95  ServiceRequester(const std::string& name, TaskContext* owner = 0);
96  virtual ~ServiceRequester();
97 
98  const std::string& getRequestName() const { return mrname; }
99 
100  RequesterNames getRequesterNames() const;
101 
106  TaskContext* getServiceOwner() const { return mrowner; }
107 
112  void setOwner(TaskContext* new_owner);
113 
121 
122  bool addOperationCaller( base::OperationCallerBaseInvoker& mbi);
123 
124  OperationCallerNames getOperationCallerNames() const;
125 
126  base::OperationCallerBaseInvoker* getOperationCaller(const std::string& name);
127 
128  ServiceRequester::shared_ptr requires();
129 
130  ServiceRequester::shared_ptr requires(const std::string& service_name);
131 
140  bool addServiceRequester(shared_ptr obj);
141 
147  bool requiresService(const std::string& service_name) {
148  return mrequests.find(service_name) != mrequests.end();
149  }
150 
162  virtual bool connectTo(Service::shared_ptr sp);
163 
168  virtual bool ready() const;
169 
173  virtual void disconnect();
174 
178  virtual void clear();
179 
180  protected:
181  typedef std::map< std::string, ServiceRequester::shared_ptr > Requests;
183  Requests mrequests;
184 
186  typedef std::map<std::string, base::OperationCallerBaseInvoker*> OperationCallers;
187  OperationCallers mmethods;
188 
189  std::string mrname;
192  };
193 }
194 
195 #endif /* ORO_SERVICEREQUESTER_HPP_ */
std::vector< std::string > RequesterNames
OperationCallers mmethods
boost::shared_ptr< const ServiceRequester > shared_constptr
const std::string & getRequestName() const
boost::shared_ptr< ServiceRequester > shared_ptr
Requests mrequests
the services we implement.
boost::shared_ptr< Service > shared_ptr
Definition: Service.hpp:101
std::map< std::string, ServiceRequester::shared_ptr > Requests
Service::shared_ptr mprovider
Service::shared_ptr getReferencedService()
std::map< std::string, base::OperationCallerBaseInvoker * > OperationCallers
Our methods.
bool requiresService(const std::string &service_name)
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
TaskContext * getServiceOwner() const
boost::enable_shared_from_this< Service > shared_from_raw
Definition: Service.hpp:75
std::vector< std::string > OperationCallerNames


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