8 template<
typename DataObject>
20 template<
typename DataObject>
27 template<
typename DataObject>
32 template<
typename DataObject>
40 template<
typename DataObject>
42 if(m_dict.find(
"selected") != m_dict.end()) {
43 m_dict.erase(
"selected");
49 "Returns true if configuration is specified in the input selection"
57 template<
typename DataObject>
60 set_selected(selected_type(selection));
67 template<
typename DataObject>
70 auto new_formatter = datum_formatter_alias<DataObject>(alias_name, alias_command, m_dict);
71 auto key = m_dict.key(new_formatter);
74 if(m_dict.find(key) == m_dict.end()) {
75 m_dict.insert(new_formatter);
78 else if(aliases().
find(alias_name) != aliases().end()) {
79 m_set->err_log() <<
"WARNING: I already know '" << alias_name <<
"' as:\n"
80 <<
" " << _aliases()[alias_name] <<
"\n"
81 <<
" I will forget it and learn '" << alias_name <<
"' as:\n"
82 <<
" " << alias_command << std::endl;
83 m_dict.insert(new_formatter);
88 ss <<
"Error: Attempted to over-write standard CASM query name with user alias.\n";
89 throw std::runtime_error(ss.str());
93 _aliases()[alias_name] = alias_command;
98 template<
typename DataFormatterDictInserter,
typename RuntimeLibInserter>
99 std::pair<DataFormatterDictInserter, RuntimeLibInserter>
102 DataFormatterDictInserter dict_it,
103 RuntimeLibInserter lib_it) {
105 typedef typename DataFormatterDictInserter::container_type dict_type;
106 typedef typename dict_type::DataObject DataObject;
107 typedef typename dict_type::DatumFormatterType formatter_type;
108 typedef formatter_type *formatter_type_ptr;
109 typedef formatter_type_ptr(signature)();
113 if(dir.root_dir().empty()) {
114 return std::make_pair(dict_it, lib_it);
117 if(fs::is_directory(dir.query_plugins<DataObject>())) {
120 for(
auto &entry : boost::make_iterator_range(fs::directory_iterator(dir.query_plugins<DataObject>()), {})) {
123 std::string p_s = p.string();
124 auto p_size = p_s.size();
126 if(fs::is_regular_file(p) && p_s.compare(p_size - 3, p_size,
".cc") == 0) {
129 std::string f_s = f.string();
130 auto f_size = f_s.size();
132 std::string msg =
"compiling new custom query: " + f_s.substr(0, f_size - 3);
135 auto lib_ptr = std::make_shared<RuntimeLibrary>(
136 p_s.substr(0, p_size - 3),
142 auto make_formatter = lib_ptr->template get_function<signature>(
143 "make_" + f_s.substr(0, f_size - 3) +
"_formatter");
145 std::unique_ptr<formatter_type> ptr(make_formatter());
149 *lib_it++ = std::make_pair(ptr->name(), lib_ptr);
154 return std::make_pair(dict_it, lib_it);
DataFormatterDictionary< DataObject > make_dictionary()
Template to can be specialized for constructing dictionaries for particular DataObject.
Specification of CASM project directory structure.
std::string include_path(const fs::path &dir)
std::string so_options() const
Get current shared library options string.
QueryHandler(const ProjectSettings &set)
Read/modify settings of an already existing CASM project.
void set_selected(const typename QueryTraits< DataObject >::Selected &selection)
Set the selection to be used for the 'selected' column.
DataFormatterDictionary< DataObject > m_dict
std::pair< DataFormatterDictInserter, RuntimeLibInserter > load_query_plugins(const ProjectSettings &set, DataFormatterDictInserter dict_it, RuntimeLibInserter lib_it)
Load enumerator plugins from a CASM project.
Iterator find(Iterator begin, Iterator end, const T &value, BinaryCompare q)
Equivalent to std::find(begin, end, value), but with custom comparison.
std::string compile_options() const
Get current compilation options string.
DataFormatterDictionary< DataObject > & dict()
void add_alias(const std::string &alias_name, const std::string &alias_command)
Add user-defined query alias.
std::map< std::string, std::shared_ptr< RuntimeLibrary > > m_lib
const DirectoryStructure & dir() const