Exemplo n.º 1
0
void CTraderApi::AddToSendQueue(SRequest * pRequest)
{
	if (NULL == pRequest)
		return;

	CLock cl(&m_csList);
	bool bFind = false;

	if (!bFind)
		m_reqList.push_back(pRequest);

	if (NULL == m_hThread
		&&!m_reqList.empty())
	{
		m_bRunning = true;
		m_hThread = CreateThread(NULL,0,SendThread_TD,this,0,NULL); 
	}
}
Exemplo n.º 2
0
bool
manager::wait_for_next(void)
{
   client *cl((client*)pthread_getspecific(client_key));
   assert(cl != NULL);

   cl->cunits++;

   while(cl->counter <= 0) {
      if(cl->done)
         return true;
      usleep(100);
   }
   if(cl->done)
      return true;
   cl->counter--;
   return true;
}
Exemplo n.º 3
0
inline T& UMatrix2D<T>::GetValue(unsigned int x,unsigned int y)
{
#ifdef _SAFE_ACCESS_
    CheckLocker cl(GetLocker());
#endif //_SAFE_ACCESS_
    
    if(x>=nX) {
        ms=MXS_ERR_OUT_OF_INDEX;throw(this);
    } else if(y>=nY) {
        ms=MXS_ERR_OUT_OF_INDEX;throw(this);
    } else ms = MXS_OK;
    
    if(mso == MSO_XY)
        return Ptr[y*nX + x];
    else
        return Ptr[x*nY + y];
    //  return Ptr[ATF(x,y,atfN)]; 
}
Exemplo n.º 4
0
void CTraderApi::AddRequestMapBuf(int nRequestID,SRequest* pRequest)
{
	if(NULL == pRequest)
		return;

	CLock cl(&m_csMap);
	map<int,SRequest*>::iterator it = m_reqMap.find(nRequestID);
	if (it!=m_reqMap.end())
	{
		SRequest* p = it->second;
		if(pRequest != p)//如果实际上指的是同一内存,不再插入
		{
			delete p->pBuf;
			delete p;
			m_reqMap[nRequestID] = pRequest;
		}
	}
}
Exemplo n.º 5
0
void read_clique(vector<vector<int>> &neutral_vectors){
	ifstream cl("clique.txt");
	int count = -1;
	string c;
	while (!cl.eof())
	{
		getline(cl, c);
		count++;
	}
	cl.close();
	cl.open("clique.txt");
	vector<int> init = { -1, -1, -1, -1, -1 };
	for (int v = 0; v < count; v++){
		neutral_vectors.push_back(init);
		cl >> neutral_vectors[v][0] >> neutral_vectors[v][1] >> neutral_vectors[v][2] >> neutral_vectors[v][3] >> neutral_vectors[v][4];
	}
	cl.close();
}
Exemplo n.º 6
0
  //////////////////////////////////////////////////////////////////////
  // get PBS Job full status (qstat -f job_id)
  //
  jobstat_ptr qstat::get_full_status(std::string id,
				     std::ostringstream& os)
  {
    //bp::command_line cl(command, command, path);
    
    jobstat_ptr ret_val;
    
    try {
      bp::command_line cl(command);
  
      cl.argument("-f");
  //    cl.argument("@nrg04.cc.kek.jp");
      cl.argument(id);
  
      bp::launcher l;
      l.set_stdout_behavior(bp::redirect_stream);
      l.set_stderr_behavior(bp::redirect_stream);
  
      bp::child c = l.start(cl);
  
      bp::pistream& stdout = c.get_stdout();
  
  //    if(!stdout){
  //    	std::cout << "pistream is empty" << std::endl;
  //    }
  
      jobstat_ptr fullstat = builder.create(stdout);
      stdout.close();
  
      bp::status s = c.wait();
      if (s.exited() && s.exit_status() == EXIT_SUCCESS) {
        ret_val = fullstat;
      } else {
        error_handling(c.get_stderr(), os);
        jobstat_ptr empty_data;
        ret_val = empty_data;
      }
    }
    catch(std::exception const &e) {
      SAGA_ADAPTOR_THROW_NO_CONTEXT(e.what(), saga::NoSuccess);
    }
    
    return ret_val;
  }
Exemplo n.º 7
0
static
void
hs_dummy_kernel_enqueue(cl_command_queue cq,
                        uint32_t         wait_list_size,
                        cl_event const * wait_list,
                        cl_event       * event)
{
  size_t const global_work_size = 1;

  cl(EnqueueNDRangeKernel(cq,
                          hs_dummy_kernel,
                          1,
                          NULL,
                          &global_work_size,
                          NULL,
                          wait_list_size,
                          wait_list,
                          event));
}
Exemplo n.º 8
0
void InterpretTest::callTest()
{
	ConstantPool * pool = new ConstantPool();
	Class * cls = initClass("CallTest", pool);
	const char code1[] = 
	{
		RET_VOID
	};
	const char code2[] = 
	{
		PUSH, 0x00, 0x00,
		RET
	};
	const char code[] =
	{
		CALL, 0x01, 0x00, 0x02, 0x00, //ClassRef na pozici 1, MethodRef na pozici 2
		CALL, 0x01, 0x00, 0x03, 0x00, //ClassRef na pozici 1, MethodRef na pozici 3
		RET
	};
	Method * m = initMethod("callTest", code, sizeof(code), 0, 0, 0);
	Method * m1 = initMethod("returnVoid", code1, sizeof(code1), 0, 0, 0);
	Method * m2 = initMethod("returnInt", code2, sizeof(code2), 0, 0, 0);
	ClassLoader cl("");
	Interpret instance(&cl);
	IntConst i;
	i.value = 1;
	pool->addItem(&i, INT_CONST);//0
	ClassRef cr;
	memset(cr.name, 0x00, IDENTIFIER_LENGTH);
	sprintf(cr.name, "%s", cls->getName().c_str());
	pool->addItem(&cr, CLASS_REF);//1
	MethodRef mr;
	sprintf(mr.name, "%s", m1->getName().c_str());
	mr.params = 0;
	pool->addItem(&mr, METHOD_REF);//2
	sprintf(mr.name, "%s", m2->getName().c_str());
	pool->addItem(&mr, METHOD_REF);//3
	cls->addMethod(m);
	cls->addMethod(m1);
	cls->addMethod(m2);
	cl.addClass(cls);
	assert(1 == instance.run(cls->getName().c_str(), m->getName().c_str()));
}
Exemplo n.º 9
0
void HRInto_G1RemSet::updateRS(int worker_i) {
  ConcurrentG1Refine* cg1r = _g1->concurrent_g1_refine();

  double start = os::elapsedTime();
  _g1p->record_update_rs_start_time(worker_i, start * 1000.0);

  // Apply the appropriate closure to all remaining log entries.
  _g1->iterate_dirty_card_closure(false, worker_i);
  // Now there should be no dirty cards.
  if (G1RSLogCheckCardTable) {
    CountNonCleanMemRegionClosure cl(_g1);
    _ct_bs->mod_card_iterate(&cl);
    // XXX This isn't true any more: keeping cards of young regions
    // marked dirty broke it.  Need some reasonable fix.
    guarantee(cl.n() == 0, "Card table should be clean.");
  }

  _g1p->record_update_rs_time(worker_i, (os::elapsedTime() - start) * 1000.0);
}
Exemplo n.º 10
0
void initParserByString(char * str)
{
	pSt.type = PT_STRING;

	cl();
	waitLex();

	if (pSt.srcStr != NULL)
		free(pSt.srcStr);
	pSt.srcStr = str;
	/*pSt.fileStr = NULL;*/

	if (pSt.list == NULL)
		pSt.list = newLexList();
	else
		clearLexList(pSt.list);

	initLexerByString(str);
}
Exemplo n.º 11
0
void clearParser()
{
	pSt.type = PT_STDIN;

	cl();
	waitLex();

	pSt.srcStr = NULL;
	/*pSt.fileStr = NULL;*/

	if (pSt.list != NULL)
	{
		clearLexList(pSt.list);
		free(pSt.list);
		pSt.list = NULL;
	}

	clearLexer();
}
Exemplo n.º 12
0
  void scanCard(size_t index, HeapRegion *r) {
    // Stack allocate the DirtyCardToOopClosure instance
    HeapRegionDCTOC cl(_g1h, r, _oc,
                       CardTableModRefBS::Precise);

    // Set the "from" region in the closure.
    _oc->set_region(r);
    MemRegion card_region(_bot_shared->address_for_index(index), G1BlockOffsetSharedArray::N_words);
    MemRegion pre_gc_allocated(r->bottom(), r->scan_top());
    MemRegion mr = pre_gc_allocated.intersection(card_region);
    if (!mr.is_empty() && !_ct_bs->is_card_claimed(index)) {
      // We make the card as "claimed" lazily (so races are possible
      // but they're benign), which reduces the number of duplicate
      // scans (the rsets of the regions in the cset can intersect).
      _ct_bs->set_card_claimed(index);
      _cards_done++;
      cl.do_MemRegion(mr);
    }
  }
Exemplo n.º 13
0
static
void
skc_raster_builder_pfn_release(struct skc_raster_builder_impl * const impl)
{
  // decrement reference count
  if (--impl->raster_builder->refcount != 0)
    return;

  //
  // otherwise, dispose of the the raster builder and its impl
  //
  struct skc_runtime * const runtime = impl->runtime;

  // free the raster builder
  skc_runtime_host_perm_free(runtime,impl->raster_builder);

  // free durable/perm extents
  skc_extent_phrwg_thr1s_free(runtime,&impl->path_ids);
  skc_extent_phw1g_tdrNs_free(runtime,&impl->transforms);
  skc_extent_phw1g_tdrNs_free(runtime,&impl->clips);
  skc_extent_phw1g_tdrNs_free(runtime,&impl->fill_cmds);
  skc_extent_phrwg_tdrNs_free(runtime,&impl->raster_ids);

  // release kernels
  cl(ReleaseKernel(impl->kernels.fills_expand));
  cl(ReleaseKernel(impl->kernels.rasterize_all));

#if 0
  cl(ReleaseKernel(impl->kernels.rasterize_lines));
  cl(ReleaseKernel(impl->kernels.rasterize_quads));
  cl(ReleaseKernel(impl->kernels.rasterize_cubics));
#endif

  cl(ReleaseKernel(impl->kernels.segment));
  cl(ReleaseKernel(impl->kernels.rasters_alloc));
  cl(ReleaseKernel(impl->kernels.prefix));

  // free the impl
  skc_runtime_host_perm_free(runtime,impl);
}
Exemplo n.º 14
0
int main (int argc, char *argv[] )

