2 #include <samchon/examples/packer/ProductArray.hpp> 3 #include <samchon/examples/packer/Instance.hpp> 13 using namespace library;
14 using namespace protocol;
55 Wrapper(
const string &name,
int price,
int volume,
int weight)
57 Instance(name, price, volume, weight)
74 virtual void construct(shared_ptr<XML> xml)
override 76 super::construct(xml);
77 Instance::construct(xml);
96 for (
size_t i = 0; i < size(); i++)
98 volume += at(i)->getVolume();
99 weight += at(i)->getWeight();
102 if (product->getVolume() + volume > this->volume ||
103 product->getWeight() + weight > this->weight)
115 virtual auto TAG()
const ->
string override 120 virtual auto toXML()
const -> shared_ptr<XML>
override 122 shared_ptr<XML> &xml = super::toXML();
123 xml->insertAllProperties(Instance::toXML());
137 for (
size_t i = 0; i < size(); i++)
138 str +=
"\t\t" + at(i)->toString()
139 + ((i == size() - 1) ?
"" :
"\n");
virtual auto toString() const -> string override
Return a string represent the wrapper.
auto tryInsert(shared_ptr< Product > product) -> bool
Try to insert a product into the wrapper.
Wrapper()
Default Constructor.
Wrapper(const Wrapper &wrapper)
Copy Constructor.
An array of Product objects.
Wrapper(const string &name, int price, int volume, int weight)
Construct from argument of a wrapper.
virtual auto toString() const -> string
Return a string represents the Instance.
A wrapper can contain products.