OperationCallerProxy.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Thu Dec 2 12:51:36 2010 +0100 OperationCallerProxy.hpp
3 
4  OperationCallerProxy.hpp - description
5  -------------------
6  begin : Thu Dec 2 2010
7  copyright : (C) 2010 Peter Soetens
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  * 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 #include "ServiceRequesterC.h"
40 #include <string>
41 #include "../../base/OperationCallerBaseInvoker.hpp"
43 
44 namespace RTT
45 {
46  namespace corba {
54  {
55  std::string mname;
56  CServiceRequester_var msrq;
57  OperationCallerProxy(const std::string& opname, CServiceRequester_ptr srq)
58  : mname(opname), msrq(srq) {}
59 
60  virtual bool ready() const {
61  return msrq->callerReady( mname.c_str() );
62  }
63 
64  virtual void disconnect() {
65  msrq->disconnectCaller( mname.c_str() );
66  }
67 
68  virtual bool setImplementation(boost::shared_ptr<base::DisposableInterface> impl, ExecutionEngine* caller = 0) {
69  // impossible for remote operation callers.
70  return false;
71  }
72 
74  // todo: forward to remote side.
75  // if orp is local, we need to provide the remote side with a service to this operation part.
76  // if orp is remote, we need to pass on the service
77  CorbaOperationCallerFactory* cocf = dynamic_cast<CorbaOperationCallerFactory*>(orp);
78  if (cocf) {
79  // good: it's already a remote service, just pass on the misery
80  return msrq->connectCallerTo(mname.c_str(), cocf->getService() );
81  } else {
82  // bad: we need to create or lookup
83  log(Error) <<"Can't connect an operation caller proxy directly to a local service."<<endlog();
84  log(Error) <<"Use CServiceRequester::connectTo() or CServiceRequester::connectCallerTo(). "<<endlog();
85  }
86  return false;
87  }
88 
89  virtual void setCaller(ExecutionEngine* caller) {
90  // ignored.
91  }
92 
93  virtual const std::string& getName() const {
94  return mname;
95  }
96  };
97  }
98 }
virtual bool setImplementation(boost::shared_ptr< base::DisposableInterface > impl, ExecutionEngine *caller=0)
virtual void setCaller(ExecutionEngine *caller)
virtual const std::string & getName() const
OperationCallerProxy(const std::string &opname, CServiceRequester_ptr srq)
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
static Logger & log()
Definition: Logger.hpp:350
virtual bool setImplementationPart(OperationInterfacePart *orp, ExecutionEngine *caller=0)
static Logger::LogFunction endlog()
Definition: Logger.hpp:362


rtt
Author(s): RTT Developers
autogenerated on Fri Oct 25 2019 03:59:34