SourceXtractorPlusPlus  0.15
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SourceIDTask.h
Go to the documentation of this file.
1 
17 /*
18  * SourceIDTask.h
19  *
20  * Created on: May 30, 2018
21  * Author: mschefer
22  */
23 
24 #ifndef _SEIMPLEMENTATION_PLUGIN_SOURCEIDS_SOURCEIDTASK_H_
25 #define _SEIMPLEMENTATION_PLUGIN_SOURCEIDS_SOURCEIDTASK_H_
26 
27 #include <atomic>
31 
32 namespace SourceXtractor {
33 
34 class SourceIDTask : public SourceTask {
35 
36 public:
37  virtual ~SourceIDTask() = default;
38 
40 
41  virtual void computeProperties(SourceInterface& source) const override {
42  auto detection_id = source.getProperty<SourceId>().getDetectionId();
43  source.setProperty<SourceID>(getNewId(), detection_id);
44  }
45 
46 private:
47  static unsigned int getNewId() {
48  static std::atomic<std::uint32_t> s_id(1);
49  return s_id++;
50  }
51 
52 };
53 
54 } /* namespace SourceXtractor */
55 
56 #endif /* _SEIMPLEMENTATION_PLUGIN_SOURCEIDS_SOURCEIDTASK_H_ */
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
A Task that acts on a Source to compute one or more properties.
Definition: SourceTask.h:36
virtual void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
Definition: SourceIDTask.h:41
static unsigned int getNewId()
Definition: SourceIDTask.h:47
virtual ~SourceIDTask()=default
The SourceInterface is an abstract &quot;source&quot; that has properties attached to it.