get/set Properties for Object, without known the Methods.

Get answers to all your basic programming questions. No Ogre questions, please!
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:

Post by Praetor »

Yeah ^ is a reference-counted pointer. Just syntactic sugar on a built-in smart pointer implementation.

Implementations for delegates do exist. I have one in the odyssey library. Boost's signals and slots can give a very generic mechanism similar to delegates, and boost's function and bind libraries can be used as well (and of course there's even more available). In C++, you try to do things with libraries instead of language features if you can.
User avatar
Caius
Halfling
Posts: 52
Joined: Fri Oct 06, 2006 9:00 pm

Post by Caius »

yep, I'll have a look on boost,
here is the article I've found on delegate, it looks really well though
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:

Post by Praetor »

That's a popular one, because it really is fast. Very thorough description and good read if you want to dig deep down into the implementation details of some of C++'s language features. I prefer boost largely because it is more generic and is generally easier to use. The one complaint being its size, and given the incredible interconnectedness of it, it is sometimes difficult to untangle one library from another. The first time you bring boost in as a dependency can be painful, but once you get used to it and have it available it definitely repays you for your efforts.
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Post by Vectrex »

Caius wrote:A reflection system tool that would launch on prebuild event, look into the project directory, parse each .h file and add/update string-based class information

It's damn possible!
The difference between .Net and c++, is multiple inheritance capabilities, which means reflection information should be in a form of a hierarchic three nodes... it's duable !
If this does not exist, i'm gonna work on it :D
yeah that's what the links I posted do! They have a utility to parse all the source and another to do simple reflection (presumably with the parsed info but I haven't tested it yet). It looks very neat and it's LGPL
User avatar
Caius
Halfling
Posts: 52
Joined: Fri Oct 06, 2006 9:00 pm

Post by Caius »

yeah that's what the links I posted do! They have a utility to parse all the source and another to do simple reflection (presumably with the parsed info but I haven't tested it yet). It looks very neat and it's LGPL
so the wheel has already been invented eh
what the hell am I gonna do this week end now =)
The first time you bring boost in as a dependency can be painful, but once you get used to it and have it available it definitely repays you for your efforts.
ok i know, i'll be compiling boost :lol:
yeah I compiled it once long time ago, it was painful indeed, Jbam and all that mess yeah I remember =)
Is cross platform/compiler compatibility 100% guarantied? I guess it is
That's a popular one, because it really is fast. Very thorough description and good read if you want to dig deep down into the implementation details of some of C++'s language features. I prefer boost largely because it is more generic and is generally easier to use.
go back to the article, at the bottom:
Natural syntax and Boost compatibility (new to 1.4)

Jody Hagins has enhanced the FastDelegateN classes to allow the same attractive syntax provided by recent versions of Boost.Function and Boost.Signal.
you might want to use FastDelegate now =)
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Post by Vectrex »

Caius wrote: so the wheel has already been invented eh
what the hell am I gonna do this week end now =)
get it actually working and post a demo using ogre :D
User avatar
FrameFever
Platinum Sponsor
Platinum Sponsor
Posts: 414
Joined: Fri Apr 27, 2007 10:05 am

Post by FrameFever »

why are you compiling it by yourself?


http://www.boost-consulting.com/products/free

you can get it prebuild like OGRE
User avatar
Project5
Goblin
Posts: 245
Joined: Mon Nov 22, 2004 11:56 pm
Location: New York, NY, USA

Post by Project5 »

Two other approaches to consider are Luabind's and FUBI's, the former if you want manual control of what gets bound, and the latter if you'd rather walk the exports table for your platform than parse C++ code for the auto approach.

I'm using the former since it gives more control (and I can tag attributes), but having it done automatically must be nice when you're refactoring :-)

--Ben
User avatar
Caius
Halfling
Posts: 52
Joined: Fri Oct 06, 2006 9:00 pm

Post by Caius »

get it actually working and post a demo using ogre :D
i'll give a shot
why are you compiling it by yourself?
thanks for that link!
Two other approaches to consider are Luabind's and FUBI's, the former if you want manual control of what gets bound, and the latter if you'd rather walk the exports table for your platform than parse C++ code for the auto approach.
yeah you're right, a manual approach is better, especially for a game.
I don't know if that reflex lib scans every classes of the project... What I was thinking to do, would have been manual selection of classes just by inheriting from an abstract class that would be called something like "reflectable", so the parser would look for those classes only also I was thinking, the public interface only is necessary to bind right?

The idea of reflection, is different to scripts engine's purpose, the idea is to be able to query the nature of an object, on the fly, used for example in an AI system, where an entity could query in a generic way what's around it. and act depending the environment.
User avatar
FrameFever
Platinum Sponsor
Platinum Sponsor
Posts: 414
Joined: Fri Apr 27, 2007 10:05 am

Post by FrameFever »

damn, nobody is reading my post above, you don't need a parser and all this shit. metadata is nice, but makes you programm big, Like Stroustrup said.

you can do a nice property system without this shit.

think about, when you devloping an editor, with plugin functionality.
than these people need also the parser, and all these crap.

this is what you need, and nothing more
http://www.delta3d.org/article.php?stor ... =tutorials
User avatar
Caius
Halfling
Posts: 52
Joined: Fri Oct 06, 2006 9:00 pm

Post by Caius »

It is a great pattern indeed, thanks for the link =)
As Stroustrup said, it does take a lot of memory.
but he said it thinking of the way microsoft does it (every classes of every assembly)
What I have in mind is actually like that tutorial, but with a tool that binds it for you, using hard coded constant strings, only for the classes you need, and only the public interface described.
It would be a way to transpose directly objects relationships of the code to the virtual world. it would have query functions that would allow to do things like "does this object "pizza" is a food?" you see what I mean?
and since that tutorial has a great pattern, it's a great starting point, thanks =)
Post Reply