Re: [Maya2osg-users] Config Implementation
Status: Alpha
Brought to you by:
jtaibo
From: Javier T. <jav...@gm...> - 2011-05-31 16:29:13
|
I absolutely agree with everything! On Tue, May 31, 2011 at 6:16 PM, Peter Wrobel <pp...@cg...> wrote: > Hi, > > I added new flags, and think that the Config Class should be refactored, > as we have to change a lot at lot of places. > Adding attributes getter and setter to Config.h, > Initializing the attributes in Config.cpp > adding lot of hard to read code to osg write for parsing > Morover, when Config.h has changed, this means recompile of nearly all > sources, as its included nearly everywhere. > > Here is my suggestion of improvement, and would like to know if this > would be O.K. for you ( Javier and all ). > > instead of e.g. > > Config::Instance -> getComputeShadow ; > Config::Instance -> getBool( "ComputeShadow" ) ; > > this would access a map< std::string , bool > and deliver the Value > > same maps would exist for other types, enums would be a map < > std::string , std::string > and the function getEnum would convert it > back to the proper enum. > > best thing would be even typeless, e.g. Config::Instance -> get( > "ComputeShadow" ), but I would not know how to implement this, > overwriting this function would not work, as input is always a string, > and only returntype would be different. > > So back to getType( std::string ). > The Maps would be declared in Config.h, defined and populated with > default values in Config.cpp. > When an export command is invoked, osgwriter searches each map for the > argument string ( key ), and sets the second pair value to the next > argument of the argumant list. > > Advantages: > We would not need to change Config.h ( seldom at least ) so no need for > recompile > Defining default arguments would be one line, adding argument as key and > default value as 2nd pair value. > There would be one single short loop as argument parser, which just > searches arguments ( keys ) in each map., and replaces the value. > > Drawbacks: > Accessing Config has to be changed in all the files that query the config. > > Javier, I would like to try this, if this is O.K. for you, and any > critics or comments are welcome. > > Cheers, PP > > > > ------------------------------------------------------------------------------ > Simplify data backup and recovery for your virtual environment with vRanger. > Installation's a snap, and flexible recovery options mean your data is safe, > secure and there when you need it. Data protection magic? > Nope - It's vRanger. Get your free trial download today. > http://p.sf.net/sfu/quest-sfdev2dev > _______________________________________________ > Maya2osg-users mailing list > May...@li... > https://lists.sourceforge.net/lists/listinfo/maya2osg-users > -- Javier Taibo |