Line data Source code
1 :
2 : /* Copyright (c) 2005-2011, Stefan Eilemann <eile@equalizergraphics.com>
3 : * 2010, Cedric Stalder <cedric.stalder@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 EQSERVER_PIPE_H
20 : #define EQSERVER_PIPE_H
21 :
22 : #include "api.h"
23 : #include "types.h"
24 : #include "state.h" // enum
25 : #include "visitorResult.h" // enum
26 :
27 : #include <eq/fabric/iAttribute.h> // eq::OFF enum
28 : #include <eq/fabric/pipe.h> // parent
29 : #include <eq/fabric/pixelViewport.h> // member
30 : #include <lunchbox/monitor.h> // member
31 :
32 : #include <ostream>
33 : #include <vector>
34 :
35 : namespace eq
36 : {
37 : namespace server
38 : {
39 : /** The pipe. */
40 : class Pipe : public fabric::Pipe< Node, Pipe, Window, PipeVisitor >
41 : {
42 : public:
43 : /** Construct a new Pipe. */
44 : EQSERVER_API Pipe( Node* parent );
45 :
46 : virtual ~Pipe();
47 :
48 : ServerPtr getServer();
49 : ConstServerPtr getServer() const;
50 :
51 : Config* getConfig();
52 : const Config* getConfig() const;
53 :
54 : co::CommandQueue* getMainThreadQueue();
55 : co::CommandQueue* getCommandThreadQueue();
56 :
57 : Channel* getChannel( const ChannelPath& path );
58 :
59 : /** @return the state of this pipe. */
60 120 : State getState() const { return _state.get(); }
61 :
62 : /** @internal */
63 0 : void setState( const State state ) { _state = state; }
64 :
65 : /** Increase pipe activition count. */
66 : void activate();
67 :
68 : /** Decrease pipe activition count. */
69 : void deactivate();
70 :
71 : /** @return if this pipe is actively used for rendering. */
72 52 : bool isActive() const { return (_active != 0); }
73 :
74 : /** @return if this pipe is running. */
75 12 : bool isRunning() const { return _state == STATE_RUNNING; }
76 :
77 : /**
78 : * Add additional tasks this pipe, and all its parents, might
79 : * potentially execute.
80 : */
81 : void addTasks( const uint32_t tasks );
82 :
83 : /**
84 : * @name Data Access
85 : */
86 : //@{
87 : /** The last drawing compound for this entity. @internal */
88 14 : void setLastDrawWindow( const Window* window )
89 14 : { _lastDrawWindow = window; }
90 7 : const Window* getLastDrawWindow() const { return _lastDrawWindow; }
91 : //@}
92 :
93 : /**
94 : * @name Operations
95 : */
96 : //@{
97 : /** Start initializing this entity. */
98 : void configInit( const uint128_t& initID, const uint32_t frameNumber );
99 :
100 : /** Sync initialization of this entity. */
101 : bool syncConfigInit();
102 :
103 : /** Start exiting this entity. */
104 : void configExit();
105 :
106 : /** Sync exit of this entity. */
107 : bool syncConfigExit();
108 :
109 : /**
110 : * Trigger the rendering of a new frame.
111 : *
112 : * @param frameID a per-frame identifier passed to all rendering
113 : * methods.
114 : * @param frameNumber the number of the frame.
115 : */
116 : void update( const uint128_t& frameID, const uint32_t frameNumber );
117 : //@}
118 :
119 : co::ObjectOCommand send( const uint32_t cmd );
120 : void output( std::ostream& ) const; //!< @internal
121 :
122 : protected:
123 :
124 : /** @sa co::Object::attachToSession. */
125 : virtual void attach( const uint128_t& id, const uint32_t instanceID );
126 :
127 : /** @internal Execute the slave remove request. */
128 : virtual void removeChild( const uint128_t& id );
129 :
130 : private:
131 : /** Number of activations for this pipe. */
132 : uint32_t _active;
133 :
134 : friend class Node;
135 :
136 : /** The current state for state change synchronization. */
137 : lunchbox::Monitor< State > _state;
138 :
139 : /** The last draw window for this entity. */
140 : const Window* _lastDrawWindow;
141 :
142 : struct Private;
143 : Private* _private; // placeholder for binary-compatible changes
144 :
145 : /* command handler functions. */
146 : bool _cmdConfigInitReply( co::ICommand& command );
147 : bool _cmdConfigExitReply( co::ICommand& command );
148 : };
149 : }
150 : }
151 : #endif // EQSERVER_PIPE_H
|