wintermute-devel team mailing list archive
-
wintermute-devel team
-
Mailing list archive
-
Message #00096
[Merge] lp:~jackyalcine/wintermute/database into lp:wintermute
Jacky Alciné has proposed merging lp:~jackyalcine/wintermute/database into lp:wintermute.
Requested reviews:
Adrian Borucki (gentoolx): merge, packaging
For more details, see:
https://code.launchpad.net/~jackyalcine/wintermute/database/+merge/56176
*** A lot is in this little bad boy; it requires libjson.a (in lp:~wintermute-devel/wintermute/json) and needs the Boost Filesystem library >= 1.4.0
*** removed Glib dependencies.
--
https://code.launchpad.net/~jackyalcine/wintermute/database/+merge/56176
Your team Wintermute Developers is subscribed to branch lp:wintermute.
=== added file '.bzrignore'
--- .bzrignore 1970-01-01 00:00:00 +0000
+++ .bzrignore 2011-04-04 14:29:41 +0000
@@ -0,0 +1,5 @@
+nbproject
+wintermute-database-cli/nbproject
+wintermute-database/nbproject
+dist
+build
=== added directory 'bin'
=== added file 'bin/onto.xml'
--- bin/onto.xml 1970-01-01 00:00:00 +0000
+++ bin/onto.xml 2011-04-04 14:29:41 +0000
@@ -0,0 +1,17 @@
+<!--
+ onto.xml - Wintermute's Ontology
+
+ Represents the notation that Wintermute'll use to
+ render information about anything. Hopefully, this will
+ be in a very friendly format. Entries in the ontology
+ are issued specific IDs, or ontoids. Quick lookups can
+ be done by using xPaths (ie: Ontology/Entry[ontoid='4546543545']).
+
+ Default Attributes:
+
+ 'isA' : ontoid to the object that inherits from (ie: Man -> Human -> Mammal)
+-->
+<Ontology>
+ <Entry ontoid="0x023490349a0d35fe0fefd">
+ </Entry>
+<Ontology>
=== added directory 'debian'
=== added directory 'wintermute-database'
=== added directory 'wintermute-database-cli'
=== added file 'wintermute-database-cli/.dep.inc'
--- wintermute-database-cli/.dep.inc 1970-01-01 00:00:00 +0000
+++ wintermute-database-cli/.dep.inc 2011-04-04 14:29:41 +0000
@@ -0,0 +1,5 @@
+# This code depends on make tool being used
+DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES}))
+ifneq (${DEPFILES},)
+include ${DEPFILES}
+endif
=== added directory 'wintermute-database-cli/debian'
=== added directory 'wintermute-database-cli/src'
=== added file 'wintermute-database-cli/src/main.cpp'
--- wintermute-database-cli/src/main.cpp 1970-01-01 00:00:00 +0000
+++ wintermute-database-cli/src/main.cpp 2011-04-04 14:29:41 +0000
@@ -0,0 +1,27 @@
+/*
+ * Author: $NAME <$EMAIL>
+ *
+ * Copyright 2011 $NAME
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+int main(int argc, char** argv) {
+
+ return 0;
+}
+
=== added file 'wintermute-database/.dep.inc'
--- wintermute-database/.dep.inc 1970-01-01 00:00:00 +0000
+++ wintermute-database/.dep.inc 2011-04-04 14:29:41 +0000
@@ -0,0 +1,5 @@
+# This code depends on make tool being used
+DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES}))
+ifneq (${DEPFILES},)
+include ${DEPFILES}
+endif
=== added file 'wintermute-database/AUTHORS'
--- wintermute-database/AUTHORS 1970-01-01 00:00:00 +0000
+++ wintermute-database/AUTHORS 2011-04-04 14:29:41 +0000
@@ -0,0 +1,1 @@
+Jacky Alcine <jackyalcine@xxxxxxxxx>
\ No newline at end of file
=== added file 'wintermute-database/HACKING'
--- wintermute-database/HACKING 1970-01-01 00:00:00 +0000
+++ wintermute-database/HACKING 2011-04-04 14:29:41 +0000
@@ -0,0 +1,1 @@
+Nothing to hack; yet >:}
\ No newline at end of file
=== added file 'wintermute-database/README'
--- wintermute-database/README 1970-01-01 00:00:00 +0000
+++ wintermute-database/README 2011-04-04 14:29:41 +0000
@@ -0,0 +1,25 @@
+ *
+ * Author: Jacky Alcine
+ *
+ * Copyright 2011 the S.I.I
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ *
+
+This module is the core of the data engines of Wintermute. In this module, the
+essence of ontology structures are found, as well as Wintermute's ability to store
+and retrieve data via a flexible data framework.
=== added file 'wintermute-database/TODO'
--- wintermute-database/TODO 1970-01-01 00:00:00 +0000
+++ wintermute-database/TODO 2011-04-04 14:29:41 +0000
@@ -0,0 +1,2 @@
+** Add more data serialization handlers
+ - Perhaps to MySQL, JSON, XML
=== added directory 'wintermute-database/debian'
=== added directory 'wintermute-database/src'
=== added directory 'wintermute-database/src/bin'
=== added file 'wintermute-database/src/except.cpp'
--- wintermute-database/src/except.cpp 1970-01-01 00:00:00 +0000
+++ wintermute-database/src/except.cpp 2011-04-04 14:29:41 +0000
@@ -0,0 +1,23 @@
+/*
+ * except.cpp
+ * This file is part of wintermute-database
+ *
+ * Copyright (C) 2011 - Wintermute Developers
+ *
+ * wintermute-database 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * wintermute-database 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 wintermute-database; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#include "except.hpp"
=== added file 'wintermute-database/src/except.hpp'
--- wintermute-database/src/except.hpp 1970-01-01 00:00:00 +0000
+++ wintermute-database/src/except.hpp 2011-04-04 14:29:41 +0000
@@ -0,0 +1,37 @@
+/*
+ * except.hpp
+ * This file is part of wintermute-database
+ *
+ * Copyright (C) 2011 - Wintermute Developers
+ *
+ * wintermute-database 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * wintermute-database 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 wintermute-database; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+namespace Wintermute {
+ namespace Data {
+ namespace Exceptions {
+ class Exception;
+ class InvalidOperationException;
+ class NotFoundException;
+
+ class Exception {};
+
+ class InvalidOperationException : public Exception {};
+
+ class NotFoundException : public Exception {};
+ }
+ }
+}
=== added file 'wintermute-database/src/linguistics.cpp'
--- wintermute-database/src/linguistics.cpp 1970-01-01 00:00:00 +0000
+++ wintermute-database/src/linguistics.cpp 2011-04-04 14:29:41 +0000
@@ -0,0 +1,623 @@
+/**
+ * @author Jacky Alcine <jackyalcine@xxxxxxxxx>
+ * @copyright 2011 SII
+ *
+ * <license>
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ * </license>
+ *
+ */
+
+#include <libxml++/libxml++.h>
+#include <sigc++/sigc++.h>
+#include <boost/filesystem.hpp>
+#include <include/json.h>
+#include <string>
+#include <fstream>
+#include <iostream>
+#include <sstream>
+#include <map>
+
+#include "except.hpp"
+#include "linguistics.hpp"
+
+using namespace std;
+using namespace Json;
+using namespace xmlpp;
+using namespace Wintermute::Data;
+using std::string;
+using std::ios;
+using std::ofstream;
+using std::ifstream;
+using std::ostringstream;
+using std::istringstream;
+using Json::Value;
+using Json::Reader;
+using Json::FastWriter;
+using xmlpp::DomParser;
+using xmlpp::Document;
+
+namespace Wintermute {
+ namespace Data {
+ namespace Linguistics {
+ NodeInteroperingSignalVector NodeReader::handles;
+ NodeInteroperingSignalVector NodeWriter::handles;
+ XmlNode::XmlDataSources XmlNode::_docs;
+ JsonNode::JsonDataSources JsonNode::_data;
+
+ string Configuration::_locale = "en";
+ string Configuration::_root = "store";
+
+ //// @todo Fix the XmlNode and JsonNode readers; they're not working!
+ void Configuration::Initialize(const string& root, const string& locale) {
+ // cout << "(database) Initializing Linguistics data.." << endl;
+ NodeInteroperingSignalPair localNodeReader;
+ localNodeReader.first = new NodeIoExistsSignal;
+ localNodeReader.second = new NodeIoHandleSignal;
+ localNodeReader.first->connect(sigc::ptr_fun(&LocalNode::exists));
+ localNodeReader.second->connect(sigc::ptr_fun(&LocalNodeReader::obtain));
+
+ NodeInteroperingSignalPair jsonNodeReader;
+ jsonNodeReader.first = new NodeIoExistsSignal;
+ jsonNodeReader.second = new NodeIoHandleSignal;
+ jsonNodeReader.first->connect(sigc::ptr_fun(&JsonNode::exists));
+ jsonNodeReader.second->connect(sigc::ptr_fun(&JsonNodeReader::obtain));
+
+ NodeInteroperingSignalPair xmlNodeReader;
+ xmlNodeReader.first = new NodeIoExistsSignal;
+ xmlNodeReader.second = new NodeIoHandleSignal;
+ xmlNodeReader.first->connect(sigc::ptr_fun(&XmlNode::exists));
+ xmlNodeReader.second->connect(sigc::ptr_fun(&XmlNodeReader::obtain));
+
+ NodeInteroperingSignalPair localNodeWriter;
+ localNodeWriter.first = new NodeIoExistsSignal;
+ localNodeWriter.second = new NodeIoHandleSignal;
+ localNodeWriter.first->connect(sigc::ptr_fun(&LocalNode::exists));
+ localNodeWriter.second->connect(sigc::ptr_fun(&LocalNodeWriter::obtain));
+
+ NodeInteroperingSignalPair jsonNodeWriter;
+ jsonNodeWriter.first = new NodeIoExistsSignal;
+ jsonNodeWriter.second = new NodeIoHandleSignal;
+ jsonNodeWriter.first->connect(sigc::ptr_fun(&JsonNode::exists));
+ jsonNodeWriter.second->connect(sigc::ptr_fun(&JsonNodeWriter::obtain));
+
+ /*NodeInteroperingSignalPair xmlNodeWriter;
+ xmlNodeWriter.first = new NodeIoExistsSignal;
+ xmlNodeWriter.second = new NodeIoHandleSignal;
+ xmlNodeWriter.first->connect(sigc::ptr_fun(&XmlNode::exists));
+ xmlNodeWriter.second->connect(sigc::ptr_fun(&XmlNodeWriter::obtain));*/
+ // cout << "(database) Parsing linguistics data... " << endl;
+
+ Configuration::setRootDirectory(root);
+ Configuration::setLocale(locale);
+
+ NodeReader::addHandle(localNodeReader);
+ NodeWriter::addHandle(localNodeWriter);
+
+ if (XmlNode::loadLocale(locale)) {
+ //NodeReader::addHandle(xmlNodeReader);
+ //NodeWriter::addHandle(xmlNodeWriter);
+ }
+
+ if (JsonNode::loadLocale(locale)) {
+ NodeReader::addHandle(jsonNodeReader);
+ NodeWriter::addHandle(jsonNodeWriter);
+ }
+ }
+
+ void Configuration::setLocale(const string locale) {
+ if (locale.size() == 0)
+ return;
+
+ Configuration::_locale = locale;
+ // cout << "## Global locale set to " << locale << endl;
+ }
+
+ void Configuration::setRootDirectory(const string root) {
+ if (root.size() == 0)
+ return;
+
+ boost::filesystem::path theRoot(root);
+ Configuration::_root = theRoot.string();
+ // cout << "## Root set to " << root << endl;
+ }
+
+ const string Configuration::getLocale() {
+ return Configuration::_locale;
+ }
+
+ const string Configuration::getRootDirectory(const string locale) {
+ string theLocale = locale;
+ if (locale.empty())
+ theLocale = Configuration::getLocale();
+
+ string path = Configuration::_root + string("/locale/") + theLocale;
+ boost::filesystem::path thePath(path);
+ return thePath.string();
+ }
+
+ NodeIo::NodeIo(const string& nodeID, const string& nodeLocale) : strID(nodeID), strLocale(nodeLocale) {
+ }
+
+ const string NodeIo::getID() const {
+ return this->strID;
+ }
+
+ const string NodeIo::getLocale() const {
+ return this->strLocale;
+ }
+
+ const bool NodeIo::isNull() const {
+ return (this == NULL);
+ }
+
+ NodeReader::NodeReader(const string& nodeID, const string& nodeLocale) : NodeIo(nodeID, nodeLocale) {
+ // cout << "(database) Abstract linguistcal data input source initialized for (" << nodeLocale << ")# " << nodeID << "." << endl;
+ }
+
+ NodeReader::NodeReader(const NodeReader& node) : NodeIo(node.getID(), node.getLocale()) {
+
+ }
+
+ void NodeReader::addHandle(const NodeInteroperingSignalPair& dataPair) {
+ if (!(&dataPair == NULL)) {
+ NodeReader::handles.push_back(dataPair);
+ // cout << "(database) Linguistics data input source added (#" << NodeReader::handles.size() << ")" << endl;
+ }
+ }
+
+ NodeReader* NodeReader::obtain(const string &nodeID, const string &nodeLocale) {
+ // cout << "(database) Searching for linguistics data input sources..." << endl;
+ for (NodeInteroperingSignalVector::const_iterator itr = NodeReader::handles.begin(); itr != NodeReader::handles.end(); itr++) {
+ const NodeInteroperingSignalPair aPair = *itr;
+ if (aPair.first->emit(nodeID, nodeLocale))
+ return static_cast<NodeReader*> (aPair.second->emit(nodeID, nodeLocale));
+ }
+ // cout << "(database) No linguistics data input sources found!" << endl;
+ return NULL;
+ }
+
+ bool NodeReader::exists(const string &nodeID, const string &nodeLocale) {
+ // cout << nodeID << " " << nodeLocale << endl;
+ for (NodeInteroperingSignalVector::const_iterator itr = NodeReader::handles.begin(); itr != NodeReader::handles.end(); itr++) {
+ const NodeInteroperingSignalPair aPair = *itr;
+ if (aPair.first->emit(nodeID, nodeLocale))
+ return true;
+ }
+ return false;
+ }
+
+ const string NodeReader::get() const {
+ // cout << "(database) [NodeReader] Reading from stdin..." << endl;
+ string data, flags, semid;
+ ostringstream outData;
+ cin >> data;
+ outData << data << endl;
+
+ while (flags != "-1") {
+ cin >> flags >> semid;
+ outData << flags << " " << semid << " " << endl;
+ }
+
+ return outData.str();
+ }
+
+ void NodeReader::getData(const NodeReader& data, Lexical& out) {
+ // cout << "(database) [NodeReader] *** Read node #" << data.getID() << ".." << endl;
+ const string theData = data.get();
+ if (!theData.empty()) {
+ out.flags().clear();
+ string symbol, flags, semid;
+ istringstream inData(theData);
+
+ inData >> out.symbol();
+
+ while (inData >> flags >> semid)
+ out.flags().insert(Lexical::LexicalMap::value_type(flags, semid));
+
+ inData.clear();
+ }
+ }
+
+ NodeWriter::NodeWriter(const string& nodeID, const string& nodeLocale) : NodeIo(nodeID, nodeLocale) {
+ // cout << "(database) Abstract linguistcal data output source initialized for (" << nodeLocale << ")# " << nodeID << "." << endl;
+ }
+
+ NodeWriter::NodeWriter(const NodeWriter& node) : NodeIo(node.getID(), node.getLocale()) {
+ // cout << "(database) [NodeWriter] Abstract linguistcal data output source initialized for (" << getLocale() << ")# " << getID() << "." << endl;
+ }
+
+ NodeWriter::NodeWriter(const NodeIo& io) : NodeIo(io) {
+ // cout << "(database) [NodeIo] Abstract linguistcal data output source initialized for (" << getLocale() << ")# " << getID() << "." << endl;
+ }
+
+ void NodeWriter::addHandle(const NodeInteroperingSignalPair& dataPair) {
+ if (!(&dataPair == NULL)) {
+ NodeWriter::handles.push_back(dataPair);
+ // cout << "(database) Linguistics data output source added (#" << NodeWriter::handles.size() << ")" << endl;
+ }
+ }
+
+ NodeWriter* NodeWriter::obtain(const string& nodeID, const string& nodeLocale) {
+ // cout << "(database) Searching for linguistics data output sources..." << endl;
+ for (NodeInteroperingSignalVector::const_iterator itr = NodeWriter::handles.begin(); itr != NodeWriter::handles.end(); itr++) {
+ const NodeInteroperingSignalPair aPair = *itr;
+ if (!aPair.first->emit(nodeID, nodeLocale)) {
+ return new NodeWriter(*aPair.second->emit(nodeID, nodeLocale));
+ }
+ }
+ // cout << "(database) No linguistics data output sources found!" << endl;
+ return NULL;
+ }
+
+ bool NodeWriter::exists(const string &nodeID, const string &nodeLocale) {
+ for (NodeInteroperingSignalVector::const_iterator itr = NodeWriter::handles.begin(); itr != NodeWriter::handles.end(); itr++) {
+ const NodeInteroperingSignalPair aPair = *itr;
+ if (aPair.first->emit(nodeID, nodeLocale))
+ return true;
+ }
+ return false;
+ }
+
+ void NodeWriter::write(const string& data) {
+ // cout << "(database) [NodeWriter] Writing to stdout..." << endl;
+ // cout << data << endl;
+ }
+
+ void NodeWriter::setData(NodeWriter& writer, Lexical& in) {
+ ostringstream outData;
+ outData << in.symbol() << endl;
+
+ for (Lexical::LexicalMap::const_iterator itr = in.flags().begin(); itr != in.flags().end(); itr++)
+ outData << itr->first << " " << itr->second << endl;
+
+ writer.write(outData.str());
+ outData.clear();
+ }
+
+ LocalNode::LocalNode() {
+ // cout << "(database) [LocalNode] Linguisics data source base initialized." << endl;
+ }
+
+ LocalNode::~LocalNode() {
+ // cout << "(database) [LocalNode] Linguisics data source base destroyed." << endl;
+ }
+
+ const string LocalNode::getPath(const string& nodeID, const string& nodeLocale) {
+ string myLocale = nodeLocale;
+ if (nodeLocale.empty())
+ myLocale = Configuration::getLocale();
+
+ string path = Configuration::getRootDirectory(nodeLocale) + string("/nods/") + nodeID;
+ boost::filesystem::path thePath(path);
+
+ //cout << "Formed path: " << thePath.relative_path().string() << endl;
+ return thePath.string();
+ }
+
+ bool LocalNode::exists(const string& nodeID, const string& nodeLocale) {
+ // cout << "(database) [LocalNode] Determing existence of (" << nodeLocale << ")'" << nodeID << "'..." << endl;
+ return boost::filesystem::exists(LocalNode::getPath(nodeID, nodeLocale));
+ }
+
+ LocalNodeReader::LocalNodeReader(const string& nodeID, const string& nodeLocale) : NodeReader(nodeID, nodeLocale), LocalNode() {
+ // cout << "(database) [LocalNodeReader] Linguistics data input source initialized. " << endl;
+ }
+
+ LocalNodeReader::LocalNodeReader(const NodeReader& node) : NodeReader(node), LocalNode() {
+
+ }
+
+ const string LocalNodeReader::get() const {
+ // TODO: Allow configuration of location globally and internally.
+ string path, data, flags, semid;
+
+ // get the path to the node on disk.
+ path = LocalNode::getPath(this->getID(), this->getLocale());
+
+ ifstream inNode(path.c_str(), ios::in);
+ ostringstream outData("");
+ inNode >> data;
+ outData << data << endl;
+
+ while (inNode >> flags >> semid)
+ outData << flags << " " << semid << " " << endl;
+
+ inNode.close();
+ // cout << outData.str() << std::endl;
+ return outData.str();
+ }
+
+ LocalNodeReader* LocalNodeReader::obtain(const string& nodeID, const string& nodeLocale) {
+ // cout << "(database) [LocalNodeReader] Linguistics data input source formed. " << endl;
+ if (LocalNode::exists(nodeID,nodeLocale))
+ return new LocalNodeReader(nodeID, nodeLocale);
+ else
+ return NULL;
+ }
+
+ LocalNodeWriter::LocalNodeWriter(const string& nodeID, const string& nodeLocale) : NodeWriter(nodeID, nodeLocale), LocalNode() {
+ // cout << "(database) [LocalNodeWriter] Linguistics data output source initialized. " << endl;
+ if (LocalNode::exists(nodeID, nodeLocale)){
+ // cout << "(database) [LocalNodeWriter] Overwriting pre-existing data... " << endl;
+ }
+ }
+
+ LocalNodeWriter::LocalNodeWriter(const NodeWriter& node) : NodeWriter(node), LocalNode() {
+ // cout << "(database) [LocalNodeWriter] Linguistics data output source initialized. " << endl;
+ if (LocalNode::exists(getID(), getLocale())){
+ // cout << "(database) [LocalNodeWriter] Overwriting pre-existing data... " << endl;
+ }
+ }
+
+ void LocalNodeWriter::write(const string& data) {
+ // cout << "(database) [LocalNodeWriter] Saving... " << endl;
+ string path;
+
+ path = LocalNode::getPath(this->getID(), this->getLocale());
+ ofstream outNode(path.c_str(), ios::out | ios::trunc);
+ outNode << data;
+ outNode.close();
+ // cout << "(database) [LocalNodeWriter] Wrote " << data.length() * sizeof (char) << " bytes to '" << path << "'." << endl;
+ }
+
+ LocalNodeWriter* LocalNodeWriter::obtain(const string& nodeID, const string& nodeLocale) {
+ return new LocalNodeWriter(nodeID, nodeLocale);
+ }
+
+ JsonNode::JsonNode() {
+ // cout << "(database) [JsonNode] Linguisics data source base initialized." << endl;
+ }
+
+ JsonNode::~JsonNode() {
+ // cout << "(database) [JsonNode] Linguisics data source base destroyed." << endl;
+ }
+
+ bool JsonNode::loadLocale(const string& nodeLocale) {
+ // cout << "(database) [JsonNode] < " << nodeLocale << " > Loading locale information ..." << endl;
+ string path = Configuration::getRootDirectory(nodeLocale) + "/db.json";
+ boost::filesystem::path thePath(path);
+ path = thePath.string();
+ Json::Reader aReader;
+ Json::Value theValue;
+ aReader.parse(path, theValue);
+
+ if (theValue.isNull()) {
+ // cout << "(database) [JsonNode] < " << nodeLocale << " > Malformed information recieved." << endl << "\t" << aReader.getFormatedErrorMessages() << endl;
+ return false;
+ }
+
+ JsonDataSources::value_type dataPair(nodeLocale, theValue);
+ // cout << theValue.toStyledString() << endl;
+ JsonNode::_data.insert(dataPair);
+ return true;
+ }
+
+ Json::Value JsonNode::getJsonLocale(const string& locale) {
+ JsonDataSources::iterator jsItr = JsonNode::_data.find(locale);
+ if (jsItr != JsonNode::_data.end())
+ return jsItr->second;
+
+ return Json::Value::null;
+ }
+
+ bool JsonNode::exists(const string& nodeID, const string& nodeLocale) {
+ // cout << "(database) [JsonNode] Determing existence of (" << nodeLocale << ")'" << nodeID << "'..." << endl;
+ JsonDataSources::iterator theItr = _data.find(nodeLocale);
+ if (theItr == _data.end())
+ return false;
+
+ Json::Value theLocale = theItr->second;
+ return theLocale.isMember(nodeID);
+ }
+
+ JsonNodeReader::JsonNodeReader(const string& nodeID, const string& nodeLocale) : NodeReader(nodeID, nodeLocale) {
+ // cout << "(database) [JsonNodeWriter] Linguistics data input source initialized. " << endl;
+ }
+
+ JsonNodeReader* JsonNodeReader::obtain(const string& nodeID, const string& nodeLocale) {
+ // cout << "(database) [JsonNodeReader] Linguistics data input source formed. " << endl;
+ return new JsonNodeReader(nodeID, nodeLocale);
+ }
+
+ const string JsonNodeReader::get() const {
+ Json::Value theLocale = _data.find(this->getLocale())->second;
+ Json::Value node = theLocale[this->getID()];
+
+ // cout << "Dump: " << endl << theLocale.toStyledString() << endl;
+ // cout << "Focused dump: " << endl << node.toStyledString() << endl;
+ ostringstream outData;
+ outData << node["symbol"] << endl;
+
+ Json::Value flagCollection = theLocale["links"];
+ for (Json::Value::iterator itr = flagCollection.begin(); itr != flagCollection.end(); itr++) {
+ Json::Value aValue = *itr;
+ outData << aValue["flags"] << " " << aValue["semantic"] << endl;
+ }
+
+ return outData.str();
+ }
+
+ JsonNodeWriter::JsonNodeWriter(const string& nodeID, const string& nodeLocale) : NodeWriter(nodeID, nodeLocale) {
+
+ }
+
+ void JsonNodeWriter::write(const string& data) {
+ istringstream inData(data);
+ Json::Value theLocale = JsonNode::getJsonLocale(this->getLocale());
+ Json::Value theNode;
+ if (!theLocale.isMember(this->getID())) {
+ Json::Reader aReader;
+ aReader.parse(string("{'") + this->getID() + string("' : {}}"), theNode);
+ theLocale.append(theNode);
+ }
+ theNode = theLocale[this->getID()];
+ inData >> theNode["symbol"];
+
+ Json::Value flagCollection = theNode["links"];
+ string flags, semid;
+ while (inData >> flags >> semid) {
+ Json::Reader aLinkReader;
+ Json::Value theLink;
+ ostringstream outLink;
+ outLink << "{ flags : '" << flags << "', semantic: '" << semid << "' }";
+ aLinkReader.parse(outLink.str(), theLink);
+ flagCollection.append(theLink);
+ }
+ }
+
+ JsonNodeWriter* JsonNodeWriter::obtain(const string& nodeID, const string& nodeLocale) {
+ return new JsonNodeWriter(nodeID, nodeLocale);
+ }
+
+ XmlNode::XmlNode() {
+ // cout << "(database) [XmlNode] Linguisics data source base initialized." << endl;
+ }
+
+ XmlNode::~XmlNode() {
+ // cout << "(database) [XmlNode] Linguisics data source base destroyed." << endl;
+ }
+
+ Element* XmlNode::getXmlLocale(const string& locale) {
+ XmlDataSources::iterator theItr = XmlNode::_docs.find(locale);
+ if (theItr == XmlNode::_docs.end())
+ return NULL;
+ else
+ return theItr->second->get_root_node();
+ }
+
+ bool XmlNode::loadLocale(const string& nodeLocale) {
+ // cout << "(database) [XmlNode] < " << nodeLocale << " > Loading locale information ..." << endl;
+ string path = Configuration::getRootDirectory(nodeLocale) + "/db.xml";
+ boost::filesystem::path thePath(path);
+ path = thePath.string();
+
+ DomParser aParser;
+ aParser.set_validate(false);
+ aParser.set_substitute_entities(false);
+ try {
+ aParser.parse_file(path);
+ } catch (xmlpp::exception &e) {
+ // cout << "(database) [XmlNode] <" << nodeLocale << "> Error parsing linguistics data; '" << e.what() << "'" << endl;
+ return false;
+ }
+
+ if (!aParser) {
+ // cout << "(database) [XmlNode] <" << nodeLocale << "> Malformed linguistics data." << endl;
+ return false;
+ }
+
+ Document* theDoc = aParser.get_document();
+ if (theDoc != NULL) {
+ Element* theElem = theDoc->get_root_node();
+ if (theElem == NULL){
+ theElem = theDoc->create_root_node("Collection");
+ theDoc->write_to_file(path);
+ }
+
+ if (theElem) {
+ _docs.insert(XmlDataSources::value_type(nodeLocale, theDoc));
+ // cout << "(database) [XmlNode] Memory dump:" << endl << theElem->get_children().size() << endl;
+ return true;
+ } else
+ return false;
+ } else {
+ return false;
+ }
+ return false;
+ }
+
+ bool XmlNode::exists(const string& nodeID, const string& nodeLocale) {
+ // cout << "(database) [XmlNode] Determing existence of (" << nodeLocale << ")'" << nodeID << "'..." << endl;
+ if (XmlNode::_docs.find(nodeLocale) == XmlNode::_docs.end())
+ return false;
+
+ return XmlNode::obtainNode(nodeID, nodeLocale) != NULL;
+ }
+
+ Element* XmlNode::obtainNode(const string& nodeID, const string& nodeLocale) {
+ XmlDataSources::iterator docItr = XmlNode::_docs.find(nodeLocale);
+ if (docItr == XmlNode::_docs.end())
+ return NULL;
+
+ Element* rootNode = docItr->second->get_root_node();
+ if (rootNode != NULL) {
+ if (rootNode->has_child_text()) {
+ NodeSet collection = rootNode->find("Node");
+ if (!collection.empty()) {
+ for (NodeSet::const_iterator itr = collection.begin(); itr != collection.end(); itr++) {
+ Element* aElement = dynamic_cast<Element*> (*itr);
+ if (aElement->get_attribute_value("ID") == nodeID)
+ return aElement;
+ }
+ }
+ }
+ }
+ return NULL;
+ }
+
+ XmlNodeReader::XmlNodeReader(const string& nodeID, const string& nodeLocale) : NodeReader(nodeID, nodeLocale) {
+ // cout << "(database) [XmlNodeReader] Linguistics data input source initialized. " << endl;
+ }
+
+ const string XmlNodeReader::get() const {
+ ostringstream outData;
+ Element* theNode = XmlNode::obtainNode(this->getID(), this->getLocale());
+ NodeSet theLinks = theNode->find("Link");
+
+ outData << theNode->get_attribute_value("symbol");
+ if (!theLinks.empty()) {
+ for (NodeSet::const_iterator itr = theLinks.begin(); itr != theLinks.end(); itr++) {
+ Element* theLink = dynamic_cast<Element*> (*itr);
+ outData << theLink->get_attribute_value("flag") << " " << theLink->get_attribute_value("semanticID") << endl;
+ }
+ }
+
+ return outData.str();
+ }
+
+ XmlNodeReader* XmlNodeReader::obtain(const string& nodeID, const string& nodeLocale) {
+ // cout << "(database) [XmlNodeReader] Linguistics data input source formed. " << endl;
+ return new XmlNodeReader(nodeID, nodeLocale);
+ }
+
+ Lexical::Lexical() {
+
+ }
+
+ Lexical* Lexical::obtain() {
+ return new Lexical();
+ }
+
+ void Lexical::load(const NodeReader& node) {
+ NodeReader::getData(node, *this);
+ }
+
+ void Lexical::save(NodeWriter& node) {
+ NodeWriter::setData(node, *this);
+ }
+
+ string& Lexical::symbol() {
+ return _strSymbol;
+ }
+
+ Lexical::LexicalMap& Lexical::flags() {
+ return _data;
+
+ }
+ }
+ }
+}
\ No newline at end of file
=== added file 'wintermute-database/src/linguistics.hpp'
--- wintermute-database/src/linguistics.hpp 1970-01-01 00:00:00 +0000
+++ wintermute-database/src/linguistics.hpp 2011-04-04 14:29:41 +0000
@@ -0,0 +1,549 @@
+/*
+ * Author: Jacky Alcine <jackyalcine@xxxxxxxxx>
+ *
+ * Copyright 2011 Jacky Alcine
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+
+ * @file linguistics.hpp
+ * @author jacky
+ * @created March 29, 2011, 3:08 PM
+ */
+
+#ifndef LINGUISTICS_HPP
+#define LINGUISTICS_HPP
+
+#include <sigc++/sigc++.h>
+#include <libxml++-2.6/libxml++/libxml++.h>
+#include </home/jacky/Documents/Development/Projects/Desktop/Wintermute/~wintermute-devel/json/src/include/json.h>
+#include <string>
+#include <vector>
+#include <map>
+#include <stdexcept>
+
+using namespace std;
+using namespace xmlpp;
+using std::string;
+using std::vector;
+using std::pair;
+using std::map;
+using xmlpp::Document;
+
+namespace Wintermute {
+ namespace Data {
+ namespace Linguistics {
+ class Configuration;
+ class NodeIo;
+ class LocalNode;
+ class JsonNode;
+ class XmlNode;
+ class Lexical;
+
+ class NodeReader;
+ class LocalNodeReader;
+ class XmlNodeReader;
+ class JsonNodeReader;
+
+ class NodeWriter;
+ class LocalNodeWriter;
+ class XmlNodeWriter;
+ class JsonNodeWriter;
+
+ /**
+ */
+ typedef sigc::slot<bool, const string&, const string&> NodeIoExistsSlot;
+ /**
+ */
+ typedef sigc::slot<NodeIo*, const string&, const string&> NodeIoHandleSlot;
+ /**
+ */
+ typedef sigc::signal<bool, const string&, const string&> NodeIoExistsSignal;
+ /**
+ */
+ typedef sigc::signal<NodeIo*, const string&, const string&> NodeIoHandleSignal;
+ /**
+ */
+ typedef pair<NodeIoExistsSignal*, NodeIoHandleSignal*> NodeInteroperingSignalPair;
+ /**
+ */
+ typedef vector<NodeInteroperingSignalPair> NodeInteroperingSignalVector;
+ /**
+ */
+ typedef LocalNode LocalData;
+ /**
+ */
+ typedef JsonNode JsonData;
+ /**
+ */
+ typedef XmlNode XmlData;
+
+ /**
+ * An abstract static class representing the current configuration
+ * of the linguistics data.
+ */
+ class Configuration {
+ private:
+ static string _root;
+ static string _locale;
+ Configuration();
+ ~Configuration();
+
+ public:
+ /**
+ * Initializes the system by running prerequieste code.
+ * @param string root The directory of which data should be loaded from.
+ * @param string locale The locale that should initially loaded.
+ */
+ static void Initialize(const string& = "store", const string& = "en");
+ /**
+ * @description Sets the default locale to use.
+ * @param locale The locale to set.
+ */
+ static void setLocale(const string = "en");
+ /**
+ * @description Sets the root directory to load information from.
+ * @param root The root directory.
+ */
+ static void setRootDirectory(const string = "store");
+ /**
+ * @description Gets current locale used.
+ * @return String with the current locale.
+ */
+ static const string getLocale();
+ /**
+ * @description Gets the root directory for the specified locale.
+ * @param locale String with the locale name.
+ * @return String with the path to the locale root, relative to the main root.
+ */
+ static const string getRootDirectory(const string = "en");
+ };
+
+ /**
+ * Represents the foundational class of all node input and output.
+ */
+ class NodeIo {
+ protected:
+ /**
+ * Creates a new NodeIo.
+ * @param string nodeID The ID of the node.
+ * @param string nodeLocale The locale of the node.
+ */
+ NodeIo(const string&, const string&);
+ const string strID;
+ const string strLocale;
+ public:
+ /**
+ * Obtains the representing ID of this I/O object.
+ * @return string The ID.
+ */
+ const string getID() const;
+ /**
+ * Obtains the underlying locale of this I/O object.
+ * @return string The locale in a two to five-character string.
+ */
+ const string getLocale() const;
+ /**
+ *
+ * @return
+ */
+ const bool isNull() const;
+ };
+
+ /**
+ * Dependant on NodeIo; this class represents all NodeIo objects that
+ * read data.
+ * @see NodeIo
+ */
+ class NodeReader : public NodeIo {
+ friend class Lexical;
+ private:
+ static NodeInteroperingSignalVector handles;
+ protected:
+ /**
+ * Creates an input object based on NodeIo.
+ * @param string nodeID The ID of the node.
+ * @param string nodeLocale The locale of the node.
+ */
+ NodeReader(const string&, const string&);
+ /**
+ *
+ * @param
+ */
+ NodeReader(const NodeReader&);
+ NodeReader(const NodeIo&);
+ /**
+ * Returns the data to be parsed as a Node.
+ * @return string
+ */
+ virtual const string get() const;
+
+ public:
+ /**
+ * Attachs a new handler to obtain data from.
+ * @param NodeInteroperingSignalPair The std::pair to add to the internal vector.
+ * @see NodeInteroperingSignalPair
+ * @see NodeReader::obtain
+ */
+ static void addHandle(const NodeInteroperingSignalPair&);
+ /**
+ *
+ * @param
+ * @param
+ * @return
+ */
+ static NodeReader* obtain(const string&, const string&);
+ /**
+ *
+ * @param
+ * @param
+ * @return
+ */
+ static bool exists(const string&, const string&);
+ static void getData(const NodeReader&, Lexical&);
+ };
+
+ /**
+ */
+ class NodeWriter : public NodeIo {
+ friend class Lexical;
+ private:
+ static NodeInteroperingSignalVector handles;
+
+ protected:
+ /**
+ *
+ * @param
+ * @param
+ */
+ NodeWriter(const string&, const string&);
+ /**
+ *
+ * @param
+ */
+ NodeWriter(const NodeIo&);
+ /**
+ *
+ * @param
+ */
+ NodeWriter(const NodeWriter&);
+ /**
+ *
+ * @param
+ */
+ virtual void write(const string&);
+
+ public:
+ /**
+ *
+ * @param
+ */
+ static void addHandle(const NodeInteroperingSignalPair&);
+ /**
+ *
+ * @param
+ * @param
+ * @return
+ */
+ static NodeWriter* obtain(const string&, const string&);
+ /**
+ *
+ * @param
+ * @param
+ * @return
+ */
+ static bool exists(const string&, const string&);
+ static void setData(NodeWriter&, Lexical&);
+ };
+
+ /**
+ */
+ class Lexical {
+ protected:
+ Lexical();
+ public:
+ /**
+ */
+ typedef map<string, string> LexicalMap;
+ static Lexical* obtain();
+ void save(NodeWriter&);
+ void load(const NodeReader&);
+ string& symbol();
+ LexicalMap& flags();
+ private:
+ string _strSymbol;
+ LexicalMap _data;
+ };
+
+ /**
+ */
+ class LocalNode {
+ protected:
+ /**
+ *
+ */
+ LocalNode();
+ virtual ~LocalNode() = 0;
+ /**
+ *
+ * @param
+ * @param
+ * @return
+ */
+ static const string getPath(const string&, const string&);
+
+ public:
+ /**
+ *
+ * @param
+ * @param
+ * @return
+ */
+ static bool exists(const string&, const string&);
+ };
+
+ /**
+ *
+ */
+ class LocalNodeReader : public NodeReader, protected LocalNode {
+ protected:
+ /**
+ *
+ * @param
+ * @param
+ */
+ LocalNodeReader(const string&, const string&);
+ LocalNodeReader(const NodeReader&);
+ public:
+ /**
+ *
+ * @param
+ * @param
+ * @return
+ */
+ static LocalNodeReader* obtain(const string&, const string&);
+ /**
+ *
+ * @return
+ */
+ const string get() const;
+ };
+
+ /**
+ */
+ class LocalNodeWriter : public NodeWriter, protected LocalNode {
+ protected:
+ /**
+ *
+ * @param
+ * @param
+ */
+ LocalNodeWriter(const string&, const string&);
+ LocalNodeWriter(const NodeWriter&);
+
+ public:
+ /**
+ *
+ * @param
+ * @param
+ * @return
+ */
+ static LocalNodeWriter* obtain(const string&, const string&);
+ /**
+ *
+ * @param
+ */
+ void write(const string&);
+ };
+
+ /**
+ */
+ class XmlNode {
+ typedef map<const string, Document*> XmlDataSources;
+ protected:
+ /**
+ *
+ */
+ XmlNode();
+ virtual ~XmlNode() = 0;
+ static XmlDataSources _docs;
+ /**
+ *
+ * @param
+ * @param
+ * @return
+ */
+ static Element* obtainNode(const string&, const string&);
+ /**
+ *
+ * @param
+ * @return
+ */
+ static Element* getXmlLocale(const string& = "");
+ public:
+ /**
+ *
+ * @param
+ * @return
+ */
+ static bool loadLocale(const string& = "");
+ /**
+ *
+ * @param
+ * @param
+ * @return
+ */
+ static bool exists(const string&, const string&);
+ };
+
+ /**
+ *
+ */
+ class XmlNodeReader : public NodeReader, protected XmlNode {
+ protected:
+ /**
+ *
+ * @param
+ * @param
+ */
+ XmlNodeReader(const string&, const string&);
+ public:
+ /**
+ *
+ * @param
+ * @param
+ * @return
+ */
+ static XmlNodeReader* obtain(const string&, const string&);
+ /**
+ *
+ * @return
+ */
+ virtual const string get() const;
+ };
+
+ /**
+ */
+ class XmlNodeWriter : public NodeWriter, protected XmlNode {
+ protected:
+ /**
+ *
+ * @param
+ * @param
+ */
+ XmlNodeWriter(const string&, const string&);
+ public:
+ /**
+ *
+ * @param
+ * @param
+ * @return
+ */
+ static XmlNodeWriter* obtain(const string&, const string&);
+ /**
+ *
+ * @param
+ */
+ virtual void write(const string&);
+ };
+
+ /**
+ */
+ class JsonNode {
+ typedef map<const string, Json::Value> JsonDataSources;
+ protected:
+ /**
+ *
+ */
+ JsonNode();
+ virtual ~JsonNode() = 0;
+ static JsonDataSources _data;
+ /**
+ *
+ * @param
+ * @return
+ */
+ static Json::Value getJsonLocale(const string& = "");
+ public:
+ /**
+ *
+ * @param
+ * @return
+ */
+ static bool loadLocale(const string& = "");
+ /**
+ *
+ * @param
+ * @param
+ * @return
+ */
+ static bool exists(const string&, const string&);
+ };
+
+ /**
+ *
+ */
+ class JsonNodeReader : public NodeReader, protected JsonNode {
+ protected:
+ /**
+ *
+ * @param
+ * @param
+ */
+ JsonNodeReader(const string&, const string&);
+ public:
+ /**
+ *
+ * @param
+ * @param
+ * @return
+ */
+ static JsonNodeReader* obtain(const string&, const string&);
+ /**
+ *
+ * @return
+ */
+ virtual const string get() const;
+ };
+
+ /**
+ *
+ */
+ class JsonNodeWriter : public NodeWriter, protected JsonNode {
+ protected:
+ /**
+ *
+ * @param
+ * @param
+ */
+ JsonNodeWriter(const string&, const string&);
+ public:
+ /**
+ *
+ * @param
+ * @param
+ * @return
+ */
+ static JsonNodeWriter* obtain(const string&, const string&);
+ /**
+ *
+ * @param
+ */
+ virtual void write(const string&);
+ };
+ }
+ }
+}
+#endif /* LINGUISTICS_HPP */
=== added file 'wintermute-database/src/ontology.cpp'
--- wintermute-database/src/ontology.cpp 1970-01-01 00:00:00 +0000
+++ wintermute-database/src/ontology.cpp 2011-04-04 14:29:41 +0000
@@ -0,0 +1,47 @@
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+
+ * @file ontology.cpp
+ * @author Jacky Alcine
+ * @created March 29, 2011, 2:25 PM
+ */
+#include "ontology.hpp"
+
+namespace Wintermute {
+ namespace Data {
+ namespace Ontology {
+
+ Concept::Concept(const string& conceptID) : id(conceptID){
+ }
+
+ const string Concept::getID() const {
+ return this->id;
+ }
+
+ Concept* Concept::obtain(const string& conceptID) {
+ return new Concept(conceptID);
+ }
+
+ Instance::Instance(const string& conceptID) : Concept(conceptID){
+
+ }
+
+ Instance* Instance::createFrom(const string& conceptID){
+ return new Instance(conceptID);
+ }
+ }
+ }
+}
=== added file 'wintermute-database/src/ontology.hpp'
--- wintermute-database/src/ontology.hpp 1970-01-01 00:00:00 +0000
+++ wintermute-database/src/ontology.hpp 2011-04-04 14:29:41 +0000
@@ -0,0 +1,101 @@
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+
+ * @file ontology.hpp
+ * @author Jacky Alcine
+ * @created March 29, 2011, 2:25 PM
+ */
+
+#ifndef ONTOLOGY_HPP
+#define ONTOLOGY_HPP
+
+#include <vector>
+#include <string>
+
+using namespace std;
+
+using std::vector;
+using std::pair;
+using std::string;
+
+namespace Wintermute {
+ namespace Data {
+ namespace Ontology {
+ /**
+ * This class represents a node within the ontology.
+ */
+ class Concept;
+ class Relationship;
+ class Attribute;
+ class RelationshipCollection;
+ class Instance;
+
+ class Concept {
+ protected:
+ Concept(const string&);
+ const string id;
+
+ public:
+ static Concept* obtain(const string&);
+ const string getID() const;
+ };
+
+ class Relationship {
+ protected:
+ Relationship();
+ virtual ~Relationship();
+ };
+
+ class RelationshipCollection : protected vector<Relationship*> {
+ public:
+ RelationshipCollection();
+ RelationshipCollection(const vector<Relationship*> &);
+ virtual ~RelationshipCollection() = 0;
+ };
+
+ class Attribute {
+ protected:
+ Attribute();
+ virtual ~Attribute() = 0;
+
+ public:
+
+ class Facet {
+ protected:
+ Facet();
+ virtual ~Facet() = 0;
+ public:
+
+ };
+ };
+
+ class Instance : public Concept {
+ protected:
+ Instance(const string&);
+ void load();
+
+ public:
+ static Instance* createFrom(const Concept&);
+ static Instance* createFrom(const string&);
+ static Instance* createFrom(const vector<Concept&> &);
+ static Instance* createFrom(const vector<string&> &);
+ };
+ }
+ }
+}
+
+#endif /* ONTOLOGY_HPP */
+
=== added file 'wintermute-database/src/wintermute-database.cpp'
--- wintermute-database/src/wintermute-database.cpp 1970-01-01 00:00:00 +0000
+++ wintermute-database/src/wintermute-database.cpp 2011-04-04 14:29:41 +0000
@@ -0,0 +1,23 @@
+/*
+ * Author: Jacky Alcine <jacky.alcine@xxxxxxxxxx>
+ *
+ * Copyright 2011 Jacky Alcine
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "wintermute-database.hpp"
\ No newline at end of file
=== added file 'wintermute-database/src/wintermute-database.hpp'
--- wintermute-database/src/wintermute-database.hpp 1970-01-01 00:00:00 +0000
+++ wintermute-database/src/wintermute-database.hpp 2011-04-04 14:29:41 +0000
@@ -0,0 +1,30 @@
+ /*
+ * Author: Jacky Alcine <jacky.alcine@xxxxxxxxxx
+ *
+ * Copyright 2011 Wintermute Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef CORE_HPP
+#define CORE_HPP
+
+#include "except.hpp"
+#include "ontology.hpp"
+#include "linguistics.hpp"
+
+#endif /* CORE_HPP */
Follow ups