aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine/Stateful.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/Stateful.cpp')
-rw-r--r--src/engine/Stateful.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/engine/Stateful.cpp b/src/engine/Stateful.cpp
new file mode 100644
index 0000000..7608a06
--- /dev/null
+++ b/src/engine/Stateful.cpp
@@ -0,0 +1,39 @@
+/*
+ This file is part of Machina.
+ Copyright 2007-2013 David Robillard <http://drobilla.net>
+
+ Machina 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 any later version.
+
+ Machina 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 Machina. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "Stateful.hpp"
+
+namespace machina {
+
+uint64_t Stateful::_next_id = 1;
+
+Stateful::Stateful()
+ : _id(next_id())
+{}
+
+const Sord::Node&
+Stateful::rdf_id(Sord::World& world) const
+{
+ if (!_rdf_id.is_valid()) {
+ std::ostringstream ss;
+ ss << "b" << _id;
+ _rdf_id = Sord::Node(world, Sord::Node::BLANK, ss.str());
+ }
+
+ return _rdf_id;
+}
+
+} // namespace machina