Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ObserverCache.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file basic/datacache/ObserverCache.hh
11 /// @brief A DataCache storing objects derived from
12 /// basic::datacache::CacheableData.
13 /// @author Yih-En Andrew Ban (yab@u.washington.edu)
14 
15 #ifndef INCLUDED_core_pose_datacache_ObserverCache_hh
16 #define INCLUDED_core_pose_datacache_ObserverCache_hh
17 
18 // unit headers
20 
21 // package headers
22 // AUTO-REMOVED #include <core/pose/datacache/CacheableObserver.hh>
23 
24 // project headers
25 #include <core/pose/Pose.fwd.hh>
26 #include <basic/datacache/DataCache.hh>
27 
29 #include <utility/vector1.hh>
30 
31 
32 
33 
34 namespace core {
35 namespace pose {
36 namespace datacache {
37 
38 
39 /// @brief A DataCache storing Pose/Conformation observers derived from
40 /// core::pose::datacache::CacheableObserver.
41 class ObserverCache : public basic::datacache::DataCache< CacheableObserver > {
42 
43 
44 private: // typedefs
45 
46 
47  typedef basic::datacache::DataCache< CacheableObserver > Super;
48 
49 
50 public: // typedefs
51 
52 
53  typedef Super::Size Size;
54 
55 
56 protected: // typedefs
57 
58 
59  typedef Super::DataOPs ObserverOPs;
60 
61 
62 public: // construct/destruct
63 
64 
65  /// @brief constructor
66  /// @param[in] n_types The number of slots for this ObserverCache.
67  /// @param[in] pose The Pose that will be watched by the Observers in this cache.
69  Size const n_slots,
70  Pose & pose
71  );
72 
73 
74  /// @brief default destructor
75  virtual
77 
78 
79 private: // disallowed constructors
80 
81 
82  /// @brief default constructor
83  ObserverCache();
84 
85 
86  /// @brief copy constructor
87  ObserverCache( ObserverCache const & rval );
88 
89 
90 public: // assignment
91 
92 
93  /// @brief copy assignment
94  ObserverCache & operator =( ObserverCache const & rval );
95 
96 
97 public: // methods
98 
99 
100  /// @brief clear all the observers
101  void clear();
102 
103 
104  /// @brief clear the observer in a selected slot
105  void clear( Size const slot );
106 
107 
108  /// @brief store a copy of the observer in the given slot and attach it to
109  /// the Pose
110  /// @param[in] The slot to use.
111  /// @param[in] observer The Observer to clone() and store.
112  /// @remarks this function exists to ensure the base class version is
113  /// overridden
114  void set(
115  Size const slot,
116  CacheableObserverOP observer
117  );
118 
119 
120  /// @brief store a copy of the observer in the given slot
121  /// @param[in] The slot to use.
122  /// @param[in] observer The Observer to clone() and store.
123  /// @param[in] auto_attach Attach the observer to the Pose?
124  void set(
125  Size const slot,
126  CacheableObserverOP observer,
127  bool const auto_attach
128  );
129 
130 
131 public: // observer interface
132 
133 
134  /// @brief is the observer in the slot attached to the Pose?
135  /// @return true if attached, false if not attached or no observer
136  /// exists in the slot
137  bool is_attached( Size const slot ) const;
138 
139 
140  /// @brief attach all stored observers to the Pose
141  void attach();
142 
143 
144  /// @brief detach all observers from the Pose
145  void detach();
146 
147 
148  /// @brief attach an observer in a particular slot to the Pose
149  /// @param[in] slot Attach the observer in this slot.
150  void attach( Size const slot );
151 
152 
153  /// @brief detach an observer in a particular slot to the Pose
154  /// @param[in] slot Detach the observer in this slot.
155  void detach( Size const slot );
156 
157 
158 private: // data
159 
160 
161  /// @brief The Pose being watched by the observers in this cache.
162  /// @remarks This must be a pointer and not an owning pointer in case
163  /// the Pose is on the stack.
165 
166 
167 };
168 
169 
170 } // namespace datacache
171 } // namespace pose
172 } // namespace core
173 
174 
175 #endif /* INCLUDED_core_pose_datacache_ObserverCache_HH */