2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: Task.cc /main/2 1996/07/18 15:22:57 drk $ */
24 /* $XConsortium: Task.cc /main/2 1996/07/18 15:22:57 drk $ */
26 /* exported interfaces... */
29 /* imported interfaces... */
35 #include "AttributeRec.h"
37 ComplexTask::ComplexTask()
43 ComplexTask::~ComplexTask()
47 for(i = 0; i < used; i++){
51 if ( subtasks ) delete subtasks;
54 void ComplexTask::removeAllSubTasks()
56 for ( int i = 0; i < used; i++ ) {
60 if ( subtasks ) { delete subtasks; subtasks = 0; }
64 void ComplexTask::addSubTask(Task *t)
71 void ComplexTask::stopSubTask(Task *t)
73 for(int i = 0; i < used; i++){
78 subtasks[i] = subtasks[i+1];
88 fprintf(stderr, "Internal errnor: stop unknown task.");
94 ComplexTask::grow(int needed)
96 if(needed + 1 > alloc){
97 Task **born = new Task*[alloc = needed * 3 / 2 + 10];
100 memcpy(born, subtasks, sizeof(Task*) * used);
101 delete subtasks; subtasks = 0;
108 void ComplexTask::markup(const Token& t)
112 for(i = 0; i < used; i++){
113 subtasks[i]->markup(t);
117 void ComplexTask::data(const char *d, size_t len)
121 for(i = 0; i < used; i++){
122 subtasks[i]->data(d, len);
131 void TestTask::markup(const Token &t)
135 printf("\nStart Element: %s\n", t.giName());
137 const AttributeRec *a;
139 for(a = t.GetFirstAttr(); a ; a = t.GetNextAttr(a)){
140 const char *ty = SGMLName::lookup(a->getAttrType());
141 printf("Attribute: %s = [%s]`%s'\n",
142 SGMLName::lookup(a->getAttrName()), ty, a->getAttrValueString());
148 printf("End Element: %s\n", t.giName());
152 printf("Unknown Token Type: %d\n", t.type());
160 void TestTask::data(const char *data, size_t)
162 printf("data: `%s'\n", data);
166 * TestTask 2 is for OL-Data testing
172 TestTask2::TestTask2()
177 void TestTask2::markup(const Token &t)
180 ComplexTask::markup( t );
186 * See if any OLIAS Architecture Form exists
189 if ( t.AttributeMatch( OLAF::OLIAS, OLAF::Graphic ) ) {
192 if ( t.LookupAttr( OLAF::OL_data ) )
193 ComplexTask::addSubTask( new OL_Data ( t, OLAF::OL_data ) );
198 if ( f_base == t.level() ) {
199 for ( int i=0; i < ComplexTask::used; i++ ) {
200 OL_Data *t = ( OL_Data *) subtask(i);
201 cout << "OL_Data found = " << t->content() << endl;
213 void TestTask2::data(const char *data, size_t t)
215 ComplexTask::data( data, t );