Maybe this topic will be great for newbies like me wondering about design decisions in Ogre.
So my first question:
why is vector<T>::type better than vector<T>?
I just started to port my "old" 1.6.x code to the fancy new 1.7.1 and I have to rewrite a lot of vector defs to the new ::type style - but why?
Ogre patterns / habits: why?
-
- Gremlin
- Posts: 158
- Joined: Mon Mar 10, 2008 10:55 pm
- Location: Budapest, Hungary
- x 1
-
- Hobgoblin
- Posts: 525
- Joined: Mon Apr 02, 2007 12:18 am
- Location: Sweden
- x 79
Re: Ogre patterns / habits: why?
Favor composition over inheritance.
(No, you don't need a "CGameLevel" class that inherits from BSPSceneManager, ParticleManager, StaticGeometry and half a dozen other classes...)
(No, you don't need a "CGameLevel" class that inherits from BSPSceneManager, ParticleManager, StaticGeometry and half a dozen other classes...)
-
- OGRE Retired Moderator
- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
Re: Ogre patterns / habits: why?
That's probably to support custom STL allocators. 
I am not sure though.

I am not sure though.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
-
- Gnoll
- Posts: 638
- Joined: Mon Dec 15, 2008 6:14 pm
- Location: Istanbul, Turkey
- x 42
Re: Ogre patterns / habits: why?
yup if yo try to use Ogre::vector<T> it will fail. its not a habit, when an allocator is used, you simply can not use that definition, instead you need to use ::type
Ismail TARIM
Ogitor - Ogre Scene Editor
WWW:http://www.ogitor.org
Repository: https://bitbucket.org/ogitor
Ogitor - Ogre Scene Editor
WWW:http://www.ogitor.org
Repository: https://bitbucket.org/ogitor
-
- OGRE Retired Team Member
- Posts: 3335
- Joined: Tue Jun 21, 2005 8:26 pm
- Location: Rochester, New York, US
- x 3
Re: Ogre patterns / habits: why?
Not just custom allocators but allocators which are integrated into the entire engine. This is so that custom allocators which are used within Ogre's core can be seamlessly used for all of the STL containers as well. So, when you compile with the NED pooling allocator for all of Ogre's main objects, it will automatically use the NED allocator for the STL contains as well. This could have also been done using macros but I think that is too error prone. Using some template magic like this you can force the compiler to do some decent error checking for you.
Game Development, Engine Development, Porting
http://www.darkwindmedia.com
http://www.darkwindmedia.com
-
- Halfling
- Posts: 77
- Joined: Tue Oct 24, 2006 1:52 am
- Location: Tropical North Queensland
Re: Ogre patterns / habits: why?
Um, what's a NED allocator?
-
- Gremlin
- Posts: 158
- Joined: Mon Mar 10, 2008 10:55 pm
- Location: Budapest, Hungary
- x 1
Re: Ogre patterns / habits: why?
Thank you for the answers! I decided to create a wiki article-section to this topic, probably wiki is the best place to collect these informations. I also marked this forum thread as related to the section. Please let me know if I did something wrong.
Link: http://www.ogre3d.org/wiki/index.php/Og ... ed_in_Ogre
Link: http://www.ogre3d.org/wiki/index.php/Og ... ed_in_Ogre
-
- OGRE Retired Team Member
- Posts: 3335
- Joined: Tue Jun 21, 2005 8:26 pm
- Location: Rochester, New York, US
- x 3
Re: Ogre patterns / habits: why?
It is the default memory allocator now for Ogre. When you use "new" and "delete" the system must allocate memory for you. The system will usually use its default, built in allocation algorithm to do this. Good allocation strategy isn't a solved issue (as in there is no "perfect" way) so there are actually other allocators besides your system default. They have pros and cons and try to meet different needs. NED is one of those alternative memory allocators.robagar wrote:Um, what's a NED allocator?
Game Development, Engine Development, Porting
http://www.darkwindmedia.com
http://www.darkwindmedia.com
-
- Greenskin
- Posts: 131
- Joined: Fri Aug 22, 2008 6:12 pm
Re: Ogre patterns / habits: why?
I think you can uncheck the "OGRE_CONFIG_CONTAINERS_USE_CUSTOM_ALLOCATOR" option in the CMAKE 'Advanced View' if you want to avoid having to redefine all of your vector definitions.
-Fish
-Fish