CProtocolEvent is used to send messages from the general plugins (GP) to the protocol plugins (PP). It contains all the necessary data to complete the request actions and for the daemon to send it to the proper PP. The daemon will return an event ID to the GP and the PP will use this event ID to signal actions on this event, such as acknowleding sent messages.

class CProtocolEvent
{
public:
  CProtocolEvent(std::string &protocolId, std::string &eventId, CEventData *data);
};

Here is the basic object definition for passing event data from the GP to the PP. This object is designed in such a way that it can be generic and handle any object. Most of the time, you will see a program use functions for each type that it will handle. For example setInt(), setString(), setFloat(), etc. This one aims to be easier to use. The only bad point about it is the object we use, the copy constructor gets called a bit too much I believe. If you think you can improve on this, please discuss it here.

class CEventData
{
public:
    CEventData() { }
    ~CEventData() { }

    template <typename T>
    void setData(const std::string &s, T t)
    {
      static std::map<std::string, T> v;
      boost::associative_property_map< std::map<std::string, T> > propMap(v);

      v.insert(make_pair(s, t));

      m_Prop.property(s, propMap);
    }

    template <typename T>
    T getData(const std::string &s)
    {
      using boost::get;

      T val = get<T, std::string>(s, m_Prop, s);

      return val;
    }

private:
    boost::dynamic_properties m_Prop;
};

And here is an example of how to use it

CEventData a;
int x = 2;
a.setData(std::string("test"), x);
a.setData(std::string("test2"), std::string("OK"));
a.setData(std::string("test3"), x+4);

int ret = a.getData<int>(std::string("test"));
std::cout << "test: " << ret << std::endl;
std::cout << "test2: " << a.getData<std::string>(std::string("test2")) << std::endl;
ret = a.getData<int>(std::string("test3"));
std::cout << "test3: " << ret << std::endl;