Line data Source code
1 :
2 : /* Copyright (c) 2011-2016, Stefan Eilemann <eile@eyescale.ch>
3 : * Petros Kataras <petroskataras@gmail.com>
4 : *
5 : * This library is free software; you can redistribute it and/or modify it under
6 : * the terms of the GNU Lesser General Public License version 2.1 as published
7 : * by the Free Software Foundation.
8 : *
9 : * This library is distributed in the hope that it will be useful, but WITHOUT
10 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 : * details.
13 : *
14 : * You should have received a copy of the GNU Lesser General Public License
15 : * along with this library; if not, write to the Free Software Foundation, Inc.,
16 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 : */
18 :
19 : #ifndef EQSEQUEL_APPLICATION_H
20 : #define EQSEQUEL_APPLICATION_H
21 :
22 : #include <co/objectFactory.h> // interface
23 : #include <seq/types.h>
24 : #include <eq/client.h> // base class
25 :
26 : namespace seq
27 : {
28 : /** The main application object. */
29 : class Application : public eq::Client, public co::ObjectFactory
30 : {
31 : public:
32 : /** Construct a new application instance. @version 1.0 */
33 : SEQ_API Application();
34 :
35 : /** @name Data Access */
36 : //@{
37 : /** @return the node running the main instance. @version 1.3.1 */
38 : SEQ_API co::NodePtr getMasterNode();
39 : //@}
40 :
41 : /** @name Operations */
42 : //@{
43 : /**
44 : * Initialize the application instance.
45 : *
46 : * The initData object is registered and is passed to all initialization
47 : * callbacks on all processes. The object may be 0, if the application does
48 : * not want to use an object during initialization.
49 : *
50 : * @param argc the command line argument count.
51 : * @param argv the command line arguments.
52 : * @param initData a distributable object for initialization data.
53 : * @return true on success, false otherwise.
54 : * @version 1.0
55 : */
56 : SEQ_API virtual bool init( int argc, char** argv, co::Object* initData );
57 :
58 : /**
59 : * Run the application main loop.
60 : *
61 : * The frameData object is registered and is passed to all rendering
62 : * callbacks on all processes. It is automatically committed at the
63 : * beginning of each frame. The instance passed to the render callbacks is
64 : * automatically synchronized to the version belonging to the frame
65 : * rendered. The object may be 0, if the application does not want to use a
66 : * per-frame object.
67 : *
68 : * @return true on success, false otherwise.
69 : * @param frameData a distributed object holding frame-specific data.
70 : * @version 1.0
71 : */
72 : SEQ_API virtual bool run( co::Object* frameData );
73 :
74 : /**
75 : * Exit this application instance.
76 : *
77 : * @return true on success, false otherwise.
78 : * @version 1.0
79 : */
80 : SEQ_API virtual bool exit();
81 :
82 : /** Request that the application leaves its run loop. @version 1.1.6 */
83 : SEQ_API void stopRunning();
84 : //@}
85 :
86 : /** @name Callbacks */
87 : //@{
88 : /**
89 : * Initialize a render client.
90 : *
91 : * Also called on the master application node if it contributes to the
92 : * rendering.
93 : *
94 : * @param initData A slave instance of the object passed to init().
95 : * @return true on success, false on error.
96 : * @version 1.0
97 : */
98 0 : virtual bool clientInit( co::Object* initData LB_UNUSED )
99 0 : { return true; }
100 :
101 : /** Exit a render client. @version 1.0 */
102 0 : virtual bool clientExit() { return true; }
103 :
104 : /**
105 : * Create a new renderer instance.
106 : *
107 : * Called once per rendering thread, potentially in parallel, during
108 : * initialization.
109 : *
110 : * @return the new renderer
111 : * @version 1.0
112 : */
113 : virtual Renderer* createRenderer() = 0;
114 :
115 : /** Delete the given renderer. @version 1.0 */
116 : SEQ_API virtual void destroyRenderer( Renderer* renderer );
117 :
118 : /**
119 : * Create a new per-view data instance.
120 : *
121 : * Called once for each view in the current configuration. Creates the view
122 : * data objects used by the application to set parameters for the renderers.
123 : *
124 : * @param view the view requesting the view data
125 : * @return the new view data
126 : * @version 1.11
127 : */
128 : SEQ_API virtual ViewData* createViewData( View& view );
129 :
130 : /** Delete the given view data. @version 1.0 */
131 : SEQ_API virtual void destroyViewData( ViewData* viewData );
132 : //@}
133 :
134 : /** @name Internal */
135 : //@{
136 : SEQ_API eq::Config* getConfig(); //!< @internal
137 0 : detail::Application* getImpl() { return _impl; } //!< @internal
138 : //@}
139 :
140 : /** @name Distributed Object API */
141 : //@{
142 : /**
143 : * Add and register a new object as master instance.
144 : *
145 : * @param object the new object to add and register
146 : * @param type unique object type to create object via slave factory
147 : * @return true on success, false otherwise.
148 : * @version 1.8
149 : * @sa co::ObjectMap::register_()
150 : */
151 : SEQ_API bool registerObject( co::Object* object, const uint32_t type );
152 :
153 : /**
154 : * Remove and deregister an object.
155 : *
156 : * @param object the object to remove and deregister
157 : * @return false if object was not registered, true otherwise
158 : * @version 1.8
159 : * @sa co::ObjectMap::deregister()
160 : */
161 : SEQ_API bool deregister( co::Object* object );
162 : //@}
163 :
164 : protected:
165 : /** Destruct this application instance. @version 1.0 */
166 : SEQ_API virtual ~Application();
167 :
168 : private:
169 : detail::Application* _impl;
170 : };
171 : }
172 : #endif // EQSEQUEL_APPLICATION_H
|