VISR  0.11.6
Versatile Interactive Scene Renderer
indexed_value_parameter.hpp
Go to the documentation of this file.
1 /* Copyright Institute of Sound and Vibration Research - All rights reserved */
2 
3 #ifndef VISR_PML_INDEXED_STRING_PARAMETER_HPP_INCLUDED
4 #define VISR_PML_INDEXED_STRING_PARAMETER_HPP_INCLUDED
5 
7 #include "export_symbols.hpp"
8 
11 
12 #include <string>
13 #include <utility>
14 #include <vector>
15 
16 namespace visr
17 {
18 namespace pml
19 {
20 
21 namespace // unnamed
22 {
26 template<typename ValueType> struct IndexedValueParameterType {};
27 
28 template<> struct IndexedValueParameterType<std::vector<float> >
29 { static constexpr const ParameterType ptype() { return detail::compileTimeHashFNV1( "IndexedFloatVector" ); } };
30 template<> struct IndexedValueParameterType<std::vector<double> >
31 { static constexpr const ParameterType ptype() { return detail::compileTimeHashFNV1( "IndexedDoubleVector" ); } };
32 template<> struct IndexedValueParameterType<std::string >
33 { static constexpr const ParameterType ptype() { return detail::compileTimeHashFNV1( "IndexedString" ); }};
34 } // unnamed namespace
35 
36 
37 
41 template<typename IndexType, typename ValueType >
42 class VISR_PML_LIBRARY_SYMBOL IndexedValueParameter:
43  public std::pair< std::size_t, std::string >,
44  public TypedParameterBase< IndexedValueParameter<IndexType, ValueType>, EmptyParameterConfig, IndexedValueParameterType<ValueType>::ptype() >
45 {
46 public:
47  using DataType = std::pair<IndexType, ValueType >;
48 
50 
51  explicit IndexedValueParameter( IndexType const & index, ValueType const & value );
52 
53  explicit IndexedValueParameter( ParameterConfigBase const & config );
54 
55  explicit IndexedValueParameter( const EmptyParameterConfig & config );
56 
57  virtual ~IndexedValueParameter( ) override;
58 
59  IndexType index( ) const
60  {
61  return mData.first;
62  }
63 
64  ValueType const & value( ) const
65  {
66  return mData.second;
67  }
68 
69 
70  void setIndex( IndexType index )
71  {
72  mData.first = index;
73  }
74 
75  void setValue( ValueType const & value )
76  {
77  mData.second = value;
78  }
79 
80 
81 private:
82  DataType mData;
83 };
84 
85 // For some reason, the DEFINE_PARAMETER_TYPE macro fails if called with the full templated type.
86 // Note that the construct works for MatrixParameter (with only one template parameter)
90 
91 } // namespace pml
92 } // namespace visr
93 
97 
98 #endif // VISR_PML_INDEXED_STRING_PARAMETER_HPP_INCLUDED
void setValue(ValueType const &value)
Definition: indexed_value_parameter.hpp:75
uint64_t ParameterType
Definition: parameter_type.hpp:13
IndexType index() const
Definition: indexed_value_parameter.hpp:59
void setIndex(IndexType index)
Definition: indexed_value_parameter.hpp:70
constexpr uint64_t compileTimeHashFNV1(const char *s)
Definition: compile_time_hash_fnv1.hpp:25
Definition: options.cpp:10
Definition: parameter_factory.hpp:20
Definition: parameter_config_base.hpp:22
ValueType const & value() const
Definition: indexed_value_parameter.hpp:64
#define DEFINE_PARAMETER_TYPE(ParameterClassType, ParameterId, ParameterConfigType)
Definition: parameter_type.hpp:60
Definition: indexed_value_parameter.hpp:42
std::pair< IndexType, ValueType > DataType
Definition: indexed_value_parameter.hpp:47
Definition: empty_parameter_config.hpp:21