IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
LogMessageFormater.h
1 // LogMessageFormater.h:
3 // ---------------------
4 //
14 
15 #ifndef __IPSDKUTIL_LOGMESSAGEFORMATER_H__
16 #define __IPSDKUTIL_LOGMESSAGEFORMATER_H__
17 
18 // suppression warnings
19 // warning C4275: interface non dll class 'boost::noncopyable_::noncopyable' utilisée comme base d'une interface dll class 'ipsdk::LogMessageFormater'
20 // warning C4251: 'ipsdk::LogMessageFormater::_format' : class 'boost::basic_format<Ch>' nécessite une interface DLL pour être utilisé(e) par les clients de class 'ipsdk::LogMessageFormater'
21 #pragma warning (push)
22 #pragma warning (disable : 4275 4251)
23 
25 #include <IPSDKUtil/BaseTypes.h>
26 #include <boost/noncopyable.hpp>
27 #include <boost/format.hpp>
28 #include <sstream>
29 
30 namespace ipsdk {
31 
32 class LogMessageManager;
33 
36 
37 class IPSDKUTIL_API LogMessageFormater : public boost::noncopyable
38 {
39 public:
42  LogMessageFormater(const LogMessageManager& logMsgManager);
45 
46 // methods
47 public:
49  template <typename EnumT>
50  LogMessageFormater& operator[](const EnumT& messageId)
51  {
52  return setMsgId(typeid(EnumT).name(), (ipInt32)messageId);
53  }
54 
56  LogMessageFormater& setMsgId(const std::string& enumTypeStr,
57  ipInt32 msgId);
58 
60  template <class T>
62  {
63  _format % arg;
64 
65  // check whether format is fully completed
66  if (_format.remaining_args() == 0) {
67  _os << _format;
68  _format = boost::format();
69  }
70 
71  return *this;
72  }
73 
75  template <class T>
77  {
78  _os << msg;
79  return *this;
80  }
81 
83  std::string string();
84 
86  void clear();
87 
88 // attributes
89 protected:
91  boost::format _format;
92 
94  std::ostringstream _os;
95 
98 };
99 
102 
103 } // end of namespace ipsdk
104 
105 #pragma warning (pop)
106 
107 #endif // __IPSDKUTIL_LOGMESSAGEFORMATER_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
LogMessageFormater & operator%(const T &arg)
arguments filling operator
Definition: LogMessageFormater.h:61
const LogMessageManager & _logMsgManager
underlying log message manager
Definition: LogMessageFormater.h:97
boost::format _format
underlying boost format structure
Definition: LogMessageFormater.h:91
std::ostringstream _os
underlying string stream
Definition: LogMessageFormater.h:94
int32_t ipInt32
Base types definition.
Definition: BaseTypes.h:52
Class alowing to easily format log message and handle id conversions.
Definition: LogMessageFormater.h:37
Base types for multiplatform compatibility.
LogMessageFormater & operator[](const EnumT &messageId)
template member for easy message id selection
Definition: LogMessageFormater.h:50
#define IPSDKUTIL_API
Import/Export macro for library IPSDKUtil.
Definition: IPSDKUtilExports.h:27
Log message manager for ipsdk libraries.
Definition: LogMessageManager.h:44
Definition of import/export macro for library.
LogMessageFormater & operator<<(const T &msg)
streaming operators
Definition: LogMessageFormater.h:76