24 #include "man-database.h" 
   25 #include "man-pipeline.h" 
   30 static void DatabaseBuild(
const DatabaseOptions &values) {
 
   32     std::cerr << 
"Narrowed catalog has " << narrowedCatalog.size() << 
" stars." << std::endl;
 
   44     std::cerr << 
"Generated database with " << ser.buffer.size() << 
" bytes" << std::endl;
 
   45     std::cerr << 
"Database flagged with " << std::bitset<8*sizeof(dbFlags)>(dbFlags) << std::endl;
 
   47     UserSpecifiedOutputStream pos = UserSpecifiedOutputStream(values.outputPath, 
true);
 
   48     pos.Stream().write((
char *) ser.buffer.data(), ser.buffer.size());
 
   53 static void PipelineRun(
const PipelineOptions &values) {
 
   56     std::vector<PipelineOutput> outputs = pipeline.Go(input);
 
  108     std::string str(cstr);
 
  109     if (str == 
"1" || str == 
"true") {
 
  112     if (str == 
"0" || str == 
"false") {
 
  122 #define LOST_OPTIONAL_OPTARG()                                   \ 
  123     ((optarg == NULL && optind < argc && argv[optind][0] != '-') \ 
  124      ? (bool) (optarg = argv[optind++])                          \ 
  128 static int LostMain(
int argc, 
char **argv) {
 
  131         std::cout << 
"Usage: ./lost database or ./lost pipeline" << std::endl
 
  132                   << 
"Use --help flag on those commands for further help" << std::endl;
 
  136     std::string command(argv[1]);
 
  139     if (command == 
"database") {
 
  141         enum class DatabaseCliOption {
 
  142 #define LOST_CLI_OPTION(name, type, prop, defaultVal, converter, defaultArg) prop, 
  144 #undef LOST_CLI_OPTION 
  148         static struct option long_options[] = {
 
  149 #define LOST_CLI_OPTION(name, type, prop, defaultVal, converter, defaultArg) \ 
  151              defaultArg == 0 ? required_argument : optional_argument, \ 
  153              (int)DatabaseCliOption::prop}, 
  155 #undef LOST_CLI_OPTION 
  156                 {
"help", no_argument, 0, (int) DatabaseCliOption::help},
 
  160         DatabaseOptions databaseOptions;
 
  164         while ((option = getopt_long(argc, argv, 
"", long_options, &index)) != -1) {
 
  166 #define LOST_CLI_OPTION(name, type, prop, defaultVal, converter, defaultArg) \ 
  167                 case (int)DatabaseCliOption::prop :                     \ 
  168                     if (defaultArg == 0) {     \ 
  169                         databaseOptions.prop = converter;       \ 
  171                         if (LOST_OPTIONAL_OPTARG()) {           \ 
  172                             databaseOptions.prop = converter;   \ 
  174                             databaseOptions.prop = defaultArg;  \ 
  179 #undef LOST_CLI_OPTION 
  180                 case (
int) DatabaseCliOption::help :std::cout << documentation_database_txt << std::endl;
 
  183                 default :std::cout << 
"Illegal flag" << std::endl;
 
  188         lost::DatabaseBuild(databaseOptions);
 
  190     } 
else if (command == 
"pipeline") {
 
  192         enum class PipelineCliOption {
 
  193 #define LOST_CLI_OPTION(name, type, prop, defaultVal, converter, defaultArg) prop, 
  195 #undef LOST_CLI_OPTION 
  199         static struct option long_options[] = {
 
  200 #define LOST_CLI_OPTION(name, type, prop, defaultVal, converter, defaultArg) \ 
  202              defaultArg == 0 ? required_argument : optional_argument, \ 
  204              (int)PipelineCliOption::prop}, 
  206 #undef LOST_CLI_OPTION 
  209                 {
"help", no_argument, 0, (int) PipelineCliOption::help},
 
  217         while ((option = getopt_long(argc, argv, 
"", long_options, &index)) != -1) {
 
  219 #define LOST_CLI_OPTION(name, type, prop, defaultVal, converter, defaultArg) \ 
  220                 case (int)PipelineCliOption::prop :                         \ 
  221                     if (defaultArg == 0) {    \ 
  222                         pipelineOptions.prop = converter;       \ 
  224                         if (LOST_OPTIONAL_OPTARG()) {           \ 
  225                             pipelineOptions.prop = converter;   \ 
  227                             pipelineOptions.prop = defaultArg;  \ 
  232 #undef LOST_CLI_OPTION 
  233                 case (
int) PipelineCliOption::help :std::cout << documentation_pipeline_txt << std::endl;
 
  236                 default :std::cout << 
"Illegal flag" << std::endl;
 
  241         lost::PipelineRun(pipelineOptions);
 
  244         std::cout << 
"Usage: ./lost database or ./lost pipeline" << std::endl
 
  245                   << 
"Use --help flag on those commands for further help" << std::endl;
 
  252 int main(
int argc, 
char **argv) {
 
  253     return lost::LostMain(argc, argv);
 
The command line options passed when running a pipeline.
#define MULTI_DB_FLOAT_FLAG
A database that contains multiple databases This is almost always the database that is actually passe...
int main(int argc, char **argv)
const Catalog & CatalogRead()
Read and parse the full catalog from disk. If called multiple times, will re-use the first result.
decimal DegToRad(decimal deg)
Catalog NarrowCatalog(const Catalog &catalog, int maxMagnitude, int maxStars, decimal minSeparation)
Remove unwanted stars from an unfiltered catalog.
std::vector< MultiDatabaseEntry > MultiDatabaseDescriptor
MultiDatabaseDescriptor GenerateDatabases(const Catalog &catalog, const DatabaseOptions &values)
Appropriately create descriptors for all requested databases according to command-line options.
SerializeContext serFromDbValues(const DatabaseOptions &values)
std::vector< std::unique_ptr< PipelineInput > > PipelineInputList
PipelineInputList GetPipelineInput(const PipelineOptions &values)
Come up with a list of pipeline inputs based on command line options.
void SerializeMultiDatabase(SerializeContext *ser, const MultiDatabaseDescriptor &dbs, uint32_t flags)
void PipelineComparison(const PipelineInputList &expected, const std::vector< PipelineOutput > &actual, const PipelineOptions &values)
Print or otherwise analyze the results of (perhaps multiple) runs of a star tracking pipeline.
Pipeline SetPipeline(const PipelineOptions &values)
Create a pipeline from command line options.
bool atobool(const char *cstr)
Convert string to boolean.
std::vector< CatalogStar > Catalog