TCApplication.h

Go to the documentation of this file.
00001 //*******************************************************************************
00002 //
00003 // *******   ***   ***               *
00004 //    *     *     *                  *
00005 //    *    *      *                *****
00006 //    *    *       ***  *   *   **   *    **    ***
00007 //    *    *          *  * *   *     *   ****  * * *
00008 //    *     *         *   *      *   * * *     * * *
00009 //    *      ***   ***    *     **   **   **   *   *
00010 //                        *
00011 //*******************************************************************************
00012 // see http://sourceforge.net/projects/tcsystem/ for details.
00013 // Copyright (C) 2003 - 2008 Thomas Goessler. All Rights Reserved. 
00014 //*******************************************************************************
00015 //
00016 // TCSystem is the legal property of its developers.
00017 // Please refer to the COPYRIGHT file distributed with this source distribution.
00018 // 
00019 // This library is free software; you can redistribute it and/or             
00020 // modify it under the terms of the GNU Lesser General Public                
00021 // License as published by the Free Software Foundation; either              
00022 // version 2.1 of the License, or (at your option) any later version.        
00023 //                                                                           
00024 // This library is distributed in the hope that it will be useful,           
00025 // but WITHOUT ANY WARRANTY; without even the implied warranty of            
00026 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         
00027 // Lesser General Public License for more details.                           
00028 //                                                                           
00029 // You should have received a copy of the GNU Lesser General Public          
00030 // License along with this library; if not, write to the Free Software       
00031 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
00032 //*******************************************************************************
00033 //  $Id: TCApplication.h 870 2008-07-21 14:15:33Z the_____tiger $
00034 //*******************************************************************************
00035 #ifndef _TC_APPLICATION_H_
00036 #define _TC_APPLICATION_H_
00037 
00038 #include "TCNonCopyable.h"
00039 
00040 #include <vector>
00041 #include <string>
00042 #include <cstdarg>
00043 
00044 namespace TC
00045 {
00067    class TCBASE_API Application: protected NonCopyAble
00068    {
00069    public:
00071       Application();
00073       virtual ~Application();
00074       
00076       virtual void Init(sint32 numArg, char **argv,
00077                         const std::string &name, const std::string &version);
00078 
00080       static Application* GetInstance();
00081 
00083       inline const std::string& GetProgrammName() const      { return m_programm_name;}
00085       inline const std::string& GetProgrammVersion() const   { return m_programm_version;}
00086 
00094       void ErrorMessage(const std::string &routineName, const char* message_id, ...);
00102       void WarningMessage(const std::string &routineName, const char* message_id, ...);
00110       void InfoMessage (const std::string &routineName, const char* message_id, ...);
00118       void ErrorMessageBox(const std::string &routineName, const char* message_id, ...);
00126       void WarningMessageBox(const std::string &routineName, const char* message_id, ...);
00131       void AlwaysStdOut(bool output) {m_display_std_out = output; }
00132 
00133    protected:
00134       void displayUsage();
00135       
00136       std::string getMessageOfId(const char* message_id, va_list arguments);
00137 
00138       virtual void processArguments(const std::vector< std::string > &) {};
00139       virtual std::string getUsage() { return ""; }
00140 
00141       virtual void displayErrorMessage(const std::string &,
00142                                         const std::string &) {};
00143       virtual void displayWarningMessage(const std::string &,
00144                                         const std::string &) {};
00145       virtual void displayInfoMessage (const std::string &,
00146                                         const std::string &) {};
00147       virtual void displayErrorMessageBox(const std::string &routineName,
00148                                         const std::string &message) { displayErrorMessage(routineName, message); };
00149       virtual void displayWarningMessageBox(const std::string &routineName,
00150                                         const std::string &message) { displayWarningMessage(routineName, message);};
00151 
00152    protected:
00153       std::vector< std::string > m_programm_arguments;
00154       
00155       std::string m_programm_name;
00156       std::string m_programm_version;
00157      
00158       bool m_display_std_out;
00159       
00160    private:
00161       static Application *m_application;
00162    };
00163 
00168 } // namespace TC
00169 
00170 #endif // _TCBASE_APPLICATION_H_

Copyright (c) Thomas Goessler 2003 - 2008