Added clang-format and clang-tidy
This commit is contained in:
parent
a80da53d0c
commit
363778019e
8 changed files with 146 additions and 99 deletions
3
.clang-format
Normal file
3
.clang-format
Normal file
|
@ -0,0 +1,3 @@
|
|||
Language: Cpp
|
||||
BasedOnStyle: LLVM
|
||||
|
39
.clang-tidy
Normal file
39
.clang-tidy
Normal file
|
@ -0,0 +1,39 @@
|
|||
Checks: "*,
|
||||
-abseil-*,
|
||||
-altera-*,
|
||||
-android-*,
|
||||
-fuchsia-*,
|
||||
-google-*,
|
||||
-llvm*,
|
||||
-modernize-use-trailing-return-type,
|
||||
-zircon-*,
|
||||
-readability-else-after-return,
|
||||
-readability-static-accessed-through-instance,
|
||||
-readability-avoid-const-params-in-decls,
|
||||
-cppcoreguidelines-non-private-member-variables-in-classes,
|
||||
-misc-non-private-member-variables-in-classes,
|
||||
"
|
||||
WarningsAsErrors: ''
|
||||
HeaderFilterRegex: ''
|
||||
FormatStyle: none
|
||||
CheckOptions:
|
||||
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
|
||||
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
|
||||
- { key: readability-identifier-naming.StructCase, value: CamelCase }
|
||||
- { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase }
|
||||
- { key: readability-identifier-naming.FunctionCase, value: camelBack }
|
||||
- { key: readability-identifier-naming.VariableCase, value: lower_case }
|
||||
- { key: readability-identifier-naming.PrivateMemberSuffix, value: _ }
|
||||
- { key: readability-identifier-naming.ProtectedMemberSuffix, value: _ }
|
||||
- { key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }
|
||||
- { key: readability-identifier-naming.EnumConstantCase, value: CamelCase }
|
||||
- { key: readability-identifier-naming.EnumConstantPrefix, value: k }
|
||||
- { key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase }
|
||||
- { key: readability-identifier-naming.ConstexprVariablePrefix, value: k }
|
||||
- { key: readability-identifier-naming.GlobalConstantCase, value: CamelCase }
|
||||
- { key: readability-identifier-naming.GlobalConstantPrefix, value: k }
|
||||
- { key: readability-identifier-naming.MemberConstantCase, value: CamelCase }
|
||||
- { key: readability-identifier-naming.MemberConstantPrefix, value: k }
|
||||
- { key: readability-identifier-naming.StaticConstantCase, value: CamelCase }
|
||||
- { key: readability-identifier-naming.StaticConstantPrefix, value: k }
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
build
|
||||
.cache
|
||||
|
|
|
@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 3.30)
|
|||
project(yadro-task VERSION 0.1)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_FLAGS "-Wall")
|
||||
|
||||
file(GLOB SOURCES "src/*.cpp")
|
||||
|
||||
|
|
|
@ -7,23 +7,31 @@
|
|||
#include <string>
|
||||
|
||||
/**
|
||||
* Mock tape implementation that uses text files as data source.
|
||||
*
|
||||
* Simulates tape operations by artificially pausing the execution of some methods
|
||||
* using time intervals, specified in command line arguments or a configuration file.
|
||||
* Each cell is represented as a seperate line in a file, cell data is stored as plain text.
|
||||
*/
|
||||
* Mock tape implementation that uses text files as data source.
|
||||
*
|
||||
* Simulates tape operations by artificially pausing the execution of some
|
||||
* methods using time intervals, specified in command line arguments or a
|
||||
* configuration file. Each cell is represented as a seperate line in a file,
|
||||
* cell data is stored as plain text.
|
||||
*/
|
||||
class FileTape : public Tape {
|
||||
private:
|
||||
std::fstream file;
|
||||
std::fstream file_;
|
||||
|
||||
public:
|
||||
~FileTape() override;
|
||||
FileTape &operator=(const FileTape &) = delete;
|
||||
FileTape(const FileTape &) = delete;
|
||||
FileTape(FileTape &&) = delete;
|
||||
FileTape &operator=(FileTape &&) = delete;
|
||||
|
||||
/**
|
||||
* Initialize a new instance of FileTape that will open a file with the specified name.
|
||||
* File must be read and write accessible.
|
||||
* Initialize a new instance of FileTape that will open a file with the
|
||||
* specified name. File must be read and write accessible.
|
||||
*
|
||||
* @param file_name Name of a file to be opened.
|
||||
*/
|
||||
FileTape(std::string file_name);
|
||||
explicit FileTape(const std::string &fileName);
|
||||
|
||||
/**
|
||||
* Advances the underlying fstream to a new line.
|
||||
|
@ -52,11 +60,11 @@ public:
|
|||
* @param data Number, that should be written to the current line.
|
||||
*/
|
||||
void write(int32_t data) override;
|
||||
};
|
||||
|
||||
/**
|
||||
* Closes the underlying fstream
|
||||
*/
|
||||
~FileTape() override;
|
||||
struct FileTapeSettings {
|
||||
unsigned int readDelayMs, writeDelayMs;
|
||||
unsigned int seekForwardDelayMs, seekBackwardsDelayMs;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,28 +4,36 @@
|
|||
#include <cstdint>
|
||||
|
||||
/**
|
||||
* Abstract class representing a magnetic tape.
|
||||
*
|
||||
* Tape is a storage medium consisting of N cells, where each cell contains a 32-bit signed integer.
|
||||
* Data can be read or written into one cell at a time. Tape can be moved
|
||||
* one cell forward or backwards in order to change the targeted cell.
|
||||
* Tape performs every operation sequentially. The amount of data stored on a single tape
|
||||
* could exceed the amount of available RAM. Moving tape forward or backwards
|
||||
* is a very time-consuming operation.
|
||||
*/
|
||||
* Abstract class representing a magnetic tape.
|
||||
*
|
||||
* Tape is a storage medium consisting of N cells, where each cell contains a
|
||||
* 32-bit signed integer. Data can be read or written into one cell at a time.
|
||||
* Tape can be moved one cell forward or backwards in order to change the
|
||||
* targeted cell. Tape performs every operation sequentially. The amount of data
|
||||
* stored on a single tape could exceed the amount of available RAM. Moving tape
|
||||
* forward or backwards is a very time-consuming operation.
|
||||
*/
|
||||
class Tape {
|
||||
public:
|
||||
Tape(const Tape &) = default;
|
||||
Tape(Tape &&) = default;
|
||||
Tape &operator=(const Tape &) = default;
|
||||
Tape &operator=(Tape &&) = default;
|
||||
virtual ~Tape() = default;
|
||||
|
||||
/**
|
||||
* Advances the tape one cell forward.
|
||||
*
|
||||
* @return false if the next cell doesn't exist (reached end of tape), otherwise true.
|
||||
* @return false if the next cell doesn't exist (reached end of tape),
|
||||
* otherwise true.
|
||||
*/
|
||||
virtual bool seekForward() = 0;
|
||||
|
||||
/**
|
||||
* Rewinds the tape one cell backwards.
|
||||
*
|
||||
* @return false if the previous cell doesn't exist (reached beginning of tape), otherwise true.
|
||||
* @return false if the previous cell doesn't exist (reached beginning of
|
||||
* tape), otherwise true.
|
||||
*/
|
||||
virtual bool seekBackwards() = 0;
|
||||
|
||||
|
@ -42,9 +50,6 @@ public:
|
|||
* @param data Number, that should be written to the current cell.
|
||||
*/
|
||||
virtual void write(int32_t data) = 0;
|
||||
|
||||
// default virtual destructor to prevent memory leaks in implementing classes
|
||||
virtual ~Tape() = default;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,26 +3,16 @@
|
|||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
FileTape::FileTape(std::string file_name) {
|
||||
this->file = std::fstream(file_name);
|
||||
FileTape::FileTape(const std::string &fileName) {
|
||||
this->file_ = std::fstream(fileName);
|
||||
}
|
||||
|
||||
bool FileTape::seekForward() {
|
||||
return true;
|
||||
}
|
||||
bool FileTape::seekForward() { return true; }
|
||||
|
||||
bool FileTape::seekBackwards() {
|
||||
return true;
|
||||
}
|
||||
bool FileTape::seekBackwards() { return true; }
|
||||
|
||||
int32_t FileTape::read() {
|
||||
return 0;
|
||||
}
|
||||
int32_t FileTape::read() { return 0; }
|
||||
|
||||
void FileTape::write(int32_t data) {
|
||||
void FileTape::write(int32_t data) {}
|
||||
|
||||
}
|
||||
|
||||
FileTape::~FileTape() {
|
||||
this->file.close();
|
||||
}
|
||||
FileTape::~FileTape() { this->file_.close(); }
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#include "filetape.h"
|
||||
#include <memory>
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
std::unique_ptr<Tape> tape(new FileTape("test"));
|
||||
int main(int /*argc*/, char * /*argv*/[]) {
|
||||
FileTape tape("waw");
|
||||
std::cout << "Hello, World!" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue