OGLplus (0.52.0) a C++ wrapper for OpenGL

lazy.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_PROG_VAR_LAZY_1405052234_HPP
14 #define OGLPLUS_PROG_VAR_LAZY_1405052234_HPP
15 
16 #include <oglplus/detail/lazy.hpp>
18 #include <oglplus/string/def.hpp>
19 #include <oglplus/string/ref.hpp>
20 
21 namespace oglplus {
22 
23 template <typename ProgVar_>
24 class LazyImpl<tag::ProgVar, ProgVar_>
25  : public ProgVar_
26 {
27 private:
28  String _identifier;
29 public:
30  LazyImpl(ProgramName program, String&& identifier)
31  : ProgVar_(program)
32  , _identifier(std::move(identifier))
33  { }
34 
35  LazyImpl& Init(void)
36  {
37  if(!this->IsActive())
38  {
39  this->BindTo(_identifier);
40  ProgVar_::RequireActive(_identifier);
41  _identifier.clear();
42  }
43  return *this;
44  }
45 
46  LazyImpl& TryInit(void)
47  {
48  if(!this->IsActive())
49  {
50  if(this->BindTo(_identifier, false).IsActive())
51  {
52  _identifier.clear();
53  }
54  }
55  return *this;
56  }
57 
58  ProgVar_ operator[](std::size_t offset)
59  {
60  Init();
61  return ProgVar_(
62  ProgramName(this->_program),
63  this->_location+offset
64  );
65  }
66 
67  template <typename T>
68  void Set(T&& value)
69  {
70  Init();
71  ProgVar_::Set(std::forward<T>(value));
72  }
73 
74  template <typename T0, typename T1>
75  void Set(T0&& v0, T1&& v1)
76  {
77  Init();
79  std::forward<T0>(v0),
80  std::forward<T1>(v1)
81  );
82  }
83 
84  template <typename T0, typename T1, typename T2>
85  void Set(T0&& v0, T1&& v1, T2&& v2)
86  {
87  Init();
89  std::forward<T0>(v0),
90  std::forward<T1>(v1),
91  std::forward<T1>(v2)
92  );
93  }
94 
95  template <typename T0, typename T1, typename T2, typename T3>
96  void Set(T0&& v0, T1&& v1, T2&& v2, T3&& v3)
97  {
98  Init();
100  std::forward<T0>(v0),
101  std::forward<T1>(v1),
102  std::forward<T1>(v2),
103  std::forward<T1>(v3)
104  );
105  }
106 };
107 
108 } // namespace oglplus
109 
110 #endif // include guard
Program variable wrapper.
String type definition and related functions.
::std::basic_string< ALchar > String
String reference.

Copyright © 2010-2014 Matúš Chochlík, University of Žilina, Žilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Mon Sep 22 2014 by Doxygen (version 1.8.6).