Advanced Strategic Command
messaginghub.h
Go to the documentation of this file.
1 
2 /*
3  This file is part of Advanced Strategic Command; http://www.asc-hq.de
4  Copyright (C) 1994-2010 Martin Bickel and Marc Schellenberger
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; see the file COPYING. If not, write to the
18  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19  Boston, MA 02111-1307 USA
20 */
21 
22 
23 #ifndef messaginghubH
24 #define messaginghubH
25 
26  #include <set>
27 
28  #include <sigc++/sigc++.h>
29  #include "loki/Singleton.h"
30 
31  #include "../ascstring.h"
32 
35  public:
36  class UserData {
38  int counter;
39  public:
40  UserData() : counter(1) {};
41  virtual ~UserData() {};
42  virtual void SetText( const ASCString& text ) {};
43 
44  };
45  private:
46  UserData* userData;
47  protected:
48  void copy( const StatusMessageWindowHolder& smw );
49  void unlink();
50  public:
52  StatusMessageWindowHolder( UserData* ud ) : userData(ud) {};
55  void close();
56  void SetText( const ASCString& text );
58  };
59 
60 
62  std::set<ASCString> enabledLogCategories;
63 
64  protected:
65  int verbosity;
66 
67  public:
69  void setVerbosity( int v ) { verbosity = v; };
70  int getVerbosity() { return verbosity; };
71 
72  void setLoggingCategory( const ASCString& category, bool enable );
73  bool logCategoryEnabled( const ASCString& category );
74 
76 
78  sigc::signal<void, const ASCString&> fatalError;
79 
81  sigc::signal<void> exitHandler;
82 
84  sigc::signal<void, const ASCString&> error;
85 
87  sigc::signal<void, const ASCString&> warning;
88 
90  sigc::signal<void, const ASCString&> infoMessage;
91 
93  sigc::signal<void, const ASCString&> statusInformation;
94 
96  sigc::signal<void, const ASCString&,int> logMessage;
97 
99  sigc::signal<void, const ASCString&,const ASCString&> logCategorizedMessage;
100 
102  void message( MessageType type, const char* msg, ... );
103 
105  void message( MessageType type, const ASCString& msg );
106 
107 
118 
120  sigc::signal<StatusMessageWindowHolder, const ASCString&> messageWindowFactory;
121 
122  };
123 
124  typedef Loki::SingletonHolder<MessagingHubBase,Loki::CreateUsingNew,Loki::NoDestroy > MessagingHub;
125 
126 
127 
128  extern void fatalError ( const char* formatstring, ... );
129  extern void fatalError ( const ASCString& string );
130  extern void errorMessage ( const ASCString& string );
131  extern void warningMessage ( const ASCString& string );
132  extern void infoMessage ( const ASCString& string );
133  extern void statusMessage ( const ASCString& string );
134 
135  extern void displayLogMessage ( int msgVerbosity, const char* message, ... );
136  extern void displayLogMessage ( int msgVerbosity, const ASCString& message );
137  extern void logMessage ( const ASCString& category, const ASCString& message );
138 
139 #endif
sigc::signal< void, const ASCString & > warning
displays a warning
Definition: messaginghub.h:87
bool logCategoryEnabled(const ASCString &category)
sigc::signal< void, const ASCString & > fatalError
displays an error message and aborts the game
Definition: messaginghub.h:78
sigc::signal< void, const ASCString &, int > logMessage
prints a message to the logging file
Definition: messaginghub.h:96
void statusMessage(const ASCString &string)
sigc::signal< void, const ASCString & > error
displays an error message and continues game
Definition: messaginghub.h:84
void message(MessageType type, const char *msg,...)
displays any kind of message, as specified by parameter
StatusMessageWindowHolder(UserData *ud)
Definition: messaginghub.h:52
Loki::SingletonHolder< MessagingHubBase, Loki::CreateUsingNew, Loki::NoDestroy > MessagingHub
Definition: messaginghub.h:124
A class that hols a MessageWindow. This class ensures that the window is removed if the last copy of ...
Definition: messaginghub.h:34
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
sigc::signal< void, const ASCString &, const ASCString & > logCategorizedMessage
prints a message to the logging file
Definition: messaginghub.h:99
void displayLogMessage(int msgVerbosity, const char *message,...)
sigc::signal< void > exitHandler
exits the program
Definition: messaginghub.h:81
void setLoggingCategory(const ASCString &category, bool enable)
void errorMessage(const ASCString &string)
void fatalError(const char *formatstring,...)
sigc::signal< StatusMessageWindowHolder, const ASCString & > messageWindowFactory
prints a message to the logging file
Definition: messaginghub.h:120
StatusMessageWindowHolder & operator=(const StatusMessageWindowHolder &smw)
void warningMessage(const ASCString &string)
void setVerbosity(int v)
Definition: messaginghub.h:69
void infoMessage(const ASCString &string)
virtual ~StatusMessageWindowHolder()
StatusMessageWindowHolder infoMessageWindow(const ASCString &msg)
Displays a status window.
sigc::signal< void, const ASCString & > statusInformation
displays a message in the message line
Definition: messaginghub.h:93
void SetText(const ASCString &text)
void logMessage(const ASCString &category, const ASCString &message)
virtual void SetText(const ASCString &text)
Definition: messaginghub.h:42
void copy(const StatusMessageWindowHolder &smw)
sigc::signal< void, const ASCString & > infoMessage
displays an informational message
Definition: messaginghub.h:90