Line data Source code
1 :
2 : /* Copyright (c) 2012, Daniel Nachbaur <danielnachbaur@gmail.com>
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 EQFABRIC_EQUALIZER_H
19 : #define EQFABRIC_EQUALIZER_H
20 :
21 : #include <eq/fabric/api.h>
22 : #include <eq/fabric/vmmlib.h>
23 :
24 : namespace co
25 : {
26 : class DataOStream;
27 : class DataIStream;
28 : }
29 :
30 :
31 : namespace eq
32 : {
33 : namespace fabric
34 : {
35 : namespace detail { class Equalizer; }
36 :
37 : /** Base data transport class for equalizers. @sa eq::server::Equalizer */
38 : class Equalizer
39 : {
40 : public:
41 : /** @internal */
42 : EQFABRIC_API Equalizer();
43 :
44 : /** @internal */
45 : EQFABRIC_API Equalizer( const Equalizer& rhs );
46 :
47 : /** @internal */
48 : EQFABRIC_API Equalizer& operator=( const Equalizer& rhs );
49 :
50 : /** @internal */
51 : EQFABRIC_API virtual ~Equalizer();
52 :
53 : enum Mode
54 : {
55 : MODE_DB = 0, //!< Adapt for a sort-last decomposition
56 : MODE_HORIZONTAL, //!< Adapt for sort-first using horizontal stripes
57 : MODE_VERTICAL, //!< Adapt for sort-first using vertical stripes
58 : MODE_2D //!< Adapt for a sort-first decomposition
59 : };
60 :
61 : /** @name Data Access. */
62 : //@{
63 : /** Set the equalizer to freeze the current state. */
64 : EQFABRIC_API void setFrozen( const bool onOff );
65 :
66 : /** @return the equalizer frozen state. */
67 : EQFABRIC_API bool isFrozen() const;
68 :
69 : /** Set the load balancer adaptation mode. */
70 : EQFABRIC_API void setMode( const Mode mode );
71 :
72 : /** @return the load balancer adaptation mode. */
73 : EQFABRIC_API Mode getMode() const;
74 :
75 : /** Set the damping factor for the viewport, range or zoom adjustment.*/
76 : EQFABRIC_API void setDamping( const float damping );
77 :
78 : /** @return the damping factor. */
79 : EQFABRIC_API float getDamping() const;
80 :
81 : /** Set the average frame rate for the DFREqualizer. */
82 : EQFABRIC_API void setFrameRate( const float frameRate );
83 :
84 : /** @return the average frame rate for the DFREqualizer. */
85 : EQFABRIC_API float getFrameRate() const;
86 :
87 : /** Set a boundary for 2D tiles. */
88 : EQFABRIC_API void setBoundary( const Vector2i& boundary );
89 :
90 : /** Set a boundary for DB ranges. */
91 : EQFABRIC_API void setBoundary( const float boundary );
92 :
93 : /** @return the boundary for 2D tiles. */
94 : EQFABRIC_API const Vector2i& getBoundary2i() const;
95 :
96 : /** @return the boundary for DB ranges. */
97 : EQFABRIC_API float getBoundaryf() const;
98 :
99 : /** Set a resistance for 2D tiles. */
100 : EQFABRIC_API void setResistance( const Vector2i& resistance );
101 :
102 : /** Set a resistance for DB ranges. */
103 : EQFABRIC_API void setResistance( const float resistance );
104 :
105 : /** @return the resistance for 2D tiles. */
106 : EQFABRIC_API const Vector2i& getResistance2i() const;
107 :
108 : /** @return the resistance for DB ranges. */
109 : EQFABRIC_API float getResistancef() const;
110 :
111 : /** Set the limit when to assign assemble tasks only. */
112 : EQFABRIC_API void setAssembleOnlyLimit( const float limit );
113 :
114 : /** @return the limit when to assign assemble tasks only. */
115 : EQFABRIC_API float getAssembleOnlyLimit() const;
116 :
117 : /** Set the tile size for the TileEqualizer. */
118 : EQFABRIC_API void setTileSize( const Vector2i& size );
119 :
120 : /** @return the tile size for the TileEqualizer. */
121 : EQFABRIC_API const Vector2i& getTileSize() const;
122 : //@}
123 :
124 : EQFABRIC_API void serialize( co::DataOStream& os ) const; //!< @internal
125 : EQFABRIC_API void deserialize( co::DataIStream& is ); //!< @internal
126 :
127 : EQFABRIC_API void backup(); //!< @internal
128 : EQFABRIC_API void restore(); //!< @internal
129 :
130 : private:
131 : detail::Equalizer* _data;
132 : detail::Equalizer* _backup;
133 : };
134 :
135 : EQFABRIC_API co::DataOStream& operator << ( co::DataOStream& os,
136 : const Equalizer& );
137 :
138 : EQFABRIC_API co::DataIStream& operator >> ( co::DataIStream& is,
139 : Equalizer& );
140 :
141 : EQFABRIC_API std::ostream& operator << ( std::ostream& os,
142 : const Equalizer::Mode );
143 : }
144 : }
145 :
146 : namespace lunchbox
147 : {
148 0 : template<> inline void byteswap( eq::fabric::Equalizer::Mode& value )
149 0 : { byteswap( reinterpret_cast< uint32_t& >( value )); }
150 : }
151 :
152 : #endif // EQFABRIC_EQUALIZER_H
|