libH/Util.hpp

Go to the documentation of this file.
00001 
00012 /*
00013   
00014   Copyright (c) 2007, Tim Burrell
00015   Licensed under the Apache License, Version 2.0 (the "License");
00016   you may not use this file except in compliance with the License.
00017   You may obtain a copy of the License at 
00018 
00019         http://www.apache.org/licenses/LICENSE-2.0
00020 
00021   Unless required by applicable law or agreed to in writing, software
00022   distributed under the License is distributed on an "AS IS" BASIS,
00023   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00024   See the License for the specific language governing permissions and 
00025   limitations under the License. 
00026   
00027 */
00028 
00029 #ifndef __Util_h
00030 #define __Util_h
00031 
00032 #if HAVE_CONFIG_H
00033 #include "config.h"
00034 #endif
00035 
00036 #include "Debug.hpp"
00037 #include <cstdlib>
00038 #include <iostream>
00039 
00041 // Namespace
00043 
00044 namespace H {
00045 
00047 // Global Algorithms
00049         
00054 #define foreach BOOST_FOREACH
00055                 
00064 template<class Object, class Functor>
00065 inline Functor for_all(Object & object, Functor functor) {
00066         return std::for_each(object.begin(), object.end(), functor);
00067 }
00068 
00079 #define apply_func(object, functor, functee) \
00080         for_all(object, boost::bind(functor, functee, _1))
00081         
00093 #define apply_func_args(object, functor, functee, ...) \
00094         for_all(object, boost::bind(functor, functee, _1, ## __VA_ARGS__))
00095         
00106 #define apply_static_func_args(object, functor, ...) \
00107         for_all(object, boost::bind(functor, _1, ## __VA_ARGS__))
00108 
00114 #define sort_all(object) \
00115         sort(object.begin(), object.end())
00116 
00118 // Global Functors
00120         
00125 inline void dbg_print_item(std::string & object) {
00126         H::dbg0 << object << std::endl;
00127 }
00128         
00133 inline void print_item(std::string & object) {
00134         std::cout << object << std::endl;
00135 }
00136         
00138 // Class Definition
00140 
00149 class Util {
00150 public:
00151         // Public Member Functions
00152         
00153         // Construction / Deconstruction
00154         Util();
00155         virtual ~Util();
00156 
00157 private:
00158         // Private Member Functions
00159 
00160         // Private Member Variables
00161 };
00162 
00163 } // H namespace
00164 
00165 #endif // __Util_h

Generated on Wed Nov 7 10:04:16 2007 for gizmod by  doxygen 1.5.3