Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
AbstractDecklistNode Class Referenceabstract

Base class for all nodes in the deck list tree. More...

#include <abstract_deck_list_node.h>

Inheritance diagram for AbstractDecklistNode:
[legend]
Collaboration diagram for AbstractDecklistNode:
[legend]

Public Member Functions

 AbstractDecklistNode (InnerDecklistNode *_parent=nullptr, int position=-1)
 Construct a new AbstractDecklistNode and insert it into its parent.
virtual ~AbstractDecklistNode ()=default
 Virtual destructor. Child classes must clean up their resources.
virtual void setSortMethod (DeckSortMethod method)
 Set the sort method for this node’s children.
virtual bool isDeckHeader () const =0
 Whether this node is the "deck header" (deck metadata).
InnerDecklistNodegetParent () const
int depth () const
 Compute the depth of this node in the tree.
virtual int height () const =0
 Compute the "height" of this node.
virtual bool compare (AbstractDecklistNode *other) const =0
 Compare this node against another for sorting.
Core identification properties

These methods provide a standard way for the model to retrieve identifying information about a node, regardless of type.

virtual QString getName () const =0
virtual QString getCardProviderId () const =0
virtual QString getCardSetShortName () const =0
virtual QString getCardCollectorNumber () const =0
XML serialization

These methods support reading and writing decks from/to Cockatrice deck XML format.

virtual bool readElement (QXmlStreamReader *xml)=0
virtual void writeElement (QXmlStreamWriter *xml)=0

Protected Attributes

InnerDecklistNodeparent
 Pointer to the parent node, or nullptr if this is the root.
DeckSortMethod sortMethod
 Current sorting strategy for this node's children.

Detailed Description

Base class for all nodes in the deck list tree.

This class defines the common interface for every node in the deck representation: zones, groupings, and cards.

Responsibilities:

  • Maintain a pointer to its parent (if any).
  • Track the sorting method to be used for child nodes.
  • Provide a consistent interface for retrieving basic identifying properties (name, set, collector number, provider ID).
  • Define abstract methods for XML serialization, used when saving or loading deck files.

Lifetime / Ownership:

  • Nodes are arranged hierarchically under InnerDecklistNode parents.
  • The parent takes ownership of its children; destruction cascades.
  • The DeckListModel holds the invisible root node, which in turn owns the entire hierarchy.

Extension:

Constructor & Destructor Documentation

◆ AbstractDecklistNode()

AbstractDecklistNode::AbstractDecklistNode ( InnerDecklistNode * _parent = nullptr,
int position = -1 )
explicit

Construct a new AbstractDecklistNode and insert it into its parent.

Parameters
_parentParent node. May be nullptr if this is the root.
positionOptional index at which to insert into the parent's children. If -1, the node is appended to the end.

If a parent is provided, the constructor automatically appends or inserts this node into the parent’s child list.

Here is the caller graph for this function:

◆ ~AbstractDecklistNode()

virtual AbstractDecklistNode::~AbstractDecklistNode ( )
virtualdefault

Virtual destructor. Child classes must clean up their resources.

Member Function Documentation

◆ compare()

virtual bool AbstractDecklistNode::compare ( AbstractDecklistNode * other) const
pure virtual

Compare this node against another for sorting.

The semantics of comparison depend on the node type and the current sortMethod.

Parameters
otherThe node to compare against.
Returns
true if this node should come before other.

Implemented in AbstractDecklistCardNode, and InnerDecklistNode.

Here is the call graph for this function:

◆ depth()

int AbstractDecklistNode::depth ( ) const
nodiscard

Compute the depth of this node in the tree.

Returns
Distance from the root (root = 0, children = 1, etc.).

◆ getCardCollectorNumber()

virtual QString AbstractDecklistNode::getCardCollectorNumber ( ) const
nodiscardpure virtual

◆ getCardProviderId()

virtual QString AbstractDecklistNode::getCardProviderId ( ) const
nodiscardpure virtual

◆ getCardSetShortName()

virtual QString AbstractDecklistNode::getCardSetShortName ( ) const
nodiscardpure virtual

◆ getName()

virtual QString AbstractDecklistNode::getName ( ) const
nodiscardpure virtual

◆ getParent()

InnerDecklistNode * AbstractDecklistNode::getParent ( ) const
inlinenodiscard
Returns
The parent node, or nullptr if this is the root.
Here is the caller graph for this function:

◆ height()

virtual int AbstractDecklistNode::height ( ) const
nodiscardpure virtual

Compute the "height" of this node.

Height is defined by subclasses; it usually represents how many levels of descendants this node spans.

For example:

  • A card node has height 1.
  • A group node containing cards has height 2.

Implemented in AbstractDecklistCardNode, and InnerDecklistNode.

Here is the caller graph for this function:

◆ isDeckHeader()

virtual bool AbstractDecklistNode::isDeckHeader ( ) const
nodiscardpure virtual

Whether this node is the "deck header" (deck metadata).

This distinguishes special nodes that represent deck-level information rather than cards or groupings.

Implemented in DecklistCardNode, DecklistModelCardNode, and InnerDecklistNode.

Here is the caller graph for this function:

◆ readElement()

virtual bool AbstractDecklistNode::readElement ( QXmlStreamReader * xml)
pure virtual

◆ setSortMethod()

virtual void AbstractDecklistNode::setSortMethod ( DeckSortMethod method)
inlinevirtual

Set the sort method for this node’s children.

Parameters
methodThe sorting strategy to use.

Subclasses may override if they need to apply additional logic.

Reimplemented in InnerDecklistNode.

◆ writeElement()

virtual void AbstractDecklistNode::writeElement ( QXmlStreamWriter * xml)
pure virtual

Member Data Documentation

◆ parent

InnerDecklistNode* AbstractDecklistNode::parent
protected

Pointer to the parent node, or nullptr if this is the root.

Ownership note: The parent is responsible for destroying this node when it is removed from the tree.

◆ sortMethod

DeckSortMethod AbstractDecklistNode::sortMethod
protected

Current sorting strategy for this node's children.

Sorting is applied recursively by the DeckListModel when the view requests it.


The documentation for this class was generated from the following files: