GammaLib
2.0.0
|
VO client class. More...
#include <GVOClient.hpp>
Public Member Functions | |
GVOClient (void) | |
Void constructor. More... | |
GVOClient (const GVOClient &client) | |
Copy constructor. More... | |
virtual | ~GVOClient (void) |
Destructor. More... | |
GVOClient & | operator= (const GVOClient &client) |
Assignment operator. More... | |
void | clear (void) |
Clear object. More... | |
GVOClient * | clone (void) const |
Clone object. More... | |
std::string | classname (void) const |
Return class name. More... | |
void | connect (void) |
Register client at VO Hub. More... | |
void | disconnect (void) |
Unregister client from VO Hub. More... | |
bool | has_hub (void) const |
Signals if client has VO Hub information. More... | |
bool | is_connected (void) const |
Signals if client is connected to VO Hub. More... | |
bool | ping_hub (void) const |
Ping VO Hub. More... | |
void | shutdown_hub (void) const |
Shutdown VO Hub. More... | |
GXml | execute (const std::string &request) const |
Execute function on server. More... | |
void | publish (const GFitsHDU &hdu) |
Publish FITS HDU. More... | |
void | publish (const GVOTable &votable) |
Publish VO table. More... | |
std::string | print (const GChatter &chatter=NORMAL) const |
Print VO client information. More... | |
Public Member Functions inherited from GBase | |
virtual | ~GBase (void) |
Destructor. More... | |
Protected Member Functions | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GVOClient &client) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
bool | find_hub (void) |
Find VO Hub. More... | |
bool | require_hub (void) |
Require VO Hub. More... | |
void | register_to_hub (void) |
Register client at SAMP Hub. More... | |
void | unregister_from_hub (void) |
Unregister client from SAMP Hub. More... | |
void | send_metadata (void) const |
Send client metadata to SAMP Hub. More... | |
void | connect_to_hub (void) const |
Connect to SAMP Hub. More... | |
void | post_string (const std::string &string) const |
Post string content to Hub. More... | |
std::string | receive_string (void) const |
Receive string content from Hub. More... | |
std::string | get_response_value (const GXml &xml, const std::string &name) const |
Returns value for a SAMP Hub response parameter. More... | |
std::string | get_hub_lockfile (void) const |
Returns SAMP Hub lockfile URL. More... | |
bool | response_is_valid (const GXml &xml) const |
Checks if response is valid. More... | |
int | response_error_code (const GXml &xml) const |
Return response error code. More... | |
std::string | response_error_message (const GXml &xml) const |
Return response error message. More... | |
Protected Attributes | |
std::string | m_name |
Client name. More... | |
std::string | m_secret |
Secret Hub key. More... | |
std::string | m_hub_url |
The XML-RPC endpoint for communication with the hub. More... | |
std::string | m_hub_host |
Hub host (extracted from XML-RPC endpoint) More... | |
std::string | m_hub_port |
Hub port (extracted from XML-RPC endpoint) More... | |
std::string | m_hub_path |
Hub path (extracted from XML-RPC endpoint) More... | |
std::string | m_version |
The version of the SAMP Standard Profile implemented by the hub. More... | |
std::string | m_client_key |
Private client key. More... | |
std::string | m_hub_id |
Hub identifier. More... | |
std::string | m_client_id |
Client identifier. More... | |
int | m_socket |
Hub socket. More... | |
VO client class.
This class implements a client for the Virtual Observatory. Upon construction of an instance of the class, the client will search for a VO Hub. The has_hub() method signals whether VO Hub information was found.
The connect() method will connect the client to the VO Hub. If no VO Hub has been found or if the VO Hub that was found is not alive the client will start an own VO Hub using the GVOHub class. The is_connected() method signals whether the client is connected to a Hub.
The disconnect() method disconnects a client from the VO Hub.
Definition at line 59 of file GVOClient.hpp.
GVOClient::GVOClient | ( | void | ) |
Void constructor.
Definition at line 69 of file GVOClient.cpp.
References find_hub(), and init_members().
Referenced by clone().
GVOClient::GVOClient | ( | const GVOClient & | client | ) |
Copy constructor.
[in] | client | VO client. |
Definition at line 87 of file GVOClient.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GBase.
Definition at line 127 of file GVOClient.hpp.
|
virtual |
Clear object.
Reset object to a clean initial state.
Implements GBase.
Definition at line 157 of file GVOClient.cpp.
References free_members(), and init_members().
|
virtual |
Clone object.
Implements GBase.
Definition at line 173 of file GVOClient.cpp.
References GVOClient().
void GVOClient::connect | ( | void | ) |
Register client at VO Hub.
Registers a client at the VO Hub. The method will search for a VO Hub, launch it's own VO Hub if no Hub was found, and the register the client at the Hub, including sending of metadata.
Definition at line 187 of file GVOClient.cpp.
References has_hub(), register_to_hub(), require_hub(), and send_metadata().
Referenced by connect_to_hub(), and publish().
|
protected |
Connect to SAMP Hub.
Connects to Hub by creating a socket and connecting to this socket. The method expects that a Hub has already been found. If no Hub has been found (i.e. has_hub() returns false), the method does nothing.
The method extracts the hostname and the port from the Hub endpoint URL. If Hub connection fails, any created socket is closed.
If the method is successful, m_socket will contain on exit a non-negative number. If any failure occurs, m_socket will be set to -1.
Definition at line 972 of file GVOClient.cpp.
References connect(), m_hub_host, m_hub_port, and m_socket.
Referenced by execute().
|
protected |
Copy class members.
[in] | client | VO client. |
Definition at line 597 of file GVOClient.cpp.
References m_client_id, m_client_key, m_hub_host, m_hub_id, m_hub_path, m_hub_port, m_hub_url, m_name, m_secret, m_socket, and m_version.
Referenced by GVOClient(), and operator=().
void GVOClient::disconnect | ( | void | ) |
Unregister client from VO Hub.
Disconnects the VO client from the VO Hub. The client is unregistered.
Definition at line 213 of file GVOClient.cpp.
References has_hub(), m_socket, and unregister_from_hub().
Referenced by publish().
GXml GVOClient::execute | ( | const std::string & | request | ) | const |
Execute function on server.
[in] | request | XML request string |
Definition at line 327 of file GVOClient.cpp.
References connect_to_hub(), m_socket, post_string(), and receive_string().
Referenced by ping_hub(), publish(), register_to_hub(), send_metadata(), shutdown_hub(), and unregister_from_hub().
|
protected |
Find VO Hub.
Search a valid VO Hub and retrieve all mandatory token for this Hub. The mandatory tokens are
samp.secret Opaque text string required for Hub registration samp.hub.xmlrpc.url XML-RPC endpoint for communication samp.profile.version Version of SAMP profile
Implements IVOA standard REC-SAMP-1.3-20120411.
Definition at line 650 of file GVOClient.cpp.
References get_hub_lockfile(), has_hub(), m_hub_host, m_hub_path, m_hub_port, m_hub_url, m_secret, m_version, and gammalib::strip_chars().
Referenced by GVOClient(), and require_hub().
|
protected |
Delete class members.
Definition at line 620 of file GVOClient.cpp.
References m_socket, and unregister_from_hub().
Referenced by clear(), operator=(), and ~GVOClient().
|
protected |
Returns SAMP Hub lockfile URL.
Implements IVOA standard REC-SAMP-1.3-20120411.
Definition at line 1168 of file GVOClient.cpp.
References gammalib::getenv().
Referenced by find_hub().
|
protected |
Returns value for a SAMP Hub response parameter.
[in] | xml | Hub response XML document. |
[in] | name | Parameter name. |
Returns value for a SAMP Hub response parameter. If the specified parameter was not found or if the response structure is not compliant, an empty string is returned.
Definition at line 1134 of file GVOClient.cpp.
References GXmlNode::element(), GXml::element(), GXmlNode::elements(), and gammalib::xml_get_name_value_pair().
Referenced by register_to_hub().
bool GVOClient::has_hub | ( | void | ) | const |
Signals if client has VO Hub information.
Checks if all mandatory VO Hub tokens are non-empty.
Definition at line 241 of file GVOClient.cpp.
References m_hub_url, m_secret, and m_version.
Referenced by connect(), disconnect(), find_hub(), and print().
|
protected |
Initialise class members.
Definition at line 572 of file GVOClient.cpp.
References m_client_id, m_client_key, m_hub_host, m_hub_id, m_hub_path, m_hub_port, m_hub_url, m_name, m_secret, m_socket, and m_version.
Referenced by clear(), GVOClient(), and operator=().
bool GVOClient::is_connected | ( | void | ) | const |
Signals if client is connected to VO Hub.
Checks if the clients has non-empty client key, Hub ID and client ID.
Definition at line 255 of file GVOClient.cpp.
References m_client_id, m_client_key, and m_hub_id.
Referenced by print(), publish(), and unregister_from_hub().
Assignment operator.
[in] | client | VO client. |
Definition at line 125 of file GVOClient.cpp.
References copy_members(), free_members(), and init_members().
bool GVOClient::ping_hub | ( | void | ) | const |
Ping VO Hub.
Definition at line 267 of file GVOClient.cpp.
References execute(), and response_is_valid().
Referenced by require_hub().
|
protected |
Post string content to Hub.
[in] | content | String content to post |
Posts the content of a string to the Hub.
The method does nothing if no Hub connection has been established.
Definition at line 1037 of file GVOClient.cpp.
References m_hub_path, m_socket, and gammalib::str().
Referenced by execute().
Print VO client information.
[in] | chatter | Chattiness. |
Implements GBase.
Definition at line 513 of file GVOClient.cpp.
References has_hub(), is_connected(), m_client_id, m_client_key, m_hub_host, m_hub_id, m_hub_path, m_hub_port, m_hub_url, m_name, m_secret, m_version, gammalib::parformat(), and SILENT.
void GVOClient::publish | ( | const GFitsHDU & | hdu | ) |
Publish FITS HDU.
[in] | hdu | FITS HDU |
Publishes a FITS HDU.
Definition at line 372 of file GVOClient.cpp.
References GFits::append(), connect(), disconnect(), execute(), GFitsHDU::extname(), is_connected(), m_client_key, GFits::saveto(), and gammalib::tmpnam().
Referenced by GFits::publish(), and GSkyMap::publish().
void GVOClient::publish | ( | const GVOTable & | votable | ) |
Publish VO table.
[in] | votable | VO table |
Publishes a VO table.
Definition at line 445 of file GVOClient.cpp.
References connect(), disconnect(), execute(), is_connected(), m_client_key, GVOTable::name(), GXml::save(), gammalib::tmpnam(), and GVOTable::xml().
|
protected |
Receive string content from Hub.
Reads information sent by Hub into a string.
The method does nothing if no Hub connection has been established.
Definition at line 1088 of file GVOClient.cpp.
References m_socket, and gammalib::recv().
Referenced by execute().
|
protected |
Register client at SAMP Hub.
GException::invalid_value | Unable to connect to Hub. |
Definition at line 816 of file GVOClient.cpp.
References execute(), G_REGISTER_TO_HUB, get_response_value(), m_client_id, m_client_key, m_hub_id, m_secret, response_error_code(), response_error_message(), response_is_valid(), and gammalib::str().
Referenced by connect().
|
protected |
Require VO Hub.
Make sure that a VO Hub is available and alive. If no VO Hub is found or alive the method will start a GammaLib internal Hub.
Definition at line 753 of file GVOClient.cpp.
References find_hub(), G_REQUIRE_HUB, m_hub_url, m_secret, m_version, ping_hub(), and GVOHub::start().
Referenced by connect().
|
protected |
Return response error code.
Definition at line 1238 of file GVOClient.cpp.
References GXmlNode::element(), GXml::element(), and gammalib::toint().
Referenced by register_to_hub().
|
protected |
Return response error message.
Definition at line 1262 of file GVOClient.cpp.
References GXmlNode::element(), and GXml::element().
Referenced by register_to_hub().
|
protected |
Checks if response is valid.
Definition at line 1217 of file GVOClient.cpp.
References GXml::element().
Referenced by ping_hub(), and register_to_hub().
|
protected |
Send client metadata to SAMP Hub.
Definition at line 891 of file GVOClient.cpp.
References execute(), m_client_key, and m_name.
Referenced by connect().
void GVOClient::shutdown_hub | ( | void | ) | const |
|
protected |
Unregister client from SAMP Hub.
Definition at line 856 of file GVOClient.cpp.
References execute(), is_connected(), m_client_id, m_client_key, and m_hub_id.
Referenced by disconnect(), and free_members().
|
protected |
Client identifier.
Definition at line 116 of file GVOClient.hpp.
Referenced by copy_members(), init_members(), is_connected(), print(), register_to_hub(), and unregister_from_hub().
|
protected |
Private client key.
Definition at line 114 of file GVOClient.hpp.
Referenced by copy_members(), init_members(), is_connected(), print(), publish(), register_to_hub(), send_metadata(), and unregister_from_hub().
|
protected |
Hub host (extracted from XML-RPC endpoint)
Definition at line 110 of file GVOClient.hpp.
Referenced by connect_to_hub(), copy_members(), find_hub(), init_members(), and print().
|
protected |
Hub identifier.
Definition at line 115 of file GVOClient.hpp.
Referenced by copy_members(), init_members(), is_connected(), print(), register_to_hub(), and unregister_from_hub().
|
protected |
Hub path (extracted from XML-RPC endpoint)
Definition at line 112 of file GVOClient.hpp.
Referenced by copy_members(), find_hub(), init_members(), post_string(), and print().
|
protected |
Hub port (extracted from XML-RPC endpoint)
Definition at line 111 of file GVOClient.hpp.
Referenced by connect_to_hub(), copy_members(), find_hub(), init_members(), and print().
|
protected |
The XML-RPC endpoint for communication with the hub.
Definition at line 109 of file GVOClient.hpp.
Referenced by copy_members(), find_hub(), has_hub(), init_members(), print(), and require_hub().
|
protected |
Client name.
Definition at line 107 of file GVOClient.hpp.
Referenced by copy_members(), init_members(), print(), and send_metadata().
|
protected |
Secret Hub key.
Definition at line 108 of file GVOClient.hpp.
Referenced by copy_members(), find_hub(), has_hub(), init_members(), print(), register_to_hub(), and require_hub().
|
mutableprotected |
Hub socket.
Definition at line 117 of file GVOClient.hpp.
Referenced by connect_to_hub(), copy_members(), disconnect(), execute(), free_members(), init_members(), post_string(), and receive_string().
|
protected |
The version of the SAMP Standard Profile implemented by the hub.
Definition at line 113 of file GVOClient.hpp.
Referenced by copy_members(), find_hub(), has_hub(), init_members(), print(), and require_hub().