ServiceRequester.hpp
Go to the documentation of this file.
00001 /***************************************************************************
00002   tag: The SourceWorks  Tue Sep 7 00:55:18 CEST 2010  ServiceRequester.hpp
00003 
00004                         ServiceRequester.hpp -  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 #ifndef ORO_SERVICEREQUESTER_HPP_
00040 #define ORO_SERVICEREQUESTER_HPP_
00041 
00042 #include "rtt-config.h"
00043 #include "rtt-fwd.hpp"
00044 #include "base/OperationCallerBaseInvoker.hpp"
00045 #include "Service.hpp"
00046 #include <map>
00047 #include <vector>
00048 #include <string>
00049 
00050 #include <boost/enable_shared_from_this.hpp>
00051 #if BOOST_VERSION >= 104000 && BOOST_VERSION < 105300
00052 #include <boost/smart_ptr/enable_shared_from_this2.hpp>
00053 #endif
00054 #if BOOST_VERSION >= 105300
00055 #include <boost/smart_ptr/enable_shared_from_raw.hpp>
00056 #endif
00057 
00058 namespace RTT
00059 {
00072     class RTT_API ServiceRequester :
00073 #if BOOST_VERSION >= 104000
00074 #if BOOST_VERSION < 105300
00075         public boost::enable_shared_from_this2<ServiceRequester>
00076 #else
00077         public boost::enable_shared_from_raw
00078 #endif
00079 #else
00080         public boost::enable_shared_from_this<ServiceRequester>
00081 #endif
00082 
00083     {
00084     public:
00085         typedef std::vector<std::string> RequesterNames;
00086         typedef std::vector<std::string> OperationCallerNames;
00087         typedef boost::shared_ptr<ServiceRequester> shared_ptr;
00088         typedef boost::shared_ptr<const ServiceRequester> shared_constptr;
00089 
00090 #if BOOST_VERSION >= 105300
00091         ServiceRequester::shared_ptr shared_from_this() { return boost::shared_from_raw(this); }
00092         ServiceRequester::shared_constptr shared_from_this() const { return boost::shared_from_raw(this); }
00093 #endif
00094 
00095         ServiceRequester(const std::string& name, TaskContext* owner = 0);
00096         virtual ~ServiceRequester();
00097 
00098         const std::string& getRequestName() const { return mrname; }
00099 
00100         RequesterNames getRequesterNames() const;
00101 
00106         TaskContext* getServiceOwner() const { return mrowner; }
00107 
00112         void setOwner(TaskContext* new_owner);
00113 
00120         Service::shared_ptr getReferencedService() { return mprovider; }
00121 
00122         bool addOperationCaller( base::OperationCallerBaseInvoker& mbi);
00123 
00124         OperationCallerNames getOperationCallerNames() const;
00125 
00126         base::OperationCallerBaseInvoker* getOperationCaller(const std::string& name);
00127 
00128         ServiceRequester::shared_ptr requires();
00129 
00130         ServiceRequester::shared_ptr requires(const std::string& service_name);
00131 
00140         bool addServiceRequester(shared_ptr obj);
00141 
00147         bool requiresService(const std::string& service_name) {
00148             return mrequests.find(service_name) != mrequests.end();
00149         }
00150 
00162         virtual bool connectTo(Service::shared_ptr sp);
00163 
00168         virtual bool ready() const;
00169 
00173         virtual void disconnect();
00174 
00178         virtual void clear();
00179 
00180     protected:
00181         typedef std::map< std::string, ServiceRequester::shared_ptr > Requests;
00183         Requests mrequests;
00184 
00186         typedef std::map<std::string, base::OperationCallerBaseInvoker*> OperationCallers;
00187         OperationCallers mmethods;
00188 
00189         std::string mrname;
00190         TaskContext* mrowner;
00191         Service::shared_ptr mprovider;
00192     };
00193 }
00194 
00195 #endif /* ORO_SERVICEREQUESTER_HPP_ */


rtt
Author(s): RTT Developers
autogenerated on Sat Jun 8 2019 18:46:18