MAK RTIspy API Documentation for HLA Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
messageProcessor.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2005 MaK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: messageProcessor.h,v $ $Revision: 1.3 $ $State: Exp $
7 *******************************************************************************/
10 
11 #ifndef DtMessageProcessor_H_
12 #define DtMessageProcessor_H_
13 
14 #include "rtiMsConfig.h"
15 #include <vector>
16 #include <list>
17 
23 template < class Address, class Message >
25 {
26 public:
27 
28  typedef std::vector< Address > AddressList;
29 
31  class Filter
32  {
33  public:
34 
35  Filter() {};
36  virtual ~Filter() {};
37 
39  virtual inline bool applyFilter( const Message& msg ) const { return false; }
40 
42  virtual inline bool processDestinations( const Address& src, const Message& msg,
43  AddressList& destinations ) const
44  {
46  if ( applyFilter( msg ))
47  return doDestinationProcessing( src, msg, destinations );
48  else
49  return false;
50  }
51 
52  virtual inline bool processMessage( const Address& src, Message& msg ) const
53  {
55  if ( applyFilter( msg ))
56  return doMessageProcessing( src, msg );
57  else
58  return false;
59  }
60 
61  protected:
62 
64  virtual inline bool doDestinationProcessing( const Address& src, const Message& msg,
65  AddressList& destinations ) const { return false; }
66 
68  virtual inline bool doMessageProcessing( const Address& src, Message& msg ) const { return false; }
69  };
70 
71  typedef std::list< Filter* > FilterList;
72 
74  virtual ~DtMessageProcessor() {};
75 
79  virtual inline bool processDestinationList( const Address& src, const Message& msg,
80  AddressList& destinations ) const;
81 
85  virtual inline bool processMessage( const Address& src, Message& msg ) const;
86 
88  virtual inline void addDestinationFilter( Filter* filter )
89  {
90  myDestFilters.push_back( filter );
91  }
92  virtual inline void removeDestinationFilter( Filter* filter )
93  {
94  if ( myDestFilters.size() )
95  {
96  myDestFilters.remove( filter );
97  }
98  }
99  virtual inline void addMessageFilter( Filter* filter )
100  {
101  myMsgFilters.push_back( filter );
102  }
103  virtual inline void removeMessageFilter( Filter* filter )
104  {
105  if ( myMsgFilters.size() )
106  {
107  myMsgFilters.remove( filter );
108  }
109  }
110 
111 protected:
112 
115 };
116 
118 #define DtMessageProcessor_Inl_
119 #include "messageProcessor.inl"
120 #undef DtMessageProcessor_Inl_
121 
122 #endif
123 
virtual bool processMessage(const Address &src, Message &msg) const
Definition: messageProcessor.h:52
User-defined Message Processing Function Object.
Definition: messageProcessor.h:31
FilterList myMsgFilters
Definition: messageProcessor.h:114
virtual void removeMessageFilter(Filter *filter)
Definition: messageProcessor.h:103
virtual void removeDestinationFilter(Filter *filter)
Definition: messageProcessor.h:92
Filter()
Definition: messageProcessor.h:35
virtual ~DtMessageProcessor()
Definition: messageProcessor.h:74
virtual bool processDestinations(const Address &src, const Message &msg, AddressList &destinations) const
Test if filter should be applied and then apply.
Definition: messageProcessor.h:42
virtual void addMessageFilter(Filter *filter)
Definition: messageProcessor.h:99
FilterList myDestFilters
Definition: messageProcessor.h:113
virtual ~Filter()
Definition: messageProcessor.h:36
std::vector< Address > AddressList
Definition: messageProcessor.h:28
std::list< Filter * > FilterList
Definition: messageProcessor.h:71
virtual bool doMessageProcessing(const Address &src, Message &msg) const
Processes and modifies passed messages.
Definition: messageProcessor.h:68
virtual bool applyFilter(const Message &msg) const
Does this filter apply to this msg?
Definition: messageProcessor.h:39
virtual bool doDestinationProcessing(const Address &src, const Message &msg, AddressList &destinations) const
Processes and modifies passed destination lists.
Definition: messageProcessor.h:64
DtMessageProcessor()
Definition: messageProcessor.h:73
The DtMessageProcessor template class allows user to register simple message processing function obje...
Definition: messageProcessor.h:24
#define DT_DLL_FORWARDER
Definition: rtiMsConfig.h:124
virtual void addDestinationFilter(Filter *filter)
Add / Remove message and destination list processing filters.
Definition: messageProcessor.h:88

Document ID: Generated on Mon Sep 7 15:40:32 EDT 2020 from SVN revision 217499
Copyright © 2005-2020 MAK Technologies Inc. All Rights Reserved (www.mak.com)