feisty meow concerns codebase  2.140
identity_infoton.cpp
Go to the documentation of this file.
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>
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 
34 : infoton(identity_classifier()),
35  _new_name(uid)
36 {}
37 
39 : root_object(),
40  infoton(to_copy),
41  _new_name(to_copy._new_name)
42 {}
43 
45 
47 {
48  astring ent_info;
49  _new_name.text_form(ent_info);
50  fill.assign(astring("entity=") + ent_info);
51 }
52 
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 
65 
66 int identity_infoton::packed_size() const { return _new_name.packed_size(); }
67 
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 
Provides a dynamically resizable ASCII character string.
Definition: astring.h:35
Defines the base class for all string processing objects in hoople.
Definition: base_string.h:28
virtual base_string & assign(const base_string &s)=0
Sets the contents of this string to "s".
A very common template for a dynamic array of bytes.
Definition: byte_array.h:36
A clonable object knows how to make copy of itself.
Definition: contracts.h:109
Encapsulates just the action of identifying an octopus user.
virtual clonable * clone() const
must be provided to allow creation of a copy of this object.
static const structures::string_array & identity_classifier()
returns the classifier for this type of infoton.
identity_infoton & operator=(const identity_infoton &to_copy)
virtual bool unpack(basis::byte_array &packed_form)
restores an infoton from a packed form.
virtual void pack(basis::byte_array &packed_form) const
stuffs the data in the infoton into the "packed_form".
virtual int packed_size() const
reports how large the infoton will be when packed.
An infoton is an individual request parcel with accompanying information.
Definition: infoton.h:32
virtual basis::astring text_form() const
local version just makes text_form() more functional.
Definition: infoton.h:108
const structures::string_array & classifier() const
this array of strings is the "name" for this infoton.
Definition: infoton.cpp:85
void set_classifier(const structures::string_array &new_classifier)
sets the infoton's classifier to the "new_classifier".
Definition: infoton.cpp:104
Provides a way of identifying users of an octopus object.
Definition: entity_defs.h:35
int packed_size() const
reports how large the packed entity will be.
virtual bool unpack(basis::byte_array &packed_form)
Restores the packable from the "packed_form".
basis::astring text_form() const
returns a readable form of the identifier.
virtual void pack(basis::byte_array &packed_form) const
Creates a packed form of the packable object in "packed_form".
An array of strings with some additional helpful methods.
Definition: string_array.h:32
The guards collection helps in testing preconditions and reporting errors.
Definition: array.h:30
SAFE_STATIC_CONST(string_array, identity_infoton::identity_classifier,(1, identity_classifier_strings)) int identity_infoton
const astring identity_classifier_strings[]
A dynamic container class that holds any kind of object via pointers.
Definition: amorph.h:55