1 #ifndef color__internal_utility_container_array 2 #define color__internal_utility_container_array 3 4 // ::color::_internal::utility::container::array<value_name, length> 5 6 #include "../type/index.hpp" 7 #include "../type/size.hpp" 8 #include "../type/traitc.hpp" 9 10 11 12 namespace color 13 { 14 namespace _internal 15 { 16 namespace utility 17 { 18 namespace container 19 { 20 21 template< typename value_name, unsigned length > 22 struct array 23 { 24 public: 25 typedef value_name value_type; 26 typedef ::color::_internal::utility::container::array< value_name, length > this_type; 27 28 typedef std::array< value_name, length> instance_type; 29 30 31 typedef instance_type const const_type; 32 typedef instance_type const& return_image_type; 33 typedef instance_type & return_type; 34 typedef instance_type & return_original_type; 35 typedef instance_type const& model_type; 36 typedef instance_type & input_type; 37 typedef instance_type & output_type; 38 39 typedef ::color::_internal::utility::type::index< typename instance_type::size_type > index_trait_type; 40 41 typedef typename index_trait_type::instance_type index_instance_type; 42 typedef typename index_trait_type::const_type index_const_type; 43 typedef typename index_trait_type::model_type index_input_const_type; 44 typedef typename index_trait_type::return_image_type index_return_image_type; 45 46 typedef ::color::_internal::utility::type::traitC< value_name > component_trait_type; 47 48 typedef typename component_trait_type::instance_type component_type; 49 typedef typename component_trait_type::const_type component_const_type; 50 typedef typename component_trait_type::return_image_type component_return_const_type; 51 typedef typename component_trait_type::model_type component_input_const_type; 52 53 typedef ::color::_internal::utility::type::size< typename instance_type::size_type > size_trait_type; 54 55 typedef typename size_trait_type::return_image_type size_return_image_type; 56 typedef typename size_trait_type::instance_type size_instance_type; 57 58 typedef void set_return_type; 59 60 enum { size_entity = length }; 61 62 initcolor::_internal::utility::container::array63 static set_return_type init( input_type container, index_input_const_type index, component_input_const_type value ) 64 { 65 this_type::set( container, index, value ); 66 } 67 68 template< index_instance_type index > initcolor::_internal::utility::container::array69 static set_return_type init( input_type container, component_input_const_type value ) 70 { 71 this_type:: template set<index>( container, value ); 72 } 73 getcolor::_internal::utility::container::array74 static component_return_const_type get( model_type container, index_input_const_type index ) 75 { 76 return container[index]; 77 } 78 79 template< index_instance_type index > getcolor::_internal::utility::container::array80 static component_return_const_type get( model_type container ) 81 { 82 //TODO C++14 static_assert( index < length, "Index is out of range." ); 83 return container[index]; 84 } 85 setcolor::_internal::utility::container::array86 static set_return_type set( input_type container, index_input_const_type index, component_input_const_type value ) 87 { 88 container[index] = value; 89 } 90 91 template< index_instance_type index > setcolor::_internal::utility::container::array92 static set_return_type set( input_type container, component_input_const_type value ) 93 { 94 //TODO C++14 static_assert( index < length, "Index is out of range." ); 95 container[index] = value; 96 } 97 sizecolor::_internal::utility::container::array98 static /*constexpr*/ size_return_image_type size() 99 { 100 static const size_instance_type local_length = size_entity; 101 return local_length; 102 } 103 }; 104 } 105 } 106 } 107 } 108 109 #endif 110