Example #1
0
//_____________________________________________________________________________
// Copy assignment.
Force& Force::operator=(const Force& source)
{
    if (&source != this) {
        Super::operator=(source);
        copyData(source);
    }
    return *this;
}
Example #2
0
int main(int argc, char *argv[])
{
	int	soc;
	struct sockaddr_un sa;
	size_t	addrLen;


	unlink(SOCKNAME);


	soc = socket(PF_LOCAL, SOCK_STREAM, 0);
	if (soc < 0)
	{
		printf("Bad Sock\n");
		exit(1);
	}

	unlink(SOCKNAME);

	sa.sun_family = AF_UNIX;
	strcpy(sa.sun_path, SOCKNAME);

	addrLen = sizeof(sa.sun_family) + strlen(sa.sun_path);

	int	ret;

	ret = bind(soc, (struct sockaddr *)&sa, addrLen);
	if (ret < 0)
	{
		printf("Bad Bind\n");
		exit(1);
	}

	ret = listen(soc, 5);
	if (ret < 0)
	{
		printf("Bad Listen\n");
		exit(1);
	}



	int fd;

	fd = accept(soc, (struct sockaddr *)&sa, &addrLen);
	if (fd < 0)
	{
		printf("Bad accept\n");
		exit(1);
	}


	copyData(fd, 1);

	unlink(SOCKNAME);

	return 0;
}	
Example #3
0
void WAbstractItemModel::dropEvent(const WDropEvent& e, DropAction action,
				   int row, int column,
				   const WModelIndex& parent)
{
  // TODO: For now, we assumes selectionBehavior() == RowSelection !

  WItemSelectionModel *selectionModel
    = dynamic_cast<WItemSelectionModel *>(e.source());
  if (selectionModel) {
    WAbstractItemModel *sourceModel = selectionModel->model();

    /*
     * (1) Insert new rows (or later: cells ?)
     */
    if (action == MoveAction || row == -1) {
      if (row == -1)
	row = rowCount(parent);

      insertRows(row, selectionModel->selectedIndexes().size(), parent);
    }

    /*
     * (2) Copy data
     */
    WModelIndexSet selection = selectionModel->selectedIndexes();

    int r = row;
    for (WModelIndexSet::const_iterator i = selection.begin();
	 i != selection.end(); ++i) {
      WModelIndex sourceIndex = *i;
      if (selectionModel->selectionBehavior() == SelectRows) {
	WModelIndex sourceParent = sourceIndex.parent();

	for (int col = 0; col < sourceModel->columnCount(sourceParent); ++col) {
	  WModelIndex s = sourceModel->index(sourceIndex.row(), col,
					     sourceParent);
	  WModelIndex d = index(r, col, parent);
	  copyData(sourceModel, s, this, d);
	}

	++r;
      } else {
	  
      }
    }

    /*
     * (3) Remove original data
     */
    if (action == MoveAction) {
      while (!selectionModel->selectedIndexes().empty()) {
	WModelIndex i = Utils::last(selectionModel->selectedIndexes());

	sourceModel->removeRow(i.row(), i.parent());
      }
    }
  }
}
Example #4
0
bool MemoryBuffer::copy(const MemoryBuffer& buf)
{
    bool ret;
    if ((ret = resize(buf.size()))) {
        copyData(buf.dataPtr<uint8_t>(), buf.size());
    }

    return ret;
}
Example #5
0
StatusFile::StatusFile(const std::string & path_)
	: path(path_)
{
	/// Если файл уже существует. NOTE Незначительный race condition.
	if (Poco::File(path).exists())
	{
		std::string contents;
		{
			ReadBufferFromFile in(path, 1024);
			LimitReadBuffer limit_in(in, 1024);
			WriteBufferFromString out(contents);
			copyData(limit_in, out);
		}

		if (!contents.empty())
			LOG_INFO(&Logger::get("StatusFile"), "Status file " << path << " already exists - unclean restart. Contents:\n" << contents);
		else
			LOG_INFO(&Logger::get("StatusFile"), "Status file " << path << " already exists and is empty - probably unclean hardware restart.");
	}

	fd = open(path.c_str(), O_WRONLY | O_CREAT, 0666);

	if (-1 == fd)
		throwFromErrno("Cannot open file " + path);

	try
	{
		int flock_ret = flock(fd, LOCK_EX | LOCK_NB);
		if (-1 == flock_ret)
		{
			if (errno == EWOULDBLOCK)
				throw Exception("Cannot lock file " + path + ". Another server instance in same directory is already running.");
			else
				throwFromErrno("Cannot lock file " + path);
		}

		if (0 != ftruncate(fd, 0))
			throwFromErrno("Cannot ftruncate " + path);

		if (0 != lseek(fd, 0, SEEK_SET))
			throwFromErrno("Cannot lseek " + path);

		/// Записываем в файл информацию о текущем экземпляре сервера.
		{
			WriteBufferFromFileDescriptor out(fd, 1024);
			out
				<< "PID: " << getpid() << "\n"
				<< "Started at: " << LocalDateTime(time(0)) << "\n"
				<< "Revision: " << ClickHouseRevision::get() << "\n";
		}
	}
	catch (...)
	{
		close(fd);
		throw;
	}
}
Example #6
0
void VideoDecoder::update() {
	if (getTimeToNextFrame() > 0)
		return;

	debugC(Common::kDebugVideo, 9, "New video frame");

	processData();
	copyData();
}
int main(int argc, char *argv[]) {
	if (argc < 2) {
		printf("Usage: %s [exe folder]\n", argv[0]);
		printf("Where [exe folder] contains the following files:\n");
		printf("- M3_EN_127.exe: English v1.27 Window binary from the DVD release\n");
		printf("- M3_FR_122.exe: French v1.22 Window binary from the update patch\n");
		printf("- M3_FR_122.exe: English v1.22 Window binary from the update patch\n");
		printf("- M3_XBOX_PAL.xbe: PAL XBox binary\n");
		printf("- M3_XBOX_NTSC.xbe: NTSC XBox binary\n");
		return -1;
	}

	std::string path = argv[1];
	std::string dvdExe = path + "M3_EN_127.exe";
	std::string cdIntlExe = path + "M3_FR_122.exe";
	std::string cdEnglishExe = path + "M3_EN_122.exe";
	std::string xboxPalExe = path + "M3_XBOX_PAL.xbe";
	std::string xboxNtscExe = path + "M3_XBOX_NTSC.xbe";

	Common::File temp;
	if (!temp.open("data.tmp", Common::kFileWriteMode)) {
		error("Unable to open '%s'", "data.tmp");
	}

	writeScriptData(dvdExe.c_str(), temp, roomScripts, ARRAYSIZE(roomScripts));
	writeScriptData(dvdExe.c_str(), temp, menuScriptsDvd, ARRAYSIZE(menuScriptsDvd));
	writeScriptData(cdIntlExe.c_str(), temp, menuScriptsCdIntl, ARRAYSIZE(menuScriptsCdIntl));
	writeScriptData(cdEnglishExe.c_str(), temp, menuScriptsCdEnglish, ARRAYSIZE(menuScriptsCdEnglish));
	writeScriptData(xboxPalExe.c_str(), temp, roomScriptsXBox, ARRAYSIZE(roomScriptsXBox));
	writeScriptData(xboxPalExe.c_str(), temp, menuScriptsXboxIntl, ARRAYSIZE(menuScriptsXboxIntl));
	writeScriptData(xboxNtscExe.c_str(), temp, menuScriptsXboxEnglish, ARRAYSIZE(menuScriptsXboxEnglish));

	Common::File target;
	if (!target.open("myst3.dat", Common::kFileWriteMode)) {
		error("Unable to open '%s'", "myst3.dat");
	}
	target.writeLong(MKTAG('M', 'Y', 'S', 'T'));
	target.writeLong(kVersion);

	writeScriptIndex(target, roomScripts, ARRAYSIZE(roomScripts));
	writeScriptIndex(target, menuScriptsDvd, ARRAYSIZE(menuScriptsDvd));
	writeScriptIndex(target, menuScriptsCdIntl, ARRAYSIZE(menuScriptsCdIntl));
	writeScriptIndex(target, menuScriptsCdEnglish, ARRAYSIZE(menuScriptsCdEnglish));
	writeScriptIndex(target, roomScriptsXBox, ARRAYSIZE(roomScriptsXBox));
	writeScriptIndex(target, menuScriptsXboxIntl, ARRAYSIZE(menuScriptsXboxIntl));
	writeScriptIndex(target, menuScriptsXboxEnglish, ARRAYSIZE(menuScriptsXboxEnglish));

	writeSoundNames(dvdExe.c_str(), target, 549360);
	writeSoundNames(xboxPalExe.c_str(), target, 913960);

	copyData(temp, target);

	temp.close();
	target.close();

	return 0;
}
Example #8
0
KNoneFilter::Result KNoneFilter::uncompress()
{
#ifndef NDEBUG
    if (d->mode != QIODevice::ReadOnly) {
        return KFilterBase::Error;
    }
#endif
    return copyData();
}
Example #9
0
/**
 * Buffer passed flow in Hashtable @c ht
 */
