Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ComSwitch Class Reference

#include <main.h>

Collaboration diagram for ComSwitch:

Public Member Functions

 ComSwitch ()
 Default Constructor. More...
 
 ComSwitch (int rArgc, char *rpArgv[])
 Constructor with program arguments. More...
 
 ~ComSwitch ()
 Free memory, and close open file handles. More...
 
bool parseOptions ()
 Parse command options, begin logging. More...
 
void setArguments (int rArgc, char *rpArgv[])
 Set command line arguments. More...
 
bool requiredArgsSet ()
 Check if required arguments are set. More...
 
int getFileDimensions (int rFile)
 Get file dimensions. More...
 
std::vector< adj_mapgetConvFactor (int rFile)
 Get conversion factors. More...
 
std::vector< adj_mapgetNormVal (int rFile)
 Get normalization values. More...
 
bool getVerbosity ()
 Get logging verbosity. More...
 
ifstream & getInputFile (int rFile)
 Get Input File. More...
 
string getFileName (int rFile)
 Get File Name. More...
 
ofstream & getLogFile ()
 Get Log File. More...
 
string getOutPrefix ()
 Get OutPrefix. More...
 
bool isRangeSpecified ()
 Returns a flag that indicates whether a range was supplied to this instance of CommSwitch. More...
 
BoundingBox getRange ()
 Returns a bounding box corresponding to the range of the region of interest. More...
 
std::vector< cmp_mapgetComparisonList ()
 Get Comparison List. More...
 
std::vector< std::vector< int > > getFieldMappings (int rFile)
 Get the field mapping vector for the specified file. More...
 
std::vector< index_ordergetIndexOrder (int rFile)
 Get the index order for the specified file. More...
 

Private Member Functions

void setDefaultVars ()
 Set default member variables. More...
 
bool readOptions ()
 Set option string and long opts struct then parse arguments. More...
 
bool parseValuesFromArguments (string rOptString, const struct option *rLongOpts)
 Read and parse options from array. More...
 
bool initializeFileStreams ()
 Initialize file streams. More...
 
bool writeLogHeader ()
 Write the log file header Program Name - switches Input files. More...
 

Private Attributes

bool mHelp
 Help flag is set from command line options. More...
 
int mArgc
 
char ** mpArgv
 Number of arguments. More...
 
bool mBadSwitch
 The actual command line arguments. More...
 
int mInfile1Dimensions
 Bad command line switch detection. More...
 
int mInfile2Dimensions
 Infile 1 independent variable dimensions. More...
 
bool restrictToRange
 Infile 2 independent variable dimensions. More...
 
BoundingBox mRange
 Flag used to indicate if the metrics will be restricted to a given range. More...
 
std::vector< adj_mapmFile1ConversionFactor
 Range of region of interest. More...
 
std::vector< adj_mapmFile2ConversionFactor
 
std::vector< adj_mapmFile1Norm
 
std::vector< adj_mapmFile2Norm
 
ofstream mLog
 
string mOutPrefix
 
string mInfileName1
 
string mInfileName2
 
ifstream mInfile1
 
ifstream mInfile2
 
std::vector< cmp_mapmComparisonList
 
std::vector< std::vector< int > > mFieldMappingsFile1
 
std::vector< std::vector< int > > mFieldMappingsFile2
 
std::vector< index_ordermIndexOrderFile1
 
std::vector< index_ordermIndexOrderFile2
 
bool mLoud
 

Detailed Description

Definition at line 32 of file main.h.

Constructor & Destructor Documentation

ComSwitch ( )

Default Constructor.

Definition at line 348 of file main.cpp.

References setDefaultVars().

348  {
349 
350  //Set default values
351  setDefaultVars();
352 }
void setDefaultVars()
Set default member variables.
Definition: main.cpp:373

Here is the call graph for this function:

ComSwitch ( int  rArgc,
char *  rpArgv[] 
)

Constructor with program arguments.

Parameters
rArgcNumber of arguments
rpArgvActual arguments

Definition at line 354 of file main.cpp.

References setArguments(), and setDefaultVars().

354  {
355 
356  //Set default values
357  setDefaultVars();
358 
359  setArguments(argc, argv);
360 }
void setArguments(int rArgc, char *rpArgv[])
Set command line arguments.
Definition: main.cpp:365
void setDefaultVars()
Set default member variables.
Definition: main.cpp:373

Here is the call graph for this function:

~ComSwitch ( )

Free memory, and close open file handles.

Definition at line 428 of file main.cpp.

References mInfile1, mInfile2, and mLog.

