SEAction.h
1/* Distributed under the Apache License, Version 2.0.
2 See accompanying NOTICE file for details.*/
3
4#pragma once
6
7enum class eMergeType { Append = 0, Replace };
8extern CDM_DECL const std::string& eMergeType_Name(eMergeType m);
9
10enum class eAppliedRespiratoryCycle { Expiratory=0, Inspiratory, Instantaneous };
11extern CDM_DECL const std::string& eAppliedRespiratoryCycle_Name(eAppliedRespiratoryCycle m);
12
13class CDM_DECL SEAction : public Loggable
14{
15 friend class PBAction;//friend the serialization class
16public:
17
18 SEAction(Logger* logger);
19 virtual ~SEAction();
20
21 SEAction(const SEAction&) = delete;
22 SEAction& operator= (const SEAction&) = delete;
23
24 virtual std::string GetName() const = 0;
25 static constexpr char const* ActionType = "Action";
26 virtual std::string GetActionType() const { return ActionType; }
27
28 virtual void Clear();
29 static SEAction* Copy(const SEAction&, const SESubstanceManager&);
30
31 virtual bool SerializeToString(std::string& dst, eSerializationFormat fmt) const;
32 static SEAction* SerializeFromString(const std::string, eSerializationFormat fmt, const SESubstanceManager&);
33
35 virtual bool IsValid() const { return true; }
36
39 virtual void Activate() { m_Active = true; }
40 virtual bool IsActive() const { return !m_Active ? false : IsValid(); }
41 virtual void Deactivate() { m_Active = false; }
42
43 virtual std::string GetComment() const;
44 virtual void SetComment(const std::string& comment);
45 virtual bool HasComment() const;
46 virtual void InvalidateComment();
47
48 virtual const SEScalar* GetScalar(const std::string& name)=0;
49
50 static std::string PrettyPrint(const std::string& str);
51
52 virtual std::string ToJSON() const;
53 virtual std::string ToString() const;
54
55protected:
56 bool m_Active = true;
57 std::string m_Comment;
58};
59
60inline std::ostream& operator<< (std::ostream& out, const SEAction& a)
61{
62 out << a.ToString();
63 return out;
64}
Definition: Logger.h:23
Definition: Logger.h:71
Definition: PBActions.h:15
static bool SerializeToString(const SEAction &a, std::string &dst, eSerializationFormat fmt=eSerializationFormat::JSON)
Definition: PBActions.cpp:150
static SEAction * Copy(const SEAction &a, const SESubstanceManager &subMgr)
Definition: PBActions.cpp:142
static SEAction * SerializeFromString(const std::string &src, eSerializationFormat fmt, const SESubstanceManager &subMgr)
Definition: PBActions.cpp:155
Definition: SEAction.h:14
virtual const SEScalar * GetScalar(const std::string &name)=0
virtual void Activate()
Definition: SEAction.h:39
virtual bool IsValid() const
Definition: SEAction.h:35
virtual bool IsActive() const
Definition: SEAction.h:40
std::string m_Comment
Definition: SEAction.h:57
virtual void Deactivate()
Definition: SEAction.h:41
SEAction(const SEAction &)=delete
virtual std::string ToString() const
Definition: SEAction.cpp:65
virtual std::string GetActionType() const
Definition: SEAction.h:26
virtual std::string GetName() const =0
Definition: SEScalar.h:19
Definition: SESubstanceManager.h:9

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.