Qpid Proton C++  0.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
connection.hpp
1 #ifndef PROTON_CPP_CONNECTION_H
2 #define PROTON_CPP_CONNECTION_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 #include "proton/object.hpp"
29 #include "proton/session.hpp"
30 #include "proton/connection_options.hpp"
31 #include "proton/types.h"
32 #include <string>
33 
34 struct pn_connection_t;
35 
36 namespace proton {
37 
38 class handler;
39 class engine;
40 
42 class connection : public object<pn_connection_t>, public endpoint {
43  public:
45  connection(pn_connection_t* c=0) : object<pn_connection_t>(c) {}
47 
49  PN_CPP_EXTERN endpoint::state state() const;
50 
51  PN_CPP_EXTERN condition local_condition() const;
52  PN_CPP_EXTERN condition remote_condition() const;
53 
58  PN_CPP_EXTERN class container &container() const;
59 
61  PN_CPP_EXTERN class transport transport() const;
62 
64  PN_CPP_EXTERN std::string host() const;
65 
69  PN_CPP_EXTERN void host(const std::string& h);
71 
73  PN_CPP_EXTERN std::string container_id() const;
74 
79  PN_CPP_EXTERN void open();
81 
84  PN_CPP_EXTERN void close();
85 
89  PN_CPP_EXTERN void release();
91 
93  PN_CPP_EXTERN session open_session();
94 
97  PN_CPP_EXTERN session default_session();
98 
100  PN_CPP_EXTERN sender open_sender(const std::string &addr,
101  const link_options &opts = link_options());
102 
104  PN_CPP_EXTERN receiver open_receiver(const std::string &addr,
105  const link_options &opts = link_options());
106 
108  PN_CPP_EXTERN link_range find_links(endpoint::state mask) const;
109 
111  PN_CPP_EXTERN session_range find_sessions(endpoint::state mask) const;
112 
120  bool closed() const { return (state() & LOCAL_CLOSED) && (state() & REMOTE_CLOSED); }
122 
123  private:
124  PN_CPP_EXTERN void user(const std::string &);
125  PN_CPP_EXTERN void password(const std::string &);
126 
128  friend class connection_context;
129  friend class connection_engine;
130  friend class connection_options;
131  friend class connector;
132  friend class transport;
133  friend class container_impl;
135 };
136 
137 }
138 
139 #endif // PROTON_CPP_CONNECTION_H
A top-level container of connections, sessions, and links.
Definition: container.hpp:57
sender open_sender(const std::string &addr, const link_options &opts=link_options())
Open a sender for addr on default_session().
std::string host() const
Return the AMQP host name for the connection.
session_range find_sessions(endpoint::state mask) const
Return sessions on this connection matching the state mask.
An interface for connection-oriented IO integration.
Definition: connection_engine.hpp:64
A link for sending messages.
Definition: sender.hpp:38
std::string container_id() const
Return the container ID for the connection.
void close()
Initiate local close.
link_range find_links(endpoint::state mask) const
Return links on this connection matching the state mask.
class container & container() const
Get the container.
A connection to a remote AMQP peer.
Definition: connection.hpp:42
Options for creating a connection.
Definition: connection_options.hpp:60
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
session default_session()
Get the default session.
int state
A bit mask of state bit values.
Definition: endpoint.hpp:45
static const state LOCAL_CLOSED
Local endpoint has been closed.
Definition: endpoint.hpp:51
condition remote_condition() const
Get the error condition of the remote endpoint.
condition local_condition() const
Get the local error condition.
session open_session()
Open a new session.
A link for receiving messages.
Definition: receiver.hpp:36
static const state REMOTE_CLOSED
Remote endpoint has been closed.
Definition: endpoint.hpp:52
A network layer supporting an AMQP connection.
Definition: transport.hpp:38
endpoint::state state() const
Get the state of this connection.
receiver open_receiver(const std::string &addr, const link_options &opts=link_options())
Open a receiver for addr on default_session().