/*
 * event.h
 *
 *  Created on: 15 Oct 2013
 *      Author: john
 */

#ifndef EVENT_H_
#define EVENT_H_

#include <object.h>

class cObjectEvent : public cObject
{
public:
   enum eEventType
   {
      EVENT_NONE,
      EVENT_DEVICE,
      EVENT_PORT,
      EVENT_SITE,
      EVENT_PORT_ANALOG
   };
   enum eEventOpType
   {
      EVENT_OP_UNKNOWN,
      EVENT_OP_CREATE,
      EVENT_OP_UPDATE,
      EVENT_OP_REMOVE,
      EVENT_OP_REPLACE
   };
   cObjectEvent();
   cObjectEvent(cObjectEvent *obj);
   ~cObjectEvent();

   cTagList * getTags();
   bool parse(KourierObject *, std::vector<KTag*>* ct = NULL);

	//potential problem with conversion as library returns double and we are casting to float.
	bool parse(json_t *dataArray); //JSON
	   //uses the append_new function for return arrays so that the json ref stays at 1
	   //returns an array of all the values
	json_t * getJSONObj(); //for JSON



   bool compIndex(cObject *obj);
   bool operator <(cObject &rhs);
   char * printKey();
   cObject * clone();


   uint32_t getDeviceSerial() const;
   void setDeviceSerial(uint32_t deviceSerial);
   uint32_t getDeviceSerialOld() const;
   void setDeviceSerialOld(uint32_t deviceSerialOld);
   eEventOpType getEventOp() const;
   void setEventOp(eEventOpType eventOp);
   eEventType getEventType() const;
   void setEventType(eEventType eventType);
   uint32_t getObjectType() const;
   void setObjectType(uint32_t objectType);
   eObjectOpState getOpState() const;
   void setOpState(eObjectOpState opState);
   uint32_t getPortId() const;
   void setPortId(uint32_t portId);
   eObjectStatus getStatus() const;
   void setStatus(eObjectStatus status);
   uint32_t getTimeStamp() const;
   void setTimeStamp(uint32_t timeStamp);
   uint32_t getSeqNum() const;
   void setSeqNum(uint32_t seqNum);
   uint32_t getStartSeq() const;
   void setStartSeq(uint32_t startSeq);
   uint32_t getStartTime() const;
   void setStartTime(uint32_t startTime);
   uint32_t getEndSeq() const;
   void setEndSeq(uint32_t endSeq);
   uint32_t getEndTime() const;
   void setEndTime(uint32_t endTime);

private:
   uint32_t mSeqNum;
   eEventType mEventType;
   uint32_t mTimeStamp;
   uint32_t mDeviceSerial;
   uint32_t mPortID;
   uint32_t mObjectType;
   eObjectStatus mStatus;
   eObjectOpState mOpState;
   eEventOpType mEventOp;

   uint32_t mDeviceSerialOld;
   uint32_t mStartSeq;
   uint32_t mEndSeq;
   uint32_t mStartTime;
   uint32_t mEndTime;

   void populate_tags(KTag* tag);
};



#endif /* EVENT_H_ */
