00001
00002 #ifndef MIX_FUNCTIONS_H_
00003 #define MIX_FUNCTIONS_H_
00004
00005 #include "misc.h"
00006 #include "extern/compose.hpp"
00007
00008 #include <functional>
00009
00014 namespace MiX{
00021 template <class charT,class traitsT>
00022 class NodeTypeChecker
00023 : public std::unary_function<const Node<charT,traitsT>*,bool>{
00024 public:
00025 MiX_Template_Typedef(charT,traitsT);
00026 typedef const Node<charT,traitsT>* argument_type;
00027 typedef bool result_type;
00028 private:
00029 NodeType type_;
00030 public:
00032 NodeTypeChecker(NodeType t) : type_(t){ };
00034 result_type operator()(argument_type node)const{
00035 return (node->getType()==type_);
00036 };
00037 };
00038
00046 template <class charT,class traitsT>
00047 class NodeNameChecker
00048 : public std::unary_function<const Node<charT,traitsT>*,bool>{
00049 public:
00050 MiX_Template_Typedef(charT,traitsT);
00051 typedef const node_type* argument_type;
00052 typedef bool result_type;
00053 private:
00054 string_type name_;
00055 public:
00057 NodeNameChecker(const string_type& name) : name_(name){ };
00059 result_type operator()(argument_type node)const;
00060 };
00061
00068 template <class charT,class traitsT>
00069 class NamedNodeFinder
00070 : public boost::compose_f_gx_hx_t<std::logical_and<bool>,NodeTypeChecker<charT,traitsT>,NodeNameChecker<charT,traitsT> >{
00071 public:
00072 MiX_Template_Typedef(charT,traitsT);
00073 typedef const node_type* argument_type;
00074 typedef bool result_type;
00075 typedef boost::compose_f_gx_hx_t<std::logical_and<bool>,NodeTypeChecker<charT,traitsT>,NodeNameChecker<charT,traitsT> > super_type;
00076 public:
00083 NamedNodeFinder(NodeType type,const string_type& name)
00084 : super_type(std::logical_and<bool>(),
00085 NodeTypeChecker<charT,traitsT>(type),
00086 NodeNameChecker<charT,traitsT>(name)){ }
00087 };
00088
00089 }
00090
00091 #ifndef MIX_FUNCTIONS_CPP_
00092 #include "Functions.cpp"
00093 #endif
00094
00095 #endif