Tapkee
context.hpp
Go to the documentation of this file.
00001 /* This software is distributed under BSD 3-clause license (see LICENSE file).
00002  *
00003  * Copyright (c) 2012-2013 Sergey Lisitsyn, Fernando Iglesias
00004  */
00005 
00006 #ifndef TAPKEE_CONTEXT_H_
00007 #define TAPKEE_CONTEXT_H_
00008 
00009 namespace tapkee
00010 {
00012 namespace tapkee_internal
00013 {
00014 
00015 class Context
00016 {
00017 public:
00018 
00019     Context(void (*progress)(double), bool (*cancel)()) :
00020         progress_function(progress), cancel_function(cancel)
00021     {
00022     }
00023 
00024     inline void report_progress(double x) const
00025     {
00026         if (progress_function)
00027             progress_function(x);
00028     }
00029 
00030     inline bool is_cancelled() const
00031     {
00032         if (cancel_function)
00033             return cancel_function();
00034         return false;
00035     }
00036 
00037 private:
00038     void (*progress_function)(double);
00039     bool (*cancel_function)();
00040 };
00041 
00042 }
00043 }
00044 
00045 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines