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 __cdecl Warning(const char* fmt, ...);
69 void __cdecl Warning(const char* fmt, va_list argList);
71 void __cdecl Confirm(const char* fmt, ...);
73 void __cdecl Confirm(const char* fmt, va_list argList);
75 void __cdecl DebugOut(const char* fmt, ...);
77 void __cdecl DebugOut(const char* fmt, va_list argList);
78
79protected:
83 bool isOpen;
84};
85
86//------------------------------------------------------------------------------
89inline bool
91{
92 return this->isOpen;
93}
94
95//------------------------------------------------------------------------------
100{
101 this->critSect.Enter();
103 this->critSect.Leave();
104 return handlers;
105}
106
107} // namespace IO
108//------------------------------------------------------------------------------
The common base class of Nebula.
Definition refcounted.h:38
Nebula's console, this is the central place for command- line-style communication with the user.
Definition console.h:30
Util::Array< Ptr< ConsoleHandler > > consoleHandlers
Definition console.h:82
bool isOpen
Definition console.h:83
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:267
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:80
void __cdecl Warning(const char *fmt,...)
put a warning message
Definition console.cc:298
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:90
void __cdecl Confirm(const char *fmt,...)
display a confirmation message box
Definition console.cc:329
void __cdecl Error(const char *fmt,...)
put an error message and cancel execution
Definition console.cc:236
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:99
__DeclareClass(Console)
Threading::CriticalSection critSect
Definition console.h:81
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
Critical section objects are used to protect a portion of code from parallel execution.
Nebula's dynamic array class.
Definition array.h:60
Instances of wrapped stream classes.
Definition orientation.cc:10
pthread_t ThreadId
Definition linuxthreadid.h:15
Nebula's universal string class.
Definition string.h:50