CrystalSpace

Public API Reference

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

verbosity.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2004 by Jorrit Tyberghein
00003               (C) 2004 by Frank Richter
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 */
00019 
00020 #ifndef __CS_CSUTIL_VERBOSITY_H__
00021 #define __CS_CSUTIL_VERBOSITY_H__
00022 
00026 #include "csextern.h"
00027 #include "iutil/verbositymanager.h"
00028 
00029 #include "csutil/csstring.h"
00030 #include "csutil/hashhandlers.h"
00031 
00048 class CS_CSUTIL_EXPORT csVerbosityParser
00049 {
00050   struct VerbosityFlag
00051   {
00052     csString msgClass;
00057     bool defaultFlag;
00058     csHash<bool, csStrKey, csConstCharHashKeyHandler> msgSubclasses;
00059     
00060     VerbosityFlag() : defaultFlag(true) {}
00061   };
00062   csArray<VerbosityFlag> verbosityFlags;
00063   enum
00064   {
00065     ForceResult = 1,
00066     DefTrue = 2,
00067     DefFalse = 0,
00068     DefMask = DefTrue
00069   };
00070   uint defaultGlobalFlag;
00071 
00072   static int VfKeyCompare (const VerbosityFlag& vf, const char* const& K);
00073   static int VfCompare (const VerbosityFlag& vf1, const VerbosityFlag& vf2);
00074 public:
00080   csVerbosityParser (const char* flags);
00081   
00085   bool CheckFlag (const char* msgClass, const char* msgSubclass = 0);
00086 };
00087 
00094 extern CS_CSUTIL_EXPORT bool csCheckVerbosity (int argc,
00095   const char* const argv[], const char* msgClass,
00096   const char* msgSubclass = 0);
00097   
00102 class CS_CSUTIL_EXPORT csVerbosityManager : public iVerbosityManager
00103 {
00104   csVerbosityParser vp;
00105 public:
00106   SCF_DECLARE_IBASE;
00107 
00108   csVerbosityManager (const char* flags) : vp (flags)
00109   {
00110     SCF_CONSTRUCT_IBASE(0);
00111   }
00112   virtual ~csVerbosityManager()
00113   {
00114     SCF_DESTRUCT_IBASE();
00115   }
00116 
00117   virtual bool CheckFlag (const char* msgClass, 
00118     const char* msgSubclass = 0)
00119   { return vp.CheckFlag (msgClass, msgSubclass); }
00120 };
00121 
00122 #endif // __CS_CSUTIL_VERBOSITY_H__

Generated for Crystal Space by doxygen 1.3.9.1