2#ifndef DBC_STATEMENT_HANDLER_H
3#define DBC_STATEMENT_HANDLER_H
6#include "dbc_diagnostic.h"
7#include "typefactory.h"
10#include <unordered_map>
36 std::size_t lineNumber,
const std::string &message)
37 : std::runtime_error(filePath +
":" + std::to_string(lineNumber) +
": " + message),
38 diagnostic{DbcDiagnosticSeverity::Error, code, filePath, lineNumber, message} {}
67 void ResolveAttributes(
const std::string &filePath, std::vector<DbcDiagnostic> &diagnostics);
87 static FrameInfo ParseFrameLine(
const std::string &line);
96 static SignalInfo ParseSignalLine(
const std::string &line);
136 template<
class Handler>
139 m_handlers.insert_or_assign(keyword, m_factory.
create(keyword));
146 using HandlerMap = std::unordered_map<std::string, std::shared_ptr<DbcStatementHandler>>;
148 HandlerMap m_handlers;
Defer typed attribute statements for resolution.
void Handle(const std::string &line, DbcParseContext &context) const override
Process a trimmed statement using state belonging to this parse.
DbcDiagnosticError(DbcDiagnosticCode code, const std::string &filePath, std::size_t lineNumber, const std::string &message)
Create an exception with a structured source diagnostic.
Parse and append frame definitions.
void Handle(const std::string &line, DbcParseContext &context) const override
Process a trimmed statement using state belonging to this parse.
void Handle(const std::string &line, DbcParseContext &context) const override
Process a trimmed statement using state belonging to this parse.
Parse and append signals to the current frame.
void Handle(const std::string &line, DbcParseContext &context) const override
Process a trimmed statement using state belonging to this parse.
void RegisterType(const std::string &keyword)
Register or replace a handler and create its reusable instance.
DbcStatementDispatcher()
Register supported statement handlers through TypeFactory.
bool Dispatch(const std::string &line, DbcParseContext &context) const
Interface for processing a registered DBC statement.
virtual void Handle(const std::string &line, DbcParseContext &context) const =0
Process a trimmed statement using state belonging to this parse.
Reject unsupported extended multiplexing statements.
void Handle(const std::string &line, DbcParseContext &context) const override
Process a trimmed statement using state belonging to this parse.
Defer raw value descriptions for target resolution.
void Handle(const std::string &line, DbcParseContext &context) const override
Process a trimmed statement using state belonging to this parse.
Registry-based factory for creating objects by runtime identifier.
BasePtr create(const ClassId &id, Args... args) const
Creates an instance for the given id using provided arguments.
void registerType(const ClassId &id)
Registers a Derived type under the given id.
Parsed DBC database and attribute metadata.
Parsed DBC content stored in a simple internal form.
Diagnostic message and physical source location.
void ResolveAttributes(const std::string &filePath, std::vector< DbcDiagnostic > &diagnostics)
Resolve definitions, defaults, then assignments; append format warnings.
std::vector< PendingComment > pendingComments
void ValidateMultiplexing(const std::string &filePath) const
Validate selectors, branch ranges, and signal overlap.
void ResolveValueDescriptions(const std::string &filePath)
Resolve deferred raw descriptions against unique targets.
std::vector< PendingValueDescriptions > pendingValues
void ResolveComments(const std::string &filePath)
Resolve deferred comments after all definitions are known.
std::vector< std::vector< std::size_t > > signalLines
std::vector< PendingAttribute > pendingAttributes
Describes one CAN frame from a DBC file.
Attribute statement retained for ordered resolution.
Deferred raw value descriptions and their target.
ValueDescriptions descriptions
Describes one signal inside a DBC frame.