SourceXtractorPlusPlus  0.10
Please provide a description of the project.
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 
33 namespace SourceXtractor {
34 
47 
48 public:
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>
64  void setIndexedProperty(std::size_t index, Args... 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");
67  setProperty(std::unique_ptr<PropertyType>{new PropertyType(std::forward<Args>(args)...)},
68  PropertyId::create<PropertyType>(index));
69  }
70 
71  template<typename PropertyType, typename ... Args>
72  void setProperty(Args... args) {
73  setIndexedProperty<PropertyType>(0, std::forward<Args>(args)...);
74  }
75 
78  virtual const Property& getProperty(const PropertyId& property_id) const = 0;
79  virtual void setProperty(std::unique_ptr<Property> property, const PropertyId& property_id) = 0;
80 
81 }; /* End of SourceInterface class */
82 
83 } /* namespace SourceXtractor */
84 
85 
86 #endif
PropertyId.h
SourceXtractor::Property
Base class for all Properties. (has no actual content)
Definition: Property.h:33
SourceXtractor::PropertyId
Identifier used to set and retrieve properties.
Definition: PropertyId.h:40
SourceXtractor
Definition: Aperture.h:30
Property.h
SourceXtractor::SourceInterface::setIndexedProperty
void setIndexedProperty(std::size_t index, Args... args)
Convenience template method to call setProperty() with a more user-friendly syntax.
Definition: SourceInterface.h:64
SourceXtractor::SourceInterface::~SourceInterface
virtual ~SourceInterface()=default
Destructor.
std::is_constructible
SourceXtractor::SourceInterface::getProperty
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
Definition: SourceInterface.h:57
std::size_t
SourceXtractor::SourceInterface
The SourceInterface is an abstract "source" that has properties attached to it.
Definition: SourceInterface.h:46
std::unique_ptr
STL class.
SourceXtractor::SourceInterface::setProperty
void setProperty(Args... args)
Definition: SourceInterface.h:72
PropertyNotFoundException.h
std::is_base_of