ArnLib  4.0.x
Active Registry Network
ArnInterface.hpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2022 Michael Wiklund.
2 // All rights reserved.
3 // Contact: arnlib@wiklunden.se
4 //
5 // This file is part of the ArnLib - Active Registry Network.
6 // Parts of ArnLib depend on Qt and/or other libraries that have their own
7 // licenses. Usage of these other libraries is subject to their respective
8 // license agreements.
9 //
10 // GNU Lesser General Public License Usage
11 // This file may be used under the terms of the GNU Lesser General Public
12 // License version 2.1 as published by the Free Software Foundation and
13 // appearing in the file LICENSE_LGPL.txt included in the packaging of this
14 // file. In addition, as a special exception, you may use the rights described
15 // in the Nokia Qt LGPL Exception version 1.1, included in the file
16 // LGPL_EXCEPTION.txt in this package.
17 //
18 // GNU General Public License Usage
19 // Alternatively, this file may be used under the terms of the GNU General Public
20 // License version 3.0 as published by the Free Software Foundation and appearing
21 // in the file LICENSE_GPL.txt included in the packaging of this file.
22 //
23 // Other Usage
24 // Alternatively, this file may be used in accordance with the terms and conditions
25 // contained in a signed written agreement between you and Michael Wiklund.
26 //
27 // This program is distributed in the hope that it will be useful, but WITHOUT ANY
28 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
29 // PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
30 //
31 
32 #ifndef ARNINTERFACE_HPP
33 #define ARNINTERFACE_HPP
34 
35 #include "ArnLib_global.hpp"
36 #include "ArnM.hpp"
37 
38 
39 class ARNLIBSHARED_EXPORT ArnInterface : public QObject
40 {
41  Q_OBJECT
43  Q_PROPERTY( QString info READ info NOTIFY dummyNotifier)
44 public:
46  enum SameValue {
48  SameValue_Accept = Arn::SameValue::Accept,
50  SameValue_Ignore = Arn::SameValue::Ignore,
52  SameValue_DefaultAction = Arn::SameValue::DefaultAction
53  };
54  Q_ENUMS( SameValue)
55 
56 
57  enum DataType {
58  DataType_Null = Arn::DataType::Null,
59  DataType_Int = Arn::DataType::Int,
60  DataType_Double = Arn::DataType::Double,
61  DataType_Real = Arn::DataType::Real,
62  DataType_ByteArray = Arn::DataType::ByteArray,
63  DataType_String = Arn::DataType::String,
64  DataType_Variant = Arn::DataType::Variant
65  };
66  Q_ENUMS( DataType)
67 
68 
69  enum ObjectMode {
71  ObjectMode_BiDir = Arn::ObjectMode::BiDir,
73  ObjectMode_Pipe = Arn::ObjectMode::Pipe,
75  ObjectMode_Save = Arn::ObjectMode::Save
76  };
77  Q_ENUMS( ObjectMode)
78 
79 
80  enum NameF {
82  NameF_Default = Arn::NameF::Default,
84  NameF_NoFolderMark = Arn::NameF::NoFolderMark,
86  NameF_EmptyOk = Arn::NameF::EmptyOk,
88  NameF_Relative = Arn::NameF::Relative
89  };
90  Q_ENUMS( NameF)
91 
92  explicit ArnInterface( QObject* parent = arnNullptr) : QObject( parent) {}
94 
95  QString info() {return QString::fromUtf8( ArnM::instance().info().constData());}
97 
98 public slots:
99 
101  QVariant value( const QString& path) {return ArnM::instance().valueVariant( path);}
102 
104  QVariant variant( const QString& path) {return ArnM::instance().valueVariant( path);}
105 
107  QString string( const QString& path) {return ArnM::instance().valueString( path);}
108 
110  QByteArray bytes( const QString& path) {return ArnM::instance().valueByteArray( path);}
111 
113 #ifdef ARNREAL_FLOAT
114  float num( const QString& path) {return ArnM::instance().valueDouble( path);}
115 #else
116  double num( const QString& path) {return ArnM::instance().valueDouble( path);}
117 #endif
118 
120  int intNum( const QString& path) {return ArnM::instance().valueInt( path);}
121 
123  QStringList items( const QString& path) {return ArnM::instance().items( path);}
124 
126  bool exist(const QString& path) {return ArnM::instance().exist( path);}
127 
129  bool isFolder( const QString& path) {return ArnM::instance().isFolder( path);}
130 
132  bool isLeaf( const QString& path) {return ArnM::instance().isLeaf( path);}
133 
135  void setValue( const QString& path, const QVariant& value)
136  {ArnM::instance().setValue( path, value);}
137 
139  void setVariant( const QString& path, const QVariant& value, const QString& typeName = QString())
140  {ArnM::instance().setValue( path, value, typeName.toLatin1().constData());}
141 
143  void setString( const QString& path, const QString& value)
144  {ArnM::instance().setValue( path, value);}
145 
147  void setBytes( const QString& path, const QByteArray& value)
148  {ArnM::instance().setValue( path, value);}
149 
151 #ifdef ARNREAL_FLOAT
152  void setNum( const QString& path, float value)
153 #else
154  void setNum( const QString& path, double value)
155 #endif
156  {ArnM::instance().setValue( path, value);}
157 
159  void setIntNum( const QString& path, int value)
160  {ArnM::instance().setValue( path, value);}
161 
163 
165  bool isFolderPath( const QString& path) {return Arn::isFolderPath( path);}
166 
168  bool isProviderPath( const QString& path) {return Arn::isProviderPath( path);}
169 
171  QString itemName( const QString& path) {return Arn::itemName( path);}
172 
174  QString twinPath( const QString& path) {return Arn::twinPath( path);}
175 
177  QString changeBasePath( const QString& oldBasePath, const QString& newBasePath, const QString& path)
178  {return Arn::changeBasePath( oldBasePath, newBasePath, path);}
179 
181  QString childPath( const QString& parentPath, const QString& posterityPath)
182  {return Arn::childPath( parentPath, posterityPath);}
183 
185  QString makePath( const QString& parentPath, const QString& itemName)
186  {return Arn::makePath( parentPath, itemName);}
187 
189  QString providerPath( const QString& path, bool giveProviderPath = true)
190  {return Arn::providerPathIf( path, giveProviderPath);}
191 
193 signals:
194  void dummyNotifier();
196 };
197 
198 #endif // ARNINTERFACE_HPP
QString childPath(const QString &parentPath, const QString &posterityPath)
Get substring for child from a path (posterityPath)
Definition: Arn.cpp:100
QString changeBasePath(const QString &oldBasePath, const QString &newBasePath, const QString &path)
See Arn::changeBasePath()
bool isFolder(const QString &path)
See ArnM::isFolder()
static bool isFolder(const QString &path)
Definition: ArnM.cpp:413
void setValue(const QString &path, const QVariant &value)
See ArnM::setValue()
static void setValue(const QString &path, int value)
Assign an integer to an Arn Data Object at path
Definition: ArnM.cpp:473
bool isFolderPath(const QString &path)
See Arn::isFolderPath()
Path: "/@/test" ==> "//test", Item: "@" ==> "".
Definition: Arn.hpp:189
double num(const QString &path)
See ArnM::valueDouble()
Empty not ok, Path: Absolute Item: FolderMark.
Definition: Arn.hpp:185
static bool exist(const QString &path)
Definition: ArnM.cpp:402
Implies BiDir and all data is preserved as a stream.
Definition: Arn.hpp:128
void setBytes(const QString &path, const QByteArray &value)
See ArnM::setValue()
bool isProviderPath(const QString &path)
See Arn::isProviderPath()
NameF
Selects a format for path or item name.
static int valueInt(const QString &path)
Get the value of Arn Data Object at path
Definition: ArnM.cpp:244
QString providerPath(const QString &path, bool giveProviderPath=true)
See Arn::providerPath()
QVariant variant(const QString &path)
See ArnM::valueVariant()
Assigning same value generates an update of the Arn Data Object
Definition: Arn.hpp:64
int intNum(const QString &path)
See ArnM::valueInt()
static QString valueString(const QString &path)
Get the value of Arn Data Object at path
Definition: ArnM.cpp:272
Only on path, no effect on discrete names. "/test/value" ==> "test/value".
Definition: Arn.hpp:191
QString childPath(const QString &parentPath, const QString &posterityPath)
See Arn::childPath()
DataType
Data type of an Arn Data Object
static double valueDouble(const QString &path)
Get the value of Arn Data Object at path
Definition: ArnM.cpp:255
QString string(const QString &path)
See ArnM::valueString()
static QStringList items(const QString &path)
Get the childrens of the folder at path
Definition: ArnM.cpp:315
A two way object, typically for validation or pipe.
Definition: Arn.hpp:126
QVariant value(const QString &path)
See ArnM::valueVariant()
QString makePath(const QString &parentPath, const QString &itemName)
Make a path from a parent and an item name.
Definition: Arn.cpp:128
ObjectMode
General global mode of an Arn Data Object
QString changeBasePath(const QString &oldBasePath, const QString &newBasePath, const QString &path)
Change the base (start) of a path.
Definition: Arn.cpp:114
static bool isLeaf(const QString &path)
Definition: ArnM.cpp:424
Assigning same value gives default action set in ArnM or ArnItem.
Definition: Arn.hpp:68
static QVariant valueVariant(const QString &path)
Get the value of Arn Data Object at path
Definition: ArnM.cpp:294
static QByteArray valueByteArray(const QString &path)
Get the value of Arn Data Object at path
Definition: ArnM.cpp:283
void setNum(const QString &path, double value)
See ArnM::setValue()
SameValue
Action when assigning same value to an ArnItem.
QString twinPath(const QString &path)
Get the bidirectional twin to a given path
Definition: Arn.cpp:195
QStringList items(const QString &path)
See ArnM::items()
QString itemName(const QString &path)
See Arn::itemName()
QString makePath(const QString &parentPath, const QString &itemName)
See Arn::makePath()
bool isLeaf(const QString &path)
See ArnM::isLeaf()
bool exist(const QString &path)
See ArnM::exist()
QString providerPathIf(const QString &path, bool giveProviderPath)
Get provider path or requester path
Definition: Arn.cpp:204
QString twinPath(const QString &path)
See Arn::twinPath()
QString parentPath(const QString &path)
Get the parent to a given path
Definition: Arn.cpp:183
void setVariant(const QString &path, const QVariant &value, const QString &typeName=QString())
See ArnM::setValue()
static ArnM & instance()
Definition: ArnM.cpp:1048
QString itemName(const QString &path)
The last part of a path
Definition: Arn.cpp:90
#define ARNLIBSHARED_EXPORT
bool isFolderPath(const QString &path)
Test if path is a folder path
Definition: Arn.cpp:210
Assigning same value is ignored.
Definition: Arn.hpp:66
Data is persistent and will be saved.
Definition: Arn.hpp:130
Only on discrete names, no effect on path. "test/" ==> "test".
Definition: Arn.hpp:187
void setIntNum(const QString &path, int value)
See ArnM::setValue()
QByteArray bytes(const QString &path)
See ArnM::valueByteArray()
void setString(const QString &path, const QString &value)
See ArnM::setValue()
bool isProviderPath(const QString &path)
Test if path is a provider path
Definition: Arn.cpp:216