snark
coloured.h
1 // This file is part of snark, a generic and flexible library
2 // for robotics research.
3 //
4 // Copyright (C) 2011 The University of Sydney
5 //
6 // snark is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 3 of the License, or (at your option) any later version.
10 //
11 // snark is distributed in the hope that it will be useful, but WITHOUT ANY
12 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14 // for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with snark. If not, see <http://www.gnu.org/licenses/>.
18 
19 #ifndef SNARK_GRAPHICS_COLOURED_H_
20 #define SNARK_GRAPHICS_COLOURED_H_
21 
22 #include <boost/array.hpp>
23 #include <comma/Visiting/traits.h>
24 #include <snark/graphics/Vertex.h>
25 
26 namespace snark { namespace graphics {
27 
28 template < typename T, typename S >
29 struct coloured // real quick and dirty
30 {
31  T value;
32  colour< S > colour;
33  coloured() {}
34  coloured( const T& value, const colour< S > = colours< S >::black() ) : value( value ), colour( colour ) {}
35 };
36 
37 } } // namespace snark { namespace graphics {
38 
39 namespace snark { namespace Visiting {
40 
42 template < typename T, typename S > struct traits< snark::graphics::coloured< T, S > >
43 {
45  template < typename Key, class Visitor >
46  static void visit( const Key&, const snark::graphics::coloured< T, S >& p, Visitor& v )
47  {
48  v.apply( "value", p.value );
49  v.apply( "colour", p.colour );
50  }
51 
53  template < typename Key, class Visitor >
54  static void visit( const Key&, snark::graphics::coloured< T, S >& p, Visitor& v )
55  {
56  v.apply( "value", p.value );
57  v.apply( "colour", p.colour );
58  }
59 };
60 
61 } } // namespace snark { namespace Visiting {
62 
63 #endif /*SNARK_GRAPHICS_GL_COLOURED_H_*/