00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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;
00044 struct Parser;
00045 struct RouteHead;
00046 struct MetadataObject;
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
00224
00228
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