Skip to content

Commit

Permalink
remove Settings.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
sytelus committed Jul 11, 2017
1 parent 9d504b8 commit 1adbe54
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 29 deletions.
1 change: 0 additions & 1 deletion AirLib/AirLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@
<ClCompile Include="src\rpc\RpcLibClient.cpp" />
<ClCompile Include="src\rpc\RpcLibServer.cpp" />
<ClCompile Include="src\safety\SafetyEval.cpp" />
<ClCompile Include="src\controllers\Settings.cpp" />
<ClCompile Include="src\controllers\FileSystem.cpp" />
</ItemGroup>
<ItemGroup>
Expand Down
3 changes: 0 additions & 3 deletions AirLib/AirLib.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,6 @@
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\controllers\Settings.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\safety\ObstacleMap.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down
25 changes: 16 additions & 9 deletions AirLib/include/controllers/Settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,21 @@ namespace msr {
class Settings
{
private:
static Settings settings_;
std::string file_;
nlohmann::json doc_;
bool load_success_ = false;
static std::mutex file_access_;

private:
static std::mutex& getFileAccessMutex()
{
static std::mutex file_access;
return file_access;
}

public:
static Settings& singleton() {
return settings_;
static Settings instance;
return instance;
}

std::string getFileName() { return file_; }
Expand All @@ -35,17 +42,17 @@ namespace msr {

static Settings& loadJSonFile(std::string fileName)
{
std::lock_guard<std::mutex> guard(file_access_);
std::lock_guard<std::mutex> guard(getFileAccessMutex());
std::string path = getFullPath(fileName);
settings_.file_ = fileName;
singleton().file_ = fileName;

settings_.load_success_ = false;
singleton().load_success_ = false;

std::ifstream s;
common_utils::FileSystem::openTextFile(path, s);
if (!s.fail()) {
s >> settings_.doc_;
settings_.load_success_ = true;
s >> singleton().doc_;
singleton().load_success_ = true;
}

return singleton();
Expand All @@ -62,7 +69,7 @@ namespace msr {

void saveJSonFile(std::string fileName)
{
std::lock_guard<std::mutex> guard(file_access_);
std::lock_guard<std::mutex> guard(getFileAccessMutex());
std::string path = getFullPath(fileName);
std::ofstream s;
common_utils::FileSystem::createTextFile(path, s);
Expand Down
16 changes: 0 additions & 16 deletions AirLib/src/controllers/Settings.cpp

This file was deleted.

2 changes: 2 additions & 0 deletions Unreal/Plugins/AirSim/Source/RenderRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ void RenderRequest::ExecuteTask()
FIntPoint size;
auto flags = setupRenderResource(rt_resource, data.get(), size);

//should we be using ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER which was in original commit by @saihv
//https://github.com/Microsoft/AirSim/pull/162/commits/63e80c43812300a8570b04ed42714a3f6949e63f#diff-56b790f9394f7ca1949ddbb320d8456fR64
if (!data->pixels_as_float) {
//below is undocumented method that avoids flushing, but it seems to segfault every 2000 or so calls
RHICmdList.ReadSurfaceData(
Expand Down

0 comments on commit 1adbe54

Please sign in to comment.