first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / octopi / library / octopus / identity_infoton.cpp
1 /*****************************************************************************\
2 *                                                                             *
3 *  Name   : identity_infoton                                                  *
4 *  Author : Chris Koeritz                                                     *
5 *                                                                             *
6 *******************************************************************************
7 * Copyright (c) 2002-$now By Author.  This program is free software; you can  *
8 * redistribute it and/or modify it under the terms of the GNU General Public  *
9 * License as published by the Free Software Foundation; either version 2 of   *
10 * the License or (at your option) any later version.  This is online at:      *
11 *     http://www.fsf.org/copyleft/gpl.html                                    *
12 * Please send any updates to: fred@gruntose.com                               *
13 \*****************************************************************************/
14
15 #include "identity_infoton.h"
16 #include "tentacle.h"
17
18 #include <basis/byte_array.h>
19 #include <basis/mutex.h>
20 #include <structures/string_array.h>
21 #include <structures/static_memory_gremlin.h>
22
23 using namespace basis;
24 using namespace structures;
25
26 namespace octopi {
27
28 identity_infoton::identity_infoton()
29 : infoton(identity_classifier()),
30   _new_name()
31 {}
32
33 identity_infoton::identity_infoton(const octopus_entity &uid)
34 : infoton(identity_classifier()),
35   _new_name(uid)
36 {}
37
38 identity_infoton::identity_infoton(const identity_infoton &to_copy)
39 : root_object(),
40   infoton(to_copy),
41   _new_name(to_copy._new_name)
42 {}
43
44 identity_infoton::~identity_infoton() {} 
45
46 void identity_infoton::text_form(base_string &fill) const
47 {
48   astring ent_info;
49   _new_name.text_form(ent_info);
50   fill.assign(astring("entity=") + ent_info);
51 }
52
53 identity_infoton &identity_infoton::operator =(const identity_infoton &to_copy)
54 {
55   if (this == &to_copy) return *this;
56   set_classifier(to_copy.classifier());
57   _new_name = to_copy._new_name;
58   return *this;
59 }
60
61 const astring identity_classifier_strings[] = { "#octide" };
62
63 SAFE_STATIC_CONST(string_array, identity_infoton::identity_classifier,
64     (1, identity_classifier_strings))
65
66 int identity_infoton::packed_size() const { return _new_name.packed_size(); }
67
68 clonable *identity_infoton::clone() const
69 { return cloner<identity_infoton>(*this); }
70
71 void identity_infoton::pack(byte_array &packed_form) const
72 { _new_name.pack(packed_form); }
73
74 bool identity_infoton::unpack(byte_array &packed_form)
75 {
76   if (!_new_name.unpack(packed_form)) return false;
77   return true;
78 }
79
80 } //namespace.
81
82