Robot Raconteur Core C++ Library
Loading...
Searching...
No Matches
ServiceFactory.h
Go to the documentation of this file.
1
23
24#pragma once
25
29
30namespace RobotRaconteur
31{
32
33class ROBOTRACONTEUR_CORE_API StructureStub;
34class ROBOTRACONTEUR_CORE_API ServiceStub;
35class ROBOTRACONTEUR_CORE_API ServiceSkel;
36
37class ROBOTRACONTEUR_CORE_API ClientContext;
38class ROBOTRACONTEUR_CORE_API ServerContext;
39
40class ROBOTRACONTEUR_CORE_API RobotRaconteurNode;
41
55class ROBOTRACONTEUR_CORE_API ServiceFactory
56{
57
58 public:
59 RR_SHARED_PTR<RobotRaconteurNode> GetNode();
60
61 void SetNode(const RR_SHARED_PTR<RobotRaconteurNode>& node);
62
63 virtual ~ServiceFactory() {}
64
70 virtual std::string GetServiceName() = 0;
71
77 virtual std::string DefString() = 0;
78
79 virtual RR_SHARED_PTR<StructureStub> FindStructureStub(boost::string_ref s) = 0;
80
81 virtual RR_INTRUSIVE_PTR<MessageElementNestedElementList> PackStructure(
82 const RR_INTRUSIVE_PTR<RRStructure>& structin) = 0;
83
84 virtual RR_INTRUSIVE_PTR<RRValue> UnpackStructure(
85 const RR_INTRUSIVE_PTR<MessageElementNestedElementList>& mstructin) = 0;
86
87 virtual RR_INTRUSIVE_PTR<MessageElementNestedElementList> PackPodArray(
88 const RR_INTRUSIVE_PTR<RRPodBaseArray>& structure) = 0;
89
90 virtual RR_INTRUSIVE_PTR<RRPodBaseArray> UnpackPodArray(
91 const RR_INTRUSIVE_PTR<MessageElementNestedElementList>& structure) = 0;
92
93 virtual RR_INTRUSIVE_PTR<MessageElementNestedElementList> PackPodMultiDimArray(
94 const RR_INTRUSIVE_PTR<RRPodBaseMultiDimArray>& structure) = 0;
95
96 virtual RR_INTRUSIVE_PTR<RRPodBaseMultiDimArray> UnpackPodMultiDimArray(
97 const RR_INTRUSIVE_PTR<MessageElementNestedElementList>& structure) = 0;
98
99 virtual RR_INTRUSIVE_PTR<MessageElementNestedElementList> PackNamedArray(
100 const RR_INTRUSIVE_PTR<RRNamedBaseArray>& structure) = 0;
101
102 virtual RR_INTRUSIVE_PTR<RRNamedBaseArray> UnpackNamedArray(
103 const RR_INTRUSIVE_PTR<MessageElementNestedElementList>& structure) = 0;
104
105 virtual RR_INTRUSIVE_PTR<MessageElementNestedElementList> PackNamedMultiDimArray(
106 const RR_INTRUSIVE_PTR<RRNamedBaseMultiDimArray>& structure) = 0;
107
108 virtual RR_INTRUSIVE_PTR<RRNamedBaseMultiDimArray> UnpackNamedMultiDimArray(
109 const RR_INTRUSIVE_PTR<MessageElementNestedElementList>& structure) = 0;
110
111 virtual RR_SHARED_PTR<ServiceStub> CreateStub(boost::string_ref objecttype, boost::string_ref path,
112 const RR_SHARED_PTR<ClientContext>& context) = 0;
113
114 virtual RR_SHARED_PTR<ServiceSkel> CreateSkel(boost::string_ref objecttype, boost::string_ref path,
115 const RR_SHARED_PTR<RRObject>& obj,
116 const RR_SHARED_PTR<ServerContext>& context) = 0;
117
123 virtual RR_SHARED_PTR<ServiceDefinition> ServiceDef();
124
125 virtual std::string RemovePath(boost::string_ref path);
126
127 virtual void DownCastAndThrowException(RobotRaconteurException& exp) = 0;
128
129 virtual RR_SHARED_PTR<RobotRaconteurException> DownCastException(
130 const RR_SHARED_PTR<RobotRaconteurException>& exp) = 0;
131
132 private:
133 RR_SHARED_PTR<ServiceDefinition> sdef;
134 RR_WEAK_PTR<RobotRaconteurNode> node;
135};
136
145class ROBOTRACONTEUR_CORE_API DynamicServiceFactory
146{
147 public:
148 virtual ~DynamicServiceFactory() {}
149
158 virtual RR_SHARED_PTR<ServiceFactory> CreateServiceFactory(boost::string_ref def) = 0;
159
169 virtual std::vector<RR_SHARED_PTR<ServiceFactory> > CreateServiceFactories(const std::vector<std::string>& def) = 0;
170};
171
172#ifndef ROBOTRACONTEUR_NO_CXX11_TEMPLATE_ALIASES
174using ServiceFactoryPtr = RR_SHARED_PTR<ServiceFactory>;
176using DynamicServiceFactoryPtr = RR_SHARED_PTR<DynamicServiceFactory>;
177#endif
178
179} // namespace RobotRaconteur
boost::shared_ptr< ServiceFactory > ServiceFactoryPtr
Convenience alias for ServiceFactory shared_ptr.
Definition ServiceFactory.h:174
boost::shared_ptr< DynamicServiceFactory > DynamicServiceFactoryPtr
Convenience alias for DynamicServiceFactory shared_ptr.
Definition ServiceFactory.h:176
Dynamic service factory base class.
Definition ServiceFactory.h:146
virtual std::vector< boost::shared_ptr< ServiceFactory > > CreateServiceFactories(const std::vector< std::string > &def)=0
Override to return collection of service factories from a collection of service definition strings.
virtual boost::shared_ptr< ServiceFactory > CreateServiceFactory(boost::string_ref def)=0
Override to return service factory from a service definition string.
Base class for Robot Raconteur exceptions.
Definition Error.h:53
The central node implementation.
Definition RobotRaconteurNode.h:132
Context for services registered in a node for use by clients.
Definition Service.h:253
Base class for service factories.
Definition ServiceFactory.h:56
virtual boost::shared_ptr< ServiceDefinition > ServiceDef()
Return the parsed ServiceDefinition.
virtual std::string GetServiceName()=0
Returns the name of the service.
virtual std::string DefString()=0
Return the service definition string used to generate the service factory.