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

📄 icecell.h

📁 使用stl技术,(还没看,是听说的)
💻 H
📖 第 1 页 / 共 2 页
字号:
		 *	This is the recommended way, since it provides best of both worlds:
		 *	- type comparisons are fast since you just compare 2 dwords instead of 2 strings
		 *	- yet it remains human-readable, not as if you were using GUIDs or something
		 *
		 *	\param		type	[in] cell's type
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		inline_			void			SetType(const char* type)								{ m__Type = type;						}

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Gets the cell's type.
		 *	\return		cell's type
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		inline_			const char*		GetType()									const		{ return m__Type;						}

		// Flags
		inline_			udword			GetCellFlag()								const		{ return m__Flags;						}
		inline_			bool			IsSet(CellFlag flag)						const		{ return (m__Flags&flag)!=0;			}
		inline_			Cell&			Enable(CellFlag flag)									{ m__Flags |= flag;		return *this;	}
		inline_			Cell&			Disable(CellFlag flag)									{ m__Flags &= ~flag;	return *this;	}

		//! Shared data blocks [experimental - don't use]
						DataBlock*		CreateDataBlock(udword length);
						DataBlock*		ShareDataBlock(DataBlock* block);
		// Naming
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Sets the cell's name. You can override it to impose particular naming conventions.
		 *	\param		name	[in] cell's name
		 *	\return		true if success
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		virtual			bool			SetName(const char* name);

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Gets the cell's name.
		 *	\param		name	[out] cell's name
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		inline_			void			GetName(String& name)						const		{ name = m__Name;						}

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Gets the cell's name.
		 *	\return		cell's name
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		inline_			const char*		GetName()									const		{ return m__Name.Get();					}

		// Destruction
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Checks a cell can be destroyed.
		 *	\return		true if the cell can be destroyed
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		virtual			bool			CanDestruct()								const		{ return GetNbOwners()==0;				}

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	The self-destruction method. The kernel always deletes cells indirectly, using this method. That way the app has a way to
		 *	definitely prevent the kernel from deleting cells, by overriding this method. This should not be needed nonetheless.
		 *	\param		context		[in] destruction context
		 *	\param		user_data	[in] possible user-defined data
		 *	\return		true if the cell has been deleted
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		virtual			bool			SelfDestruct(udword context=0, udword user_data=0);

		//! TO BE DOCUMENTED
						Cell*			Clone(bool copymembers=true);

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Gets the size of the object.
		 *	\return		derivation level
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		virtual			udword			GetSize()									const		{ return SIZEOFOBJECT;					}

		// Notifications & events
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Registers a user-notification for this cell.
		 *	\param		notif_index	[in] notification index
		 *	\param		callback	[in] notification callback
		 *	\param		user_data	[in] user-defined data
		 *	\return		true if success
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		virtual			bool			RegisterNotif(udword notif_index, NotifCallback callback, udword user_data);

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Validates an event for a given notification.
		 *	\param		notif_index	[in] notification index
		 *	\param		bit_mask	[in] event bitmask
		 *	\return		true if success
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		virtual			bool			ValidateEvent(udword notif_index, udword bit_mask);

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Invalidates an event for a given notification.
		 *	\param		notif_index	[in] notification index
		 *	\param		bit_mask	[in] event bitmask
		 *	\return		true if success
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		virtual			bool			InvalidateEvent(udword notif_index, udword bit_mask);

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Unregisters a user-notification for this cell.
		 *	\param		notif_index	[in] notification index
		 *	\param		callback	[in] notification callback
		 *	\return		true if success
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		virtual			bool			RemoveNotif(udword notif_index, NotifCallback callback=null);

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Unregisters all user-notifications for this cell.
		 *	\return		true if success
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		virtual			bool			RemoveNotif();

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Executes a user-notification.
		 *	\param		notif_index	[in] notification index
		 *	\param		bit_mask	[in] notification bitmask
		 *	\param		param		[in] a parameter sent to the notification callback
		 *	\param		result		[out] returned from notification callback
		 *	\return		true if a callback has been found
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
						bool			ExecuteNotif(udword notif_index, udword bit_mask, udword param, bool& result);

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Gets a priority. The higher the value, the less the priority.
		 *	\return		priority value
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		virtual			udword			GetPriority()											{ return 0;								}

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Assigns a script to the object.
		 *	\param		filename	[in] script filename
		 *	\return		true if success
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		virtual			bool			AssignScript(const char* filename);

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Executes a given command.
		 *	\param		command		[in] the command to execute, or null. If null, EnumCommand gets called for each command found.
		 *	\param		user_data	[in] user-defined data, sent to EnumCommand if needed.
		 *	\return		true if success
		 *	\see		EnumCommand(const char* command, udword user_data)
		 *	\see		DispatchCommand(const char* command, udword user_data, bool refs)
		 *	\warning	No commands defined for Cell.
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		virtual			bool			ExecCommand(const char* command, udword user_data=0)	{ return false;							}

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Callback used by ExecCommand to enumerate all registered commands.
		 *	\param		command		[in] current command found
		 *	\param		user_data	[in] user-defined data, coming from ExecCommand
		 *	\return		Self-reference
		 *	\see		ExecCommand(const char* command, udword user_data)
		 *	\see		DispatchCommand(const char* command, udword user_data, bool refs)
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		virtual			Cell&			EnumCommand(const char* command, udword user_data=0)	{ return *this;							}

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Command dispatcher. Sends command to all references or all owners.
		 *	\param		command		[in] the command to send
		 *	\param		user_data	[in] user-defined data
		 *	\param		bool		[in] true to send the command to references, else sent to owners
		 *	\return		true if success
		 *	\see		ExecCommand(const char* command, udword user_data)
		 *	\see		EnumCommand(const char* command, udword user_data)
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
						bool			DispatchCommand(const char* command, udword user_data=0, bool refs=true);

						bool			BindData(const char* data_name, udword user_data);
						bool			RemoveData(const char* data_name, udword* user_data=null);
						bool			GetData(const char* data_name, udword* user_data=null);

		private:
		// NB: the m__XXXX member naming convention is used so that you can reuse names like "mType" and "mFlags" in your
		// derived classes, in a non-ambiguous way.
						NotifBundle*	m__NB;			//!< Notification array
						KID				m__KernelID;	//!< Global unique kernel identifier
#ifdef USE_HANDLE_MANAGER
						udword			m__Flags;		//!< Cell flags
#else
						uword			m__Flags;		//!< Cell flags
#endif
						const char*		m__Type;		//!< Cell type
						String			m__Name;		//!< Cell name

						Constants*		m__UserData;	//!< Named user-data

		static			Kernel*			m__Kernel;		//!< Shared kernel shortcut

//		virtual			Cell*			CreateInstance()										{ return new Cell;						}

		friend			class			Kernel;
	};

#endif // __ICECELL_H__

⌨️ 快捷键说明

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