/*
Ousía
Copyright (C) 2014, 2015 Benjamin Paaßen, Andreas Stöckel
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
#include
#include
#include
#include "Domain.hpp"
#include "Document.hpp"
#include "Project.hpp"
#include "Typesystem.hpp"
namespace ousia {
Project::Project(Manager &mgr, Registry ®istry)
: Node(mgr),
registry(registry),
systemTypesystem(acquire(new SystemTypesystem(mgr))),
documents(this)
{
}
Rooted Project::parse(const std::string &path, const std::string mimetype,
const std::string rel,
const RttiSet &supportedTypes, Logger &logger)
{
ParserScope scope;
ParserContext context(this, scope, logger);
return resourceManager.link(registry, context, path, mimetype, rel,
supportedTypes);
}
Rooted Project::link(ParserContext &ctx, const std::string &path,
const std::string mimetype, const std::string rel,
const RttiSet &supportedTypes)
{
return resourceManager.link(registry, ctx, path, mimetype, rel,
supportedTypes);
}
Rooted Project::include(ParserContext &ctx, const std::string &path,
const std::string mimetype, const std::string rel,
const RttiSet &supportedTypes)
{
return resourceManager.include(registry, ctx, path, mimetype, rel,
supportedTypes);
}
SourceContextCallback Project::getSourceContextCallback()
{
return [&](const SourceLocation &location) {
return resourceManager.readContext(location);
};
}
bool Project::doValidate(Logger &logger) const
{
return continueValidation(documents, logger);
}
Rooted Project::getSystemTypesystem()
{
return systemTypesystem;
}
Rooted Project::createTypesystem(const std::string &name)
{
return Rooted{
new Typesystem{getManager(), systemTypesystem, name}};
}
Rooted Project::createDocument(const std::string &name)
{
Rooted document{new Document(getManager(), name)};
addDocument(document);
return document;
}
Rooted Project::createDomain(const std::string &name)
{
return Rooted{new Domain(getManager(), systemTypesystem, name)};
}
void Project::addDocument(Handle document)
{
invalidate();
documents.push_back(document);
}
const NodeVector &Project::getDocuments() const { return documents; }
namespace RttiTypes {
const Rtti Project = RttiBuilder("Project")
.parent(&Node)
.composedOf(&Document)
.composedOf(&SystemTypesystem);
}
}