Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

messaginghub.h

Go to the documentation of this file.
00001 
00002 /*
00003     This file is part of Advanced Strategic Command; http://www.asc-hq.de
00004     Copyright (C) 1994-1999  Martin Bickel  and  Marc Schellenberger
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; see the file COPYING. If not, write to the
00018     Free Software Foundation, Inc., 59 Temple Place, Suite 330,
00019     Boston, MA  02111-1307  USA
00020 */
00021 
00022 
00023 #ifndef messaginghubH
00024 #define messaginghubH
00025 
00026  #include <sigc++/sigc++.h>
00027  #include "libs/loki/Singleton.h"
00028 
00029  #include "ascstring.h"
00030 
00032   class StatusMessageWindowHolder {
00033     public:
00034        class UserData {
00035              friend class StatusMessageWindowHolder;
00036              int counter;  
00037           public:
00038              UserData() : counter(1) {};
00039              virtual ~UserData() {};
00040        
00041        };
00042     private:   
00043        UserData* userData;
00044     protected:
00045        void copy( const StatusMessageWindowHolder& smw );
00046        void unlink();
00047     public:
00048        StatusMessageWindowHolder();
00049        StatusMessageWindowHolder( UserData* ud ) : userData(ud) {};
00050        StatusMessageWindowHolder( const StatusMessageWindowHolder& smw );
00051        StatusMessageWindowHolder& operator=( const StatusMessageWindowHolder& smw );    
00052        void close();
00053        virtual ~StatusMessageWindowHolder();
00054  };
00055 
00056 
00057  class MessagingHubBase {
00058     protected:
00059        int verbosity;
00060     
00061     public:
00062        MessagingHubBase() : verbosity(0) {};
00063        void setVerbosity( int v ) { verbosity = v; };
00064        int  getVerbosity() { return verbosity; };
00065        
00066        enum MessageType { FatalError, Error, Warning, InfoMessage, StatusInfo, LogMessage };
00067        
00069        SigC::Signal1<void, const ASCString&> fatalError;
00070 
00072        SigC::Signal0<void> exitHandler;
00073               
00075        SigC::Signal1<void, const ASCString&> error;
00076        
00078        SigC::Signal1<void, const ASCString&> warning;
00079        
00081        SigC::Signal1<void, const ASCString&> infoMessage;
00082        
00084        SigC::Signal1<void, const ASCString&> statusInformation;
00085        
00087        SigC::Signal2<void, const ASCString&,int> logMessage;
00088        
00090        void message( MessageType type, const char* msg, ... );
00091 
00093        void message( MessageType type, const ASCString& msg );
00094 
00095 
00105        StatusMessageWindowHolder infoMessageWindow( const ASCString& msg );
00106         
00108        SigC::Signal1<StatusMessageWindowHolder, const ASCString&> messageWindowFactory;
00109               
00110    };
00111        
00112  typedef Loki::SingletonHolder<MessagingHubBase > MessagingHub;
00113 
00114 
00115  
00116  extern void fatalError ( const char* formatstring, ... );
00117  extern void fatalError ( const ASCString& string );
00118  extern void errorMessage ( const ASCString& string );
00119  extern void warning ( const ASCString& string );
00120  extern void infoMessage ( const ASCString& string );
00121  extern void statusMessage ( const ASCString& string );
00122        
00123  extern void displayLogMessage ( int msgVerbosity, const char* message, ... );
00124  extern void displayLogMessage ( int msgVerbosity, const ASCString& message );
00125 
00126 
00127 #endif
00128 

Generated on Tue Jun 24 01:27:45 2008 for Advanced Strategic Command by  doxygen 1.4.2