OpenASIP
2.2
Loading...
Searching...
No Matches
src
applibs
Simulator
StateLocator.cc
Go to the documentation of this file.
1
/*
2
Copyright (c) 2002-2009 Tampere University.
3
4
This file is part of TTA-Based Codesign Environment (TCE).
5
6
Permission is hereby granted, free of charge, to any person obtaining a
7
copy of this software and associated documentation files (the "Software"),
8
to deal in the Software without restriction, including without limitation
9
the rights to use, copy, modify, merge, publish, distribute, sublicense,
10
and/or sell copies of the Software, and to permit persons to whom the
11
Software is furnished to do so, subject to the following conditions:
12
13
The above copyright notice and this permission notice shall be included in
14
all copies or substantial portions of the Software.
15
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
DEALINGS IN THE SOFTWARE.
23
*/
24
/**
25
* @file StateLocator.cc
26
*
27
* Definition of StateLocator class.
28
*
29
* @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30
* @note rating: red
31
*/
32
33
#include <string>
34
35
#include "
StateLocator.hh
"
36
#include "
StateData.hh
"
37
#include "
MachinePart.hh
"
38
39
using
std::string;
40
using namespace
TTAMachine
;
41
42
/**
43
* Constructor.
44
*/
45
StateLocator::StateLocator
() {
46
}
47
48
/**
49
* Destructor.
50
*/
51
StateLocator::~StateLocator
() {
52
}
53
54
/**
55
* Adds state to to StateLocator.
56
*
57
* @param momComponent Machine object model component.
58
* @param state Machine state model state.
59
*/
60
void
61
StateLocator::addState
(
const
MachinePart
& momComponent,
StateData
& state) {
62
StateContainer::iterator iter =
states_
.find(&momComponent);
63
if
(iter !=
states_
.end()) {
64
(*iter).second = &
state
;
65
}
else
{
66
states_
[&momComponent] = &
state
;
67
}
68
}
69
70
/**
71
* Returns state corresponding to the given component.
72
*
73
* @param momComponent Component.
74
* @return State corresponding to given component.
75
* @exception IllegalParameters If state is not found.
76
*/
77
StateData
&
78
StateLocator::state
(
const
MachinePart
& momComponent)
const
{
79
StateContainer::const_iterator iter =
states_
.find(&momComponent);
80
if
(iter ==
states_
.end()) {
81
string
msg =
"State corresponding to component not found"
;
82
throw
IllegalParameters
(__FILE__, __LINE__,
__func__
, msg);
83
}
84
85
return
*((*iter).second);
86
}
__func__
#define __func__
Definition
Application.hh:67
MachinePart.hh
StateData.hh
StateLocator.hh
IllegalParameters
Definition
Exception.hh:113
StateData
Definition
StateData.hh:44
StateLocator::StateLocator
StateLocator()
Definition
StateLocator.cc:45
StateLocator::states_
StateContainer states_
Contains all the states indexed by MOM components.
Definition
StateLocator.hh:72
StateLocator::~StateLocator
virtual ~StateLocator()
Definition
StateLocator.cc:51
StateLocator::addState
void addState(const TTAMachine::MachinePart &momComponent, StateData &state)
Definition
StateLocator.cc:61
StateLocator::state
StateData & state(const TTAMachine::MachinePart &momComponent) const
Definition
StateLocator.cc:78
TTAMachine::MachinePart
Definition
MachinePart.hh:57
TTAMachine
Definition
Assembler.hh:48
Generated by
1.9.8