Generic priority order queue with no gameplay or entity semantics. 更多...
#include <CommandQueue.h>
Public 成员函数 | |
| eve::Result< std::string > | append (const std::string &kind, int priority=0, double timeoutSeconds=0.0) |
| Appends a command and returns its stable identity or validation failure. | |
| eve::Result< std::string > | replace (const std::string &kind, int priority=0, double timeoutSeconds=0.0) |
| Cancels unfinished commands and starts a replacement. | |
| eve::Result< std::string > | interrupt (const std::string &kind, int priority=0, double timeoutSeconds=0.0) |
| Preempts the active command when priority permits. | |
| eve::Result< void > | complete (const std::string &id) |
| Completes the active command. | |
| eve::Result< void > | fail (const std::string &id, const std::string &reason) |
| Fails the active command. | |
| eve::Result< void > | cancel (const std::string &id, const std::string &reason="cancelled") |
| Cancels an active or queued command. | |
| eve::Result< void > | update (double dtSeconds) |
| Checked simulation update. | |
| void | clear () |
| Resets the queue, retained history, ids, and event sequences. | |
| eve::OptionalRef< Order > | current () |
| Returns the active order, or a null observation when the queue is idle. | |
| eve::OptionalRef< const Order > | current () const |
| Returns the active order as a read-only observation, or null when idle. | |
| eve::OptionalRef< Order > | find (const std::string &id) |
| Returns an order by stable id, including terminal history. | |
| eve::OptionalRef< const Order > | find (const std::string &id) const |
| Returns an order by stable id as a read-only observation. | |
| int | queuedCount () const |
| Returns the number of queued orders, excluding the active order. | |
| int | orderCount () const |
| Returns the total retained order count. | |
| eve::OptionalRef< Order > | orderAt (int index) |
| Returns an order in creation order, or null for an invalid index. | |
| eve::OptionalRef< const Order > | orderAt (int index) const |
| Returns an order in creation order as a read-only observation. | |
| int | eventCount () const |
| Returns the number of retained deterministic events. | |
| eve::OptionalRef< OrderEvent > | eventAt (int index) |
| Returns an event by sequence order, or null for an invalid index. | |
| eve::OptionalRef< const OrderEvent > | eventAt (int index) const |
| Returns a read-only event by sequence order, or null for an invalid index. | |
| void | clearEvents () |
| Clears retained events without resetting their sequence counter. | |
| eve::Result< std::string > | snapshot () const |
| Serializes the complete command queue as deterministic JSON. | |
| eve::Result< void > | restore (std::string_view json) |
| Restores a command queue transactionally from a JSON snapshot. | |
详细描述
Generic priority order queue with no gameplay or entity semantics.
Queued orders are selected by descending priority and then insertion order. The queue owns returned Order pointers; pointers remain valid until clear().
在文件 CommandQueue.h 第 89 行定义.
成员函数说明
◆ append()
| eve::Result< std::string > eve::orders::CommandQueue::append | ( | const std::string & | kind, |
| int | priority = 0, |
||
| double | timeoutSeconds = 0.0 |
||
| ) |
Appends a command and returns its stable identity or validation failure.
在文件 CommandQueue.cpp 第 271 行定义.
引用了 eve::Applied, eve::Diagnostic::error(), eve::Failed, eve::Result< T >::failure(), eve::InvalidArgument, kind, priority, eve::Status::success() , 以及 eve::Result< T >::success().
◆ cancel()
| eve::Result< void > eve::orders::CommandQueue::cancel | ( | const std::string & | id, |
| const std::string & | reason = "cancelled" |
||
| ) |
Cancels an active or queued command.
在文件 CommandQueue.cpp 第 339 行定义.
引用了 eve::Applied, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, eve::NotFound, eve::Status::success() , 以及 eve::Result< T >::success().
◆ clear()
| void eve::orders::CommandQueue::clear | ( | ) |
Resets the queue, retained history, ids, and event sequences.
在文件 CommandQueue.cpp 第 367 行定义.
◆ clearEvents()
| void eve::orders::CommandQueue::clearEvents | ( | ) |
Clears retained events without resetting their sequence counter.
在文件 CommandQueue.cpp 第 420 行定义.
◆ complete()
| eve::Result< void > eve::orders::CommandQueue::complete | ( | const std::string & | id | ) |
Completes the active command.
在文件 CommandQueue.cpp 第 319 行定义.
引用了 eve::Applied, eve::Conflict, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, eve::Status::success() , 以及 eve::Result< T >::success().
◆ current() [1/2]
| eve::OptionalRef< Order > eve::orders::CommandQueue::current | ( | ) |
Returns the active order, or a null observation when the queue is idle.
- 返回
- Borrowed mutable view owned by this queue; nullable when no order is active. @ownership CommandQueue retains ownership and callers must not delete the result. @lifetime Valid until the next mutating queue operation or clear(). @thread Call on the queue's owning simulation thread. @reentrancy The returned object must not be used from a re-entrant callback.
在文件 CommandQueue.cpp 第 376 行定义.
◆ current() [2/2]
| eve::OptionalRef< const Order > eve::orders::CommandQueue::current | ( | ) | const |
Returns the active order as a read-only observation, or null when idle.
- 返回
- Borrowed nullable pointer owned by this queue. @ownership The queue owns the order; callers never release it. @lifetime Valid until the next mutating queue operation or clear(). @thread Call on the queue's owning simulation thread. @reentrancy Do not retain this observation across callbacks or queue mutation.
在文件 CommandQueue.cpp 第 380 行定义.
◆ eventAt() [1/2]
| eve::OptionalRef< OrderEvent > eve::orders::CommandQueue::eventAt | ( | int | index | ) |
Returns an event by sequence order, or null for an invalid index.
- 返回
- Borrowed nullable mutable pointer owned by this queue's event log. @ownership CommandQueue owns retained events; callers must not delete the result. @lifetime Valid until clearEvents(), clear(), or another operation that reallocates the log. @thread Call on the queue's owning simulation thread. @reentrancy Do not retain across event callbacks or queue mutation.
在文件 CommandQueue.cpp 第 410 行定义.
引用了 index.
被这些函数引用 eve::queue_editing::RuntimeQueueInspector::capture().
◆ eventAt() [2/2]
| eve::OptionalRef< const OrderEvent > eve::orders::CommandQueue::eventAt | ( | int | index | ) | const |
Returns a read-only event by sequence order, or null for an invalid index.
在文件 CommandQueue.cpp 第 415 行定义.
引用了 index.
◆ eventCount()
| int eve::orders::CommandQueue::eventCount | ( | ) | const |
Returns the number of retained deterministic events.
在文件 CommandQueue.cpp 第 408 行定义.
被这些函数引用 eve::queue_editing::RuntimeQueueInspector::capture().
◆ fail()
| eve::Result< void > eve::orders::CommandQueue::fail | ( | const std::string & | id, |
| const std::string & | reason | ||
| ) |
Fails the active command.
在文件 CommandQueue.cpp 第 329 行定义.
引用了 eve::Applied, eve::Conflict, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, eve::Status::success() , 以及 eve::Result< T >::success().
◆ find() [1/2]
| eve::OptionalRef< Order > eve::orders::CommandQueue::find | ( | const std::string & | id | ) |
Returns an order by stable id, including terminal history.
- 返回
- Borrowed nullable mutable pointer owned by this queue. @ownership CommandQueue owns every returned order; callers must not delete it. @lifetime Valid until the next mutating queue operation or clear(). @thread Call on the queue's owning simulation thread. @reentrancy Do not use the pointer after a re-entrant queue mutation.
在文件 CommandQueue.cpp 第 384 行定义.
引用了 order.
◆ find() [2/2]
| eve::OptionalRef< const Order > eve::orders::CommandQueue::find | ( | const std::string & | id | ) | const |
Returns an order by stable id as a read-only observation.
- 返回
- Borrowed nullable pointer owned by this queue. @ownership CommandQueue owns the order and retains it as history. @lifetime Valid until the next mutating queue operation or clear(). @thread Call on the queue's owning simulation thread. @reentrancy The observation is not valid across re-entrant mutation.
在文件 CommandQueue.cpp 第 389 行定义.
引用了 order.
◆ interrupt()
| eve::Result< std::string > eve::orders::CommandQueue::interrupt | ( | const std::string & | kind, |
| int | priority = 0, |
||
| double | timeoutSeconds = 0.0 |
||
| ) |
Preempts the active command when priority permits.
在文件 CommandQueue.cpp 第 301 行定义.
引用了 eve::Applied, eve::Conflict, eve::Diagnostic::error(), eve::Failed, eve::Result< T >::failure(), eve::InvalidArgument, kind, priority, eve::Status::success() , 以及 eve::Result< T >::success().
◆ orderAt() [1/2]
| eve::OptionalRef< Order > eve::orders::CommandQueue::orderAt | ( | int | index | ) |
Returns an order in creation order, or null for an invalid index.
- 返回
- Borrowed nullable mutable pointer owned by this queue. @ownership CommandQueue owns the order; callers must not delete it. @lifetime Valid until the next mutating queue operation or clear(). @thread Call on the queue's owning simulation thread. @reentrancy Do not retain across callbacks or queue mutation.
在文件 CommandQueue.cpp 第 398 行定义.
引用了 index.
被这些函数引用 eve::queue_editing::RuntimeQueueInspector::capture().
◆ orderAt() [2/2]
| eve::OptionalRef< const Order > eve::orders::CommandQueue::orderAt | ( | int | index | ) | const |
Returns an order in creation order as a read-only observation.
- 返回
- Borrowed nullable pointer owned by this queue. @ownership CommandQueue retains the order; callers never release it. @lifetime Valid until the next mutating queue operation or clear(). @thread Call on the queue's owning simulation thread. @reentrancy Do not retain across callbacks or queue mutation.
在文件 CommandQueue.cpp 第 403 行定义.
引用了 index.
◆ orderCount()
| int eve::orders::CommandQueue::orderCount | ( | ) | const |
Returns the total retained order count.
在文件 CommandQueue.cpp 第 396 行定义.
被这些函数引用 eve::queue_editing::RuntimeQueueInspector::capture().
◆ queuedCount()
| int eve::orders::CommandQueue::queuedCount | ( | ) | const |
Returns the number of queued orders, excluding the active order.
在文件 CommandQueue.cpp 第 394 行定义.
◆ replace()
| eve::Result< std::string > eve::orders::CommandQueue::replace | ( | const std::string & | kind, |
| int | priority = 0, |
||
| double | timeoutSeconds = 0.0 |
||
| ) |
Cancels unfinished commands and starts a replacement.
在文件 CommandQueue.cpp 第 286 行定义.
引用了 eve::Applied, eve::Diagnostic::error(), eve::Failed, eve::Result< T >::failure(), eve::InvalidArgument, kind, priority, eve::Status::success() , 以及 eve::Result< T >::success().
◆ restore()
| eve::Result< void > eve::orders::CommandQueue::restore | ( | std::string_view | json | ) |
Restores a command queue transactionally from a JSON snapshot.
- 参数
-
json JSON encoded by snapshot().
- 返回
- Success, or a parse/schema/invariant failure. On failure this queue remains unchanged.
在文件 CommandQueue.cpp 第 476 行定义.
引用了 eve::orders::Active, eve::Applied, eve::Diagnostic::error(), eve::Result< T >::failure(), from, eve::orders::OrderEvent::from, eve::Value::fromJson(), eve::Value::getIf(), ids, index, eve::orders::OrderEvent::kind, object, order, eve::orders::OrderEvent::orderId, eve::ParseError, previous, priority, eve::orders::Queued, eve::scheduling::EventMetadata::reason, root, eve::scheduling::EventMetadata::sequence, state, eve::Status::success(), eve::Result< T >::success(), to , 以及 eve::orders::OrderEvent::to.
被这些函数引用 eve::rts::RTSProductionActionAdapter::cancel(), eve::rts::OrderComponent::restore() , 以及 eve::rts::OrderComponent::restoreState().
◆ snapshot()
| eve::Result< std::string > eve::orders::CommandQueue::snapshot | ( | ) | const |
Serializes the complete command queue as deterministic JSON.
- 返回
- A canonical JSON snapshot containing schema/version, every order, queue membership, active order, event history, and both counters.
在文件 CommandQueue.cpp 第 422 行定义.
引用了 eve::Diagnostic::error(), events, eve::Result< T >::failure(), index, order, eve::ParseError, queued, root, eve::orders::stateName(), eve::Result< T >::success() , 以及 eve::Value::toJson().
◆ update()
| eve::Result< void > eve::orders::CommandQueue::update | ( | double | dtSeconds | ) |
Checked simulation update.
- 参数
-
dtSeconds Non-negative simulation delta; zero is a successful no-op.
- 返回
- Applied/NoOp or a validation failure for non-finite/negative time.
在文件 CommandQueue.cpp 第 349 行定义.
引用了 eve::Applied, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, eve::NoOp, eve::Status::success() , 以及 eve::Result< T >::success().
该类的文档由以下文件生成:
- src/modules/orders/CommandQueue.h
- src/modules/orders/CommandQueue.cpp