MAK RTIspy API Documentation for HLA Evolved
messageProcessor.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002 ** Copyright (c) 2005 MaK Technologies, Inc.
00003 ** All rights reserved.
00004 *******************************************************************************/
00005 /*******************************************************************************
00006 ** $RCSfile: messageProcessor.h,v $ $Revision: 1.3 $ $State: Exp $
00007 *******************************************************************************/
00010 
00011 #ifndef DtMessageProcessor_H_
00012 #define DtMessageProcessor_H_
00013 
00014 #include "rtiMsConfig.h"
00015 #include <vector>
00016 #include <list>
00017 
00023 template < class Address, class Message >
00024 class DT_DLL_FORWARDER DtMessageProcessor
00025 {
00026 public:
00027 
00028    typedef std::vector< Address > AddressList;
00029 
00031    class Filter
00032    {
00033    public:
00034       
00035       Filter() {};
00036       virtual ~Filter() {};
00037 
00039       virtual inline bool applyFilter( const Message& msg ) const { return false; }
00040 
00042       virtual inline bool processDestinations( const Address& src, const Message& msg,
00043                                               AddressList& destinations ) const
00044       {
00046          if ( applyFilter( msg ))
00047             return doDestinationProcessing( src, msg, destinations );
00048          else
00049             return false;
00050       }
00051 
00052       virtual inline bool processMessage( const Address& src, Message& msg ) const
00053       {
00055          if ( applyFilter( msg ))
00056             return doMessageProcessing( src, msg );
00057          else
00058             return false;
00059       }
00060       
00061    protected:
00062 
00064       virtual inline bool doDestinationProcessing( const Address& src, const Message& msg,
00065                                                    AddressList& destinations ) const { return false; }
00066 
00068       virtual inline bool doMessageProcessing( const Address& src, Message& msg ) const { return false; }      
00069    };
00070 
00071    typedef std::list< Filter* > FilterList;
00072 
00073    DtMessageProcessor() {}
00074    virtual ~DtMessageProcessor() {};
00075 
00079    virtual inline bool processDestinationList( const Address& src, const Message& msg,
00080                                                AddressList& destinations ) const;         
00081 
00085    virtual inline bool processMessage( const Address& src, Message& msg ) const;
00086 
00088    virtual inline void addDestinationFilter( Filter* filter ) 
00089    { 
00090       myDestFilters.push_back( filter ); 
00091    }
00092    virtual inline void removeDestinationFilter( Filter* filter ) 
00093    {
00094       if ( myDestFilters.size() )
00095       {
00096          myDestFilters.remove( filter );
00097       } 
00098    }
00099    virtual inline void addMessageFilter( Filter* filter ) 
00100    { 
00101       myMsgFilters.push_back( filter ); 
00102    }
00103    virtual inline void removeMessageFilter( Filter* filter ) 
00104    { 
00105       if ( myMsgFilters.size() )
00106       {
00107          myMsgFilters.remove( filter ); 
00108       }
00109    }
00110       
00111 protected:
00112 
00113    FilterList myDestFilters;
00114    FilterList myMsgFilters;
00115 };
00116 
00118 #define DtMessageProcessor_Inl_
00119 #include "messageProcessor.inl"
00120 #undef DtMessageProcessor_Inl_
00121    
00122 #endif //! DtMessageProcessor_H_
00123 

Document ID: Generated on Thu Jun 14 14:15:04 EDT 2012 from SVN revision 116116
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)