tr1::shared_ptr<AbstractNumber> E::divide(tr1::shared_ptr<AbstractNumber>number){ char newSign = '-'; if (getSign() == number->getSign()) { newSign = '+'; } if (number -> getName() == "E") { if (newSign == '+') { tr1::shared_ptr<AbstractNumber> output(new SmartInteger(1)); return output; } else { tr1::shared_ptr<AbstractNumber> output(new SmartInteger(-1)); return output; } } else if (number -> getName() == "Exponent") { tr1::shared_ptr<Exponent> numExp = tr1::static_pointer_cast<Exponent>(number); if (numExp -> getValue("base") -> getName() == "E") { tr1::shared_ptr<AbstractNumber> num(new SmartInteger(1)); tr1::shared_ptr<AbstractNumber> exp = number->getValue("power"); tr1::shared_ptr<AbstractNumber> exp2(new SmartInteger(-1)); tr1::shared_ptr<AbstractNumber> me(new E()); tr1::shared_ptr<AbstractNumber> ans2(new Exponent(me, exp -> add(exp2), newSign)); tr1::shared_ptr<AbstractNumber> output2(new MultExpression(num, ans2, '+')); return output2; } } else if(number->getName() == "MultExpression") { tr1::shared_ptr<MultExpression> MultE = tr1::static_pointer_cast<MultExpression>(number); vector<tr1::shared_ptr<AbstractNumber> > MultENum = MultE->getNumerator(); vector<tr1::shared_ptr<AbstractNumber> > MultEDem = MultE->getDenominator(); if (MultEDem.size() == 0) { tr1::shared_ptr<AbstractNumber> one(new SmartInteger(1)); MultEDem.push_back(one); } tr1::shared_ptr<AbstractNumber> reversedMultE(new MultExpression(MultEDem, MultENum, number->getSign())); return reversedMultE->multiply(shared_from_this()); } tr1::shared_ptr<AbstractNumber> output2(new MultExpression(shared_from_this(), number, newSign)); return output2; }
BingoStorage::BingoStorage (OracleEnv &env, int context_id) { _shmem_state = 0; _age_loaded = -1; _top_lob_pending_mark = 0; _index_lob_pending_mark = 0; QS_DEF(Array<char>, instance); QS_DEF(Array<char>, schema); OracleStatement::executeSingleString(instance, env, "SELECT PROPERTY_VALUE from database_properties where property_name = 'GLOBAL_DB_NAME'"); OracleStatement::executeSingleString(schema, env, "SELECT SYS_CONTEXT('USERENV', 'CURRENT_SCHEMA') from dual"); ArrayOutput output1(_shmem_id); output1.printf("%s#%s#%d#bs2", instance.ptr(), schema.ptr(), context_id); output1.writeChar(0); ArrayOutput output2(_table_name); output2.printf("STORAGE_%d", context_id); output2.writeChar(0); }
int plugin_main(PluginContext &context) { assert(context.data); TestData *pdata = (TestData *)(context.data); output2(pdata->num); output(pdata->test_str); return 0; }
void main_loop (int argc, char *argv[]) { int i; output2(titel,VERSION,(unsigned long)(ramend-ramstart)); newram=startlocal=endlocal=ramstart; udfend=ramstart; changedepsilon=epsilon=10000*DBL_EPSILON; sort_builtin(); sort_command(); make_xors(); clear_fktext(); accuinit(); next=input_line; *next=0; /* clear input line */ strcpy(input_line,"wait(1); load \"euler.cfg\";"); for (i=1; i<argc; i++) { if (argv[i][0]=='"') strcat(input_line," load "); else strcat(input_line," load \""); strcat(input_line,argv[i]); if (argv[i][0]=='"') strcat(input_line,";"); else strcat(input_line,"\";"); } path[0]=(char *)malloc(5); strcpy(path[0],"."); npath=1; while (!quit) { startglobal=startlocal; endglobal=endlocal; command(); /* interpret until "quit" */ if (trace<0) trace=0; } }
int main(){ exception e; VTDGen *vg = NULL; VTDNav *vn = NULL; AutoPilot *ap = NULL; XMLModifier *xm = NULL; FILE *f = NULL; UCSChar *string = NULL; int i; f = fopen("d:/ximpleware_2.2_c/vtd-xml/codeGuru/6/input.vxl","rb"); if (f==NULL) return 0; Try{ xm = createXMLModifier(); ap = createAutoPilot2(); selectXPath(ap,L"/a/b"); vg = createVTDGen(); vn = loadIndex (vg,f); bind(ap,vn); bind4XMLModifier(xm,vn); while((i=evalXPath(ap))!=-1){ insertAttribute(xm,L" attr1='val'"); } output2(xm,"d:/ximpleware_2.2_c/vtd-xml/codeGuru/6/new.xml"); free(vn->XMLDoc); }Catch(e){// handle various types of exceptions here } fclose(f); freeAutoPilot(ap); freeXMLModifier(xm); freeVTDGen(vg); freeVTDNav(vn); return 0; }
int main(int argc, char** argv){ SndWave infile(argv[1], READ); SndIn sig1(&infile,1); SndIn sig2(&infile,2); SndAiff output1(argv[2], OVERWRITE); SndAiff output2(argv[3], OVERWRITE); output1.SetOutput(1, &sig1); output2.SetOutput(1, &sig1); while(!infile.Eof()){ infile.Read(); sig1.DoProcess(); sig2.DoProcess(); output1.Write(); output2.Write(); } return 0; }
int bfs(int m, int n) { int head=0; int tail=1; book[0][0] = 0; qu[0].x = 0; qu[0].y = 0; int next[4][2] = {{1,0},{0,1},{-1,0},{0,-1}}; int i, flag = 0; while(head<tail) { int x,y; for(i=0;i<4;i++) { x = qu[head].x + next[i][0]; y = qu[head].y + next[i][1]; //printf("%d %d %d %d\n",x,y,head,tail); if(x<0 || x>=m || y<0 || y>=n) continue; if(map[x][y]=='X') continue; int tt = book[qu[head].x][qu[head].y] + 1 ; if (map[x][y] != '.') tt += map[x][y]-'0' ; if (book[x][y] != -1 && book[x][y] <= tt) continue ; qu[tail].x = x; qu[tail].y = y; book[x][y] = tt; prt[x][y] = head; tail++; } head++; } if(book[m-1][n-1]!=-1) { //for(i=0;i<=tail;i++) // printf("%d %d %d %d\n",i, qu[i].x, qu[i].y, qu[i].f); printf("It takes %d seconds to reach the target position, let me show you the way.\n", book[m-1][n-1]); output2(m-1,n-1); } else { printf("God please help our poor hero.\n"); } printf("FINISH\n"); }
void bkp_follow(std::vector<std::string> &tokens){ std::cout << "backup follow execute\n"; std::unique_lock<std::mutex> lck(file3); std::unique_lock<std::mutex> lck2(file4); std::ifstream ifs(get_path(file_id[3])); std::string line, username = tokens[1], newf = tokens[2]; std::vector<std::string> flwing; bool found = false, valid = true; std::ofstream output; std::string temp_file = get_path(file_id[4]); if(ifs.is_open()){ output.open(temp_file); while(getline(ifs, line) && valid){ std::istringstream iss2(line); std::vector<std::string> temp{std::istream_iterator<std::string>{iss2}, std::istream_iterator<std::string>{}}; if(temp[0] == username){ found = true; for(int i = 1; i < temp.size(); i++){ flwing.push_back(temp[i]); if(newf == temp[i]){ std::cout << "cond 1\n"; valid = false; break; } } }else{ output << line << "\n"; } } ifs.close(); output.close(); } if(!found){ std::cout << "cond 2\n"; std::ofstream output2(get_path(file_id[3]), std::ios::app); std::string retval = username + " " + newf; output2 << "\n" << retval; output2.close(); } if(valid && found){ std::cout << "cond 3\n"; output.open(get_path(file_id[3])); ifs.open(temp_file); while(getline(ifs, line)){ output << line << "\n"; } std::string retval = username + " "; for(int i = 0; i < flwing.size(); i++){ retval += flwing[i]; retval += " "; } retval += newf; output << retval; output.close(); ifs.close(); } }
int main(){ std::ofstream output("out.dat", std::ostream::out), output2("energy.dat", std::ostream::out); auto state = generate_initial(INITIAL_SIZE, TIMESTEP); //std::cout << state.v_ref << '\t' << state.particles.size() << '\n'; diffuse(state, output, output2); }
int output2(int x, int y) { int i, t, idx = prt[x][y] ; if (idx == -1) return 0 ; t = output2(qu[idx].x, qu[idx].y) ; printf ("%ds:(%d,%d)->(%d,%d)\n", ++t, qu[idx].x, qu[idx].y,x,y) ; if (map[x][y] != '.') for (i = 0 ; i < map[x][y]-'0' ; i++) printf ("%ds:FIGHT AT (%d,%d)\n", ++t, x, y) ; return t ; }
int main(int argc, char ** argv) { QHash<QString,WhitLocation> hash; QCoreApplication app(argc,argv); QFile input("listall"); QFile index("whitindex.cal"); QFile output("whitdefinitions.cal"); input.open(QFile::ReadOnly); index.open(QFile::WriteOnly); output.open(QFile::WriteOnly); QTextStream is(&input); QTextStream ins(&index); QString line; while(!is.atEnd()) { line = is.readLine(); QProcess process; QStringList args; args.push_back(line); process.start("./words", args); process.waitForStarted(); process.write("\n\n\n\n\n"); process.waitForFinished(); QByteArray ret = process.readAllStandardOutput(); QString retstring(ret); app.processEvents(); ins << line << endl; ins << QString::number(output.pos()) << endl; QByteArray outd = retstring.toUtf8(); ins << outd.length() << endl; WhitLocation wl; wl.pos = output.pos(); wl.len = outd.length(); line=line.remove("\n"); hash[line]=wl; output.write(outd); output.flush(); } QFile output2("whitindexhash.cal"); output2.open(QFile::WriteOnly); QDataStream qds(&output2); qds << hash; }
void ParameterOperator::execute(DataProvider& provider) { Id2DataPair input1(INPUT_1); Id2DataPair input2(INPUT_2); provider.receiveInputData(input1 && input2); // execute... Id2DataPair output1(OUTPUT_1, input1.data()); Id2DataPair output2(OUTPUT_2, input2.data()); provider.sendOutputData(output1 && output2); }
int main(int, char**) { std::vector<std::chrono::duration<double,std::milli>> duration_vector_1; std::vector<std::chrono::duration<double,std::milli>> duration_vector_2; Halide::Buffer<float> input(Halide::Float(32), 10000, 10000); // Init randomly for (int y = 0; y < input.height(); ++y) { for (int x = 0; x < input.width(); ++x) { input(x, y) = random(); input(x, y) = random(); } } Halide::Buffer<float> output1(input.width(), input.height()); Halide::Buffer<float> output2(input.width(), input.height()); // Tiramisu for (int i=0; i<NB_TESTS; i++) { auto start1 = std::chrono::high_resolution_clock::now(); divergence2d_tiramisu(input.raw_buffer(), output1.raw_buffer()); auto end1 = std::chrono::high_resolution_clock::now(); std::chrono::duration<double,std::milli> duration1 = end1 - start1; duration_vector_1.push_back(duration1); } // Reference for (int i=0; i<NB_TESTS; i++) { auto start2 = std::chrono::high_resolution_clock::now(); divergence2d_ref(input.raw_buffer(), output2.raw_buffer()); auto end2 = std::chrono::high_resolution_clock::now(); std::chrono::duration<double,std::milli> duration2 = end2 - start2; duration_vector_2.push_back(duration2); } print_time("performance_CPU.csv", "divergence2d", {"Tiramisu", "Halide"}, {median(duration_vector_1), median(duration_vector_2)}); // compare_2_2D_arrays("Blurxy", output1.data(), output2.data(), input.extent(0), input.extent(1)); Halide::Tools::save_image(output1, "./build/divergence2d_tiramisu.png"); Halide::Tools::save_image(output2, "./build/divergence2d_ref.png"); return 0; }
int break_Rkey_Xor() { string inputFile; cout << "Enter the name of an existing text file in the current directory: "; cin >> inputFile; //open input file for reading ifstream input(inputFile); string bin_text = ""; //this while loop converts the input to binary form while(input.good()) { char c = input.get(); //if input is still valid if(input.good()) { bin_text += hextobin(c); } } input.close(); int pos[3]; find_shortest_distances(bin_text,pos); vector <string> keyOneBlocks = breakIntoBlocks(pos[0],bin_text); vector <string> keyTwoBlocks = breakIntoBlocks(pos[1],bin_text); vector <string> keyThreeBlocks = breakIntoBlocks(pos[2],bin_text); vector <string> keyOneTranspose = transpose(keyOneBlocks); vector <string> keyTwoTranspose = transpose(keyTwoBlocks); vector <string> keyThreeTranspose = transpose(keyThreeBlocks); ofstream output("keyOneoutput.txt"); for(int i = 0; i < keyOneTranspose.size(); i++) { sByteXor(keyOneTranspose[i],output); } output.close(); ofstream output2("keyTwooutput.txt"); for(int i = 0; i < keyTwoTranspose.size(); i++) { sByteXor(keyTwoTranspose[i],output2); } output2.close(); ofstream output3("keyThreeoutput.txt"); for(int i = 0; i < keyThreeTranspose.size(); i++) { sByteXor(keyThreeTranspose[i],output3); } output3.close(); return 0; }
void main() { exception e; Try{ VTDGen *vg = NULL; /* This is the VTDGen that parses XML */ VTDNav *vn = NULL; /* This is the VTDNav that navigates the VTD records */ AutoPilot *ap = NULL, *ap2=NULL; XMLModifier *xm = NULL; ElementFragmentNs *ef = NULL; int i= -1; Long l= -1; vg = createVTDGen(); ap = createAutoPilot2(); ap2 = createAutoPilot2(); xm = createXMLModifier(); selectXPath(ap,L"(/*/*/*)[position()>1 and position()<4]"); selectXPath(ap2,L"/*/*/*"); if (parseFile(vg,TRUE,"soap2.xml")) { //FILE *f1 = fopen("d:/new3.xml","wb"); vn = getNav(vg); bind(ap,vn); bind(ap2,vn); bind4XMLModifier(xm,vn); evalXPath(ap2); ef = getElementFragmentNs(vn); while( (i=evalXPath(ap))!=-1) { insertAfterElement4(xm,ef); printf(" index %d \n",i); } //fwrite(vn->XMLDoc+vn->docOffset,sizeof(UByte),vn->docLen,f1); output2(xm,"new3.xml"); //fclose(f1); free(vn->XMLDoc); freeVTDNav(vn); } freeElementFragmentNs(ef); freeXMLModifier(xm); freeAutoPilot(ap); freeAutoPilot(ap2); freeVTDGen(vg); } Catch(e) { printf("exception !!!!!!!!!!! \n"); } }
void _ConstructSheets(Source & so,Sink & si) { simpleString filename("build_output.tex"); ofstream output(filename.chars()); MyOstream output2(output); #ifdef WANT_MNGRADAPTER PartialGB & pgb = (PartialGB &) ((ManagerAdapter *)run)->PARTIALGB(); Spreadsheet x(pgb,AdmissibleOrder::s_getCurrent()); #endif #ifdef WANT_MNGRSUPER FactControl & fc = (FactControl &) ((MngrSuper *)run)->GetFactBase(); // GBStream << fc; #if 1 const GBList<int> VEC(fc.indicesOfPermanentFacts()); GBList<int>::const_iterator VECB = VEC.begin(); vector<GroebnerRule> vec; const int VECSZ = VEC.size(); vec.reserve(VECSZ); for(int iii=1;iii<=VECSZ;++iii,++VECB) { vec.push_back(fc.fact(*VECB)); }; Sheet1 x(vec,AdmissibleOrder::s_getCurrent()); #else Spreadsheet x(fc,AdmissibleOrder::s_getCurrent()); x.uglyprint(GBStream); #endif TeXSink tex_sink(output2); #if 0 TeX1Display tester(tex_sink,x,AdmissibleOrder::s_getCurrent()); #endif #if 0 list<GroebnerRule> L; copy(x.d_rules.begin(),x.d_rules.end(),back_inserter(L)); TeX2Display tester(tex_sink,L,AdmissibleOrder::s_getCurrent()); #endif #if 1 TeX3Display tester(tex_sink,x,AdmissibleOrder::s_getCurrent()); #endif tester.perform(); #endif GBStream << '\n'; so.shouldBeEnd(); si.noOutput(); os.flush(); output.close(); };
TEST(PackUnpack, Basic) { nbase::PackBuffer pbuffer; nbase::Pack test_pack(pbuffer); EXPECT_EQ(0, test_pack.size()); test_pack.push_uint8(8); test_pack.push_uint16(16); test_pack.push_uint32(32); test_pack.push_uint64(64); std::string input1 = "test input string 1"; std::string input2 = "test input string 2"; std::string input3 = "test input string 3"; std::string input4 = "test input string 4"; std::string input5 = "test input string 5"; nbase::Varstr var_str(input1.data(), input1.size()); test_pack.push_varstr(var_str); test_pack.push_varstr(input2.c_str()); test_pack.push_varstr(input3); test_pack.push_varstr(input4.data(), input4.size()); test_pack.push_varstr32(input5.data(), input5.size()); nbase::Unpack test_unpack(pbuffer.data(), pbuffer.size()); EXPECT_EQ(8, test_unpack.pop_uint8()); EXPECT_EQ(16, test_unpack.pop_uint16()); EXPECT_EQ(32, test_unpack.pop_uint32()); EXPECT_EQ(64, test_unpack.pop_uint64()); nbase::Varstr var_output1 = test_unpack.pop_varstr_ptr(); std::string output1(var_output1.data(), var_output1.size()); EXPECT_EQ(input1, output1); nbase::Varstr var_output2 = test_unpack.pop_varstr_ptr(); std::string output2(var_output2.data(), var_output2.size()); EXPECT_EQ(input2, output2); nbase::Varstr var_output3 = test_unpack.pop_varstr_ptr(); std::string output3(var_output3.data(), var_output3.size()); EXPECT_EQ(input3, output3); nbase::Varstr var_output4 = test_unpack.pop_varstr_ptr(); std::string output4(var_output4.data(), var_output4.size()); EXPECT_EQ(input4, output4); nbase::Varstr var_output5 = test_unpack.pop_varstr32_ptr(); std::string output5(var_output5.data(), var_output5.size()); EXPECT_EQ(input5, output5); }
void out_matrix (header *hd) /***** out_matrix print a matrix. *****/ { int c,r,i,j,c0,cend; double *m,*x; getmatrix(hd,&r,&c,&m); for (c0=0; c0<c; c0+=linew) { cend=c0+linew-1; if (cend>=c) cend=c-1; if (c>linew) output2("Column %d to %d:\n",c0+1,cend+1); for (i=0; i<r; i++) { x=mat(m,c,i,c0); for (j=c0; j<=cend; j++) double_out(*x++); output("\n"); if (test_key()==escape) return; } } }
int main() { char c[3] = { '1', '2', '3' }; char d[3]; char e[3]; char * s; int length; std::ofstream output("other.bin"); //open da file output.write( c, 3); //writing to a binary file, write( char[], int ) int for how many characters from the array to write onto the file output.close(); //done with the file std::ifstream input("other.bin"); //open da file input.read(d, 3); //simple way to read everything in a binary file, read ( char[], int ) int for how many characters to read input.seekg(0, input.end); //places the cursor at the end of the file, 0 means that it's at position 0 length = input.tellg(); //tellg() returns the int value of how many characters long the file is input.seekg(0, input.beg); //places the cursor at the beginning of the file at position 0 s = new char [ length ]; //make the character array [length] which we just got above input.read(s, length); // read( char *, int ) reads all the data in a binary file up to [length] characters input.close(); //done with the file std::cout.write(s, length); //function to print out everything in char array std::cout << "\n"; //make it pretty delete s; // *s was dynamic, gotta delete it std::ofstream output2 ( "other.txt" ); output2 << c[0] << " " << c[1] << " " << c[2]; output2.close(); std::ifstream input2 ( "other.txt" ); input2 >> e[0] >> e[1] >> e[2]; input2.close(); std::cout << e[0] << " " << e[1] << " " << e[2] << "\n"; std::cout << d[0] << " " << d[1] << " " << d[2] << "\n"; return 0; }
void TestOperator::execute(DataProvider& provider) { if(m_throwException) { throw InternalError("Funny exception."); } Id2DataPair input1(INPUT_1); Id2DataPair input2(INPUT_2); provider.receiveInputData(input1 && input2); // execute... m_numExecutes++; boost::this_thread::sleep_for(boost::chrono::milliseconds(m_sleepTime)); Id2DataPair output1(OUTPUT_1, input1.data()); Id2DataPair output2(OUTPUT_2, input2.data()); provider.sendOutputData(output1 && output2); }
void out_imatrix (header *hd) /***** out_matrix print a complex matrix. *****/ { int c,r,i,j,c0,cend; double *m,*x; getmatrix(hd,&r,&c,&m); for (c0=0; c0<c; c0+=ilinew) { cend=c0+ilinew-1; if (cend>=c) cend=c-1; if (c>ilinew) output2("Column %d to %d:\n",c0+1,cend+1); for (i=0; i<r; i++) { x=imat(m,c,i,c0); for (j=c0; j<=cend; j++) { interval_out(*x,*(x+1)); x+=2; } output("\n"); if (test_key()==escape) return; } } }
int main (int argc, char* argv[]) { //Do it by Forward Euler std::ofstream output("eulerSolution.dat"); assert(output.is_open()); ForwardEulerSolver solver(&myFunc, 0.05, 0.0, 1.0, 2.0); solver.SolveEquation(output); output.close(); //Do it by R-K 4 std::ofstream output2("rkSolution.dat"); assert(output2.is_open()); RungeKuttaFour solver2(&myFunc, 0.05, 0.0, 1.0, 2.0); solver2.SolveEquation(output2); output2.close(); }
int main(){ exception e; VTDGen *vg = NULL; VTDNav *vn = NULL; AutoPilot *ap1 = NULL; XMLModifier *xm = NULL; UCSChar *string = NULL; int i; Long l; ba0=L" "; ba1=L" "; ba2=L" "; ba3=L" "; ba4=L" "; ba5=L" "; Try{ vg = createVTDGen(); if (parseFile(vg,TRUE,"d:/ximpleware_2.2_c/vtd-xml/codeGuru/11/old_cd.xml")==FALSE){ free(vg->XMLDoc); freeVTDGen(vg); return 0; } xm = createXMLModifier(); ap1 = createAutoPilot2(); selectXPath(ap1,L"/CATALOG/CD"); vn = getNav(vg); bind(ap1,vn); bind4XMLModifier(xm,vn); while((i=evalXPath(ap1))!=-1){ convert(vn,xm); } output2(xm,"d:/ximpleware_2.2_c/vtd-xml/codeGuru/11/cd_template.xml"); free(vn->XMLDoc); }Catch(e){// handle various types of exceptions here } freeAutoPilot(ap1); freeXMLModifier(xm); freeVTDGen(vg); freeVTDNav(vn); return 0; }
MangoShadowFetch::MangoShadowFetch (MangoFetchContext &context) : _context(context) { _total_count = -1; _table_name.push(0); ArrayOutput output(_table_name); output.printf(context.context().shadow_table.getName()); output.writeChar(0); ArrayOutput output2(_components_table_name); output2.printf(context.context().shadow_table.getComponentsName()); output2.writeChar(0); _executed = false; _fetch_type = 0; _processed_rows = 0; _end = false; _rowid.ptr()[0] = 0; }
int main(void) { setlocale(LC_CTYPE, "RUSSIAN"); freopen("input2.txt", "r", stdin); //freopen("output.txt", "w", stdout); int m; // Кількість ребер int n; // Кількість вершин int v, u; // Вершини scanf_s("%d%d", &n, &m); for (int i = 1; i <= m; i++) { scanf_s("%d%d", &v, &u); g_s[v][u] = 1; } output1(n); output2(n); output3(n); }
void follow(int connfd, std::vector<std::string> &tokens){ std::cout << "follow execute\n"; std::unique_lock<std::mutex> lck(file3); std::unique_lock<std::mutex> lck2(file4); std::ifstream ifs(get_path(file_id[3])); std::string line, username = tokens[1], newf = tokens[2]; std::vector<std::string> flwing; bool found = false, valid = true; std::ofstream output; std::string temp_file = get_path(file_id[4]); if(ifs.is_open()){ output.open(temp_file); while(getline(ifs, line) && valid){ std::istringstream iss2(line); std::vector<std::string> temp{std::istream_iterator<std::string>{iss2}, std::istream_iterator<std::string>{}}; if(temp[0] == username){ found = true; for(int i = 1; i < temp.size(); i++){ flwing.push_back(temp[i]); if(newf == temp[i]){ std::cout << "cond 1\n"; valid = false; write(connfd, "false", 5); break; } } }else{ output << line << "\n"; } } ifs.close(); output.close(); } if(!found){ std::cout << "cond 2\n"; std::ofstream output2(get_path(file_id[3]), std::ios::app); std::string retval = username + " " + newf; output2 << "\n" << retval; output2.close(); std::string s = "follow " + tokens[1] + " " + tokens[2]; const char *msg = s.c_str(); int len = strlen(msg); if(b3_active){ send(backfd3, msg, len, 0); connect(3); } write(connfd, "true", 4); } if(valid && found){ std::cout << "cond 3\n"; output.open(get_path(file_id[3])); ifs.open(temp_file); while(getline(ifs, line)){ output << line << "\n"; } std::string retval = username + " "; for(int i = 0; i < flwing.size(); i++){ retval += flwing[i]; retval += " "; } retval += newf; output << retval; output.close(); ifs.close(); std::string s = "follow " + tokens[1] + " " + tokens[2]; const char *msg = s.c_str(); int len = strlen(msg); if(b1_active){ send(backfd1, msg, len, 0); connect(1); } if(b2_active){ send(backfd2, msg, len, 0); connect(2); } if(b3_active){ send(backfd3, msg, len, 0); connect(3); } write(connfd, "true", 4); } }
Gui::Gui(){ setupUi(this); pref = new Preferences(this); myOutput = new QTextStream(stdout); if(!QProcessEnvironment().isEmpty()) shell = QProcess::systemEnvironment().filter("SHELL").first().remove("SHELL="); if(shell.isEmpty() && QFile("/bin/bash").exists()) shell = "/bin/bash"; else *myOutput << "E: No shells found! qprogram-starter might not work as expected..."; //Versioning QFile versionFile(":version"); versionFile.open(QIODevice::ReadOnly | QIODevice::Text); QTextStream in(&versionFile); statusBar()->showMessage(tr("Version ") + in.readLine(),15000); versionFile.close(); aborted = false; process2Started = false; dateEdit->setMinimumDate(QDate::currentDate()); dateTimeTimer = new QTimer(this); dateTimeTimer->start(1000); timer = new QTimer(this); process1 = new QProcess(this); process2 = new QProcess(this); logBox1 = new QTextEdit; logBox1->setReadOnly(true); logBox1->resize(520,450); logBox1->setWindowTitle("error log 1"); logBox1->setWindowModality(Qt::NonModal); logBox2 = new QTextEdit; logBox2->setReadOnly(true); logBox2->resize(520,450); logBox2->setWindowTitle("error log 2"); logBox2->setWindowModality(Qt::NonModal); hintMsgBox = new QTextEdit; hintMsgBox->setReadOnly(true); hintMsgBox->resize(520,450); hintMsgBox->setWindowTitle("Info"); hintMsgBox->setWindowModality(Qt::NonModal); hintMsgBox->setHtml(tr("The command in the second text editor (if there is any) will be executed after the first one. The message boxes will close themselves after 10 seconds.<br/>To start a program just type i.e. \"firefox\" or \"firefox www.google.com\" and then click on Start. Commands etc. can be linked by \"&&\" etc. <br/><br/>If the process is \"finished\" although it is still running, then try the --nofork option (i.e. kopete --nofork). Note that this will also occure for some programs like gedit, firefox or gnome-terminal if they are already running.<br/><br/>When you want to start a program or command with sudo, please use for example gksu(do) or kdesu(do).<br/><br/>make examples:<br/> make -C /path/to/project<br/> make clean -C /path/to/project<br/><br/>About Errors:<br/>Because almost every program gives a different error code, it is impossible to say what happend. So just log the output and see what kind of error occured. The output files can be found at <i>~/.qprogram-starter/</i>.<br/><br/>If the shutdown won't work, it means that \"sudo shutdown -P now\" is used. This needs root permissions. You can do the this:<br/><br/>Post the following in a terminal:<pre>EDITOR=nano sudo -E visudo</pre> and add this line:<pre>* ALL = NOPASSWD:/sbin/shutdown</pre> whereas * replaces the username or %groupname.<br/><br/>The configuration-file can be found at <i>~/.qprogram-starter/</i>.")); connect(action_Configure, SIGNAL(triggered(bool)), pref, SLOT(show())); connect(dateTimeTimer, SIGNAL(timeout()), this, SLOT(currentDateAndTime())); connect(startB, SIGNAL(clicked(bool)), this, SLOT(run())); connect(abortB, SIGNAL(clicked(bool)), this, SLOT(abortProcesses())); connect(saveButton, SIGNAL(clicked(bool)), this, SLOT(saveData())); connect(timer, SIGNAL(timeout()), this, SLOT(check())); connect(browse1, SIGNAL(clicked(bool)), this, SLOT(getProgram1())); connect(browse2, SIGNAL(clicked(bool)), this, SLOT(getProgram2())); connect(process1, SIGNAL(readyReadStandardOutput()), this, SLOT(output1())); connect(process1, SIGNAL(readyReadStandardError()), this, SLOT(errorOutput1())); connect(process1, SIGNAL(finished(int)), this, SLOT(checkForProcess2())); connect(process1, SIGNAL(error(QProcess::ProcessError)), this, SLOT(message())); connect(process2, SIGNAL(readyReadStandardOutput()), this, SLOT(output2())); connect(process2, SIGNAL(readyReadStandardError()), this, SLOT(errorOutput2())); connect(process2, SIGNAL(finished(int)), this, SLOT(shutdown_or_message())); connect(process2, SIGNAL(error(QProcess::ProcessError)), this, SLOT(message())); connect(this, SIGNAL(finished()), this, SLOT(shutdown_or_message())); connect(action_Hints, SIGNAL(triggered(bool)), this, SLOT(info_hint())); connect(showLogsButton, SIGNAL(clicked(bool)), this, SLOT(showLogs())); }
//--------------------------------------------------------------------------- int __stdcall validate(Block *aBlock) { if((aBlock->input.size() == 0) && (aBlock->output.size() == 0)) { BlockInput input1("input1"); input1.allowedTypes.push_back("Bitmap1bit"); input1.allowedTypes.push_back("Bitmap4bit"); input1.allowedTypes.push_back("Bitmap8bit"); input1.allowedTypes.push_back("Bitmap16bit"); input1.allowedTypes.push_back("Bitmap24bit"); input1.allowedTypes.push_back("Bitmap32bit"); input1.setDescription("Domyslne wejscie"); input1.setErrorCode(1); input1.setErrorDescription("Brak obiektu na wejsciu"); aBlock->input.push_back(input1); BlockOutput output1("output1"); output1.setOutputType("Bitmap8bit"); output1.setDescription("Domyslne wyjscie"); output1.setErrorCode(1); output1.setErrorDescription("Brak obiektu na wejsciu"); aBlock->output.push_back(output1); BlockOutput output2("output2"); output2.setOutputType("Bitmap8bit"); output2.setDescription("Domyslne wyjscie"); output2.setErrorCode(1); output2.setErrorDescription("Brak obiektu na wejsciu"); aBlock->output.push_back(output2); return 2; } else { if(aBlock->input[0].getConnectedType().IsEmpty()) { aBlock->input[0].setErrorCode(1); aBlock->input[0].setErrorDescription("Brak obiektu na wejsciu"); aBlock->output[0].setErrorCode(1); aBlock->output[0].setErrorDescription("Brak obiektu na wejsciu"); aBlock->output[0].setOutputType("Bitmap8bit"); aBlock->output[1].setErrorCode(1); aBlock->output[1].setErrorDescription("Brak obiektu na wejsciu"); aBlock->output[1].setOutputType("Bitmap8bit"); return 1; } else { if(aBlock->input[0].getErrorCode() != 0 || aBlock->output[0].getErrorCode() != 0 || aBlock->output[1].getErrorCode() != 0) { aBlock->input[0].setErrorCode(0); aBlock->output[0].setErrorCode(0); aBlock->output[1].setErrorCode(0); aBlock->input[0].setErrorDescription(""); aBlock->output[0].setErrorDescription(""); aBlock->output[1].setErrorDescription(""); return 1; } else return 0; } } }
void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud) { PCProc<pcl::PointXYZRGBA> pc1; pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_filtered (new pcl::PointCloud<pcl::PointXYZRGBA>); pcl::PointCloud<pcl::PointXYZRGBA>::Ptr output1 (new pcl::PointCloud<pcl::PointXYZRGBA>); if(bVoxelGrid) { pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr inputc = cloud;//.makeShared(); pc1.downSampling(inputc,output1 , leafsz,leafsz,leafsz); } else { output1 = cloud->makeShared(); } /////////////////////////////////////// // passthrough pcl::PointCloud<pcl::PointXYZRGBA>::Ptr output2 (new pcl::PointCloud<pcl::PointXYZRGBA>); pc1.PassThroughZ(output1, output2, 1, 3); cloud_filtered = output2; /////////////////////////////////////// // normal display pcl::NormalEstimation<pcl::PointXYZRGBA, pcl::Normal> ne; ne.setInputCloud (output2); // Create an empty kdtree representation, and pass it to the normal estimation object. // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given). pcl::search::KdTree<pcl::PointXYZRGBA>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZRGBA> ()); ne.setSearchMethod (tree); // Output datasets pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>); // Use all neighbors in a sphere of radius 3cm ne.setRadiusSearch (0.03); // Compute the features ne.compute (*cloud_normals); //viewer.addPointCloudNormals<pcl::PointXYZ,pcl::Normal>(cloud, cloud_normals, 1, 0.01, "normals1", 0); int nf = cloud_filtered->size(); int n = cloud->size(); lpMapping[0] = n; lpMapping[1] = nf; lpMapping[2] = bVoxelGrid; lpMapping[3] = leafsz; ; int i; for(i=0; i<nf; i++)//DATA_LEN/6 { float x = cloud_filtered->points[i].x; lpMapping[HEADER_LEN + 6*i +0] = cloud_filtered->points[i].x; lpMapping[HEADER_LEN + 6*i +1] = cloud_filtered->points[i].y; lpMapping[HEADER_LEN + 6*i +2] = cloud_filtered->points[i].z; lpMapping[HEADER_LEN + 6*i +3] = cloud_filtered->points[i].r; lpMapping[HEADER_LEN + 6*i +4] = cloud_filtered->points[i].g; lpMapping[HEADER_LEN + 6*i +5] = cloud_filtered->points[i].b; } //viewer.addPointCloud<pcl::PointXYZ> (cloud, "sample cloud"); if (!viewer.wasStopped()) { viewer.showCloud (cloud_filtered); } }
void MainWindow::createActions() { newAction = new QAction(tr("&New"), this); newAction->setIcon(QIcon(":/images/filenew.png")); newAction->setShortcut(QKeySequence::New); newAction->setStatusTip(tr("Create a new file")); connect(newAction, SIGNAL(triggered()), this, SLOT(newFile())); openAction = new QAction(tr("&Open..."), this); openAction->setIcon(QIcon(":/images/fileopen.png")); openAction->setShortcut(QKeySequence::Open); openAction->setStatusTip(tr("Open an existing file")); connect(openAction, SIGNAL(triggered()), this, SLOT(open())); printAction = new QAction(QIcon(":/images/fileprint.png"), tr("&Print"), this); printAction->setShortcut(QKeySequence::Print); printAction->setStatusTip(tr("Print File")); connect(printAction, SIGNAL(triggered()), this, SLOT(print())); saveAction = new QAction(tr("&Save"), this); saveAction->setIcon(QIcon(":/images/filesave.png")); saveAction->setShortcut(QKeySequence::Save); saveAction->setStatusTip(tr("Save the file to disk")); connect(saveAction, SIGNAL(triggered()), this, SLOT(save())); saveAsAction = new QAction(tr("Save &As..."), this); saveAsAction->setIcon(QIcon(":/images/filesave.png")); saveAsAction->setStatusTip(tr("Save the file under a new name")); connect(saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs())); exitAction = new QAction(tr("&Quit..."), this); exitAction->setShortcut(tr("Ctrl+Q")); exitAction->setStatusTip(tr("Exit the application")); connect(exitAction, SIGNAL(triggered()), this, SLOT(closep())); cutAction = new QAction(tr("Cu&t"), this); cutAction->setIcon(QIcon(":/images/editcut.png")); cutAction->setShortcut(QKeySequence::Cut); cutAction->setStatusTip(tr("Cut the current selection to the clipboard")); connect(cutAction, SIGNAL(triggered()), this, SLOT(cut())); copyAction = new QAction(tr("&Copy"), this); copyAction->setIcon(QIcon(":/images/editcopy.png")); copyAction->setShortcut(QKeySequence::Copy); copyAction->setStatusTip(tr("Copy the current selection to the clipboard")); connect(copyAction, SIGNAL(triggered()), this, SLOT(copy())); pasteAction = new QAction(tr("&Paste"), this); pasteAction->setIcon(QIcon(":/images/editpaste.png")); pasteAction->setShortcut(QKeySequence::Paste); pasteAction->setStatusTip(tr("Paste the clipboard's contents at the cursor position")); connect(pasteAction, SIGNAL(triggered()), this, SLOT(paste())); //---------------------------------------------------------- textBoldAction = new QAction(QIcon(":/images/textbold.png"), tr("&Bold"), this); textBoldAction->setShortcut(Qt::CTRL + Qt::Key_B); textBoldAction->setStatusTip(tr("Text Bold")); QFont bold; bold.setBold(true); textBoldAction->setFont(bold); textBoldAction->setCheckable(true); connect(textBoldAction, SIGNAL(triggered()), this, SLOT(textBold())); textItalicAction = new QAction(QIcon(":/images/textitalic.png"), tr("&Italic"), this); textItalicAction->setShortcut(Qt::CTRL + Qt::Key_I); textItalicAction->setStatusTip(tr("Text Italic")); QFont italic; italic.setItalic(true); textItalicAction->setFont(italic); textItalicAction->setCheckable(true); connect(textItalicAction, SIGNAL(triggered()), this, SLOT(textItalic())); textUnderlineAction = new QAction(QIcon(":/images/textunder.png"), tr("&Underline"), this); textUnderlineAction->setShortcut(Qt::CTRL + Qt::Key_U); textUnderlineAction->setStatusTip(tr("Text Underline")); QFont underline; underline.setUnderline(true); textUnderlineAction->setFont(underline); textUnderlineAction->setCheckable(true); connect(textUnderlineAction, SIGNAL(triggered()), this, SLOT(textUnderline())); QPixmap pix(16, 16); pix.fill(Qt::black); textColorAction = new QAction(pix, tr("&Color..."), this); textColorAction->setStatusTip(tr("Select Text Color")); connect(textColorAction, SIGNAL(triggered()), this, SLOT(textColor())); //create font toolbar toolbFont = new QToolBar(this); toolbFont->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea); toolbFont->setWindowTitle(tr("Format Actions")); addToolBarBreak(Qt::TopToolBarArea); //addToolBar(toolbFont); //moved to createtoolbar //create fontcombobox comboFont = new QFontComboBox(toolbFont); toolbFont->addWidget(comboFont); comboFont->setToolTip("Set Font Type"); comboFont->setStatusTip("Select Font Type"); connect(comboFont, SIGNAL(activated(const QString &)), this, SLOT(textFamily(const QString &))); //create fontsize combobox comboSize = new QComboBox(toolbFont); comboSize->setObjectName("comboSize"); toolbFont->addWidget(comboSize); comboSize->setToolTip("Set Font Size"); comboSize->setStatusTip("Select Font Size"); comboSize->setEditable(true); QFontDatabase db; foreach(int size, db.standardSizes()) comboSize->addItem(QString::number(size)); connect(comboSize, SIGNAL(activated(const QString &)), this, SLOT(textSize(const QString &))); comboSize->setCurrentIndex(comboSize->findText(QString::number(QApplication::font().pointSize()))); setFontAction = new QAction(tr("&Font"), this); setFontAction->setShortcut(Qt::CTRL + Qt::Key_F); setFontAction->setStatusTip(tr("Set Font")); connect(setFontAction, SIGNAL(triggered()), this, SLOT(setFont())); //---------------------------------------------------------- inputAction = new QAction(tr("Input"), this); inputAction->setShortcut(Qt::CTRL + Qt::Key_A); inputAction->setStatusTip(tr("Select Input Paramerters")); connect(inputAction, SIGNAL(triggered()), this, SLOT(inputparameters())); output1Action = new QAction(tr("Output1"), this); output1Action->setShortcut(Qt::CTRL + Qt::Key_R); output1Action->setStatusTip(tr("Output 1")); connect(output1Action, SIGNAL(triggered()), this, SLOT(output1())); output2Action = new QAction(tr("Output2"), this); output2Action->setShortcut(Qt::CTRL + Qt::Key_T); output2Action->setStatusTip(tr("Output 2")); connect(output2Action, SIGNAL(triggered()), this, SLOT(output2())); //---------------------------------------------------------- closeAction = new QAction(tr("Cl&ose"), this); closeAction->setShortcut(QKeySequence::Close); closeAction->setStatusTip(tr("Close the active window")); connect(closeAction, SIGNAL(triggered()), mdiArea, SLOT(closeActiveSubWindow())); closeAllAction = new QAction(tr("Close &All"), this); closeAllAction->setStatusTip(tr("Close all windows")); connect(closeAllAction, SIGNAL(triggered()), mdiArea, SLOT(closeAllSubWindows())); tileAction = new QAction(tr("&Tile"), this); tileAction->setStatusTip(tr("Tile the windows")); connect(tileAction, SIGNAL(triggered()), mdiArea, SLOT(tileSubWindows())); cascadeAction = new QAction(tr("&Cascade"), this); cascadeAction->setStatusTip(tr("Cascade the windows")); connect(cascadeAction, SIGNAL(triggered()), mdiArea, SLOT(cascadeSubWindows())); nextAction = new QAction(tr("Ne&xt"), this); nextAction->setShortcut(QKeySequence::NextChild); nextAction->setStatusTip(tr("Move the focus to the next window")); connect(nextAction, SIGNAL(triggered()), mdiArea, SLOT(activateNextSubWindow())); previousAction = new QAction(tr("Pre&vious"), this); previousAction->setShortcut(QKeySequence::PreviousChild); previousAction->setStatusTip(tr("Move the focus to the previous window")); connect(previousAction, SIGNAL(triggered()), mdiArea, SLOT(activatePreviousSubWindow())); separatorAction = new QAction(this); separatorAction->setSeparator(true); aboutAction = new QAction(tr("&About"), this); aboutAction->setStatusTip(tr("the application's About box")); connect(aboutAction, SIGNAL(triggered()), this, SLOT(about())); aboutQtAction = new QAction(tr("About &Qt"), this); aboutQtAction->setStatusTip(tr("the Qt library's About box")); connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); windowActionGroup = new QActionGroup(this); }