Category.hh
Go to the documentation of this file.
00001 /*
00002  * Category.hh
00003  *
00004  * Copyright 2000, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
00005  * Copyright 2000, Bastiaan Bakker. All rights reserved.
00006  *
00007  * See the COPYING file for the terms of usage and distribution.
00008  */
00009 
00010 #ifndef _LOG4CPP_CATEGORY_HH
00011 #define _LOG4CPP_CATEGORY_HH
00012 
00013 #include "Base/GCException.h"
00014 #include <log4cpp/Portability.hh>
00015 #include <log4cpp/Appender.hh>
00016 #include <log4cpp/LoggingEvent.hh>
00017 #include <log4cpp/Priority.hh>
00018 #include <log4cpp/CategoryStream.hh>
00019 #include <log4cpp/threading/Threading.hh>
00020 #include <log4cpp/convenience.h>
00021 
00022 #include <map>
00023 #include <vector>
00024 #include <cstdarg>
00025 #include <stdexcept>
00026 
00027 LOG4CPP_NS_BEGIN
00028 
00034     class LOG4CPP_EXPORT Category {
00035         friend class HierarchyMaintainer;
00036 
00037         public:
00049         static Category& getRoot();
00050 
00055         static void setRootPriority(Priority::Value priority);
00056 
00061         static Priority::Value getRootPriority() throw();
00062 
00070         static Category& getInstance(const std::string& name);
00071             
00077         static Category* exists(const std::string& name);
00078 
00091         static std::vector<Category*>* getCurrentCategories();
00092 
00096         static void shutdown();
00097 
00101         virtual ~Category();
00102         
00107         virtual const std::string& getName() const throw(); 
00108         
00116         virtual void setPriority(Priority::Value priority);
00117             //throw(GenICam::InvalidArgumentException);
00118 
00123         virtual Priority::Value getPriority() const throw();
00124 
00133         virtual Priority::Value getChainedPriority() const throw();
00134 
00141         virtual bool isPriorityEnabled(Priority::Value priority) const throw();
00142         
00150         virtual void addAppender(Appender* appender);
00151         //throw(GenICam::InvalidArgumentException);
00152 
00159         virtual void addAppender(Appender& appender);
00160 
00169         inline void setAppender(Appender* appender) {
00170             if (appender) {
00171                 addAppender(appender);
00172             } else {
00173                 removeAllAppenders();
00174             }
00175         };
00176 
00183         inline void setAppender(Appender& appender) {
00184             addAppender(appender);
00185         };
00186 
00193         virtual Appender* getAppender() const;
00194 
00201         virtual Appender* getAppender(const std::string& name) const;
00202 
00208         virtual AppenderSet getAllAppenders() const;
00209 
00213         virtual void removeAllAppenders();
00214 
00219         virtual void removeAppender(Appender* appender);
00220 
00227         virtual bool ownsAppender() const throw() {
00228             return ownsAppender(getAppender());
00229         };
00230 
00236         virtual bool ownsAppender(Appender* appender) const throw();
00237 
00249         virtual void callAppenders(const LoggingEvent& event) throw();
00250         
00254         virtual void setAdditivity(bool additivity);
00255 
00259         virtual bool getAdditivity() const throw();
00260 
00266         virtual Category* getParent() throw();
00267 
00273         virtual const Category* getParent() const throw();
00274 
00282         virtual void log(Priority::Value priority, const char* stringFormat,
00283                          ...) throw();
00284 
00290         virtual void log(Priority::Value priority, 
00291                          const std::string& message) throw();
00292         
00301         virtual void logva(Priority::Value priority, 
00302                            const char* stringFormat,
00303                            va_list va) throw();
00304         
00311         void debug(const char* stringFormat, ...) throw();
00312 
00317         void debug(const std::string& message) throw();
00318 
00323         inline bool isDebugEnabled() throw() { 
00324             if( !_ValidDebugEnabledCache )
00325             {
00326                 _DebugEnabled = isPriorityEnabled(Priority::DEBUG);
00327                 _ValidDebugEnabledCache = true;
00328             }
00329             return _DebugEnabled;
00330         };
00331         
00336         inline CategoryStream debugStream() {
00337             return getStream(Priority::DEBUG);
00338         }
00339 
00346         void info(const char* stringFormat, ...) throw();
00347 
00354         void info_push(const char* stringFormat, ...) throw();
00355 
00362         void info_pop(const char* stringFormat, ...) throw();
00363 
00368         void info(const std::string& message) throw();
00369 
00374         inline bool isInfoEnabled() throw() { 
00375             if( !_ValidInfoEnabledCache )
00376             {
00377                 _InfoEnabled = isPriorityEnabled(Priority::INFO);
00378                 _ValidInfoEnabledCache = true;
00379             }
00380             return _InfoEnabled;
00381         };
00382 
00387         inline CategoryStream infoStream() {
00388             return getStream(Priority::INFO);
00389         }
00390         
00397         void notice(const char* stringFormat, ...) throw();
00398 
00403         void notice(const std::string& message) throw();
00404 
00409         inline bool isNoticeEnabled() const throw() { 
00410             return isPriorityEnabled(Priority::NOTICE);
00411         };
00412 
00417         inline CategoryStream noticeStream() {
00418             return getStream(Priority::NOTICE);
00419         }
00420         
00427         void warn(const char* stringFormat, ...) throw();
00428 
00433         void warn(const std::string& message) throw();
00434 
00439         inline bool isWarnEnabled() throw() { 
00440             if( !_ValidWarnEnabledCache )
00441             {
00442                 _WarnEnabled = isPriorityEnabled(Priority::WARN);
00443                 _ValidWarnEnabledCache = true;
00444             }
00445             return _WarnEnabled;
00446         };
00447 
00452         inline CategoryStream warnStream() {
00453             return getStream(Priority::WARN);
00454         };
00455         
00462         void error(const char* stringFormat, ...) throw();
00463 
00468         void error(const std::string& message) throw();
00469 
00474         inline bool isErrorEnabled() const throw() { 
00475             return isPriorityEnabled(Priority::ERROR);
00476         };
00477         
00482         inline CategoryStream errorStream() {
00483             return getStream(Priority::ERROR);
00484         };
00485 
00492         void crit(const char* stringFormat, ...) throw();
00493 
00498         void crit(const std::string& message) throw();
00499 
00504         inline bool isCritEnabled() const throw() { 
00505             return isPriorityEnabled(Priority::CRIT);
00506         };
00507         
00512         inline CategoryStream critStream() {
00513             return getStream(Priority::CRIT);
00514         };
00515         
00522         void alert(const char* stringFormat, ...) throw();
00523 
00528         void alert(const std::string& message) throw();
00529 
00534         inline bool isAlertEnabled() const throw() { 
00535             return isPriorityEnabled(Priority::ALERT);
00536         };
00537         
00542         inline CategoryStream alertStream() throw() {
00543             return getStream(Priority::ALERT);
00544         };
00545 
00552         void emerg(const char* stringFormat, ...) throw();
00553 
00558         void emerg(const std::string& message) throw();
00559 
00564         inline bool isEmergEnabled() const throw() { 
00565             return isPriorityEnabled(Priority::EMERG);
00566         };
00567         
00572         inline CategoryStream emergStream() {
00573             return getStream(Priority::EMERG);
00574         };
00575 
00584         void fatal(const char* stringFormat, ...) throw();
00585 
00592         void fatal(const std::string& message) throw();
00593 
00600         inline bool isFatalEnabled() const throw() { 
00601             return isPriorityEnabled(Priority::FATAL);
00602         };
00603         
00610         inline CategoryStream fatalStream() {
00611             return getStream(Priority::FATAL);
00612         };
00613 
00619         virtual CategoryStream getStream(Priority::Value priority);
00620 
00626         virtual CategoryStream operator<<(Priority::Value priority);
00627 
00628         protected:
00629 
00638         Category(const std::string& name, Category* parent, 
00639                                 Priority::Value priority = Priority::NOTSET);
00640         
00641         virtual void _logUnconditionally(Priority::Value priority, 
00642                                          const char* format, 
00643                                          va_list arguments) throw();
00644         
00650         virtual void _logUnconditionally2(Priority::Value priority, 
00651                                           const std::string& message) throw();
00652 
00653         private:
00654 
00655         /* prevent copying and assignment */
00656         Category(const Category& other);
00657         Category& operator=(const Category& other);
00658 
00660         const std::string _name;
00661 
00666         Category* _parent;
00667 
00671         volatile Priority::Value _priority;
00672 
00673         typedef std::map<Appender *, bool> OwnsAppenderMap;
00674 
00681         virtual bool ownsAppender(Appender* appender, 
00682                                   OwnsAppenderMap::iterator& i2) throw();
00683 
00684         AppenderSet _appender;
00685         mutable threading::Mutex _appenderSetMutex;
00686 
00692         OwnsAppenderMap _ownsAppender;
00693 
00698         volatile bool _isAdditive;
00699 
00701         bool _ValidInfoEnabledCache;
00702 
00704         bool _InfoEnabled;
00705         
00707         bool _ValidDebugEnabledCache;
00708 
00710         bool _DebugEnabled;
00711 
00713         bool _ValidWarnEnabledCache;
00714 
00716         bool _WarnEnabled;
00717 
00719         void InvalidateEnabledCache(bool InvalidateAll = true);
00720     };
00721 
00722 LOG4CPP_NS_END
00723 #endif // _LOG4CPP_CATEGORY_HH


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:02