00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 #ifndef ARCHON_X3D_NETWORK_H
00021 #define ARCHON_X3D_NETWORK_H
00022 
00029 #include <vector>
00030 
00031 #include <archon/x3d/server/scene.H>
00032 
00033 namespace Archon
00034 {
00035   namespace X3D
00036   {
00056     struct UrlObject: virtual NodeBase
00057     {
00058       static const NodeType *type;
00059 
00067       Ref<const Loader::Contents> getContents() const;
00068 
00069     protected:
00070       UrlObject();
00071       virtual ~UrlObject();
00072 
00077       void addUri(string, Time stamp);
00078 
00087       virtual void clear() {}
00088 
00109       virtual void onLoaded() {}
00110 
00124       virtual bool mayStartLoading() const { return true; }
00125 
00137       void startLoading();
00138 
00139     private:
00140       friend void initializeNetworkComponent();
00141 
00142       vector<string> url;
00143 
00144       EventSource urlChanged;
00145 
00146       Time urlStamp;
00147 
00148 
00196       struct LoaderJob: Loader::Job
00197       {
00198         LoaderJob(UrlObject *urlObject, Ref<Loader> loader, Uri baseUri,
00199                   const vector<string> &uriList, Loader::UriType uriType,
00200                   Ref<AbstractFileServer> fileServer):
00201           Loader::Job(loader, baseUri, uriList, uriType, fileServer),
00202           urlObject(urlObject) {}
00203 
00204         void kill();
00205 
00206       private:
00207         void onCompletion();
00208 
00209         Mutex mutex;
00210         UrlObject *urlObject;
00211       };
00212 
00213 
00219       Mutex loaderMutex;
00220 
00221       Ref<LoaderJob> loaderJob;
00222       Ref<const Loader::Contents> contents;
00223 
00224       void setContents(Ref<const Loader::Contents> c);
00225 
00226       void killLoaderJob();
00227 
00233       bool urlAssign(const vector<string> &, const Time &);
00234 
00235       virtual Loader::UriType getUriType() const = 0;
00236     };
00237 
00250     struct SubSceneNode: virtual ChildNode
00251     {
00252       static const NodeType *type;
00253 
00254       Ref<SceneBase> getSubScene() const;
00255       void setSubScene(Ref<SceneBase>);
00256 
00260       Ref<SceneBase> getSubSceneNoLock() const { return subScene; }
00261 
00262     protected:
00263       SubSceneNode() {}
00264 
00265       Ref<SceneBase> subScene;
00266 
00267       void refForwardDestroy();
00268     };
00269 
00276     struct Inline: SubSceneNode, UrlObject
00277     {
00278       static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00279       {
00280         return new Inline(c);
00281       }
00282 
00283       static const NodeType *type;
00284       const NodeType *getType() const { return type; }
00285 
00286       Inline(BackRef<ExecutionContext> c): NodeBase(c) {}
00287 
00288     private:
00289       friend void initializeNetworkComponent();
00290 
00291       bool load;
00292 
00293       EventSource loadChanged;
00294 
00295       Time loadStamp;
00296 
00297       Loader::UriType getUriType() const
00298       {
00299         return Loader::uriType_X3D;
00300       }
00301 
00307       bool loadAssign(const bool &, const Time &);
00308 
00309       void onLoaded(); 
00310       void clear(); 
00311     };
00312 
00321     struct ApplicationLink: SubSceneNode
00322     {
00323       static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00324       {
00325         return new ApplicationLink(c);
00326       }
00327 
00328       static const NodeType *type;
00329       const NodeType *getType() const { return type; }
00330 
00331       ApplicationLink(BackRef<ExecutionContext> c): NodeBase(c) {}
00332 
00333     private:
00334       friend void initializeNetworkComponent();
00335 
00336       
00337     };
00338   }
00339 }
00340 
00341 #endif // ARCHON_X3D_NETWORK_H