You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.2 KiB

25 years ago
  1. // Concrete class of single float numbers.
  2. #ifndef _CL_FFLOAT_CLASS_H
  3. #define _CL_FFLOAT_CLASS_H
  4. #include "cl_number.h"
  5. #include "cl_float_class.h"
  6. class cl_FF : public cl_F {
  7. public:
  8. // Default constructor.
  9. cl_FF ();
  10. // Assignment operators.
  11. cl_FF& operator= (const cl_FF&);
  12. // Optimization of method pointer_p().
  13. cl_boolean pointer_p() const
  14. #if defined(CL_WIDE_POINTERS)
  15. { return cl_false; }
  16. #else
  17. { return cl_true; }
  18. #endif
  19. // Faster pointer_p() gives a faster copy constructor (but not destructor!!!).
  20. cl_FF (const cl_FF& x);
  21. // Constructors and assignment operators from C numeric types.
  22. cl_FF (const float);
  23. cl_FF& operator= (const float);
  24. // Other constructors.
  25. cl_FF (const char *);
  26. // Private constructor.
  27. cl_FF (cl_private_thing);
  28. #if defined(CL_WIDE_POINTERS)
  29. cl_FF (struct cl_heap_ffloat * /* NULL! */, cl_uint);
  30. #else
  31. cl_FF (struct cl_heap_ffloat *);
  32. // Private pointer manipulations.
  33. operator struct cl_heap_ffloat * () const;
  34. #endif
  35. public: // Ability to place an object at a given address.
  36. void* operator new (size_t size) { return cl_malloc_hook(size); }
  37. void* operator new (size_t size, cl_FF* ptr) { (void)size; return ptr; }
  38. void operator delete (void* ptr) { cl_free_hook(ptr); }
  39. };
  40. // Private constructors.
  41. inline cl_FF::cl_FF (cl_private_thing ptr) : cl_F (ptr) {}
  42. // The assignment operators:
  43. CL_DEFINE_ASSIGNMENT_OPERATOR(cl_FF, cl_FF)
  44. // The default constructors.
  45. #if defined(CL_WIDE_POINTERS)
  46. inline cl_FF::cl_FF ()
  47. : cl_F ((cl_private_thing) cl_combine(cl_FF_tag,0)) {}
  48. #else
  49. // Private pointer manipulations. Never throw away a `struct cl_heap_ffloat *'!
  50. inline cl_FF::operator struct cl_heap_ffloat * () const
  51. {
  52. struct cl_heap_ffloat * hpointer = (struct cl_heap_ffloat *) pointer;
  53. cl_inc_refcount(*this);
  54. return hpointer;
  55. }
  56. extern const cl_FF cl_FF_0;
  57. inline cl_FF::cl_FF ()
  58. : cl_F ((cl_private_thing) (struct cl_heap_ffloat *) cl_FF_0) {}
  59. CL_REQUIRE(cl_FF_globals)
  60. #if 0 // see cl_FF.h
  61. inline cl_FF::cl_FF (struct cl_heap_ffloat * ptr)
  62. : cl_F ((cl_private_thing) ptr) {}
  63. #endif
  64. #endif
  65. // The copy constructors.
  66. CL_DEFINE_COPY_CONSTRUCTOR2(cl_FF,cl_F)
  67. // Constructors and assignment operators from C numeric types.
  68. CL_DEFINE_FLOAT_CONSTRUCTOR(cl_FF)
  69. #endif /* _CL_FFLOAT_CLASS_H */