GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmNanBoxedValue.h
Go to the documentation of this file.
1/************************************************************************
2**
3** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4** All rights reserved.
5**
6** This file is part of the "GeMA" software. It's use should respect
7** the terms in the license agreement that can be found together
8** with this source code.
9** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11** A PARTICULAR PURPOSE.
12**
13************************************************************************/
14
23#ifndef _GEMA_NANBOXED_VALUE_H_
24#define _GEMA_NANBOXED_VALUE_H_
25
26#include "gmCoreConfig.h"
27
28class GmUserFunction;
30
31#include <qtNanBoxedValue.h>
32
33
40class GmNanBoxedValue : public QtNanBoxedValue
41{
42public:
43
50
53
55 GmNanBoxedValue(double value) : QtNanBoxedValue(value) {}
56
58 GmNanBoxedValue(GmUserFunction* ptr) : QtNanBoxedValue(ptr, UserFunction) {}
59
62
64 bool isUserFunction() const { return ptrTag() == UserFunction; }
65
67 bool isUserFunctionEvaluator() const { return ptrTag() == FunctionEvaluator; }
68
70 GmUserFunction* toUserFunction() const { assert(isUserFunction()); return toPtr<GmUserFunction>(); }
71
73 GmUserFunctionEvaluator* toUserFunctionEvaluator() const { assert(isUserFunctionEvaluator()); return toPtr<GmUserFunctionEvaluator>(); }
74};
75
77class GmNanBoxedIndex : public QtNanBoxedValue
78{
79public:
80
83 {
85 };
86
89
97 GmNanBoxedIndex(double value, bool normalizeNans) : QtNanBoxedValue(value, normalizeNans) {}
98
104 explicit GmNanBoxedIndex(unsigned index) : QtNanBoxedValue((void*)((quint64)index), IndexValue) {}
105
107 bool isIndex() const { return ptrTag() == IndexValue; }
108
110 unsigned toIndex() const { assert(isIndex()); return (unsigned)((quint64)toPointer()); }
111};
112
113
114Q_DECLARE_TYPEINFO(GmNanBoxedValue, Q_PRIMITIVE_TYPE);
115
116#endif
A helper class to store an usigned index as the boxed nan value.
Definition gmNanBoxedValue.h:78
GmNanBoxedIndex()
Default constructor: a zero double value.
Definition gmNanBoxedValue.h:88
PointerTags
Pointer tag values.
Definition gmNanBoxedValue.h:83
@ IndexValue
Make the quiet nan + prefix equal to 0xFFFF000000000000. Nicer for external file generators.
Definition gmNanBoxedValue.h:84
bool isIndex() const
Is this a User function pointer value?
Definition gmNanBoxedValue.h:107
GmNanBoxedIndex(unsigned index)
Constructor for storing an index. Marked as explicit since we don't want an integer (or even a double...
Definition gmNanBoxedValue.h:104
unsigned toIndex() const
Returns the stored value as an index.
Definition gmNanBoxedValue.h:110
GmNanBoxedIndex(double value, bool normalizeNans)
Constructor for storing a double value. If normalizeNans is true, if the given value is a quiet NAN v...
Definition gmNanBoxedValue.h:97
A wrapper class around QtNanBoxedValue providing specific constructors to store user functions / user...
Definition gmNanBoxedValue.h:41
PointerTags
Pointer tag values.
Definition gmNanBoxedValue.h:46
@ UserFunction
Stored pointer is a GmUserFunction*.
Definition gmNanBoxedValue.h:47
@ FunctionEvaluator
Stored pointer is a GmUserFunctionEvaluator*.
Definition gmNanBoxedValue.h:48
bool isUserFunctionEvaluator() const
Is this a User function evaluator pointer value?
Definition gmNanBoxedValue.h:67
GmNanBoxedValue(double value)
Constructor for storing a double value. Value is always normalized.
Definition gmNanBoxedValue.h:55
GmNanBoxedValue(GmUserFunctionEvaluator *ptr)
Constructor for storing a User function evaluator pointer.
Definition gmNanBoxedValue.h:61
GmUserFunctionEvaluator * toUserFunctionEvaluator() const
Returns the stored value as a GmUserFunctionEvaluator*.
Definition gmNanBoxedValue.h:73
bool isUserFunction() const
Is this a User function pointer value?
Definition gmNanBoxedValue.h:64
GmNanBoxedValue(GmUserFunction *ptr)
Constructor for storing a User function pointer.
Definition gmNanBoxedValue.h:58
GmNanBoxedValue()
Default constructor: a zero double value.
Definition gmNanBoxedValue.h:52
GmUserFunction * toUserFunction() const
Returns the stored value as a GmUserFunction*.
Definition gmNanBoxedValue.h:70
Class responsible for evaluating a UserFunction over a node / cell.
Definition gmUserFunction.h:160
Class used to store the definition of a user function and its parameters.
Definition gmUserFunction.h:82
Declaration of useful configuration definitions for the Core library.