428  {
429 
430  //Close files
431  mLog.close();
432  mInfile1.close();
433  mInfile2.close();
434 }
ifstream mInfile1
Definition: main.h:234
ofstream mLog
Definition: main.h:228
ifstream mInfile2
Definition: main.h:235

Member Function Documentation

std::vector< cmp_map > getComparisonList ( )

Get Comparison List.

Returns
Vector comparison list

Definition at line 550 of file main.cpp.

References mComparisonList.

Referenced by compareFiles().

550  {
551  return mComparisonList;
552 }
std::vector< cmp_map > mComparisonList
Definition: main.h:237

Here is the caller graph for this function:

std::vector< adj_map > getConvFactor ( int  rFile)

Get conversion factors.

Parameters
rFileFile number (1 or 2)
Returns
Vector of conversion factors for the file

Definition at line 474 of file main.cpp.

References mFile1ConversionFactor, and mFile2ConversionFactor.

Referenced by openAndParseFiles().

474  {
475  if(file == 1){
476  return mFile1ConversionFactor;
477  }
478  else if(file == 2){
479  return mFile2ConversionFactor;
480  }
481 
482  std::vector<adj_map> ret;
483  return ret;
484 }
std::vector< adj_map > mFile2ConversionFactor
Definition: main.h:223
std::vector< adj_map > mFile1ConversionFactor
Range of region of interest.
Definition: main.h:222

Here is the caller graph for this function:

std::vector< std::vector< int > > getFieldMappings ( int  rFile)

Get the field mapping vector for the specified file.

Parameters
rFileFile number (1 or 2)
Returns
Field mapping vector

Definition at line 557 of file main.cpp.

References empty(), mFieldMappingsFile1, and mFieldMappingsFile2.

Referenced by openAndParseFiles().

557  {
558  switch( rFile ){
559 
560  case 1 :
561  return mFieldMappingsFile1;
562  break;
563 
564  case 2 :
565  return mFieldMappingsFile2;
566  break;
567 
568  default :
569  std::vector< std::vector<int> > empty;
570  return empty;
571  }
572 }
boolean empty(T_VertexSet s)
std::vector< std::vector< int > > mFieldMappingsFile1
Definition: main.h:239
std::vector< std::vector< int > > mFieldMappingsFile2
Definition: main.h:240

Here is the call graph for this function:

Here is the caller graph for this function:

int getFileDimensions ( int  rFile)

Get file dimensions.

Parameters
rFileFile number (1 or 2)
Returns
Number of independent dimensions

Definition at line 462 of file main.cpp.

References mInfile1Dimensions, and mInfile2Dimensions.

Referenced by openAndParseFiles().

462  {
463  if(file == 1)
464  return mInfile1Dimensions;
465  else if(file == 2)
466  return mInfile2Dimensions;
467  else
468  return -1;
469 }
int mInfile2Dimensions
Infile 1 independent variable dimensions.
Definition: main.h:217
int mInfile1Dimensions
Bad command line switch detection.
Definition: main.h:216

Here is the caller graph for this function:

string getFileName ( int  rFile)

Get File Name.

Parameters
rFileFile number (1 or 2)
Returns
File name

Definition at line 523 of file main.cpp.

References mInfileName1, and mInfileName2.

Referenced by openAndParseFiles().

523  {
524  string ret("");
525  if(rFile == 1)
526  ret = mInfileName1;
527  else if(rFile == 2)
528  ret = mInfileName2;
529 
530  return ret;
531 }
string mInfileName1
Definition: main.h:231
string mInfileName2
Definition: main.h:232

Here is the caller graph for this function:

std::vector< index_order > getIndexOrder ( int  rFile)

Get the index order for the specified file.

Parameters
rFileFile number (1 or 2)
Returns
Index order vector

Definition at line 577 of file main.cpp.

References empty(), mIndexOrderFile1, and mIndexOrderFile2.

Referenced by openAndParseFiles().

577  {
578  switch( rFile ){
579 
580  case 1 :
581  return mIndexOrderFile1;
582  break;
583 
584  case 2 :
585  return mIndexOrderFile2;
586  break;
587 
588  default :
589  std::vector<index_order> empty;
590  return empty;
591  }
592 }
boolean empty(T_VertexSet s)
std::vector< index_order > mIndexOrderFile2
Definition: main.h:243
std::vector< index_order > mIndexOrderFile1
Definition: main.h:242

Here is the call graph for this function:

Here is the caller graph for this function:

ifstream & getInputFile ( int  rFile)

Get Input File.

Parameters
rFileFile number (1 or 2)
Returns
Reference to ifstream

Definition at line 511 of file main.cpp.

References mInfile1, and mInfile2.

Referenced by openAndParseFiles().

