ArnLib  4.0.x
Active Registry Network
ArnItemNet.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 ARNITEMNET_HPP
33 #define ARNITEMNET_HPP
34 
35 
36 #include "ArnInc/ArnBasicItem.hpp"
37 #include "ArnInc/ArnItem.hpp"
38 #include <QStringList>
39 
40 
42 class ArnItemNet : public ArnBasicItem
43 {
44 public:
45  explicit ArnItemNet( void* sessionHandler);
46  virtual ~ArnItemNet();
47  bool openWithFlags( const QString& path, Arn::LinkFlags linkFlags);
48 
49  void setNetId( uint netId);
50  uint netId() const;
51  void* sessionHandler() const;
52 
53  void addSyncModeString( const QByteArray& smode, bool linkShare);
54  QByteArray getSyncModeString() const;
55  void setModeString( const QByteArray& mode);
56  QByteArray getModeString() const;
57 
58  void sendNewItemMonEvent( const QString& path, bool isOld = false);
59  void sendMonEvent( int type, const QByteArray& data = QByteArray(), bool isLocal = true);
60  void setBlockEcho( bool blockEcho);
61  void setDisable( bool disable = true);
62  bool isDisable() const;
63  bool isMonitor() const;
64  void setMonitor( bool isMonitor);
65  void setQueueNum( int num);
66  int queueNum() const;
67  void nextEchoSeq();
68  void resetEchoSeq();
69  void setEchoSeq( qint8 echoSeq);
70  qint8 echoSeq() const;
71  bool isEchoSeqOld( qint8 receivedEchoSeq);
72 
73  void resetDirtyValue();
74  void resetDirtyMode();
75  bool isDirtyValue() const;
76  bool isDirtyMode() const;
77  bool isLeadValueUpdate();
78  bool isLeadModeUpdate();
79  bool isBlock( quint32 sendId);
80  void setIniMaster( bool iniMaster);
81  void setIniSlave( bool iniSlave);
82  bool isMasterAtStart() const;
83  void setSyncFlux( bool isSyncFlux);
84  bool isSyncFlux() const;
85  void setSaveFlux( bool saveFlux);
86  bool isSaveFlux() const;
87  quint32 localUpdateSinceStop() const;
88  void onConnectStop();
89 
90  virtual void arnEvent( QEvent* ev, bool isAlienThread);
91 
92  static Arn::ObjectMode stringToObjectMode( const QByteArray& modeString);
93  static QByteArray ObjectModeToString( Arn::ObjectMode mode);
94 
95  using ArnBasicItem::addSyncMode;
100  using ArnBasicItem::addIsOnlyEcho;
101  using ArnBasicItem::isOnlyEcho;
102  using ArnBasicItem::retireType;
103  using ArnBasicItem::type;
106  using ArnBasicItem::childItemsMain;
107  using ArnBasicItem::openWithFlags;
108 
109 private:
110  void init();
111 
112  void* _sessionHandler; // E.g ArnClient
113 
114  uint _netId; // id used during sync over net
115  int _queueNum; // number used in itemQueue
116  quint32 _updateCountStop; // Local update count at connection lost
117  qint8 _curEchoSeq; // Used to avoid obsolete echo
118  bool _dirty : 1; // item has been updated but not yet sent
119  bool _dirtyMode : 1; // item Mode has been updated but not yet sent
120  bool _disable : 1; // item is defunct and should not send (destroy command)
121  bool _isMonitor : 1; // item is used as a Monitor
122  bool _blockEcho : 1;
123  bool _iniMaster : 1; // Temporary master logic for next sync
124  bool _iniSlave : 1; // Temporary slave logic for next sync
125  bool _syncFlux : 1; // Value to be fluxed is due to sync
126  bool _saveFlux : 1; // Value to be fluxed is persist load or initial flux persistent
127 };
128 
129 
130 class ArnItemNetEar : public ArnItem
131 {
132  Q_OBJECT
133 public:
134  explicit ArnItemNetEar( QObject* parent = arnNullptr);
135 
136 signals:
137  void arnTreeCreated( const QString& path);
138  void arnTreeDestroyed( const QString& path, bool isGlobal);
139 
140 protected:
141  virtual void customEvent( QEvent* ev);
142 
143 private:
144 };
146 
147 #endif // ARNITEMNET_HPP
Arn::ObjectSyncMode syncMode() const
Arn::ObjectMode getMode() const
Use with care, link must be "referenced" before use, otherwise it might have been deleted...
void arnImport(const QByteArray &data, int ignoreSame=Arn::SameValue::DefaultAction)
Import data to an Arn Data Object
Arn::DataType type() const
The type stored in the Arn Data Object
bool isFolder() const
QByteArray arnExport() const
Handle for an Arn Data Object.
Definition: ArnItem.hpp:72
bool isPipeMode() const
Base class handle for an Arn Data Object.