I am designing a project which has class Encoder having function void write(int p_val) which writes encoded val into std::ostream data-member and class Decoderwhich has void read(int& p_val) from std::istream data-member and overwrites p_val reference. So in order to check whether Encode/Decode process causes data loss or not I want to design another class which will use <boost/iostreams/copy.hpp> to copy std::ostream object's content into std::istream object.
class Encoder{
public:
void write(int p_val){
...//encodes then writes p_val into m_out
}
...
private:
std::ostream& m_out;
...
}
class Decoder{
public:
void read(int& p_val){
...//reads from m_in decodes then overwrites p_val
}
...
private:
std::istream& m_in;
...
}
Supposing that the design of both classes we can't change, which is the optimal solution to design new class Checker which will check the data-loss in encode/decode process? I found that <boost/iostreams/copy.hpp> gives a way to copy std::ostream into std::istream but I think it isn't the best deal, also having poor skills of multithreading I try to aviod design Checker via multithreading.
Aucun commentaire:
Enregistrer un commentaire