JEMRIS 2.9.2
open-source MRI simulations
Loading...
Searching...
No Matches
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.
 
void SetPublic (bool val)
 Set this attribute to be public for manipulation through XML.
 
bool IsObservable () const
 Check, if this attribute is observable by other attributes.
 
void SetObservable (bool val)
 Set this attribute to be observable by other attributes.
 
bool IsDynamic () const
 Check, if this attribute is dynamic. This is needed for exporting static XML Files of the Sequence.
 
void SetDynamic (bool val)
 Set this attribute to be dynamic.
 
int GetDiff ()
 Get the number of symbolic differentiations of the attribute's expression.
 
double GetImaginary ()
 Get the imaginary part the attribute's evaluation.
 
bool IsComplex () const
 Check, if this attribute's evaluation is complex.
 
void SetDiff (int val=0, std::string sym="diff")
 Set the number of symbolic differentiations of the attribute's expression.
 
std::string GetName () const
 Get the name of the attribute.
 
std::string GetTypeID () const
 Get the type ID of the attribute.
 
void * GetAddress () const
 Get the pointer to the value represented by this attribute.
 
PrototypeGetPrototype () const
 Get the pointer to the Prototype to which this attribute belongs.
 
std::string GetSymbol ()
 Get the GiNaC symbol of this attribute.
 
std::string GetFormula ()
 Get the GiNaC formula of this attribute.
 
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:
 
void EvalExpression ()
 Evaluate the GiNaC expression of this attribute.
 
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.
 
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)
 
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.
 
template<typename T >
bool NewState (const T &val)
 Check the state of the value represented by this attribute.
 
void AttachObserver (Attribute *attrib)
 Append a new observer of this attribute.
 
void AttachSubject (Attribute *attrib)
 Append a new subject observed by this this attribute.
 

Private Member Functions

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

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

◆ AttachObserver()

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:

◆ AttachSubject()

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:

◆ EvalCompiledExpression()

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:

◆ EvalCompiledNLGExpression()

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:

◆ EvalExpression()

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:

◆ GetAddress()

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:

◆ GetDiff()

int Attribute::GetDiff ( )
inline

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

Returns
The order of the derivative

◆ GetFormula()

std::string Attribute::GetFormula ( )
inline

Get the GiNaC formula of this attribute.

return the GiNaC formula

+ Here is the caller graph for this function:

◆ GetImaginary()

double Attribute::GetImaginary ( )
inline

Get the imaginary part the attribute's evaluation.

Returns
The imaginary part
+ Here is the caller graph for this function:

◆ GetMember()

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:

◆ GetName()

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:

◆ GetPrototype()

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:

◆ GetSymbol()

std::string Attribute::GetSymbol ( )
inline

Get the GiNaC symbol of this attribute.

return the GiNaC symbol

+ Here is the caller graph for this function:

◆ GetTypeID()

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:

◆ Initialize()

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
+ Here is the caller graph for this function:

◆ IsComplex()

bool Attribute::IsComplex ( ) const
inline

Check, if this attribute's evaluation is complex.

Returns
true/false

◆ IsDynamic()

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

◆ IsObservable()

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:

◆ IsPublic()

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:

◆ NewState()

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
+ Here is the caller graph for this function:

◆ Notify()

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

Notify all observers.

Returns
true, if notification took place.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetDiff()

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:

◆ SetDynamic()

void Attribute::SetDynamic ( bool val)
inline

Set this attribute to be dynamic.

Parameters
valThe state of being dynamic.

◆ SetMember()

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:

◆ SetObservable()

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:

◆ SetPublic()

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:

◆ UpdatePrototype()

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:

◆ WriteMember()

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 03.01.2025 | Tony Stoecker | Imprint | Data Protection --