PLCnext API Documentation  21.0.0.35466
Console.hpp
1 //
3 // Copyright PHOENIX CONTACT Electronics GmbH
4 //
6 #pragma once
7 #include "Arp/System/Core/Arp.h"
8 #include "Arp/System/Commons/Text/Formatter.hxx"
9 #include <iostream>
10 #include <mutex>
11 
12 using namespace std;
13 
14 namespace Arp { namespace System { namespace Commons
15 {
16 
17 class Console
18 {
19 public:
20  template<typename... Args> static void Write(const char* pFormat, const Args& ... args);
21  template<typename... Args> static void WriteLine(const char* pFormat, const Args& ... args);
22 
23 private:
24  static std::mutex consoleMutex;
25 };
26 
28 // inline methods of class Console
29 template<typename... Args>
30 inline void Console::WriteLine(const char* pFormat, const Args& ... args)
31 {
32  std::lock_guard<std::mutex> lock(consoleMutex);
33  {
34  std::cout << Text::Formatter::FormatCommon(pFormat, args...) << std::endl;
35  }
36 }
37 
38 template<typename... Args>
39 inline void Console::Write(const char* pFormat, const Args& ... args)
40 {
41  std::lock_guard<std::mutex> lock(consoleMutex);
42  {
43  std::cout << Text::Formatter::FormatCommon(pFormat, args...);
44  }
45 }
46 
47 }}} // end of namespace Arp::System::Commons
Definition: Console.hpp:17
Namespace of the C++ standard library
Root namespace for the PLCnext API
System components used by the System, Device, Plc or Io domains.