1 #ifndef CARMA_UTIL_CONFIGCHECKER_H
2 #define CARMA_UTIL_CONFIGCHECKER_H
14 #include "carma/util/IoLock.h"
15 #include "carma/util/Program.h"
16 #include "carma/util/PthreadMutex.h"
17 #include "carma/util/PthreadRWLock.h"
19 #include <log4cpp/Category.hh>
20 #include <log4cpp/Priority.hh>
24 #define DPRINT(objptr, classname, statement) \
25 { if(objptr->isDebug("All") || objptr->isDebug(classname)) {\
26 const carma::util::IoLock::ScopedCerrLock cerrLock; \
27 if (objptr->printTime()) {\
28 std::cerr << carma::util::Time::getTimeString(2) << ": "; \
30 if (objptr->prettyFunction()) {\
32 << __PRETTY_FUNCTION__ << ": "; \
34 std::cerr << statement << std::endl; \
37 #define DPRINT(objptr, classname, statement) {}
40 #define LOGCMD(objptr, classname, statement) \
41 {if(objptr->isLogCmd("All") || objptr->isLogCmd(classname)) {\
42 const carma::util::IoLock::ScopedCerrLock cerrLock; \
43 log4cpp::Category& log = objptr->getLogger(); \
44 std::ostringstream os; \
45 if (objptr->prettyFunction()) {\
46 os << "In " << __PRETTY_FUNCTION__ << ": "; \
49 log << log4cpp::Priority::INFO << os.str(); \
52 #define LOGEXCEPTION(objptr, classname, statement) \
54 const carma::util::IoLock::ScopedCerrLock cerrLock; \
55 log4cpp::Category& log = objptr->getLogger(); \
56 std::ostringstream os; \
57 os << "In " << __PRETTY_FUNCTION__ << ": "; \
59 log << log4cpp::Priority::ERROR << os.str(); \
62 #define LOGPROBLEM(objptr, classname, statement) \
64 const carma::util::IoLock::ScopedCerrLock cerrLock; \
65 log4cpp::Category& log = objptr->getLogger(); \
66 std::ostringstream os; \
67 os << "In " << __PRETTY_FUNCTION__ << ": "; \
69 log << log4cpp::Priority::WARN << os.str(); \
72 #define LOGINFO(objptr, classname, statement) \
74 const carma::util::IoLock::ScopedCerrLock cerrLock; \
75 log4cpp::Category& log = objptr->getLogger(); \
76 std::ostringstream os; \
77 os << "In " << __PRETTY_FUNCTION__ << ": "; \
79 log << log4cpp::Priority::INFO << os.str(); \
127 std::string
getValue( const ::std::string & key )
const;
129 bool valueIsEmpty( const ::std::string & key )
const;
131 bool valueIsOneString( const ::std::string & key )
const;
133 bool valueIsZeroString( const ::std::string & key )
const;
141 bool getConfigFileNotFound( )
const;
144 static void updateThreadEntrypoint(
ConfigChecker & configChecker );
151 int getDelay( )
const;
157 ::std::string getFilename( )
const;
160 const ::std::string kOneString_;
161 const ::std::string kZeroString_;
164 const int delayBetweenFileReads_;
165 const ::std::string fileName_;
168 bool configFileNotFound_;
169 ::std::map< ::std::string, ::std::string > pairs_;
170 bool haveFirstReadCtime_;
171 time_t firstReadCtime_;
172 log4cpp::Category & log_;
175 bool updateThreadStarted_;
176 ::pthread_t updateThread_;
184 #endif // End #ifndef CARMA_UTIL_CONFIGCHECKER_H
A simple wrapper class that makes use of ::pthread_rwlock_t easier in a C++ world.
ConfigChecker(const std::string &filename)
Constructor.
void start()
start reading the configuration file in a separate thread
std::string getValue(const ::std::string &key) const
return the value associated with key.
Abstract Base class for managing configuration files.
log4cpp::Category & getLogger() const
Get a logger.
A simple wrapper class that makes use of ::pthread_mutex_t easier in a C++ world. ...
virtual ~ConfigChecker()
Destructor.