|
QP/C++
|
00001 00002 // Product: QP/C++ 00003 // Last Updated for Version: 4.5.04 00004 // Date of the Last Update: Jan 16, 2013 00005 // 00006 // Q u a n t u m L e a P s 00007 // --------------------------- 00008 // innovating embedded systems 00009 // 00010 // Copyright (C) 2002-2013 Quantum Leaps, LLC. All rights reserved. 00011 // 00012 // This program is open source software: you can redistribute it and/or 00013 // modify it under the terms of the GNU General Public License as published 00014 // by the Free Software Foundation, either version 2 of the License, or 00015 // (at your option) any later version. 00016 // 00017 // Alternatively, this program may be distributed and modified under the 00018 // terms of Quantum Leaps commercial licenses, which expressly supersede 00019 // the GNU General Public License and are specifically designed for 00020 // licensees interested in retaining the proprietary status of their code. 00021 // 00022 // This program is distributed in the hope that it will be useful, 00023 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00024 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00025 // GNU General Public License for more details. 00026 // 00027 // You should have received a copy of the GNU General Public License 00028 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00029 // 00030 // Contact information: 00031 // Quantum Leaps Web sites: http://www.quantum-leaps.com 00032 // http://www.state-machine.com 00033 // e-mail: info@quantum-leaps.com 00035 #ifndef qevt_h 00036 #define qevt_h 00037 00044 00051 #define QP_VERSION 0x4503U 00052 00053 #ifndef Q_ROM 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 #define Q_ROM 00067 #endif 00068 #ifndef Q_ROM_VAR // if NOT defined, provide the default definition 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 #define Q_ROM_VAR 00083 #endif 00084 #ifndef Q_ROM_BYTE 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 #define Q_ROM_BYTE(rom_var_) (rom_var_) 00099 #endif 00100 00101 #ifndef Q_SIGNAL_SIZE 00102 00103 00104 00105 00106 00107 00108 #define Q_SIGNAL_SIZE 2 00109 #endif 00110 00111 #ifndef Q_NNAMESPACE 00112 00116 #define QP_BEGIN_ namespace QP { 00117 00121 #define QP_END_ } 00122 00126 #define QP_ QP:: 00127 00128 #else 00129 00130 #define QP_BEGIN_ 00131 #define QP_END_ 00132 #define QP_ 00133 00134 #endif 00135 00136 QP_BEGIN_ 00137 00138 #if (Q_SIGNAL_SIZE == 1) 00139 typedef uint8_t QSignal; 00140 #elif (Q_SIGNAL_SIZE == 2) 00141 00142 00143 00144 00145 00146 00147 00148 00149 00150 typedef uint16_t QSignal; 00151 #elif (Q_SIGNAL_SIZE == 4) 00152 typedef uint32_t QSignal; 00153 #else 00154 #error "Q_SIGNAL_SIZE defined incorrectly, expected 1, 2, or 4" 00155 #endif 00156 00157 #ifdef Q_EVT_CTOR // Provide the constructor for the QEvt class? 00158 00168 class QEvt { 00169 public: 00170 QSignal sig; 00171 00172 QEvt(QSignal const s) // poolId_ intentionally uninitialized 00173 : sig(s) {} 00174 00175 #ifdef Q_EVT_VIRTUAL 00176 virtual ~QEvt() {} // virtual destructor 00177 #endif 00178 00179 private: 00180 uint8_t poolId_; 00181 uint8_t refCtr_; 00182 00183 friend class QF; 00184 friend class QTimeEvt; 00185 friend uint8_t QF_EVT_POOL_ID_ (QEvt const * const e); 00186 friend uint8_t QF_EVT_REF_CTR_ (QEvt const * const e); 00187 friend void QF_EVT_REF_CTR_INC_(QEvt const * const e); 00188 friend void QF_EVT_REF_CTR_DEC_(QEvt const * const e); 00189 }; 00190 00191 #else // QEvt is a POD (Plain Old Datatype) 00192 00193 struct QEvt { 00194 QSignal sig; 00195 uint8_t poolId_; 00196 uint8_t refCtr_; 00197 }; 00198 00199 #endif // Q_EVT_CTOR 00200 00201 QP_END_ 00202 00205 #define Q_DIM(array_) (sizeof(array_) / sizeof(array_[0])) 00206 00208 // typedefs for basic numerical types; MISRA-C++ 2008 rule 3-9-2(req). 00209 00216 typedef char char_t; 00217 00219 typedef float float32_t; 00220 00222 typedef double float64_t; 00223 00225 typedef int enum_t; 00226 00235 #define Q_UINT2PTR_CAST(type_, uint_) (reinterpret_cast<type_ *>(uint_)) 00236 00242 #define QEVT_INITIALIZER(sig_) { static_cast<QP_ QSignal>(sig_), \ 00243 static_cast<uint8_t>(0), static_cast<uint8_t>(0) } 00244 00246 // facilities for backwards compatibility 00247 // 00248 #ifndef Q_NQEVENT 00249 // typedef struct QEvt QEvent; 00250 #define QEvent QEvt 00251 #endif 00252 00253 #endif // qevt_h
1.7.6.1