CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
Handlers.hh
Go to the documentation of this file.
1 #ifndef HANDLERS_HH
2 #define HANDLERS_HH
3 
4 #include <string>
5 #include <vector>
6 #include <boost/program_options.hpp>
8 
9 namespace CASM {
10  namespace Completer {
34  class ArgHandler {
35  public:
36 
38 
40  static ARG_TYPE determine_type(const po::option_description &boost_option);
41 
43  static std::string path();
44 
46  static std::string command();
47 
49  static std::string supercell();
50 
52  static std::string query();
53 
55  static std::string operation();
56 
58  static std::string configname();
59 
61  static std::string coordtype();
62 
63 
65  static void void_to_bash(std::vector<std::string> &arguments);
66 
68  static void path_to_bash(std::vector<std::string> &arguments);
69 
71  static void command_to_bash(std::vector<std::string> &arguments);
72 
74  static void scelname_to_bash(std::vector<std::string> &arguments);
75 
77  static void query_to_bash(std::vector<std::string> &arguments);
78 
80  static void operator_to_bash(std::vector<std::string> &arguments);
81 
82 
83  private:
84 
86  static const std::vector<std::pair<std::string, ARG_TYPE> > m_argument_table;
87 
88  };
89 
99  public:
100 
102  OptionHandlerBase(const std::string &init_option_tag);
103 
105  OptionHandlerBase(const std::string &init_option_tag, const std::string &init_descriptor);
106 
108  po::variables_map &vm();
109 
111  const po::variables_map &vm() const;
112 
114  const po::options_description &desc();
115 
117  const std::string &tag() const;
118 
119 
120  protected:
121 
123  std::string m_tag;
124 
126  po::options_description m_desc;
127 
129  po::variables_map m_vm;
130 
132  virtual void initialize() = 0;
133 
134  //-------------------------------------------------------------------------------------//
135 
137  void add_configlist_suboption(const fs::path &_default = "MASTER");
138 
141 
143  const fs::path &selection_path() const;
144 
145  //----------------------------//
146 
148  void add_configlists_suboption(const fs::path &_default = "MASTER");
149 
151  std::vector<fs::path> m_selection_paths;
152 
154  const std::vector<fs::path> &selection_paths() const;
155 
156  //-------------------------------------------------------------------------------------//
157 
160 
161  //----------------------------//
162 
165 
166  //-------------------------------------------------------------------------------------//
167 
169  void add_help_suboption();
170 
171  //-------------------------------------------------------------------------------------//
172 
175 
177  std::vector<std::string> m_help_opt_vec;
178 
180  const std::vector<std::string> &help_opt_vec() const;
181 
182  //-------------------------------------------------------------------------------------//
183 
186 
188  std::string m_verbosity_str;
189 
191  const std::string &verbosity_str() const;
192 
193  //-------------------------------------------------------------------------------------//
194 
196  void add_input_suboption(bool required = true);
197 
199  std::string m_input_str;
200 
202  std::string input_str() const;
203 
204  //-------------------------------------------------------------------------------------//
205 
207  void add_settings_suboption(bool required = true);
208 
211 
213  const fs::path settings_path() const;
214 
215  //-------------------------------------------------------------------------------------//
216 
218  void add_output_suboption();
219 
222 
224  const fs::path output_path() const;
225 
226  //-------------------------------------------------------------------------------------//
227 
229  void add_gzip_suboption();
230 
233 
235  bool gzip_flag() const;
236 
237  //-------------------------------------------------------------------------------------//
238 
240  void add_scelname_suboption();
241 
243  std::string m_supercell_str;
244 
246  const std::string &supercell_str() const;
247 
248  //----------------------------//
249 
252 
254  std::vector<std::string> m_supercell_strs;
255 
257  const std::vector<std::string> &supercell_strs() const;
258 
259  //-------------------------------------------------------------------------------------//
260 
263 
265  std::string m_config_str;
266 
268  const std::string &config_str() const;
269 
270  //----------------------------//
271 
274 
276  std::vector<std::string> m_config_strs;
277 
279  const std::vector<std::string> &config_strs() const;
280 
281  //-------------------------------------------------------------------------------------//
282 
285 
287  std::string m_coordtype_str;
288 
290  const std::string &coordtype_str() const;
291 
293  COORD_TYPE coordtype_enum() const;
294 
295  //-------------------------------------------------------------------------------------//
296 
297  //Add more general suboption adding routines here//
298  };
299 
305 
306 
307  public:
308 
311 
312  MonteOption();
313 
314  Index condition_index() const;
315 
316  private:
317 
318  void initialize() override;
319 
321  };
322 
323  //*****************************************************************************************************//
324 
329  class RunOption : public OptionHandlerBase {
330 
331  public:
332 
334 
335  RunOption();
336 
337  const std::string &exec_str() const;
338 
339  private:
340 
341  void initialize() override;
342 
343  std::string m_exec_str;
344  };
345 
346  //*****************************************************************************************************//
347 
353 
354  public:
355 
360 
361  QueryOption();
362 
363  const std::vector<std::string> &columns_vec() const;
364 
365  const std::vector<std::string> &new_alias_vec() const;
366 
367  bool json_flag() const;
368 
369  bool verbatim_flag() const;
370 
371  bool no_header_flag() const;
372 
373  private:
374 
375  void initialize() override;
376 
377  std::vector<std::string> m_columns_vec;
378 
379  std::vector<std::string> m_new_alias_vec;
380 
382 
384 
386 
387  };
388 
389  //*****************************************************************************************************//
390 
395  class BsetOption : public OptionHandlerBase {
396 
397  public:
398 
399  BsetOption();
400 
401  private:
402 
403  void initialize() override;
404 
405  };
406 
407  //*****************************************************************************************************//
408 
414 
415  public:
416 
418 
419  const std::string &axis_choice_str() const;
420 
421  private:
422 
423  void initialize() override;
424 
425  std::string m_axis_choice_str;
426 
427  };
428 
429  //*****************************************************************************************************//
430 
435  class RefOption : public OptionHandlerBase {
436 
437  public:
438 
441 
442  RefOption();
443 
444  const std::string &set_str() const;
445 
446  private:
447 
448  void initialize() override;
449 
450  std::string m_set_str;
451 
452  };
453 
454  //*****************************************************************************************************//
455 
461 
462  public:
463 
466 
467  FilesOption();
468 
469  const std::vector<std::string> &calc_vec() const;
470 
471  const std::string &settings_str() const;
472 
473  private:
474 
475  void initialize() override;
476 
477  std::vector<std::string> m_calc_vec;
478 
479  std::string m_settings_str;
480 
481  };
482 
483  //*****************************************************************************************************//
484 
490 
491  public:
492 
493  FormatOption();
494 
495  private:
496 
497  void initialize() override;
498 
499  };
500 
501  //*****************************************************************************************************//
502 
508 
509  public:
510 
511  ImportOption();
512 
513  double vol_tolerance() const;
514 
515  double lattice_weight() const;
516 
517  double min_va_frac() const;
518 
519  double max_va_frac() const;
520 
521  const std::vector<fs::path> &pos_vec() const;
522 
523  const fs::path &batch_path() const;
524 
525 
526  private:
527 
528  void initialize() override;
529 
531 
533 
535 
537 
538  std::vector<fs::path> m_pos_vec;
539 
541 
542  };
543 
544  //*****************************************************************************************************//
545 
550  class InitOption : public OptionHandlerBase {
551 
552  public:
553 
554  InitOption();
555 
556  private:
557 
558  void initialize() override;
559 
560  };
561 
562  //*****************************************************************************************************//
563 
569 
570  public:
571 
573 
574  PerturbOption();
575 
576  const fs::path &cspecs_path() const;
577 
578  private:
579 
580  void initialize() override;
581 
583 
584  };
585 
586  //*****************************************************************************************************//
587 
593 
594  public:
595 
599 
600  SelectOption();
601 
602  const std::vector<std::string> &criteria_vec() const;
603 
604  private:
605 
606  void initialize() override;
607 
608  std::vector<std::string> m_criteria_vec;
609 
610 
611  };
612 
613  //*****************************************************************************************************//
614 
620 
621  public:
622 
623  SettingsOption();
624 
625  const std::string &input_str() const;
626 
627  const std::vector<std::string> &input_vec() const;
628 
629  private:
630 
631  void initialize() override;
632 
633  std::string m_input_str;
634 
635  std::vector<std::string> m_input_vec;
636 
637 
638  };
639 
640  //*****************************************************************************************************//
641 
647 
648  public:
649 
650  StatusOption();
651 
652  private:
653 
654  void initialize() override;
655 
656  };
657 
658  //*****************************************************************************************************//
659 
665 
666  public:
667 
672 
673  SuperOption();
674 
675  const std::vector<fs::path> &transf_mat_paths() const;
676 
677  const fs::path &struct_path() const;
678 
679  const std::string &unit_scel_str() const;
680 
681  Index min_vol() const;
682 
683  double tolerance() const;
684 
685  private:
686 
687  void initialize() override;
688 
689  std::vector<fs::path> m_transf_mat_paths;
690 
692 
693  std::string m_unit_scel_str;
694 
696 
697  double m_tolerance;
698  };
699 
700  //*****************************************************************************************************//
701 
706  class SymOption : public OptionHandlerBase {
707 
708  public:
709 
711 
712  SymOption();
713 
714  private:
715 
716  void initialize() override;
717 
718  };
719 
720  //*****************************************************************************************************//
721 
726  class RmOption : public OptionHandlerBase {
727 
728  public:
729 
733 
734  RmOption();
735 
736  bool force() const;
737 
738  bool dry_run() const;
739 
740  private:
741 
742  void initialize() override;
743 
744  };
745 
746  //*****************************************************************************************************//
747 
753 
754  public:
755 
757 
759 
760  UpdateOption();
761 
762  double vol_tolerance() const;
763 
764  double lattice_weight() const;
765 
766  double min_va_frac() const;
767 
768  double max_va_frac() const;
769 
770  private:
771 
772  void initialize() override;
773 
775 
776  double m_lattice_weight; //TODO: Push to base? Other commands use this
777 
779 
781 
782  };
783 
784  //*****************************************************************************************************//
785 
790  class ViewOption : public OptionHandlerBase {
791 
792  public:
793 
796 
797  ViewOption();
798 
799  private:
800 
801  void initialize() override;
802 
803  };
804 
805  //*****************************************************************************************************//
806 
811  class EnumOption : public OptionHandlerBase {
812 
813  public:
814 
815  EnumOption();
816 
820 
821  const std::vector<std::string> &desc_vec() const {
822  return m_desc_vec;
823  }
824 
825  std::string method() const {
826  return m_method;
827  }
828 
829  int min_volume() const {
830  return m_min_volume;
831  }
832 
833  int max_volume() const {
834  return m_max_volume;
835  }
836 
837  bool all_existing() const {
838  return m_all_existing;
839  }
840 
841  const std::vector<std::string> &filter_strs() const {
842  return m_filter_strs;
843  }
844 
845  private:
846 
847  void initialize() override;
848 
849  std::vector<std::string> m_desc_vec;
850 
851  std::string m_method;
855  std::vector<std::string> m_filter_strs;
856 
857  };
858 
859  //*****************************************************************************************************//
860 
861  }
862 }
863 
864 
865 #endif
const std::string & exec_str() const
Definition: run.cc:25
COORD_TYPE coordtype_enum() const
Return the coordinate type recasted as the CASM defined enum.
Definition: Handlers.cc:220
std::vector< std::string > m_columns_vec
Definition: Handlers.hh:377
void initialize() override
Fill in the options descriptions accordingly.
Definition: import.cc:46
std::string m_input_str
The settings path to go with add_input_suboption()
Definition: Handlers.hh:199
std::vector< std::string > m_calc_vec
Definition: Handlers.hh:477
static void operator_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for OPERATOR.
Definition: Handlers.cc:97
const std::string & coordtype_str() const
Return the coordinate type in the form of a string.
Definition: Handlers.cc:216
std::vector< std::string > m_help_opt_vec
The list of strings to go with add_general_help_suboption()
Definition: Handlers.hh:177
std::vector< std::string > m_new_alias_vec
Definition: Handlers.hh:379
std::string m_supercell_str
The string of the supercell name of add_scelname_suboption()
Definition: Handlers.hh:243
const std::vector< std::string > & input_vec() const
Definition: settings.cc:32
void add_output_suboption()
Add a –output suboption. Expects to allow "STDOUT" to print to screen.
Definition: Handlers.cc:326
void initialize() override
Fill in the options descriptions accordingly.
Definition: status.cc:346
const fs::path & struct_path() const
Definition: super.cc:22
std::vector< std::string > m_config_strs
The list of the supercell names of add_configname_suboption()
Definition: Handlers.hh:276
std::vector< fs::path > m_pos_vec
Definition: Handlers.hh:538
void add_verbosity_suboption()
Add a –verbosity suboption. Default "standard" of "none", "quiet", "standard", "verbose", "debug" or an int 0-100.
Definition: Handlers.cc:289
double lattice_weight() const
Definition: import.cc:23
void add_scelnames_suboption()
Add a –scelnames suboption.
Definition: Handlers.cc:346
virtual void initialize()=0
Fill in the options descriptions accordingly.
bool json_flag() const
Definition: query.cc:67
std::vector< std::string > m_input_vec
Definition: Handlers.hh:635
static std::string configname()
Get value_type string for configuration completion.
Definition: Handlers.cc:59
const std::string & axis_choice_str() const
Definition: composition.cc:58
const std::vector< std::string > & filter_strs() const
Definition: Handlers.hh:841
void initialize() override
Fill in the options descriptions accordingly.
Definition: perturb.cc:15
void initialize() override
Fill in the options descriptions accordingly.
Definition: ref.cc:137
void initialize() override
Fill in the options descriptions accordingly.
Definition: init.cc:15
const std::string & input_str() const
Definition: settings.cc:28
const fs::path settings_path() const
Returns the path corresponding to add_settings_suboption.
Definition: Handlers.cc:180
const std::string & config_str() const
Returns the name of the supercell for add_configname_suboption(), for when multiple=false.
Definition: Handlers.cc:200
void add_help_suboption()
Add a plain –help suboption.
Definition: Handlers.cc:276
void add_settings_suboption(bool required=true)
Add a –settings suboption. Expects a corresponding casm format to go with it.
Definition: Handlers.cc:296
void initialize() override
Fill in the options descriptions accordingly.
Definition: format.cc:13
void add_configname_suboption()
Add a –configname suboption.
Definition: Handlers.cc:354
double tolerance() const
Definition: super.cc:34
std::string m_config_str
The name of a single configname to go with add_configname_suboption()
Definition: Handlers.hh:265
void add_general_help_suboption()
Add a smart –help suboption that takes "properties" or "operators".
Definition: Handlers.cc:283
void add_configlists_nodefault_suboption()
Add –configs suboption (no default)
Definition: Handlers.cc:267
void initialize() override
Fill in the options descriptions accordingly.
Definition: composition.cc:48
std::string method() const
Definition: Handlers.hh:825
const std::vector< fs::path > & pos_vec() const
Definition: import.cc:38
void add_configlist_suboption(const fs::path &_default="MASTER")
Add –config suboption (defaults to MASTER)
Definition: Handlers.cc:238
Main CASM namespace.
Definition: complete.cpp:8
static void query_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for QUERY.
Definition: Handlers.cc:86
double max_va_frac() const
Definition: import.cc:35
fs::path m_selection_path
The selection string to go with add_config_suboption.
Definition: Handlers.hh:140
void initialize() override
Fill in the options descriptions accordingly.
Definition: settings.cc:36
const std::string & verbosity_str() const
Returns the string corresponding to add_verbosity_suboption()
Definition: Handlers.cc:176
void initialize() override
Fill in the options descriptions accordingly.
Definition: enum.cc:15
std::string m_tag
name of the casm command
Definition: Handlers.hh:123
const fs::path & selection_path() const
Returns the string corresponding to add_config_suboption()
Definition: Handlers.cc:168
static std::string path()
Get value_type string for path completion.
Definition: Handlers.cc:39
static std::string supercell()
Get value_type string for supercell completion.
Definition: Handlers.cc:47
void add_input_suboption(bool required=true)
Add a –input suboption. Expects a corresponding casm format to go with it.
Definition: Handlers.cc:311
void add_configlists_suboption(const fs::path &_default="MASTER")
Add –configs suboption (defaults to MASTER)
Definition: Handlers.cc:248
static std::string coordtype()
Get value_type string for coordinate mode completion.
Definition: Handlers.cc:63
static std::string operation()
Get value_type string for operation completion.
Definition: Handlers.cc:55
std::string input_str() const
Returns the path corresponding to add_input_suboption.
Definition: Handlers.cc:184
void add_configlist_nodefault_suboption()
Add –config suboption (no default)
Definition: Handlers.cc:258
const po::options_description & desc()
Get the program options, filled with the initialized values.
Definition: Handlers.cc:160
const std::vector< std::string > & criteria_vec() const
Definition: select.cc:118
po::variables_map m_vm
Boost program options variable map.
Definition: Handlers.hh:129
std::vector< std::string > m_desc_vec
Definition: Handlers.hh:849
static ARG_TYPE determine_type(const po::option_description &boost_option)
Translate the stored boost value_name into an ARG_TYPE for the completer engine.
Definition: Handlers.cc:13
const std::vector< std::string > & help_opt_vec() const
Returns the list of strings corresponding to add_general_help_suboption()
Definition: Handlers.cc:196
double lattice_weight() const
Definition: update.cc:22
static std::string command()
Get value_type string for command completion (i.e. stuff in your $PATH)
Definition: Handlers.cc:43
EigenIndex Index
For long integer indexing:
std::vector< fs::path > m_transf_mat_paths
Definition: Handlers.hh:689
fs::path m_output_path
The path that goes with add_output_suboption.
Definition: Handlers.hh:221
static std::string query()
Get value_type string for query completion.
Definition: Handlers.cc:51
OptionHandlerBase(const std::string &init_option_tag)
Define the name of the command during construction.
Definition: Handlers.cc:128
void initialize() override
Fill in the options descriptions accordingly.
Definition: files.cc:21
static void void_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for VOID (i.e. do nothing) ...
Definition: Handlers.cc:68
Index condition_index() const
Definition: monte.cc:75
std::vector< std::string > m_criteria_vec
Definition: Handlers.hh:608
const std::string & unit_scel_str() const
Definition: super.cc:26
po::options_description m_desc
Boost program options. All the derived classes have them, but will fill them up themselves.
Definition: Handlers.hh:126
void initialize() override
Fill in the options descriptions accordingly.
Definition: bset.cc:18
const std::vector< std::string > & config_strs() const
Returns the names of the supercells for add_configname_suboption(), for when multiple=false.
Definition: Handlers.cc:204
const std::vector< std::string > & desc_vec() const
Definition: Handlers.hh:821
bool gzip_flag() const
Returns the value assigned for add_gzip_suboption()
Definition: Handlers.cc:192
static void path_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for PATH.
Definition: Handlers.cc:72
void add_gzip_suboption()
Add a –gzip suboption. The value will default to false unless overridden by the derived class...
Definition: Handlers.cc:332
const std::string & supercell_str() const
Returns the name of the supercell for add_scelname_suboption()
Definition: Handlers.cc:208
double min_va_frac() const
Definition: import.cc:31
double max_va_frac() const
Definition: update.cc:34
double vol_tolerance() const
Definition: import.cc:27
const fs::path & batch_path() const
Definition: import.cc:42
void add_confignames_suboption()
Add a –confignames suboption.
Definition: Handlers.cc:365
fs::path m_settings_path
The settings path to go with add_settings_suboption()
Definition: Handlers.hh:210
bool all_existing() const
Definition: Handlers.hh:837
void initialize() override
Fill in the options descriptions accordingly.
Definition: sym.cc:15
const std::vector< std::string > & columns_vec() const
Definition: query.cc:59
const std::vector< std::string > & supercell_strs() const
Returns the list of the supercells for add_scelnames_suboption()
Definition: Handlers.cc:212
void initialize() override
Fill in the options descriptions accordingly.
Definition: rm.cc:24
void add_scelname_suboption()
Add a –scelname suboption.
Definition: Handlers.cc:338
bool m_gzip_flag
The bool that goes with add_gzip_suboption.
Definition: Handlers.hh:232
po::variables_map & vm()
Get the variables map.
Definition: Handlers.cc:145
static void scelname_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for SCELNAME TODO: This routine is cu...
void add_coordtype_suboption()
Add a –coord suboption to specify FRAC or CART.
Definition: Handlers.cc:377
void initialize() override
Fill in the options descriptions accordingly.
Definition: update.cc:38
bool no_header_flag() const
Definition: query.cc:75
double vol_tolerance() const
Definition: update.cc:26
const std::string & tag() const
The desired name for the casm option (Perhaps this should get tied with CommandArg?)
Definition: Handlers.cc:140
std::string m_verbosity_str
The verbosity string to go with add_config_suboption.
Definition: Handlers.hh:188
const std::string & settings_str() const
Definition: files.cc:17
static void command_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for COMMAND.
Definition: Handlers.cc:77
std::string m_coordtype_str
The enum value in the form of a string for add_coordtype_suboption(). Only the first letter matters...
Definition: Handlers.hh:287
const std::vector< std::string > & calc_vec() const
Definition: files.cc:13
void initialize() override
Fill in the options descriptions accordingly.
Definition: monte.cc:63
std::vector< std::string > m_supercell_strs
The list of supercell names of add_scelnames_suboption()
Definition: Handlers.hh:254
void initialize() override
Fill in the options descriptions accordingly.
Definition: view.cc:16
const fs::path output_path() const
Returns the path corresponding to add_output_suboption()
Definition: Handlers.cc:188
const std::vector< std::string > & new_alias_vec() const
Definition: query.cc:63
bool dry_run() const
Definition: rm.cc:20
static const std::vector< std::pair< std::string, ARG_TYPE > > m_argument_table
List of pairs relating the value type name of po::option_description to its corresponding argument ty...
Definition: Handlers.hh:86
double min_va_frac() const
Definition: update.cc:30
void initialize() override
Fill in the options descriptions accordingly.
Definition: super.cc:38
void initialize() override
Fill in the options descriptions accordingly.
Definition: query.cc:39
bool force() const
Definition: rm.cc:16
const fs::path & cspecs_path() const
Definition: perturb.cc:11
std::vector< std::string > m_filter_strs
Definition: Handlers.hh:855
void initialize() override
Fill in the options descriptions accordingly.
Definition: select.cc:122
const std::string & set_str() const
Definition: ref.cc:133
const std::vector< fs::path > & transf_mat_paths() const
Definition: super.cc:18
std::vector< fs::path > m_selection_paths
The selection string to go with add_config_suboption.
Definition: Handlers.hh:151
const std::vector< fs::path > & selection_paths() const
Returns the string corresponding to add_config_suboption()
Definition: Handlers.cc:172
void initialize() override
Fill in the options descriptions accordingly.
Definition: run.cc:16
Index min_vol() const
Definition: super.cc:30
bool verbatim_flag() const
Definition: query.cc:71