511  {
512 
513  if(rFile == 1)
514  return mInfile1;
515  else
516  return mInfile2;
517 
518 }
ifstream mInfile1
Definition: main.h:234
ifstream mInfile2
Definition: main.h:235

Here is the caller graph for this function:

ofstream & getLogFile ( )

Get Log File.

Returns
Reference to ofstream logfile

Definition at line 536 of file main.cpp.

References mLog.

Referenced by compareFiles(), and openAndParseFiles().

536  {
537  return mLog;
538 }
ofstream mLog
Definition: main.h:228

Here is the caller graph for this function:

std::vector< adj_map > getNormVal ( int  rFile)

Get normalization values.

Parameters
rFileFile number (1 or 2)
Returns
Vector of normalization values for the file

Definition at line 489 of file main.cpp.

References mFile1Norm, and mFile2Norm.

Referenced by openAndParseFiles().

489  {
490  if(file == 1){
491  return mFile1Norm;
492  }
493  else if(file == 2){
494  return mFile2Norm;
495  }
496 
497  std::vector<adj_map> ret;
498  return ret;
499 }
std::vector< adj_map > mFile1Norm
Definition: main.h:225
std::vector< adj_map > mFile2Norm
Definition: main.h:226

Here is the caller graph for this function:

string getOutPrefix ( )

Get OutPrefix.

Returns
OutPrefix string

Definition at line 543 of file main.cpp.

References mOutPrefix.

Referenced by compareFiles().

543  {
544  return mOutPrefix;
545 }
string mOutPrefix
Definition: main.h:229

Here is the caller graph for this function:

BoundingBox getRange ( )
inline

Returns a bounding box corresponding to the range of the region of interest.

Returns
b a bounding box instance.
See Also
BoundingBox

Definition at line 144 of file main.h.

Referenced by compareFiles().

145  {
146  return this ->mRange;
147  }

Here is the caller graph for this function:

bool getVerbosity ( )

Get logging verbosity.

Returns
True if logging is verbose, otherwise false

Definition at line 504 of file main.cpp.

References mLoud.

Referenced by compareFiles(), and openAndParseFiles().

504  {
505  return mLoud;
506 }
bool mLoud
Definition: main.h:245

Here is the caller graph for this function:

bool initializeFileStreams ( )
private

Initialize file streams.

Returns
True on successful initialization false on failure

Definition at line 922 of file main.cpp.

References mInfile1, mInfile2, mInfileName1, mInfileName2, mLog, mOutPrefix, and printUsage().

Referenced by parseOptions().

922  {
923 
924  //Intialize Log File
925  if(mOutPrefix.compare("") != 0){
926  mLog.open((mOutPrefix + ".log").c_str(), ofstream::out);
927 
928  if(!mLog.is_open()){
929  string err_ps("Invalid Output File Prefix Specified: Directory may not exist");
930  printUsage(err_ps);
931 
932  return false;
933  }
934  }
935 
936  //Initialize Input File 1
937  if(mInfileName1.compare("") != 0){
938  mInfile1.open(mInfileName1.c_str(), ifstream::in);
939 
940  if(!mInfile1.is_open()){
941  string err_ps("Could Not Open Input File 1: ");
942  err_ps += mInfileName1;
943  printUsage(err_ps);
944 
945  return false;
946  }
947  }
948 
949  //Initialize Input File 2
950  if(mInfileName2.compare("") != 0){
951  mInfile2.open(mInfileName2.c_str(), ifstream::in);
952 
953  if(!mInfile2.is_open()){
954  string err_ps("Could Not Open Input File 2: ");
955  err_ps += mInfileName2;
956  printUsage(err_ps);
957 
958  return false;
959  }
960  }
961 
962  return true;
963 
964 }
string mInfileName1
Definition: main.h:231
ifstream mInfile1
Definition: main.h:234
void printUsage(const char *why)
Definition: makeflo.cpp:68
ofstream mLog
Definition: main.h:228
string mOutPrefix
Definition: main.h:229
string mInfileName2
Definition: main.h:232
ifstream mInfile2
Definition: main.h:235

Here is the call graph for this function:

Here is the caller graph for this function:

bool isRangeSpecified ( )
inline

Returns a flag that indicates whether a range was supplied to this instance of CommSwitch.

Returns

Definition at line 133 of file main.h.

Referenced by compareFiles().

134  {
135  return this ->restrictToRange;
136  };

Here is the caller graph for this function:

bool parseOptions ( )

Parse command options, begin logging.

Returns
True if options were successfully parsed

Definition at line 395 of file main.cpp.

