Cafu Engine
1 /*
2 Cafu Engine,
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
10 #include <string>
13 namespace cf
14 {
15  /// This class is an interface to the application console.
16  /// Google search for "console input non blocking" yields interesting insights for non-blocking console input under Linux.
17  /// The unix_main.c file from Q3 has something, too.
18  class ConsoleI
19  {
20  public:
22  /// Virtual dtor so that derived classes properly destroy.
23  virtual ~ConsoleI() { }
25  // Methods for console output.
26  virtual void Print(const std::string& s)=0; ///< Print message to console.
27  virtual void DevPrint(const std::string& s)=0; ///< Print dev message to console.
28  virtual void Warning(const std::string& s)=0; ///< Print warning to console.
29  virtual void DevWarning(const std::string& s)=0; ///< Print dev warning to console.
30  };
33  /// Builds a std::string from a printf-like format string and the variable argument list.
34  std::string va(const char* FormatString, ...);
35 }
38 /// A global pointer to an implementation of the ConsoleI interface.
39 ///
40 /// Each module (exe or dll) that uses this pointer must somewhere provide exactly one definition for it (none is provided by the Console library).
41 /// That is, typically the main.cpp or similar file of each exe and dll must contain a line like
42 /// cf::ConsoleI* Console=NULL;
43 /// or else the module will not link successfully due to an undefined symbol.
44 ///
45 /// Exe files will then want to reset this pointer to an instance of e.g. a ConsoleStdoutT during their initialization
46 /// e.g. by code like: Console=new cf::ConsoleStdoutT;
47 ///
48 /// Dlls typically get one of their init functions called immediately after they have been loaded.
49 /// By doing so, the exe passes a pointer to its above instance to the dll, which in turn copies it to its Console variable.
50 extern cf::ConsoleI* Console;
52 #endif
virtual void Print(const std::string &s)=0
Print message to console.
virtual ~ConsoleI()
Virtual dtor so that derived classes properly destroy.
Definition: Console.hpp:23
virtual void DevWarning(const std::string &s)=0
Print dev warning to console.
This class is an interface to the application console.
Definition: Console.hpp:18
virtual void Warning(const std::string &s)=0
Print warning to console.
virtual void DevPrint(const std::string &s)=0
Print dev message to console.