PLCnext API Documentation  22.9.0.33
ModuleLibraryBase.hxx
1 //
3 // Copyright PHOENIX CONTACT Electronics GmbH
4 //
6 #pragma once
7 #include "Arp/System/Core/Arp.h"
8 #include "Arp/System/Core/AppDomain.hpp"
9 #include "Arp/System/Commons/Diagnostics/Logging/LogManager.hpp"
10 #include "Arp/System/Commons/Extensibility/ModuleFactory.hxx"
11 
12 namespace Arp { namespace System { namespace Commons { namespace Extensibility
13 {
14 
15 
16 
32 template<typename TModuleInterface>
34 {
35 protected: // construction/destruction
37  explicit ModuleLibraryBase(AppDomain& appDomain);
39  ModuleLibraryBase(const ModuleLibraryBase& arg) = default;
41  ModuleLibraryBase(ModuleLibraryBase&& arg) noexcept = default;
45  ModuleLibraryBase& operator=(ModuleLibraryBase&& arg) noexcept = default;
47  virtual ~ModuleLibraryBase(void) noexcept = default;
48 
49 
50 public: // operations
54 
55 protected:
59 
60 private: // fields
62 };
63 
64 template<typename TModuleInterface>
66 {
68 
69  // just assign the as argument passed appDomain to the appDomain singleton of this library (only
70  // important for DLLs)
71  AppDomain::Assign(appDomain);
72 
73  // must assign other appDomain explicitly to log engine, because log4cplus uses own static
74  // variables (e.g. defaultContext)
75  LogManager::AssignAppDomain(appDomain);
76 }
77 
78 template<typename TModuleInterface>
80 {
81  return this->factory;
82 }
83 
84 template<typename TModuleInterface>
86 {
87  return this->factory;
88 }
89 
90 }}}} // namespace Arp::System::Commons::Extensibility
This class represents a single application domain for each process and is implemented as singleton.
Definition: AppDomain.hpp:122
static void Assign(AppDomain &other)
Assgins the current AppdDomain singleton from the as argument passed other.
Definition: AppDomain.hpp:270
Factory class for extension modules
Definition: ModuleFactory.hxx:20
Base class for a library providing extension modules
Definition: ModuleLibraryBase.hxx:34
ModuleLibraryBase(const ModuleLibraryBase &arg)=default
Copy constructor.
ModuleLibraryBase & operator=(ModuleLibraryBase &&arg) noexcept=default
Move-assignment operator.
virtual ~ModuleLibraryBase(void) noexcept=default
Destructs this instance and frees all resources.
ModuleLibraryBase(ModuleLibraryBase &&arg) noexcept=default
Move constructor.
ModuleLibraryBase(AppDomain &appDomain)
Constructs an ModuleLibraryBase instance.
Definition: ModuleLibraryBase.hxx:65
const ModuleFactory< TModuleInterface > & GetFactory() const
Returns a const reference to the ModuleFactory
Definition: ModuleLibraryBase.hxx:79
ModuleLibraryBase & operator=(const ModuleLibraryBase &arg)=default
Copy-assignment operator.
@ System
System components used by the System, Device, Plc or Io domains.
Namespace for logging classes
Definition: LoggingForwards.h:10
Root namespace for the PLCnext API