{
  ODABAClient      uti_client(argc > 1 ? argv[1] : NULL,"WorkSpace",argv[0],APT_Console);
  CommandLine      cl(NULL);
  char             tree_opt[3];
  logical          term = NO;
BEGINSEQ

  CSUtilityHandle  uti_handle(uti_client,"WorkSpace",argc > 1 ? argv[1] : NULL,argv[0],APT_Console);
  
  std::cout << std::endl << "Running Workspace Utility ..." << std::endl;
  std::cout.flush();
  
  if ( CheckRuntimeParms(argc,argv,4,7) )            ERROR
  if ( uti_handle.sdbures->SetupVariables(argv[2]) ) ERROR

  cl.InputFromArguments(argc,argv);
  
  *tree_opt = 0;
  if ( cl.GetOption('T') || cl.GetOption('t') )  
    strcpy(tree_opt,"-T");
    
  if ( UWorkspace(uti_handle,cl.Parm(2),cl.Parm(3),cl.Parm(4),tree_opt) )
                                                     ERROR
  
  std::cout << std::endl << argv[3] << " Workspace terminated successfully." << std::endl;
  std::cout.flush();


RECOVER

  std::cout << std::endl << (argc > 3 ? argv[3] : "")    << " Workspace"
       << (argc > 3 ? "" : " Utility") << " terminated with errors. See error log for details." << std::endl;
  std::cout.flush();
  term = YES;

ENDSEQ

  uti_client.ShutDown();
  return(term);
}
Exemplo n.º 15
0
void InterpretTest::consoleTest()
{
	ConstantPool * pool = new ConstantPool();
	Class * cls = initClass("ConsoleTest", pool);
	const char code[] = 
	{
		PUSH, 0x00, 0x00,
		CALL, 0x01, 0x00, 0x02, 0x00, //console.print(20)
		CALL, 0x01, 0x00, 0x03, 0x00, //line = console.readLine()
		CALL, 0x01, 0x00, 0x02, 0x00, //console.print(line)
		CALL, 0x01, 0x00, 0x04, 0x00, //i = console.readInt()
		CALL, 0x01, 0x00, 0x02, 0x00, //console.print(i)
		CALL, 0x01, 0x00, 0x05, 0x00, //i = console.readReal()
		CALL, 0x01, 0x00, 0x02, 0x00, //console.print(i)
		RET_VOID
	};
	Method * m = initMethod("consoleTest", code, sizeof(code), 0, 2, 0);
	ClassLoader cl("");
	Interpret instance(&cl);
	IntConst i;
	i.value = 20;
	pool->addItem(&i, INT_CONST);//0
	ClassRef cr;
	sprintf(cr.name, "%s", CONSOLE_CLASS);//1
	pool->addItem(&cr, CLASS_REF);
	MethodRef mr;
	sprintf(mr.name, "print");
	mr.params = 1;
	pool->addItem(&mr, METHOD_REF);//2
	sprintf(mr.name, "readLine");
	mr.params = 0;
	pool->addItem(&mr, METHOD_REF);//3
	sprintf(mr.name, "readInt");
	mr.params = 0;
	pool->addItem(&mr, METHOD_REF);//4
	sprintf(mr.name, "readReal");
	mr.params = 0;
	pool->addItem(&mr, METHOD_REF);//5
	cls->addMethod(m);
	cl.addClass(cls);
	instance.run(cls->getName().c_str(), m->getName().c_str());
}
Exemplo n.º 16
0
QString CardOCR::suit(const QImage * img_wb, const QImage * img)
{
   if ((img_wb->width() != img->width()) ||
      (img_wb->height() != img->height()))
      return QString();

   const int w = img->width();
   const int h = img->height();
   
   QRgb clMinValue;
   qreal minVal = 1.0;
   for (int x = 0; x < w; ++x)
   {
      for (int y = 0; y < h; ++y)
      {
         QRgb rgb_wb = img_wb->pixel(x, y);
         //рассматриваем только черные точки
         if (rgb_wb == qRgb(0, 0, 0))
         {
            QRgb rgb = img->pixel(x, y);
            QColor cl(rgb);
            if (cl.valueF() < minVal)
            {
               minVal = cl.valueF();
               clMinValue = rgb;
               //qDebug() << x << y;
            }
         }
      }
   }
   
   if (isRed(clMinValue))
      return "h";
   else if (isBlue(clMinValue))
      return "d";
   else if (isGreen(clMinValue))
      return "c";
   else
      return "s";

   return QString();
}
Exemplo n.º 17
0
void JoinCommand :: BuildJoinSpecs( const string & js ) {

	if ( js == "" ) {
		CSVTHROW( "No join specified with " << FLAG_COLS << " flag" );
	}

	ALib::CommaList cl( js );
	for ( unsigned int i = 0; i < cl.Size(); i++ ) {
		vector <string> cols;
		if ( ALib::Split( cl.At(i), ':', cols ) != 2 ) {
			CSVTHROW( "Invalid join specification: " << cl.At(i) );
		}
		int c1 = ALib::ToInteger( cols[0], "Invalid column: " + cols[0] );
		int c2 = ALib::ToInteger( cols[1], "Invalid column: " + cols[1] );
		if ( c1 < 1 || c2 < 1 ) {
			CSVTHROW( "Invalid join specfication: " << cl.At(i) );
		}
		mJoinSpecs.push_back( std::make_pair( c1 - 1, c2 - 1 ) );
	}
}
Exemplo n.º 18
0
void VCCueList_Test::keySequences()
{
    QWidget w;

    VCCueList cl(&w, m_doc);
    cl.setNextKeySequence(QKeySequence(keySequenceB));
    QCOMPARE(cl.nextKeySequence(), QKeySequence(keySequenceB));
    QCOMPARE(cl.previousKeySequence(), QKeySequence());
    QCOMPARE(cl.playbackKeySequence(), QKeySequence());

    cl.setPreviousKeySequence(QKeySequence(keySequenceA));
    QCOMPARE(cl.nextKeySequence(), QKeySequence(keySequenceB));
    QCOMPARE(cl.previousKeySequence(), QKeySequence(keySequenceA));
    QCOMPARE(cl.playbackKeySequence(), QKeySequence());

    cl.setPlaybackKeySequence(QKeySequence(keySequenceD));
    QCOMPARE(cl.nextKeySequence(), QKeySequence(keySequenceB));
    QCOMPARE(cl.previousKeySequence(), QKeySequence(keySequenceA));
    QCOMPARE(cl.playbackKeySequence(), QKeySequence(keySequenceD));
}
Exemplo n.º 19
0
int main(int /*argc*/, char ** /*argv*/) {
  starpu::init();

  starpu::codelet cl(STARPU_CPU, cpu_func);

  struct params params = { 1, 2.0f };

  starpu::task task(cl);
  task
    .set_sync()
    .arg(&params)
    .callback(callback_func, (void*) 0x42);

  starpu::submit(task);

  // terminate StarPU
  starpu::shutdown();

  return 0;
}
Exemplo n.º 20
0
void NR::bcucof(Vec_I_DP &y, Vec_I_DP &y1, Vec_I_DP &y2, Vec_I_DP &y12,
	const DP d1, const DP d2, Mat_O_DP &c)
{
	static int wt_d[16*16]=
		{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
		-3, 0, 0, 3, 0, 0, 0, 0,-2, 0, 0,-1, 0, 0, 0, 0,
		2, 0, 0,-2, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0,
		0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
		0, 0, 0, 0,-3, 0, 0, 3, 0, 0, 0, 0,-2, 0, 0,-1,
		0, 0, 0, 0, 2, 0, 0,-2, 0, 0, 0, 0, 1, 0, 0, 1,
		-3, 3, 0, 0,-2,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0,-3, 3, 0, 0,-2,-1, 0, 0,
		9,-9, 9,-9, 6, 3,-3,-6, 6,-6,-3, 3, 4, 2, 1, 2,
		-6, 6,-6, 6,-4,-2, 2, 4,-3, 3, 3,-3,-2,-1,-1,-2,
		2,-2, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 2,-2, 0, 0, 1, 1, 0, 0,
		-6, 6,-6, 6,-3,-3, 3, 3,-4, 4, 2,-2,-2,-2,-1,-1,
		4,-4, 4,-4, 2, 2,-2,-2, 2,-2,-2, 2, 1, 1, 1, 1};
	int l,k,j,i;
	DP xx,d1d2;
	Vec_DP cl(16),x(16);
	static Mat_INT wt(wt_d,16,16);

	d1d2=d1*d2;
	for (i=0;i<4;i++) {
		x[i]=y[i];
		x[i+4]=y1[i]*d1;
		x[i+8]=y2[i]*d2;
		x[i+12]=y12[i]*d1d2;
	}
	for (i=0;i<16;i++) {
		xx=0.0;
		for (k=0;k<16;k++) xx += wt[i][k]*x[k];
		cl[i]=xx;
	}
	l=0;
	for (i=0;i<4;i++)
		for (j=0;j<4;j++) c[i][j]=cl[l++];
}
Exemplo n.º 21
0
int maxHue(const QImage & img)
{
   QMap<int, int> hueGist;
   QMap<int, int> hueGray;

   const int width = img.width();
   const int height = img.height();
   for (int x = 0; x < width; ++x)
   {
      for (int y = 0; y < height; ++y)
      {
         QRgb rgb = img.pixel(x, y);
         QColor cl(rgb);
         if (cl.red() > 200 && cl.green() > 200 && cl.blue() > 200)
            continue;
         
         int gr = qGray(rgb);
         //int hu = cl.hue();
         //if (hu != -1)
         //   hueGist[hu]++;
         hueGray[gr]++;
      }
   }
   //qDebug() << hueGist;
   //qDebug() << hueGray;

   int maxHueCount = 0;
   int maxHueValue = 0;
   int maxGray = 0;
   foreach (int hue, hueGray.keys())
   {
      if (hueGray[hue] > maxHueCount)
      {
         maxHueCount = hueGray[hue];
         maxHueValue = hue;
         maxGray = hueGray[hue];
      }
   }
   return maxHueValue;
   //return maxGray;
}
Exemplo n.º 22
0
int main()
{
	boost::asio::io_service ios;
	IpcClient cl(ios, "127.0.0.1", 7171);
	ios.run();
	bool read = true;
	std::function<void(const std::string& s)> a = boost::bind(PrintPayload, _1);
	std::string test{ "sendinc async+wait on read" };
	while (read)
	{
		char x;
		x = getchar();
		switch (x)
		{
		case 'q':
			read = false;
			break;
		case 'h':
			PrintHelp();
			break;
		case 'w':
			std::cout << "sendinc symple async" << std::endl;
			cl.SendAsyncString("sendinc symple async");
			break;
		case 'e':
			std::cout << test << std::endl;
			cl.SendAsyncString(test, &a);//[&](const std::string& s)->void{std::cout << "payload: " << s << std::endl; }
			break;
		case 'r':

			break;
		case 't':

			break;
		default:
			std::cout << "problem" << std::endl;
			break;
		}
	}
	getchar();
}
Exemplo n.º 23
0
bool init_params(int argc, char** argv, po::variables_map* cfg) {
	po::options_description cl("\nPerforms bm25-based batch retrieval based on Ture's SIGIR'12 models for a set of queries on a document tf collection coming from STDIN.\nCommand Line Options");
	cl.add_options()
			("queries,q", po::value<string>(), "* File containing Queries")
			("dftable,d", po::value<string>(), "* table containing the df values")
			("K,k", po::value<int>(), "* Keep track of K-best documents per query. (Number of results per query)")
			("N,n", po::value<double>(), "Number of documents in collection (for idf calculation)")
			("avg_len,a", po::value<double>(), "* Average length of documents (required for BM25)")
			("run-id,r", po::value<string>()->default_value("1"), "run id shown in the output")
			("show-empty-results",po::value<bool>()->zero_tokens(), "set this if you want to include dummy output for proper scoring (default false)");

	po::store(parse_command_line(argc, argv, cl), *cfg);
	po::notify(*cfg);

	if(!cfg->count("queries") || !cfg->count("K") || !cfg->count("dftable") || !cfg->count("avg_len")) {
		cerr << cl << endl;
		return false;
	}

	return true;
}
Exemplo n.º 24
0
UMatrix2D<T>::UMatrix2D(T* ptr, unsigned int x, unsigned int y,  MatrixStorageOrder2D m) :Locker()
{
#ifdef _SAFE_ACCESS_
    CheckLocker cl(GetLocker());
#endif //_SAFE_ACCESS_
    mt = MXT_MAP;
    mso = m;
    Ptr = ptr;
    nX  = x;
    nY  = y;
    if(Ptr == NULL) {
        ms = MXS_ERR_MAP;throw(this);
    } else ms = MXS_OK;
    if(mso==MSO_XY) {
        ATF  = _XY; 
        atfN = nY;
    } else {
        ATF  = _YX;
        atfN = nX;
    }
}
Exemplo n.º 25
0
void VCCueList_Test::modeChange()
{
    QWidget w;
    VCFrame parent(&w, m_doc);
    VCCueList cl(&parent, m_doc);
    Chaser* c = createChaser(m_doc);
    cl.setChaser(c->id());

    m_doc->setMode(Doc::Operate);
    // QCOMPARE(m_doc->masterTimer()->m_dmxSourceList.size(), 1);
    // QCOMPARE(m_doc->masterTimer()->m_dmxSourceList[0], &cl);
    // QVERIFY(cl.m_runner == NULL);
    QVERIFY(cl.m_tree->isEnabled() == true);

    // cl.createRunner();

    m_doc->setMode(Doc::Design);
    QCOMPARE(m_doc->masterTimer()->m_dmxSourceList.size(), 0);
    // QVERIFY(cl.m_runner == NULL);
    QVERIFY(cl.m_tree->isEnabled() == false);
}
Exemplo n.º 26
0
int CTraderApi::ReqOrderAction(CUstpFtdcOrderField *pOrder, int count, OrderIDType* pOutput)
{
	if (nullptr == m_pApi)
		return 0;

	CUstpFtdcOrderActionField body = {0};

	strcpy(body.BrokerID, pOrder->BrokerID);
	strcpy(body.InvestorID, pOrder->InvestorID);
	strcpy(body.UserID, pOrder->UserID);

	///报单引用
	strcpy(body.UserOrderLocalID, pOrder->UserOrderLocalID);

	///交易所代码
	strcpy(body.ExchangeID,pOrder->ExchangeID);
	///报单编号
	strcpy(body.OrderSysID,pOrder->OrderSysID);
	///操作标志
	body.ActionFlag = USTP_FTDC_AF_Delete;

	int nRet = 0;
	{
		lock_guard<mutex> cl(m_csOrderRef);
		sprintf(body.UserOrderActionLocalID, "%012lld", m_nMaxOrderRef);
		++m_nMaxOrderRef;
		nRet = m_pApi->ReqOrderAction(&body, ++m_lRequestID);
		if (nRet < 0)
		{
			sprintf(m_orderAction_Id, "%d", nRet);
		}
		else
		{
			memset(m_orderAction_Id, 0, sizeof(OrderIDType));
		}
	}
	strncpy((char*)pOutput, m_orderAction_Id, sizeof(OrderIDType));

	return nRet;
}
Exemplo n.º 27
0
void VCCueList_Test::functionRemoved()
{
    QWidget w;
    VCCueList cl(&w, m_doc);
    Chaser* c = createChaser(m_doc);
    cl.setChaser(c->id());

    // Chaser members are removed from list
    m_doc->deleteFunction(c->steps().first().fid);
    QCOMPARE(cl.m_tree->topLevelItemCount(), 3);
    QCOMPARE(cl.m_tree->topLevelItem(0)->text(0), QString("1"));
    QCOMPARE(cl.m_tree->topLevelItem(1)->text(0), QString("2"));
    QCOMPARE(cl.m_tree->topLevelItem(2)->text(0), QString("3"));
    QCOMPARE(cl.m_tree->topLevelItem(0)->text(1), QString("Second"));
    QCOMPARE(cl.m_tree->topLevelItem(1)->text(1), QString("Third"));
    QCOMPARE(cl.m_tree->topLevelItem(2)->text(1), QString("Fourth"));

    // Chaser is removed completely
    m_doc->deleteFunction(c->id());
    QCOMPARE(cl.m_tree->topLevelItemCount(), 0);
    QCOMPARE(cl.chaser(), Function::invalidId());
}
Exemplo n.º 28
0
QValidator::State QIntValidator::validate(QString & input, int&) const
{
    QByteArray buff;
    if (!locale().d()->validateChars(input, QLocalePrivate::IntegerMode, &buff)) {
        QLocale cl(QLocale::C);
        if (!cl.d()->validateChars(input, QLocalePrivate::IntegerMode, &buff))
            return Invalid;
    }

    if (buff.isEmpty())
        return Intermediate;

    if (b >= 0 && buff.startsWith('-'))
        return Invalid;

    if (t < 0 && buff.startsWith('+'))
        return Invalid;

    if (buff.size() == 1 && (buff.at(0) == '+' || buff.at(0) == '-'))
        return Intermediate;

    bool ok, overflow;
    qlonglong entered = QLocalePrivate::bytearrayToLongLong(buff.constData(), 10, &ok, &overflow);
    if (overflow || !ok)
        return Invalid;

    if (entered >= b && entered <= t) {
        locale().toInt(input, &ok, 10);
        return ok ? Acceptable : Intermediate;
    }

    if (entered >= 0) {
        // the -entered < b condition is necessary to allow people to type
        // the minus last (e.g. for right-to-left languages)
        return (entered > t && -entered < b) ? Invalid : Intermediate;
    } else {
        return (entered < b) ? Invalid : Intermediate;
    }
}
Exemplo n.º 29
0
void VCCueList_Test::copy()
{
    // Input sources are tested by VCWidget tests. No point testing here.

    QWidget w;
    VCFrame parent(&w, m_doc);
    VCCueList cl(&parent, m_doc);
    Chaser* c = createChaser(m_doc);

    cl.setChaser(c->id());
    cl.setCaption("Wheeee");
    cl.setNextKeySequence(QKeySequence(keySequenceB));
    cl.setPreviousKeySequence(QKeySequence(keySequenceA));
    cl.setPlaybackKeySequence(QKeySequence(keySequenceC));

    VCCueList* cl2 = qobject_cast<VCCueList*> (cl.createCopy(&parent));
    QVERIFY(cl2 != NULL);
    QCOMPARE(cl2->caption(), QString("Wheeee"));
    QCOMPARE(cl2->nextKeySequence(), QKeySequence(keySequenceB));
    QCOMPARE(cl2->previousKeySequence(), QKeySequence(keySequenceA));
    QCOMPARE(cl2->playbackKeySequence(), QKeySequence(keySequenceC));
    QCOMPARE(cl2->chaserID(), c->id());
    QCOMPARE(cl2->m_tree->topLevelItemCount(), 4);

    VCCueList cl3(&parent, m_doc);
    cl3.copyFrom(NULL);
    QCOMPARE(cl3.m_tree->topLevelItemCount(), 0);
    QCOMPARE(cl3.caption(), tr("Cue list"));

    cl.copyFrom(&cl3);
    QCOMPARE(cl.caption(), cl3.caption());
    QCOMPARE(cl.chaserID(), Function::invalidId());
    QCOMPARE(cl.m_tree->topLevelItemCount(), 0);
    QCOMPARE(cl.nextKeySequence(), QKeySequence());
    QCOMPARE(cl.previousKeySequence(), QKeySequence());
    QCOMPARE(cl.playbackKeySequence(), QKeySequence());

    delete cl2;
}
Exemplo n.º 30
0
void MainWindow::setTableManager(TableManager *tm)
{
    this->tm = tm;
    tm->setTableWidget(ui->tableWidget);
   // QObject::connect(ui->pushButton_1, SIGNAL(clicked()), SLOT(buttonReceiver()));
    //QObject::connect(ui->pushButton_2, SIGNAL(clicked()), SLOT(buttonReceiver()));
    //print data to the TableWidget
    QObject::connect(ui->pushButton_3, SIGNAL(clicked()), SLOT(buttonReceiver()));
    QObject::connect(ui->pushButton_4, SIGNAL(clicked()), SLOT(buttonReceiver()));
    QObject::connect(ui->pushButton_5, SIGNAL(clicked()), SLOT(buttonReceiver()));
    QObject::connect(ui->pushButton_6, SIGNAL(clicked()), SLOT(buttonReceiver()));
    QObject::connect(ui->pushButton_7, SIGNAL(clicked()), SLOT(buttonReceiver()));
    QObject::connect(ui->pushButton_8, SIGNAL(clicked()), SLOT(buttonReceiver()));
    QObject::connect(ui->pushButton_9, SIGNAL(clicked()), SLOT(buttonReceiver()));
    //QObject::connect(ui->pushButton_10, SIGNAL(clicked()), SLOT(buttonReceiver()));
    //transition node
    QObject::connect(this, SIGNAL(sendButtonIndex(int)), tm, SLOT(setIndex(int)));
    //close signal
    QObject::connect(this, SIGNAL(cl()), tm, SLOT(setClose()));
    //resize MainWindow
    //QObject::connect(ui->centralwidget, SIGNAL())
}