DEENESPTFRRUARHIKOZHNL

类 ara::shwa::DeviceSelector

Diese Seite wurde vollständig KI-generiert auf Basis von SWS Safe Hardware Acceleration (R25-11) — kein offizieller AUTOSAR-Text und keine automatisch extrahierte API-Seite wie die übrigen Module. Als Interpretation gekennzeichnete Aussagen sind Schlussfolgerungen aus den Quellen.

[AP_SWS_SHWA_00401] 原文尚未导入 Upstream: RS_SHWA_00006

class DeviceSelector {...};

Die Spezifikation definiert diesen Klassentyp mit der gezeigten Schnittstelle.

Header-Datei#include "ara/shwa/device_selector.h"
Scopenamespace ara::shwa

用户指南人工智能生成

用作基于特定选择策略评估和选择设备的抽象接口。
AI 生成 未审核 模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: 4c64c523c424 来源 未决问题(3)
译自德文指南gemini-3.8-flash-low · 2026-10-13 · 德文原文

用作基于特定选择策略评估和选择设备的抽象接口。

抽象类 ara::shwa::DeviceSelector 定义了一个策略接口,用于在子系统 shwa 中评估和选择目标设备。它允许通过 SelectDevice() 直接确定最佳设备,并通过 operator() 对各个候选设备进行比较评估 [AP_SWS_SHWA_00403]、[AP_SWS_SHWA_00404]。虚默认析构函数保证了派生策略实例的安全销毁。关键约束条件包括调用不是线程安全的,并且在发生故障时不适用自动回滚语义。

上下文

类 ara::shwa::DeviceSelector 在模块 shwa 中提供了一个抽象接口,用于基于特定选择策略选择或评估硬件或功能设备(Device)。它充当上层控制应用程序与具体选择过程之间的解耦层。参与的交互对象包括调用方应用程序、选择策略的具体实现以及 Device 类型的目标对象。该接口定义了两个核心操作:通过 SelectDevice() [AP_SWS_SHWA_00403] 直接选择设备,以及通过函数调用运算符 operator() [AP_SWS_SHWA_00404] 对设备进行比较性单独评估。

DeviceSelectorKontext Anwendung Anwendung DeviceSelector DeviceSelector Anwendung->DeviceSelector 使用 Device Device DeviceSelector->Device selektiert / bewertet

上下文图:DeviceSelector 在应用程序与设备目标之间的嵌入。来源:[AP_SWS_SHWA_00403]、[AP_SWS_SHWA_00404]

生命周期

作为包含纯虚方法的抽象基类,DeviceSelector 无法直接实例化。具体的选择策略应该实现为派生类并由应用程序组件创建。 问题 Q-4e22b2e57ef141e9 (未决)所有权管理通常由应用程序负责,例如通过智能指针如 std::unique_ptr<DeviceSelector>。为了对特化类进行彻底的多态销毁,该接口声明了一个虚默认析构函数 ~DeviceSelector() [AP_SWS_SHWA_00402]。该析构函数显式声明为 noexcept,从而在销毁实例时满足异常安全性(exception safe)要求 [AP_SWS_SHWA_00402]。

在并发性和状态转换方面,接口操作被归类为非线程安全(not thread-safe)[AP_SWS_SHWA_00403]、[AP_SWS_SHWA_00404]。尽管成员函数带有 const 注解,但在没有外部同步的情况下,不得从不同线程对同一实例进行并发访问。此外,规范未对失败的调用规定自动回滚机制(no_rollback_semantics)[AP_SWS_SHWA_00403]、[AP_SWS_SHWA_00404]。

使用路径

典型的使用流程包括初始化具体策略实例,然后对候选设备进行评估或选择。这里存在两条主要调用路径:

  • 直接设备选择:应用程序调用无参数方法 SelectDevice() [AP_SWS_SHWA_00403]。具体策略自主确定最合适的设备并返回 ara::core::Result<Device>。
  • 迭代式单独评估:在用于过滤或排序多个候选设备的算法中,应用程序将各个实例相继传递给 operator()(const Device &device) [AP_SWS_SHWA_00404]。通过 operator() 进行的求值应该在内部分析所传递设备的相关属性或操作状态。 问题 Q-8ba0b9b900196d50 (未决)在 ara::core::Result<int> 中返回的 int 值在此应该反映适用性指标或优先级,调用方据此做出选择决策。
设备评估与选择的调用序列应用DeviceSelectorUse Case: 单个候选设备的评估operator()(device)altErfolgreiche AuswertungResult<int> (Bewertungswert)Ressource belegtShwaErrorCode::kResourceBusyUse Case: 直接设备选择SelectDevice()altErfolgreiche SelektionResult<Device>不支持的功能ShwaErrorCode::kFeatureNotSupported

时序图:用于单独评估和直接选择的调用序列,包括错误处理。来源:[AP_SWS_SHWA_00403]、[AP_SWS_SHWA_00404]

错误场景

