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

  1.  
  2.  
  3. #ifndef _iofilter_h_ /* Thu Jul  7 15:49:50 1994 */
  4. #define _iofilter_h_
  5.  
  6.  
  7.  
  8.  
  9. /*
  10.  *
  11.  *          Copyright (C) 1994, M. A. Sridhar
  12.  *  
  13.  *
  14.  *     This software is Copyright M. A. Sridhar, 1994. You are free
  15.  *     to copy, modify or distribute this software  as you see fit,
  16.  *     and to use  it  for  any  purpose, provided   this copyright
  17.  *     notice and the following   disclaimer are included  with all
  18.  *     copies.
  19.  *
  20.  *                        DISCLAIMER
  21.  *
  22.  *     The author makes no warranties, either expressed or implied,
  23.  *     with respect  to  this  software, its  quality, performance,
  24.  *     merchantability, or fitness for any particular purpose. This
  25.  *     software is distributed  AS IS.  The  user of this  software
  26.  *     assumes all risks  as to its quality  and performance. In no
  27.  *     event shall the author be liable for any direct, indirect or
  28.  *     consequential damages, even if the  author has been  advised
  29.  *     as to the possibility of such damages.
  30.  *
  31.  */
  32.  
  33.  
  34.  
  35. #ifdef __GNUC__
  36. #pragma interface
  37. #endif
  38.  
  39. #include "base/object.h"
  40.  
  41. class CL_EXPORT CL_ObjectIOFilter: public CL_Object {
  42.  
  43. public:
  44.     ~CL_ObjectIOFilter () {};
  45.     
  46.     virtual CL_ObjectPtr RestoreFrom (const CL_Stream& s);
  47.     // "Polymorphic" restoration: the returned pointer is to a newly
  48.     // created object which can be of any class derived from CL_Object.
  49.     // The default implementation returns an object whose type is
  50.     // indicated by the class id seen in the stream.
  51.  
  52.     virtual bool RestoreFrom (const CL_Stream& s, CL_Object& o);
  53.     // Restore the object o from the stream. With the default
  54.     // implementation, the type of object restored
  55.     // matches the type of o. If the stream contains an object that is not
  56.     // of o's class, the restoration fails.
  57.     
  58.     virtual bool       SaveTo (CL_Stream& s, const CL_Object& o) const;
  59.     // Write the value of o to the stream. The default implementation uses
  60.     // o's {\tt WriteTo} method.
  61.     
  62.     virtual bool   SaveTo (CL_Stream& s, CL_ObjectPtr o) const;
  63.     // Write the value determined by the pointer {\tt o} into the stream.
  64.     // The default implementation simply forwards the call to the stream.
  65.     
  66. };
  67.  
  68.  
  69.  
  70.  
  71. template <class Base>
  72. class CL_EXPORT CL_IOFilter: public CL_ObjectIOFilter {
  73.  
  74. public:
  75.     ~CL_IOFilter () {};
  76.     
  77.     virtual CL_Object* RestoreFrom (const CL_Stream& s);
  78.  
  79.     virtual bool RestoreFrom (const CL_Stream& s, CL_Object& o);
  80.     
  81. };
  82.  
  83.  
  84. #endif /* _iofilter_h_ */
  85.