/*----- PROTECTED REGION ID(SupervisedID.h) ENABLED START -----*/
//=============================================================================
//
// file :        SupervisedID.h
//
// description : Include for the SupervisedID class.
//
// project :     Supervised ID: common interface for supervised insertion devices.
//
// $Author: claudio $
//
// $Revision: 1.2 $
// $Date: 2014-04-14 14:51:54 $
//
// SVN only:
// $HeadURL:  $
//
// CVS only:
// $Source: /home/cvsadm/cvsroot/AbstractClasses7/SupervisedID/SupervisedID.h,v $
// $Log: SupervisedID.h,v $
// Revision 1.2  2014-04-14 14:51:54  claudio
// for 8.1.2.c and pogo-8
//
// Revision 1.1.1.1  2012-03-05 14:01:56  claudio
// frist import
//
//
//=============================================================================
//                This file is generated by POGO
//        (Program Obviously used to Generate tango Object)
//=============================================================================


#ifndef SUPERVISEDID_H
#define SUPERVISEDID_H


#include <tango.h>
#include <map>

/*----- PROTECTED REGION END -----*/	//	SupervisedID.h

/**
 *  SupervisedID class description:
 *    This abstract class incapsulates the common interface for insertion devices used
 *    under ID supervisor. The "supervisor" can inhibi/allow the operations on the insertion device
 *    and impose limits on the permited range.
 */

namespace SupervisedID_ns
{
/*----- PROTECTED REGION ID(SupervisedID::Additional Class Declarations) ENABLED START -----*/

		//		Additional Class Declarations

	/*----- PROTECTED REGION END -----*/	//	SupervisedID::Additional Class Declarations
enum privilege{NORMAL,AUTHORIZED,PRIVILEGED};
class SupervisedID : public TANGO_BASE_CLASS
{

/*----- PROTECTED REGION ID(SupervisedID::Data Members) ENABLED START -----*/

	//		Add your own data members
protected:
    privilege caller_privileges(void);
    bool is_privileged; //true is the caller has all privileges - must be handled in alawys_executed
    string clientAddress;
    map<string,int> hostMap;
    privilege check_privileges(privilege, string); //check privileges , emits diagnostics and throw exception, returns actual privileges

	/*----- PROTECTED REGION END -----*/	//	SupervisedID::Data Members

//	Device property data members
public:
	//	HostPrivileges:	list of host:privileges
	//  host:2   host is privileged can read and write and change limits and change permission
	//  host:1  host is authorized can read and write when permitted
	//  host:0 host can only read
	vector<string>	hostPrivileges;

//	Attribute data members
public:

//	Constructors and destructors
public:
	/**
	 * Constructs a newly device object.
	 *
	 *	@param cl	Class.
	 *	@param s 	Device Name
	 */
	SupervisedID(Tango::DeviceClass *cl,string &s);
	/**
	 * Constructs a newly device object.
	 *
	 *	@param cl	Class.
	 *	@param s 	Device Name
	 */
	SupervisedID(Tango::DeviceClass *cl,const char *s);
	/**
	 * Constructs a newly device object.
	 *
	 *	@param cl	Class.
	 *	@param s 	Device name
	 *	@param d	Device description.
	 */
	SupervisedID(Tango::DeviceClass *cl,const char *s,const char *d);
	/**
	 * The device object destructor.
	 */
	~SupervisedID() {delete_device();};


//	Miscellaneous methods
public:
	/*
	 *	will be called at device destruction or at init command.
	 */
	void delete_device();
	/*
	 *	Initialize the device
	 */
	virtual void init_device();
	/*
	 *	Read the device properties from database
	 */
	void get_device_property();
	/*
	 *	Always executed method before execution command method.
	 */
	virtual void always_executed_hook();


//	Attribute methods
public:
	//--------------------------------------------------------
	/*
	 *	Method      : SupervisedID::read_attr_hardware()
	 *	Description : Hardware acquisition for attributes.
	 */
	//--------------------------------------------------------
	virtual void read_attr_hardware(vector<long> &attr_list);
	//--------------------------------------------------------
	/*
	 *	Method      : SupervisedID::write_attr_hardware()
	 *	Description : Hardware writing for attributes.
	 */
	//--------------------------------------------------------
	virtual void write_attr_hardware(vector<long> &attr_list);

/**
 *	Attribute Enabled related methods
 *	Description: True when
 *
 *	Data type:	Tango::DevBoolean
 *	Attr type:	Scalar
 */
	virtual void read_Enabled(Tango::Attribute &attr) = 0;
	virtual void write_Enabled(Tango::WAttribute &attr) = 0;
	virtual bool is_Enabled_allowed(Tango::AttReqType type);
/**
 *	Attribute Ready related methods
 *	Description: true when operating condtions of the ID make it operable by the beamlines:
 *               - good flags and in range.
 *
 *	Data type:	Tango::DevBoolean
 *	Attr type:	Scalar
 */
	virtual void read_Ready(Tango::Attribute &attr) = 0;
	virtual bool is_Ready_allowed(Tango::AttReqType type);
/**
 *	Attribute StatRF related methods
 *	Description: bit mask for compatibility with old style software
 *               Holds the ready and enabled bits together
 *
 *	Data type:	Tango::DevBoolean
 *	Attr type:	Spectrum max = 32
 */
	virtual void read_StatRF(Tango::Attribute &attr) = 0;
	virtual bool is_StatRF_allowed(Tango::AttReqType type);


	//--------------------------------------------------------
	/**
	 *	Method      : SupervisedID::add_dynamic_attributes()
	 *	Description : Add dynamic attributes if any.
	 */
	//--------------------------------------------------------
	void add_dynamic_attributes();




//	Command related methods
public:


	//--------------------------------------------------------
	/**
	 *	Method      : SupervisedID::add_dynamic_commands()
	 *	Description : Add dynamic commands if any.
	 */
	//--------------------------------------------------------
	void add_dynamic_commands();

/*----- PROTECTED REGION ID(SupervisedID::Additional Method prototypes) ENABLED START -----*/

	//	Additional Method prototypes

	/*----- PROTECTED REGION END -----*/	//	SupervisedID::Additional Method prototypes
};

/*----- PROTECTED REGION ID(SupervisedID::Additional Classes Definitions) ENABLED START -----*/

	//	Additional Classes definitions

	/*----- PROTECTED REGION END -----*/	//	SupervisedID::Additional Classes Definitions

}	//	End of namespace

#endif   //	SupervisedID_H