diff --git a/alib2common/src/global/GlobalData.cpp b/alib2common/src/global/GlobalData.cpp index d718b0e34464e500cb7e7c79ad9f06b18e6952f3..64e9d6352890b3cd54c0d37ab86599567c121896 100644 --- a/alib2common/src/global/GlobalData.cpp +++ b/alib2common/src/global/GlobalData.cpp @@ -43,6 +43,11 @@ std::ostream & operator << ( ext::reference_wrapper < std::ostream > & os, std:: return os; } +std::istream & operator >> ( ext::reference_wrapper < std::istream > & is, std::istream & ( * func ) ( std::istream & ) ) { + is.get () >> func; + return is; +} + std::istream & operator >> ( ext::reference_wrapper < std::istream > & is, std::ios_base & ( * func ) ( std::ios_base & ) ) { is.get () >> func; return is; diff --git a/alib2common/src/global/GlobalData.h b/alib2common/src/global/GlobalData.h index 2b5b9f886760fb37a6271322283c4ac742b6c34f..8cfa8e80cc8a45ae5f28eca8db4beccc41adb8e6 100644 --- a/alib2common/src/global/GlobalData.h +++ b/alib2common/src/global/GlobalData.h @@ -14,22 +14,76 @@ namespace common { +/** + * \brief + * Class to represent some global modifiers and data. + */ class GlobalData { public: + /** + * \brief + * Verbose flag. Some algorithms print additional runtime information about internal datastructures or their trace. Set the variable to true to enable. + */ static bool verbose; + + /** + * \brief + * Measure flag. Some algorithms support measurements of runtime properties (time, memory, etc.) Set the variable to true to enable. + */ static bool measure; + + /** + * Xml internal representation optimize flag. The xml representation of datatypes may contain references to previous nodes to remove duplicty. Set the variable to true to enable. + */ static bool optimizeXml; + /** + * \brief + * The number of argument values as provided by the shell to the main function. + */ static int argc; + + /** + * \brief + * The agrument values as provided by the shell to the main function. + */ static char * * argv; }; +/** + * \brief + * Aggregation class for various standard streams defined by the library. + */ class Streams { public: + /** + * \brief + * Standard input stream. Mapped to descriptor 0. + */ static ext::reference_wrapper < std::istream > in; + + /** + * \brief + * Standard output stream. Mapped to descriptor 1. + */ static ext::reference_wrapper < std::ostream > out; + + /** + * \brief + * Standard error stream. Mapped to descriptor 2. + */ static ext::reference_wrapper < std::ostream > err; + + /** + * \brief + * Standard loging stream. Mapped to descriptor 4. + */ static ext::reference_wrapper < std::ostream > log; + + /** + * \brief + * Standard measurement stream. Mapped to descriptor 5. + */ static ext::reference_wrapper < std::ostream > measure; }; @@ -37,30 +91,60 @@ public: namespace ext { +/** + * \brief + * Overloaded function allowing same operations on wrapped output stream as on the actual output stream, specific for constant lvalue referenced objects. + */ template < class T > -std::ostream & operator << ( ext::reference_wrapper < std::ostream > & os, T & data ) { +std::ostream & operator << ( ext::reference_wrapper < std::ostream > & os, const T & data ) { os.get ( ) << data; return os; } +/** + * \brief + * Overloaded function allowing same operations on wrapped output stream as on the actual output stream, specific for rvalue referenced objects. + */ template < class T > std::ostream & operator << ( ext::reference_wrapper < std::ostream > & os, T && data ) { os.get ( ) << data; return os; } +/** + * \brief + * Overloaded function allowing same operations on wrapped output stream as on the actual output stream, specific for modifiers from inside of ostream class. + */ std::ostream & operator << ( ext::reference_wrapper < std::ostream > & os, std::ostream & ( * func ) ( std::ostream & ) ); +/** + * \brief + * Overloaded function allowing same operations on wrapped output stream as on the actual output stream, specific for modifiers from inside of ios_base class. + */ std::ostream & operator << ( ext::reference_wrapper < std::ostream > & os, std::ios_base & ( * func ) ( std::ios_base & ) ); +/** + * \brief + * Overloaded function allowing same operations on wrapped input stream as on the actual input stream, specific for lvalue referenced objects. + */ template < class T > std::istream & operator >> ( ext::reference_wrapper < std::istream > & is, T & data ) { is.get ( ) >> data; return is; } +/** + * \brief + * Overloaded function allowing same operations on wrapped input stream as on the actual input stream, specific for modifiers from inside of istream class. + */ +std::istream & operator >> ( ext::reference_wrapper < std::istream > & is, std::istream & ( * func ) ( std::istream & ) ); + +/** + * \brief + * Overloaded function allowing same operations on wrapped input stream as on the actual input stream, specific for modifiers from inside of ios_base class. + */ std::istream & operator >> ( ext::reference_wrapper < std::istream > & is, std::ios_base & ( * func ) ( std::ios_base & ) ); } /* namespace ext */