Commit 215da4f6 authored by Fabian Vogt's avatar Fabian Vogt

Drop KIOFuseNode::NodeType in favor of using RTTI everywhere

Convert some uses of the type member into dynamic casts or typeid
comparisons. Has slightly more overhead, but in the success case
the result is needed anyway.
Also remove some unnecessary Q_OBJECT macros while at it.
parent 8bf5d0e1
......@@ -67,8 +67,8 @@ Each node knows about its parent and children inode numbers. The two root nodes
have an invalid inode number (0) set as parent.
For details on the class hierarchy and their members, read kiofusenode.h.
For carrying out special operations depending on the node type, either the
node's virtual type method is called or RTTI is queried using dynamic_cast.
For carrying out special operations depending on the node type, RTTI is used,
by either querying the typeid or doing a dynamic_cast.
During runtime, the tree can look like this:
......
......@@ -29,23 +29,6 @@ public:
virtual ~KIOFuseNode() {}
enum class NodeType {
// Dir types
RootNode,
ProtocolNode,
RemoteDirNode,
LastDirType = RemoteDirNode,
// File types
RemoteSymlinkNode,
RemoteCacheBasedFileNode,
RemoteFileJobBasedFileNode,
};
// By having this as a virtual method instead of a class member
// this is "for free" - the vtable ptr is enough
virtual NodeType type() const = 0;
uint64_t m_lookupCount = 0, // This counts how many references to this node the kernel has
m_openCount = 0; // This counts how often the kernel has this node opened
fuse_ino_t m_parentIno;
......@@ -64,15 +47,11 @@ public:
class KIOFuseRootNode : public KIOFuseDirNode {
public:
using KIOFuseDirNode::KIOFuseDirNode;
static const NodeType Type = NodeType::RootNode;
NodeType type() const override { return Type; }
};
class KIOFuseProtocolNode : public KIOFuseDirNode {
public:
using KIOFuseDirNode::KIOFuseDirNode;
static const NodeType Type = NodeType::ProtocolNode;
NodeType type() const override { return Type; }
};
// Used for automated testing of expiration.
......@@ -102,8 +81,6 @@ class KIOFuseRemoteDirNode : public KIOFuseRemoteNodeInfo, public KIOFuseDirNode
Q_OBJECT
public:
using KIOFuseDirNode::KIOFuseDirNode;
static const NodeType Type = NodeType::RemoteDirNode;
NodeType type() const override { return Type; }
// Whether a dirlist was requested. If true, the signal "gotChildren" will
// be emitted on finish.
......@@ -119,7 +96,6 @@ Q_SIGNALS:
};
class KIOFuseRemoteFileNode : public KIOFuseRemoteNodeInfo, public KIOFuseNode {
Q_OBJECT
public:
using KIOFuseNode::KIOFuseNode;
};
......@@ -132,8 +108,6 @@ public:
if(m_localCache)
fclose(m_localCache);
}
static const NodeType Type = NodeType::RemoteCacheBasedFileNode;
NodeType type() const override { return Type; }
// Cache information
bool cacheIsComplete() { return m_cacheComplete; }
FILE *m_localCache = nullptr; // The tmpfile containing data. If nullptr, not requested yet.
......@@ -149,19 +123,13 @@ Q_SIGNALS:
void cacheFlushed(int error);
};
class KIOFuseRemoteFileJobBasedFileNode : public KIOFuseRemoteFileNode {
Q_OBJECT
public:
using KIOFuseRemoteFileNode::KIOFuseRemoteFileNode;
static const NodeType Type = NodeType::RemoteFileJobBasedFileNode;
NodeType type() const override { return Type; }
};
class KIOFuseSymLinkNode : public KIOFuseRemoteNodeInfo, public KIOFuseNode {
public:
using KIOFuseNode::KIOFuseNode;
static const NodeType Type = NodeType::RemoteSymlinkNode;
NodeType type() const override { return Type; }
QString m_target;
};
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment