This section describes the set of routines and operators that can apply to any class in DataViewer, be it a geometrical class or a simple property class.
Let DVclass
be any class in DataViewer. Then we can define the
following routines:
The default destructor. It is declared virtual so that the correct descendant destructor will get called.
virtual ~DVclass();
A routine that returns a pointer to a copy of the object created with new.
virtual DVclass *copy();
The copy constructor and the assignment operator.
DVclass(const DVclass &data); const DVclass &operator=(const DVclass &data);
Operators to check for equality and for non equality.
int operator==(const DVclass &data); int operator!=(const DVclass &data);
Virtual print function so that we can print instantiations of the various classes derived from DVclass.
virtual void print(ostream &);
A friend routine to overload the << operator.
friend ostream &operator<<(ostream &, DVclass &);
The draw routine that uses the geometrical stack must be defined by each geometrical class. It has to be virtual so that the correct descendant routine gets called.
virtual void draw(LCVMstack<DVproperty*>&);
This paragraph concerns the geometrical classes corresponding to data organized in a matrix of several lines and columns, or even several matrices of various sizes. The geometrical objects in this category inherit both from the DVobject class and from the DVpick_components class. This category includes the following classes:
All the containers must know how to add and to delete a child from their list of descendants.
DVobject ©_child(DVobject &child); DVobject &delete_current_child();
In general, a LCVMarray is a class containing a normal array together with information about its size. All the LCVMarray classes are instantiations of the LCVMarray template class, or of other template classes derived from it.
Let T
be the basic class for the LCVMarray template class. The most
important methods that can be applied to this class are:
Constructors
The constructor with a given size, which is 0 by default.
LCVMarray(const int = 0)
The constructor with a given size, and initialized with a value of the basic class.
LCVMarray(const int, const T&)
Copy constructor.
LCVMarray(const LCVMarray&)
Copy constructor from a normal array of the basic type. It needs the size of the array.
LCVMarray(const T* const, const int)
Set the data in the array
For each constructor, there is a similar set_data method, with the same arguments. These methods first delete the existing array and the data it contains, then initialize the object again with the new data.
Without reallocating the array contained in the object, you can initialize each component of the array with the given value:
LCVMarray (const T&)
The data in a LCVMarray can be deleted (but not the object itself) with the following method, returning the object itself after the operation:
LCVMarray ()
Extract data from the array
To know the size of such an array, use the following method:
int get_size() const
The elements of a LCVMarray can be accessed as the elements of a
normal array with the []
operator:
T [](const int)
or with the following method:
T get_element(const int) const
Two methods can copy the data in the LCVMarray to another LCVMarray:
void get_data(LCVMarray&) const
or to a normal array:
void get_data(T*) const
For more information on each specific LCVMarray class, see the class reference.
In principle, the scene file parser is organized in the following way:
The input file
The scene file is opened in a global variable, managed by the
scene_data
module. No other module should have access to it.
The function
char *GetNextWord();
moves the input file pointer to the next word in the file, skipping
all the blanc characters and the comments. Separators like {
are
considered entire words.
The function
char *TheWord();
returns the word in the input file at the current position.
Tokens
There is a set of tokens defined in the scene_tokens
module. The
function
int CheckToken(char *aString, TokenName aToken);
verifies that the given string represents the specified token.
If a new token is added to the file parser, all the modules that use
tokens have to be recompiled. We recommend to do a make clean
and
then recompile everything again.
Constructors
Each geometrical class and several other classes have constructors taking a file option as input. The normal constructor from the global input file with a file option should receive the file pointer at the beginning of an object in the file of its class type. Usually the container constructor from a file option calls the appropriate constructors according to the current token in the file. The class creates an instance of itself using the information in the file, and then return the file pointer at a position immediately after the object.