home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / base / objseq.cxx < prev    next >
C/C++ Source or Header  |  1995-04-04  |  3KB  |  127 lines

  1.  
  2.  
  3.  
  4.  
  5. /*
  6.  *
  7.  *          Copyright (C) 1994, M. A. Sridhar
  8.  *  
  9.  *
  10.  *     This software is Copyright M. A. Sridhar, 1994. You are free
  11.  *     to copy, modify or distribute this software  as you see fit,
  12.  *     and to use  it  for  any  purpose, provided   this copyright
  13.  *     notice and the following   disclaimer are included  with all
  14.  *     copies.
  15.  *
  16.  *                        DISCLAIMER
  17.  *
  18.  *     The author makes no warranties, either expressed or implied,
  19.  *     with respect  to  this  software, its  quality, performance,
  20.  *     merchantability, or fitness for any particular purpose. This
  21.  *     software is distributed  AS IS.  The  user of this  software
  22.  *     assumes all risks  as to its quality  and performance. In no
  23.  *     event shall the author be liable for any direct, indirect or
  24.  *     consequential damages, even if the  author has been  advised
  25.  *     as to the possibility of such damages.
  26.  *
  27.  */
  28.  
  29.  
  30.  
  31.  
  32.  
  33. #ifdef __GNUC__
  34. #pragma implementation
  35. #endif
  36.  
  37.  
  38. #ifndef __BORLANDC__
  39. #include "base/seqimp.cxx"    // Include this first, to appease GNU C++
  40.  
  41. // This is not included under BC++ because it implicitly instantiates
  42. // CL_Sequence<long> here as well as in strgseq.obj, causing multiple
  43. // definitions.
  44. #endif
  45.  
  46. #include "base/objseq.h"
  47. #include "base/stream.h"
  48.  
  49. CL_DEFINE_CLASS(CL_ObjectSequence, _CL_ObjectSequence_CLASSID);
  50.  
  51. #if defined(__GNUC__) && __GNUC_MINOR__ >= 6
  52. template class CL_Sequence<CL_ObjectPtr>;
  53. #else
  54. typedef CL_Sequence<CL_ObjectPtr> CL_PtrSeq;  // Don't use this: use the class
  55.                                               // CL_ObjectSequence instead.
  56. #endif
  57.  
  58.  
  59. CL_ObjectSequence::CL_ObjectSequence (long initial_size ,
  60.                    CL_ObjectIOFilter* bld)
  61. : CL_Sequence<CL_ObjectPtr> (initial_size)
  62. {
  63.     _builder = bld;
  64. }
  65.  
  66.  
  67. CL_ObjectSequence::CL_ObjectSequence
  68.     (const CL_ObjectPtr data[], long count, CL_ObjectIOFilter* builder)
  69. : CL_Sequence<CL_ObjectPtr> (data, count)
  70. {
  71.     _builder = builder;
  72. }
  73.  
  74. CL_ObjectSequence::CL_ObjectSequence (const CL_ObjectSequence& s)
  75. : CL_Sequence<CL_ObjectPtr> (s)
  76. {
  77.     _builder = s._builder;
  78. }
  79.  
  80.  
  81. CL_ObjectSequence::~CL_ObjectSequence ()
  82. {
  83. }
  84.  
  85.  
  86.  
  87.  
  88. void CL_ObjectSequence::DestroyContents ()
  89. {
  90.     if (!PrepareToChange())
  91.         return;
  92.     long n = Size();
  93.     for (long i = 0; i < n; i++) {
  94.         CL_ObjectPtr p = (*this)[i];
  95.         if (p)
  96.             delete p;
  97.     }
  98.     _size = 0;
  99.     Notify ();
  100. }
  101.  
  102.  
  103. bool CL_ObjectSequence::ReadFrom (const CL_Stream& s)
  104. {
  105. //     if (!_builder || !ReadClassId (s) )
  106. //         return FALSE;
  107. //     if (!PrepareToChange())
  108. //         return FALSE;
  109. //     long size;
  110. //     if (!s.Read (size))
  111. //         return FALSE;
  112. //     if (!ChangeSize (size))
  113. //         return FALSE;
  114. //     for (long i = 0; i < size; i++) {
  115. //         CL_ObjectPtr p = _builder->BuildFrom (s);
  116. //         if (!p)
  117. //             return FALSE;
  118. //         (*this)[i] = p;
  119. //     }
  120. //     Notify();
  121. //     return TRUE;
  122.     return CL_Sequence<CL_ObjectPtr>::ReadFrom (s);
  123. }
  124.  
  125.  
  126.  
  127.