References initializeFileStreams(), mBadSwitch, mHelp, printUsage(), readOptions(), requiredArgsSet(), and writeLogHeader().

Referenced by main().

395  {
396 
397  //Parse Arguments
398  readOptions();
399 
400  if( mHelp ){
401  printUsage(string(""));
402  exit(0);
403  }
404 
405  if( mBadSwitch ){
406  printUsage(string(""));
407  exit(1);
408  }
409 
410  if( !initializeFileStreams() )
411  exit(1);
412 
413  //Check completeness
414  if(requiredArgsSet()){
415  writeLogHeader();
416  }
417  else{
418  string err_ps("Missing Arguments");
419  printUsage(err_ps);
420 
421  exit(1);
422  }
423 
424  return true;
425 
426 }
void printUsage(const char *why)
Definition: makeflo.cpp:68
bool writeLogHeader()
Write the log file header Program Name - switches Input files.
Definition: main.cpp:969
bool requiredArgsSet()
Check if required arguments are set.
Definition: main.cpp:436
bool mHelp
Help flag is set from command line options.
Definition: main.h:211
bool readOptions()
Set option string and long opts struct then parse arguments.
Definition: main.cpp:597
bool mBadSwitch
The actual command line arguments.
Definition: main.h:215
bool initializeFileStreams()
Initialize file streams.
Definition: main.cpp:922

Here is the call graph for this function:

Here is the caller graph for this function:

bool parseValuesFromArguments ( string  rOptString,
const struct option *  rLongOpts 
)
private

Read and parse options from array.

Parameters
rOptStringShort options string
rLongOptsLong options struct
Returns
True if options were successfully parsed

Definition at line 624 of file main.cpp.

References cimg_library::cimg::atof(), check_non_numeric_str(), CGAL::compare(), adj_map::factor, cmp_map::file1_partitions, cmp_map::file2_partition, mArgc, mBadSwitch, mComparisonList, cmp_map::metric, mFieldMappingsFile1, mFieldMappingsFile2, mFile1ConversionFactor, mFile1Norm, mFile2ConversionFactor, mFile2Norm, mHelp, mIndexOrderFile1, mIndexOrderFile2, mInfile1Dimensions, mInfile2Dimensions, mInfileName1, mInfileName2, mLoud, mOutPrefix, mpArgv, mRange, index_order::order, index_order::partition_number, restrictToRange, BoundingBox::setCoordinates(), str_tokenize(), cmp_map::var1, cmp_map::var2, and adj_map::variable.

Referenced by readOptions().

