conversions.hh
Go to the documentation of this file.
1 // Created by Joseph Mirabel in December 2020.
2 // Copyright (c) 2020 LAAS-CNRS. All rights reserved.
3 //
4 
5 #ifndef GEPETTO_VIEWER_CORBA_CONVERSIONS_HH
6 #define GEPETTO_VIEWER_CORBA_CONVERSIONS_HH
7 
8 #include <assert.h>
9 #include <omniORB4/CORBA.h>
10 #include <gepetto/viewer/corba/graphical-interface.hh>
11 
12 
13 namespace gepetto {
14 namespace viewer {
15 namespace corba {
16 using namespace ::gepetto::corbaserver;
17 
18 #if __cplusplus >= 201103L
19 
20 template<typename Scalar>
21 PositionSeq positionSeq(std::initializer_list< std::initializer_list<Scalar> > l)
22 {
23  Position* posSeq = PositionSeq::allocbuf((CORBA::ULong) l.size());
24 
25  PositionSeq seq ((CORBA::ULong) l.size(), (CORBA::ULong) l.size(), posSeq);
26  CORBA::ULong i = 0;
27  for (const std::initializer_list<Scalar>& el : l) {
28  assert(el.size() == 3);
29  const Scalar* f = el.begin();
30  posSeq[i][0] = static_cast<float>(*(f++));
31  posSeq[i][1] = static_cast<float>(*(f++));
32  posSeq[i][2] = static_cast<float>(*(f++));
33  ++i;
34  }
35  return seq;
36 }
37 
38 #endif // __cplusplus >= 201103L
39 
40 } //end of namespace corba
41 } //end of namespace viewer
42 } //end of namespace gepetto
43 
44 #endif // GEPETTO_VIEWER_CORBA_CONVERSIONS_HH
float Position[3]
Definition: graphical-interface.idl:22
sequence< Position > PositionSeq
Definition: graphical-interface.idl:27
Definition: graphical-interface.idl:9