Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: nRF51_Vdd TextLCD BME280
FunctionPointer.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2015 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #ifndef MBED_FUNCTIONPOINTER_H 00017 #define MBED_FUNCTIONPOINTER_H 00018 00019 #include "platform/Callback.h" 00020 #include "platform/mbed_toolchain.h" 00021 #include <string.h> 00022 #include <stdint.h> 00023 00024 namespace mbed { 00025 /** \addtogroup platform */ 00026 /** @{*/ 00027 /** 00028 * \defgroup platform_FunctionPointer FunctionPointer class 00029 * @{ 00030 */ 00031 00032 // Declarations for backwards compatibility 00033 // To be foward compatible, code should adopt the Callback class 00034 template <typename R, typename A1> 00035 class FunctionPointerArg1 : public Callback<R(A1)> { 00036 public: 00037 MBED_DEPRECATED_SINCE("mbed-os-5.1", 00038 "FunctionPointerArg1<R, A> has been replaced by Callback<R(A)>") 00039 FunctionPointerArg1(R(*function)(A1) = 0) 00040 : Callback<R(A1)>(function) {} 00041 00042 template<typename T> 00043 MBED_DEPRECATED_SINCE("mbed-os-5.1", 00044 "FunctionPointerArg1<R, A> has been replaced by Callback<R(A)>") 00045 FunctionPointerArg1(T *object, R(T::*member)(A1)) 00046 : Callback<R(A1)>(object, member) {} 00047 00048 R(*get_function())(A1) 00049 { 00050 return *reinterpret_cast<R(* *)(A1)>(this); 00051 } 00052 00053 R call(A1 a1) const 00054 { 00055 if (!Callback<R(A1)>::operator bool()) { 00056 return (R)0; 00057 } 00058 00059 return Callback<R(A1)>::call(a1); 00060 } 00061 00062 R operator()(A1 a1) const 00063 { 00064 return Callback<R(A1)>::call(a1); 00065 } 00066 }; 00067 00068 template <typename R> 00069 class FunctionPointerArg1<R, void> : public Callback<R()> { 00070 public: 00071 MBED_DEPRECATED_SINCE("mbed-os-5.1", 00072 "FunctionPointer has been replaced by Callback<void()>") 00073 FunctionPointerArg1(R(*function)() = 0) 00074 : Callback<R()>(function) {} 00075 00076 template<typename T> 00077 MBED_DEPRECATED_SINCE("mbed-os-5.1", 00078 "FunctionPointer has been replaced by Callback<void()>") 00079 FunctionPointerArg1(T *object, R(T::*member)()) 00080 : Callback<R()>(object, member) {} 00081 00082 R(*get_function())() 00083 { 00084 return *reinterpret_cast<R(* *)()>(this); 00085 } 00086 00087 R call() const 00088 { 00089 if (!Callback<R()>::operator bool()) { 00090 return (R)0; 00091 } 00092 00093 return Callback<R()>::call(); 00094 } 00095 00096 R operator()() const 00097 { 00098 return Callback<R()>::call(); 00099 } 00100 }; 00101 00102 typedef FunctionPointerArg1<void, void> FunctionPointer; 00103 00104 /**@}*/ 00105 00106 /**@}*/ 00107 00108 00109 } // namespace mbed 00110 00111 #endif
Generated on Tue Jul 12 2022 15:15:45 by
