OpenASIP 2.2
Loading...
Searching...
No Matches
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
43class ObjectState;
44
45namespace TTAMachine {
46
47class Connection;
48class Bus;
49class Socket;
50
51/**
52 * Represents a segment of a bus.
53 */
54class Segment : public SubComponent {
55public:
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
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
93private:
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
void detachSocket(Socket &socket)
Definition Segment.cc:210
std::vector< const Connection * > ConnectionTable
Vector of Connection pointers.
Definition Segment.hh:95
virtual void loadState(const ObjectState *state)
Definition Segment.cc:448
void detachAllSockets()
Definition Segment.cc:229
const Connection & connection(const Socket &socket) const
Definition Segment.cc:250
virtual ObjectState * saveState() const
Definition Segment.cc:421
ConnectionTable connections_
Contains all the connections to sockets.
Definition Segment.hh:109
Segment * destinationSegment() const
void moveBefore(Segment &segment)
Definition Segment.cc:320
static const std::string OSKEY_DESTINATION
ObjectState attribute key for destination segment name.
Definition Segment.hh:91
void moveAfter(Segment &segment)
Definition Segment.cc:357
Segment * sourceSegment_
Source segment.
Definition Segment.hh:105
static const std::string OSNAME_SEGMENT
ObjectState name for Segment.
Definition Segment.hh:87
bool hasSourceSegment() const
Definition Segment.cc:388
std::string name_
Name of the segment.
Definition Segment.hh:101
void setName(const std::string &name)
Definition Segment.cc:148
Bus * parent_
The parent bus.
Definition Segment.hh:103
Segment * sourceSegment() const
bool isConnectedTo(const Socket &socket) const
Definition Segment.cc:274
bool hasDestinationSegment() const
Definition Segment.cc:399
static const std::string OSKEY_NAME
ObjectState attribute key for segment name.
Definition Segment.hh:89
int connectionCount() const
void removeConnection(const Connection *connection)
Definition Segment.cc:410
std::string name() const
Bus * parentBus() const
Segment * destinationSegment_
Destination segment.
Definition Segment.hh:107
void loadStateWithoutReferences(const ObjectState *state)
Definition Segment.cc:469
void attachSocket(Socket &socket)
Definition Segment.cc:180