00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef ARCHON_X3D_PROXY_NODE_H
00021 #define ARCHON_X3D_PROXY_NODE_H
00022
00023 #include <archon/x3d/proxy/context.H>
00024
00025 namespace Archon
00026 {
00027 namespace X3D
00028 {
00029 namespace Proxy
00030 {
00031 struct Session;
00032 struct ExecutionContext;
00033
00037 struct NodeBase: virtual RefObjectBase
00038 {
00039 Ref<Session> getSession() const { return session; }
00040
00041 protected:
00042 friend struct Session;
00043 friend struct ExecutionContext;
00044 friend struct Field;
00045 template<typename F> friend struct FieldGet;
00046 template<typename F> friend struct FieldSeqGet;
00047 template<typename F> friend struct FieldSet;
00048 template<typename F> friend struct FieldSeqSet;
00049
00050 NodeBase() {}
00051
00052 NodeBase(Session *s, unsigned long id):
00053 session(s), id(id), transCount(0) {}
00054
00055 ~NodeBase() {{ session->destroyNode(this); }}
00056
00057 template<typename T>
00058 static Ref<T> create(ExecutionContext *c,
00059 unsigned long nodeTypeIndex)
00060 {
00061 Ref<NodeBase> n = c->session->createNode(c, nodeTypeIndex);
00062 return dynamic_cast<T *>(n.get());
00063 }
00064
00065 const Ref<Session> session;
00066
00067 private:
00068 unsigned long id;
00069 unsigned long transCount;
00070
00071 void importValue(unsigned long id,
00072 x3d::sai::Value &w, void *v) const
00073 {
00074 session->im(id, w, v);
00075 }
00076
00077 void exportValue(unsigned long id,
00078 const void *v, x3d::sai::Value &w) const
00079 {
00080 session->ex(id, v, w);
00081 }
00082
00083 x3d::sai::Value *fieldGet(unsigned long id);
00084 x3d::sai::Value *fieldGetAt(unsigned long id, unsigned long index);
00085
00086 void fieldSet(unsigned long id, x3d::sai::Value &);
00087 void fieldSetAt(unsigned long id, x3d::sai::Value &,
00088 unsigned long index);
00089 void fieldAdd(unsigned long id, x3d::sai::Value &);
00090 void fieldDel(unsigned long id, x3d::sai::Value &);
00091
00092 void registerFieldInterest(unsigned long fi,
00093 EventHandlerBase *h, bool destroy)
00094 {
00095 session->registerFieldInterest(id, fi, h, destroy);
00096 }
00097 };
00098 }
00099 }
00100 }
00101
00102 #endif // ARCHON_X3D_PROXY_NODE_H