WSF
WsfScriptMessageHandler.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 WSFSCRIPTMESSAGEHANDLER_HPP
13#define WSFSCRIPTMESSAGEHANDLER_HPP
14
15#include "wsf_export.h"
16
17#include <vector>
18
19class UtInput;
20#include "UtScriptData.hpp"
21class UtScript;
22
23class WsfMessage;
24class WsfPlatform;
26#include "WsfStringId.hpp"
27
40
42{
43public:
47 virtual ~WsfScriptMessageHandler() = default;
48
51 bool HasMessageHandler() const { return mHasMessageHandler; }
52
53 virtual bool Initialize(double aSimTime, WsfPlatform* aPlatformPtr);
54
55 virtual bool ProcessInput(UtInput& aInput);
56
57 virtual bool ProcessMessage(double aSimTime, const WsfMessage& aMessage);
58
59 void SetTimeAndMessage(double aSimTime, const WsfMessage& aMessage);
60
62 struct Handler
63 {
64 public:
66 : mType(nullptr)
67 , mSubTypes()
68 , mScriptIndex(0)
69 {
70 }
71
73 std::vector<WsfStringId> mSubTypes;
74 std::vector<UtScript*>::size_type mScriptIndex;
75 };
76
77protected:
79
82
84 std::vector<Handler> mHandlers;
85
87 std::vector<WsfStringId> mScriptNames;
88
92 std::vector<UtScript*> mScriptPtrs;
93
95 UtScript* mOnMessageScriptPtr{nullptr};
96
98 bool mHasMessageHandler{false};
99
103};
104
105#endif
ut::script::Data UtScriptData
Definition WsfScriptContext.hpp:47
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
A base class for messages sent among simulation communication objects, processors and sensors.
Definition WsfMessage.hpp:33
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
Definition WsfScriptContext.hpp:71
bool mHasMessageHandler
true if 'on_message' or 'script void on_message()' has been defined.
Definition WsfScriptMessageHandler.hpp:98
int mMessageVarIndex
Definition WsfScriptMessageHandler.hpp:102
virtual ~WsfScriptMessageHandler()=default
std::vector< WsfStringId > mScriptNames
The list of script names, indexed by the handlers script index.
Definition WsfScriptMessageHandler.hpp:87
WsfPlatform * mPlatformPtr
Definition WsfScriptMessageHandler.hpp:78
WsfScriptContext * mContextPtr
The context used for compiling and executing scripts.
Definition WsfScriptMessageHandler.hpp:81
WsfScriptMessageHandler()=default
std::vector< UtScript * > mScriptPtrs
Definition WsfScriptMessageHandler.hpp:92
std::vector< Handler > mHandlers
The list of message handlers.
Definition WsfScriptMessageHandler.hpp:84
bool HasMessageHandler() const
Definition WsfScriptMessageHandler.hpp:51
UtScript * mOnMessageScriptPtr
The pointer to the explicit 'script void on_message()' if it was defined.
Definition WsfScriptMessageHandler.hpp:95
UtScriptData * mMessageVarPtr
The message script variable's memory index.
Definition WsfScriptMessageHandler.hpp:101
Handler()
Definition WsfScriptMessageHandler.hpp:65
std::vector< WsfStringId > mSubTypes
Definition WsfScriptMessageHandler.hpp:73
WsfStringId mType
Definition WsfScriptMessageHandler.hpp:72
std::vector< UtScript * >::size_type mScriptIndex
Definition WsfScriptMessageHandler.hpp:74
Copyrights Multiple, All Rights Reserved