changed: auto add updateData callback to stages so that stagedata can be updated...
[opensg.git] / Source / WindowSystem / EGL / OSGEGLWindowBase.cpp
blob852f28cdf03f281dfcb32da4876d8ae922f53672
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 /*****************************************************************************\
40 *****************************************************************************
41 ** **
42 ** This file is automatically generated. **
43 ** **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
46 ** **
47 ** Do not change this file, changes should be done in the derived **
48 ** class EGLWindow!
49 ** **
50 *****************************************************************************
51 \*****************************************************************************/
53 #include <cstdlib>
54 #include <cstdio>
56 #include "OSGConfig.h"
61 #include "OSGEGLWindowBase.h"
62 #include "OSGEGLWindow.h"
64 #include <boost/bind.hpp>
66 #ifdef WIN32 // turn off 'this' : used in base member initializer list warning
67 #pragma warning(disable:4355)
68 #endif
70 OSG_BEGIN_NAMESPACE
72 /***************************************************************************\
73 * Description *
74 \***************************************************************************/
76 /*! \class OSG::EGLWindow
77 The class for EGL windows.
80 /***************************************************************************\
81 * Field Documentation *
82 \***************************************************************************/
84 /*! \var EGLDisplay EGLWindowBase::_sfDisplay
88 /*! \var EGLSurface EGLWindowBase::_sfWindow
92 /*! \var EGLContext EGLWindowBase::_sfContext
97 /***************************************************************************\
98 * FieldType/FieldTrait Instantiation *
99 \***************************************************************************/
101 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
102 DataType FieldTraits<EGLWindow *>::_type("EGLWindowPtr", "WindowPtr");
103 #endif
105 OSG_FIELDTRAITS_GETTYPE(EGLWindow *)
107 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
108 EGLWindow *,
111 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
112 EGLWindow *,
115 /***************************************************************************\
116 * Field Description *
117 \***************************************************************************/
119 void EGLWindowBase::classDescInserter(TypeObject &oType)
121 FieldDescriptionBase *pDesc = NULL;
124 pDesc = new SFEGLDisplay::Description(
125 SFEGLDisplay::getClassType(),
126 "display",
128 DisplayFieldId, DisplayFieldMask,
129 true,
130 (Field::SFDefaultFlags | Field::FStdAccess),
131 static_cast<FieldEditMethodSig>(&EGLWindow::editHandleDisplay),
132 static_cast<FieldGetMethodSig >(&EGLWindow::getHandleDisplay));
134 oType.addInitialDesc(pDesc);
136 pDesc = new SFEGLSurface::Description(
137 SFEGLSurface::getClassType(),
138 "window",
140 WindowFieldId, WindowFieldMask,
141 true,
142 (Field::SFDefaultFlags | Field::FStdAccess),
143 static_cast<FieldEditMethodSig>(&EGLWindow::editHandleWindow),
144 static_cast<FieldGetMethodSig >(&EGLWindow::getHandleWindow));
146 oType.addInitialDesc(pDesc);
148 pDesc = new SFEGLContext::Description(
149 SFEGLContext::getClassType(),
150 "context",
152 ContextFieldId, ContextFieldMask,
153 true,
154 (Field::SFDefaultFlags | Field::FStdAccess),
155 static_cast<FieldEditMethodSig>(&EGLWindow::editHandleContext),
156 static_cast<FieldGetMethodSig >(&EGLWindow::getHandleContext));
158 oType.addInitialDesc(pDesc);
162 EGLWindowBase::TypeObject EGLWindowBase::_type(
163 EGLWindowBase::getClassname(),
164 Inherited::getClassname(),
165 "NULL",
167 reinterpret_cast<PrototypeCreateF>(&EGLWindowBase::createEmptyLocal),
168 EGLWindow::initMethod,
169 EGLWindow::exitMethod,
170 reinterpret_cast<InitalInsertDescFunc>(&EGLWindow::classDescInserter),
171 false,
173 "<?xml version=\"1.0\"?>\n"
174 "\n"
175 "<FieldContainer\n"
176 " name=\"EGLWindow\"\n"
177 " parent=\"Window\"\n"
178 " library=\"WindowEGL\"\n"
179 " pointerfieldtypes=\"both\"\n"
180 " structure=\"concrete\"\n"
181 " systemcomponent=\"true\"\n"
182 " parentsystemcomponent=\"true\"\n"
183 " >\n"
184 " The class for EGL windows.\n"
185 " <Field\n"
186 "\t name=\"display\"\n"
187 "\t type=\"EGLDisplay\"\n"
188 "\t cardinality=\"single\"\n"
189 "\t visibility=\"internal\"\n"
190 "\t defaultValue=\"0\"\n"
191 "\t fieldHeader=\"OSGEGLWindowDataFields.h\"\n"
192 "\t access=\"public\"\n"
193 "\t >\n"
194 " </Field>\n"
195 " <Field\n"
196 "\t name=\"window\"\n"
197 "\t type=\"EGLSurface\"\n"
198 "\t cardinality=\"single\"\n"
199 "\t visibility=\"internal\"\n"
200 "\t defaultValue=\"0\"\n"
201 "\t fieldHeader=\"OSGEGLWindowDataFields.h\"\n"
202 "\t access=\"public\"\n"
203 "\t >\n"
204 " </Field>\n"
205 " <Field\n"
206 "\t name=\"context\"\n"
207 "\t type=\"EGLContext\"\n"
208 "\t cardinality=\"single\"\n"
209 "\t visibility=\"internal\"\n"
210 "\t defaultValue=\"0\"\n"
211 "\t fieldHeader=\"OSGEGLWindowDataFields.h\"\n"
212 "\t access=\"public\"\n"
213 "\t >\n"
214 " </Field>\n"
215 "</FieldContainer>\n",
216 "The class for EGL windows.\n"
219 /*------------------------------ get -----------------------------------*/
221 FieldContainerType &EGLWindowBase::getType(void)
223 return _type;
226 const FieldContainerType &EGLWindowBase::getType(void) const
228 return _type;
231 UInt32 EGLWindowBase::getContainerSize(void) const
233 return sizeof(EGLWindow);
236 /*------------------------- decorator get ------------------------------*/
239 SFEGLDisplay *EGLWindowBase::editSFDisplay(void)
241 editSField(DisplayFieldMask);
243 return &_sfDisplay;
246 const SFEGLDisplay *EGLWindowBase::getSFDisplay(void) const
248 return &_sfDisplay;
252 SFEGLSurface *EGLWindowBase::editSFWindow(void)
254 editSField(WindowFieldMask);
256 return &_sfWindow;
259 const SFEGLSurface *EGLWindowBase::getSFWindow(void) const
261 return &_sfWindow;
265 SFEGLContext *EGLWindowBase::editSFContext(void)
267 editSField(ContextFieldMask);
269 return &_sfContext;
272 const SFEGLContext *EGLWindowBase::getSFContext(void) const
274 return &_sfContext;
282 /*------------------------------ access -----------------------------------*/
284 SizeT EGLWindowBase::getBinSize(ConstFieldMaskArg whichField)
286 SizeT returnValue = Inherited::getBinSize(whichField);
288 if(FieldBits::NoField != (DisplayFieldMask & whichField))
290 returnValue += _sfDisplay.getBinSize();
292 if(FieldBits::NoField != (WindowFieldMask & whichField))
294 returnValue += _sfWindow.getBinSize();
296 if(FieldBits::NoField != (ContextFieldMask & whichField))
298 returnValue += _sfContext.getBinSize();
301 return returnValue;
304 void EGLWindowBase::copyToBin(BinaryDataHandler &pMem,
305 ConstFieldMaskArg whichField)
307 Inherited::copyToBin(pMem, whichField);
309 if(FieldBits::NoField != (DisplayFieldMask & whichField))
311 _sfDisplay.copyToBin(pMem);
313 if(FieldBits::NoField != (WindowFieldMask & whichField))
315 _sfWindow.copyToBin(pMem);
317 if(FieldBits::NoField != (ContextFieldMask & whichField))
319 _sfContext.copyToBin(pMem);
323 void EGLWindowBase::copyFromBin(BinaryDataHandler &pMem,
324 ConstFieldMaskArg whichField)
326 Inherited::copyFromBin(pMem, whichField);
328 if(FieldBits::NoField != (DisplayFieldMask & whichField))
330 editSField(DisplayFieldMask);
331 _sfDisplay.copyFromBin(pMem);
333 if(FieldBits::NoField != (WindowFieldMask & whichField))
335 editSField(WindowFieldMask);
336 _sfWindow.copyFromBin(pMem);
338 if(FieldBits::NoField != (ContextFieldMask & whichField))
340 editSField(ContextFieldMask);
341 _sfContext.copyFromBin(pMem);
345 //! create a new instance of the class
346 EGLWindowTransitPtr EGLWindowBase::createLocal(BitVector bFlags)
348 EGLWindowTransitPtr fc;
350 if(getClassType().getPrototype() != NULL)
352 FieldContainerTransitPtr tmpPtr =
353 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
355 fc = dynamic_pointer_cast<EGLWindow>(tmpPtr);
358 return fc;
361 //! create a new instance of the class, copy the container flags
362 EGLWindowTransitPtr EGLWindowBase::createDependent(BitVector bFlags)
364 EGLWindowTransitPtr fc;
366 if(getClassType().getPrototype() != NULL)
368 FieldContainerTransitPtr tmpPtr =
369 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
371 fc = dynamic_pointer_cast<EGLWindow>(tmpPtr);
374 return fc;
377 //! create a new instance of the class
378 EGLWindowTransitPtr EGLWindowBase::create(void)
380 EGLWindowTransitPtr fc;
382 if(getClassType().getPrototype() != NULL)
384 FieldContainerTransitPtr tmpPtr =
385 getClassType().getPrototype()-> shallowCopy();
387 fc = dynamic_pointer_cast<EGLWindow>(tmpPtr);
390 return fc;
393 EGLWindow *EGLWindowBase::createEmptyLocal(BitVector bFlags)
395 EGLWindow *returnValue;
397 newPtr<EGLWindow>(returnValue, bFlags);
399 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
401 return returnValue;
404 //! create an empty new instance of the class, do not copy the prototype
405 EGLWindow *EGLWindowBase::createEmpty(void)
407 EGLWindow *returnValue;
409 newPtr<EGLWindow>(returnValue, Thread::getCurrentLocalFlags());
411 returnValue->_pFieldFlags->_bNamespaceMask &=
412 ~Thread::getCurrentLocalFlags();
414 return returnValue;
418 FieldContainerTransitPtr EGLWindowBase::shallowCopyLocal(
419 BitVector bFlags) const
421 EGLWindow *tmpPtr;
423 newPtr(tmpPtr, dynamic_cast<const EGLWindow *>(this), bFlags);
425 FieldContainerTransitPtr returnValue(tmpPtr);
427 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
429 return returnValue;
432 FieldContainerTransitPtr EGLWindowBase::shallowCopyDependent(
433 BitVector bFlags) const
435 EGLWindow *tmpPtr;
437 newPtr(tmpPtr, dynamic_cast<const EGLWindow *>(this), ~bFlags);
439 FieldContainerTransitPtr returnValue(tmpPtr);
441 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
443 return returnValue;
446 FieldContainerTransitPtr EGLWindowBase::shallowCopy(void) const
448 EGLWindow *tmpPtr;
450 newPtr(tmpPtr,
451 dynamic_cast<const EGLWindow *>(this),
452 Thread::getCurrentLocalFlags());
454 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
456 FieldContainerTransitPtr returnValue(tmpPtr);
458 return returnValue;
464 /*------------------------- constructors ----------------------------------*/
466 EGLWindowBase::EGLWindowBase(void) :
467 Inherited(),
468 _sfDisplay (EGLDisplay(0)),
469 _sfWindow (EGLSurface(0)),
470 _sfContext (EGLContext(0))
474 EGLWindowBase::EGLWindowBase(const EGLWindowBase &source) :
475 Inherited(source),
476 _sfDisplay (source._sfDisplay ),
477 _sfWindow (source._sfWindow ),
478 _sfContext (source._sfContext )
483 /*-------------------------- destructors ----------------------------------*/
485 EGLWindowBase::~EGLWindowBase(void)
490 GetFieldHandlePtr EGLWindowBase::getHandleDisplay (void) const
492 SFEGLDisplay::GetHandlePtr returnValue(
493 new SFEGLDisplay::GetHandle(
494 &_sfDisplay,
495 this->getType().getFieldDesc(DisplayFieldId),
496 const_cast<EGLWindowBase *>(this)));
498 return returnValue;
501 EditFieldHandlePtr EGLWindowBase::editHandleDisplay (void)
503 SFEGLDisplay::EditHandlePtr returnValue(
504 new SFEGLDisplay::EditHandle(
505 &_sfDisplay,
506 this->getType().getFieldDesc(DisplayFieldId),
507 this));
510 editSField(DisplayFieldMask);
512 return returnValue;
515 GetFieldHandlePtr EGLWindowBase::getHandleWindow (void) const
517 SFEGLSurface::GetHandlePtr returnValue(
518 new SFEGLSurface::GetHandle(
519 &_sfWindow,
520 this->getType().getFieldDesc(WindowFieldId),
521 const_cast<EGLWindowBase *>(this)));
523 return returnValue;
526 EditFieldHandlePtr EGLWindowBase::editHandleWindow (void)
528 SFEGLSurface::EditHandlePtr returnValue(
529 new SFEGLSurface::EditHandle(
530 &_sfWindow,
531 this->getType().getFieldDesc(WindowFieldId),
532 this));
535 editSField(WindowFieldMask);
537 return returnValue;
540 GetFieldHandlePtr EGLWindowBase::getHandleContext (void) const
542 SFEGLContext::GetHandlePtr returnValue(
543 new SFEGLContext::GetHandle(
544 &_sfContext,
545 this->getType().getFieldDesc(ContextFieldId),
546 const_cast<EGLWindowBase *>(this)));
548 return returnValue;
551 EditFieldHandlePtr EGLWindowBase::editHandleContext (void)
553 SFEGLContext::EditHandlePtr returnValue(
554 new SFEGLContext::EditHandle(
555 &_sfContext,
556 this->getType().getFieldDesc(ContextFieldId),
557 this));
560 editSField(ContextFieldMask);
562 return returnValue;
566 #ifdef OSG_MT_CPTR_ASPECT
567 void EGLWindowBase::execSyncV( FieldContainer &oFrom,
568 ConstFieldMaskArg whichField,
569 AspectOffsetStore &oOffsets,
570 ConstFieldMaskArg syncMode,
571 const UInt32 uiSyncInfo)
573 EGLWindow *pThis = static_cast<EGLWindow *>(this);
575 pThis->execSync(static_cast<EGLWindow *>(&oFrom),
576 whichField,
577 oOffsets,
578 syncMode,
579 uiSyncInfo);
581 #endif
584 #ifdef OSG_MT_CPTR_ASPECT
585 FieldContainer *EGLWindowBase::createAspectCopy(
586 const FieldContainer *pRefAspect) const
588 EGLWindow *returnValue;
590 newAspectCopy(returnValue,
591 dynamic_cast<const EGLWindow *>(pRefAspect),
592 dynamic_cast<const EGLWindow *>(this));
594 return returnValue;
596 #endif
598 void EGLWindowBase::resolveLinks(void)
600 Inherited::resolveLinks();
606 OSG_END_NAMESPACE