PLCnext API Documentation  22.9.0.33
ThreadConfigs.hpp
1 //
3 // Copyright PHOENIX CONTACT Electronics GmbH
4 //
6 #pragma once
7 #include "Arp/System/Core/Arp.h"
8 #include "Arp/System/Commons/Xml/IXmlSerializable.hpp"
9 #include "Arp/System/Commons/Configuration/ThreadConfig.hpp"
10 
11 #include <list>
12 
13 namespace Arp { namespace System { namespace Commons { namespace Configuration
14 {
15 
16 using namespace Arp::System::Commons::Xml;
17 
18 class ThreadConfigs : public IXmlSerializable, private Loggable<ThreadConfigs>
19 {
20 public: // typedefs
21  using Items = std::list<ThreadConfig>;
22 
23 public: // construction/destruction
25  ThreadConfigs(void) = default;
27  ThreadConfigs(const ThreadConfigs& arg) = delete;
29  ThreadConfigs(ThreadConfigs&& arg) = delete;
31  ~ThreadConfigs(void) = default;
32 
33 public: // setter/getter operations
34  Items& GetItems();
35  bool TryGetThreadConfig(const String& threadName, ThreadConfig::ConstPtr& threadConfig)const;
36  const ThreadConfig& GetThreadConfig(const String& threadName)const;
37 
38 public: // operations
39  void Clear(void);
40 
41 public: // IXmlSerializable operations
42  void ReadXml(XmlReader& reader, XmlSerializationContext& context)override;
43  void WriteXml(XmlWriter& writer, XmlSerializationContext& context)override;
44 
45 private: // static fields
46  static const char* XmlElementName;
47 
48 private: // fields
49  Items items;
50 };
51 
53 // inline methods of class ThreadConfigs
54 inline void ThreadConfigs::Clear()
55 {
56  this->items.clear();
57 }
58 
59 inline ThreadConfigs::Items& ThreadConfigs::GetItems()
60 {
61  return this->items;
62 }
63 
64 }}}} // end of namespace Arp::System::Commons::Configuration
void ReadXml(XmlReader &reader, XmlSerializationContext &context) override
ReadXML must be implemented by all classes which should read its context from xml files
ThreadConfigs(void)=default
Constructs an ThreadConfigs instance.
~ThreadConfigs(void)=default
Destructs this instance and frees all resources.
ThreadConfigs(const ThreadConfigs &arg)=delete
Copy constructor.
ThreadConfigs(ThreadConfigs &&arg)=delete
Move constructor.
Interface for all classes which should be serializable for xml
Definition: IXmlSerializable.hpp:18
Class to read an XML File. Non buffered reader, can only read forward
Definition: XmlReader.hpp:25
XML context used during XML reading and writing to hold the context information
Definition: XmlSerializationContext.hpp:26
Class to write an XML File
Definition: XmlWriter.hpp:21
@ System
System components used by the System, Device, Plc or Io domains.
Namespace for classes to read XML files
Definition: ConfigHeader.hpp:12
Root namespace for the PLCnext API