Public Member Functions | Private Member Functions | Private Attributes | List of all members
Calendar Class Reference

#include <calendar.h>

Public Member Functions

 Calendar ()
 
Eventfind (string query) throw ( logic_error )
 
void print (ostream &out=cout) const
 
void read (string filename) throw ( logic_error, invalid_argument )
 
void read (istream &in) throw ( invalid_argument )
 
unsigned size () const
 
void synchronize (Calendar &e)
 
void write (string filename) const
 
void write (ostream &out=cout) const
 

Private Member Functions

void synchronize (vector< Event > &e1, vector< Event > &e2)
 

Private Attributes

vector< Eventevents
 

Detailed Description

A class for storing events of a calendar that can be synchronized with other calendars. Methods exist to read and write events to and from files, which serve as proxies for sending and receiving between calendars on devices, on computers, and in the cloud. A find method searches for events based on name and location.

Author
Mark Maloof (maloof at cs georgetown edu)
Version
1.1, 11/28/12
1.2, 11/08/16

Constructor & Destructor Documentation

Calendar::Calendar ( )

Default constructor.

Member Function Documentation

Event & Calendar::find ( string  query)
throw (logic_error
)

Returns a reference to the event with a name or location that partially matches with the query. Otherwise, throws logic_error.

Parameters
querythe search string
Returns
a reference to the matching event
Exceptions
logic_errorif no event matches
void Calendar::print ( ostream &  out = cout) const

Prints the events of this Calendar to the output stream in a format suitable for a user view, meaning that the events are printed in the external format and deleted events are excluded.

Parameters
outthe output stream for printing
void Calendar::read ( string  filename)
throw ( logic_error,
invalid_argument
)

Reads the events in the internal format from file with the specified by opening an input-file stream and, if successful, passing it to Calendar::read( istream & ). Throws an exception if the file does not open successfully. Throws an exception if a read operation encounters invalid input.

Parameters
filenamethe name of the file containing the events
Exceptions
logic_errorif the file does not open successfully
invalid_argumentif a read operation encounters invalid input
void Calendar::read ( istream &  in)
throw (invalid_argument
)

Reads the events in the internal format from the input stream, and stores them in the vector events. Throws an exception if a read operation encounters invalid input.

Parameters
inthe input stream name containing the events
Exceptions
invalid_argumentif a read operation encounters invalid input
unsigned Calendar::size ( ) const

Returns the size of this calendar, that is, the number of events.

Returns
the number of events
void Calendar::synchronize ( Calendar calendar)

Synchonizes this Calendar object with the specified Calendar object. Adds new events from one calendar to the another. Copies updated and deleted events based on most recent modification date and time of pairs of matching events.

Parameters
calendarthe specified calendar for synchronization
void Calendar::synchronize ( vector< Event > &  e1,
vector< Event > &  e2 
)
private

Synchronizes events e2 to e1. For each event in e2, adds new events and copies updated and deleted events based on most recent modification date and time of pairs of matching events.

Parameters
e1a vector of events
e2a vector of events
void Calendar::write ( string  filename) const

Writes the events of this Calendar to the file named filename in the internal format.

Parameters
filenamethe name of the file for writing
void Calendar::write ( ostream &  out = cout) const

Writes the events of this Calendar to the output stream in the internal format.

Parameters
outthe output stream for writing

Member Data Documentation

vector<Event> Calendar::events
private

the events of this calendar


The documentation for this class was generated from the following files: