/* * * VVV VVV A * VVV VVV AAA Virtual Acoustics * VVV VVV AAA Real-time auralisation for virtual reality * VVV VVV AAA * VVVVVV AAA (c) Copyright Institut für Technische Akustik (ITA) * VVVV AAA RWTH Aachen (http://www.akustik.rwth-aachen.de) * * --------------------------------------------------------------------------------- * * File: VAAttributable.h * * Purpose: Attribute aspect interface * * Autor(en): Frank Wefers (Frank.Wefers@akustik.rwth-aachen.de) * * --------------------------------------------------------------------------------- */ // $Id: $ #ifndef __VABASE_ATTRIBUTABLE_H__ #define __VABASE_ATTRIBUTABLE_H__ #include #include //! Attribute base class /** * This is the base class for attributes. * Currently it only defines the destructor. */ class VABASE_API IVAAttribute { public: virtual ~IVAAttribute(); }; //! Attributation interface /** * This aspect allows attaching/detaching attributes by means of a pointer * to some instance of a class. The attributes are associated with their owner, * the instance, which added/removed them. Thereby 1 instance can be associated * with N attributes. The interface is used, so that other class can extend * previously created instances of some base class with their own runtime data. * Example: An HRIR dataset can be attach with some frequency-domain HRTF representation. */ class VABASE_API IVAAttributable { public: virtual ~IVAAttributable(); virtual void AttachAttribute(void* pOwner, IVAAttribute* pAttr)=0; virtual void DetachAttribute(void* pOwner)=0; virtual IVAAttribute* GetAttribute(void* pOwner)=0; }; //! Attributation interface default implementation /** * Implements the IVAAttributable interface using std::map. * This implementation is not thread-safe! You need to take care yourself! */ class VABASE_API CVAAttributableImpl : public IVAAttributable { public: virtual ~CVAAttributableImpl(); virtual void AttachAttribute(void* pOwner, IVAAttribute* pAttr); virtual void DetachAttribute(void* pOwner); virtual IVAAttribute* GetAttribute(void* pOwner); private: typedef std::map AttrMap; typedef AttrMap::iterator AttrMapIt; AttrMap m_mAttr; }; #endif // __VABASE_ATTRIBUTABLE_H__