Skip to content

5 minutes HOWTO guide

chefabien edited this page Feb 22, 2016 · 14 revisions

This page shows you how to get started with AutoRDF

#Compiling from source on Debian or Ubuntu

apt-get install build-essential cmake librdf0-dev 
cmake .
make install

Write your ontology

We assume here that you already have a working OWL or RDFS file somewhere that defines your ontology. If not we suggest you start playing with some existing ontology such as FOAF, available at http://xmlns.com/foaf/spec/20140114.rdf

Start generating generating code

fchevalier@ganymede:/tmp/test$ autordfcodegen -a 20140114.rdf 
No prefix found for class http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing namespace, ignoring
Class http://xmlns.com/foaf/0.1/Person has unreachable ancesto http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing, ignoring ancestor
Property http://xmlns.com/foaf/0.1/based_near refers to unreachable rdfs class     http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing, skipping
Property http://xmlns.com/foaf/0.1/focus refers to unreachable rdfs class http://www.w3.org/2004/02/skos/core#Concept, skipping

Write your first program

#include <autordf/Factory.h>

#include <foaf/foaf.h>

int main(int argc, char ** argv) {
    autordf::Factory f;
    autordf::Object::setFactory(&f);

    if ( argc == 2 ) {
        f.loadFromFile(argv[1]);
    } else {
        std::cerr << "Should provide rdf file as first argument" << std::endl;
    }

    auto personList = foaf::Person::find();

    for ( const foaf::Person& person : personList ) {
        std::cout << "Found " << person.nameList() << std::endl;
    }
}

Compile the whole thing

clang++ -std=c++11 -I. -I/usr/local/include main.cpp RdfTypeInfo.cpp AllInOne.cpp -lautordf -o main

Clone this wiki locally