示例#1
0
文件: RDFS.cpp 项目: ventosus/ingen
Objects
instances(World* world, const URISet& types)
{
	LilvNode* rdf_type = lilv_new_uri(
		world->lilv_world(), LILV_NS_RDF "type");

	Objects result;
	for (const auto& t : types) {
		LilvNode*  type    = lilv_new_uri(world->lilv_world(), t.c_str());
		LilvNodes* objects = lilv_world_find_nodes(
			world->lilv_world(), NULL, rdf_type, type);
		LILV_FOREACH(nodes, o, objects) {
			const LilvNode* object = lilv_nodes_get(objects, o);
			if (!lilv_node_is_uri(object)) {
				continue;
			}
			const std::string label = RDFS::label(world, object);
			result.insert(
				std::make_pair(label,
				               Raul::URI(lilv_node_as_string(object))));
		}
		lilv_node_free(type);
	}

	lilv_node_free(rdf_type);
	return result;
}
示例#2
0
文件: sole.hpp 项目: guker/flipsta
        /** \brief
        Force the pointer for the object in store to be a specific pointer.

        This can be useful for singleton values.
        These usually must be removed from the store explicitly.

        \pre No object with this value is already in the store.
        */
        void set (std::shared_ptr <Value const> pointer) {
            // The value must not be in the store yet.
            assert (objects_.find (*pointer,
                boost::hash <Value>(), EqualToWeakPtr()) == objects_.end());

            objects_.insert (std::move (pointer));
        }
示例#3
0
文件: Store.cpp 项目: ventosus/ingen
void
Store::remove(const iterator top, Objects& removed)
{
	if (top != end()) {
		const iterator descendants_end = find_descendants_end(top);
		removed.insert(top, descendants_end);
		erase(top, descendants_end);
	}
}
示例#4
0
文件: sole.hpp 项目: guker/flipsta
        // Rvalue reference.
        std::shared_ptr <Value const> get (Value && value) {
            auto existing = objects_.find (value,
                boost::hash <Value>(), EqualToWeakPtr());
            if (existing != objects_.end())
                return existing->get();

            // The value is not in the store yet; insert it.
            auto sole = SoleType::construct (*this, std::move (value));
            Pointer newElement (sole);
            objects_.insert (std::move (newElement));

            return sole;
        }
示例#5
0
	// called in Stored constructor
	// assignes new unique ID and back iterator
	virtual ID add(Target * object)
	{
		assert(generator);
		if(!valid(object->id()))	
			object->localID=generator->generate(object);
		else if(contains(object->id()))
		{
			assert(false);
		}
		objects.insert(std::make_pair(object->id(),object));	
		Objects::iterator it=objects.find(object->id());
		object->back=it;
		onAdd(object);		// raise onAdd event.
		return object->id();
	}
示例#6
0
文件: sole.hpp 项目: guker/flipsta
        /** \brief
        Retrieve the sole object with value \a value.

        If an object with this value is already in the store, return a pointer
        to that object.
        If not, return a pointer to a newly allocated object.
        */
        std::shared_ptr <Value const> get (Value const & value) {
            auto existing = objects_.find (value,
                boost::hash <Value>(), EqualToWeakPtr());
            if (existing != objects_.end())
                return existing->get();

            // The value is not in the store yet; insert it.
            auto sole = SoleType::construct (*this, value);
            Pointer newElement (sole);
            // Note that this insertion involves a mere copy of newElement into
            // another place in memory.
            // No objects will therefore be deleted, and no objects will
            // therefore attempt to remove themselves from the store.
            objects_.insert (std::move (newElement));

            return sole;
        }