00001 00002 /* 00003 | Author: Michael Schmidt; 00004 | Gunnar Jehl 00005 | 00006 | ************************* SOFTWARE LICENSE AGREEMENT *********************** 00007 | This source code is published under the BSD License. 00008 | 00009 | See file 'LICENSE.txt' that comes with this distribution or 00010 | http://dbis.informatik.uni-freiburg.de/index.php?project=GCX/license.php 00011 | for the full license agreement. 00012 | 00013 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00014 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00015 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00016 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00017 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00018 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00019 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00020 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00021 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00022 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00023 | POSSIBILITY OF SUCH DAMAGE. 00024 | **************************************************************************** 00025 */ 00026 00035 #ifndef TOKENCONFIGURATION_H 00036 #define TOKENCONFIGURATION_H 00037 00038 #include "projectiontree.h" 00039 #include "runtimeexception.h" 00040 00057 class TokenConfiguration { 00058 00059 public: 00064 TokenConfiguration(ProjectionTree * pt); 00065 00071 TokenConfiguration(TokenConfiguration * parent); 00072 00076 virtual ~ TokenConfiguration(); 00077 00087 void createRoleList(vector < Role * >&roles, 00088 vector < unsigned >&role_counts); 00089 00096 TokenConfiguration *applyTag(TAG t); 00097 00103 TokenConfiguration *applyText(); 00104 00112 inline void addPassiveTokens(unsigned i, unsigned n) { 00113 passive_tokens[i] += n; 00114 } void print(OutputStream & dos, bool is_text = false); 00122 00128 inline vector < unsigned >getActiveTokens() { 00129 return active_tokens; 00130 } 00131 00139 inline void setActiveTokens(unsigned i, unsigned n) { 00140 active_tokens[i] = n; 00141 } 00142 00148 inline vector < unsigned >getPassiveTokens() { 00149 return passive_tokens; 00150 } 00151 00159 inline void setPassiveTokens(unsigned i, unsigned n) { 00160 passive_tokens[i] = n; 00161 } 00162 00170 inline unsigned getActiveTokensById(unsigned i) { 00171 return active_tokens[i]; 00172 } 00173 00181 inline unsigned getPassiveTokensById(unsigned i) { 00182 return passive_tokens[i]; 00183 } 00184 00196 unsigned getLastActiveTokenCountFor(unsigned token_id); 00197 00204 inline ProjectionTreeLabels *getLabels() { 00205 return labels; 00206 } 00207 00214 bool isEmpty(); 00215 00223 bool isOutput(); 00224 00232 bool hasActiveToken(); 00233 00241 unsigned sumUpActiveTokenCountFor(unsigned token_id); 00242 00251 bool forceChildKeep(); 00252 00262 bool keepSubtree(); 00263 00269 bool skipSubtree(); 00270 00271 private: 00276 TokenConfiguration * parent; 00277 00282 ProjectionTreeLabels *labels; 00283 00292 vector < unsigned >active_tokens; 00293 00302 vector < unsigned >passive_tokens; 00303 }; 00304 00305 #endif // TOKENCONFIGURATION_H