EPT library documentation

to the EPT library

The EPT library is a collection of data providers, that are interface to access various kind of information about packages.

All data providers are independent from each other and can be instantiated alone. This allows to instantiate only the amount of infrastructure that is needed for a job, and to use alternative data provider implementations where appropriate.

Because of this, for example, libept can be used in applications that already use libapt-pkg directly: if the Apt object is not instantiated, then libept will not use the apt-pkg library at all.

Package names (and, where used, versions) are what brings all the data providers together: all the data providers access information about Debian packages, which have a well defined namespace. libept represents a package simply with a std::string containing its name: to get various kinds of information about a package, one just queries it by name to many data providers:

    Apt apt;
    Debtags debtags;
    Popcon popcon;

    // Get the Apt record for the debtags package
    PackageRecord record(apt.rawRecord("debtags"));

    // Get the tags of the debtags package
    std::set<Tag> tags = debtags.getTagsOfItem("debtags");

    // Get the popcon score of the debtags package
    float score = popcon.score("debtags");

    // Print the records of all image editors
    std::set<Tag> imageEditors;
    imageEditors.insert(debtags.vocabulary().tagByName("use::editing"));
    imageEditors.insert(debtags.vocabulary().tagByName("works-with::image"));
    imageEditors.insert(debtags.vocabulary().tagByName("role::program"));
    std::set<std::string> packages = debtags.getItemsHavingTags(imageEditors);
    for (std::set<std::string>::const_iterator i = packages.begin();
        i != packages.end(); ++i)
    {
        PackageRecord rec(apt.rawRecord(*i));
        PackageState state = apt.state(*i);
        // Also show whether a package is installed
        if (state.isInstalled())
            std::cout << rec.package() << " i " << rec.shortDescription();
        else
            std::cout << rec.package() << " - " << rec.shortDescription();
    }

A data provider does not need to know about the others, nor it needs to implement a specific interface: the only requirement on a data provider is that it can be queried using package names.

The only methods that are found in all data providers are hasData() and timestamp(), that can be used to query if a data provider is working and how up to date it is.

The data providers currently implemented are:

It is easy to implement more data providers. It is also easy to implement new data providers outside of this library, as long as they can be queried using package names.