1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "streamable_entity_composite.h"
22 #include "nel/misc/progress_callback.h"
28 H_AUTO_DECL(RZ_StremableEntityComposite
)
30 //===============================================================================
31 CStreamableEntityComposite::~CStreamableEntityComposite()
33 H_AUTO_USE(RZ_StremableEntityComposite
)
34 for(TStreambleEntities::iterator it
= _Entities
.begin(); it
!= _Entities
.end(); ++it
)
40 //===============================================================================
41 void CStreamableEntityComposite::add(IStreamableEntity
*entity
)
43 H_AUTO_USE(RZ_StremableEntityComposite
)
45 nlassert(std::find(_Entities
.begin(), _Entities
.end(), entity
) == _Entities
.end());
46 _Entities
.push_back(entity
);
49 //===============================================================================
50 void CStreamableEntityComposite::remove(IStreamableEntity
*entity
)
52 H_AUTO_USE(RZ_StremableEntityComposite
)
53 TStreambleEntities::iterator it
= std::find(_Entities
.begin(), _Entities
.end(), entity
);
54 nlassert(it
!= _Entities
.end());
59 //===============================================================================
60 /*virtual*/ bool CStreamableEntityComposite::needCompleteLoading(const NLMISC::CVector
&pos
) const
62 H_AUTO_USE(RZ_StremableEntityComposite
)
63 for(TStreambleEntities::const_iterator it
= _Entities
.begin(); it
!= _Entities
.end(); ++it
)
65 if ((*it
)->needCompleteLoading(pos
)) return true;
70 //===============================================================================
71 /*virtual*/ void CStreamableEntityComposite::update(const NLMISC::CVector
&pos
)
73 H_AUTO_USE(RZ_StremableEntityComposite
)
74 for(TStreambleEntities::iterator it
= _Entities
.begin(); it
!= _Entities
.end(); ++it
)
80 //===============================================================================
81 /*virtual*/ void CStreamableEntityComposite::forceUpdate(const NLMISC::CVector
&pos
, NLMISC::IProgressCallback
&progress
)
83 H_AUTO_USE(RZ_StremableEntityComposite
)
84 const uint size
= (uint
)_Entities
.size();
86 for(TStreambleEntities::iterator it
= _Entities
.begin(); it
!= _Entities
.end(); ++it
)
89 progress
.progress((float)count
/(float)size
);
90 progress
.pushCropedValues((float)count
/(float)size
, (float)(count
+1)/(float)size
);
92 (*it
)->forceUpdate(pos
, progress
);
95 progress
.popCropedValues();
99 //===============================================================================
100 void CStreamableEntityComposite::reserve(uint size
)
102 H_AUTO_USE(RZ_StremableEntityComposite
)
103 _Entities
.reserve(size
);
106 //===============================================================================
107 void CStreamableEntityComposite::removeAll()
109 H_AUTO_USE(RZ_StremableEntityComposite
)
110 for(TStreambleEntities::iterator it
= _Entities
.begin(); it
!= _Entities
.end(); ++it
)
114 NLMISC::contReset(_Entities
);
118 //===============================================================================
119 void CStreamableEntityComposite::forceUnload()
121 H_AUTO_USE(RZ_StremableEntityComposite
)
122 for(TStreambleEntities::iterator it
= _Entities
.begin(); it
!= _Entities
.end(); ++it
)
124 (*it
)->forceUnload();