casacore
Public Member Functions | List of all members
casacore::DefaultValue_global_functions_defval Struct Reference

More...

#include <DefaultValue.h>

Public Member Functions

template<class T >
void defaultValue (T &theValue)
 

Detailed Description

A templated function which sets a variable to a default value.

Intended use:

Public interface

Review Status

Reviewed By:
syang
Date Reviewed:
1996/03/14
Test programs:
tDefaultValue

Etymology

The DefaultValue function name is derived from its use to fill a data type with a default value, usually zero.

Synopsis

The DefaultValue function is passed an instance of a data type and the variable is filled with a default value. The majority of classes may use the templated version here. Special classes may use their own non-templated specializations as demonstrated in ../Utilities/test/tDefaultValue.cc.

Example

Int foo = 35;
AlwaysAssert(foo == 0, AipsError);
Array<Float> bar;
AlwaysAssert(allEQ(bar, 0.0f), AipsError);
#define AlwaysAssert(expr, exception)
These marcos are provided for use instead of simply using the constructors of assert_ to allow additi...
Definition: Assert.h:157
int Int
Definition: aipstype.h:50

A special class may need its own implementation:

void defaultValue(MySpecialClass &val){
// make a default value be all zeros
val.operator()(IPosition(2,3,4)) = Table.keywords().defaultval();
};

Motivation

We needed a common way of setting all objects to zero or some null/default value. Specializing a templated function seemed the only way to reach everyone.

Template Type Argument Requirements (T)

Thrown Exceptions

To Do


Definition at line 99 of file DefaultValue.h.

Member Function Documentation

◆ defaultValue()

template<class T >
void casacore::DefaultValue_global_functions_defval::defaultValue ( T &  theValue)
inline

Definition at line 100 of file DefaultValue.h.


The documentation for this struct was generated from the following file: