MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NdbApiSignal.hpp
1 /*
2  Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 /**********************************************************************
19  * Name: NdbApiSignal.H
20  * Include:
21  * Link:
22  * Author: UABMNST Mona Natterkvist UAB/B/SD
23  * Date: 97----
24  * Version: 0.1
25  * Description: Interface between TIS and NDB
26  * Documentation:
27  * Adjust: 971204 UABMNST First version.
28  * Adjust: 000705 QABANAB Changes in Protocol2
29  * Comment:
30  *****************************************************************************/
31 #ifndef NdbApiSignal_H
32 #define NdbApiSignal_H
33 
34 #include <kernel_types.h>
35 #include <RefConvert.hpp>
36 #include <TransporterDefinitions.hpp>
37 
38 class Ndb;
39 
45 class NdbApiSignal : public SignalHeader
46  {
47 public:
48  NdbApiSignal(Ndb* ndb);
49  NdbApiSignal(BlockReference ref);
50  NdbApiSignal(const NdbApiSignal &);
51  NdbApiSignal(const SignalHeader &header)
52  : SignalHeader(header), theNextSignal(0), theRealData(0) {};
53  ~NdbApiSignal();
54 
55  void set(Uint8 trace,
56  Uint16 receiversBlockNumber,
57  Uint16 signalNumber,
58  Uint32 length);
59 
60 
61  void setData(Uint32 aWord, Uint32 aDataNo);
62  Uint32 readData(Uint32 aDataNo) const; // Read word in signal
63 
64  // Set signal header
65  int setSignal(int NdbSignalType, Uint32 receiverBlockNo);
66  int readSignalNumber() const; // Read signal number
67  Uint32 getLength() const;
68  void setLength(Uint32 aLength);
69  void next(NdbApiSignal* anApiSignal);
70  NdbApiSignal* next();
71 
72  const Uint32 * getDataPtr() const;
73  Uint32 * getDataPtrSend();
74  const Uint32 * getConstDataPtrSend() const;
75  STATIC_CONST( MaxSignalWords = 25);
76 
77  NodeId get_sender_node();
78 
82  bool isFragmented() const { return m_fragmentInfo != 0;}
83  bool isFirstFragment() const { return m_fragmentInfo <= 1;}
84  bool isLastFragment() const {
85  return m_fragmentInfo == 0 || m_fragmentInfo == 3;
86  }
87 
88  Uint32 getFragmentId() const {
89  return (m_fragmentInfo == 0 ? 0 : getDataPtr()[theLength - 1]);
90  }
91 
92  NdbApiSignal& operator=(const NdbApiSignal& src) {
93  copyFrom(&src);
94  return *this;
95  }
96 
97 private:
98  void setDataPtr(Uint32 *);
99 
100  friend class NdbTransaction;
101  friend class NdbScanReceiver;
102  friend class Table;
103  friend class TransporterFacade;
104  void copyFrom(const NdbApiSignal * src);
105 
109  Uint32 theData[MaxSignalWords];
110  NdbApiSignal *theNextSignal;
111  Uint32 *theRealData;
112 };
113 /**********************************************************************
114 NodeId get_sender_node
115 Remark: Get the node id of the sender
116 ***********************************************************************/
117 inline
118 NodeId
119 NdbApiSignal::get_sender_node()
120 {
121  return refToNode(theSendersBlockRef);
122 }
123 
124 /**********************************************************************
125 void getLength
126 Remark: Get the length of the signal.
127 ******************************************************************************/
128 inline
129 Uint32
130 NdbApiSignal::getLength() const{
131  return theLength;
132 }
133 
134 /**********************************************************************
135 void setLength
136 Parameters: aLength: Signal length
137 Remark: Set the length in the signal.
138 ******************************************************************************/
139 inline
140 void
141 NdbApiSignal::setLength(Uint32 aLength){
142  theLength = aLength;
143 }
144 
145 /**********************************************************************
146 void next(NdbApiSignal* aSignal);
147 
148 Parameters: aSignal: Signal object.
149 Remark: Insert signal rear in a linked list.
150 *****************************************************************************/
151 inline
152 void
153 NdbApiSignal::next(NdbApiSignal* aSignal){
154  theNextSignal = aSignal;
155 }
156 /**********************************************************************
157 NdbApiSignal* next();
158 
159 Return Value: Return theNext signal object if the next was successful.
160  Return NULL: In all other case.
161 Remark: Read the theNext in signal.
162 *****************************************************************************/
163 inline
164 NdbApiSignal*
165 NdbApiSignal::next(){
166  return theNextSignal;
167 }
168 /**********************************************************************
169 int readSignalNo();
170 
171 Return Value: Return the signalNumber.
172 Remark: Read signal number
173 *****************************************************************************/
174 inline
175 int
176 NdbApiSignal::readSignalNumber() const
177 {
178  return (int)theVerId_signalNumber;
179 }
180 /**********************************************************************
181 Uint32 readData(Uint32 aDataNo);
182 
183 Return Value: Return Data word in a signal.
184  Return -1: In all other case.
185  aDataNo: Data number in signal.
186 Remark: Return the dataWord information in a signal for a dataNo.
187 ******************************************************************************/
188 inline
189 Uint32
190 NdbApiSignal::readData(Uint32 aDataNo) const {
191  return getDataPtr()[aDataNo-1];
192 }
193 /**********************************************************************
194 int setData(Uint32 aWord, int aDataNo);
195 
196 Return Value: Return 0 : setData was successful.
197  Return -1: In all other case.
198 Parameters: aWord: Data word.
199  aDataNo: Data number in signal.
200 Remark: Set Data word in signal 1 - 25
201 ******************************************************************************/
202 inline
203 void
204 NdbApiSignal::setData(Uint32 aWord, Uint32 aDataNo){
205  getDataPtrSend()[aDataNo -1] = aWord;
206 }
207 
211 inline
212 const Uint32 *
214  return theRealData;
215 }
216 
217 inline
218 Uint32 *
219 NdbApiSignal::getDataPtrSend(){
220  return (Uint32*)&theData[0];
221 }
222 
223 inline
224 const Uint32 *
225 NdbApiSignal::getConstDataPtrSend() const
226 {
227  return (Uint32*)&theData[0];
228 }
229 
230 inline
231 void
232 NdbApiSignal::setDataPtr(Uint32 * ptr){
233  theRealData = ptr;
234 }
235 
236 #endif