summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwolff1 <wolff1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2007-12-21 19:11:22 +0000
committerwolff1 <wolff1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2007-12-21 19:11:22 +0000
commit9feb8ea5e2d5845da0cdb0fc92ba81a38712a90a (patch)
treec3be598c014f8e360cd7601bcf0ec73800fec07e
parent2d83a98b31e556cbbc0d0170dbd0f74812f1a6d6 (diff)
downloadATCD-9feb8ea5e2d5845da0cdb0fc92ba81a38712a90a.tar.gz
added initial Unbounded_Object_Ref_Sequence test and checks for ACE_HAS_STDCPP_STL_INCLUDES
-rw-r--r--TAO/tao/Bounded_Basic_String_Sequence_T.h4
-rw-r--r--TAO/tao/Generic_Sequence_T.h15
-rw-r--r--TAO/tao/Unbounded_Basic_String_Sequence_T.h3
-rw-r--r--TAO/tao/Unbounded_Object_Reference_Sequence_T.h64
-rw-r--r--TAO/tao/Unbounded_Value_Sequence_T.h8
-rw-r--r--TAO/tests/Sequence_Iterators/Sequence_Iterators.mpc16
-rw-r--r--TAO/tests/Sequence_Iterators/Unbounded_Objectref.cpp185
-rwxr-xr-xTAO/tests/Sequence_Iterators/run_test.pl10
8 files changed, 296 insertions, 9 deletions
diff --git a/TAO/tao/Bounded_Basic_String_Sequence_T.h b/TAO/tao/Bounded_Basic_String_Sequence_T.h
index 7a3f5e1cd28..923447e523b 100644
--- a/TAO/tao/Bounded_Basic_String_Sequence_T.h
+++ b/TAO/tao/Bounded_Basic_String_Sequence_T.h
@@ -105,6 +105,8 @@ public:
implementation_type::freebuf(buffer);
}
+#ifdef ACE_HAS_STDCPP_STL_INCLUDES
+
///
/// Additions to support iterator semantics for TAO unbounded basic
/// string sequences.
@@ -166,6 +168,8 @@ public:
return impl_.rend ();
}
+#endif /* ACE_HAS_STDCPP_STL_INCLUDES */
+
private:
implementation_type impl_;
};
diff --git a/TAO/tao/Generic_Sequence_T.h b/TAO/tao/Generic_Sequence_T.h
index 8ea9e4869d7..1fd067c4c83 100644
--- a/TAO/tao/Generic_Sequence_T.h
+++ b/TAO/tao/Generic_Sequence_T.h
@@ -68,6 +68,8 @@ namespace TAO
namespace details
{
+#ifdef ACE_HAS_STDCPP_STL_INCLUDES
+
// Forward declare the iterators
template<typename T>
class Generic_Sequence_Iterator;
@@ -81,16 +83,23 @@ class Generic_Sequence_Reverse_Iterator;
template<typename T>
class Const_Generic_Sequence_Reverse_Iterator;
+#endif /* ACE_HAS_STDCPP_STL_INCLUDES */
+
template<typename T,
class ALLOCATION_TRAITS,
class ELEMENT_TRAITS>
class generic_sequence
{
+
+#ifdef ACE_HAS_STDCPP_STL_INCLUDES
+
friend class Generic_Sequence_Iterator<generic_sequence<T, ALLOCATION_TRAITS, ELEMENT_TRAITS> >;
friend class Const_Generic_Sequence_Iterator<generic_sequence<T, ALLOCATION_TRAITS, ELEMENT_TRAITS> >;
friend class Generic_Sequence_Reverse_Iterator<generic_sequence<T, ALLOCATION_TRAITS, ELEMENT_TRAITS> >;
friend class Const_Generic_Sequence_Reverse_Iterator<generic_sequence<T, ALLOCATION_TRAITS, ELEMENT_TRAITS> >;
+#endif /* ACE_HAS_STDCPP_STL_INCLUDES */
+
public:
typedef T value_type;
typedef ALLOCATION_TRAITS allocation_traits;
@@ -335,6 +344,8 @@ public:
allocation_traits::freebuf(buffer);
}
+#ifdef ACE_HAS_STDCPP_STL_INCLUDES
+
///
/// Additions to support iterator semantics for TAO sequences.
///
@@ -405,6 +416,8 @@ public:
-1);
}
+#endif /* ACE_HAS_STDCPP_STL_INCLUDES */
+
private:
/// The maximum number of elements the buffer can contain.
CORBA::ULong maximum_;
@@ -417,6 +430,7 @@ private:
mutable CORBA::Boolean release_;
};
+#ifdef ACE_HAS_STDCPP_STL_INCLUDES
/**
* @class Generic_Sequence_Iterator
@@ -1294,6 +1308,7 @@ template<typename SEQUENCE_T>
return Const_Generic_Sequence_Reverse_Iterator<SEQUENCE_T> (iter.sequence_, iter.pos_ + n);
}
+#endif /* ACE_HAS_STDCPP_STL_INCLUDES */
} // namespace details
} // namespace TAO
diff --git a/TAO/tao/Unbounded_Basic_String_Sequence_T.h b/TAO/tao/Unbounded_Basic_String_Sequence_T.h
index b4d419cc573..9c0194a86d5 100644
--- a/TAO/tao/Unbounded_Basic_String_Sequence_T.h
+++ b/TAO/tao/Unbounded_Basic_String_Sequence_T.h
@@ -112,6 +112,7 @@ public:
implementation_type::freebuf(buffer);
}
+#ifdef ACE_HAS_STDCPP_STL_INCLUDES
///
/// Additions to support iterator semantics for TAO unbounded basic
@@ -174,6 +175,8 @@ public:
return impl_.rend ();
}
+#endif /* ACE_HAS_STDCPP_STL_INCLUDES */
+
private:
implementation_type impl_;
};
diff --git a/TAO/tao/Unbounded_Object_Reference_Sequence_T.h b/TAO/tao/Unbounded_Object_Reference_Sequence_T.h
index 50d1ae9fd9b..3bfc59f384c 100644
--- a/TAO/tao/Unbounded_Object_Reference_Sequence_T.h
+++ b/TAO/tao/Unbounded_Object_Reference_Sequence_T.h
@@ -107,6 +107,70 @@ public:
implementation_type::freebuf(buffer);
}
+#ifdef ACE_HAS_STDCPP_STL_INCLUDES
+
+ ///
+ /// Additions to support iterator semantics for TAO unbounded object reference
+ /// sequences.
+ ///
+
+ // = Traits and factory methods that create iterators.
+ typedef details::Generic_Sequence_Iterator<details::generic_sequence<value_type, allocation_traits, element_traits> > iterator;
+ typedef details::Const_Generic_Sequence_Iterator<details::generic_sequence<value_type, allocation_traits, element_traits> > const_iterator;
+ typedef details::Generic_Sequence_Reverse_Iterator<details::generic_sequence<value_type, allocation_traits, element_traits> > reverse_iterator;
+ typedef details::Const_Generic_Sequence_Reverse_Iterator<details::generic_sequence<value_type, allocation_traits, element_traits> > const_reverse_iterator;
+
+ // Get an iterator that points to the beginning of the sequence.
+ iterator begin (void)
+ {
+ return impl_.begin ();
+ }
+
+ // Get a const iterator that points to the beginning of the sequence.
+ const_iterator begin (void) const
+ {
+ return impl_.begin ();
+ }
+
+ // Get an iterator that points to the end of the sequence.
+ iterator end (void)
+ {
+ return impl_.end ();
+ }
+
+ // Get a const iterator that points to the end of the sequence.
+ const_iterator end (void) const
+ {
+ return impl_.end ();
+ }
+
+ // Get a reverse iterator that points to the end of the sequence.
+ reverse_iterator rbegin (void)
+ {
+ return impl_.rbegin ();
+ }
+
+ // Get a const reverse iterator that points to the end of the sequence.
+ const_reverse_iterator rbegin (void) const
+ {
+ return impl_.rbegin ();
+ }
+
+ // Get a reverse iterator that points to one before the beginning
+ // of the sequence.
+ reverse_iterator rend (void)
+ {
+ return impl_.end ();
+ }
+
+ // Get a const reverse iterator that points to one before the
+ // beginning of the sequence.
+ const_reverse_iterator rend (void) const
+ {
+ return impl_.rend ();
+ }
+
+#endif /* ACE_HAS_STDCPP_STL_INCLUDES */
private:
implementation_type impl_;
diff --git a/TAO/tao/Unbounded_Value_Sequence_T.h b/TAO/tao/Unbounded_Value_Sequence_T.h
index 742324745c1..ab72d60c3c1 100644
--- a/TAO/tao/Unbounded_Value_Sequence_T.h
+++ b/TAO/tao/Unbounded_Value_Sequence_T.h
@@ -89,9 +89,11 @@ public:
implementation_type::freebuf(buffer);
}
+#ifdef ACE_HAS_STDCPP_STL_INCLUDES
+
///
- /// Additions to support iterator semantics for TAO unbounded basic
- /// string sequences.
+ /// Additions to support iterator semantics for TAO unbounded value
+ /// sequences.
///
// = Traits and factory methods that create iterators.
@@ -150,6 +152,8 @@ public:
return impl_.rend ();
}
+#endif /* ACE_HAS_STDCPP_STL_INCLUDES */
+
private:
implementation_type impl_;
};
diff --git a/TAO/tests/Sequence_Iterators/Sequence_Iterators.mpc b/TAO/tests/Sequence_Iterators/Sequence_Iterators.mpc
index f07b9c6cd82..31f3f0e886f 100644
--- a/TAO/tests/Sequence_Iterators/Sequence_Iterators.mpc
+++ b/TAO/tests/Sequence_Iterators/Sequence_Iterators.mpc
@@ -2,13 +2,29 @@
// $Id$
project(StringSeq) : taoexe {
+
+ exename = StringSeq
+
Source_Files {
StringSeq.cpp
}
}
project(Bounded_String) : taoexe {
+
+ exename = Bounded_String
+
Source_Files {
Bounded_String.cpp
}
+}
+
+project(Unbounded_Objectref) : taoexe {
+
+ exename = Unbounded_Objectref
+
+ Source_Files {
+ mock_reference.cpp
+ Unbounded_Objectref.cpp
+ }
} \ No newline at end of file
diff --git a/TAO/tests/Sequence_Iterators/Unbounded_Objectref.cpp b/TAO/tests/Sequence_Iterators/Unbounded_Objectref.cpp
new file mode 100644
index 00000000000..418d2cb2bb9
--- /dev/null
+++ b/TAO/tests/Sequence_Iterators/Unbounded_Objectref.cpp
@@ -0,0 +1,185 @@
+/**
+ * @file Unbounded_Objectref.cpp
+ *
+ * @brief test for STL iterator behaviour of CORBA unbounded value sequence
+ *
+ * $Id$
+ *
+ * @author Friedhelm Wolf (fwolf@dre.vanderbilt.edu)
+ */
+
+#include "ace/Log_Msg.h"
+
+#include <iostream>
+#include <iterator>
+#include <sstream>
+
+#include "tao/Object_Reference_Traits_T.h"
+#include "mock_reference.hpp"
+#include "tao/Unbounded_Object_Reference_Sequence_T.h"
+
+#define FAIL_RETURN_IF(CONDITION) \
+ ACE_DEBUG ((LM_INFO, ACE_TEXT ("in %N:%l\n"))); \
+ if (CONDITION) \
+ { \
+ ACE_DEBUG ((LM_ERROR, ACE_TEXT ("\tFailed at %N:%l\n"))); \
+ return 1; \
+ }
+
+typedef TAO::unbounded_object_reference_sequence<mock_reference, mock_reference_var> tested_sequence;
+
+template <typename ITERATOR_T>
+int test_sequence ()
+{
+ tested_sequence a;
+
+ // test equality operator
+ FAIL_RETURN_IF (!(a.begin () == a.begin ()));
+
+ // test non-equality operator
+ FAIL_RETURN_IF (a.end () != a.end ());
+
+ // test for correct behaviour for empty sequence
+
+ FAIL_RETURN_IF (a.begin() != a.end ());
+
+ mock_reference* elem0 = mock_reference::allocate (0);
+ mock_reference* elem1 = mock_reference::allocate (1);
+ mock_reference* elem2 = mock_reference::allocate (2);
+ mock_reference* elem3 = mock_reference::allocate (3);
+
+ // setup of an example sequence
+ a.length (4);
+ a[0] = mock_reference::_duplicate (elem0);
+ a[1] = mock_reference::_duplicate (elem1);
+ a[2] = mock_reference::_duplicate (elem2);
+ a[3] = mock_reference::_duplicate (elem3);
+
+ // test iterator copy constructor
+ ITERATOR_T a_it (a.begin ());
+ FAIL_RETURN_IF (a_it != a.begin ());
+
+ // test assignment operator
+ a_it = a.begin ();
+ FAIL_RETURN_IF (a_it != a.begin ());
+
+ // test non const dereferencing
+ mock_reference* value0 = *a_it;
+ FAIL_RETURN_IF (value0->id () != elem0->id ());
+
+ // test const dereferencing
+ const mock_reference* const value1 = *a_it;
+ FAIL_RETURN_IF (value1->id () != elem0->id ());
+
+ // test increment operation
+ a_it++;
+ FAIL_RETURN_IF (a_it == a.begin());
+ FAIL_RETURN_IF ((*a_it)->id () != elem1->id ());
+
+ // test < operator
+ FAIL_RETURN_IF (!(a.begin () < a_it));
+ FAIL_RETURN_IF (a_it < a.begin ());
+
+ // test difference type
+ int a_diff = a_it - a.begin ();
+ FAIL_RETURN_IF (a_diff != 1);
+
+ // test copy constructor
+ ITERATOR_T a_it1 (a_it);
+ FAIL_RETURN_IF (a_it1 != a_it);
+
+ // test preincrement operator
+ ++a_it1;
+ FAIL_RETURN_IF ((a_it1 - a_it) != 1);
+
+ // test = and += operator
+ ITERATOR_T a_it2 = a_it += 3;
+ FAIL_RETURN_IF (a_it2 != a_it);
+ FAIL_RETURN_IF ((a_it - a_it1) != 2);
+
+ // test + operator
+ a_it2 = a_it1 + 3;
+ FAIL_RETURN_IF ((a_it2 - a_it1) != 3);
+
+ // test post-decrement operation
+ a_it = a.end ();
+ a_it--;
+ FAIL_RETURN_IF (a_it == a.end ());
+ FAIL_RETURN_IF ((a.end () - a_it) != 1);
+ FAIL_RETURN_IF ((*a_it)->id () != elem3->id ());
+
+ // test pre-decrement operator
+ a_it = a.end ();
+ --a_it;
+ FAIL_RETURN_IF (a_it == a.end ());
+ FAIL_RETURN_IF ((a.end () - a_it) != 1);
+ FAIL_RETURN_IF ((*a_it)->id () != elem3->id ());
+
+ // test -= operator
+ a_it -= 3;
+ FAIL_RETURN_IF ((a_it1 - a_it) != 2);
+
+ // test - operator
+ a_it2 = a_it1 - 2;
+ FAIL_RETURN_IF ((a_it1 - a_it2) != 2);
+
+ // test operator[] read
+ a_it = a.begin ();
+ FAIL_RETURN_IF (a_it[0]->id () != a[0]->id ());
+ a_it += 2;
+ FAIL_RETURN_IF (a_it[0]->id () != a[2]->id ());
+
+ // test for loop behaviour
+ tested_sequence b = a;
+ ITERATOR_T b_it = b.begin ();
+
+ for (a_it = a.begin ();
+ a_it != a.end ();
+ a_it++, b_it++)
+ {
+ FAIL_RETURN_IF ((*a_it)->id () != (*b_it)->id ());
+ }
+
+ tested_sequence test;
+ test.length (a.length ());
+
+ // Memory is leaked here from
+ // TAO::details::string_traits_base<char>::default_initializer()
+
+ std::copy (a.begin (),
+ a.end (),
+ test.begin ());
+
+ FAIL_RETURN_IF (test.length () != a.length ());
+
+ ITERATOR_T copytest_iter = test.begin ();
+ for (ITERATOR_T copya_iter = a.begin ();
+ copya_iter != a.end ();
+ ++copya_iter, ++copytest_iter)
+ {
+ FAIL_RETURN_IF ((*copya_iter)->id () != (*copytest_iter)->id ());
+ }
+
+ /// Testing - using ostream_iterator
+
+ std::ostringstream ostream;
+ std::copy (a.begin (),
+ a.end (),
+ std::ostream_iterator<tested_sequence::value_type> (ostream,
+ "\n"));
+
+ FAIL_RETURN_IF (
+ ostream.str ().compare ("elem0\nelem1\nelem2\nelem3\n") != 0);
+
+ return 0;
+}
+
+int main(int,char*[])
+{
+ int status = 0;
+
+ // Test Generic_Sequence_Iterator.
+ status += test_sequence< tested_sequence::iterator> ();
+
+ return status;
+}
diff --git a/TAO/tests/Sequence_Iterators/run_test.pl b/TAO/tests/Sequence_Iterators/run_test.pl
index 7bfb5ce867a..6dc14ab3f2c 100755
--- a/TAO/tests/Sequence_Iterators/run_test.pl
+++ b/TAO/tests/Sequence_Iterators/run_test.pl
@@ -38,11 +38,9 @@ my @tests = qw(
);
my @testsNoBoost = qw(
-# Unbounded_Octet
-# Unbounded_Simple_Types
-# Bounded_Simple_Types
- StringSeq
- Bounded_String
+ StringSeq
+ Bounded_String
+ Unbounded_Objectref
);
my @testsToRun = qw();
@@ -53,8 +51,6 @@ push(@testsToRun, @testsNoBoost) if ($#ARGV < 0 || $ARGV[0] eq '-noboost');
foreach my $process (@testsToRun) {
-
-
my $P = 0;
if (PerlACE::is_vxworks_test()) {
$P = new PerlACE::ProcessVX ($process,