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 BUFFERNODE_H 00036 #define BUFFERNODE_H 00037 00042 #define TYPE_TAG true 00043 00048 #define TYPE_PCDATA false 00049 00050 #include <vector> 00051 #include <sstream> 00052 #include "tagmap.h" 00053 #include "tagnode.h" 00054 #include "charnode.h" 00055 #include "intmultiset.h" 00056 #include "role.h" 00057 00058 // forward declarations 00059 class PathExpression; 00060 struct BufferNode; 00061 00078 struct BufferNode { 00084 BufferNode(const char *_data, BufferNode * _parent); 00085 00091 BufferNode(TAG _tag, BufferNode * _parent); 00092 00101 BufferNode(const char *_data, BufferNode * _parent, 00102 vector < unsigned >*_cumulative_roles, 00103 vector < unsigned >*_non_cumulative_roles); 00104 00113 BufferNode(TAG _tag, BufferNode * _parent, 00114 vector < unsigned >*_cumulative_roles, 00115 vector < unsigned >*_non_cumulative_roles); 00116 00120 virtual ~ BufferNode(); 00121 00128 void addChild(BufferNode * child); 00129 00138 void appendRoles(vector < unsigned >*_cumulative_roles, 00139 vector < unsigned >*_non_cumulative_roles); 00140 00148 void print(OutputStream & eos); 00149 00157 void printNoSubnodes(OutputStream & dos); 00158 00166 void debugPrint(OutputStream & dos); 00167 00176 void debugPrintCompleteBuffer(OutputStream & dos); 00177 00184 const char *getPCDataRepresentation(); 00185 00193 void getPCDataRepresentation(std::ostringstream & s); 00194 00203 inline void close() { 00204 ((TagNode *) node)->is_closed = true; 00205 } inline bool isClosed() { 00215 return ((TagNode *) node)->is_closed; 00216 } 00217 00223 inline void lock() { 00224 is_locked = true; 00225 } 00226 00233 inline void unlock() { 00234 is_locked = false; 00235 } 00236 00242 inline bool isLocked() { 00243 return is_locked; 00244 } 00245 00252 inline bool isRoot() { 00253 return type == TYPE_TAG && ((TagNode *) node)->tag == TAGID_ROOT; 00254 } 00255 00262 bool isMarked(); 00263 00270 bool isCumulativeMarked(); 00271 00278 bool hasCumulativeMarkedAncestor(); 00279 00288 bool hasNoMarkedAndNoLockedDos(); 00289 00297 void removeRoleFromNode(Role * role); 00298 00304 void clear(); 00305 00312 void clearSubtreeIfPossible(); 00313 00319 bool type; 00320 00325 BufferNode *parent; 00326 00331 BufferNode *r_sibling; 00332 00333 #ifdef ROLE_REFCOUNT 00334 00340 unsigned cumulative_roles; 00341 #else 00342 00349 IntMultiSet *cumulative_roles; 00350 #endif // #ifdef ROLE_REFCOUNT 00351 00352 #ifdef ROLE_REFCOUNT 00353 00359 unsigned non_cumulative_roles; 00360 #else 00361 00368 IntMultiSet *non_cumulative_roles; 00369 #endif // #ifdef ROLE_REFCOUNT 00370 00377 void *node; 00378 00385 bool is_locked; 00386 }; 00387 00388 #endif // BUFFERNODE_H