FBase.H 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* -*-C++-*-
  2. "$Id: FBase.H,v 1.3 2000/05/14 06:05:53 jamespalmer Exp $"
  3. Copyright 1999-2000 by the Flek development team.
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with this library; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  15. USA.
  16. Please report all bugs and problems to "[email protected]".
  17. */
  18. #ifndef _FBASE_H_
  19. #define _FBASE_H_
  20. /** @package libflek_core
  21. * FBase is the Abstract base class for all f classes. The FBase
  22. * class can be used to build container classes which use object
  23. * pointers. The same container class can then be used with any
  24. * derived classes without the need of any additional code or templates.
  25. *
  26. * FBase has no member data. It only has protected constructors (to
  27. * prevent instantiation), virtual destructors and an assignment operator.
  28. */
  29. class FBase
  30. {
  31. public:
  32. typedef FBase* Ptr;
  33. /**
  34. * Assignment operator. This operator must be overriden to be useful,
  35. * it's default behavior is to do nothing.
  36. *
  37. * @param src
  38. */
  39. FBase& operator = (const FBase&) {
  40. return *this;
  41. }
  42. /**
  43. * Destructor.
  44. */
  45. virtual ~FBase () {}
  46. /**
  47. * Derived class should give a meaningful implementation
  48. * for the following functions.
  49. *
  50. * Classes such as List which use FBase pointers
  51. * will use these functions, for memory management
  52. *
  53. * Make a copy of the FBase and return a pointer to the new one.
  54. */
  55. virtual Ptr copy () const = 0;
  56. protected:
  57. /**
  58. * The default constructor is protected to prevent instantiation,
  59. */
  60. FBase () {}
  61. /**
  62. * The copy constructor is protected to prevent instantiation.
  63. *
  64. * @param src The class to take initial data from.
  65. */
  66. FBase (const FBase&) {}
  67. };
  68. #endif // #ifndef FBASE_H_