LSST Applications 27.0.0,g0265f82a02+469cd937ee,g02d81e74bb+21ad69e7e1,g1470d8bcf6+cbe83ee85a,g2079a07aa2+e67c6346a6,g212a7c68fe+04a9158687,g2305ad1205+94392ce272,g295015adf3+81dd352a9d,g2bbee38e9b+469cd937ee,g337abbeb29+469cd937ee,g3939d97d7f+72a9f7b576,g487adcacf7+71499e7cba,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+df404f777f,g5a732f18d5+be83d3ecdb,g64a986408d+21ad69e7e1,g858d7b2824+21ad69e7e1,g8a8a8dda67+a6fc98d2e7,g99cad8db69+f62e5b0af5,g9ddcbc5298+d4bad12328,ga1e77700b3+9c366c4306,ga8c6da7877+71e4819109,gb0e22166c9+25ba2f69a1,gb6a65358fc+469cd937ee,gbb8dafda3b+69d3c0e320,gc07e1c2157+a98bf949bb,gc120e1dc64+615ec43309,gc28159a63d+469cd937ee,gcf0d15dbbd+72a9f7b576,gdaeeff99f8+a38ce5ea23,ge6526c86ff+3a7c1ac5f1,ge79ae78c31+469cd937ee,gee10cc3b42+a6fc98d2e7,gf1cff7945b+21ad69e7e1,gfbcc870c63+9a11dc8c8f
LSST Data Management Base Package
Loading...
Searching...
No Matches
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);
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}}}}
#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