Ogre patterns / habits: why?

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
ShadeOgre
Gremlin
Posts: 158
Joined: Mon Mar 10, 2008 10:55 pm
Location: Budapest, Hungary
x 1

Ogre patterns / habits: why?

Post by ShadeOgre »

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?
User avatar
lingfors
Hobgoblin
Posts: 524
Joined: Mon Apr 02, 2007 12:18 am
Location: Sweden
x 78

Re: Ogre patterns / habits: why?

Post by lingfors »

Favor composition over inheritance.

(No, you don't need a "CGameLevel" class that inherits from BSPSceneManager, ParticleManager, StaticGeometry and half a dozen other classes...)
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Ogre patterns / habits: why?

Post by jacmoe »

That's probably to support custom STL allocators. :wink:
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.
User avatar
stealth977
Gnoll
Posts: 638
Joined: Mon Dec 15, 2008 6:14 pm
Location: Istanbul, Turkey
x 42

Re: Ogre patterns / habits: why?

Post by stealth977 »

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
User avatar
Praetor
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3335
Joined: Tue Jun 21, 2005 8:26 pm
Location: Rochester, New York, US
x 3
Contact:

Re: Ogre patterns / habits: why?

Post by Praetor »

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
User avatar
robagar
Halfling
Posts: 77
Joined: Tue Oct 24, 2006 1:52 am
Location: Tropical North Queensland

Re: Ogre patterns / habits: why?

Post by robagar »

Um, what's a NED allocator?
ShadeOgre
Gremlin
Posts: 158
Joined: Mon Mar 10, 2008 10:55 pm
Location: Budapest, Hungary
x 1

Re: Ogre patterns / habits: why?

Post by ShadeOgre »

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
User avatar
Praetor
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3335
Joined: Tue Jun 21, 2005 8:26 pm
Location: Rochester, New York, US
x 3
Contact:

Re: Ogre patterns / habits: why?

Post by Praetor »

robagar wrote:Um, what's a NED allocator?
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.
Game Development, Engine Development, Porting
http://www.darkwindmedia.com
User avatar
Fish
Greenskin
Posts: 131
Joined: Fri Aug 22, 2008 6:12 pm

Re: Ogre patterns / habits: why?

Post by Fish »

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
Post Reply