RootComponent.h Source File

Back to the index.

RootComponent.h
Go to the documentation of this file.
1 #ifndef ROOTCOMPONENT_H
2 #define ROOTCOMPONENT_H
3 
4 /*
5  * Copyright (C) 2009-2010 Anders Gavare. All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * 3. The name of the author may not be used to endorse or promote products
16  * derived from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  */
30 
31 /*
32  * Note: This is a special component, which cannot be created interactively
33  * by the user.
34  */
35 
36 #include "Component.h"
37 
38 #include "UnitTest.h"
39 
40 class GXemul;
41 
42 
43 /**
44  * \brief A Component which is the default root node in the configuration.
45  *
46  * This Component is mostly a dummy component, but it holds the 'step'
47  * count for the entire emulation (inherited from Component), and the following
48  * settings:
49  *
50  * <ul>
51  * <li>accuracy ("cycle" or "sloppy")
52  * </ul>
53  *
54  * NOTE: A RootComponent is not registered in the component registry, and
55  * can thus not be created interactively by the user at runtime.
56  */
58  : public Component
59  , public UnitTestable
60 {
61 public:
62  /**
63  * \brief Constructs a RootComponent.
64  */
65  RootComponent(GXemul* owner = NULL);
66 
68  {
69  return this;
70  }
71 
72  virtual bool PreRunCheckForComponent(GXemul* gxemul);
73 
75  {
76  return m_gxemul;
77  }
78 
79  void SetOwner(GXemul* owner);
80 
81 
82  /********************************************************************/
83 public:
84  static void RunUnitTests(int& nSucceeded, int& nFailures);
85 
86 protected:
87  virtual bool CheckVariableWrite(StateVariable& var, const string& oldValue);
88 
89 private:
90  // Pointer to owner (may be NULL):
91  GXemul* m_gxemul;
92 
93  // Model:
94  string m_accuracy;
95 };
96 
97 
98 #endif // ROOTCOMPONENT_H
RootComponent::PreRunCheckForComponent
virtual bool PreRunCheckForComponent(GXemul *gxemul)
Checks the state of this component, before starting execution.
Definition: RootComponent.cc:44
GXemul
The main emulator class.
Definition: GXemul.h:55
StateVariable
StateVariables make up the persistent state of Component objects.
Definition: StateVariable.h:69
RootComponent::CheckVariableWrite
virtual bool CheckVariableWrite(StateVariable &var, const string &oldValue)
Checks whether a write to a variable is OK.
Definition: RootComponent.cc:61
RootComponent::RootComponent
RootComponent(GXemul *owner=NULL)
Constructs a RootComponent.
Definition: RootComponent.cc:33
RootComponent::GetOwner
GXemul * GetOwner()
Definition: RootComponent.h:74
RootComponent::AsRootComponent
virtual RootComponent * AsRootComponent()
Returns the component's RootComponent interface.
Definition: RootComponent.h:67
UnitTest.h
Component.h
RootComponent::RunUnitTests
static void RunUnitTests(int &nSucceeded, int &nFailures)
RootComponent
A Component which is the default root node in the configuration.
Definition: RootComponent.h:60
Component
A Component is a node in the configuration tree that makes up an emulation setup.
Definition: Component.h:64
UnitTestable
Base class for unit testable classes.
Definition: UnitTest.h:75
RootComponent::SetOwner
void SetOwner(GXemul *owner)
Definition: RootComponent.cc:55

Generated on Tue Aug 25 2020 19:25:06 for GXemul by doxygen 1.8.18