两种选择方法均声明为 noexcept,且不抛出 C++ 异常(exception safe)。相反,它们通过 ara::core::Result 的错误通道发出失败信号。应用程序必须始终在访问结果之前检查返回值是否存在错误。为 SelectDevice() 和 operator() 定义了以下错误状态:

  • ShwaErrorCode::kResourceBusy:由于所需资源当前被占用,无法执行请求的操作 [AP_SWS_SHWA_00403]、[AP_SWS_SHWA_00404]。在这种情况下,应用程序可以在稍后时间重试调用或选择替代策略。
  • ShwaErrorCode::kFeatureNotSupported:如果底层实现不支持选择或评估所请求的功能,则返回该错误 [AP_SWS_SHWA_00403]、[AP_SWS_SHWA_00404]。

由于不存在回滚语义(no_rollback_semantics)[AP_SWS_SHWA_00403]、[AP_SWS_SHWA_00404],发生错误时系统将保持在当前状态,调用方负责采取适当的补偿措施。此外,operator() 的先决条件是所传递的设备引用必须在整个调用期间保持有效。

本类指南基于 AUTOSAR Adaptive R25-11 规范(shwa 模块),并经过自动化整理。

成员图

构造函数和析构函数

1

运算符

1

详细视图

请在大纲中选择一个条目。

构造函数和析构函数

Die Spezifikation definiert diese Deklaration mit der in der Signatur ausgewiesenen Semantik.

virtual ~DeviceSelector () noexcept=default;

方法

Bewertet beziehungsweise selektiert ein Device entsprechend der Selektor-Strategie.

virtual ara::core::Result< Device > SelectDevice () const noexcept=0;

运算符

operator() 函数

Bewertet beziehungsweise selektiert ein Device entsprechend der Selektor-Strategie.

virtual ara::core::Result< int > operator() (const Device &device) const noexcept=0;

详细信息

函数 ~DeviceSelector [AP_SWS_SHWA_00402] Upstream: RS_SHWA_00006

virtual ~DeviceSelector () noexcept=default;

Die Spezifikation definiert diese Deklaration mit der in der Signatur ausgewiesenen Semantik.

Scopeclass ara::shwa::DeviceSelector
Exception Safetyexception safe

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/AP_SWS_SHWA_00402
Status
valid/unmigrated
Version
AUTOSAR/AP/record/AP_SWS_SHWA_00402@rel:R25-11#c95904ee
Content hash
c95904ee
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_SafeHardwareAcceleration.pdf#nameddest=AP_SWS_SHWA_00402
Status: valid/unmigrated Version: rel:R25-11#8e9d36b4 Versionshistorie & Revisions (1 transition)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/AP_SWS_SHWA_00402@rel:R25-11#8e9d36b4
Point-in-Time History:
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill

函数 SelectDevice [AP_SWS_SHWA_00403] Upstream: RS_SHWA_00006, RS_SHWA_00007

virtual ara::core::Result< Device > SelectDevice () const noexcept=0;

Bewertet beziehungsweise selektiert ein Device entsprechend der Selektor-Strategie.

Scopeclass ara::shwa::DeviceSelector
Thread Safetynot thread-safe no_rollback_semantics ShwaErrorCode::k ResourceBusy The operation could not be performed because the resource is currently busy no_rollback_semantics
Exception Safetyexception safe
ErrorsShwaErrorCode::k FeatureNotSupported Used when a requested feature isn’t supported

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/AP_SWS_SHWA_00403
Status
valid/unmigrated
Version
AUTOSAR/AP/record/AP_SWS_SHWA_00403@rel:R25-11#b7e62899
Content hash
b7e62899
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_SafeHardwareAcceleration.pdf#nameddest=AP_SWS_SHWA_00403
Status: valid/unmigrated Version: rel:R25-11#83b7e520 Versionshistorie & Revisions (1 transition)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/AP_SWS_SHWA_00403@rel:R25-11#83b7e520
Point-in-Time History:
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill

函数 operator() [AP_SWS_SHWA_00404] Upstream: RS_SHWA_00006, RS_SHWA_00007

virtual ara::core::Result< int > operator() (const Device &device) const noexcept=0;

Bewertet beziehungsweise selektiert ein Device entsprechend der Selektor-Strategie.

Scopeclass ara::shwa::DeviceSelector
Thread Safetynot thread-safe no_rollback_semantics ShwaErrorCode::k ResourceBusy The operation could not be performed because the resource is currently busy no_rollback_semantics
Exception Safetyexception safe
ErrorsShwaErrorCode::k FeatureNotSupported Used when a requested feature isn’t supported

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/AP_SWS_SHWA_00404
Status
valid/unmigrated
Version
AUTOSAR/AP/record/AP_SWS_SHWA_00404@rel:R25-11#4750d07d
Content hash
4750d07d
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_SafeHardwareAcceleration.pdf#nameddest=AP_SWS_SHWA_00404
Status: valid/unmigrated Version: rel:R25-11#2bfa9942 Versionshistorie & Revisions (1 transition)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/AP_SWS_SHWA_00404@rel:R25-11#2bfa9942
Point-in-Time History:
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill