root/ggpa/SentenceStructure.h

Revision 1, 5.5 kB (checked in by pantley2, 4 years ago)

GGPA code from the good old days of SIGART

Line 
1 /*
2  * SentenceStructure.h
3  * Header file for SentenceStructure class
4  */
5
6 #ifndef SENTENCE_STRUCTURE_H
7 #define SENTENCE_STRUCTURE_H
8 #include <vector>
9 #include <string>
10 #include <ostream>
11 #include <iostream>
12 using namespace std;
13
14 /*
15  * Class to hold the general structure of a sentence type.  It will have all
16  * the values for every sentence type.  For example, in the tic-tac-toe game,
17  * for "cell" this class will have the values set {{1, 2, 3}, {1, 2, 3},
18  * {o, x, b}}
19  */
20 class SentenceStructure {
21    
22 private:
23
24     // the name of the operator
25     string name;
26
27     // Holds the set of possible values for each variable
28     vector<vector<string>* > possibleValues;
29
30     // Indicates if the value list for the ith parameter is a reference
31     //vector<SentenceStructure*> references;
32
33     // The offset of this sentence type in the State object
34     int offset;
35
36     // true if this sentence represents an Action, false otherwise
37     bool action;
38
39    
40
41 public:
42
43     /*
44      * Two argument constructor for SentenceStructure
45      * Parameters:   theName - a string containing the name of the new
46      *                      SentenceStructure
47      *               numParameters - int containing the number of parameters
48      *                               for this SentenceStructure
49      *               isActionValue - a boolean representing whether this is an
50      *                          action
51      * Sets name to be the parameter name, and creates a new possibleValues
52      *    vector of size specified by numParameters
53      */
54     SentenceStructure(string theName, int numParameters, bool isActionValue);
55
56     /*
57      * getName
58      * Parameters:  None
59      * Return type: string
60      * Returns the name of this SentenceStructure
61      */
62     string getName() const;
63
64     /*
65      * getNumParameters
66      * No parameters
67      * Return type: int
68      * Returns the number of parameters for this SentenceStructure
69      */
70     unsigned int getNumParameters() const;
71
72     /*
73      * getValues
74      * Parameters:   num - an int representing the index of the variable we
75      *                     are interested in
76      * Return type: a vector of strings representing the set of possible values
77      * Gets the set of possible values for the variable at index num.
78      */
79     vector<string>& getValues(int num) const;
80
81     /*
82      * getValuesPointer
83      * Parameters:   num - an int representing the index of the variable we
84      *                     are interested in
85      * Return type: a vector of strings representing the set of possible values
86      * Gets the set of possible values for the variable at index num.
87      */
88     vector<string>* getValuesPointer(int num) const;
89
90     /*
91      * getValueIndex
92      * Parameters:   num - an int representing the index of the variable we
93      *                     are interested in
94      *               value - a string representing the value we are searching
95      *                       for
96      * Return type: int
97      * Returns the index of the value in the value set of the numth parameter,
98      * or -1 if it is not present.
99      */
100     int getValueIndex(int num, string value) const;
101
102     /*
103      * addValue
104      * Parameters:   num - an int representing the index of the variable we
105      *                     are interested in
106      *               value - a string containing the new value to add for
107      *                       that variable
108      * No return type
109      * Adds value to the set of possible values for the variable at index num
110      */
111     void addValue(int num, string value);
112
113     /*
114      * mergeValues
115      * Parameters:   counterpart - another structure with which to merge the
116      *                             values for a certain parameter
117      *               thisIndex - the index of the parameter in this
118      *               thatIndex - the index of the parameter in counterpart
119      * Return type: none
120      * This function should be used when there is a shared reference between
121      * two sentences of different SentenceStructures. These two parameters
122      * must thus have the same values, so we want to make it so that they will
123      * have the same value set.
124      */
125     //void mergeValues(SentenceStructure* counterpart, int thisIndex,
126     //                 int thatIndex);
127
128     /*
129      * getOffset
130      * No parameters
131      * Return type: int
132      * Returns the offset for this sentence type for State
133      */
134     int getOffset() const;
135
136     /*
137      * setOffset
138      * Parameters: theOffset - int containing the new offset for this sentence
139      *                      type in the state
140      * No return value
141      * Sets the offset to the parameter value
142      */
143     void setOffset(int theOffset);
144
145
146     /*
147      * isAction
148      * No parameters
149      * Return type: bool
150      * Returns true if this sentence is an Action, and false otherwise
151      */
152     bool isAction() const;
153
154     /*
155      * operator ==
156      * Parameters:   s2 - another SentenceStructure for comparison
157      * Return type: bool
158      * Returns true if the two SentenceStructures are equal, and false
159      * otherwise.
160      */
161     bool operator==(const SentenceStructure& s2) const;
162
163     /*
164      * numPossibleSentences
165      * No parameters
166      * Returns the number of sentences that could be built on this sentence
167      * structure
168      */
169     int numPossibleSentences();
170
171     /*
172      * print
173      * Parameters: output: a stream to output to.
174      *             indent: indent on each line
175      * No return type.
176      * Prints the sentence to the given stream
177      */
178     void print(ostream& output = cout, string indent = "") const;
179
180 };
181
182 #endif
183
Note: See TracBrowser for help on using the browser.