Project 1
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)
 
void print (ostream &out=cout) const
 
void read (string filename)
 
void read (istream &in)
 
unsigned size () const
 
void synchronize (Calendar &calendar)
 
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
1.3, 01/08/20

Constructor & Destructor Documentation

◆ Calendar()

Calendar::Calendar ( )

Default constructor.

Member Function Documentation

◆ find()

Event & Calendar::find ( string  query)

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

Parameters
querythe search string
Returns
a reference to the matching event
Exceptions
logic_errorif no event matches

◆ print()

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

◆ read() [1/2]

void Calendar::read ( istream &  in)

Reads the events in the internal format from the input stream, and stores them in the vector events. Indirectly 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

◆ read() [2/2]

void Calendar::read ( string  filename)

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 & ). Directly throws an exception if the file does not open successfully. Indirectly 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

◆ size()

unsigned Calendar::size ( ) const

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

Returns
the number of events

◆ synchronize() [1/2]

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

◆ synchronize() [2/2]

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

◆ write() [1/2]

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

◆ write() [2/2]

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

Member Data Documentation

◆ events

vector<Event> Calendar::events
private

the events of this calendar


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