Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends
omni::proj::TuningList Class Reference

Tuning List contains a list of tunings Tuning List is serializable via QDataStream. More...

#include <TuningList.h>

Inheritance diagram for omni::proj::TuningList:
Inheritance graph
[legend]
Collaboration diagram for omni::proj::TuningList:
Collaboration graph
[legend]

Public Types

typedef std::vector
< std::unique_ptr< Tuning > > 
container_type
 

Public Member Functions

 TuningList (Session const &)
 
Tuningadd (bool _makeCurrent=true)
 Add tuning to list Returns pointer new tuning. More...
 
void remove ()
 Remove tuning with current index. More...
 
void remove (int)
 Remove tuning with custom index. More...
 
Tuningcurrent ()
 Returns pointer to current tuning Returns nullptr if currentIdx_ == -1 or tuning list is empty. More...
 
Tuning const * current () const
 Returns pointer to current tuning (const version) Returns nullptr if currentIdx_ == -1 or tuning list is empty. More...
 
void setCurrentIndex (int)
 Set new current index, must be between 0 and size()-1. More...
 
int currentIndex () const
 Return current index. More...
 
void clear ()
 Deletes all tunings. More...
 
Tuningoperator[] (int)
 Returns tuning at a specific index. More...
 
Tuning const * operator[] (int) const
 Returns tuning at a specific index (const version) More...
 
void fromStream (QDataStream &)
 Deserialize list from stream. More...
 
void toStream (QDataStream &) const
 Serialize list to stream. More...
 

Private Member Functions

bool validIndex (int) const
 Test of index is between 0 and size()-1. More...
 

Private Attributes

int currentIdx_ = -1
 
Session const & session_
 

Friends

bool operator== (TuningList const &, TuningList const &)
 Test both lists for equality. More...
 

Detailed Description

Tuning List contains a list of tunings Tuning List is serializable via QDataStream.

Member Typedef Documentation

typedef std::vector<std::unique_ptr<Tuning> > omni::proj::TuningList::container_type

Constructor & Destructor Documentation

omni::proj::TuningList::TuningList ( Session const &  _session)
33  :
34  session_(_session) {
35 
36  }
Session const & session_
Definition: TuningList.h:100

Member Function Documentation

Tuning * omni::proj::TuningList::add ( bool  _makeCurrent = true)

Add tuning to list Returns pointer new tuning.

Parameters
_makeCurrentFlag whether to set current index when added successfully
39  {
40  container_type::emplace_back(new Tuning(session_));
41  auto* _tuning = container_type::back().get();
42  if (_makeCurrent)
43  setCurrentIndex(container_type::size()-1);
44 
45  // Assign virtual screen initially, this also sets up projector aspectRatio correctly
46  _tuning->assignVirtualScreen();
47  _tuning->projector().setup("PeripheralSetup",session_.scene().size());
48 
49  return _tuning;
50  }
void setCurrentIndex(int)
Set new current index, must be between 0 and size()-1.
Definition: TuningList.cpp:66
Session const & session_
Definition: TuningList.h:100
Scene & scene()
Return reference to export settings.
Definition: Session.cpp:144
void omni::proj::TuningList::clear ( )

Deletes all tunings.

93  {
94  container_type::clear();
95  currentIdx_ = -1;
96  }
int currentIdx_
Definition: TuningList.h:98
Tuning * omni::proj::TuningList::current ( )

Returns pointer to current tuning Returns nullptr if currentIdx_ == -1 or tuning list is empty.

58  {
59  return validIndex(currentIdx_) ? container_type::at(currentIdx_).get() : nullptr;
60  }
bool validIndex(int) const
Test of index is between 0 and size()-1.
Definition: TuningList.cpp:158
int currentIdx_
Definition: TuningList.h:98
Tuning const * omni::proj::TuningList::current ( ) const

Returns pointer to current tuning (const version) Returns nullptr if currentIdx_ == -1 or tuning list is empty.

62  {
63  return validIndex(currentIdx_) ? container_type::at(currentIdx_).get() : nullptr;
64  }
bool validIndex(int) const
Test of index is between 0 and size()-1.
Definition: TuningList.cpp:158
int currentIdx_
Definition: TuningList.h:98
int omni::proj::TuningList::currentIndex ( ) const

Return current index.

