Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef T_PARAM_INCLUDED
Toshihiro Shimizu 890ddd
#define T_PARAM_INCLUDED
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tpersist.h"
Toshihiro Shimizu 890ddd
#include "tsmartpointer.h"
Toshihiro Shimizu 890ddd
#include <set></set>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TPARAM_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TParamObserver;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
//! This class is an abstract class and is a generic interface to the features of an object.
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
	It is used to access to the parameters of an object, with the purpose  
Toshihiro Shimizu 890ddd
	to store and retrieve the key features.
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
class DVAPI TParam : public TSmartObject, public TPersist
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	DECLARE_CLASS_CODE
Shinya Kitaoka 3bfa54
	std::string m_name;
Shinya Kitaoka 3bfa54
	std::string m_description;
Shinya Kitaoka 3bfa54
	std::string m_label;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
		The contructor store the name of the parameter and initialize his 
Toshihiro Shimizu 890ddd
		interface with I/O through the class TPersist.
Toshihiro Shimizu 890ddd
	*/
Shinya Kitaoka 3bfa54
	TParam(std::string name = "", std::string description = "", std::string label = "")
Toshihiro Shimizu 890ddd
		: TSmartObject(m_classCode), TPersist(), m_name(name), m_description(description),
Toshihiro Shimizu 890ddd
		  m_label(label) {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	virtual ~TParam() {}
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
		Returns the name of the parameter.
Toshihiro Shimizu 890ddd
	*/
Shinya Kitaoka 3bfa54
	std::string getName() const { return m_name; };
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
		This method sets the name of the parameter to \e name.
Toshihiro Shimizu 890ddd
	*/
Shinya Kitaoka 3bfa54
	void setName(const std::string &name) { m_name = name; };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
		Return the description.
Toshihiro Shimizu 890ddd
	*/
Shinya Kitaoka 3bfa54
	std::string getDescription() const { return m_description; }
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
		Set the description.
Toshihiro Shimizu 890ddd
	*/
Shinya Kitaoka 3bfa54
	void setDescription(const std::string &description) { m_description = description; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool hasUILabel() const { return m_label != "" ? true : false; }
Toshihiro Shimizu 890ddd
	void setUILabel(const std::string &l) { m_label = l; };
Toshihiro Shimizu 890ddd
	std::string getUILabel() const { return m_label; };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
		This method must be implemented with a clone function, i.e a function that make 
Toshihiro Shimizu 890ddd
		a new copy of the parameter. 
Toshihiro Shimizu 890ddd
	*/
Toshihiro Shimizu 890ddd
	virtual TParam *clone() const = 0;
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
		Performs a copy function of the parameter in an existing object.
Toshihiro Shimizu 890ddd
	*/
Toshihiro Shimizu 890ddd
	virtual void copy(TParam *src) = 0;
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
		An observer is a generic class that takes care and manages of canghes in the parameters.
Toshihiro Shimizu 890ddd
		This method must be implemented with a function that add objects to an observer internal list.   
Toshihiro Shimizu 890ddd
	*/
Toshihiro Shimizu 890ddd
	virtual void addObserver(TParamObserver *) = 0;
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
		Removes \e this from the observer. 
Toshihiro Shimizu 890ddd
		\sa addObserver()
Toshihiro Shimizu 890ddd
	*/
Toshihiro Shimizu 890ddd
	virtual void removeObserver(TParamObserver *) = 0;
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
		This method is used to sets the status changing notification of the parameter. i.e the 
Toshihiro Shimizu 890ddd
		observer must take care of the changes. 
Toshihiro Shimizu 890ddd
     */
Toshihiro Shimizu 890ddd
	virtual void enableNotification(bool on) {}
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
		This method must return \e true if the  notification status is enabled.
Toshihiro Shimizu 890ddd
	*/
Toshihiro Shimizu 890ddd
	virtual bool isNotificationEnabled() const { return true; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
		This pure virtual method must return a string with the value of the parameter 
Toshihiro Shimizu 890ddd
		and the precision needed.
Toshihiro Shimizu 890ddd
	*/
Shinya Kitaoka 3bfa54
	virtual std::string getValueAlias(double frame, int precision) = 0;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	virtual bool isAnimatable() const = 0;
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
		It must returns \e true if the \e frame is a keyframe.
Toshihiro Shimizu 890ddd
	*/
Toshihiro Shimizu 890ddd
	virtual bool isKeyframe(double frame) const = 0;
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
		Removes \e frame from the list of the keyframes associated to this parameter.	
Toshihiro Shimizu 890ddd
	*/
Toshihiro Shimizu 890ddd
	virtual void deleteKeyframe(double frame) = 0;
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
		Removes all keyframes from this parameter.
Toshihiro Shimizu 890ddd
	*/
Toshihiro Shimizu 890ddd
	virtual void clearKeyframes() = 0;
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
		Makes the \e frame associated to this parameter a keyframe
Toshihiro Shimizu 890ddd
	*/
Toshihiro Shimizu 890ddd
	virtual void assignKeyframe(
Toshihiro Shimizu 890ddd
		double frame,
Toshihiro Shimizu 890ddd
		const TSmartPointerT<tparam> &src, double srcFrame,</tparam>
Toshihiro Shimizu 890ddd
		bool changedOnly = false) = 0;
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
		This function must be overridden with a method that returns as a reference 
Toshihiro Shimizu 890ddd
		a list of keyframes in the form of a standard list.  
Toshihiro Shimizu 890ddd
	*/
Toshihiro Shimizu 890ddd
	virtual void getKeyframes(std::set<double> &frames) const {}</double>
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
		This method must return true if there are keyframes associated to this parameter.
Toshihiro Shimizu 890ddd
	*/
Toshihiro Shimizu 890ddd
	virtual bool hasKeyframes() const { return false; }
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
		This method must return the index of the keyframe (if any) after the \e frame, otherwiswe 
Toshihiro Shimizu 890ddd
		returns -1.
Toshihiro Shimizu 890ddd
	*/
Toshihiro Shimizu 890ddd
	virtual int getNextKeyframe(double frame) const { return -1; }
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
		This method must return the index of the keyframe (if any) before the \e frame, otherwiswe 
Toshihiro Shimizu 890ddd
		returns -1.
Toshihiro Shimizu 890ddd
	*/
Toshihiro Shimizu 890ddd
	virtual int getPrevKeyframe(double frame) const { return -1; }
Toshihiro Shimizu 890ddd
	/*!
Toshihiro Shimizu 890ddd
		This method must returns a frame given the index \e index. A frame is a double value representing 
Toshihiro Shimizu 890ddd
		a frame.
Toshihiro Shimizu 890ddd
	*/
Toshihiro Shimizu 890ddd
	virtual double keyframeIndexToFrame(int index) const { return 0.0; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	// not implemented
Toshihiro Shimizu 890ddd
	TParam(const TParam &);
Toshihiro Shimizu 890ddd
	TParam &operator=(const TParam &);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 9f5a1b
#ifdef _WIN32
Toshihiro Shimizu 890ddd
template class DVAPI TSmartPointerT<tparam>;</tparam>
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
typedef TSmartPointerT<tparam> TParamP;</tparam>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 9f5a1b
#ifdef _WIN32
Toshihiro Shimizu 890ddd
#define DVAPI_PARAM_SMARTPOINTER(PARAM)         \
Toshihiro Shimizu 890ddd
	template class DVAPI TSmartPointerT<param>; \
Toshihiro Shimizu 890ddd
	template class DVAPI TDerivedSmartPointerT<param, tparam="">;</param,>
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI_PARAM_SMARTPOINTER(PARAM)
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define DEFINE_PARAM_SMARTPOINTER(PARAM, TYPE)                         \
Toshihiro Shimizu 890ddd
	DVAPI_PARAM_SMARTPOINTER(PARAM)                                    \
Toshihiro Shimizu 890ddd
                                                                       \
Toshihiro Shimizu 890ddd
	class DVAPI PARAM##P : public TDerivedSmartPointerT<param, tparam=""> \</param,>
Toshihiro Shimizu 890ddd
	{                                                                  \
Toshihiro Shimizu 890ddd
	public:                                                            \
Toshihiro Shimizu 890ddd
		PARAM##P(PARAM *p = 0) : DerivedSmartPointer(p) {}             \
Toshihiro Shimizu 890ddd
		PARAM##P(TYPE v) : DerivedSmartPointer(new PARAM(v)) {}        \
Toshihiro Shimizu 890ddd
		PARAM##P(TParamP &p) : DerivedSmartPointer(p) {}               \
Toshihiro Shimizu 890ddd
		PARAM##P(const TParamP &p) : DerivedSmartPointer(p) {}         \
Toshihiro Shimizu 890ddd
		operator TParamP() const { return TParamP(m_pointer); }        \
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif