NDEVR
API Documentation
VehicleDatabase.h
1#pragma once
2#include "DLLInfo.h"
3#include <NDEVR/File.h>
4#include <NDEVR/DBFParser.h>
5#include <NDEVR/Dictionary.h>
6#include <NDEVR/INIInterface.h>
7namespace NDEVR
8{
9 class VehicleDatabase;
14 class VEHICLE_DATABASE_API VehicleRecord
15 {
16 public:
20 VehicleRecord(uint04 index, const VehicleDatabase* database);
23 const String& make() const;
26 const String& model() const;
29 const uint04& year() const;
32 const fltp08& curbWeight() const;
38 File modelFile() const;
39 protected:
42 };
43
47 struct VEHICLE_DATABASE_API VehicleSearchItem : public INIInterface
48 {
54 uint04 start_year = Constant<uint04>::Invalid;
55 uint04 end_year = Constant<uint04>::Invalid;
56
59 VehicleSearchItem(const File& default_file)
60 : INIInterface(default_file)
61 {};
62
65 bool isValid(const VehicleRecord& record) const;
69 uint04 score(const VehicleRecord& record) const;
70 void getINI(INIFactory& factory) override;
71 };
72
76 class VEHICLE_DATABASE_API VehicleDatabase
77 {
78 public:
82
85 void readDatabaseFromFolder(const File& folder);
88 void readSearchTermsFromFolder(const File& folder);
91 void readFromDBF(const File& f);
97 Buffer<uint04> filterModels(const String& make, const String& model, uint04 year) const;
104 bool recordFilterPass(uint04 record_number, const String& make, const String& model, uint04 year) const;
107 uint04 recordCount() const { return vehicle_makes.size(); }
111 VehicleRecord record(uint04 i) const { return VehicleRecord(i, this); }
116 Buffer<String> getMakes(const String& model = String(), uint04 year = Constant<uint04>::Invalid) const;
121 Buffer<String> getModels(const String& make = String(), uint04 year = Constant<uint04>::Invalid) const;
126 Buffer<uint04> getYears(const String& make = String(), const String& model = String()) const;
130 public:
134 static uint04 ParseYear(const File& f);
135 public:
145 };
146}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
Contains methods for easily reading and writing to an INI file including efficient casting,...
Definition INIReader.h:107
INIInterface()
Constructs an INIInterface with no default INI file.
The core String class for the NDEVR API.
Definition String.h:95
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
A database of vehicle specifications (make, model, year, dimensions, weight) loaded from DBF files an...
Buffer< fltp08 > curb_weight
Vehicle curb weights, one per record.
VehicleRecord record(uint04 i) const
Returns a record accessor for the given index.
void readFromDBF(const File &f)
Reads vehicle records from a single DBF file.
Buffer< fltp08 > wheel_base
Vehicle wheel bases, one per record.
Buffer< String > getModels(const String &make=String(), uint04 year=Constant< uint04 >::Invalid) const
Returns all unique models, optionally filtered by make and year.
Buffer< VehicleSearchItem > file_search_terms
Search term mappings for associating records to 3D model files.
Buffer< uint04 > filterModels(const String &make, const String &model, uint04 year) const
Returns indices of records matching the given make, model, and year criteria.
bool recordFilterPass(uint04 record_number, const String &make, const String &model, uint04 year) const
Checks whether a specific record passes the given filter criteria.
static uint04 ParseYear(const File &f)
Parses a year value from a file name.
Buffer< String > vehicle_models
Vehicle model names, one per record.
Buffer< String > getMakes(const String &model=String(), uint04 year=Constant< uint04 >::Invalid) const
Returns all unique makes, optionally filtered by model and year.
VehicleDatabase()
Default constructor.
void readSearchTermsFromFolder(const File &folder)
Reads vehicle-to-model search term mappings from INI files in the given folder.
Buffer< uint04 > getYears(const String &make=String(), const String &model=String()) const
Returns all unique years, optionally filtered by make and model.
Buffer< fltp08 > overall_height
Vehicle overall heights, one per record.
static VehicleDatabase & DefaultDatabase()
Returns the global singleton VehicleDatabase instance.
void readDatabaseFromFolder(const File &folder)
Reads vehicle data and search terms from DBF and INI files in the given folder.
Buffer< fltp08 > overall_length
Vehicle overall lengths, one per record.
Buffer< fltp08 > overall_width
Vehicle overall widths, one per record.
Buffer< uint04 > vehicle_year
Vehicle model years, one per record.
uint04 recordCount() const
Returns the total number of vehicle records.
Buffer< String > vehicle_makes
Vehicle manufacturer names, one per record.
A read-only accessor for a single vehicle record within a VehicleDatabase, providing make,...
const uint04 & year() const
Returns the vehicle model year.
const Vector< 3, fltp08 > dimensions() const
Returns the vehicle overall dimensions (length, width, height).
const fltp08 & curbWeight() const
Returns the vehicle curb weight.
VehicleRecord(uint04 index, const VehicleDatabase *database)
Constructs a record accessor for the given index in a database.
const String & make() const
Returns the vehicle manufacturer name.
const VehicleDatabase *const m_database
The owning database providing field data.
const uint04 m_index
Index of this record within the database buffers.
File modelFile() const
Returns the file path to the associated 3D model.
const String & model() const
Returns the vehicle model name.
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
uint04 score(const VehicleRecord &record) const
Computes a match score for the given record against this search item.
String model_exclude_terms
Keywords to exclude from model matching.
String make_search_terms
Keywords to match against vehicle make (space-separated).
uint04 start_year
Earliest valid year (inclusive), or Invalid for no lower bound.
String make_exclude_terms
Keywords to exclude from make matching.
uint04 end_year
Latest valid year (inclusive), or Invalid for no upper bound.
bool isValid(const VehicleRecord &record) const
Checks whether the given record matches this search item's criteria.
void getINI(INIFactory &factory) override
Populates the given INI factory with the options managed by this interface.
VehicleSearchItem(const File &default_file)
Constructs a search item that reads/writes its INI from the given file.
String model_search_terms
Keywords to match against vehicle model (space-separated).
File model_file
The 3D model file to use for matching vehicles.