Prefetcher.hpp 1.54 KB
Newer Older
1 2 3 4
#ifndef __HEPNOS_PREFETCHER_HPP
#define __HEPNOS_PREFETCHER_HPP

#include <memory>
5
#include <hepnos/Demangle.hpp>
6
#include <hepnos/Prefetchable.hpp>
7 8 9 10 11 12 13

namespace hepnos {

class DataStore;
class PrefetcherImpl;
class AsyncEngine;
class RunSet;
14 15 16
class EventSet;
class Run;
class SubRun;
17
class Event;
18 19 20 21

class Prefetcher {

    friend class RunSet;
22 23 24
    friend class EventSet;
    friend class Run;
    friend class SubRun;
25
    friend class Event;
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

    public:

    Prefetcher(const DataStore& ds,
               unsigned int cache_size=16,
               unsigned int batch_size=16);
    Prefetcher(const DataStore& ds, const AsyncEngine& async, 
               unsigned int cache_size=16,
               unsigned int batch_size=16);
    ~Prefetcher();
    Prefetcher(const Prefetcher&) = delete;
    Prefetcher(Prefetcher&&) = delete;
    Prefetcher& operator=(const Prefetcher&) = delete;
    Prefetcher& operator=(Prefetcher&&) = delete;

    unsigned int getCacheSize() const;
    void setCacheSize(unsigned int size);
    unsigned int getBatchSize() const;
    void setBatchSize(unsigned int size);
45 46 47 48 49

    template<typename Container>
    Prefetchable<Container> operator()(const Container& c) const {
        return Prefetchable<Container>(c, *this);
    }
50 51 52 53 54 55 56 57 58 59 60 61

    template<typename V>
    void fetchProduct(const std::string& label, bool fetch=true) const {
        fetchProductImpl(label + "#" + demangle<V>(), fetch);
    }

    private:

    std::shared_ptr<PrefetcherImpl> m_impl;

    void fetchProductImpl(const std::string& labelAndType, bool fetch) const;

62 63 64 65 66
};

}

#endif