625  {
626 
627 
628  //Parse options
629  int opt = 0;
630  opt = getopt_long( mArgc, mpArgv, rOptString.c_str(), rLongOpts, NULL );
631 
632  while( opt != -1 ){
633  switch( opt ){
634 
635  //Outfile
636  case 'o': {
637  mOutPrefix = optarg;
638  } break;
639 
640  //File 1
641  case '1': {
642  std::vector<string> infile_info = str_tokenize(string(optarg), string(":"));
643 
644  if(infile_info.size() != 2)
645  break;
646 
647  if( check_non_numeric_str( infile_info[1] ) )
648  break;
649 
650  mInfileName1 = infile_info[0];
651  mInfile1Dimensions = atoi(infile_info[1].c_str());
652  } break;
653 
654  //File 2
655  case '2': {
656  std::vector<string> infile_info = str_tokenize(string(optarg), string(":"));
657 
658  if(infile_info.size() != 2)
659  break;
660 
661  if( check_non_numeric_str( infile_info[1] ) )
662  break;
663 
664  mInfileName2 = infile_info[0];
665  mInfile2Dimensions = atoi(infile_info[1].c_str());
666  } break;
667 
668  //Field mapping
669  case 'f': {
670  std::vector<string> field_map = str_tokenize(string(optarg), string(":/"));
671 
672  if(field_map.size() != 3)
673  break;
674 
675  //Make sure we only have numerals or "null"
676  if( check_non_numeric_str( field_map[0] ) ||
677  check_non_numeric_str( field_map[1] ) ){
678 
679  if(check_non_numeric_str( field_map[2] ) &&
680  field_map[2].compare("null") != 0 ){
681  break;
682  }
683  }
684 
685  //Pack entry
686  vector<int> entry;
687  entry.push_back( atoi(field_map[1].c_str()) );
688 
689  if(field_map[2].compare("null") != 0)
690  entry.push_back( atoi(field_map[2].c_str()) );
691  else
692  entry.push_back( -1 );
693 
694  //Add entry to list of mappings
695  switch( atoi(field_map[0].c_str()) ){
696 
697  case 1:
698  mFieldMappingsFile1.push_back(entry);
699  break;
700 
701  case 2:
702  mFieldMappingsFile2.push_back(entry);
703  break;
704 
705  default:
706  break;
707 
708  }
709 
710  } break;
711 
712  //Index order
713  case 'i': {
714  std::vector<string> order = str_tokenize(string(optarg), string(":,"));
715  std::vector<int> order_int;
716 
717  if(order.size() <= 0)
718  break;
719 
720  //Get the file number
721  int file_num = 0;
722  if(!check_non_numeric_str(order[0])){
723  file_num = atoi(order[0].c_str());
724 
725  if(file_num != 1 && file_num != 2){
726  break;
727  }
728  }
729 
730  //Get the partition number
731  int partition_num = -1;
732  if(!check_non_numeric_str(order[1])){
733  partition_num = atoi(order[1].c_str());
734  if(partition_num < 0)
735  break;
736  }
737 
738  bool non_numeric = false;
739 
740  //Loop through remaining values
741  for(int token_num = 2; token_num < order.size(); token_num++){
742 
743  if(!check_non_numeric_str(order[token_num])){
744 
745  //Convert to int
746  int value = atoi(order[token_num].c_str());
747 
748  //Check for repeats
749  bool repeat = false;
750  for(int prev_num = 0; prev_num < order_int.size(); prev_num++){
751  if(value == order_int[prev_num]){
752  repeat = true;
753  break;
754  }
755  }
756 
757  //Add value to the list
758  if(!repeat)
759  order_int.push_back(value);
760  }
761  else{
762  non_numeric = true;
763  break;
764  }
765  }
766 
767  //Discard all values if any are non-numeric
768  if(non_numeric)
769  break;
770 
771  index_order curr_index;
772  curr_index.order = order_int;
773  curr_index.partition_number = partition_num;
774 
775  if(file_num == 1)
776  mIndexOrderFile1.push_back(curr_index);
777  else if(file_num == 2)
778  mIndexOrderFile2.push_back(curr_index);
779 
780  } break;
781 
782  //Conversion factor
783  case 'c': {
784  std::vector<string> conv_info = str_tokenize(string(optarg), string(":"));
785 
786  if(conv_info.size() != 3)
787  break;
788 
789  adj_map add;
790  add.variable = atoi(conv_info[1].c_str());
791  add.factor = strtold(conv_info[2].c_str(), NULL);
792 
793  int file = atoi(conv_info[0].c_str());
794 
795  if(file == 1)
796  mFile1ConversionFactor.push_back(add);
797  else if(file == 2)
798  mFile2ConversionFactor.push_back(add);
799 
800  } break;
801 
802  // Range used for cropping
803  case 'r': {
804 
805  // Set the flag to indicate that matrics are going to be restricted to the user-supplied range.
806  restrictToRange = true;
807 
808  std::vector< std::string > conv_info = str_tokenize( std::string( optarg ), std::string( "," ) );
809 
810  //
811  // The expected parameters are of the form "xmin,ymin,zmin,xmax,ymax,zmax"
812  //
813  if( conv_info.size( ) != 6 )
814  break;
815 
816  double xmin = std::atof( conv_info[ 0 ].c_str( ) );
817  double ymin = std::atof( conv_info[ 1 ].c_str( ) );
818  double zmin = std::atof( conv_info[ 2 ].c_str( ) );
819  double xmax = std::atof( conv_info[ 3 ].c_str( ) );
820  double ymax = std::atof( conv_info[ 4 ].c_str( ) );
821  double zmax = std::atof( conv_info[ 5 ].c_str( ) );
822 
823  mRange.setCoordinates( xmin, ymin, zmin, xmax, ymax, zmax );
824 
825  }
826 
827  //Normalization factor
828  case 'n': {
829  std::vector<string> norm_info = str_tokenize(string(optarg), string(":"));
830 
831  if(norm_info.size() != 3)
832  break;
833 
834  adj_map add;
835  add.variable = atoi(norm_info[1].c_str());
836  add.factor = strtold(norm_info[2].c_str(), NULL);
837 
838  int file = atoi(norm_info[0].c_str());
839 
840  if(file == 1)
841  mFile1Norm.push_back(add);
842  else if(file == 2)
843  mFile2Norm.push_back(add);
844  } break;
845 
846  //Comparison
847  case 'm': {
848  std::vector<string> comp = str_tokenize(string(optarg), string("=:/"));
849 
850  if(comp.size() != 5)
851  break;
852 
853  if( check_non_numeric_str( comp[0] ) ||
854  check_non_numeric_str( comp[2] ) ||
855  check_non_numeric_str( comp[3] ) ||
856  check_non_numeric_str( comp[4] ) ){
857 
858  break;
859  }
860 
861  bool bad_entry = false;
862 
863  //Get file 1's partition list
864  std::vector<string> partitions_1 = str_tokenize(string(comp[1]), string(","));
865  std::vector<int> partitions_1_int;
866 
867  for(int token_num = 0; token_num < partitions_1.size(); token_num++){
868 
869  if(check_non_numeric_str( partitions_1[token_num] )){
870  bad_entry = true;
871  break;
872  }
873 
874  partitions_1_int.push_back( atoi(partitions_1[token_num].c_str()) );
875  }
876 
877  if(bad_entry)
878  break;
879 
880  cmp_map add_cmp;
881  add_cmp.metric = atoi(comp[0].c_str());
882  add_cmp.file1_partitions = partitions_1_int;
883  add_cmp.var1 = atoi(comp[2].c_str());
884  add_cmp.file2_partition = atoi(comp[3].c_str());
885  add_cmp.var2 = atoi(comp[4].c_str());
886 
887  mComparisonList.push_back(add_cmp);
888 
889  } break;
890 
891  //Logging Level
892  case 'v': {
893  mLoud = true;
894  } break;
895 
896  //Help message
897  case 'h': {
898  mHelp = true;
899  return false;
900  } break;
901 
902  case 0: {
903  mBadSwitch = true;
904  return false;
905  } break;
906 
907  case '?': {
908  mBadSwitch = true;
909  return false;
910  } break;
911  }
912 
913  opt = getopt_long( mArgc, mpArgv, rOptString.c_str(), rLongOpts, NULL );
914  }
915 
916  return true;
917 }
string mInfileName1
Definition: main.h:231
int variable
Definition: datatypedef.h:32
int mInfile2Dimensions
Infile 1 independent variable dimensions.
Definition: main.h:217
std::vector< int > file1_partitions
Definition: datatypedef.h:45
bool restrictToRange
Infile 2 independent variable dimensions.
Definition: main.h:219
std::vector< adj_map > mFile1Norm
Definition: main.h:225
int metric
Definition: datatypedef.h:43
std::vector< cmp_map > mComparisonList
Definition: main.h:237
Used to store index order information.
Definition: datatypedef.h:22
int partition_number
Definition: datatypedef.h:24
Used by cmd parser to store comparison information.
Definition: datatypedef.h:41
bool mLoud
Definition: main.h:245
std::vector< index_order > mIndexOrderFile2
Definition: main.h:243
std::vector< int > order
Definition: datatypedef.h:23
int var2
Definition: datatypedef.h:49
BoundingBox mRange
Flag used to indicate if the metrics will be restricted to a given range.
Definition: main.h:220
float atof(const char *const str)
Read a float number from a C-string.
Definition: CImg.h:4905
void setCoordinates(const double x, const double y, const double z, const double X, const double Y, const double Z)
Sets the coordinates of this BoundingBox instance.
bool mHelp
Help flag is set from command line options.
Definition: main.h:211
std::vector< std::vector< int > > mFieldMappingsFile1
Definition: main.h:239
string mOutPrefix
Definition: main.h:229
char ** mpArgv
Number of arguments.
Definition: main.h:214
int mInfile1Dimensions
Bad command line switch detection.
Definition: main.h:216
std::vector< adj_map > mFile2ConversionFactor
Definition: main.h:223
string mInfileName2
Definition: main.h:232
std::vector< std::vector< int > > mFieldMappingsFile2
Definition: main.h:240
long double factor
Definition: datatypedef.h:33
int mArgc
Definition: main.h:213
Used to store adjustment (normalization factor, conversion factor) information.
Definition: datatypedef.h:31
CGAL_KERNEL_INLINE Comparison_result compare(const NT &n1, const NT &n2)
Definition: number_utils.h:143
std::vector< adj_map > mFile1ConversionFactor
Range of region of interest.
Definition: main.h:222
std::vector< string > str_tokenize(string full, string delimiters)
int var1
Definition: datatypedef.h:46
std::vector< index_order > mIndexOrderFile1
Definition: main.h:242
int file2_partition
Definition: datatypedef.h:48
std::vector< adj_map > mFile2Norm
Definition: main.h:226
bool mBadSwitch
The actual command line arguments.
Definition: main.h:215
bool check_non_numeric_str(string test_str)

