how to call a service's operation outside of a TaskContext?

I’ve built a component that provides an operation through a service.

MyComponent::MyComponent(std::string const& name) : TaskContext(name)
{
// std::string foo()
this->provides(“MyService”)->addOperation(“MyOperation”, &MyComponent::foo, this, ClientThread);
}

I’ve instantiated that component in a C++ deployment for the purpose of unit testing/benchmarking.

int ORO_main(int argc, char** argv)
{
boost::shard_ptr<MyComponent> myComponent;
myComponent.reset(new MyComponent(“MyComponent”));

OperationCaller<std::string(void)> op_myOperation = myComponent->getOperation(“MyOperation”);
std::cout << op_myOperation() << std::endl;
}

This results in: “No such operation in service ‘MyComponent’: MyOperation"

How do I go about calling MyOperation from within ORO_main()? (I can call this method from other components with the use of requires(“MyService”).) I’m getting lost in the weeds. There’s TaskContext::getOperation, but I think that’s missing the service layer. Do I need to use an RTT::Service or RTT::ServiceRequester class somewhere?

--
Dustin Gooding
NASA/JSC Robotics
IM: dgooding [..] ...<xmpp:dgooding [..] ...>

how to call a service's operation outside of a TaskContext?

On Thu, Aug 7, 2014 at 11:59 AM, Gooding, Dustin R. (JSC-ER411) <
dustin [dot] r [dot] gooding [..] ...> wrote:

> OperationCaller<std::string(void)> op_myOperation =
> myComponent->getOperation("MyOperation");
>

```
OperationCaller<std::string(void)> op_myOperation =
myComponent->provides("MyService")->getOperation("MyOperation");
```

-j

how to call a service's operation outside of a TaskContext?

On Aug 7, 2014, at 12:32 PM, Jonathan Bohren <jonathan [dot] bohren [..] ...jonathan [dot] bohren [..] ...>> wrote:

On Thu, Aug 7, 2014 at 11:59 AM, Gooding, Dustin R. (JSC-ER411) <dustin [dot] r [dot] gooding [..] ...dustin [dot] r [dot] gooding [..] ...>> wrote:
OperationCaller<std::string(void)> op_myOperation = myComponent->getOperation(“MyOperation”);

```
OperationCaller<std::string(void)> op_myOperation = myComponent->provides("MyService")->getOperation(“MyOperation”);
```

-j

--
Jonathan Bohren
Laboratory for Computational Sensing and Robotics
http://dscl.lcsr.jhu.edu/People/JonathanBohren

Oh my, am I embarrassed….

Thanks Jonathan.

--
dustin