Nebula
Loading...
Searching...
No Matches
console.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
16#include "core/types.h"
17#include "util/string.h"
18#include "util/array.h"
19#include "core/refcounted.h"
20#include "core/singleton.h"
21#include "core/ptr.h"
22#include "io/consolehandler.h"
23#include "threading/threadid.h"
25
26//------------------------------------------------------------------------------
27namespace IO
28{
30{
33public:
35 Console();
37 virtual ~Console();
39 void Open();
41 void Close();
43 bool IsOpen() const;
45 void Update();
47 void AttachHandler(const Ptr<ConsoleHandler>& handler);
49 void RemoveHandler(const Ptr<ConsoleHandler>& handler);
53 bool HasInput() const;
55 Util::String GetInput() const;
57 void __cdecl Print(const char* fmt, ...);
59 void __cdecl Print(const char* fmt, va_list argList);
61 void Print(const Util::String& s);
63 void __cdecl Error(const char* fmt, ...);
65 void __cdecl Error(const char* fmt, va_list argList);
67 void Error(const Util::String& str);
69 void __cdecl Warning(const char* fmt, ...);
71 void __cdecl Warning(const char* fmt, va_list argList);
73 void Warning(const Util::String& str);
75 void __cdecl Confirm(const char* fmt, ...);
77 void __cdecl Confirm(const char* fmt, va_list argList);
79 void __cdecl DebugOut(const char* fmt, ...);
81 void __cdecl DebugOut(const char* fmt, va_list argList);
82
83protected:
85 Threading::CriticalSection critSect;
87 bool isOpen;
88};
89
90//------------------------------------------------------------------------------
93inline bool
95{
96 return this->isOpen;
97}
98
99//------------------------------------------------------------------------------
104{
105 this->critSect.Enter();
107 this->critSect.Leave();
108 return handlers;
109}
110
111} // namespace IO
112//------------------------------------------------------------------------------
The common base class of Nebula.
Definition refcounted.h:38
Util::Array< Ptr< ConsoleHandler > > consoleHandlers
Definition console.h:86
bool isOpen
Definition console.h:87
void Open()
open the console
Definition console.cc:54
virtual ~Console()
destructor
Definition console.cc:39
void __cdecl DebugOut(const char *fmt,...)
print a debug-only message
Definition console.cc:270
void Update()
called per-frame
Definition console.cc:96
Util::String GetInput() const
get user input
Definition console.cc:167
Threading::ThreadId creatorThreadId
Definition console.h:84
void __cdecl Warning(const char *fmt,...)
put a warning message
Definition console.cc:301
void AttachHandler(const Ptr< ConsoleHandler > &handler)
attach a console handler to the console
Definition console.cc:114
bool IsOpen() const
return true if currently open
Definition console.h:94
void __cdecl Confirm(const char *fmt,...)
display a confirmation message box
Definition console.cc:341
void __cdecl Error(const char *fmt,...)
put an error message and cancel execution
Definition console.cc:230
bool HasInput() const
return true if user input is available
Definition console.cc:145
Console()
constructor
Definition console.cc:29
void __cdecl Print(const char *fmt,...)
print a formatted line (printf style)
Definition console.cc:189
Util::Array< Ptr< ConsoleHandler > > GetHandlers() const
get array of currently installed handlers
Definition console.h:103
__DeclareClass(Console)
Threading::CriticalSection critSect
Definition console.h:85
void RemoveHandler(const Ptr< ConsoleHandler > &handler)
remove a console handler from the console
Definition console.cc:130
void Close()
close the console
Definition console.cc:77
__DeclareInterfaceSingleton(Console)
Nebula's smart pointer class which manages the life time of RefCounted objects.
Definition ptr.h:38
Nebula's dynamic array class.
Definition array.h:61
Nebula's universal string class.
Definition string.h:50
Instances of wrapped stream classes.
Definition multiplayerfeatureunit.cc:324
pthread_t ThreadId
Definition linuxthreadid.h:15