]> www.ginac.de Git - cln.git/blob - include/cln/dfloat_class.h
Replace CL_REQUIRE/CL_PROVIDE(cl_DF_globals) with portable code.
[cln.git] / include / cln / dfloat_class.h
1 // Concrete class of double float numbers.
2
3 #ifndef _CL_DFLOAT_CLASS_H
4 #define _CL_DFLOAT_CLASS_H
5
6 #include "cln/number.h"
7 #include "cln/float_class.h"
8
9 namespace cln {
10
11 class cl_DF : public cl_F {
12 public:
13 // Default constructor.
14         cl_DF ();
15 // Assignment operators.
16         cl_DF& operator= (const cl_DF&);
17 // Optimization of method pointer_p().
18         bool pointer_p() const
19                 { return true; }
20 // Faster pointer_p() gives a faster copy constructor (but not destructor!!!).
21         cl_DF (const cl_DF& x);
22 // Constructors and assignment operators from C numeric types.
23         cl_DF (const double);
24         cl_DF& operator= (const double);
25 // Other constructors.
26         cl_DF (const char *);
27 // Private constructor.
28         cl_DF (cl_private_thing);
29         cl_DF (struct cl_heap_dfloat *);
30 // Private pointer manipulations.
31         operator struct cl_heap_dfloat * () const;
32 public: // Ability to place an object at a given address.
33         void* operator new (size_t size) { return malloc_hook(size); }
34         void* operator new (size_t size, void* ptr) { (void)size; return ptr; }
35         void operator delete (void* ptr) { free_hook(ptr); }
36 private:
37 // Friend declarations. They are for the compiler. Just ignore them.
38 };
39
40 // Private constructors.
41 inline cl_DF::cl_DF (cl_private_thing ptr) : cl_F (ptr) {}
42 // The assignment operators:
43 CL_DEFINE_ASSIGNMENT_OPERATOR(cl_DF, cl_DF)
44 // The default constructors.
45 // Private pointer manipulations. Never throw away a `struct cl_heap_dfloat *'!
46 inline cl_DF::operator struct cl_heap_dfloat * () const
47 {
48         struct cl_heap_dfloat * hpointer = (struct cl_heap_dfloat *) pointer;
49         cl_inc_refcount(*this);
50         return hpointer;
51 }
52 extern const cl_DF cl_DF_0;
53 inline cl_DF::cl_DF ()
54         : cl_F ((cl_private_thing) (struct cl_heap_dfloat *) cl_DF_0) {}
55 class cl_DF_globals_init_helper
56 {
57         static int count;
58 public:
59         cl_DF_globals_init_helper();
60         ~cl_DF_globals_init_helper();
61 };
62 static cl_DF_globals_init_helper cl_DF_globals_init_helper_instance;
63
64 #if 0 // see cl_DF.h
65 inline cl_DF::cl_DF (struct cl_heap_dfloat * ptr)
66         : cl_F ((cl_private_thing) ptr) {}
67 #endif
68 // The copy constructors.
69 CL_DEFINE_COPY_CONSTRUCTOR2(cl_DF,cl_F)
70 // Constructors and assignment operators from C numeric types.
71 CL_DEFINE_DOUBLE_CONSTRUCTOR(cl_DF)
72
73 }  // namespace cln
74
75 #endif /* _CL_DFLOAT_CLASS_H */