cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mtsLODMultiplexerStreambuf.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5 
6  Author(s): Min Yang Jung
7  Created on: 2011-08-04
8 
9  (C) Copyright 2011 Johns Hopkins University (JHU), All Rights
10  Reserved.
11 
12 --- begin cisst license - do not edit ---
13 
14 This software is provided "as is" under an open source license, with
15 no warranty. The complete license can be found in license.txt and
16 http://www.cisst.org/cisst/license.txt.
17 
18 --- end cisst license ---
19 
20 */
21 
22 #ifndef _mtsLODMultiplexerStreambuf_h
23 #define _mtsLODMultiplexerStreambuf_h
24 
29 
30 #if (CISST_OS == CISST_LINUX_RTAI) || (CISST_OS == CISST_LINUX) || (CISST_OS == CISST_SOLARIS) || (CISST_OS == CISST_QNX) || (CISST_OS == CISST_WINDOWS)
31 #include <map>
32 #elif (CISST_OS == CISST_DARWIN) || (CISST_OS == CISST_XENOMAI)
33 #include <vector>
34 #endif
35 
37 {
38 public:
40  typedef std::char_traits<char> TraitType;
43 
44 protected:
45  // MJ: Use std::vector instead of std::map on Mac and Xenomai
46 #if (CISST_OS == CISST_LINUX_RTAI) || (CISST_OS == CISST_LINUX) || (CISST_OS == CISST_SOLARIS) || (CISST_OS == CISST_QNX) || (CISST_OS == CISST_WINDOWS)
47  // Map (osaThread, PerThreadBufferType)
48  typedef std::map<osaThreadId, PerThreadChannelType*, osaThreadId> PerThreadChannelMapType;
49  typedef std::pair<PerThreadChannelMapType::iterator, bool> PerThreadChannelMapPairType;
51 #elif (CISST_OS == CISST_DARWIN) || (CISST_OS == CISST_XENOMAI)
52  typedef struct {
53  osaThreadId ThreadId;
54  PerThreadChannelType * PerThreadChannel;
55  } PerThreadChannelElementType;
56  typedef std::vector<PerThreadChannelElementType> PerThreadChannelContainerType;
57  PerThreadChannelContainerType PerThreadChannelContainer;
58 #endif
59 
62 
63  // Override these methods for log dispatch based on caller's thread id
64  std::streamsize xsputn(const char * s, std::streamsize n, cmnLogLevel level);
65  std::streamsize xsputn(const char *s, std::streamsize n);
66 
68  IntType overflow(IntType c = mtsLODMultiplexerStreambuf::TraitType::eof());
69 
70  int sync(void);
71 
75 
76 public:
79 };
80 
81 #endif
std::map< osaThreadId, PerThreadChannelType *, osaThreadId > PerThreadChannelMapType
Definition: mtsLODMultiplexerStreambuf.h:48
Definition: mtsLODMultiplexerStreambuf.h:36
PerThreadChannelMapType PerThreadChannelMap
Definition: mtsLODMultiplexerStreambuf.h:50
Declaration of osaMutex.
Declaration of the class cmnCallbackStreambuf.
Define a Mutex object.
Definition: osaMutex.h:48
PerThreadChannelType * GetThreadChannel(const osaThreadId &threadId)
Declaration of osaThread.
std::basic_streambuf< char, std::char_traits< char > >::int_type int_type
Definition: cmnLODMultiplexerStreambuf.h:235
BaseType::int_type IntType
Definition: mtsLODMultiplexerStreambuf.h:42
short cmnLogLevel
Definition: cmnLogLoD.h:55
Type Definitions for dynamic control of output messages.
ThreadId type.
Definition: osaThread.h:77
cmnLODMultiplexerStreambuf< char > BaseType
Definition: mtsLODMultiplexerStreambuf.h:39
std::char_traits< char > TraitType
Definition: mtsLODMultiplexerStreambuf.h:40
std::pair< PerThreadChannelMapType::iterator, bool > PerThreadChannelMapPairType
Definition: mtsLODMultiplexerStreambuf.h:49
std::streamsize xsputn(const char *s, std::streamsize n, cmnLogLevel level)
osaMutex PerThreadChannelMapSync
Definition: mtsLODMultiplexerStreambuf.h:61
A Streambuffer class that outputs via a callback function.
Definition: cmnCallbackStreambuf.h:66
cmnCallbackStreambuf< char > PerThreadChannelType
Definition: mtsLODMultiplexerStreambuf.h:41
IntType overflow(IntType c, cmnLogLevel level)
A Streambuffer class that allows output to multiple streambuf objects for Level of Detail information...
Definition: cmnLODMultiplexerStreambuf.h:108