Skip to content

Commit 3289f96

Browse files
committed
# Conflicts: # ReaperDAWHub.GUI/Source/ProjectBrowserComponent.cpp # ReaperDAWHub.GUI/Source/ProjectBrowserTabComponent.cpp # ReaperDAWHub.GUI/Source/ProjectEntryListComponent.cpp # ReaperDAWHub.GUI/includes/ProjectBrowserComponent.h # ReaperDAWHub.GUI/includes/ProjectEntryListComponent.h
2 parents 91d1d47 + d9176da commit 3289f96

26 files changed

+570
-101
lines changed
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<ProjectGuid>{58477CDE-78FB-4D72-920B-2C2660D64B9F}</ProjectGuid>
23+
<RootNamespace>ReaperDAWHubGUIController</RootNamespace>
24+
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
25+
</PropertyGroup>
26+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
27+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
28+
<ConfigurationType>StaticLibrary</ConfigurationType>
29+
<UseDebugLibraries>true</UseDebugLibraries>
30+
<PlatformToolset>v140</PlatformToolset>
31+
<CharacterSet>MultiByte</CharacterSet>
32+
</PropertyGroup>
33+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
34+
<ConfigurationType>StaticLibrary</ConfigurationType>
35+
<UseDebugLibraries>false</UseDebugLibraries>
36+
<PlatformToolset>v140</PlatformToolset>
37+
<WholeProgramOptimization>true</WholeProgramOptimization>
38+
<CharacterSet>MultiByte</CharacterSet>
39+
</PropertyGroup>
40+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
41+
<ConfigurationType>Application</ConfigurationType>
42+
<UseDebugLibraries>true</UseDebugLibraries>
43+
<PlatformToolset>v140</PlatformToolset>
44+
<CharacterSet>MultiByte</CharacterSet>
45+
</PropertyGroup>
46+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
47+
<ConfigurationType>Application</ConfigurationType>
48+
<UseDebugLibraries>false</UseDebugLibraries>
49+
<PlatformToolset>v140</PlatformToolset>
50+
<WholeProgramOptimization>true</WholeProgramOptimization>
51+
<CharacterSet>MultiByte</CharacterSet>
52+
</PropertyGroup>
53+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
54+
<ImportGroup Label="ExtensionSettings">
55+
</ImportGroup>
56+
<ImportGroup Label="Shared">
57+
</ImportGroup>
58+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
59+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
60+
<Import Project="..\conanbuildinfo.props" />
61+
</ImportGroup>
62+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
63+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
64+
<Import Project="..\conanbuildinfo.props" />
65+
</ImportGroup>
66+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
67+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68+
<Import Project="..\conanbuildinfo.props" />
69+
</ImportGroup>
70+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
71+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
72+
<Import Project="..\conanbuildinfo.props" />
73+
</ImportGroup>
74+
<PropertyGroup Label="UserMacros" />
75+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
76+
<OutDir>C:\Program Files (x86)\Reaper\Plugins\</OutDir>
77+
</PropertyGroup>
78+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
79+
<OutDir>C:\Program Files (x86)\Reaper\Plugins\</OutDir>
80+
</PropertyGroup>
81+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
82+
<ClCompile>
83+
<WarningLevel>Level3</WarningLevel>
84+
<Optimization>Disabled</Optimization>
85+
<SDLCheck>true</SDLCheck>
86+
<AdditionalIncludeDirectories>..\JuceLibraryCode;..\JuceLibraryCode\modules;.\includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
87+
</ClCompile>
88+
</ItemDefinitionGroup>
89+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
90+
<ClCompile>
91+
<WarningLevel>Level3</WarningLevel>
92+
<Optimization>Disabled</Optimization>
93+
<SDLCheck>true</SDLCheck>
94+
</ClCompile>
95+
</ItemDefinitionGroup>
96+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
97+
<ClCompile>
98+
<WarningLevel>Level3</WarningLevel>
99+
<Optimization>MaxSpeed</Optimization>
100+
<FunctionLevelLinking>true</FunctionLevelLinking>
101+
<IntrinsicFunctions>true</IntrinsicFunctions>
102+
<SDLCheck>true</SDLCheck>
103+
<AdditionalIncludeDirectories>..\JuceLibraryCode;..\JuceLibraryCode\modules;.\includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
104+
</ClCompile>
105+
<Link>
106+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
107+
<OptimizeReferences>true</OptimizeReferences>
108+
</Link>
109+
</ItemDefinitionGroup>
110+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
111+
<ClCompile>
112+
<WarningLevel>Level3</WarningLevel>
113+
<Optimization>MaxSpeed</Optimization>
114+
<FunctionLevelLinking>true</FunctionLevelLinking>
115+
<IntrinsicFunctions>true</IntrinsicFunctions>
116+
<SDLCheck>true</SDLCheck>
117+
</ClCompile>
118+
<Link>
119+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
120+
<OptimizeReferences>true</OptimizeReferences>
121+
</Link>
122+
</ItemDefinitionGroup>
123+
<ItemGroup>
124+
<ClInclude Include="includes\ProjectBrowserWindowController.h" />
125+
<ClInclude Include="includes\ProjectEntryListController.h" />
126+
<ClInclude Include="includes\ProjectsStrategy.h" />
127+
<ClInclude Include="includes\RepeatedPollingProjectsStrategy.h" />
128+
</ItemGroup>
129+
<ItemGroup>
130+
<ClCompile Include="Source\OneTimeGetProjectsStrategy.cpp" />
131+
<ClCompile Include="Source\ProjectBrowserWindowController.cpp" />
132+
<ClCompile Include="Source\ProjectEntryListController.cpp" />
133+
<ClCompile Include="Source\RepeatedPollingProjectsStrategy.cpp" />
134+
</ItemGroup>
135+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
136+
<ImportGroup Label="ExtensionTargets">
137+
</ImportGroup>
138+
</Project>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClInclude Include="includes\ProjectBrowserWindowController.h">
19+
<Filter>Header Files</Filter>
20+
</ClInclude>
21+
<ClInclude Include="includes\ProjectEntryListController.h">
22+
<Filter>Header Files</Filter>
23+
</ClInclude>
24+
<ClInclude Include="includes\ProjectsStrategy.h">
25+
<Filter>Header Files</Filter>
26+
</ClInclude>
27+
<ClInclude Include="includes\RepeatedPollingProjectsStrategy.h">
28+
<Filter>Header Files</Filter>
29+
</ClInclude>
30+
</ItemGroup>
31+
<ItemGroup>
32+
<ClCompile Include="Source\ProjectBrowserWindowController.cpp">
33+
<Filter>Source Files</Filter>
34+
</ClCompile>
35+
<ClCompile Include="Source\ProjectEntryListController.cpp">
36+
<Filter>Source Files</Filter>
37+
</ClCompile>
38+
<ClCompile Include="Source\RepeatedPollingProjectsStrategy.cpp">
39+
<Filter>Source Files</Filter>
40+
</ClCompile>
41+
<ClCompile Include="Source\OneTimeGetProjectsStrategy.cpp">
42+
<Filter>Source Files</Filter>
43+
</ClCompile>
44+
</ItemGroup>
45+
</Project>

