/** @file BaseStorage.h
  * @brief The RTTI class for any type
  * @author Paolo Medici [ medici AT ce DOT unipr DOT it ]
  **/
#ifndef _BASE_STORAGE_H
#define _BASE_STORAGE_H

//////////////

/// Un contenitore generico per permette di astrarre il tipo di dato
///  e farlo funzionare con RTTI. int, bool, double, etc etc non 
///  hanno RTTI in quanto sono tipi base senza metodi astratti.
class BaseStorage {
	public:
	virtual ~BaseStorage() {}
    /// Crea una copia dello storage (puo' servire?)
    ///  se non serve. si puo' togliere
    virtual BaseStorage *clone() const = 0;
};

/// A specialized container for type `T'
template<class T>
class SpecializedStorage : public BaseStorage  {
	T m_storage;
	public:
	/// ctor usend when this object is destination
	SpecializedStorage() { }
	/// ctor used when this object is source
	SpecializedStorage(const T & t) : m_storage(t) { }
	virtual ~SpecializedStorage() { }
    /// generate a copy of this storage (however I do not know if can be used)
	virtual BaseStorage *clone(void) const { return new SpecializedStorage<T>(m_storage); }
	/// method to access to value
	inline T & Value() { return m_storage; }
	inline const T & Value() const { return m_storage; }
};

#endif