OpenClonk
C4StartupModsLocalModDiscovery Class Reference

#include <C4StartupModsDlg.h>

Inheritance diagram for C4StartupModsLocalModDiscovery:
[legend]
Collaboration diagram for C4StartupModsLocalModDiscovery:
[legend]

Classes

struct  ModsInfo
 

Public Member Functions

 C4StartupModsLocalModDiscovery (C4StartupModsDlg *parent)
 
bool IsDiscoveryFinished () const
 
void WaitForDiscoveryFinished ()
 
const bool IsModInstalled (const std::string &id)
 
ModsInfo GetModInformation (const std::string &id)
 
void RemoveMod (const std::string &id)
 
ModsInfoAddMod (const std::string &id, const std::string &path, const std::string &name)
 
const std::map< std::string, ModsInfo > & GetAllModInformation ()
 
CStdLock Lock ()
 
bool Start ()
 
void SignalStop ()
 
void Stop ()
 
bool IsStarted ()
 

Protected Member Functions

void Execute () override
 
bool IsStopSignaled ()
 
virtual bool IsSelfDestruct ()
 

Detailed Description

Definition at line 71 of file C4StartupModsDlg.h.


Class Documentation

◆ C4StartupModsLocalModDiscovery::ModsInfo

struct C4StartupModsLocalModDiscovery::ModsInfo

Definition at line 83 of file C4StartupModsDlg.h.

Class Members
string id
string name
string path

Constructor & Destructor Documentation

◆ C4StartupModsLocalModDiscovery()

C4StartupModsLocalModDiscovery::C4StartupModsLocalModDiscovery ( C4StartupModsDlg parent)
inline

Definition at line 76 of file C4StartupModsDlg.h.

76  :
77  discoveryFinishedEvent(true),
78  parent(parent)
79  {
81  }
bool Start()

References StdThread::Start().

Here is the call graph for this function:

Member Function Documentation

◆ AddMod()

ModsInfo& C4StartupModsLocalModDiscovery::AddMod ( const std::string &  id,
const std::string &  path,
const std::string &  name 
)
inline

Definition at line 111 of file C4StartupModsDlg.h.

112  {
113  CStdLock lock(&modInformationModification);
114  modsInformation[id] = ModsInfo{ id, path, name };
115  return modsInformation[id];
116  }

◆ Execute()

void C4StartupModsLocalModDiscovery::Execute ( )
overrideprotectedvirtual

Implements StdThread.

Definition at line 482 of file C4StartupModsDlg.cpp.

483 {
484  assert(!discoveryFinished);
485  discoveryFinishedEvent.Reset();
486 
487  ExecuteDiscovery();
488 
489  discoveryFinished = true;
490  discoveryFinishedEvent.Set();
491 
492  parent->QueueSyncWithDiscovery();
493 
495 }
void Set()
Definition: StdSync.h:158
void Reset()
Definition: StdSync.h:160
void SignalStop()

References C4StartupModsDlg::QueueSyncWithDiscovery(), CStdEvent::Reset(), CStdEvent::Set(), and StdThread::SignalStop().

Here is the call graph for this function:

◆ GetAllModInformation()

const std::map<std::string, ModsInfo>& C4StartupModsLocalModDiscovery::GetAllModInformation ( )
inline

Definition at line 119 of file C4StartupModsDlg.h.

120  {
121  return modsInformation;
122  }

◆ GetModInformation()

ModsInfo C4StartupModsLocalModDiscovery::GetModInformation ( const std::string &  id)
inline

Definition at line 100 of file C4StartupModsDlg.h.

101  {
102  CStdLock lock(&modInformationModification);
103  assert(IsDiscoveryFinished());
104  return modsInformation[id];
105  }

References IsDiscoveryFinished().

Here is the call graph for this function:

◆ IsDiscoveryFinished()

bool C4StartupModsLocalModDiscovery::IsDiscoveryFinished ( ) const
inline

Definition at line 91 of file C4StartupModsDlg.h.

91 { return discoveryFinished; }

Referenced by GetModInformation(), and IsModInstalled().

Here is the caller graph for this function:

◆ IsModInstalled()

