DPsim
Task.h
1 /* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
2  * EONERC, RWTH Aachen University
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7  *********************************************************************************/
8 
9 #pragma once
10 
11 #include <memory>
12 #include <vector>
13 
14 #include <dpsim-models/Attribute.h>
15 
16 namespace CPS {
25 class Task {
26 public:
27  typedef std::shared_ptr<Task> Ptr;
28  typedef std::vector<Ptr> List;
29 
30  Task() {}
31  virtual ~Task() {}
32 
33  virtual void execute(Real time, Int timeStepCount) = 0;
34 
35  virtual String toString() const { return mName; }
36 
37  const std::vector<AttributeBase::Ptr> &getAttributeDependencies() {
38  return mAttributeDependencies;
39  }
40 
41  const std::vector<AttributeBase::Ptr> &getModifiedAttributes() {
42  return mModifiedAttributes;
43  }
44 
45  const std::vector<AttributeBase::Ptr> &getPrevStepDependencies() {
46  return mPrevStepDependencies;
47  }
48 
49 protected:
50  Task(const std::string &name) : mName(name) {}
51  std::string mName;
52  std::vector<AttributeBase::Ptr> mAttributeDependencies;
53  std::vector<AttributeBase::Ptr> mModifiedAttributes;
54  std::vector<AttributeBase::Ptr> mPrevStepDependencies;
55 };
56 } // namespace CPS
Tasks to be defined by every component.
Definition: Task.h:25