diff --git a/ChangeLog b/ChangeLog index 00d4a64..75a5a3e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -2014-01-24 Juergen Knoedlseder +2014-01-25 Juergen Knoedlseder * Bug fix Version 0.8.1 released ================================ @@ -9,6 +9,7 @@ id attribute into XML file (#1092) Add GChatter typedef to Python interface GAMMALIB_CALDB takes precedence over CALDB environment var (#1094) + Added vo module and GVOClient class to Python interface 2014-01-18 Juergen Knoedlseder diff --git a/NEWS b/NEWS index e3a3ec5..ba24260 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,7 @@ New Features and Important Changes in GammaLib 00-08-01 Author(s) : Juergen Knoedlseder -24 January 2014 +25 January 2014 1. Introduction @@ -89,7 +89,8 @@ None 15. VO module ------------- -None +The vo module and GVOClient class have been added to the Python +interface. 16. Xspec module diff --git a/configure.ac b/configure.ac index f8a99fb..bd2e568 100644 --- a/configure.ac +++ b/configure.ac @@ -887,7 +887,8 @@ else pyext/gammalib/support_wrap.cpp pyext/gammalib/support.py pyext/gammalib/test_wrap.cpp pyext/gammalib/test.py pyext/gammalib/xml_wrap.cpp pyext/gammalib/xml.py - pyext/gammalib/xspec_wrap.cpp pyext/gammalib/xspec.py],, + pyext/gammalib/xspec_wrap.cpp pyext/gammalib/xspec.py + pyext/gammalib/vo_wrap.cpp pyext/gammalib/vo.py],, [has_wrappers="no"]) if test "x$with_mwl" = "xyes"; then AC_CHECK_FILES([pyext/gammalib/mwl_wrap.cpp pyext/gammalib/mwl.py],, diff --git a/pyext/GVOClient.i b/pyext/GVOClient.i new file mode 100644 index 0000000..47f8d48 --- /dev/null +++ b/pyext/GVOClient.i @@ -0,0 +1,62 @@ +/*************************************************************************** + * GVOClient.i - VO client class * + * ----------------------------------------------------------------------- * + * copyright (C) 2014 by Juergen Knoedlseder * + * ----------------------------------------------------------------------- * + * * + * 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 3 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, see . * + * * + ***************************************************************************/ +/** + * @file GVOClient.i + * @brief VO client class interface definition + * @author Juergen Knoedlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GVOClient.hpp" +%} + + +/***********************************************************************//** + * @class GVOClient + * + * @brief VO client class + ***************************************************************************/ +class GVOClient : public GBase { +public: + // Constructors and destructors + GVOClient(void); + GVOClient(const GVOClient& client); + virtual ~GVOClient(void); + + // Methods + void clear(void); + GVOClient* clone(void) const; + void connect(void); + void disconnect(void); + bool has_hub(void) const; + bool is_connected(void) const; + GXml response(void) const; +}; + + +/***********************************************************************//** + * @brief GVOClient class extension + ***************************************************************************/ +%extend GVOClient { + GVOClient copy() { + return (*self); + } +}; diff --git a/pyext/Makefile.am b/pyext/Makefile.am index fb087eb..6ebd176 100755 --- a/pyext/Makefile.am +++ b/pyext/Makefile.am @@ -61,9 +61,10 @@ BUILT_SOURCES = gammalib/app_wrap.cpp gammalib/app.py \ gammalib/opt_wrap.cpp gammalib/opt.py \ gammalib/sky_wrap.cpp gammalib/sky.py \ gammalib/support_wrap.cpp gammalib/support.py \ + gammalib/test_wrap.cpp gammalib/test.py \ gammalib/xml_wrap.cpp gammalib/xml.py \ gammalib/xspec_wrap.cpp gammalib/xspec.py \ - gammalib/test_wrap.cpp gammalib/test.py \ + gammalib/vo_wrap.cpp gammalib/vo.py \ $(INST_SWIG_TARGETS) # Dependencies. Obtain the list of dependencies by executing ls. diff --git a/pyext/gammalib/vo.i b/pyext/gammalib/vo.i new file mode 100644 index 0000000..85ff472 --- /dev/null +++ b/pyext/gammalib/vo.i @@ -0,0 +1,50 @@ +/*************************************************************************** + * vo.i - Virtual Observatory module * + * ----------------------------------------------------------------------- * + * copyright (C) 2014 by Juergen Knoedlseder * + * ----------------------------------------------------------------------- * + * * + * 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 3 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, see . * + * * + * ----------------------------------------------------------------------- * + * Usage: * + * swig -c++ -python -Wall vo.i * + ***************************************************************************/ +/** + * @file vo.i + * @brief Virtual Observatory module + * @author Juergen Knoedlseder + */ +%module vo +%feature("autodoc", "1"); + +/* __ Headers needed for compilation _____________________________________ */ +%{ +#include +#include "GException.hpp" +#include "GTools.hpp" +%} + +/* __ Include standard typemaps for vectors and strings __________________ */ +//%include stl.i + +/* __ Include interface classes __________________________________________ */ +%import(module="gammalib.base") "GBase.i"; +//%import(module="gammalib.base") "GContainer.i"; + +/* __ Make sure that exceptions are catched ______________________________ */ +//%import(module="gammalib.support") "GException.i"; + +/* __ Virtual Observatory module _________________________________________ */ +%include "GVOClient.i" diff --git a/pyext/setup.py.in b/pyext/setup.py.in index 79d1855..0d6ac7b 100644 --- a/pyext/setup.py.in +++ b/pyext/setup.py.in @@ -31,7 +31,8 @@ pkg_name = 'gammalib' # Define core modules core_modules = ['app', 'base', 'fits', 'linalg', 'model', 'numerics', \ - 'obs', 'opt', 'sky', 'support', 'test', 'xml', 'xspec'] + 'obs', 'opt', 'sky', 'support', 'test', 'xml', 'xspec', \ + 'vo'] # Detect execution mode is_build = True diff --git a/test/test_GVO.py b/test/test_GVO.py new file mode 100755 index 0000000..3bd4ba9 --- /dev/null +++ b/test/test_GVO.py @@ -0,0 +1,66 @@ +# ========================================================================== +# This module performs unit tests for the GammaLib vo module. +# +# Copyright (C) 2014 Juergen Knoedlseder +# +# 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 3 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, see . +# +# ========================================================================== +from gammalib import * +from math import * +import os + + +# ================================= # +# Test class for GammaLib vo module # +# ================================= # +class Test(GPythonTestSuite): + """ + Test class for GammaLib vo module. + """ + # Constructor + def __init__(self): + """ + Constructor. + """ + # Call base class constructor + GPythonTestSuite.__init__(self) + + # Return + return + + # Set test functions + def set(self): + """ + Set all test functions. + """ + # Set test name + self.name("vo") + + # Append tests + self.append(self.test_voclient, "Test GVOClient") + + # Return + return + + # Test GVOClient class + def test_voclient(self): + """ + Test GVOClient class. + """ + # Allocate GVOClient object + client = GVOClient() + + # Return + return diff --git a/test/test_python.py b/test/test_python.py index 8a86baa..d117d66 100755 --- a/test/test_python.py +++ b/test/test_python.py @@ -2,7 +2,7 @@ # ========================================================================== # This scripts performs unit tests for the GammaLib Python bindings. # -# Copyright (C) 2012 Juergen Knoedlseder +# Copyright (C) 2012-2014 Juergen Knoedlseder # # 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 @@ -33,6 +33,7 @@ import test_GSupport import test_GTest import test_GXml import test_GXspec +import test_GVO # Try importing MWL tests try: @@ -86,6 +87,7 @@ if __name__ == '__main__': suite10 = test_GTest.Test() suite11 = test_GXml.Test() suite12 = test_GXspec.Test() + suite13 = test_GVO.Test() # Setup unit tests suite1.set() @@ -100,6 +102,7 @@ if __name__ == '__main__': suite10.set() suite11.set() suite12.set() + suite13.set() # Append tests to container suites.append(suite1) @@ -114,6 +117,7 @@ if __name__ == '__main__': suites.append(suite10) suites.append(suite11) suites.append(suite12) + suites.append(suite13) # Optionally handle MWL suite if has_mwl: