Samchon Framework for CPP  1.0.0
samchon::example::packer::Wrapper Class Reference

A wrapper can contain products. More...

#include <Wrapper.hpp>

Collaboration diagram for samchon::example::packer::Wrapper:

Public Member Functions

 Wrapper ()
 Default Constructor. More...
 
 Wrapper (const string &name, int price, int volume, int weight)
 Construct from argument of a wrapper. More...
 
 Wrapper (const Wrapper &wrapper)
 Copy Constructor. More...
 
auto tryInsert (shared_ptr< Product > product) -> bool
 Try to insert a product into the wrapper. More...
 
virtual auto TAG () const -> string override
 A tag name when represented by XML. More...
 
virtual auto toXML () const -> shared_ptr< XML > override
 Get an XML object represents the Entity. More...
 
virtual auto toString () const -> string override
 Return a string represent the wrapper. More...
 
- Public Member Functions inherited from samchon::example::packer::ProductArray
virtual auto CHILD_TAG () const -> string override
 A tag name of children. More...
 
- Public Member Functions inherited from samchon::protocol::EntityGroup< _Container, _ETy, T >
 EntityGroup ()
 Default Constructor. More...
 
virtual void construct (std::shared_ptr< library::XML > xml)
 Construct data of the Entity from an XML object. More...
 
auto has (const std::string &key) const -> bool
 Indicates whether a container has an object having the specified identifier. More...
 
auto get (const std::string &key) -> value_type &
 Access the element by specified identifier(key). More...
 
auto get (const std::string &key) const -> const value_type &
 Access the const element by specified identifier(key). More...
 
- Public Member Functions inherited from samchon::protocol::Entity
 Entity ()
 Default Constructor. More...
 
virtual auto key () const -> std::string
 Get a key that can identify the Entity uniquely. More...
 
- Public Member Functions inherited from samchon::protocol::IEntityGroup
 IEntityGroup ()
 Default Constructor. More...
 
- Public Member Functions inherited from samchon::example::packer::Instance
 Instance ()
 Default Constructor. More...
 
 Instance (const string &name, int price, int volume, int weight)
 Construct from instance. More...
 
auto getName () const -> string
 Get name. More...
 
auto getPrice () const -> int
 Get price. More...
 
auto getVolume () const -> int
 Get volume. More...
 
auto getWeight () const -> int
 Get weight. More...
 

Additional Inherited Members

- Protected Member Functions inherited from samchon::protocol::EntityGroup< _Container, _ETy, T >
virtual auto createChild (std::shared_ptr< library::XML >) -> entity_type *=0
 Factory method of a child Entity. More...
 
- Protected Attributes inherited from samchon::example::packer::Instance
string name
 Name represent the Instance. More...
 
int price
 Price of an instance -> 1,000 won. More...
 
int volume
 Volume of an instance -> 130 cm^3. More...
 
int weight
 Weight of an instance -> 1,200 g. More...
 

Detailed Description

A wrapper can contain products.

A wrapper containing products with its limitation of weight and volume.

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

Definition at line 27 of file Wrapper.hpp.

Constructor & Destructor Documentation

samchon::example::packer::Wrapper::Wrapper ( )
inline

Default Constructor.

Definition at line 41 of file Wrapper.hpp.

samchon::example::packer::Wrapper::Wrapper ( const string &  name,
int  price,
int  volume,
int  weight 
)
inline

Construct from argument of a wrapper.

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 55 of file Wrapper.hpp.

samchon::example::packer::Wrapper::Wrapper ( const Wrapper wrapper)
inline

Copy Constructor.

Copy constructor of wrapper does not copy children items. Only copies arguments of Instance's.

Definition at line 66 of file Wrapper.hpp.

Member Function Documentation

auto samchon::example::packer::Wrapper::tryInsert ( shared_ptr< Product product) -> bool
inline

Try to insert a product into the wrapper.

If the Wrapper has enough volume and limit of weight, inserts the Product into the Wrapper and returns true. If not enough, does not insert and just return false.

Parameters
productA product try to insert in.
Returns
Whether to success put in

Definition at line 91 of file Wrapper.hpp.

Referenced by samchon::example::packer::WrapperArray::optimize().

Here is the caller graph for this function:

virtual auto samchon::example::packer::Wrapper::TAG ( ) const -> string
inlineoverridevirtual

A tag name when represented by XML.

Returns
A tag name

Reimplemented from samchon::example::packer::ProductArray.

Definition at line 115 of file Wrapper.hpp.

virtual auto samchon::example::packer::Wrapper::toXML ( ) const -> shared_ptr<XML>
inlineoverridevirtual

Get an XML object represents the Entity.

Returns an XML object that can represents the Entity containing member variables into properties.

A member variable (not object, but atomic value like number, string or date) is categorized as a property within the framework of entity side. Thus, when overriding a toXML() method and archiving member variables to an XML object to return, puts each variable to be a property belongs to only an XML object.

Don't archive the member variable of atomic value to XML::value causing enormouse creation of XML objects to number of member variables. An Entity must be represented by only an XML instance (tag).

Standard Usage Non-standard usage abusing value
<memberList>
     <member id='jhnam88' name='Jeongho+Nam' birthdate='1988-03-11' />
     <member id='master' name='Administartor' birthdate='2011-07-28' />
</memberList>
<member>
     <id>jhnam88</id>
     <name>Jeongho+Nam</name>
     <birthdate>1988-03-11</birthdate>
</member>
Returns
An XML object representing the Entity.

Reimplemented from samchon::example::packer::Instance.

Definition at line 120 of file Wrapper.hpp.

References samchon::example::packer::Instance::toXML().

Here is the call graph for this function:

virtual auto samchon::example::packer::Wrapper::toString ( ) const -> string
inlineoverridevirtual

Return a string represent the wrapper.

Returns a string of the Wrapper and Product(s) packaged in.

Returns
A string represents the Wrapper and contained Product(s).

Reimplemented from samchon::example::packer::Instance.

Definition at line 134 of file Wrapper.hpp.

References samchon::example::packer::Instance::toString().

Here is the call graph for this function:


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