/******************************************************************************* * Copyright (C) 2013-2015 Ragnar Thomsen * * * * This program is free software: you can redistribute it and/or modify it * * under the terms of the GNU General Public License as published by the Free * * Software Foundation, either version 2 of the License, or (at your option) * * any later version. * * * * 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, see . * *******************************************************************************/ #ifndef CONFOPTION_H #define CONFOPTION_H #include #include #include "kcm-systemd-features.h" #if defined(HAVE_CXX11_CHRONO) #include #include namespace ratio = std; namespace chrono = std::chrono; #else #include #include namespace ratio = boost; namespace chrono = boost::chrono; #endif enum settingType { BOOL, TIME, INTEGER, STRING, LIST, MULTILIST, RESLIMIT, SIZE }; enum confFile { SYSTEMD, JOURNALD, LOGIND, COREDUMP }; class confOption { public: typedef chrono::duration nanoseconds; typedef chrono::duration microseconds; typedef chrono::duration milliseconds; typedef chrono::duration seconds; typedef chrono::duration > minutes; typedef chrono::duration > hours; typedef chrono::duration > days; typedef chrono::duration > weeks; typedef chrono::duration > months; // define a month as 30.4375days typedef chrono::duration > years; typedef enum timeUnit { ns, us, ms, s, min, h, d, w, month, year } timeUnit; confFile file; settingType type; QString uniqueName, realName, toolTip; qlonglong minVal = 0, maxVal = 999999999; QStringList possibleVals = QStringList(); static QStringList capabilities; confOption(); // Used for comparing explicit confOption(QString newName); explicit confOption(QVariantMap); bool operator==(const confOption& other) const; int setValue(QVariant); int setValueFromFile(QString); bool isDefault() const; void setToDefault(); QVariant getValue() const; QString getValueAsString() const; QString getLineForFile() const; QString getFilename() const; QString getTimeUnit() const; private: bool hasNsec = false; QVariant value, defVal; timeUnit defUnit = timeUnit::s, defReadUnit = timeUnit::s, minUnit = timeUnit::ns, maxUnit = timeUnit::year; QVariant convertTimeUnit(double, timeUnit, timeUnit); }; #endif