Boost logo

Boost Users :

From: Alan Baljeu (alanbaljeu_at_[hidden])
Date: 2008-08-21 09:10:41


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/


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net