I am wondering what is a good design pattern in terms of C++ class
relationship for the problem I am trying to solve.
template<class DbKey, class DbVal, class DbTag> class srvBerkDB :
public Db
//class for reading and writing to Berkeley DB
{
VecB KeyPosn;
DbTag tag;
//Only a snippet of the class is shown here.
public:
srvBerkDB (std::string& oDBFil, std::string& oDBTabl, ...)
{
parse (std::string& oDBFil, ????srvBerkDB&) //friend
class or function ?????
}
//DB access functions like put() , get() etc
};
srvBerkDB class uses parse () which in turn uses Xerces-C XML parser to
parse a metadata file and fill in the private variables of srvBerkDB.
I want to reuse much of the parser code in other contexts.
I want to define a parser class for dealing with all the parsing.
What is the best way to define this relationship from C++ point of
view. Should the parser be defined as a friend class of srvBerkDB, or
just define a member function and pass all the private variables by
reference to the parse function.
Also I am thinking of making the parse member function static as I
don't see any need for instantiating the parser class