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

A packer planning the best packaging. More...

#include <Packer.hpp>

Collaboration diagram for samchon::examples::packer::Packer:

Public Member Functions

 Packer ()
 Default Constructor. More...
 
 Packer (shared_ptr< ProductArray > productArray)
 Construct from products and wrapper. More...
 
 Packer (const Packer &packer)
 Copy Constructor. More...
 
auto productSize () const -> size_t
 Get number of products to package. More...
 
auto calcPrice () const -> int
 Calculate price of the wrappers. More...
 
void optimize (size_t start=0, size_t size=-1)
 Find the best packaging method. 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 an packaging method. 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< ProductArrayproductArray
 Prodcut(s) to package in some Wrapper(s) 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

A packer planning the best packaging.

example_packer.png

Retrieves the solution of packaging by combination permuation and factorial case.

Warning

Be careful about number of products and wrappers.

The time complexity of Packer overs O(m^n). Elapsed time of calculation increases enourmously. Do not use Packer if the digits of number of products or wrappers overs 2.

Author
Jeongho Nam http://samchon.org

Definition at line 36 of file Packer.hpp.

Constructor & Destructor Documentation

samchon::examples::packer::Packer::Packer ( )
inline

Default Constructor.

Definition at line 55 of file Packer.hpp.

samchon::examples::packer::Packer::Packer ( shared_ptr< ProductArray productArray)
inline

Construct from products and wrapper.

Parameters
productArrayProduct(s) to input some Wrapper
wrapperArrayType of Wrapper(s) to be used

Definition at line 67 of file Packer.hpp.

samchon::examples::packer::Packer::Packer ( const Packer packer)
inline

Copy Constructor.

Copy constructor of Packer does not copy children items.

Only copies member variables(productArray, wrapperArray) of Packer's.

Definition at line 80 of file Packer.hpp.

Member Function Documentation

auto samchon::examples::packer::Packer::productSize ( ) const -> size_t
inline

Get number of products to package.

Definition at line 109 of file Packer.hpp.

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

Calculate price of the wrappers.

Definition at line 117 of file Packer.hpp.

void samchon::examples::packer::Packer::optimize ( size_t  start = 0,
size_t  size = -1 
)
inline

Find the best packaging method.

Definition at line 132 of file Packer.hpp.

References samchon::library::CaseGenerator::size().

Referenced by toString().

Here is the call graph for this function:

Here is the caller graph for this function:

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

A tag name of children.

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

Implements samchon::protocol::EntityGroupBase.

Definition at line 187 of file Packer.hpp.

virtual auto samchon::examples::packer::Packer::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 192 of file Packer.hpp.

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

Return a string represents an packaging method.

Definition at line 203 of file Packer.hpp.

References optimize(), and toString().

Referenced by toString().

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

shared_ptr<ProductArray> samchon::examples::packer::Packer::productArray
protected

Prodcut(s) to package in some Wrapper(s)

Definition at line 46 of file Packer.hpp.


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