JEMRIS  2.8.1
open-source MRI simulations
List of all members | Public Member Functions | Private Member Functions | Private Attributes
Attribute Class Reference

Attribute class. Attributes are private member variables of a Prototype which are accessible through XML and, thus, they are subject to observation mechanism. More...

#include <Attribute.h>

+ Collaboration diagram for Attribute:

Public Member Functions

 Attribute (const std::string &name, Prototype *proto, const bool &pub, const bool &obs, const double &val)
 Constructors: must provide name (XML), Prototype, public/observable status, and the member variable.
 
 Attribute (const std::string &name, Prototype *proto, const bool &pub, const bool &obs, const int &val)
 
 Attribute (const std::string &name, Prototype *proto, const bool &pub, const bool &obs, const long &val)
 
 Attribute (const std::string &name, Prototype *proto, const bool &pub, const bool &obs, const unsigned &val)
 
 Attribute (const std::string &name, Prototype *proto, const bool &pub, const bool &obs, const bool &val)
 
 Attribute (const std::string &name, Prototype *proto, const bool &pub, const bool &obs, const std::string &val)
 
 Attribute (const std::string &name, Prototype *proto, const bool &pub, const bool &obs, const PulseAxis &val)
 
 Attribute (const std::string &name, Prototype *proto, const bool &pub, const bool &obs)
 Constructor for an unobservable Attribute which does not represent a member variable.
 
virtual ~Attribute ()
 Destructor deletes local copies of Prototype member variables.
 
bool IsPublic () const
 Check, if this attribute is public for manipulation through XML. More...
 
void SetPublic (bool val)
 Set this attribute to be public for manipulation through XML. More...
 
bool IsObservable () const
 Check, if this attribute is observable by other attributes. More...
 
void SetObservable (bool val)
 Set this attribute to be observable by other attributes. More...
 
bool IsDynamic () const
 Check, if this attribute is dynamic. This is needed for exporting static XML Files of the Sequence. More...
 
void SetDynamic (bool val)
 Set this attribute to be dynamic. More...
 
int GetDiff ()
 Get the number of symbolic differentiations of the attribute's expression. More...
 
double GetImaginary ()
 Get the imaginary part the attribute's evaluation. More...
 
bool IsComplex () const
 Check, if this attribute's evaluation is complex. More...
 
void SetDiff (int val=0, std::string sym="diff")
 Set the number of symbolic differentiations of the attribute's expression. More...
 
std::string GetName () const
 Get the name of the attribute. More...
 
std::string GetTypeID () const
 Get the type ID of the attribute. More...
 
void * GetAddress () const
 Get the pointer to the value represented by this attribute. More...
 
PrototypeGetPrototype () const
 Get the pointer to the Prototype to which this attribute belongs. More...
 
std::string GetSymbol ()
 Get the GiNaC symbol of this attribute. More...
 
std::string GetFormula ()
 Get the GiNaC formula of this attribute. More...
 
bool SetMember (std::string expr, const std::vector< Attribute * > &obs_attribs, const std::vector< std::string > &obs_attrib_keyword, bool verbose=false)
 Set the Prototype's private member represented by this attribute. The function performs the following tasks: More...
 
void EvalExpression ()
 Evaluate the GiNaC expression of this attribute. More...
 
std::vector< Attribute * > GetObservers ()
 Return the observers.
 
std::vector< Attribute * > GetSubjects ()
 Return the subjects.
 
double EvalCompiledExpression (double const val, std::string const attrib)
 Evaluate the compiled GiNaC expression of this attribute. More...
 
double EvalCompiledNLGExpression (double const x, double const y, double const z, double const g)
 Evaluate the compiled GiNaC expression of the NLG attribute (nonlinear gradients) More...
 
bool HasGinacExCompiler ()
 True, if GiNaC external compiler is available on this system.
 
int GetNumberFunctionPointers ()
 Return the total number of function pointers.
 
int GetCurrentFunctionPointer ()
 Return the counter to the current function pointer.
 
void ResetCurrentFunctionPointer ()
 Set the counter to the current function pointer to zero.
 
void StepCurrentFunctionPointer ()
 Increase the counter to the current function pointer by one.
 
template<typename T >
bool Notify (const T &val)
 Notify all observers. More...
 
template<typename T >
bool NewState (const T &val)
 Check the state of the value represented by this attribute. More...
 
void AttachObserver (Attribute *attrib)
 Append a new observer of this attribute. More...
 
void AttachSubject (Attribute *attrib)
 Append a new subject observed by this this attribute. More...
 

