OpenASIP  2.0
SocketEncoding.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 SocketEncoding.hh
26  *
27  * Declaration of SocketEncoding class.
28  *
29  * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_SOCKET_ENCODING_HH
34 #define TTA_SOCKET_ENCODING_HH
35 
36 #include "Encoding.hh"
37 
38 class SocketCodeTable;
39 class SlotField;
40 
41 /**
42  * The SocketEncoding class models how socket sources or destinations are
43  * mapped to control codes.
44  *
45  * Sockets have an independent encoding in each source or destination
46  * field they appear in. A socket encoding can be more complex than a
47  * fixed control code and encode many destinations or sources all
48  * reached from the same socket. In this case, the socket encoding
49  * contains SocketCodeTable instance.
50  */
51 class SocketEncoding : public Encoding {
52 public:
54  const std::string& name, unsigned int encoding, unsigned int extraBits,
55  SlotField& parent);
57  virtual ~SocketEncoding();
58 
59  SlotField* parent() const;
60 
61  std::string socketName() const;
62 
63  void setSocketCodes(SocketCodeTable& codeTable);
64  void unsetSocketCodes();
65  bool hasSocketCodes() const;
67  int socketCodePosition() const;
68 
69  void setEncoding(unsigned int encoding, unsigned int extraBits);
70 
71  int socketIDPosition() const;
72  int socketIDWidth() const;
73  virtual int width() const;
74  virtual int bitPosition() const;
75 
76  virtual ObjectState* saveState() const;
77 
78  /// ObjectState name for socket encoding.
79  static const std::string OSNAME_SOCKET_ENCODING;
80  /// ObjectState attribute key for the name of the socket.
81  static const std::string OSKEY_SOCKET_NAME;
82  /// ObjectState attribute key for the name of the socket code table.
83  static const std::string OSKEY_SC_TABLE;
84 
85 private:
86 
87  void detachFromParent();
88 
89  /// Name of the socket.
90  std::string name_;
91  /// Socket code table.
93 };
94 
95 #endif
SocketEncoding::detachFromParent
void detachFromParent()
Definition: SocketEncoding.cc:316
SocketEncoding::setSocketCodes
void setSocketCodes(SocketCodeTable &codeTable)
Definition: SocketEncoding.cc:156
SocketEncoding::bitPosition
virtual int bitPosition() const
Definition: SocketEncoding.cc:291
SocketEncoding::saveState
virtual ObjectState * saveState() const
Definition: SocketEncoding.cc:302
ObjectState
Definition: ObjectState.hh:59
SocketEncoding::~SocketEncoding
virtual ~SocketEncoding()
Definition: SocketEncoding.cc:119
SocketEncoding::socketCodePosition
int socketCodePosition() const
Definition: SocketEncoding.cc:203
SocketEncoding::width
virtual int width() const
Definition: SocketEncoding.cc:276
Encoding.hh
SocketCodeTable
Definition: SocketCodeTable.hh:68
Encoding
Definition: Encoding.hh:46
SocketEncoding::OSKEY_SC_TABLE
static const std::string OSKEY_SC_TABLE
ObjectState attribute key for the name of the socket code table.
Definition: SocketEncoding.hh:83
SocketEncoding::OSNAME_SOCKET_ENCODING
static const std::string OSNAME_SOCKET_ENCODING
ObjectState name for socket encoding.
Definition: SocketEncoding.hh:79
SocketEncoding::setEncoding
void setEncoding(unsigned int encoding, unsigned int extraBits)
Definition: SocketEncoding.cc:223
SocketEncoding::socketName
std::string socketName() const
Definition: SocketEncoding.cc:145
SocketEncoding::SocketEncoding
SocketEncoding(const std::string &name, unsigned int encoding, unsigned int extraBits, SlotField &parent)
Definition: SocketEncoding.cc:66
SocketEncoding::hasSocketCodes
bool hasSocketCodes() const
Definition: SocketEncoding.cc:177
Encoding::encoding
unsigned int encoding() const
Definition: Encoding.cc:108
SocketEncoding::socketIDWidth
int socketIDWidth() const
Definition: SocketEncoding.cc:264
SocketEncoding::socketIDPosition
int socketIDPosition() const
Definition: SocketEncoding.cc:249
SlotField
Definition: SlotField.hh:58
SocketEncoding::parent
SlotField * parent() const
Definition: SocketEncoding.cc:127
SocketEncoding::unsetSocketCodes
void unsetSocketCodes()
Definition: SocketEncoding.cc:165
SocketEncoding::socketCodes_
SocketCodeTable * socketCodes_
Socket code table.
Definition: SocketEncoding.hh:92
SocketEncoding::name_
std::string name_
Name of the socket.
Definition: SocketEncoding.hh:90
SocketEncoding::socketCodes
SocketCodeTable & socketCodes() const
Definition: SocketEncoding.cc:191
SocketEncoding
Definition: SocketEncoding.hh:51
Encoding::extraBits
unsigned int extraBits() const
Definition: Encoding.cc:119
SocketEncoding::OSKEY_SOCKET_NAME
static const std::string OSKEY_SOCKET_NAME
ObjectState attribute key for the name of the socket.
Definition: SocketEncoding.hh:81