SO3Engine
SO3EnvironmentComponent.cpp
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
33
34namespace SO3
35{
36
37SEnvironmentComponent::SEnvironmentComponent(SEnvironment* parent, const std::string& environmentComponentName) : SData(environmentComponentName)
38{
39 parentEnvironment = parent;
40 isEnable = false;
41 cleaned = false;
42}
43
44SEnvironmentComponent::SEnvironmentComponent() : SData("")
45{
46 // Forbiden (private)
47}
48
50{
51 // It's a dev security.
52 if(!cleaned)
53 OGRE_EXCEPT(Ogre::Exception::ERR_INTERNAL_ERROR, "Did you call \"Cleanup\" function in the SEnvironmentComponent inherited class destructor?", "SEnvironmentComponent::~SEnvironmentComponent");
54
56}
57
62
64{
65 return isEnable;
66}
67
68void SEnvironmentComponent::SetEnable(const bool& enableComponent)
69{
70 if(isEnable == enableComponent)
71 return;
72
73 isEnable = enableComponent;
74 SetEnableImpl(enableComponent);
75}
76
78{
80}
81
83{
84}
85
87{
88 ViewportList::iterator iSearchedViewport = viewportList.find(viewport);
89 if(iSearchedViewport == viewportList.end())
90 {
91 viewportList.insert(viewport);
92 RegisterViewportImpl(viewport);
93 }
94 else
95 OGRE_EXCEPT(Ogre::Exception::ERR_DUPLICATE_ITEM, "The viewport already exist in the list of associated viewports!", "SEnvironmentComponent::RegisterViewport");
96}
97
99{
100 ViewportList::iterator iSearchedViewport = viewportList.find(viewport);
101 if(iSearchedViewport != viewportList.end())
102 {
103 UnregisterViewportImpl(viewport);
104 viewportList.erase(iSearchedViewport);
105 }
106 else
107 OGRE_EXCEPT(Ogre::Exception::ERR_ITEM_NOT_FOUND, "Cannot find the viewport in the list of associated viewports!", "SEnvironmentComponent::UnregisterViewport");
108}
109
114
116{
117 ViewportList viewportListCopy = viewportList;
118 ViewportList::iterator iViewport = viewportListCopy.begin();
119 while(iViewport != viewportListCopy.end())
120 {
121 UnregisterViewport(*iViewport);
122 iViewport++;
123 }
124 cleaned = true;
125}
126
130
131}
void RegisterViewport(SViewPort *viewport)
void UnregisterCamera(Ogre::Camera *cam)
virtual void RegisterViewportImpl(SViewPort *viewport)=0
virtual void UnregisterCameraImpl(Ogre::Camera *cam)
virtual void UpdateCamera(SViewPort *viewport)
virtual void UnregisterViewportImpl(SViewPort *viewport)=0
std::set< SViewPort * > ViewportList
void UnregisterViewport(SViewPort *viewport)
virtual void SetEnableImpl(const bool &enableComponent)=0
void SetEnable(const bool &enableComponent)