Qpid .NET Messaging API  0.26
 All Classes Namespaces Files Functions Variables Typedefs
Connection.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 
20 #pragma once
21 
22 #include <windows.h>
23 #include <msclr\lock.h>
24 #include <oletx2xa.h>
25 #include <string>
26 #include <limits>
27 
28 #include "qpid/messaging/Connection.h"
29 #include "qpid/messaging/Session.h"
30 
31 namespace Org {
32 namespace Apache {
33 namespace Qpid {
34 namespace Messaging {
35 
39 
40  ref class Session;
41 
42  public ref class Connection
43  {
44  private:
45  // The kept object in the Messaging C++ DLL
46  ::qpid::messaging::Connection * nativeObjPtr;
47 
48  // per-instance lock object
49  System::Object ^ privateLock;
50 
51  // Disallow use after object is destroyed
52  void ThrowIfDisposed();
53 
54  public:
55  Connection(System::String ^ url);
56 
57  Connection(System::String ^ url,
58  System::Collections::Generic::Dictionary<
59  System::String ^, System::Object ^> ^ options);
60 
61  Connection(System::String ^ url, System::String ^ options);
62 
63  // copy constructor
64  Connection(const Connection ^ connection);
65  Connection(const Connection % connection);
66 
67  // unmanaged clone
68  // not defined
69 
70  ~Connection();
71  !Connection();
72 
73  // assignment operator
75  {
76  msclr::lock lk(privateLock);
77  ThrowIfDisposed();
78 
79  if (this == %rhs)
80  {
81  // Self assignment, do nothing
82  }
83  else
84  {
85  if (NULL != nativeObjPtr)
86  delete nativeObjPtr;
87  nativeObjPtr = new ::qpid::messaging::Connection(
88  *(const_cast<Connection %>(rhs).NativeConnection) );
89  }
90  return *this;
91  }
92 
93  //
94  // IsDisposed
95  //
96  property bool IsDisposed
97  {
98  bool get()
99  {
100  return NULL == nativeObjPtr;
101  }
102  }
103 
104 
105  //
106  // NativeConnection
107  //
108  property ::qpid::messaging::Connection * NativeConnection
109  {
110  ::qpid::messaging::Connection * get ()
111  {
112  return nativeObjPtr;
113  }
114  }
115 
116  void SetOption(System::String ^ name, System::Object ^ value);
117 
118  void Open();
119  void Close();
120 
121  property System::Boolean IsOpen
122  {
123  System::Boolean get ()
124  {
125  msclr::lock lk(privateLock);
126  ThrowIfDisposed();
127 
128  return nativeObjPtr->isOpen();
129  }
130  }
131 
132  // CreateTransactionalSession()
134  Session ^ CreateTransactionalSession(System::String ^ name);
135 
136  // CreateSession()
138  Session ^ CreateSession(System::String ^ name);
139 
140  Session ^ GetSession(System::String ^ name);
141 
142  property System::String ^ AuthenticatedUsername
143  {
144  System::String ^ get ()
145  {
146  msclr::lock lk(privateLock);
147  ThrowIfDisposed();
148 
149  return gcnew System::String(nativeObjPtr->getAuthenticatedUsername().c_str());
150  }
151  }
152  };
153 }}}}
Session GetSession(System::String^name)
Definition: Connection.cpp:374
property System::Boolean IsOpen
Definition: Connection.h:122
~Connection()
Definition: Connection.cpp:176
void Close()
Definition: Connection.cpp:247
Session CreateTransactionalSession(System::String^name)
Definition: Connection.cpp:273
Session CreateSession()
Definition: Connection.cpp:325
Connection operator=(const Connection%rhs)
Definition: Connection.h:74
Definition: Connection.h:42
void Open()
Definition: Connection.cpp:224
Connection(System::String^url)
Definition: Connection.cpp:54
property bool IsDisposed
Definition: Connection.h:97