#ifndef __LCM_UTIL_H__
#define __LCM_UTIL_H__

#include <glib.h>

#include <lcm/lcm.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * lcu_mainloop_attach_lc (lc_t *lcm)
 * attaches/detaches LCM to/from the glib mainloop
 * When attached, lc_handle() is invoked "automatically" when a message is 
 * received over LCM.
 *
 * only one instance of lcm_t can be attached per process
 *
 * returns 0 on success, -1 on failure
 */
int
lcmu_glib_mainloop_attach_lcm (lcm_t *lcm);

int
lcmu_glib_mainloop_detach_lcm (lcm_t *lcm);


/* lcmu_handle_timeout (lcm_t *lcm, struct timeval *timeout)
 * performs the same function as lcm_handle, but with a timeout.
 * 
 * returns -1 error, 0 timeout, >0 lcm event
 */
int
lcmu_handle_timeout (lcm_t *lcm, struct timeval *timeout);

#ifdef __cplusplus
}
#endif

#endif // __LCM_UTIL_H__
