Skip to content

Commit

Permalink
gaia: extend astrocat open command to test if catalogue is already open
Browse files Browse the repository at this point in the history
  • Loading branch information
pwdraper committed Aug 8, 2014
1 parent f89832a commit eb7bbc3
Show file tree
Hide file tree
Showing 3 changed files with 304 additions and 1 deletion.
14 changes: 13 additions & 1 deletion applications/gaia/gaia/generic/GaiaSkySearch.C
Expand Up @@ -119,7 +119,7 @@ public:
{"imgplot", &GaiaSkySearch::imgplotCmd, 1, 4},
{"info", &GaiaSkySearch::infoCmd, 1, 2},
{"namesvr", &GaiaSkySearch::namesvrCmd, 2, 2},
{"open", &GaiaSkySearch::openCmd, 1, 2},
{"open", &GaiaSkySearch::openCmd, 0, 2},
{"origin", &GaiaSkySearch::originCmd, 0, 2},
{"save", &GaiaSkySearch::saveCmd, 1, 5},
{"setequinox", &GaiaSkySearch::setequinoxCmd, 1, 1}
Expand Down Expand Up @@ -225,6 +225,18 @@ GaiaSkySearch::~GaiaSkySearch()
*/
int GaiaSkySearch::openCmd(int argc, char* argv[])
{
// Return if a catalogue is open if no args are given.
if ( argc == 0 ) {
if ( cat_ ) {
set_result( "1" );
}
else {
set_result( "0" );
}
return TCL_OK;
}


if ( cat_ ) {
delete cat_;
cat_ = NULL;
Expand Down
115 changes: 115 additions & 0 deletions applications/gaia/gaiavo/library/GaiaVORegV1.tcl
@@ -0,0 +1,115 @@
#+
# Name:
# GaiaVORegV1

# Type of Module:
# [incr Tcl] class

# Purpose:
# Utilities methods for RI1.0.

# Description:
# Provides a number of methods that describe the registries
# interface version 1.0.

# Invocations:
#
# GaiaVORegV1 object_name [configuration options]
#
# This creates an instance of a GaiaTAPQuery object. The return is
# the name of the object.
#
# object_name configure -configuration_options value
#
# Applies any of the configuration options (after the instance has
# been created).
#
# object_name method arguments
#
# Performs the given method on this object.

# Copyright:
# Copyright (C) 2014 Science and Technology Facilities Council
# All Rights Reserved.

# Licence:
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street,Fifth Floor, Boston, MA
# 02110-1301, USA

# Authors:
# PWD: Peter Draper (JAC, Durham University)
# {enter_new_authors_here}

# History:
# 04-AUG-2014 (PWD):
# Original version.
# {enter_further_changes_here}

#-

#.

itcl::class gaiavo::GaiaVORegV1 {

# Inheritances:
# -------------

# Nothing

# Constructor:
# ------------
constructor {args} {
# Nothing to do, just a holder for static methods.
}

# Destructor:
# -----------
destructor {
}

# Methods:
# --------

# Get the default registry endpoints. Returns a list of pairs of values,
# a symbolic name followed by the endpoint.
public proc get_registries {} {
return [::array get registries_]
}

# Add a new registry to the default list. Not peristent.
public proc add_registry {shortname url} {
set registries_($shortname) $url
}

# Get the "default" registry.
public proc default_registry {} {
return [list AstroGrid $registries_(AstroGrid)]
}

# Configuration options: (public variables)
# ----------------------


# Common variables: (shared by all instances)
# -----------------

# Known RegV1 servers. Needed to boot this process.
protected common registries_
set registries_(NVO) "http://nvo.stsci.edu/vor10/ristandardservice.asmx"
set registries_(AstroGrid) \
"http://registry.astrogrid.org/astrogrid-registry/services/RegistryQueryv1_0"

# End of class definition.
}
176 changes: 176 additions & 0 deletions applications/gaia/gaiavo/library/GaiaVORegV1Query.tcl
@@ -0,0 +1,176 @@
#+
# Name:
# GaiaVORegV1Query

# Type of Module:
# [incr Tcl] class

# Purpose:
# Class defining utilities methods for RI1.0.

# Description:
# Provides a number of methods that describe the registries
# interface version 1.0.

# Invocations:
#
# GaiaVORegV1Query object_name [configuration options]
#
# This creates an instance of a GaiaTAPQuery object. The return is
# the name of the object.
#
# object_name configure -configuration_options value
#
# Applies any of the configuration options (after the instance has
# been created).
#
# object_name method arguments
#
# Performs the given method on this object.

# Copyright:
# Copyright (C) 2014 Science and Technology Facilities Council
# All Rights Reserved.

# Licence:
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street,Fifth Floor, Boston, MA
# 02110-1301, USA

# Authors:
# PWD: Peter Draper (JAC, Durham University)
# {enter_new_authors_here}

# History:
# 04-AUG-2014 (PWD):
# Original version.
# {enter_further_changes_here}

#-

#.

itcl::class gaiavo::GaiaVORegV1Query {

# Singleton entry point:
# ----------------------
proc instance {} {
if { $instance_ == {} } {
set instance_ [GaiaVORegV1Query ::\#auto]
}
return $instance_
}

# Inheritances:
# -------------

# Nothing

# Constructor:
# ------------
constructor {args} {
# Nothing to do, just a holder for static methods.
}

# Destructor:
# -----------
destructor {
}

# Methods:
# --------

# Return the service type.
public method get_type {} {
return "RegV1"
}

# Get the default registry endpoints. Returns a list of pairs of values,
# a symbolic name followed by the endpoint.
public method get_registries {} {
return [::array get registries_]
}

# Add a new registry to the default list. Not peristent.
public method add_registry {shortname url} {
set registries_($shortname) $url
}

# Get the "default" registry.
public method default_registry {} {
return [list AstroGrid $registries_(AstroGrid)]
}

# Get the standard id for a service type shortname.
public method get_standard_id {name} {
return $standardIDs_($name)
}

# Get the default columns to show.
public method default_columns {} {
return "$default_columns_"
}

# Extract the access url from a row of values. The headers are the
# names of the associated columns.
public method get_access_url {row headers} {
eval lassign "$row" $headers
if { [info exists accessURL] } {
return $accessURL
}
return {}
}

# Extract a name for a service from a row of values. The headers are the
# names of the associated columns.
public method get_name {row headers} {
eval lassign "$row" $headers
if { [info exists shortName] && $shortName != {} } {
return $shortName
}
if { [info exists title] } {
return $title
}
return {}
}

# Configuration options: (public variables)
# ----------------------


# Common variables: (shared by all instances)
# -----------------

# The instance of this class.
protected common instance_ {}

# Known RegV1 servers. Needed to boot this process.
protected common registries_
set registries_(NVO) "http://nvo.stsci.edu/vor10/ristandardservice.asmx"
set registries_(AstroGrid) \
"http://registry.astrogrid.org/astrogrid-registry/services/RegistryQueryv1_0"

# Mapping of short service names to their standard ids. Yes these differ
# in case from RegTAP.
protected common standardIDs_
set standardIDs_(SIAP) "ivo://ivoa.net/std/SIA"
set standardIDs_(SSAP) "ivo://ivoa.net/std/SSA"
set standardIDs_(CONE) "ivo://ivoa.net/std/ConeSearch"
set standardIDs_(TAP) "ivo://ivoa.net/std/TAP"

# Default columns to show in table views.
protected common default_columns_ "shortName title"

# End of class definition.
}

0 comments on commit eb7bbc3

Please sign in to comment.