diff options
author | zedarider <ymherklotz@gmail.com> | 2016-11-27 15:15:53 +0000 |
---|---|---|
committer | zedarider <ymherklotz@gmail.com> | 2016-11-27 15:15:53 +0000 |
commit | 4a41d23bc68c4fa55a76ea2b23ff9499d7f8e860 (patch) | |
tree | 85e454bae5584f5e69c3fefbb9baf182bcb25c9a | |
parent | dd5af3d6748be7826e1f312a5ed73bc1c7092912 (diff) | |
download | second-year-computing-4a41d23bc68c4fa55a76ea2b23ff9499d7f8e860.tar.gz second-year-computing-4a41d23bc68c4fa55a76ea2b23ff9499d7f8e860.zip |
finished assessment
m--------- | Lab Assessment | 0 | ||||
-rw-r--r-- | lab 1/Makefile (renamed from labs/Makefile) | 0 | ||||
-rwxr-xr-x | lab 1/bin/points (renamed from labs/bin/points) | bin | 204616 -> 204616 bytes | |||
-rw-r--r-- | lab 1/build/counter.o (renamed from labs/build/counter.o) | bin | 21640 -> 21640 bytes | |||
-rw-r--r-- | lab 1/build/intvector.o (renamed from labs/build/intvector.o) | bin | 10216 -> 10216 bytes | |||
-rw-r--r-- | lab 1/build/main.o (renamed from labs/build/main.o) | bin | 85240 -> 85240 bytes | |||
-rw-r--r-- | lab 1/build/modulo_counter.o (renamed from labs/build/modulo_counter.o) | bin | 20160 -> 20160 bytes | |||
-rw-r--r-- | lab 1/build/point.o (renamed from labs/build/point.o) | bin | 47616 -> 47616 bytes | |||
-rw-r--r-- | lab 1/build/rcl_circuit.o (renamed from labs/build/rcl_circuit.o) | bin | 38392 -> 38392 bytes | |||
-rw-r--r-- | lab 1/build/stopwatch.o (renamed from labs/build/stopwatch.o) | bin | 22944 -> 22944 bytes | |||
-rw-r--r-- | lab 1/build/triangle.o (renamed from labs/build/triangle.o) | bin | 44392 -> 44392 bytes | |||
-rw-r--r-- | lab 1/include/counter.hpp (renamed from labs/include/counter.hpp) | 0 | ||||
-rw-r--r-- | lab 1/include/intvector.hpp (renamed from labs/include/intvector.hpp) | 0 | ||||
-rw-r--r-- | lab 1/include/modulo_counter.hpp (renamed from labs/include/modulo_counter.hpp) | 0 | ||||
-rw-r--r-- | lab 1/include/people.hpp (renamed from labs/include/people.hpp) | 0 | ||||
-rw-r--r-- | lab 1/include/point.hpp (renamed from labs/include/point.hpp) | 0 | ||||
-rw-r--r-- | lab 1/include/rcl_circuit.hpp (renamed from labs/include/rcl_circuit.hpp) | 0 | ||||
-rw-r--r-- | lab 1/include/stopwatch.hpp (renamed from labs/include/stopwatch.hpp) | 0 | ||||
-rw-r--r-- | lab 1/include/triangle.hpp (renamed from labs/include/triangle.hpp) | 0 | ||||
-rw-r--r-- | lab 1/src/counter.cpp (renamed from labs/src/counter.cpp) | 0 | ||||
-rw-r--r-- | lab 1/src/intvector.cpp (renamed from labs/src/intvector.cpp) | 0 | ||||
-rw-r--r-- | lab 1/src/main.cpp (renamed from labs/src/main.cpp) | 0 | ||||
-rw-r--r-- | lab 1/src/main_intvector.cpp.bck (renamed from labs/src/main_intvector.cpp.bck) | 0 | ||||
-rw-r--r-- | lab 1/src/main_stopwatch.cpp.bck (renamed from labs/src/main_stopwatch.cpp.bck) | 0 | ||||
-rw-r--r-- | lab 1/src/main_triangles.cpp.bck (renamed from labs/src/main_triangles.cpp.bck) | 0 | ||||
-rw-r--r-- | lab 1/src/modulo_counter.cpp (renamed from labs/src/modulo_counter.cpp) | 0 | ||||
-rw-r--r-- | lab 1/src/point.cpp (renamed from labs/src/point.cpp) | 0 | ||||
-rw-r--r-- | lab 1/src/rcl_circuit.cpp (renamed from labs/src/rcl_circuit.cpp) | 0 | ||||
-rw-r--r-- | lab 1/src/stopwatch.cpp (renamed from labs/src/stopwatch.cpp) | 0 | ||||
-rw-r--r-- | lab 1/src/triangle.cpp (renamed from labs/src/triangle.cpp) | 0 | ||||
-rw-r--r-- | lab 2/.atom-build.json | 3 | ||||
-rw-r--r-- | lab 2/.clang_complete | 1 | ||||
-rw-r--r-- | lab 2/Makefile | 34 | ||||
-rwxr-xr-x | lab 2/bin/main | bin | 0 -> 50728 bytes | |||
-rw-r--r-- | lab 2/build/db_access.o | bin | 0 -> 1544 bytes | |||
-rw-r--r-- | lab 2/build/lockdb.o | bin | 0 -> 155532 bytes | |||
-rw-r--r-- | lab 2/build/main.o | bin | 0 -> 86428 bytes | |||
-rw-r--r-- | lab 2/include/lockdb.hpp | 13 | ||||
-rw-r--r-- | lab 2/src/db_access.cpp | 46 | ||||
-rw-r--r-- | lab 2/src/lockdb.cpp | 36 | ||||
-rw-r--r-- | lab 2/src/main.cpp | 37 |
41 files changed, 170 insertions, 0 deletions
diff --git a/Lab Assessment b/Lab Assessment new file mode 160000 +Subproject 5973d6a630ccf93e580ed01bd347c2ffa3fb7b3 diff --git a/labs/Makefile b/lab 1/Makefile index b82064e..b82064e 100644 --- a/labs/Makefile +++ b/lab 1/Makefile diff --git a/labs/bin/points b/lab 1/bin/points Binary files differindex 066ab5a..066ab5a 100755 --- a/labs/bin/points +++ b/lab 1/bin/points diff --git a/labs/build/counter.o b/lab 1/build/counter.o Binary files differindex 814cfb5..814cfb5 100644 --- a/labs/build/counter.o +++ b/lab 1/build/counter.o diff --git a/labs/build/intvector.o b/lab 1/build/intvector.o Binary files differindex 443a714..443a714 100644 --- a/labs/build/intvector.o +++ b/lab 1/build/intvector.o diff --git a/labs/build/main.o b/lab 1/build/main.o Binary files differindex 963448d..963448d 100644 --- a/labs/build/main.o +++ b/lab 1/build/main.o diff --git a/labs/build/modulo_counter.o b/lab 1/build/modulo_counter.o Binary files differindex d9ea828..d9ea828 100644 --- a/labs/build/modulo_counter.o +++ b/lab 1/build/modulo_counter.o diff --git a/labs/build/point.o b/lab 1/build/point.o Binary files differindex 808d1e4..808d1e4 100644 --- a/labs/build/point.o +++ b/lab 1/build/point.o diff --git a/labs/build/rcl_circuit.o b/lab 1/build/rcl_circuit.o Binary files differindex ad391de..ad391de 100644 --- a/labs/build/rcl_circuit.o +++ b/lab 1/build/rcl_circuit.o diff --git a/labs/build/stopwatch.o b/lab 1/build/stopwatch.o Binary files differindex c4ccb63..c4ccb63 100644 --- a/labs/build/stopwatch.o +++ b/lab 1/build/stopwatch.o diff --git a/labs/build/triangle.o b/lab 1/build/triangle.o Binary files differindex 1680109..1680109 100644 --- a/labs/build/triangle.o +++ b/lab 1/build/triangle.o diff --git a/labs/include/counter.hpp b/lab 1/include/counter.hpp index f072183..f072183 100644 --- a/labs/include/counter.hpp +++ b/lab 1/include/counter.hpp diff --git a/labs/include/intvector.hpp b/lab 1/include/intvector.hpp index f5f0912..f5f0912 100644 --- a/labs/include/intvector.hpp +++ b/lab 1/include/intvector.hpp diff --git a/labs/include/modulo_counter.hpp b/lab 1/include/modulo_counter.hpp index 5c04ab0..5c04ab0 100644 --- a/labs/include/modulo_counter.hpp +++ b/lab 1/include/modulo_counter.hpp diff --git a/labs/include/people.hpp b/lab 1/include/people.hpp index c4f8b64..c4f8b64 100644 --- a/labs/include/people.hpp +++ b/lab 1/include/people.hpp diff --git a/labs/include/point.hpp b/lab 1/include/point.hpp index 40aa56f..40aa56f 100644 --- a/labs/include/point.hpp +++ b/lab 1/include/point.hpp diff --git a/labs/include/rcl_circuit.hpp b/lab 1/include/rcl_circuit.hpp index 41e1e6d..41e1e6d 100644 --- a/labs/include/rcl_circuit.hpp +++ b/lab 1/include/rcl_circuit.hpp diff --git a/labs/include/stopwatch.hpp b/lab 1/include/stopwatch.hpp index 208aebd..208aebd 100644 --- a/labs/include/stopwatch.hpp +++ b/lab 1/include/stopwatch.hpp diff --git a/labs/include/triangle.hpp b/lab 1/include/triangle.hpp index 9c13fb9..9c13fb9 100644 --- a/labs/include/triangle.hpp +++ b/lab 1/include/triangle.hpp diff --git a/labs/src/counter.cpp b/lab 1/src/counter.cpp index 2af38a8..2af38a8 100644 --- a/labs/src/counter.cpp +++ b/lab 1/src/counter.cpp diff --git a/labs/src/intvector.cpp b/lab 1/src/intvector.cpp index fae9ff0..fae9ff0 100644 --- a/labs/src/intvector.cpp +++ b/lab 1/src/intvector.cpp diff --git a/labs/src/main.cpp b/lab 1/src/main.cpp index 399a22c..399a22c 100644 --- a/labs/src/main.cpp +++ b/lab 1/src/main.cpp diff --git a/labs/src/main_intvector.cpp.bck b/lab 1/src/main_intvector.cpp.bck index c3043e5..c3043e5 100644 --- a/labs/src/main_intvector.cpp.bck +++ b/lab 1/src/main_intvector.cpp.bck diff --git a/labs/src/main_stopwatch.cpp.bck b/lab 1/src/main_stopwatch.cpp.bck index 9239cc0..9239cc0 100644 --- a/labs/src/main_stopwatch.cpp.bck +++ b/lab 1/src/main_stopwatch.cpp.bck diff --git a/labs/src/main_triangles.cpp.bck b/lab 1/src/main_triangles.cpp.bck index 217b95e..217b95e 100644 --- a/labs/src/main_triangles.cpp.bck +++ b/lab 1/src/main_triangles.cpp.bck diff --git a/labs/src/modulo_counter.cpp b/lab 1/src/modulo_counter.cpp index 3173139..3173139 100644 --- a/labs/src/modulo_counter.cpp +++ b/lab 1/src/modulo_counter.cpp diff --git a/labs/src/point.cpp b/lab 1/src/point.cpp index 2f63c24..2f63c24 100644 --- a/labs/src/point.cpp +++ b/lab 1/src/point.cpp diff --git a/labs/src/rcl_circuit.cpp b/lab 1/src/rcl_circuit.cpp index 8ec3fb2..8ec3fb2 100644 --- a/labs/src/rcl_circuit.cpp +++ b/lab 1/src/rcl_circuit.cpp diff --git a/labs/src/stopwatch.cpp b/lab 1/src/stopwatch.cpp index 602bafb..602bafb 100644 --- a/labs/src/stopwatch.cpp +++ b/lab 1/src/stopwatch.cpp diff --git a/labs/src/triangle.cpp b/lab 1/src/triangle.cpp index 8c715b3..8c715b3 100644 --- a/labs/src/triangle.cpp +++ b/lab 1/src/triangle.cpp diff --git a/lab 2/.atom-build.json b/lab 2/.atom-build.json new file mode 100644 index 0000000..33d28f5 --- /dev/null +++ b/lab 2/.atom-build.json @@ -0,0 +1,3 @@ +{ + "cmd": "make" +} diff --git a/lab 2/.clang_complete b/lab 2/.clang_complete new file mode 100644 index 0000000..30679be --- /dev/null +++ b/lab 2/.clang_complete @@ -0,0 +1 @@ +-Iinclude diff --git a/lab 2/Makefile b/lab 2/Makefile new file mode 100644 index 0000000..c13729d --- /dev/null +++ b/lab 2/Makefile @@ -0,0 +1,34 @@ +CC := g++ # this is the main compiler +# CC := clange --analyze # and comment out the linker last line +SRCDIR := src +BUILDDIR := build +TARGET := bin/main + +SRCEXT := cpp +SOURCES := $(shell find $(SRCDIR) -type f -name "*.$(SRCEXT)") +OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o)) +CFLAGS := -g -Wall -Wextra -Wpedantic -std=c++14 +LIB := +INC := -Iinclude + +$(TARGET): $(OBJECTS) + @echo " Linking..." + @echo " $(CC) $^ -o $(TARGET) $(LIB)"; $(CC) $^ -o $(TARGET) $(LIB) + +$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT) + @mkdir -p $(BUILDDIR) + @echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $< + +clean: + @echo " Cleaning..." + @echo " $(RM) -r $(BUILDDIR) $(TARGET)"; $(RM) -r $(BUILDDIR) $(TARGET) + +# Tests +tester: + @echo " $(CC) $(CFLAGS) test/tester.cpp $(INC) $(LIB) -o bin/tester"; $(CC) $(CFLAGS) test/tester.cpp $(INC) $(LIB) -o bin/tester + +# Spikes +ticket: + @echo " $(CC) $(CFLAGS) spikes/ticket.cpp $(INC) $(LIB) -o bin/ticket"; $(CC) $(CFLAGS) spikes/ticket.cpp $(INC) $(LIB) -o bin/ticket + +.PHONY: clean diff --git a/lab 2/bin/main b/lab 2/bin/main Binary files differnew file mode 100755 index 0000000..ff7a80d --- /dev/null +++ b/lab 2/bin/main diff --git a/lab 2/build/db_access.o b/lab 2/build/db_access.o Binary files differnew file mode 100644 index 0000000..0e3df43 --- /dev/null +++ b/lab 2/build/db_access.o diff --git a/lab 2/build/lockdb.o b/lab 2/build/lockdb.o Binary files differnew file mode 100644 index 0000000..d3100ac --- /dev/null +++ b/lab 2/build/lockdb.o diff --git a/lab 2/build/main.o b/lab 2/build/main.o Binary files differnew file mode 100644 index 0000000..6d75397 --- /dev/null +++ b/lab 2/build/main.o diff --git a/lab 2/include/lockdb.hpp b/lab 2/include/lockdb.hpp new file mode 100644 index 0000000..43335a4 --- /dev/null +++ b/lab 2/include/lockdb.hpp @@ -0,0 +1,13 @@ +#ifndef LOCKDB_HPP +#define LOCKDB_HPP + +class Lockdb { +public: + Lockdb(); + ~Lockdb(); + bool get_status(); +private: + bool status; +}; + +#endif diff --git a/lab 2/src/db_access.cpp b/lab 2/src/db_access.cpp new file mode 100644 index 0000000..7cb32c1 --- /dev/null +++ b/lab 2/src/db_access.cpp @@ -0,0 +1,46 @@ +/*#include <iostream> +#include <fstream> + +using namespace std; + +void write_db(int data) { + // do some work here + // throw exception(); +} + +bool update_db(int data) { + bool exit_code; + ifstream infile(".lockdb"); + + if(infile.is_open()) { + cout << "resource is busy" << endl; + infile.close(); + exit_code = false; + } else { + ofstream outfile(".lockdb"); + + if(!outfile.is_open()) { + throw runtime_error("couldn't lock resource"); + } + + cout << "resource is locked" << endl; + outfile.close(); + cout << "doing some operations" << endl; + write_db(data); + remove(".lockdb"); + cout << "resource is unlocked" << endl; + exit_code = true; + } + + return exit_code; +} + +int main(int argc, char* argv[]) { + try { + update_db(10); + } catch(exception e) { + cout << "exception occured" << endl; + } + + return 0; +}*/ diff --git a/lab 2/src/lockdb.cpp b/lab 2/src/lockdb.cpp new file mode 100644 index 0000000..82903da --- /dev/null +++ b/lab 2/src/lockdb.cpp @@ -0,0 +1,36 @@ +#include "lockdb.hpp" + +#include <fstream> +#include <iostream> + +using namespace std; + +Lockdb::Lockdb() { + ifstream infile(".lockdb"); + if(infile.is_open()) { + status = false; + cout << "resouce is busy" << endl; + } else { + ofstream outfile(".lockdb"); + + if(!outfile.is_open()) { + status = false; + throw runtime_error("couldn't lock resource"); + } + + status = true; + cout << "resource is locked" << endl; + } +} + +Lockdb::~Lockdb() { + cout << "destructor" << endl; + if(status) { + remove(".lockdb"); + cout << "resource unlocked" << endl; + } +} + +bool Lockdb::get_status() { + return status; +} diff --git a/lab 2/src/main.cpp b/lab 2/src/main.cpp new file mode 100644 index 0000000..440da42 --- /dev/null +++ b/lab 2/src/main.cpp @@ -0,0 +1,37 @@ +#include "lockdb.hpp" + +#include <iostream> + +using namespace std; + +bool update_db(int data); +void write_db(int data); + +int main(int argc, char* argv[]) { + try { + update_db(10); + } catch(exception e) { + cout << "exception occured" << endl; + } + return 0; +} + +bool update_db(int data) { + bool exit_code; + Lockdb ldb; + + if(ldb.get_status()) { + cout << "doing some operations" << endl; + write_db(data); + exit_code = true; + } else { + exit_code = false; + } + + return exit_code; +} + +void write_db(int data) { + // do something with data + throw exception(); +} |