Example #1
0
DataPtr DataManagerImpl::loadData(const QString& uid, const QString& path)
{
	if (mData.count(uid)) // dont load same image twice
		return mData[uid];

	QString type = DataReaderWriter().findDataTypeFromFile(path);
	if(!mDataFactory)
		reportError("DataManagerImpl::loadData() Got no DataFactory");
	DataPtr data = mDataFactory->create(type, uid);

	if (!data)
	{
		reportError("Failed to find loaded for: [" + path + "]");
		return DataPtr();
	}

	bool loaded = data->load(path);

	if (!loaded)
	{
		reportError("Failed to load file: [" + path + "]");
		return DataPtr();
	}

	this->loadData(data);
	return data;
}
Example #2
0
BitKey & BitKey::operator=(const BitString & bit_string)
{
  if(iv_Capacity)
  {
    BitString bs(iv_Capacity,DataPtr());
    bs.Pattern(0x00000000);
  }
  ReAllocate(bit_string.GetLength());
  BitString dbs(iv_Capacity,DataPtr());
  dbs.SetBits(bit_string);
  return(*this);
}
Example #3
0
DataPtr DataManagerImpl::getData(const QString& uid) const
{
	DataMap::const_iterator iter = mData.find(uid);
	if (iter == mData.end())
		return DataPtr();
	return iter->second;
}
Example #4
0
BitKey & BitKey::operator=(const BitKey & bit_list)
{
  if(iv_Capacity)
  {
    BitString bs(iv_Capacity,DataPtr());
    bs.Pattern(0x00000000);
  }
  ReAllocate(bit_list.iv_Capacity);
  if(IsDirect()) // implies bit_list is also direct
  {
    iv_storage1 = bit_list.iv_storage1;
    iv_rep.storage2 = bit_list.iv_rep.storage2;
  }
  else
  {
    const uint32_t * dataPtr = NULL;
    if(bit_list.IsDirect())
    {
      dataPtr = &bit_list.iv_storage1;
    } else
    {
      dataPtr = bit_list.iv_rep.buffer;
    }
    memcpy(iv_rep.buffer,dataPtr,4*getWordSize(bit_list.iv_Capacity));
  }
  return(*this);
}
Example #5
0
void BitKey::ReAllocate(uint32_t i_len)
{
  if(i_len > iv_Capacity)  // never shrink
  {
    bool wasDirect = IsDirect();
    uint32_t oldSize = iv_Capacity;
    uint32_t * oldPtr = DataPtr();

    uint32_t wordsize = getWordSize(i_len);
    iv_Capacity = 32*wordsize;

    bool isDirect = IsDirect();

    if(!isDirect)  // to indirect
    {
      uint32_t * newBuffer = new uint32_t[wordsize];
      BitString dbs(iv_Capacity,newBuffer);
      dbs.Pattern(0x00000000);
      BitString sbs(oldSize,oldPtr);
      dbs.SetBits(sbs);
      iv_storage1 = 0;
      if(!wasDirect) // from indirect
      {
        delete [] iv_rep.buffer;
      }
      iv_rep.buffer = newBuffer;
    }
  }
}
Example #6
0
void BitKey::removeBit(uint32_t n)
{
  if(n < size())
  {
    BitString bs(iv_Capacity,DataPtr());
    bs.Clear(getListValue(n));
  }
}
Example #7
0
DistillerStatus gjpg_passthrough(DistillerInput *din, DistillerOutput *dout)
{
  strcpy(dout->mimeType, din->mimeType);
  SetDataLength(dout,DataLength(din));
  SetData(dout, DataPtr(din));
  DataNeedsFree(dout,gm_False);
  return distOk;
}
Example #8
0
inline RETCODE Record::SetData (const RecordIdentifier & rid, char * ptr, size_t sz) {
	_id = rid;
	_size = sz;
	_pData = DataPtr (new char[_size] ( ));
	memcpy_s (_pData.get ( ), _size, ptr, _size);

	return RETCODE::COMPLETE;
}
Example #9
0
DataPtr PatientModelImplService::getData(const QString& uid) const
{
	std::map<QString, DataPtr> dataMap = this->getData();
	std::map<QString, DataPtr>::const_iterator iter = dataMap.find(uid);
	if (iter == dataMap.end())
		return DataPtr();
	return iter->second;
}
Example #10
0
DataPtr CResourceManager::load(const String& name)
{
	CLog::instance()->log(CLog::msgLvlTrace,_("Loading resource: '%s'.\n"),name.c_str());
	std::map<String, CResourceLocation*>::iterator it = m_resources.find(name);
	if( it != m_resources.end() )
		return (*it).second->load((*it).first);
	CLog::instance()->log(CLog::msgLvlError,_("Error loading resource: '%s'.\n"),name.c_str());
	return DataPtr();
};
Example #11
0
void BitKey::setBit(uint32_t i_bitValue)
{
  if(i_bitValue >= iv_Capacity)
  {
    ReAllocate(i_bitValue+1);
  }
  BitString bs(iv_Capacity,DataPtr());
  bs.Set(i_bitValue);
}
Example #12
0
DataPtr ViewGroupData::getData(QString uid) const
{
	DataPtr data = mServices->patientModelService->getData(uid);
	if (!data)
	{
		reportError("Couldn't find the data: [" + uid + "] in the datamanager.");
		return DataPtr();
	}
	return data;
}
Example #13
0
DataPtr DataManagerImpl::loadData(QDomElement node, QString rootPath)
{
	QString uid = node.toElement().attribute("uid");
	QString name = node.toElement().attribute("name");
	QString type = node.toElement().attribute("type");

	QDir relativePath = this->findRelativePath(node, rootPath);
	QString absolutePath = this->findAbsolutePath(relativePath, rootPath);

	if (mData.count(uid)) // dont load same image twice
		return mData[uid];

	DataPtr data = mDataFactory->create(type, uid, name);
	if (!data)
	{
		reportWarning(QString("Unknown type: %1 for file %2").arg(type).arg(absolutePath));
		return DataPtr();
	}
	bool loaded = data->load(absolutePath);

	if (!loaded)
	{
		reportWarning("Unknown file: " + absolutePath);
		return DataPtr();
	}

	if (!name.isEmpty())
		data->setName(name);
	data->setFilename(relativePath.path());

	this->loadData(data);

	// conversion for change in format 2013-10-29
	QString newPath = rootPath+"/"+data->getFilename();
	if (QDir::cleanPath(absolutePath) != QDir::cleanPath(newPath))
	{
		reportWarning(QString("Detected old data format, converting from %1 to %2").arg(absolutePath).arg(newPath));
		data->save(rootPath);
	}

	return data;
}
DataPtr PatientModelService::getData(const QString& uid) const
{
	if (uid=="active")
		return this->getActiveImage();

	std::map<QString, DataPtr> all = this->getData();
	std::map<QString, DataPtr>::const_iterator iter = all.find(uid);
	if (iter == all.end())
		return DataPtr();
	return iter->second;
}
Example #15
0
static object get( Context &c, const IECore::InternedString &name )
{
	ConstDataPtr d = c.get<Data>( name );
	try
	{
		return despatchTypedData<SimpleTypedDataGetter, TypeTraits::IsSimpleTypedData>( constPointerCast<Data>( d ) );
	}
	catch( const InvalidArgumentException &e )
	{
		return object( DataPtr( d->copy() ) );
	}
}
Example #16
0
void LoaderCurrent::ParseTypes()
{
  Classificator & c = classif();

  ArrayByteSource source(DataPtr() + m_TypesOffset);

  size_t const count = m_pF->GetTypesCount();
  for (size_t i = 0; i < count; ++i)
    m_pF->m_types[i] = c.GetTypeForIndex(ReadVarUint<uint32_t>(source));

  m_CommonOffset = CalcOffset(source);
}
Example #17
0
void BitKey::removeBit(void)
{
  BitString bs(iv_Capacity,DataPtr());
  uint32_t i = iv_Capacity;
  while(i != 0)
  {
    --i;
    if(bs.IsSet(i))
    {
      bs.Clear(i);
      break;
    }
  }
}
Example #18
0
DataPtr DataFactory::createRaw(QString type, QString uid)
{
	CREATE_IF_MATCH(type, Image);
	CREATE_IF_MATCH(type, Mesh);
	CREATE_IF_MATCH(type, TrackedStream);
	CREATE_METRIC_IF_MATCH(type, PointMetric);
	CREATE_METRIC_IF_MATCH(type, PlaneMetric);
	CREATE_METRIC_IF_MATCH(type, DistanceMetric);
	CREATE_METRIC_IF_MATCH(type, AngleMetric);
	CREATE_METRIC_IF_MATCH(type, FrameMetric);
	CREATE_METRIC_IF_MATCH(type, ToolMetric);
	CREATE_METRIC_IF_MATCH(type, DonutMetric);
	CREATE_METRIC_IF_MATCH(type, SphereMetric);
	return DataPtr ();
}
Example #19
0
void LoaderCurrent::ParseCommon()
{
  ArrayByteSource source(DataPtr() + m_CommonOffset);

  uint8_t const h = Header();
  m_pF->m_params.Read(source, h);

  if (m_pF->GetFeatureType() == GEOM_POINT)
  {
    m_pF->m_center = serial::LoadPoint(source, GetDefCodingParams());
    m_pF->m_limitRect.Add(m_pF->m_center);
  }

  m_Header2Offset = CalcOffset(source);
}
Example #20
0
BitKey & BitKey::operator=(const char * string_ptr)
{
  if(iv_Capacity)
  {
    BitString bs(iv_Capacity,DataPtr());
    bs.Pattern(0x00000000);
  }

  while(*string_ptr != '\0')
  {
    uint32_t bit_position = (uint32_t) ((*string_ptr) - 1);
    setBit(bit_position);
    ++string_ptr;
  }
  return(*this);
}
Example #21
0
int FileMcIDAS::DiskWrite(int channel){  
  
  McIDAS_LineDoc mline;

  mline.ValidityCode = 0 ;
  mline.BlockHeaderCRC = gvar.crc();
  memcpy(&mline.ScanStatus,&imagerDoc.Iscan,4); 
  memcpy(mline.Time,&imagerDoc.T_sps_current,sizeof(imagerDoc.T_sps_current) );  
  memcpy(mline.BlockHeader,&gvar.Hdr, 30);
  memcpy(mline.LineDoc, lineDoc, 32);

  write(Bin[channel],&mline, 80);
  write(Bin[channel],DataPtr(channel,0,0), 
	xSize(channel)*wordSize(channel));
  
  return(0);
}
Example #22
0
const wchar_t* Misc::GetVersion()
{
    if(!pszVersion)
    {
        //Get version from resource
        wchar_t szFileName[MAX_PATH];
        GetModuleFileName(0, szFileName, _countof(szFileName));
        DWORD dwHandle; //Doesn't do anything but still needed
        const DWORD dwSize = GetFileVersionInfoSize(szFileName, &dwHandle);
        std::unique_ptr<char[]> DataPtr(new char[dwSize]);
        GetFileVersionInfo(szFileName, 0, dwSize, DataPtr.get());
        void* pVersion = nullptr;

        UINT iLen;
        VerQueryValue(DataPtr.get(), L"\\StringFileInfo\\041304b0\\ProductVersion", &pVersion, &iLen);
        assert(pVersion);
        pszVersion.reset(new wchar_t[iLen]);
        wcscpy_s(pszVersion.get(), iLen, static_cast<wchar_t*>(pVersion));
    }

    return pszVersion.get();
}
void RegistrationImplService::clearSlot()
{
	this->setLastRegistrationTime(QDateTime());
	this->setFixedData(DataPtr());
}
Example #24
0
 uint8_t Header() const {
     return static_cast<uint8_t>(*DataPtr());
 }
