home *** CD-ROM | disk | FTP | other *** search
- /*
- * Production.h - class definition for L-System productions.
- *
- * 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 Production_H
- # define Production_H
-
- #include "mathutilities.h"
- #include "Predecessor.h"
- #include "Successor.h"
-
- //___________________________________________________________ Production
- //
- // A production of an L-System has tree parts: the predecessor, the
- // condition and a successor list.
-
- class Production
- {
- public:
- Production(Predecessor*, Expression*, SuccessorList*);
- ~Production();
-
- int hashValue();
- int argCount() const;
- const Name& name() const;
-
- int cumulateProbability();
- int evalCondition();
- ModuleList* cloneSuccessor();
-
- friend ostream& operator<<(ostream&, Production&);
-
- private:
- Name _name; // copy of the predecessor name
- int arg_count;
- int stochastic; // more than one successor => Yes: choose by random
-
- Predecessor* predecessor;
- Expression* condition;
- SuccessorList* successors;
- };
-
- typedef Production* ProductionPtr;
- declareList(ProductionList, ProductionPtr);
-
- inline int Production::argCount() const {
- return arg_count;
- }
-
- inline const Name& Production::name() const {
- return _name;
- }
-
- inline int Production::evalCondition() {
- if (condition)
- return (real(condition->evaluate()) ? 1 : 0);
- else
- return 1;
- }
-
- #endif // Production_H
-