const bool C4StartupModsLocalModDiscovery::IsModInstalled ( const std::string &  id)
inline

Definition at line 94 of file C4StartupModsDlg.h.

95  {
96  CStdLock lock(&modInformationModification);
97  assert(IsDiscoveryFinished());
98  return modsInformation.count(id) != 0;
99  }

References IsDiscoveryFinished().

Here is the call graph for this function:

◆ IsSelfDestruct()

virtual bool StdThread::IsSelfDestruct ( )
inlineprotectedvirtualinherited

Reimplemented in CPNGSaveThread.

Definition at line 338 of file StdScheduler.h.

338 { return false; } // whether thread should delete itself after execution finished

◆ IsStarted()

bool StdThread::IsStarted ( )
inlineinherited

Definition at line 332 of file StdScheduler.h.

332 { return fStarted; }

◆ IsStopSignaled()

bool StdThread::IsStopSignaled ( )
protectedinherited

Definition at line 342 of file StdScheduler.cpp.

343 {
344  return fStopSignaled;
345 }

◆ Lock()

CStdLock C4StartupModsLocalModDiscovery::Lock ( )
inline

Definition at line 123 of file C4StartupModsDlg.h.

124  {
125  return std::move(CStdLock(&modInformationModification));
126  }

◆ RemoveMod()

void C4StartupModsLocalModDiscovery::RemoveMod ( const std::string &  id)
inline

Definition at line 106 of file C4StartupModsDlg.h.

107  {
108  CStdLock lock(&modInformationModification);
109  modsInformation.erase(id);
110  }

◆ SignalStop()

void StdThread::SignalStop ( )
inherited

Definition at line 298 of file StdScheduler.cpp.

299 {
300  // Not running?
301  if (!fStarted) return;
302  // Set flag
303  fStopSignaled = true;
304 }

Referenced by CPNGSaveThread::Execute(), Execute(), and C4StartupModsDownloader::ModInfo::LocalDiscoveryCheck::Execute().

Here is the caller graph for this function:

◆ Start()

bool StdThread::Start ( )
inherited

Definition at line 282 of file StdScheduler.cpp.

283 {
284  // already running? stop
285  if (fStarted) Stop();
286  // begin thread
287  fStopSignaled = false;
288 #ifdef HAVE_WINTHREAD
289  iThread = _beginthread(_ThreadFunc, 0, this);
290  fStarted = (iThread != -1);
291 #elif defined(HAVE_PTHREAD)
292  fStarted = !pthread_create(&Thread, nullptr, _ThreadFunc, this);
293 #endif
294  // success?
295  return fStarted;
296 }

References StdThread::Stop().

Referenced by C4StartupModsLocalModDiscovery(), CPNGFile::ScheduleSaving(), and C4StartupModsDownloader::ModInfo::LocalDiscoveryCheck::Start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Stop()

void StdThread::Stop ( )
inherited

Definition at line 306 of file StdScheduler.cpp.

307 {
308  // Not running?
309  if (!fStarted) return;
310  // Set flag
311  fStopSignaled = true;
312 #ifdef HAVE_WINTHREAD
313  // Wait for thread to terminate itself
314  HANDLE hThread = reinterpret_cast<HANDLE>(iThread);
315  if (WaitForSingleObject(hThread, 10000) == WAIT_TIMEOUT)
316  // ... or kill it in case it refuses to do so
317  TerminateThread(hThread, -1);
318 #elif defined(HAVE_PTHREAD)
319  // wait for thread to terminate itself
320  // (whithout security - let's trust these unwashed hackers for once)
321  pthread_join(Thread, nullptr);
322 #endif
323  fStarted = false;
324  // ok
325  return;
326 }

Referenced by StdThread::Start(), and StdThread::~StdThread().

Here is the caller graph for this function:

◆ WaitForDiscoveryFinished()

void C4StartupModsLocalModDiscovery::WaitForDiscoveryFinished ( )
inline

Definition at line 92 of file C4StartupModsDlg.h.

92 { discoveryFinishedEvent.WaitFor(-1); }
bool WaitFor(int)
Definition: StdSync.h:161

References CStdEvent::WaitFor().

Here is the call graph for this function:

The documentation for this class was generated from the following files: