Part 1
- Create a class – Device with the following members:
- Attributes:
- Id – generated automatically for every device
- Name
- IRQ number
- Base address
- Operations:
- Constructor
- Init – to initialize the hardware (dummy implementation)
- Log – to write a message/error to log
- Attributes:
- Derive RTC class from Device
- Attributes:
- Match time – integer
- Enable/disable – Boolean
- Operations
- Constructor
- Init
- Set_time (dummy or not)
- Get_time (dummy or not)
- Attributes:
- Derive UART class from Device
- Attributes:
- Baud rate – enum with options
- Parity – Boolean
- Data bits – integer
- Stop bit – enum with options
- Operations:
- Constructor
- Init
- Send (dummy)
- Receive(dummy)
- Attributes:
- Create a class DeviceManager
- Add an array of pointers to devices
- Add a function CreateDevice
- Input: enum devicetype
- Output: pointer to the created device (create the object dynamically and add it to the array)
- Add Init function to initialize all the devices
- Add a main function and test your work
- Notes:
- Use const for functions and parameters
- Use explicit for conversion constructors
- Divide the project to cpp/hpp files for each class
Part 2
- make sure that the only possible way to create devices is using the DeviceManager class
- Add another device class for Timer and change/add the code to support it
- Change the DeviceManager class to singleton
- Create a class Logger as abstract class with abstract method Log(string s)
- Derive 2 classes from logger:
- FileLogger – write the log to file
- NetLogger – write the log to network
- Implement the functions as dummy operations
- Add the device classes a logging support