1
/* Copyright (C) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
/**********************************************************************
17
* Name: NdbApiSignal.H
20
* Author: UABMNST Mona Natterkvist UAB/B/SD
23
* Description: Interface between TIS and NDB
25
* Adjust: 971204 UABMNST First version.
26
* Adjust: 000705 QABANAB Changes in Protocol2
28
*****************************************************************************/
29
#ifndef NdbApiSignal_H
30
#define NdbApiSignal_H
32
#include <kernel_types.h>
33
#include "TransporterFacade.hpp"
34
#include <TransporterDefinitions.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))
41
* A NdbApiSignal : public SignalHeader
43
* Stores the address to theData in theSignalId
45
class NdbApiSignal : public SignalHeader
48
NdbApiSignal(Ndb* ndb);
49
NdbApiSignal(BlockReference ref);
50
NdbApiSignal(const NdbApiSignal &);
51
NdbApiSignal(const SignalHeader &header)
52
: SignalHeader(header), theNextSignal(0), theRealData(0) {};
56
Uint16 receiversBlockNumber,
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);
71
const Uint32 * getDataPtr() const;
72
Uint32 * getDataPtrSend();
74
NodeId get_sender_node();
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]);
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;
99
void copyFrom(const NdbApiSignal * src);
102
* Only used when creating a signal in the api
105
NdbApiSignal *theNextSignal;
108
/**********************************************************************
109
NodeId get_sender_node
110
Remark: Get the node id of the sender
111
***********************************************************************/
114
NdbApiSignal::get_sender_node()
116
return refToNode(theSendersBlockRef);
119
/**********************************************************************
121
Remark: Get the length of the signal.
122
******************************************************************************/
125
NdbApiSignal::getLength() const{
129
/**********************************************************************
131
Parameters: aLength: Signal length
132
Remark: Set the length in the signal.
133
******************************************************************************/
136
NdbApiSignal::setLength(Uint32 aLength){
140
/**********************************************************************
141
void next(NdbApiSignal* aSignal);
143
Parameters: aSignal: Signal object.
144
Remark: Insert signal rear in a linked list.
145
*****************************************************************************/
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
*****************************************************************************/
160
NdbApiSignal::next(){
161
return theNextSignal;
163
/**********************************************************************
166
Return Value: Return the signalNumber.
167
Remark: Read signal number
168
*****************************************************************************/
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
******************************************************************************/
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
******************************************************************************/
199
NdbApiSignal::setData(Uint32 aWord, Uint32 aDataNo){
200
getDataPtrSend()[aDataNo -1] = aWord;
204
* Return pointer to data structure
208
NdbApiSignal::getDataPtr() const {
214
NdbApiSignal::getDataPtrSend(){
215
return (Uint32*)&theData[0];
220
NdbApiSignal::setDataPtr(Uint32 * ptr){