mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / ndb / src / ndbapi / NdbApiSignal.hpp
blob0718cc40dd424cf34fd820443db01be367605b67
1 /* Copyright (c) 2003-2005 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
16 /**********************************************************************
17 * Name: NdbApiSignal.H
18 * Include:
19 * Link:
20 * Author: UABMNST Mona Natterkvist UAB/B/SD
21 * Date: 97----
22 * Version: 0.1
23 * Description: Interface between TIS and NDB
24 * Documentation:
25 * Adjust: 971204 UABMNST First version.
26 * Adjust: 000705 QABANAB Changes in Protocol2
27 * Comment:
28 *****************************************************************************/
29 #ifndef NdbApiSignal_H
30 #define NdbApiSignal_H
32 #include <kernel_types.h>
33 #include "TransporterFacade.hpp"
34 #include <TransporterDefinitions.hpp>
35 #include "Ndb.hpp"
37 #define CAST_PTR(X,Y) static_cast<X*>(static_cast<void*>(Y))
38 #define CAST_CONSTPTR(X,Y) static_cast<const X*>(static_cast<const void*>(Y))
40 /**
41 * A NdbApiSignal : public SignalHeader
43 * Stores the address to theData in theSignalId
45 class NdbApiSignal : public SignalHeader
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();
55 void set(Uint8 trace,
56 Uint16 receiversBlockNumber,
57 Uint16 signalNumber,
58 Uint32 length);
61 void setData(Uint32 aWord, Uint32 aDataNo);
62 Uint32 readData(Uint32 aDataNo) const; // Read word in signal
64 int setSignal(int NdbSignalType); // Set signal header
65 int readSignalNumber(); // Read signal number
66 Uint32 getLength() const;
67 void setLength(Uint32 aLength);
68 void next(NdbApiSignal* anApiSignal);
69 NdbApiSignal* next();
71 const Uint32 * getDataPtr() const;
72 Uint32 * getDataPtrSend();
74 NodeId get_sender_node();
76 /**
77 * Fragmentation
79 bool isFirstFragment() const { return m_fragmentInfo <= 1;}
80 bool isLastFragment() const {
81 return m_fragmentInfo == 0 || m_fragmentInfo == 3;
84 Uint32 getFragmentId() const {
85 return (m_fragmentInfo == 0 ? 0 : getDataPtr()[theLength - 1]);
88 private:
89 friend void execute(void * callbackObj,
90 struct SignalHeader * const header,
91 Uint8 prio, Uint32 * const theData,
92 LinearSectionPtr ptr[3]);
94 void setDataPtr(Uint32 *);
96 friend class NdbTransaction;
97 friend class NdbScanReceiver;
98 friend class Table;
99 void copyFrom(const NdbApiSignal * src);
102 * Only used when creating a signal in the api
104 Uint32 theData[25];
105 NdbApiSignal *theNextSignal;
106 Uint32 *theRealData;
108 /**********************************************************************
109 NodeId get_sender_node
110 Remark: Get the node id of the sender
111 ***********************************************************************/
112 inline
113 NodeId
114 NdbApiSignal::get_sender_node()
116 return refToNode(theSendersBlockRef);
119 /**********************************************************************
120 void getLength
121 Remark: Get the length of the signal.
122 ******************************************************************************/
123 inline
124 Uint32
125 NdbApiSignal::getLength() const{
126 return theLength;
129 /**********************************************************************
130 void setLength
131 Parameters: aLength: Signal length
132 Remark: Set the length in the signal.
133 ******************************************************************************/
134 inline
135 void
136 NdbApiSignal::setLength(Uint32 aLength){
137 theLength = aLength;
140 /**********************************************************************
141 void next(NdbApiSignal* aSignal);
143 Parameters: aSignal: Signal object.
144 Remark: Insert signal rear in a linked list.
145 *****************************************************************************/
146 inline
147 void
148 NdbApiSignal::next(NdbApiSignal* aSignal){
149 theNextSignal = aSignal;
151 /**********************************************************************
152 NdbApiSignal* next();
154 Return Value: Return theNext signal object if the next was successful.
155 Return NULL: In all other case.
156 Remark: Read the theNext in signal.
157 *****************************************************************************/
158 inline
159 NdbApiSignal*
160 NdbApiSignal::next(){
161 return theNextSignal;
163 /**********************************************************************
164 int readSignalNo();
166 Return Value: Return the signalNumber.
167 Remark: Read signal number
168 *****************************************************************************/
169 inline
170 int
171 NdbApiSignal::readSignalNumber()
173 return (int)theVerId_signalNumber;
175 /**********************************************************************
176 Uint32 readData(Uint32 aDataNo);
178 Return Value: Return Data word in a signal.
179 Return -1: In all other case.
180 aDataNo: Data number in signal.
181 Remark: Return the dataWord information in a signal for a dataNo.
182 ******************************************************************************/
183 inline
184 Uint32
185 NdbApiSignal::readData(Uint32 aDataNo) const {
186 return getDataPtr()[aDataNo-1];
188 /**********************************************************************
189 int setData(Uint32 aWord, int aDataNo);
191 Return Value: Return 0 : setData was successful.
192 Return -1: In all other case.
193 Parameters: aWord: Data word.
194 aDataNo: Data number in signal.
195 Remark: Set Data word in signal 1 - 25
196 ******************************************************************************/
197 inline
198 void
199 NdbApiSignal::setData(Uint32 aWord, Uint32 aDataNo){
200 getDataPtrSend()[aDataNo -1] = aWord;
204 * Return pointer to data structure
206 inline
207 const Uint32 *
208 NdbApiSignal::getDataPtr() const {
209 return theRealData;
212 inline
213 Uint32 *
214 NdbApiSignal::getDataPtrSend(){
215 return (Uint32*)&theData[0];
218 inline
219 void
220 NdbApiSignal::setDataPtr(Uint32 * ptr){
221 theRealData = ptr;
224 #endif