Program Listing for File Source.hpp

Return to documentation for file (include/nix/Source.hpp)

// Copyright (c) 2013, German Neuroinformatics Node (G-Node)
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted under the terms of the BSD License. See
// LICENSE file in the root of the Project.

#ifndef NIX_SOURCE_H
#define NIX_SOURCE_H

#include <nix/util/filter.hpp>
#include <nix/types.hpp>
#include <nix/base/EntityWithMetadata.hpp>
#include <nix/base/ISource.hpp>
#include <nix/ObjectType.hpp>

#include <nix/Platform.hpp>

#include <ostream>
#include <string>

namespace nix {

class NIXAPI Source : public base::EntityWithMetadata<base::ISource> {

public:

    Source();

    Source(const Source &other);

    Source(const std::shared_ptr<base::ISource> &p_impl);

    Source(std::shared_ptr<base::ISource> &&ptr);

    //--------------------------------------------------
    // Methods concerning child sources
    //--------------------------------------------------

    bool hasSource(const std::string &name_or_id) const {
        return backend()->hasSource(name_or_id);
    }

    bool hasSource(const Source &source) const;

    Source getSource(const std::string &name_or_id) const {
        return backend()->getSource(name_or_id);
    }

    Source getSource(ndsize_t index) const {
        return backend()->getSource(index);
    }

    ndsize_t sourceCount() const {
        return backend()->sourceCount();
    }

    std::vector<Source> sources(const util::Filter<Source>::type &filter = util::AcceptAll<Source>()) const;

    std::vector<Source> findSources(const util::Filter<Source>::type &filter = util::AcceptAll<Source>(),
                                    size_t max_depth = std::numeric_limits<size_t>::max()) const;

    Source createSource(const std::string &name, const std::string &type);

    bool deleteSource(const std::string &name_or_id) {
        return backend()->deleteSource(name_or_id);
    }

    bool deleteSource(const Source &source);

    //--------------------------------------------------
    // Other methods and functions
    //--------------------------------------------------

    nix::Source parentSource() const;

    std::vector<nix::DataArray> referringDataArrays() const;


    std::vector<nix::Tag> referringTags() const;


    std::vector<nix::MultiTag> referringMultiTags() const;


    Source &operator=(const none_t &t) {
        ImplContainer::operator=(t);
        return *this;
    }

    Source &operator=(const Source &other)  {
        ImplContainer::operator=(other);
        return *this;
    }

    NIXAPI friend std::ostream& operator<<(std::ostream &out, const Source &ent);

};

template<>
struct objectToType<nix::Source> {
    static const bool isValid = true;
    static const ObjectType value = ObjectType::Source;
    typedef nix::base::ISource backendType;
};

NIXAPI std::ostream& operator<<(std::ostream &out, const Source &ent);

} // namespace nix

#endif // NIX_SOURCE_H