GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GVOClient Class Reference

VO client class. More...

#include <GVOClient.hpp>

Inheritance diagram for GVOClient:
GBase

Public Member Functions

 GVOClient (void)
 Void constructor. More...
 
 GVOClient (const GVOClient &client)
 Copy constructor. More...
 
virtual ~GVOClient (void)
 Destructor. More...
 
GVOClientoperator= (const GVOClient &client)
 Assignment operator. More...
 
void clear (void)
 Clear object. More...
 
GVOClientclone (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...
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Parameters
[in]clientVO client.

Definition at line 87 of file GVOClient.cpp.

References copy_members(), and init_members().

GVOClient::~GVOClient ( void  )
virtual

Destructor.

Definition at line 103 of file GVOClient.cpp.

References free_members().

Member Function Documentation

std::string GVOClient::classname ( void  ) const
inlinevirtual

Return class name.

Returns
String containing the class name ("GVOClient").

Implements GBase.

Definition at line 127 of file GVOClient.hpp.

void GVOClient::clear ( void  )
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().

GVOClient * GVOClient::clone ( void  ) const
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().

void GVOClient::connect_to_hub ( void  ) const
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().

void GVOClient::copy_members ( const GVOClient client)
protected

Copy class members.

Parameters
[in]clientVO 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.

Parameters
[in]requestXML request string
Returns
XML response

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().

bool GVOClient::find_hub ( void  )
protected

Find VO Hub.

Returns
True if VO Hub has been found, false otherwise.

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().

void GVOClient::free_members ( void  )
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().

std::string GVOClient::get_hub_lockfile ( void  ) const
protected

Returns SAMP Hub lockfile URL.

Returns
SAMP Hub lockfile URL (empty if no lockfile was found).

Implements IVOA standard REC-SAMP-1.3-20120411.

Definition at line 1168 of file GVOClient.cpp.

References gammalib::getenv().

Referenced by find_hub().

std::string GVOClient::get_response_value ( const GXml xml,
const std::string &  name 
) const
protected

Returns value for a SAMP Hub response parameter.

Parameters
[in]xmlHub response XML document.
[in]nameParameter name.
Returns
Parameter value.

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.

Returns
True if client has VO Hub information, false otherwise.

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().

void GVOClient::init_members ( void  )
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.

Returns
True if client is connected to VO Hub, false otherwise.

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().

GVOClient & GVOClient::operator= ( const GVOClient client)

Assignment operator.

Parameters
[in]clientVO client.
Returns
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.

Returns
True if VO Hub is alive, false otherwise.

Definition at line 267 of file GVOClient.cpp.

References execute(), and response_is_valid().

Referenced by require_hub().

void GVOClient::post_string ( const std::string &  content) const
protected

Post string content to Hub.

Parameters
[in]contentString 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().

std::string GVOClient::print ( const GChatter chatter = NORMAL) const
virtual

Print VO client information.

Parameters
[in]chatterChattiness.
Returns
String containing VO client information

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.

Parameters
[in]hduFITS 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.

Parameters
[in]votableVO 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().

std::string GVOClient::receive_string ( void  ) const
protected

Receive string content from Hub.

Returns
String received 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().

void GVOClient::register_to_hub ( void  )
protected

Register client at SAMP Hub.

Exceptions
GException::invalid_valueUnable 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().

bool GVOClient::require_hub ( void  )
protected

Require VO Hub.

Returns
True if VO Hub has been found, false otherwise.

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().

int GVOClient::response_error_code ( const GXml xml) const
protected

Return response error code.

Returns
Response error core (0 if no error occured).

Definition at line 1238 of file GVOClient.cpp.

References GXmlNode::element(), GXml::element(), and gammalib::toint().

Referenced by register_to_hub().

std::string GVOClient::response_error_message ( const GXml xml) const
protected

Return response error message.

Returns
Response error message (blank if no error occured).

Definition at line 1262 of file GVOClient.cpp.

References GXmlNode::element(), and GXml::element().

Referenced by register_to_hub().

bool GVOClient::response_is_valid ( const GXml xml) const
protected

Checks if response is valid.

Returns
True if response is valid, false otherwise.

Definition at line 1217 of file GVOClient.cpp.

References GXml::element().

Referenced by ping_hub(), and register_to_hub().

void GVOClient::send_metadata ( void  ) const
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

Shutdown VO Hub.

Definition at line 299 of file GVOClient.cpp.

References execute().

void GVOClient::unregister_from_hub ( void  )
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().

Member Data Documentation

std::string GVOClient::m_client_id
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().

std::string GVOClient::m_client_key
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().

std::string GVOClient::m_hub_host
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().

std::string GVOClient::m_hub_id
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().

std::string GVOClient::m_hub_path
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().

std::string GVOClient::m_hub_port
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().

std::string GVOClient::m_hub_url
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().

std::string GVOClient::m_name
protected

Client name.

Definition at line 107 of file GVOClient.hpp.

Referenced by copy_members(), init_members(), print(), and send_metadata().

std::string GVOClient::m_secret
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().

int GVOClient::m_socket
mutableprotected
std::string GVOClient::m_version
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().


The documentation for this class was generated from the following files: