summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog-98b20
-rw-r--r--ace/Containers_T.cpp46
-rw-r--r--ace/Containers_T.h101
-rw-r--r--ace/Containers_T.i61
-rw-r--r--ace/OS.cpp2
-rw-r--r--ace/Object_Manager.cpp6
-rw-r--r--ace/Template_Instantiations.cpp4
-rw-r--r--apps/JAWS/clients/Caching/URL_Properties.cpp4
-rwxr-xr-xbin/Array.pl31
-rwxr-xr-xbin/Array_Helper16
-rwxr-xr-xbin/count_lines8
11 files changed, 254 insertions, 45 deletions
diff --git a/ChangeLog-98b b/ChangeLog-98b
index 8ae41a02a8a..6e5d20171f2 100644
--- a/ChangeLog-98b
+++ b/ChangeLog-98b
@@ -1,3 +1,23 @@
+Fri Jan 1 12:22:14 1999 Carlos O'Ryan <coryan@cs.wustl.edu>
+
+ * ace/Containers_T.h:
+ * ace/Containers_T.i:
+ * ace/Containers_T.cpp:
+ * bin/Array_Helper:
+ * bin/Array.pl:
+ Moved most of the implementation of ACE_Array into
+ ACE_Array_Base this class does not require == or != operators
+ defined for the template parameter.
+ I also added methods to access and manipulate the capacity of
+ the array (max_size) as opposed to always changing its size (the
+ portion actually used).
+
+ * ace/Object_Manager.cpp:
+ * ace/Template_Instantiations.cpp:
+ * ace/OS.cpp:
+ * apps/JAWS/clients/Caching/URL_Properties.cpp:
+ Fixed ACE_Array instantiations.
+
Thu Dec 31 13:25:53 1998 James CE Johnson <jcej@chiroptera.tragus.org>
* docs/tutorials/019/server[2].cpp:
diff --git a/ace/Containers_T.cpp b/ace/Containers_T.cpp
index 0b801da9429..794c5009fc5 100644
--- a/ace/Containers_T.cpp
+++ b/ace/Containers_T.cpp
@@ -2229,11 +2229,12 @@ ACE_DLList<T>::delete_tail (void)
return temp2;
}
+// ****************************************************************
// Dynamically initialize an array.
template <class T>
-ACE_Array<T>::ACE_Array (size_t size)
+ACE_Array_Base<T>::ACE_Array_Base (size_t size)
: max_size_ (size),
cur_size_ (size)
{
@@ -2244,8 +2245,8 @@ ACE_Array<T>::ACE_Array (size_t size)
}
template <class T>
-ACE_Array<T>::ACE_Array (size_t size,
- const T &default_value)
+ACE_Array_Base<T>::ACE_Array_Base (size_t size,
+ const T &default_value)
: max_size_ (size),
cur_size_ (size)
{
@@ -2258,7 +2259,7 @@ ACE_Array<T>::ACE_Array (size_t size,
// The copy constructor (performs initialization).
template <class T>
-ACE_Array<T>::ACE_Array (const ACE_Array<T> &s)
+ACE_Array_Base<T>::ACE_Array_Base (const ACE_Array_Base<T> &s)
: max_size_ (s.size ()),
cur_size_ (s.size ())
{
@@ -2270,18 +2271,18 @@ ACE_Array<T>::ACE_Array (const ACE_Array<T> &s)
// Assignment operator (performs assignment).
-template <class T> void
-ACE_Array<T>::operator= (const ACE_Array<T> &s)
+template <class T> ACE_Array_Base<T>&
+ACE_Array_Base<T>::operator= (const ACE_Array_Base<T> &s)
{
// Check for "self-assignment".
if (this == &s)
- return;
+ return *this;
else if (this->max_size_ < s.size ())
{
delete [] this->array_;
- ACE_NEW (this->array_, T[s.size ()]);
+ ACE_NEW_RETURN (this->array_, T[s.size ()], *this);
this->max_size_ = s.size ();
}
@@ -2290,12 +2291,14 @@ ACE_Array<T>::operator= (const ACE_Array<T> &s)
for (size_t i = 0; i < this->size (); i++)
this->array_[i] = s.array_[i];
+
+ return *this;
}
// Set an item in the array at location index.
template <class T> int
-ACE_Array<T>::set (const T &new_item, size_t index)
+ACE_Array_Base<T>::set (const T &new_item, size_t index)
{
if (this->in_range (index))
{
@@ -2309,7 +2312,7 @@ ACE_Array<T>::set (const T &new_item, size_t index)
// Get an item in the array at location index.
template <class T> int
-ACE_Array<T>::get (T &item, size_t index) const
+ACE_Array_Base<T>::get (T &item, size_t index) const
{
if (this->in_range (index))
{
@@ -2324,7 +2327,7 @@ ACE_Array<T>::get (T &item, size_t index) const
}
template<class T> int
-ACE_Array<T>::size (size_t new_size)
+ACE_Array_Base<T>::max_size (size_t new_size)
{
if (new_size >= this->max_size_)
{
@@ -2338,11 +2341,21 @@ ACE_Array<T>::size (size_t new_size)
this->array_ = tmp;
this->max_size_ = new_size;
}
- this->cur_size_ = new_size;
+ return 0;
+}
+template<class T> int
+ACE_Array_Base<T>::size (size_t new_size)
+{
+ int r = this->max_size (new_size);
+ if (r != 0)
+ return r;
+ this->cur_size_ = new_size;
return 0;
}
+// ****************************************************************
+
// Compare this array with <s> for equality.
template <class T> int
@@ -2350,16 +2363,19 @@ ACE_Array<T>::operator== (const ACE_Array<T> &s) const
{
if (this == &s)
return 1;
- else if (this->cur_size_ != s.cur_size_)
+ else if (this->size () != s.size ())
return 0;
- for (size_t index = 0; index < s.cur_size_; index++)
- if (this->array_[index] != s.array_[index])
+ for (size_t index = 0; index < s.size (); index++)
+ if ((*this)[index] != s[index])
return 0;
return 1;
}
+// ****************************************************************
+
+
template <class T> int
ACE_Array_Iterator<T>::next (T *&item)
{
diff --git a/ace/Containers_T.h b/ace/Containers_T.h
index 3dddf39b32d..c1e2508d443 100644
--- a/ace/Containers_T.h
+++ b/ace/Containers_T.h
@@ -1377,34 +1377,42 @@ private:
// Allocation strategy of the set.
};
+// ****************************************************************
+
// Forward declaration.
template <class T> class ACE_Array_Iterator;
-template <class T>
-class ACE_Array
+template<class T>
+class ACE_Array_Base
{
// = TITLE
- // Implement a dynamic array class.
+ // Implement a simple dynamic array
+ //
+ // = DESCRIPTION
+ // This parametric class implements a simple dynamic array;
+ // resizing must be controlled by the user. No comparison or find
+ // operations are implemented.
+ //
public:
+
// Define a "trait"
typedef T TYPE;
-
- // = Exceptions.
+ typedef ACE_Array_Iterator<T> ITERATOR;
// = Initialization and termination methods.
- ACE_Array (size_t size = 0);
+ ACE_Array_Base (size_t size = 0);
// Dynamically create an uninitialized array.
- ACE_Array (size_t size, const T &default_value);
+ ACE_Array_Base (size_t size, const T &default_value);
// Dynamically initialize the entire array to the <default_value>.
- ACE_Array (const ACE_Array<T> &s);
+ ACE_Array_Base (const ACE_Array_Base<T> &s);
// The copy constructor performs initialization by making an exact
// copy of the contents of parameter <s>, i.e., *this == s will
// return true.
- void operator= (const ACE_Array<T> &s);
+ ACE_Array_Base& operator= (const ACE_Array_Base<T> &s);
// Assignment operator performs an assignment by making an exact
// copy of the contents of parameter <s>, i.e., *this == s will
// return true. Note that if the <max_size_> of <array_> is >= than
@@ -1412,7 +1420,7 @@ public:
// <max_size_> is < <s.max_size_> we must delete the <array_>,
// reallocate a new <array_>, and then copy the contents of <s>.
- ~ACE_Array (void);
+ ~ACE_Array_Base (void);
// Clean up the array (e.g., delete dynamically allocated memory).
// = Set/get methods.
@@ -1443,15 +1451,14 @@ public:
// It copies the old contents into the new array.
// Return -1 on failure.
- int operator== (const ACE_Array<T> &s) const;
- // Compare this array with <s> for equality. Two arrays are equal
- // if their size()'s are equal and all the elements from 0 .. size()
- // are equal.
+ size_t max_size (void) const;
+ // Returns the <max_size_> of the array.
- int operator!= (const ACE_Array<T> &s) const;
- // Compare this array with <s> for inequality such that <*this> !=
- // <s> is always the complement of the boolean return value of
- // <*this> == <s>.
+ int max_size (size_t new_size);
+ // Changes the size of the array to match <new_size>.
+ // It copies the old contents into the new array.
+ // Return -1 on failure.
+ // It does not affect new_size
private:
int in_range (size_t index) const;
@@ -1475,6 +1482,60 @@ private:
friend class ACE_Array_Iterator<T>;
};
+// ****************************************************************
+
+template <class T>
+class ACE_Array : public ACE_Array_Base<T>
+{
+ // = TITLE
+ // Implement a dynamic array class.
+ //
+ // = DESCRIPTION
+ // This class extends ACE_Array_Base, it provides comparison
+ // operators.
+ //
+public:
+ // Define a "trait"
+ typedef T TYPE;
+
+ typedef ACE_Array_Iterator<T> ITERATOR;
+
+ // = Exceptions.
+
+ // = Initialization and termination methods.
+
+ ACE_Array (size_t size = 0);
+ // Dynamically create an uninitialized array.
+
+ ACE_Array (size_t size, const T &default_value);
+ // Dynamically initialize the entire array to the <default_value>.
+
+ ACE_Array (const ACE_Array<T> &s);
+ // The copy constructor performs initialization by making an exact
+ // copy of the contents of parameter <s>, i.e., *this == s will
+ // return true.
+
+ void operator= (const ACE_Array<T> &s);
+ // Assignment operator performs an assignment by making an exact
+ // copy of the contents of parameter <s>, i.e., *this == s will
+ // return true. Note that if the <max_size_> of <array_> is >= than
+ // <s.max_size_> we can copy it without reallocating. However, if
+ // <max_size_> is < <s.max_size_> we must delete the <array_>,
+ // reallocate a new <array_>, and then copy the contents of <s>.
+
+ // = Compare operators
+
+ int operator== (const ACE_Array<T> &s) const;
+ // Compare this array with <s> for equality. Two arrays are equal
+ // if their size()'s are equal and all the elements from 0 .. size()
+ // are equal.
+
+ int operator!= (const ACE_Array<T> &s) const;
+ // Compare this array with <s> for inequality such that <*this> !=
+ // <s> is always the complement of the boolean return value of
+ // <*this> == <s>.
+};
+
template <class T>
class ACE_Array_Iterator
{
@@ -1488,7 +1549,7 @@ class ACE_Array_Iterator
// odd, and dangerous.
public:
// = Initialization method.
- ACE_Array_Iterator (ACE_Array<T> &);
+ ACE_Array_Iterator (ACE_Array_Base<T> &);
// = Iteration methods.
@@ -1513,7 +1574,7 @@ private:
u_int current_;
// Pointer to the current item in the iteration.
- ACE_Array<T> &array_;
+ ACE_Array_Base<T> &array_;
// Pointer to the Array we're iterating over.
};
diff --git a/ace/Containers_T.i b/ace/Containers_T.i
index 50ec3667388..0f972b92884 100644
--- a/ace/Containers_T.i
+++ b/ace/Containers_T.i
@@ -301,38 +301,83 @@ ACE_Ordered_MultiSet<T>::size (void) const
return this->cur_size_;
}
+// ****************************************************************
+
// Clean up the array (e.g., delete dynamically allocated memory).
template <class T> ACE_INLINE
-ACE_Array<T>::~ACE_Array (void)
+ACE_Array_Base<T>::~ACE_Array_Base (void)
{
delete [] this->array_;
}
template <class T> ACE_INLINE size_t
-ACE_Array<T>::size (void) const
+ACE_Array_Base<T>::size (void) const
{
return this->cur_size_;
}
+template <class T> ACE_INLINE size_t
+ACE_Array_Base<T>::max_size (void) const
+{
+ return this->max_size_;
+}
+
template <class T> ACE_INLINE int
-ACE_Array<T>::in_range (size_t index) const
+ACE_Array_Base<T>::in_range (size_t index) const
{
return index < this->cur_size_;
}
template <class T> ACE_INLINE T &
-ACE_Array<T>::operator[] (size_t index)
+ACE_Array_Base<T>::operator[] (size_t index)
{
return this->array_[index];
}
template <class T> ACE_INLINE const T &
-ACE_Array<T>::operator[] (size_t index) const
+ACE_Array_Base<T>::operator[] (size_t index) const
{
return this->array_[index];
}
+// ****************************************************************
+
+template <class T> ACE_INLINE
+ACE_Array<T>::ACE_Array (size_t size)
+ : ACE_Array_Base<T>(size)
+{
+}
+
+template <class T> ACE_INLINE
+ACE_Array<T>::ACE_Array (size_t size,
+ const T &default_value)
+ : ACE_Array_Base<T> (size, default_value)
+{
+}
+
+// The copy constructor (performs initialization).
+
+template <class T>
+ACE_Array<T>::ACE_Array (const ACE_Array<T> &s)
+ : ACE_Array_Base<T> (s)
+{
+}
+
+// Assignment operator (performs assignment).
+
+template <class T> void
+ACE_Array<T>::operator= (const ACE_Array<T> &s)
+{
+ // Check for "self-assignment".
+
+ if (this == &s)
+ return;
+ else {
+ this->ACE_Array_Base<T>::operator= (s);
+ }
+}
+
// Compare this array with <s> for inequality.
template <class T> ACE_INLINE int
@@ -341,6 +386,8 @@ ACE_Array<T>::operator!= (const ACE_Array<T> &s) const
return !(*this == s);
}
+// ****************************************************************
+
template <class T> ACE_INLINE void
ACE_Array_Iterator<T>::dump (void) const
{
@@ -348,7 +395,7 @@ ACE_Array_Iterator<T>::dump (void) const
}
template <class T> ACE_INLINE
-ACE_Array_Iterator<T>::ACE_Array_Iterator (ACE_Array<T> &a)
+ACE_Array_Iterator<T>::ACE_Array_Iterator (ACE_Array_Base<T> &a)
: current_ (0),
array_ (a)
{
@@ -380,6 +427,8 @@ ACE_Array_Iterator<T>::done (void) const
return this->current_ >= array_.size ();
}
+// ****************************************************************
+
template <class T> ACE_INLINE void
ACE_DLList<T>::operator= (ACE_DLList<T> &l)
{
diff --git a/ace/OS.cpp b/ace/OS.cpp
index 6bd6ded7a00..fe136c43a04 100644
--- a/ace/OS.cpp
+++ b/ace/OS.cpp
@@ -1858,11 +1858,13 @@ ACE_TSS_Emulation::tss_open (void *ts_storage[ACE_TSS_THREAD_KEYS_MAX])
# if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class ACE_Array<ACE_TSS_Info>;
+template class ACE_Array_Base<ACE_TSS_Info>;
template class ACE_Array_Iterator<ACE_TSS_Info>;
template class ACE_Node<ACE_TSS_Ref>;
template class ACE_TSS<ACE_TSS_Keys>;
# elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
# pragma instantiate ACE_Array<ACE_TSS_Info>
+# pragma instantiate ACE_Array_Base<ACE_TSS_Info>
# pragma instantiate ACE_Array_Iterator<ACE_TSS_Info>
# pragma instantiate ACE_Node<ACE_TSS_Ref>
# pragma instantiate ACE_TSS<ACE_TSS_Keys>
diff --git a/ace/Object_Manager.cpp b/ace/Object_Manager.cpp
index 67dc50b614d..81af54dcbb3 100644
--- a/ace/Object_Manager.cpp
+++ b/ace/Object_Manager.cpp
@@ -961,8 +961,11 @@ ACE_Static_Object_Lock::cleanup_lock (void)
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
template class ACE_Array<ACE_Thread_Mutex *>;
+ template class ACE_Array_Base<ACE_Thread_Mutex *>;
template class ACE_Array<ACE_Mutex *>;
+ template class ACE_Array_Base<ACE_Mutex *>;
template class ACE_Array<ACE_RW_Thread_Mutex *>;
+ template class ACE_Array_Base<ACE_RW_Thread_Mutex *>;
template class ACE_Cleanup_Adapter<ACE_Null_Mutex>;
template class ACE_Cleanup_Adapter<ACE_Mutex>;
template class ACE_Cleanup_Adapter<ACE_Recursive_Thread_Mutex>;
@@ -980,8 +983,11 @@ ACE_Static_Object_Lock::cleanup_lock (void)
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
# pragma instantiate ACE_Array<ACE_Thread_Mutex *>
+# pragma instantiate ACE_Array_Base<ACE_Thread_Mutex *>
# pragma instantiate ACE_Array<ACE_Mutex *>
+# pragma instantiate ACE_Array_Base<ACE_Mutex *>
# pragma instantiate ACE_Array<ACE_RW_Thread_Mutex *>
+# pragma instantiate ACE_Array_Base<ACE_RW_Thread_Mutex *>
# pragma instantiate ACE_Cleanup_Adapter<ACE_Null_Mutex>
# pragma instantiate ACE_Cleanup_Adapter<ACE_Mutex>
# pragma instantiate ACE_Cleanup_Adapter<ACE_Recursive_Thread_Mutex>
diff --git a/ace/Template_Instantiations.cpp b/ace/Template_Instantiations.cpp
index eb19acdc688..54d458591f6 100644
--- a/ace/Template_Instantiations.cpp
+++ b/ace/Template_Instantiations.cpp
@@ -57,9 +57,13 @@ template class ACE_Guard<ACE_RW_Thread_Mutex>;
ACE_MT (template class ACE_TSS_Guard<ACE_Recursive_Thread_Mutex>);
template class ACE_Array<ACE_Mutex *>;
+template class ACE_Array_Base<ACE_Mutex *>;
template class ACE_Array<ACE_RW_Thread_Mutex *>;
+template class ACE_Array_Base<ACE_RW_Thread_Mutex *>;
template class ACE_Array<ACE_TSS_Info>;
+template class ACE_Array_Base<ACE_TSS_Info>;
template class ACE_Array<ACE_Thread_Mutex *>;
+template class ACE_Array_Base<ACE_Thread_Mutex *>;
template class ACE_Array_Iterator<ACE_TSS_Info>;
// ACE_PROCESS_MUTEX is defined in Malloc.h,
diff --git a/apps/JAWS/clients/Caching/URL_Properties.cpp b/apps/JAWS/clients/Caching/URL_Properties.cpp
index a0beac5892a..eeae1f43581 100644
--- a/apps/JAWS/clients/Caching/URL_Properties.cpp
+++ b/apps/JAWS/clients/Caching/URL_Properties.cpp
@@ -138,7 +138,9 @@ ACE_URL_Offer::dump (void) const
}
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
+template class ACE_Array_Base<ACE_URL_Property>;
template class ACE_Array<ACE_URL_Property>;
+template class ACE_Array_Base<ACE_URL_Offer>;
template class ACE_Array<ACE_URL_Offer>;
template size_t ace_array_size (ACE_Array<ACE_URL_Property> &);
template size_t ace_array_encode (void *, ACE_Array<ACE_URL_Property> &);
@@ -147,7 +149,9 @@ template size_t ace_array_size (ACE_Array<ACE_URL_Offer> &);
template size_t ace_array_encode (void *, ACE_Array<ACE_URL_Offer> &);
template size_t ace_array_decode (void *, ACE_Array<ACE_URL_Offer> &);
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
+#pragma instantiate ACE_Array_Base<ACE_URL_Property>
#pragma instantiate ACE_Array<ACE_URL_Property>
+#pragma instantiate ACE_Array_Base<ACE_URL_Offer>
#pragma instantiate ACE_Array<ACE_URL_Offer>
#pragma instantiate size_t ace_array_size (ACE_Array<ACE_URL_Property> &)
#pragma instantiate size_t ace_array_encode (void *, ACE_Array<ACE_URL_Property> &)
diff --git a/bin/Array.pl b/bin/Array.pl
new file mode 100755
index 00000000000..7f9bf393e15
--- /dev/null
+++ b/bin/Array.pl
@@ -0,0 +1,31 @@
+#!/bin/sh -- # -*- perl -*-
+eval 'exec perl -pi.Array.$$ -S $0 ${1+"$@"}'
+ if 0;
+
+# $Id$
+
+#
+# After the 4.6.10 release the template instantiations for ACE_Array
+# have changed, the class is implemented in terms of ACE_Array_Base;
+# this script fixes the template instantiations if needed.
+#
+# It changes instantiations of:
+#
+# ACE_Array<T>
+#
+# into:
+#
+# ACE_Array<T>
+# ACE_Array_Base<T>
+#
+
+# Notice the use of the -pi options: the while(<>) loop is implicit,
+# printing the current line is also implicit as well as fixing the
+# file in place.
+
+if (m/template class\s+ACE_Array\s*<(.*)>\s*;\s*/) {
+ print "template class ACE_Array_Base<", $1, ">;\n";
+} elsif (m/#pragma instantiate\s+ACE_Array\s*<(.*)>\s*$/) {
+ print "#pragma instantiate ACE_Array_Base<", $1, ">\n";
+}
+
diff --git a/bin/Array_Helper b/bin/Array_Helper
new file mode 100755
index 00000000000..6ffce3b799e
--- /dev/null
+++ b/bin/Array_Helper
@@ -0,0 +1,16 @@
+#! /bin/sh
+#
+# $Id$
+#
+
+# Finds all files that instantiate ACE_Array and runs the Array.pl
+# perl script on them, please check $ACE_ROOT/bin/Array.pl for more
+# details.
+
+find $* -type f -a \( -name '*.h' \
+ -o -name '*.i' \
+ -o -name '*.cpp' \) |
+ xargs egrep -l 'template[ \t]*class[ \t]*ACE_Array[ \t]*\<' |
+ xargs perl -pi $ACE_ROOT/bin/Hash_Map_Manager.pl
+
+
diff --git a/bin/count_lines b/bin/count_lines
index def948ae00c..ed6f2d21375 100755
--- a/bin/count_lines
+++ b/bin/count_lines
@@ -1,11 +1,11 @@
-# -*- perl -*-
-# $Id$
-#
-
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
& eval 'exec perl -S $0 $argv:q'
if 0;
+# -*- perl -*-
+# $Id$
+#
+
use File::Basename;
$cmd= basename($0);