Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ProgressSemaphorePool.hh
1 #ifndef __ProgressSemaphorePool_hh__
2 #define __ProgressSemaphorePool_hh__
3 
4 // includes
5 #include <bias_config.h>
6 
7 #include <Base/Common/Singleton.hh>
8 #include <Base/Common/SharedPtr.hh>
9 #include <map>
10 #include <vector>
11 
12 namespace BIAS {
13 
14 
15  class BIASCommon_EXPORT ProgressSemaphore;
16 
17  /** @class ProgressSemaphorePool
18  @brief
19  @author evers 03/2008 */
20  class BIASCommon_EXPORT ProgressSemaphorePool: public Singleton<ProgressSemaphorePool>
21  {
22  public:
23 
24  /// destructor
26 
27  // register to use a named semaphore. A new one is created if
28  // necessary. Use the returned pointer to use the semaphore If the
29  // pool is cleared (Clear()), the SharedPtr remains valid but
30  // useless.
31  SharedPtr<ProgressSemaphore> Register(const std::string &name);
32 
33  void GetAllSemaphoreNames(std::vector<std::string> &names);
34 
35  // set Terminate flag for all contained ProgressSemaphores
36  void TerminateAll();
37 
38  // accumulate progress over all contained ProgressSemaphores,
39  // normalized to bw within standard intervall [0,1]
40  float GetOverallProgress();
41 
42  // The application can clear the pool when ever appropriate.
43  void Clear();
44 
45  // ask for the existance of a special ProgressSemaphore
46  bool Exists(const std::string &name);
47 
49 protected:
51 // ProgressSemaphorePool(const &ProgressSemaphorePool);
52 // ProgressSemaphorePool& operator=(const &ProgressSemaphorePool);
53 
54 
55  std::map<std::string, SharedPtr<ProgressSemaphore> > Semaphores_;
56 
57 
58  }; // class ProgressSemaphorePool
59 
60 } // namespace
61 
62 #endif // __ProgressSemaphorePool_hh__
std::map< std::string, SharedPtr< ProgressSemaphore > > Semaphores_
pointer with reference count and automatic deletion
Definition: SharedPtr.hh:50
this class represents a progress counter which multiple processes can use.
Simple singleton implementation for multithreaded applications.
Definition: Singleton.hh:86