Merge branch 'dev' of feistymeow.org:feisty_meow into dev
[feisty_meow.git] / nucleus / library / processes / letter.cpp
1 /*****************************************************************************\
2 *                                                                             *
3 *  Name   : letter                                                            *
4 *  Author : Chris Koeritz                                                     *
5 *                                                                             *
6 *******************************************************************************
7 * Copyright (c) 1998-$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 "letter.h"
16
17 #include <basis/astring.h>
18 #include <basis/functions.h>
19 #include <timely/time_stamp.h>
20
21 using namespace basis;
22 using namespace timely;
23
24 namespace processes {
25
26 letter::letter(int type, int start_after)
27 : _type(type),
28   _ready_time(new time_stamp(start_after))
29 {}
30
31 letter::letter(const letter &to_copy)
32 : _type(to_copy._type),
33   _ready_time(new time_stamp(*to_copy._ready_time))
34 {
35 }
36
37 letter::~letter()
38 {
39   _type = 0;
40   WHACK(_ready_time);
41 }
42
43 bool letter::ready_to_send() { return time_stamp() >= *_ready_time; }
44
45 void letter::set_ready_time(int start_after)
46 { *_ready_time = time_stamp(start_after); }
47
48 letter &letter::operator =(const letter &to_copy)
49 {
50   if (this == &to_copy) return *this;
51   _type = to_copy._type;
52   *_ready_time = *to_copy._ready_time;
53   return *this;
54 }
55
56 } //namespace.
57