Browse code

clean up linter warnings

Tom Sherman authored on 24/06/2019 19:44:02
Showing1 changed files
... ...
@@ -20,7 +20,8 @@ class Archive
20 20
 public:
21 21
 
22 22
     Archive(const std::string &path, std::ios_base::openmode flags)
23
-        : mStream(path.c_str(), std::ios::binary | flags)
23
+        :
24
+    mStream(path.c_str(), std::ios::binary | flags)
24 25
     {
25 26
         if (flags == ARCHIVE_WRITE)
26 27
         {
... ...
@@ -64,8 +65,8 @@ public:
64 65
     friend Archive& operator<<(Archive &ar, bool val)     { return writeToArchive(ar, val); }
65 66
     friend Archive& operator<<(Archive &ar, int val)      { return writeToArchive(ar, val); }
66 67
     friend Archive& operator<<(Archive &ar, unsigned val) { return writeToArchive(ar, val); }
67
-    friend Archive& operator<<(Archive &ar, unsigned long val) { return writeToArchive(ar, val); }
68
-    friend Archive& operator<<(Archive &ar, unsigned long long val) { return writeToArchive(ar, val); }
68
+    friend Archive& operator<<(Archive &ar, unsigned long val) { return writeToArchive(ar, val); } //NOLINT
69
+    friend Archive& operator<<(Archive &ar, unsigned long long val) { return writeToArchive(ar, val); } //NOLINT
69 70
     friend Archive& operator<<(Archive &ar, int64_t val)  { return writeToArchive(ar, val); }
70 71
     friend Archive& operator<<(Archive &ar, float val)    { return writeToArchive(ar, val); }
71 72
     friend Archive& operator<<(Archive &ar, double val)   { return writeToArchive(ar, val); }
... ...
@@ -74,8 +75,8 @@ public:
74 75
     friend Archive& operator>>(Archive &ar, bool &val)     { return readFromArchive(ar, val); }
75 76
     friend Archive& operator>>(Archive &ar, int &val)      { return readFromArchive(ar, val); }
76 77
     friend Archive& operator>>(Archive &ar, unsigned &val) { return readFromArchive(ar, val); }
77
-    friend Archive& operator>>(Archive &ar, unsigned long &val) { return readFromArchive(ar, val); }
78
-    friend Archive& operator>>(Archive &ar, unsigned long long &val) { return readFromArchive(ar, val); }
78
+    friend Archive& operator>>(Archive &ar, unsigned long &val) { return readFromArchive(ar, val); } //NOLINT
79
+    friend Archive& operator>>(Archive &ar, unsigned long long &val) { return readFromArchive(ar, val); } //NOLINT
79 80
     friend Archive& operator>>(Archive &ar, int64_t &val)  { return readFromArchive(ar, val); }
80 81
     friend Archive& operator>>(Archive &ar, float &val)    { return readFromArchive(ar, val); }
81 82
     friend Archive& operator>>(Archive &ar, double &val)   { return readFromArchive(ar, val); }
Browse code

updated config to commit file permissions

Tom Sherman authored on 29/10/2018 19:56:14
Showing1 changed files
1 1
old mode 100644
2 2
new mode 100755
Browse code

tests passing

Tom Sherman authored on 25/10/2018 22:31:44
Showing1 changed files
... ...
@@ -17,10 +17,6 @@
17 17
 
18 18
 class Archive
19 19
 {
20
-private:
21
-
22
-    std::fstream mStream;
23
-
24 20
 public:
25 21
 
26 22
     Archive(const std::string &path, std::ios_base::openmode flags)
... ...
@@ -83,6 +79,10 @@ public:
83 79
     friend Archive& operator>>(Archive &ar, int64_t &val)  { return readFromArchive(ar, val); }
84 80
     friend Archive& operator>>(Archive &ar, float &val)    { return readFromArchive(ar, val); }
85 81
     friend Archive& operator>>(Archive &ar, double &val)   { return readFromArchive(ar, val); }
82
+
83
+private:
84
+
85
+    std::fstream mStream;
86 86
 };
87 87
 
88 88
 #endif // __COGAPS_ARCHIVE_H__
Browse code

dense sampler appears to be working

Tom Sherman authored on 15/10/2018 20:52:28
Showing1 changed files
... ...
@@ -24,8 +24,7 @@ private:
24 24
 public:
25 25
 
26 26
     Archive(const std::string &path, std::ios_base::openmode flags)
27
-        :
28
-    mStream(path.c_str(), std::ios::binary | flags)
27
+        : mStream(path.c_str(), std::ios::binary | flags)
29 28
     {
30 29
         if (flags == ARCHIVE_WRITE)
31 30
         {
Browse code

polymorphic structure

Tom Sherman authored on 02/10/2018 20:54:21
Showing1 changed files
... ...
@@ -42,7 +42,7 @@ public:
42 42
         }
43 43
     }
44 44
 
45
-    void close()
45
+    ~Archive()
46 46
     {
47 47
         mStream.close();
48 48
     }
Browse code

basic framework in place for full async

Tom Sherman authored on 29/08/2018 21:41:05
Showing1 changed files
... ...
@@ -12,7 +12,8 @@
12 12
 
13 13
 // magic number written to beginning of archive files
14 14
 // needs to be updated everytime the method of checkpointing changes
15
-#define ARCHIVE_MAGIC_NUM 0xCE45D32B // v3.3.22
15
+//#define ARCHIVE_MAGIC_NUM 0xCE45D32B // v3.3.22
16
+#define ARCHIVE_MAGIC_NUM 0xB123AA4D // v3.3.30
16 17
 
17 18
 class Archive
18 19
 {
Browse code

started making changes

Tom Sherman authored on 28/08/2018 19:53:08
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,88 @@
1
+#ifndef __COGAPS_ARCHIVE_H__
2
+#define __COGAPS_ARCHIVE_H__
3
+
4
+#include "GapsAssert.h"
5
+
6
+#include <fstream>
7
+#include <stdint.h>
8
+
9
+// flags for opening an archive
10
+#define ARCHIVE_READ  std::ios::in
11
+#define ARCHIVE_WRITE (std::ios::out | std::ios::trunc)
12
+
13
+// magic number written to beginning of archive files
14
+// needs to be updated everytime the method of checkpointing changes
15
+#define ARCHIVE_MAGIC_NUM 0xCE45D32B // v3.3.22
16
+
17
+class Archive
18
+{
19
+private:
20
+
21
+    std::fstream mStream;
22
+
23
+public:
24
+
25
+    Archive(const std::string &path, std::ios_base::openmode flags)
26
+        :
27
+    mStream(path.c_str(), std::ios::binary | flags)
28
+    {
29
+        if (flags == ARCHIVE_WRITE)
30
+        {
31
+            *this << static_cast<uint32_t>(ARCHIVE_MAGIC_NUM);
32
+        }
33
+        else // read
34
+        {
35
+            uint32_t magic = 0;
36
+            *this >> magic;
37
+            if (magic != ARCHIVE_MAGIC_NUM)
38
+            {
39
+                GAPS_ERROR("incompatible checkpoint file\n");
40
+            }            
41
+        }
42
+    }
43
+
44
+    void close()
45
+    {
46
+        mStream.close();
47
+    }
48
+
49
+    template<typename T>
50
+    friend Archive& writeToArchive(Archive &ar, T val)
51
+    {
52
+        ar.mStream.write(reinterpret_cast<char*>(&val), sizeof(T)); // NOLINT
53
+        return ar;
54
+    }
55
+
56
+    template<typename T>
57
+    friend Archive& readFromArchive(Archive &ar, T &val)
58
+    {
59
+        ar.mStream.read(reinterpret_cast<char*>(&val), sizeof(T)); // NOLINT
60
+        return ar;
61
+    }    
62
+
63
+    // explicitly define which types can be automatically written/read
64
+    // don't have C++11 and don't want to add another dependency on boost,
65
+    // so no template tricks
66
+
67
+    friend Archive& operator<<(Archive &ar, char val)     { return writeToArchive(ar, val); }
68
+    friend Archive& operator<<(Archive &ar, bool val)     { return writeToArchive(ar, val); }
69
+    friend Archive& operator<<(Archive &ar, int val)      { return writeToArchive(ar, val); }
70
+    friend Archive& operator<<(Archive &ar, unsigned val) { return writeToArchive(ar, val); }
71
+    friend Archive& operator<<(Archive &ar, unsigned long val) { return writeToArchive(ar, val); }
72
+    friend Archive& operator<<(Archive &ar, unsigned long long val) { return writeToArchive(ar, val); }
73
+    friend Archive& operator<<(Archive &ar, int64_t val)  { return writeToArchive(ar, val); }
74
+    friend Archive& operator<<(Archive &ar, float val)    { return writeToArchive(ar, val); }
75
+    friend Archive& operator<<(Archive &ar, double val)   { return writeToArchive(ar, val); }
76
+
77
+    friend Archive& operator>>(Archive &ar, char &val)     { return readFromArchive(ar, val); }
78
+    friend Archive& operator>>(Archive &ar, bool &val)     { return readFromArchive(ar, val); }
79
+    friend Archive& operator>>(Archive &ar, int &val)      { return readFromArchive(ar, val); }
80
+    friend Archive& operator>>(Archive &ar, unsigned &val) { return readFromArchive(ar, val); }
81
+    friend Archive& operator>>(Archive &ar, unsigned long &val) { return readFromArchive(ar, val); }
82
+    friend Archive& operator>>(Archive &ar, unsigned long long &val) { return readFromArchive(ar, val); }
83
+    friend Archive& operator>>(Archive &ar, int64_t &val)  { return readFromArchive(ar, val); }
84
+    friend Archive& operator>>(Archive &ar, float &val)    { return readFromArchive(ar, val); }
85
+    friend Archive& operator>>(Archive &ar, double &val)   { return readFromArchive(ar, val); }
86
+};
87
+
88
+#endif // __COGAPS_ARCHIVE_H__