4 /*****************************************************************************\
7 * Author : Chris Koeritz *
9 *******************************************************************************
10 * Copyright (c) 1998-$now By Author. This program is free software; you can *
11 * redistribute it and/or modify it under the terms of the GNU General Public *
12 * License as published by the Free Software Foundation; either version 2 of *
13 * the License or (at your option) any later version. This is online at: *
14 * http://www.fsf.org/copyleft/gpl.html *
15 * Please send any updates to: fred@gruntose.com *
16 \*****************************************************************************/
18 #include <timely/time_stamp.h>
22 //! A virtual base class for pieces of "mail". Used by the mailbox object.
24 class letter : public virtual basis::text_formable
27 letter(int type = 0, int start_after = 0);
28 //!< constructs a letter with the "type" and initial pause of "start_after".
29 /*!< a "type" for this letter must be specified, even if it is not intended
30 to be used. some letter managers may rely on this number identifying
31 different kinds of mail. the types should be unique within one mailbox.
32 a "type" of zero indicates an invalid letter. if the "start_after" is
33 non-zero, then it indicates that this letter should not be sent until
34 that many milliseconds have elapsed. */
36 letter(const letter &to_copy);
37 //!< copy constructor for base parts.
40 //!< derived classes should also implement this.
41 /*!< a virtual destructor should be implemented by each derived class
42 to take care of class specific cleaning. note that the destructor should
43 NEVER attempt to use the mailbox system that it was stored in (or any
44 other mailbox system for that matter). this is necessary for prohibiting
45 deadlock conditions, but it's not that much of a restriction usually. */
47 letter &operator =(const letter &to_copy);
48 //!< assignment operator for base object.
50 virtual void text_form(basis::base_string &fill) const = 0;
51 //!< derived letters must print a status blurb describing their contents.
53 int type() const { return _type; }
54 //!< returns the type of letter held here.
57 //!< returns true if this letter is ready to
59 void set_ready_time(int start_after);
60 //!< resets the time when this letter is ready to be sent.
61 /*!< the letter will now not be allowed to send until "start_after"
62 milliseconds from now. once the letter is added to a mailbox, it may
63 be too late to adjust this duration. */
66 int _type; //!< the kind of mail this item represents.
67 timely::time_stamp *_ready_time; //!< time when this letter will be ready to send.