feisty meow concerns codebase  2.140
letter.cpp
Go to the documentation of this file.
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 
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 
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 
A virtual base class for pieces of "mail". Used by the mailbox object.
Definition: letter.h:25
bool ready_to_send()
returns true if this letter is ready to
Definition: letter.cpp:43
virtual ~letter()
derived classes should also implement this.
Definition: letter.cpp:37
letter(int type=0, int start_after=0)
constructs a letter with the "type" and initial pause of "start_after".
Definition: letter.cpp:26
void set_ready_time(int start_after)
resets the time when this letter is ready to be sent.
Definition: letter.cpp:45
letter & operator=(const letter &to_copy)
assignment operator for base object.
Definition: letter.cpp:48
Represents a point in time relative to the operating system startup time.
Definition: time_stamp.h:38
The guards collection helps in testing preconditions and reporting errors.
Definition: array.h:30
void WHACK(contents *&ptr)
deletion with clearing of the pointer.
Definition: functions.h:121
#include <time.h>
Definition: earth_time.cpp:37