82  {
83  return currentIdx_;
84  }
int currentIdx_
Definition: TuningList.h:98
void omni::proj::TuningList::fromStream ( QDataStream &  _stream)

Deserialize list from stream.

112  {
113  clear();
114  PropertyMap _map;
115  _stream >> _map;
116  uint32_t _size = _map.getValue<uint32_t>("size",0);
117  int _currentIdx = _map.getValue<int>("currentIndex",-1);
118 
119  for (int i = 0; i < _size; ++i)
120  {
121  auto* _tuning = add(false /* Dont modify current tuning index */);
122  if (!_tuning) continue;
123  _stream >> *_tuning;
124  }
125  setCurrentIndex(_currentIdx);
126  }
void setCurrentIndex(int)
Set new current index, must be between 0 and size()-1.
Definition: TuningList.cpp:66
void clear()
Deletes all tunings.
Definition: TuningList.cpp:92
Tuning * add(bool _makeCurrent=true)
Add tuning to list Returns pointer new tuning.
Definition: TuningList.cpp:38
Tuning * omni::proj::TuningList::operator[] ( int  _index)

Returns tuning at a specific index.

99  {
100  return validIndex(_index) ?
101  container_type::at(_index).get() : nullptr;
102  }
bool validIndex(int) const
Test of index is between 0 and size()-1.
Definition: TuningList.cpp:158
Tuning const * omni::proj::TuningList::operator[] ( int  _index) const

Returns tuning at a specific index (const version)

105  {
106  return validIndex(_index) ?
107  container_type::at(_index).get() : nullptr;
108  }
bool validIndex(int) const
Test of index is between 0 and size()-1.
Definition: TuningList.cpp:158
void omni::proj::TuningList::remove ( )

Remove tuning with current index.

53  {
54  remove(currentIdx_);
55  }
int currentIdx_
Definition: TuningList.h:98
void omni::proj::TuningList::remove ( int  _idx)

Remove tuning with custom index.

87  {
88  if (!validIndex(_idx)) return;
89  container_type::erase(container_type::begin() + _idx);
90  }
bool validIndex(int) const
Test of index is between 0 and size()-1.
Definition: TuningList.cpp:158
void omni::proj::TuningList::setCurrentIndex ( int  _currentIdx)

Set new current index, must be between 0 and size()-1.

67  {
68  if (_currentIdx < 0)
69  {
70  currentIdx_ = 0;
71  return;
72  }
73  if (_currentIdx >= size())
74  {
75  currentIdx_ = size() - 1;
76  return;
77  }
78  currentIdx_ = _currentIdx;
79  }
int currentIdx_
Definition: TuningList.h:98
void omni::proj::TuningList::toStream ( QDataStream &  _stream) const

Serialize list to stream.

129  {
130  PropertyMap _map;
131  _map("size",uint32_t(container_type::size()));
132  _map("currentIndex",currentIdx_);
133  _stream << _map;
134 
135  for (auto& _tuning : *this)
136  _stream << *_tuning;
137  }
int currentIdx_
Definition: TuningList.h:98
bool omni::proj::TuningList::validIndex ( int  _idx) const
private

Test of index is between 0 and size()-1.

159  {
160  return (_idx >= 0) && (_idx < container_type::size());
161  }

Friends And Related Function Documentation

bool operator== ( TuningList const &  _lhs,
TuningList const &  _rhs 
)
friend

Test both lists for equality.

140  {
141  // Lambda for testing if pointers of two tunings are equal
142  auto _tuningsEqual = [](Tuning const* _a, Tuning const* _b) -> bool
143  {
144  return _a && _b // Test if pointer have same address
145  ?
146  // Derefence pointers and use equality operator to test equality
147  ((*_a) == (*_b))
148  :
149  // Compare pointers and if test of pointer are not nullptrs
150  (_a == _b);
151  };
152 
153  return
155  util::testPtrVectorEqual(_lhs,_rhs,_tuningsEqual);
156  }
int currentIdx_
Definition: TuningList.h:98
#define OMNI_TEST_MEMBER_EQUAL(member)
Definition: util.h:125
bool testPtrVectorEqual(T const &_a, T const &_b, F f)
Test if two vectors which hold unique_ptr's of SerializationInterfaces.
Definition: util.h:78

Field Documentation

int omni::proj::TuningList::currentIdx_ = -1
private
Session const& omni::proj::TuningList::session_
private

The documentation for this class was generated from the following files: