Dining Philosophers Problem (DPP) example for the QP active object framework. Demonstrates: event-driven programming, hierarchical state machines in C++, modeling and graphical state machine design, code generation, preemptive multitasking, software tracing, power saving mode, direct event posting, publish-subscribe. More information available in the [[/users/QL/notebook|Quantum Leaps Notebook pages]]. See also [[http://www.state-machine.com|state-machine.com]].
Diff: dpp.h
- Revision:
- 4:6189d844a1a2
- Parent:
- 0:efb9ac8d1a88
diff -r 81ceb3127876 -r 6189d844a1a2 dpp.h --- a/dpp.h Mon Sep 26 02:21:01 2011 +0000 +++ b/dpp.h Tue Sep 04 22:41:20 2012 +0000 @@ -1,50 +1,40 @@ ////////////////////////////////////////////////////////////////////////////// -// Product: DPP example -// Last Updated for Version: 4.0.00 -// Date of the Last Update: Apr 07, 2008 -// -// Q u a n t u m L e a P s -// --------------------------- -// innovating embedded systems -// -// Copyright (C) 2002-2008 Quantum Leaps, LLC. All rights reserved. +// Model: dpp.qm +// File: ././dpp.h // -// This software may be distributed and modified under the terms of the GNU -// General Public License version 2 (GPL) as published by the Free Software -// Foundation and appearing in the file GPL.TXT included in the packaging of -// this file. Please note that GPL Section 2[b] requires that all works based -// on this software must also be made publicly available under the terms of -// the GPL ("Copyleft"). +// This file has been generated automatically by QP Modeler (QM). +// DO NOT EDIT THIS FILE MANUALLY. // -// Alternatively, this software may be distributed and modified under the -// terms of Quantum Leaps commercial licenses, which expressly supersede -// the GPL and are specifically designed for licensees interested in -// retaining the proprietary status of their code. -// -// Contact information: -// Quantum Leaps Web site: http://www.quantum-leaps.com -// e-mail: info@quantum-leaps.com +// Please visit www.state-machine.com/qm for more information. ////////////////////////////////////////////////////////////////////////////// #ifndef dpp_h #define dpp_h +namespace DPP { + enum DPPSignals { - EAT_SIG = Q_USER_SIG, // published by Table to let a philosopher eat - DONE_SIG, // published by Philosopher when done eating - TERMINATE_SIG, // published by BSP to terminate the application - MAX_PUB_SIG, // the last published signal + EAT_SIG = QP::Q_USER_SIG, // published by Table to let a philosopher eat + DONE_SIG, // published by Philosopher when done eating + PAUSE_SIG, // published by BSP to pause the application + TERMINATE_SIG, // published by BSP to terminate the application + MAX_PUB_SIG, // the last published signal - HUNGRY_SIG, // posted from hungry Philosopher to Table - MAX_SIG // the last signal + HUNGRY_SIG, // posted direclty to Table from hungry Philo + MAX_SIG // the last signal }; -struct TableEvt : public QEvent { - uint8_t philoNum; // philosopher number +// @(/1/0) ................................................................... +class TableEvt : public QP::QEvt { +public: + uint8_t philoNum; }; -enum { N_PHILO = 5 }; // number of philosophers +// number of philosophers +#define N_PHILO ((uint8_t)5) -extern QActive * const AO_Philo[N_PHILO]; // "opaque" pointers to Philo AO -extern QActive * const AO_Table; // "opaque" pointer to Table AO +extern QP::QActive * const AO_Philo[N_PHILO]; +extern QP::QActive * const AO_Table; -#endif // dpp_h +} // namespace DPP + +#endif // dpp_h