diff options
| author | Joerg Bornemann <joerg.bornemann@digia.com> | 2013-08-02 09:37:45 +0200 |
|---|---|---|
| committer | Christian Kandeler <christian.kandeler@digia.com> | 2013-08-02 10:57:40 +0200 |
| commit | b47da5be0461aeaf54b16025430bf604938dd6fb (patch) | |
| tree | 42ebce6104dee23183ae7628b4f4567adf374ea7 /src/lib/buildgraph | |
| parent | 7893c2b986c8f767e2cc747e98efcc6b48aec05f (diff) | |
| download | qbs-b47da5be0461aeaf54b16025430bf604938dd6fb.tar.gz | |
unmystify the serialization of artifacts
Move the serialization responsibility to Artifact itself.
Do not store parents. They are merely backpointers that can be restored
after loading.
Change-Id: I82b07f6ac07bd74b638985d86635894330743558
Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
Diffstat (limited to 'src/lib/buildgraph')
| -rw-r--r-- | src/lib/buildgraph/artifact.cpp | 10 | ||||
| -rw-r--r-- | src/lib/buildgraph/productbuilddata.cpp | 58 |
2 files changed, 12 insertions, 56 deletions
diff --git a/src/lib/buildgraph/artifact.cpp b/src/lib/buildgraph/artifact.cpp index 28fd44dd9..9583f5f02 100644 --- a/src/lib/buildgraph/artifact.cpp +++ b/src/lib/buildgraph/artifact.cpp @@ -76,6 +76,13 @@ void Artifact::initialize() void Artifact::load(PersistentPool &pool) { FileResourceBase::load(pool); + pool.loadContainer(children); + + // restore parents of the loaded children + for (ArtifactList::const_iterator it = children.constBegin(); it != children.constEnd(); ++it) + (*it)->parents.insert(this); + + pool.loadContainer(fileDependencies); properties = pool.idLoadS<PropertyMapInternal>(); transformer = pool.idLoadS<Transformer>(); unsigned char c; @@ -90,6 +97,9 @@ void Artifact::load(PersistentPool &pool) void Artifact::store(PersistentPool &pool) const { FileResourceBase::store(pool); + // Do not store parents to avoid recursion. + pool.storeContainer(children); + pool.storeContainer(fileDependencies); pool.store(properties); pool.store(transformer); pool.stream() diff --git a/src/lib/buildgraph/productbuilddata.cpp b/src/lib/buildgraph/productbuilddata.cpp index 50f53c3d7..a8d0841a8 100644 --- a/src/lib/buildgraph/productbuilddata.cpp +++ b/src/lib/buildgraph/productbuilddata.cpp @@ -46,67 +46,13 @@ ProductBuildData::~ProductBuildData() void ProductBuildData::load(PersistentPool &pool) { - // artifacts - int i; - pool.stream() >> i; - artifacts.clear(); - for (; --i >= 0;) { - Artifact *artifact = pool.idLoad<Artifact>(); - artifacts.insert(artifact); - } - - // edges - for (i = artifacts.count(); --i >= 0;) { - Artifact *artifact = pool.idLoad<Artifact>(); - int k; - pool.stream() >> k; - artifact->parents.clear(); - artifact->parents.reserve(k); - for (; --k >= 0;) - artifact->parents.insert(pool.idLoad<Artifact>()); - - pool.stream() >> k; - artifact->children.clear(); - artifact->children.reserve(k); - for (; --k >= 0;) - artifact->children.insert(pool.idLoad<Artifact>()); - - pool.stream() >> k; - artifact->fileDependencies.clear(); - artifact->fileDependencies.reserve(k); - for (; --k >= 0;) - artifact->fileDependencies.insert(pool.idLoad<FileDependency>()); - } - - // other data + pool.loadContainer(artifacts); pool.loadContainer(targetArtifacts); } void ProductBuildData::store(PersistentPool &pool) const { - pool.stream() << artifacts.count(); - - //artifacts - for (ArtifactList::const_iterator i = artifacts.constBegin(); i != artifacts.constEnd(); ++i) - pool.store(*i); - - // edges - for (ArtifactList::const_iterator i = artifacts.constBegin(); i != artifacts.constEnd(); ++i) { - Artifact * artifact = *i; - pool.store(artifact); - - pool.stream() << artifact->parents.count(); - foreach (Artifact * n, artifact->parents) - pool.store(n); - pool.stream() << artifact->children.count(); - foreach (Artifact * n, artifact->children) - pool.store(n); - pool.stream() << artifact->fileDependencies.count(); - foreach (FileDependency *dependency, artifact->fileDependencies) - pool.store(dependency); - } - - // other data + pool.storeContainer(artifacts); pool.storeContainer(targetArtifacts); } |
