Robin Thoni před 8 roky
revize
52e1313363

+ 32
- 0
.gitignore Zobrazit soubor

@@ -0,0 +1,32 @@
1
+/.idea
2
+/build
3
+*.swp
4
+
5
+# Compiled Object files
6
+*.slo
7
+*.lo
8
+*.o
9
+*.obj
10
+
11
+# Precompiled Headers
12
+*.gch
13
+*.pch
14
+
15
+# Compiled Dynamic libraries
16
+*.so
17
+*.dylib
18
+*.dll
19
+
20
+# Fortran module files
21
+*.mod
22
+
23
+# Compiled Static libraries
24
+*.lai
25
+*.la
26
+*.a
27
+*.lib
28
+
29
+# Executables
30
+*.exe
31
+*.out
32
+*.app

+ 9
- 0
CMakeLists.txt Zobrazit soubor

@@ -0,0 +1,9 @@
1
+cmake_minimum_required(VERSION 2.8)
2
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/")
3
+project(rozitm)
4
+find_package(GTest)
5
+add_subdirectory(src)
6
+if (GTEST_FOUND)
7
+    enable_testing()
8
+    add_subdirectory(tests)
9
+endif (GTEST_FOUND)

+ 0
- 0
CMakeModules/.gitkeep Zobrazit soubor


+ 0
- 0
src/Business/.gitkeep Zobrazit soubor


+ 7
- 0
src/CMakeLists.txt Zobrazit soubor

@@ -0,0 +1,7 @@
1
+include_directories(.)
2
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
3
+set(SOURCE_FILES
4
+        DataAccess/Pcap.cpp
5
+        )
6
+add_library(rozitm SHARED ${SOURCE_FILES})
7
+target_link_libraries(rozitm ${LIBS})

+ 0
- 0
src/DBO/.gitkeep Zobrazit soubor


+ 52
- 0
src/DBO/Result.h Zobrazit soubor

@@ -0,0 +1,52 @@
1
+//
2
+// Created by robin on 8/9/15.
3
+//
4
+
5
+#ifndef PDNS_SLAVE_RESULT_H
6
+#define PDNS_SLAVE_RESULT_H
7
+
8
+# include <string>
9
+# include <vector>
10
+
11
+template <class T> class Result
12
+{
13
+public:
14
+    Result();
15
+
16
+    Result(const T& data);
17
+
18
+    virtual ~Result();
19
+
20
+    Result<T>& ok(const T& data);
21
+
22
+    T& getData();
23
+
24
+    bool isSuccess() const;
25
+
26
+    Result<T>& addWarning(const std::string& warning);
27
+
28
+    const std::vector<std::string>& getWarnings() const;
29
+
30
+    Result<T>& error(const std::string& error);
31
+
32
+    const std::string& getError() const;
33
+
34
+    bool operator !() const;
35
+
36
+    operator bool() const;
37
+
38
+    const Result<T>& print() const;
39
+
40
+private:
41
+    T _data;
42
+
43
+    std::vector<std::string> _warnings;
44
+
45
+    std::string _error;
46
+};
47
+
48
+typedef Result<bool> BResult;
49
+
50
+# include "DBO/Result.hxx"
51
+
52
+#endif //PDNS_SLAVE_RESULT_H

+ 89
- 0
src/DBO/Result.hxx Zobrazit soubor

