field.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_FIELD_H
00021 #define ARCHON_X3D_FIELD_H
00022 
00029 #include <archon/x3d/server/field_type.H>
00030 #include <archon/x3d/server/type.H>
00031 #include <archon/x3d/server/event.H>
00032 // #include <archon/x3d/server/dump.H>
00033 
00034 
00035 namespace Archon
00036 {
00037   namespace X3D
00038   {
00039     template<class N, typename T>
00040     struct StaticField: virtual FieldBase
00041     {
00042     protected:
00043       StaticField(T N::*var, bool (N::*func)(const T &, const Time &),
00044                   EventSource N::*eventSource, Time N::*stamp):
00045         var(var), func(func), eventSource(eventSource), stamp(stamp)
00046       {
00047         if(!var && (getIsEventSource() || !getIsEventTarget()) ||
00048            func && getIsEventSource() && !getIsEventTarget() ||
00049            bool(eventSource) != getIsEventSource() ||
00050            bool(stamp) != getIsEventTarget())
00051           ARCHON_THROW1(ArgumentException, "Bad StaticField '" + getName() + "'");
00052       }
00053 
00054       bool addRoute(NodeBase *n, const RouteTail *r) const
00055       {
00056         return (dynamic_cast<N *>(n)->*eventSource).addRoute(r);
00057       }
00058 
00059       void delRoute(NodeBase *n, const RouteTail *r) const
00060       {
00061         (dynamic_cast<N *>(n)->*eventSource).delRoute(r);
00062       }
00063 
00064       bool delRouteMatch(NodeBase *n, const RouteTail *r) const
00065       {
00066         return (dynamic_cast<N *>(n)->*eventSource).delRouteMatch(r);
00067       }
00068 
00069       T N::*var;
00070       bool (N::*func)(const T &, const Time &);
00071       EventSource N::*eventSource;
00072       Time N::*stamp;
00073     };
00074 
00075     template<class N, typename T>
00076     struct SimpleField: StaticField<N, T>
00077     {
00078       SimpleField(string name, const FieldType *type,
00079                   bool isEventTarget, bool isEventSource,
00080                   T N::*var,
00081                   bool (N::*func)(const T &, const Time &),
00082                   EventSource N::*eventSource,
00083                   Time N::*stamp):
00084         FieldBase(name, type, isEventTarget, isEventSource),
00085         StaticField<N, T>(var, func, eventSource, stamp) {}
00086 
00087       Ref<ValueBase> get(const NodeBase *n) const
00088       {
00089         if(!this->var) ARCHON_THROW1(InternalException, "No variable");
00090         return new SimpleValue<T>(this->getType(), dynamic_cast<const N *>(n)->*this->var);
00091       }
00092 
00093       void set(NodeBase *n, const Event *e, bool cascade) const
00094       {
00095         const SimpleValueBase *val =
00096           dynamic_cast<const SimpleValueBase *>(e->value.get());
00097         if(!val) ARCHON_THROW1(InternalException,
00098                                "SimpleField::set: "
00099                                "Value/Field type inconsistency");
00100         const T &v = *static_cast<const T *>(val->getValuePtr());
00101         if(this->func) cascade &= (dynamic_cast<N *>(n)->*this->func)(v, e->time);
00102         else
00103         {
00104           if(this->stamp) dynamic_cast<N *>(n)->*this->stamp = e->time;
00105           if(this->var) dynamic_cast<N *>(n)->*this->var = v;
00106         }
00107         if(cascade && this->eventSource)
00108           (dynamic_cast<N *>(n)->*this->eventSource).cascadeEvent(e);
00109       }
00110 
00115       bool changedSince(const NodeBase *n, const Time &t) const
00116       {
00117         return this->stamp && dynamic_cast<const N *>(n)->*this->stamp >= t;
00118       }
00119 
00120       /*
00121       string dump(const NodeBase *n, int level) const
00122       {
00123         if(!var) return "";
00124         return
00125           string(2*level, ' ') + getName() + " " +
00126           dumpValue(dynamic_cast<const N *>(n)->*var) + "\n";
00127       }
00128       */
00129 
00130       void forwardClear(NodeBase *n) const
00131       {
00132         if(this->eventSource) (dynamic_cast<N *>(n)->*this->eventSource).clear();
00133       }
00134 
00135     protected:
00136       SimpleField(T N::*var,
00137                   bool (N::*func)(const T &, const Time &),
00138                   EventSource N::*eventSource,
00139                   Time N::*stamp):
00140         StaticField<N, T>(var, func, eventSource, stamp) {}
00141     };
00142 
00143     template<class N, typename T>
00144     struct SimpleSequenceField: SimpleField<N, vector<T> >, SequenceFieldBase
00145     {
00146       typedef vector<T> V;
00147 
00148       SimpleSequenceField(string name, const FieldType *type,
00149                           bool isEventTarget, bool isEventSource,
00150                           V N::*var,
00151                           bool (N::*func)(const V &, const Time &),
00152                           EventSource N::*eventSource,
00153                           Time N::*stamp):
00154         FieldBase(name, type, isEventTarget, isEventSource),
00155         SimpleField<N, V>(var, func, eventSource, stamp) {}
00156 
00157       unsigned getSize(const NodeBase *n) const
00158       {
00159         if(!this->var) ARCHON_THROW1(InternalException, "No variable");
00160         return (dynamic_cast<const N *>(n)->*this->var).size();
00161       }
00162 
00163       Ref<ValueBase> getAt(const NodeBase *n, unsigned i) const
00164       {
00165         if(i >= getSize(n))
00166           ARCHON_THROW1(InternalException, "Index out of range");
00167         return new SimpleValue<T>
00168           (getType()->getSingleType(), (dynamic_cast<const N *>(n)->*this->var)[i]);
00169       }
00170 
00171       void setAt(NodeBase *n, const ValueBase *v,
00172                  unsigned i, Time time, bool cascade) const
00173       {
00174         if(i >= getSize(n))
00175           ARCHON_THROW1(InternalException, "Index out of range");
00176         const SimpleValue<T> *w = dynamic_cast<const SimpleValue<T> *>(v);
00177         if(!w) ARCHON_THROW1(InternalException, "Value/Field type mismatch");
00178         if(!this->var) ARCHON_THROW1(InternalException, "No variable");
00179         if(this->func)
00180         {
00181           V u = dynamic_cast<N *>(n)->*this->var;
00182           u[i] = w->value;
00183           cascade &= (dynamic_cast<N *>(n)->*this->func)(u, time);
00184         }
00185         else
00186         {
00187           if(this->stamp) dynamic_cast<N *>(n)->*this->stamp = time;
00188           (dynamic_cast<N *>(n)->*this->var)[i] = w->value;
00189         }
00190         if(cascade && this->eventSource)
00191         {
00192           Ref<ValueBase> x = get(n);
00193           SimpleValue<V> *s =
00194             dynamic_cast<SimpleValue<V> *>(x.get());
00195           if(!s) ARCHON_THROW1(InternalException, "Wrong value type");
00196           Event e(s, time);
00197           (dynamic_cast<N *>(n)->*this->eventSource).cascadeEvent(&e);
00198         }
00199       }
00200 
00201       void add(NodeBase *n, const ValueBase *v, Time time, bool cascade) const
00202       {
00203         const SimpleValue<T> *w = dynamic_cast<const SimpleValue<T> *>(v);
00204         if(!w) ARCHON_THROW1(InternalException, "Value/Field type mismatch");
00205         if(!this->var) ARCHON_THROW1(InternalException, "No variable");
00206         if(this->func)
00207         {
00208           V u = dynamic_cast<N *>(n)->*this->var;
00209           u.push_back(w->value);
00210           cascade &= (dynamic_cast<N *>(n)->*this->func)(u, time);
00211         }
00212         else
00213         {
00214           if(this->stamp) dynamic_cast<N *>(n)->*this->stamp = time;
00215           (dynamic_cast<N *>(n)->*this->var).push_back(w->value);
00216         }
00217         if(cascade && this->eventSource)
00218         {
00219           Ref<ValueBase> x = get(n);
00220           SimpleValue<V> *s =
00221             dynamic_cast<SimpleValue<V> *>(x.get());
00222           if(!s) ARCHON_THROW1(InternalException, "Wrong value type");
00223           Event e(s, time);
00224           (dynamic_cast<N *>(n)->*this->eventSource).cascadeEvent(&e);
00225         }
00226       }
00227 
00228       void remove(NodeBase *n, const ValueBase *v, Time time, bool cascade) const
00229       {
00230         const SimpleValue<T> *w = dynamic_cast<const SimpleValue<T> *>(v);
00231         if(!w) ARCHON_THROW1(InternalException, "Value/Field type mismatch");
00232         if(!this->var) ARCHON_THROW1(InternalException, "No variable");
00233         if(this->func)
00234         {
00235           V u = dynamic_cast<N *>(n)->*this->var;
00236           u.erase(std::remove(u.begin(), u.end(), w->value), u.end());
00237           cascade &= (dynamic_cast<N *>(n)->*this->func)(u, time);
00238         }
00239         else
00240         {
00241           if(this->stamp) dynamic_cast<N *>(n)->*this->stamp = time;
00242           V &u = dynamic_cast<N *>(n)->*this->var;
00243           u.erase(std::remove(u.begin(), u.end(), w->value), u.end());
00244         }
00245         if(cascade && this->eventSource)
00246         {
00247           Ref<ValueBase> x = get(n);
00248           SimpleValue<V> *s =
00249             dynamic_cast<SimpleValue<V> *>(x.get());
00250           if(!s) ARCHON_THROW1(InternalException, "Wrong value type");
00251           Event e(s, time);
00252           (dynamic_cast<N *>(n)->*this->eventSource).cascadeEvent(&e);
00253         }
00254       }
00255     };
00256 
00257     template<class N, typename C>
00258     struct NodeField: NodeFieldBase, StaticField<N, Ref<C> >
00259     {
00260       NodeField(string name,
00261                 const NodeType *nodeType,
00262                 bool isEventTarget, bool isEventSource,
00263                 Ref<C> N::*var,
00264                 bool (N::*func)(const Ref<C> &, const Time &),
00265                 EventSource N::*eventSource,
00266                 Time N::*stamp):
00267         FieldBase(name, SFNode::type, isEventTarget, isEventSource),
00268         NodeFieldBase(nodeType),
00269         StaticField<N, Ref<C> >(var, func, eventSource, stamp) {}
00270 
00271       Ref<ValueBase> get(const NodeBase *n) const
00272       {
00273         if(!this->var) ARCHON_THROW1(InternalException, "No variable");
00274         return new NodeValue(SFNode::type,
00275                              (dynamic_cast<const N *>(n)->*this->var).get());
00276       }
00277 
00278       void set(NodeBase *n, const Event *e, bool cascade) const
00279       {
00280         const NodeValue *val =
00281           dynamic_cast<const NodeValue *>(e->value.get());
00282         if(!val) ARCHON_THROW1(InternalException,
00283                                "NodeField::set: "
00284                                "Value/Field type inconsistency");
00285         C *v = dynamic_cast<C *>(val->value.get());
00286         if(!v && val->value.get())
00287           ARCHON_THROW1(InternalException,
00288                         "NodeField::set: "
00289                         "Incompatible node");
00290         if(this->func) cascade &= (dynamic_cast<N *>(n)->*this->func)(v, e->time);
00291         else
00292         {
00293           if(this->stamp) dynamic_cast<N *>(n)->*this->stamp = e->time;
00294           if(this->var) dynamic_cast<N *>(n)->*this->var = v;
00295         }
00296         if(cascade && this->eventSource)
00297           (dynamic_cast<N *>(n)->*this->eventSource).cascadeEvent(e);
00298       }
00299 
00300       bool inject(NodeBase *n, NodeBase *child, Time time, bool cascade) const
00301       {
00302         C *c = dynamic_cast<C *>(child);
00303         if(!c && child)
00304           ARCHON_THROW1(InternalException,
00305                         "NodeField::inject: "
00306                         "Incompatible node");
00307         if(!this->var) return false;
00308         if(dynamic_cast<N *>(n)->*this->var) return false;
00309         if(this->func) cascade &= (dynamic_cast<N *>(n)->*this->func)(c, time);
00310         else
00311         {
00312           if(this->stamp) dynamic_cast<N *>(n)->*this->stamp = time;
00313           if(this->var) dynamic_cast<N *>(n)->*this->var = c;
00314         }
00315         if(cascade && this->eventSource)
00316         {
00317           Event e(new NodeValue(SFNode::type, c), time);
00318           (dynamic_cast<N *>(n)->*this->eventSource).cascadeEvent(&e);
00319         }
00320         return true;
00321       }
00322 
00327       bool changedSince(const NodeBase *n, const Time &t) const
00328       {
00329         const N *m = dynamic_cast<const N *>(n);
00330         if(this->stamp && m->*this->stamp >= t) return true;
00331         if(!this->var) return false;
00332         const C *c = (m->*this->var).get();
00333         return c && c->changedSince(t);
00334       }
00335 
00336       /*
00337       string dump(const NodeBase *n, int level) const
00338       {
00339         if(!var) return "";
00340         NodeBase *child = (dynamic_cast<const N *>(n)->*var).get();
00341         if(!child) return "";
00342         return string(2*level, ' ') + getName() + " " + child->dump(level, false);
00343       }
00344       */
00345 
00346       void forwardClear(NodeBase *n) const
00347       {
00348         if(this->var) (dynamic_cast<N *>(n)->*this->var).reset();
00349         if(this->eventSource) (dynamic_cast<N *>(n)->*this->eventSource).clear();
00350       }
00351     };
00352 
00353 
00354     template<class N, typename C>
00355     struct NodeSequenceField: NodeSequenceFieldBase, StaticField<N, vector<Ref<C> > >
00356     {
00357       NodeSequenceField(string name,
00358                         const NodeType *nodeType,
00359                         bool isEventTarget, bool isEventSource,
00360                         vector<Ref<C> > N::*var,
00361                         bool (N::*func)(const vector<Ref<C> > &, const Time &),
00362                         EventSource N::*eventSource,
00363                         Time N::*stamp):
00364         FieldBase(name, MFNode::type, isEventTarget, isEventSource),
00365         NodeSequenceFieldBase(nodeType),
00366         StaticField<N, vector<Ref<C> > >(var, func, eventSource, stamp) {}
00367 
00368       void set(NodeBase *n, const Event *e, bool cascade) const
00369       {
00370         const NodeSequenceValue *val =
00371           dynamic_cast<const NodeSequenceValue *>(e->value.get());
00372         if(!val) ARCHON_THROW1(InternalException,
00373                                "NodeSequenceField::set: "
00374                                "Value/Field type inconsistency");
00375         vector<Ref<C> > v;
00376         v.resize(val->value.size());
00377         for(unsigned i=0; i<val->value.size(); ++i)
00378         {
00379           NodeBase *m = val->value[i].get();
00380           if(!m) ARCHON_THROW1(InternalException,
00381                                "NodeSequenceField::set: "
00382                                "Null node is illegal");
00383           v[i] = dynamic_cast<C *>(m);
00384           if(!v[i])
00385             ARCHON_THROW1(InternalException,
00386                           "NodeSequenceField::set: "
00387                           "Incompatible node");
00388         }
00389         if(this->func) cascade &= (dynamic_cast<N *>(n)->*this->func)(v, e->time);
00390         else
00391         {
00392           if(this->stamp) dynamic_cast<N *>(n)->*this->stamp = e->time;
00393           if(this->var) dynamic_cast<N *>(n)->*this->var = v;
00394         }
00395         if(cascade && this->eventSource)
00396           (dynamic_cast<N *>(n)->*this->eventSource).cascadeEvent(e);
00397       }
00398 
00399       Ref<ValueBase> get(const NodeBase *n) const
00400       {
00401         if(!this->var) ARCHON_THROW1(InternalException, "No variable");
00402         Ref<NodeSequenceValue> v = new NodeSequenceValue(MFNode::type);
00403         const vector<Ref<C> > &w = dynamic_cast<const N *>(n)->*this->var;
00404         v->value.resize(w.size());
00405         for(unsigned i=0; i<w.size(); ++i) v->value[i] = w[i];
00406         return v;
00407       }
00408 
00409       unsigned getSize(const NodeBase *n) const
00410       {
00411         if(!this->var) ARCHON_THROW1(InternalException, "No variable");
00412         return (dynamic_cast<const N *>(n)->*this->var).size();
00413       }
00414 
00415       Ref<ValueBase> getAt(const NodeBase *n, unsigned i) const
00416       {
00417         if(i >= getSize(n))
00418           ARCHON_THROW1(InternalException, "Index out of range");
00419         return new NodeValue(SFNode::type,
00420                              (dynamic_cast<const N *>(n)->*this->var)[i].get());
00421       }
00422 
00423       void setAt(NodeBase *n, const ValueBase *v,
00424                  unsigned i, Time time, bool cascade) const
00425       {
00426         if(i >= getSize(n))
00427           ARCHON_THROW1(InternalException, "Index out of range");
00428         const NodeValue *w = dynamic_cast<const NodeValue *>(v);
00429         if(!w) ARCHON_THROW1(InternalException, "Value/Field type mismatch");
00430         C *c = dynamic_cast<C *>(w->value.get());
00431         if(!c) ARCHON_THROW1(InternalException, "Incompatible node type");
00432         if(!this->var) ARCHON_THROW1(InternalException, "No variable");
00433 
00434         if(this->func)
00435         {
00436           vector<Ref<C> > u = dynamic_cast<N *>(n)->*this->var;
00437           u[i].reset(c);
00438           cascade &= (dynamic_cast<N *>(n)->*this->func)(u, time);
00439         }
00440         else
00441         {
00442           if(this->stamp) dynamic_cast<N *>(n)->*this->stamp = time;
00443           (dynamic_cast<N *>(n)->*this->var)[i].reset(c);
00444         }
00445         if(cascade && this->eventSource)
00446         {
00447           Ref<ValueBase> x = get(n);
00448           NodeSequenceValue *s =
00449             dynamic_cast<NodeSequenceValue *>(x.get());
00450           if(!s) ARCHON_THROW1(InternalException, "Wrong value type");
00451           Event e(s, time);
00452           (dynamic_cast<N *>(n)->*this->eventSource).cascadeEvent(&e);
00453         }
00454       }
00455 
00456       void add(NodeBase *n, const ValueBase *v, Time time, bool cascade) const
00457       {
00458         const NodeValue *w = dynamic_cast<const NodeValue *>(v);
00459         if(!w) ARCHON_THROW1(InternalException, "Value/Field type mismatch");
00460         C *c = dynamic_cast<C *>(w->value.get());
00461         if(!c) ARCHON_THROW1(InternalException, "Incompatible node type");
00462         if(!this->var) ARCHON_THROW1(InternalException, "No variable");
00463 
00464         if(this->func)
00465         {
00466           vector<Ref<C> > u = dynamic_cast<N *>(n)->*this->var;
00467           u.push_back(c);
00468           cascade &= (dynamic_cast<N *>(n)->*this->func)(u, time);
00469         }
00470         else
00471         {
00472           if(this->stamp) dynamic_cast<N *>(n)->*this->stamp = time;
00473           (dynamic_cast<N *>(n)->*this->var).push_back(c);
00474         }
00475         if(cascade && this->eventSource)
00476         {
00477           Ref<ValueBase> x = get(n);
00478           NodeSequenceValue *s =
00479             dynamic_cast<NodeSequenceValue *>(x.get());
00480           if(!s) ARCHON_THROW1(InternalException, "Wrong value type");
00481           Event e(s, time);
00482           (dynamic_cast<N *>(n)->*this->eventSource).cascadeEvent(&e);
00483         }
00484       }
00485 
00486       void remove(NodeBase *n, const ValueBase *v, Time time, bool cascade) const
00487       {
00488         const NodeValue *w = dynamic_cast<const NodeValue *>(v);
00489         if(!w) ARCHON_THROW1(InternalException, "Value/Field type mismatch");
00490         C *c = dynamic_cast<C *>(w->value.get());
00491         if(!c) ARCHON_THROW1(InternalException, "Incompatible node type");
00492         if(!this->var) ARCHON_THROW1(InternalException, "No variable");
00493 
00494         if(this->func)
00495         {
00496           vector<Ref<C> > u = dynamic_cast<N *>(n)->*this->var;
00497           u.erase(std::remove(u.begin(), u.end(), Ref<C>(c)), u.end());
00498           cascade &= (dynamic_cast<N *>(n)->*this->func)(u, time);
00499         }
00500         else
00501         {
00502           if(this->stamp) dynamic_cast<N *>(n)->*this->stamp = time;
00503           vector<Ref<C> > &u = dynamic_cast<N *>(n)->*this->var;
00504           u.erase(std::remove(u.begin(), u.end(), Ref<C>(c)), u.end());
00505         }
00506         if(cascade && this->eventSource)
00507         {
00508           Ref<ValueBase> x = get(n);
00509           NodeSequenceValue *s =
00510             dynamic_cast<NodeSequenceValue *>(x.get());
00511           if(!s) ARCHON_THROW1(InternalException, "Wrong value type");
00512           Event e(s, time);
00513           (dynamic_cast<N *>(n)->*this->eventSource).cascadeEvent(&e);
00514         }
00515       }
00516 
00517       bool inject(NodeBase *n, NodeBase *child, Time time, bool cascade) const
00518       {
00519         C *c = dynamic_cast<C *>(child);
00520         if(!c && child)
00521           ARCHON_THROW1(InternalException,
00522                         "NodeField::inject: "
00523                         "Incompatible node");
00524         if(!this->var) return false;
00525         if(this->func)
00526         {
00527           vector<Ref<C> > u = dynamic_cast<N *>(n)->*this->var;
00528           u.push_back(c);
00529           cascade &= (dynamic_cast<N *>(n)->*this->func)(u, time);
00530         }
00531         else
00532         {
00533           if(this->stamp) dynamic_cast<N *>(n)->*this->stamp = time;
00534           (dynamic_cast<N *>(n)->*this->var).push_back(c);
00535         }
00536         if(cascade && this->eventSource)
00537         {
00538           Ref<ValueBase> x = get(n);
00539           NodeSequenceValue *s =
00540             dynamic_cast<NodeSequenceValue *>(x.get());
00541           if(!s) ARCHON_THROW1(InternalException, "Wrong value type");
00542           Event e(s, time);
00543           (dynamic_cast<N *>(n)->*this->eventSource).cascadeEvent(&e);
00544         }
00545         return true;
00546       }
00547 
00552       bool changedSince(const NodeBase *n, const Time &t) const
00553       {
00554         const N *m = dynamic_cast<const N *>(n);
00555         if(this->stamp && m->*this->stamp >= t) return true;
00556         if(!this->var) return false;
00557         const vector<Ref<C> > &v = m->*this->var;
00558         for(unsigned i=0; i<v.size(); ++i)
00559         {
00560           const C *c = v[i].get();
00561           if(c && c->changedSince(t)) return true;
00562         }
00563         return false;
00564       }
00565 
00566       /*
00567       string dump(const NodeBase *n, int level) const
00568       {
00569         if(!var) return "";
00570         const vector<Ref<C> > &v = dynamic_cast<const N *>(n)->*var;
00571         if(!v.size()) return "";
00572         string indent(2*level, ' ');
00573         string s = indent + getName() + "\n" + indent + "[\n";
00574         for(unsigned i=0; i<v.size(); ++i)
00575         {
00576           if(i) s += "\n";
00577           const C *child = v[i].get();
00578           s += child ? child->dump(level+1) : indent + "  NULL\n";
00579         }
00580         return s + indent + "]\n";
00581       }
00582       */
00583 
00584       void forwardClear(NodeBase *n) const
00585       {
00586         if(this->var) (dynamic_cast<N *>(n)->*this->var).clear();
00587         if(this->eventSource) (dynamic_cast<N *>(n)->*this->eventSource).clear();
00588       }
00589     };
00590 
00591 
00592 
00593     // SimpleField
00594 
00595     template<class N, typename T>
00596     const SimpleField<N, T> *newPrivateField(string n, const FieldType *t,
00597                                              T N::*v)
00598     {
00599       return new SimpleField<N, T>(n, t, false, false, v, 0, 0, 0);
00600     }
00601 
00602     template<class N, typename T>
00603     const SimpleField<N, T> *newEventIn(string n, const FieldType *t, T N::*v,
00604                                         Time N::*p)
00605     {
00606       return new SimpleField<N, T>(n, t, true, false, v, 0, 0, p);
00607     }
00608 
00609     template<class N, typename T>
00610     const SimpleField<N, T> *newEventIn(string n, const FieldType *t,
00611                                         bool (N::*f)(const T &, const Time &),
00612                                         Time N::*p)
00613     {
00614       return new SimpleField<N, T>(n, t, true, false, 0, f, 0, p);
00615     }
00616 
00617     template<class N, typename T>
00618     const SimpleField<N, T> *newExposedField(string n, const FieldType *t,
00619                                              T N::*v, EventSource N::*s,
00620                                              Time N::*p)
00621     {
00622       return new SimpleField<N, T>(n, t, true, true, v, 0, s, p);
00623     }
00624 
00625     template<class N, typename T>
00626     const SimpleField<N, T> *newExposedField(string n, const FieldType *t, T N::*v,
00627                                              bool (N::*f)(const T &, const Time &),
00628                                              EventSource N::*s, Time N::*p)
00629     {
00630       return new SimpleField<N, T>(n, t, true, true, v, f, s, p);
00631     }
00632 
00633     template<class N, typename T>
00634     const SimpleField<N, T> *newEventOut(string n, const FieldType *t,
00635                                          T N::*v, EventSource N::*s)
00636     {
00637       return new SimpleField<N, T>(n, t, false, true, v, 0, s, 0);
00638     }
00639 
00640 
00641 
00642     // SimpleSequenceField
00643 
00644     template<class N, typename T>
00645     const SimpleSequenceField<N, T> *
00646     newPrivateField(string n, const FieldType *t, vector<T> N::*v)
00647     {
00648       return new SimpleSequenceField<N, T>(n, t, false, false,
00649                                            v, 0, 0, 0);
00650     }
00651 
00652     template<class N, typename T>
00653     const SimpleSequenceField<N, T> *
00654     newEventIn(string n, const FieldType *t, vector<T> N::*v, Time N::*p)
00655     {
00656       return new SimpleSequenceField<N, T>(n, t, true, false,
00657                                            v, 0, 0, p);
00658     }
00659 
00660     template<class N, typename T>
00661     const SimpleSequenceField<N, T> *
00662     newEventIn(string n, const FieldType *t,
00663                bool (N::*f)(const vector<T> &, const Time &),
00664                Time N::*p)
00665     {
00666       return new SimpleSequenceField<N, T>(n, t, true, false,
00667                                            0, f, 0, p);
00668     }
00669 
00670     template<class N, typename T>
00671     const SimpleSequenceField<N, T> *
00672     newExposedField(string n, const FieldType *t, vector<T> N::*v,
00673                     EventSource N::*s, Time N::*p)
00674     {
00675       return new SimpleSequenceField<N, T>(n, t, true, true,
00676                                            v, 0, s, p);
00677     }
00678 
00679     template<class N, typename T>
00680     const SimpleSequenceField<N, T> *
00681     newExposedField(string n, const FieldType *t, vector<T> N::*v,
00682                     bool (N::*f)(const vector<T> &, const Time &),
00683                     EventSource N::*s, Time N::*p)
00684     {
00685       return new SimpleSequenceField<N, T>(n, t, true, true,
00686                                            v, f, s, p);
00687     }
00688 
00689     template<class N, typename T>
00690     const SimpleSequenceField<N, T> *
00691     newEventOut(string n, const FieldType *t, vector<T> N::*v,
00692                 EventSource N::*s)
00693     {
00694       return new SimpleSequenceField<N, T>(n, t, false, true,
00695                                            v, 0, s, 0);
00696     }
00697 
00698 
00699 
00700     // NodeField
00701 
00702     template<class N, typename C>
00703     const NodeField<N, C> *newPrivateField(string n, Ref<C> N::*v)
00704     {
00705       return new NodeField<N, C>(n, C::type, false, false, v, 0, 0, 0);
00706     }
00707 
00708     template<class N, typename C>
00709     const NodeField<N, C> *newEventIn(string n, Ref<C> N::*v, Time N::*p)
00710     {
00711       return new NodeField<N, C>(n, C::type, true, false, v, 0, 0, p);
00712     }
00713 
00714     template<class N, typename C>
00715     const NodeField<N, C> *newEventIn(string n,
00716                                       bool (N::*f)(const Ref<C> &, const Time &),
00717                                       Time N::*p)
00718     {
00719       return new NodeField<N, C>(n, C::type, true, false, 0, f, 0, p);
00720     }
00721 
00722     template<class N, typename C>
00723     const NodeField<N, C> *newExposedField(string n, Ref<C> N::*v,
00724                                            EventSource N::*s, Time N::*p)
00725     {
00726       return new NodeField<N, C>(n, C::type, true, true, v, 0, s, p);
00727     }
00728 
00729     template<class N, typename C>
00730     const NodeField<N, C> *newExposedField(string n, Ref<C> N::*v,
00731                                            bool (N::*f)(const Ref<C> &, const Time &),
00732                                            EventSource N::*s, Time N::*p)
00733     {
00734       return new NodeField<N, C>(n, C::type, true, true, v, f, s, p);
00735     }
00736 
00737     template<class N, typename C>
00738     const NodeField<N, C> *newEventOut(string n, Ref<C> N::*v,
00739                                        EventSource N::*s)
00740     {
00741       return new NodeField<N, C>(n, C::type, false, true, v, 0, s, 0);
00742     }
00743 
00744 
00745 
00746     // NodeSequenceField
00747 
00748     template<class N, typename C>
00749     const NodeSequenceField<N, C> *
00750     newPrivateField(string n, vector<Ref<C> > N::*v)
00751     {
00752       return new NodeSequenceField<N, C>(n, C::type, false, false,
00753                                          v, 0, 0, 0);
00754     }
00755 
00756     template<class N, typename C>
00757     const NodeSequenceField<N, C> *
00758     newEventIn(string n, vector<Ref<C> > N::*v, Time N::*p)
00759     {
00760       return new NodeSequenceField<N, C>(n, C::type, true, false,
00761                                          v, 0, 0, p);
00762     }
00763 
00764     template<class N, typename C>
00765     const NodeSequenceField<N, C> *
00766     newEventIn(string n, bool (N::*f)(const vector<Ref<C> > &, const Time &),
00767                Time N::*p)
00768     {
00769       return new NodeSequenceField<N, C>(n, C::type, true, false,
00770                                          0, f, 0, p);
00771     }
00772 
00773     template<class N, typename C>
00774     const NodeSequenceField<N, C> *
00775     newExposedField(string n, vector<Ref<C> > N::*v, EventSource N::*s,
00776                     Time N::*p)
00777     {
00778       return new NodeSequenceField<N, C>(n, C::type, true, true,
00779                                          v, 0, s, p);
00780     }
00781 
00782     template<class N, typename C>
00783     const NodeSequenceField<N, C> *
00784     newExposedField(string n, vector<Ref<C> > N::*v,
00785                     bool (N::*f)(const vector<Ref<C> > &, const Time &),
00786                     EventSource N::*s, Time N::*p)
00787     {
00788       return new NodeSequenceField<N, C>(n, C::type, true, true,
00789                                          v, f, s, p);
00790     }
00791 
00792     template<class N, typename C>
00793     const NodeSequenceField<N, C> *
00794     newEventOut(string n, vector<Ref<C> > N::*v, EventSource N::*s)
00795     {
00796       return new NodeSequenceField<N, C>(n, C::type, false, true,
00797                                          v, 0, s, 0);
00798     }
00799   }
00800 }
00801 
00802 #endif // ARCHON_X3D_FIELD_H

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