本文整理汇总了C++中Controller类的典型用法代码示例。如果您正苦于以下问题:C++ Controller类的具体用法?C++ Controller怎么用?C++ Controller使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Controller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int, char const**)
{
// Create the main window
sf::RenderWindow window(sf::VideoMode(800, 600), "Gemini", sf::Style::Close);
srand(std::chrono::system_clock::now().time_since_epoch()/std::chrono::milliseconds(1)%10000);
window.setFramerateLimit(40);
unsigned int maxNumberOfThreads = std::thread::hardware_concurrency();
maxNumberOfThreads = 1;
// Set the Icon
sf::Image icon;
if (!icon.loadFromFile(resourcePath() + "icon.png")) {
return EXIT_FAILURE;
}
window.setIcon(icon.getSize().x, icon.getSize().y, icon.getPixelsPtr());
Board board;
board.setRandomArr();
HashTable transpositionTable;
RunAIInput input;
input.shouldAiBeRunning = false;
input.transpositionTable = &transpositionTable;
SearchAICommunicator searchCommunicator[4];
if(maxNumberOfThreads != 1)
{
while(input.lock.try_lock()){}
for(int i=0; i<maxNumberOfThreads; i++)
{
searchCommunicator[i].transpositionTable = &transpositionTable;
input.communicator.push_back(&searchCommunicator[i]);
}
input.lock.unlock();
}
Controller controller = Controller(&input);
pthread_t aiThread;
pthread_create(&aiThread, NULL, startAI, (void *)(&input));
bool commandLeft = false;
bool commandRight = false;
while (window.isOpen())
{
// Process events
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
window.close();
}
else if(event.type == sf::Event::KeyPressed)
{
if(event.key.code == sf::Keyboard::Escape)
{
// Escape pressed : exit
while(input.lock.try_lock()){}
input.shouldAiBeRunning = false;
input.lock.unlock();
struct timespec tim, tim2;
tim.tv_sec = 0;
tim.tv_nsec = 10; // milliseconds
tim.tv_nsec *= 1000000;
nanosleep(&tim , &tim2);
window.close();
}
else if(event.key.code == sf::Keyboard::LSystem)
{
commandLeft = true;
}
else if(event.key.code == sf::Keyboard::RSystem)
{
commandRight = true;
}
else if((commandLeft || commandRight) && (event.key.code == sf::Keyboard::W || event.key.code == sf::Keyboard::Q))
{
window.close();
}
else if(event.key.code == sf::Keyboard::W)
{
if(commandLeft || commandRight)
{
window.close();
}
}
else
{
controller.keyDown(event.key.code);
}
}
else if(event.type == sf::Event::KeyReleased)
{
//.........这里部分代码省略.........
示例2: get_height
void
Menu::process_input()
{
int menu_height = (int) get_height();
if (menu_height > SCREEN_HEIGHT)
{ // Scrolling
int scroll_offset = (menu_height - SCREEN_HEIGHT) / 2 + 32;
pos.y = SCREEN_HEIGHT/2 - scroll_offset * ((float(active_item) / (items.size()-1)) - 0.5f) * 2.0f;
}
MenuAction menuaction = MENU_ACTION_NONE;
Controller* controller = InputManager::current()->get_controller();
/** check main input controller... */
if(controller->pressed(Controller::UP)) {
menuaction = MENU_ACTION_UP;
menu_repeat_time = real_time + MENU_REPEAT_INITIAL;
}
if(controller->hold(Controller::UP) &&
menu_repeat_time != 0 && real_time > menu_repeat_time) {
menuaction = MENU_ACTION_UP;
menu_repeat_time = real_time + MENU_REPEAT_RATE;
}
if(controller->pressed(Controller::DOWN)) {
menuaction = MENU_ACTION_DOWN;
menu_repeat_time = real_time + MENU_REPEAT_INITIAL;
}
if(controller->hold(Controller::DOWN) &&
menu_repeat_time != 0 && real_time > menu_repeat_time) {
menuaction = MENU_ACTION_DOWN;
menu_repeat_time = real_time + MENU_REPEAT_RATE;
}
if(controller->pressed(Controller::LEFT)) {
menuaction = MENU_ACTION_LEFT;
menu_repeat_time = real_time + MENU_REPEAT_INITIAL;
}
if(controller->hold(Controller::LEFT) &&
menu_repeat_time != 0 && real_time > menu_repeat_time) {
menuaction = MENU_ACTION_LEFT;
menu_repeat_time = real_time + MENU_REPEAT_RATE;
}
if(controller->pressed(Controller::RIGHT)) {
menuaction = MENU_ACTION_RIGHT;
menu_repeat_time = real_time + MENU_REPEAT_INITIAL;
}
if(controller->hold(Controller::RIGHT) &&
menu_repeat_time != 0 && real_time > menu_repeat_time) {
menuaction = MENU_ACTION_RIGHT;
menu_repeat_time = real_time + MENU_REPEAT_RATE;
}
if(controller->pressed(Controller::ACTION)
|| controller->pressed(Controller::MENU_SELECT)) {
menuaction = MENU_ACTION_HIT;
}
if(controller->pressed(Controller::ESCAPE) ||
controller->pressed(Controller::START) ||
controller->pressed(Controller::MENU_BACK)) {
menuaction = MENU_ACTION_BACK;
}
if(items.size() == 0)
return;
// The menu_action() call can pop() the menu from the stack and thus
// delete it, so it's important that no further member variables are
// accessed after this call
process_action(menuaction);
}
示例3: onFrame
void LeapListener::onFrame(const Controller &controller){
const Frame frame = controller.frame();
HandList hands = frame.hands();
std::vector<HandModel> myhands;
BoneModel mybone;
HandModel myhand;
//printf("frame: %d\n", frame.id());
float scale = 0.025;
float disp = 3.5f;
bool record = true;
for (int i = 0; i < hands.count(); i++){
FingerList fingers = hands[i].fingers();
myhand.bones.clear();
myhand.references.clear();
Vector handPosition = hands[i].palmPosition();
handPosition *= scale;
handPosition.y -= disp;
Vector wrist = hands[i].wristPosition();
wrist *= scale;
wrist.y -= disp;
myhand.palmPosition = handPosition;
myhand.palmNormal = hands[i].palmNormal();
myhand.direction = hands[i].direction();
for (int j = 0; j < fingers.count(); j++){
Bone bone;
Bone::Type boneType;
Vector currentPosition = fingers[j].tipPosition();
currentPosition *= scale;
currentPosition.y -= disp;
Vector lastPosition = m_lastFrame.finger(fingers[j].id()).tipPosition();
lastPosition *= scale;
lastPosition.y -= disp;
Vector diff = currentPosition - lastPosition;
//printf("%f, %f, %f\n", abs(diff.x), abs(diff.y), abs(diff.z));
//if (abs(diff.x) > 0.2 || abs(diff.y) > 0.2 || abs(diff.z) > 0.2) record = false;
if (abs(diff.x) < 0.0001 || abs(diff.y) < 0.0001 || abs(diff.z) < 0.0001) record = false;
for (int k = 0; k < 4; k++){
boneType = static_cast<Bone::Type>(k);
bone = fingers[j].bone(boneType);
if (fingers[j].type() == Finger::Type::TYPE_THUMB && k == 0) continue;
Vector prevPos = bone.prevJoint();
prevPos *= scale;
prevPos.y -= disp;
Vector nextPos = bone.nextJoint();
nextPos *= scale;
nextPos.y -= disp;
mybone.direction = nextPos - prevPos;
mybone.position = (prevPos + nextPos) / 2;
mybone.prevJoint = prevPos;
mybone.nextJoint = nextPos;
mybone.length = bone.length() * scale;
if (boneType == Bone::Type::TYPE_PROXIMAL){
if (fingers[j].type() == Finger::Type::TYPE_THUMB){
myhand.thumb = prevPos;
//myhand.references.push_back(nextPos);
}
else{
myhand.references.push_back(prevPos);
}
}
myhand.bones.push_back(mybone);
}
}
myhand.base = myhand.references[3] - myhand.references[0];
Vector disp = myhand.base.normalized() * 0.3f;
myhand.references[3] += disp;
myhand.references[0] -= disp;
//for (int i = 1; i < 5; i++){
// printf("%f\n", myhand.references[i - 1].distanceTo(myhand.references[i]));
//}
myhands.push_back(myhand);
}
if (record){
m_hands.clear();
for (int i = 0; i < myhands.size(); i++){
m_hands.push_back(myhands[i]);
}
}
//.........这里部分代码省略.........
示例4: onFrame
void SampleListener::onFrame(const Controller& controller) {
// Get the most recent frame and report some basic information
const Frame frame = controller.frame();
/* std::cout << "Frame id: " << frame.id()
<< ", timestamp: " << frame.timestamp()
<< ", hands: " << frame.hands().count()
<< ", fingers: " << frame.fingers().count()
<< ", tools: " << frame.tools().count() << std::endl;
*/
if (!frame.hands().empty()) {
// get mutex
boost::mutex::scoped_lock lk(mtx);
// clear last datas
rhand.clear();
//vhand.clear();
//mhand.clear();
//vfinger.clear();
// set new datas
Vector3f v, x, y, z;
Matrix3f m;
Vector tmp, normal, direction;
capture_time.pop_front();
capture_time.push_back(frame.timestamp());
const HandList hlist = frame.hands();
// for(int i=0;i<hlist.count();i++){
int i=0;
rhand.push_back(hlist[i].sphereRadius());
tmp = hlist[i].palmPosition();
v << -tmp[2]/1000.0f, -tmp[0]/1000.0f, tmp[1]/1000.0f;
vhand.pop_front();
vhand.push_back(v);
tmp = hlist[i].palmVelocity();
v << -tmp[2]/1000.0f, -tmp[0]/1000.0f, tmp[1]/1000.0f;
vvhand.pop_front();
vvhand.push_back(v);
/*
normal = hlist[i].palmNormal();
direction = hlist[i].direction();
y << -normal[2], -normal[0], normal[1];
z << -direction[2], -direction[0], direction[1];
z = -z;
x = y.cross(z);
z = x.cross(y);
m << x[0], x[1], x[2],
y[0], y[1], y[2],
z[0], z[1], z[2];
mhand.push_back(m);
*/
// }
/*
// Check if the hand has any fingers
const FingerList fingers = frame.fingers();
for(int i=0;i<fingers.count();i++){
tmp = fingers[i].tipPosition();
v << -tmp[2]/1000.0f, -tmp[0]/1000.0f, tmp[1]/1000.0f;
vfinger.push_back(v);
}
*/
}
}
示例5: startGame
//==============================
int startGame()
{
initExternLibrary();
initSDL();
initDecoder();
initTunnelNetwork();
initController();
SDL_Event event;
_beginthread(networkThread,NULL,NULL);
_beginthread(SDL_VideoDisplayThread,NULL,NULL);
runFlag=true;
while(runFlag)
{
Sleep(GUISLEEPTIME);
while( SDL_PollEvent( &event ) )
{
switch( event.type )
{
case SDL_KEYDOWN:
if(event.key.keysym.sym==SDLK_F2)
{
SDL_WM_GrabInput(SDL_GRAB_OFF);
break;
}
//printf("%d%d\n",event.key.keysym.sym,event.key.keysym.mod);
controller.sendKeyEvent(event.key.keysym.sym,event.key.keysym.mod);
break;
case SDL_MOUSEMOTION:
//printf("Mouse moved by %d,%d to (%d,%d)\n",event.motion.xrel, event.motion.yrel,event.motion.x, event.motion.y);
controller.sendMouseEvent(event.motion.xrel, event.motion.yrel,0,0);
break;
case SDL_MOUSEBUTTONDOWN:
if(SDL_WM_GrabInput(SDL_GRAB_QUERY)==SDL_GRAB_OFF)
{
SDL_WM_GrabInput(SDL_GRAB_ON);
break;
}
//printf("Mouse button %d pressed at (%d,%d,%d,%d)\n",event.button.button, event.button.x, event.button.y,event.motion.xrel,event.motion.yrel);
controller.sendMouseEvent(0,0,event.button.button,PRESSDOWNDIRECTION);
break;
case SDL_MOUSEBUTTONUP:
controller.sendMouseEvent(0,0,event.button.button,PRESSUPDIRECTION);
break;
case SDL_QUIT:
runFlag = false;
break;
default:
break;
}
}
}
tunnel.stopTunnelLoop();
Sleep(2000);
WSACleanup();
return 0;
}
示例6: main
int main(int argc, char* argv[])
{
// parameter
uint32_t drv_num = 5;
uint64_t max_drv_bytes = (uint64_t)32*(1024*1024*1024);
//double avg_cmp_ratio = 0.5;
double ctl_op_ratio = 1.25;
uint32_t ctl_cmp_chunk = 16;
double ssd_op_ratio = 1.25;
uint64_t ttl_io = 32*1024*1024 ;
// uint64_t ttl_io = 1 ;
uint32_t io_size_sect = 8;
COMP_MODE mode = CTL_SIDE;
std::string trace_file = "osdb_comp_trace.txt";
bool single_ssd_mode = true;
bool skip_ssd_mode = false;
{ // analyze input argument
int i;
if( argc == 1 )
{
printf("#_no_opt:_load_default_parameter\n");
}
else
{
for( i = 1; i < argc; i++ )
{
if( strcmp(argv[i], "--drive_num") == 0 || strcmp(argv[i], "-d") ==0 )
{
if( !CheckAdditionalOpt(++i, argc, argv) ) return 0;
else drv_num = atoi(argv[i]);
}
else if( strcmp(argv[i], "--max_drive_bytes") == 0 || strcmp(argv[i], "-b") ==0 )
{
if( !CheckAdditionalOpt(++i, argc, argv) ) return 0;
else max_drv_bytes = std::stoull(argv[i]);
}
// else if( strcmp(argv[i], "--avg_cmp_ratio") == 0 || strcmp(argv[i], "-c") ==0 )
// {
// if( !CheckAdditionalOpt(++i, argc, argv) ) return 0;
// else avg_cmp_ratio = std::stod(argv[i]);
// }
else if( strcmp(argv[i], "--comp_mode") == 0 || strcmp(argv[i], "-m") ==0 )
{
if( !CheckAdditionalOpt(++i, argc, argv) ) return 0;
else if( strcmp(argv[i], "c") == 0 )
mode = CTL_SIDE;
else if( strcmp(argv[i], "s") == 0 )
mode = SSD_SIDE;
else {
printf("invalid option for mode%s\n", argv[i] );
return false;
}
}
else if( strcmp(argv[i], "--ctl_op_ratio") == 0 || strcmp(argv[i], "-R") ==0 )
{
if( !CheckAdditionalOpt(++i, argc, argv) ) return 0;
else ctl_op_ratio = std::stod(argv[i]);
}
else if( strcmp(argv[i], "--ctl_cmp_chunk") == 0 || strcmp(argv[i], "-C") ==0 )
{
if( !CheckAdditionalOpt(++i, argc, argv) ) return 0;
else ctl_cmp_chunk = std::stol(argv[i]);
}
else if( strcmp(argv[i], "--ssd_op_ratio") == 0 || strcmp(argv[i], "-r") ==0 )
{
if( !CheckAdditionalOpt(++i, argc, argv) ) return 0;
else ssd_op_ratio = std::stod(argv[i]);
}
//else if( strcmp(argv[i], "--ttl_io_cnt") == 0 || strcmp(argv[i], "-i") ==0 )
//{
// if( !CheckAdditionalOpt(++i, argc, argv) ) return 0;
// else ttl_io = std::stoll(argv[i]);
//}
else if( strcmp(argv[i], "--trace_file") == 0 || strcmp(argv[i], "-t") ==0 )
{
if( !CheckAdditionalOpt(++i, argc, argv) ) return 0;
else trace_file = argv[i];
}
else if( strcmp(argv[i], "--skip_ssd") == 0 )
{
skip_ssd_mode = true;
}
else if( strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0 )
{
HowtoUse(argv[0]);
return 0;
}
else
{
printf("Invalid option -- %s\n", argv[i]);
HowtoUse(argv[0]);
return 0;
}
}
}
}
Controller* ctl;
std::vector<SSD*> ssd_list;
//.........这里部分代码省略.........
示例7: ProtoProcessFile
ProtoProcessFile ( Controller<ProtoProcessFile<T>, T>& controller, const std::string& name )
: ProcessFile ( controller.getFS(), name ), controller_ ( controller )
{}
示例8: isAnyAvailable
static int isAnyAvailable(lua_State *L)
{
Controller *c = getInstance(L, 1);
lua_pushboolean(L, (bool)c->isAnyAvailable());
return 1;
}
示例9: BitwiseFlip
// 按位取反
void BitwiseFlip(Tape &t)
{
Controller c;
// 如果这里看到的是0,那么S1将写1;
// 如果这里看到的是1,那么S2将写0。
c.AddRule(0, '0', 1, ' ', 'R');
c.AddRule(0, '1', 2, ' ', 'R');
c.AddRule(0, '$', 4, '$', 'S');
c.AddRule(1, '0', 1, '0', 'R');
c.AddRule(1, '1', 1, '1', 'R');
c.AddRule(1, ' ', 3, '1', 'L');
c.AddRule(1, '$', 1, '$', 'R');
c.AddRule(2, '0', 2, '0', 'R');
c.AddRule(2, '1', 2, '1', 'R');
c.AddRule(2, ' ', 3, '0', 'L');
c.AddRule(2, '$', 2, '$', 'R');
// 往回移到数字开头。
c.AddRule(3, '0', 3, '0', 'L');
c.AddRule(3, '1', 3, '1', 'L');
c.AddRule(3, ' ', 0, ' ', 'R');
c.AddRule(3, '$', 3, '$', 'L');
c.MarkFinal(4);
c.Run(t, true);
}
示例10: Less
// a<=b?
// 必须同等长度
void Less(Tape &t)
{
Controller c;
// 若第一位为0,则去(a)
// 若第一位为1,则去(b)
c.AddRule(0, '0', 1, ' ', 'R');
c.AddRule(0, '1', 4, ' ', 'R');
c.AddRule(0, '$', 6, ' ', 'R'); // 等于最后也写0
// (a) 若0,把第二个数的第一位改成$;若1,则确定小于
c.AddRule(1, '0', 1, '0', 'R');
c.AddRule(1, '1', 1, '1', 'R');
c.AddRule(1, '$', 2, '$', 'R');
c.AddRule(2, '$', 2, '$', 'R');
c.AddRule(2, '0', 3, '$', 'L');
c.AddRule(2, '1', 9, ' ', 'R');
// 移回第一个数开头。
c.AddRule(3, '0', 3, '0', 'L');
c.AddRule(3, '1', 3, '1', 'L');
c.AddRule(3, '$', 3, '$', 'L');
c.AddRule(3, ' ', 0, ' ', 'R');
// (b) 如果第二个数的第一位是1继续比较;如果是0,那确定大于
c.AddRule(4, '0', 4, '0', 'R');
c.AddRule(4, '1', 4, '1', 'R');
c.AddRule(4, '$', 5, '$', 'R');
c.AddRule(5, '$', 5, '$', 'R');
c.AddRule(5, '0', 6, ' ', 'R');
c.AddRule(5, '1', 3, '$', 'L');
// 最后写0
c.AddRule(6, '0', 6, ' ', 'R');
c.AddRule(6, '1', 6, ' ', 'R');
c.AddRule(6, '$', 6, ' ', 'R');
c.AddRule(6, ' ', 7, '0', 'R');
// 最后写1
c.AddRule(9, '0', 9, ' ', 'R');
c.AddRule(9, '1', 9, ' ', 'R');
c.AddRule(9, '$', 9, ' ', 'R');
c.AddRule(9, ' ', 7, '1', 'R');
//c.AddRule(7, ' ', 8, '$', 'L');
c.MarkFinal(7);
c.Run(t, true);
}
示例11: processVideo
int processVideo() {
VideoCapture capture(1);
if (!capture.isOpened()) {
cerr << "Failed to open video stream\n" << endl;
return 1;
}
namedWindow("Main", CV_WINDOW_KEEPRATIO); //resizable window;
Mat rgbFrame, grayFrame;
capture.read(rgbFrame);
// Try to read the pattern:
cv::Mat patternImage, patternImageGray;
patternImage = cv::imread(path + "/images/card.jpg");
if (patternImage.empty()) {
std::cout << "Input image cannot be read" << std::endl;
return 2;
}
cvtColor(patternImage, patternImageGray, CV_RGB2GRAY);
Controller *controller = Controller::getInstance();
for (; ;) {
capture.read(rgbFrame);
if (rgbFrame.empty()) break;
if (!controller->isInitialized) {
controller->initialize(rgbFrame, path);
}
cvtColor(rgbFrame, grayFrame, CV_RGB2GRAY);
if (grayFrame.empty()) {
std::cout << "Cannot open video capture device" << std::endl;
}
// call display function with frame data
controller->displayFunction(rgbFrame, grayFrame);
imshow("Main", rgbFrame);
char key = (char) waitKey(5); //delay N millis, usually long enough to display and capture input
switch (key) {
case 'q':
controller->isModeObjectDetection(true);
cout << "Recognition started.." << endl;
break;
case 'w':
controller->isModeObjectDetection(false);
cout << "Recognition stopped!" << endl;
break;
case 'e':
controller->isModeTracking(true);
cout << "Tracking started.." << endl;
break;
case 'r':
controller->isModeTracking(false);
cout << "Tracking stopped!" << endl;
break;
case 's':
controller->createObjectPattern(patternImage, patternImageGray);
cout << "Image registered" << endl;
break;
case 'd':
controller->createObjectPattern(rgbFrame, grayFrame);
cout << "Frame registered" << endl;
break;
case 't':
cout << "Configure SURF as detector" << endl;
cout << "RESULT=" << controller->setDetector("SURF");
break;
case 'z':
cout << "Configure SURF as extractor" << endl;
cout << "RESULT=" << controller->setExtractor("SURF");
break;
case 'u':
cout << "Configure BF as matcher" << endl;
cout << "RESULT=" << controller->setMatcher("BF");
break;
case 27: //escape key
return 0;
default:
break;
}
}
}
示例12: main
int main() {
int action = -1;
Controller controller;
TaskList* taskList = new TaskList();
taskLoader = new TaskLoader("tasks");
taskLoader->loadTasks(taskList);
while(action != 0) {
system("clear");
std::cout << "Wybierz opcje:\n" << std::endl;
std::cout << "1 - Dodaj zadanie" << std::endl;
std::cout << "2 - Wypisz listę zadań" << std::endl;
std::cout << "0 - Zakończ działanie programu\n" << std::endl;
std::cout << "Podaj nr opcji: ";
while(!(std::cin >> action) || ((action != 1) && (action != 2) && (action != 0))) {
std::cout << "Podałeś zły nr opcji i nasatąpiło wyrzucenie nic nie zaczącego wyjątku." << std::endl;
try {
throw std::exception();
} catch(std::exception& e) {
std::cout << "Następuje obsługe nic nie zaczącego wyjątku" << std::endl;
std::cout << e.what();
}
std::cout << "Spróbuj jeszcze raz: ";
std::cin.clear();
std::cin.ignore (1000, '\n');
}
switch(action) {
case 1:
try {
controller.addTask(taskList);
} catch(std::exception& e) {
std::cout << "Podałeś złą wartść. Wszystkie poprzednie zaminy zostaną zapisane i nastąpi wyjcie z programu.";
taskLoader->saveLastLoadedTasks();
exit(0);
}
break;
case 2:
while(action != 0) {
system("clear");
controller.showTasksList(taskList);
std::cout << std::endl;
std::cout << std::endl;
std::cout << std::endl;
std::cout << "Wybierz opcje:\n" << std::endl;
std::cout << "1 - Przejdź do wybranego zadania" << std::endl;
std::cout << "0 - Powróć do głównego menu" << std::endl;
std::cout << "Podaj nr opcji: ";
while(!(std::cin >> action) || ((action != 1) && (action != 0))) {
std::cout << "Podałeś zły nr opcji. Spróbuj jeszcze raz: ";
std::cin.clear();
std::cin.ignore (1000, '\n');
}
switch(action) {
case 1:
int taskId;
std::cout << "Podaj id zadania: ";
while(!(std::cin >> taskId) || !((taskList->getNumberOfTasks() + 1 > taskId) && (taskId > 0))) {
std::cout << "Podałeś zły nr id zadania. Spróbuj jeszcze raz: ";
std::cin.clear();
std::cin.ignore (1000, '\n');
}
taskId--;
while(action != 0) {
system("clear");
controller.showTask(taskList->getTask(taskId));
std::cout << std::endl;
std::cout << std::endl;
std::cout << std::endl;
std::cout << "Wybierz opcje:\n" << std::endl;
std::cout << "1 - Edytuj zadanie" << std::endl;
std::cout << "2 - Usuń zadanie" << std::endl;
std::cout << "0 - Powróć do listy zadań" << std::endl;
std::cout << "Podaj nr opcji: ";
while(!(std::cin >> action) || ((action != 1) && (action != 2) && (action != 0))) {
std::cout << "Podałeś zły nr opcji. Spróbuj jeszcze raz: ";
std::cin.clear();
std::cin.ignore (1000, '\n');
}
switch(action) {
case 1:
try {
controller.editTask(taskList->getTask(taskId));
} catch(std::exception& e) {
std::cout << "Podałeś złą wartść. Wszystkie poprzednie zaminy zostaną zapisane i nastąpi wyjcie z programu.";
taskLoader->saveLastLoadedTasks();
exit(0);
}
break;
case 2:
//.........这里部分代码省略.........
示例13: runTest1
void runTest1 ()
{
Controller controller;
controller.addBook( "AAA", std::vector< std::string >( 1, "Author 1" ), "en", 2000 );
controller.addRevised( "AAA", 1, 2, 2005 );
controller.addTranslation( "le AAA", "AAA", "fr", 2012 );
controller.addBook( "BBB", std::vector< std::string >( 1, "Author 2" ), "en", 2002 );
controller.addRevised( "BBB", 1, 2, 2007 );
controller.addTranslation( "la BBB", "BBB", "it", 2008 );
controller.addBook( "CCC", std::vector< std::string >( 1, "Author 3" ), "en", 2002 );
controller.addRevised( "CCC", 1, 2, 2005 );
controller.addBook( "DDD", std::vector< std::string >( 1, "Author 4" ), "en", 2004 );
controller.addTranslation( "das DDD", "DDD", "de", 2009 );
controller.addBook( "EEE", std::vector< std::string >( 1, "Author 5" ), "en", 2007 );
std::set< std::string > result = controller.fetchBooksBothTranslatedRevised();
assert( result.size() == 2 );
assert( result.find( "AAA" ) != result.end() );
assert( result.find( "BBB" ) != result.end() );
result = controller.fetchAuthorsNotBeingTranslated();
assert( result.size() == 2 );
assert( result.find( "Author 3" ) != result.end() );
assert( result.find( "Author 5" ) != result.end() );
}
示例14: accept
void EventStart::accept(Controller& visitor)
{
visitor.visit(*this);
}
示例15: getPlayerCount
static int getPlayerCount(lua_State *L)
{
Controller *c = getInstance(L, 1);
lua_pushnumber(L, c->getPlayerCount());
return 1;
}