Here is the call graph for this function:

Here is the caller graph for this function:

bool readOptions ( )
private

Set option string and long opts struct then parse arguments.

Returns
True if options were successfully parsed

Definition at line 597 of file main.cpp.

References cimg_library::cimg::option(), and parseValuesFromArguments().

Referenced by parseOptions().

597  {
598 
599  //Short options
600  string opt_string("o:1:2:f:i:c:n:m:r:vh");
601 
602  //Long options
603  static const struct option long_opts[] = {
604  {"outfile", required_argument, NULL, 'o'},
605  {"infile1", required_argument, NULL, '1'},
606  {"infile2", required_argument, NULL, '2'},
607  {"fieldmap", required_argument, NULL, 'f'},
608  {"index-order", required_argument, NULL, 'i'},
609  {"conv", required_argument, NULL, 'c'},
610  {"norm", required_argument, NULL, 'n'},
611  {"range", required_argument, NULL, 'r'},
612  {"metric", required_argument, NULL, 'm'},
613  {"verbose", no_argument, NULL, 'v'},
614  {"help", no_argument, NULL, 'h'},
615  {NULL, no_argument, NULL, 0 }
616  };
617 
618  return parseValuesFromArguments(opt_string, long_opts);
619 }
const char * option(const char *const name, const int argc, const char *const *const argv, const char *defaut, const char *const usage=0)
Definition: CImg.h:5604
bool parseValuesFromArguments(string rOptString, const struct option *rLongOpts)
Read and parse options from array.
Definition: main.cpp:624

