Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / Bounded_Value_Sequence_T.h
blob07383956c049f5dc937abc513866576c2fb99787
1 #ifndef guard_bounded_value_sequence_hpp
2 #define guard_bounded_value_sequence_hpp
3 /**
4 * @file
6 * @brief Implement bounded sequences for types with value-like
7 * semantics.
9 * @author Carlos O'Ryan
12 #include "tao/Bounded_Value_Allocation_Traits_T.h"
13 #include "tao/Value_Traits_T.h"
14 #include "tao/Generic_Sequence_T.h"
16 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
18 namespace TAO
20 template<class T, CORBA::ULong MAX, class Tag=int>
21 class bounded_value_sequence
23 public:
24 typedef T value_type;
25 typedef T element_type;
26 typedef T const const_value_type;
27 typedef value_type & subscript_type;
28 typedef value_type const & const_subscript_type;
29 typedef ::CORBA::ULong size_type;
31 typedef details::bounded_value_allocation_traits<value_type,MAX,true> allocation_traits;
32 typedef details::value_traits<value_type,true> element_traits;
33 typedef details::generic_sequence<value_type, allocation_traits, element_traits> implementation_type;
35 inline bounded_value_sequence()
36 : impl_()
38 inline bounded_value_sequence(
39 CORBA::ULong length,
40 value_type * data,
41 CORBA::Boolean release = false)
42 : impl_(MAX, length, data, release)
44 /* Use default ctor, operator= and dtor */
46 // @copydoc TAO::details::generic_sequence::maximum()
47 inline CORBA::ULong maximum() const {
48 return impl_.maximum();
50 // @copydoc TAO::details::generic_sequence::release()
51 inline CORBA::Boolean release() const {
52 return impl_.release();
54 // @copydoc TAO::details::generic_sequence::length()
55 inline CORBA::ULong length() const {
56 return impl_.length();
58 // @copydoc TAO::details::generic_sequence::length()
59 inline void length(CORBA::ULong length) {
60 implementation_type::range::check_length(length, MAX);
61 impl_.length(length);
63 // @copydoc TAO::details::generic_sequence::operator[]
64 inline value_type const & operator[](CORBA::ULong i) const {
65 return impl_[i];
67 // @copydoc TAO::details::generic_sequence::operator[]
68 inline value_type & operator[](CORBA::ULong i) {
69 return impl_[i];
71 // @copydoc TAO::details::generic_sequence::replace()
72 inline void replace(
73 CORBA::ULong length,
74 value_type * data,
75 CORBA::Boolean release = false) {
76 impl_.replace(MAX, length, data, release);
78 // @copydoc TAO::details::generic_sequence::get_buffer()
79 inline value_type const * get_buffer() const {
80 return impl_.get_buffer();
82 // @copydoc TAO::details::generic_sequence::get_buffer(CORBA::Boolean)
83 inline value_type * get_buffer(CORBA::Boolean orphan = false) {
84 return impl_.get_buffer(orphan);
86 // @copydoc TAO::details::generic_sequence::swap()
87 inline void swap(bounded_value_sequence & rhs) noexcept {
88 impl_.swap(rhs.impl_);
90 static value_type * allocbuf(CORBA::ULong maximum) {
91 return implementation_type::allocbuf(maximum);
93 static value_type * allocbuf() {
94 return implementation_type::allocbuf(MAX);
96 static void freebuf(value_type * buffer)
98 implementation_type::freebuf(buffer);
101 private:
102 implementation_type impl_;
104 } // namespace TAO
106 TAO_END_VERSIONED_NAMESPACE_DECL
108 #endif // guard_bounded_string_sequence_hpp