00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 00005 #ifndef BALL_CONCEPT_PROCESSOR_H 00006 #define BALL_CONCEPT_PROCESSOR_H 00007 00008 #ifndef BALL_COMMON_H 00009 # include <BALL/common.h> 00010 #endif 00011 00012 #ifndef BALL_CONCEPT_BASEFUNCTOR_H 00013 # include <BALL/CONCEPT/baseFunctor.h> 00014 #endif 00015 00016 #ifndef BALL_COMMON_GLOBAL_H 00017 # include <BALL/COMMON/global.h> 00018 #endif 00019 00020 namespace BALL 00021 { 00022 00028 00031 class BALL_EXPORT Processor 00032 { 00033 public: 00036 typedef int Result; 00037 00040 enum 00041 { 00044 ABORT = 0, 00047 BREAK = 1, 00050 CONTINUE = 2 00051 }; 00052 }; 00053 00054 00057 template <typename T> 00058 class UnaryProcessor 00059 : public UnaryFunctor<T, Processor::Result> 00060 { 00061 public: 00062 00066 BALL_CREATE(UnaryProcessor) 00069 UnaryProcessor() 00070 { 00071 } 00072 00075 UnaryProcessor 00076 (const UnaryProcessor& /* processor */) 00077 { 00078 } 00079 00082 virtual ~UnaryProcessor() 00083 { 00084 } 00086 00092 virtual bool start() 00093 { 00094 return true; 00095 } 00096 00099 virtual bool finish() 00100 { 00101 return true; 00102 } 00103 00106 virtual Processor::Result operator () (T &) 00107 { 00108 return Processor::CONTINUE; 00109 } 00111 }; 00112 00115 template <typename T1, typename T2> 00116 class BinaryProcessor 00117 : public BinaryFunctor<T1, T2, Processor::Result> 00118 { 00119 public: 00120 00124 BALL_CREATE(BinaryProcessor) 00125 00126 00128 BinaryProcessor() 00129 { 00130 } 00131 00134 BinaryProcessor 00135 (const BinaryProcessor& /* processor */) 00136 { 00137 } 00138 00141 virtual ~BinaryProcessor() 00142 { 00143 } 00145 00149 00152 virtual bool start() 00153 { 00154 return true; 00155 } 00156 00159 virtual bool finish() 00160 { 00161 return true; 00162 } 00163 00166 virtual Processor::Result operator () (T1&, T2&) 00167 { 00168 return Processor::CONTINUE; 00169 } 00171 }; 00172 00174 // required for visual studio 00175 #ifdef BALL_COMPILER_MSVC 00176 class Atom; 00177 template class BALL_EXPORT UnaryProcessor<Atom>; 00178 #endif 00179 00180 } // namespace BALL 00181 00182 #endif // BALL_CONCEPT_PROCESSOR_H