Line data Source code
1 :
2 : /* Copyright (c) 2011-2014, Stefan Eilemann <eile@eyescale.ch>
3 : *
4 : * This library is free software; you can redistribute it and/or modify it under
5 : * the terms of the GNU Lesser General Public License version 2.1 as published
6 : * by the Free Software Foundation.
7 : *
8 : * This library is distributed in the hope that it will be useful, but WITHOUT
9 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11 : * details.
12 : *
13 : * You should have received a copy of the GNU Lesser General Public License
14 : * along with this library; if not, write to the Free Software Foundation, Inc.,
15 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 : */
17 :
18 : #ifndef EQSEQUEL_APPLICATION_H
19 : #define EQSEQUEL_APPLICATION_H
20 :
21 : #include <co/objectFactory.h> // interface
22 : #include <seq/types.h>
23 : #include <eq/client/client.h> // base class
24 :
25 : namespace seq
26 : {
27 : /** The main application object. */
28 : class Application : public eq::Client, public co::ObjectFactory
29 : {
30 : public:
31 : /** Construct a new application instance. @version 1.0 */
32 : SEQ_API Application();
33 :
34 : /** @name Data Access */
35 : //@{
36 : /** @return the node running the main instance. @version 1.3.1 */
37 : SEQ_API co::NodePtr getMasterNode();
38 : //@}
39 :
40 : /** @name Operations */
41 : //@{
42 : /**
43 : * Initialize the application instance.
44 : *
45 : * The initData object is registered and is passed to all initialization
46 : * callbacks on all processes. The object may be 0, if the application does
47 : * not want to use an object during initialization.
48 : *
49 : * @param argc the command line argument count.
50 : * @param argv the command line arguments.
51 : * @param initData a distributable object for initialization data.
52 : * @return true on success, false otherwise.
53 : * @version 1.0
54 : */
55 : SEQ_API virtual bool init( const int argc, char** argv,
56 : 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 1 : virtual bool clientInit( co::Object* initData LB_UNUSED )
99 1 : { return true; }
100 :
101 : /** Exit a render client. @version 1.0 */
102 1 : 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 : * @return the new view data
125 : * @version 1.0
126 : */
127 : SEQ_API virtual ViewData* createViewData();
128 :
129 : /** Delete the given view data. @version 1.0 */
130 : SEQ_API virtual void destroyViewData( ViewData* viewData );
131 : //@}
132 :
133 : /** @name Internal */
134 : //@{
135 : SEQ_API eq::Config* getConfig(); //!< @internal
136 4 : detail::Application* getImpl() { return _impl; } //!< @internal
137 : //@}
138 :
139 : protected:
140 : /** Destruct this application instance. @version 1.0 */
141 : SEQ_API virtual ~Application();
142 :
143 : private:
144 : detail::Application* _impl;
145 : };
146 : }
147 : #endif // EQSEQUEL_APPLICATION_H
|