SourceXtractorPlusPlus 0.19
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
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
32namespace SourceXtractor {
33
34class SourceIDTask : public SourceTask {
35
36public:
37 virtual ~SourceIDTask() = default;
38
40
41 void computeProperties(SourceInterface& source) const override {
42 auto detection_id = source.getProperty<SourceId>().getDetectionId();
43 source.setProperty<SourceID>(getNewId(), detection_id);
44 }
45
46private:
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_ */
virtual ~SourceIDTask()=default
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
The SourceInterface is an abstract "source" that has properties attached to it.
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