diff options
author | David Robillard <d@drobilla.net> | 2006-10-03 22:24:22 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2006-10-03 22:24:22 +0000 |
commit | 91d5cb109563c67bdad5f3ebeaafc8e1e8f7e14a (patch) | |
tree | cb70af457552eb1b87f745989f41c31da8220583 /src/common | |
parent | 35a5d92cfcf6815553a0939c3e2bf77c1108fd31 (diff) | |
download | ingen-91d5cb109563c67bdad5f3ebeaafc8e1e8f7e14a.tar.gz ingen-91d5cb109563c67bdad5f3ebeaafc8e1e8f7e14a.tar.bz2 ingen-91d5cb109563c67bdad5f3ebeaafc8e1e8f7e14a.zip |
shared_ptr bugfixes.
Updated Ingen to work with new FlowCanvas.
Updated Patchage to work with new(er) FlowCanvas.
git-svn-id: http://svn.drobilla.net/lad/ingen@152 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/util/CountedPtr.h | 4 | ||||
-rw-r--r-- | src/common/util/RedlandAtom.h | 47 |
2 files changed, 34 insertions, 17 deletions
diff --git a/src/common/util/CountedPtr.h b/src/common/util/CountedPtr.h index 0f00be87..63b2bdf4 100644 --- a/src/common/util/CountedPtr.h +++ b/src/common/util/CountedPtr.h @@ -31,7 +31,7 @@ static std::list<void*> counted_ptr_counters; // Use debug hooks to ensure 2 shared_ptrs never point to the same thing namespace boost { - static void sp_scalar_constructor_hook(void* object, unsigned long cnt, void* ptr) { + inline void sp_scalar_constructor_hook(void* object, unsigned long cnt, void* ptr) { assert(std::find(counted_ptr_counters.begin(), counted_ptr_counters.end(), (void*)object) == counted_ptr_counters.end()); counted_ptr_counters.push_back(object); @@ -39,7 +39,7 @@ namespace boost { // << object << ", count = " << cnt << std::endl; } - static void sp_scalar_destructor_hook(void* object, unsigned long cnt, void* ptr) { + inline void sp_scalar_destructor_hook(void* object, unsigned long cnt, void* ptr) { counted_ptr_counters.remove(object); //std::cerr << "Destroying CountedPtr to " // << object << ", count = " << cnt << std::endl; diff --git a/src/common/util/RedlandAtom.h b/src/common/util/RedlandAtom.h index 6b5658cf..df55affb 100644 --- a/src/common/util/RedlandAtom.h +++ b/src/common/util/RedlandAtom.h @@ -17,7 +17,8 @@ #ifndef REDLAND_ATOM_H #define REDLAND_ATOM_H -#include <redland.h> +#include <cstring> +#include <raptor.h> #include "util/Atom.h" #define U(x) ((const unsigned char*)(x)) @@ -28,31 +29,46 @@ */ class RedlandAtom { public: - static librdf_node* atom_to_node(librdf_world* world, const Atom& atom) { - char tmp_buf[32]; + /** Set this atom's value to the object (value) portion of an RDF triple. + * + * Caller is responsible for calling free(triple->object). + */ + static void atom_to_triple_object(raptor_statement* triple, const Atom& atom) { + static const size_t STR_LENGTH = 32; // FIXME ? + char* str = (char*)malloc(sizeof(char) * STR_LENGTH); switch (atom.type()) { - //case NIL: - // (see below) - //break; case Atom::INT: - snprintf(tmp_buf, 32, "%d", atom.get_int32()); - return librdf_new_node_from_typed_literal(world, U(tmp_buf), NULL, librdf_new_uri(world, U("http://www.w3.org/2001/XMLSchema#integer"))); - break; + snprintf(str, 32, "%d", atom.get_int32()); + triple->object = (unsigned char*)str; + triple->object_type = RAPTOR_IDENTIFIER_TYPE_LITERAL; + triple->object_literal_datatype = raptor_new_uri( + U("http://www.w3.org/2001/XMLSchema#integer")); + break; case Atom::FLOAT: - snprintf(tmp_buf, 32, "%f", atom.get_float()); - return librdf_new_node_from_typed_literal(world, U(tmp_buf), NULL, librdf_new_uri(world, U("http://www.w3.org/2001/XMLSchema#float"))); + snprintf(str, 32, "%f", atom.get_float()); + triple->object = (unsigned char*)str; + triple->object_type = RAPTOR_IDENTIFIER_TYPE_LITERAL; + triple->object_literal_datatype = raptor_new_uri( + U("http://www.w3.org/2001/XMLSchema#float")); break; case Atom::STRING: - return librdf_new_node_from_literal(world, U(atom.get_string()), NULL, 0); + snprintf(str, 32, "%f", atom.get_float()); + triple->object = (unsigned char*)str; + triple->object_type = RAPTOR_IDENTIFIER_TYPE_LITERAL; + break; case Atom::BLOB: + case Atom::NIL: + default: cerr << "WARNING: Unserializable atom!" << endl; - return NULL; - default: // This catches Atom::Type::NIL too - return librdf_new_node(world); // blank node + // FIXME: what to do? + triple->object = NULL; + triple->object_type = RAPTOR_IDENTIFIER_TYPE_UNKNOWN; + free(str); // FIXME: ew } } +#if 0 static Atom node_to_atom(librdf_node* node) { /*switch (type) { case 'i': @@ -70,6 +86,7 @@ public: cerr << "FIXME: node_to_atom\n"; return Atom(); } +#endif }; |