OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
OpenXcom::ItemContainer Class Reference

Represents the items contained by a certain entity, like base stores, craft equipment, etc. More...

#include <ItemContainer.h>

Public Member Functions

 ItemContainer ()
 Creates an empty item container. More...
 
 ~ItemContainer ()
 Cleans up the item container.
 
void load (const YAML::Node &node)
 Loads the item container from YAML. More...
 
YAML::Node save () const
 Saves the item container to YAML. More...
 
void addItem (const std::string &id, int qty=1)
 Adds an item to the container. More...
 
void removeItem (const std::string &id, int qty=1)
 Removes an item from the container. More...
 
int getItem (const std::string &id) const
 Gets an item in the container. More...
 
int getTotalQuantity () const
 Gets the total quantity of items in the container. More...
 
double getTotalSize (const Ruleset *rule) const
 Gets the total size of items in the container. More...
 
std::map< std::string, int > * getContents ()
 Gets all the items in the container. More...
 

Detailed Description

Represents the items contained by a certain entity, like base stores, craft equipment, etc.

Handles all necessary item management tasks.

Constructor & Destructor Documentation

OpenXcom::ItemContainer::ItemContainer ( )

Creates an empty item container.

Initializes an item container with no contents.

Member Function Documentation

void OpenXcom::ItemContainer::addItem ( const std::string &  id,
int  qty = 1 
)

Adds an item to the container.

Adds an item amount to the container.

Parameters
idItem ID.
qtyItem quantity.
std::map< std::string, int > * OpenXcom::ItemContainer::getContents ( )

Gets all the items in the container.

Returns all the items currently contained within.

Returns
List of contents.
int OpenXcom::ItemContainer::getItem ( const std::string &  id) const

Gets an item in the container.

Returns the quantity of an item in the container.

Parameters
idItem ID.
Returns
Item quantity.
int OpenXcom::ItemContainer::getTotalQuantity ( ) const

Gets the total quantity of items in the container.

Returns the total quantity of the items in the container.

Returns
Total item quantity.
double OpenXcom::ItemContainer::getTotalSize ( const Ruleset rule) const

Gets the total size of items in the container.

Returns the total size of the items in the container.

Parameters
rulePointer to ruleset.
Returns
Total item size.
void OpenXcom::ItemContainer::load ( const YAML::Node &  node)

Loads the item container from YAML.

Loads the item container from a YAML file.

Parameters
nodeYAML node.
void OpenXcom::ItemContainer::removeItem ( const std::string &  id,
int  qty = 1 
)

Removes an item from the container.

Removes an item amount from the container.

Parameters
idItem ID.
qtyItem quantity.
YAML::Node OpenXcom::ItemContainer::save ( ) const

Saves the item container to YAML.

Saves the item container to a YAML file.

Returns
YAML node.

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