1 #ifndef _FMATVEC_ATOM_H
2 #define _FMATVEC_ATOM_H
34 #define FMATVEC_ATOM_MSGTYPE_SIZE 6
35 #ifndef SWIG // swig can not parse this however it is not needed for swig
36 static_assert(SIZE==FMATVEC_ATOM_MSGTYPE_SIZE,
"The proprocessor define FMATVEC_ATOM_MSGTYPE_SIZE must be equal Atom::SIZE.");
47 #ifndef SWIG // no assignment operator for swig
58 const std::shared_ptr<bool> &a=std::make_shared<bool>(
true),
59 const std::shared_ptr<std::ostream> &s=std::make_shared<std::ostream>(std::cout.rdbuf()));
66 std::shared_ptr<bool> &a,
67 std::shared_ptr<std::ostream> &s)
const;
84 return *_msgAct[type];
90 return *_msgStatic[type];
95 return *_msgActStatic[type];
101 static std::shared_ptr<std::ostream> _nullStream;
105 static std::array<std::shared_ptr<bool >, SIZE> _msgActStatic;
106 static std::array<std::shared_ptr<std::ostream>, SIZE> _msgSavedStatic;
107 static std::array<std::shared_ptr<std::ostream>, SIZE> _msgStatic;
111 std::array<std::shared_ptr<bool >, SIZE> _msgAct;
112 std::array<std::shared_ptr<std::ostream>, SIZE> _msgSaved;
113 std::array<std::shared_ptr<std::ostream>, SIZE> _msg;
117 class PrePostfixedStream :
public std::ostream {
121 PrePostfixedStream(
const std::string &prefix_,
const std::string &postfix_,
const std::function<
void(
const std::string &)> &f);
123 PrePostfixedStream(
const std::string &prefix_,
const std::string &postfix_, std::ostream &outstr_);
127 StringBuf(
const std::string &prefix_,
const std::string &postfix_,
const std::function<
void(
const std::string &)> &f_);
132 const std::function<void(const std::string &)> f;
static std::ostream & msgStatic(MsgType type)
Definition: atom.h:89
static void setCurrentMessageStream(MsgType type, const std::shared_ptr< bool > &a=std::make_shared< bool >(true), const std::shared_ptr< std::ostream > &s=std::make_shared< std::ostream >(std::cout.rdbuf()))
Definition: atom.cc:58
void adoptMessageStreams(const Atom *src=nullptr)
Definition: atom.cc:76
void setMessageStreamActive(MsgType type, bool activeFlag)
Set the active flag of this object and all objects which were created using the same message stream a...
Definition: atom.cc:64
bool msgAct(MsgType type) const
Definition: atom.h:83
PrePostfixedStream(const std::string &prefix_, const std::string &postfix_, const std::function< void(const std::string &)> &f)
Call f with every message of the stream, prefixed/postfixed.
Atom()
When a Atom is default constructed use the current statically set message streams.
Definition: atom.cc:40
void getMessageStream(MsgType type, std::shared_ptr< bool > &a, std::shared_ptr< std::ostream > &s) const
Get the shared message stream active flag and the shared message stream of this object.
Definition: atom.cc:69
static bool msgActStatic(MsgType type)
Definition: atom.h:94
std::ostream & msg(MsgType type) const
Definition: atom.h:77
MsgType
Messages can be printed to different message types named here.
Definition: atom.h:25
Atom & operator=(const Atom &)
When a Atom is assinged do not change the messsage streams since we always use the message streams be...
Definition: atom.cc:54