design pattern/ class relationship

N

nin234ATIyahoo.com

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top