PLCnext API Documentation 23.6.0.37
Console.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6#pragma once
8#include "Arp/System/Commons/Text/Formatter.hxx"
9#include <iostream>
10#include <mutex>
11
12namespace Arp { namespace System { namespace Commons
13{
14
16{
17public:
18 template<typename... Args> static void Write(const char* pFormat, const Args& ... args);
19 template<typename... Args> static void WriteLine(const char* pFormat, const Args& ... args);
20
21private:
22 static std::mutex consoleMutex;
23};
24
26// inline methods of class Console
27template<typename... Args>
28inline void Console::WriteLine(const char* pFormat, const Args& ... args)
29{
30 std::lock_guard<std::mutex> lock(consoleMutex);
31 {
32 std::cout << Text::Formatter::FormatCommon(pFormat, args...) << std::endl;
33 }
34}
35
36template<typename... Args>
37inline void Console::Write(const char* pFormat, const Args& ... args)
38{
39 std::lock_guard<std::mutex> lock(consoleMutex);
40 {
41 std::cout << Text::Formatter::FormatCommon(pFormat, args...);
42 }
43}
44
45}}} // end of namespace Arp::System::Commons
Definition: Console.hpp:16
static String FormatCommon(const String &format, const Args &... args)
Uses common CLR syntax (.Net) for the placeholders in the format string like '{0}'.
Definition: Formatter.hxx:39
@ System
System components used by the System, Device, Plc or Io domains.
Root namespace for the PLCnext API