Loading [MathJax]/extensions/tex2jax.js
LSST Applications g0f08755f38+05b4b46b2c,g1653933729+a905cd61c3,g168dd56ebc+a905cd61c3,g1a2382251a+526767c3b0,g20f6ffc8e0+05b4b46b2c,g217e2c1bcf+f8df405040,g28da252d5a+e530e4405a,g2bbee38e9b+e060cc3e60,g2bc492864f+e060cc3e60,g32e5bea42b+7044b77928,g347aa1857d+e060cc3e60,g35bb328faa+a905cd61c3,g3a166c0a6a+e060cc3e60,g3bd4b5ce2c+9af3f3d415,g3e281a1b8c+2bff41ced5,g3e8969e208+a905cd61c3,g414038480c+882f223820,g41af890bb2+f72d0f2eea,g43bc871e57+ad86a2d9e2,g78460c75b0+4ae99bb757,g80478fca09+8d821d1b28,g82479be7b0+ec26a56c2d,g858d7b2824+05b4b46b2c,g9125e01d80+a905cd61c3,ga5288a1d22+64e5455051,gb58c049af0+84d1b6ec45,gc28159a63d+e060cc3e60,gc5452a3dca+b82ec7cc4c,gcab2d0539d+01da5adb7a,gcf0d15dbbd+56822d21ae,gda6a2b7d83+56822d21ae,gdaeeff99f8+686ef0dd99,ge79ae78c31+e060cc3e60,gef2f8181fd+f2c81e61ee,gf0baf85859+f9edac6842,gf1e97e5484+3a635bd7af,gfa517265be+05b4b46b2c,gfa999e8aa5+d85414070d,w.2024.51
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ModuleImporter.cc
Go to the documentation of this file.
1// -*- lsst-c++ -*-
2/*
3 * LSST Data Management System
4 * Copyright 2008-2013 LSST Corporation.
5 *
6 * This product includes software developed by the
7 * LSST Project (http://www.lsst.org/).
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the LSST License Statement and
20 * the GNU General Public License along with this program. If not,
21 * see <http://www.lsstcorp.org/LegalNotices/>.
22 */
23
25
26namespace lsst { namespace base {
27
28namespace {
29
30class PlaceholderModuleImporter : public ModuleImporter {
31public:
32 static ModuleImporter const * get() {
33 static PlaceholderModuleImporter const instance;
34 return &instance;
35 }
36private:
37 PlaceholderModuleImporter() {}
38protected:
39 virtual bool _import(std::string const & name) const { return false; }
40};
41
42ModuleImporter const * & getImporterSingleton() {
43 static ModuleImporter const * instance = PlaceholderModuleImporter::get();
44 return instance;
45}
46
47} // anonymous
48
50 return getImporterSingleton()->_import(name);
51}
52
53void ModuleImporter::install(ModuleImporter const * importer) {
54 getImporterSingleton() = importer;
55}
56
57}} // namespace lsst::base
Mechanism for safely importing Python modules from C++; should not be included except by its own impl...
Base class that defines an interface for importing Python modules.
static bool import(std::string const &name)
Import the given Python module, and return true if successful.