<commit_before>/*
 * Copyright (c) 2017 SUSE LLC
 *
 * All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as published
 * by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, contact Novell, Inc.
 *
 * To contact Novell about this file by physical or electronic mail, you may
 * find current contact information at www.novell.com.
 */


#ifndef STORAGE_MOUNT_POINT_H
#define STORAGE_MOUNT_POINT_H


#include "storage/Devices/Device.h"
#include "storage/Filesystems/Mountable.h"


namespace storage
{

    class Devicegraph;


    class InvalidMountPointPath : public Exception
    {
    public:

        InvalidMountPointPath(const std::string& path);
    };


    /**
     * Class to represent a mount point.
     */
    class MountPoint : public Device
    {
    public:

	/**
	 * @throw InvalidMountPointPath
	 */
	static MountPoint* create(Devicegraph* devicegraph, const std::string& path);

	static MountPoint* load(Devicegraph* devicegraph, const xmlNode* node);

	static std::vector<MountPoint*> get_all(Devicegraph* devicegraph);
	static std::vector<const MountPoint*> get_all(const Devicegraph* devicegraph);

	const std::string& get_path() const;

	/**
	 * @throw InvalidMountPointPath
	 */
	void set_path(const std::string& path);

	/**
	 * Get the mount-by method.
	 */
	MountByType get_mount_by() const;

	/**
	 * Set the mount-by method.
	 */
	void set_mount_by(const MountByType mount_by);

	/**
	 * Set the mount-by method to the global default, see
	 * Storage::get_default_mount_by().
	 */
	void set_default_mount_by();

	const std::vector<std::string>& get_mount_options() const;
	void set_mount_options(const std::vector<std::string>& mount_options);

	void set_default_mount_options();

	int get_freq() const;

	int get_passno() const;

	bool is_active() const;
	void set_active(bool active);

	/**
	 * Query whether the mount point is present (probed devicegraph) or
	 * will be present (staging devicegraph) in /etc/fstab.
	 */
	bool is_in_etc_fstab() const;

	/**
	 * Set whether the mount point will be present in /etc/fstab.
	 */
	void set_in_etc_fstab(bool in_etc_fstab);

	/**
	 * Checks whether the mount point has a mountable. This is usally true
	 * unless the devicegraph is broken.<commit_msg>- extended documentation<commit_after>/*
 * Copyright (c) 2017 SUSE LLC
 *
 * All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as published
 * by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, contact Novell, Inc.
 *
 * To contact Novell about this file by physical or electronic mail, you may
 * find current contact information at www.novell.com.
 */


#ifndef STORAGE_MOUNT_POINT_H
#define STORAGE_MOUNT_POINT_H


#include "storage/Devices/Device.h"
#include "storage/Filesystems/Mountable.h"


namespace storage
{

    class Devicegraph;


    class InvalidMountPointPath : public Exception
    {
    public:

        InvalidMountPointPath(const std::string& path);
    };


    /**
     * Class to represent a mount point.
     */
    class MountPoint : public Device
    {
    public:

	/**
	 * @throw InvalidMountPointPath
	 */
	static MountPoint* create(Devicegraph* devicegraph, const std::string& path);

	static MountPoint* load(Devicegraph* devicegraph, const xmlNode* node);

	static std::vector<MountPoint*> get_all(Devicegraph* devicegraph);
	static std::vector<const MountPoint*> get_all(const Devicegraph* devicegraph);

	const std::string& get_path() const;

	/**
	 * @throw InvalidMountPointPath
	 */
	void set_path(const std::string& path);

	/**
	 * Get the mount-by method.
	 */
	MountByType get_mount_by() const;

	/**
	 * Set the mount-by method.
	 */
	void set_mount_by(const MountByType mount_by);

	/**
	 * Set the mount-by method to the global default, see
	 * Storage::get_default_mount_by().
	 */
	void set_default_mount_by();

	/**
	 * Get the mount options.
	 */
	const std::vector<std::string>& get_mount_options() const;

	/**
	 * Set the mount options. Avoid overriding the subvol option for btrfs
	 * subvolumes unless you are certain what you are doing.
	 */
	void set_mount_options(const std::vector<std::string>& mount_options);

	/**
	 * Set the mount options to the default mount options. So far the
	 * default mount options only contain the subvol for btrfs subvolumes.
	 */
	void set_default_mount_options();

	int get_freq() const;

	int get_passno() const;

	bool is_active() const;
	void set_active(bool active);

	/**
	 * Query whether the mount point is present (probed devicegraph) or
	 * will be present (staging devicegraph) in /etc/fstab.
	 */
	bool is_in_etc_fstab() const;

	/**
	 * Set whether the mount point will be present in /etc/fstab.
	 */
	void set_in_etc_fstab(bool in_etc_fstab);

	/**
	 * Checks whether the mount point has a mountable. This is usally true
	 * unless the devicegraph is broken.
{'fraction_non_alphanumeric': 0.09237794169301018, 'fraction_numerical': 0.0017562346329469617, 'mean_word_length': 3.777684563758389, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2209720', 'n_tokens_mistral': 1751, 'n_tokens_neox': 1632, 'n_words': 615}