node.H

Go to the documentation of this file.
00001 /*
00002  * This file is part of the "Archon" framework.
00003  * (http://files3d.sourceforge.net)
00004  *
00005  * Copyright © 2002 by Kristian Spangsege and Brian Kristiansen.
00006  *
00007  * Permission to use, copy, modify, and distribute this software and
00008  * its documentation under the terms of the GNU General Public License is
00009  * hereby granted. No representations are made about the suitability of
00010  * this software for any purpose. It is provided "as is" without express
00011  * or implied warranty. See the GNU General Public License
00012  * (http://www.gnu.org/copyleft/gpl.html) for more details.
00013  *
00014  * The characters in this file are ISO8859-1 encoded.
00015  *
00016  * The documentation in this file is in "Doxygen" style
00017  * (http://www.doxygen.org).
00018  */
00019 
00020 #ifndef ARCHON_X3D_NODE_H
00021 #define ARCHON_X3D_NODE_H
00022 
00030 #include <string>
00031 
00032 #include <archon/util/logger.H>
00033 #include <archon/util/ref.H>
00034 
00035 #include <archon/x3d/server/exception.H>
00036 #include <archon/x3d/server/type.H>
00037 #include <archon/x3d/server/event_source.H>
00038 
00039 namespace Archon
00040 {
00041   namespace X3D
00042   {
00043     struct ExecutionContext; // "scene.H"
00044     struct Parser;           // "parse.H"
00045     struct RouteHead;        // "event.H"
00046     struct MetadataObject;   // "core.H"
00047 
00048     struct NodeNameInUseException: Exception
00049     {
00050       NodeNameInUseException(string l): Exception(l) {}
00051     };
00052 
00058     struct NodeBase: virtual BackRefObjectBase
00059     {
00060       virtual const NodeType *getType() const = 0;
00061 
00068       struct RealizedException: Exception
00069       {
00070         RealizedException(string l): Exception(l) {}
00071       };
00077       struct AccessException: Exception
00078       {
00079         AccessException(string l): Exception(l) {}
00080       };
00085       struct RangeException: Exception
00086       {
00087         RangeException(string l): Exception(l) {}
00088       };
00089 
00104       void realize();
00105 
00106       bool isRealized() const;
00107 
00112       virtual void onRealized() {}
00113 
00114       string getName() const;
00115 
00116       void setName(string name)
00117         throw(NodeNameInUseException);
00118 
00133       virtual const FieldBase *lookupField(string name) const;
00134 
00138       Ref<ValueBase> get(const FieldBase *)
00139         const throw(AccessException, UnexpectedException);
00140 
00144       unsigned getSize(const SequenceFieldBase *) const
00145         throw(AccessException, UnexpectedException);
00146 
00150       Ref<ValueBase> getAt(const SequenceFieldBase *, unsigned index) const
00151         throw(AccessException, RangeException, UnexpectedException);
00152 
00160       void set(const FieldBase *, const Event *)
00161         throw(AccessException, UnexpectedException);
00162 
00168       void setAt(const SequenceFieldBase *, Ref<const ValueBase>,
00169                  unsigned index, Time)
00170         throw(AccessException, RangeException, UnexpectedException);
00171 
00177       void add(const SequenceFieldBase *, Ref<const ValueBase>, Time)
00178         throw(AccessException, UnexpectedException);
00179 
00185       void remove(const SequenceFieldBase *, Ref<const ValueBase>, Time)
00186         throw(AccessException, UnexpectedException);
00187 
00192       void add(const NodeSequenceFieldBase *, Ref<NodeBase>, Time)
00193         throw(AccessException, UnexpectedException);
00194 
00199       void remove(const NodeSequenceFieldBase *, Ref<NodeBase>, Time)
00200         throw(AccessException, UnexpectedException);
00201 
00207       bool inject(const NodeFieldBase *, Ref<NodeBase> childNode, Time stamp)
00208         throw(AccessException, UnexpectedException);
00209 
00215       virtual bool changedSince(const Time &t) const;
00216 
00223       //virtual string dumpFields(set<const NodeBase *> processedNodes, int level) const;
00224 
00228       //string dump(set<const NodeBase *> processedNodes, int level, bool indentFirstLine) const;
00229 
00239       const BackRef<ExecutionContext> context;
00240 
00241     protected:
00246       NodeBase(BackRef<ExecutionContext> context);
00247 
00260       NodeBase();
00261 
00262       virtual ~NodeBase();
00263 
00264       virtual void refForwardDestroy();
00265 
00266       bool isRealizedNoLock() const { return realized; }
00267 
00268       const Mutex mutex;
00269 
00270     private:
00271       friend struct Route;
00272       Mutex routeTargetsMutex;
00273       list<Ref<const RouteHead> > routeTargets;
00274       void addRouteTarget(Ref<const RouteHead>);
00275       void removeRouteTarget(Ref<const RouteHead>);
00276 
00286       string name;
00287 
00291       bool realized;
00292     };
00293   }
00294 }
00295 
00296 #endif // ARCHON_X3D_NODE_H

Generated on Sun Jul 30 22:55:47 2006 for Archon by  doxygen 1.4.4