1 #ifndef _FMATVEC_ATOM_H
2 #define _FMATVEC_ATOM_H
33 #define FMATVEC_ATOM_MSGTYPE_SIZE 6
34 #ifndef SWIG // swig can not parse this however it is not needed for swig
35 static_assert(SIZE==FMATVEC_ATOM_MSGTYPE_SIZE,
"The proprocessor define FMATVEC_ATOM_MSGTYPE_SIZE must be equal Atom::SIZE.");
46 #ifndef SWIG // no assignment operator for swig
57 const std::shared_ptr<bool> &a=std::make_shared<bool>(
true),
58 const std::shared_ptr<std::ostream> &s=std::make_shared<std::ostream>(std::cout.rdbuf()));
65 std::shared_ptr<bool> &a,
66 std::shared_ptr<std::ostream> &s)
const;
83 return *_msgAct[type];
89 return *_msgStatic[type];
94 return *_msgActStatic[type];
100 static std::shared_ptr<std::ostream> _nullStream;
104 static std::array<std::shared_ptr<bool >, SIZE> _msgActStatic;
105 static std::array<std::shared_ptr<std::ostream>, SIZE> _msgSavedStatic;
106 static std::array<std::shared_ptr<std::ostream>, SIZE> _msgStatic;
110 std::array<std::shared_ptr<bool >, SIZE> _msgAct;
111 std::array<std::shared_ptr<std::ostream>, SIZE> _msgSaved;
112 std::array<std::shared_ptr<std::ostream>, SIZE> _msg;
116 class PrePostfixedStream :
public std::ostream {
120 PrePostfixedStream(
const std::string &prefix_,
const std::string &postfix_,
const std::function<
void(
const std::string &)> &f);
122 PrePostfixedStream(
const std::string &prefix_,
const std::string &postfix_, std::ostream &outstr_);
126 StringBuf(
const std::string &prefix_,
const std::string &postfix_,
const std::function<
void(
const std::string &)> &f_);
131 const std::function<void(const std::string &)> f;
static std::ostream & msgStatic(MsgType type)
Definition: atom.h:88
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:82
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:93
std::ostream & msg(MsgType type) const
Definition: atom.h:76
MsgType
Messages can be printed to different message types named here.
Definition: atom.h:24
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