blob: 95085a2a32754bb666a6a943720ab946daef3953 [file] [log] [blame]
Deepak Panickal6f9c4682014-05-16 10:51:01 +00001//===-- MICmnStreamStderr.h -------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
Deepak Panickal6f9c4682014-05-16 10:51:01 +000010#pragma once
11
12// In-house headers:
13#include "MIUtilString.h"
14#include "MICmnBase.h"
15#include "MIUtilSingletonBase.h"
16#include "MIUtilThreadBaseStd.h"
17
18//++ ============================================================================
Zachary Turner1d6af022014-11-17 18:06:21 +000019// Details: MI common code class. The MI driver requires this object.
20// CMICmnStreamStderr sets up and tears downs stderr for the driver.
21//
22// Singleton class.
Deepak Panickal6f9c4682014-05-16 10:51:01 +000023//--
Zachary Turner1d6af022014-11-17 18:06:21 +000024class CMICmnStreamStderr : public CMICmnBase, public MI::ISingleton<CMICmnStreamStderr>
Deepak Panickal6f9c4682014-05-16 10:51:01 +000025{
Zachary Turner1d6af022014-11-17 18:06:21 +000026 friend class MI::ISingleton<CMICmnStreamStderr>;
Deepak Panickal6f9c4682014-05-16 10:51:01 +000027
Zachary Turner1d6af022014-11-17 18:06:21 +000028 // Statics:
29 public:
30 static bool TextToStderr(const CMIUtilString &vrTxt);
31 static bool LLDBMsgToConsole(const CMIUtilString &vrTxt);
Deepak Panickal877569c2014-06-24 16:35:50 +000032
Zachary Turner1d6af022014-11-17 18:06:21 +000033 // Methods:
34 public:
Bruce Mitchenere2453af2015-08-04 10:24:20 +000035 bool Initialize() override;
36 bool Shutdown() override;
Zachary Turner1d6af022014-11-17 18:06:21 +000037 //
Bruce Mitchenere2453af2015-08-04 10:24:20 +000038 bool Lock();
39 bool Unlock();
Zachary Turner1d6af022014-11-17 18:06:21 +000040 bool Write(const CMIUtilString &vText, const bool vbSendToLog = true);
41 bool WriteLLDBMsg(const CMIUtilString &vText, const bool vbSendToLog = true);
Deepak Panickal6f9c4682014-05-16 10:51:01 +000042
Zachary Turner1d6af022014-11-17 18:06:21 +000043 // Methods:
44 private:
Bruce Mitchenere2453af2015-08-04 10:24:20 +000045 /* ctor */ CMICmnStreamStderr();
Zachary Turner1d6af022014-11-17 18:06:21 +000046 /* ctor */ CMICmnStreamStderr(const CMICmnStreamStderr &);
47 void operator=(const CMICmnStreamStderr &);
48 //
49 bool WritePriv(const CMIUtilString &vText, const CMIUtilString &vTxtForLogFile, const bool vbSendToLog = true);
Deepak Panickal6f9c4682014-05-16 10:51:01 +000050
Zachary Turner1d6af022014-11-17 18:06:21 +000051 // Overridden:
52 private:
53 // From CMICmnBase
Bruce Mitchenere2453af2015-08-04 10:24:20 +000054 /* dtor */ ~CMICmnStreamStderr() override;
Zachary Turner1d6af022014-11-17 18:06:21 +000055
56 // Attributes:
57 private:
58 CMIUtilThreadMutex m_mutex; // Mutex object for sync during Write()
Deepak Panickal6f9c4682014-05-16 10:51:01 +000059};