Show msghook.h syntax highlighted
/***************************************************************************
msghook.h - Action executed on specific message
-------------------
begin : Tue Dec 17 2002
copyright : (C) 2002 by Mattias Jansson
email : mattias@realityrift.com
***************************************************************************
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is the NeoEngine, NeoWTK, msghook.h
The Initial Developer of the Original Code is Mattias Jansson.
Portions created by Mattias Jansson are Copyright (C) 2002
Reality Rift Studios. All Rights Reserved.
***************************************************************************/
#ifndef __NEOWTKMSGHOOK_H
#define __NEOWTKMSGHOOK_H
#include "base.h"
#include "msg.h"
#ifdef HAVE_NEOCHUNKIO
# include <neochunkio/complex.h>
# include "chunktype.h"
#endif
/**
* \file msghook.h
* Object used to hook into a wtk object message processing pipeline
*/
namespace NeoWTK
{
// Forward declarations
class MsgHook;
/**
* \brief Interface for message hook procedures
* \author Mattias Jansson (mattias@realityrift.com)
*/
class NEOWTK_API MsgHookMethod
{
public:
/**
* Execute action
* \param pkHook Hook object we are invoked by
* \param pkMsg Message that triggered hook
*/
virtual void ProcessHook( MsgHook *pkHook, Msg *pkMsg ) = 0;
};
/**
* \brief Object used to hook into a wtk object message processing pipeline
* \author Mattias Jansson (mattias@realityrift.com)
*/
class NEOWTK_API MsgHook
{
public:
/*! Message ID or MSGID_INVALID if any */
Msg::MSGID m_eID;
/*! Required sender object or null if any */
Object *m_pkSender;
/*! Required receiver object or null if any */
Object *m_pkReceiver;
/*! Method */
MsgHookMethod *m_pkProcessor;
/*! Flag indicating if we should delete processor object in dtor (default false) */
bool m_bDeleteProcessor;
/**
*/
MsgHook();
/**
* \param eID Message ID to listen to, Msg::INVALID if any
* \param pkSender Required sender object, null if any
* \param pkReceiver Required receiver object, null if any
* \param pkProcessor Hook method object
* \param bDeleteProcessor Flag indicating if processor method object in dtor, default false
*/
MsgHook( Msg::MSGID eID, Object *pkSender, Object *pkReceiver, MsgHookMethod *pkProcessor, bool bDeleteProcessor = false );
/**
*/
virtual ~MsgHook();
/**
* \param pkMsg Message object
* \return true if message match hook parameters, false if not
*/
virtual bool IsHook( Msg *pkMsg );
};
#ifdef HAVE_NEOCHUNKIO
/**
* \brief Chunk for message hooks
* \author Mattias Jansson (mattias@realityrift.com)
*/
class NEOWTK_API MsgHookChunk : public NeoChunkIO::ComplexChunk
{
public:
/*! Message hook object */
MsgHook *m_pkHook;
/**
* Initialize chunk
* \param usType Chunk type
* \param rstrType Chunk type as string
* \param rstrID Chunk ID string
*/
MsgHookChunk( unsigned short usType, const NeoEngine::HashString &rstrType, const NeoEngine::HashString &rstrID = "" ) : NeoChunkIO::ComplexChunk( usType, rstrType, rstrID ), m_pkHook( 0 ) { m_usFindType = NeoWTK::ChunkType::MSGHOOK; }
/**
* Deallocate data and subchunks
*/
virtual ~MsgHookChunk();
/**
* Parse chunk data
* \param uiFlags Parse flags
* \param pkFileManager File manager
* \return <0 if error, >0 if successful (0 reserved)
*/
virtual int ParseData( unsigned int uiFlags, NeoEngine::FileManager *pkFileManager );
};
#endif
};
#endif
See more files for this project here