Samchon Framework for CPP  1.0.0
samchon::examples::packer::WrapperArray Class Reference

An array of wrapper with same category (name). More...

#include <WrapperArray.hpp>

Collaboration diagram for samchon::examples::packer::WrapperArray:

Public Member Functions

 WrapperArray ()
 Default Constructor. More...
 
 WrapperArray (const string &name, int price, int volume, int weight)
 Construct from arguments of sample. More...
 
 WrapperArray (const WrapperArray &wrapperArray)
 Copy Constructor. More...
 
auto tryInsert (shared_ptr< Product > product) -> bool
 Try to insert a product into reserved list. More...
 
void optimize ()
 Optimize to retrieve the best solution. More...
 
auto calcPrice () const -> int
 Calculate price of the Wrapper(s) More...
 
virtual auto CHILD_TAG () const -> string override
 A tag name of children. More...
 
virtual auto toXML () const -> shared_ptr< XML > override
 Get an XML object represents the EntityGroup. More...
 
auto toString () const -> string
 Return a string represents Wrapper(s) of same type. More...
 
- Public Member Functions inherited from samchon::protocol::EntityGroup< Container, T, Key >
virtual void construct (std::shared_ptr< library::XML > xml)
 Construct data of the Entity from an XML object. More...
 
auto find (const typename child_type::key_type &key) -> typename container_type::iterator
 Get iterator to element. More...
 
auto find (const typename child_type::key_type &key) const -> typename container_type::const_iterator
 Get const iterator to element. More...
 
auto has (const typename child_type::key_type &key) const -> bool
 Indicates whether a container has an object having the specified identifier. More...
 
auto count (const typename child_type::key_type &key) const -> size_t
 Count elements with a specific key. More...
 
auto get (const typename child_type::key_type &key) -> typename container_type::value_type &
 Access the element by specified identifier(key). More...
 
auto get (const typename child_type::key_type &key) const -> const typename container_type::value_type &
 Access the const element by specified identifier(key). More...
 
- Public Member Functions inherited from samchon::protocol::Entity< Key >
virtual auto key () const -> Key
 Get a key that can identify the Entity uniquely. More...
 

Protected Attributes

shared_ptr< ProductArrayreserved
 A list for reserved Product(s). More...
 
shared_ptr< Wrappersample
 A sample wrapper used to copy. More...
 

Additional Inherited Members

- Protected Member Functions inherited from samchon::protocol::EntityGroup< Container, T, Key >
virtual auto createChild (std::shared_ptr< library::XML >) -> child_type *=0
 Factory method of a child Entity. More...
 

Detailed Description

An array of wrapper with same category (name).

WrapperArray reserves Product(s) and generates enough number of Wrapper(s).

WrapperArray will retrieve the best arrange and packaging method for reserved Product(s).

example_packer.png
Author
Jeongho Nam http://samchon.org

Definition at line 32 of file WrapperArray.hpp.

Constructor & Destructor Documentation

samchon::examples::packer::WrapperArray::WrapperArray ( )
inline

Default Constructor.

Definition at line 56 of file WrapperArray.hpp.

samchon::examples::packer::WrapperArray::WrapperArray ( const string &  name,
int  price,
int  volume,
int  weight 
)
inline

Construct from arguments of sample.

Parameters
nameCategory name of a wrapper, can be identified
pricePrice of a wrapper
volumeLimited volume of a wrapper can put in.
weightLimited weight of a wrapper can put in.

Definition at line 71 of file WrapperArray.hpp.

samchon::examples::packer::WrapperArray::WrapperArray ( const WrapperArray wrapperArray)
inline

Copy Constructor.

Copy constructor of WrapperArray does not copy children items.

Only copies sample.

Definition at line 86 of file WrapperArray.hpp.

References sample.

Member Function Documentation

auto samchon::examples::packer::WrapperArray::tryInsert ( shared_ptr< Product product) -> bool
inline

Try to insert a product into reserved list.

If the Product's volume and weight is equal or less than the Wrapper categorized so that enable to insert in a Wrapper, reserve the Product and returns true. If not, does not reserve and just return false.

Returns
Whether the Product's volume and weight is equal or less than the Wrapper.

Definition at line 119 of file WrapperArray.hpp.

void samchon::examples::packer::WrapperArray::optimize ( )
inline

Optimize to retrieve the best solution.

Retrieve the best solution of packaging in level of WrapperArray.

Shuffles sequence of reserved Product(s) by samchon::FactorialGenerator and insert the reserved Products(s) following the sequence creating Wrapper(s) as needed. Between the sequences from FactorialGenerator, retrieve and determine the best solution.

Note

Sequence of inserting Product can affeact to numbers of Wrapper(s) to be used.

It's the reason why even WrapperArray has the optimize() method.

See also
samchon::FactorialGenerator

Definition at line 149 of file WrapperArray.hpp.

References samchon::examples::packer::Wrapper::tryInsert().

Here is the call graph for this function:

auto samchon::examples::packer::WrapperArray::calcPrice ( ) const -> int
inline

Calculate price of the Wrapper(s)

Calculates price of all wrapppers'. The price does not contain inserted products'

Definition at line 192 of file WrapperArray.hpp.

virtual auto samchon::examples::packer::WrapperArray::CHILD_TAG ( ) const -> string
inlineoverridevirtual

A tag name of children.

< TAG>
     <CHILD_TAG />
     <CHILD_TAG />
</TAG>

Implements samchon::protocol::EntityGroupBase.

Definition at line 204 of file WrapperArray.hpp.

virtual auto samchon::examples::packer::WrapperArray::toXML ( ) const -> shared_ptr<XML>
inlineoverridevirtual

Get an XML object represents the EntityGroup.

Archives the EntityGroup's own member variables only to the returned XML object.

Do not consider about archiving children Entity objects' data in EntityGroup::toXML(). Those children Entity objects will converted to XML object by their own toXML() method. The insertion of XML objects representing children are done by abstract method of EntityGroup::toXML().

Archives only data of EntityGroup's own.

[Inherited]

Reimplemented from samchon::protocol::EntityGroup< Container, T, Key >.

Definition at line 209 of file WrapperArray.hpp.

auto samchon::examples::packer::WrapperArray::toString ( ) const -> string
inline

Return a string represents Wrapper(s) of same type.

Definition at line 220 of file WrapperArray.hpp.

Member Data Documentation

shared_ptr<ProductArray> samchon::examples::packer::WrapperArray::reserved
protected

A list for reserved Product(s).

Definition at line 42 of file WrapperArray.hpp.

shared_ptr<Wrapper> samchon::examples::packer::WrapperArray::sample
protected

A sample wrapper used to copy.

Definition at line 47 of file WrapperArray.hpp.

Referenced by WrapperArray().


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