processor.h

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // $Id: processor.h,v 1.18 2005/12/23 17:01:41 amoll Exp $
00005 //
00006 
00007 #ifndef BALL_CONCEPT_PROCESSOR_H
00008 #define BALL_CONCEPT_PROCESSOR_H
00009 
00010 #ifndef BALL_COMMON_H
00011 # include <BALL/common.h>
00012 #endif
00013 
00014 #ifndef BALL_CONCEPT_BASEFUNCTOR_H
00015 # include <BALL/CONCEPT/baseFunctor.h>
00016 #endif
00017 
00018 #ifndef BALL_COMMON_GLOBAL_H
00019 # include <BALL/COMMON/global.h>
00020 #endif
00021 
00022 namespace BALL 
00023 {
00024 
00030 
00033   class BALL_EXPORT Processor
00034   {
00035     public:
00038     typedef int Result;
00039 
00042     enum
00043     {
00046       ABORT    = 0,
00049       BREAK    = 1,
00052       CONTINUE = 2
00053     };
00054   };
00055  
00056 
00059   template <typename T>
00060   class UnaryProcessor
00061     : public UnaryFunctor<T, Processor::Result>
00062   {
00063     public:
00064 
00068     BALL_CREATE(UnaryProcessor)
00071     UnaryProcessor()
00072     {
00073     }
00074 
00077     UnaryProcessor
00078       (const UnaryProcessor& /* processor */)
00079     {
00080     }
00081 
00084     virtual ~UnaryProcessor()
00085     {
00086     }
00088 
00094     virtual bool start()
00095     {
00096       return true;
00097     }
00098 
00101     virtual bool finish()
00102     {
00103       return true;
00104     }
00105 
00108     virtual Processor::Result operator () (T &)
00109     {
00110       return Processor::CONTINUE;
00111     }
00113   };
00114 
00117   template <typename T1, typename T2>
00118   class BinaryProcessor
00119     : public BinaryFunctor<T1, T2, Processor::Result>
00120   {
00121     public:
00122 
00126     BALL_CREATE(BinaryProcessor)
00127 
00128     
00130     BinaryProcessor() 
00131     {
00132     }
00133 
00136     BinaryProcessor 
00137       (const BinaryProcessor& /* processor */)
00138     {
00139     }
00140 
00143     virtual ~BinaryProcessor()
00144     {
00145     }
00147 
00151     
00154     virtual bool start()
00155     {
00156       return true;
00157     }
00158 
00161     virtual bool finish()
00162     {
00163       return true;
00164     }
00165 
00168     virtual Processor::Result operator () (T1&, T2&)
00169     {
00170       return Processor::CONTINUE;
00171     }
00173   };
00174 
00176 // required for visual studio
00177 #ifdef BALL_COMPILER_MSVC
00178 class Atom;
00179 template class BALL_EXPORT UnaryProcessor<Atom>;
00180 #endif
00181 
00182 } // namespace BALL
00183 
00184 #endif // BALL_CONCEPT_PROCESSOR_H