WSF
WsfMessageTable.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef WSFMESSAGETABLE_HPP
13#define WSFMESSAGETABLE_HPP
14
15#include "wsf_export.h"
16
17#include <map>
18
19class UtInput;
20class UtInputBlock;
21#include "UtRandom.hpp"
22class WsfMessage;
23#include "WsfStringId.hpp"
24
46
48{
49public:
50 struct MsgProp
51 {
53 : mCommType(nullptr)
54 , mType(nullptr)
55 , mSubType(nullptr)
56 , mSize(0)
57 , mPriority(0)
58 {
59 }
60
61 MsgProp(WsfStringId aCommType, WsfStringId aType, WsfStringId aSubType, int aSize, int aPriority)
62 : mCommType(aCommType)
63 , mType(aType)
64 , mSubType(aSubType)
65 , mSize(aSize)
66 , mPriority(aPriority)
67 {
68 }
69
73 int mSize;
75 };
77
78 bool ProcessInput(UtInput& aInput);
79
80 bool Initialize();
81
82 void Add(WsfStringId aCommType, WsfStringId aMessageType, WsfStringId aMessageSubType, int aMessageSize, int aMessagePriority);
83
84 void Remove(WsfStringId aCommType, WsfStringId aMessageType, WsfStringId aMessageSubType);
85
86 MsgProp Find(WsfStringId aCommType, WsfStringId aMessageType, WsfStringId aMessageSubType = nullptr) const;
87
88 MsgProp DefaultProp() const;
89
90 MsgProp RandomProp(ut::Random& aRandom) const;
91
92 void SetMessageProp(WsfStringId aCommType, WsfMessage& aMessage) const;
93
94private:
95 bool ProcessMessageTypes(UtInputBlock& aInputBlock, WsfStringId aCommTypeId);
96
97 bool ProcessMessageSubTypes(UtInputBlock& aInputBlock, WsfStringId aCommTypeId, WsfStringId aMessageTypeId);
98
102
103 struct Key
104 {
105 Key(WsfStringId aCommType, WsfStringId aMessageType, WsfStringId aMessageSubType)
106 : mCommType(aCommType)
107 , mMessageType(aMessageType)
108 , mMessageSubType(aMessageSubType)
109 {
110 }
111
112 bool operator<(const Key& aRhs) const
113 {
114 if (mCommType < aRhs.mCommType)
115 {
116 return true;
117 }
118 else if (mCommType == aRhs.mCommType)
119 {
120 if (mMessageType < aRhs.mMessageType)
121 {
122 return true;
123 }
124 else if (mMessageType == aRhs.mMessageType)
125 {
126 if (mMessageSubType < aRhs.mMessageSubType)
127 {
128 return true;
129 }
130 }
131 }
132 return false;
133 }
134
135 WsfStringId mCommType;
136 WsfStringId mMessageType;
137 WsfStringId mMessageSubType;
138 };
139
140 typedef std::map<Key, MsgProp> MessagePropMap;
141
142 MessagePropMap mMessagePropMap;
143 MsgProp mDefaultProp;
144};
145
146#endif
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
void Remove(WsfStringId aCommType, WsfStringId aMessageType, WsfStringId aMessageSubType)
Definition WsfMessageTable.cpp:123
MsgProp Find(WsfStringId aCommType, WsfStringId aMessageType, WsfStringId aMessageSubType=nullptr) const
Definition WsfMessageTable.cpp:157
bool Initialize()
Definition WsfMessageTable.cpp:76
void SetMessageProp(WsfStringId aCommType, WsfMessage &aMessage) const
Definition WsfMessageTable.cpp:250
MsgProp DefaultProp() const
Definition WsfMessageTable.cpp:217
WsfMessageTable()
Definition WsfMessageTable.cpp:25
bool ProcessInput(UtInput &aInput)
Definition WsfMessageTable.cpp:36
MsgProp RandomProp(ut::Random &aRandom) const
Definition WsfMessageTable.cpp:223
void Add(WsfStringId aCommType, WsfStringId aMessageType, WsfStringId aMessageSubType, int aMessageSize, int aMessagePriority)
Definition WsfMessageTable.cpp:98
A base class for messages sent among simulation communication objects, processors and sensors.
Definition WsfMessage.hpp:33
Definition WsfMessageTable.hpp:51
MsgProp(WsfStringId aCommType, WsfStringId aType, WsfStringId aSubType, int aSize, int aPriority)
Definition WsfMessageTable.hpp:61
WsfStringId mSubType
Definition WsfMessageTable.hpp:72
int mSize
Definition WsfMessageTable.hpp:73
MsgProp()
Definition WsfMessageTable.hpp:52
WsfStringId mType
Definition WsfMessageTable.hpp:71
WsfStringId mCommType
Definition WsfMessageTable.hpp:70
int mPriority
Definition WsfMessageTable.hpp:74
Copyrights Multiple, All Rights Reserved