Private Member Functions

void UpdatePrototype ()
 Update a Prototype which holds an observing Attribute. More...
 
template<typename T >
void WriteMember (const T &val)
 write the member variable of this attribute More...
 
template<typename T >
GetMember ()
 get the member variable of this attribute More...
 
template<typename T >
void Initialize (const std::string &name, Prototype *proto, const bool &pub, const bool &obs, const T &val)
 Initialize private members. More...
 

Private Attributes

bool m_public
 Indicating whether the attribute is accessible through XML.
 
bool m_observable
 Indicating whether the attribute is observable.
 
bool m_dynamic
 Indicating whether the attribute dynamically changes its value in runtime.
 
std::string m_name
 Name of the attribute (in XML).
 
void * m_address
 Pointer to the Prototype member variable, which is represented by this attribute.
 
std::string m_datatype
 Type of the Prototype member variable, which is represented by this attribute.
 
void * m_backup
 Backup value of the Prototype member variable, which is represented by this attribute.
 
Prototypem_prototype
 Pointer to the Prototype object, which instantiated this attribute.
 
std::string m_symbol_name
 GiNaC symbol name of the attribute.
 
std::string m_sym_diff
 GiNaC symbol name for symbolic derivative.
 
std::string m_formula
 Mathematical formula of the attribute (in XML) for GiNaC evaluation.
 
GiNaC::ex m_expression
 GiNaC Mathematical expression of the attribute.
 
GiNaC::lst m_symlist
 GiNaC list of all symbols involved in the calculation.
 
bool m_ginac_excomp
 True, if GiNaC external compiler is available on this system.
 
unsigned int m_num_fp
 Number of GiNaC expression function pointers owned by this attribute.
 
unsigned int m_cur_fp
 Current GiNaC expression function pointer.
 
std::vector< bool > m_compiled
 True, if GiNaC expression is compiled successfully in run time.
 
std::vector< GiNaC::FUNCP_1P > m_fp
 Function pointers to GiNaC expression evaluation.
 
std::vector< GiNaC::FUNCP_1P > m_fpi
 Function pointers to GiNaC expression evaluation of imaginary part.
 
FUNCP_4P m_nlgfp
 Function pointer to GiNaC expression evaluation of nonlinear gradients.
 
int m_diff
 Number of symbolic differentiations of the attribute's expression.
 
bool m_complex
 If symbolic expressions are complex, the imaginary part is considered.
 
double m_imaginary
 The imaginary part of complex expression evaluation.
 
std::vector< Attribute * > m_subjects
 Vector of attributes under observation by this attribute.
 
std::vector< Attribute * > m_observers
 Vector of attributes observing this attribute.
 

Detailed Description

Attribute class. Attributes are private member variables of a Prototype which are accessible through XML and, thus, they are subject to observation mechanism.

Member Function Documentation

void Attribute::AttachObserver ( Attribute attrib)

Append a new observer of this attribute.

Parameters
attribThe observing attribute.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Attribute::AttachSubject ( Attribute attrib)

Append a new subject observed by this this attribute.

Parameters
attribThe observed attribute.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double Attribute::EvalCompiledExpression ( double const  val,
std::string const  attrib 
)

Evaluate the compiled GiNaC expression of this attribute.

At first call, performs runtime compilation of the GiNaC expression. Then, compiled function evaluation is returned. Runtime compilation is repeated, if the expression changes according to notification of observed attributes in the expression. Attention: 1) Only to be used for attributes of type double. 2) The evaluation is NOT written to the Prototype's private member represented by this attribute. 3) Attributes observing this attribute are NOT notified. 4) Falls back to slow analytic evaluation, if external compilation fails.

Parameters
valfunction input value
attribattribute representing the function input value
Returns
expression evaluation

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double Attribute::EvalCompiledNLGExpression ( double const  x,
double const  y,
double const  z,
double const  g 
)

Evaluate the compiled GiNaC expression of the NLG attribute (nonlinear gradients)

At first call, performs runtime compilation of the GiNaC expression. Then, compiled function evaluation is returned.

Parameters
xx position of spin
yy position of spin
zz position of spin
ggradient
Returns
expression evaluation

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Attribute::EvalExpression ( )

Evaluate the GiNaC expression of this attribute.

The evaluation depends on the current state of all observed attributes. It is written to the Prototype's private member represented by this attribute. Afterwards, attributes observing this attribute are notified.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void* Attribute::GetAddress ( ) const
inline

Get the pointer to the value represented by this attribute.

