| 1 |
#ifndef PROTON_TERMINUS_HPP |
| 2 |
#define PROTON_TERMINUS_HPP |
| 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 "./map.hpp" |
| 26 |
#include "./types_fwd.hpp" |
| 27 |
#include "./internal/export.hpp" |
| 28 |
|
| 29 |
#include <proton/terminus.h> |
| 30 |
|
| 31 |
#include <map> |
| 32 |
#include <string> |
| 33 |
#include <vector> |
| 34 |
|
| 35 |
/// @file |
| 36 |
/// @copybrief proton::terminus |
| 37 |
|
| 38 |
struct pn_link_t; |
| 39 |
struct pn_terminus_t; |
| 40 |
|
| 41 |
namespace proton { |
| 42 |
|
| 43 |
namespace internal { |
| 44 |
template <class T> class factory; |
| 45 |
} |
| 46 |
|
| 47 |
/// One end of a link, either a source or a target. |
| 48 |
/// |
| 49 |
/// The source terminus is where messages originate; the target |
| 50 |
/// terminus is where they go. |
| 51 |
/// |
| 52 |
/// @see proton::link |
| 53 |
class terminus { |
| 54 |
/// @cond INTERNAL |
| 55 |
terminus(pn_terminus_t* t); |
| 56 |
/// @endcond |
| 57 |
|
| 58 |
public: |
| 59 |
typedef map<symbol, value> dynamic_property_map; |
| 60 |
|
| 61 |
terminus() : object_(0), parent_(0) {} |
| 62 |
|
| 63 |
/// The persistence mode of the source or target. |
| 64 |
enum durability_mode { |
| 65 |
/// No persistence. |
| 66 |
NONDURABLE = PN_NONDURABLE, |
| 67 |
/// Only configuration is persisted. |
| 68 |
CONFIGURATION = PN_CONFIGURATION, |
| 69 |
/// Configuration and unsettled state are persisted. |
| 70 |
UNSETTLED_STATE = PN_DELIVERIES |
| 71 |
}; |
| 72 |
|
| 73 |
/// When expiration of the source or target begins. |
| 74 |
enum expiry_policy { |
| 75 |
/// When the link is closed. |
| 76 |
LINK_CLOSE = PN_EXPIRE_WITH_LINK, |
| 77 |
/// When the containing session is closed. |
| 78 |
SESSION_CLOSE = PN_EXPIRE_WITH_SESSION, |
| 79 |
/// When the containing connection is closed. |
| 80 |
CONNECTION_CLOSE = PN_EXPIRE_WITH_CONNECTION, |
| 81 |
/// The terminus never expires. |
| 82 |
NEVER = PN_EXPIRE_NEVER |
| 83 |
}; |
| 84 |
|
| 85 |
// XXX This should have address? |
| 86 |
|
| 87 |
/// Get the policy for when expiration begins. |
| 88 |
PN_CPP_EXTERN enum expiry_policy expiry_policy() const; |
| 89 |
|
| 90 |
/// The period after which the source is discarded on expiry. The |
| 91 |
/// duration is rounded to the nearest second. |
| 92 |
PN_CPP_EXTERN duration timeout() const; |
| 93 |
|
| 94 |
/// Get the durability flag. |
| 95 |
PN_CPP_EXTERN enum durability_mode durability_mode(); |
| 96 |
|
| 97 |
/// True if the remote node is created dynamically. |
| 98 |
PN_CPP_EXTERN bool dynamic() const; |
| 99 |
|
| 100 |
/// True if the remote node is an anonymous-relay |
| 101 |
PN_CPP_EXTERN bool anonymous() const; |
| 102 |
|
| 103 |
/// Obtain the AMQP dynamic node properties for the terminus as a single value. |
| 104 |
/// See also lifetime_policy. |
| 105 |
/// @deprecated in favor of dynamic_properties() |
| 106 |
PN_CPP_EXTERN value node_properties() const; |
| 107 |
|
| 108 |
/// **Unsettled API** Extension capabilities that are supported/requested |
| 109 |
PN_CPP_EXTERN std::vector<symbol> capabilities() const; |
| 110 |
|
| 111 |
/// **Unsettled API** Obtain the AMQP dynamic node properties for the |
| 112 |
/// terminus as a map. |
| 113 |
PN_CPP_EXTERN dynamic_property_map dynamic_properties() const; |
| 114 |
|
| 115 |
protected: |
| 116 |
pn_terminus_t *pn_object() const { return object_; } |
| 117 |
private: |
| 118 |
pn_terminus_t* object_; |
| 119 |
pn_link_t* parent_; |
| 120 |
|
| 121 |
/// @cond INTERNAL |
| 122 |
friend class internal::factory<terminus>; |
| 123 |
friend class source; |
| 124 |
friend class target; |
| 125 |
/// @endcond |
| 126 |
}; |
| 127 |
|
| 128 |
} // proton |
| 129 |
|
| 130 |
#endif // PROTON_TERMINUS_HPP |