1 //===-- MICmnStreamStdout.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 10 #pragma once 11 12 // In-house headers: 13 #include "MICmnBase.h" 14 #include "MIUtilSingletonBase.h" 15 #include "MIUtilString.h" 16 #include "MIUtilThreadBaseStd.h" 17 18 //++ 19 //============================================================================ 20 // Details: MI common code class. The MI driver requires this object. 21 // CMICmnStreamStdout sets up and tears downs stdout for the driver. 22 // 23 // Singleton class. 24 //-- 25 class CMICmnStreamStdout : public CMICmnBase, 26 public MI::ISingleton<CMICmnStreamStdout> { 27 friend class MI::ISingleton<CMICmnStreamStdout>; 28 29 // Statics: 30 public: 31 static bool TextToStdout(const CMIUtilString &vrTxt); 32 static bool WritePrompt(); 33 34 // Methods: 35 public: 36 bool Initialize() override; 37 bool Shutdown() override; 38 // 39 bool Lock(); 40 bool Unlock(); 41 bool Write(const CMIUtilString &vText, const bool vbSendToLog = true); 42 bool WriteMIResponse(const CMIUtilString &vText, 43 const bool vbSendToLog = true); 44 45 // Methods: 46 private: 47 /* ctor */ CMICmnStreamStdout(); 48 /* ctor */ CMICmnStreamStdout(const CMICmnStreamStdout &); 49 void operator=(const CMICmnStreamStdout &); 50 // 51 bool WritePriv(const CMIUtilString &vText, 52 const CMIUtilString &vTxtForLogFile, 53 const bool vbSendToLog = true); 54 55 // Overridden: 56 private: 57 // From CMICmnBase 58 /* dtor */ ~CMICmnStreamStdout() override; 59 60 // Attributes: 61 private: 62 CMIUtilThreadMutex m_mutex; // Mutex object for sync during writing to stream 63 }; 64