VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
commandSpecJob.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (c) 2026 MAK Technologies, Inc.
3  * All rights reserved.
4  ******************************************************************************/
5 
6 #pragma once
7 
10 
11 #include <chrono>
12 #include <condition_variable>
13 #include <list>
14 #include <memory>
15 #include <mutex>
16 
17 #include <json/json.h>
18 
20 
30 {
31 public:
32  DtCommandSpecJob() = default;
33  virtual ~DtCommandSpecJob() = default;
34 
35  DtCommandSpecJob(const DtCommandSpecJob&) = delete;
37 
39  bool isComplete() const;
40 
43  bool waitFor(std::chrono::milliseconds timeout);
44 
47  Json::Value result() const;
48 
49 protected:
50  mutable std::mutex myMutex;
51  std::condition_variable myCV;
52  bool myReady = false;
54 };
55 
57 using DtCommandSpecJobHandle = std::shared_ptr<DtCommandSpecJob>;
58 
65 {
66 public:
67  DtCommandSpecJobBuilder(Json::Value initialResult);
68  DtCommandSpecJobBuilder(Json::Value initialResult, std::list<std::unique_ptr<DtCommandSpecParamBuilder>> paramBuilders);
69  DtCommandSpecJobBuilder() = default;
70  virtual ~DtCommandSpecJobBuilder() override = default;
71 
74 
77  void complete();
78 
79  // Checks on status of any paramBuilders, inserts their results into the spec if ready, and completes the job if all builders are done.
80  void update();
81 
82 protected:
83  std::list<std::unique_ptr<DtCommandSpecParamBuilder>> myParamBuilders;
84 };
DtCommandSpecJobBuilder()=default
DtCommandSpecJob & operator=(const DtCommandSpecJob &)=delete
bool myReady
Definition: commandSpecJob.h:52
bool waitFor(std::chrono::milliseconds timeout)
Blocks the calling thread until the job completes or timeout elapses.
Abstract base and immediate concrete implementation for per-parameter command spec builders...
std::shared_ptr< DtCommandSpecJob > DtCommandSpecJobHandle
Shared-ownership handle to a DtCommandSpecJob.
Definition: commandSpecJob.h:57
DtCommandSpecJobBuilder & operator=(const DtCommandSpecJobBuilder &)=delete
std::list< std::unique_ptr< DtCommandSpecParamBuilder > > myParamBuilders
Definition: commandSpecJob.h:83
void complete()
Resolves the job with the completed spec and wakes all waiters. Safe to call from any thread...
Awaitable result handle for an in-progress or completed command spec.
Definition: commandSpecJob.h:29
IMGUI_API void Value(const char *prefix, bool b)
Json::Value myResult
Definition: commandSpecJob.h:53
Extends DtCommandSpecJob with the ability to resolve the job.
Definition: commandSpecJob.h:64
DtCommandSpecJob()=default
std::condition_variable myCV
Definition: commandSpecJob.h:51
virtual ~DtCommandSpecJobBuilder() override=default
std::mutex myMutex
Definition: commandSpecJob.h:50
Json::Value result() const
Returns the resolved command spec JSON object. Only valid after isComplete() returns true...
bool isComplete() const
Returns true if the job has been resolved via DtCommandSpecJobBuilder::complete().
virtual ~DtCommandSpecJob()=default

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)