GemaCoreLib
The GeMA Core library
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 
28 class GmUserFunction;
30 
31 #include <qtNanBoxedValue.h>
32 
33 
40 class GmNanBoxedValue : public QtNanBoxedValue
41 {
42 public:
43 
46  {
49  };
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 
76 Q_DECLARE_TYPEINFO(GmNanBoxedValue, Q_PRIMITIVE_TYPE);
77 
78 #endif
GmNanBoxedValue(GmUserFunctionEvaluator *ptr)
Constructor for storing a User function evaluator pointer.
Definition: gmNanBoxedValue.h:61
GmNanBoxedValue(GmUserFunction *ptr)
Constructor for storing a User function pointer.
Definition: gmNanBoxedValue.h:58
Class responsible for evaluating a UserFunction over a node / cell.
Definition: gmUserFunction.h:148
Declaration of usefull configuration definitions for the Core library.
Stored pointer is a GmUserFunction*.
Definition: gmNanBoxedValue.h:47
PointerTags
Pointer tag values.
Definition: gmNanBoxedValue.h:45
Stored pointer is a GmUserFunctionEvaluator*.
Definition: gmNanBoxedValue.h:48
GmUserFunctionEvaluator * toUserFunctionEvaluator() const
Returns the stored value as a GmUserFunctionEvaluator*.
Definition: gmNanBoxedValue.h:73
GmUserFunction * toUserFunction() const
Returns the stored value as a GmUserFunction*.
Definition: gmNanBoxedValue.h:70
A wrapper class around QtNanBoxedValue providing specific constructors to store user functions / user...
Definition: gmNanBoxedValue.h:40
GmNanBoxedValue()
Default constructor: a zero double value.
Definition: gmNanBoxedValue.h:52
bool isUserFunction() const
Is this a User function pointer value?
Definition: gmNanBoxedValue.h:64
GmNanBoxedValue(double value)
Constructor for storing a double value.
Definition: gmNanBoxedValue.h:55
bool isUserFunctionEvaluator() const
Is this a User function evaluator pointer value?
Definition: gmNanBoxedValue.h:67
Class used to store the definition of a user function and its parameters.
Definition: gmUserFunction.h:78