network.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_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(); // Overriding from UrlObject
00310       void clear(); // Overriding from UrlObject
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       // string dump(int level) const;
00337     };
00338   }
00339 }
00340 
00341 #endif // ARCHON_X3D_NETWORK_H

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