void aggregateTemplateData(Hashtable* ht, TemplateInfo* ti, FieldData* data)
{
	int i;

	/* Create data block to be inserted into buffer... */
	FieldData* htdata = (FieldData*)malloc(ht->fieldLength);

	for (i = 0; i < ht->dataTemplate->fieldCount; i++) {
		FieldInfo* hfi = &ht->dataTemplate->fieldInfo[i];
		FieldInfo* tfi = getTemplateFieldInfo(ti, &hfi->type);

		if(!tfi) {
			DPRINTF("Flow to be buffered did not contain %s field\n", typeid2string(hfi->type.id));
			continue;
		}

		copyData(&hfi->type, htdata + hfi->offset, &tfi->type, data + tfi->offset, ht->fieldModifier[i]);

		/* copy associated mask, should there be one */
		switch (hfi->type.id) {
		case IPFIX_TYPEID_sourceIPv4Address:
			tfi = getTemplateFieldInfo(ti, &(FieldType){.id = IPFIX_TYPEID_sourceIPv4Mask, .eid = 0});

			if(tfi) {
				if(hfi->type.length != 5) {
					DPRINTF("Tried to set mask of length %d IP address\n", hfi->type.length);
				} else {
					if(tfi->type.length == 1) {
						*(uint8_t*)(htdata + hfi->offset + 4) = *(uint8_t*)(data + tfi->offset);
					} else {
						DPRINTF("Cannot process associated mask with invalid length %d\n", tfi->type.length);
					}
				}
			}
			break;

		case IPFIX_TYPEID_destinationIPv4Address:
			tfi = getTemplateFieldInfo(ti, &(FieldType){.id = IPFIX_TYPEID_destinationIPv4Mask, .eid = 0});

			if(tfi) {
				if(hfi->type.length != 5) {
					DPRINTF("Tried to set mask of length %d IP address\n", hfi->type.length);
				} else {
					if(tfi->type.length == 1) {
						*(uint8_t*)(htdata + hfi->offset + 4) = *(uint8_t*)(data + tfi->offset);
					} else {
						DPRINTF("Cannot process associated mask with invalid length %d\n", tfi->type.length);
					}
				}
			}
			break;

		default:
			break;
		}
errorCode insertNewElement(limSizeCache * lsc, unsigned int slot, void * key, void * data){
  copyData(lsc, slot, data);
  //setCnt(lsc, slot, 1);
  updateAccessTime(lsc, slot);
  ACCNT_USED(lsc, slot) = 1;
  ACCNT_KEY(lsc, slot) = key;
  ACCNT_BH(lsc, slot) = NULL;
  ACCNT_EVICT(lsc, slot) = 0;

  return STATUS_OK;
}
Example #11
0
TcpStreamData& TcpStreamData::operator=(const TcpStreamData& other)
{
	if (this == &other)
		return *this;

	if (m_DeleteDataOnDestruction && m_Data != NULL)
		delete [] m_Data;

	copyData(other);
	return *this;
}
Example #12
0
void Attribute<DimensionStruct>::reflectAttribute(const RTI::AttributeHandleValuePairSet& theAttributes, int idx) throw (RTI::FederateInternalError)
{
    unsigned char data[12];
    copyData(theAttributes, idx, data, sizeof(data));
    value.XAxisLength = fromNet<float>(data+0);
    value.YAxisLength = fromNet<float>(data+4);
    value.ZAxisLength = fromNet<float>(data+8);
    std::cout << "Dimension " << value.XAxisLength;
    std::cout << " " << value.YAxisLength;
    std::cout << " " << value.ZAxisLength;
    std::cout << std::endl;
}
Example #13
0
ConnectionData& ConnectionData::operator=(const ConnectionData& other)
{
	if (srcIP != NULL)
		delete srcIP;

	if (dstIP != NULL)
		delete dstIP;

	copyData(other);

	return *this;
}
Example #14
0
void Attribute<EntityIdentifierStruct>::reflectAttribute(const RTI::AttributeHandleValuePairSet& theAttributes, int idx) throw (RTI::FederateInternalError)
{
    unsigned char data[6];
    copyData(theAttributes, idx, data, sizeof(data));
    value.siteId =            fromNet<unsigned short>(data+0);
    value.applicationId =    fromNet<unsigned short>(data+2);
    value.entityNumber =    fromNet<unsigned short>(data+4);
    std::cout << "Entity ID " << value.siteId << ":";
    std::cout << value.applicationId << ":";
    std::cout << value.entityNumber;
    std::cout << std::endl;
}
Example #15
0
void Attribute<AggregateMarkingStruct>::reflectAttribute(const RTI::AttributeHandleValuePairSet& theAttributes, int idx) throw (RTI::FederateInternalError)
{
    unsigned char data[12];
    copyData(theAttributes, idx, data, sizeof(data));
    value.MarkingEncodingType = MarkingEncodingEnum8(fromNet<unsigned char>(data+0));
    memcpy(value.MarkingData, data+1, sizeof(value.MarkingData)-1);
    value.MarkingData[31] = 0;
    std::cout << "Aggregate Marking data " << value.MarkingEncodingType << " ";
    for(size_t i=0; i<sizeof(value.MarkingData); i++)
        std::cout << value.MarkingData[i];
    std::cout << std::endl;
}
Example #16
0
void Attribute<RelativePositionStruct>::reflectAttribute(const RTI::AttributeHandleValuePairSet& theAttributes, int idx) throw (RTI::FederateInternalError)
{
    unsigned char data[12];
    copyData(theAttributes, idx, data, sizeof(data));
    value.BodyXDistance = fromNet<float>(data+0);
    value.BodyYDistance = fromNet<float>(data+4);
    value.BodyZDistance = fromNet<float>(data+8);
    std::cout << "Relative Position " << value.BodyXDistance;
    std::cout << " " << value.BodyYDistance;
    std::cout << " " << value.BodyZDistance;
    std::cout << std::endl;
}
Example #17
0
            static void toCVTImage( Image& dst, const openni::VideoFrameRef& frame )
            {
                dst.reallocate( frame.getWidth(), frame.getHeight(), Openni2Helper::toIFormat( frame.getVideoMode().getPixelFormat() ) );

                switch( frame.getVideoMode().getPixelFormat() ){
                    case openni::PIXEL_FORMAT_RGB888:
                        copyRGB( dst, ( const uint8_t* )frame.getData(), frame.getStrideInBytes() );
                        break;
                    default:
                        copyData( dst, ( const uint8_t* )frame.getData(), frame.getStrideInBytes() );
                }
            }
Example #18
0
void Attribute<OrientationStruct>::reflectAttribute(const RTI::AttributeHandleValuePairSet& theAttributes, int idx) throw (RTI::FederateInternalError)
{
    unsigned char data[12];
    copyData(theAttributes, idx, data, sizeof(data));
    value.Psi =        fromNet<float>(data+0);
    value.Theta =    fromNet<float>(data+4);
    value.Phi =        fromNet<float>(data+8);
    std::cout << "Entity orientation " << value.Psi;
    std::cout << " " << value.Theta;
    std::cout << " " << value.Phi;
    std::cout << std::endl;
}
Example #19
0
// Based on libarchive's public example code.
// https://github.com/libarchive/libarchive/wiki/Examples#wiki-Constructing_Objects_On_Disk
void GuiZipper::unpackFile(const char *zipFile, const char *outputDir)
    throw (ZipperException*) {
  // TODO: use archive_write_disk_open instead (if/when it exists)
  char cwd[4096];
  getcwd(cwd, 4096);
  char *absZipFile = fileManager_->getAbsFilePath(zipFile);
  platformstl::filesystem_traits<char> traits;
  traits.set_current_directory(outputDir);
  
  struct archive *a;
  struct archive *ext;
  struct archive_entry *entry;
  int flags;
  int r;
  
  flags = ARCHIVE_EXTRACT_TIME;
  flags |= ARCHIVE_EXTRACT_PERM;
  flags |= ARCHIVE_EXTRACT_ACL;
  flags |= ARCHIVE_EXTRACT_FFLAGS;
  
  a = archive_read_new();
  archive_read_support_format_tar(a);
  archive_read_support_filter_gzip(a);
  ext = archive_write_disk_new();
  archive_write_disk_set_options(ext, flags);
  archive_write_disk_set_standard_lookup(ext);
  r = archive_read_open_filename(a, absZipFile, 10240);
  checkForErrors("Error opening archive for reading", a, r);
  for (;;) {
    r = archive_read_next_header(a, &entry);
    if (r == ARCHIVE_EOF) {
      break;
    }
    checkForErrors("Error reading next archive header", a, r);
    r = archive_write_header(ext, entry);
    checkForErrors("Error writing next archive header", a, r);
    copyData(a, ext, outputDir);
    r = archive_write_finish_entry(ext);
    checkForErrors("Error writing archive finish entry", a, r);
  }
  r = archive_read_close(a);
  checkForErrors("Error closing read archive", a, r);
  r = archive_read_free(a);
  checkForErrors("Error freeing read archive", a, r);
  r = archive_write_close(ext);
  checkForErrors("Error closing write archive", a, r);
  r = archive_write_free(ext);
  checkForErrors("Error freeing write archive", a, r);

  traits.set_current_directory(cwd);
  delete absZipFile;
}
Example #20
0
LLKeywords::WStringMapIndex::WStringMapIndex(const WStringMapIndex& other)
{
	if(other.mOwner)
	{
		copyData(other.mData, other.mLength);
	}
	else
	{
		mOwner = false;
		mLength = other.mLength;
		mData = other.mData;
	}
}
Example #21
0
/*
 *  processBuffer() - Process audio data once it has been received.
 */
void processBuffer(void)
{
    Uint32 pingPong;

    /* Get contents of mailbox posted by edmaHwi */
    pingPong =  SWI_getmbox();

    /* Copy data from transmit to receive, could process audio here */
    if (pingPong == PING) {
        /* Toggle LED #3 as a visual cue */
        DSK6713_LED_toggle(3);

        /* Copy receive PING buffer to transmit PING buffer */
        copyData(gBufferRcvPing, gBufferXmtPing, BUFFSIZE);
    } else {
        /* Toggle LED #2 as a visual cue */
        DSK6713_LED_toggle(2);

        /* Copy receive PONG buffer to transmit PONG buffer */
        copyData(gBufferRcvPong, gBufferXmtPong, BUFFSIZE);
    }
}
static double lbfgsCallback(void* instance, const double* x, double* g,
	const int n, const double step)
{
	const CostAndGradientFunction* callback =
		reinterpret_cast<const CostAndGradientFunction*>(instance);

	auto weights  = callback->getUninitializedDataStructure();
	auto gradient = callback->getUninitializedDataStructure();
	
	assert(weights.size() > 0);
	assert(gradient.size() > 0);
	
	// TODO: get rid of these copies	
	copyData(weights,  x);
	//copyData(gradient, g); // can we comment this guy out?
	
	float cost = callback->computeCostAndGradient(gradient, weights);
	
	copyData(g, gradient);
	
	return cost;
}
Example #23
0
/**OK
 * Estrae il file fileName, contenuto nell'oggetto zip, con il nome fileDest.
 * Se la funzione fallisce restituisce false e cancella il file che si e tentato di estrarre.
 *
 * La funzione fallisce se:
 * * zip==NULL;
 * * l'oggetto zip e stato aperto in una modalita non compatibile con l'estrazione di file;
 * * non e possibile aprire il file all'interno dell'oggetto zip;
 * * non e possibile creare il file estratto;
 * * si e rilevato un errore nella copia dei dati (1);
 * * non e stato possibile chiudere il file all'interno dell'oggetto zip (1);
 *
 * (1): prima di uscire dalla funzione cancella il file estratto.
 */
bool JlCompress::extractFile(QuaZip* zip, QString fileName, QString fileDest) {
    // zip: oggetto dove aggiungere il file
    // filename: nome del file reale
    // fileincompress: nome del file all'interno del file compresso

    // Controllo l'apertura dello zip
    if (!zip) return false;
    if (zip->getMode()!=QuaZip::mdUnzip) return false;

    // Apro il file compresso
    if (!fileName.isEmpty())
        zip->setCurrentFile(fileName);
    QuaZipFile inFile(zip);
    if(!inFile.open(QIODevice::ReadOnly) || inFile.getZipError()!=UNZ_OK) return false;

    // Controllo esistenza cartella file risultato
    QDir curDir;
    if (!curDir.mkpath(QFileInfo(fileDest).absolutePath())) {
        return false;
    }

    QuaZipFileInfo info;
    if (!zip->getCurrentFileInfo(&info))
        return false;

    if (fileDest.endsWith('/') && QFileInfo(fileDest).isDir()) {
        return QFile(fileDest).setPermissions(info.getPermissions());
    }

    // Apro il file risultato
    QFile outFile;
    outFile.setFileName(fileDest);
    if(!outFile.open(QIODevice::WriteOnly)) return false;

    // Copio i dati
    if (!copyData(inFile, outFile) || inFile.getZipError()!=UNZ_OK) {
        outFile.close();
        removeFile(QStringList(fileDest));
        return false;
    }
    outFile.close();

    // Chiudo i file
    inFile.close();
    if (inFile.getZipError()!=UNZ_OK) {
        removeFile(QStringList(fileDest));
        return false;
    }

    return outFile.setPermissions(info.getPermissions());
}
Example #24
0
/**OK
 * Comprime il file fileName, nell'oggetto zip, con il nome fileDest.
 *
 * La funzione fallisce se:
 * * zip==NULL;
 * * l'oggetto zip e stato aperto in una modalita non compatibile con l'aggiunta di file;
 * * non e possibile aprire il file d'origine;
 * * non e possibile creare il file all'interno dell'oggetto zip;
 * * si e rilevato un errore nella copia dei dati;
 * * non e stato possibile chiudere il file all'interno dell'oggetto zip;
 */
bool JlCompress::compressFile(QuaZip* zip, QString fileName, QString fileDest)
{
    // zip: oggetto dove aggiungere il file
    // fileName: nome del file reale
    // fileDest: nome del file all'interno del file compresso

    // Controllo l'apertura dello zip
    if(!zip)
    {
        return false;
    }
    if(zip->getMode() != QuaZip::mdCreate &&
            zip->getMode() != QuaZip::mdAppend &&
            zip->getMode() != QuaZip::mdAdd)
    {
        return false;
    }

    // Apro il file originale
    QFile inFile;
    inFile.setFileName(fileName);
    if(!inFile.open(QIODevice::ReadOnly))
    {
        return false;
    }

    // Apro il file risulato
    QuaZipFile outFile(zip);
    if(!outFile.open(QIODevice::WriteOnly, QuaZipNewInfo(fileDest, inFile.fileName())))
    {
        return false;
    }

    // Copio i dati
    if(!copyData(inFile, outFile) || outFile.getZipError() != UNZ_OK)
    {
        return false;
    }

    // Chiudo i file
    outFile.close();
    if(outFile.getZipError() != UNZ_OK)
    {
        return false;
    }
    inFile.close();

    return true;
}
Example #25
0
static ASTPtr getCreateQueryImpl(const String & path, const String & table_name)
{
	String table_name_escaped = escapeForFileName(table_name);
	String table_metadata_path = path + "/" + table_name_escaped + ".sql";

	String query;
	{
		ReadBufferFromFile in(table_metadata_path, 4096);
		WriteBufferFromString out(query);
		copyData(in, out);
	}

	ParserCreateQuery parser;
	return parseQuery(parser, query.data(), query.data() + query.size(), "in file " + table_metadata_path);
}
Example #26
0
/**
 * Return (malloc'ed) copy of entry data.
 * @param type		entry data type
 * @param p		entry data
 * @param c		entry item count
 * @retval lengthPtr	no. bytes in returned data
 * @return 		(malloc'ed) copy of entry data, NULL on error
 */
static void *
grabData(rpm_tagtype_t type, rpm_constdata_t p, rpm_count_t c, int * lengthPtr)
{
    rpm_data_t data = NULL;
    int length;

    length = dataLength(type, p, c, 0, NULL);
    if (length > 0) {
	data = xmalloc(length);
	copyData(type, data, p, c, length);
    }

    if (lengthPtr)
	*lengthPtr = length;
    return data;
}
Example #27
0
void Attribute<WorldLocationStruct>::reflectAttribute(const RTI::AttributeHandleValuePairSet& theAttributes, int idx) throw (RTI::FederateInternalError)
{
    unsigned char data[24];
    copyData(theAttributes, idx, data, sizeof(data));
    value.x = fromNet<double>(data+0);
    value.y = fromNet<double>(data+8);
    value.z = fromNet<double>(data+16);
    HlaConvertGccToLatLonAlt(value.x, value.y, value.z, value.lat, value.lon, value.alt);
    std::cout << "Entity location " << value.x;
    std::cout << " " << value.y;
    std::cout << " " << value.z;
    std::cout << "   " << value.lat;
    std::cout << " " << value.lon;
    std::cout << " " << value.alt;
    std::cout << std::endl;
}
Example #28
0
wxLuaDebugData wxLuaDebugData::Copy() const
{
    wxCHECK_MSG(M_DEBUGREFDATA != NULL, wxNullLuaDebugData, wxT("Invalid ref data"));

    wxLuaDebugData copyData(true);

    size_t idx, count = GetCount();
    for (idx = 0; idx < count; ++idx)
    {
        const wxLuaDebugItem *pOldData = M_DEBUGREFDATA->m_dataArray.Item(idx);
        if (pOldData != NULL)
            copyData.Add(new wxLuaDebugItem(*pOldData));
    }

    return copyData;
}
Example #29
0
void lu(Array<T> &lower, Array<T> &upper, Array<int> &pivot, const Array<T> &in)
{
    dim4 iDims = in.dims();
    int M = iDims[0];
    int N = iDims[1];

    Array<T> in_copy = copyArray<T>(in);

    //////////////////////////////////////////
    // LU inplace
    int *pivotPtr  = pinnedAlloc<int>(min(M, N));
    T   *inPtr     = pinnedAlloc<T>  (in_copy.elements());
    copyData(inPtr, in);

    getrf_func<T>()(AF_LAPACK_COL_MAJOR, M, N,
                    inPtr, in_copy.strides()[1],
                    pivotPtr);

    convertPivot(&pivotPtr, M, min(M, N));

    pivot = createHostDataArray<int>(af::dim4(M), pivotPtr);
    //////////////////////////////////////////

    // SPLIT into lower and upper
    dim4 ldims(M, min(M, N));
    dim4 udims(min(M, N), N);

    T *lowerPtr = pinnedAlloc<T>(ldims.elements());
    T *upperPtr = pinnedAlloc<T>(udims.elements());

    dim4 lst(1, ldims[0], ldims[0] * ldims[1], ldims[0] * ldims[1] * ldims[2]);
    dim4 ust(1, udims[0], udims[0] * udims[1], udims[0] * udims[1] * udims[2]);

    lu_split<T>(lowerPtr, upperPtr, inPtr, ldims, udims, iDims,
                lst, ust, in_copy.strides());

    lower = createHostDataArray<T>(ldims, lowerPtr);
    upper = createHostDataArray<T>(udims, upperPtr);

    lower.eval();
    upper.eval();

    pinnedFree(lowerPtr);
    pinnedFree(upperPtr);
    pinnedFree(pivotPtr);
    pinnedFree(inPtr);
}
Example #30
0
////////////////////////////////////////
//  copy dialog setup
///////////////
CopyDialog::CopyDialog(QString fromPath, QWidget *parent) : QDialog(parent), cpFromPath(fromPath)
{
    setWindowTitle("Copy to Location");
    setWindowFlags(Qt::Tool);
    this->setGeometry(0,0,320,250);

    cpDirModel.setRootPath(INTERNAL_USER_PATH);
    cpDirModel.setResolveSymlinks(true);
    cpDirModel.setFilter(QDir::AllEntries | QDir::NoDotAndDotDot);
    cpIndex = cpDirModel.index(INTERNAL_USER_PATH);

    QHBoxLayout *mainLayout = new QHBoxLayout;
    cpTreeView = new QTreeView(this);
    cpTreeView->setModel(&cpDirModel);
    cpTreeView->setRootIndex(cpIndex);
    cpTreeView->setRootIsDecorated(true);
    cpTreeView->setCurrentIndex(cpIndex);
    cpTreeView->setFrameRect(QRect(0,0,238,250));
    mainLayout->addWidget(cpTreeView);

    QVBoxLayout *buttonLayout = new QVBoxLayout;

    buttonLayout->addStretch(0);

    copyButton = new QPushButton("Copy");
    copyButton->setMinimumWidth(80);
    copyButton->setMinimumHeight(30);
    copyButton->setStyleSheet("QPushButton{border:0px;background-image:url(:/actions/rivet80x30L.png);color:black;} QPushButton:pressed{border:0px;background-image:url(:/actions/rivet80x30D.png);color:white;}");
    buttonLayout->addWidget(copyButton);

    buttonLayout->addStretch(0);

    cancelButton = new QPushButton("Cancel");
    cancelButton->setMinimumWidth(80);
    cancelButton->setMinimumHeight(30);
    cancelButton->setStyleSheet("QPushButton{border:0px;background-image:url(:/actions/rivet80x30L.png);color:black;} QPushButton:pressed{border:0px;background-image:url(:/actions/rivet80x30D.png);color:white;}");
    buttonLayout->addWidget(cancelButton);

    buttonLayout->addStretch(0);

    mainLayout->addLayout(buttonLayout);

    connect(copyButton,SIGNAL(clicked()),this,SLOT(copyData()));
    connect(cancelButton,SIGNAL(clicked()),this,SLOT(reject()));

    this->setLayout(mainLayout);
}