Opencv 3.1 project on GR-PEACH board

Fork of gr-peach-opencv-project by the do

Committer:
thedo
Date:
Tue Jul 04 06:23:13 2017 +0000
Revision:
170:54ff26da7eb6
Parent:
167:1657b442184c
project opencv 3.1 on GR PEACH board, no use SD card.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thedo 167:1657b442184c 1 /* mbed Microcontroller Library
thedo 167:1657b442184c 2 * Copyright (c) 2006-2013 ARM Limited
thedo 167:1657b442184c 3 *
thedo 167:1657b442184c 4 * Licensed under the Apache License, Version 2.0 (the "License");
thedo 167:1657b442184c 5 * you may not use this file except in compliance with the License.
thedo 167:1657b442184c 6 * You may obtain a copy of the License at
thedo 167:1657b442184c 7 *
thedo 167:1657b442184c 8 * http://www.apache.org/licenses/LICENSE-2.0
thedo 167:1657b442184c 9 *
thedo 167:1657b442184c 10 * Unless required by applicable law or agreed to in writing, software
thedo 167:1657b442184c 11 * distributed under the License is distributed on an "AS IS" BASIS,
thedo 167:1657b442184c 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
thedo 167:1657b442184c 13 * See the License for the specific language governing permissions and
thedo 167:1657b442184c 14 * limitations under the License.
thedo 167:1657b442184c 15 */
thedo 167:1657b442184c 16 #ifndef MBED_CALLCHAIN_H
thedo 167:1657b442184c 17 #define MBED_CALLCHAIN_H
thedo 167:1657b442184c 18
thedo 167:1657b442184c 19 #include "platform/Callback.h"
thedo 167:1657b442184c 20 #include "platform/mbed_toolchain.h"
thedo 167:1657b442184c 21 #include <string.h>
thedo 167:1657b442184c 22
thedo 167:1657b442184c 23 namespace mbed {
thedo 167:1657b442184c 24 /** \addtogroup platform */
thedo 167:1657b442184c 25
thedo 167:1657b442184c 26 /** Group one or more functions in an instance of a CallChain, then call them in
thedo 167:1657b442184c 27 * sequence using CallChain::call(). Used mostly by the interrupt chaining code,
thedo 167:1657b442184c 28 * but can be used for other purposes.
thedo 167:1657b442184c 29 *
thedo 167:1657b442184c 30 * @note Synchronization level: Not protected
thedo 167:1657b442184c 31 *
thedo 167:1657b442184c 32 * Example:
thedo 167:1657b442184c 33 * @code
thedo 167:1657b442184c 34 * #include "mbed.h"
thedo 167:1657b442184c 35 *
thedo 167:1657b442184c 36 * CallChain chain;
thedo 167:1657b442184c 37 *
thedo 167:1657b442184c 38 * void first(void) {
thedo 167:1657b442184c 39 * printf("'first' function.\n");
thedo 167:1657b442184c 40 * }
thedo 167:1657b442184c 41 *
thedo 167:1657b442184c 42 * void second(void) {
thedo 167:1657b442184c 43 * printf("'second' function.\n");
thedo 167:1657b442184c 44 * }
thedo 167:1657b442184c 45 *
thedo 167:1657b442184c 46 * class Test {
thedo 167:1657b442184c 47 * public:
thedo 167:1657b442184c 48 * void f(void) {
thedo 167:1657b442184c 49 * printf("A::f (class member).\n");
thedo 167:1657b442184c 50 * }
thedo 167:1657b442184c 51 * };
thedo 167:1657b442184c 52 *
thedo 167:1657b442184c 53 * int main() {
thedo 167:1657b442184c 54 * Test test;
thedo 167:1657b442184c 55 *
thedo 167:1657b442184c 56 * chain.add(second);
thedo 167:1657b442184c 57 * chain.add_front(first);
thedo 167:1657b442184c 58 * chain.add(&test, &Test::f);
thedo 167:1657b442184c 59 * chain.call();
thedo 167:1657b442184c 60 * }
thedo 167:1657b442184c 61 * @endcode
thedo 167:1657b442184c 62 * @ingroup platform
thedo 167:1657b442184c 63 */
thedo 167:1657b442184c 64
thedo 167:1657b442184c 65 typedef Callback<void()> *pFunctionPointer_t;
thedo 167:1657b442184c 66 class CallChainLink;
thedo 167:1657b442184c 67
thedo 167:1657b442184c 68 class CallChain {
thedo 167:1657b442184c 69 public:
thedo 167:1657b442184c 70 /** Create an empty chain
thedo 167:1657b442184c 71 *
thedo 167:1657b442184c 72 * @param size (optional) Initial size of the chain
thedo 167:1657b442184c 73 */
thedo 167:1657b442184c 74 CallChain(int size = 4);
thedo 167:1657b442184c 75 virtual ~CallChain();
thedo 167:1657b442184c 76
thedo 167:1657b442184c 77 /** Add a function at the end of the chain
thedo 167:1657b442184c 78 *
thedo 167:1657b442184c 79 * @param func A pointer to a void function
thedo 167:1657b442184c 80 *
thedo 167:1657b442184c 81 * @returns
thedo 167:1657b442184c 82 * The function object created for 'func'
thedo 167:1657b442184c 83 */
thedo 167:1657b442184c 84 pFunctionPointer_t add(Callback<void()> func);
thedo 167:1657b442184c 85
thedo 167:1657b442184c 86 /** Add a function at the end of the chain
thedo 167:1657b442184c 87 *
thedo 167:1657b442184c 88 * @param obj pointer to the object to call the member function on
thedo 167:1657b442184c 89 * @param method pointer to the member function to be called
thedo 167:1657b442184c 90 *
thedo 167:1657b442184c 91 * @returns
thedo 167:1657b442184c 92 * The function object created for 'obj' and 'method'
thedo 167:1657b442184c 93 *
thedo 167:1657b442184c 94 * @deprecated
thedo 167:1657b442184c 95 * The add function does not support cv-qualifiers. Replaced by
thedo 167:1657b442184c 96 * add(callback(obj, method)).
thedo 167:1657b442184c 97 */
thedo 167:1657b442184c 98 template<typename T, typename M>
thedo 167:1657b442184c 99 MBED_DEPRECATED_SINCE("mbed-os-5.1",
thedo 167:1657b442184c 100 "The add function does not support cv-qualifiers. Replaced by "
thedo 167:1657b442184c 101 "add(callback(obj, method)).")
thedo 167:1657b442184c 102 pFunctionPointer_t add(T *obj, M method) {
thedo 167:1657b442184c 103 return add(callback(obj, method));
thedo 167:1657b442184c 104 }
thedo 167:1657b442184c 105
thedo 167:1657b442184c 106 /** Add a function at the beginning of the chain
thedo 167:1657b442184c 107 *
thedo 167:1657b442184c 108 * @param func A pointer to a void function
thedo 167:1657b442184c 109 *
thedo 167:1657b442184c 110 * @returns
thedo 167:1657b442184c 111 * The function object created for 'func'
thedo 167:1657b442184c 112 */
thedo 167:1657b442184c 113 pFunctionPointer_t add_front(Callback<void()> func);
thedo 167:1657b442184c 114
thedo 167:1657b442184c 115 /** Add a function at the beginning of the chain
thedo 167:1657b442184c 116 *
thedo 167:1657b442184c 117 * @param obj pointer to the object to call the member function on
thedo 167:1657b442184c 118 * @param method pointer to the member function to be called
thedo 167:1657b442184c 119 *
thedo 167:1657b442184c 120 * @returns
thedo 167:1657b442184c 121 * The function object created for 'tptr' and 'mptr'
thedo 167:1657b442184c 122 *
thedo 167:1657b442184c 123 * @deprecated
thedo 167:1657b442184c 124 * The add_front function does not support cv-qualifiers. Replaced by
thedo 167:1657b442184c 125 * add_front(callback(obj, method)).
thedo 167:1657b442184c 126 */
thedo 167:1657b442184c 127 template<typename T, typename M>
thedo 167:1657b442184c 128 MBED_DEPRECATED_SINCE("mbed-os-5.1",
thedo 167:1657b442184c 129 "The add_front function does not support cv-qualifiers. Replaced by "
thedo 167:1657b442184c 130 "add_front(callback(obj, method)).")
thedo 167:1657b442184c 131 pFunctionPointer_t add_front(T *obj, M method) {
thedo 167:1657b442184c 132 return add_front(callback(obj, method));
thedo 167:1657b442184c 133 }
thedo 167:1657b442184c 134
thedo 167:1657b442184c 135 /** Get the number of functions in the chain
thedo 167:1657b442184c 136 */
thedo 167:1657b442184c 137 int size() const;
thedo 167:1657b442184c 138
thedo 167:1657b442184c 139 /** Get a function object from the chain
thedo 167:1657b442184c 140 *
thedo 167:1657b442184c 141 * @param i function object index
thedo 167:1657b442184c 142 *
thedo 167:1657b442184c 143 * @returns
thedo 167:1657b442184c 144 * The function object at position 'i' in the chain
thedo 167:1657b442184c 145 */
thedo 167:1657b442184c 146 pFunctionPointer_t get(int i) const;
thedo 167:1657b442184c 147
thedo 167:1657b442184c 148 /** Look for a function object in the call chain
thedo 167:1657b442184c 149 *
thedo 167:1657b442184c 150 * @param f the function object to search
thedo 167:1657b442184c 151 *
thedo 167:1657b442184c 152 * @returns
thedo 167:1657b442184c 153 * The index of the function object if found, -1 otherwise.
thedo 167:1657b442184c 154 */
thedo 167:1657b442184c 155 int find(pFunctionPointer_t f) const;
thedo 167:1657b442184c 156
thedo 167:1657b442184c 157 /** Clear the call chain (remove all functions in the chain).
thedo 167:1657b442184c 158 */
thedo 167:1657b442184c 159 void clear();
thedo 167:1657b442184c 160
thedo 167:1657b442184c 161 /** Remove a function object from the chain
thedo 167:1657b442184c 162 *
thedo 167:1657b442184c 163 * @arg f the function object to remove
thedo 167:1657b442184c 164 *
thedo 167:1657b442184c 165 * @returns
thedo 167:1657b442184c 166 * true if the function object was found and removed, false otherwise.
thedo 167:1657b442184c 167 */
thedo 167:1657b442184c 168 bool remove(pFunctionPointer_t f);
thedo 167:1657b442184c 169
thedo 167:1657b442184c 170 /** Call all the functions in the chain in sequence
thedo 167:1657b442184c 171 */
thedo 167:1657b442184c 172 void call();
thedo 167:1657b442184c 173
thedo 167:1657b442184c 174 void operator ()(void) {
thedo 167:1657b442184c 175 call();
thedo 167:1657b442184c 176 }
thedo 167:1657b442184c 177 pFunctionPointer_t operator [](int i) const {
thedo 167:1657b442184c 178 return get(i);
thedo 167:1657b442184c 179 }
thedo 167:1657b442184c 180
thedo 167:1657b442184c 181 /* disallow copy constructor and assignment operators */
thedo 167:1657b442184c 182 private:
thedo 167:1657b442184c 183 CallChain(const CallChain&);
thedo 167:1657b442184c 184 CallChain & operator = (const CallChain&);
thedo 167:1657b442184c 185 CallChainLink *_chain;
thedo 167:1657b442184c 186 };
thedo 167:1657b442184c 187
thedo 167:1657b442184c 188 } // namespace mbed
thedo 167:1657b442184c 189
thedo 167:1657b442184c 190 #endif
thedo 167:1657b442184c 191
thedo 167:1657b442184c 192