OpenASIP 2.2
Loading...
Searching...
No Matches
Unit.hh
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 Unit.hh
26 *
27 * Declaration of Unit class.
28 *
29 * @author Lasse Laasonen 2003 (lasse.laasonen-no.spam-tut.fi)
30 * @note rating: red
31 * @note reviewed 22 Jun 2004 by ao, ml, vpj, ll
32 */
33
34#ifndef TTA_UNIT_HH
35#define TTA_UNIT_HH
36
37#include <string>
38#include <vector>
39#include <set>
40
41#include "MachinePart.hh"
42#include "Exception.hh"
43
44namespace TTAMachine {
45
46class Port;
47
48/**
49 * An Abstract base class for the different units in the machine.
50 */
51class Unit : public Component {
52public:
53 virtual ~Unit();
54
55 virtual bool hasPort(const std::string& name) const;
56 virtual Port* port(const std::string& name) const;
57 virtual Port* port(int index) const;
58 virtual int portCount() const;
59 virtual int outputPortCount(bool countBidir = false) const;
60 virtual int inputPortCount(bool countBidir = false) const;
61 virtual int bidirPortCount() const;
62
63 virtual void setMachine(Machine& mach);
64 virtual void unsetMachine();
65
66 virtual ObjectState* saveState() const;
67 virtual void loadState(const ObjectState* state);
68
69 /// ObjectState name for Unit.
70 static const std::string OSNAME_UNIT;
71
72protected:
73 Unit(const std::string& name);
74 Unit(const ObjectState* state);
75
76 virtual void removePort(Port& port);
77
78private:
79 /// Container for ports.
80 typedef std::vector<Port*> PortTable;
81 /// Set type for strings.
82 typedef std::set<std::string> NameSet;
83
84 /// Copying forbidden.
85 Unit(const Unit&);
86 /// Assingment forbidden.
88
89 void addPort(Port& port);
90 void deleteAllPorts();
91 void deleteOtherPorts(const NameSet& portsToLeave);
92 static NameSet portNames(const ObjectState* state);
93 void loadStateWithoutReferences(const ObjectState* state);
94
95 /// Contains all the ports of the unit.
97
98 // Port is a friend class to be able add and remove itself from the unit
99 friend class Port;
100};
101}
102
103#endif
virtual TCEString name() const
virtual void unsetMachine()
Definition Unit.cc:262
virtual bool hasPort(const std::string &name) const
Definition Unit.cc:96
void loadStateWithoutReferences(const ObjectState *state)
Definition Unit.cc:334
PortTable ports_
Contains all the ports of the unit.
Definition Unit.hh:96
void addPort(Port &port)
Definition Unit.cc:213
void deleteAllPorts()
Definition Unit.cc:373
virtual ~Unit()
Definition Unit.cc:84
virtual int portCount() const
Definition Unit.cc:135
std::set< std::string > NameSet
Set type for strings.
Definition Unit.hh:82
virtual void setMachine(Machine &mach)
Definition Unit.cc:253
virtual Port * port(const std::string &name) const
Definition Unit.cc:116
static NameSet portNames(const ObjectState *state)
Definition Unit.cc:409
std::vector< Port * > PortTable
Container for ports.
Definition Unit.hh:80
Unit(const Unit &)
Copying forbidden.
virtual int bidirPortCount() const
Definition Unit.cc:174
virtual int inputPortCount(bool countBidir=false) const
Definition Unit.cc:160
virtual void loadState(const ObjectState *state)
Definition Unit.cc:309
virtual ObjectState * saveState() const
Definition Unit.cc:285
Unit & operator=(const Unit &)
Assingment forbidden.
static const std::string OSNAME_UNIT
ObjectState name for Unit.
Definition Unit.hh:70
virtual int outputPortCount(bool countBidir=false) const
Definition Unit.cc:145
virtual void removePort(Port &port)
Definition Unit.cc:235
void deleteOtherPorts(const NameSet &portsToLeave)
Definition Unit.cc:389