GammaLib 2.0.0
Loading...
Searching...
No Matches
GVOClient.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GVOClient.hpp - VO client class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2013-2019 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- *
6 * *
7 * This program is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19 * *
20 ***************************************************************************/
21/**
22 * @file GVOClient.hpp
23 * @brief VO client class interface definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GVOCLIENT_HPP
28#define GVOCLIENT_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include "GBase.hpp"
33
34/* __ Forward declarations _______________________________________________ */
35class GFitsHDU;
36class GXml;
37class GXmlNode;
38class GVOTable;
39
40
41/***********************************************************************//**
42 * @class GVOClient
43 *
44 * @brief VO client class
45 *
46 * This class implements a client for the Virtual Observatory. Upon
47 * construction of an instance of the class, the client will search for a
48 * VO Hub. The has_hub() method signals whether VO Hub information was
49 * found.
50 *
51 * The connect() method will connect the client to the VO Hub. If no VO
52 * Hub has been found or if the VO Hub that was found is not alive the
53 * client will start an own VO Hub using the GVOHub class. The
54 * is_connected() method signals whether the client is connected to a
55 * Hub.
56 *
57 * The disconnect() method disconnects a client from the VO Hub.
58 ***************************************************************************/
59class GVOClient : public GBase {
60
61public:
62 // Constructors and destructors
63 GVOClient(void);
64 GVOClient(const GVOClient& client);
65 virtual ~GVOClient(void);
66
67 // Operators
68 GVOClient& operator=(const GVOClient& client);
69
70 // Methods
71 void clear(void);
72 GVOClient* clone(void) const;
73 std::string classname(void) const;
74 void connect(void);
75 void disconnect(void);
76 bool has_hub(void) const;
77 bool is_connected(void) const;
78 bool ping_hub(void) const;
79 void shutdown_hub(void) const;
80 GXml execute(const std::string& request) const;
81 void publish(const GFitsHDU& hdu);
82 void publish(const GVOTable& votable);
83 std::string print(const GChatter& chatter = NORMAL) const;
84
85protected:
86 // Protected methods
87 void init_members(void);
88 void copy_members(const GVOClient& client);
89 void free_members(void);
90 bool find_hub(void);
91 bool require_hub(void);
92 void register_to_hub(void);
93 void unregister_from_hub(void);
94 void send_metadata(void) const;
95
96 // Low-level methods
97 void connect_to_hub(void) const;
98 void post_string(const std::string& string) const;
99 std::string receive_string(void) const;
100 std::string get_response_value(const GXml& xml, const std::string& name) const;
101 std::string get_hub_lockfile(void) const;
102 bool response_is_valid(const GXml& xml) const;
103 int response_error_code(const GXml& xml) const;
104 std::string response_error_message(const GXml& xml) const;
105
106 // Protected data area
107 std::string m_name; //!< Client name
108 std::string m_secret; //!< Secret Hub key
109 std::string m_hub_url; //!< The XML-RPC endpoint for communication with the hub
110 std::string m_hub_host; //!< Hub host (extracted from XML-RPC endpoint)
111 std::string m_hub_port; //!< Hub port (extracted from XML-RPC endpoint)
112 std::string m_hub_path; //!< Hub path (extracted from XML-RPC endpoint)
113 std::string m_version; //!< The version of the SAMP Standard Profile implemented by the hub
114 std::string m_client_key; //!< Private client key
115 std::string m_hub_id; //!< Hub identifier
116 std::string m_client_id; //!< Client identifier
117 mutable int m_socket; //!< Hub socket
118};
119
120
121/***********************************************************************//**
122 * @brief Return class name
123 *
124 * @return String containing the class name ("GVOClient").
125 ***************************************************************************/
126inline
127std::string GVOClient::classname(void) const
128{
129 return ("GVOClient");
130}
131
132#endif /* GVOCLIENT_HPP */
Definition of interface for all GammaLib classes.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
Interface class for all GammaLib classes.
Definition GBase.hpp:52
Abstract FITS extension base class.
Definition GFitsHDU.hpp:51
VO client class.
Definition GVOClient.hpp:59
std::string m_hub_host
Hub host (extracted from XML-RPC endpoint)
GVOClient * clone(void) const
Clone object.
int response_error_code(const GXml &xml) const
Return response error code.
std::string m_version
The version of the SAMP Standard Profile implemented by the hub.
std::string m_secret
Secret Hub key.
std::string response_error_message(const GXml &xml) const
Return response error message.
bool has_hub(void) const
Signals if client has VO Hub information.
std::string print(const GChatter &chatter=NORMAL) const
Print VO client information.
std::string m_hub_id
Hub identifier.
void free_members(void)
Delete class members.
bool response_is_valid(const GXml &xml) const
Checks if response is valid.
std::string m_hub_url
The XML-RPC endpoint for communication with the hub.
void post_string(const std::string &string) const
Post string content to Hub.
std::string m_name
Client name.
virtual ~GVOClient(void)
Destructor.
void publish(const GFitsHDU &hdu)
Publish FITS HDU.
void copy_members(const GVOClient &client)
Copy class members.
std::string get_hub_lockfile(void) const
Returns SAMP Hub lockfile URL.
std::string classname(void) const
Return class name.
void unregister_from_hub(void)
Unregister client from SAMP Hub.
void shutdown_hub(void) const
Shutdown VO Hub.
void connect(void)
Register client at VO Hub.
void send_metadata(void) const
Send client metadata to SAMP Hub.
void register_to_hub(void)
Register client at SAMP Hub.
void clear(void)
Clear object.
GXml execute(const std::string &request) const
Execute function on server.
std::string m_client_key
Private client key.
std::string m_client_id
Client identifier.
std::string m_hub_port
Hub port (extracted from XML-RPC endpoint)
GVOClient & operator=(const GVOClient &client)
Assignment operator.
void disconnect(void)
Unregister client from VO Hub.
GVOClient(void)
Void constructor.
Definition GVOClient.cpp:69
void init_members(void)
Initialise class members.
int m_socket
Hub socket.
void connect_to_hub(void) const
Connect to SAMP Hub.
std::string m_hub_path
Hub path (extracted from XML-RPC endpoint)
std::string get_response_value(const GXml &xml, const std::string &name) const
Returns value for a SAMP Hub response parameter.
bool find_hub(void)
Find VO Hub.
bool require_hub(void)
Require VO Hub.
std::string receive_string(void) const
Receive string content from Hub.
bool ping_hub(void) const
Ping VO Hub.
bool is_connected(void) const
Signals if client is connected to VO Hub.
VOTable class.
Definition GVOTable.hpp:55
Abstract XML node base class.
Definition GXmlNode.hpp:57
XML class.
Definition GXml.hpp:172