#include "ros_bridge/include/ROSBridge.h"

ROSBridge::ROSBridge::ROSBridge() :
    _casePacker(&_typeFactory, &_jsonFactory)
  , _rbc("localhost:9090")
  , _topicPublisher(&_casePacker, &_rbc)
  , _topicSubscriber(&_casePacker, &_rbc)
{

}

void ROSBridge::ROSBridge::publish(ROSBridge::ROSBridge::JsonDocUPtr doc)
{
    _topicPublisher.publish(std::move(doc));
}

void ROSBridge::ROSBridge::subscribe(const char *topic, const std::function<void(JsonDocUPtr)> &callBack)
{
    _topicSubscriber.subscribe(topic, callBack);
}

const ROSBridge::CasePacker *ROSBridge::ROSBridge::casePacker() const
{
    return &_casePacker;
}

void ROSBridge::ROSBridge::start()
{
    _topicPublisher.start();
    _topicSubscriber.start();
}

void ROSBridge::ROSBridge::reset()
{
    _topicPublisher.reset();
    _topicSubscriber.reset();
}

