19 #ifndef INCLUDE_RCF_PUBLISHINGSERVICE_HPP 20 #define INCLUDE_RCF_PUBLISHINGSERVICE_HPP 26 #include <RCF/Export.hpp> 27 #include <RCF/PeriodicTimer.hpp> 30 #include <RCF/Service.hpp> 31 #include <RCF/ThreadLibrary.hpp> 32 #include <RCF/Timer.hpp> 33 #include <RCF/Tools.hpp> 43 void setTopicName(
const std::string & topicName);
46 std::string getTopicName()
const;
56 friend class PublishingService;
58 std::string mTopicName;
71 std::string getTopicName();
74 std::size_t getSubscriberCount();
81 friend class PublishingService;
85 PublishingService & mPublishingService;
88 std::string mTopicName;
89 RcfClientPtr mRcfClientPtr;
93 template<
typename Interface>
98 typedef typename Interface::RcfClientT RcfClientT;
104 if (mTopicName.empty())
106 mTopicName = getInterfaceName<Interface>();
109 mRcfClientPtr.reset(
new RcfClientT(
ClientStub(mTopicName) ) );
110 mpClient =
dynamic_cast<RcfClientT *
>(mRcfClientPtr.get());
118 RCF_ASSERT(!mClosed);
124 RcfClientT * mpClient;
127 class I_RequestSubscription;
128 template<
typename T>
class RcfClient;
130 class RCF_EXPORT PublishingService :
137 ~PublishingService();
139 template<
typename Interface>
140 std::shared_ptr< Publisher<Interface> > createPublisher(
143 std::shared_ptr< Publisher<Interface> > publisherPtr(
146 std::string topicName = publisherPtr->getTopicName();
148 RCF_ASSERT(topicName.size() > 0);
149 Lock lock(mPublishersMutex);
150 mPublishers[topicName] = publisherPtr;
154 void setPingIntervalMs(std::uint32_t pingIntervalMs);
155 std::uint32_t getPingIntervalMs()
const;
160 friend class RcfClient<I_RequestSubscription>;
162 friend class PublishingServicePb;
165 std::int32_t RequestSubscription(
166 const std::string &subscriptionName);
168 std::int32_t RequestSubscription(
169 const std::string &subscriptionName,
170 std::uint32_t subToPubPingIntervalMs,
171 std::uint32_t & pubToSubPingIntervalMs);
176 void onServiceRemoved(
RcfServer &server);
180 void addSubscriberTransport(
182 const std::string &publisherName,
183 ClientTransportUniquePtrPtr clientTransportUniquePtrPtr);
185 void closePublisher(
const std::string & name);
189 typedef std::map<std::string, PublisherWeakPtr> Publishers;
191 Mutex mPublishersMutex;
192 Publishers mPublishers;
194 std::uint32_t mPingIntervalMs;
195 PeriodicTimer mPeriodicTimer;
197 virtual void onTimer();
198 void pingAllSubscriptions();
199 void harvestExpiredSubscriptions();
203 typedef std::shared_ptr<PublishingService> PublishingServicePtr;
207 #endif // ! INCLUDE_RCF_PUBLISHINGSERVICE_HPP RcfClientT & publish()
Returns a reference to the RcfClient<> instance to use when publishing messages.
Definition: PublishingService.hpp:116
Represents a server side session, associated with a client connection.
Definition: RcfSession.hpp:67
Controls the client side of a RCF connection.
Definition: ClientStub.hpp:69
std::function< void(RcfSession &, const std::string &)> OnSubscriberDisconnect
Describes a user-provided callback function to be called on the publisher side, whenever a subscriber...
Definition: RcfFwd.hpp:74
Provides RCF server-side functionality.
Definition: RcfServer.hpp:54
Represents a single publisher within a RcfServer. To create a publisher, use RcfServer::createPublish...
Definition: PublishingService.hpp:94
Definition: AmiIoHandler.hpp:24
General configuration of a publisher.
Definition: PublishingService.hpp:38
std::function< bool(RcfSession &, const std::string &)> OnSubscriberConnect
Describes a user-provided callback function to be called on the publisher side, whenever a subscriber...
Definition: RcfFwd.hpp:71
RCF_EXPORT bool init(RcfConfigT *=nullptr)
Reference-counted initialization of RCF library. May be called multiple times (see deinit())...
Base class of all publishers.
Definition: PublishingService.hpp:64