unhandled_request.cpp

Go to the documentation of this file.
00001 /*****************************************************************************\
00002 *                                                                             *
00003 *  Name   : unhandled_request                                                 *
00004 *  Author : Chris Koeritz                                                     *
00005 *                                                                             *
00006 *******************************************************************************
00007 * Copyright (c) 2004-$now By Author.  This program is free software; you can  *
00008 * redistribute it and/or modify it under the terms of the GNU General Public  *
00009 * License as published by the Free Software Foundation; either version 2 of   *
00010 * the License or (at your option) any later version.  This is online at:      *
00011 *     http://www.fsf.org/copyleft/gpl.html                                    *
00012 * Please send any updates to: fred@gruntose.com                               *
00013 \*****************************************************************************/
00014 
00015 #include "unhandled_request.h"
00016 
00017 using namespace basis;
00018 using namespace structures;
00019 
00020 namespace octopi {
00021 
00022 unhandled_request::unhandled_request(const octopus_request_id &original_id,
00023     const string_array &original_classifier, const outcome &reason)
00024 : infoton(the_classifier()),
00025   _original_id(original_id),
00026   _original_classifier(original_classifier),
00027   _reason(reason)
00028 {}
00029 
00030 clonable *unhandled_request::clone() const 
00031 { return new unhandled_request(_original_id, _original_classifier, _reason); }
00032 
00033 int unhandled_request::packed_size() const
00034 {
00035   return _original_id.packed_size() + _original_classifier.packed_size()
00036       + _reason.packed_size();
00037 }
00038 
00039 void unhandled_request::text_form(basis::base_string &fill) const
00040 {
00041   fill.assign(astring("classifier=") + the_classifier().text_form()
00042       + " original_id=" + _original_id.text_form()
00043       + a_sprintf(" reason=%d", _reason.value()));
00044 }
00045 
00046 const char *initter[] = { "__Unhandled__", NIL };
00047 
00048 string_array unhandled_request::the_classifier()
00049 { return string_array(1, initter); }
00050 
00051 void unhandled_request::pack(byte_array &packed_form) const 
00052 {
00053   _original_id.pack(packed_form);
00054   _original_classifier.pack(packed_form);
00055   attach(packed_form, _reason.value());
00056 }
00057 
00058 bool unhandled_request::unpack(byte_array &packed_form) 
00059 {
00060   if (!_original_id.unpack(packed_form)) return false;
00061   if (!_original_classifier.unpack(packed_form)) return false;
00062   int val;
00063   if (!detach(packed_form, val)) return false;
00064   _reason = outcome(val);
00065   return true;
00066 }
00067 
00068 } //namespace.
00069 
Generated on Sat Jan 28 04:22:43 2012 for hoople2 project by  doxygen 1.6.3