This repository has been archived by the owner on Nov 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.cpp
41 lines (37 loc) · 1.61 KB
/
common.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* Source file containing all functions common to all elements */
#include "common.hpp"
#include <iostream>
#include <chrono>
void err_msg(ErrorType error)
// Receives a member of the ErrorType class and displays its corresponding error message
{
switch (error) {
case ErrorType::unopened_file:
std::cout << "The specified file does not exist or could not be opened.\n";
break;
case ErrorType::wrong_type:
std::cout << "The specified file is not a bitmap image.\n";
break;
case ErrorType::wrong_planes:
std::cout << "The specified bitmap is invalid (number of plains is not equal to 1).\n";
break;
case ErrorType::wrong_point_size:
std::cout << "The specified bitmap is invalid (point size is not equal to 24).\n";
break;
case ErrorType::wrong_compression:
std::cout << "The specified bitmap is invalid (compression value is not equal to 0).\n";
break;
}
exit(-1);// Finish the execution after the error message is displayed with error code -1
}
void print_data(const std::string &op, long loadtime, long opertime, long storetime) {
std::cout << "Load time: " << loadtime << "\n";
std::cout << op << " time: " << opertime << "\n";
std::cout << "Store time: " << storetime << "\n";
}
long stop_chrono(std::chrono::time_point<std::chrono::system_clock> start) {
auto stop = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);
auto time = duration.count();
return time;
}