casacore
Loading...
Searching...
No Matches
casa
Utilities
DefaultValue.h
Go to the documentation of this file.
1
//# DefaultValue.h: fill a variable with its default value.
2
//# Copyright (C) 1995,1996,2000
3
//# Associated Universities, Inc. Washington DC, USA.
4
//#
5
//# This library is free software; you can redistribute it and/or modify it
6
//# under the terms of the GNU Library General Public License as published by
7
//# the Free Software Foundation; either version 2 of the License, or (at your
8
//# option) any later version.
9
//#
10
//# This library is distributed in the hope that it will be useful, but WITHOUT
11
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13
//# License for more details.
14
//#
15
//# You should have received a copy of the GNU Library General Public License
16
//# along with this library; if not, write to the Free Software Foundation,
17
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18
//#
19
//# Correspondence concerning AIPS++ should be addressed as follows:
20
//# Internet email: casa-feedback@nrao.edu.
21
//# Postal address: AIPS++ Project Office
22
//# National Radio Astronomy Observatory
23
//# 520 Edgemont Road
24
//# Charlottesville, VA 22903-2475 USA
25
26
#ifndef CASA_DEFAULTVALUE_H
27
#define CASA_DEFAULTVALUE_H
28
29
#include <casacore/casa/aips.h>
30
31
namespace
casacore
{
//# NAMESPACE CASACORE - BEGIN
32
33
// <summary>
34
// A templated function which sets a variable to a default value.
35
// </summary>
36
37
// <use visibility=export>
38
39
// <reviewed reviewer="syang" date="1996/03/14" tests="tDefaultValue.cc" demos="">
40
// </reviewed>
41
42
// <prerequisite>
43
// </prerequisite>
44
//
45
// <etymology>
46
// The DefaultValue function name is derived from its use to fill a data type
47
// with a default value, usually zero.
48
// </etymology>
49
//
50
// <synopsis>
51
// The DefaultValue function is passed an instance of a data type and the
52
// variable is filled with a default value. The majority of classes may
53
// use the templated version here. Special classes may use their own
54
// non-templated specializations as demonstrated in
55
// ../Utilities/test/tDefaultValue.cc.
56
// </synopsis>
57
//
58
// <example>
59
// <srcblock>
60
// Int foo = 35;
61
// defaultValue(foo);
62
// AlwaysAssert(foo == 0, AipsError);
63
// Array<Float> bar;
64
// defaultValue(bar);
65
// AlwaysAssert(allEQ(bar, 0.0f), AipsError);
66
// </srcblock>
67
// A special class may need its own implementation:
68
// <srcblock>
69
// void defaultValue(MySpecialClass &val){
70
// // make a default value be all zeros
71
// val.operator()(IPosition(2,3,4)) = Table.keywords().defaultval();
72
// };
73
// </srcblock>
74
// </example>
75
//
76
// <motivation>
77
// We needed a common way of setting all objects to zero or some
78
// null/default value. Specializing a templated function seemed the only way
79
// to reach everyone.
80
// </motivation>
81
//
82
// <templating arg=T>
83
// <li> constructor T(Int)
84
// <li> assignment operator (copy semantics)
85
// </templating>
86
//
87
// <thrown>
88
// <li> none
89
// </thrown>
90
//
91
// <todo asof="1996/02/22">
92
// <li> none
93
// </todo>
94
95
// <group name=defval>
96
97
template
<
class
T>
inline
void
defaultValue
(T &theValue)
98
{
99
theValue = T(0);
100
}
101
102
// </group>
103
104
105
}
//# NAMESPACE CASACORE - END
106
107
#endif
casacore
this file contains all the compiler specific defines
Definition
mainpage.dox:28
casacore::DefaultValue_global_functions_defval
Definition
DefaultValue.h:96
casacore::DefaultValue_global_functions_defval::defaultValue
void defaultValue(T &theValue)
Definition
DefaultValue.h:97
Generated by
1.9.8