DPsim
Loading...
Searching...
No Matches
IdentifiedObject.h
Go to the documentation of this file.
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
12#include <dpsim-models/Config.h>
14#include <dpsim-models/Utils.h>
15
16namespace CPS {
20protected:
23
24public:
29
30 typedef std::shared_ptr<IdentifiedObject> Ptr;
31 typedef std::vector<Ptr> List;
32
34
36 : mName(mAttributes->create("name", name)),
37 mUID(mAttributes->create("uid", uid)) {}
38
41
42 virtual ~IdentifiedObject() = default;
43
46 return mAttributes->attribute(name);
47 }
48
50 template <typename T>
52 return mAttributes->attributeTyped<T>(name);
53 }
54
56 return mAttributes->attributes();
57 };
58
59 String name() { return **mName; }
61 String uid() { return **mUID; }
63 String type() { return Utils::className(this); }
64 // Returns a description of the object
65 virtual String description() { return ""; }
66};
67} // namespace CPS
AttributePointer< AttributeBase > Ptr
Definition Attribute.h:122
std::map< String, Ptr > Map
Definition Attribute.h:125
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:250
std::shared_ptr< AttributeList > Ptr
const Attribute< String >::Ptr mName
Human readable name.
const AttributeBase::Map & attributes() const
Attribute< T >::Ptr attributeTyped(const String &name) const
Return pointer to an attribute.
std::shared_ptr< IdentifiedObject > Ptr
IdentifiedObject(const String &uid, const String &name)
virtual ~IdentifiedObject()=default
String uid()
Returns unique id.
std::vector< Ptr > List
String type()
Get component type (cross-platform)
AttributeBase::Ptr attribute(const String &name) const
Return pointer to an attribute.
const Attribute< String >::Ptr mUID
Unique identifier.
virtual String description()
IdentifiedObject(const String &name)
AttributeList::Ptr mAttributes
Attribute List.
static std::shared_ptr< AttributeList > make(Args &&...args)
Definition PtrFactory.h:19
String className(T *ptr, const String &prefix="CPS::")
Definition Utils.h:21
std::string String
Definition Definitions.h:65