LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
prefsImpl.cc
Go to the documentation of this file.
1// -*- lsst-C++ -*-
2#include "lsst/meas/extensions/psfex/prefs.hh"
3#include "lsst/daf/base.h"
4
5namespace lsst { namespace meas { namespace extensions { namespace psfex {
6
7Prefs::Prefs(std::string const& filename, lsst::daf::base::PropertySet const* values
8 ) : _command_line(0) {
9 char *cfilename = const_cast<char *>(filename.c_str()); // const_cast as PSFEX isn't careful about const
10 int const narg = values->nameCount();
11 if (narg == 0) {
12 readprefs(cfilename, 0x0, 0x0, narg);
13 } else {
14 std::vector<char *> argkey(narg);
15 std::vector<char *> argval(narg);
16 std::vector<std::string> const names = values->paramNames();
17 // Next, decalre a vector to store string values. These strings must
18 // live long enough such that pointers to them (returned by c_str) stay
19 // valid until the readprefs function can read their values. Once this
20 // happens, the srings and pointers are no longer needed, and will be
21 // cleaned up when the vector goes out of scope
22 std::vector<std::string> paramvalues(narg);
23
24 for (int i = 0; i != narg; ++i) {
25 std::string const& name = names[i];
26 argkey[i] = const_cast<char *>(name.c_str());
27 paramvalues[i] = values->getAsString(name);
28 argval[i] = const_cast<char *>(paramvalues[i].c_str());
29 }
30
31 readprefs(cfilename, &argkey[0], &argval[0], narg);
32 }
33
34 for (int i = 0; i != prefs.ncontext_name; ++i) {
35 _context_names.push_back(prefs.context_name[i]);
36 }
37 for (int i = 0; i != prefs.ncontext_group; ++i) {
38 _context_groups.push_back(prefs.context_group[i]);
39 }
40 for (int i = 0; i != prefs.ngroup_deg; ++i) {
41 _group_degs.push_back(prefs.group_deg[i]);
42 }
43}
44
45Prefs::~Prefs()
46{
47 delete[] _command_line;
48}
49
50void
51Prefs::setCommandLine(std::vector<std::string> const& argv)
52{
53 prefs.ncommand_line = argv.size();
54 _command_line = new char const*[prefs.ncommand_line + 1];
55 int i;
56 for (i = 0; i != prefs.ncommand_line; ++i) {
57 _command_line[i] = argv[i].c_str();
58 }
59 _command_line[i] = 0;
60 prefs.command_line = const_cast<char **>(_command_line);
61}
62
63void
64Prefs::addCatalog(std::string const& filename) {
65 if (prefs.ncat >= MAXFILE) {
66 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError, "Too many input catalogues");
67 }
68 _catalogs.push_back(filename);
69 prefs.incat_name[prefs.ncat++] = const_cast<char *>((_catalogs.end() - 1)->c_str());
70}
71
72}}}}
table::Key< std::string > name
Definition: Amplifier.cc:116
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
T c_str(T... args)
Class for storing generic metadata.
Definition: PropertySet.h:66
std::string getAsString(std::string const &name) const
Get the last value for a string property name (possibly hierarchical).
size_t nameCount(bool topLevelOnly=true) const
Get the number of names in the PropertySet, optionally including those in subproperties.
std::vector< std::string > paramNames(bool topLevelOnly=true) const
A variant of names that excludes the names of subproperties.
Reports attempts to exceed implementation-defined length limits for some classes.
Definition: Runtime.h:76
A base class for image defects.
T size(T... args)