diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2013-02-09 22:49:34 +0000 |
|---|---|---|
| committer | Jabiertxo Arraiza Cenoz <jtx@jtx.marker.es> | 2013-02-09 22:49:34 +0000 |
| commit | f7fafe0ced665cbb122bd5828e68046d52086c71 (patch) | |
| tree | 751c8c5912ab02f789a4291f22cf344d01bd8adc /src/dom | |
| parent | Merge from branch (diff) | |
| parent | Use update_font_list() in font-lister.cpp. Remove equivalent code in text-too... (diff) | |
| download | inkscape-f7fafe0ced665cbb122bd5828e68046d52086c71.tar.gz inkscape-f7fafe0ced665cbb122bd5828e68046d52086c71.zip | |
Merge from Trunk
(bzr r11950.1.20)
Diffstat (limited to 'src/dom')
| -rw-r--r-- | src/dom/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | src/dom/Makefile_insert | 4 | ||||
| -rw-r--r-- | src/dom/odf/odfdocument.cpp | 167 | ||||
| -rw-r--r-- | src/dom/odf/odfdocument.h | 150 | ||||
| -rw-r--r-- | src/dom/svgimpl.h | 9 | ||||
| -rw-r--r-- | src/dom/svgtypes.h | 239 | ||||
| -rw-r--r-- | src/dom/util/thread.cpp | 126 | ||||
| -rw-r--r-- | src/dom/util/thread.h | 156 |
8 files changed, 128 insertions, 729 deletions
diff --git a/src/dom/CMakeLists.txt b/src/dom/CMakeLists.txt index df2411b13..15b4ba74d 100644 --- a/src/dom/CMakeLists.txt +++ b/src/dom/CMakeLists.txt @@ -26,10 +26,7 @@ set(dom_SRC io/stringstream.cpp io/uristream.cpp - odf/odfdocument.cpp - util/digest.cpp - util/thread.cpp util/ziptool.cpp @@ -64,8 +61,6 @@ set(dom_SRC xpathparser.h xpathtoken.h - odf/odfdocument.h - io/base64stream.h io/bufferstream.h io/domstream.h @@ -74,7 +69,6 @@ set(dom_SRC io/uristream.h util/digest.h - util/thread.h util/ziptool.h ) diff --git a/src/dom/Makefile_insert b/src/dom/Makefile_insert index ace53b4a2..17bab94ac 100644 --- a/src/dom/Makefile_insert +++ b/src/dom/Makefile_insert @@ -64,12 +64,8 @@ dom_libdom_a_SOURCES = \ dom/io/stringstream.h \ dom/io/uristream.cpp \ dom/io/uristream.h \ - dom/odf/odfdocument.cpp \ - dom/odf/odfdocument.h \ dom/util/digest.h \ dom/util/digest.cpp \ - dom/util/thread.h \ - dom/util/thread.cpp \ dom/util/ziptool.h \ dom/util/ziptool.cpp diff --git a/src/dom/odf/odfdocument.cpp b/src/dom/odf/odfdocument.cpp deleted file mode 100644 index cf460c964..000000000 --- a/src/dom/odf/odfdocument.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * - * This class contains an ODF Document. - * Initially, we are just concerned with .odg content.xml + resources - * - * --------------------------------------------------------------------- - * - * Copyright (C) 2006-2008 Bob Jamison - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * For more information, please write to rwjj@earthlink.net - * - * RWJ : 080207: Changed to GPL2 by me - * - */ - -#include "odfdocument.h" - - -namespace odf -{ - - -//######################################################################## -//# I M A G E D A T A -//######################################################################## - - -/** - * - */ -ImageData::ImageData(const std::string &fname, - const std::vector<unsigned char> &buf) - : fileName (fname), - data (buf) - -{ -} - -/** - * - */ -ImageData::ImageData(const ImageData &other) - : fileName (other.fileName), - data (other.data) - -{ -} - -/** - * - */ -ImageData::~ImageData() -{ -} - -/** - * - */ -std::string ImageData::getFileName() -{ - return fileName; -} - -/** - * - */ -void ImageData::setFileName(const std::string &val) -{ - fileName = val; -} - -/** - * - */ -std::vector<unsigned char> &ImageData::getData() -{ - return data; -} - -/** - * - */ -void ImageData::setData(const std::vector<unsigned char> &buf) -{ - data = buf; -} - - - - - -//######################################################################## -//# O D F D O C U M E N T -//######################################################################## - - - -/** - * - */ -OdfDocument::OdfDocument() : - content(0), - images() -{ -} - - -/** - * - */ -OdfDocument::OdfDocument(const OdfDocument &other) : - content (other.content), - images (other.images) -{ -} - - -/** - * - */ -OdfDocument::~OdfDocument() -{ -} - -/** - * - */ -bool OdfDocument::readFile(const std::string &/*fileName*/) -{ - return true; -} - -/** - * - */ -bool OdfDocument::writeFile(const std::string &/*fileName*/) -{ - return true; -} - - - - - -} //namespace odf - - - - -//######################################################################## -//# E N D O F F I L E -//######################################################################## - diff --git a/src/dom/odf/odfdocument.h b/src/dom/odf/odfdocument.h deleted file mode 100644 index 168df11c7..000000000 --- a/src/dom/odf/odfdocument.h +++ /dev/null @@ -1,150 +0,0 @@ -#ifndef SEEN_ODF_DOCUMENT_H -#define SEEN_ODF_DOCUMENT_H -/* - * Copyright (C) 2006 Bob Jamison - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * For more information, please write to rwjj@earthlink.net - * - * RWJ : 080207: Changed to GPL2 by me - */ - -#include <vector> -#include <string> - -#include "dom/dom.h" - -namespace odf -{ - - -//######################################################################## -//# I M A G E D A T A -//######################################################################## - -/** - * - */ -class ImageData -{ -public: - - /** - * - */ - ImageData(const std::string &fileName, - const std::vector<unsigned char> &buf); - - /** - * - */ - ImageData(const ImageData &other); - - /** - * - */ - virtual ~ImageData(); - - /** - * - */ - virtual std::string getFileName(); - - /** - * - */ - virtual void setFileName(const std::string &val); - - /** - * - */ - virtual std::vector<unsigned char> &getData(); - - /** - * - */ - virtual void setData(const std::vector<unsigned char> &buf); - -private: - - std::string fileName; - - std::vector<unsigned char> data; - -}; - - - - - -//######################################################################## -//# O D F D O C U M E N T -//######################################################################## - - -/** - * - * This class contains an ODF Document. - * Initially, we are just concerned with .odg content.xml + resources - */ -class OdfDocument -{ -public: - - /** - * - */ - OdfDocument(); - - /** - * Copy constructor - */ - OdfDocument(const OdfDocument &other); - - /** - * - */ - virtual ~OdfDocument(); - - /** - * - */ - virtual bool readFile(const std::string &fileName); - - /** - * - */ - virtual bool writeFile(const std::string &fileName); - - -private: - - org::w3c::dom::Document *content; - - std::vector<ImageData> images; - -}; - -} //namespace odf - - - -#endif // SEEN_ODF_DOCUMENT_H - -//######################################################################## -//# E N D O F F I L E -//######################################################################## - diff --git a/src/dom/svgimpl.h b/src/dom/svgimpl.h index 83d56fa22..2ee5c8bc7 100644 --- a/src/dom/svgimpl.h +++ b/src/dom/svgimpl.h @@ -980,7 +980,14 @@ public: /** * */ - SVGSVGElementImpl() : SVGElementImpl() + SVGSVGElementImpl() : SVGElementImpl(), + pixelUnitToMillimeterX(0), + pixelUnitToMillimeterY(0), + screenPixelToMillimeterX(0), + screenPixelToMillimeterY(0), + useCurrentView(false), + currentScale(0), + currentTime(0) {} diff --git a/src/dom/svgtypes.h b/src/dom/svgtypes.h index 41b4de307..bb828571f 100644 --- a/src/dom/svgtypes.h +++ b/src/dom/svgtypes.h @@ -645,20 +645,20 @@ public: /** * */ - SVGTransform() + SVGTransform() : + type (SVG_TRANSFORM_UNKNOWN), + angle (0.0) { - type = SVG_TRANSFORM_UNKNOWN; - angle = 0.0; } /** * */ - SVGTransform(const SVGTransform &other) + SVGTransform(const SVGTransform &other) : + type (other.type), + angle (other.angle), + matrix (other.matrix) { - type = other.type; - angle = other.angle; - matrix = other.matrix; } /** @@ -834,9 +834,9 @@ public: /** * */ - SVGTransformList(const SVGTransformList &other) + SVGTransformList(const SVGTransformList &other) : + items (other.items) { - items = other.items; } /** @@ -893,10 +893,10 @@ public: /** * */ - SVGAnimatedTransformList(const SVGAnimatedTransformList &other) + SVGAnimatedTransformList(const SVGAnimatedTransformList &other) : + baseVal (other.baseVal), + animVal (other.animVal) { - baseVal = other.baseVal; - animVal = other.animVal; } /** @@ -1181,9 +1181,9 @@ public: /** * */ - SVGStringList(const SVGStringList &other) + SVGStringList(const SVGStringList &other) : + items (other.items) { - items = other.items; } /** @@ -1657,9 +1657,9 @@ public: /** * */ - SVGNumberList(const SVGNumberList &other) + SVGNumberList(const SVGNumberList &other) : + items (other.items) { - items = other.items; } /** @@ -1719,10 +1719,10 @@ public: /** * */ - SVGAnimatedNumberList(const SVGAnimatedNumberList &other) + SVGAnimatedNumberList(const SVGAnimatedNumberList &other) : + baseVal (other.baseVal), + animVal (other.animVal) { - baseVal = other.baseVal; - animVal = other.animVal; } /** @@ -1934,10 +1934,10 @@ public: /** * */ - SVGAnimatedLength(const SVGAnimatedLength &other) + SVGAnimatedLength(const SVGAnimatedLength &other) : + baseVal (other.baseVal), + animVal (other.animVal) { - baseVal = other.baseVal; - animVal = other.animVal; } /** @@ -2085,9 +2085,9 @@ public: /** * */ - SVGLengthList(const SVGLengthList &other) + SVGLengthList(const SVGLengthList &other) : + items (other.items) { - items = other.items; } /** @@ -2147,10 +2147,10 @@ public: /** * */ - SVGAnimatedLengthList(const SVGAnimatedLengthList &other) + SVGAnimatedLengthList(const SVGAnimatedLengthList &other) : + baseVal (other.baseVal), + animVal (other.animVal) { - baseVal = other.baseVal; - animVal = other.animVal; } /** @@ -2357,16 +2357,17 @@ public: /** * */ - SVGAnimatedAngle(const SVGAngle &angle) - { baseVal = angle; } + SVGAnimatedAngle(const SVGAngle &angle) : + baseVal (angle) + {} /** * */ - SVGAnimatedAngle(const SVGAnimatedAngle &other) + SVGAnimatedAngle(const SVGAnimatedAngle &other) : + baseVal (other.baseVal), + animVal (other.animVal) { - baseVal = other.baseVal; - animVal = other.animVal; } /** @@ -2434,10 +2435,10 @@ public: /** * */ - SVGICCColor(const SVGICCColor &other) + SVGICCColor(const SVGICCColor &other) : + colorProfile (other.colorProfile), + colors (other.colors) { - colorProfile = other.colorProfile; - colors = other.colors; } /** @@ -2448,7 +2449,6 @@ public: protected: DOMString colorProfile; - SVGNumberList colors; }; @@ -2732,10 +2732,10 @@ public: /** * */ - SVGAnimatedRect(const SVGAnimatedRect &other) + SVGAnimatedRect(const SVGAnimatedRect &other) : + baseVal (other.baseVal), + animVal (other.animVal) { - baseVal = other.baseVal; - animVal = other.animVal; } /** @@ -2956,9 +2956,9 @@ public: /** * */ - SVGPointList(const SVGPointList &other) + SVGPointList(const SVGPointList &other) : + items (other.items) { - items = other.items; } @@ -3071,10 +3071,10 @@ public: /** * */ - SVGStylable(const SVGStylable &other) + SVGStylable(const SVGStylable &other) : + className (other.className), + style (other.style) { - className = other.className; - style = other.style; } /** @@ -3168,7 +3168,10 @@ public: /** * */ - SVGLocatable(const SVGLocatable &/*other*/) + SVGLocatable(const SVGLocatable &/*other*/) : + bbox(), + ctm(), + screenCtm() { } @@ -3224,9 +3227,9 @@ public: /** * */ - SVGTransformable(const SVGTransformable &other) : SVGLocatable(other) + SVGTransformable(const SVGTransformable &other) : SVGLocatable(other), + transforms (other.transforms) { - transforms = other.transforms; } /** @@ -3303,11 +3306,11 @@ public: /** * */ - SVGTests(const SVGTests &other) + SVGTests(const SVGTests &other) : + requiredFeatures (other.requiredFeatures), + requiredExtensions (other.requiredExtensions), + systemLanguage (other.systemLanguage) { - requiredFeatures = other.requiredFeatures; - requiredExtensions = other.requiredExtensions; - systemLanguage = other.systemLanguage; } /** @@ -3445,9 +3448,9 @@ public: /** * */ - SVGExternalResourcesRequired(const SVGExternalResourcesRequired &other) + SVGExternalResourcesRequired(const SVGExternalResourcesRequired &other) : + required (other.required) { - required = other.required; } /** @@ -3611,10 +3614,10 @@ public: /** * */ - SVGAnimatedPreserveAspectRatio(const SVGAnimatedPreserveAspectRatio &other) + SVGAnimatedPreserveAspectRatio(const SVGAnimatedPreserveAspectRatio &other) : + baseVal (other.baseVal), + animVal (other.animVal) { - baseVal = other.baseVal; - baseVal = other.animVal; } /** @@ -3671,10 +3674,10 @@ public: * */ - SVGFitToViewBox(const SVGFitToViewBox &other) + SVGFitToViewBox(const SVGFitToViewBox &other) : + viewBox (other.viewBox), + preserveAspectRatio (other.preserveAspectRatio) { - viewBox = other.viewBox; - preserveAspectRatio = other.preserveAspectRatio; } /** @@ -3685,7 +3688,6 @@ public: protected: SVGAnimatedRect viewBox; - SVGAnimatedPreserveAspectRatio preserveAspectRatio; }; @@ -3828,18 +3830,19 @@ public: /** * */ - SVGViewSpec() + SVGViewSpec() : + viewTarget (NULL), + transform () { - viewTarget = NULL; } /** * */ - SVGViewSpec(const SVGViewSpec &other) : SVGZoomAndPan(other), SVGFitToViewBox(other) + SVGViewSpec(const SVGViewSpec &other) : SVGZoomAndPan(other), SVGFitToViewBox(other), + viewTarget (other.viewTarget), + transform (other.transform) { - viewTarget = other.viewTarget; - transform = other.transform; } /** @@ -3884,14 +3887,16 @@ public: /** * */ - SVGURIReference() {} + SVGURIReference() : + href () + {} /** * */ - SVGURIReference(const SVGURIReference &other) + SVGURIReference(const SVGURIReference &other) : + href (other.href) { - href = other.href; } /** @@ -6135,9 +6140,9 @@ public: /** * */ - SVGPathSegList(const SVGPathSegList &other) + SVGPathSegList(const SVGPathSegList &other) : + items (other.items) { - items = other.items; } @@ -6272,10 +6277,10 @@ public: /** * */ - SVGAnimatedPoints(const SVGAnimatedPoints &other) + SVGAnimatedPoints(const SVGAnimatedPoints &other) : + points (other.points), + animatedPoints (other.animatedPoints) { - points = other.points; - animatedPoints = other.animatedPoints; } /** @@ -6366,19 +6371,19 @@ public: /** * */ - SVGPaint() + SVGPaint() : + paintType (SVG_PAINTTYPE_UNKNOWN), + uri ("") { - uri = ""; - paintType = SVG_PAINTTYPE_UNKNOWN; } /** * */ - SVGPaint(const SVGPaint &other) : css::CSSValue(other), SVGColor(other) + SVGPaint(const SVGPaint &other) : css::CSSValue(other), SVGColor(other), + paintType (SVG_PAINTTYPE_UNKNOWN), + uri ("") { - uri = ""; - paintType = SVG_PAINTTYPE_UNKNOWN; } /** @@ -6452,17 +6457,19 @@ public: /** * */ - SVGColorProfileRule() {} + SVGColorProfileRule() : + renderingIntent(0) + {} /** * */ SVGColorProfileRule(const SVGColorProfileRule &other) - : SVGCSSRule(other), SVGRenderingIntent(other) + : SVGCSSRule(other), SVGRenderingIntent(other), + renderingIntent (other.renderingIntent), + src (other.src), + name (other.name) { - renderingIntent = other.renderingIntent; - src = other.src; - name = other.name; } /** @@ -6540,13 +6547,13 @@ public: * */ SVGFilterPrimitiveStandardAttributes(const SVGFilterPrimitiveStandardAttributes &other) - : SVGStylable(other) + : SVGStylable(other), + x (other.x), + y (other.y), + width (other.width), + height (other.height), + result (other.result) { - x = other.x; - y = other.y; - width = other.width; - height = other.height; - result = other.result; } /** @@ -6567,13 +6574,6 @@ protected: - - - - - - - /*######################################################################### ## SVGEvent #########################################################################*/ @@ -6660,20 +6660,26 @@ public: /** * */ - SVGZoomEvent() + SVGZoomEvent(): + zoomRectScreen(), + previousScale(0), + previousTranslate(), + newScale(0), + newTranslate() {} /** * */ - SVGZoomEvent(const SVGZoomEvent &other) : events::Event(other), - events::UIEvent(other) + SVGZoomEvent(const SVGZoomEvent &other) : + events::Event(other), + events::UIEvent(other), + zoomRectScreen(other.zoomRectScreen), + previousScale(other.previousScale), + previousTranslate(other.previousTranslate), + newScale(other.newScale), + newTranslate(other.newTranslate) { - zoomRectScreen = other.zoomRectScreen; - previousScale = other.previousScale; - previousTranslate = other.previousTranslate; - newScale = other.newScale; - newTranslate = other.newTranslate; } /** @@ -6776,13 +6782,18 @@ public: /** * */ - SVGElementInstance() {} + SVGElementInstance() : + correspondingElement(NULL), + correspondingUseElement(NULL) + {} /** * */ SVGElementInstance(const SVGElementInstance &other) - : events::EventTarget(other) + : events::EventTarget(other), + correspondingElement(NULL), + correspondingUseElement(NULL) { } @@ -6858,9 +6869,9 @@ public: /** * */ - SVGElementInstanceList(const SVGElementInstanceList &other) + SVGElementInstanceList(const SVGElementInstanceList &other) : + items (other.items) { - items = other.items; } /** @@ -6877,16 +6888,6 @@ protected: - - - - - - - - - - } //namespace svg } //namespace dom } //namespace w3c diff --git a/src/dom/util/thread.cpp b/src/dom/util/thread.cpp deleted file mode 100644 index d5368ef59..000000000 --- a/src/dom/util/thread.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2006 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * Thread wrapper. This provides a platform-independent thread - * class for IO and testing. - * - */ - -#include "thread.h" -#include <stdio.h> -#include <string.h> - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace util -{ - - -#ifdef __WIN32__ -#include <windows.h> - -static DWORD WINAPI WinThreadFunction(LPVOID context) -{ - Thread *thread = static_cast<Thread *>(context); - thread->execute(); - return 0; -} - - -void Thread::start() -{ - DWORD dwThreadId; - HANDLE hThread = CreateThread(NULL, 0, WinThreadFunction, - (LPVOID)this, 0, &dwThreadId); - //Make sure the thread is started before 'this' is deallocated - while (!started) - sleep(10); - CloseHandle(hThread); -} - -void Thread::sleep(unsigned long millis) -{ - Sleep(millis); -} - - - -#else /* UNIX */ -#include <pthread.h> - -void *PthreadThreadFunction(void *context) -{ - Thread *thread = static_cast<Thread *>(context); - thread->execute(); - return NULL; -} - - -void Thread::start() -{ - pthread_t thread; - - int ret = pthread_create(&thread, NULL, - PthreadThreadFunction, (void *)this); - if (ret != 0) - printf("Thread::start: thread creation failed: %s\n", strerror(ret)); - - //Make sure the thread is started before 'this' is deallocated - while (!started) - sleep(10); - -} - -void Thread::sleep(unsigned long millis) -{ - timespec requested; - requested.tv_sec = millis / 1000; - requested.tv_nsec = (millis % 1000 ) * 1000000L; - nanosleep(&requested, NULL); -} - -#endif /* __WIN32__ */ - -} //namespace util -} //namespace dom -} //namespace w3c -} //namespace org - - - -//######################################################################### -//# E N D O F F I L E -//######################################################################### - - diff --git a/src/dom/util/thread.h b/src/dom/util/thread.h deleted file mode 100644 index 1408cd78f..000000000 --- a/src/dom/util/thread.h +++ /dev/null @@ -1,156 +0,0 @@ -#ifndef SEEN_DOM_THREAD_H -#define SEEN_DOM_THREAD_H -/** - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - */ -/* - * Authors: - * Bob Jamison - * - * Copyright (C) 2006 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* - * Thread wrapper. This provides a platform-independent thread - * class for IO and testing. - * - */ - - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace util -{ - - -/** - * This is the interface for a delegate class which can - * be run by a Thread. - * Thread thread(runnable); - * thread.start(); - */ -class Runnable -{ -public: - - Runnable() - {} - virtual ~Runnable() - {} - - /** - * The method of a delegate class which can - * be run by a Thread. Thread is completed when this - * method is done. - */ - virtual void run() = 0; - -}; - - - -/** - * A simple wrapper of native threads in a portable class. - * It can be used either to execute its own run() method, or - * delegate to a Runnable class's run() method. - */ -class Thread -{ -public: - - /** - * Create a thread which will execute its own run() method. - */ - Thread() - { runnable = (Runnable *)0 ; started = false; } - - /** - * Create a thread which will run a Runnable class's run() method. - */ - Thread(const Runnable &runner) - { runnable = (Runnable *)&runner; started = false; } - - /** - * This does not kill a spawned thread. - */ - virtual ~Thread() - {} - - /** - * Static method to pause the current thread for a given - * number of milliseconds. - */ - static void sleep(unsigned long millis); - - /** - * This method will be executed if the Thread was created with - * no delegated Runnable class. The thread is completed when - * the method is done. - */ - virtual void run() - {} - - /** - * Starts the thread. - */ - virtual void start(); - - /** - * Calls either this class's run() method, or that of a Runnable. - * A user would normally not call this directly. - */ - virtual void execute() - { - started = true; - if (runnable) - runnable->run(); - else - run(); - } - -private: - - Runnable *runnable; - - bool started; - -}; - - -} //namespace util -} //namespace dom -} //namespace w3c -} //namespace org - - - -#endif // SEEN_DOM_THREAD_H -//######################################################################### -//# E N D O F F I L E -//######################################################################### - - |
