SourceXtractorPlusPlus 0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SourceInterface.h
Go to the documentation of this file.
1
23#ifndef _SEFRAMEWORK_SOURCE_SOURCEINTERFACE_H
24#define _SEFRAMEWORK_SOURCE_SOURCEINTERFACE_H
25
26#include <memory>
27#include <type_traits>
28
32
33namespace SourceXtractor {
34
47
48public:
49
53 virtual ~SourceInterface() = default;
54
56 template<typename PropertyType>
57 const PropertyType& getProperty(unsigned int index = 0) const {
58 static_assert(std::is_base_of<Property, PropertyType>::value, "PropertyType must inherit from SourceXtractor::Property");
59 return dynamic_cast<const PropertyType&>(getProperty(PropertyId::create<PropertyType>(index)));
60 }
61
63 template<typename PropertyType, typename ... Args>
65 static_assert(std::is_base_of<Property, PropertyType>::value, "PropertyType must inherit from SourceXtractor::Property");
66 static_assert(std::is_constructible<PropertyType, Args...>::value, "PropertyType must be constructible from args");
68 PropertyId::create<PropertyType>(index));
69 }
70
71 template<typename PropertyType, typename ... Args>
75
78 virtual const Property& getProperty(const PropertyId& property_id) const = 0;
80
81}; /* End of SourceInterface class */
82
83} /* namespace SourceXtractor */
84
85
86#endif
Identifier used to set and retrieve properties.
Definition PropertyId.h:40
Base class for all Properties. (has no actual content)
Definition Property.h:33
The SourceInterface is an abstract "source" that has properties attached to it.
void setIndexedProperty(std::size_t index, Args... args)
Convenience template method to call setProperty() with a more user-friendly syntax.
virtual ~SourceInterface()=default
Destructor.
virtual const Property & getProperty(const PropertyId &property_id) const =0
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
virtual void setProperty(std::unique_ptr< Property > property, const PropertyId &property_id)=0