RefleX
Build DDS Applications in Modern C++ without IDL
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
bounded.h
Go to the documentation of this file.
1 /*********************************************************************************************
2 (c) 2005-2014 Copyright, Real-Time Innovations, Inc. All rights reserved.
3 RTI grants Licensee a license to use, modify, compile, and create derivative works
4 of the Software. Licensee has the right to distribute object form only for use with RTI
5 products. The Software is provided "as is", with no warranty of any type, including
6 any warranty for fitness for any purpose. RTI is under no obligation to maintain or
7 support the Software. RTI shall not be liable for any incidental or consequential
8 damages arising out of the use or inability to use the software.
9 **********************************************************************************************/
10 
11 #ifndef RTIREFLEX_BOUNDED_H
12 #define RTIREFLEX_BOUNDED_H
13 
14 #include <vector>
15 #include <string>
16 
17 namespace reflex {
18  namespace match {
19 
20  template <class T, size_t Bound>
21  struct BoundedRange;
22 
23  template <typename T, size_t Bound>
24  class Bounded
25  {
26  T * ptr;
27 
28  public:
29  Bounded() : ptr(0) {}
30 
31  explicit Bounded(T & t)
32  : ptr(&t)
33  {}
34 
35  Bounded(const Bounded & b)
36  : ptr(b.ptr)
37  {}
38 
39  operator T & () const
40  {
41  if (ptr)
42  return *ptr;
43  else
44  throw std::runtime_error("Bounded<T>: Null pointer");
45  }
46 
48  {
49  ptr = &t;
50  return *this;
51  }
52  };
53 
54  template <class Iter, size_t Bound>
55  class BoundedViewIterator : public Iter
56  {
57  public:
59  : Iter()
60  {}
61 
62  explicit BoundedViewIterator(Iter i)
63  : Iter(i)
64  {}
65 
67  : Iter(bvi)
68  {}
69  };
70 
71  template <size_t Bound, class Iter>
73  {
75  }
76 
77  } // namespace match
78 } // namespace reflex
79 
80 #endif // RTIREFLEX_BOUNDED_H
81 
BoundedViewIterator(const BoundedViewIterator &bvi)
Definition: bounded.h:66
BoundedViewIterator(Iter i)
Definition: bounded.h:62
Bounded & operator=(T &t)
Definition: bounded.h:47
BoundedViewIterator()
Definition: bounded.h:58
Bounded(T &t)
Definition: bounded.h:31
Definition: bounded.h:24
Bounded(const Bounded &b)
Definition: bounded.h:35
Definition: bounded.h:55
BoundedViewIterator< Iter, Bound > make_bounded_view_iterator(Iter iter)
Definition: bounded.h:72
Definition: bounded.h:21
Bounded()
Definition: bounded.h:29