AMPS C/C++ Client Class Reference AMPS C/C++ Client Version 5.3.5.7

ServerChooser.hpp
Go to the documentation of this file.
1 //
3 // Copyright (c) 2010-2026 60East Technologies Inc., All Rights Reserved.
4 //
5 // This computer software is owned by 60East Technologies Inc. and is
6 // protected by U.S. copyright laws and other laws and by international
7 // treaties. This computer software is furnished by 60East Technologies
8 // Inc. pursuant to a written license agreement and may be used, copied,
9 // transmitted, and stored only in accordance with the terms of such
10 // license agreement and with the inclusion of the above copyright notice.
11 // This computer software or any other copies thereof may not be provided
12 // or otherwise made available to any other person.
13 //
14 // U.S. Government Restricted Rights. This computer software: (a) was
15 // developed at private expense and is in all respects the proprietary
16 // information of 60East Technologies Inc.; (b) was not developed with
17 // government funds; (c) is a trade secret of 60East Technologies Inc.
18 // for all purposes of the Freedom of Information Act; and (d) is a
19 // commercial item and thus, pursuant to Section 12.212 of the Federal
20 // Acquisition Regulations (FAR) and DFAR Supplement Section 227.7202,
21 // Government's use, duplication or disclosure of the computer software
22 // is subject to the restrictions set forth by 60East Technologies Inc..
23 //
25
26 #ifndef _SERVERCHOOSER_H_
27 #define _SERVERCHOOSER_H_
28
29 #include <amps/ampsplusplus.hpp>
30 #include <amps/ServerChooserImpl.hpp>
31
36
37
38 namespace AMPS
39 {
40
46 class ServerChooser
47 {
48 RefHandle<ServerChooserImpl> _body;
49 public:
50 ServerChooser() : _body(NULL) {}
51
52 ServerChooser(ServerChooserImpl* body_) : _body(body_) {}
53
54 ~ServerChooser() = default;
55
56 bool isValid()
57 {
58 return _body.isValid();
59 }
60
66 std::string getCurrentURI()
67 {
68 return _body.get().getCurrentURI();
69 }
70
76 Authenticator& getCurrentAuthenticator()
77 {
78 return _body.get().getCurrentAuthenticator();
79 }
80
88 void reportFailure(const AMPSException& exception_,
89 const ConnectionInfo& info_)
90 {
91 _body.get().reportFailure(exception_, info_);
92 }
93
101 std::string getError()
102 {
103 return _body.get().getError();
104 }
105
110 void reportSuccess(const ConnectionInfo& info_)
111 {
112 _body.get().reportSuccess(info_);
113 }
114
118 ServerChooser& add(const std::string& uri_)
119 {
120 _body.get().add(uri_);
121 return *this;
122 }
123
127 void remove(const std::string& uri_)
128 {
129 _body.get().remove(uri_);
130 }
131
132 ServerChooser(const ServerChooser& rhs) : _body(rhs._body)
133 {
134 }
135 ServerChooser(ServerChooser&& rhs) : _body(rhs._body)
136 {
137 }
138
139 ServerChooser& operator=(ServerChooser&& rhs)
140 {
141 _body = rhs._body;
142 return *this;
143 }
144 ServerChooser& operator=(const ServerChooser& rhs)
145 {
146 _body = rhs._body;
147 return *this;
148 }
149 };
150
151 } //namespace AMPS
152
153 #endif //_SERVERCHOOSER_H_
154
ampsplusplus.hpp
Core type, function, and class declarations for the AMPS C++ client.
AMPS::AMPSException
Base class for all exceptions in AMPS.
Definition: AMPSException.hpp:41
AMPS::Authenticator
The interface for handling authentication with the AMPS server.
Definition: ampsplusplus.hpp:1007
AMPS::ServerChooserImpl
Abstract base class for choosing amongst multiple URIs for both the initial connection and reconnecti...
Definition: ServerChooserImpl.hpp:40
AMPS::ServerChooser
Abstract base class for choosing amongst multiple URIs for both the initial connection and reconnecti...
Definition: ServerChooser.hpp:47
AMPS::ServerChooser::getError
std::string getError()
Provides additional detail to be included in an exception thrown when the AMPS instance(s) are not av...
Definition: ServerChooser.hpp:101
AMPS::ServerChooser::add
ServerChooser & add(const std::string &uri_)
Add a server to a server chooser if its policy permits.
Definition: ServerChooser.hpp:118
AMPS::ServerChooser::getCurrentAuthenticator
Authenticator & getCurrentAuthenticator()
Returns the Authenticator instance associated with the current URI.
Definition: ServerChooser.hpp:76
AMPS::ServerChooser::remove
void remove(const std::string &uri_)
Remove a server from a server chooser if its policy permits.
Definition: ServerChooser.hpp:127
AMPS::ServerChooser::reportSuccess
void reportSuccess(const ConnectionInfo &info_)
Called by the HAClient when successfully connected and logged on to the current instance.
Definition: ServerChooser.hpp:110
AMPS::ServerChooser::getCurrentURI
std::string getCurrentURI()
Returns the current URI.
Definition: ServerChooser.hpp:66
AMPS::ServerChooser::reportFailure
void reportFailure(const AMPSException &exception_, const ConnectionInfo &info_)
Called by HAClient when an error occurs connecting to the current URI, and/or when an error occurs lo...
Definition: ServerChooser.hpp:88