Sarah Marsh / Mbed OS EddystoneBeacon
Committer:
sarahmarshy
Date:
Tue Nov 29 06:29:10 2016 +0000
Revision:
0:1c7da5f83647
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sarahmarshy 0:1c7da5f83647 1 /*
sarahmarshy 0:1c7da5f83647 2 * Copyright (c) 2016, ARM Limited, All Rights Reserved
sarahmarshy 0:1c7da5f83647 3 * SPDX-License-Identifier: Apache-2.0
sarahmarshy 0:1c7da5f83647 4 *
sarahmarshy 0:1c7da5f83647 5 * Licensed under the Apache License, Version 2.0 (the "License"); you may
sarahmarshy 0:1c7da5f83647 6 * not use this file except in compliance with the License.
sarahmarshy 0:1c7da5f83647 7 * You may obtain a copy of the License at
sarahmarshy 0:1c7da5f83647 8 *
sarahmarshy 0:1c7da5f83647 9 * http://www.apache.org/licenses/LICENSE-2.0
sarahmarshy 0:1c7da5f83647 10 *
sarahmarshy 0:1c7da5f83647 11 * Unless required by applicable law or agreed to in writing, software
sarahmarshy 0:1c7da5f83647 12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
sarahmarshy 0:1c7da5f83647 13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
sarahmarshy 0:1c7da5f83647 14 * See the License for the specific language governing permissions and
sarahmarshy 0:1c7da5f83647 15 * limitations under the License.
sarahmarshy 0:1c7da5f83647 16 */
sarahmarshy 0:1c7da5f83647 17 #ifndef EVENTQUEUE_DETAIL_THUNKVTABLE_H_
sarahmarshy 0:1c7da5f83647 18 #define EVENTQUEUE_DETAIL_THUNKVTABLE_H_
sarahmarshy 0:1c7da5f83647 19
sarahmarshy 0:1c7da5f83647 20 namespace eq {
sarahmarshy 0:1c7da5f83647 21
sarahmarshy 0:1c7da5f83647 22 // forward declaration of the Thunk class
sarahmarshy 0:1c7da5f83647 23 class Thunk;
sarahmarshy 0:1c7da5f83647 24
sarahmarshy 0:1c7da5f83647 25 namespace detail {
sarahmarshy 0:1c7da5f83647 26
sarahmarshy 0:1c7da5f83647 27 /**
sarahmarshy 0:1c7da5f83647 28 * This POD is used as a vtable by Thunk implementation.
sarahmarshy 0:1c7da5f83647 29 * Thunk is a value type for all type nullary callable and therefore standard
sarahmarshy 0:1c7da5f83647 30 * polymorphism is not suitable for that use case.
sarahmarshy 0:1c7da5f83647 31 * Instead, the vtable is generated for each type contained in a thunk.
sarahmarshy 0:1c7da5f83647 32 * This structure is the prototype of such vtable.
sarahmarshy 0:1c7da5f83647 33 * \note see ThunkVTableGenerator for implementation and the generation of
sarahmarshy 0:1c7da5f83647 34 * Thunk vtables.
sarahmarshy 0:1c7da5f83647 35 */
sarahmarshy 0:1c7da5f83647 36 struct ThunkVTable {
sarahmarshy 0:1c7da5f83647 37 typedef Thunk thunk_t;
sarahmarshy 0:1c7da5f83647 38
sarahmarshy 0:1c7da5f83647 39 /**
sarahmarshy 0:1c7da5f83647 40 * destroy a thunk (act like a destructor).
sarahmarshy 0:1c7da5f83647 41 */
sarahmarshy 0:1c7da5f83647 42 void (* const destroy)(thunk_t& self);
sarahmarshy 0:1c7da5f83647 43
sarahmarshy 0:1c7da5f83647 44 /**
sarahmarshy 0:1c7da5f83647 45 * Copy self into dest.
sarahmarshy 0:1c7da5f83647 46 * It is expected that dest is empty.
sarahmarshy 0:1c7da5f83647 47 */
sarahmarshy 0:1c7da5f83647 48 void (* const copy)(thunk_t& dest, const thunk_t& self);
sarahmarshy 0:1c7da5f83647 49
sarahmarshy 0:1c7da5f83647 50 /**
sarahmarshy 0:1c7da5f83647 51 * Synthetized call for the inner object of the thunk_t.
sarahmarshy 0:1c7da5f83647 52 */
sarahmarshy 0:1c7da5f83647 53 void (* const call)(const thunk_t& self);
sarahmarshy 0:1c7da5f83647 54 };
sarahmarshy 0:1c7da5f83647 55
sarahmarshy 0:1c7da5f83647 56 } // namespace detail
sarahmarshy 0:1c7da5f83647 57 } // namespace eq
sarahmarshy 0:1c7da5f83647 58
sarahmarshy 0:1c7da5f83647 59 #endif /* EVENTQUEUE_DETAIL_THUNKVTABLE_H_ */