Example #25
0
	DataPtr Data::CreateInstance()
	{
		DataPtr result = DataPtr(new Data());
		result->mWeakThis = DataWeak(result);
		return result;
	}
Example #26
0
int
main(int argc, char *argv[])
{
  DistillerStatus st;
  UINT32 len;
  Argument args[12];
  int nargs = 0;
  int i;
  char *k;
  FILE *f;
  char nextfile[255];
  DistillerInput in;
  DistillerOutput out;
  C_DistillerType distType;

  sprintf(distType.string, "test " INPUT_MIME_TYPE);
  
  if ((argc < 2) || (argc >= 2  &&  strncmp(argv[1], "-h", 2) == 0)) {
    usage();
    exit(1);
  }

  if ((f = fopen(argv[1], "r")) == NULL) {
    fprintf(stderr, "Can't open input file %s\n", argv[1]);
    exit(1);
  }


  for (i=2; i<argc-1; i += 2, nargs++) {
    SET_ARG_ID(args[nargs], strtoul(&argv[i][1], (char**)NULL, 0));
    switch (argv[i][0]) {
    case 'i':
      SET_ARG_INT(args[nargs], strtol(argv[i+1], (char**)NULL, 0));
      fprintf(stderr, "Arg id %lu is %ld\n", ARG_ID(args[nargs]),
              ARG_INT(args[nargs]));
      break;
    case 'f':
      SET_ARG_DOUBLE(args[nargs], strtod(argv[i+1], (char**)NULL));
      fprintf(stderr, "Arg id %lu is %f\n", ARG_ID(args[nargs]),
              (float)ARG_DOUBLE(args[nargs]));
      break;
    case 's':
    default:
      SET_ARG_STRING(args[nargs], argv[i+1]);
      fprintf(stderr, "Arg id %lu is \"%s\"\n", ARG_ID(args[nargs]),
              ARG_STRING(args[nargs]));
    }
  }

  if ((st = DistillerInit(distType, 0, NULL)) != distOk) {
    fprintf(stderr, "DistillerInit failed: error %d\n", (int)st);
    exit(1);
  }

  SetMimeType(&in, INPUT_MIME_TYPE);
  while (fgets(nextfile, 254, f) != NULL) {
    char nextfile2[255];
    int fd;
    int count;
    int ii;
      
    nextfile[strlen(nextfile)-1] = 0;
    fd = open(nextfile, O_RDONLY);
    if (fd == -1) {
      fprintf(stderr, "Can't read %s, skipping\n", nextfile);
      continue;
    }
    for (len = 0;
         (count = read(fd, (void*)(buf+len), (sizeof(buf)-len))) > 0;
         len += count)
      ;
          
    fprintf(stderr, "Read %lu bytes from %s\n", len, nextfile);
    SetData(&in, (void *)buf);
    SetDataLength(&in, len);
    SetMetadata(&in, NULL);
    SetMetadataLength(&in, 0);

    for (ii= 0; ii<REPEAT_COUNT; ii++) {

      fprintf(stderr,"Calling distiller main\n");
      st = DistillerMain(args,nargs,&in,&out);
      if (st != distOk) {
        fprintf(stderr, "DistillerMain failed: error %d\n", (int)st);
      }
      close(fd);
      strcpy(nextfile2, argv[argc-1]);
      if (nextfile2[strlen(nextfile2)-1] != '/')
        strcat(nextfile2,"/");
      k = strrchr(nextfile, '/');
      if (k)
        strcat(nextfile2, k+1);
      else
        strcat(nextfile2, nextfile);
      strcat(nextfile2, ".OUT");
      fd = open(nextfile2, O_CREAT | O_WRONLY | O_TRUNC, 0666);
      if (fd == -1) {
        fprintf(stderr, "Can't write %s, using stdout\n", nextfile2);
        fd = fileno(stdout);
      }
      len = write(fd, (const void *)DataPtr(&out), (size_t)(DataLength(&out)));
      if (fd != fileno(stdout))
        close(fd);
      fprintf(stderr, "Wrote %lu of %lu bytes to %s\n", len, DataLength(&out), nextfile2);
      if (out.data.freeMe == gm_True) 
        DistillerFree(DataPtr(&out));
      if (out.metadata.freeMe == gm_True)
        DistillerFree(MetadataPtr(&out));
    }
  }
  return(1);
}
Example #27
0
int
main(int argc, char *argv[])
{
  DistillerStatus st;
  UINT32 len;
  int i;
  char nextfile[MAX_FILENAME];
  char logFile[MAX_FILENAME];
  char *timeStr;
  TestRun runs[MAX_TESTRUNS];
  FILE *f;
  time_t t;
  
  int numRuns;
  int repeatCount;
  DistillerInput in;
  DistillerOutput out;
  C_DistillerType distType;


  sprintf(distType.string, "test " INPUT_MIME_TYPE);
  if (argc < 3) {
    usage();
    exit(1);
  }
  
  if (!(numRuns = readInputFile(argv[1],runs))) {
    fprintf(stderr, "Error reading input file %s.\n", argv[1]);
    exit(1);
  }
  repeatCount = atoi(argv[2]);
  if (repeatCount <=0) {
    fprintf(stderr, "Invaild count value.\n");
    exit(1);
  }

  if ((st = DistillerInit(distType, 0, NULL)) != distOk) {
    fprintf(stderr, "DistillerInit failed: error %d\n", (int)st);
    exit(1);
  }

  sprintf(logFile,"harness.log");

  t = time(NULL);
  timeStr = ctime(&t);

  printf("%s\n",logFile);
  if ((f = fopen(logFile, "a")) == NULL) {
    fprintf(stderr, "Can't open log file %s\n", logFile);
    return 0;
  }

  SetMimeType(&in, INPUT_MIME_TYPE);
  
  for (i=0;i<numRuns;i++) {
    int fd;
    int count;
    int ii;

    fprintf(stdout,"Test run for case %s:\n",runs[i].inputFileName);
    fprintf(f,"Test run for case %s:\n",runs[i].inputFileName);
    printArguments(f,*(runs[i].argList));

    fd = open(runs[i].inputFileName, O_RDONLY);


    if (fd == -1) {
      fprintf(stderr, "Can't read %s, skipping\n", runs[i].inputFileName);
      fprintf(f, "Can't read %s, skipping\n", runs[i].inputFileName);
      continue;
    }
    for (len = 0;
         (count = read(fd, (void*)(buf+len), (sizeof(buf)-len))) > 0;
         len += count)
      ;

          
    fprintf(stderr, "Read %lu bytes from %s\n", len, runs[i].inputFileName);
    fprintf(f, "Read %lu bytes from %s\n", len, runs[i].inputFileName);
    SetData(&in, (void *)buf);
    SetDataLength(&in, len);
    SetMetadata(&in, NULL);
    SetMetadataLength(&in, 0);


    for (ii= 0; ii<repeatCount; ii++) {

      fprintf(stderr,"Calling distiller main\n");
      fprintf(f,"Calling distiller main\n");
     /* Distiller status */
      st = DistillerMain(runs[i].argList->arg,runs[i].argList->nargs,&in,&out); 
      if (st != distOk) {
        fprintf(stderr, "DistillerMain failed: error %d\n", (int)st);
        fprintf(f, "DistillerMain failed: error %d\n", (int)st);
      }
      close(fd);
      strcpy(nextfile,runs[i].inputFileName);
      strcat(nextfile, ".OUT");
      fd = open(nextfile, O_CREAT | O_WRONLY | O_TRUNC, 0666);
      if (fd == -1) {
        fprintf(stderr, "Can't write %s, using stdout\n", nextfile);
        fprintf(f, "Can't write %s, using stdout\n", nextfile);
        fd = fileno(stdout);
      }
      len = write(fd, (const void *)DataPtr(&out), (size_t)(DataLength(&out)));
      if (fd != fileno(stdout))
        close(fd);
      fprintf(stderr, "Wrote %lu of %lu bytes to %s\n", len, DataLength(&out), nextfile);
      fprintf(f, "Wrote %lu of %lu bytes to %s\n", len, DataLength(&out), nextfile);
      if (out.data.freeMe == gm_True) 
        DistillerFree(DataPtr(&out));
      if (out.metadata.freeMe == gm_True)
        DistillerFree(MetadataPtr(&out));
    }
  }
  fclose(f);
  return(1);
}
Example #28
0
void BitKey::removeBits(const BitKey & i_bk)
{
  BitString mybs(iv_Capacity,(CPU_WORD *)DataPtr());
  const BitString yobs(i_bk.iv_Capacity,(CPU_WORD *)i_bk.cDataPtr());
  mybs.Mask(yobs);
}
Example #29
0
uint32_t LoaderBase::CalcOffset(ArrayByteSource const & source) const
{
    return static_cast<uint32_t>(source.PtrC() - DataPtr());
}
DataPtr NullFactory::createData() const {
    return DataPtr(new NullData());
}