Fawkes API  Fawkes Development Version
syncpoint_manager.h
1 /***************************************************************************
2  * syncpoint_manager.h - Fawkes SyncPointManager
3  *
4  * Created: Thu Jan 09 15:17:03 2014
5  * Copyright 2014 Till Hofmann
6  *
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Library General Public License for more details.
18  *
19  * Read the full text in the LICENSE.GPL file in the doc directory.
20  */
21 
22 #ifndef _SYNCPOINT_SYNCPOINT_MANAGER_H_
23 #define _SYNCPOINT_SYNCPOINT_MANAGER_H_
24 
25 #include <core/threading/mutex.h>
26 #include <core/utils/refptr.h>
27 #include <logging/multi.h>
28 #include <syncpoint/syncpoint.h>
29 
30 #include <set>
31 #include <string>
32 
33 namespace fawkes {
34 
35 class SyncPoint;
36 
38 {
39 public:
41  virtual ~SyncPointManager();
42 
43  RefPtr<SyncPoint> get_syncpoint(const std::string &component, const std::string &identifier);
44  void release_syncpoint(const std::string &component, RefPtr<SyncPoint> syncpoint);
45 
46  std::set<RefPtr<SyncPoint>, SyncPointSetLessThan> get_syncpoints();
47 
48 protected:
49  /** Set of all existing SyncPoints */
50  std::set<RefPtr<SyncPoint>, SyncPointSetLessThan> syncpoints_;
51  /** Mutex used for all SyncPointManager calls */
53 
54 private:
55  std::string find_prefix(const std::string &identifier) const;
56  RefPtr<SyncPoint> get_syncpoint_no_lock(const std::string &component,
57  const std::string &identifier);
58  void release_syncpoint_no_lock(const std::string &component, RefPtr<SyncPoint> syncpoint);
59  bool component_watches_any_successor(const RefPtr<SyncPoint> sp,
60  const std::string component) const;
61  MultiLogger *logger_;
62 };
63 
64 } // end namespace fawkes
65 
66 #endif
fawkes::SyncPointManager::mutex_
Mutex * mutex_
Mutex used for all SyncPointManager calls.
Definition: syncpoint_manager.h:52
fawkes::SyncPointManager
This class gives access to SyncPoints.
Definition: syncpoint_manager.h:38
fawkes::Mutex
Mutex mutual exclusion lock.
Definition: mutex.h:33
fawkes::MultiLogger
Log through multiple loggers.
Definition: multi.h:35
fawkes::RefPtr< SyncPoint >
fawkes::SyncPointManager::syncpoints_
std::set< RefPtr< SyncPoint >, SyncPointSetLessThan > syncpoints_
Set of all existing SyncPoints.
Definition: syncpoint_manager.h:50
fawkes::SyncPointManager::get_syncpoint
RefPtr< SyncPoint > get_syncpoint(const std::string &component, const std::string &identifier)
Get a SyncPoint.
Definition: syncpoint_manager.cpp:68
fawkes
Fawkes library namespace.
fawkes::SyncPointSetLessThan
Compare sets of syncpoints.
Definition: syncpoint.h:44
fawkes::SyncPointManager::SyncPointManager
SyncPointManager(MultiLogger *logger)
Constructor.
Definition: syncpoint_manager.cpp:46
fawkes::SyncPointManager::get_syncpoints
std::set< RefPtr< SyncPoint >, SyncPointSetLessThan > get_syncpoints()
Get the current list of all SyncPoints managed by this SyncPointManager.
Definition: syncpoint_manager.cpp:115
fawkes::SyncPointManager::release_syncpoint
void release_syncpoint(const std::string &component, RefPtr< SyncPoint > syncpoint)
Release a SyncPoint.
Definition: syncpoint_manager.cpp:86