1 #ifndef __lcm_cpp_hpp__
2 #define __lcm_cpp_hpp__
4 #ifndef LCM_CXX_11_ENABLED
5 #if __cplusplus >= 201103L
6 #define LCM_CXX_11_ENABLED 1
8 #define LCM_CXX_11_ENABLED 0
18 #if LCM_CXX_11_ENABLED
55 inline LCM(std::string lcm_url =
"");
92 inline int publish(
const std::string &channel,
const void *data,
unsigned int datalen);
105 template <
class MessageType>
106 inline int publish(
const std::string &channel,
const MessageType *msg);
199 template <
class MessageType,
class MessageHandlerClass>
201 void (MessageHandlerClass::*handlerMethod)(
const ReceiveBuffer *rbuf,
202 const std::string &channel,
203 const MessageType *msg),
204 MessageHandlerClass *handler);
253 template <
class MessageHandlerClass>
255 void (MessageHandlerClass::*handlerMethod)(
const ReceiveBuffer *rbuf,
256 const std::string &channel),
257 MessageHandlerClass *handler);
317 template <
class MessageType,
class ContextClass>
320 const std::string &channel,
321 const MessageType *msg, ContextClass context),
322 ContextClass context);
364 template <
class ContextClass>
367 const std::string &channel,
368 ContextClass context),
369 ContextClass context);
371 #if LCM_CXX_11_ENABLED
375 template <
class MessageType>
377 const std::string &channel,
const MessageType *msg)>;
426 template <
class MessageType>
463 std::vector<Subscription *> subscriptions;
528 Subscription() { channel_buf.reserve(LCM_MAX_CHANNEL_NAME_LENGTH); };
540 std::string channel_buf;
597 inline LogFile(
const std::string &path,
const std::string &mode);
657 lcm_eventlog_t *eventlog;
658 lcm_eventlog_event_t *last_event;
665 #define __lcm_cpp_impl_ok__
666 #include "lcm-cpp-impl.hpp"
667 #undef __lcm_cpp_impl_ok__
Core communications class for the C++ API.
Definition: lcm-cpp.hpp:44
int publish(const std::string &channel, const MessageType *msg)
Publishes a message with automatic message encoding.
Subscription * subscribe(const std::string &channel, void(MessageHandlerClass::*handlerMethod)(const ReceiveBuffer *rbuf, const std::string &channel), MessageHandlerClass *handler)
Subscribe a callback method of an object to a channel, without automatic message decoding.
LCM(std::string lcm_url="")
Constructor.
Subscription * subscribeFunction(const std::string &channel, void(*handler)(const ReceiveBuffer *rbuf, const std::string &channel, const MessageType *msg, ContextClass context), ContextClass context)
Subscribe a function callback to a channel, with automatic message decoding.
bool good() const
Checks if initialization succeeded during object construction.
Subscription * subscribe(const std::string &channel, void(MessageHandlerClass::*handlerMethod)(const ReceiveBuffer *rbuf, const std::string &channel, const MessageType *msg), MessageHandlerClass *handler)
Subscribes a callback method of an object to a channel, with automatic message decoding.
LCM(lcm_t *lcm_in)
Constructor.
int publish(const std::string &channel, const void *data, unsigned int datalen)
Publishes a raw data message.
int handleTimeout(int timeout_millis)
Waits for and dispatches messages, with a timeout.
Subscription * subscribe(const std::string &channel, HandlerFunction< MessageType > handler)
Subscribes a callback function to a channel, with automatic message decoding.
lcm_t * getUnderlyingLCM()
retrives the lcm_t C data structure wrapped by this class.
int handle()
Waits for and dispatches messages.
int getFileno()
Returns a file descriptor or socket that can be used with select(), poll(), or other event loops for ...
Subscription * subscribeFunction(const std::string &channel, void(*handler)(const ReceiveBuffer *rbuf, const std::string &channel, ContextClass context), ContextClass context)
Subscribe a function callback to a channel, without automatic message decoding.
std::function< void(const ReceiveBuffer *rbuf, const std::string &channel, const MessageType *msg)> HandlerFunction
Definition: lcm-cpp.hpp:377
int unsubscribe(Subscription *subscription)
Unsubscribes a message handler.
Read and write LCM log files.
Definition: lcm-cpp.hpp:588
FILE * getFilePtr()
retrives the underlying FILE* wrapped by this class.
const LogEvent * readNextEvent()
int writeEvent(LogEvent *event)
int seekToTimestamp(int64_t timestamp)
LogFile(const std::string &path, const std::string &mode)
Represents a channel subscription, and can be used to unsubscribe and set options.
Definition: lcm-cpp.hpp:500
int getQueueSize() const
Query the current number of unhandled messages queued up for this subscription.
lcm_subscription_t * c_subs
Definition: lcm-cpp.hpp:528
int setQueueCapacity(int num_messages)
Adjusts the maximum number of received messages that can be queued up for this subscription.
struct _lcm_subscription_t lcm_subscription_t
Definition: lcm.h:55
struct _lcm_t lcm_t
Definition: lcm.h:50
Represents a single event (message) in a log file.
Definition: lcm-cpp.hpp:554
void * data
Definition: lcm-cpp.hpp:576
int64_t eventnum
Definition: lcm-cpp.hpp:559
std::string channel
Definition: lcm-cpp.hpp:568
int64_t timestamp
Definition: lcm-cpp.hpp:564
int32_t datalen
Definition: lcm-cpp.hpp:572
Stores the raw bytes and timestamp of a received message.
Definition: lcm-cpp.hpp:471
void * data
Definition: lcm-cpp.hpp:475
uint32_t data_size
Definition: lcm-cpp.hpp:479
int64_t recv_utime
Definition: lcm-cpp.hpp:484