this hurts

Dependencies:   FFT

Committer:
shyamgatech
Date:
Thu Dec 03 18:15:35 2020 +0000
Revision:
7:0d62545e6d73
Parent:
0:d6c9b09b4042
addded gui mbed code;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
annieluo2 0:d6c9b09b4042 1 /* mbed Microcontroller Library
annieluo2 0:d6c9b09b4042 2 * Copyright (c) 2006-2015 ARM Limited
annieluo2 0:d6c9b09b4042 3 *
annieluo2 0:d6c9b09b4042 4 * Licensed under the Apache License, Version 2.0 (the "License");
annieluo2 0:d6c9b09b4042 5 * you may not use this file except in compliance with the License.
annieluo2 0:d6c9b09b4042 6 * You may obtain a copy of the License at
annieluo2 0:d6c9b09b4042 7 *
annieluo2 0:d6c9b09b4042 8 * http://www.apache.org/licenses/LICENSE-2.0
annieluo2 0:d6c9b09b4042 9 *
annieluo2 0:d6c9b09b4042 10 * Unless required by applicable law or agreed to in writing, software
annieluo2 0:d6c9b09b4042 11 * distributed under the License is distributed on an "AS IS" BASIS,
annieluo2 0:d6c9b09b4042 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
annieluo2 0:d6c9b09b4042 13 * See the License for the specific language governing permissions and
annieluo2 0:d6c9b09b4042 14 * limitations under the License.
annieluo2 0:d6c9b09b4042 15 */
annieluo2 0:d6c9b09b4042 16 #ifndef MBED_FUNCTIONPOINTER_H
annieluo2 0:d6c9b09b4042 17 #define MBED_FUNCTIONPOINTER_H
annieluo2 0:d6c9b09b4042 18
annieluo2 0:d6c9b09b4042 19 #include "platform/Callback.h"
annieluo2 0:d6c9b09b4042 20 #include "platform/toolchain.h"
annieluo2 0:d6c9b09b4042 21 #include <string.h>
annieluo2 0:d6c9b09b4042 22 #include <stdint.h>
annieluo2 0:d6c9b09b4042 23
annieluo2 0:d6c9b09b4042 24 namespace mbed {
annieluo2 0:d6c9b09b4042 25 /** \addtogroup platform */
annieluo2 0:d6c9b09b4042 26 /** @{*/
annieluo2 0:d6c9b09b4042 27
annieluo2 0:d6c9b09b4042 28
annieluo2 0:d6c9b09b4042 29 // Declarations for backwards compatibility
annieluo2 0:d6c9b09b4042 30 // To be foward compatible, code should adopt the Callback class
annieluo2 0:d6c9b09b4042 31 template <typename R, typename A1>
annieluo2 0:d6c9b09b4042 32 class FunctionPointerArg1 : public Callback<R(A1)> {
annieluo2 0:d6c9b09b4042 33 public:
annieluo2 0:d6c9b09b4042 34 MBED_DEPRECATED_SINCE("mbed-os-5.1",
annieluo2 0:d6c9b09b4042 35 "FunctionPointerArg1<R, A> has been replaced by Callback<R(A)>")
annieluo2 0:d6c9b09b4042 36 FunctionPointerArg1(R (*function)(A1) = 0)
annieluo2 0:d6c9b09b4042 37 : Callback<R(A1)>(function) {}
annieluo2 0:d6c9b09b4042 38
annieluo2 0:d6c9b09b4042 39 template<typename T>
annieluo2 0:d6c9b09b4042 40 MBED_DEPRECATED_SINCE("mbed-os-5.1",
annieluo2 0:d6c9b09b4042 41 "FunctionPointerArg1<R, A> has been replaced by Callback<R(A)>")
annieluo2 0:d6c9b09b4042 42 FunctionPointerArg1(T *object, R (T::*member)(A1))
annieluo2 0:d6c9b09b4042 43 : Callback<R(A1)>(object, member) {}
annieluo2 0:d6c9b09b4042 44
annieluo2 0:d6c9b09b4042 45 R (*get_function())(A1) {
annieluo2 0:d6c9b09b4042 46 return *reinterpret_cast<R (**)(A1)>(this);
annieluo2 0:d6c9b09b4042 47 }
annieluo2 0:d6c9b09b4042 48
annieluo2 0:d6c9b09b4042 49 R call(A1 a1) const {
annieluo2 0:d6c9b09b4042 50 if (!Callback<R(A1)>::operator bool()) {
annieluo2 0:d6c9b09b4042 51 return (R)0;
annieluo2 0:d6c9b09b4042 52 }
annieluo2 0:d6c9b09b4042 53
annieluo2 0:d6c9b09b4042 54 return Callback<R(A1)>::call(a1);
annieluo2 0:d6c9b09b4042 55 }
annieluo2 0:d6c9b09b4042 56
annieluo2 0:d6c9b09b4042 57 R operator()(A1 a1) const {
annieluo2 0:d6c9b09b4042 58 return Callback<R(A1)>::call(a1);
annieluo2 0:d6c9b09b4042 59 }
annieluo2 0:d6c9b09b4042 60 };
annieluo2 0:d6c9b09b4042 61
annieluo2 0:d6c9b09b4042 62 template <typename R>
annieluo2 0:d6c9b09b4042 63 class FunctionPointerArg1<R, void> : public Callback<R()> {
annieluo2 0:d6c9b09b4042 64 public:
annieluo2 0:d6c9b09b4042 65 MBED_DEPRECATED_SINCE("mbed-os-5.1",
annieluo2 0:d6c9b09b4042 66 "FunctionPointer has been replaced by Callback<void()>")
annieluo2 0:d6c9b09b4042 67 FunctionPointerArg1(R (*function)() = 0)
annieluo2 0:d6c9b09b4042 68 : Callback<R()>(function) {}
annieluo2 0:d6c9b09b4042 69
annieluo2 0:d6c9b09b4042 70 template<typename T>
annieluo2 0:d6c9b09b4042 71 MBED_DEPRECATED_SINCE("mbed-os-5.1",
annieluo2 0:d6c9b09b4042 72 "FunctionPointer has been replaced by Callback<void()>")
annieluo2 0:d6c9b09b4042 73 FunctionPointerArg1(T *object, R (T::*member)())
annieluo2 0:d6c9b09b4042 74 : Callback<R()>(object, member) {}
annieluo2 0:d6c9b09b4042 75
annieluo2 0:d6c9b09b4042 76 R (*get_function())() {
annieluo2 0:d6c9b09b4042 77 return *reinterpret_cast<R (**)()>(this);
annieluo2 0:d6c9b09b4042 78 }
annieluo2 0:d6c9b09b4042 79
annieluo2 0:d6c9b09b4042 80 R call() const {
annieluo2 0:d6c9b09b4042 81 if (!Callback<R()>::operator bool()) {
annieluo2 0:d6c9b09b4042 82 return (R)0;
annieluo2 0:d6c9b09b4042 83 }
annieluo2 0:d6c9b09b4042 84
annieluo2 0:d6c9b09b4042 85 return Callback<R()>::call();
annieluo2 0:d6c9b09b4042 86 }
annieluo2 0:d6c9b09b4042 87
annieluo2 0:d6c9b09b4042 88 R operator()() const {
annieluo2 0:d6c9b09b4042 89 return Callback<R()>::call();
annieluo2 0:d6c9b09b4042 90 }
annieluo2 0:d6c9b09b4042 91 };
annieluo2 0:d6c9b09b4042 92
annieluo2 0:d6c9b09b4042 93 typedef FunctionPointerArg1<void, void> FunctionPointer;
annieluo2 0:d6c9b09b4042 94
annieluo2 0:d6c9b09b4042 95
annieluo2 0:d6c9b09b4042 96 } // namespace mbed
annieluo2 0:d6c9b09b4042 97
annieluo2 0:d6c9b09b4042 98 #endif
annieluo2 0:d6c9b09b4042 99
annieluo2 0:d6c9b09b4042 100 /** @}*/