1 /* 2 * **************************************************************************** 3 * This file is part of libNUML. Please visit http://code.google.com/p/numl/for more 4 * information about NUML, and the latest version of libNUML. 5 * Copyright (c) 2013 The University of Manchester. 6 * 7 * This library is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU Lesser General Public License as published 9 * by the Free Software Foundation. A copy of the license agreement is 10 * provided in the file named "LICENSE.txt" included with this software 11 * distribution and also available online as http://www.gnu.org/licenses/lgpl.html 12 * 13 * Contributors: 14 * Joseph O. Dada, The University of Manchester - initial API and implementation 15 * **************************************************************************** 16 **/ 17 18 /** 19 * @class NUMLVisitor 20 * @brief visitor for numl classes 21 */ 22 23 24 #ifndef NUMLVisitor_h 25 #define NUMLVisitor_h 26 27 28 29 30 31 #include <numl/NUMLTypeCodes.h> 32 33 #ifdef __cplusplus 34 LIBNUML_CPP_NAMESPACE_BEGIN 35 36 /** 37 * Forward class name declarations avoid cyclic dependencies. 38 */ 39 40 class NMBase; 41 42 class NUMLDocument; 43 class OntologyTerm; 44 45 46 47 //class Result; 48 class ResultComponent; 49 class Dimension; 50 class CompositeValue; 51 class Tuple; 52 class AtomicValue; 53 class DimensionDescription; 54 class CompositeDescription; 55 class TupleDescription; 56 class AtomicDescription; 57 58 class NUMLList; 59 60 61 /** 62 * Implementation of the Visitor design pattern, for operations on NUML objects 63 * 64 * The Visitor Pattern (Design Patterns, Gamma et al.\ ) allows you to add 65 * operations to an established class hierarchy without actually modifying 66 * the classes in heirarchy. For computer science types, C++ 67 * implementations of Visitor are a form of double-dispatch. 68 * 69 * For convenience, an NUMLVisitor couples the notion of visitation with 70 * NUML object tree traversal. 71 */ 72 class NUMLVisitor 73 { 74 public: 75 76 virtual ~NUMLVisitor (); 77 78 virtual void visit (const NUMLDocument &x); 79 virtual void visit (const NUMLList &x, NUMLTypeCode_t type); 80 81 virtual bool visit (const NMBase &x); 82 virtual bool visit (const OntologyTerm &x); 83 84 // virtual bool visit (const Result &x); 85 virtual bool visit (const ResultComponent &x); 86 virtual bool visit (const Dimension &x); 87 virtual bool visit (const CompositeValue &x); 88 virtual bool visit (const AtomicValue &x); 89 virtual bool visit (const Tuple &x); 90 virtual bool visit (const DimensionDescription &x); 91 virtual bool visit (const CompositeDescription &x); 92 virtual bool visit (const AtomicDescription &x); 93 virtual bool visit (const TupleDescription &x); 94 95 96 virtual void leave (const NUMLDocument &x); 97 virtual void leave (const OntologyTerm &x); 98 99 virtual void leave (const Tuple &x); 100 // virtual void leave (const Result &x); 101 virtual void leave (const ResultComponent &x); 102 virtual void leave (const Dimension &x); 103 virtual void leave (const DimensionDescription &x); 104 virtual void leave (const CompositeValue &x); 105 virtual void leave (const AtomicValue &x); 106 virtual void leave (const CompositeDescription &x); 107 virtual void leave (const TupleDescription &x); 108 virtual void leave (const AtomicDescription &x); 109 110 virtual void leave (const NUMLList &x, NUMLTypeCode_t type); 111 }; 112 113 LIBNUML_CPP_NAMESPACE_END 114 115 #endif /* __cplusplus */ 116 #endif /* NUMLVisitor_h */ 117