Here is the call graph for this function:

Here is the caller graph for this function:

bool requiredArgsSet ( )

Check if required arguments are set.

Returns
True if all required args are set, otherwise false

Definition at line 436 of file main.cpp.

References mBadSwitch, mComparisonList, mInfile1, mInfile1Dimensions, mInfile2, mInfile2Dimensions, mLog, and mOutPrefix.

Referenced by parseOptions().

436  {
437 
438  if( mOutPrefix.compare("") == 0 )
439  return false;
440 
441  if( !mLog.is_open() )
442  return false;
443 
444  if( !mInfile1.is_open() || !mInfile2.is_open() )
445  return false;
446 
447  if( mComparisonList.size() <= 0 )
448  return false;
449 
450  if( mInfile1Dimensions <= 0 || mInfile2Dimensions <= 0 )
451  return false;
452 
453  if( mBadSwitch )
454  return false;
455 
456  return true;
457 }
int mInfile2Dimensions
Infile 1 independent variable dimensions.
Definition: main.h:217
ifstream mInfile1
Definition: main.h:234
std::vector< cmp_map > mComparisonList
Definition: main.h:237
ofstream mLog
Definition: main.h:228
string mOutPrefix
Definition: main.h:229
int mInfile1Dimensions
Bad command line switch detection.
Definition: main.h:216
ifstream mInfile2
Definition: main.h:235
bool mBadSwitch
The actual command line arguments.
Definition: main.h:215

Here is the caller graph for this function:

void setArguments ( int  rArgc,
char *  rpArgv[] 
)

Set command line arguments.

Parameters
rArgcNumber of arguments
rpArgvActual arguments

Definition at line 365 of file main.cpp.

References mArgc, and mpArgv.

Referenced by ComSwitch(), and main().

365  {
366  mArgc = rArgc;
367  mpArgv = rpArgv;
368 }
char ** mpArgv
Number of arguments.
Definition: main.h:214
int mArgc
Definition: main.h:213

Here is the caller graph for this function:

void setDefaultVars ( )
private

Set default member variables.

Definition at line 373 of file main.cpp.

References mBadSwitch, mHelp, mInfile1Dimensions, mInfile2Dimensions, mLoud, and restrictToRange.

Referenced by ComSwitch().

373  {
374 
375  //Help message flag
376  mHelp = false;
377 
378  //Bad command line switches
379  mBadSwitch = false;
380 
381  //File dimensions
382  mInfile1Dimensions = -1;
383  mInfile2Dimensions = -1;
384 
385  //Log verbosity
386  mLoud = false;
387 
388  // Restrict search
389  restrictToRange = false;
390 }
int mInfile2Dimensions
Infile 1 independent variable dimensions.
Definition: main.h:217
bool restrictToRange
Infile 2 independent variable dimensions.
Definition: main.h:219
bool mLoud
Definition: main.h:245
bool mHelp
Help flag is set from command line options.
Definition: main.h:211
int mInfile1Dimensions
Bad command line switch detection.
Definition: main.h:216
bool mBadSwitch
The actual command line arguments.
Definition: main.h:215

Here is the caller graph for this function:

bool writeLogHeader ( )
private

Write the log file header Program Name - switches Input files.

Definition at line 969 of file main.cpp.

References mArgc, mInfileName1, mInfileName2, mLog, and mpArgv.

Referenced by parseOptions().

