Esempio n. 1
0
/** loadPlane **/
void loadPlane(FILE *inFP, entity_t *ent, char *attribute) {
   char *attributes[] = {"point", "orient1", "orient2", NULL};
   int ndx;
   assert(ent->magic == ENTITY_T);
   sobj_t *sobj = ent->entDerived;
   assert(sobj->magic == SCENEOBJ_T);
   plane_t *plane = sobj->sobjDerived;
   assert(plane->magic == PLANE_T);

   ndx = getindex(attribute, attributes);

   switch (ndx) {
      case 0:
         /* point */
         plane->point = readTuple(inFP, "Could not read plane point");
         break;

      case 1:
         /* orient1 */
         plane->orient1 = readTuple(inFP, "Could not read plane orient1");
         break;

      case 2:
         /* orient1 */
         plane->orient2 = readTuple(inFP, "Could not read plane orient2");
         break;

      default:
         loadSceneObj(inFP, ent, attribute);
   }
}
Esempio n. 2
0
void loadPointLight(FILE *inFP, entity_t *ent, char *token){
    char *attributes[] = {"color","brightness","center",NULL};
    int ndx;
    
    assert(ent->magic == ENTITY_T);
    pointlight_t *pointlight = ent->entDerived;
    assert(pointlight->magic == POINTLIGHT_T);
    
    ndx = getindex(token,attributes);
    
    switch(ndx) {
        case 0:
            pointlight->color = readColor(inFP, "Could not read light color");
            break;
        case 1:
            pointlight->brightness = readDouble(inFP, "Could not read light brightness");
            break;
        case 2:
            pointlight->center = readTuple(inFP, "Could not read light center");
            break;
        default:
            loadEntity(inFP, ent, token);
            break;
        }
}
Esempio n. 3
0
int NdbIndexOperation::readTuple(NdbOperation::LockMode lm)
{ 
  switch(lm) {
  case LM_Read:
    return readTuple();
    break;
  case LM_Exclusive:
    return readTupleExclusive();
    break;
  case LM_CommittedRead:
    return readTuple();
    break;
  case LM_SimpleRead:
    return readTuple();
    break;
  default:
    return -1;
  };
}
Esempio n. 4
0
Bool_t KernelDensity::readTuple(TTree* tree, const char* var1, UInt_t maxEvents) {

  UInt_t dim = phaseSpace()->dimensionality(); 
  std::vector<TString> varList(dim); 
  
  if (dim>=1 && var1!=0) varList[0] = TString(var1); 
  
  return readTuple(tree, varList, maxEvents); 

}
Esempio n. 5
0
const NdbOperation * KeyOperation::prepare(NdbTransaction *tx) {
  switch(opcode) {
    case 1:  // OP_READ:
      return readTuple(tx);
    case 2:  // OP_INSERT:
      return insertTuple(tx);
    case 4:  // OP_UPDATE:
      return updateTuple(tx);
    case 8:  // OP_WRITE:
      return writeTuple(tx);
    case 16: // OP_DELETE:
      return deleteTuple(tx);
    default:
      return NULL;
  }
}
Esempio n. 6
0
Bool_t KernelDensity::readTuple(TTree* tree, const char* var1, const char* var2, 
                                const char* var3, const char* var4, 
                                const char* var5, UInt_t maxEvents) {

  UInt_t dim = phaseSpace()->dimensionality(); 
  std::vector<TString> varList(dim); 
  
  if (dim>=1 && var1!=0) varList[0] = TString(var1); 
  if (dim>=2 && var2!=0) varList[1] = TString(var2); 
  if (dim>=3 && var3!=0) varList[2] = TString(var3); 
  if (dim>=4 && var4!=0) varList[3] = TString(var4); 
  if (dim>=5 && var5!=0) varList[4] = TString(var5); 
  
  return readTuple(tree, varList, maxEvents); 

}
static Obj *readObject( istream& is )
{
	if( !eat( is ) ) {
		return NULL;
	}

	int ch = is.peek();

	if( (ch == '-') || (ch >= '0' && ch <= '9') ) {
		return readScalar( is );
	} else if( ch == '"' ) {
		return readString( is );
	} else if( ch == '(' ) {
		return readTuple( is );
	} else if( ch == '{' ) {
		return readDict( is );
	} else {
		return readName( is );
	}
}
Esempio n. 8
0
extern "C" void* NdbThreadFuncRead(void* pArg)
{
    myRandom48Init((long int)NdbTick_CurrentMillisecond());
    unsigned nSucc = 0;
    unsigned nFail = 0;
    NdbRecAttr** ppNdbRecAttrDSum = new NdbRecAttr*[g_nDistrictPerWarehouse];
    NdbRecAttr** ppNdbRecAttrDCnt = new NdbRecAttr*[g_nDistrictPerWarehouse];
    Ndb* pNdb = NULL ;
    pNdb = new Ndb("TEST_DB");
    VerifyMethodInt(pNdb, init());
    VerifyMethodInt(pNdb, waitUntilReady());

    while(NdbMutex_Trylock(g_pNdbMutex)) {
        Uint32 nWarehouse = myRandom48(g_nWarehouseCount);
        NdbConnection* pNdbConnection = NULL ;
        VerifyMethodPtr(pNdbConnection, pNdb, startTransaction());
        CHK_TR(pNdbConnection) ; // epaulsa
        NdbOperation* pNdbOperationW = NULL ;
        VerifyMethodPtr(pNdbOperationW, pNdbConnection, getNdbOperation(c_szWarehouse));
        VerifyMethodInt(pNdbOperationW, readTuple());
        VerifyMethodInt(pNdbOperationW, equal(c_szWarehouseNumber, nWarehouse));
        NdbRecAttr* pNdbRecAttrWSum;
        VerifyMethodPtr(pNdbRecAttrWSum, pNdbOperationW, getValue(c_szWarehouseSum, 0));
        NdbRecAttr* pNdbRecAttrWCnt;
        VerifyMethodPtr(pNdbRecAttrWCnt, pNdbOperationW, getValue(c_szWarehouseCount, 0));
        for(Uint32 nDistrict=0; nDistrict<g_nDistrictPerWarehouse; ++nDistrict) {
            NdbOperation* pNdbOperationD = NULL ;
            VerifyMethodPtr(pNdbOperationD, pNdbConnection, getNdbOperation(c_szDistrict));
            VerifyMethodInt(pNdbOperationD, readTuple());
            VerifyMethodInt(pNdbOperationD, equal(c_szDistrictWarehouseNumber, nWarehouse));
            VerifyMethodInt(pNdbOperationD, equal(c_szDistrictNumber, nDistrict));
            VerifyMethodPtr(ppNdbRecAttrDSum[nDistrict], pNdbOperationD, getValue(c_szDistrictSum, 0));
            VerifyMethodPtr(ppNdbRecAttrDCnt[nDistrict], pNdbOperationD, getValue(c_szDistrictCount, 0));
        }
        int iExec = pNdbConnection->execute(Commit);
        int iError = pNdbConnection->getNdbError().code;

        if(iExec<0 && iError!=0 && iError!=266 && iError!=626) {
            ReportMethodInt(iExec, pNdbConnection, "pNdbConnection", "execute(Commit)", __FILE__, __LINE__);
        }
        if(iExec==0) {
            Uint32 nSum = 0;
            Uint32 nCnt = 0;
            for(Uint32 nDistrict=0; nDistrict<g_nDistrictPerWarehouse; ++nDistrict) {
                nSum += ppNdbRecAttrDSum[nDistrict]->u_32_value();
                nCnt += ppNdbRecAttrDCnt[nDistrict]->u_32_value();
            }
            if(nSum!=pNdbRecAttrWSum->u_32_value()
                    || nCnt!=g_nDistrictPerWarehouse*pNdbRecAttrWCnt->u_32_value()) {
                ndbout << "INCONSISTENT!" << endl;
                ndbout << "iExec==" << iExec << endl;
                ndbout << "iError==" << iError << endl;
                ndbout << endl;
                ndbout << c_szWarehouseSum << "==" << pNdbRecAttrWSum->u_32_value() << ", ";
                ndbout << c_szWarehouseCount << "==" << pNdbRecAttrWCnt->u_32_value() << endl;
                ndbout << "nSum==" << nSum << ", nCnt=" << nCnt << endl;
                for(Uint32 nDistrict=0; nDistrict<g_nDistrictPerWarehouse; ++nDistrict) {
                    ndbout << c_szDistrictSum << "[" << nDistrict << "]==" << ppNdbRecAttrDSum[nDistrict]->u_32_value() << ", ";
                    ndbout << c_szDistrictCount << "[" << nDistrict << "]==" << ppNdbRecAttrDCnt[nDistrict]->u_32_value() << endl;
                }
                VerifyMethodVoid(pNdb, closeTransaction(pNdbConnection));
                delete pNdb;
                pNdb = NULL ;
                delete[] ppNdbRecAttrDSum;
                ppNdbRecAttrDSum = NULL ;
                delete[] ppNdbRecAttrDCnt;
                ppNdbRecAttrDCnt = NULL ;
                NDBT_ProgramExit(NDBT_FAILED);
            }
            ++nSucc;
        } else {
            ++nFail;
        }
        VerifyMethodVoid(pNdb, closeTransaction(pNdbConnection));
    }
    ndbout << "read: " << nSucc << " succeeded, " << nFail << " failed " << endl;
    NdbMutex_Unlock(g_pNdbMutex);
    delete pNdb;
    pNdb = NULL ;
    delete[] ppNdbRecAttrDSum;
    ppNdbRecAttrDSum = NULL ;
    delete[] ppNdbRecAttrDCnt;
    ppNdbRecAttrDCnt = NULL ;
    return NULL;
}
Esempio n. 9
0
void BaseAtlas::load (const char *current, const char *end) {
	if (!current) throw invalid_argument("current cannot be null.");
	if (!end) throw invalid_argument("end cannot be null.");

	string value;
	string tuple[4];
	BaseAtlasPage *page = 0;
	while (current != end) {
		readLine(current, end, value);
		trim(value);
		if (value.length() == 0) {
			page = 0;
		} else if (!page) {
			page = newAtlasPage(value);
			pages.push_back(page);
			page->name = value;
			page->format = static_cast<Format>(indexOf(formatNames, 7, readValue(current, end, value)));

			readTuple(current, end, value, tuple);
			page->minFilter = static_cast<TextureFilter>(indexOf(textureFilterNames, 7, tuple[0]));
			page->magFilter = static_cast<TextureFilter>(indexOf(textureFilterNames, 7, tuple[1]));

			readValue(current, end, value);
			if (value == "x") {
				page->uWrap = repeat;
				page->vWrap = clampToEdge;
			} else if (value == "y") {
				page->uWrap = clampToEdge;
				page->vWrap = repeat;
			} else if (value == "xy") {
				page->uWrap = repeat;
				page->vWrap = repeat;
			}
		} else {
			BaseAtlasRegion *region = newAtlasRegion(page);
			regions.push_back(region);
			region->name = value;

			region->rotate = readValue(current, end, value) == "true";

			readTuple(current, end, value, tuple);
			region->x = atoi(tuple[0].c_str());
			region->y = atoi(tuple[1].c_str());

			readTuple(current, end, value, tuple);
			region->width = atoi(tuple[0].c_str());
			region->height = atoi(tuple[1].c_str());

			if (readTuple(current, end, value, tuple) == 4) { // split is optional
				region->splits = new int[4];
				region->splits[0] = atoi(tuple[0].c_str());
				region->splits[1] = atoi(tuple[1].c_str());
				region->splits[2] = atoi(tuple[2].c_str());
				region->splits[3] = atoi(tuple[3].c_str());

				if (readTuple(current, end, value, tuple) == 4) { // pad is optional, but only present with splits
					region->pads = new int[4];
					region->pads[0] = atoi(tuple[0].c_str());
					region->pads[1] = atoi(tuple[1].c_str());
					region->pads[2] = atoi(tuple[2].c_str());
					region->pads[3] = atoi(tuple[3].c_str());

					readTuple(current, end, value, tuple);
				}
			}

			region->originalWidth = atoi(tuple[0].c_str());
			region->originalHeight = atoi(tuple[1].c_str());

			readTuple(current, end, value, tuple);
			region->offsetX = (float)atoi(tuple[0].c_str());
			region->offsetY = (float)atoi(tuple[1].c_str());

			region->index = atoi(readValue(current, end, value).c_str());
		}
	}
}