WSF
WsfEventPipeOptions.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 WSFEVENTPIPEOPTIONS_HPP
13#define WSFEVENTPIPEOPTIONS_HPP
14
15#include <map>
16#include <string>
17#include <vector>
18
19class UtInput;
20
21// Stores an enable bit for each event category
23{
24public:
26
27 void SetMaxEventId(int aMaxEventId) { mBoolOptions.resize(aMaxEventId + 1); }
28
29 bool ProcessInput(UtInput& aInput, const std::vector<std::string>& aEventNames);
30
31 void Add(const WsfEventPipeOptions& aOtherOptions)
32 {
33 if (mBoolOptions.size() < aOtherOptions.mBoolOptions.size())
34 {
35 mBoolOptions.resize(aOtherOptions.mBoolOptions.size());
36 }
37 for (size_t i = 0; i < mBoolOptions.size(); ++i)
38 {
39 mBoolOptions[i] = mBoolOptions[i] || aOtherOptions.mBoolOptions[i];
40 }
41 }
42
43 void Subtract(const WsfEventPipeOptions& aOtherOptions)
44 {
45 if (mBoolOptions.size() < aOtherOptions.mBoolOptions.size())
46 {
47 mBoolOptions.resize(aOtherOptions.mBoolOptions.size());
48 }
49 for (size_t i = 0; i < mBoolOptions.size(); ++i)
50 {
51 mBoolOptions[i] = mBoolOptions[i] && aOtherOptions.mBoolOptions[i];
52 }
53 }
54
55 void EnableAll();
56 void DisableAll();
57
58 // for options registered through RegisterBoolOption()
59 bool IsOptionEnabled(int aOptionIndex) const { return mBoolOptions[aOptionIndex]; }
60
61 void EnableOption(int aOptionIndex, bool aEnable = true) { mBoolOptions[aOptionIndex] = aEnable; }
62
63 // returns the update interval that should be applied to visual parts.
64 // 0 indicates parts' articulations should not be published except initially
65 double GetVisualPartUpdateInterval() const { return mVisualPartUpdateInterval; }
66 void SetVisualPartUpdateInterval(double aValue) { mVisualPartUpdateInterval = aValue; }
67
68 bool operator!=(const WsfEventPipeOptions& aRhs) const { return mBoolOptions != aRhs.mBoolOptions; }
69
70 std::map<std::string, bool> GetOptionValues(const std::vector<std::string>& aEventNames) const;
71
72private:
73 std::vector<bool> mBoolOptions;
74
75 // the interval on which the sim puts out articulation updates for visual parts
76 // defaults to 0.0, which will not publish visual-part articulations.
77 double mVisualPartUpdateInterval{0.0};
78};
79
80#endif
WsfEventPipeOptions()=default
std::map< std::string, bool > GetOptionValues(const std::vector< std::string > &aEventNames) const
This is called by WsfGrammarInterface::OutputForIDE in order to retrieve the event names and their se...
Definition WsfEventPipeOptions.cpp:66
void EnableOption(int aOptionIndex, bool aEnable=true)
Definition WsfEventPipeOptions.hpp:61
double GetVisualPartUpdateInterval() const
Definition WsfEventPipeOptions.hpp:65
void Subtract(const WsfEventPipeOptions &aOtherOptions)
Definition WsfEventPipeOptions.hpp:43
bool operator!=(const WsfEventPipeOptions &aRhs) const
Definition WsfEventPipeOptions.hpp:68
void SetMaxEventId(int aMaxEventId)
Definition WsfEventPipeOptions.hpp:27
void EnableAll()
Definition WsfEventPipeOptions.cpp:76
void DisableAll()
Definition WsfEventPipeOptions.cpp:81
bool ProcessInput(UtInput &aInput, const std::vector< std::string > &aEventNames)
Definition WsfEventPipeOptions.cpp:24
void Add(const WsfEventPipeOptions &aOtherOptions)
Definition WsfEventPipeOptions.hpp:31
bool IsOptionEnabled(int aOptionIndex) const
Definition WsfEventPipeOptions.hpp:59
void SetVisualPartUpdateInterval(double aValue)
Definition WsfEventPipeOptions.hpp:66
Copyrights Multiple, All Rights Reserved