#ifndef MACROS_H
#define MACROS_H

/*
** Macros for global access to managers.
*/
#define registerGlobalManager(className, classAlias) \
		static className& classAlias() \
		{ \
			return *(className*)&application().getManager(className::TypeId); \
		}

/*
** For class types that require unique Ids, call this function just before the implementation
** of the constructor to register with the UniqueId handler.
*/
#define defineUniqueId(className) \
		const Salamander::UniqueId className::TypeId = Salamander::UniqueId();

/*
** Macros for registering classes that use unique Ids. There are four different macros to use,
** depending on the context. It is recommended that macro rewriting be used to provide more
** intuitive names to users based on the situation.
**
** This function provides a typeOf method that can be used to check against all clases in an
** inheritance chain.
*/
#define registerInheritedUniqueId(baseClassName) \
		/*
		** The 'TypeId' member will return the UniqueId of the type of class that is declared in code.
		*/ \
		static const Salamander::UniqueId TypeId; \
		/*
		** The 'typeId()' method uses virtual functions to return the type of the actual object. This 
		** should be preferred over direction access to the TypeId member.
		*/ \
		virtual const Salamander::UniqueId& typeId() const \
		{ \
			return TypeId; \
		}; \
		/*
		** In situations where a class is likely to be subclassed, yet type checking should still register
		** the type of the base class, this 'typeOf()' method should be used. It will return true if this
		** class, any subclasses, or any superclasses have the specified type.
		*/ \
		virtual bool typeOf(const Salamander::UniqueId& typeId) const \
		{ \
			return (TypeId == typeId) || \
					baseClassName::typeOf(typeId); \
		};

/*
** This function should be implmented by any interfaces that require a uniqueID and need to provide
** the hierarchy dependant typeOf method. The pure virtual function forces all inherited classes to
** define a uniqueID using registerInheritedUniqueId.
*/
#define registerInterfaceInheritedUniqueId() \
		static const Salamander::UniqueId TypeId; \
		virtual const Salamander::UniqueId& typeId() const = 0 \
		{ \
			return TypeId; \
		}; \
		virtual bool typeOf(const Salamander::UniqueId& typeId) const = 0 \
		{ \
			return (TypeId == typeId); \
		};

/*
** This function should be used by all classes that require a uniqueID, but do not need
** to know the strict hierarchy. It requires no parameters and is therefore easier to use.
*/
#define registerUniqueId() \
		static const Salamander::UniqueId TypeId; \
		virtual const Salamander::UniqueId& typeId() const \
		{ \
			return TypeId; \
		}; \

/*
** This method should be used by interfaces that require a uniqueID, but do not need
** to know the strict hierarchy. It contains a pure virtual method that forces all inherited
** classes to also register a UniqueID using registerUniqueId.
*/
#define registerInterfaceUniqueId() \
		static const Salamander::UniqueId TypeId; \
		virtual const Salamander::UniqueId& typeId() const = 0 \
		{ \
			return TypeId; \
		}; \

/*
** This macro allows the creation of enum-style containers with modifiable members that
** can also be evaluated at runtime. Used primarily in event handling to allow for hardware
** code remapping.
**
** Microsoft specific compilers could potentially use __COUNTER__ instead of __LINE__
*/
#define defineCode(codeName) \
		static EventCode codeName = __LINE__;


#endif // MACROS_H