#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include "VOClient.h"
Functions | |
RegResult | voc_regSearch (char *term1, char *term2, int orValues) |
High-level Registry query interface. | |
RegResult | voc_regSearchByService (char *svc, char *term, int orValues) |
Search Registry using a search term and service constraint. | |
RegQuery | voc_regQuery (char *term, int orValues) |
Create a RegistryQuery object. | |
void | voc_regAddSearchTerm (RegQuery query, char *term, int orValue) |
Add a search term to the specified query. | |
void | voc_regRemoveSearchTerm (RegQuery query, char *term) |
Remove a search term to the specified query. | |
void | voc_regConstWaveband (RegQuery query, char *waveband) |
Constrain the Registry search by waveband. | |
void | voc_regConstSvcType (RegQuery query, char *svcType) |
void | voc_regDALOnly (RegQuery query, int value) |
Set the "DAL Only" flag. | |
void | voc_regSortRes (RegQuery query, int value) |
Set the resource "sort" flag. | |
int | voc_regGetSTCount (RegQuery query) |
Get the number of search terms in the current query. | |
char * | voc_regGetQueryString (RegQuery query) |
Get the current query as an http GET URL. | |
RegResult | voc_regExecute (RegQuery query) |
Execute the specified query. | |
char * | voc_regExecuteRaw (RegQuery query) |
Execute the specified query and return raw result string. | |
int | voc_resGetCount (RegResult res) |
Return a count of the number of results records. | |
char * | voc_resGetStr (RegResult res, char *attribute, int index) |
Get a string-valued attribute from the result resource record. | |
double | voc_resGetFloat (RegResult res, char *attribute, int index) |
Get a real-valued attribute from the result resource record. | |
int | voc_resGetInt (RegResult res, char *attribute, int index) |
Get an int-valued attribute from the result resource record. | |
Variables | |
VOClient * | vo |
RegistryQuery ----------------------
High-Level Query:
res = voc_regSearch (sql, keywords, orValues) res =voc_regSearchByService (svc, term, orValues)
Programmatic Query:
query = voc_regQuery (term, orValues) // OR keyword list?
voc_regConstSvcType (query, svcType) // search constraints voc_regConstWaveband (query, waveband) voc_regDALOnly (query, value) voc_regSortRes (query, value)
voc_regAddSearchTerm (query, term, orValue) // OR term w/ previous voc_regRemoveSearchTerm (query, term) // remove search term count = voc_regGetSTCount (query)
str = voc_regGetQueryString (query) // GET form of query
res = voc_regExecute (query) // return result obj str = voc_regExecuteRaw (query) // return raw XML
RegistryQueryResult
count = voc_resGetCount (res)
str = voc_resGetStr (res, attribute, index) dval = voc_resGetFloat (res, attribute, index) ival = voc_resGetInt (res, attribute, index)
For this implementation, we've chose to use the NVO Registry at JHU/STScI, specifically the QueryRegistry() method which provides a 'SimpleResource' form of the resource record. Support for the newer IVOA standard will be added later, for now we can quickly access the most commonly used fields of a resource using both a keyword and SQL form of the search.
void voc_regAddSearchTerm | ( | RegQuery | query, | |
char * | term, | |||
int | orValue | |||
) |
Add a search term to the specified query.
VOC_REGADDSEARCHTERM -- Add a search term (sql predicate or keyword list) to the specified query.
query | Registry query handle | |
term | keyword search term | |
orValues | logically OR values? |
void voc_regConstWaveband | ( | RegQuery | query, | |
char * | waveband | |||
) |
Constrain the Registry search by waveband.
Constrain the Registry search by service type.
VOC_REGCONSTWAVEBAND -- Constrain the Registry search by waveband.
query | Registry query handle | |
waveband | waveband string |
query | Registry query handle | |
svcType | service type string |
void voc_regDALOnly | ( | RegQuery | query, | |
int | value | |||
) |
Set the "DAL Only" flag.
VOC_REGDALONLY -- Set the "DAL Only" flag. If set, we expand a resource search to break out the individual DAL services into separate results.
query | Registry query handle | |
value | value of the DAL-only flag |
RegResult voc_regExecute | ( | RegQuery | query | ) |
Execute the specified query.
VOC_REGEXECUTE -- Execute the specified query, returning a result object code or NULL.
query | Registry query handle |
char* voc_regExecuteRaw | ( | RegQuery | query | ) |
Execute the specified query and return raw result string.
VOC_REGEXECUTERAW -- Execute the specified query and return the raw resulting XML string.
query | Registry query handle |
char* voc_regGetQueryString | ( | RegQuery | query | ) |
Get the current query as an http GET URL.
VOC_REGGETQUERYSTRING -- Get the current query as an http GET URL.
query | Registry query handle |
int voc_regGetSTCount | ( | RegQuery | query | ) |
Get the number of search terms in the current query.
VOC_REGGETSTCOUNT -- Get the number of search terms in the current query.
query | Registry query handle |
RegQuery voc_regQuery | ( | char * | term, | |
int | orValues | |||
) |
Create a RegistryQuery object.
VOC_REGQUERY -- Create a RegistryQuery object.
term | keyword search term | |
orValues | logically OR values? |
void voc_regRemoveSearchTerm | ( | RegQuery | query, | |
char * | term | |||
) |
Remove a search term to the specified query.
VOC_REMOVESEARCHTERM -- Remove the search term from the query.
query | Registry query handle | |
term | keyword search term |
RegResult voc_regSearch | ( | char * | term1, | |
char * | term2, | |||
int | orValues | |||
) |
High-level Registry query interface.
VOC_REGSEARCH -- High-level procedure to form a query and execute it immediately. We allow that 'term1' may be a complex SQL WHERE predicate, and that 'term2' (or vice versa) is a search-keyword list. The 'orValues' applies to the keyword list (if present), otherwise it applies to the two search term elements. The default action if two terms are specified is to logically AND them.
The thinking here is that one might want SIAP services for Quasars. This is easily expressed in an SQL form to get SIAP resources, however a Quasar may be known as a QSO, AGN, active-nuclei, etc and so we need a easy way to OR the keywords but AND that result with the SQL predicate.
term1 | first search term | |
term2 | second search term | |
orValues | logically OR values? |
RegResult voc_regSearchByService | ( | char * | svc, | |
char * | term, | |||
int | orValues | |||
) |
Search Registry using a search term and service constraint.
VOC_REGSEARCHBYSERVICE -- Search the Registry using a search term and constrain by service type.
svc | service type constraint | |
term | keyword search term | |
orValues | logically OR values? |
void voc_regSortRes | ( | RegQuery | query, | |
int | value | |||
) |
Set the resource "sort" flag.
VOC_REGSORTRES -- Set the resource "sort" flag. If enabled, we try to order the resource table by some logical means.
query | Registry query handle | |
value | value of the sort flag |
int voc_resGetCount | ( | RegResult | res | ) |
Return a count of the number of results records.
VOC_RESGETCOUNT -- Return a count of the number of results records.
res | Registry result handle |
double voc_resGetFloat | ( | RegResult | res, | |
char * | attribute, | |||
int | index | |||
) |
Get a real-valued attribute from the result resource record.
VOC_GETFLOAT -- Get a real-valued attribute from the result resource record. Currently recognized real-valued attributes include:
MaxSR maximum search radius
Attribute string are case-insensitive.
res | Registry result handle | |
attr | record attribute | |
index | record index |
int voc_resGetInt | ( | RegResult | res, | |
char * | attribute, | |||
int | index | |||
) |
Get an int-valued attribute from the result resource record.
VOC_GETINT -- Get a integer-valued attribute from the result resource record. Currently recognized real-valued attributes include:
MaxRecords maximum records returned by the service
Attribute string are case-insensitive.
res | Registry result handle | |
attr | record attribute | |
index | record index |
char* voc_resGetStr | ( | RegResult | res, | |
char * | attribute, | |||
int | index | |||
) |
Get a string-valued attribute from the result resource record.
VOC_GETSTR -- Get a string-valued attribute from the result resource record. Currently recognized real-valued attributes include:
Title Resource title (long version) ShortName Short name of Resource ServiceURL Service URL (if appropriate) ReferenceURL URL to reference about Resource Description Text description of resource Identifier Standard ivo identifier of resource ServiceType Service Type (Cone, Siap, etc) Type Resource Type (catalog, survey, etc) CoverageSpatial Spatial coverage (STC) CoverageTemporal Temporal coverage of data
CoverageSpectral Spectral coverage (csv list of bandpasses) ContentLevel Content level (research, EPO, etc -- csv list)
Attribute strings are case-insensitive.
res | Registry result handle | |
attr | record attribute | |
index | record index |