BuildmLearn Toolkit  2.0.4
BuildmLearn Toolkit is an easy-to-use program that helps users make mobile apps without any knowledge of application development.
 All Classes Functions Enumerations Groups Pages
templatesimulator.h
1 /*
2  Copyright (c) 2012, BuildmLearn Contributors listed at http://buildmlearn.org/people/
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this
9  list of conditions and the following disclaimer.
10 
11  * Redistributions in binary form must reproduce the above copyright notice,
12  this list of conditions and the following disclaimer in the documentation
13  and/or other materials provided with the distribution.
14 
15  * Neither the name of the BuildmLearn nor the names of its
16  contributors may be used to endorse or promote products derived from
17  this software without specific prior written permission.
18 
19  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30 
31 #ifndef TEMPLATESIMULATOR_H
32 #define TEMPLATESIMULATOR_H
33 
34 #include <QWidget>
35 
36 
37 class TemplateCore;
38 
39 /// \brief Base widget which represents simulator of the template.
40 /// \ingroup template-interfaces
41 class TemplateSimulator : public QWidget {
42  Q_OBJECT
43 
44  public:
45  // Constructors and destructors.
46  explicit TemplateSimulator(TemplateCore *core, QWidget *parent = 0);
47  virtual ~TemplateSimulator();
48 
49  /// \brief Hint for default and fixed size for all
50  /// simulator contents.
51  QSize sizeHint() const;
52 
53  /// \brief Called when core with this simulator widget is fully loaded from XML
54  /// bundle or newly created.
55  virtual void launch();
56 
57  /// \brief Access to associated template core.
58  /// \return Returns associated template core.
59  /// \see TemplateCore
60  TemplateCore *core() const;
61 
62  public slots:
63  /// \brief (Re)starts the simulation.
64  /// \return Returns true if simulation was (re)started, false otherwise.
65  virtual bool startSimulation() = 0;
66 
67  /// \brief Stops simulation and resets its to initial state, all user
68  /// data from simulation are cleared.
69  /// \return Returns true if simulation was stopped, false otherwise.
70  virtual bool stopSimulation() = 0;
71 
72  /// \brief Gets simulation one step back.
73  /// \return Returns true if simulation was rolled one step back, false otherwise.
74  virtual bool goBack() = 0;
75 
76  signals:
77  /// \brief Emitted if "can go back" status of simulator changes.
78  /// \param can_go_back True if simulation can be rolled back one step, false otherwise.
79  /// \warning This signal MUST be emitted explicitly by simulator when its stopSimulator() slot
80  /// is called.
81  void canGoBackChanged(bool can_go_back);
82 
83  /// \brief Emitted if simulation is stopped from template itself.
85 
86  protected:
87  TemplateCore *m_core;
88 };
89 
90 #endif // TEMPLATESIMULATOR_H
virtual bool stopSimulation()=0
Stops simulation and resets its to initial state, all user data from simulation are cleared...
virtual bool goBack()=0
Gets simulation one step back.
void canGoBackChanged(bool can_go_back)
Emitted if "can go back" status of simulator changes.
TemplateCore * core() const
Access to associated template core.
void simulationStopRequested()
Emitted if simulation is stopped from template itself.
virtual void launch()
Called when core with this simulator widget is fully loaded from XML bundle or newly created...
QSize sizeHint() const
Hint for default and fixed size for all simulator contents.
The core class container for single template.
Definition: templatecore.h:43
virtual bool startSimulation()=0
(Re)starts the simulation.
Base widget which represents simulator of the template.