KiCad PCB EDA Suite
coroutines.cpp File Reference
#include <functional>
#include <tool/coroutine.h>
#include <qa_utils/utility_registry.h>
#include <common.h>
#include <wx/cmdline.h>
#include <cstdio>
#include <string>

Go to the source code of this file.

Classes

class  CoroutineExample
 A simple harness that counts to a preset value in a couroutine, yielding each value. More...
 

Typedefs

typedef COROUTINE< int, int > MyCoroutine
 

Functions

static int coroutine_main_func (int argc, char **argv)
 

Variables

static const wxCmdLineEntryDesc g_cmdLineDesc []
 
static bool registered
 

Typedef Documentation

◆ MyCoroutine

typedef COROUTINE<int, int> MyCoroutine

Definition at line 38 of file coroutines.cpp.

Function Documentation

◆ coroutine_main_func()

static int coroutine_main_func ( int  argc,
char **  argv 
)
static

Definition at line 101 of file coroutines.cpp.

102 {
103  wxCmdLineParser cl_parser( argc, argv );
104  cl_parser.SetDesc( g_cmdLineDesc );
105  cl_parser.AddUsageText( _( "Test a simple coroutine that yields a given number of times" ) );
106 
107  int cmd_parsed_ok = cl_parser.Parse();
108  if( cmd_parsed_ok != 0 )
109  {
110  // Help and invalid input both stop here
111  return ( cmd_parsed_ok == -1 ) ? KI_TEST::RET_CODES::OK : KI_TEST::RET_CODES::BAD_CMDLINE;
112  }
113 
114  long count = 5;
115  cl_parser.Found( "count", &count );
116 
117  CoroutineExample obj( (int) count );
118 
119  obj.Run();
120 
121  return KI_TEST::RET_CODES::OK;
122 }
#define OK
The command line was not correct for the tool.
static const wxCmdLineEntryDesc g_cmdLineDesc[]
Definition: coroutines.cpp:80
#define _(s)
A simple harness that counts to a preset value in a couroutine, yielding each value.
Definition: coroutines.cpp:47

References _, KI_TEST::BAD_CMDLINE, g_cmdLineDesc, OK, and CoroutineExample::Run().

Variable Documentation

◆ g_cmdLineDesc

const wxCmdLineEntryDesc g_cmdLineDesc[]
static
Initial value:
= {
{
wxCMD_LINE_SWITCH,
"h",
"help",
_( "displays help on the command line parameters" ).mb_str(),
wxCMD_LINE_VAL_NONE,
wxCMD_LINE_OPTION_HELP,
},
{
wxCMD_LINE_OPTION,
"c",
"count",
_( "how high to count" ).mb_str(),
wxCMD_LINE_VAL_NUMBER,
wxCMD_LINE_PARAM_OPTIONAL,
},
{ wxCMD_LINE_NONE }
}
#define _(s)

Definition at line 80 of file coroutines.cpp.

Referenced by coroutine_main_func().

◆ registered

bool registered
static
Initial value:
"coroutine",
"Test a simple coroutine",
} )
static bool Register(const KI_TEST::UTILITY_PROGRAM &aProgInfo)
Register a utility program factory function against an ID string.
static int coroutine_main_func(int argc, char **argv)
Definition: coroutines.cpp:101

Definition at line 128 of file coroutines.cpp.

Referenced by DSN::SPECCTRA_DB::FromBOARD().