Roy Want / Mbed OS beaconCompileReadyFork
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ThunkVTable.h Source File

ThunkVTable.h

00001 /*
00002  * Copyright (c) 2016, ARM Limited, All Rights Reserved
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License"); you may
00006  * not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  * http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00013  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 #ifndef EVENTQUEUE_DETAIL_THUNKVTABLE_H_
00018 #define EVENTQUEUE_DETAIL_THUNKVTABLE_H_
00019 
00020 namespace eq {
00021 
00022 // forward declaration of the Thunk class
00023 class Thunk;
00024 
00025 namespace detail {
00026 
00027 /**
00028  * This POD is used as a vtable by Thunk implementation.
00029  * Thunk is a value type for all type nullary callable and therefore standard
00030  * polymorphism is not suitable for that use case.
00031  * Instead, the vtable is generated for each type contained in a thunk.
00032  * This structure is the prototype of such vtable.
00033  * \note see ThunkVTableGenerator for implementation and the generation of
00034  * Thunk vtables.
00035  */
00036 struct ThunkVTable {
00037     typedef Thunk thunk_t;
00038 
00039     /**
00040      * destroy a thunk (act like a destructor).
00041      */
00042     void (* const destroy)(thunk_t& self);
00043 
00044     /**
00045      * Copy self into dest.
00046      * It is expected that dest is empty.
00047      */
00048     void (* const copy)(thunk_t& dest, const thunk_t& self);
00049 
00050     /**
00051      * Synthetized call for the inner object of the thunk_t.
00052      */
00053     void (* const call)(const thunk_t& self);
00054 };
00055 
00056 } // namespace detail
00057 } // namespace eq
00058 
00059 #endif /* EVENTQUEUE_DETAIL_THUNKVTABLE_H_ */