Skip to content

Commit 2f0dd74

Browse files
committed
Add missing comments to Source python wrappers
1 parent bc9d776 commit 2f0dd74

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

SEPythonModule/SEPythonModule/SourceInterface.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030

3131
namespace SourceXPy {
3232

33+
/**
34+
* A DetachedSource is "outside" sourcextractor++'s pipeline, so it does not keep any
35+
* reference to internal properties such as the detection frame
36+
*/
3337
struct DetachedSource {
3438
boost::python::dict m_attributes;
3539

@@ -38,6 +42,9 @@ struct DetachedSource {
3842
boost::python::object attribute(const std::string& key) const;
3943
};
4044

45+
/**
46+
* An AttachedSource is bound to sourcextractor++'s pipeline. It can not be serialized.
47+
*/
4148
struct AttachedSource {
4249
ContextPtr m_context;
4350
SourceXtractor::SourceInterface* m_source_ptr = nullptr;
@@ -49,6 +56,13 @@ struct AttachedSource {
4956
DetachedSource detach() const;
5057
};
5158

59+
/**
60+
* An OwnedSource is fully owned by the pipeline stage that receives it.
61+
* It is still attached to the pipeline, but it is safe to keep a reference to it from Python
62+
* @warning This is only true since the pipelines clone the sources that come from Python, which is an inefficiency.
63+
* If acceptable, m_owned_source could be moved away, m_source_ptr set to nullptr, and let any later call
64+
* catch this nullptr situation if the caller kept a reference without explicitly cloning.
65+
*/
5266
struct OwnedSource : public AttachedSource {
5367
OwnedSource(ContextPtr context, std::unique_ptr<SourceXtractor::SourceInterface> source)
5468
: AttachedSource(std::move(context), source.get()), m_owned_source(std::move(source)) {}
@@ -61,12 +75,25 @@ struct OwnedSource : public AttachedSource {
6175
int detection_id, const boost::python::tuple& pixels);
6276
};
6377

78+
/**
79+
* An EntangledSource lifetime is bound to its containing SourceGroup. When iterating a SourceGroup,
80+
* only the current EntangledSource is safe to use. i.e.
81+
*
82+
* sources = []
83+
* for source in group:
84+
* print(source) # Safe
85+
* sources.append(source) # Unsafe
86+
* print(sources) # Unsafe
87+
*/
6488
struct EntangledSource : public AttachedSource {
6589
explicit EntangledSource(ContextPtr context) : AttachedSource(std::move(context), nullptr) {}
6690

6791
std::string repr() const;
6892
};
6993

94+
/**
95+
* A SourceGroup is always owned by the called pipeline stage
96+
*/
7097
struct SourceGroup {
7198
struct Iterator {
7299
SourceXtractor::SourceGroupInterface::const_iterator m_i;

0 commit comments

Comments
 (0)