ReaperDAWHub.GUI.Controller/Source/OneTimeGetProjectsStrategy.cpp

Whitespace-only changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include "../includes/ProjectBrowserWindowController.h"
2+
3+
void ProjectBrowserWindowController::initProjectsAsync()
4+
{
5+
6+
}
7+
8+
ProjectBrowserWindowController::ProjectBrowserWindowController(ProjectBrowserWindow *wnd)
9+
{
10+
this->wnd = wnd;
11+
}
12+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include "../includes/ProjectEntryListController.h"
2+
#include <string>
3+
#include "../../ReaperDAWHub.Model/includes/Project.h"
4+
#include "RepeatedPollingProjectsStrategy.h"
5+
6+
void ProjectEntryListController::initProjectsFetched(std::vector<Project> projects)
7+
{
8+
for (auto project : projects)
9+
{
10+
ProjectEntryComponent *pec = new ProjectEntryComponent(std::to_string(project.getId()), "222");
11+
component->addListEntry(pec);
12+
component->writeToLog("got projs");
13+
}
14+
}
15+
16+
void ProjectEntryListController::initProjects()
17+
{
18+
strategy->fetchProjects(ProjectLocationsEnum::Remote, ProjectsRepositoryOwnerEnum::Self, this);
19+
}
20+
21+
22+
void ProjectEntryListController::writeToLog(std::string logMessage)
23+
{
24+
component->writeToLog(logMessage);
25+
}
26+
27+
ProjectEntryListController::ProjectEntryListController(ProjectEntryListComponent *owner) {
28+
this->component = owner;
29+
strategy = new RepeatedPollingProjectsStrategy();
30+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include "../includes/RepeatedPollingProjectsStrategy.h"
2+
#include "../../ReaperDAWHub.GUI/includes/ProjectEntryListComponent.h"
3+
#define BOOST_THREAD_PROVIDES_FUTURE
4+
5+
6+
template<typename R>
7+
bool isReady(std::future<R> const& f)
8+
{
9+
Logger::writeToLog("check future");
10+
return f.wait_for(std::chrono::seconds(-1)) == std::future_status::ready;
11+
}
12+
13+
void RepeatedPollingProjectsStrategy::fetchProjects(ProjectLocationsEnum location, ProjectsRepositoryOwnerEnum owner, ProjectEntryListController *owningController)
14+
{
15+
this->owningController = owningController;
16+
requestProjects();
17+
backgroundCheckFuture();
18+
}
19+
20+
void RepeatedPollingProjectsStrategy::requestProjects()
21+
{
22+
owningController->writeToLog("requesting projects");
23+
projectsFuture = std::async(std::launch::async, &ProjectsController::getProjects, &pc);
24+
owningController->writeToLog("requested projects");
25+
}
26+
27+
void RepeatedPollingProjectsStrategy::backgroundCheckFuture()
28+
{
29+
timer = new boost::asio::deadline_timer(io_service, boost::posix_time::seconds(interval_secs));
30+
timer->async_wait(boost::bind(&RepeatedPollingProjectsStrategy::timerTick, this, boost::asio::placeholders::error, timer));
31+
ioSvcFuture = std::async(std::launch::async, static_cast<size_t(boost::asio::io_service::*)()>(&boost::asio::io_service::run), &io_service);
32+
}
33+
34+
void RepeatedPollingProjectsStrategy::timerTick(const boost::system::error_code& /*e*/,
35+
boost::asio::deadline_timer* tmr) {
36+
if (isReady(projectsFuture)) {
37+
projects = projectsFuture.get();
38+
owningController->writeToLog("requested projects");
39+
owningController->initProjectsFetched(projects);
40+
}
41+
else {
42+
tmr->expires_at(tmr->expires_at() + boost::posix_time::seconds(interval_secs));
43+
tmr->async_wait(boost::bind(&RepeatedPollingProjectsStrategy::timerTick, this, boost::asio::placeholders::error, tmr));
44+
}
45+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#pragma once
2+
#include "../../ReaperDAWHub.GUI.Controller/includes/ProjectBrowserWindowController.h"
3+
#include "../../ReaperDAWHub.GUI/includes/ProjectBrowserWindow.h"
4+
5+
class ProjectBrowserWindowController
6+
{
7+
public:
8+
ProjectBrowserWindowController(ProjectBrowserWindow *wnd);
9+
void initProjectsAsync();
10+
11+
private:
12+
ProjectBrowserWindow* wnd;
13+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#pragma once
2+
#include "../../ReaperDAWHub.GUI/includes/ProjectEntryListComponent.h"
3+
#include "../../ReaperDAWHub.Model/includes/Project.h"
4+
#include <vector>
5+
#include "ProjectsStrategy.h"
6+
7+
class ProjectEntryListController
8+
{
9+
public:
10+
ProjectEntryListController(ProjectEntryListComponent *owner);
11+
void initProjects();
12+
void initProjectsFetched(std::vector<Project> projects);
13+
void writeToLog(std::string logMessage);
14+
private:
15+
ProjectEntryListComponent *component;
16+
ProjectsStrategy *strategy;
17+
};
18+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#pragma once
2+
3+
class ProjectEntryListController;
4+
5+
enum ProjectLocationsEnum
6+
{
7+
Local,
8+
Remote
9+
};
10+
11+
enum ProjectsRepositoryOwnerEnum
12+
{
13+
Self,
14+
Friend
15+
};
16+
class ProjectsStrategy
17+
{
18+
public:
19+
virtual void fetchProjects(ProjectLocationsEnum location, ProjectsRepositoryOwnerEnum owner, ProjectEntryListController *owningController) = 0;
20+
protected:
21+
ProjectEntryListController *owningController;
22+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#pragma once
2+
#include "ProjectsStrategy.h"
3+
#include <future>
4+
#include <iostream>
5+
#include <boost/asio.hpp>
6+
#include <boost/bind.hpp>
7+
#include "../ReaperDAWHub.Model/includes/Project.h"
8+
#include "../ReaperDAWHub.Controller/includes/ProjectsController.h"
9+
#include "../ReaperDAWHub.GUI.Controller/includes/ProjectEntryListController.h"
10+
11+
class RepeatedPollingProjectsStrategy : public ProjectsStrategy
12+
{
13+
public:
14+
void fetchProjects(ProjectLocationsEnum location, ProjectsRepositoryOwnerEnum owner, ProjectEntryListController *owningController) override;
15+
private:
16+
void timerTick(const boost::system::error_code& /*e*/,
17+
boost::asio::deadline_timer* tmr);
18+
void requestProjects();
19+
void backgroundCheckFuture();
20+
21+
std::vector<Project> projects;
22+
ProjectsController pc;
23+
std::future<std::vector<Project>> projectsFuture;
24+
std::future<size_t> ioSvcFuture;
25+
int interval_secs = 1;
26+
boost::asio::io_service io_service;
27+
boost::asio::deadline_timer* timer;
28+
ProjectLocationsEnum location;
29+
ProjectsRepositoryOwnerEnum owner;
30+
};

0 commit comments

Comments
 (0)