changeset 22:9abc896958cf classical-rdf

* Fixes for static initialiser ordering (etc)
author Chris Cannam
date Thu, 25 Feb 2010 22:34:11 +0000
parents ea477e4cc75c
children 437442790e51
files common/Objects.cpp common/Objects.h common/TypeRegistrar.cpp common/TypeRegistrar.h testapp/Loader.cpp utilities/composer/composer.cpp
diffstat 6 files changed, 11 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/common/Objects.cpp	Thu Feb 25 18:21:53 2010 +0000
+++ b/common/Objects.cpp	Thu Feb 25 22:34:11 2010 +0000
@@ -157,7 +157,7 @@
                 s += "c. ";
                 showApprox = false;
             }
-            s += QString("%1").arg(birth()->year());
+            s += QString("%1").arg(birth()->year().toInt());
         }
         s += "-";
         if (death()) {
@@ -168,7 +168,7 @@
                 s += "c. ";
                 showApprox = false;
             }
-            s += QString("%1").arg(death()->year());
+            s += QString("%1").arg(death()->year().toInt());
         }
     }
 
--- a/common/Objects.h	Thu Feb 25 18:21:53 2010 +0000
+++ b/common/Objects.h	Thu Feb 25 22:34:11 2010 +0000
@@ -24,12 +24,12 @@
     Year() : m_year(0) { }
     Year(int y) : m_year(y) { }
 
-    int year() const { return m_year; }
+    int toInt() const { return m_year; }
     operator int() { return m_year; }
 
     struct Encoder : public Dataquay::Node::VariantEncoder {
         QString fromVariant(const QVariant &v) {
-            return QString("%1").arg(v.value<Year>().year());
+            return QString("%1").arg(v.value<Year>().toInt());
         }
         QVariant toVariant(const QString &s) {
             return QVariant::fromValue<Year>(s.toInt());
--- a/common/TypeRegistrar.cpp	Thu Feb 25 18:21:53 2010 +0000
+++ b/common/TypeRegistrar.cpp	Thu Feb 25 22:34:11 2010 +0000
@@ -12,7 +12,8 @@
 
 namespace ClassicalData {
 
-TypeRegistrar::TypeRegistrar()
+void
+TypeRegistrar::registerTypes()
 {
     qRegisterMetaType<Year>
 	("ClassicalData::Year");
@@ -172,8 +173,5 @@
     mapper->addPropertyMapping("ClassicalData::Composition", "works", "mo:produced_work");
 }
 
-TypeRegistrar
-TypeRegistrar::m_instance;
-
 }
 
--- a/common/TypeRegistrar.h	Thu Feb 25 18:21:53 2010 +0000
+++ b/common/TypeRegistrar.h	Thu Feb 25 22:34:11 2010 +0000
@@ -13,11 +13,8 @@
 class TypeRegistrar
 {
 public:
+    static void registerTypes();
     static void addMappings(Dataquay::BasicStore *, Dataquay::ObjectMapper *);
-
-private:
-    TypeRegistrar();
-    static TypeRegistrar m_instance;
 };
 
 }
--- a/testapp/Loader.cpp	Thu Feb 25 18:21:53 2010 +0000
+++ b/testapp/Loader.cpp	Thu Feb 25 22:34:11 2010 +0000
@@ -47,6 +47,7 @@
     store->setBaseUri(Uri("http://dbtune.org/classical/resource/"));
     ObjectMapper *mapper = new ObjectMapper(store);
 
+    TypeRegistrar::registerTypes();
     TypeRegistrar::addMappings(store, mapper);
 
     if (!load(store, ":data.ntriples")) {
--- a/utilities/composer/composer.cpp	Thu Feb 25 18:21:53 2010 +0000
+++ b/utilities/composer/composer.cpp	Thu Feb 25 22:34:11 2010 +0000
@@ -234,6 +234,7 @@
     store->setBaseUri(Uri("http://dbtune.org/classical/resource/"));
     ObjectMapper *mapper = new ObjectMapper(store);
 
+    TypeRegistrar::registerTypes();
     TypeRegistrar::addMappings(store, mapper);
 
     if (!load(store, inFileName)) {
@@ -260,8 +261,10 @@
     }
 
     if (command == "list") {
+        if (!args.empty()) usage(argv[0]);
         listBrief(allComposers);
     } else if (command == "list-uris") {
+        if (!args.empty()) usage(argv[0]);
         listUris(allComposers);
     } else {
         if (args.empty()) usage(argv[0]);