The first thing we need to know about an IGF90 object is how to create one. A class object is initialized by the initialization of its data members. C++ supports an automatic mechanism for the initialization of class objects. A special class member function, called a constructor, is invoked implicitely by the compiler whenever a class object is defined. Constructor functions are characterized by having the same name as of its class. There are several syntactical rules by which an IGF90 constructor can be called:
#include "IGF90.h"
...
const int N = 7; // number of dimensions
int numSamples[N];
for (int i=0; i < N; i++)
numSamples[i] = i+1; // num. of samples along dim. i
// Construct by giving dimensions
IGF90 data1( N, numSamples);
const int N = 3 ; // number of dimensions AxisArray axes(N); Axis firstAxis( 0.000 , 0.004, "Time", "seconds" , 1024 ); Axis secondAxis( -2.0 , 0.050, "Offset", "km" , 256 ); Axis thirdAxis( 1 , 1, "CDP-X", "meter" , 1024 ); axes[0] = firstAxis; axes[1] = secondAxis; axes[2] = thirdAxis; // construct by giving dimensions and a list of Axes IGF90 data2( N , axes );Each Axis object is constructed by specifying its origin, increment, label, physical unit and its number of samples.
// look for the tag "name=" on the command line
IGF90 data3("name");
// Constructs a copy of the first object IGF90 data4(data3);
// Constructs a copy of the first object IGF90 data5( data3.Space() );
data1 and data2
are SEPlib90 data structures with a regular geometry. In the last
example, the sintax data3.Space() returns a reference to the
vector space of data3. Space() is a member function of
the IGF90 class. The IGF90 data5 is then constructed with the
same geometry as data3.
For many programs, all objects are allocated in the heap and
referenced through pointers. The new operator allocates new
dynamic memory. The delete operator takes a pointer to an
object and reclaims its memory. Because of memory constraints, we
will typically want to allocate IGF90 objects dynamically, and
deallocate them as soon as we have finished using them.
IGF90 * data5; // A pointer to an IGF90 object.
data5 = new IGF90 ("input"); // allocate dynamically and invoke
// the constructor
...
delete data5; // invoke the destructor and reclaim the mem