Files
Cockatrice/common/abstract_deck_list_card_node.h
BruebachL f8c4f774cf [Documentation] Sort *every* file into a doxygen group. (#6198)
* Sort *every* file into a doxygen group.

Took 7 hours 9 minutes

Took 18 seconds

Took 2 minutes

* Lint some ingroup definitions.

Took 10 minutes


Took 2 seconds

* Just include the groups in the Doxyfile in this commit.

Took 3 minutes

* Update some group comments so they link!

Took 14 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
2025-09-30 12:13:32 +02:00

150 lines
5.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @file abstract_deck_list_card_node.h
* @brief Defines the AbstractDecklistCardNode base class, which adds
* card-specific behavior on top of AbstractDecklistNode.
*
* This class is the intermediate abstract base between the generic
* AbstractDecklistNode and concrete card entries such as DecklistCardNode
* or DecklistModelCardNode.
*/
#ifndef COCKATRICE_ABSTRACT_DECK_LIST_CARD_NODE_H
#define COCKATRICE_ABSTRACT_DECK_LIST_CARD_NODE_H
#include "abstract_deck_list_node.h"
/**
* @class AbstractDecklistCardNode
* @ingroup DeckModels
* @brief Abstract base class for all deck list nodes that represent
* actual card entries.
*
* While AbstractDecklistNode provides the general interface for all
* nodes in the deck tree (zones, groups, cards), this subclass refines
* the interface to cover properties specific to *cards*:
* - Quantity (number of copies).
* - Name.
* - Set code and collector number.
* - Provider ID.
*
* ### Role in the hierarchy:
* - Leaf-oriented abstract class; no children of its own.
* - Serves as the base for concrete implementations:
* - @c DecklistCardNode: Stores real card data in the deck tree.
* - @c DecklistModelCardNode: Wraps a DecklistCardNode for use
* in the Qt model layer.
*
* ### Responsibilities:
* - Defines getters/setters for all card-identifying attributes.
* - Provides comparison logic for sorting by name or number.
* - Implements XML serialization for saving/loading deck files.
*
* ### Ownership:
* - As with all nodes, owned by its parent InnerDecklistNode.
*/
class AbstractDecklistCardNode : public AbstractDecklistNode
{
public:
/**
* @brief Construct a new AbstractDecklistCardNode.
*
* @param _parent Optional parent node. If provided, this node
* will be inserted into the parents children list.
* @param position Index at which to insert into parents children.
* If -1, the node is appended to the end.
*/
explicit AbstractDecklistCardNode(InnerDecklistNode *_parent = nullptr, int position = -1)
: AbstractDecklistNode(_parent, position)
{
}
/// @return The number of copies of this card in the deck.
virtual int getNumber() const = 0;
/// @param _number Set the number of copies of this card.
virtual void setNumber(int _number) = 0;
/// @return The display name of this card.
QString getName() const override = 0;
/// @param _name Set the display name of this card.
virtual void setName(const QString &_name) = 0;
/// @return The provider identifier for this card (e.g., UUID).
virtual QString getCardProviderId() const override = 0;
/// @param _cardProviderId Set the provider identifier for this card.
virtual void setCardProviderId(const QString &_cardProviderId) = 0;
/// @return The abbreviated set code (e.g., "NEO").
virtual QString getCardSetShortName() const override = 0;
/// @param _cardSetShortName Set the abbreviated set code.
virtual void setCardSetShortName(const QString &_cardSetShortName) = 0;
/// @return The collector number of the card within its set.
virtual QString getCardCollectorNumber() const override = 0;
/// @param _cardSetNumber Set the collector number.
virtual void setCardCollectorNumber(const QString &_cardSetNumber) = 0;
/**
* @brief Get the height of this node in the tree.
*
* For card nodes, height is always 0 because they are leaf nodes
* and do not contain children.
*
* @return 0
*/
int height() const override
{
return 0;
}
/**
* @brief Compare this card node against another for sorting.
*
* Uses the nodes current @c sortMethod to determine how to compare:
* - ByName: Alphabetical comparison.
* - ByNumber: Numerical comparison.
* - Default: Falls back to implementation-defined behavior.
*
* @param other Another node to compare against.
* @return true if this node should sort before @p other.
*/
bool compare(AbstractDecklistNode *other) const override;
/**
* @brief Compare this card node to another by quantity.
* @param other Node to compare against.
* @return true if this nodes number < others number.
*/
bool compareNumber(AbstractDecklistNode *other) const;
/**
* @brief Compare this card node to another by name.
* @param other Node to compare against.
* @return true if this nodes name comes before others name.
*/
bool compareName(AbstractDecklistNode *other) const;
/**
* @brief Deserialize this nodes properties from XML.
* @param xml QXmlStreamReader positioned at the element.
* @return true if parsing succeeded.
*
* This supports loading deck files from Cockatrices XML format.
*/
bool readElement(QXmlStreamReader *xml) override;
/**
* @brief Serialize this nodes properties to XML.
* @param xml Writer to append this nodes XML element.
*
* This supports saving deck files to Cockatrices XML format.
*/
void writeElement(QXmlStreamWriter *xml) override;
};
#endif // COCKATRICE_ABSTRACT_DECK_LIST_CARD_NODE_H