Qore ConnectionProvider Module Reference  1.3
AbstractConnection.qc.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
2 // Qore AbstractConnection class definition
3 
4 /* AbstractConnection.qc Copyright 2016 - 2019 Qore Technologies, s.r.o.
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23 */
24 
25 
27 namespace ConnectionProvider {
29 
31 class AbstractConnection : public Serializable {
32 
33 public:
35  string name;
36 
38  string desc;
39 
41  string url;
42 
44  string safe_url;
45 
47  *hash<auto> orig_opts;
48 
50  *hash<auto> opts;
51 
53  hash<auto> urlh;
54 
57 
59  string status = "not checked";
60 
62  bool up = False;
63 
65  bool monitor;
66 
69 
71  bool loopback = False;
72 
74  static *code post_processing;
75 
77  bool enabled = True;
78 
80  bool locked = False;
81 
83  bool debug_data = False;
84 
86  hash<auto> tags = {};
87 
89  hash<auto> internal_info;
90 
92 
101  deprecated
102 constructor(string n_name, string n_desc, string n_url, bool n_monitor, *hash n_opts, hash n_urlh, *string n_safe_url, *bool n_enabled);
103 
104 
106 
122  constructor(string name, string description, string url, hash<auto> attributes = {}, hash<auto> options = {});
123 
124 
125 private:
126  constructorInit(string name, string description, string url, hash<auto> attributes, hash<auto> options);
127 public:
128 
129 
131 
137  hash<auto> validateOptions(hash<auto> options);
138 
139 
141 
149 protected:
150  hash<UrlInfo> parseUrl(string url);
151 public:
152 
153 
155 
168 protected:
169  string getSafeUrl(hash<auto> urlh);
170 public:
171 
172 
174 
178  hash<PingInfo> ping(bool throw_exception = False);
179 
180 
182 protected:
183  hash<PingInfo> pingIntern(hash<PingInfo> rv);
184 public:
185 
186 
188 
192  hash<ConnectionInfo> getInfo(bool with_password = False);
193 
194 
196 
198  hash<ConfigInfo> getConfigHash();
199 
200 
202  *hash<auto> getOptions();
203 
204 
206  *hash<auto> getRuntimeOptions();
207 
208 
210  *hash<auto> getDefaultOptions();
211 
212 
214  *hash<auto> getRealOptions();
215 
216 
218 
220  object get(bool connect = True, *hash<auto> rtopts);
221 
222 
224 
227 
228 
230  hash<auto> getTags();
231 
232 
234  auto getTag(string tag);
235 
236 
238 
240  auto getTagEx(string tag);
241 
242 
244 
255  AbstractDataProvider getDataProvider();
256 
257 
259 
268  bool hasDataProvider();
269 
270 
272 
277 protected:
278  abstract object getImpl(bool connect = True, *hash<auto> rtopts);
279 public:
280 
282  abstract string getType();
283  };
284 }; // ConnectionProvider namespace
parseTextOptions()
this method is called when parsing connection file definitions from text files when loading into the ...
auto getTag(string tag)
returns the value of the given tag or NOTHING if not present
bool monitor
monitoring flag
Definition: AbstractConnection.qc.dox.h:65
date date(date dt)
hash< auto > internal_info
internal tags
Definition: AbstractConnection.qc.dox.h:89
date last_check
date/time of last check/ping
Definition: AbstractConnection.qc.dox.h:56
bool locked
locked/unlocked flag
Definition: AbstractConnection.qc.dox.h:80
hash< ConnectionInfo > getInfo(bool with_password=False)
returns a ConnectionInfo hash of information about the connection
string getSafeUrl(hash< auto > urlh)
creates a "safe" URL string with password information removed
*hash< auto > getOptions()
returns static / initialization options
const True
deprecated constructor(string n_name, string n_desc, string n_url, bool n_monitor, *hash n_opts, hash n_urlh, *string n_safe_url, *bool n_enabled)
creates the AbstractConnection object
string name
connection name
Definition: AbstractConnection.qc.dox.h:35
hash< auto > urlh
broken down URL hash (as returned by Qore::parse_url())
Definition: AbstractConnection.qc.dox.h:53
*hash< auto > opts
connection options
Definition: AbstractConnection.qc.dox.h:50
static *code post_processing
optional code for default post-processing of objects created by getImpl(); must take the connection o...
Definition: AbstractConnection.qc.dox.h:74
hash< PingInfo > ping(bool throw_exception=False)
returns a hash with the results of the ping operation
const False
string status
status string; in case of a connection error this string will be the error string
Definition: AbstractConnection.qc.dox.h:59
hash< auto > tags
connection tags; user-defined key-value pairs
Definition: AbstractConnection.qc.dox.h:86
bool hasDataProvider()
returns True if the connection returns a data provider with the getDataProvider() method
abstract base class for connections
Definition: AbstractConnection.qc.dox.h:31
AbstractDataProvider getDataProvider()
returns a data provider object for this connection, if supported
string safe_url
"safe" URL (password information removed)
Definition: AbstractConnection.qc.dox.h:44
*hash< auto > getRealOptions()
returns options for saving the connection's configuration information
bool enabled
enabled/disabled indicator flag
Definition: AbstractConnection.qc.dox.h:77
auto getTagEx(string tag)
returns the value of the given tag or throws an exception if the tag is not set with a value
abstract object getImpl(bool connect=True, *hash< auto > rtopts)
this method must return the connection object corresponding to the object's configuration
abstract string getType()
returns the string type name for the connection object
hash< ConfigInfo > getConfigHash()
returns a ConfigInfo hash of static configuration information about the connection
hash< auto > getTags()
returns all tags associated with the connection
string desc
connection description
Definition: AbstractConnection.qc.dox.h:38
hash< auto > hash(object obj)
date updated
date/time of last update
Definition: AbstractConnection.qc.dox.h:68
hash< auto > validateOptions(hash< auto > options)
performs options validation in the constructor
object get(bool connect=True, *hash< auto > rtopts)
returns the underlying connection object
hash< UrlInfo > parseUrl(string url)
Parse the URL to a hash.
bool up
connection status flag; set by monitoring or explicit pings/connections
Definition: AbstractConnection.qc.dox.h:62
*hash< auto > getRuntimeOptions()
returns runtime options
string url
connection URL (potentially with password info)
Definition: AbstractConnection.qc.dox.h:41
bool debug_data
debug data flag; to be used an an indication for a higher-level implementation
Definition: AbstractConnection.qc.dox.h:83
*hash< auto > orig_opts
original connection options
Definition: AbstractConnection.qc.dox.h:47
hash< PingInfo > pingIntern(hash< PingInfo > rv)
performs the ping by executing get(); returns a PingInfo hash
bool loopback
set to True for loopback connections
Definition: AbstractConnection.qc.dox.h:71
the ConnectionProvider namespace. All classes used in the ConnectionProvider module should be inside ...
Definition: AbstractConnection.qc.dox.h:27
*hash< auto > getDefaultOptions()
returns default options