Author |
Topic |
|
dreijer
Ketchup Master
62 Posts |
Posted - Mar 14 2008 : 10:55:11 AM
|
I have implemented a singleton class which is accessed through a method named Instance(). For example:
SomeSingletonClass::Instance().DoSomething(); For convenience, I have written the following macro:
#define g_singletonClass SomeSingletonClass::Instance() This allows me to access the singleton simply by writing:
g_singletonClass.DoSomething(); However, VA seems to be having some problems parsing the macro. At least it doesn't show a list box with methods once I type . after g_singletonClass. If I don't use the macro, everything works fine. |
|
rhummer
Tomato Guru
USA
527 Posts |
|
dreijer
Ketchup Master
62 Posts |
Posted - Mar 14 2008 : 11:56:56 AM
|
Oh, I'm probably just blind then. Thanks |
|
|
feline
Whole Tomato Software
United Kingdom
19020 Posts |
Posted - Mar 15 2008 : 12:00:51 PM
|
You could try editing VA's stdafx.h file, and adding:
#define g_singletonClass SomeSingletonClass::Instance()
I have not tried this here, so I am not sure if it will work or not, but it might.
Editing VA's "StdAfx.h" file is explained in this FAQ entry:
http://docs.wholetomato.com?W302
This file is used to help VA's parser with difficult code, and can be used to work around odd effects. After modifying this file you need to rebuild the VA symbol database for the changes to take effect:
VA Options -> Performance -> General -> Rebuild symbol databases |
zen is the art of being at one with the two'ness |
|
|
accord
Whole Tomato Software
United Kingdom
3287 Posts |
Posted - Mar 22 2008 : 6:23:20 PM
|
When I want to force VAX to use a type I am using an ugly but working trick:
#define g_singletonClass dynamic_cast<cSingleton*, x>
Certainly you have to replace cSingleton with the type of your current class (the returning type of Instance()) Unfortunately you have to do it for all your singleton #define, but you don't use a lot of singletons, do you? |
|
|
dreijer
Ketchup Master
62 Posts |
Posted - Mar 22 2008 : 6:29:38 PM
|
Thanks for the trick, accord. Unfortunately, I'm not interested in causing a run-time overhead by using RTTI just to make VA work. Then I'd rather just work around it
Thanks for the tip though! |
|
|
accord
Whole Tomato Software
United Kingdom
3287 Posts |
Posted - Mar 22 2008 : 6:41:46 PM
|
Sorry, I was ambiguous. You should place this piece of code into VAX's own stdafx.h This file is only parsed by VAX, and certainly you don't have to change your original #define.
Editing VA's "StdAfx.h" file is explained in this FAQ entry:
http://docs.wholetomato.com?W302
So, this won't affect your run-time performance, because the compiler do not see this file.
("x" is only used for valid syntax, VAX will not miss this symbol.) |
Edited by - accord on Mar 22 2008 7:02:24 PM |
|
|
dreijer
Ketchup Master
62 Posts |
Posted - Mar 23 2008 : 04:35:56 AM
|
Oh, much better then. Cheers! |
|
|
|
Topic |
|