I have this library (one class with 700 methods) I want to wrap all the calls, so I can log the calls and do other stuff. Using emacs macros and stuff, I can create a proxy class which has the same signature, but each method calls a C macro which calls the original class method, and does other stuff. For example: void logfunc(char *func) const { OutputDebugStringA(func); } void logarg(int a) // overload for each type of parameter { CString x; x.Format(L"%d", a); OutputDebugString(x); } ULONG GetID(const CKSEntity &pEntity) const { return proxy1(GetID, pEntity); } // repeat for all 700 methods. // Repeat these macros for every count of arg between 0 and 24. #define proxy10(Func, Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8,Arg9,Arg10) \ ( log10(#Func, Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8,Arg9,Arg10), \ thePart.Func( Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8,Arg9,Arg10)) #define log10(Func, Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8,Arg9,Arg10) \ log9(Func, Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8,Arg9), logarg(Arg10) #define log0(Func ) \ logfunc(Func) I'm thinking there must be a better way. I'm thinking BOOST_PP library could abstract the above macros into something concise. However, the library is intimidating. There are lots of features, and I'm not clear on how I should get started. __________________________________________________________________ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/
Date: Thu, 21 Aug 2008 06:10:41 -0700 From: alanbaljeu@yahoo.com To: boost-users@lists.boost.org Subject: [Boost-users] Wrapping a library
I have this library (one class with 700 methods) I want to wrap all the calls, so I can log the calls and do other stuff. Using emacs macros and stuff, I can create a proxy class which has the same signature, but each method calls a C macro which calls the original class method, and does other stuff.
A class or a namespace?
I'm thinking there must be a better way. I'm thinking BOOST_PP library could abstract the above macros into something concise. However, the library is intimidating. There are lots of features, and I'm not clear on how I should get started.
For ad hoc code generation, I usually end up with awk and sed. I just did this wrapping thing with a java class definition ( no actual source code) and could pretty much use lynx to render the javadoc html, extract method signatures, and use awk to generate methods with sed and finally vi to touch stuff up. The generated class contained an instance of the original class that was simply called in each generated method after my custion code,if any, executed. I wasn't just interested in wrapping as I also made a fake version for unsupported operations. I'm not really sure you need a c++ library for this but I imagine there are cases where it would be worth the learning curve. Personally, I try to learn generic tools with wider applicability unless I need something more specialized. Mike Marchywka 586 Saint James Walk Marietta GA 30067-7165 415-264-8477 (w)<- use this 404-788-1216 (C)<- leave message 989-348-4796 (P)<- emergency only marchywka@hotmail.com Note: If I am asking for free stuff, I normally use for hobby/non-profit information but may use in investment forums, public and private. Please indicate any concerns if applicable. Note: Hotmail is possibly blocking my mom's entire ISP - try me on marchywka@yahoo.com if no reply here. Thanks. _________________________________________________________________ Talk to your Yahoo! Friends via Windows Live Messenger. Find out how. http://www.windowslive.com/explore/messenger?ocid=TXT_TAGLM_WL_messenger_yah...
Hi there! I just guess, are there any tutorials on Boost.Threads? As far as I remember, documentation for Boost.Threads lib in Boost 1.34 was much more readable. But now Synchronization page offers a great amount of concepts but not eatable step-by-step tutorials. Are there any resources for this? Or maybe it is time to create it... Sorry if my topic is silly.
participants (3)
-
Alan Baljeu
-
Mike Marchywka
-
Roma..