tools/Tools.hpp

00001 #ifndef __TOOLS_HPP__
00002 #define __TOOLS_HPP__
00003 
00004 namespace DAPTA { // Define namespace DAPTA
00005 
00007 template <typename T>
00008 void zap(T & x) {
00009    delete x;
00010    x = NULL;
00011 }
00012 
00014 template <typename PAIR>
00015 class TakeSecond {
00016    private:
00017       typedef void (*func_type)(typename PAIR::second_type &);
00018       func_type func;
00019    public:
00020       TakeSecond(func_type f) : func(f) {;}
00021       void operator()(PAIR &p) { func(p.second); }
00022 };
00023 
00025 template <typename T>
00026 class GetID : public std::unary_function<T*, int> {
00027    public:
00028       int operator()(T* first) const { return first->globalID; }
00029    private:
00030 };
00031 
00033 template <typename T>
00034 class VertexComparison : public std::binary_function<T*, T*, bool> {
00035    public:
00036       VertexComparison(const int& _dir) : dir(_dir) {;}
00037       ~VertexComparison() {;}
00038       
00039       bool operator()(T* first, T* second) const { return (first->coords.at(dir) < second->coords.at(dir)); }
00040    private:
00041       const int dir;
00042 };
00043 
00045 template <typename T>
00046 class IDComparison : public std::binary_function<T*, T*, bool> {
00047    public:
00048       bool operator()(T* first, T* second) const { return (first->globalID < second->globalID); }
00049    private:
00050 };
00051 
00053 template <typename T>
00054 class IDEqual : public std::binary_function<int, T*, bool> {
00055    public:
00056       bool operator()(int first, T* second) const { return (first == second->globalID); }
00057    private:
00058 };
00059 
00061 template <typename T>
00062 class LinkStateJoin : public std::binary_function<T, T, T> {
00063    public:
00064       T operator()(T first, T second) const {
00065          return std::max(first, second);
00066       }
00067    private:
00068 };
00069 
00070 } // namespace DAPTA
00071 
00072 #include "Tools.cpp"
00073 
00074 #endif

Generated on Tue May 29 17:13:49 2007 for DAPTA by  doxygen 1.5.1