Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

TS-2177: Add invoke utility method to APIHooks.

  • Loading branch information...
commit 6da47d5c43419d2d54429d9c777f5e40c774c41a 1 parent b71ca55
@SolidWallOfCode SolidWallOfCode authored
Showing with 17 additions and 0 deletions.
  1. +17 −0 proxy/InkAPIInternal.h
View
17 proxy/InkAPIInternal.h
@@ -143,6 +143,7 @@ class APIHooks
APIHook *get();
void clear();
bool is_empty() const;
+ void invoke(int event, void* data);
private:
Que(APIHook, m_link) m_hooks;
@@ -154,6 +155,12 @@ APIHooks::is_empty() const
return NULL == m_hooks.head;
}
+inline void
+APIHooks::invoke(int event, void* data) {
+ for ( APIHook* hook = m_hooks.head ; NULL != hook ; hook = hook->next())
+ hook->invoke(event, data);
+}
+
/** Container for API hooks for a specific feature.
This is an array of hook lists, each identified by a numeric identifier (id). Each array element is a list of all
@@ -184,6 +191,9 @@ class FeatureAPIHooks
/// @return @c true if @a id is a valid id, @c false otherwise.
static bool is_valid(ID id);
+ /// Invoke the callbacks for the hook @a id.
+ void invoke(ID id, int event, void* data);
+
/// Fast check for any hooks in this container.
///
/// @return @c true if any list has at least one hook, @c false if
@@ -246,6 +256,13 @@ FeatureAPIHooks<ID,N>::get(ID id)
}
template < typename ID, ID N >
+void
+FeatureAPIHooks<ID,N>::invoke(ID id, int event, void* data)
+{
+ m_hooks[id].invoke(event, data);
+}
+
+template < typename ID, ID N >
bool
FeatureAPIHooks<ID,N>::has_hooks() const
{
Please sign in to comment.
Something went wrong with that request. Please try again.