Mercurial > repos > IBDev-IBBoard.WarFoundry.API
diff api/Objects/WarFoundryStagedLoadingObject.cs @ 8:613bc5eaac59
Re #9 - Make WarFoundry loading granular
* Remove specific staged loading classes
* Rework category loading for GameSystem and Race to make it use AddCategory(Category) method
* Promote staged loading from Native Factory to all Factories level
* Refactor XML Factory to use smaller methods
Also removed some commented code that isn't used any more
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 04 Jan 2009 19:24:13 +0000 |
parents | |
children | 306558904c2a |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api/Objects/WarFoundryStagedLoadingObject.cs Sun Jan 04 19:24:13 2009 +0000 @@ -0,0 +1,79 @@ +// WarFoundryStagedLoadingObject.cs is a part of the IBBoard.WarFoundry.API library (referred to from here as "this program") +// +// Copyright (C) 2009 IBBoard +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// + +using System; +using System.IO; +using IBBoard.WarFoundry.API.Factories; + +namespace IBBoard.WarFoundry.API.Objects +{ + public class WarFoundryStagedLoadingObject : WarFoundryObject, IWarFoundryStagedLoadObject + { + private bool isFullyLoaded; + private IWarFoundryFactory creatingFactory; + private FileInfo sourceFile; + + protected WarFoundryStagedLoadingObject(IWarFoundryFactory creatingFactory) : this (null, creatingFactory) + { + } + + protected WarFoundryStagedLoadingObject(string objName, IWarFoundryFactory creatingFactory) : this(null, objName, creatingFactory) + { + } + + protected WarFoundryStagedLoadingObject(string objId, string objName, IWarFoundryFactory creatingFactory) : base(objId, objName) + { + this.creatingFactory = creatingFactory; + isFullyLoaded = false; + } + + public FileInfo SourceFile + { + get { return sourceFile; } + set { sourceFile = value; } + } + + public void EnsureFullyLoaded () + { + if (!IsFullyLoaded) + { + if (Factory == null) + { + throw new InvalidOperationException("No factory set for partially loaded object with ID "+ID); + } + + Factory.CompleteLoading(this); + } + } + + public IWarFoundryFactory Factory + { + get { return creatingFactory; } + } + + public bool IsFullyLoaded + { + get { return isFullyLoaded; } + } + + public void SetAsFullyLoaded() + { + isFullyLoaded = true; + } + } +}