OpenASIP  2.0
Segment.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 Segment.hh
26  *
27  * Declaration of Segment class.
28  *
29  * @author Lasse Laasonen 2003 (lasse.laasonen-no.spam-tut.fi)
30  * @note reviewed 14 Jun 2004 by am, tr, ao, ll
31  * @note rating: red
32  */
33 
34 #ifndef TTA_SEGMENT_HH
35 #define TTA_SEGMENT_HH
36 
37 #include <string>
38 #include <vector>
39 
40 #include "MachinePart.hh"
41 #include "Exception.hh"
42 
43 class ObjectState;
44 
45 namespace TTAMachine {
46 
47 class Connection;
48 class Bus;
49 class Socket;
50 
51 /**
52  * Represents a segment of a bus.
53  */
54 class Segment : public SubComponent {
55 public:
56  Segment(const std::string& name, Bus& parent);
57  Segment(const ObjectState* state, Bus& parent);
58  ~Segment();
59 
60  void setName(const std::string& name);
61  std::string name() const;
62 
63  void attachSocket(Socket& socket);
64  void detachSocket(Socket& socket);
65  void detachAllSockets();
66 
67  bool isConnectedTo(const Socket& socket) const;
68  const Connection& connection(const Socket& socket) const;
69  Socket* connection(int index) const;
70  int connectionCount() const;
71 
72  Bus* parentBus() const;
73 
74  void moveBefore(Segment& segment);
75  void moveAfter(Segment& segment);
76 
77  bool hasSourceSegment() const;
78  bool hasDestinationSegment() const;
79 
80  Segment* sourceSegment() const;
81  Segment* destinationSegment() const;
82 
83  virtual ObjectState* saveState() const;
84  virtual void loadState(const ObjectState* state);
85 
86  /// ObjectState name for Segment.
87  static const std::string OSNAME_SEGMENT;
88  /// ObjectState attribute key for segment name.
89  static const std::string OSKEY_NAME;
90  /// ObjectState attribute key for destination segment name.
91  static const std::string OSKEY_DESTINATION;
92 
93 private:
94  /// Vector of Connection pointers.
95  typedef std::vector<const Connection*> ConnectionTable;
96 
97  void loadStateWithoutReferences(const ObjectState* state);
99 
100  /// Name of the segment.
101  std::string name_;
102  /// The parent bus.
104  /// Source segment.
106  /// Destination segment.
108  /// Contains all the connections to sockets.
110 };
111 }
112 
113 #include "Segment.icc"
114 
115 #endif
TTAMachine::Segment::setName
void setName(const std::string &name)
Definition: Segment.cc:148
TTAMachine::Segment::destinationSegment_
Segment * destinationSegment_
Destination segment.
Definition: Segment.hh:107
TTAMachine::Segment::attachSocket
void attachSocket(Socket &socket)
Definition: Segment.cc:180
TTAMachine::SubComponent
Definition: MachinePart.hh:168
Exception.hh
TTAMachine::Segment
Definition: Segment.hh:54
TTAMachine::Segment::ConnectionTable
std::vector< const Connection * > ConnectionTable
Vector of Connection pointers.
Definition: Segment.hh:95
TTAMachine::Bus
Definition: Bus.hh:53
Segment.icc
TTAMachine::Segment::destinationSegment
Segment * destinationSegment() const
TTAMachine::Segment::OSKEY_NAME
static const std::string OSKEY_NAME
ObjectState attribute key for segment name.
Definition: Segment.hh:89
ObjectState
Definition: ObjectState.hh:59
TTAMachine::Segment::connections_
ConnectionTable connections_
Contains all the connections to sockets.
Definition: Segment.hh:109
TTAMachine::Segment::moveAfter
void moveAfter(Segment &segment)
Definition: Segment.cc:357
TTAMachine::Segment::loadState
virtual void loadState(const ObjectState *state)
Definition: Segment.cc:448
MachinePart.hh
TTAMachine::Segment::OSNAME_SEGMENT
static const std::string OSNAME_SEGMENT
ObjectState name for Segment.
Definition: Segment.hh:87
TTAMachine::Segment::detachSocket
void detachSocket(Socket &socket)
Definition: Segment.cc:210
TTAMachine::Segment::connectionCount
int connectionCount() const
TTAMachine::Segment::~Segment
~Segment()
Definition: Segment.cc:121
TTAMachine::Segment::parentBus
Bus * parentBus() const
TTAMachine::Socket
Definition: Socket.hh:53
TTAMachine::Segment::detachAllSockets
void detachAllSockets()
Definition: Segment.cc:229
TTAMachine::Segment::isConnectedTo
bool isConnectedTo(const Socket &socket) const
Definition: Segment.cc:274
TTAMachine::Segment::sourceSegment_
Segment * sourceSegment_
Source segment.
Definition: Segment.hh:105
TTAMachine::Segment::connection
const Connection & connection(const Socket &socket) const
Definition: Segment.cc:250
TTAMachine::Segment::hasSourceSegment
bool hasSourceSegment() const
Definition: Segment.cc:388
TTAMachine::Segment::saveState
virtual ObjectState * saveState() const
Definition: Segment.cc:421
TTAMachine::Connection
Definition: Connection.hh:48
TTAMachine::Segment::sourceSegment
Segment * sourceSegment() const
TTAMachine::Segment::hasDestinationSegment
bool hasDestinationSegment() const
Definition: Segment.cc:399
TTAMachine::Segment::moveBefore
void moveBefore(Segment &segment)
Definition: Segment.cc:320
TTAMachine::Segment::parent_
Bus * parent_
The parent bus.
Definition: Segment.hh:103
TTAMachine::Segment::name_
std::string name_
Name of the segment.
Definition: Segment.hh:101
TTAMachine::Segment::OSKEY_DESTINATION
static const std::string OSKEY_DESTINATION
ObjectState attribute key for destination segment name.
Definition: Segment.hh:91
TTAMachine::Segment::Segment
Segment(const std::string &name, Bus &parent)
Definition: Segment.cc:70
TTAMachine::Segment::removeConnection
void removeConnection(const Connection *connection)
Definition: Segment.cc:410
TTAMachine::Segment::name
std::string name() const
TTAMachine
Definition: Assembler.hh:48
TTAMachine::Segment::loadStateWithoutReferences
void loadStateWithoutReferences(const ObjectState *state)
Definition: Segment.cc:469