Skip to content
Snippets Groups Projects
Commit f5f41e77 authored by Matthew McGill's avatar Matthew McGill
Browse files

Interface changes

Former-commit-id: af8d489f959a5fd65773df254be54d6e5d5c74ab
parent d17ac54d
No related branches found
No related tags found
No related merge requests found
#ifndef IR_Files_h
#define IR_Files_h
// TODO: This should really use unordered maps and sets,
// but I was having trouble building with those.
#include <map>
#include <utility>
#include <memory>
#include <iterator>
#include <set>
// If our toolchain use paradigm changes, this class can be extended
// to support adding, removing, writing back, and getting individual file IRs
// in a variant (may require adding more maps).
// *** A toolchain step should NOT delete pointers to any variant, file IR, or file object stored
// in a IRFiles_t object. I have made pointers shared where possible to communicate this. ***
class IRFiles_t
{
public:
IRFiles_t() {};
~IRFiles_t();
// add/remove file IRs (have option to write back to DB upon removal)
// If choosing to write back to DB, may throw a database error exception.
// If the write back fails, the FileIR will not be destroyed.
void AddFileIR(FileIR_t&);
void RemoveFileIR(FileIR_t&, bool);
void RemoveFileIR(File_t&, bool);
// has file IR?
bool HasFileIR(File_t&);
bool HasFileIR(FileIR_t&);
// Add/remove file IRs.
// Adding file IRs also adds the variant the files belong to.
// Removing file IRs also removes the variant the files belong to.
// When removing file IRs, have the option to write back to the DB.
int AddFileIRs(db_id_t variant_id);
int RemoveFileIRs(db_id_t variant_id, bool write_to_DB);
// get a variant
std::shared_ptr<VariantID_t> GetVariant(db_id_t variant_id);
// get file IRs (returns a shared ptr to a set of shared ptrs to file IRs)
std::shared_ptr<std::set<std::shared_ptr<FileIR_t>>> GetFileIRs(db_id_t variant_id);
// get file IR
FileIR_t* GetFileIR(File_t&);
// Write back all variants and file IRs stored in this IRFiles_t object.
int WriteBackAll(void);
private:
// map for speed of finding if a needed file
// has already been read from the DB
std::map<File_t*, std::shared_ptr<FileIR_t>> file_IR_map;
// maps for speed of finding needed file IRs and/or variants
// that have already been read from the DB
std::map<db_id_t, std::shared_ptr<VariantID_t>> variant_map;
std::map<db_id_t, std::shared_ptr<std::set<std::shared_ptr<FileIR_t>>>> file_IRs_map;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment