~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/ndb/src/ndbapi/NdbApiSignal.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2003 MySQL AB
 
2
 
 
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.
 
6
 
 
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.
 
11
 
 
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 */
 
15
 
 
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
 
31
 
 
32
#include <kernel_types.h>
 
33
#include "TransporterFacade.hpp"
 
34
#include <TransporterDefinitions.hpp>
 
35
#include "Ndb.hpp"
 
36
 
 
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))
 
39
 
 
40
/**
 
41
 * A NdbApiSignal : public SignalHeader
 
42
 *
 
43
 * Stores the address to theData in theSignalId
 
44
 */
 
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
  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();
 
70
 
 
71
   const Uint32 *       getDataPtr() const;
 
72
         Uint32 *       getDataPtrSend();
 
73
 
 
74
  NodeId                get_sender_node();
 
75
 
 
76
  /**
 
77
   * Fragmentation
 
78
   */
 
79
  bool isFirstFragment() const { return m_fragmentInfo <= 1;}
 
80
  bool isLastFragment() const { 
 
81
    return m_fragmentInfo == 0 || m_fragmentInfo == 3; 
 
82
  }
 
83
  
 
84
  Uint32 getFragmentId() const { 
 
85
    return (m_fragmentInfo == 0 ? 0 : getDataPtr()[theLength - 1]); 
 
86
  }
 
87
  
 
88
private:
 
89
  friend void execute(void * callbackObj, 
 
90
                      struct SignalHeader * const header, 
 
91
                      Uint8 prio, Uint32 * const theData, 
 
92
                      LinearSectionPtr ptr[3]);
 
93
   
 
94
  void setDataPtr(Uint32 *);
 
95
  
 
96
  friend class NdbTransaction;
 
97
  friend class NdbScanReceiver;
 
98
  friend class Table;
 
99
  void copyFrom(const NdbApiSignal * src);
 
100
 
 
101
  /**
 
102
   * Only used when creating a signal in the api
 
103
   */
 
104
  Uint32 theData[25];
 
105
  NdbApiSignal *theNextSignal;
 
106
  Uint32 *theRealData;
 
107
};
 
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()
 
115
{
 
116
  return refToNode(theSendersBlockRef);
 
117
}
 
118
 
 
119
/**********************************************************************
 
120
void getLength
 
121
Remark:        Get the length of the signal.
 
122
******************************************************************************/
 
123
inline
 
124
Uint32
 
125
NdbApiSignal::getLength() const{
 
126
  return theLength;
 
127
}
 
128
 
 
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;
 
138
}
 
139
 
 
140
/**********************************************************************
 
141
void next(NdbApiSignal* aSignal);
 
142
 
 
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;
 
150
}
 
151
/**********************************************************************
 
152
NdbApiSignal* next();
 
153
 
 
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;
 
162
}
 
163
/**********************************************************************
 
164
int readSignalNo();
 
165
 
 
166
Return Value:    Return the signalNumber. 
 
167
Remark:          Read signal number 
 
168
*****************************************************************************/
 
169
inline
 
170
int             
 
171
NdbApiSignal::readSignalNumber()
 
172
{
 
173
  return (int)theVerId_signalNumber;
 
174
}
 
175
/**********************************************************************
 
176
Uint32 readData(Uint32 aDataNo);
 
177
 
 
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];
 
187
}
 
188
/**********************************************************************
 
189
int setData(Uint32 aWord, int aDataNo);
 
190
 
 
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;
 
201
}
 
202
 
 
203
/**
 
204
 * Return pointer to data structure
 
205
 */
 
206
inline
 
207
const Uint32 *
 
208
NdbApiSignal::getDataPtr() const {
 
209
  return theRealData;
 
210
}
 
211
 
 
212
inline
 
213
Uint32 *
 
214
NdbApiSignal::getDataPtrSend(){
 
215
  return (Uint32*)&theData[0];
 
216
}
 
217
 
 
218
inline
 
219
void
 
220
NdbApiSignal::setDataPtr(Uint32 * ptr){
 
221
  theRealData = ptr;
 
222
}
 
223
 
 
224
#endif