GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 _______________________________________________ */
35 class GFitsHDU;
36 class GXml;
37 class GXmlNode;
38 class 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  ***************************************************************************/
59 class GVOClient : public GBase {
60 
61 public:
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 
85 protected:
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  ***************************************************************************/
126 inline
127 std::string GVOClient::classname(void) const
128 {
129  return ("GVOClient");
130 }
131 
132 #endif /* GVOCLIENT_HPP */
bool ping_hub(void) const
Ping VO Hub.
Definition: GVOClient.cpp:267
Abstract XML node base class.
Definition: GXmlNode.hpp:57
VO client class.
Definition: GVOClient.hpp:59
void connect_to_hub(void) const
Connect to SAMP Hub.
Definition: GVOClient.cpp:972
std::string m_name
Client name.
Definition: GVOClient.hpp:107
GXml execute(const std::string &request) const
Execute function on server.
Definition: GVOClient.cpp:327
void clear(void)
Clear object.
Definition: GVOClient.cpp:157
GVOClient * clone(void) const
Clone object.
Definition: GVOClient.cpp:173
void publish(const GFitsHDU &hdu)
Publish FITS HDU.
Definition: GVOClient.cpp:372
Abstract FITS extension base class.
Definition: GFitsHDU.hpp:51
std::string receive_string(void) const
Receive string content from Hub.
Definition: GVOClient.cpp:1088
Definition of interface for all GammaLib classes.
std::string get_response_value(const GXml &xml, const std::string &name) const
Returns value for a SAMP Hub response parameter.
Definition: GVOClient.cpp:1134
void shutdown_hub(void) const
Shutdown VO Hub.
Definition: GVOClient.cpp:299
std::string m_version
The version of the SAMP Standard Profile implemented by the hub.
Definition: GVOClient.hpp:113
void disconnect(void)
Unregister client from VO Hub.
Definition: GVOClient.cpp:213
std::string m_hub_url
The XML-RPC endpoint for communication with the hub.
Definition: GVOClient.hpp:109
std::string m_hub_path
Hub path (extracted from XML-RPC endpoint)
Definition: GVOClient.hpp:112
std::string print(const GChatter &chatter=NORMAL) const
Print VO client information.
Definition: GVOClient.cpp:513
bool find_hub(void)
Find VO Hub.
Definition: GVOClient.cpp:650
std::string m_secret
Secret Hub key.
Definition: GVOClient.hpp:108
void unregister_from_hub(void)
Unregister client from SAMP Hub.
Definition: GVOClient.cpp:856
int m_socket
Hub socket.
Definition: GVOClient.hpp:117
virtual ~GVOClient(void)
Destructor.
Definition: GVOClient.cpp:103
bool require_hub(void)
Require VO Hub.
Definition: GVOClient.cpp:753
std::string m_hub_host
Hub host (extracted from XML-RPC endpoint)
Definition: GVOClient.hpp:110
std::string m_client_id
Client identifier.
Definition: GVOClient.hpp:116
XML class.
Definition: GXml.hpp:172
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
std::string m_client_key
Private client key.
Definition: GVOClient.hpp:114
GChatter
Definition: GTypemaps.hpp:33
bool is_connected(void) const
Signals if client is connected to VO Hub.
Definition: GVOClient.cpp:255
std::string classname(void) const
Return class name.
Definition: GVOClient.hpp:127
int response_error_code(const GXml &xml) const
Return response error code.
Definition: GVOClient.cpp:1238
bool response_is_valid(const GXml &xml) const
Checks if response is valid.
Definition: GVOClient.cpp:1217
bool has_hub(void) const
Signals if client has VO Hub information.
Definition: GVOClient.cpp:241
std::string m_hub_port
Hub port (extracted from XML-RPC endpoint)
Definition: GVOClient.hpp:111
void copy_members(const GVOClient &client)
Copy class members.
Definition: GVOClient.cpp:597
std::string get_hub_lockfile(void) const
Returns SAMP Hub lockfile URL.
Definition: GVOClient.cpp:1168
void send_metadata(void) const
Send client metadata to SAMP Hub.
Definition: GVOClient.cpp:891
GVOClient(void)
Void constructor.
Definition: GVOClient.cpp:69
void connect(void)
Register client at VO Hub.
Definition: GVOClient.cpp:187
GVOClient & operator=(const GVOClient &client)
Assignment operator.
Definition: GVOClient.cpp:125
VOTable class.
Definition: GVOTable.hpp:55
std::string response_error_message(const GXml &xml) const
Return response error message.
Definition: GVOClient.cpp:1262
void init_members(void)
Initialise class members.
Definition: GVOClient.cpp:572
void free_members(void)
Delete class members.
Definition: GVOClient.cpp:620
void register_to_hub(void)
Register client at SAMP Hub.
Definition: GVOClient.cpp:816
void post_string(const std::string &string) const
Post string content to Hub.
Definition: GVOClient.cpp:1037
std::string m_hub_id
Hub identifier.
Definition: GVOClient.hpp:115