Re: [Doxygen-users] documenting multiple methods defined by a single macro - help
Brought to you by:
dimitri
From: Manfred D. <man...@me...> - 2005-11-30 01:57:49
|
Sven Bauhan wrote: > As I see, you use the boost library, so your compiler should be able to handle > it and the STL. > That's right - and indeed the compiler does handle the Boost code, and the STL. > On Tuesday 29 November 2005 09:40, Manfred Doudar wrote: > >>#define RESHAPE_DIM_MAX 10 >> > > this kind of constant definition is obsolete. No, it's not. -It defines in one place in the header, the level of macro recursion, upto one less than the array rank I want to support. Should one day we want to alter this, we only need modify the value held at RESHAPE_DIM_MAX > > >>#define RESHAPE(z, N, _) \ >> \ >> static void reshape(const blitz::Array<T, BOOST_PP_INC(N)>& btz, \ >> MoeArray<T>& data \ >> ) \ >> throw(); \ >> \ >> static boost::shared_ptr<MoeArray<T> > \ >> reshape(const blitz::Array<T, BOOST_PP_INC(N)>& btz) throw(); \ >> /**/ >> >> >> BOOST_PP_REPEAT(BOOST_PP_INC(RESHAPE_DIM_MAX), RESHAPE, _) >> >>#undef RESHAPE >> > > this is also obsolete. use typedef instead. Not quite. These are declarations, and the definitions are similarly written. -The Boost PP library is an ideal candidate for this kind of code. The point of the above code is to cut down on boiler-plate code, so I can reduce maintenence of the code, and cut down on transcription errors, and copy/paste ... - that is I don't want to be writing the following explicitly in code: static void reshape(const blitz::Array<T, 1>& btz, MoeArray<T>& data ) throw(); static void reshape(const blitz::Array<T, 2>& btz, MoeArray<T>& data ) throw(); static void reshape(const blitz::Array<T, 3>& btz, MoeArray<T>& data ) throw(); ... static void reshape(const blitz::Array<T, 11>& btz, MoeArray<T>& data ) throw(); ... and ... static boost::shared_ptr<MoeArray<T> > reshape(const blitz::Array<T, 1>& btz) throw(); static boost::shared_ptr<MoeArray<T> > reshape(const blitz::Array<T, 2>& btz) throw(); static boost::shared_ptr<MoeArray<T> > reshape(const blitz::Array<T, 3>& btz) throw(); ... static boost::shared_ptr<MoeArray<T> > reshape(const blitz::Array<T, 11>& btz) throw(); ... and then imagine the amount of repition and boiler-plate code you'll have to duplicate in the definitions, not to mention maintence of such code, and how error prone and messy it would be. With the macros, the code is as close to readable as you're going to get; and sure you *could* typedef the boost::shared_ptr<MoeArray<T> > but you're not going to win much. Cheers, -- Manfred Doudar MetOcean Engineers www.metoceanengineers.com |