Show msghook.cpp syntax highlighted
/***************************************************************************
msghook.cpp - 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.cpp
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.
***************************************************************************/
#include "msghook.h"
#ifdef HAVE_NEOCHUNKIO
# include <neochunkio/integer.h>
# include <neochunkio/bool.h>
#endif
namespace NeoWTK
{
MsgHook::MsgHook() :
m_eID( Msg::INVALID ),
m_pkSender( 0 ),
m_pkReceiver( 0 ),
m_pkProcessor( 0 ),
m_bDeleteProcessor( false )
{
}
MsgHook::MsgHook( Msg::MSGID eID, Object *pkSender, Object *pkReceiver, MsgHookMethod *pkProcessor, bool bDeleteProcessor ) :
m_eID( eID ),
m_pkSender( pkSender ),
m_pkReceiver( pkReceiver ),
m_pkProcessor( pkProcessor ),
m_bDeleteProcessor( bDeleteProcessor )
{
}
MsgHook::~MsgHook()
{
if( m_bDeleteProcessor )
delete m_pkProcessor;
}
bool MsgHook::IsHook( Msg *pkMsg )
{
return( ( ( m_eID == Msg::INVALID ) || ( m_eID == pkMsg->m_eID ) ) &&
( !m_pkSender || !pkMsg->m_pkSender || ( m_pkSender == pkMsg->m_pkSender ) ) &&
( !m_pkReceiver || !pkMsg->m_pkReceiver || ( m_pkReceiver == pkMsg->m_pkReceiver ) ) );
}
#ifdef HAVE_NEOCHUNKIO
using namespace NeoChunkIO;
MsgHookChunk::~MsgHookChunk()
{
delete m_pkHook;
}
int MsgHookChunk::ParseData( unsigned int uiFlags, NeoEngine::FileManager *pkFileManager )
{
if( !m_pkHook )
m_pkHook = new MsgHook;
Chunk *pkChunk;
if( ( pkChunk = FindChunk( "msgid", NeoChunkIO::ChunkType::INTEGER ) ) )
m_pkHook->m_eID = Msg::MSGID( dynamic_cast< IntChunk* >( pkChunk )->m_iData );
if( ( pkChunk = FindChunk( "delete", NeoChunkIO::ChunkType::BOOL ) ) )
m_pkHook->m_bDeleteProcessor = dynamic_cast< BoolChunk* >( pkChunk )->m_bData;
return 1;
}
#endif
};
See more files for this project here