Returns
The pointer to the value of the attribute.

+ Here is the caller graph for this function:

int Attribute::GetDiff ( )
inline

Get the number of symbolic differentiations of the attribute's expression.

Returns
The order of the derivative
std::string Attribute::GetFormula ( )
inline

Get the GiNaC formula of this attribute.

return the GiNaC formula

+ Here is the caller graph for this function:

double Attribute::GetImaginary ( )
inline

Get the imaginary part the attribute's evaluation.

Returns
The imaginary part

+ Here is the caller graph for this function:

template<typename T >
T Attribute::GetMember ( )
inlineprivate

get the member variable of this attribute

Returns
the value of the member variable

+ Here is the caller graph for this function:

std::string Attribute::GetName ( ) const
inline

Get the name of the attribute.

Returns
The name of the attribute.

+ Here is the caller graph for this function:

Prototype* Attribute::GetPrototype ( ) const
inline

Get the pointer to the Prototype to which this attribute belongs.

Returns
The pointer to the Prototype.

+ Here is the caller graph for this function:

std::string Attribute::GetSymbol ( )
inline

Get the GiNaC symbol of this attribute.

return the GiNaC symbol

+ Here is the caller graph for this function:

std::string Attribute::GetTypeID ( ) const
inline

Get the type ID of the attribute.

Returns
The type ID of the attribute.

+ Here is the caller graph for this function:

template<typename T >
void Attribute::Initialize ( const std::string &  name,
Prototype proto,
const bool &  pub,
const bool &  obs,
const T &  val 
)
inlineprivate

Initialize private members.

Parameters
namethe XML name
protothe Prototype which holds this Attribute
pubpublic status
obsobservable status
valthe member variable
bool Attribute::IsComplex ( ) const
inline

Check, if this attribute's evaluation is complex.

Returns
true/false
bool Attribute::IsDynamic ( ) const
inline

Check, if this attribute is dynamic. This is needed for exporting static XML Files of the Sequence.

Returns
true/false
bool Attribute::IsObservable ( ) const
inline

Check, if this attribute is observable by other attributes.

Returns
true/false

+ Here is the caller graph for this function:

bool Attribute::IsPublic ( ) const
inline

Check, if this attribute is public for manipulation through XML.

Returns
true/false

+ Here is the caller graph for this function:

template<typename T >
bool Attribute::NewState ( const T &  val)
inline

Check the state of the value represented by this attribute.

Parameters
thevalue to ckeck return true, if the value is new
template<typename T >
bool Attribute::Notify ( const T &  val)
inline

Notify all observers.

Returns
true, if notification took place.

+ Here is the caller graph for this function:

void Attribute::SetDiff ( int  val = 0,
std::string  sym = "diff" 
)
inline

Set the number of symbolic differentiations of the attribute's expression.

Parameters
valThe order of the derivative
symSymbol

+ Here is the caller graph for this function:

void Attribute::SetDynamic ( bool  val)
inline

Set this attribute to be dynamic.

Parameters
valThe state of being dynamic.
bool Attribute::SetMember ( std::string  expr,
const std::vector< Attribute * > &  obs_attribs,
const std::vector< std::string > &  obs_attrib_keyword,
bool  verbose = false 
)

Set the Prototype's private member represented by this attribute. The function performs the following tasks:

  • write a value to the Prototype's private member, in case of non-dynamic expressions
  • add all observed attributes which are necessary for GiNaC evaluation
  • set the GiNaC expression to calculate the value for the Prototype's private member
  • test once, if evaluation is possible
Parameters
exprthe attribute value as it is read from XML
obs_attribslist of attributes observed by the Prototype
verboseif true, warnings will be dumped to stdout
Returns
success/failure of operation

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Attribute::SetObservable ( bool  val)
inline

Set this attribute to be observable by other attributes.

Parameters
valThe state of being observable.

+ Here is the caller graph for this function:

void Attribute::SetPublic ( bool  val)
inline

Set this attribute to be public for manipulation through XML.

Parameters
valThe state of being public.

+ Here is the caller graph for this function:

void Attribute::UpdatePrototype ( )
private

Update a Prototype which holds an observing Attribute.

Parameters
protthe Prototype to update

+ Here is the call graph for this function:

template<typename T >
void Attribute::WriteMember ( const T &  val)
inlineprivate

write the member variable of this attribute

Parameters
valthe new value

+ Here is the caller graph for this function:


The documentation for this class was generated from the following files:

-- last change 17.06.2016 | Tony Stoecker | Imprint --