OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimKakaduMessaging.h
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // License: LGPL
4 //
5 // See LICENSE.txt file in the top level directory for more details.
6 //
7 // Description: Common OSSIM Kakadu messaging definitions.
8 //
9 //----------------------------------------------------------------------------
10 // $Id: ossimKakaduMessaging.h 22884 2014-09-12 13:14:35Z dburken $
11 
12 #ifndef ossimKakaduMessaging_HEADER
13 #define ossimKakaduMessaging_HEADER 1
14 
15 #include <ossim/base/ossimNotify.h>
16 #include <kdu_messaging.h>
17 #include <ostream>
18 #include <string>
19 
20 /* ========================================================================= */
21 /* Set up kakadu messaging services to be sent to ossimNotify. */
22 /* ========================================================================= */
23 class kdu_stream_message : public kdu_core::kdu_thread_safe_message
24 {
25 public: // Member classes
26  kdu_stream_message( std::ostream *stream, bool throw_exc )
27  : kdu_core::kdu_thread_safe_message(),
28  m_stream(stream),
29  m_throw_exc(throw_exc)
30  {}
31 
32  virtual void put_text(const char *string)
33  {
34  (*m_stream) << string;
35  }
36 
37  virtual void flush(bool end_of_message=false)
38  {
39  m_stream->flush();
40 
41  // This call unlocks mutex in kakadu_thread_safe_message:
42  kdu_core::kdu_thread_safe_message::flush(end_of_message);
43 
44  if (end_of_message && m_throw_exc)
45  {
46  //---
47  // Using ossimException caused hang. From kakadu kdu_messaging.h:
48  // Unless you have good reason to do otherwise, you are strongly
49  // recommended to use the default `exception_val' of
50  // `KDU_ERROR_EXCEPTION'
51  //---
52  throw KDU_ERROR_EXCEPTION;
53  }
54  }
55 
56 private: // Data
59 };
60 
62  false);
64  true);
65 static kdu_core::kdu_message_formatter pretty_cout(&cout_message);
66 static kdu_core::kdu_message_formatter pretty_cerr(&cerr_message);
67 
68 #endif /* #ifndef ossimKakaduMessaging_HEADER */
virtual void put_text(const char *string)
virtual void flush(bool end_of_message=false)
kdu_stream_message(std::ostream *stream, bool throw_exc)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23