969  {
970 
971  //Write the program name to the log file
972  if(mArgc > 0)
973  mLog << mpArgv[0] << endl;
974 
975  mLog << endl;
976 
977  //Write the supplied arguments to the log file
978  mLog << "ARGUMENTS: " << endl;
979 
980  for(int arg_num=0; arg_num < mArgc; arg_num++){
981  mLog << mpArgv[arg_num] << " ";
982  }
983 
984  mLog << endl << endl;
985 
986  //Write input files to log file
987  mLog << "INPUT FILES: " << endl;
988  mLog << mInfileName1;
989  mLog << ", " << mInfileName2 << endl << endl;
990 
991  //Write header for run output
992  mLog << "RUN OUTPUT:" << endl << flush;
993 
994  return false;
995 }
string mInfileName1
Definition: main.h:231
ofstream mLog
Definition: main.h:228
char ** mpArgv
Number of arguments.
Definition: main.h:214
string mInfileName2
Definition: main.h:232
int mArgc
Definition: main.h:213

Here is the caller graph for this function:

Member Data Documentation

int mArgc
private

Definition at line 213 of file main.h.

Referenced by parseValuesFromArguments(), setArguments(), and writeLogHeader().

bool mBadSwitch
private

The actual command line arguments.

Definition at line 215 of file main.h.

Referenced by parseOptions(), parseValuesFromArguments(), requiredArgsSet(), and setDefaultVars().

std::vector<cmp_map> mComparisonList
private

Definition at line 237 of file main.h.

Referenced by getComparisonList(), parseValuesFromArguments(), and requiredArgsSet().

std::vector< std::vector<int> > mFieldMappingsFile1
private

Definition at line 239 of file main.h.

Referenced by getFieldMappings(), and parseValuesFromArguments().

std::vector< std::vector<int> > mFieldMappingsFile2
private

Definition at line 240 of file main.h.

Referenced by getFieldMappings(), and parseValuesFromArguments().

std::vector<adj_map> mFile1ConversionFactor
private

Range of region of interest.

Definition at line 222 of file main.h.

Referenced by getConvFactor(), and parseValuesFromArguments().

std::vector<adj_map> mFile1Norm
private

Definition at line 225 of file main.h.

Referenced by getNormVal(), and parseValuesFromArguments().

std::vector<adj_map> mFile2ConversionFactor
private

Definition at line 223 of file main.h.

Referenced by getConvFactor(), and parseValuesFromArguments().

std::vector<adj_map> mFile2Norm
private

Definition at line 226 of file main.h.

Referenced by getNormVal(), and parseValuesFromArguments().

bool mHelp
private

Help flag is set from command line options.

Definition at line 211 of file main.h.

Referenced by parseOptions(), parseValuesFromArguments(), and setDefaultVars().

std::vector<index_order> mIndexOrderFile1
private

Definition at line 242 of file main.h.

Referenced by getIndexOrder(), and parseValuesFromArguments().

std::vector<index_order> mIndexOrderFile2
private

Definition at line 243 of file main.h.

Referenced by getIndexOrder(), and parseValuesFromArguments().

ifstream mInfile1
private

Definition at line 234 of file main.h.

Referenced by getInputFile(), initializeFileStreams(), requiredArgsSet(), and ~ComSwitch().

int mInfile1Dimensions
private

Bad command line switch detection.

Definition at line 216 of file main.h.

Referenced by getFileDimensions(), parseValuesFromArguments(), requiredArgsSet(), and setDefaultVars().

ifstream mInfile2
private

Definition at line 235 of file main.h.

Referenced by getInputFile(), initializeFileStreams(), requiredArgsSet(), and ~ComSwitch().

int mInfile2Dimensions
private

Infile 1 independent variable dimensions.

Definition at line 217 of file main.h.

Referenced by getFileDimensions(), parseValuesFromArguments(), requiredArgsSet(), and setDefaultVars().

string mInfileName1
private
string mInfileName2
private
ofstream mLog
private
bool mLoud
private

Definition at line 245 of file main.h.

Referenced by getVerbosity(), parseValuesFromArguments(), and setDefaultVars().

string mOutPrefix
private
char** mpArgv
private

Number of arguments.

Definition at line 214 of file main.h.

Referenced by parseValuesFromArguments(), setArguments(), and writeLogHeader().

BoundingBox mRange
private

Flag used to indicate if the metrics will be restricted to a given range.

Definition at line 220 of file main.h.

Referenced by parseValuesFromArguments().

bool restrictToRange
private

Infile 2 independent variable dimensions.

Definition at line 219 of file main.h.

Referenced by parseValuesFromArguments(), and setDefaultVars().


The documentation for this class was generated from the following files: