home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Graphics 16,000
/
graphics-16000.iso
/
msdos
/
utils
/
graphtal.lzh
/
Graphtal.Amiga
/
Module.h
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-17
|
3KB
|
116 lines
/*
* Module.h - class definition for L-System modules.
*
* Copyright (C) 1992, Christoph Streit (streit@iam.unibe.ch)
* University of Berne, Switzerland
* All rights reserved.
*
* This software may be freely copied, modified, and redistributed
* provided that this copyright notice is preserved on all copies.
*
* You may not distribute this software, in whole or in part, as part of
* any commercial product without the express consent of the authors.
*
* There is no warranty or other guarantee of fitness of this software
* for any purpose. It is provided solely "as is".
*
*/
#ifndef Module_H
# define Module_H
#include <iostream.h>
#include "list.h"
#include "Expression.h"
#include "Name.h"
declareList(ExpressionList, ExpressionPtr);
declareList(ValueList, ValuePtr);
//___________________________________________________________ Formals
//
// common storage access used for the formal parameters of all the
// production. Example:
//
// A(l,w) -> ... : parameter l is assigned to Formals(0) and
// parameter w to Formals(1)
//
// Now it's possible to simply assign the actual parameters of a
// module to the Formals-array and the binding is done
Value* Formals(int);
//___________________________________________________________ ProdModule
//
// ProdModule's are used in productions, where we need expressions
// as arguments
class ProdModule
{
friend class Module;
public:
ProdModule(const Name&, ExpressionList*);
~ProdModule();
friend ostream& operator<<(ostream&, const ProdModule&);
private:
Name name;
// hashvalue is associated with the name and the number
// of arguments
int hashValue;
ExpressionList* parameters;
};
typedef ProdModule* ProdModulePtr;
declareList(ProdModuleList, ProdModulePtr);
//___________________________________________________________ Module
//
// The resulting module string of an L-System consists of modules
// with constant arguments. Because there are a lot of them
// allocated, it makes sense to make a difference between the
// modules of a production (class ProdModule) and the modules of
// the resulting string (=> better space and speed efficiency)
class Module
{
public:
Module(ProdModule*);
~Module();
const Name& name() const;
int hashValue() const;
int argCount() const;
const Value* arg(int);
void bind();
friend ostream& operator<<(ostream&, const Module&);
private:
Name _name;
int _hashValue;
ValueList* parameters;
};
typedef Module* ModulePtr;
declareList(ModuleList, ModulePtr);
inline const Name& Module::name() const {
return _name;
}
inline int Module::hashValue() const {
return _hashValue;
}
inline int Module::argCount() const {
return ((parameters) ? (parameters->count())
: 0);
}
inline const Value* Module::arg(int i) {
return parameters->item(i);
}
#endif // Module_H