Skip to content

Commit b96efa3

Browse files
authored
created include folder for the public interface (#4)
* created include folder for the public interface * fixed include * moved forward declaration of GAState to GACommon.h * updated header
1 parent af83af8 commit b96efa3

File tree

15 files changed

+201
-79
lines changed

15 files changed

+201
-79
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ set(DEPENDENCIES_DIR "${GA_SOURCE_DIR}/dependencies")
77
set(EXTERNALS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/externals")
88
set(LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libs")
99
set(GA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/gameanalytics")
10+
set(INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
1011

1112
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/CMakeIncludes")
1213

@@ -32,6 +33,7 @@ set(CMAKE_CXX_STANDARD 17)
3233
include_directories(
3334
# gameanalytics includes
3435
"${GA_SOURCE_DIR}/gameanalytics"
36+
"${INCLUDE_DIR}"
3537

3638
# depndencies includes
3739
"${DEPENDENCIES_DIR}"

include/.DS_Store

6 KB
Binary file not shown.

include/GameAnalytics/GATypes.h

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#pragma once
2+
3+
#include <string>
4+
#include <vector>
5+
#include <cinttypes>
6+
#include <memory>
7+
#include <ostream>
8+
#include <utility>
9+
#include <cstring>
10+
#include <array>
11+
#include <functional>
12+
13+
namespace gameanalytics
14+
{
15+
/*!
16+
@enum
17+
@discussion
18+
This enum is used to specify flow in resource events
19+
@constant GAResourceFlowTypeSource
20+
Used when adding to a resource currency
21+
@constant GAResourceFlowTypeSink
22+
Used when subtracting from a resource currency
23+
*/
24+
enum EGAResourceFlowType
25+
{
26+
Source = 1,
27+
Sink = 2
28+
};
29+
30+
/*!
31+
@enum
32+
@discussion
33+
this enum is used to specify status for progression event
34+
@constant GAProgressionStatusStart
35+
User started progression
36+
@constant GAProgressionStatusComplete
37+
User succesfully ended a progression
38+
@constant GAProgressionStatusFail
39+
User failed a progression
40+
*/
41+
enum EGAProgressionStatus
42+
{
43+
Start = 1,
44+
Complete = 2,
45+
Fail = 3
46+
};
47+
48+
/*!
49+
@enum
50+
@discussion
51+
this enum is used to specify severity of an error event
52+
@constant GAErrorSeverityDebug
53+
@constant GAErrorSeverityInfo
54+
@constant GAErrorSeverityWarning
55+
@constant GAErrorSeverityError
56+
@constant GAErrorSeverityCritical
57+
*/
58+
enum EGAErrorSeverity
59+
{
60+
Debug = 1,
61+
Info = 2,
62+
Warning = 3,
63+
Error = 4,
64+
Critical = 5
65+
};
66+
67+
enum EGALoggerMessageType
68+
{
69+
LogError = 0,
70+
LogWarning = 1,
71+
LogInfo = 2,
72+
LogDebug = 3,
73+
LogVerbose = 4
74+
};
75+
76+
using StringVector = std::vector<std::string>;
77+
78+
using LogHandler = std::function<void(std::string const&, EGALoggerMessageType)>;
79+
using FPSTracker = std::function<float()>;
80+
81+
struct IRemoteConfigsListener
82+
{
83+
virtual void onRemoteConfigsUpdated(std::string const& remoteConfigs) = 0;
84+
};
85+
}
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,7 @@
55

66
#pragma once
77

8-
#include "GACommon.h"
9-
10-
#include <vector>
11-
#include <memory>
12-
#include <future>
13-
14-
#if GA_SHARED_LIB
15-
#include "GameAnalyticsExtern.h"
16-
#endif
8+
#include "GameAnalytics/GATypes.h"
179

1810
namespace gameanalytics
1911
{

sample/Main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#include <string>
22
#include <iostream>
3+
#include <thread>
34

4-
#include "GameAnalytics.h"
5+
#include "GameAnalytics/GameAnalytics.h"
56

67
constexpr const char* GAME_KEY = "bd624ee6f8e6efb32a054f8d7ba11618";
78
constexpr const char* SECRET_KEY = "7f5c3f682cbd217841efba92e92ffb1b3b6612bc";

source/gameanalytics/GACommon.h

Lines changed: 108 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,108 @@
1-
#pragma once
2-
3-
#include "GAConstants.h"
4-
5-
#if IS_MAC
6-
#include <sys/sysctl.h>
7-
#elif IS_WIN32
8-
#include <winsock2.h>
9-
#include <windows.h>
10-
#elif IS_UWP
11-
#include <winsock2.h>
12-
#include <windows.h>
13-
#elif IS_LINUX
14-
#include <sys/utsname.h>
15-
#include <sys/types.h>
16-
#include <sys/stat.h>
17-
#endif
18-
19-
20-
#include <string>
21-
#include <vector>
22-
#include <cinttypes>
23-
#include <memory>
24-
#include <thread>
25-
#include <filesystem>
26-
#include <iostream>
27-
#include <cstdio>
28-
#include <cstdlib>
29-
#include <cerrno>
30-
#include <cctype>
31-
#include <future>
32-
#include <ostream>
33-
#include <mutex>
34-
#include <fstream>
35-
#include <csignal>
36-
#include <utility>
37-
#include <cstring>
38-
#include <cstdio>
39-
#include <array>
40-
41-
#include "nlohmann/json.hpp"
42-
43-
namespace gameanalytics
44-
{
45-
using nlohmann::json;
46-
using StringVector = std::vector<std::string>;
47-
48-
using LogHandler = std::function<void(std::string const&, EGALoggerMessageType)>;
49-
using FPSTracker = std::function<float()>;
50-
51-
namespace state
52-
{
53-
class GAState;
54-
}
55-
56-
struct IRemoteConfigsListener
57-
{
58-
virtual void onRemoteConfigsUpdated(std::string const& remoteConfigs) = 0;
59-
};
60-
}
1+
#pragma once
2+
3+
#if defined(_WIN32) || defined(_WIN64) || defined(GA_UWP_BUILD)
4+
5+
#ifndef GA_UWP_BUILD
6+
#define IS_WIN32 1
7+
#define IS_UWP 0
8+
#else
9+
#define IS_WIN32 0
10+
#define IS_UWP 1
11+
#endif
12+
13+
#define _WIN32_DCOM
14+
15+
#ifndef WIN32_LEAN_AND_MEAN
16+
#define WIN32_LEAN_AND_MEAN
17+
#endif
18+
19+
#ifndef NOMINMAX
20+
#define NOMINMAX
21+
#endif
22+
23+
#else
24+
#define IS_WIN32 0
25+
#define IS_UWP 0
26+
#endif
27+
28+
#if IS_MAC
29+
#include <sys/sysctl.h>
30+
#elif IS_WIN32
31+
#include <winsock2.h>
32+
#include <windows.h>
33+
#elif IS_UWP
34+
#include <winsock2.h>
35+
#include <windows.h>
36+
#elif IS_LINUX
37+
#include <sys/utsname.h>
38+
#include <sys/types.h>
39+
#include <sys/stat.h>
40+
#endif
41+
42+
#include "GameAnalytics/GATypes.h"
43+
44+
#include <string>
45+
#include <vector>
46+
#include <cinttypes>
47+
#include <memory>
48+
#include <thread>
49+
#include <filesystem>
50+
#include <iostream>
51+
#include <cstdio>
52+
#include <cstdlib>
53+
#include <cerrno>
54+
#include <cctype>
55+
#include <future>
56+
#include <ostream>
57+
#include <mutex>
58+
#include <fstream>
59+
#include <csignal>
60+
#include <utility>
61+
#include <cstring>
62+
#include <cstdio>
63+
#include <array>
64+
65+
#include "nlohmann/json.hpp"
66+
67+
#if defined(__linux__) || defined(__unix__) || defined(__unix) || defined(unix)
68+
#define IS_LINUX 1
69+
#else
70+
#define IS_LINUX 0
71+
#endif
72+
73+
#if defined(__MACH__) || defined(__APPLE__)
74+
#define IS_MAC 1
75+
#else
76+
#define IS_MAC 0
77+
#endif
78+
79+
namespace gameanalytics
80+
{
81+
using nlohmann::json;
82+
83+
namespace state
84+
{
85+
class GAState;
86+
}
87+
88+
constexpr const char* GA_VERSION_STR = "cpp 4.0.0-alpha";
89+
90+
constexpr int MAX_CUSTOM_FIELDS_COUNT = 50;
91+
constexpr int MAX_CUSTOM_FIELDS_KEY_LENGTH = 64;
92+
constexpr int MAX_CUSTOM_FIELDS_VALUE_STRING_LENGTH = 256;
93+
94+
constexpr int UUID_STR_LENGTH = 128;
95+
constexpr int TEXT_BUFFER_LENGTH = 256;
96+
97+
constexpr const char* UNKNOWN_VALUE = "unknown";
98+
99+
constexpr int MAX_ERROR_TYPE_COUNT = 10;
100+
constexpr int MAX_ERROR_MSG_LEN = 8192;
101+
102+
constexpr int JSON_PRINT_INDENT = 4;
103+
104+
constexpr const char* CONNECTION_OFFLINE = "offline";
105+
constexpr const char* CONNECTION_LAN = "lan";
106+
constexpr const char* CONNECTION_WIFI = "wifi";
107+
constexpr const char* CONNECTION_WWAN = "wwan";
108+
}

source/gameanalytics/GADevice.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
#pragma once
77

8-
#include "GAConstants.h"
98
#include "GACommon.h"
109
#include "GAHealth.h"
1110
#include "Platform/GAPlatform.h"

source/gameanalytics/GAEvents.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#pragma once
77

88
#include "GACommon.h"
9-
#include "GameAnalytics.h"
109

1110
namespace gameanalytics
1211
{

source/gameanalytics/GALogger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "GALogger.h"
2-
#include "GameAnalytics.h"
2+
#include "GameAnalytics/GameAnalytics.h"
33
#include <iostream>
44
#include "GADevice.h"
55
#include <cstdarg>

source/gameanalytics/GAState.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <cstdlib>
1313
#include <unordered_map>
1414

15-
#include "GameAnalytics.h"
1615
#include "GACommon.h"
1716
#include "GAUtilities.h"
1817
#include "GALogger.h"

0 commit comments

Comments
 (0)