10 #ifndef LOFAR_PARMDB_SOURCEDB_H
11 #define LOFAR_PARMDB_SOURCEDB_H
37 void link() { itsCount++; }
47 virtual void lock(
bool lockForWrite);
74 virtual unsigned int addPatch(
const std::string& patchName,
int catType,
75 double apparentBrightness,
double ra,
76 double dec,
bool check) = 0;
79 virtual void updatePatch(
unsigned int patchId,
double apparentBrightness,
80 double ra,
double dec) = 0;
91 const std::string& patchName,
92 const ParmMap& defaultParameters,
double ra,
93 double dec,
bool check) = 0;
100 const std::string& patchName,
int catType,
101 double apparentBrightness,
102 const ParmMap& defaultParameters,
double ra,
103 double dec,
bool check) = 0;
109 const std::string& pattern,
110 double minBrightness,
111 double maxBrightness) = 0;
115 const std::string& pattern,
116 double minBrightness,
117 double maxBrightness) = 0;
121 const std::string& patchName) = 0;
125 const std::string& patchName) = 0;
131 virtual std::vector<SourceInfo>
getSources(
const std::string& pattern) = 0;
170 const std::string& patch_name,
int cat_type,
171 double apparent_brightness,
172 const ParmMap& default_parameters,
double ra,
173 double dec,
bool check) = 0;
176 const std::string& patch_name,
177 const ParmMap& default_parameters,
double ra,
178 double dec,
bool check) = 0;
184 virtual unsigned addPatch(
const std::string& patch_name,
int cat_type,
185 double apparent_brightness,
double ra,
double dec,
188 virtual void updatePatch(
unsigned patch_id,
double apparent_brightness,
189 double ra,
double dec) = 0;
216 void lock(
bool lockForWrite =
true) { itsRep->
lock(lockForWrite); }
251 unsigned int addPatch(
const std::string& patchName,
int catType,
252 double apparentBrightness,
double ra,
double dec,
253 bool check)
override {
254 return itsRep->
addPatch(patchName, catType, apparentBrightness, ra, dec,
259 void updatePatch(
unsigned int patchId,
double apparentBrightness,
double ra,
260 double dec)
override {
261 itsRep->
updatePatch(patchId, apparentBrightness, ra, dec);
273 const ParmMap& defaultParameters,
double ra,
double dec,
274 bool check)
override {
275 itsRep->
addSource(sourceInfo, patchName, defaultParameters, ra, dec, check);
284 int catType,
double apparentBrightness,
285 const ParmMap& defaultParameters,
double ra,
double dec,
286 bool check)
override {
287 itsRep->
addSource(sourceInfo, patchName, catType, apparentBrightness,
288 defaultParameters, ra, dec, check);
295 int category = -1,
const std::string& pattern = std::string(),
296 double minBrightness = -1,
double maxBrightness = -1)
const {
297 return itsRep->
getPatches(category, pattern, minBrightness, maxBrightness);
302 int category = -1,
const std::string& pattern = std::string(),
303 double minBrightness = -1,
double maxBrightness = -1)
const {
304 return itsRep->
getPatchInfo(category, pattern, minBrightness,
315 const std::string& patchName)
const {
326 const std::string& sourceNamePattern)
const {
361 std::filesystem::path itsSourceDBPath;
Base class for a table holding parameters.
Base class for a table holding sources and their parameters.
Envelope class for a table holding parameters.
Definition: ParmDB.h:159
const ParmDBMeta & getParmDBMeta() const
Get the name and type of the ParmDB.
Definition: ParmDB.h:273
A map of parameter name to value set.
Definition: ParmMap.h:30
Definition: SourceDB.h:157
virtual void addSource(const SourceInfo &source_info, const std::string &patch_name, const ParmMap &default_parameters, double ra, double dec, bool check)=0
virtual ~SourceDBBase()=default
virtual void updatePatch(unsigned patch_id, double apparent_brightness, double ra, double dec)=0
virtual unsigned addPatch(const std::string &patch_name, int cat_type, double apparent_brightness, double ra, double dec, bool check)=0
virtual void addSource(const SourceInfo &source_info, const std::string &patch_name, int cat_type, double apparent_brightness, const ParmMap &default_parameters, double ra, double dec, bool check)=0
Abstract base class for a table holding source parameters.
Definition: SourceDB.h:29
void link()
Link to the DBRep by incrementing the count.
Definition: SourceDB.h:37
virtual void getNextSource(SourceData &src)=0
virtual void addSource(const SourceInfo &sourceInfo, const std::string &patchName, const ParmMap &defaultParameters, double ra, double dec, bool check)=0
virtual void rewind()=0
Reset to the beginning of the file.
virtual bool atEnd()=0
Tell if we are the end of the file.
virtual void checkDuplicates()=0
virtual void clearTables()=0
Clear database or table.
SourceDBRep(const ParmDBMeta &ptm, bool forceNew)
This creates the underlying ParmDB object.
virtual void updatePatch(unsigned int patchId, double apparentBrightness, double ra, double dec)=0
Update the ra/dec and apparent brightness of a patch.
ParmDB & getParmDB()
Get the associated ParmDB.
Definition: SourceDB.h:52
virtual std::vector< SourceData > getPatchSourceData(const std::string &patchName)=0
Get all data of the sources belonging to the given patch.
virtual std::vector< PatchInfo > getPatchInfo(int category, const std::string &pattern, double minBrightness, double maxBrightness)=0
Get the info of selected patches (default all patches).
const ParmDBMeta & getParmDBMeta() const
Get the name and type of the SourceDB.
Definition: SourceDB.h:140
virtual std::vector< std::string > findDuplicatePatches()=0
Find non-unique patch names.
virtual std::vector< std::string > findDuplicateSources()=0
Find non-unique source names.
virtual std::vector< std::string > getPatches(int category, const std::string &pattern, double minBrightness, double maxBrightness)=0
virtual bool patchExists(const std::string &patchName)=0
Test if the patch already exists.
virtual void addSource(const SourceInfo &sourceInfo, const std::string &patchName, int catType, double apparentBrightness, const ParmMap &defaultParameters, double ra, double dec, bool check)=0
virtual bool sourceExists(const std::string &sourceName)=0
Test if the source already exists.
virtual unsigned int addPatch(const std::string &patchName, int catType, double apparentBrightness, double ra, double dec, bool check)=0
virtual std::vector< SourceInfo > getSources(const std::string &pattern)=0
Get the info of all sources matching the given (filename like) pattern.
virtual void lock(bool lockForWrite)
virtual SourceInfo getSource(const std::string &sourceName)=0
Get the source type of the given source.
int unlink()
Unlink by decrementing the count.
Definition: SourceDB.h:40
virtual void deleteSources(const std::string &sourceNamePattern)=0
Delete the sources records matching the given (filename like) pattern.
virtual std::vector< SourceInfo > getPatchSources(const std::string &patchName)=0
Get the sources belonging to the given patch.
virtual void addSource(const SourceData &source, bool check)=0
Envelope class for a table holding source parameters.
Definition: SourceDB.h:193
SourceInfo getSource(const std::string &sourceName) const
Get the source info of the given source.
Definition: SourceDB.h:320
void lock(bool lockForWrite=true)
Definition: SourceDB.h:216
void checkDuplicates() const
Definition: SourceDB.h:225
SourceDB(const ParmDBMeta &ptm, bool mustExist, bool forceNew)
std::vector< SourceInfo > getPatchSources(const std::string &patchName) const
Get the info of the sources belonging to the given patch.
Definition: SourceDB.h:309
bool patchExists(const std::string &patchName) const
Test if the patch already exists.
Definition: SourceDB.h:238
void addSource(const SourceInfo &sourceInfo, const std::string &patchName, const ParmMap &defaultParameters, double ra, double dec, bool check) override
Definition: SourceDB.h:272
std::vector< std::string > getPatches(int category=-1, const std::string &pattern=std::string(), double minBrightness=-1, double maxBrightness=-1) const
Definition: SourceDB.h:294
void unlock()
Definition: SourceDB.h:217
ParmDB & getParmDB()
Get the associated ParmDB.
Definition: SourceDB.h:221
void rewind()
Reset to the beginning of the file.
Definition: SourceDB.h:349
bool sourceExists(const std::string &sourceName) const
Test if the source already exists.
Definition: SourceDB.h:243
~SourceDB() override
Delete underlying object if no more references to it.
std::vector< SourceInfo > getSources(const std::string &sourceNamePattern) const
Get the info of all sources matching the given (filename like) pattern.
Definition: SourceDB.h:325
SourceDB(const SourceDB &)
Copy contructor has reference semantics.
void getNextSource(SourceData &src)
Definition: SourceDB.h:343
std::vector< SourceData > getPatchSourceData(const std::string &patchName) const
Get all data of the sources belonging to the given patch.
Definition: SourceDB.h:314
SourceDB & operator=(const SourceDB &)
Assignment has reference semantics.
bool atEnd()
Tell if we are the end of the file.
Definition: SourceDB.h:346
unsigned int addPatch(const std::string &patchName, int catType, double apparentBrightness, double ra, double dec, bool check) override
Definition: SourceDB.h:251
std::vector< PatchInfo > getPatchInfo(int category=-1, const std::string &pattern=std::string(), double minBrightness=-1, double maxBrightness=-1) const
Get the info of all patches (name, ra, dec).
Definition: SourceDB.h:301
void addSource(const SourceInfo &sourceInfo, const std::string &patchName, int catType, double apparentBrightness, const ParmMap &defaultParameters, double ra, double dec, bool check) override
Add a source which forms a patch in itself (with the same name).
Definition: SourceDB.h:283
void deleteSources(const std::string &sourceNamePattern)
Delete the sources records matching the given (filename like) pattern.
Definition: SourceDB.h:331
std::vector< std::string > findDuplicateSources() const
Find non-unique source names.
Definition: SourceDB.h:233
void addSource(const SourceData &source, bool check=true)
Definition: SourceDB.h:277
void updatePatch(unsigned int patchId, double apparentBrightness, double ra, double dec) override
Update the ra/dec and apparent brightness of a patch.
Definition: SourceDB.h:259
void clearTables()
Clear database tables (i.e. remove all rows from all tables).
Definition: SourceDB.h:336
const ParmDBMeta & getParmDBMeta() const
Get the name and type of the SourceDB.
Definition: SourceDB.h:339
std::vector< std::string > findDuplicatePatches() const
Find non-unique patch names.
Definition: SourceDB.h:228
Class holding a data of a source.
Definition: SourceData.h:31
Info about a source.
Definition: SourceInfo.h:29
This file has generic helper routines for testing steps.
Definition: AntennaConfig.h:53