ArnLib  4.0.x
Active Registry Network
ArnCoreItem.cpp
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 #include "ArnInc/ArnBasicItem.hpp"
33 #include "ArnInc/ArnAdaptItem.hpp"
34 #include "private/ArnBasicItem_p.hpp"
35 #include "ArnInc/ArnM.hpp"
36 #include "ArnInc/ArnEvent.hpp"
37 #include "ArnInc/ArnLib.hpp"
38 #include "ArnLink.hpp"
39 #include <QDataStream>
40 #include <QThreadStorage>
41 #include <QCoreApplication>
42 #include <QThread>
43 #include <QDebug>
44 
45 
46 void ArnCoreItem::init()
47 {
48 }
49 
50 
52  : d_ptr( new ArnBasicItemPrivate)
53 {
54 }
55 
56 
57 ArnCoreItem::ArnCoreItem( ArnBasicItemPrivate& dd)
58  : d_ptr( &dd)
59 {
60 }
61 
62 
64 {
65  delete d_ptr;
66 }
67 
68 
69 QThread* ArnCoreItem::thread() const
70 {
71  Heritage heritage = d_ptr->heritage();
72  if (heritage.is( Heritage::AdaptItem)) {
73  return reinterpret_cast<const ArnAdaptItem*>(this)->thread();
74  }
75  else if (heritage.is( Heritage::BasicItem)) {
76  return static_cast<const ArnBasicItem*>(this)->thread();
77  }
78  return arnNullptr; // TODO:
79 }
80 
81 
82 void ArnCoreItem::sendArnEventItem( ArnEvent* ev, bool isAlienThread, bool isLocked)
83 {
84  Heritage heritage = d_ptr->heritage();
85  if (heritage.is( Heritage::AdaptItem)) {
86  return reinterpret_cast<ArnAdaptItem*>(this)->sendArnEventItem( ev, isAlienThread, isLocked);
87  }
88  else if (heritage.is( Heritage::BasicItem)) {
89  return static_cast<ArnBasicItem*>(this)->sendArnEventItem( ev, isAlienThread, isLocked);
90  }
91 }
92 
93 
94 void ArnCoreItem::addHeritage( ArnCoreItem::Heritage heritage)
95 {
96  d_ptr->addHeritage( heritage);
97 }
! Non Qt and threadsafe handle for an Arn Data Object.
ArnCoreItem()
Standard constructor of a closed handle.
Definition: ArnCoreItem.cpp:51
QThread * thread() const
Get the thread affinity of this ArnCoreItem.
Definition: ArnCoreItem.cpp:69
virtual ~ArnCoreItem()
Definition: ArnCoreItem.cpp:63
Base class handle for an Arn Data Object.