⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iceapi.h

📁 使用stl技术,(还没看,是听说的)
💻 H
字号:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
 *	Contains an abstract API class.
 *	\file		IceAPI.h
 *	\author		Pierre Terdiman
 *	\date		June, 20, 2002
 */
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Include Guard
#ifndef __ICEAPI_H__
#define __ICEAPI_H__

	//! API flags
	enum APIFlag
	{
		API_INITIALIZED	= (1<<0),	//!< API has been initialized

		API_READ_ONLY	= API_INITIALIZED,

		API_FORCE_DWORD	= 0x7fffffff
	};

	#define DECLARE_CREATOR(current_class, base_class)									\
		public:		current_class();													\
		virtual		~current_class()	{}												\
		DECLARE_RTTI(current_class, base_class)											\
		DECLARE_FIELDS																	\
		override(Parsable) bool Parameter(const char* line, const ParameterBlock& pb)	\
		{																				\
			if(current_class::SetFrom(pb))	return false;								\
			return base_class::Parameter(line, pb);										\
		}

	//! Base class for APIs' creation structures
	class ICECORE_API APICREATE : public Parsable
	{
		public:
							APICREATE()		{}
		virtual				~APICREATE()	{}

							DECLARE_RTTI_BASE(APICREATE)
	};

	class ICECORE_API IceAPI
	{
		public:
		// Constructor/Destructor
							IceAPI();
		virtual				~IceAPI();

							DECLARE_FLAGS(APIFlag, mAPIFlags, API_READ_ONLY)

		inline_	BOOL		HasBeenInitialized()	const			{ return mRefCount;	}

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Initializes the API. Must be called first, else the API behaviour is undefined.
		 *	\param		create	[in] creation parameters
		 *	\return		true if the API is initialized for the first time
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		virtual	bool		Init(const APICREATE* create);

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Closes the API.
		 *	\param		force_release	[in] true to force the lib to be released, else use refcounting
		 *	\return		false if the API is still beeing referenced
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		virtual	bool		Close(bool force_release=false);

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Gets the API's name.
		 *	\return		the API name
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		virtual	const char*	GetAPIName()			const			= 0;

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Gets the compile-time string. This can be used to check which DLL is the most recent.
		 *	\return		compile-time string
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		virtual	const char*	GetCompileTimeString()	const			= 0;

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Class factory.
		 *	\param		class_name	[in] name of desired class
		 *	\return		new class instance, or null
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		virtual	void*		CreateClass(const char* class_name)		= 0;

		virtual	void		NewInterface(IceInterface* it)			= 0;

		protected:
				void		LogAPIInfo()			const;
		private:
				udword		mRefCount;	//!< API's refcounter
	};

#endif // __ICEAPI_H__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -