📄 base.hh
字号:
/* -*- c++ -*- --------------------------------------------------------------- Copyright (C) 2005, SWECO, All Rights Reserved. Global, basic definitions $Id$ Author: Zsolt Molnar (Zsolt.Molnar@ieee.org) ---------------------------------------------------------------------------*/#ifndef __BASE_HH__#define __BASE_HH__#include <algorithm>#include <functional>using namespace std;// Configuration//#define __TEST__ 1// In test mode...#ifndef __TEST__// The sleep time between the demon activities#define CFG_WAIT_PERIOD 2// The rescan should occure in this period#define CFG_NEXT_SCAN_WAIT 40 / CFG_WAIT_PERIOD#else // #ifndef __TEST__# define CFG_WAIT_PERIOD 0# define CFG_NEXT_SCAN_WAIT 0#endif // #ifdef __TEST__#define CFG_RESET_FILENAME "/tmp/__reset__"#define CFG_BAN_FILENAME "/tmp/__ban__"// The device database file name#define CFG_DEV_DB_FNAME "devdb.txt"// Utility functions// Function object which performs an operation on each element of a container.template< class CONTAINER, class OP >class For_All_t : public std::unary_function< CONTAINER, void >{public: // Interface // Construct/destruct/copy For_All_t ( const OP& aOp ) : iOp( const_cast< OP& >( aOp ) ) {}; // Members void operator () ( CONTAINER& aCont ) const; private: // Members OP& iOp;};template< class CONTAINER, class OP > inline voidFor_All_t< CONTAINER, OP >::operator () ( CONTAINER& aCont ) const{ std::for_each( aCont.begin(), aCont.end(), iOp );}template< class CONTAINER, class OP > inline void For_All( CONTAINER& aCont, const OP& aOp ){ For_All_t< CONTAINER, OP > op( aOp ); op( aCont);}// Function object which deletes an object pointed by its parameter.template< class T >class Delete_Object_t : public std::unary_function< T, void >{public: // Interface void operator () ( const T aPointer ) const { delete aPointer; };};template< class CONTAINER > inline voidDelete_All_Objects( CONTAINER& aCont ){ For_All( aCont, Delete_Object_t< typename CONTAINER::value_type >() );}#endif /* #ifndef __BASE_HH__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -