c++ - #define include alternative for hardware cursor? -


this program i'm working on has 3d (hardware/non-hardware) cursor option i'm trying make config option for. right it's set using preprocessor #define macro sets types of cursortype, cursorname, , cursordisplay. currently, way can toggle on or off 3d cursor comment or uncomment #define use_3d_cursor line (which bad).

#define use_3d_cursor #if defined (use_3d_cursor)   #include <osgdb/readfile>   #define cursortype osg::image *   #define cursorname const stringobj&    #define cursordisplay osg::texture * #elif defined (_msc_ver)   #include <windows.h>   #include <osgviewer/api/win32/graphicswindowwin32>   #define slash "\\"   #define cursortype hcursor   #define cursorname lptstr   #define cursordisplay hmodule #elif defined(__linux__)   //... 

so said before, i'd change config file option can set before runtime. but, i'm not sure best way go doing this. should use templated functions maybe?

that's not possible definition, since #define , #include statements evaluated during compile time.

you'll need kind of os abstraction layer this, instead of #define cursortype etc.

in other words: define abstract interfaces describe cursor specific behaviors, , have os specific implementations these. use factory pattern instantiate correct implementations @ compile time, use interface configure specific behavior , capabilities , properties @ runtime.

i'd recommend reading factory, facade , decorator patterns. imho whole thing bit complex provide code sample here (may i'm lazy now). if s.o. else gets mean, , willing give one, or has source such abstraction layer, feel free!


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -