cisst-saw
Loading...
Searching...
No Matches
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
14This software is provided "as is" under an open source license, with
15no warranty. The complete license can be found in license.txt and
16http://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{
38public:
40 typedef std::char_traits<char> TraitType;
43
44protected:
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
76public:
79};
80
81#endif
A Streambuffer class that outputs via a callback function.
Definition cmnCallbackStreambuf.h:67
std::basic_streambuf< char, std::char_traits< char > >::int_type int_type
Definition cmnLODMultiplexerStreambuf.h:235
cmnLODMultiplexerStreambuf(std::ofstream &fileStream)
Definition cmnLODMultiplexerStreambuf.h:136
PerThreadChannelType * GetThreadChannel(const osaThreadId &threadId)
BaseType::int_type IntType
Definition mtsLODMultiplexerStreambuf.h:42
IntType overflow(IntType c, cmnLogLevel level)
IntType overflow(IntType c=mtsLODMultiplexerStreambuf::TraitType::eof())
cmnLODMultiplexerStreambuf< char > BaseType
Definition mtsLODMultiplexerStreambuf.h:39
cmnCallbackStreambuf< char > PerThreadChannelType
Definition mtsLODMultiplexerStreambuf.h:41
osaMutex PerThreadChannelMapSync
Definition mtsLODMultiplexerStreambuf.h:61
std::pair< PerThreadChannelMapType::iterator, bool > PerThreadChannelMapPairType
Definition mtsLODMultiplexerStreambuf.h:49
std::char_traits< char > TraitType
Definition mtsLODMultiplexerStreambuf.h:40
std::streamsize xsputn(const char *s, std::streamsize n, cmnLogLevel level)
std::streamsize xsputn(const char *s, std::streamsize n)
PerThreadChannelMapType PerThreadChannelMap
Definition mtsLODMultiplexerStreambuf.h:50
std::map< osaThreadId, PerThreadChannelType *, osaThreadId > PerThreadChannelMapType
Definition mtsLODMultiplexerStreambuf.h:48
Define a Mutex object.
Definition osaMutex.h:48
ThreadId type.
Definition osaThread.h:77
Declaration of the class cmnCallbackStreambuf.
Type Definitions for dynamic control of output messages.
short cmnLogLevel
Definition cmnLogLoD.h:55
Declaration of osaMutex.
Declaration of osaThread.