0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
HandleCallback.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
22 #ifndef Hyperspace_HandleCallback_h
23 #define Hyperspace_HandleCallback_h
24 
25 #include <memory>
26 #include <string>
27 
28 namespace Hyperspace {
29 
30  /*
31  * The following event masks are ORed together and
32  * passed in as the event_mask argument to Open()
33  * to indicate which events should be reported to
34  * the application for the opened handle.
35  */
36  enum {
44  };
45 
46  const char *event_mask_to_string(uint32_t mask);
47 
48  /*
49  * A callback object derived from this class gets passed
50  * into each Open() call. Node state changes get reported
51  * to the application via this callback. Internally, this
52  * object gets inspected to determine what events should be
53  * delivered back to the application.
54  */
56  public:
61  HandleCallback(uint32_t event_mask) : m_event_mask(event_mask) { return; }
62 
68  virtual void attr_set(const std::string &name) { return; }
69 
75  virtual void attr_del(const std::string &name) { return; }
76 
82  virtual void child_node_added(const std::string &name) { return; }
83 
89  virtual void child_node_removed(const std::string &name) { return; }
90 
96  virtual void lock_acquired(uint32_t mode) { return; }
97 
101  virtual void lock_released() { return; }
102 
107  int get_event_mask() { return m_event_mask; }
108 
109  protected:
110  uint32_t m_event_mask;
111  };
112 
113  typedef std::shared_ptr<HandleCallback> HandleCallbackPtr;
114 
115 } // namespace Hyperspace
116 
117 #endif // Hyperspace_HandleCallback_h
int get_event_mask()
Returns the event mask of this callback object.
virtual void child_node_added(const std::string &name)
Invoked when a child node gets added to the directory associated with the registered handle...
virtual void lock_acquired(uint32_t mode)
Invoked when a lock gets acquired on the file associated with the registered handle.
Hyperspace definitions
HandleCallback(uint32_t event_mask)
Constructor.
std::shared_ptr< HandleCallback > HandleCallbackPtr
virtual void lock_released()
Invoked when a lock gets released on the file associated with the registered handle.
virtual void child_node_removed(const std::string &name)
Invoked when an attribute gets deleted from the file associated with the registered handle...
virtual void attr_set(const std::string &name)
Invoked when an attribute gets set on the file associated with the registered handle.
const char * event_mask_to_string(uint32_t mask)
virtual void attr_del(const std::string &name)
Invoked when an attribute gets deleted from the file associated with the registered handle...