torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DDBConsoleStreams.hpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 /// \file
17 /// \brief Header for the DDBConsoleStreams class.
18 
19 #ifndef TORC_ARCHITECTURE_DDBCONSOLESTREAMS_HPP
20 #define TORC_ARCHITECTURE_DDBCONSOLESTREAMS_HPP
21 
22 //#include <iostream>
23 
24 namespace std {
25  /// \brief Forward declaration of template basic_istream.
26  template <typename _CharT, typename _Traits> class basic_istream;
27  /// \brief Forward declaration of template basic_ostream.
28  template <typename _CharT, typename _Traits> class basic_ostream;
29 }
30 
31 namespace torc {
32 namespace architecture {
33 
34  /// \brief Device database console streams class.
35  /// \details This allows the user to specify alternate streams for cin, cout, and cerr, to
36  /// redirect console input to or output from the device database.
38  public:
39  // types
40  /// \brief Internal typedef of istream;
42  /// \brief Internal typedef of ostream;
44  // statics
47  // constructors
48  /// \brief Null constructor.
49  DDBConsoleStreams(void);
50  /// \brief Explicit constructor.
51  DDBConsoleStreams(istream& inIn, ostream& inOut, ostream& inErr, ostream& inLog)
52  { setConsoleStreams(inIn, inOut, inErr, inLog); }
53  /// \brief Virtual destructor.
54  virtual ~DDBConsoleStreams(void) {}
55  // accessors
56  /// \brief Returns the database console input stream.
57  istream& mIn(void) { return *mInPtr; }
58  /// \brief Returns the database console output stream.
59  ostream& mOut(void) { return *mOutPtr; }
60  /// \brief Returns the database console error stream.
61  ostream& mErr(void) { return *mErrPtr; }
62  /// \brief Returns the database console log stream.
63  ostream& mLog(void) { return *mLogPtr; }
64  /// \brief Returns the database console input stream.
65  istream& getConsoleIn(void) { return mIn(); }
66  /// \brief Returns the database console output stream.
67  ostream& getConsoleOut(void) { return mOut(); }
68  /// \brief Returns the database console error stream.
69  ostream& getConsoleErr(void) { return mErr(); }
70  /// \brief Returns the database console log stream.
71  ostream& getConsoleLog(void) { return mLog(); }
72  /// \brief Sets the database console input stream.
73  void setConsoleIn(istream& inStream) { mInPtr = &inStream; }
74  /// \brief Sets the database console output stream.
75  void setConsoleOut(ostream& inStream) { mOutPtr = &inStream; }
76  /// \brief Sets the database console error stream.
77  void setConsoleErr(ostream& inStream) { mErrPtr = &inStream; }
78  /// \brief Sets the database console log stream.
79  void setConsoleLog(ostream& inStream) { mLogPtr = &inStream; }
80  /// \brief Sets all of the database console streams.
81  /// \param inIn The console input stream.
82  /// \param inOut The console output stream.
83  /// \param inErr The console error stream.
84  /// \param inLog The console log stream.
85  virtual void setConsoleStreams(istream& inIn, ostream& inOut, ostream& inErr,
86  ostream& inLog) {
87  setConsoleIn(inIn);
88  setConsoleOut(inOut);
89  setConsoleErr(inErr);
90  setConsoleLog(inLog);
91  }
92  protected:
93  /// \brief Pointer to the database console input stream.
98  };
99 
100 } // namespace architecture
101 } // namespace torc
102 
103 #endif // TORC_ARCHITECTURE_DDBCONSOLESTREAMS_HPP
std::basic_istream< char > istream
Internal typedef of istream;.
Forward declaration of template basic_istream.
ostream & getConsoleOut(void)
Returns the database console output stream.
ostream & getConsoleErr(void)
Returns the database console error stream.
void setConsoleOut(ostream &inStream)
Sets the database console output stream.
ostream & getConsoleLog(void)
Returns the database console log stream.
DDBConsoleStreams(istream &inIn, ostream &inOut, ostream &inErr, ostream &inLog)
Explicit constructor.
istream * mInPtr
Pointer to the database console input stream.
static DDBConsoleStreams sDefaultConsoleStreams
Device database console streams class.
ostream & mErr(void)
Returns the database console error stream.
Forward declaration of template basic_ostream.
void setConsoleIn(istream &inStream)
Sets the database console input stream.
void setConsoleLog(ostream &inStream)
Sets the database console log stream.
ostream & mOut(void)
Returns the database console output stream.
ostream & mLog(void)
Returns the database console log stream.
virtual ~DDBConsoleStreams(void)
Virtual destructor.
static DDBConsoleStreams sNullConsoleStreams
istream & getConsoleIn(void)
Returns the database console input stream.
istream & mIn(void)
Returns the database console input stream.
std::basic_ostream< char > ostream
Internal typedef of ostream;.
virtual void setConsoleStreams(istream &inIn, ostream &inOut, ostream &inErr, ostream &inLog)
Sets all of the database console streams.
void setConsoleErr(ostream &inStream)
Sets the database console error stream.