prova invio BLE

Dependents:   BLE_HeartRate_IDB04A1

Fork of BLE_API by Bluetooth Low Energy

Revision:
953:f6eb43f524b2
Parent:
952:8a6c287de1be
Child:
961:259acb1c9d04
diff -r 8a6c287de1be -r f6eb43f524b2 ble/CallChainOfFunctionPointersWithContext.h
--- a/ble/CallChainOfFunctionPointersWithContext.h	Thu Nov 26 12:52:33 2015 +0000
+++ b/ble/CallChainOfFunctionPointersWithContext.h	Thu Nov 26 12:52:33 2015 +0000
@@ -97,6 +97,14 @@
         return common_add(new FunctionPointerWithContext<ContextType>(tptr, mptr));
     }
 
+    /** Add a function at the front of the chain.
+     *
+     *  @param func The FunctionPointerWithContext to add.
+     */
+    void add(const FunctionPointerWithContext<ContextType>& func) {
+        common_add(new FunctionPointerWithContext<ContextType>(func));
+    }
+
     /** 
      * Detach a function pointer from a callchain
      * 
@@ -153,6 +161,29 @@
         }
     }
 
+    /**
+     * @brief same as above but const 
+     */
+    void call(ContextType context) const {
+        if (chainHead) {
+            chainHead->call(context);
+        }
+    }
+
+    /**
+     * @brief same as above but with function call operator
+     */
+    void operator()(ContextType context) const {
+        call(context);
+    }
+
+    typedef void (CallChainOfFunctionPointersWithContext::*bool_type)() const;
+    void True() const {}
+
+    operator bool_type() const {
+        return chainHead == NULL ? 0 : &CallChainOfFunctionPointersWithContext::True;
+    }
+
 private:
     pFunctionPointerWithContext_t common_add(pFunctionPointerWithContext_t pf) {
         if (chainHead == NULL) {