Commit 374eee9a authored by Markus Mirz's avatar Markus Mirz
Browse files

remove inheritance from Component class

parent 60b676ce
......@@ -27,25 +27,43 @@
#include <cps/Task.h>
namespace CPS {
///
class SignalComponent : public Component {
/// Base class for all signal type components
/// that have only unidirectional connections
class SignalComponent : public IdentifiedObject {
public:
enum Behaviour { Initialization, Simulation };
protected:
/// Component logger
Logger::Log mSLog;
/// Component logger control for internal variables
Logger::Level mLogLevel;
/// Determine state of the simulation, e.g. to implement
/// special behavior for components during initialization
Bool mBehaviour = Behaviour::Simulation;
public:
typedef std::shared_ptr<SignalComponent> Ptr;
typedef std::vector<Ptr> List;
///
SignalComponent(String uid, String name, Logger::Level logLevel = Logger::Level::off)
: Component(uid, name, logLevel) { }
: IdentifiedObject(uid, name), mLogLevel(logLevel) {
mSLog = Logger::get(name, logLevel);
}
///
SignalComponent(String name, Logger::Level logLevel = Logger::Level::off)
: SignalComponent(name, name, logLevel) { }
///
virtual ~SignalComponent() { }
///
virtual void initialize(Real timeStep) { }
// XXX
///
virtual void initialize(Real omega, Real timeStep) { initialize(timeStep); }
///
virtual Task::List getTasks() {
return Task::List();
}
/// Set behavior of component, e.g. initialization
void setBehaviour(Behaviour behaviour) { mBehaviour = behaviour; }
};
}
/**
* @file
* @author Markus Mirz <mmirz@eonerc.rwth-aachen.de>
* @copyright 2017-2018, Institute for Automation of Complex Power Systems, EONERC
* @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
*
* CPowerSystems
*
......@@ -21,28 +19,55 @@
#pragma once
#include <cps/Component.h>
#include <typeinfo>
#include <iostream>
#include <vector>
#include <memory>
#include <cps/Logger.h>
#include <cps/IdentifiedObject.h>
#include <cps/TopologicalTerminal.h>
#include <cps/TopologicalNode.h>
namespace CPS {
class TopologicalComponent : public Component {
/// Base class for all electrical components that are
/// connected to nodes via terminals
class TopologicalComponent : public IdentifiedObject {
public:
enum Behaviour { Initialization, Simulation };
protected:
/// Determines the number of Terminals which can be connected to network Nodes
UInt mNumTerminals = 0;
/// Determines the number of virtual or internal Nodes
UInt mNumVirtualNodes = 0;
/// Component logger
Logger::Log mSLog;
/// Component logger control for internal variables
Logger::Level mLogLevel;
/// Determine state of the simulation, e.g. to implement
/// special behavior for components during initialization
Bool mBehaviour = Behaviour::Simulation;
public:
typedef std::shared_ptr<TopologicalComponent> Ptr;
typedef std::vector<Ptr> List;
using Component::Component;
/// Basic constructor that takes UID, name and log level
TopologicalComponent(String uid, String name, Logger::Level logLevel = Logger::Level::off)
: IdentifiedObject(uid, name), mLogLevel(logLevel) {
mSLog = Logger::get(name, logLevel);
}
/// Basic constructor that takes name and log level and sets the UID to name as well
TopologicalComponent(String name, Logger::Level logLevel = Logger::Level::off)
: TopologicalComponent(name, name, logLevel) { }
/// Destructor - does not do anything
virtual ~TopologicalComponent() { }
///
/// Returns nodes connected to this component
virtual TopologicalNode::List topologicalNodes() = 0;
///
/// Returns terminal that are part of the component
virtual TopologicalTerminal::List topologicalTerminals() = 0;
/// Set behavior of component, e.g. initialization
void setBehaviour(Behaviour behaviour) { mBehaviour = behaviour; }
};
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment