Qpid Proton C++  0.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
session.hpp
1 #ifndef PROTON_CPP_SESSION_H
2 #define PROTON_CPP_SESSION_H
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
24 
25 #include "proton/export.hpp"
26 #include "proton/endpoint.hpp"
27 #include "proton/link.hpp"
28 
29 #include "proton/types.h"
30 #include "proton/link.h"
31 #include <string>
32 
33 struct pn_connection_t;
34 struct pn_session_t;
35 
36 namespace proton {
37 
38 class container;
39 class handler;
40 
42 class session : public object<pn_session_t>, public endpoint
43 {
44  public:
46  session(pn_session_t* s=0) : object<pn_session_t>(s) {}
48 
49  // Endpoint behaviours
50 
52  PN_CPP_EXTERN endpoint::state state() const;
53 
54  PN_CPP_EXTERN condition local_condition() const;
55  PN_CPP_EXTERN condition remote_condition() const;
56 
61  PN_CPP_EXTERN void open();
63 
66  PN_CPP_EXTERN void close();
67 
69  PN_CPP_EXTERN class connection connection() const;
70 
73 
79  PN_CPP_EXTERN receiver create_receiver(const std::string& name="");
80 
86  PN_CPP_EXTERN sender create_sender(const std::string& name="");
87 
89 
91  PN_CPP_EXTERN sender open_sender(const std::string &addr, const link_options &opts = link_options());
92 
94  PN_CPP_EXTERN receiver open_receiver(const std::string &addr, const link_options &opts = link_options());
95 
99  PN_CPP_EXTERN session next(endpoint::state) const;
101 
103  PN_CPP_EXTERN link_range find_links(endpoint::state mask) const;
104 };
105 
109 class session_iterator : public iter_base<session> {
110  public:
111  explicit session_iterator(session p = session(), endpoint::state s = 0) :
112  iter_base<session>(p, s) {}
113  PN_CPP_EXTERN session_iterator operator++();
114  session_iterator operator++(int) { session_iterator x(*this); ++(*this); return x; }
115 };
117 
119 typedef range<session_iterator> session_range;
120 
121 }
122 
123 #endif // PROTON_CPP_SESSION_H
void close()
Initiate local close.
A link for sending messages.
Definition: sender.hpp:38
A connection to a remote AMQP peer.
Definition: connection.hpp:42
The base class for session, connection, and link.
Definition: endpoint.hpp:32
A container of links.
Definition: session.hpp:42
Describes an endpoint error state.
Definition: condition.hpp:35
link_range find_links(endpoint::state mask) const
Return the links on this session matching the state mask.
int state
A bit mask of state bit values.
Definition: endpoint.hpp:45
receiver open_receiver(const std::string &addr, const link_options &opts=link_options())
Open a receiver for addr.
A link for receiving messages.
Definition: receiver.hpp:36
sender open_sender(const std::string &addr, const link_options &opts=link_options())
Open a sender for addr.
endpoint::state state() const
Get the state of this session.
condition local_condition() const
Get the local error condition.
condition remote_condition() const
Get the error condition of the remote endpoint.