@@ -0,0 +1,89 @@
1
+//
2
+// Created by robin on 8/9/15.
3
+//
4
+
5
+#include <iostream>
6
+#include "Result.h"
7
+
8
+template<class T>
9
+Result<T>::Result()
10
+{
11
+}
12
+
13
+template<class T>
14
+Result<T>::Result(const T &data)
15
+        : _data(data)
16
+{
17
+}
18
+
19
+template<class T>
20
+Result<T>::~Result()
21
+{
22
+}
23
+
24
+template<class T>
25
+Result<T> &Result<T>::ok(const T &data)
26
+{
27
+    _data = data;
28
+    return *this;
29
+}
30
+
31
+template<class T>
32
+T &Result<T>::getData()
33
+{
34
+    return _data;
35
+}
36
+
37
+template<class T>
38
+bool Result<T>::isSuccess() const
39
+{
40
+    return _error.empty();
41
+}
42
+
43
+template<class T>
44
+const std::vector<std::string>& Result<T>::getWarnings() const
45
+{
46
+    return _warnings;
47
+}
48
+
49
+template<class T>
50
+Result<T>& Result<T>::addWarning(const std::string &warning)
51
+{
52
+    _warnings.push_back(warning);
53
+    return *this;
54
+}
55
+
56
+template<class T>
57
+bool Result<T>::operator!() const
58
+{
59
+    return !isSuccess();
60
+}
61
+
62
+template<class T>
63
+Result<T>::operator bool() const
64
+{
65
+    return isSuccess();
66
+}
67
+
68
+template<class T>
69
+Result<T> &Result<T>::error(const std::string &error)
70
+{
71
+    _error = error;
72
+    return *this;
73
+}
74
+
75
+template<class T>
76
+const std::string &Result<T>::getError() const
77
+{
78
+    return _error;
79
+}
80
+
81
+template<class T>
82
+const Result<T>& Result<T>::print() const
83
+{
84
+    for (auto warning : _warnings)
85
+        std::cerr << "WARNING: " << warning << std::endl;
86
+    if (!isSuccess())
87
+        std::cerr << "ERROR: " << _error << std::endl;
88
+    return *this;
89
+}

+ 0
- 0
src/DataAccess/.gitkeep Zobrazit soubor


+ 14
- 0
src/DataAccess/Pcap.cpp Zobrazit soubor

@@ -0,0 +1,14 @@
1
+//
2
+// Created by robin on 5/10/16.
3
+//
4
+
5
+#include "Pcap.h"
6
+
7
+Pcap::Pcap(const std::string &device)
8
+{
9
+}
10
+
11
+void Pcap::test()
12
+{
13
+
14
+}

+ 20
- 0
src/DataAccess/Pcap.h Zobrazit soubor

@@ -0,0 +1,20 @@
1
+//
2
+// Created by robin on 5/10/16.
3
+//
4
+
5
+#ifndef ROZITM_PCAP_H
6
+#define ROZITM_PCAP_H
7
+
8
+
9
+#include <string>
10
+
11
+class Pcap
12
+{
13
+public:
14
+    Pcap(const std::string& device);
15
+
16
+    void test();
17
+};
18
+
19
+
20
+#endif //ROZITM_PCAP_H

+ 0
- 0
src/Interface/.gitkeep Zobrazit soubor


+ 11
- 0
tests/CMakeLists.txt Zobrazit soubor

@@ -0,0 +1,11 @@
1
+enable_testing()
2
+include_directories(${CHECK_INCLUDE_DIRS})
3
+include_directories(. ../src)
4
+find_package (Threads)
5
+set(LIBS ${LIBS} gtest pthread rozitm)
6
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
7
+add_executable(test-main
8
+  test-main.cpp
9
+  )
10
+target_link_libraries(test-main ${LIBS})
11
+add_test(test-main ${CMAKE_CURRENT_BINARY_DIR}/test-main)

+ 17
- 0
tests/test-main.cpp Zobrazit soubor

@@ -0,0 +1,17 @@
1
+#include <iostream>
2
+#include <string.h>
3
+#include <gtest/gtest.h>
4
+#include "DataAccess/Pcap.h"
5
+
6
+TEST(None, None)
7
+{
8
+  ASSERT_TRUE(true);
9
+}
10
+
11
+int main(int argc, char* argv[])
12
+{
13
+  Pcap pcap("eth0");
14
+  pcap.test();
15
+  ::testing::InitGoogleTest(&argc, argv);
16
+  return RUN_ALL_TESTS();
17
+}

Načítá se…
Zrušit
Uložit