Qpid .NET Messaging API  0.26
 All Classes Namespaces Files Functions Variables Typedefs
Session.h
Go to the documentation of this file.
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 #pragma once
20 
21 #include <windows.h>
22 #include <msclr\lock.h>
23 #include <oletx2xa.h>
24 #include <string>
25 #include <limits>
26 
27 #include "qpid/messaging/Session.h"
28 #include "qpid/messaging/Connection.h"
29 #include "qpid/messaging/Duration.h"
30 #include "qpid/messaging/Receiver.h"
31 #include "qpid/messaging/Sender.h"
32 
33 namespace qpid {
34 namespace messaging {
35  // Dummy class to satisfy linker
36  class SessionImpl {};
37 }}
38 
39 namespace Org {
40 namespace Apache {
41 namespace Qpid {
42 namespace Messaging {
43 
47 
48  ref class Address;
49  ref class Connection;
50  ref class Duration;
51  ref class Receiver;
52  ref class Sender;
53  ref class Message;
54 
55  public ref class Session
56  {
57  private:
58  // The kept object in the Messaging C++ DLL
59  ::qpid::messaging::Session * nativeObjPtr;
60 
61  // The connection that created this session
62  Connection ^ parentConnectionp;
63 
64  // per-instance lock object
65  System::Object ^ privateLock;
66 
67  // Disallow use after object is destroyed
68  void ThrowIfDisposed();
69 
70  public:
71 
72  // unmanaged clone
73  Session(const ::qpid::messaging::Session & nativeObjPtr,
74  Connection ^ connRef);
75 
76  // copy constructor
77  Session(const Session ^ session);
78  Session(const Session % session);
79 
80  ~Session();
81  !Session();
82 
83  // assignment operator
84  Session % operator=(const Session % rhs)
85  {
86  msclr::lock lk(privateLock);
87  ThrowIfDisposed();
88 
89  if (this == %rhs)
90  {
91  // Self assignment, do nothing
92  }
93  else
94  {
95  if (NULL != nativeObjPtr)
96  delete nativeObjPtr;
97  nativeObjPtr = new ::qpid::messaging::Session(
98  *(const_cast<Session %>(rhs).NativeSession) );
99  parentConnectionp = rhs.parentConnectionp;
100  }
101  return *this;
102  }
103 
104  //
105  // IsDisposed
106  //
107  property bool IsDisposed
108  {
109  bool get()
110  {
111  return NULL == nativeObjPtr;
112  }
113  }
114 
115 
116  //
117  // NativeSession
118  //
119  property ::qpid::messaging::Session * NativeSession
120  {
121  ::qpid::messaging::Session * get ()
122  {
123  return nativeObjPtr;
124  }
125  }
126 
127  void Close();
128  void Commit();
129  void Rollback();
130  void Acknowledge();
131  void Acknowledge(bool sync);
132  void Acknowledge(Message ^ message);
133  void Acknowledge(Message ^ message, bool sync);
134  void AcknowledgeUpTo(Message ^ message);
135  void AcknowledgeUpTo(Message ^ message, bool sync);
136  void Reject(Message ^);
137  void Release(Message ^);
138  void Sync();
139  void Sync(bool block);
140 
141  property System::UInt32 Receivable
142  {
143  System::UInt32 get ()
144  {
145  msclr::lock lk(privateLock);
146  ThrowIfDisposed();
147 
148  return nativeObjPtr->getReceivable();
149  }
150  }
151 
152  property System::UInt32 UnsettledAcks
153  {
154  System::UInt32 get ()
155  {
156  msclr::lock lk(privateLock);
157  ThrowIfDisposed();
158 
159  return nativeObjPtr->getUnsettledAcks();
160  }
161  }
162 
163  // next(receiver)
164  bool NextReceiver(Receiver ^ rcvr);
165  bool NextReceiver(Receiver ^ rcvr, Duration ^ timeout);
166 
167  // receiver = next()
168  Receiver ^ NextReceiver();
169  Receiver ^ NextReceiver(Duration ^ timeout);
170 
171 
172  Sender ^ CreateSender(System::String ^ address);
173  Sender ^ CreateSender(Address ^ address);
174 
175  Receiver ^ CreateReceiver(System::String ^ address);
176  Receiver ^ CreateReceiver(Address ^ address);
177 
178  Sender ^ GetSender(System::String ^ name);
179  Receiver ^ GetReceiver(System::String ^ name);
180 
182  {
184  {
185  msclr::lock lk(privateLock);
186  ThrowIfDisposed();
187 
188  return parentConnectionp;
189  }
190  }
191 
192 
193  property System::Boolean HasError
194  {
195  System::Boolean get ()
196  {
197  msclr::lock lk(privateLock);
198  ThrowIfDisposed();
199 
200  return nativeObjPtr->hasError();
201  }
202  }
203 
204  void CheckError();
205  };
206 }}}}
Definition: Session.h:36
void AcknowledgeUpTo(Message^message)
Definition: Session.cpp:280
void Reject(Message^)
Definition: Session.cpp:308
void Commit()
Definition: Session.cpp:178
Session operator=(const Session%rhs)
Definition: Session.h:84
void Sync()
Definition: Session.cpp:354
void Release(Message^)
Definition: Session.cpp:331
Sender GetSender(System::String^name)
Definition: Session.cpp:626
Session(const ::qpid::messaging::Session &nativeObjPtr, Connection^connRef)
Definition: Session.cpp:57
void Rollback()
Definition: Session.cpp:201
property System::UInt32 Receivable
Definition: Session.h:142
Receiver CreateReceiver(System::String^address)
Definition: Session.cpp:544
void Acknowledge()
Definition: Session.cpp:224
~Session()
Definition: Session.cpp:82
Definition: Connection.h:42
property bool IsDisposed
Definition: Session.h:108
Receiver NextReceiver()
Definition: Session.cpp:421
Sender CreateSender(System::String^address)
Definition: Session.cpp:462
Receiver GetReceiver(System::String^name)
Definition: Session.cpp:666
property Org::Apache::Qpid::Messaging::Connection Connection
Definition: Session.h:182