I have a cc file which includes a header file(txTask.h) which inturn includes again a header file(DDMSDBAMgr.h)
which again includes the header file(txtask.h) from where it is called.So forward declarations are used.
But this is not accepted by g++ compiler.
could any one please throw some lights on this issue and provide a good solution?
here are the details.
txTask.h
-------------
#ifndef TXTASK_H
#define TXTASK_H
#include <DDMSDBAMgr.h>
class DDMSDBAMgrStats;
class TxMgrTask
{
public:
static int value;
static RWCString configFile;
static RWCString helpFile;
static RWCString configSection;
static RWCString digilatorFile;
static RWCString neHandler;
static RWCString nePath;
virtual void getDBAStats( DDMSDBAMgrStats &stats )
{
dbaManager->getStats( stats );
}
protected:
DDMSDBAgentManager<DDMSUsn, unsigned long> *dbaManager;
};
#endif //TXTASK_H
DDMSDBAMgr.h
---------------
#ifndef DDMSDBAMGR_H
#define DDMSDBAMGR_H
#include <txTask.h>
// forward declarations
class TxMgrTask;
class DDMSDBAMgrStats
{
public:
DDMSDBAMgrStats(){}
virtual ~DDMSDBAMgrStats(){}
long minDBAs;
long maxDBAs;
long registeredDBAs;
long noFreeAgents;
long deferredTxs;
};
template <class TxIdType, class ClientIdType> class DDMSDBAgentManager
{
public:
DDMSDBAgentManager( TxMgrTask *txmgr);
void show(static RWCString );
virtual void startMinimumDBAgents();
protected:
TxMgrTask *txTask;
}
template< class TxIdType, class ClientIdType>
DDMSDBAgentManager<TxIdType,ClientIdType>:
DMSDBAgentManager( TxMgrTask *txmgr )
{
show(TxMgrTask::configFile);
txTask = txmgr;
}
virtual void DDMSDBAgentManager<TxIdType, ClientIdType>::startMinimumDBAgents()
{
if ( !TxMgrTask::value )
{
}
}
txTask.cc
--------
#include<txTask.h>
Now when i compiled txTask.cc errors were thrown as follows
n file included from ./txTask.h:10,
from txTask.C:18:
./DDMSDBAMgr.h: In constructor `DDMSDBAgentManager<TxIdType, ClientIdType>:
DMSDBAgentManager(TxMgrTask*)':
./DDMSDBAMgr.h: error: incomplete type `TxMgrTask' used in nested name specifier
DDMSDBAMgr.h: In member function `virtual void DDMSDBAgentManager<TxIdType, ClientIdType>::startMinimumDBAgents()':
./DDMSDBAMgr.h: error: incomplete type `TxMgrTask' used in nested name specifier
There is a cyclic dependency between these two header files but i dont know how to resolve it.
The header files itself were not included properly while compiling cc file.
could any one please throw some lights on this issue and provide a good solution?
Regards
Mani