//-------------------------------------------------------------------------------------------------
// <copyright file="LWEventLua.h" company="LiquidRobotics">
//  Copyright (c) Liquid Robotics Corporation, confidential and proprietary.  All rights reserved. 
// </copyright>
//
// <summary>
//	-- not currently used --
//	Declarations for LWEventLua class, an implementation of metatable methods exposed
//	to lua.  The event has an associated IEventBasePtr with which the methods
//	interact.
//	-- not currently used --
// </summary>
//
// <owner>Mike Cookson</owner>
//-------------------------------------------------------------------------------------------------

#ifndef __LWEvent_H__
#define __LWEvent_H__

#include "LWConcreteCmd.h"
#include "LqrSMACLuaInstance.h"
#include "LqrSMACSharedLib.h"
#include "LqrSMACTimerCollection.h"
#include "Luna2.h"
#include <boost/shared_ptr.hpp>

namespace LiquidRobotics {

namespace EventLib {
	class IEventBase;
}

namespace SMACFramework {
	class Logger;
}

namespace LuaWrapper {

class SHARED_LIB_PUBLIC LWEventLua : public boost::noncopyable
{
public:

	typedef LiquidRobotics::EventLib::IEventBase IEventBase;
	typedef boost::shared_ptr<IEventBase> IEventBasePtr;
	typedef LiquidRobotics::SMACFramework::Logger Logger;
	typedef LiquidRobotics::SMACFramework::LuaInstance LuaInstance;
	typedef std::string string;

	LWEventLua(LuaInstance& L);					// will not be called directly from lua since other information is required
	virtual ~LWEventLua();

	void Initialize(IEventBasePtr _eventPtr, LWControllerBase0* _pController, Logger* pLogger);

	static string GetClassName();
	static int GetRegistrations(const Luna2<LWEventLua>::RegType*& regBase);
	static void PreRegistration(LuaInstance& L);

	int Duplicate(LuaInstance& L);				// Duplicate():event
	int GetCreationTime(LuaInstance& L);		// GetCreationTime():{time_t,microseconds}
	int SetCreationTime(LuaInstance& L);		// SetCreationTime(time_t or {time_t,microseconds} or nil)
	int GetEventName(LuaInstance& L);			// GetEventName():string
	int GetEventType(LuaInstance& L);			// GetEventType():{string type-name, string domain-name)
	int GetProperty(LuaInstance& L);			// GetProperty(string propName[, string format]):propValue
	int HasProperty(LuaInstance& L);			// HasProperty(string propName):boolean
	int SetProperty(LuaInstance& L);			// SetProperty(string propName, propValue[, string format])
	int GetPropertyNames(LuaInstance& L);		// GetPropertyNames():{..strings..}
	int GetPropertyType(LuaInstance& L);		// GetPropertyType(string propName):string
	int GetSourceAddress(LuaInstance& L);		// GetSourceAddress():number
	int GetSourceBoardID(LuaInstance& L);		// GetSourceBoardID():number
	int GetSourceTaskID(LuaInstance& L);		// GetSourceTaskID():number
	int GetLocation(LuaInstance& L);			// GetLocation():{number latitude, number longitude}
	int SetLocation(LuaInstance& L);			// SetLocation(number latitude, number longitude);
	int RemoveProperty(LuaInstance& L);			// RemoveProperty(string propName)
	int ToTable(LuaInstance& L);				// ToTable():{}
	int Transmit(LuaInstance& L);				// Transmit()

private:

	static const Luna2<LWEventLua>::RegType registrations[];
	static const size_t registrationCount;

	IEventBasePtr eventPtr;
	LWControllerBase0* pController;
	Logger* pLogger;
};

}
}

#endif
