SEAction.h
1 /**************************************************************************************
2 Copyright 2015 Applied Research Associates, Inc.
3 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 this file except in compliance with the License. You may obtain a copy of the License
5 at:
6 http://www.apache.org/licenses/LICENSE-2.0
7 Unless required by applicable law or agreed to in writing, software distributed under
8 the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9 CONDITIONS OF ANY KIND, either express or implied. See the License for the
10 specific language governing permissions and limitations under the License.
11 **************************************************************************************/
12 
13 #pragma once
14 #include <biogears/cdm/CommonDataModel.h>
15 #include <biogears/exports.h>
16 
17 CDM_BIND_DECL(ActionData);
18 
19 namespace biogears {
20 class SESubstanceManager;
21 
22 class BIOGEARS_API SEAction : public Loggable {
23 public:
24  virtual const char* classname() const = 0;
25 
26  SEAction();
27  virtual ~SEAction();
28 
29  virtual void Clear(); // Deletes all members
30 
32  virtual bool IsValid() const { return true; }
35  virtual bool IsActive() const { return IsValid(); }
36 
37  static SEAction* newFromBind(const CDM::ActionData& action, SESubstanceManager& substances);
38 
39  virtual bool Load(const CDM::ActionData& in);
40  virtual CDM::ActionData* Unload() const;
41 
42 protected:
43  void Unload(CDM::ActionData& data) const;
44 
45 public:
46  virtual const char* GetComment() const;
47  virtual void SetComment(const char* comment);
48  virtual void SetComment(const std::string& comment);
49  virtual bool HasComment() const;
50  virtual void InvalidateComment();
51 
52  virtual void ToString(std::ostream& str) const = 0;
53  virtual const char* ToString() const;
54 
55 protected:
56  std::string m_Comment;
57  mutable std::string m_StringRepresnetation; //<Cached Value of the last called to ToString();
58 };
59 
60 inline std::ostream& operator<<(std::ostream& out, const SEAction& a)
61 {
62  a.ToString(out);
63  return out;
64 }
65 }
Definition: SEAction.h:22
std::string m_StringRepresnetation
Definition: SEAction.h:57
Definition: Logger.h:27
Class corresponding to the ActionData schema type.
Definition: Scenario.hxx:1034
std::ostream & operator<<(std::ostream &out, const SEConsciousRespirationCommand &c)
Definition: SEConsciousRespirationCommand.h:48
std::string m_Comment
Definition: SEAction.h:56
virtual bool IsActive() const
Definition: SEAction.h:35
Definition: SESubstanceManager.h:23
Definition: SEElectricalCircuit.h:18
virtual void ToString(std::ostream &str) const =0
virtual bool IsValid() const
Definition: SEAction.h:32