#include "Packet.h" namespace psyc { Packet::Packet(std::map vars, std::string mc, std::string message) : mVars(vars), mMc(mc), mMessage(message) { } Packet::Packet() { } Packet::~Packet() { for (std::map::iterator i = mVars.begin(); i != mVars.end(); i++) { delete i->second; } // delete mVars; } std::map Packet::getVars() { return mVars; } std::map Packet::addVar(psyc::Var* var) { mVars[var->getName()] = var; return mVars; } std::string Packet::setMc(std::string mc) { return (mMc = mc); } std::string Packet::getMc() { return mMc; } std::string Packet::setMessage(std::string message) { return (mMessage = message); } std::string Packet::getMessage() { return mMessage; } std::string Packet::print() { std::string packet = "\n*** VARIABLES ***\n\n"; for (std::map::iterator i = mVars.begin(); i != mVars.end(); i++) { packet += i->second->print() + "\n"; } packet += "\n*** MESSAGE CODE ***\n\n"; packet += getMc() + "\n"; packet += "\n*** BODY ***\n\n"; packet += getMessage(); packet += ".\n"; packet += "\n*** THANKS FOR YOUR ATTENTION ***\n\n"; return packet; } }