I have a container class that has a plain old datatype called DataStore. This data store will be passed to visitor.They share a single copy since any updated performed by the container are to be seen by visitor.
class xyz
{
//Plain Old Datatype
typedef struct DataStore
{
//add any new required data by any test here
bool _detectorConnectionStatus;
DataStore():_detectorConnectionStatus(false){}
}DataStore;
DataStore _dataStore;
typedef struct visitorData
{
DataStore& dataStore;
visitorData(DataStore data):dataStore(data){}
}visitorData;
//data to be sent to visitor
visitorData _visitorData;
};
xyz::xyz():_visitorData(_dataStore)
{
}
class IVisitor
{
private:
struct DataStore* dataStore;
public:
//get the data,no check for validity of data performed
void visit(struct DataStore& dataStore){};
//process the data
virtual void process() = 0;
};
The code compiles but is there a better/cleaner way to do it?
Aucun commentaire:
Enregistrer un commentaire