summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog-97a21
-rw-r--r--README6
-rw-r--r--ace/Array.cpp143
-rw-r--r--ace/Array.h114
-rw-r--r--ace/Array.i19
-rw-r--r--apps/JAWS/server/HTTP_Helpers.cpp2
6 files changed, 292 insertions, 13 deletions
diff --git a/ChangeLog-97a b/ChangeLog-97a
index fea1296dec6..7e07a0e35cf 100644
--- a/ChangeLog-97a
+++ b/ChangeLog-97a
@@ -1,15 +1,8 @@
-Wed Apr 30 09:22:33 1997 David L. Levine <levine@cs.wustl.edu>
-
- * ace/IOStream.{h,cpp}: James CE Johnson <jcej@lads.com> updated
- the IOStream class, see comments in IOStream.h.
-
- * examples/Logger/client/logging_app.cpp (main),
- performance-tests/Misc/test_naming.cpp (*): replaced sprintf
- with ACE_OS::sprintf. Thanks to Thilo Kielmann
- <kielmann@informatik.uni-siegen.de> for reporting these.
-
Wed Apr 30 08:42:55 1997 Douglas C. Schmidt <schmidt@flamenco.cs.wustl.edu>
+ * ace: Added a new generic Array class, which we'll use until
+ STL becomes more widely portable.
+
* ace: Added a new macro ACE_LACKS_GETPGID to clean up the code
in ACE_OS::getpgid().
@@ -18,6 +11,14 @@ Wed Apr 30 08:42:55 1997 Douglas C. Schmidt <schmidt@flamenco.cs.wustl.edu>
Wed Apr 30 07:44:36 1997 David L. Levine <levine@cs.wustl.edu>
+ * ace/IOStream.{h,cpp}: James CE Johnson <jcej@lads.com> updated
+ the IOStream class, see comments in IOStream.h.
+
+ * examples/Logger/client/logging_app.cpp (main),
+ performance-tests/Misc/test_naming.cpp (*): replaced sprintf
+ with ACE_OS::sprintf. Thanks to Thilo Kielmann
+ <kielmann@informatik.uni-siegen.de> for reporting these.
+
* ace/config-osf1-4.0*.h: removed ACE_HAS_SIGWAIT.
* ace/OS.{h,i}: applied Thilo's patch for sigwait on Digital
diff --git a/README b/README
index 66b778b907f..497696fa334 100644
--- a/README
+++ b/README
@@ -33,9 +33,9 @@ services in one or more processes or threads.
ACE has been ported to a wide range of uni-processor and multi-process
OS platforms including Win32 (i.e., WinNT and Win95), most versions of
-UNIX (e.g., SunOS 4.x and 5.x, SGI IRIX, HP-UX, OSF/1, AIX, Linux, and
-SCO), VxWorks, and MVS OpenEdition. It is currently used in
-commercial products by dozens of companies including Ericsson,
+UNIX (e.g., SunOS 4.x and 5.x, SGI IRIX, HP-UX, OSF/1, AIX, Linux,
+SCO, and FreeBSD), VxWorks, and MVS OpenEdition. It is currently used
+in commercial products by dozens of companies including Ericsson,
Bellcore, Siemens, Motorola, Kodak, and McDonnell Douglas. There are
both C++ and Java versions of ACE available.
diff --git a/ace/Array.cpp b/ace/Array.cpp
new file mode 100644
index 00000000000..238831e78c6
--- /dev/null
+++ b/ace/Array.cpp
@@ -0,0 +1,143 @@
+// Array.cpp
+// $Id$
+
+#if !defined (ARRAY_C)
+#define ARRAY_C
+
+#define ACE_BUILD_DLL
+#include "Array.h"
+
+#if !defined (__INLINE__)
+#define INLINE
+#include "Array.i"
+#endif /* __INLINE__ */
+
+// Dynamically initialize an array.
+
+template <class T>
+ACE_Array<T>::ACE_Array (size_t size)
+ : cur_size_ (size),
+ max_size_ (size)
+{
+ ACE_NEW (this->array_, T[size]);
+}
+
+template <class T>
+ACE_Array<T>::ACE_Array (size_t size,
+ const T &default_value)
+ : cur_size_ (size),
+ max_size_ (size)
+{
+ ACE_NEW (this->array_, T[size]);
+
+ for (size_t i = 0; i < size; i++)
+ this->array_[i] = default_value;
+}
+
+// The copy constructor (performs initialization).
+
+template <class T>
+ACE_Array<T>::ACE_Array (const ACE_Array<T> &s)
+ : cur_size_ (s.size ()),
+ max_size_ (s.size ())
+{
+ ACE_NEW (this->array_ T[s.size ()]);
+
+ for (size_t i = 0; i < this->size (); i++)
+ this->array_[i] = s.array_[i];
+}
+
+// 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 if (this->max_size_ < s.size ())
+ {
+ delete [] this->array_;
+
+ ACE_NEW (this->array_ T[s.size ()]);
+
+ this->max_size_ = s.size ();
+ }
+
+ this->cur_size_ = s.size ();
+
+ for (size_t i = 0; i < this->size (); i++)
+ this->array_[i] = s.array_[i];
+}
+
+// Clean up the array (e.g., delete dynamically allocated memory).
+
+template <class T>
+ACE_Array<T>::~ACE_Array (void)
+{
+ delete [] this->array_;
+}
+
+// = Set/get methods.
+
+template <class T> T &
+ACE_Array<T>::operator[] (size_t index)
+{
+ return this->array_[index];
+}
+
+// Set an item in the array at location index.
+
+template <class T> int
+ACE_Array<T>::set (const T &new_item, size_t index)
+{
+ if (this->in_range (index))
+ {
+ this->array_[index] = new_item;
+ return 0;
+ }
+ else
+ return -1;
+}
+
+// Get an item in the array at location index.
+
+template <class T> int
+ACE_Array<T>::get (T &item, size_t index) const
+{
+ if (this->in_range (index))
+ {
+ item = this->array_[index];
+ return 0;
+ }
+ else
+ return -1;
+}
+
+// Compare this array with <s> for equality.
+
+template <class T> int
+ACE_Array<T>::operator== (const ACE_Array<T> &s) const
+{
+ if (this == &s)
+ return 1;
+ else if (this->cur_size_ != s.cur_size_)
+ return 0;
+
+ for (size_t index = 0; index < s.cur_size_; index++)
+ if (this->array_[index] != s.array_[index])
+ return 0;
+
+ return 1;
+}
+
+// Compare this array with <s> for inequality.
+
+template <class T> int
+ACE_Array<T>::operator!= (const ACE_Array<T> &s) const
+{
+ return !(*this == s);
+}
+
+#endif /* ARRAY_C */
diff --git a/ace/Array.h b/ace/Array.h
new file mode 100644
index 00000000000..beab85b3b69
--- /dev/null
+++ b/ace/Array.h
@@ -0,0 +1,114 @@
+/* -*- C++ -*- */
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// ace
+//
+// = FILENAME
+// Array.h
+//
+// = AUTHOR
+// Doug Schmidt
+//
+// ============================================================================
+
+#if !defined (ACE_ARRAY_H)
+#define ACE_ARRAY_H
+
+#include "ace/ACE.h"
+
+template <class T>
+class ACE_Array
+{
+public:
+ // Define a "trait"
+ typedef T TYPE;
+
+ // = Exceptions.
+
+ // = Initialization and termination methods.
+
+ ACE_Array (size_t size);
+ // 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>.
+
+ ~ACE_Array (void);
+ // Clean up the array (e.g., delete dynamically allocated memory).
+
+ // = Set/get methods.
+
+ T &operator [] (size_t index);
+ // Set/get item in the array at location <index>. Doesn't
+ // perform range checking.
+
+ int set (const T &new_item, size_t index);
+ // Set an item in the array at location <index>. Returns
+ // -1 if <index> is not in range, else returns 0.
+
+ int get (T &item, size_t index);
+ // Get an item in the array at location <index>. Returns -1 if
+ // <index> is not in range, else returns 0.
+
+ size_t size (void) const;
+ // Returns the <cur_size_> of the array.
+
+ 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>.
+
+private:
+ int in_range (size_t index) const;
+ // Returns 1 if <index> is within range, i.e., 0 >= <index> <
+ // <cur_size_>, else returns 0.
+
+ size_t max_size_;
+ // Maximum size of the array, i.e., the total number of <T> elements
+ // in <array_>.
+
+ size_t cur_size_;
+ // Current size of the array. This starts out being == to
+ // <max_size_>. However, if we are assigned a smaller array, then
+ // <cur_size_> will become less than <max_size_>. The purpose of
+ // keeping track of both sizes is to avoid reallocating memory if we
+ // don't have to.
+
+ T *array_;
+ // Pointer to the array's storage buffer.
+};
+
+#if defined (__ACE_INLINE__)
+#include "ace/Array.i"
+#endif /* __ACE_INLINE__ */
+
+#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
+#include "ace/Array.cpp"
+#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
+
+#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
+#pragma implementation ("Array.cpp")
+#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
+
+#endif /* ACE_ARRAY_H */
diff --git a/ace/Array.i b/ace/Array.i
new file mode 100644
index 00000000000..597cde467cc
--- /dev/null
+++ b/ace/Array.i
@@ -0,0 +1,19 @@
+/* -*- C++ -*- */
+
+template <class T> ACE_INLINE size_t
+ACE_Array<T>::size (void) const
+{
+ return this->cur_size_;
+}
+
+template <class T> ACE_INLINE int
+ACE_Array<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)
+{
+ return this->array_[index];
+}
diff --git a/apps/JAWS/server/HTTP_Helpers.cpp b/apps/JAWS/server/HTTP_Helpers.cpp
index 3c363e83bdf..135b0fbfba6 100644
--- a/apps/JAWS/server/HTTP_Helpers.cpp
+++ b/apps/JAWS/server/HTTP_Helpers.cpp
@@ -77,8 +77,10 @@ HTTP_Helper::HTTP_mktime (const char *httpdate)
/* mktime is a Standard C function */
{
#if !defined (ACE_HAS_REENTRANT_LIBC)
+#if defined (ACE_HAS_THREADS)
static ACE_Thread_Mutex mutex;
ACE_Guard<ACE_Thread_Mutex> g(mutex);
+#endif /* ACE_HAS_THREADS */
#endif /* NOT ACE_HAS_REENTRANT_LIBC */
return ::mktime(&tms);
}