Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: a8cc02ee8148c04a556cb467cdb5f98ee81c6a7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
   server/console.cc
   This file is part of the Osirion project and is distributed under
   the terms and conditions of the GNU General Public License version 2
*/

#include "server/console.h"
#include "core/core.h"

#include <iostream>

namespace server {

namespace console {

//--- private definition ------------------------------------------

/// server console implementation
class Console : public sys::ConsoleInterface {
public:
	/// stream to send normal messages too
	virtual std::ostream & messagestream();

	/// stream to send warning messages too
	virtual std::ostream & warningstream();

	/// stream to send warning messages too
	virtual std::ostream & errorstream();
	
	/// stream to send debug messages too
	virtual std::ostream & debugstream();

	unsigned long ping;
	
};

// private console object
Console console;

//--- engine functions --------------------------------------------

extern "C" void func_con_ping(std::stringstream &args)
{
	con_print << "Ping!" << std::endl;
	console.ping++;
}

//--- public ------------------------------------------------------

void init()
{
	con_print << "Initializing console..." << std::endl;

	// register our engine functions
	core::func::add("con_ping", func_con_ping);
}

void shutdown()
{
	con_print << "Shutting down console..." << std::endl;

	// unregister our engine functions
	core::func::remove("con_ping");
}

//--- private -----------------------------------------------------

std::ostream & Console::messagestream()
{
	return std::cout;
}

std::ostream & Console::warningstream()
{
	return std::cerr;
}
std::ostream & Console::errorstream()
{
	return std::cerr;
}

std::ostream & Console::debugstream()
{
	return std::cout;
}

} // namespace console

} // namespace server