FreeWRL/FreeX3D  3.0.0
SAIBrowser.h
1 /****************************************************************************
2  This file is part of the FreeWRL/FreeX3D Distribution.
3 
4  Copyright 2009 CRC Canada. (http://www.crc.gc.ca)
5 
6  FreeWRL/FreeX3D is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  FreeWRL/FreeX3D is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with FreeWRL/FreeX3D. If not, see <http://www.gnu.org/licenses/>.
18 ****************************************************************************/
19 
20 #ifndef _SAIBROWSER_H_ABSTRACT_
21 #define _SAIBROWSER_H_ABSTRACT_
22 
23 #include "SAIGlobals.h"
24 
25 namespace freeWRLSAI_cpp
26 {
27  //forward declarations
28  class saiScene;
29  class saiNode;
30  class saiExecutionContext;
31 
32  class saiBrowser
33  {
34  //GENERAL NOTICE: classes derived from saiBrowser should never be contructed with a standard ctor, so ctor/dtor group should be as follows
35  //protected:
36  // //standard ctor is never to be used;
37  // saiBrowser(){};
38  //public:
39  // saiBrowser(const SAIParameter* pParams) = 0; //null pointer should be allowed but always managed
40  // virtual ~saiBrowser(){};
41 
42  public:
43  //browser retrieval / creation
44  virtual saiBrowser* getBrowser(const SAIParameter* pParams) = 0; //null pointer should be allowed but always managed
45  virtual saiBrowser* createBrowser(const SAIParameter* pParams, std::map<std::string, std::string>* pProperties) = 0;
46 
47  //browser services
48 
49  virtual const char* getName() = 0; //return NULL if not supported
50  virtual const char* getVersion() = 0; //return NULL if not supported
51  virtual float getCurrentSpeed() = 0; //return 0.0f if not supported
52  virtual float getCurrentFrameRate() = 0; //return 0.0f if not supported
53 
54 
55 
56  virtual void replaceWorld(const char* sceneURI) = 0; //no return required. Throws if error.
57  //virtual void replaceWorld(const X3D_??* sourceScenePtr) = 0; //maybe not necessary, but W3C docs also declares the possibility of creating a scene from a scene object
58 
59  virtual void loadURL(const char* sceneURL) = 0; //no return required. Throws if error
60 
61  virtual void setDescription(const char* strDescription) = 0; //no return required.
62 
63  virtual saiScene* createX3DFromString(const char* strX3DSource) = 0;
64 
65  virtual void updateControl(unsigned int nAction)= 0; //it's better to throw a "not supported" exception if not really implemented
66 
67  virtual void registerBrowserInterest(unsigned int nAction, saiBrowser* pRequester) = 0; //it's better to throw a "not supported" exception if not really implemented
68  //it is perfectly acceptable that "pRequester" can be "this"
69  virtual std::map<std::string, std::string>* getRenderingProperties() = 0;
70 
71  virtual std::map<std::string, std::string>* getBrowserProperties() = 0;
72 
73  virtual void changeViewpoint(unsigned int nAction) = 0; //changes only the active context's viewpoint.
74 
75  virtual void print() = 0;
76 
77  virtual void dispose() = 0;
78 
79  virtual bool setBrowserOption(const char* strOptionName, void* pOptionValue) = 0; //returns true if the option is set, false if not.
80  //it's better to throw a "not supported" exception if not really implemented
81 
82  virtual const std::vector<saiProfileDeclaration*>* getSupportedProfiles() = 0; //should return a list of all the supported profiles and only that
83 
84  virtual const saiProfileDeclaration* getProfile(const char* strProfileName) = 0; //should return a pointer to the profile with matching name or throw NotSupportedException
85 
86  virtual const std::map<std::string,saiComponent*>* getSupportedComponents() = 0; //should return a map of all the supported components. We use the saiComponentDeclaration pair to browse the map
87 
88  virtual const saiComponent* getComponent(const char* strComponentName) = 0; //should return a pointer to an instance of saiComponent with matching name or throw NotSupportedException
89 
90  virtual const saiExecutionContext* getExecutionContext() = 0;
91 
92  virtual saiExecutionContext* createScene() = 0;
93 
94  virtual saiExecutionContext* importDocument(const char* DOMdocURI) = 0;
95 
96  virtual saiExecutionContext* createX3DFromStream(void* pStreambuf) = 0;
97 
98  virtual saiExecutionContext* createX3DFromUrl(const char* srcURL) = 0;
99  };
100 
101 };
102 
103 #endif _SAIBROWSER_H_ABSTRACT