ArnLib  4.0.x
Active Registry Network
Arn.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 ARN_HPP
33 #define ARN_HPP
34 
35 #include "MQFlags.hpp"
36 #include "ArnLib_global.hpp"
37 #include <QString>
38 
39 #define DATASTREAM_VER QDataStream::Qt_4_6
40 
41 #if defined( ARNREAL_FLOAT)
42 # define ARNREAL float
43 #else
44 # define ARNREAL double
45 #endif
46 
47 
48 namespace Arn {
49 
50  const quint16 defaultTcpPort = 2022;
51 
52  extern const QString pathLocal;
53  extern const QString pathLocalSys;
54  extern const QString pathDiscover;
55  extern const QString pathDiscoverThis;
56  extern const QString pathDiscoverConnect;
57  extern const QString pathServer;
58  extern const QString pathServerSessions;
59 
61 struct SameValue {
62  enum E {
64  Accept = 0,
66  Ignore = 1,
69  };
71 };
72 
74 class DataType {
75  Q_GADGET
76  Q_ENUMS(E)
77 public:
78  enum E {
79  Null = 0,
80  Int = 1,
81  Double = 2,
82  Real = 2,
83  ByteArray = 3,
84  String = 4,
85  Variant = 5
86  // 16 and above (max 255) is reserved by ArnItemB::ExportCode
87  };
89 };
90 
92 class ExportCode {
93  Q_GADGET
94  Q_ENUMS(E)
95 public:
96  enum E {
97  ByteArray = 3,
98  String = 4,
99  Variant = 5, // Legacy
102  };
104 };
105 
107 struct InfoType {
108  enum E {
110  Custom = 0,
111  N // Max N = 1000
112  };
114 };
115 
118 class ObjectMode {
119  Q_GADGET
120  Q_ENUMS(E)
121 public:
122  enum E {
124  Normal = 0x00,
126  BiDir = 0x01,
128  Pipe = 0x02,
130  Save = 0x04
131  };
133 };
134 
137 class ObjectSyncMode { // This mode is sent with sync-command
138  Q_GADGET
139  Q_ENUMS(E)
140 public:
141  enum E {
143  Normal = 0x00,
145  Monitor = 0x01,
147  Master = 0x02,
149  AutoDestroy = 0x04
150  };
152 };
153 
156  enum E {
165  };
167 };
168 
170 struct LinkFlags {
171  enum E {
172  Folder = 0x01,
174  SilentError = 0x04,
175  LastLink = 0x08,
176  Threaded = 0x80
177  };
179 };
180 
181 struct NameF {
183  enum E {
185  Default = 0x00,
187  NoFolderMark = 0x01,
189  EmptyOk = 0x02,
191  Relative = 0x04
192  };
194 };
195 
196 struct Coding {
197  enum E {
199  Binary = 0x0000,
201  Text = 0x1000
202  };
204 };
205 
206 class Allow {
207  Q_GADGET
208  Q_ENUMS(E)
209 public:
210  enum E {
212  None = 0x00,
214  Read = 0x01,
216  Write = 0x02,
218  Create = 0x04,
220  Delete = 0x08,
222  ModeChange = 0x10,
224  ReadWrite = 0x03,
226  All = 0xff
227  };
229 };
230 
232 
239 QString convertName( const QString& name, Arn::NameF nameF = Arn::NameF());
240 
242 
247 QString fullPath( const QString& path);
248 
250 
253 bool isFolderPath( const QString& path);
254 
256 
260 bool isProviderPath( const QString& path);
261 
263 
267 QString itemName( const QString& path);
268 
270 
284 QString childPath( const QString& parentPath, const QString& posterityPath);
285 
287 
298 QString changeBasePath( const QString& oldBasePath, const QString& newBasePath, const QString& path);
299 
301 
310 QString makePath( const QString& parentPath, const QString& itemName);
311 
313 
323 QString addPath( const QString& parentPath, const QString& childRelPath,
325 
327 
333 QString convertPath( const QString& path,
335 
337 
342 QString parentPath( const QString& path);
343 
345 
351 QString twinPath( const QString& path);
352 
354 
362 QString providerPathIf( const QString& path, bool giveProviderPath = true);
363 
365 
368 QString uuidPath( const QString& path);
369 
371 
386 QString makeHostWithInfo( const QString& host, const QString& info);
387 
389 
400 QString hostFromHostWithInfo( const QString& hostWithInfo);
401 
402 bool isNullPtr( const void* ptr);
403 
404 uint rand();
405 
406 #ifndef DOXYGEN_SKIP
407 QString convertBaseName( const QString& name, Arn::NameF nameF);
408 #endif
409 
410 } // Arn::
411 
418 
419 #endif // ARN_HPP
QString childPath(const QString &parentPath, const QString &posterityPath)
Get substring for child from a path (posterityPath)
Definition: Arn.cpp:100
Data type of an Arn Data Object
Definition: Arn.hpp:74
QString convertName(const QString &name, NameF nameF)
Convert a name to a specific format.
Definition: Arn.cpp:54
Info type for exchange static (meta) info between ArnClient and ArnServer.
Definition: Arn.hpp:107
uint rand()
Definition: Arn.cpp:259
QString hostFromHostWithInfo(const QString &hostWithInfo)
Get the host from the HostWithInfo string.
Definition: Arn.cpp:242
Monitor of server object for client.
Definition: Arn.hpp:145
const QString pathDiscover
Definition: Arn.cpp:47
Path: "/@/test" ==> "//test", Item: "@" ==> "".
Definition: Arn.hpp:189
Delete Arn Objects.
Definition: Arn.hpp:220
Empty not ok, Path: Absolute Item: FolderMark.
Definition: Arn.hpp:185
Implies BiDir and all data is preserved as a stream.
Definition: Arn.hpp:128
E
Selects a format for path or item name.
Definition: Arn.hpp:183
const QString pathLocal
Definition: Arn.cpp:45
#define MQ_DECLARE_FLAGSTXT(FEStruct)
Flags text.
Definition: MQFlags.hpp:57
QString fullPath(const QString &path)
Convert a path to a full absolute path.
Definition: Arn.cpp:82
const QString pathServer
Definition: Arn.cpp:50
Value for Server, can not be set in Client.
Definition: Arn.hpp:158
#define MQ_DECLARE_FLAGS(FEStruct)
Flags.
Definition: MQFlagsBase.hpp:49
Assigning same value generates an update of the Arn Data Object
Definition: Arn.hpp:64
bool isNullPtr(const void *ptr)
Definition: Arn.cpp:253
The Client session Sync mode at connect & reconnect.
Definition: Arn.hpp:155
const QString pathLocalSys
Definition: Arn.cpp:46
const quint16 defaultTcpPort
Definition: Arn.hpp:50
Action when assigning same value to an ArnItem.
Definition: Arn.hpp:61
Nothing allowed.
Definition: Arn.hpp:212
Explicit permanent Master mode, typically an observer or manually setup Master mode.
Definition: Arn.hpp:164
Only on path, no effect on discrete names. "/test/value" ==> "test/value".
Definition: Arn.hpp:191
QString addPath(const QString &parentPath, const QString &childRelPath, Arn::NameF nameF)
Make a path from a parent and an additional relative path.
Definition: Arn.cpp:137
Convenience, allow all.
Definition: Arn.hpp:226
Read from Arn Objects.
Definition: Arn.hpp:214
A two way object, typically for validation or pipe.
Definition: Arn.hpp:126
const QString pathDiscoverConnect
Definition: Arn.cpp:49
QString makePath(const QString &parentPath, const QString &itemName)
Make a path from a parent and an item name.
Definition: Arn.cpp:128
QString changeBasePath(const QString &oldBasePath, const QString &newBasePath, const QString &path)
Change the base (start) of a path.
Definition: Arn.cpp:114
Text coding, can be any character set.
Definition: Arn.hpp:201
Assigning same value gives default action set in ArnM or ArnItem.
Definition: Arn.hpp:68
Write to Arn Objects.
Definition: Arn.hpp:216
QString uuidPath(const QString &path)
Get a path to an Arn Object with a unique uuid name.
Definition: Arn.cpp:222
#define MQ_DECLARE_OPERATORS_FOR_FLAGS(FEStruct)
Definition: MQFlagsBase.hpp:65
Definition: Arn.cpp:43
Destroy this Arn Data Object when client (tcp/ip) closes.
Definition: Arn.hpp:149
QString convertPath(const QString &path, Arn::NameF nameF)
Convert a path to a specific format.
Definition: Arn.cpp:148
QString twinPath(const QString &path)
Get the bidirectional twin to a given path
Definition: Arn.cpp:195
First local write gives permanent Master mode, typically a client value reporter. ...
Definition: Arn.hpp:162
Code used in blob for arnExport() and arnImport()
Definition: Arn.hpp:92
const QString pathServerSessions
Definition: Arn.cpp:51
QString providerPathIf(const QString &path, bool giveProviderPath)
Get provider path or requester path
Definition: Arn.cpp:204
const QString pathDiscoverThis
Definition: Arn.cpp:48
QString parentPath(const QString &path)
Get the parent to a given path
Definition: Arn.cpp:183
#define MQ_DECLARE_ENUMTXT(EStruct)
Enums text.
Definition: MQFlags.hpp:102
Change Mode of Arn Objects.
Definition: Arn.hpp:222
QString itemName(const QString &path)
The last part of a path
Definition: Arn.cpp:90
Convenience, allow read & write.
Definition: Arn.hpp:224
Default dynamic auto master mode, general purpose, prohibit Null value sync.
Definition: Arn.hpp:160
QString makeHostWithInfo(const QString &host, const QString &info)
Make a combined host and info string, i.e. HostWithInfo
Definition: Arn.cpp:235
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
#define MQ_DECLARE_ENUM(EStruct)
Enums.
Definition: MQFlagsBase.hpp:70
No special coding, can be anything.
Definition: Arn.hpp:199
Only on discrete names, no effect on path. "test/" ==> "test".
Definition: Arn.hpp:187
Create Arn Objects.
Definition: Arn.hpp:218
The client is default generator of data.
Definition: Arn.hpp:147
bool isProviderPath(const QString &path)
Test if path is a provider path
Definition: Arn.cpp:216