//----------------------------------------------------------------------------------
// <copyright file="IEventBase.h" company="LiquidRobotics">
//
// Copyright (c) 2014 Liquid Robotics, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// This software is associated with a release.  Liquid Robotics makes no
// representation that the design, interfaces or component distribution will
// remain unchanged in future releases.
//
// </copyright>
//
// <summary>
// 	Declarations for IEventBase class, which is is an interface class for EventBase,
//  a common base class for all event classes.
// </summary>
//
// <owner>Mike Cookson</owner>
//----------------------------------------------------------------------------------

#ifndef __EVENTLIB_IEVENTLIB_H__
#define __EVENTLIB_IEVENTLIB_H__

#include "LqrSMACSharedLib.h"
#include <ostream>
#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>
#include "CosNotification.hh"
#include "EventPropertyValue.h"
#include "EventSettings.h"
#include "EventType.h"

namespace LiquidRobotics {
namespace EventLib {

typedef std::string EventName;
typedef std::string IOR;

class SHARED_LIB_PUBLIC IEventBase
{
public:

	typedef std::string string;
	typedef string EventNameType;
	typedef string PropertyNameType;
	typedef std::vector<PropertyNameType> PropertyNameArrayType;
	typedef boost::shared_ptr<PropertyNameArrayType> PropertyNameArrayPtr;
	typedef EventPropertyValue PropertyValueType;
	typedef boost::shared_ptr<PropertyValueType> PropertyValuePtr;
	typedef ::CosNotification::StructuredEvent CORBA_StructuredEvent;
	typedef ::CosNotification::StructuredEvent_var CORBA_StructuredEvent_var;
	typedef boost::shared_ptr<IEventBase> Ptr;
	typedef std::ostream ostream;

	virtual PropertyValuePtr CreateValue() = 0;

	virtual ostream& Describe(ostream& stm) const = 0;
	virtual string Describe() const = 0;
	virtual ostream& DescribeGeneric(ostream& stm) const = 0;
	virtual string DescribeGeneric() const = 0;

	virtual Ptr Duplicate() const = 0;

	virtual const EventName& GetEventName() const = 0;
	virtual void SetEventName(const EventName& newValue) = 0;

	virtual const EventSettings& GetEventSettings() const = 0;
	virtual void SetEventSettings(const EventSettings& newValue) = 0;

	virtual const EventType& GetEventType() const = 0;
	virtual void SetEventType(const EventType& newValue) = 0;

	virtual bool ContainsSenderIOR() const = 0;
	virtual const IOR& GetSenderIOR() const = 0;
	virtual void SetSenderIOR(const IOR& newValue) = 0;

	virtual void ClearProperties() = 0;
	virtual void ClearProperty(const PropertyNameType& propertyName) = 0;
	virtual bool ContainsProperty(const PropertyNameType& propertyName, bool throwOnUnsupportedType = false) const = 0;
	virtual PropertyValueType& GetProperty(const PropertyNameType& propertyName, bool throwOnUnsupportedType = false) = 0;
	virtual const PropertyValueType& GetProperty(const PropertyNameType& propertyName, bool throwOnUnsupportedType = false) const = 0;
	virtual PropertyNameArrayPtr GetPropertyNames() const = 0;
	virtual void SetProperty(const PropertyNameType& propertyName, const PropertyValueType& newValue) = 0;

	virtual CORBA_StructuredEvent_var CreateStructuredEvent() const = 0;
	virtual void InitFromStructuredEvent(const CORBA_StructuredEvent& structEvent) = 0;

	PropertyValueType& operator[](const PropertyNameType& propertyName)
	{
		return GetProperty(propertyName);
	}

	const PropertyValueType& operator[](const PropertyNameType& propertyName) const
	{
		return GetProperty(propertyName);
	}
};

inline std::ostream& operator<<(std::ostream& out, const IEventBase& evt)
{
	return evt.Describe(out);
}

}
}

#endif
