From 626cb7eb5156c696a68c515bab2a686d90530deb Mon Sep 17 00:00:00 2001
From: Max Tyson <98maxt98@gmail.com>
Date: Fri, 22 Dec 2023 21:21:48 +1300
Subject: [PATCH] Style Corrections
---
.github/ISSUE_TEMPLATE/feature_request.md | 2 +-
README.md | 4 +-
docs/Bugs.md | 18 -
docs/CONTRIBUTING.md | 6 +-
docs/Goals.md | 2 +-
docs/Notes.md | 94 +-
docs/Styles/ClionCodeStyleSettings.xml | 29 +
docs/Styles/Coding Style.md | 561 +++++++++
docs/Styles/Interface Style.md | 79 ++
docs/commit.md | 2 -
kernel/include/common/colour.h | 13 +-
kernel/include/common/eventHandler.h | 63 +-
kernel/include/common/graphicsContext.h | 64 +-
kernel/include/common/inputStream.h | 286 +++--
kernel/include/common/map.h | 155 ++-
kernel/include/common/outputStream.h | 98 +-
kernel/include/common/pair.h | 18 +-
kernel/include/common/rectangle.h | 150 +--
kernel/include/common/time.h | 3 +
kernel/include/common/vector.h | 335 ++---
kernel/include/drivers/ata.h | 44 +-
kernel/include/drivers/clock/clock.h | 49 +-
kernel/include/drivers/console/console.h | 119 +-
kernel/include/drivers/console/textmode.h | 25 +-
kernel/include/drivers/console/vesaboot.h | 39 +-
kernel/include/drivers/driver.h | 57 +-
.../include/drivers/ethernet/amd_am79c973.h | 10 +-
kernel/include/drivers/ethernet/ethernet.h | 26 +-
kernel/include/drivers/ethernet/intel_i217.h | 18 +-
.../include/drivers/ethernet/rawdatahandler.h | 4 +
kernel/include/drivers/peripherals/keyboard.h | 363 +++---
kernel/include/drivers/peripherals/mouse.h | 48 +-
kernel/include/drivers/video/vesa.h | 95 +-
kernel/include/drivers/video/vga.h | 54 +-
kernel/include/drivers/video/video.h | 19 +-
kernel/include/filesystem/fat32.h | 261 +---
kernel/include/filesystem/filesystem.h | 85 +-
kernel/include/filesystem/msdospart.h | 36 +-
kernel/include/gui/desktop.h | 47 +-
kernel/include/gui/font.h | 28 +-
kernel/include/gui/widget.h | 90 +-
kernel/include/gui/widgets/button.h | 57 +-
kernel/include/gui/widgets/inputbox.h | 46 +-
kernel/include/gui/widgets/text.h | 17 +-
kernel/include/gui/window.h | 48 +-
.../hardwarecommunication/interrupts.h | 66 +-
kernel/include/hardwarecommunication/pci.h | 83 +-
kernel/include/hardwarecommunication/port.h | 69 +-
kernel/include/hardwarecommunication/serial.h | 124 --
kernel/include/memory/memoryIO.h | 58 +-
kernel/include/memory/memorymanagement.h | 63 +-
kernel/include/net/ethernetframe.h | 2 +-
kernel/include/net/tcp.h | 3 +-
kernel/include/net/udp.h | 3 +-
kernel/include/system/gdt.h | 64 +-
kernel/include/system/multiboot.h | 4 +-
kernel/include/system/multitasking.h | 90 +-
kernel/include/system/multithreading.h | 86 +-
kernel/include/system/process.h | 26 +-
kernel/include/system/syscalls.h | 4 +-
kernel/src/common/colour.cpp | 33 +-
kernel/src/common/graphicsContext.cpp | 478 ++++----
kernel/src/common/inputStream.cpp | 5 +-
kernel/src/common/outputStream.cpp | 118 +-
kernel/src/drivers/ata.cpp | 314 ++---
kernel/src/drivers/clock/clock.cpp | 128 +-
kernel/src/drivers/console/console.cpp | 263 ++--
kernel/src/drivers/console/textmode.cpp | 94 +-
kernel/src/drivers/console/vesaboot.cpp | 130 +-
kernel/src/drivers/driver.cpp | 141 ++-
kernel/src/drivers/ethernet/amd_am79c973.cpp | 117 +-
kernel/src/drivers/ethernet/ethernet.cpp | 47 +-
kernel/src/drivers/ethernet/intel_i217.cpp | 86 +-
kernel/src/drivers/peripherals/keyboard.cpp | 467 +++----
kernel/src/drivers/peripherals/mouse.cpp | 143 ++-
kernel/src/drivers/video/vesa.cpp | 82 +-
kernel/src/drivers/video/vga.cpp | 154 ++-
kernel/src/drivers/video/video.cpp | 44 +-
kernel/src/filesystem/fat32.cpp | 1091 -----------------
kernel/src/filesystem/filesystem.cpp | 325 -----
kernel/src/filesystem/msdospart.cpp | 34 +-
kernel/src/gui/desktop.cpp | 243 ++--
kernel/src/gui/font.cpp | 85 +-
kernel/src/gui/widget.cpp | 391 +++---
kernel/src/gui/widgets/button.cpp | 112 +-
kernel/src/gui/widgets/inputbox.cpp | 138 ++-
kernel/src/gui/widgets/text.cpp | 40 +-
kernel/src/gui/window.cpp | 245 ++--
.../src/hardwarecommunication/interrupts.cpp | 519 ++++----
kernel/src/hardwarecommunication/pci.cpp | 284 ++---
kernel/src/hardwarecommunication/port.cpp | 70 +-
kernel/src/hardwarecommunication/serial.cpp | 245 ----
kernel/src/kernel.cpp | 242 +---
kernel/src/memory/memoryIO.cpp | 139 ++-
kernel/src/memory/memorymanagement.cpp | 194 ++-
kernel/src/net/arp.cpp | 6 +-
kernel/src/net/ethernetframe.cpp | 16 +-
kernel/src/net/icmp.cpp | 4 +-
kernel/src/net/ipv4.cpp | 14 +-
kernel/src/net/tcp.cpp | 46 +-
kernel/src/net/udp.cpp | 33 +-
kernel/src/system/gdt.cpp | 200 ++-
kernel/src/system/multitasking.cpp | 85 +-
kernel/src/system/multithreading.cpp | 207 +---
kernel/src/system/process.cpp | 121 --
kernel/src/system/syscalls.cpp | 176 +--
106 files changed, 5402 insertions(+), 7159 deletions(-)
delete mode 100644 docs/Bugs.md
create mode 100644 docs/Styles/ClionCodeStyleSettings.xml
create mode 100644 docs/Styles/Coding Style.md
create mode 100644 docs/Styles/Interface Style.md
delete mode 100644 docs/commit.md
delete mode 100644 kernel/include/hardwarecommunication/serial.h
delete mode 100644 kernel/src/hardwarecommunication/serial.cpp
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
index bbcbbe7d..d639adc2 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -1,7 +1,7 @@
---
name: Feature request
about: Suggest an idea for this project
-title: ''
+m_title: ''
labels: ''
assignees: ''
diff --git a/README.md b/README.md
index ff9fe822..5867193c 100644
--- a/README.md
+++ b/README.md
@@ -53,8 +53,8 @@ Kernel Cleanup
- [x] Cross-Compiler
- [x] Better Scripts
- [x] GUI Bug Fixes
-- [ ] Better Commenting and Doxygen Documentation
-- [ ] Use better c++ coding conventions
+- [x] Better Commenting and Doxygen Documentation
+- [x] Use better c++ coding conventions
- [ ] CMAKE Build System (and maybe get it building and debugging in CLion)
- [ ] Clean up all the TODOs
- [ ] Rewrite Readme
diff --git a/docs/Bugs.md b/docs/Bugs.md
deleted file mode 100644
index ca266b95..00000000
--- a/docs/Bugs.md
+++ /dev/null
@@ -1,18 +0,0 @@
-
-# Known Bugs
-| Status | #Issue Code | Info |
-|:------:|:-----------:|:-------------------------------------------------:|
-| Fixing | X | Example |
-| Known | | Event handlers only trigger for one event handler |
-| Known | | Windows have to be weirdly clicked to resize |
-
-
-# Annoying
-Bugs that were simple to fix but took forever to find
-
-| Time Spent | Bug | Fix | Fix Commit |
-|:----------:|:----------------------------------------:|:-------------------------------------------------:|:-----------------------------------------------------------------------------------------------:|
-| 2:00 | amd network driver not sending/reciveing | - Change 0x7FF -> 0xF7FF AND write(1) -> write(2) | [Github](https://github.com/maxtyson123/max-os/commit/4a0a080a271a9bf27d9cc3701c7d32b40aa2bab3) |
-| 3:44 | amd network driver not init | - PCI read/write check fail AND driver issue | [Github](https://github.com/maxtyson123/max-os/commit/4a0a080a271a9bf27d9cc3701c7d32b40aa2bab3) |
-
-
diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md
index 1474688c..26bb716d 100644
--- a/docs/CONTRIBUTING.md
+++ b/docs/CONTRIBUTING.md
@@ -16,7 +16,7 @@ To keep the code understanble please make sure it is formatted and reable. Addit
## We Use [GitHub Flow](https://guides.github.com/introduction/flow/index.html), So All Code Changes Happen Through Pull Requests
Pull requests are the best way to propose changes to the codebase (we use [GitHub Flow](https://guides.github.com/introduction/flow/index.html)). We actively welcome your pull requests:
-1. Fork the repo and create your branch from `master`.
+1. Fork the repo and create your branch from `m_is_master`.
2. If you've added code that should be tested, add tests.
3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes.
@@ -26,12 +26,12 @@ Pull requests are the best way to propose changes to the codebase (we use [GitHu
## Report bugs using GitHub's [issues](https://github.com/briandk/transcriptase-atom/issues)
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](); it's that easy!
-## Write bug reports with detail, background, and sample code
+## write bug reports with detail, m_background, and sample code
[This is an example](http://stackoverflow.com/q/12488905/180626) of a bug report someone wrote, and I think it's not a bad model. Here's [another example from Craig Hockenberry](http://www.openradar.me/11905408), an app developer whom I greatly respect.
**Great Bug Reports** tend to have:
-- A quick summary and/or background
+- A quick summary and/or m_background
- Steps to reproduce
- Be specific!
- Give sample code if you can. [This stackoverflow question](http://stackoverflow.com/q/12488905/180626) includes sample code that *anyone* with a base R setup can run to reproduce what I was seeing
diff --git a/docs/Goals.md b/docs/Goals.md
index b1539c48..dbe4bcb1 100644
--- a/docs/Goals.md
+++ b/docs/Goals.md
@@ -59,6 +59,6 @@
# Other
- Clipboard
-- Privelges (Rings, Read/Write)
+- Privelges (Rings, read/write)
- Apps installer
- App store
\ No newline at end of file
diff --git a/docs/Notes.md b/docs/Notes.md
index 4200dbb0..133a9d7f 100644
--- a/docs/Notes.md
+++ b/docs/Notes.md
@@ -8,7 +8,7 @@ These are my notes relative to various parts of the OS
+ [Data Send and Receive](#data-send-and-receive)
+ [Interrupts](#interrupts)
+ [Peripheral Component Interconnect (PCI)](#peripheral-component-interconnect-pci)
- + [Base Address Registers](#base-address-registers)
+ + [base Address Registers](#base-address-registers)
+ [RTC Timer](#rtc-timer)
- [Files And Drives](#files-and-drives)
+ [Hard-drives](#hard-drives)
@@ -19,7 +19,7 @@ These are my notes relative to various parts of the OS
+ [GUI - Framework](#gui-framework)
- [System Stuff](#system-stuff)
+ [Multitasking](#multitasking)
- + [Threads](#threads)
+ + [m_threads](#threads)
+ [Dynamic Memory Management / Heap](#dynamic-memory-management-heap)
+ [System Calls](#system-calls)
- [Networking](#networking)
@@ -103,15 +103,15 @@ This relates to "pci.cpp", See also [PCI](https://www.lowlevel.eu/wiki/Periphera
- The PCI controller will also tell more general information such as class and subclass IDs, which are useful for compatibility modes
- Once the PCI driver is set up then it becomes easy to extend the OS as in future all that needs to be done is to get the device ID and write drivers for them
-### Base Address Registers
-- The solution for having multiple PCI devices (two GPUS, two screens etc…) is to have a Base Address Registers (BAR)
-- Base address registers are registers in the PCI configuration space, which in a more simple way is just storing the address of a PCI device in memory
-- There are two types of BARs, one is the I/O BAR, this is for devices that communicate bit by bit e.g. mouse where the position is read from the port each interrupt
+### base Address Registers
+- The solution for having multiple PCI devices (two GPUS, two screens etc…) is to have a base Address Registers (BAR)
+- base address registers are registers in the PCI configuration space, which in a more simple way is just storing the address of a PCI device in memory
+- There are two types of BARs, one is the I/O BAR, this is for devices that communicate bit by bit e.g. mouse where the m_position is read from the port each interrupt
- The I/O base address register is 4 bytes long:
- - Lowest bit: Type Of register: (I/O bit = 1)
- - Second-lowest bit: Reserved
- - Bits 3 - 16: Port Number (MUST BE MULTIPLE OF 4)
-- Memory mapping is another type of BAR, this one is where the device takes x memory location, and to communicate with it just write/read from that location in memory. This is better performance-wise as the CPU can do other tasks while that is updating in the background
+- Memory mapping is another type of BAR, this one is where the device takes x memory location, and to communicate with it just write/read from that location in memory. This is better performance-wise as the CPU can do other m_tasks while that is updating in the m_background
- The Memory Mapping BAR is 4 bytes long:
- - Lowest Bit: Type Of register: (MemMap bit = 0)
- - Second and third: (00 = 32bit BAR) or (01 = 20bit BAR) or (10 = 64bit BAR)
@@ -121,7 +121,7 @@ This relates to "pci.cpp", See also [PCI](https://www.lowlevel.eu/wiki/Periphera
### RTC Timer
See also [RTC](https://wiki.osdev.org/RTC)
- The RTC (Real Time Clock) is a device that is connected to the PCI controller and is used to keep track of time
-- The ports used for the RTC are 0x70(Write) and 0x71(Read)
+- The ports used for the RTC are 0x70(write) and 0x71(read)
- The base frequency of the RTC is 32768 Hz, it is possible to change this frequency but that can mess with the time keeping
- The RTC has a register called the CMOS RAM, which is a 128 byte long memory that can be read and written to, it stores the time and date
- To get the time certain registers need to be read from te data port (0x71). Before doing this updates need to be disabled so that the time is not changed while reading it.
@@ -142,7 +142,7 @@ See also [RTC](https://wiki.osdev.org/RTC)
- As hard drives have been around for a long time, they are well documented and easy to implement
- SATA devices are almost always compatible to ATA or AHCI (Advanced Host Controller Interface)
- Using the PCI controller, SATA hard drives can be found on class id 0x01 and subclass id 0x06
-- There are two different ways of accessing a hard-drive. The first one is PIO (Programed Input Output) which is relatively simple to implement but rather slow (maxs out at 16 M/Bs)
+- There are two different ways of accessing a hard-drive. The m_first_memory_chunk one is PIO (Programed Input Output) which is relatively simple to implement but rather slow (maxs out at 16 M/Bs)
- The second and better way would be DMA (Direct Memory Access) , which simply just writes the data to a memory location and sends an interrupt once finished
- Although it is better to read from the PCI devices list, the ports can just be hard coded
- For the Implementation of PIO:
@@ -155,18 +155,18 @@ See also [RTC](https://wiki.osdev.org/RTC)
### Partion Table
- This OS will use the MS DOS partition table is because it is the most common and well documented. Additionalym Windows uses it and so does Linux
- This partion table is simple so it is easy to implement, but it is also limited to 4 primary partitions and 1 extended partition.
-- The partition table is located at the end of the first sector of the hard drive
-- At the start of the first sector there is a 440 byte boot sector, which is used to boot the OS. The bootstraper will then look at the partition table to find the OS partition.
+- The partition table is located at the end of the m_first_memory_chunk sector of the hard drive
+- At the start of the m_first_memory_chunk sector there is a 440 byte boot sector, which is used to boot the OS. The bootstraper will then look at the partition table to find the OS partition.
- After the boot sector there are 4 bytes of signature.
- Then there is 2 bytes that are unused
- Then there is the partition table which is 64 bytes long and has 4 entries of 16 bytes each
-- At the end there are 2 magic bytes (0x55, 0xAA) which is used to check if the partition table is valid
+- At the end there are 2 magic bytes (0x55, 0xAA) which is used to check if the partition table is m_valid
- The structure of the partition table is as follows:
- - First 1 byte: Bootable flag (0x80 = bootable, 0x00 = not bootable) (There can only be one bootable partition per hard drive)
-- - Next 3 bytes: Cylinder Head Sector (CHS) address of the first sector of the partition
+- - Next 3 bytes: Cylinder Head Sector (CHS) address of the m_first_memory_chunk sector of the partition
- - Next 1 byte: Partition type (0x00 = empty, 0x01 = FAT12, 0x04 = FAT16, 0x05 = Extended, 0x06 = FAT16, 0x07 = NTFS, 0x0B = FAT32, 0x0C = FAT32, 0x0E = FAT16, 0x0F = Extended, 0x11 = Hidden FAT12, 0x14 = Hidden FAT16, 0x16 = Hidden FAT16, 0x1B = Hidden FAT32, 0x1C = Hidden FAT32, 0x1E = Hidden FAT16, 0x42 = MBR, 0x82 = Linux Swap, 0x83 = Linux, 0x84 = Hibernation, 0x85 = Linux Extended, 0x86 = NTFS Volume Set, 0x87 = NTFS Volume Set, 0xA5 = FreeBSD, 0xA6 = OpenBSD, 0xA9 = NetBSD, 0xB7 = BSDI, 0xB8 = BSDI Swap, 0xEB = BeOS, 0xEE = GPT, 0xEF = EFI System, 0xFB = VMWare File System, 0xFC = VMWare Swap)
- - Next 3 bytes: Cylinder Head Sector (CHS) address of the last sector of the partition
-- - Next 4 bytes: LBA address of the first sector of the partition
+- - Next 4 bytes: LBA address of the m_first_memory_chunk sector of the partition
- - Next 4 bytes: Number of sectors in the partition
### Fat 32 File System
@@ -219,11 +219,11 @@ See also [FAT32](https://en.wikipedia.org/wiki/Design_of_the_FAT_file_system#FAT
- The structure of a directory entry is as follows:
- - First 8 bytes: File name (8.3 format)
- - Next 3 bytes: File extension
-- - Next 1 byte: File attributes (0x01 = Read Only, 0x02 = Hidden, 0x04 = System, 0x08 = Volume ID, 0x10 = Directory, 0x20 = Archive, 0x40 = Device, 0x80 = Unused)
+- - Next 1 byte: File attributes (0x01 = read Only, 0x02 = Hidden, 0x04 = System, 0x08 = Volume ID, 0x10 = Directory, 0x20 = Archive, 0x40 = Device, 0x80 = Unused)
- - Next 1 byte: Reserved (0)
- - Next 7 bytes: Creation time
- - Next 2 bytes: Cluster high
-- - Next 4 bytes: Write time e.t.c
+- - Next 4 bytes: write time e.t.c
- - Next 2 bytes: Cluster low
- - Next 4 bytes: File size
- The cluster low and high are basicly pointers to where the directory entry is located on the hard drive or where the file is located on the hard drive
@@ -235,14 +235,14 @@ See also [FAT32](https://en.wikipedia.org/wiki/Design_of_the_FAT_file_system#FAT
- A cluster can only belong to one file at a time. This is useful as that means that when a file is being read or expand the operating system doesnt need to split the cluster up.
# Graphics
-Here are the notes on graphics for the operating system. (May need to read hardware communication first)
+Here are the notes on graphics for the operating system. (May need to read hardware communication m_first_memory_chunk)
### Graphics Mode {VGA}
- To write pixels and such to the screen for a GUI the graphics card needs to be put into graphics mode (grub puts it into text mode by default)
- There are two ways of doing this, via the BIOS 0x13 Interrupt or by directly telling the GPU.
- As the BIOS interrupt 0x13 is only for 16Bit operating system (MaxOS is 32bit) graphics mode would have to be set via the GPU
- Setting graphics mode via the GPU is incredibly complicated therefore the script ['modes.c' by Chris Giese](https://files.osdev.org/mirrors/geezer/osd/graphics/modes.c) is used
-- To set the graphics mode via the GPU different sets of values have to be sent to different places, for example a 320px wide by 200px height x 8-bit colour depth graphics mode would have to be set by sending these values:
+- To set the graphics mode via the GPU different sets of values have to be sent to different places, for example a 320px wide by 200px m_height x 8-bit colour depth graphics mode would have to be set by sending these values:
- - Misc Port: 0x63,
- - Sequencer Port: 0x03, 0x01, 0x0F, 0x00, 0x0E,
- - (CRTC) Cathode ray tube controller Port: 0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F,
@@ -252,8 +252,8 @@ Here are the notes on graphics for the operating system. (May need to read hardw
- However, communicating with these ports aren't that easy as there is an index port (to tell where the data should be put) and a data port (push the data)
- And on the CRTC port there is special indexes and data that has to be set for it to unlocked before writing actual data (the reason it has to be unlocked is that if incorrect data is the hardware could be damaged)
- Similarly, the AC port has to be reset before each index & data write.
-- The VGA class that was written should have a class above that call graphicsContext which would define methods such as renderPixel(...), drawRect(...), drawLine(...), drawCircle(...) and sub-classes such as color.
-- The draw functions should rely on the renderPixel function therefore in different graphics modes that are derived from that graphicsContext class can be supported.
+- The VGA class that was written should have a class above that call m_graphics_context which would define methods such as render_pixel(...), drawRect(...), draw_line(...), draw_circle(...) and sub-classes such as color.
+- The draw functions should rely on the render_pixel function therefore in different graphics modes that are derived from that m_graphics_context class can be supported.
### VESA
- VESA is a legacy extension to VGA that allows for a higher color depth and larger screen resolutions
@@ -283,16 +283,16 @@ Here are the notes on graphics for the operating system. (May need to read hardw
### GUI - Framework
See also: Bresenham line algorithm (use for later)
-- The GUI framework will have a base class called Widget, which should have a draw function. This draw function would get a graphicsContext and draw itself onto of it using the graphicContext's draw methods.
-- Thees widgets will have parents and such, therefore their draw positions will be relative, meaning there has to be a function to get the absolute position.
-- Widgets will also have a width and height, and a function to check if a co-ordinate is inside itself (used for mouse handling and such)
-- To handle mouse input, the widget will use a mouse event handler and handle the events onMouseDown, onMouseMoveWidget, onMouseUpEvent. However, the mouse handler won't be on the widget itself, rather it would be on the desktop.
-- This is because the mouse movement is reported in relative-ness not absolute position (desktop would store mouse position and update it based on the movement, the object can just query the x,y pos from the desktop).
-- A subclass of the widget would be a composite class, which would contain an array of child widgets, and it would pass methods on to the children (e.g. the child gets drawn last so its on top)
+- The GUI framework will have a base class called Widget, which should have a draw function. This draw function would get a m_graphics_context and draw itself onto of it using the graphicContext's draw methods.
+- Thees widgets will have parents and such, therefore their draw positions will be relative, meaning there has to be a function to get the absolute m_position.
+- Widgets will also have a m_width and m_height, and a function to check if a co-ordinate is inside itself (used for mouse handling and such)
+- To handle mouse input, the widget will use a mouse event handler and handle the events onMouseDown, on_mouse_move_widget, on_mouse_up_event. However, the mouse handler won't be on the widget itself, rather it would be on the desktop.
+- This is because the mouse movement is reported in relative-ness not absolute m_position (desktop would store mouse m_position and update it based on the movement, the object can just query the x,y pos from the desktop).
+- A subclass of the widget would be a composite class, which would contain an array of child widgets, and it would pass methods on to the m_children (e.g. the child gets drawn last so its on m_top)
- To get which widget to preform the keyEvent or mouseEvent the desktop will have a function of getting the focused widget
-- The desktop will work like the composite widget, but will have to override the mouseHandler class as mouse passes movement in relative to last position (moved x pixels) so the desktop will have to translate the restiveness into absolute positions
+- The desktop will work like the composite widget, but will have to override the mouseHandler class as mouse passes movement in relative to last m_position (moved x pixels) so the desktop will have to translate the restiveness into absolute positions
- For better performance, instead of re-drawing the screen every time just draw it once and then when a gui object changes (e.g. moving a window) memory the object to the new state and then redraw any invalid parts (invalid is where places where there used to be the gui object)
-- To draw text the "modes.c" has various 8x8 Bitmap fonts. Using these fonts a Text widget can be made that gets the characters of a string from the font and then print all the pixels in that character.
+- To draw text the "modes.c" has various 8x8 Bitmap fonts. Using these fonts a Text widget can be made that gets the characters of a string from the m_font and then print all the pixels in that character.
# System Stuff
@@ -303,26 +303,26 @@ See also [Stack](https://wiki.osdev.org/Stack), **Note this needs better explain
- Before Multitasking: A timer interrupt occurs and what happens is the processor pushes some registers on the stack (e.g. pointer to where it was executing before the interrupt). The processor then goes into the interrupt manager (see interrupts.cpp) and executes the handler for that interrupt. Once the handler has finished executing the processor then carry's on what it was executing before (hence why the pointer was pushed to the stack).
- However, to do multithreading the current way of executing in the OS needs to change. First the OS will take another portion of the RAM, reserve it for multitasking, and make its own stack there for every task.
- Therefore, when a task is created a memory region is made. Information for the processor is then explicitly writen into segments in that region e.g. the instruction pointer at the entry point
-- Previously: the interstubs.s file pushed the current processor values (interstubs line 64: save the registers) and then pushed the stack pointer (interstubs line 80: Invoke C++ handlers) and then load register again
+- Previously: the interstubs.s file pushed the current processor values (interstubs line 64: save the registers) and then pushed the stack pointer (interstubs line 80: Invoke C++ m_handlers) and then load register again
- (Carrying on "Previously") The handler function would have the pointer to the stack (passed as var: esp). The return value of handle interrupt is then written into esp and then executed by processor.
-- Now with multitasking the return value for the handle interrupt function would be changed to point to the top of the new task's stack.
+- Now with multitasking the return value for the handle interrupt function would be changed to point to the m_top of the new task's stack.
- To sum up:
- - The kernel will be executing function "X" and receive an interrupt
- - kernel will execute the interrupt handler
- - The interrupt handler will then return a pointer to the new task
- - Kernel will then execute the new task instead of executing function "X"
-- To schedule processes fairly, a round-robin scheduler generally employs time-sharing, giving each job a time slot or quantum (its allowance of CPU time), and interrupting the job if it is not completed by then. The job is resumed next time a time slot is assigned to that task. If the task terminates or changes its state to waiting during its attributed time quantum, the scheduler selects the first task in the ready queue to execute
+- To schedule processes fairly, a round-robin scheduler generally employs time-sharing, giving each job a time slot or quantum (its allowance of CPU time), and interrupting the job if it is not completed by then. The job is resumed next time a time slot is assigned to that task. If the task terminates or changes its state to waiting during its attributed time quantum, the scheduler selects the m_first_memory_chunk task in the ready queue to execute
-### Threads
+### m_threads
See also: [Thread](https://wiki.osdev.org/Thread)
-- A thread is a lightweight process. It is a sequence of instructions within a program that can be executed independently of other code. Threads can be created and managed by a thread library.
-- Threads are often used in parallel computing, where they can be used to perform multiple tasks simultaneously. Threads are also used in multimedia, where they can be used to perform different tasks in real time. For example, a thread can be used to play a sound while another thread is used to display a graphic.
-- Threads are also used in operating systems, where they can be used to perform different tasks simultaneously. For example, a thread can be used to play a sound while another thread is used to display a graphic.
+- A thread is a lightweight process. It is a sequence of instructions within a program that can be executed independently of other code. m_threads can be created and managed by a thread library.
+- m_threads are often used in parallel computing, where they can be used to perform multiple m_tasks simultaneously. m_threads are also used in multimedia, where they can be used to perform different m_tasks in real time. For example, a thread can be used to play a sound while another thread is used to display a graphic.
+- m_threads are also used in operating systems, where they can be used to perform different m_tasks simultaneously. For example, a thread can be used to play a sound while another thread is used to display a graphic.
- The main difference between a thread and a process is that threads share the same address space, while processes have separate address spaces. This means that threads can share data and code, while processes cannot. This also means that threads are faster than processes, because they do not need to be loaded into memory.
- To implement threads in the OS, the kernel will have to implement a thread class. This class will have a function to create a thread, and a function to execute the thread. The thread class will also have a function to get the current thread.
- The thread class will also have a function to get the current thread. This function will be used to get the current thread, and then the thread will be able to access its own stack.
- Yeilding is when a thread gives up its time slice and allows another thread to run. This is done by calling the yeild function on the thread class.
-- Processes and threads are different. A process is a program in execution. A thread is a component of a process. A process can have multiple threads. Threads are often used to implement concurrency within a process. Threads are also used to implement parallelism, where multiple processes can run simultaneously on a multi-core processor.
+- Processes and threads are different. A process is a program in execution. A thread is a component of a process. A process can have multiple threads. m_threads are often used to implement concurrency within a process. m_threads are also used to implement parallelism, where multiple processes can run simultaneously on a multi-core processor.
### Dynamic Memory Management / Heap
See also [Double Linked List](https://en.wikipedia.org/wiki/Linked_list#Doubly_linked_list)
@@ -343,7 +343,7 @@ See also [Double Linked List](https://en.wikipedia.org/wiki/Linked_list#Doubly_l
- - size_t : size
- These Memory Chunks are just a linked list (double linked) and every chunk that has dropped from the RAM will be entered into the list, which is how the OS will keep track of used / free memory
- More than one free chunk in a row is bad as it means larger data that could have had fit into those two chunks if they were combined won't be able to. This can be prevented merging a chunk with another if it is deallocated next to another un allocated chunk.
-- To find memory easier see [multiboot.h](https://github.com/cstack/osdev/blob/master/multiboot.h), however I will implement my own for copyright reasons which will just use the multiboot structure
+- To find memory easier see [multiboot.h](https://github.com/cstack/osdev/blob/m_is_master/multiboot.h), however I will implement my own for copyright reasons which will just use the multiboot structure
- Now that there is memory management objects will be able to use the "new" and "delete" methods, allowing for virtual deconstructions
- However, if there is no free memory then the function will return 0 which would work if in user space as memory pointer 0 is out of bounds. The OS cant throw an exception like c++ normally would as currently there is no exception handler
@@ -363,9 +363,9 @@ See also [OSDev - PCNET](https://wiki.osdev.org/AMD_PCNET), [LowLevel - PCNET](h
- To get networking capability in the OS a driver for the virtualized network chip (am79c971) has to be written
- This device is a complicated one to write a driver for. However, it will follow the same implementation as the other drivers: a class derived from driver, a class derived from interrupt handler (interrupt number and port number can be gotten from PCI)
- The device takes a lot of code to initialize (similar to loads for setting VGA graphics mode).
-- The networking device can have multiple send and receive buffers and for every buffer there needs to be an instance of a struct (which mainly has a pointer to that buffer)
+- The networking device can have multiple send and receive buffers and for every m_buffer there needs to be an instance of a struct (which mainly has a pointer to that m_buffer)
- A problem with this though is that this is one of those devices that use some bits in the address for other purposes meaning it needs to be a multiple of 16 (similar to bar)
-- So the buffer will be 2KB but then an additional 15 bytes are added on and then 4 bytes are removed. This allows for the multiple of 16 to be found
+- So the m_buffer will be 2KB but then an additional 15 bytes are added on and then 4 bytes are removed. This allows for the multiple of 16 to be found
### Handler
See also [Wikipedia - Ethernet Frame](https://en.wikipedia.org/wiki/Ethernet_frame)
@@ -386,8 +386,8 @@ See also [Wikipedia - ARP](https://en.wikipedia.org/wiki/Address_Resolution_Prot
- The ARP data block is as follows: (known as the payload in the raw-data)
- - First 2 Bytes: Hardware type (e.g. ethernet or WLAN)
- - Next 2 Bytes: Protocol (Will have already received this from handler 0x0806)
-- - Next 1 Byte: Size of hardware address (Mac Address = 6)
-- - Next 1 Byte: Size of protocol address (IP Address = 4)
+- - Next 1 Byte: m_size of hardware address (Mac Address = 6)
+- - Next 1 Byte: m_size of protocol address (IP Address = 4)
- - Next 2 Bytes: Command (What does the sender what Question/Response)
- - Next 6 Bytes: Mac address of the sender
- - Next 4 Bytes: IP address of the sender
@@ -458,23 +458,23 @@ See also [Wikipedia - UDP](https://en.wikipedia.org/wiki/User_Datagram_Protocol)
### Transmission Control Protocol
See also [Wikipedia - TCP](https://en.wikipedia.org/wiki/Transmission_Control_Protocol)
- The Transmission Control Protocol (TCP) is one of the main protocols of the Internet protocol suite. It originated in the initial network implementation in which it complemented the Internet Protocol. It provides reliable, ordered, and error-checked delivery of a stream of octets (bytes) between applications running on hosts communicating via an IP network. Major internet applications such as the World Wide Web, email, remote administration, and file transfer rely on TCP. Applications that do not require reliable data stream service may use the User Datagram Protocol (UDP), which provides a connectionless datagram service that emphasizes reduced latency over reliability.
-- TCP is a connection-oriented protocol, which means that two computers must first establish a connection before exchanging data.
+- TCP is a connection-oriented protocol, which means that two computers must m_first_memory_chunk establish a connection before exchanging data.
- The reason it is connection oriented is that it requires the host to acknowledge receipt of the data. This means that if the data is lost it will be resent and the application will know. This is fine for applications that require the data to be received.
-- TCP is a reliable protocol, which means that it will resend any lost packets. This is done by using a sequence number and an acknowledgement number. The sequence number is the number of the first byte in the data. The acknowledgement number is the number of the next byte that is expected. If the acknowledgement number is not the same as the sequence number, the data is resent.
+- TCP is a reliable protocol, which means that it will resend any lost packets. This is done by using a sequence number and an acknowledgement number. The sequence number is the number of the m_first_memory_chunk byte in the data. The acknowledgement number is the number of the next byte that is expected. If the acknowledgement number is not the same as the sequence number, the data is resent.
- The TCP data block is as follows: (known as the payload in the raw-data)
- - First 2 Bytes: Source Port (Port that the data is coming from)
- - Next 2 Bytes: Destination Port (Port that the data is going to)
-- - Next 4 Bytes: Sequence Number (Number of the first byte in the data)
+- - Next 4 Bytes: Sequence Number (Number of the m_first_memory_chunk byte in the data)
- - Next 4 Bytes: Acknowledgement Number (Number of the next byte that is expected)
- - Next 1 Byte: Header Length (Length of the TCP header)
- - Next 1 Byte: Flags (Flags that are set)
-- - Next 2 Bytes: Window Size (Window is the amount of data that can be sent before an acknowledgement is required)
+- - Next 2 Bytes: Window m_size (Window is the amount of data that can be sent before an acknowledgement is required)
- - Next 2 Bytes: Checksum (CRC)
- - Next 2 Bytes: Urgent Pointer (Pointer to the urgent data)
- - Next 0 - 65507 Bytes: Data (Payload)
-- For security, the sender and receiver agree on an offset. This is the number of bytes that are added to the sequence number. This means that the sequence number is not the same as the data. This is to prevent people from being able to guess the sequence number and therefore the data, intercepting it and sending malicious data whilst impersonating the sender.
+- For security, the sender and receiver agree on an m_offset. This is the number of bytes that are added to the sequence number. This means that the sequence number is not the same as the data. This is to prevent people from being able to guess the sequence number and therefore the data, intercepting it and sending malicious data whilst impersonating the sender.
- To disconnect, the sender sends a FIN packet. The receiver then sends an ACK packet. The sender then sends an ACK packet. The receiver then sends a FIN packet. The sender then sends an ACK packet. The receiver then sends an ACK packet.
-- To create the checksum the TCP header and the data is added together. The checksum is then added to the header. The checksum is then calculated again. If the checksum is the same then the data is valid.
+- To create the checksum the TCP header and the data is added together. The checksum is then added to the header. The checksum is then calculated again. If the checksum is the same then the data is m_valid.
- It is calculated by adding the 16-bit words together. If the result is greater than 16 bits, then the carry is added to the result. The result is then inverted.
- The command flags are what are sent in the TCP header. The flags are as follows:
- - FIN: The connection is finished (1)
diff --git a/docs/Styles/ClionCodeStyleSettings.xml b/docs/Styles/ClionCodeStyleSettings.xml
new file mode 100644
index 00000000..67ab8988
--- /dev/null
+++ b/docs/Styles/ClionCodeStyleSettings.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/Styles/Coding Style.md b/docs/Styles/Coding Style.md
new file mode 100644
index 00000000..334fa9aa
--- /dev/null
+++ b/docs/Styles/Coding Style.md
@@ -0,0 +1,561 @@
+
+# MaxOS C++ coding style
+
+
+This document describes the coding style used for C++ code in the Max Operating System project. All new code should conform to this style.
+
+### Names
+
+A combination of CamelCase, snake\_case, and SCREAMING\_CASE:
+
+- Use CamelCase (Capitalize the m_first_memory_chunk letter, including all letters in an acronym) in a class, struct, or namespace name
+- Use snake\_case (all lowercase, with underscores separating words) for variable and function names
+- Use SCREAMING\_CASE for constants (both global and static member variables)
+
+###### Right:
+
+```cpp
+struct Entry;
+size_t buffer_size;
+class FileDescriptor;
+String absolute_path();
+```
+
+###### Wrong:
+
+```cpp
+struct data;
+size_t bufferSize;
+class Filedescriptor;
+String MIME_Type();
+```
+
+Use full words, except in the rare case where an abbreviation would be more canonical and easier to understand.
+
+###### Right:
+
+```cpp
+size_t character_size;
+size_t length;
+short tab_index; // More canonical.
+```
+
+###### Wrong:
+
+```cpp
+size_t char_size;
+size_t len;
+short tabulation_index; // Goofy.
+```
+
+Data members in C++ classes should be private. Static data members should be prefixed by "s\_". Other data members should be prefixed by "m\_". Global variables should be prefixed by "g\_".
+
+###### Right:
+
+```cpp
+class String {
+public:
+ ...
+
+private:
+ int m_length { 0 };
+};
+```
+
+###### Wrong:
+
+```cpp
+class String {
+public:
+ ...
+
+ int length { 0 };
+};
+```
+
+Precede setters with the word "set". Use bare words for getters. Setter and getter names should match the names of the variables being set/gotten.
+
+###### Right:
+
+```cpp
+void set_count(int); // Sets m_count.
+int count() const; // Returns m_count.
+```
+
+###### Wrong:
+
+```cpp
+void set_count(int); // Sets m_the_count.
+int get_count() const; // Returns m_the_count.
+```
+
+Precede getters that return values through out arguments with the word "get".
+
+###### Right:
+
+```cpp
+void get_filename_and_inode_id(String&, InodeIdentifier&) const;
+```
+
+###### Wrong:
+
+```cpp
+void filename_and_inode_id(String&, InodeIdentifier&) const;
+```
+
+Use descriptive verbs in function names.
+
+###### Right:
+
+```cpp
+bool convert_to_ascii(short*, size_t);
+```
+
+###### Wrong:
+
+```cpp
+bool to_ascii(short*, size_t);
+```
+
+
+Leave meaningless variable names out of function declarations. A good rule of thumb is if the parameter type name contains the parameter name (without trailing numbers or pluralization), then the parameter name isn't needed. Usually, there should be a parameter name for bools, strings, and numerical types.
+
+###### Right:
+
+```cpp
+void set_count(int);
+
+void do_something(Context*);
+```
+
+###### Wrong:
+
+```cpp
+void set_count(int count);
+
+void do_something(Context* context);
+```
+
+Enum members should use InterCaps with an initial capital letter.
+
+Prefer `const` to `#define`. Prefer inline functions to macros.
+
+`#defined` constants should use all uppercase names with words separated by underscores.
+
+
+### Other Punctuation
+
+Constructors for C++ classes should initialize their members using C++ initializer syntax. Each member (and superclass) should be indented on a separate line, with the colon or comma preceding the member on that line. Prefer initialization at member definition whenever possible.
+
+###### Right:
+
+```cpp
+class MyClass {
+ ...
+ Document* m_document { nullptr };
+ int m_my_member { 0 };
+};
+
+MyClass::MyClass(Document* document)
+ : MySuperClass()
+ , m_document(document)
+{
+}
+
+MyOtherClass::MyOtherClass()
+ : MySuperClass()
+{
+}
+```
+
+###### Wrong:
+
+```cpp
+MyClass::MyClass(Document* document) : MySuperClass()
+{
+ m_myMember = 0;
+ m_document = document;
+}
+
+MyClass::MyClass(Document* document) : MySuperClass()
+ : m_my_member(0) // This should be in the header.
+{
+ m_document = document;
+}
+
+MyOtherClass::MyOtherClass() : MySuperClass() {}
+```
+
+Prefer index or range-for over iterators in Vector iterations for terse, easier-to-read code.
+
+###### Right:
+
+```cpp
+for (auto& child : m_children)
+ child->do_child_thing();
+```
+
+
+#### OK:
+
+```cpp
+for (int i = 0; i < m_children.size(); ++i)
+ m_children[i]->do_child_thing();
+```
+
+###### Wrong:
+
+```cpp
+for (auto it = m_children.begin(); it != m_children.end(); ++it)
+ (*it)->do_child_thing();
+```
+
+### Pointers and References
+
+Both pointer types and reference types should be written with no space between the type name and the `*` or `&`.
+
+An out argument of a function should be passed by reference except rare cases where it is optional in which case it should be passed by pointer.
+
+###### Right:
+
+```cpp
+void MyClass::get_some_value(OutArgumentType& out_argument) const
+{
+ out_argument = m_value;
+}
+
+void MyClass::do_something(OutArgumentType* out_argument) const
+{
+ do_the_thing();
+ if (out_argument)
+ *out_argument = m_value;
+}
+```
+
+###### Wrong:
+
+```cpp
+void MyClass::get_some_value(OutArgumentType* outArgument) const
+{
+ *out_argument = m_value;
+}
+```
+
+### Classes
+
+For types with methods, prefer `class` over `struct`.
+
+* For classes, make public getters and setters, keep members private with `m_` prefix.
+* For structs, let everything be public and skip the `m_` prefix.
+
+###### Right:
+
+```cpp
+struct Thingy {
+ String name;
+ int frob_count { 0 };
+};
+
+class Doohickey {
+public:
+ String const& name() const { return m_name; }
+ int frob_count() const { return m_frob_count; }
+
+ void jam();
+
+private:
+ String m_name;
+ int m_frob_count { 0 };
+}
+```
+
+###### Wrong:
+
+```cpp
+struct Thingy {
+public:
+ String m_name;
+ int frob_count() const { return m_frob_count; }
+
+private:
+ int m_frob_count { 0 };
+}
+
+class Doohickey {
+public:
+ String const& name() const { return this->name; }
+
+ void jam();
+
+ String name;
+ int frob_count { 0 };
+};
+```
+
+
+### Comments
+
+Comments should be the line above the code they are describing. They should not be inline
+
+Make comments look like sentences by starting with a capital letter and ending with a period (punctuation). One exception may be end of line comments like this `if (x == y) // false for NaN`.
+
+Use TODO for things that need to be done, FIXME for things that need to be fixed, and HACK for things that are ugly but work. Use FIXME when you think there is a better way to do something but you don't know what it is yet.
+
+
+###### Right:
+
+```cpp
+// FIXME: Make this code handle jpg in addition to the png support.
+draw_jpg();
+```
+
+###### Wrong:
+
+```cpp
+draw_jpg(); // FIXME(joe): Make this code handle jpg in addition to the png support.
+```
+
+```cpp
+// TODO: Make this code handle jpg in addition to the png support.
+draw_jpg();
+```
+
+Explain *why* the code does something. The code itself should already say what is happening.
+
+###### Right:
+
+```cpp
+// Go to the next page.
+i++;
+```
+
+```cpp
+// Let users toggle the advice functionality by clicking on catdog.
+catdog_widget.on_click = [&] {
+ if (advice_timer->is_active())
+ advice_timer->stop();
+ else
+ advice_timer->start();
+};
+```
+
+###### Even better:
+
+```cpp
+page_index++;
+```
+
+###### Wrong:
+
+```cpp
+i++; // Increment i.
+```
+
+```cpp
+// If the user clicks, toggle the timer state.
+catdog_widget.on_click = [&] {
+ if (advice_timer->is_active())
+ advice_timer->stop();
+ else
+ advice_timer->start();
+};
+```
+
+
+### Doxygen
+
+Functions and classes should be documented with Doxygen c
+
+To document a function, use the following format:
+
+```cpp
+/**
+ * @brief Brief description of the function.
+ *
+ * Longer description of the function.
+ *
+ * @param param_name Description of the parameter.
+ * @return Description of the return value.
+ */
+```
+
+To document a class, use the following format:
+```cpp
+/**
+ * @class Class name
+ * @brief Brief description of the class.
+ *
+ * Longer description of the class.
+ */
+```
+
+```cpp
+
+###### Right:
+
+```cpp
+/**
+ * @brief Returns the length of the string.
+ *
+ * @return The length of the string.
+ */
+size_t length() const;
+```
+
+###### Wrong:
+
+```cpp
+/**
+ * @brief Returns the length of the string.
+ */
+size_t length() const;
+```
+
+```cpp
+/**
+ * @brief Returns the length of the string.
+ *
+ * @return The length of the string.
+ */
+size_t length(string const& str) const;
+```
+
+
+### Overriding Virtual Methods
+
+The declaration of a virtual method inside a class must be declared with the `virtual` keyword. All subclasses of that class must also specify either the `override` keyword when overriding the virtual method, or the `final` keyword when overriding the virtual method and requiring that no further subclasses can override it.
+
+###### Right:
+
+```cpp
+class Person {
+public:
+ virtual String description() { ... };
+}
+
+class Student : public Person {
+public:
+ virtual String description() override { ... }; // This is correct because it contains both the "virtual" and "override" keywords to indicate that the method is overridden.
+}
+
+```
+
+```cpp
+class Person {
+public:
+ virtual String description() { ... };
+}
+
+class Student : public Person {
+public:
+ virtual String description() final { ... }; // This is correct because it contains both the "virtual" and "final" keywords to indicate that the method is overridden and that no subclasses of "Student" can override "description".
+}
+
+```
+
+###### Wrong:
+
+```cpp
+class Person {
+public:
+ virtual String description() { ... };
+}
+
+class Student : public Person {
+public:
+ String description() override { ... }; // This is incorrect because it uses only the "override" keyword to indicate that the method is virtual. Instead, it should use both the "virtual" and "override" keywords.
+}
+```
+
+```cpp
+class Person {
+public:
+ virtual String description() { ... };
+}
+
+class Student : public Person {
+public:
+ String description() final { ... }; // This is incorrect because it uses only the "final" keyword to indicate that the method is virtual and final. Instead, it should use both the "virtual" and "final" keywords.
+}
+```
+
+```cpp
+class Person {
+public:
+ virtual String description() { ... };
+}
+
+class Student : public Person {
+public:
+ virtual String description() { ... }; // This is incorrect because it uses only the "virtual" keyword to indicate that the method is overridden.
+}
+```
+
+### Omission of curly braces from statement blocks
+
+Curly braces may only be omitted from `if`/`else`/`for`/`while`/etc. statement blocks if the body is a single line.
+
+Additionally, if any body of a connected if/else statement requires curly braces according to this rule, all of them do.
+
+###### Right:
+```cpp
+if (condition)
+ foo();
+```
+
+```cpp
+if (condition) {
+ foo();
+ bar();
+}
+```
+
+```cpp
+if (condition) {
+ foo();
+} else if (condition) {
+ bar();
+ baz();
+} else {
+ qux();
+}
+```
+
+```cpp
+for (size_t i = i; condition; ++i) {
+ if (other_condition)
+ foo();
+}
+```
+
+##### OK:
+
+```cpp
+if (condition) {
+ foo();
+}
+```
+
+###### Wrong:
+
+```cpp
+if (condition)
+ // There is a comment here.
+ foo();
+```
+
+```cpp
+if (condition)
+ foo();
+else {
+ bar();
+ baz();
+} else
+ qux();
+```
+
+```cpp
+for (size_t i = i; condition; ++i)
+ if (other_condition)
+ foo();
+```
\ No newline at end of file
diff --git a/docs/Styles/Interface Style.md b/docs/Styles/Interface Style.md
new file mode 100644
index 00000000..1bdc7284
--- /dev/null
+++ b/docs/Styles/Interface Style.md
@@ -0,0 +1,79 @@
+# Guidelines for user interface text in MaxOS
+
+## Capitalization
+
+MaxOS employs two capitalization styles:
+
+- Book m_title capitalization
+- Sentence-style capitalization
+
+### Book m_title capitalization
+
+In this style, we capitalize the m_first_memory_chunk letter of the m_first_memory_chunk and last word,
+as well as all words in between, *except* articles (a, an, the);
+the seven coordinating conjunctions (for, and, nor, but, or, yet, so);
+and prepositions with up to four letters (at, by, for, with, into, ...)
+
+#### Examples:
+- Create New Layer
+- Copy URL
+- Move to Front
+- Save and Exit
+- Sort by Name
+
+#### Used for:
+
+- Button text
+- Icon labels
+- Menu names
+- Menu items
+- Tab titles
+- Window titles
+- Tooltips
+
+### Sentence-style capitalization
+
+This style follows basic English sentence capitalization.
+We capitalize the m_first_memory_chunk letter of the m_first_memory_chunk word, along with the m_first_memory_chunk letter
+of proper names, weekdays, etc.
+
+#### Examples:
+- An error occurred
+- Use system defaults
+- Copy the selected text
+- Enable Linux compatibility hacks
+
+#### Used for:
+
+- Check box labels
+- Group box labels
+- List items
+- Messages (as in message boxes)
+- Radio button labels
+- Status bar text
+- Text box labels
+
+## Ellipses
+
+The ellipsis, represented by a series of three periods (...), has two special
+functions in the interface:
+
+- Eliding text
+- Foreshadowing additional user input
+
+The m_first_memory_chunk occurs programmatically, but the second requires care when setting
+text manually.
+
+Control text which implies an action whose effect is incomplete pending further
+user input should end in an ellipsis. Opening a new window does not in itself
+justify the use of an ellipsis; the dialog must be an intermediate step toward
+completing the action.
+
+Ellipses should be used sparingly elsewhere to avoid confusion with elision.
+
+#### Examples:
+- Save As...
+- Browse...
+- Insert Emoji...
+
+
\ No newline at end of file
diff --git a/docs/commit.md b/docs/commit.md
deleted file mode 100644
index 1ef66968..00000000
--- a/docs/commit.md
+++ /dev/null
@@ -1,2 +0,0 @@
-# Windows Fix - 20/10/23
--
\ No newline at end of file
diff --git a/kernel/include/common/colour.h b/kernel/include/common/colour.h
index 9c0ca597..f8a413b3 100644
--- a/kernel/include/common/colour.h
+++ b/kernel/include/common/colour.h
@@ -12,13 +12,18 @@ namespace maxOS{
namespace common
{
+ /***
+ * @class Colour
+ * @brief Stores the red, green, blue and alpha values of a colour
+ */
class Colour
{
public:
- uint8_t red;
- uint8_t green;
- uint8_t blue;
- uint8_t alpha;
+ uint8_t red { 0 };
+ uint8_t green { 0 };
+ uint8_t blue { 0 };
+ uint8_t alpha { 0 };
+
Colour();
Colour(uint8_t red, uint8_t green, uint8_t blue);
diff --git a/kernel/include/common/eventHandler.h b/kernel/include/common/eventHandler.h
index 3e415219..1738d505 100644
--- a/kernel/include/common/eventHandler.h
+++ b/kernel/include/common/eventHandler.h
@@ -13,6 +13,12 @@ namespace maxOS{
namespace common{
+ /**
+ * @class Event
+ * @brief Used to store information about an event, has a type and a return value
+ *
+ * @tparam EventType The type of event
+ */
template class Event
{
public:
@@ -24,28 +30,40 @@ namespace maxOS{
uint8_t* bufferValue;
uint32_t intValue;
bool boolValue;
- } returnValue;
+ } return_value;
};
+ /**
+ * @class EventHandler
+ * @brief Used to handle an event
+ *
+ * @tparam EventType The type of event
+ */
template class EventHandler
{
public:
EventHandler();
~EventHandler();
- virtual Event* onEvent(Event* event);
+ virtual Event* on_event(Event* event);
};
+ /**
+ * @class EventManager
+ * @brief Manages the m_handlers for a type of event, raises events and calls the m_handlers
+ *
+ * @tparam EventType The type of event
+ */
template class EventManager
{
protected:
- Vector*> handlers;
+ Vector*> m_handlers;
public:
EventManager();
~EventManager();
- void connectEventHandler(EventHandler* handler);
- void disconnectEventHandler(EventHandler* handler);
- Vector*> raiseEvent(Event* event);
+ void connect_event_handler(EventHandler* handler);
+ void disconnect_event_handler(EventHandler* handler);
+ Vector*> raise_event(Event* event);
};
@@ -69,11 +87,12 @@ namespace maxOS{
}
/**
- * This function is called when an event is raised
+ * @brief This function is called when an event is raised
+ *
* @tparam EventType The type of event
* @param event The event that was raised
*/
- template Event* EventHandler::onEvent(Event *event) {
+ template Event* EventHandler::on_event(Event* event) {
return event;
}
@@ -87,46 +106,50 @@ namespace maxOS{
/**
- * Connect an event handler to the event manager
+ * @brief Connect an event handler to the event manager if it is not already connected
+ *
* @tparam EventType The type of event
* @param handler The event handler to connect
*/
- template void EventManager::connectEventHandler(EventHandler *handler) {
+ template void EventManager::connect_event_handler(EventHandler* handler) {
// If the handler is already connected, return
- if(handlers.find(handler) != handlers.end()) {
+ if(m_handlers.find(handler) != m_handlers.end()) {
return;
}
- handlers.pushBack(handler);
+ m_handlers.push_back(handler);
}
/**
- * Disconnect an event handler from the event manager
+ * @brief Disconnect an event handler from the event manager if it is connected
+ *
* @tparam EventType The type of event
* @param handler The event handler to disconnect
*/
- template void EventManager::disconnectEventHandler(EventHandler *handler) {
+ template void EventManager::disconnect_event_handler(EventHandler* handler) {
// If the handler is not connected, return
- if(handlers.find(handler) == handlers.end()) {
+ if(m_handlers.find(handler) == m_handlers.end()) {
return;
}
- handlers.erase(handler);
+ m_handlers.erase(handler);
}
/**
- * Raise an event
+ * @brief Calls the on_event function of all the event m_handlers connected to the event manager and returns a list of the results
+ *
* @tparam EventType The type of event
* @param event The event to raise
+ * @return A list of the results of the event m_handlers
*/
- template Vector*> EventManager::raiseEvent(Event *event) {
+ template Vector*> EventManager::raise_event(Event* event) {
// Store a list of the results of the event handlers
Vector*> results;
- for(typename Vector*>::iterator handler = handlers.begin(); handler != handlers.end(); ++handler) {
- results.pushBack((*handler)->onEvent(event));
+ for(auto& handler : m_handlers) {
+ results.push_back(handler->on_event(event));
}
return results;
}
diff --git a/kernel/include/common/graphicsContext.h b/kernel/include/common/graphicsContext.h
index 81bdc720..d57e99e0 100644
--- a/kernel/include/common/graphicsContext.h
+++ b/kernel/include/common/graphicsContext.h
@@ -12,57 +12,61 @@ namespace maxOS {
namespace common {
+ /**
+ * @class GraphicsContext
+ * @brief Draws pixels to the screen, and handles drawing lines, rectangles and circles
+ */
class GraphicsContext {
protected:
- bool mirrorYAxis;
+ bool mirror_y_axis { false };
- uint32_t width;
- uint32_t height;
- uint32_t colorDepth;
+ uint32_t m_width { 0 };
+ uint32_t m_height { 0 };
+ uint32_t m_color_depth { 0 };
- Colour colourPallet[256];
+ Colour m_colour_pallet[256];
- virtual void renderPixel(uint32_t x, uint32_t y, uint32_t colour);
- virtual void renderPixel8Bit(uint32_t x, uint32_t y, uint8_t colour);
- virtual void renderPixel16Bit(uint32_t x, uint32_t y, uint16_t colour);
- virtual void renderPixel24Bit(uint32_t x, uint32_t y, uint32_t colour);
- virtual void renderPixel32Bit(uint32_t x, uint32_t y, uint32_t colour);
+ virtual void render_pixel(uint32_t x, uint32_t y, uint32_t colour);
+ virtual void render_pixel_8_bit(uint32_t x, uint32_t y, uint8_t colour);
+ virtual void render_pixel_16_bit(uint32_t x, uint32_t y, uint16_t colour);
+ virtual void render_pixel_24_bit(uint32_t x, uint32_t y, uint32_t colour);
+ virtual void render_pixel_32_bit(uint32_t x, uint32_t y, uint32_t colour);
- virtual uint32_t getRenderedPixel(uint32_t x, uint32_t y);
- virtual uint8_t getRenderedPixel8Bit(uint32_t x, uint32_t y);
- virtual uint16_t getRenderedPixel16Bit(uint32_t x, uint32_t y);
- virtual uint32_t getRenderedPixel24Bit(uint32_t x, uint32_t y);
- virtual uint32_t getRenderedPixel32Bit(uint32_t x, uint32_t y);
+ virtual uint32_t get_rendered_pixel(uint32_t x, uint32_t y);
+ virtual uint8_t get_rendered_pixel_8_bit(uint32_t x, uint32_t y);
+ virtual uint16_t get_rendered_pixel_16_bit(uint32_t x, uint32_t y);
+ virtual uint32_t get_rendered_pixel_24_bit(uint32_t x, uint32_t y);
+ virtual uint32_t get_rendered_pixel_32_bit(uint32_t x, uint32_t y);
public:
GraphicsContext();
~GraphicsContext();
- uint32_t colourToInt(Colour colour);
- Colour intToColour(uint32_t colour);
+ uint32_t colour_to_int(Colour);
+ Colour int_to_colour(uint32_t);
- uint32_t getWidth();
- uint32_t getHeight();
+ uint32_t get_width();
+ uint32_t get_height();
- void putPixel(int32_t x, int32_t y, Colour colour);
+ void put_pixel(int32_t x, int32_t y, Colour colour);
void putPixel(int32_t x, int32_t y, int32_t colour);
- Colour getPixel(int32_t x, int32_t y);
- void invertPixel(int32_t x, int32_t y);
+ Colour get_pixel(int32_t x, int32_t y);
+ void invert_pixel(int32_t x, int32_t y);
- void drawLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1, Colour colour);
+ void draw_line(int32_t x0, int32_t y0, int32_t x1, int32_t y1, Colour colour);
void drawLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t colour);
- void drawRectangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, Colour colour);
- void drawRectangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t colour);
+ void draw_rectangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, Colour colour);
+ void draw_rectangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t colour);
- void fillRectangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, Colour colour);
- void fillRectangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t colour);
+ void fill_rectangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, Colour colour);
+ void fill_rectangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t colour);
- void drawCircle(int32_t x0, int32_t y0, int32_t radius, Colour colour);
- void drawCircle(int32_t x0, int32_t y0, int32_t radius, uint32_t colour);
+ void draw_circle(int32_t x0, int32_t y0, int32_t radius, Colour colour);
+ void draw_circle(int32_t x0, int32_t y0, int32_t radius, uint32_t colour);
- void fillCircle(int32_t x0, int32_t y0, int32_t radius, Colour colour);
+ void fill_circle(int32_t x0, int32_t y0, int32_t radius, Colour colour);
void fillCircle(int32_t x0, int32_t y0, int32_t radius, uint32_t colour);
};
diff --git a/kernel/include/common/inputStream.h b/kernel/include/common/inputStream.h
index e109ba6b..7b28a9f3 100644
--- a/kernel/include/common/inputStream.h
+++ b/kernel/include/common/inputStream.h
@@ -16,72 +16,102 @@ namespace maxOS{
// Forward declaration
template class GenericInputStream;
+ /**
+ * @class InputStreamEventHandler
+ * @brief Handles read and end of stream events from a set of streams
+ *
+ * @tparam Type The type of data the stream is handling
+ */
template class InputStreamEventHandler
{
friend class GenericInputStream;
protected:
- common::Vector*> genericInputStreams;
+ common::Vector*>
+ m_generic_input_streams;
public:
InputStreamEventHandler();
~InputStreamEventHandler();
- virtual void onStreamRead(Type readElement);
- virtual void onEndOfStream(GenericInputStream* stream);
+ virtual void on_stream_read(Type);
+ virtual void on_end_of_stream(GenericInputStream*);
};
+ /**
+ * @class InputStreamProcessor
+ * @brief Converts one stream data type into another
+ *
+ * @tparam Type
+ * @tparam ProcessorType
+ */
template class InputStreamProcessor : public InputStreamEventHandler, public GenericInputStream
{
public:
InputStreamProcessor();
- InputStreamProcessor(InputStreamEventHandler* genericStreamEventHandler);
+ InputStreamProcessor(InputStreamEventHandler* generic_stream_event_handler);
~InputStreamProcessor();
- void onEndOfStream(GenericInputStream* stream);
+ virtual void on_end_of_stream(GenericInputStream* stream) override;
};
+ /**
+ * @class InputStreamSocket
+ * @brief Passes read events on to the handlers
+ *
+ * @tparam Type The type of data the stream is handling
+ */
template class InputStreamSocket : public InputStreamProcessor
{
public:
InputStreamSocket();
- InputStreamSocket(InputStreamEventHandler* processorHandler);
+ InputStreamSocket(InputStreamEventHandler*);
~InputStreamSocket();
- void onStreamRead(Type readElement);
+ virtual void on_stream_read(Type) override;
};
-
-
+ /**
+ * @class InputStreamBuffer
+ * @brief Buffers data from a stream and fires an event when a certain element is read
+ *
+ * @tparam Type The type of data the stream is handling
+ */
template class InputStreamBuffer : protected InputStreamProcessor
{
protected:
- Type buffer[10240]; // Buffer o
- int offset;
- Type eventFireElement;
- Type terminationElement;
+ Type m_buffer[10240]; //TODO: Probaby make this dynamic
+ int m_offset { 0 };
+ Type m_event_fire_element;
+ Type m_termination_element;
public:
- InputStreamBuffer(Type eventFireElement, Type terminationElement);
+ InputStreamBuffer(Type event_fire_element, Type termination_element);
~InputStreamBuffer();
- void onStreamRead(Type readElement);
- void onEndOfStream(GenericInputStream* stream);
+ virtual void on_stream_read(Type) override;
+ virtual void on_end_of_stream(GenericInputStream*) override;
void flush();
};
+ /**
+ * @class GenericInputStream
+ * @brief Manages the connection of a stream to handlers
+ *
+ * @tparam Type The type of data the stream is handling
+ */
template class GenericInputStream{
protected:
- common::Vector*> inputStreamEventHandlers;
+ common::Vector*> m_input_stream_event_handlers;
public:
GenericInputStream();
- GenericInputStream(InputStreamEventHandler* inputStreamEventHandler);
+ GenericInputStream(InputStreamEventHandler*);
~GenericInputStream();
- void connectInputStreamEventHandler(InputStreamEventHandler* inputStreamEventHandler);
- void disconnectInputStreamEventHandler(InputStreamEventHandler* inputStreamEventHandler);
+ void connect_input_stream_event_handler(InputStreamEventHandler*);
+ void disconnect_input_stream_event_handler(InputStreamEventHandler*);
};
@@ -91,17 +121,22 @@ namespace maxOS{
// The ">>" operator is used to read data from a stream, it takes a stream to read from and a processor to convert the data into another type
template GenericInputStream& operator>>(GenericInputStream& source, InputStreamProcessor& processor);
+ /**
+ * @class InputStream
+ * @brief A stream that handles strings
+ */
class InputStream : public GenericInputStream
{
public:
- InputStream(InputStreamEventHandler* inputStreamEventHandler);
+ InputStream(InputStreamEventHandler*);
};
///_______________________________________________TEMPLATES_________________________________________________________________///
/**
- * @details Creates a new InputStreamProcessor
+ * @breif Creates a new InputStreamProcessor
+ *
* @tparam Type the type of data the stream is handling
*/
template InputStreamEventHandler::InputStreamEventHandler() {
@@ -109,38 +144,44 @@ namespace maxOS{
}
/**
- * @details Destroys the InputStreamProcessor and disconnects it from all streams
+ * @breif Destroys the InputStreamProcessor and disconnects it from all streams
+ *
* @tparam Type the type of data the stream is handling
*/
template InputStreamEventHandler::~InputStreamEventHandler() {
- // Loop through all the streams and disconnect this handler from them
- while(!genericInputStreams.empty())
- (*genericInputStreams.begin())->disconnectInputStreamEventHandler(this);
+
+ // Disconnect the handler from all streams
+ while(!m_generic_input_streams.empty())
+ (*m_generic_input_streams.begin()) -> disconnect_input_stream_event_handler(this);
}
/**
- * @details Called when data is read from a stream (overridden by subclasses)
+ * @breif Called when data is read from a stream (overridden by subclasses)
+ *
* @tparam Type the type of data the stream is handling
- * @param readElement The element that was read from the stream
+ * @param read_element The element that was read from the stream
*/
- template void InputStreamEventHandler::onStreamRead(Type readElement) {
+ template void InputStreamEventHandler::on_stream_read(Type read_element) {
}
/**
- * @details Called when a stream has finished. Removes the stream from the array of streams
+ * @breif Called when a stream has finished. Removes the stream from the array of streams
+ *
* @tparam Type The type of data the stream is handling
* @param stream The stream that has finished
*/
- template void InputStreamEventHandler::onEndOfStream(GenericInputStream *stream) {
- // Remove the stream from the array of streams as it has finished
- genericInputStreams.erase(stream);
+ template void InputStreamEventHandler::on_end_of_stream(GenericInputStream *stream) {
+
+ // Remove the stream
+ m_generic_input_streams.erase(stream);
}
/**
- * @details Creates a new InputStreamProcessor
+ * @breif Creates a new InputStreamProcessor
+ *
* @tparam Type The type of data the stream is handling
* @tparam ProcessorType The type of data to convert the data into via the processor
*/
@@ -152,20 +193,22 @@ namespace maxOS{
}
/**
- * @details Creates a new InputStreamProcessor
+ * @breif Creates a new InputStreamProcessor
+ *
* @tparam Type The type of data the stream is handling
* @tparam ProcessorType The type of data to convert the data into via the processor
- * @param genericStreamEventHandler The event handler to handle the data (passed to the GenericInputStream constructor)
+ * @param generic_stream_event_handler The event handler to handle the data
*/
- template InputStreamProcessor::InputStreamProcessor(InputStreamEventHandler *genericStreamEventHandler)
+ template InputStreamProcessor::InputStreamProcessor(InputStreamEventHandler *generic_stream_event_handler)
: InputStreamEventHandler(),
- GenericInputStream(genericStreamEventHandler)
+ GenericInputStream(generic_stream_event_handler)
{
}
/**
- * @details Destroys the InputStreamProcessor
+ * @breif Destroys the InputStreamProcessor
+ *
* @tparam Type The type of data the stream is handling
* @tparam ProcessorType The type of data to convert the data into via the processor
*/
@@ -174,24 +217,26 @@ namespace maxOS{
}
/**
- * @details Called when a stream has finished. Passes the event on to the internetProtocolHandlers and then removes the stream from the array of streams
+ * @breif Called when a stream has finished. Passes the event on to the handlers and then removes the stream from the array of streams
+ *
* @tparam Type The type of data the stream is handling
* @tparam ProcessorType The type of data to convert the data into via the processor
* @param stream The stream that has finished
*/
- template void InputStreamProcessor::onEndOfStream(GenericInputStream* stream) {
+ template void InputStreamProcessor::on_end_of_stream(GenericInputStream* stream) {
- // Loop through and run the end of stream event on the handlers
- for(typename Vector*>::iterator inputStreamEventHandler = this -> inputStreamEventHandlers.begin(); inputStreamEventHandler != this -> inputStreamEventHandlers.end(); inputStreamEventHandler++)
- (*inputStreamEventHandler) -> onEndOfStream(this);
+ // Pass the end of stream event on to the handlers
+ for(auto& event_handler : this -> m_input_stream_event_handlers)
+ event_handler -> on_end_of_stream(this);
- // Run the default end of stream event, this removes the stream from the array of streams
- InputStreamEventHandler::onEndOfStream(stream);
+ // Remove the stream
+ InputStreamEventHandler::on_end_of_stream(stream);
}
/**
- * @details Creates a new InputStreamSocket
+ * @breif Creates a new InputStreamSocket
+ *
* @tparam Type The type of data the stream is handling
*/
template InputStreamSocket::InputStreamSocket() {
@@ -199,18 +244,20 @@ namespace maxOS{
}
/**
- * @details Creates a new InputStreamSocket and connects it to the handler
+ * @breif Creates a new InputStreamSocket and connects it to the handler
+ *
* @tparam Type The type of data the stream is handling (and the sockets processor type)
- * @param processorHandler The handler to pass to InputStreamProcessor
+ * @param processor_handler The handler to pass to InputStreamProcessor
*/
- template InputStreamSocket::InputStreamSocket(InputStreamEventHandler *processorHandler)
- : InputStreamProcessor(processorHandler)
+ template InputStreamSocket::InputStreamSocket(InputStreamEventHandler *processor_handler)
+ : InputStreamProcessor(processor_handler)
{
}
/**
- * @details Destroys the InputStreamSocket
+ * @breif Destroys the InputStreamSocket
+ *
* @tparam Type The type of data the stream is handling
*/
template InputStreamSocket::~InputStreamSocket() {
@@ -218,35 +265,36 @@ namespace maxOS{
}
/**
- * @details Called when data is read from a stream. Passes the event on to the internetProtocolHandlers
+ * @breif Called when data is read from a stream. Passes the event on to the internetProtocolHandlers
+ *
* @tparam Type The type of data the stream is handling
- * @param readElement The element that was read from the stream
+ * @param read_element The element that was read from the stream
*/
- template void InputStreamSocket::onStreamRead(Type readElement) {
+ template void InputStreamSocket::on_stream_read(Type read_element) {
// Pass the read event on to the handlers
- for(typename Vector*>::iterator inputStreamEventHandler = this -> inputStreamEventHandlers.begin(); inputStreamEventHandler != this -> inputStreamEventHandlers.end(); inputStreamEventHandler++)
- (*inputStreamEventHandler)->onStreamRead(readElement);
+ for(auto& event_handler : this -> m_input_stream_event_handlers)
+ event_handler -> on_stream_read(read_element);
}
/**
- * @details Creates a new InputStreamBuffer
+ * @breif Creates a new InputStreamBuffer
+ *
* @tparam Type The type of data the stream is handling
- * @param eventFireElement The element to fire the event on
- * @param terminationElement The element that signifies the end of the part of the stream to be buffered (e.g a newline)
+ * @param event_fire_element The element to fire the event on
+ * @param termination_element The element that signifies the end of the part of the stream to be buffered (e.g a newline)
*/
- template InputStreamBuffer::InputStreamBuffer(Type eventFireElement, Type terminationElement) {
- // Nothing has been read so the buffer offset is at the start
- offset = 0;
+ template InputStreamBuffer::InputStreamBuffer(Type event_fire_element, Type termination_element)
+ : m_event_fire_element(event_fire_element),
+ m_termination_element(termination_element)
+ {
- // Set the event fire and termination elements
- this -> eventFireElement = eventFireElement;
- this -> terminationElement = terminationElement;
}
/**
- * @details Destroys the InputStreamBuffer
+ * @breif Destroys the InputStreamBuffer
+ *
* @tparam Type The type of data the stream is handling
*/
template InputStreamBuffer::~InputStreamBuffer() {
@@ -254,68 +302,70 @@ namespace maxOS{
}
/**
- * @details Called when data is read from a stream. Adds the data to the buffer and checks if the event should be fired
+ * @breif Called when data is read from a stream. Adds the data to the buffer and checks if the event should be fired
+ *
* @tparam Type
- * @param readElement
+ * @param read_element
*/
- template void InputStreamBuffer::onStreamRead(Type readElement) {
+ template void InputStreamBuffer::on_stream_read(Type read_element) {
- // If this element should fire an event
- if(readElement == eventFireElement){
- // Fire the event by flushing the buffer
+ // flush the buffer if the event fire element is read
+ if(read_element == m_event_fire_element){
flush();
return;
}
- // If the offset is past the length of the buffer then flush the buffer
- if(offset >= 10238){
+ // Ensure the buffer is not full
+ if(m_offset >= 10238){
flush();
}
- // Add the element to the buffer
- buffer[offset++] = readElement;
+ // Add the element
+ m_buffer[m_offset++] = read_element;
}
/**
- * @details Called when a stream has finished. Flushes the buffer if there is any data in it
+ * @breif Called when a stream has finished. Flushes the buffer if there is any data in it
+ *
* @tparam Type The type of data the stream is handling
* @param stream The stream that has finished
*/
- template void InputStreamBuffer::onEndOfStream(GenericInputStream *stream) {
+ template void InputStreamBuffer::on_end_of_stream(GenericInputStream *stream) {
- // If data had been read before the stream ends then flush the buffer
- if(offset > 0)
+ // flush the buffer if there is any data in it
+ if(m_offset > 0)
flush();
- // Run the default end of stream event
- InputStreamProcessor::onEndOfStream(stream);
-
+ // Pass the event on to the handlers and remove the stream
+ InputStreamProcessor::on_end_of_stream(stream);
}
/**
- * @details Flushes the buffer by adding the termination element and firing an on read event (NOTE: The buffer is not cleared after this just overwritten)
+ * @breif Flushes the buffer by adding the termination element and firing an on read event (NOTE: The buffer is not cleared after this just overwritten)
+ *
* @tparam Type The type of data the stream is handling
*/
template void InputStreamBuffer::flush() {
- // If there is no data in the buffer then return
- if(offset == 0)
+ // Ensure the buffer is not empty
+ if(m_offset == 0)
return;
// Add the termination element to the buffer
- buffer[offset] = terminationElement;
+ m_buffer[m_offset] = m_termination_element;
// Fire the on read event
- InputStreamProcessor::onStreamRead(buffer);
+ InputStreamProcessor::on_stream_read(m_buffer);
// Reset the offset
- offset = 0;
+ m_offset = 0;
}
/**
- * @details Creates a new GenericInputStream
+ * @breif Creates a new GenericInputStream
+ *
* @tparam Type The type of data the stream is handling
*/
template GenericInputStream::GenericInputStream() {
@@ -323,67 +373,65 @@ namespace maxOS{
}
/**
- * @details Creates a new GenericInputStream and connects it to the inputStreamEventHandler
+ * @breif Creates a new GenericInputStream and connects it to the handler
+ *
* @tparam Type The type of data the stream is handling
- * @param inputStreamEventHandler The inputStreamEventHandler to handle the data
+ * @param input_stream_event_handler The handler to handle the data
*/
- template GenericInputStream::GenericInputStream(InputStreamEventHandler *inputStreamEventHandler) {
-
- // Connect the inputStreamEventHandler
- connectInputStreamEventHandler(inputStreamEventHandler);
+ template GenericInputStream::GenericInputStream(InputStreamEventHandler *input_stream_event_handler) {
+ // Connect the handler
+ connect_input_stream_event_handler(input_stream_event_handler);
}
/**
- * @details Destroys the GenericInputStream and disconnects all internetProtocolHandlers
+ * @breif Destroys the GenericInputStream and disconnects all handlers
+ *
* @tparam Type The type of data the stream is handling
*/
template GenericInputStream::~GenericInputStream() {
// Disconnect all handlers
- while (!inputStreamEventHandlers.empty())
- disconnectInputStreamEventHandler(*(inputStreamEventHandlers.begin()));
+ while (!m_input_stream_event_handlers.empty())
+ disconnect_input_stream_event_handler(*(m_input_stream_event_handlers.begin()));
}
/**
- * @details Adds a inputStreamEventHandler to the list of internetProtocolHandlers
+ * @breif Adds a inputStreamEventHandler to the list of internetProtocolHandlers
* @tparam Type The type of data the stream is handling
- * @param inputStreamEventHandler The inputStreamEventHandler to add
+ * @param input_stream_event_handler The inputStreamEventHandler to add
*/
- template void GenericInputStream::connectInputStreamEventHandler(InputStreamEventHandler *inputStreamEventHandler) {
+ template void GenericInputStream::connect_input_stream_event_handler(InputStreamEventHandler *input_stream_event_handler) {
- // Check if the inputStreamEventHandler is already connected
- if(inputStreamEventHandlers.find(inputStreamEventHandler) != inputStreamEventHandlers.end())
+ // Don't add the handler if it is already connected
+ if(m_input_stream_event_handlers.find(input_stream_event_handler) != m_input_stream_event_handlers.end())
return;
- // Add the inputStreamEventHandler to the list of handlers
- inputStreamEventHandlers.pushBack(inputStreamEventHandler);
+ // Add the handler
+ m_input_stream_event_handlers.push_back(input_stream_event_handler);
}
/**
- * @details Removes a inputStreamEventHandler from the list of internetProtocolHandlers
+ * @breif Removes a handler from the list of handlers
+ *
* @tparam Type The type of data the stream is handling
- * @param inputStreamEventHandler The inputStreamEventHandler to remove
+ * @param input_stream_event_handler The handler to remove
*/
- template void GenericInputStream::disconnectInputStreamEventHandler(InputStreamEventHandler *inputStreamEventHandler) {
+ template void GenericInputStream::disconnect_input_stream_event_handler(InputStreamEventHandler *input_stream_event_handler) {
- // Check if the inputStreamEventHandler is connected
- if(inputStreamEventHandlers.find(inputStreamEventHandler) == inputStreamEventHandlers.end())
+ // Don't remove the handler if it is not connected
+ if(m_input_stream_event_handlers.find(input_stream_event_handler) == m_input_stream_event_handlers.end())
return;
- // Remove the inputStreamEventHandler from the list of handlers
- inputStreamEventHandlers.erase(inputStreamEventHandler);
+ // Remove the handler
+ m_input_stream_event_handlers.erase(input_stream_event_handler);
// Fire the end of stream event
- inputStreamEventHandler -> onEndOfStream(this);
+ input_stream_event_handler->on_end_of_stream(this);
}
-
-
-
}
-
}
#endif //MAXOS_INPUTSTREAM_H
diff --git a/kernel/include/common/map.h b/kernel/include/common/map.h
index 2a7050c2..f2633937 100644
--- a/kernel/include/common/map.h
+++ b/kernel/include/common/map.h
@@ -12,19 +12,34 @@ namespace maxOS{
namespace common{
+ /**
+ * @class MapIterationHandler
+ * @brief Handles iteration of a map
+ *
+ * @tparam Key The key type
+ * @tparam Value The value type
+ */
template class MapIterationHandler
{
public:
MapIterationHandler();
~MapIterationHandler();
- virtual void onRead(Key, Value);
- virtual void onEndOfStream();
+
+ virtual void on_read(Key, Value);
+ virtual void on_end_of_stream();
};
+ /**
+ * @class Map
+ * @brief A list of key-value pairs
+ *
+ * @tparam Key The key type
+ * @tparam Value The value type
+ */
template class Map
{
protected:
- Vector > elements;
+ Vector> m_elements;
public:
typedef typename Vector >::iterator iterator;
@@ -32,15 +47,15 @@ namespace maxOS{
Map();
~Map();
- Value& operator[](Key key);
+ Value& operator[](Key);
iterator begin();
iterator end();
- iterator find(Key element);
+ iterator find(Key);
bool empty();
void clear();
- void insert(Key key, Value value);
- void erase(Key key);
+ void insert(Key, Value);
+ void erase(Key);
void iterate(MapIterationHandler* handler);
void iterate(void callback(Key&, Value&));
@@ -48,23 +63,34 @@ namespace maxOS{
};
/// ______________ TEMPLATE IMPLEMENTATION ______________
- template void MapIterationHandler::onEndOfStream() {
+ template MapIterationHandler::MapIterationHandler() {
}
- template void MapIterationHandler::onRead(Key, Value) {
+ template MapIterationHandler::~MapIterationHandler() {
}
- template MapIterationHandler::~MapIterationHandler() {
+ /**
+ * @brief Called when the end of the stream is reached
+ *
+ * @tparam Key The key type
+ * @tparam Value The value type
+ */
+ template void MapIterationHandler::on_end_of_stream() {
}
- template MapIterationHandler::MapIterationHandler() {
+ /**
+ * @brief Called when a key-value pair is read
+ *
+ * @tparam Key The key type
+ * @tparam Value The value type
+ */
+ template void MapIterationHandler::on_read(Key, Value) {
}
-
template Map::Map() {
}
@@ -73,20 +99,50 @@ namespace maxOS{
}
+ /**
+ * @brief Overloads the [] operator to return the value of the key
+ *
+ * @tparam Key The key type
+ * @tparam Value The value type
+ * @param key The key to search for
+ * @return The value of the key
+ */
template Value &Map::operator[](Key key) {
// Return the value of the key (second item in the pair)
return find(key) -> second;
}
+ /**
+ * @brief Returns the beginning of the map
+ *
+ * @tparam Key The key type
+ * @tparam Value The value type
+ * @return The m_first_memory_chunk element in the map
+ */
template typename Map::iterator Map::begin() {
- return elements.begin();
+ return m_elements.begin();
}
+ /**
+ * @brief Returns the end of the map
+ *
+ * @tparam Key The key type
+ * @tparam Value The value type
+ * @return The last element in the map
+ */
template typename Map::iterator Map::end() {
- return elements.end();
+ return m_elements.end();
}
+ /**
+ * @brief Finds an element in the map based on the key
+ *
+ * @tparam Key The key type
+ * @tparam Value The value type
+ * @param element The key to search for
+ * @return The iterator of the element, or the end iterator if not found
+ */
template typename Map::iterator Map::find(Key element) {
// Loop through the elements
@@ -104,62 +160,101 @@ namespace maxOS{
}
+ /**
+ * @brief Returns whether the map is empty
+ *
+ * @tparam Key The key type
+ * @tparam Value The value type
+ * @return Whether the map is empty
+ */
template bool Map::empty() {
- return elements.empty();
+ return m_elements.empty();
}
+ /**
+ * @brief Removes all elements from the map
+ *
+ * @tparam Key The key type
+ * @tparam Value The value type
+ */
template void Map::clear() {
- elements.clear();
+ m_elements.clear();
}
+ /**
+ * @brief Updates the value of an element, or adds a new element if it does not exist
+ *
+ * @tparam Key The key type
+ * @tparam Value The value type
+ * @param key The key of the new element
+ * @param value The value of the new element
+ */
template void Map::insert(Key key, Value value) {
// Find the element
iterator it = find(key);
- // If the element is found
+ // If the element is found then update the value
if (it != end()) {
- // Set the value of the element to the new value
it -> second = value;
} else {
// Otherwise, add a new element
- elements.pushBack(Pair(key, value));
+ m_elements.push_back(Pair(key, value));
}
}
+ /**
+ * @brief Removes an element from the map
+ *
+ * @tparam Key The key type
+ * @tparam Value The value type
+ * @param key The key of the element to remove
+ */
template void Map::erase(Key key) {
// Find the element
iterator it = find(key);
- // If the element is found
+ // If the element is found then remove it
if (it != end()) {
- // Erase the element
- elements.erase(it);
+ m_elements.erase(it);
}
}
+ /**
+ * @brief Iterates through the map and calls the handler
+ *
+ * @tparam Key The key type
+ * @tparam Value The value type
+ * @param handler The handler to call
+ */
template void Map::iterate(MapIterationHandler *handler) {
// Loop through the elements
- for (iterator it = begin(); it != end(); it++) {
+ for(auto& it : m_elements) {
+
// Call the handler
- handler -> onRead(it -> first, it -> second);
+ handler->on_read(it.first, it.second);
}
// Call the handler
- handler -> onEndOfStream();
+ handler->on_end_of_stream();
}
+ /**
+ * @brief Iterates through the map and calls the callback
+ *
+ * @tparam Key The key type
+ * @tparam Value The value type
+ * @param callback The callback to call
+ */
template void Map::iterate(void (*callback)(Key &, Value &)) {
- // Loop through the elements
- for (iterator it = begin(); it != end(); it++) {
-
- // Call the callback
- callback(it -> first, it -> second);
+ // Call the callback for each element
+ for(auto& it : m_elements) {
+ callback(it.first, it.second);
}
}
}
diff --git a/kernel/include/common/outputStream.h b/kernel/include/common/outputStream.h
index 32a704cd..cd71e164 100644
--- a/kernel/include/common/outputStream.h
+++ b/kernel/include/common/outputStream.h
@@ -13,21 +13,31 @@ namespace maxOS{
namespace common{
+ /**
+ * @class OutputStream
+ * @brief A stream that can be written to.
+ *
+ * @tparam Type The type of the elements that will be written to the stream.
+ */
template class GenericOutputStream : public InputStreamProcessor
{
public:
GenericOutputStream();
~GenericOutputStream();
- void onStreamRead(Type readElement);
- void onEndOfStream(GenericInputStream* stream);
+ void on_stream_read(Type) override;
+ void on_end_of_stream(GenericInputStream*) override;
- virtual void write(Type writeElement);
+ virtual void write(Type);
virtual void close();
- virtual GenericOutputStream& operator << (Type writeElement);
+ virtual GenericOutputStream& operator << (Type);
};
+ /**
+ * @class OutputStream
+ * @brief A stream that strings can be written to.
+ */
class OutputStream : public GenericOutputStream
{
@@ -39,15 +49,15 @@ namespace maxOS{
virtual void carriageReturn();
virtual void clear();
- virtual void write(string stringToWrite);
- virtual void writeChar(char charToWrite);
- virtual void writeInt(int intToWrite);
- virtual void writeHex(uint32_t hexToWrite);
+ virtual void write(string string_to_write) override;
+ virtual void write_char(char char_to_write);
+ virtual void write_int(int int_to_write);
+ virtual void write_hex(uint32_t hex_to_write);
- OutputStream& operator << (int intToWrite);
- OutputStream& operator << (uint32_t hexToWrite);
- OutputStream& operator << (string stringToWrite);
- OutputStream& operator << (char charToWrite);
+ OutputStream& operator << (string string_to_write) override;
+ OutputStream& operator << (int int_to_write);
+ OutputStream& operator << (uint32_t hex_to_write);
+ OutputStream& operator << (char char_to_write);
};
@@ -55,7 +65,8 @@ namespace maxOS{
///__________________________________________Templates__________________________________________________///
/**
- * @details Constructor of the GenericOutputStream class.
+ * @brief Constructor of the GenericOutputStream class.
+ *
* @tparam Type The type of the elements that will be written to the stream.
*/
template GenericOutputStream::GenericOutputStream() {
@@ -63,7 +74,8 @@ namespace maxOS{
}
/**
- * @details Destructor of the GenericOutputStream class.
+ * @brief Destructor of the GenericOutputStream class.
+ *
* @tparam Type The type of the elements that will be written to the stream.
*/
template GenericOutputStream::~GenericOutputStream() {
@@ -71,52 +83,56 @@ namespace maxOS{
}
/**
- * @details This function is called when an element is read from the stream.
+ * @brief Writes the date that was read from the input stream to the output stream.
+ *
* @tparam Type The type of the elements that will be written to the stream.
- * @param readElement The element that was read from the stream.
+ * @param read_element The element that was read from the stream.
*/
- template void GenericOutputStream::onStreamRead(Type readElement) {
+ template void GenericOutputStream::on_stream_read(Type read_element) {
// When something is read from the input stream, it is written to the output stream.
- write(readElement);
+ write(read_element);
- // Pass the element to any handlers.
- for(typename Vector*>::iterator inputStreamEventHandler = this -> inputStreamEventHandlers.begin(); inputStreamEventHandler != this -> inputStreamEventHandlers.end(); ++inputStreamEventHandler)
- (*inputStreamEventHandler)->onStreamRead(readElement);
+ // Pass the element to any handlers
+ for(auto& input_stream_event_handler : this ->m_input_stream_event_handlers)
+ input_stream_event_handler->on_stream_read(read_element);
}
/**
- * @details This function is called when the end of the stream is reached.
+ * @brief Close the stream and remove it from the list of streams when the end of the stream is reached.
+ *
* @tparam Type The type of the elements that will be written to the stream.
* @param stream The stream that reached the end.
*/
- template void GenericOutputStream::onEndOfStream(GenericInputStream *stream) {
+ template void GenericOutputStream::on_end_of_stream(GenericInputStream *stream) {
// Close the stream.
close();
- // Pass the event to any handlers.
- for(typename Vector*>::iterator inputStreamEventHandler = this -> inputStreamEventHandlers.begin(); inputStreamEventHandler != this -> inputStreamEventHandlers.end(); ++inputStreamEventHandler)
- (*inputStreamEventHandler) -> onEndOfStream(stream);
+ // Pass the event to any handlers
+ for(auto& input_stream_event_handler : this ->m_input_stream_event_handlers)
+ input_stream_event_handler->on_end_of_stream(stream);
- // Handle the event on this class
- InputStreamProcessor::onEndOfStream(stream);
+ // Remove the stream from the list of streams.
+ InputStreamProcessor::on_end_of_stream(stream);
}
/**
- * @details This function writes an element to the stream.
+ * @brief write an element to the stream.
+ *
* @tparam Type The type of the elements that will be written to the stream.
- * @param writeElement The element that will be written to the stream.
+ * @param write_element The element that will be written to the stream.
*/
- template void GenericOutputStream