From a48556c1c5c01892cf493cd3eb4ff969a2f548fd Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 9 Jul 2012 15:34:11 -0600 Subject: Simple saving/loading - consider this temporary. It should be a little more compact, and have more header info so we can reconstruct the entire object from the file, right now you have to know the size in bits. --- src/phenotypebinary.cpp | 10 ++++++++++ src/phenotypebinary.h | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/src/phenotypebinary.cpp b/src/phenotypebinary.cpp index 68f9ebf..0d32c9f 100644 --- a/src/phenotypebinary.cpp +++ b/src/phenotypebinary.cpp @@ -133,3 +133,13 @@ void Genetic::PhenotypeBinary::extractBits( uint64_t &rTarget, int iStart, } } +void Genetic::PhenotypeBinary::write( Bu::Stream &rStream ) +{ + rStream.write( aGenes, sizeof(uint_fast32_t)*iWords ); +} + +void Genetic::PhenotypeBinary::read( Bu::Stream &rStream ) +{ + rStream.read( aGenes, sizeof(uint_fast32_t)*iWords ); +} + diff --git a/src/phenotypebinary.h b/src/phenotypebinary.h index cbae392..f312187 100644 --- a/src/phenotypebinary.h +++ b/src/phenotypebinary.h @@ -3,6 +3,8 @@ #include "genetic/phenotype.h" +#include + namespace Genetic { class PhenotypeBinary : public Phenotype @@ -22,6 +24,9 @@ namespace Genetic void extractBits( uint32_t &rTarget, int iStart, int iBits ); void extractBits( uint64_t &rTarget, int iStart, int iBits ); + void write( Bu::Stream &rStream ); + void read( Bu::Stream &rStream ); + private: int iSize; int iWords; -- cgit v1.2.3