blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
986 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
23 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
145 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
122 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
c7038ed65cc142d2553ea8cc30a40df19f624e69
3459ad2afff7ad28c99c0e6837755aedda7f5ff1
/WarehouseControlSystem/ControlClass/externcommuincation/tcommmcmelsectcpclient.cpp
4f9c11a21f75c95c013b63dd883dcdccf65127f9
[]
no_license
KorolWu/WCSFinal
7fbe534114d8dae3f83f0e80897e7b3fc2683097
ea0b8cd71f8ffc9da5d43ab9c511130039a9d32a
refs/heads/master
2023-04-03T01:32:45.274632
2021-04-22T01:00:17
2021-04-22T01:00:17
360,348,654
1
1
null
null
null
null
UTF-8
C++
false
false
11,146
cpp
#include "tcommmcmelsectcpclient.h" #include <QDateTime> TCommMCMelsecTCPclient::TCommMCMelsecTCPclient() { socket = nullptr; m_connectStatus = false; m_enbled = true; m_senddatatype = UnknownSendDatatype; m_opsofttype = UnknownSofttype; m_requestaddress = -1; m_requestcount = 0; // memset(m_RevData,0,128); qRegisterMetaType<QMap<int,int>>("QMap<int,int>"); qRegisterMetaType<QVector<int>>("QVector<int>"); connect(this,&TCommMCMelsecTCPclient::signalReadData,this,&TCommMCMelsecTCPclient::readDataRequest); connect(this,&TCommMCMelsecTCPclient::signalWriteData,this,&TCommMCMelsecTCPclient::on_writeData_request); connect(this,&TCommMCMelsecTCPclient::signalcreateclient,this,&TCommMCMelsecTCPclient::creadTcpClient); } /// /// \brief TCommMCMelsecTCPclient::SetCommParam /// \param paramstru /// void TCommMCMelsecTCPclient::SetCommParam(ComConfigStru paramstru) { m_config = paramstru.hwTcpstru; //creadTcpClient(); } /// /// \brief TCommMCMelsecTCPclient::GetNameID /// \return ///得到名字ID int TCommMCMelsecTCPclient::GetNameID() { return m_config.ID; } /// /// \brief TCommMCMelsecTCPclient::GetHWtype /// \return /// int TCommMCMelsecTCPclient::GetHWtype() { return m_config.hwtype; } /// /// \brief TCommMCMelsecTCPclient::GetHWprotype /// \return /// int TCommMCMelsecTCPclient::GetHWprotype() { return kMCMelsecTCPClient; } /// /// \brief TCommMCMelsecTCPclient::CloseComm /// void TCommMCMelsecTCPclient::CloseComm() { if(socket == nullptr) return; socket->disconnectFromHost(); socket->close(); m_connectStatus = false; socket = nullptr; } /// /// \brief TCommMCMelsecTCPclient::creadTcpClient /// \return /// bool TCommMCMelsecTCPclient::creadTcpClient() { socket = new QTcpSocket(this); // connect(socket,&QTcpSocket::disconnected,this,&TCommMCMelsecTCPclient::onDisconnected); // connect(socket,&QTcpSocket::connected, // [=]() // { // m_connectStatus = true; // m_connectstate = 1; // } ); connect(socket, &QTcpSocket::stateChanged, this, &TCommMCMelsecTCPclient::onStateChanged); connect(socket,&QTcpSocket::readyRead, [=]() { QMutexLocker locker(&m_Mutex); QByteArray array = socket->readAll(); //if(array.length() <= 128) { // memcpy(m_RevData,array.data(),array.length()); // emit signalReadHWdeviceData(m_config.ID,m_config.hwtype,array); /* if(*/CheckReceData(array,array.length());/* == 1)*/ // { // qDebug()<<"数据读写成功:"<<m_config.ID; // } m_enbled = true; } }); bool connect = connectServer(m_config.name,m_config.port); // emit signalHWDisconnect(m_config.ID,m_config.hwtype,m_connectStatus); return connect; } bool TCommMCMelsecTCPclient::connectServer(QString ip, qint16 port) { if(socket == nullptr) return false; socket->connectToHost(QHostAddress(ip),port); if(socket->waitForConnected(1000)) { return true; } else { return false; } } bool TCommMCMelsecTCPclient::reConnection() { m_connectStatus = connectServer(m_config.name,m_config.port); // if(m_connectStatus)//连接成功发出成功状态 // { // emit signalHWDisconnect(m_config.ID,m_config.hwtype,m_connectStatus); // m_connectstate = 1; // } // else{ // m_connectstate = 0; // } return m_connectStatus; } /// /// \brief TCommMCMelsecTCPclient::write /// \param array /// \return /// qint64 TCommMCMelsecTCPclient::write(QByteArray array) { if(!m_connectStatus)//连接成功发出成功状态 return 1; if(socket == nullptr) return 0; return socket->write(array); } /// /// \brief TCommMCMelsecTCPclient::GetWaitreplyresult /// \return ///等待回复的过程数据 int TCommMCMelsecTCPclient::GetWaitreplyresult() { int result= -1; struct timeval tpStart,tpEnd; float timeUse = 0; gettimeofday(&tpStart,NULL);//设置500ms while (timeUse < 1000) { if(m_enbled) { result = 1; break ; } gettimeofday(&tpEnd,NULL); timeUse = 1000 *(tpEnd.tv_sec - tpStart.tv_sec) + 0.001*(tpEnd.tv_usec - tpStart.tv_usec); if(timeUse >= 1000) break; QEventLoop loop;//定义一个新的事件循环 QTimer::singleShot(10, &loop, SLOT(quit()));//创建单次定时器,槽函数为事件循环的退出函数 loop.exec();//事件循环开始执行,程序会卡在这里,直到定时时间到,本循环被退出 } if(result == 1) { qDebug()<<"1s之内请求回复成功"; } return result; } /// /// \brief TCommMCMelsecTCPclient::CheckReceData /// \param array /// \return ///分析收到的数据可靠性 int TCommMCMelsecTCPclient::CheckReceData(QByteArray array,int length) { int iresult = -1; QByteArray dataTemp; dataTemp.append(array); int size = sizeof(MCFrameHeadstru); //解析收到数据帧 MCFrameHeadstru headstru; if(size >= length) return iresult; memcpy((char*)&headstru,dataTemp.data(),size); if(!(headstru.header == 208&&headstru.netindex == 0\ &&headstru.plcindex == 255 &&headstru.targetIOindex == 1023)) { //qDebug()<<"接收的数据帧头格式错误: 索引号。。。"; } switch (m_senddatatype) { case BatchRead: { // qDebug()<<"接收到读请求的结果:"<<dataTemp.toHex(); int count = m_requestcount; if(count < 1) return -2; if(headstru.length == (count*2+2)) { //校正读数据字节长度 if(length == (headstru.length +size)) { QMap<int,int> Datamap; // dataTemp.data()+i*count+2+size; for(int i = 0; i < count;++i) { // qDebug()<<"pos:"<<i*count+2+size; atoi16 a16; a16.x = 0; memcpy(a16.a,&dataTemp.data()[i*2+2+size],2); int value = a16.x; Datamap.insert(m_requestaddress+i,value); // qDebug()<<"address:"<<m_requestaddress+i <<"value:"<<value; } if(Datamap.size() > 0) { emit signalReceModbusHWdeviceData(m_config.ID,m_config.hwtype,SoftCodeD,Datamap); iresult =1; } } } //校验返回批量读的报文格式 break; } case BatchWrite: { //校验返回批量写的报文格式 // ComframeReceWriteStru recstru; if(headstru.length == 2 &&(length == (size+2))&&((int)dataTemp[length-1] == 0) ) { //数据写成功 // qDebug()<<"数据写成功:"<<m_requestaddress << m_requestcount; iresult =1; } break; } default: break; } return iresult; } /// /// \brief TCommMCMelsecTCPclient::readDataRequest /// \param type /// \param startAddress /// \param numberOfEntries /// 发送读数据的请求 void TCommMCMelsecTCPclient::readDataRequest(int type, int startAddress, int numberOfEntries) { if(m_connectstate <= 0) return; //检查是否可以执行发送请求 if(!m_enbled) { qDebug()<<"进入请求读数据函数:发现还没有回应:时间,"<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:zzz")<<"上一个发送类型是->"<<m_senddatatype; if(GetWaitreplyresult() != 1) { m_connectstate = -2; qDebug()<<"上一个请求未回复超时1s"; return; } } QMutexLocker locker(&m_Mutex); ComFrameSendReadMCStru stru; stru.headstru.length = 12; stru.defineData.cmdtype = 1025; stru.defineData.softcount = numberOfEntries; stru.defineData.softcode = type; union strtovalue{ int8_t valueby[3]; int value; }; strtovalue a; a.value = startAddress; memcpy(stru.defineData.startaddress,a.valueby,3); //得到的16进制的字节数组 QByteArray tempData; tempData.append(reinterpret_cast<char*>(&stru),sizeof(ComFrameSendReadMCStru)); //qDebug()<<"readDataRequest:"<<tempData.toHex() << sizeof(ComFrameSendReadMCStru); if(write(tempData) > 0) { m_senddatatype = BatchRead; m_requestaddress = startAddress; m_requestcount = numberOfEntries; m_enbled = false; } } /// /// \brief TCommMCMelsecTCPclient::on_writeData_request /// \param type /// \param startAddress /// \param values /// void TCommMCMelsecTCPclient::on_writeData_request(int type, int startAddress, QVector<int> values) { if(m_connectstate <= 0) return; //检查是否可以执行发送请求 if(!m_enbled) { if(GetWaitreplyresult() != 1) { m_connectstate = -2; qDebug()<<"上一个请求未回复超时1s"; return; } } QMutexLocker locker(&m_Mutex); ComFrameSendWriteMCstru writestru; writestru.headstru.length = 12 + values.size()*2; writestru.defineData.softcount = values.size(); writestru.defineData.cmdtype = 5121; writestru.defineData.softcode = type; union strtovalue{ int8_t valueby[3]; int value; }; strtovalue a; a.value = startAddress; memcpy(writestru.defineData.startaddress,a.valueby,3); QByteArray tempData; tempData.append(reinterpret_cast<char*>(&writestru),sizeof(ComFrameSendWriteMCstru)); for(int i = 0; i < values.size();++i) { int16_t datavalue = 0; datavalue = values[i]; tempData.append(reinterpret_cast<char*>(&datavalue),sizeof(int16_t)); } qDebug()<<"on_writeData_request:"<<tempData.toHex()<<endl<<"startAddress:"<<startAddress<<"value: "<<values; if(write(tempData) > 0) { m_senddatatype = BatchWrite; m_requestaddress = startAddress; m_requestcount = values.size(); m_enbled = false; } } /// /// \brief TCommMCMelsecTCPclient::onStateChanged /// \param state ///当连接状态发生改变 void TCommMCMelsecTCPclient::onStateChanged(int state) { //连接状态发生了改变 //emit signalconnectstate(state); bool connected = (state != QTcpSocket::UnconnectedState); Q_UNUSED(connected); if (state == QTcpSocket::UnconnectedState) { m_connectStatus = false; m_connectstate = -1; } else if (state == QTcpSocket::ConnectedState) { m_connectStatus = true; m_connectstate = 1; m_senddatatype = UnknownSendDatatype; } emit signalHWDisconnect(m_config.ID,m_config.hwtype,m_connectStatus); qDebug()<<"设备ID:"<<m_config.ID <<",设备类型:"<<m_config.hwtype<< ",TCommMCMelsecTCPclient连接状态发生:"<<"值:"<<state; }
[ "1050476035@qq.com" ]
1050476035@qq.com
15461411fa6e46d508616b392b170cadcd6971a5
2067d54dfd05c07e4ebd8f36a6c3a0a9c32eda59
/ThreadPool/headers/Synchronization/AtomicInteger.h
5857a64f77ff5c15ce49cdc9e0ff3966c822bb01
[]
no_license
maybe2009/learning_muduo
0912d7612592ca043c5894d36c4c7a6b4c643da3
c7a4b676e7307eff635340943d8f1dc6b99c5d55
refs/heads/master
2021-01-21T13:43:50.099554
2016-04-28T07:29:40
2016-04-28T07:29:40
55,676,236
0
0
null
null
null
null
UTF-8
C++
false
false
1,604
h
/* * This Code is edited by sun wukong @ 2015.12.16 15:44:08 CST * * Just feel free to use this code as you wish. * Any bug and ugly code, please notify me, thanks! * * Github https://githuc.com/maybe2009 * Gmail qtdssunwukong@gmail.com * -Auto Generated By UltiSnips */ #ifndef __OK_ATOMICINTEGER_INCLUDED__ #define __OK_ATOMICINTEGER_INCLUDED__ #include <stdint.h> namespace ok{ /*********************************************************************** Atomic Integer Template using gcc build-in __sync function set ************************************************************************/ template <typename T> class AtomicInteger { public: AtomicInteger (T val) : data_(val){}; T increment() { return __sync_add_and_fetch(&data_, 1); } T decrement() { return __sync_sub_and_fetch(&data_, 1); } T get() const { return __sync_val_compare_and_swap( const_cast<volatile T*>(&data_), 0, 0); } T addAndGet(T n) { return __sync_add_and_fetch(&data_, n); } T subAndGet(T n) { return __sync_sub_and_fetch(&data_, n); } T getAndAdd(T n) { return __sync_fetch_and_add(&data_, n); } T getAndSub(T n) { return __sync_fetch_and_sub(&data_, n); } private: volatile T data_; }; typedef AtomicInteger<int64_t> AtomicInt64; typedef AtomicInteger<int32_t> AtomicInt32; typedef AtomicInteger<int16_t> AtomicInt16; typedef AtomicInteger<int8_t> AtomicInt8; };//namespace ok #endif /* ifndef __OK_ATOMICINTEGER_INCLUDED__ */
[ "ox07c00@163.com" ]
ox07c00@163.com
860d2e10ddad3daf9bec59dadc28a8bf28f46ca3
bb62c6e70b7b536e658f2c045e224735fb2e9532
/src/tools/tools/src/assets/importers/audio_importer.cpp
4fec96d74565deeee3b7250e9f2d647bb1754fba
[ "Apache-2.0" ]
permissive
kariem2k/halley
b66173ef200e9b3479c433f6fd89f2e0a54f585f
6f2d09b06e49ec22ffc1457b7eda6bcd888b796d
refs/heads/master
2020-09-20T14:32:06.167665
2019-11-28T12:13:37
2019-11-28T12:15:19
224,511,194
1
0
Apache-2.0
2019-11-27T20:23:35
2019-11-27T20:23:35
null
UTF-8
C++
false
false
7,098
cpp
#include "audio_importer.h" #include "halley/tools/assets/import_assets_database.h" #include "halley/bytes/byte_serializer.h" #include "halley/resources/metadata.h" #include "halley/audio/vorbis_dec.h" #include "halley/audio/resampler.h" #include "ogg/ogg.h" #include "vorbis/codec.h" #include "vorbis/vorbisenc.h" #include "halley/concurrency/concurrent.h" #include "halley/tools/file/filesystem.h" #include "halley/text/string_converter.h" #include "halley/resources/resource_data.h" #include "halley/support/logger.h" using namespace Halley; void AudioImporter::import(const ImportingAsset& asset, IAssetCollector& collector) { Path mainFile = asset.inputFiles.at(0).name; auto& rawData = asset.inputFiles[0].data; auto resData = std::make_shared<ResourceDataStatic>(rawData.data(), rawData.size(), mainFile.string(), false); Bytes encodedData; const Bytes* fileData = &rawData; std::vector<std::vector<float>> samples; int numChannels = 0; int sampleRate = 0; bool needsEncoding = false; bool needsResampling = false; if (mainFile.getExtension() == ".ogg") { // assuming Ogg Vorbis // Load vorbis data VorbisData vorbis(resData); numChannels = vorbis.getNumChannels(); size_t numSamples = vorbis.getNumSamples(); sampleRate = vorbis.getSampleRate(); samples.resize(numChannels); for (size_t i = 0; i < numChannels; ++i) { samples[i].resize(numSamples); } // Decode if (sampleRate != 48000) { vorbis.read(samples); needsResampling = true; } } else { throw Exception("Unsupported audio format: " + mainFile.getExtension(), HalleyExceptions::Tools); } // Resample if (needsResampling) { // Resample Logger::logWarning(asset.assetId + " requires resampling from " + toString(sampleRate) + " to 48000 Hz."); Concurrent::foreach(std::begin(samples), std::end(samples), [&] (std::vector<float>& s) { s = resampleChannel(sampleRate, 48000, s); }); sampleRate = 48000; needsEncoding = true; } // Encode to vorbis if (needsEncoding) { encodedData = encodeVorbis(numChannels, sampleRate, samples); fileData = &encodedData; samples.clear(); } // Write metadata Metadata meta = asset.inputFiles.at(0).metadata; meta.set("channels", numChannels); meta.set("sampleRate", sampleRate); // Output collector.output(asset.assetId, AssetType::AudioClip, *fileData, meta); } static void onVorbisError(int error) { String str; switch (error) { case OV_EREAD: str = "A read from media returned an error."; break; case OV_ENOTVORBIS: str = "Bitstream does not contain any Vorbis data."; break; case OV_EVERSION: str = "Vorbis version mismatch."; break; case OV_EBADHEADER: str = "Invalid Vorbis bitstream header."; break; case OV_EFAULT: str = "Internal logic fault; indicates a bug or heap/stack corruption."; break; case OV_HOLE: str = "Indicates there was an interruption in the data."; break; case OV_EBADLINK: str = "Indicates that an invalid stream section was supplied to libvorbisfile, or the requested link is corrupt."; break; case OV_EINVAL: str = "Indicates the initial file headers couldn't be read or are corrupt, or that the initial open call for vf failed."; break; case OV_ENOSEEK: str = "Stream is not seekable."; break; default: str = "Unknown error."; } throw Exception("Error opening Ogg Vorbis: "+str, HalleyExceptions::Tools); } static void writeBytes(Bytes& dst, gsl::span<const gsl::byte> src) { size_t start = dst.size(); size_t size = src.size(); dst.resize(start + size); memcpy(dst.data() + start, src.data(), size); } static void outputPacket(Bytes& dst, ogg_packet& packet, ogg_stream_state& os, bool& eos) { ogg_page og; ogg_stream_packetin(&os, &packet); while (!eos) { int result = ogg_stream_pageout(&os, &og); if (result == 0) { break; } writeBytes(dst, gsl::as_bytes(gsl::span<char>(reinterpret_cast<char*>(og.header), og.header_len))); writeBytes(dst, gsl::as_bytes(gsl::span<char>(reinterpret_cast<char*>(og.body), og.body_len))); if (ogg_page_eos(&og)) { eos = true; } } } Bytes AudioImporter::encodeVorbis(int nChannels, int sampleRate, gsl::span<const std::vector<float>> src) { Bytes result; int ret = 0; bool eos = false; ogg_stream_state os; ogg_stream_init(&os, 0); // Based on steps from https://xiph.org/vorbis/doc/libvorbis/overview.html // 1. vorbis_info vi; vorbis_info_init(&vi); ret = vorbis_encode_init_vbr(&vi, long(nChannels), long(sampleRate), 0.5f); if (ret) { onVorbisError(ret); } // 2. vorbis_dsp_state v; vorbis_analysis_init(&v, &vi); // 3. vorbis_comment vc; { ogg_packet header; ogg_packet header_comm; ogg_packet header_code; vorbis_comment_init(&vc); vorbis_comment_add_tag(&vc, "ENCODER", "Halley"); ret = vorbis_analysis_headerout(&v, &vc, &header, &header_comm, &header_code); if (ret) { onVorbisError(ret); } ogg_stream_packetin(&os, &header); ogg_stream_packetin(&os, &header_comm); ogg_stream_packetin(&os, &header_code); ogg_page og; while (!eos) { ret = ogg_stream_flush(&os, &og); if (ret == 0) { break; } writeBytes(result, gsl::as_bytes(gsl::span<char>(reinterpret_cast<char*>(og.header), og.header_len))); writeBytes(result, gsl::as_bytes(gsl::span<char>(reinterpret_cast<char*>(og.body), og.body_len))); } } // 4. vorbis_block vb; ogg_packet op; ret = vorbis_block_init(&v, &vb); if (ret) { onVorbisError(ret); } // 5. / 6. constexpr int bufferSize = 1024; size_t pos = 0; size_t len = src[0].size(); while (!eos) { // 5.1. Expects(pos <= len); size_t samplesToWrite = std::min(len - pos, size_t(bufferSize)); float** buffers = vorbis_analysis_buffer(&v, bufferSize); for (size_t i = 0; i < nChannels; ++i) { for (int j = 0; j < samplesToWrite; ++j) { buffers[i][j] = src[i][j + pos]; } } pos += samplesToWrite; ret = vorbis_analysis_wrote(&v, int(samplesToWrite)); if (ret) { onVorbisError(ret); } // 5.2. while (vorbis_analysis_blockout(&v, &vb) == 1) { // 5.2.1. ret = vorbis_analysis(&vb, nullptr); if (ret) { onVorbisError(ret); } // 5.2.2. ret = vorbis_bitrate_addblock(&vb); if (ret) { onVorbisError(ret); } while (vorbis_bitrate_flushpacket(&v, &op)) { // 5.2.3. outputPacket(result, op, os, eos); } } if (samplesToWrite == 0) { eos = true; } } // 7. vorbis_comment_clear(&vc); vorbis_block_clear(&vb); vorbis_dsp_clear(&v); vorbis_info_clear(&vi); ogg_stream_clear(&os); return result; } std::vector<float> AudioImporter::resampleChannel(int from, int to, gsl::span<const float> src) { AudioResampler resampler(from, to, 1, 1.0f); std::vector<float> dst(resampler.numOutputSamples(src.size()) + 1024); auto result = resampler.resampleInterleaved(src, dst); if (result.nRead != src.size()) { throw Exception("Only read " + toString(result.nRead) + " samples, expected " + toString(src.size()), HalleyExceptions::Tools); } if (result.nWritten == dst.size()) { throw Exception("Resample dst buffer overflow.", HalleyExceptions::Tools); } dst.resize(result.nWritten); return dst; }
[ "archmagezeratul@gmail.com" ]
archmagezeratul@gmail.com
f55be71ae38cca8e9ab4904734245c7a9d9e7eb7
4df08a71e73fb06debae296caf126f6f2e8291ad
/lab05/UserInput.cpp
043595afdbac7ea54afbad9c1db792ff946d5ba7
[]
no_license
EvanBrown96/560labs
60f985ea7ac32a59debe03a34eee630da4c069e1
9b2d9950c328580a226ea6468a7f2fbbc874a901
refs/heads/master
2020-04-18T21:55:19.074220
2019-05-07T03:55:11
2019-05-07T03:55:11
167,779,203
0
0
null
null
null
null
UTF-8
C++
false
false
3,403
cpp
/** * @author: Evan Brown * @file: UserInput.cpp * @date: 2/28/19 * @brief: implementation of UserInput functions * adapted from 560 lab04 */ #include "UserInput.hpp" #include "EmptyStructure.hpp" #include <iostream> #include <limits> int myhash(const int& val){ return val; } UserInput::UserInput(const BinarySearchTree<int> startoff): test_bst(startoff){} void UserInput::clearCin(){ std::cin.clear(); std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); } bool UserInput::queryNumber(const char* query_str, int& num){ std::cout << query_str; if(std::cin >> num){ return true; } clearCin(); std::cout << "Invalid number entered.\n"; return false; } void UserInput::start(){ int choice = 0; while(true){ std::cout << "Choose one operation from the options below:\n\n"; std::cout << "\t1. Insert\n"; std::cout << "\t2. Delete\n"; std::cout << "\t3. Find\n"; std::cout << "\t4. FindMin\n"; std::cout << "\t5. FindMax\n"; std::cout << "\t6. Preorder\n"; std::cout << "\t7. Inorder\n"; std::cout << "\t8. Postorder\n"; std::cout << "\t9. Levelorder\n"; std::cout << "\t10. Exit\n"; while(!(std::cin >> choice && choice > -1 && choice < 11)){ clearCin(); std::cout << "Invalid choice, try again: "; } if(choice == 10){ break; } switch(choice){ case 0: { test_bst.printVisual(); break; } case 1: { userInsert(); break; } case 2: { userDelete(); break; } case 3: { userFind(); break; } case 4: { try{ std::cout << "Minimum number: " << test_bst.findMin() << "\n"; }catch(EmptyStructure& err){ std::cout << "Tree is empty and has no minimum.\n"; } break; } case 5: { try{ std::cout << "Maximum number: " << test_bst.findMax() << "\n"; }catch(EmptyStructure& err){ std::cout << "Tree is empty and has no maximum.\n"; } break; } case 6: { std::cout << "Preorder traversal: " << test_bst.preorder() << "\n"; break; } case 7: { std::cout << "Inorder traversal: " << test_bst.inorder() << "\n"; break; } case 8: { std::cout << "Postorder traversal: " << test_bst.postorder() << "\n"; break; } default: { std::cout << "Levelorder traversal: " << test_bst.levelorder() << "\n"; break; } } std::cout << "\n"; } std::cout << "Done!\n"; } void UserInput::userInsert(){ int insert; if(!queryNumber("Enter number to insert into BST: ", insert)) return; test_bst.insert(insert); std::cout << "Insert was successful.\n"; } void UserInput::userDelete(){ int del; if(!queryNumber("Enter number to delete from BST: ", del)) return; try{ test_bst.deleteVal(del); std::cout << "Delete was successful.\n"; } catch(ValueNotFound<int>& err){ std::cout << "Delete failed; number was not found in tree.\n"; } } void UserInput::userFind(){ int find; if(!queryNumber("Enter number to be found: ", find)) return; if(test_bst.find(find)){ std::cout << "Number is present in the tree.\n"; } else{ std::cout << "Number is not present in the tree.\n"; } }
[ "evan.br96@yahoo.com" ]
evan.br96@yahoo.com
41145ede334ab9ba6a5968af8219c7351ce17589
3fc856fb394f76bb1b58401abde83d13b8ac8df1
/applications/ArrayCam/testing/autoFocus/source/ArrayCamUtils.cpp
a8cf84b58a5ef0160864cfca0b1a4849a679323d
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "BSL-1.0" ]
permissive
TotteKarlsson/ArrayBot
69d9ad26f7614ce36eb0aee919fd4868daef953c
d0e11186abd5b380ebba6e432f642d04a947e5aa
refs/heads/master
2022-11-18T17:33:35.411944
2018-12-18T17:41:08
2018-12-18T17:41:08
57,317,749
2
1
null
null
null
null
UTF-8
C++
false
false
1,330
cpp
#pragma hdrstop #include "ArrayCamUtils.h" #include "dslUtils.h" #include "dslIPCMessageEnums.h" #include "dslLogger.h" //--------------------------------------------------------------------------- #pragma package(smart_init) using namespace dsl; //--------------------------------------------------------------------------- int getArrayCamIPCMessageID(const string& cs) { if(compareStrings(cs, "START_RECORDING_VIDEO", csCaseInsensitive)) return cStartRecordingVideo; if(compareStrings(cs, "STOP_RECORDING_VIDEO", csCaseInsensitive)) return cStopRecordingVideo; return getIPCMessageID(cs); } //--------------------------------------------------------------------------- string getArrayCamIPCMessageName(int cs) { switch (cs) { case cStartRecordingVideo: return "START_RECORDING_VIDEO"; case cStopRecordingVideo: return "STOP_RECORDING_VIDEO"; default: return getIPCMessageName(cs); } } //int extractCoverSlipID(const string& bc) //{ // string temp(bc); // //Make sure first char is a 'C' // if(!bc.size() || bc[0] != 'C') // { // Log(lError) << bc << " is not a valid barcode!"; // return -1; // } // // temp.erase(0,1); // int id = toInt(temp); // Log(lDebug3) << "Extracted id "<<id<<" from "<<bc; // return id; //}
[ "tottek@gmail.com" ]
tottek@gmail.com
8672190c2e1e6f4425bd2880e9454852b63934ac
f5dc059a4311bc542af480aa8e8784965d78c6e7
/scimath/Functionals/CompoundFunction.h
6170f4cb988441b93e2f66ba1f2d07455bc1e2b5
[]
no_license
astro-informatics/casacore-1.7.0_patched
ec166dc4a13a34ed433dd799393e407d077a8599
8a7cbf4aa79937fba132cf36fea98f448cc230ea
refs/heads/master
2021-01-17T05:26:35.733411
2015-03-24T11:08:55
2015-03-24T11:08:55
32,793,738
2
0
null
null
null
null
UTF-8
C++
false
false
10,851
h
//# CompoundFunction.h: Sum of a collection of Functions //# Copyright (C) 2001,2002,2005 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# //# $Id: CompoundFunction.h 21024 2011-03-01 11:46:18Z gervandiepen $ #ifndef SCIMATH_COMPOUNDFUNCTION_H #define SCIMATH_COMPOUNDFUNCTION_H //# Includes #include <casa/aips.h> #include <scimath/Functionals/CompoundParam.h> #include <scimath/Functionals/Function.h> #include <scimath/Mathematics/AutoDiff.h> #include <scimath/Mathematics/AutoDiffMath.h> namespace casa { //# NAMESPACE CASA - BEGIN //# Forward declarations // <summary> // Sum of a collection of Functions which behaves as one Function object. // </summary> // <use visibility=export> // <reviewed reviewer="tcornwel" date="1996/02/22" tests="tCompoundFunction" // demos=""> // </reviewed> // <prerequisite> // <li> <linkto class="Function">Function</linkto> class // </prerequisite> // // <synopsis> // This class takes an arbitrary number of Function objects, and generates // a new, single function object. The parameters of the compound object // are the union of all the parameters in the input objects. // // When CompoundFunction is evaluated, the result is the sum of // all the individual function values. // // Member functions are added with the <src>addFunction()</src> method. // // In general the interaction with the function parameters should be through // the overall function parameters (i.e. through the parameters of the // <src>CompoundFunction</src>). If for any reason you want to set the // parameters of an individual function (see e.g. the example in the // <linkto class=Fit2D>Fit2D</linkto>), call <src>consolidate()</src> before // abd after the actual setting. // // <note role=tip> // Check <linkto class=CompoundFunction>CombiFunction</linkto> class // for a simple linear combination of function objects </note> // </synopsis> // // <example> // Suppose for some reason we wanted the sum of <src>x^2</src> plus a gaussian. // We could form it as follows: // <srcblock> // Polynomial<Float> x2(2); // x[2] = 1.0; // x^2 // Gaussian1D<Float> gauss(1.0, 0.0, 1.0); // e^{-x^2} // CompoundParam<Float> sum; // sum == 0.0 // sum.addFunction(x2); // sum == x^2 // sum.addFunction(gauss); // sum == x^2+e^{-x^2} // sum(2.0); // == 4 + e^-4 // CompoundParam[0] = 2.0; // sum ==2x^2+e^{-x^2} // sum(2.0); // == 8 + e^-4 // </srcblock> // </example> // <templating arg=T> // <li> T should have standard numerical operators and exp() function. Current // implementation only tested for real types. // <li> To obtain derivatives, the derivatives should be defined. // </templating> // <thrown> // <li> AipsError if dimensions of functions added different // </thrown> // <motivation> // This class was created to allow a non-linear least squares fitter to fit a // (potentially) arbitrary number of functions (typically Gaussians). // </motivation> // // <todo asof="2001/10/22"> // <li> Nothing I know of // </todo> template <class T> class CompoundFunction : public CompoundParam<T> { public: //# Constructors // The default constructor -- no functions, no parameters, nothing, the // function operator returns a 0. CompoundFunction() : CompoundParam<T>() {} // Make this object a (deep) copy of other. If parameters have been set // without an intervening calculation, a <src>consolidate()</src> could // be necessary on <em>other</em> first. // <group> CompoundFunction(const CompoundFunction<T> &other) : CompoundParam<T>(other) {} CompoundFunction(const CompoundFunction<T> &other, Bool) : CompoundParam<T>(other, True) {} template <class W> CompoundFunction(const CompoundFunction<W> &other) : CompoundParam<T>(other) {} template <class W> CompoundFunction(const CompoundFunction<W> &other, Bool) : CompoundParam<T>(other, True) {} // </group> // Make this object a (deep) copy of other. CompoundFunction<T> &operator=(const CompoundFunction<T> &other) { other.fromParam_p(); CompoundParam<T>::operator=(other); return *this; } // Destructor virtual ~CompoundFunction() {} //# Operators // Evaluate the function at <src>x</src>. virtual T eval(typename Function<T>::FunctionArg x) const; //# Member functions // Consolidate the parameter settings. This could be necessary if // parameters have been set, and a copy constructor called. This is // necessary before and after the setting of <em>local</em> parameters; i.e. // the parameters of the individual functions. CompoundFunction<T> &consolidate() { fromParam_p(); toParam_p(); return *this; } // Return a copy of this object from the heap. The caller is responsible for // deleting the pointer. // <group> virtual Function<T> *clone() const { fromParam_p(); return new CompoundFunction<T>(*this); } virtual Function<typename FunctionTraits<T>::DiffType> *cloneAD() const { return new CompoundFunction<typename FunctionTraits<T>::DiffType>(*this); } virtual Function<typename FunctionTraits<T>::BaseType> *cloneNonAD() const { return new CompoundFunction<typename FunctionTraits<T>::BaseType> (*this, True); } // </group> private: //# Member functions // Copy the local parameters from general block void fromParam_p() const; // Make the general block from local parameters void toParam_p(); //# Make members of parent classes known. protected: using CompoundParam<T>::parset_p; using CompoundParam<T>::param_p; using CompoundParam<T>::funpar_p; using CompoundParam<T>::locpar_p; using CompoundParam<T>::paroff_p; using CompoundParam<T>::functionPtr_p; public: using CompoundParam<T>::nparameters; using CompoundParam<T>::nFunctions; using CompoundParam<T>::function; }; #define CompoundFunction_PS CompoundFunction // <summary> Partial <src>AutoDiff</src> specialization of CompoundFunction // </summary> // <synopsis> // <note role=warning> The name <src>CompoundFunction_PS</src> is only // for cxx2html documentation problems. Use // <src>CompoundFunction</src> in your code.</note> // </synopsis> template <class T> class CompoundFunction_PS<AutoDiff<T> > : public CompoundParam<AutoDiff<T> > { public: //# Constructors // The default constructor -- no functions, no parameters, nothing, the // function operator returns a 0. CompoundFunction_PS() : CompoundParam<AutoDiff<T> >() {} // Make this object a (deep) copy of other. If parameters have been set // without an intervening calculation, a <src>consolidate()</src> could // be necessary on <em>other</em> first. // <group> CompoundFunction_PS(const CompoundFunction_PS<AutoDiff<T> > &other) : CompoundParam<AutoDiff<T> >(other) {} template <class W> CompoundFunction_PS(const CompoundFunction_PS<W> &other) : CompoundParam<AutoDiff<T> >(other) {} // </group> // Make this object a (deep) copy of other. CompoundFunction_PS<AutoDiff<T> > & operator=(const CompoundFunction_PS<AutoDiff<T> > &other) { fromParam_p(); CompoundParam<AutoDiff<T> >::operator=(other); return *this; } // Destructor virtual ~CompoundFunction_PS() {} //# Operators // Evaluate the function and its derivatives at <src>x</src> <em>wrt</em> // to the coefficients. virtual AutoDiff<T> eval(typename Function<AutoDiff<T> >::FunctionArg x) const; //# Member functions // Add a function to the sum. All functions must have the same // <src>ndim()</src> as the first one. Returns the (zero relative) number // of the function just added. uInt addFunction(const Function<AutoDiff<T> > &newFunction); // Consolidate the parameter settings. This could be necessary if // parameters have been set, and a copy constructor called. This is // necessary before and after the setting of <em>local</em> parameters; i.e. // the parameters of the individual functions. CompoundFunction_PS<AutoDiff<T> > &consolidate() { fromParam_p(); toParam_p(); return *this; } // Return a copy of this object from the heap. The caller is responsible for // deleting the pointer. // <group> virtual Function<AutoDiff<T> > *clone() const { fromParam_p(); return new CompoundFunction<AutoDiff<T> >(*this); } virtual Function<typename FunctionTraits<AutoDiff<T> >::DiffType> *cloneAD() const { return new CompoundFunction<typename FunctionTraits<AutoDiff<T> >::DiffType> (*this); } virtual Function<typename FunctionTraits<AutoDiff<T> >::BaseType> *cloneNonAD() const { return new CompoundFunction<typename FunctionTraits<AutoDiff<T> >::BaseType> (*this, True); } // </group> private: //# Member functions // Copy the local parameters to/from general block void fromParam_p() const; // Make the general block from local parameters void toParam_p(); //# Make members of parent classes known. protected: using CompoundParam<AutoDiff<T> >::parset_p; using CompoundParam<AutoDiff<T> >::param_p; using CompoundParam<AutoDiff<T> >::funpar_p; using CompoundParam<AutoDiff<T> >::locpar_p; using CompoundParam<AutoDiff<T> >::paroff_p; using CompoundParam<AutoDiff<T> >::functionPtr_p; public: using CompoundParam<AutoDiff<T> >::nparameters; using CompoundParam<AutoDiff<T> >::nFunctions; using CompoundParam<AutoDiff<T> >::function; }; #undef CompoundFunction_PS } //# NAMESPACE CASA - END #ifndef CASACORE_NO_AUTO_TEMPLATES #include <scimath/Functionals/CompoundFunction.tcc> #include <scimath/Functionals/Compound2Function.tcc> #endif //# CASACORE_NO_AUTO_TEMPLATES #endif
[ "jason.mcewen@ucl.ac.uk" ]
jason.mcewen@ucl.ac.uk
73276e406ce47c2ba4993f61c7b44a85903d276f
9f8a069f7d337a022cae89e3e5b75d161c832e2d
/Final_Case/Refined_Grid/Turbulent/constant/polyMesh/boundary
701e9a6587c23d9e75087aeb17f458fe250e8fca
[]
no_license
Logan-Price/CFD
453f6df21f90fd91a834ce98bc0b3970406f148d
16e510ec882e65d5f7101e0aac91dbe8a035f65d
refs/heads/master
2023-04-06T04:17:49.899812
2021-04-19T01:22:14
2021-04-19T01:22:14
359,291,399
0
0
null
null
null
null
UTF-8
C++
false
false
1,842
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v1912 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class polyBoundaryMesh; location "constant/polyMesh"; object boundary; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 7 ( inlet { type patch; nFaces 173; startFace 24588; } outlet { type patch; nFaces 173; startFace 24761; } lowerSymmetry { type symmetryPlane; inGroups 1(symmetryPlane); nFaces 57; startFace 24934; } obstical { type wall; inGroups 1(wall); nFaces 88; startFace 24991; } obsticalTop { type wall; inGroups 1(wall); nFaces 20; startFace 25079; } top { type patch; nFaces 77; startFace 25099; } defaultFaces { type empty; inGroups 1(empty); nFaces 24882; startFace 25176; } ) // ************************************************************************* //
[ "loganprice2369@gmail.com" ]
loganprice2369@gmail.com
b4464b4e56e60a924ea17d4cd35a0f3574eedbff
1c800ad4905593750503096eacc895d962cb12bd
/FinalYearProject/FinalYearProject/Unit.cpp
83a9c3a85a80cb5648e0b830fb358a2963e78afe
[]
no_license
C00192781/FYP
e337a3b1b72b8a3917376369cc1a9f75b6579f1e
75f0be38910f1978c49f7b3af4a3a0556bc86ef7
refs/heads/master
2020-08-23T05:07:46.523207
2018-04-23T20:43:37
2018-04-23T20:43:37
216,548,000
1
0
null
null
null
null
UTF-8
C++
false
false
5,156
cpp
#include "Unit.h" Unit::Unit(float x, float y, int radius, sf::Color col) { // spawns off screen m_xPos = -100; m_yPos = -100; m_radius = radius; colour = col; move = false; moving = false; reached = true; shape.setRadius(radius); shape.setFillColor(sf::Color::Red); //shape.setOutlineColor(sf::Color::Blue); //shape.setOutlineThickness(4); shape.setPosition(m_xPos, m_yPos); } Unit::~Unit() { } void Unit::Move() { //std::cout << shape.getGlobalBounds().left << " " << shape.getGlobalBounds().top << std::endl if (move == true) { if (m_xPos < m_targetX) { m_xPos += 0.5; } if (m_xPos > m_targetX) { m_xPos -= 0.5; } if (m_yPos < m_targetY) { m_yPos += 0.5; } if (m_yPos > m_targetY) { m_yPos -= 0.5; } shape.setPosition(m_xPos, m_yPos); if (m_xPos == m_targetX && m_yPos == m_targetY) { if (m_path.size() > 0) { std::cout << m_path.size() << std::endl; SetTarget(m_path.front()->getWaypoint().x, m_path.front()->getWaypoint().y); std::cout << m_path.front()->getWaypoint().x << " " << m_path.front()->getWaypoint().y; m_path.erase(m_path.begin()); //std::cout << m_path.front()->data().first << " " << m_path.size() << std::endl; clock.restart(); //std::cout << "Path Size: " << m_path.size() << std::endl; } if (m_path.size() <= 0) { if (clock.getElapsedTime().asSeconds() >= 1) { m_xPos = m_startX; m_yPos = m_startY; SetTarget(m_startX, m_startY); } } //std::cout << "test" << std::endl; /*if (pathWaypoints.size() > 0) { std::reverse(pathWaypoints.begin(), pathWaypoints.end()); pathWaypoints.pop_back(); if (pathWaypoints.size() > 0) { std::reverse(pathWaypoints.begin(), pathWaypoints.end()); SetTarget(pathWaypoints.front()); } }*/ } } //else if (m_searchType == "AD*") //{ // if (move == true) // { // if (m_xPos < m_targetX) // { // m_xPos += 0.5; // } // if (m_xPos > m_targetX) // { // m_xPos -= 0.5; // } // if (m_yPos < m_targetY) // { // m_yPos += 0.5; // } // if (m_yPos > m_targetY) // { // m_yPos -= 0.5; // } // shape.setPosition(m_xPos, m_yPos); // if (m_xPos == m_targetX && m_yPos == m_targetY) // { // reached = true; // if (m_path.size() > 0) // { // std::cout << m_path.size() << std::endl; // SetTarget(m_path.front()->getWaypoint().x, m_path.front()->getWaypoint().y); // std::cout << m_path.front()->getWaypoint().x << " " << m_path.front()->getWaypoint().y; // m_path.erase(m_path.begin()); // //std::cout << m_path.front()->data().first << " " << m_path.size() << std::endl; // clock.restart(); // //std::cout << "Path Size: " << m_path.size() << std::endl; // } // if (m_path.size() <= 0) // { // if (clock.getElapsedTime().asSeconds() >= 1) // { // m_xPos = m_startX; // m_yPos = m_startY; // SetTarget(m_startX, m_startY); // } // } // //std::cout << "test" << std::endl; // /*if (pathWaypoints.size() > 0) // { // std::reverse(pathWaypoints.begin(), pathWaypoints.end()); // pathWaypoints.pop_back(); // if (pathWaypoints.size() > 0) // { // std::reverse(pathWaypoints.begin(), pathWaypoints.end()); // SetTarget(pathWaypoints.front()); // } // }*/ // } // } //} } void Unit::SetTarget(float tarX, float tarY) { m_targetX = tarX; m_targetY = tarY; } void Unit::SetPath(std::vector<GraphNode*>& path, int startX, int startY) { //std::cout << "path " << path.size() << std::endl; m_startX = startX; m_startY = startY; // NOTE: MAY REMOVE THESE 2 LINES m_xPos = startX; m_yPos = startY; bool extraNode = false; int index = 0; GraphNode *node; if (path.size() > 0) { move = true; m_path = path; std::cout << path.size() << std::endl; index = searchNearestWaypoint(m_xPos, m_yPos); //std::cout << "dfsffdfggfgfgfgffgfgffdff" << index << std::endl; //std::cout << path.front()->getWaypoint().x << " " << path.front()->getWaypoint().y; //***********************************IMPORTANT LINE COMMENTED OUT m_path.erase(m_path.begin(), m_path.begin() + index); std::cout << m_path.size() << std::endl; SetTarget(m_path.front()->getWaypoint().x, m_path.front()->getWaypoint().y); } } void Unit::Draw(sf::RenderWindow * window) { window->draw(shape); } int Unit::searchNearestWaypoint(float xPos, float yPos) { float differenceValue = std::numeric_limits<int>::max() - 10000; int differenceIndex; for (int i = 0; i < m_path.size(); i++) { sf::Vector2f difference; difference.x = xPos - m_path.at(i)->getWaypoint().x; difference.y = yPos - m_path.at(i)->getWaypoint().y; float diff = sqrtf((difference.x*difference.x) + (difference.y*difference.y)); if (diff < differenceValue) { differenceValue = diff; differenceIndex = i; } } //return everyWaypoint.at(differenceIndex); return differenceIndex; } void Unit::Reset() { m_xPos = m_startX; m_yPos = m_startY; } bool Unit::getReached() { return reached; } void Unit::setSearchType(std::string searchType) { m_searchType = searchType; }
[ "idakev2396@gmail.com" ]
idakev2396@gmail.com
9c36dc49cdf10d9e037db2891f01492a4397332c
e217eaf05d0dab8dd339032b6c58636841aa8815
/IfcAlignment/src/OpenInfraPlatform/IfcAlignment/entity/IfcProject.cpp
64519e1f51ca07cae5d8b60a8b3aa4f9cbfbec8f
[]
no_license
bigdoods/OpenInfraPlatform
f7785ebe4cb46e24d7f636e1b4110679d78a4303
0266e86a9f25f2ea9ec837d8d340d31a58a83c8e
refs/heads/master
2021-01-21T03:41:20.124443
2016-01-26T23:20:21
2016-01-26T23:20:21
57,377,206
0
1
null
2016-04-29T10:38:19
2016-04-29T10:38:19
null
UTF-8
C++
false
false
4,482
cpp
/*! \verbatim * \copyright Copyright (c) 2015 Julian Amann. All rights reserved. * \author Julian Amann <julian.amann@tum.de> (https://www.cms.bgu.tum.de/en/team/amann) * \brief This file is part of the BlueFramework. * \endverbatim */ #include <sstream> #include <limits> #include "OpenInfraPlatform/IfcAlignment/model/IfcAlignmentP6Exception.h" #include "OpenInfraPlatform/IfcAlignment/reader/ReaderUtil.h" #include "OpenInfraPlatform/IfcAlignment/writer/WriterUtil.h" #include "OpenInfraPlatform/IfcAlignment/IfcAlignmentP6EntityEnums.h" #include "include/IfcGloballyUniqueId.h" #include "include/IfcLabel.h" #include "include/IfcOwnerHistory.h" #include "include/IfcProject.h" #include "include/IfcRelAggregates.h" #include "include/IfcRelAssigns.h" #include "include/IfcRelAssociates.h" #include "include/IfcRelDeclares.h" #include "include/IfcRelDefinesByProperties.h" #include "include/IfcRelNests.h" #include "include/IfcRepresentationContext.h" #include "include/IfcText.h" #include "include/IfcUnitAssignment.h" namespace OpenInfraPlatform { namespace IfcAlignment { // ENTITY IfcProject IfcProject::IfcProject() { m_entity_enum = IFCPROJECT; } IfcProject::IfcProject( int id ) { m_id = id; m_entity_enum = IFCPROJECT; } IfcProject::~IfcProject() {} // method setEntity takes over all attributes from another instance of the class void IfcProject::setEntity( shared_ptr<IfcAlignmentP6Entity> other_entity ) { shared_ptr<IfcProject> other = dynamic_pointer_cast<IfcProject>(other_entity); if( !other) { return; } m_GlobalId = other->m_GlobalId; m_OwnerHistory = other->m_OwnerHistory; m_Name = other->m_Name; m_Description = other->m_Description; m_ObjectType = other->m_ObjectType; m_LongName = other->m_LongName; m_Phase = other->m_Phase; m_RepresentationContexts = other->m_RepresentationContexts; m_UnitsInContext = other->m_UnitsInContext; } void IfcProject::getStepLine( std::stringstream& stream ) const { stream << "#" << m_id << "=IFCPROJECT" << "("; if( m_GlobalId ) { m_GlobalId->getStepParameter( stream ); } else { stream << "$"; } stream << ","; if( m_OwnerHistory ) { stream << "#" << m_OwnerHistory->getId(); } else { stream << "$"; } stream << ","; if( m_Name ) { m_Name->getStepParameter( stream ); } else { stream << "$"; } stream << ","; if( m_Description ) { m_Description->getStepParameter( stream ); } else { stream << "$"; } stream << ","; if( m_ObjectType ) { m_ObjectType->getStepParameter( stream ); } else { stream << "$"; } stream << ","; if( m_LongName ) { m_LongName->getStepParameter( stream ); } else { stream << "$"; } stream << ","; if( m_Phase ) { m_Phase->getStepParameter( stream ); } else { stream << "$"; } stream << ","; writeEntityList( stream, m_RepresentationContexts ); stream << ","; if( m_UnitsInContext ) { stream << "#" << m_UnitsInContext->getId(); } else { stream << "$"; } stream << ");"; } void IfcProject::getStepParameter( std::stringstream& stream, bool ) const { stream << "#" << m_id; } void IfcProject::readStepData( std::vector<std::string>& args, const std::map<int,shared_ptr<IfcAlignmentP6Entity> >& map ) { const int num_args = (int)args.size(); if( num_args<9 ){ std::stringstream strserr; strserr << "Wrong parameter count for entity IfcProject, expecting 9, having " << num_args << ". Object id: " << getId() << std::endl; throw IfcAlignmentP6Exception( strserr.str().c_str() ); } #ifdef _DEBUG if( num_args>9 ){ std::cout << "Wrong parameter count for entity IfcProject, expecting 9, having " << num_args << ". Object id: " << getId() << std::endl; } #endif m_GlobalId = IfcGloballyUniqueId::readStepData( args[0] ); readEntityReference( args[1], m_OwnerHistory, map ); m_Name = IfcLabel::readStepData( args[2] ); m_Description = IfcText::readStepData( args[3] ); m_ObjectType = IfcLabel::readStepData( args[4] ); m_LongName = IfcLabel::readStepData( args[5] ); m_Phase = IfcLabel::readStepData( args[6] ); readEntityReferenceList( args[7], m_RepresentationContexts, map ); readEntityReference( args[8], m_UnitsInContext, map ); } void IfcProject::setInverseCounterparts( shared_ptr<IfcAlignmentP6Entity> ptr_self_entity ) { IfcContext::setInverseCounterparts( ptr_self_entity ); } void IfcProject::unlinkSelf() { IfcContext::unlinkSelf(); } } // end namespace IfcAlignment } // end namespace OpenInfraPlatform
[ "planung.cms.bv@tum.de" ]
planung.cms.bv@tum.de
bb9dc4bd1ade9b26eef39fc7c0bc636d5eee3d63
1d928c3f90d4a0a9a3919a804597aa0a4aab19a3
/c++/ClickHouse/2016/12/WriteBufferAIO.cpp
4c7fc6d417eb68f23d1564263e090fdda204e543
[ "BSL-1.0" ]
permissive
rosoareslv/SED99
d8b2ff5811e7f0ffc59be066a5a0349a92cbb845
a062c118f12b93172e31e8ca115ce3f871b64461
refs/heads/main
2023-02-22T21:59:02.703005
2021-01-28T19:40:51
2021-01-28T19:40:51
306,497,459
1
1
null
2020-11-24T20:56:18
2020-10-23T01:18:07
null
UTF-8
C++
false
false
14,986
cpp
#include <DB/IO/WriteBufferAIO.h> #include <DB/Common/ProfileEvents.h> #include <limits> #include <sys/types.h> #include <sys/stat.h> namespace ProfileEvents { extern const Event FileOpen; extern const Event FileOpenFailed; extern const Event WriteBufferAIOWrite; extern const Event WriteBufferAIOWriteBytes; } namespace CurrentMetrics { extern const Metric Write; } namespace DB { namespace ErrorCodes { extern const int FILE_DOESNT_EXIST; extern const int CANNOT_OPEN_FILE; extern const int LOGICAL_ERROR; extern const int ARGUMENT_OUT_OF_BOUND; extern const int AIO_READ_ERROR; extern const int AIO_SUBMIT_ERROR; extern const int AIO_WRITE_ERROR; extern const int AIO_COMPLETION_ERROR; extern const int CANNOT_TRUNCATE_FILE; extern const int CANNOT_FSYNC; } /// Примечание: выделяется дополнительная страница, которая содежрит те данные, которые /// не влезают в основной буфер. WriteBufferAIO::WriteBufferAIO(const std::string & filename_, size_t buffer_size_, int flags_, mode_t mode_, char * existing_memory_) : WriteBufferFromFileBase(buffer_size_ + DEFAULT_AIO_FILE_BLOCK_SIZE, existing_memory_, DEFAULT_AIO_FILE_BLOCK_SIZE), flush_buffer(BufferWithOwnMemory<WriteBuffer>(this->memory.size(), nullptr, DEFAULT_AIO_FILE_BLOCK_SIZE)), filename(filename_) { /// Исправить информацию о размере буферов, чтобы дополнительные страницы не касались базового класса BufferBase. this->buffer().resize(this->buffer().size() - DEFAULT_AIO_FILE_BLOCK_SIZE); this->internalBuffer().resize(this->internalBuffer().size() - DEFAULT_AIO_FILE_BLOCK_SIZE); flush_buffer.buffer().resize(this->buffer().size() - DEFAULT_AIO_FILE_BLOCK_SIZE); flush_buffer.internalBuffer().resize(this->internalBuffer().size() - DEFAULT_AIO_FILE_BLOCK_SIZE); ProfileEvents::increment(ProfileEvents::FileOpen); int open_flags = (flags_ == -1) ? (O_RDWR | O_TRUNC | O_CREAT) : flags_; open_flags |= O_DIRECT; fd = ::open(filename.c_str(), open_flags, mode_); if (fd == -1) { ProfileEvents::increment(ProfileEvents::FileOpenFailed); auto error_code = (errno == ENOENT) ? ErrorCodes::FILE_DOESNT_EXIST : ErrorCodes::CANNOT_OPEN_FILE; throwFromErrno("Cannot open file " + filename, error_code); } } WriteBufferAIO::~WriteBufferAIO() { if (!aio_failed) { try { flush(); } catch (...) { tryLogCurrentException(__PRETTY_FUNCTION__); } } if (fd != -1) ::close(fd); } off_t WriteBufferAIO::getPositionInFile() { return seek(0, SEEK_CUR); } void WriteBufferAIO::sync() { flush(); /// Попросим ОС сбросить данные на диск. int res = ::fsync(fd); if (res == -1) throwFromErrno("Cannot fsync " + getFileName(), ErrorCodes::CANNOT_FSYNC); } void WriteBufferAIO::nextImpl() { if (!offset()) return; if (waitForAIOCompletion()) finalize(); /// Создать запрос на асинхронную запись. prepare(); request.aio_lio_opcode = IOCB_CMD_PWRITE; request.aio_fildes = fd; request.aio_buf = reinterpret_cast<UInt64>(buffer_begin); request.aio_nbytes = region_aligned_size; request.aio_offset = region_aligned_begin; /// Отправить запрос. while (io_submit(aio_context.ctx, request_ptrs.size(), &request_ptrs[0]) < 0) { if (errno != EINTR) { aio_failed = true; throw Exception("Cannot submit request for asynchronous IO on file " + filename, ErrorCodes::AIO_SUBMIT_ERROR); } } is_pending_write = true; } off_t WriteBufferAIO::doSeek(off_t off, int whence) { flush(); if (whence == SEEK_SET) { if (off < 0) throw Exception("SEEK_SET underflow", ErrorCodes::ARGUMENT_OUT_OF_BOUND); pos_in_file = off; } else if (whence == SEEK_CUR) { if (off >= 0) { if (off > (std::numeric_limits<off_t>::max() - pos_in_file)) throw Exception("SEEK_CUR overflow", ErrorCodes::ARGUMENT_OUT_OF_BOUND); } else if (off < -pos_in_file) throw Exception("SEEK_CUR underflow", ErrorCodes::ARGUMENT_OUT_OF_BOUND); pos_in_file += off; } else throw Exception("WriteBufferAIO::seek expects SEEK_SET or SEEK_CUR as whence", ErrorCodes::ARGUMENT_OUT_OF_BOUND); if (pos_in_file > max_pos_in_file) max_pos_in_file = pos_in_file; return pos_in_file; } void WriteBufferAIO::doTruncate(off_t length) { flush(); int res = ::ftruncate(fd, length); if (res == -1) throwFromErrno("Cannot truncate file " + filename, ErrorCodes::CANNOT_TRUNCATE_FILE); } void WriteBufferAIO::flush() { next(); if (waitForAIOCompletion()) finalize(); } bool WriteBufferAIO::waitForAIOCompletion() { if (!is_pending_write) return false; CurrentMetrics::Increment metric_increment{CurrentMetrics::Write}; while (io_getevents(aio_context.ctx, events.size(), events.size(), &events[0], nullptr) < 0) { if (errno != EINTR) { aio_failed = true; throw Exception("Failed to wait for asynchronous IO completion on file " + filename, ErrorCodes::AIO_COMPLETION_ERROR); } } is_pending_write = false; bytes_written = events[0].res; ProfileEvents::increment(ProfileEvents::WriteBufferAIOWrite); ProfileEvents::increment(ProfileEvents::WriteBufferAIOWriteBytes, bytes_written); return true; } void WriteBufferAIO::prepare() { /// Менять местами основной и дублирующий буферы. buffer().swap(flush_buffer.buffer()); std::swap(position(), flush_buffer.position()); truncation_count = 0; /* Страница на диске или в памяти начальный адрес (начальная позиция в случае диска) кратен DEFAULT_AIO_FILE_BLOCK_SIZE : : +---------------+ | | | | | | | | | | | | +---------------+ <---------------> : : DEFAULT_AIO_FILE_BLOCK_SIZE */ /* Представление данных на диске XXX : данные, которые хотим записать ZZZ : данные, которые уже на диске или нули, если отсутствуют данные region_aligned_begin region_aligned_end : region_begin region_end : : : : : : : : : +---:-----------+---------------+---------------+---------------+--:------------+ | : | | | | : | | +-----------+---------------+---------------+---------------+--+ | |ZZZ|XXXXXXXXXXX|XXXXXXXXXXXXXXX|XXXXXXXXXXXXXXX|XXXXXXXXXXXXXXX|XX|ZZZZZZZZZZZZ| |ZZZ|XXXXXXXXXXX|XXXXXXXXXXXXXXX|XXXXXXXXXXXXXXX|XXXXXXXXXXXXXXX|XX|ZZZZZZZZZZZZ| | +-----------+---------------+---------------+---------------+--+ | | | | | | | +---------------+---------------+---------------+---------------+---------------+ <--><--------------------------------------------------------------><-----------> : : : : : : region_left_padding region_size region_right_padding <-------------------------------------------------------------------------------> : : region_aligned_size */ /// Регион диска, в который хотим записать данные. const off_t region_begin = pos_in_file; if ((flush_buffer.offset() > std::numeric_limits<off_t>::max()) || (pos_in_file > (std::numeric_limits<off_t>::max() - static_cast<off_t>(flush_buffer.offset())))) throw Exception("An overflow occurred during file operation", ErrorCodes::LOGICAL_ERROR); const off_t region_end = pos_in_file + flush_buffer.offset(); const size_t region_size = region_end - region_begin; /// Выровненный регион диска, в который хотим записать данные. const size_t region_left_padding = region_begin % DEFAULT_AIO_FILE_BLOCK_SIZE; const size_t region_right_padding = (DEFAULT_AIO_FILE_BLOCK_SIZE - (region_end % DEFAULT_AIO_FILE_BLOCK_SIZE)) % DEFAULT_AIO_FILE_BLOCK_SIZE; region_aligned_begin = region_begin - region_left_padding; if (region_end > (std::numeric_limits<off_t>::max() - static_cast<off_t>(region_right_padding))) throw Exception("An overflow occurred during file operation", ErrorCodes::LOGICAL_ERROR); const off_t region_aligned_end = region_end + region_right_padding; region_aligned_size = region_aligned_end - region_aligned_begin; bytes_to_write = region_aligned_size; /* Представление данных в буфере до обработки XXX : данные, которые хотим записать buffer_begin buffer_end : : : : +---------------+---------------+---------------+-------------:-+ | | | | : | +---------------+---------------+---------------+-------------+ | |XXXXXXXXXXXXXXX|XXXXXXXXXXXXXXX|XXXXXXXXXXXXXXX|XXXXXXXXXXXXX| | |XXXXXXXXXXXXXXX|XXXXXXXXXXXXXXX|XXXXXXXXXXXXXXX|XXXXXXXXXXXXX| | +---------------+---------------+---------------+-------------+ | | | | | | +---------------+---------------+---------------+---------------+ <-------------------------------------------------------------> : : buffer_size */ /// Буфер данных, которые хотим записать на диск. buffer_begin = flush_buffer.buffer().begin(); Position buffer_end = buffer_begin + region_size; size_t buffer_size = buffer_end - buffer_begin; /// Обработать буфер, чтобы он отражал структуру региона диска. /* Представление данных в буфере после обработки XXX : данные, которые хотим записать ZZZ : данные из диска или нули, если отсутствуют данные buffer_begin buffer_end дополнительная страница : : : : : : +---:-----------+---------------+---------------+---------------+--:------------+ | | | | | : | | +-----------+---------------+---------------+---------------+--+ | |ZZZ|XXXXXXXXXXX|XXXXXXXXXXXXXXX|XXXXXXXXXXXXXXX|XXXXXXXXXXXXXXX|XX|ZZZZZZZZZZZZ| |ZZZ|XXXXXXXXXXX|XXXXXXXXXXXXXXX|XXXXXXXXXXXXXXX|XXXXXXXXXXXXXXX|XX|ZZZZZZZZZZZZ| | +-----------+---------------+---------------+---------------+--+ | | | | | | | +---------------+---------------+---------------+---------------+---------------+ <--><--------------------------------------------------------------><-----------> : : : : : : region_left_padding region_size region_right_padding <-------------------------------------------------------------------------------> : : region_aligned_size */ if ((region_left_padding > 0) || (region_right_padding > 0)) { char memory_page[DEFAULT_AIO_FILE_BLOCK_SIZE] __attribute__ ((aligned (DEFAULT_AIO_FILE_BLOCK_SIZE))); if (region_left_padding > 0) { /// Сдвинуть данные буфера вправо. Дополнить начало буфера данными из диска. buffer_size += region_left_padding; buffer_end = buffer_begin + buffer_size; ::memmove(buffer_begin + region_left_padding, buffer_begin, (buffer_size - region_left_padding) * sizeof(*buffer_begin)); ssize_t read_count = ::pread(fd, memory_page, DEFAULT_AIO_FILE_BLOCK_SIZE, region_aligned_begin); if (read_count < 0) throw Exception("Read error", ErrorCodes::AIO_READ_ERROR); size_t to_copy = std::min(static_cast<size_t>(read_count), region_left_padding); ::memcpy(buffer_begin, memory_page, to_copy * sizeof(*buffer_begin)); ::memset(buffer_begin + to_copy, 0, (region_left_padding - to_copy) * sizeof(*buffer_begin)); } if (region_right_padding > 0) { /// Дополнить конец буфера данными из диска. ssize_t read_count = ::pread(fd, memory_page, DEFAULT_AIO_FILE_BLOCK_SIZE, region_aligned_end - DEFAULT_AIO_FILE_BLOCK_SIZE); if (read_count < 0) throw Exception("Read error", ErrorCodes::AIO_READ_ERROR); Position truncation_begin; off_t offset = DEFAULT_AIO_FILE_BLOCK_SIZE - region_right_padding; if (read_count > offset) { ::memcpy(buffer_end, memory_page + offset, (read_count - offset) * sizeof(*buffer_end)); truncation_begin = buffer_end + (read_count - offset); truncation_count = DEFAULT_AIO_FILE_BLOCK_SIZE - read_count; } else { truncation_begin = buffer_end; truncation_count = region_right_padding; } ::memset(truncation_begin, 0, truncation_count * sizeof(*truncation_begin)); } } } void WriteBufferAIO::finalize() { if (bytes_written < bytes_to_write) throw Exception("Asynchronous write error on file " + filename, ErrorCodes::AIO_WRITE_ERROR); bytes_written -= truncation_count; off_t pos_offset = bytes_written - (pos_in_file - request.aio_offset); if (pos_in_file > (std::numeric_limits<off_t>::max() - pos_offset)) throw Exception("An overflow occurred during file operation", ErrorCodes::LOGICAL_ERROR); pos_in_file += pos_offset; if (pos_in_file > max_pos_in_file) max_pos_in_file = pos_in_file; if (truncation_count > 0) { /// Укоротить файл, чтобы удалить из него излишние нули. int res = ::ftruncate(fd, max_pos_in_file); if (res == -1) throwFromErrno("Cannot truncate file " + filename, ErrorCodes::CANNOT_TRUNCATE_FILE); } } }
[ "rodrigosoaresilva@gmail.com" ]
rodrigosoaresilva@gmail.com
77f0646fc78709efd3e8e8b512ba9811a93def23
a23f3487ebe1a870c3d4c24664295d1140027290
/ARALGIS/VehicleDetection/SourceFiles/VehicleDetection.cpp
2d46f2e03dcecc743cc0353164fbce786343db58
[]
no_license
alisezgin/ARALGIS
c5617393daf2aab84e6b1d9b6bc93bd53d31114d
55ce3d55cf15edf818b5f0bd944a1d7b8f684fa9
refs/heads/master
2021-01-19T09:48:55.611879
2017-07-31T13:23:36
2017-07-31T13:23:36
87,786,703
0
1
null
null
null
null
UTF-8
C++
false
false
27,179
cpp
#include "stdafx.h" #include "ARALGIS.h" #include "..\HeaderFiles\VehicleDetection.h" #include "MainFrm.h" #include "ARALGISView.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // // FUNCTION: CVehicleDetection::CVehicleDetection // // DESCRIPTION: C'tor // // INPUTS: // // NOTES: // // MODIFICATIONS: // //////////////////////////////////////////////////////////////////////////////// CVehicleDetection::CVehicleDetection() { bRun = FALSE; } //////////////////////////////////////////////////////////////////////////////// // // FUNCTION: CVehicleDetection::CVehicleDetection // // DESCRIPTION: D'tor // // INPUTS: // // NOTES: // // MODIFICATIONS: // //////////////////////////////////////////////////////////////////////////////// CVehicleDetection::~CVehicleDetection() { Shutdown(); } //////////////////////////////////////////////////////////////////////////////// // // FUNCTION: CVehicleDetection::CVehicleDetection // // DESCRIPTION: starts the CameraDBServer Thread // // INPUTS: // // NOTES: // // MODIFICATIONS: // //////////////////////////////////////////////////////////////////////////////// BOOL CVehicleDetection::Start(CMainFrame* pFrame) { if (bRun) { TRACE("_beginthreadex(...) failure, for Launch ThreadVehicleDetection::Start\n"); return FALSE; } TRACE("Vehicle Detection Thread Starting ...\n"); m_pFrame = pFrame; bRun = TRUE; ShutdownEvent = CreateEvent(NULL, TRUE, FALSE, NULL); ProcessingFinishedEvent = CreateEvent(NULL, TRUE, TRUE, NULL); /// created as Set, 3rd argument is TRUE !!!!!!!! ProcessDataEvent = CreateEvent(NULL, TRUE, FALSE, NULL); // Launch Vehicle Detection Thread ThreadVehicleDetection = (HANDLE)_beginthreadex(NULL, 0, VehicleDetectionThread, this, 0, &ThreadIDVD ); if (!ThreadVehicleDetection) { TRACE("_beginthreadex(...) failure, ThreadVehicleDetection::Start\n"); return FALSE; } TRACE("ThreadVehicleDetection ThreadID %x ...\n", ThreadIDVD); TRACE(L"VehicleDetection Camera Interface Thread Starting ...\n"); // Launch CameraInterface Thread ThreadCameraInterface = (HANDLE)_beginthreadex( NULL, 0, CameraInterfaceThread, this, 0, &ThreadIDCI ); if (!ThreadCameraInterface) { TRACE("_beginthreadex(...) failure, VehicleDetection-ThreadCameraInterface::Start\n"); return FALSE; } TRACE("VehicleDetection-ThreadCameraInterface ThreadID %x ...\n", ThreadIDCI); return TRUE; } //////////////////////////////////////////////////////////////////////////////// // // FUNCTION: CVehicleDetection::Shutdown // // DESCRIPTION: stops the CameraDBServer thread // // INPUTS: // // NOTES: // // MODIFICATIONS: // //////////////////////////////////////////////////////////////////////////////// BOOL CVehicleDetection::Shutdown() { if (!bRun) return FALSE; TRACE("ThreadVehicleDetection Shutting down ...\n"); SetEvent(ShutdownEvent); WaitForSingleObject(ThreadVehicleDetection, INFINITE); WaitForSingleObject(ThreadCameraInterface, INFINITE); CloseHandle(ShutdownEvent); CloseHandle(ProcessingFinishedEvent); CloseHandle(ProcessDataEvent); CloseHandle(ThreadVehicleDetection); CloseHandle(ThreadCameraInterface); bRun = FALSE; return TRUE; } //////////////////////////////////////////////////////////////////////////////// // // FUNCTION: CVehicleDetection::CameraInterfaceThread // // DESCRIPTION: thread function for starting camera interface thread // // INPUTS: // // NOTES: // // MODIFICATIONS: // //////////////////////////////////////////////////////////////////////////////// UINT __stdcall CVehicleDetection::CameraInterfaceThread(LPVOID pParam) { CVehicleDetection *pVehicleDetection = (CVehicleDetection*)pParam; int dFrmCntr; TRACE("CameraInterfaceThread Started\n"); HANDLE Handles[2]; Handles[0] = pVehicleDetection->ShutdownEvent; Handles[1] = g_IntermediateImageReadyEvent; for (;;) { DWORD EventCaused = WaitForMultipleObjects( 2, Handles, FALSE, INFINITE); if (EventCaused == WAIT_FAILED || EventCaused == WAIT_OBJECT_0) { if (EventCaused == WAIT_FAILED) TRACE("WaitForMultipleObjects failure at CameraInterfaceThread", GetLastError()); else TRACE("CameraInterfaceThread is shutting Down normally...\n"); return THREADEXIT_SUCCESS; } // g_IntermediateImageReadyEvent is received else if (EventCaused == WAIT_OBJECT_0 + 1) { TRACE("g_IntermediateImageReadyEvent received \n"); if (g_AutoDetect_Type != NO_AUTO_VEHICLE_DETECT) { dFrmCntr = g_IntermediateCounter; } else { dFrmCntr = 1; } if (dFrmCntr == 1) { TRACE("waiting EventTTTTTTTT \n"); WaitForSingleObject(pVehicleDetection->ProcessingFinishedEvent, INFINITE); ResetEvent(pVehicleDetection->ProcessingFinishedEvent); pVehicleDetection->m_dProcessedFrameCounter = 0; pVehicleDetection->m_dFrameCounter = dFrmCntr; pVehicleDetection->m_isStopSignalled = false; //SetEvent(pVehicleDetection->ProcessDataEvent); } pVehicleDetection->m_dFrameCounter = dFrmCntr; TRACE("THR_2 FRM_CNT %d PRS_CNT %d \n", pVehicleDetection->m_dFrameCounter, pVehicleDetection->m_dProcessedFrameCounter); if (g_AutoDetect_Type != NO_AUTO_VEHICLE_DETECT) { if (pVehicleDetection->m_dFrameCounter - pVehicleDetection->m_dProcessedFrameCounter - 1 == 0) { TRACE(L"SetEvent(pVehicleDetection->ProcessDataEvent) \n"); SetEvent(pVehicleDetection->ProcessDataEvent); } } else { SetEvent(pVehicleDetection->ProcessDataEvent); } ResetEvent(g_IntermediateImageReadyEvent); } } // infite for loop return THREADEXIT_SUCCESS; } //////////////////////////////////////////////////////////////////////////////// // // FUNCTION: CVehicleDetection::VehicleDetectionThread // // DESCRIPTION: thread function for starting vehicle detection thread from test image // // INPUTS: // // NOTES: // // MODIFICATIONS: // //////////////////////////////////////////////////////////////////////////////// UINT __stdcall CVehicleDetection::VehicleDetectionThread(LPVOID pParam) { CVehicleDetection *pVehicleDetection = (CVehicleDetection*)pParam; TRACE("VehicleDetectionThread Started\n"); CView * pView = pVehicleDetection->m_pFrame->GetActiveView(); LPARAM pLparam; pLparam = reinterpret_cast<LPARAM>("ARALGIS"); bool bIsProcessingFinished; bool bIsCarFound = false; cv::Mat inGray; cv::Mat inClr; int nRows; int nCols; uchar* dataPtr1; float* fMean; fMean = new float[100000]; ////////////////////////////////////////////// int dAnalysisWindow = 10; float fMeanWindow; float fStdWindow; bool bBegIdxFound; bool bEndIdxFound; float fMeanWindowPrev, fMeanWindowCurr; float fStdWindowPrev, fStdWindowCurr; float fMeanWindowPrev2, fStdWindowPrev2; float fMeanWindowPrev3, fStdWindowPrev3; float fCoeffOfVar1, fCoeffOfVar2; //int k; fStdWindowPrev = fStdWindowCurr = 0.0; fMeanWindowPrev = fMeanWindowCurr = 0; fMeanWindowPrev2 = fStdWindowPrev2 = 0.0; float fMeanMeanStart1, fMeanMeanStart2; float fStdMeanStart1, fStdMeanStart2; int dMeanStartCtr1, dMeanStartCtr2; int dStartCancelCounter = 0; float fStartMean = 0.0; float fStartStd = 0.0; int dThresholdStartControl = 200; int dStartZeroStdCntr = 0; int dStartZeroStdThreshold = 5; int dStdSpikeCounterStart = 0; int dSpikeCtrTresholdStart = 30; fMeanMeanStart1 = fMeanMeanStart2 = 0.0; fStdMeanStart1 = fStdMeanStart2 = 0.0; dMeanStartCtr1 = 0; dMeanStartCtr2 = 0; float fMeanMeanEnd1, fMeanMeanEnd2; float fStdMeanEnd1, fStdMeanEnd2; int dMeanEndCtr1, dMeanEndCtr2; int dEndCancelCounter = 0; float fEndMean = 0.0; float fEndStd = 0.0; fMeanMeanEnd2 = 0.0; fStdMeanEnd2 = 0.0; fMeanMeanStart1 = fMeanMeanStart2 = (float)0.0; fStdMeanStart1 = fStdMeanStart2 = (float)0.0; dMeanEndCtr1 = dMeanEndCtr2 = 0; int dThresholdEndControl = 200; int dStdSpikeCounterEnd = 0; int dSpikeCtrTresholdEnd = 15; int dSmallStdCounterEnd = 0; int dSmallStdCounterTresholdEnd = 5; float fCVEnd; int dCVEndCounter = 0; int dCVEndCounterThreshold = 10; float dMagicMultiplier = (float)0.3; float dMagicMultiplier1 = (float)0.10; float dMagicMultiplier2 = (float) 0.05; float dMagicMultiplier3 = (float)0.01; bool bStartPassedTest = false; bool bEndPassedTest = false; ////////////////////////////////////////////// HANDLE Handles[2]; Handles[0] = pVehicleDetection->ShutdownEvent; Handles[1] = pVehicleDetection->ProcessDataEvent; for (;;) { DWORD EventCaused = WaitForMultipleObjects( 2, Handles, FALSE, INFINITE); if (EventCaused == WAIT_FAILED || EventCaused == WAIT_OBJECT_0) { if (EventCaused == WAIT_FAILED) TRACE("WaitForMultipleObjects failure at VehicleDetectionThread", GetLastError()); else TRACE("VehicleDetectionThread is shutting Down normally...\n"); delete[] fMean; return THREADEXIT_SUCCESS; } // ProcessDataEvent is received else if (EventCaused == WAIT_OBJECT_0 + 1) { if (pVehicleDetection->m_dFrameCounter == 1) { TRACE("THR_1 Init\n"); pVehicleDetection->m_dlineCounter = 0; g_dEndIndex = g_dBeginIndex = 0; fStdWindowCurr = (float)0.0; fStdWindowPrev = (float)0.0; fStdWindowPrev2 = (float)0.0; fStdWindowPrev3 = (float)0.0; fMeanWindowCurr = (float)0.0; fMeanWindowPrev = (float)0.0; fMeanWindowPrev2 = (float)0.0; fMeanWindowPrev3 =(float)0.0; bEndIdxFound = false; bBegIdxFound = false; bIsCarFound = false; g_dCarDetectCount = 0; g_CarFound = FALSE; dMeanStartCtr1 = 0; dMeanStartCtr2 = 0; ///////// dStartCancelCounter = 0; fStartMean =(float)0.0; fStartStd = (float)0.0; dThresholdStartControl = 200; dStartZeroStdCntr = 0; dStartZeroStdThreshold = 5; dStdSpikeCounterStart = 0; dSpikeCtrTresholdStart = 30; dEndCancelCounter = 0; fEndMean = 0.0; fEndStd = 0.0; fMeanMeanEnd2 = (float)0.0; fStdMeanEnd2 = (float)0.0; fMeanMeanStart1 = fMeanMeanStart2 = (float)0.0; fStdMeanStart1 = fStdMeanStart2 = (float)0.0; dMeanEndCtr1 = 0; dMeanEndCtr2 = 0; dThresholdEndControl = 200; dStdSpikeCounterEnd = 0; dSpikeCtrTresholdEnd = 15; dSmallStdCounterEnd = 0; dSmallStdCounterTresholdEnd = 5; dCVEndCounter = 0; dCVEndCounterThreshold = 10; bStartPassedTest = false; bEndPassedTest = false; ///////// } else { g_dEndIndex = g_dBeginIndex = 0; fStdWindowCurr = (float)0.0; fStdWindowPrev = (float)0.0; fStdWindowPrev2 = (float)0.0; fStdWindowPrev3 = (float)0.0; fMeanWindowCurr = (float)0.0; fMeanWindowPrev = (float)0.0; fMeanWindowPrev2 = (float)0.0; fMeanWindowPrev3 = (float)0.0; bEndIdxFound = false; bBegIdxFound = false; bIsCarFound = false; g_dCarDetectCount = 0; g_CarFound = FALSE; dMeanStartCtr1 = 0; dMeanStartCtr2 = 0; ///////// dStartCancelCounter = 0; fStartMean = (float)0.0; fStartStd = (float)0.0; dThresholdStartControl = 200; dStartZeroStdCntr = 0; dStartZeroStdThreshold = 5; dStdSpikeCounterStart = 0; dSpikeCtrTresholdStart = 30; dEndCancelCounter = 0; fEndMean = 0.0; fEndStd = 0.0; fMeanMeanEnd2 = (float)0.0; fStdMeanEnd2 = (float)0.0; dMeanEndCtr2 = 0; fMeanMeanStart1 = fMeanMeanStart2 = (float)0.0; fStdMeanStart1 = fStdMeanStart2 = (float)0.0; dMeanEndCtr1 = 0; dMeanEndCtr2 = 0; dThresholdEndControl = 200; dStdSpikeCounterEnd = 0; dSpikeCtrTresholdEnd = 15; dSmallStdCounterEnd = 0; dSmallStdCounterTresholdEnd = 5; dCVEndCounter = 0; dCVEndCounterThreshold = 10; bStartPassedTest = false; bEndPassedTest = false; ///TRACE("\n\n\n RESETTING THINGS !!!!!!!!!!!!!!!!!!!\n\n\n"); } //TRACE("\n STARTING WHILE \n"); bIsProcessingFinished = false; while ((bIsProcessingFinished == false) ) { TRACE("PRS FRM-CNT %d \n", pVehicleDetection->m_dProcessedFrameCounter); if (g_CameraPixelBits == 24) { inClr = g_CVImageTestIntermediate[pVehicleDetection->m_dProcessedFrameCounter].clone(); cv::cvtColor(inClr, inGray, CV_RGB2GRAY); } else { if (g_AutoDetect_Type != NO_AUTO_VEHICLE_DETECT) { inGray.create(g_CVImageTestIntermediate[pVehicleDetection->m_dProcessedFrameCounter].size(), g_CVImageTestIntermediate[pVehicleDetection->m_dProcessedFrameCounter].type()); inGray = g_CVImageTestIntermediate[pVehicleDetection->m_dProcessedFrameCounter].clone(); } else { inGray.create(g_CVImageTest.size(), g_CVImageTest.type()); inGray = g_CVImageTest.clone(); } } nRows = inGray.rows; nCols = inGray.cols; fStdWindowPrev = fStdWindowCurr = 0.0; fMeanWindowPrev = fMeanWindowCurr = 0; fMeanWindowPrev2 = fStdWindowPrev2 = 0.0; fMeanWindowPrev3 = fStdWindowPrev3 = 0.0; { g_dEndIndex = g_dBeginIndex = 0; fStdWindowCurr = (float)0.0; fStdWindowPrev = (float)0.0; fStdWindowPrev2 = (float)0.0; fStdWindowPrev3 = (float)0.0; fMeanWindowCurr = (float)0.0; fMeanWindowPrev = (float)0.0; fMeanWindowPrev2 = (float)0.0; fMeanWindowPrev3 = (float)0.0; bEndIdxFound = false; bBegIdxFound = false; bIsCarFound = false; g_CarFound = FALSE; g_dCarDetectCount = 0; dMeanStartCtr1 = 0; dMeanStartCtr2 = 0; ///////// dStartCancelCounter = 0; fStartMean = (float)0.0; fStartStd = (float)0.0; dThresholdStartControl = 200; dStartZeroStdCntr = 0; dStartZeroStdThreshold = 5; dStdSpikeCounterStart = 0; dSpikeCtrTresholdStart = 30; dEndCancelCounter = 0; fEndMean = 0.0; fEndStd = 0.0; fMeanMeanEnd2 = (float)0.0; fStdMeanEnd2 = (float)0.0; fMeanMeanStart1 = fMeanMeanStart2 = (float)0.0; fStdMeanStart1 = fStdMeanStart2 = (float)0.0; dThresholdEndControl = 200; dMeanEndCtr1 = 0; dMeanEndCtr2 = 0; dStdSpikeCounterEnd = 0; dSpikeCtrTresholdEnd = 15; dSmallStdCounterEnd = 0; dSmallStdCounterTresholdEnd = 5; dCVEndCounter = 0; dCVEndCounterThreshold = 10; bStartPassedTest = false; bEndPassedTest = false; //TRACE("\n\n\n RESETTING THINGS !!!!!!!!!!!!!!!!!!!\n\n\n"); } TRACE("lineCounter-1 %d \n", pVehicleDetection->m_dlineCounter); for (int i = 0; i < nRows; i++) { dataPtr1 = inGray.ptr<uchar>(i); fMean[pVehicleDetection->m_dlineCounter] = 0.0; for (int j = 0; j < nCols; j++) { fMean[pVehicleDetection->m_dlineCounter] += (uchar)dataPtr1[j]; } fMean[pVehicleDetection->m_dlineCounter] = (float)((float)fMean[pVehicleDetection->m_dlineCounter] / (float)nCols); pVehicleDetection->m_dlineCounter++; } TRACE("lineCounter-2 %d \n", pVehicleDetection->m_dlineCounter); #ifdef DEBUG_BORA FILE* fp; fopen_s(&fp, "C:\\Users\\bora\\Desktop\\sil\\meanStd.txt", "w"); #endif for (int k = 0; k < pVehicleDetection->m_dlineCounter - dAnalysisWindow; k++) { fMeanWindow = 0; for (int i = k; i < (dAnalysisWindow + k); i++) { fMeanWindow += fMean[i]; } fMeanWindow = fMeanWindow / (float)dAnalysisWindow; fStdWindow = 0; for (int i = k; i < (dAnalysisWindow + k); i++) { fStdWindow += ((fMeanWindow - fMean[i]) * (fMeanWindow - fMean[i])); } fStdWindow = fStdWindow / (float)dAnalysisWindow; fStdWindow = sqrtf(fStdWindow); if (bBegIdxFound == false) { fMeanMeanStart1 += fMeanWindow; fStdMeanStart1 += fStdWindow; dMeanStartCtr1++; } if (bBegIdxFound == true) { fMeanMeanStart2 += fMeanWindow; fStdMeanStart2 += fStdWindow; dMeanStartCtr2++; } if (bEndIdxFound == true) { fMeanMeanEnd2 += fMeanWindow; fStdMeanEnd2 += fStdWindow; dMeanEndCtr2++; } fStdWindowPrev3 = fStdWindowPrev2; fMeanWindowPrev3 = fMeanWindowPrev2; fStdWindowPrev2 = fStdWindowPrev; fMeanWindowPrev2 = fMeanWindowPrev; fStdWindowPrev = fStdWindowCurr; fMeanWindowPrev = fMeanWindowCurr; fMeanWindowCurr = fMeanWindow; fStdWindowCurr = fStdWindow; fCoeffOfVar1 = fMeanWindowPrev / fStdWindowPrev; fCoeffOfVar2 = fMeanWindowCurr / fStdWindowCurr; // check if begin index is still valid if ((dMeanStartCtr2 < dThresholdStartControl) && (dMeanStartCtr2 > 4)) { //TRACE("\nChecking BEGIN for Index %d MeanCurr %f MeanBegin %f CurrentCV %f PrevCV %f CurrentStd %f PrevStd %f CntrlValue %d \n", // k, fMeanWindowCurr, fMeanMeanStart1, fCoeffOfVar2, fCoeffOfVar1, fStdWindowCurr, fStdWindowPrev, dMeanStartCtr2); { if (fStdWindowCurr < 0.1) { dStdSpikeCounterStart++; } else { dStdSpikeCounterStart = 0; } if (fStdWindowCurr == 0.0) { dStartZeroStdCntr++; //TRACE("\n\n\nSTART ZERO STD %d \n\n\n", dStartZeroStdCntr); } if ((fCoeffOfVar2 > 3000) || (fStdWindowCurr < 0.1)) { if ( ( (fStdWindowCurr > (1.0 - dMagicMultiplier) * fStdMeanStart1) && (fStdWindowCurr < (1.0 + dMagicMultiplier) * fStdMeanStart1) && (fStdWindowPrev >(1.0 - dMagicMultiplier) * fStdMeanStart1) && (fStdWindowPrev < (1.0 + dMagicMultiplier) * fStdMeanStart1) && (fStdWindowPrev2 >(1.0 - dMagicMultiplier) * fStdMeanStart1) && (fStdWindowPrev2 < (1.0 + dMagicMultiplier) * fStdMeanStart1) && (fStdWindowPrev3 >(1.0 - dMagicMultiplier) * fStdMeanStart1) && (fStdWindowPrev3 < (1.0 + dMagicMultiplier) * fStdMeanStart1) ) || (dStdSpikeCounterStart > dSpikeCtrTresholdStart) || (dStartZeroStdCntr >= dStartZeroStdThreshold) ) { if ((fCoeffOfVar1 > 2000) || (dStartZeroStdCntr >= dStartZeroStdThreshold)) { bBegIdxFound = FALSE; g_dBeginIndex = 0; fMeanMeanStart1 = fMeanMeanStart2; fStdMeanStart1 = fStdMeanStart2; dMeanStartCtr1 = dMeanStartCtr2; if (fStartMean != 0.0) { fMeanMeanStart1 += fStartMean; fMeanMeanStart1 /= 2.0; fStartMean = 0.0; fStdMeanStart1 += fStartStd; fStdMeanStart1 /= 2.0; fStartStd = 0.0; } fMeanMeanStart2 = 0.0; fStdMeanStart2 = 0.0; dMeanStartCtr2 = 0; dStartZeroStdCntr = 0; dStartCancelCounter++; TRACE("\nCancelling Start.... for %d time(s) \n", dStartCancelCounter); } } } } if ((fMeanWindowCurr > fMeanMeanStart1*(1.0 - dMagicMultiplier2)) && (dStdSpikeCounterStart == 0)) { dThresholdStartControl = 100; } if ((fMeanWindowCurr > fMeanMeanStart1*(1.0 - dMagicMultiplier3)) && (dStdSpikeCounterStart == 0)) { dThresholdStartControl = 20; } } if ((dMeanStartCtr2 > dThresholdStartControl) && (bBegIdxFound == true)) { bStartPassedTest = true; } /// end of begin index control /// check if end is still valid if ((dMeanEndCtr2 < dThresholdEndControl) && (dMeanEndCtr2 > 4)) { //TRACE("\nChecking end for Index %d MeanCurr %f MeanBegin %f CurrentCV %f PrevCV %f CurrentStd %f PrevStd %f CntrlValue %d THreshold %d \n", // k, fMeanWindowCurr, fMeanMeanStart1, fCoeffOfVar2, fCoeffOfVar1, fStdWindowCurr, fStdWindowPrev, dMeanEndCtr2, dThresholdEndControl); if ((fStdWindowCurr > fStdMeanStart1*1.3) && (fStdWindowCurr > 0.1)) { dStdSpikeCounterEnd++; //TRACE("\n!!!!!!!Checking end for Index %d fStdMeanStart1 %f fStdMeanEnd2 %f Counter %d CntrlValue %d \n", // k, fStdMeanStart1, fStdWindowCurr, dStdSpikeCounterEnd, dMeanEndCtr2); } if (fStdWindowCurr < 0.05) { dSmallStdCounterEnd++; } if (dSmallStdCounterEnd >= dSmallStdCounterTresholdEnd) { if (dThresholdEndControl > 20) { dThresholdEndControl = 20; dSmallStdCounterEnd = 0; dMeanEndCtr2 = 0;; } } fCVEnd = fMeanMeanEnd2 / fStdMeanEnd2; //TRACE("\nEND CV %f\n", fCVEnd); if (fCVEnd > (float) 1500.0) { dCVEndCounter++; } if (dCVEndCounter > dCVEndCounterThreshold) { if (dThresholdEndControl > 20) { dThresholdEndControl = 20; //TRACE("\n\n\nEND BIG CV Counter %d \n\n\n", dCVEndCounter); dCVEndCounter = 0; dMeanEndCtr2 = 0;; } } if (fMeanWindowCurr < fMeanMeanStart1*(1.0 - dMagicMultiplier1)) { dThresholdEndControl++; if ( (fCoeffOfVar2 > 4000) || (fStdWindowCurr > 0.2) ) { bEndIdxFound = false; g_dEndIndex = 0; fMeanMeanEnd1 = fMeanMeanEnd2; fStdMeanEnd1 = fStdMeanEnd2; dMeanEndCtr1 = dMeanEndCtr2; if (fEndMean != 0.0) { fMeanMeanEnd1 += fEndMean; fMeanMeanEnd1 /= 2.0; fEndMean = 0.0; fStdMeanEnd1 += fEndStd; fStdMeanEnd1 /= 2.0; fEndStd = 0.0; } fMeanMeanEnd2 = 0.0; fStdMeanEnd2 = 0.0; dMeanEndCtr2 = 0; dThresholdEndControl = 200; dEndCancelCounter++; dStdSpikeCounterEnd = 0; dSmallStdCounterEnd = 0; dCVEndCounter = 0; g_dCarDetectCount--; TRACE("\nCancelling 1st End.... for %d time(s) for index %d \n", dEndCancelCounter, k); } } else if (dStdSpikeCounterEnd > dSpikeCtrTresholdEnd) { bEndIdxFound = false; g_dEndIndex = 0; fMeanMeanEnd1 = fMeanMeanEnd2; fStdMeanEnd1 = fStdMeanEnd2; dMeanEndCtr1 = dMeanEndCtr2; if (fEndMean != 0.0) { fMeanMeanEnd1 += fEndMean; fMeanMeanEnd1 /= 2.0; fEndMean = 0.0; fStdMeanEnd1 += fEndStd; fStdMeanEnd1 /= 2.0; fEndStd = 0.0; } fMeanMeanEnd2 = 0.0; fStdMeanEnd2 = 0.0; dMeanEndCtr2 = 0; dThresholdEndControl = 200; dEndCancelCounter++; dStdSpikeCounterEnd = 0; dSmallStdCounterEnd = 0; dCVEndCounter = 0; g_dCarDetectCount--; TRACE("\nCancelling 2nd End.... for %d time(s) for index %d \n", dEndCancelCounter, k); } /// end of END index cancelling if ((fMeanWindowCurr > fMeanMeanStart1*(1.0 - dMagicMultiplier2)) && (dStdSpikeCounterEnd == 0)) { dThresholdEndControl = 100; } if ((fMeanWindowCurr > fMeanMeanStart1*(1.0 - dMagicMultiplier3)) && (dStdSpikeCounterEnd == 0)) { dThresholdEndControl = 20; } } if ((dMeanEndCtr2 > dThresholdEndControl) && (bEndIdxFound == true)) { bEndPassedTest = true; } #ifdef DEBUG_BORA fprintf_s(fp, "%lf %lf %lf %lf \n", fMeanWindow, fStdWindow, fCoeffOfVar1, fCoeffOfVar2); #endif ////////////////////// if ( ( (bBegIdxFound == false) && (fStdWindowCurr > 1.0) && // 2,5 (fStdWindowPrev > 1.0) && // 1,0 (fStdWindowPrev2 > 1.0) && // 0,5 (fStdWindowPrev3 > 1.0) && // 0,5 (k > 300) && (fCoeffOfVar1 < 500.0) && (fCoeffOfVar2 > 10.0) ) ) { bBegIdxFound = true; g_dBeginIndex = k; fMeanMeanStart1 /= dMeanStartCtr1; fStdMeanStart1 /= dMeanStartCtr1; fStartMean = fMeanMeanStart1; fStartStd = fStdMeanStart1; TRACE("\n Found Start at %d ", g_dBeginIndex); } if ( ( (bEndIdxFound == false) && (bBegIdxFound == true) && (fStdWindowCurr < 0.5) && (fStdWindowPrev < 0.5) && (fStdWindowPrev2 < 0.5) && (fStdWindowPrev3 < 0.5) && (k - g_dBeginIndex > 2000) && (fCoeffOfVar1 > 4000.0) ) || ( (bEndIdxFound == false) && (bBegIdxFound == true) && (fStdWindowCurr < 0.1) && (fStdWindowPrev < 0.1) && (fStdWindowPrev2 < 0.1) && (fStdWindowPrev3 < 0.1) && (k - g_dBeginIndex > 2000) ) ) { bEndIdxFound = true; g_dEndIndex = k; g_dCarDetectCount++; fMeanMeanEnd1 = fMeanMeanStart2; fStdMeanEnd1 = fStdMeanStart2; dMeanEndCtr1 = dMeanStartCtr2; fMeanMeanEnd1 /= dMeanEndCtr1; fStdMeanEnd1 /= dMeanEndCtr1; fEndMean = fMeanMeanEnd1; fEndStd = fStdMeanEnd1; TRACE("\n Found End at %d ", g_dEndIndex); } } //// end of MAIN loop #ifdef DEBUG_BORA fclose(fp); #endif TRACE("\n bStartPassedTest %d bEndPassedTest %d \n", bStartPassedTest, bEndPassedTest); if ( (bBegIdxFound == true) && (bEndIdxFound == true) && (g_dCarDetectCount == 1) && (bStartPassedTest == true) && (bEndPassedTest == true) && (g_AutoDetect_Type != NO_AUTO_VEHICLE_DETECT) ) { bIsCarFound = true; g_CarFound = TRUE; TRACE("\n\n\nSTART %d END %d\n\n\n", g_dBeginIndex, g_dEndIndex); if (pVehicleDetection->m_isStopSignalled == false) { pVehicleDetection->m_isStopSignalled = true; TRACE("Signal STOPPPPPPPPPPPPPPPP\n"); SetEvent(g_CameraStopDataRecieveEvent); } } if (g_AutoDetect_Type == NO_AUTO_VEHICLE_DETECT) { //if ((bBegIdxFound == false) || (bEndIdxFound == false)) //{ g_CarFound = FALSE; g_dBeginIndex = 0; g_dEndIndex = pVehicleDetection->m_dlineCounter - dAnalysisWindow; pVehicleDetection->m_isStopSignalled = true; //SetEvent(g_CameraStopDataRecieveEvent); pView->SendMessage(WM_VEHICLEDETECT_FINISHED, 0, pLparam); //} } TRACE("FRM_CNT %d PRS_CNT %d \n", pVehicleDetection->m_dFrameCounter, pVehicleDetection->m_dProcessedFrameCounter); pVehicleDetection->m_dProcessedFrameCounter++; if ( (bIsCarFound == true) || (pVehicleDetection->m_dFrameCounter - pVehicleDetection->m_dProcessedFrameCounter == 0) ) { bIsProcessingFinished = true; ResetEvent(pVehicleDetection->ProcessDataEvent); SetEvent(pVehicleDetection->ProcessingFinishedEvent); } } } } // infite for loop delete[] fMean; if (inClr.rows != 0 || inClr.cols != 0) { inClr.release(); } if (inGray.rows != 0 || inGray.cols != 0) { inGray.release(); } return THREADEXIT_SUCCESS; }
[ "bora.nakiboglu@gmail.com" ]
bora.nakiboglu@gmail.com
31816679ddee50a2d054e948435f6b69fe482f6d
1cb5c9ec254e214cee277b11617ed84bc3ed824f
/runtime/runtime_test.h
8c60a6e858a6ca8fdc40eb80e99b2918fcd3d7e4
[ "BSD-3-Clause" ]
permissive
greatpie/engine
e09675cc16f4b3208e16410f13938ed9553ca51a
0b6627739dbe4329075383b0615a60cfb9f36329
refs/heads/master
2020-05-01T09:41:15.233380
2019-04-25T19:29:47
2019-04-25T19:29:47
177,405,812
2
0
BSD-3-Clause
2019-04-25T19:29:48
2019-03-24T11:31:58
C++
UTF-8
C++
false
false
1,040
h
// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef FLUTTER_RUNTIME_RUNTIME_TEST_H_ #define FLUTTER_RUNTIME_RUNTIME_TEST_H_ #include <memory> #include "flutter/common/settings.h" #include "flutter/fml/macros.h" #include "flutter/testing/test_dart_native_resolver.h" #include "flutter/testing/thread_test.h" namespace flutter { namespace testing { class RuntimeTest : public ThreadTest { public: RuntimeTest(); ~RuntimeTest(); Settings CreateSettingsForFixture(); void AddNativeCallback(std::string name, Dart_NativeFunction callback); protected: // |testing::ThreadTest| void SetUp() override; // |testing::ThreadTest| void TearDown() override; private: fml::UniqueFD assets_dir_; std::shared_ptr<TestDartNativeResolver> native_resolver_; void SetSnapshotsAndAssets(Settings& settings); }; } // namespace testing } // namespace flutter #endif // FLUTTER_RUNTIME_RUNTIME_TEST_H_
[ "noreply@github.com" ]
greatpie.noreply@github.com
ce87e3b0935f56d21ef42ff18e1cf8f5d79ce06a
af12357c008084301d9c51d807261c8dbd185118
/task.h
42d2f292a8fd819cc46e291c61e5ec30c238aa0c
[]
no_license
rlmv/pyphi-condor
3761fe2f82e9c5cb4c4cd9b25653147fbada6e4b
118a6f27ef39e394f0a06752247f12df39617b12
refs/heads/master
2021-08-08T14:21:08.635430
2017-11-10T14:01:38
2017-11-10T14:01:38
109,983,750
0
0
null
null
null
null
UTF-8
C++
false
false
1,816
h
/***************************Copyright-DO-NOT-REMOVE-THIS-LINE** * * Condor Software Copyright Notice * Copyright (C) 1990-2004, Condor Team, Computer Sciences Department, * University of Wisconsin-Madison, WI. * * This source code is covered by the Condor Public License, which can * be found in the accompanying LICENSE.TXT file, or online at * www.condorproject.org. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * AND THE UNIVERSITY OF WISCONSIN-MADISON "AS IS" AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY, OF SATISFACTORY QUALITY, AND FITNESS * FOR A PARTICULAR PURPOSE OR USE ARE DISCLAIMED. THE COPYRIGHT * HOLDERS AND CONTRIBUTORS AND THE UNIVERSITY OF WISCONSIN-MADISON * MAKE NO MAKE NO REPRESENTATION THAT THE SOFTWARE, MODIFICATIONS, * ENHANCEMENTS OR DERIVATIVE WORKS THEREOF, WILL NOT INFRINGE ANY * PATENT, COPYRIGHT, TRADEMARK, TRADE SECRET OR OTHER PROPRIETARY * RIGHT. * ****************************Copyright-DO-NOT-REMOVE-THIS-LINE**/ #ifndef _TASK_H #define _TASK_H #include <Python.h> #include <stdio.h> #include "MWTask.h" #include <string> class Task : public MWTask { public: /* constructors */ Task(); Task(PyObject* input); /* destructor */ ~Task(); /* App is required to implement the following functions. */ void pack_work( void ); void unpack_work( void ); void pack_results( void ); void unpack_results( void ); void pack_PyObject(PyObject* obj ); PyObject* unpack_PyObject( void ); /* The following functions have default implementation. */ void printself( int level = 70 ); void write_ckpt_info( FILE *fp ); void read_ckpt_info( FILE *fp ); PyObject *input; PyObject *result; }; #endif
[ "bo.marchman@gmail.com" ]
bo.marchman@gmail.com
18c645645574044c9714734b02dbf57afb595eff
205184ba19f51b010e0dcd4a1d95be928a4b5fa4
/variadic_template.cpp
2c2da5ebc34309ecb93e7c671bd7a07626298a41
[]
no_license
sqzhr/DemoC-11
fa77aed420da210be26d3cd7f08a9378b8223fcd
492df0d0feafe8c46f1af5d331772321d55e99f9
refs/heads/master
2020-03-21T16:18:40.254683
2018-08-31T11:23:00
2018-08-31T11:23:00
138,763,010
0
0
null
null
null
null
UTF-8
C++
false
false
232
cpp
template<class ... Types> void f(Types ... args) {} int main() { f(); // OK: args contains no arguments f(1); // OK: args contains one argument: int f(2, 1.0); // OK: args contains two arguments: int and double }
[ "kostenko.yulia@apriorit.com" ]
kostenko.yulia@apriorit.com
933685e4725eef79f5ea7ce43065dee6e7e7a521
f0535b751d55637ea5c3711e9dcda5938bea3ea4
/trunk/NUIFrameworks/src/modules/moSmoothModule.cpp
015af847b6a5a870a14c3476fa6d4d91114d8631
[]
no_license
nuigroup/ccv-wxwidgets
f5ebb2d1e8817a7ad1216065e70ae98faf0f2c42
b9b7fbb315ba3a622440dd5eb6c82223eb8c8cb3
refs/heads/master
2021-01-15T23:11:56.564887
2014-10-18T03:09:43
2014-10-18T03:09:43
8,324,881
2
1
null
null
null
null
UTF-8
C++
false
false
1,867
cpp
/*********************************************************************** ** Copyright (C) 2010 Movid Authors. All rights reserved. ** ** This file is part of the Movid Software. ** ** This file may be distributed under the terms of the Q Public License ** as defined by Trolltech AS of Norway and appearing in the file ** LICENSE included in the packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** Contact info@movid.org if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include <assert.h> #include "moSmoothModule.h" #include "../moLog.h" #include "cv.h" MODULE_DECLARE(Smooth, "native", "Smooth an image with one of several filters"); moSmoothModule::moSmoothModule() : moImageFilterModule8() { MODULE_INIT(); // declare properties this->properties["size"] = new moProperty(1); this->properties["size"]->setMin(1); this->properties["size"]->setMax(6); this->properties["filter"] = new moProperty("median"); this->properties["filter"]->setChoices("median;gaussian;blur;blur_no_scale"); } moSmoothModule::~moSmoothModule() { } int moSmoothModule::toCvType(const std::string &filter) { if ( filter == "median" ) return CV_MEDIAN; if ( filter == "gaussian" ) return CV_GAUSSIAN; if ( filter == "blur" ) return CV_BLUR; if ( filter == "blur_no_scale" ) return CV_BLUR_NO_SCALE; LOGM(MO_ERROR, "Unsupported filter type: " << filter); this->setError("Unsupported filter type"); return 0; } void moSmoothModule::applyFilter(IplImage *src) { cvSmooth( src, this->output_buffer, this->toCvType(this->property("filter").asString()), this->property("size").asInteger()*2+1 //make sure its odd ); }
[ "jimbo@6390893d-aae8-4ee2-985d-008520e8b1b1" ]
jimbo@6390893d-aae8-4ee2-985d-008520e8b1b1
079c1557294f1ea9fc7dcf1476d2cde74ecab45f
a67e07f2dcc5784e128a12296c1245ca02a40f3e
/XHelper/TaskHandle.h
5d1c35e38de6b9c7d4e0d63baf2ade262f644a8e
[]
no_license
z379115475/MobileAssistant
ed1d0d2e346fef63a454a415f33a9c6b454d6979
06173ce440a5db1f43ae8a8b7c974fd6ce056ba8
refs/heads/main
2022-12-26T20:28:23.918067
2020-10-13T09:49:46
2020-10-13T09:49:46
303,656,521
0
0
null
null
null
null
GB18030
C++
false
false
563
h
#pragma once class ITaskHandle; struct CTask { UINT uStatus; // 任务状态 HWND hNtfWnd; // 任务完成时,接收消息的窗口 UINT uNtfMsg; // 消息id sciter::value param; // 请求参数 sciter::value ret; // 返回结果 ITaskHandle* pHost; // 任务处理者 CTask() { uStatus = 0; pHost = NULL; } }; class ITaskHandle { public: ITaskHandle* m_pNext; ITaskHandle() { m_pNext = NULL; } virtual ~ITaskHandle() {} virtual BOOL Init() = 0; virtual BOOL ProcessTask(CTask*) = 0; virtual BOOL CancelTask(CTask*) = 0; };
[ "379115475@qq.com" ]
379115475@qq.com
40b333a656014043647edf7967ddde7324c77350
afcbc80611093736bb66be087544ef950f7c9ccf
/Plankton.h
4ac5973669323fd83eb56c374a6a62c8ed094993
[]
no_license
Zercon/Aquarium
6dcacbad50c0aa76616361418bfce5dbf0516b05
757d227062fbe50f2c7fae3ab1d735ed077e2ad7
refs/heads/master
2020-05-09T22:43:12.579456
2019-04-15T12:42:34
2019-04-15T12:42:34
181,480,114
0
0
null
null
null
null
UTF-8
C++
false
false
263
h
#pragma once #include "Obj.h" class Plankton: public Obj { public: double timeSegmentation; double countdownTimeSegmentation; public: Plankton(double lifetime, double timeSegmentation); void incrementTime(double deltaTime); ~Plankton(); };
[ "noreply@github.com" ]
Zercon.noreply@github.com
c1c3c3c99e9ddbc7309bc9068159ad559cd4b856
2155050f3f2d19b657fb56bf1a251977d3bd3477
/lab_4_csv_parser/Exception.cpp
b0e1f112fa9a76d16f6f7e7e8d3363b4396a5df3
[]
no_license
shadrina/learning-cpp
4b102f9b1178a40d8f5689a8f129a9487c6b40f3
6d3966be227fc36347ade3064f889b85b9fcc17b
refs/heads/master
2021-09-04T12:25:46.296474
2018-01-18T17:04:35
2018-01-18T17:04:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
33
cpp
#include "Exception.h" // later
[ "a.shadrina5@mail.ru" ]
a.shadrina5@mail.ru
921e1d0dbf72b934b9e8ef76eae69221bb01f9c3
0266e454d5b3d15ae819a7f95dc76a403f207b96
/roswrap/src/rossimu/kinetic/include/geometry_msgs/PoseStamped.h
f29cdc3e62cad1482b055c07bdd352c084c528d8
[ "Apache-2.0" ]
permissive
SICKAG/sick_scan_base
af7ae85279c03f2bc9685c49872ff4787a210b64
73d37605e1914fd1da8d45050ba37f449a660fd7
refs/heads/master
2022-10-13T11:51:02.203508
2022-09-05T10:27:11
2022-09-05T10:27:11
196,956,176
22
20
Apache-2.0
2021-02-08T23:26:44
2019-07-15T08:22:39
C++
UTF-8
C++
false
false
7,110
h
// Generated by gencpp from file geometry_msgs/PoseStamped.msg // DO NOT EDIT! #ifndef GEOMETRY_MSGS_MESSAGE_POSESTAMPED_H #define GEOMETRY_MSGS_MESSAGE_POSESTAMPED_H #include <string> #include <vector> #include <map> #include <ros/types.h> #include <ros/serialization.h> #include <ros/builtin_message_traits.h> #include <ros/message_operations.h> #include <std_msgs/Header.h> #include <geometry_msgs/Pose.h> namespace geometry_msgs { template <class ContainerAllocator> struct PoseStamped_ { typedef PoseStamped_<ContainerAllocator> Type; PoseStamped_() : header() , pose() { } PoseStamped_(const ContainerAllocator& _alloc) : header(_alloc) , pose(_alloc) { (void)_alloc; } typedef ::std_msgs::Header_<ContainerAllocator> _header_type; _header_type header; typedef ::geometry_msgs::Pose_<ContainerAllocator> _pose_type; _pose_type pose; typedef boost::shared_ptr< ::geometry_msgs::PoseStamped_<ContainerAllocator> > Ptr; typedef boost::shared_ptr< ::geometry_msgs::PoseStamped_<ContainerAllocator> const> ConstPtr; }; // struct PoseStamped_ typedef ::geometry_msgs::PoseStamped_<std::allocator<void> > PoseStamped; typedef boost::shared_ptr< ::geometry_msgs::PoseStamped > PoseStampedPtr; typedef boost::shared_ptr< ::geometry_msgs::PoseStamped const> PoseStampedConstPtr; // constants requiring out of line definition template<typename ContainerAllocator> std::ostream& operator<<(std::ostream& s, const ::geometry_msgs::PoseStamped_<ContainerAllocator> & v) { ros::message_operations::Printer< ::geometry_msgs::PoseStamped_<ContainerAllocator> >::stream(s, "", v); return s; } } // namespace geometry_msgs namespace ros { namespace message_traits { // BOOLTRAITS {'IsFixedSize': False, 'IsMessage': True, 'HasHeader': True} // {'std_msgs': ['/opt/ros/kinetic/share/std_msgs/cmake/../msg'], 'geometry_msgs': ['/tmp/binarydeb/ros-kinetic-geometry-msgs-1.12.5/msg']} // !!!!!!!!!!! ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_parsed_fields', 'constants', 'fields', 'full_name', 'has_header', 'header_present', 'names', 'package', 'parsed_fields', 'short_name', 'text', 'types'] template <class ContainerAllocator> struct IsFixedSize< ::geometry_msgs::PoseStamped_<ContainerAllocator> > : FalseType { }; template <class ContainerAllocator> struct IsFixedSize< ::geometry_msgs::PoseStamped_<ContainerAllocator> const> : FalseType { }; template <class ContainerAllocator> struct IsMessage< ::geometry_msgs::PoseStamped_<ContainerAllocator> > : TrueType { }; template <class ContainerAllocator> struct IsMessage< ::geometry_msgs::PoseStamped_<ContainerAllocator> const> : TrueType { }; template <class ContainerAllocator> struct HasHeader< ::geometry_msgs::PoseStamped_<ContainerAllocator> > : TrueType { }; template <class ContainerAllocator> struct HasHeader< ::geometry_msgs::PoseStamped_<ContainerAllocator> const> : TrueType { }; template<class ContainerAllocator> struct MD5Sum< ::geometry_msgs::PoseStamped_<ContainerAllocator> > { static const char* value() { return "d3812c3cbc69362b77dc0b19b345f8f5"; } static const char* value(const ::geometry_msgs::PoseStamped_<ContainerAllocator>&) { return value(); } static const uint64_t static_value1 = 0xd3812c3cbc69362bULL; static const uint64_t static_value2 = 0x77dc0b19b345f8f5ULL; }; template<class ContainerAllocator> struct DataType< ::geometry_msgs::PoseStamped_<ContainerAllocator> > { static const char* value() { return "geometry_msgs/PoseStamped"; } static const char* value(const ::geometry_msgs::PoseStamped_<ContainerAllocator>&) { return value(); } }; template<class ContainerAllocator> struct Definition< ::geometry_msgs::PoseStamped_<ContainerAllocator> > { static const char* value() { return "# A Pose with reference coordinate frame and timestamp\n\ Header header\n\ Pose pose\n\ \n\ ================================================================================\n\ MSG: std_msgs/Header\n\ # Standard metadata for higher-level stamped data types.\n\ # This is generally used to communicate timestamped data \n\ # in a particular coordinate frame.\n\ # \n\ # sequence ID: consecutively increasing ID \n\ uint32 seq\n\ #Two-integer timestamp that is expressed as:\n\ # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\ # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\ # time-handling sugar is provided by the client library\n\ time stamp\n\ #Frame this data is associated with\n\ # 0: no frame\n\ # 1: global frame\n\ string frame_id\n\ \n\ ================================================================================\n\ MSG: geometry_msgs/Pose\n\ # A representation of pose in free space, composed of position and orientation. \n\ Point position\n\ Quaternion orientation\n\ \n\ ================================================================================\n\ MSG: geometry_msgs/Point\n\ # This contains the position of a point in free space\n\ float64 x\n\ float64 y\n\ float64 z\n\ \n\ ================================================================================\n\ MSG: geometry_msgs/Quaternion\n\ # This represents an orientation in free space in quaternion form.\n\ \n\ float64 x\n\ float64 y\n\ float64 z\n\ float64 w\n\ "; } static const char* value(const ::geometry_msgs::PoseStamped_<ContainerAllocator>&) { return value(); } }; } // namespace message_traits } // namespace ros namespace ros { namespace serialization { template<class ContainerAllocator> struct Serializer< ::geometry_msgs::PoseStamped_<ContainerAllocator> > { template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m) { stream.next(m.header); stream.next(m.pose); } ROS_DECLARE_ALLINONE_SERIALIZER }; // struct PoseStamped_ } // namespace serialization } // namespace ros namespace ros { namespace message_operations { template<class ContainerAllocator> struct Printer< ::geometry_msgs::PoseStamped_<ContainerAllocator> > { template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::geometry_msgs::PoseStamped_<ContainerAllocator>& v) { s << indent << "header: "; s << std::endl; Printer< ::std_msgs::Header_<ContainerAllocator> >::stream(s, indent + " ", v.header); s << indent << "pose: "; s << std::endl; Printer< ::geometry_msgs::Pose_<ContainerAllocator> >::stream(s, indent + " ", v.pose); } }; } // namespace message_operations } // namespace ros #endif // GEOMETRY_MSGS_MESSAGE_POSESTAMPED_H
[ "michael.lehning@lehning.de" ]
michael.lehning@lehning.de
14a60e57bb6da46ffc452dec2e896ef1d87af9a5
6c57043f3879c5cd49265cb21a8cb23ec74f6364
/RenderEdit/src/EditorLayer.h
5b0e307bb1d6cc46b78ad402fbeb5629e643b301
[ "Apache-2.0" ]
permissive
dannymato/Renderent
5bc4d73937bd61d57168226e9da5929fd691dbf6
7ad60e4eaa356a521bdf3fe89b53f06c74b06b17
refs/heads/master
2022-11-20T22:58:45.100717
2020-07-22T20:52:28
2020-07-22T20:52:28
275,656,952
0
0
null
null
null
null
UTF-8
C++
false
false
845
h
#pragma once #include <Renderent.h> #include <glm/glm.hpp> namespace Renderent { class EditorLayer : public Layer { public: EditorLayer(); virtual ~EditorLayer() = default; virtual void OnAttach() override; virtual void OnDetach() override; virtual void OnUpdate(Timestep ts) override; virtual void OnImGuiRender() override; virtual void OnEvent(Event& e) override; private: Ref<VertexArray> m_SquareVA; OrthographicCameraController m_CameraController; Ref<Shader> m_FlatColorShader; glm::vec4 m_SquareColor = { 1.0f, 1.0f, 1.0f, 1.0f }; Ref<Texture2D> m_Checkerboard; Ref<Texture2D> m_Spritesheet; Ref<SubTexture2D> m_TextureStairs, m_TextureBarrel, m_TextureTree, m_TextureGround; Ref<Framebuffer> m_Framebuffer; glm::vec2 m_ViewportSize = { 0.0f, 0.0f }; float m_CurrentTime = 0.0f; }; }
[ "danny.mato1@gmail.com" ]
danny.mato1@gmail.com
f0a6aaa2b4f04d582c0563618f3b40e633eff226
804a1a6b44fe3a013352d04eaf47ea6ad89f9522
/dbms/src/Parsers/ParserShowCreateAccessEntityQuery.cpp
0caba5e0495f56fb1260307050ab099035b2edb3
[ "Apache-2.0" ]
permissive
kssenii/ClickHouse
680f533c3372094b92f407d49fe14692dde0b33b
7c300d098d409772bdfb26f25c7d0fe750adf69f
refs/heads/master
2023-08-05T03:42:09.498378
2020-02-13T17:49:51
2020-02-13T17:49:51
232,254,869
10
3
Apache-2.0
2021-06-15T11:34:08
2020-01-07T06:07:06
C++
UTF-8
C++
false
false
2,022
cpp
#include <Parsers/ParserShowCreateAccessEntityQuery.h> #include <Parsers/ASTShowCreateAccessEntityQuery.h> #include <Parsers/CommonParsers.h> #include <Parsers/parseIdentifierOrStringLiteral.h> #include <Parsers/parseDatabaseAndTableName.h> #include <assert.h> namespace DB { bool ParserShowCreateAccessEntityQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected) { if (!ParserKeyword{"SHOW CREATE"}.ignore(pos, expected)) return false; using Kind = ASTShowCreateAccessEntityQuery::Kind; Kind kind; if (ParserKeyword{"QUOTA"}.ignore(pos, expected)) kind = Kind::QUOTA; else if (ParserKeyword{"POLICY"}.ignore(pos, expected) || ParserKeyword{"ROW POLICY"}.ignore(pos, expected)) kind = Kind::ROW_POLICY; else return false; String name; bool current_quota = false; RowPolicy::FullNameParts row_policy_name; if (kind == Kind::ROW_POLICY) { String & database = row_policy_name.database; String & table_name = row_policy_name.table_name; String & policy_name = row_policy_name.policy_name; if (!parseIdentifierOrStringLiteral(pos, expected, policy_name) || !ParserKeyword{"ON"}.ignore(pos, expected) || !parseDatabaseAndTableName(pos, expected, database, table_name)) return false; } else { assert(kind == Kind::QUOTA); if (ParserKeyword{"CURRENT"}.ignore(pos, expected)) { /// SHOW CREATE QUOTA CURRENT current_quota = true; } else if (parseIdentifierOrStringLiteral(pos, expected, name)) { /// SHOW CREATE QUOTA name } else { /// SHOW CREATE QUOTA current_quota = true; } } auto query = std::make_shared<ASTShowCreateAccessEntityQuery>(kind); node = query; query->name = std::move(name); query->current_quota = current_quota; query->row_policy_name = std::move(row_policy_name); return true; } }
[ "vitbar@yandex-team.ru" ]
vitbar@yandex-team.ru
e34f2e7e23d3030cb1bb83fd5349970d563735eb
a281b1077b3c4d0722f00313ba8fab49859a2599
/timer/timer_queue.cpp
0fc18faa1ed6faec1723f99a921e9668ffd8a536
[]
no_license
weijingtao/snow_ev
e3b2ac8f4017b35718760efe6ca413efa4615217
dcfb0e45944d6a403bb544f7329587c361229d25
refs/heads/master
2020-04-02T13:46:04.862417
2016-11-19T14:48:37
2016-11-19T14:48:37
62,480,306
1
0
null
null
null
null
UTF-8
C++
false
false
2,941
cpp
// // Created by weitao on 7/9/16. // // // Created by weitao on 4/1/16. // #include "timer_queue.h" #include <cstring> #include "../logger/logger.h" namespace snow { timer_queue::timer_queue(poller* poller) : m_timer_fd(poller) { SNOW_LOG_DEBUG; m_timer_fd.init(); m_timer_fd.set_timeout_cb(std::bind(&timer_queue::handle_timeout, this)); } timer_queue::timer_id timer_queue::add_timer(const entry& timer) { bool earliestChanged = false; auto when = timer.get().expiration(); auto it = m_timers.cbegin(); if (it == m_timers.cend() || when < it->get().expiration()) { earliestChanged = true; } auto result = m_timers.insert(timer); assert(result.second); if(earliestChanged) { m_timer_fd.reset(m_timers.cbegin()->get().expiration()); } return result.first; } void timer_queue::cancel(timer_id& id) { if(id == m_timers.begin()) { m_timers.erase(id); if(!m_timers.empty()) m_timer_fd.reset(m_timers.cbegin()->get().expiration()); // else // m_timer_fd.reset(); } else { m_timers.erase(id); } } void timer_queue::handle_timeout() { auto now = std::chrono::steady_clock::now(); std::vector<entry> expired = get_expired(now); for (auto& timer : expired) { timer.get().run(); } reset(expired, now); } // move out all expired timers std::vector<timer_queue::entry> timer_queue::get_expired(const time_stamp& now) { std::vector<entry> expired; for(auto it = m_timers.begin(); it != m_timers.end();) { if(it->get().expiration() <= now) { expired.push_back(*it); it = m_timers.erase(it); } break; } /*timer sentry; auto end = m_timers.lower_bound(std::ref(sentry)); std::copy(m_timers.begin(), end, std::back_inserter(expired)); m_timers.erase(m_timers.begin(), end);*/ return std::move(expired); } void timer_queue::reset(std::vector<entry>& expired, const time_stamp& now) { for (auto& timer : expired) { if(timer.get().repeat()) { timer.get().restart(now); insert(timer); } } if (!m_timers.empty()) { m_timer_fd.reset(m_timers.cbegin()->get().expiration()); } } bool timer_queue::insert(entry& timer) { bool earliestChanged = false; auto when = timer.get().expiration(); auto it = m_timers.cbegin(); if (it == m_timers.cend() || when < it->get().expiration()) { earliestChanged = true; } auto result = m_timers.insert(timer); assert(result.second); return earliestChanged; } }
[ "625171422@qq.com" ]
625171422@qq.com
a425ff659beb67d01c587d695c13505a65262ebb
8d35a575ee5c6cc249ba7656869c16890f7e2e9b
/panda_safety/src/SphereListVisualizer.cpp
1b25136c8ba8946f4daedd4d8ad1cff223bfc8b1
[ "MIT" ]
permissive
erdalpekel/panda_simulation
5db473077bfee588b90890cba058052dc9fb1d2b
70b6a9d7a426a9cc4dd3e41b2a61f817f1531f4b
refs/heads/master
2023-03-10T06:22:39.883074
2022-09-22T08:03:49
2022-09-22T08:03:49
165,692,071
143
59
MIT
2023-03-06T20:46:27
2019-01-14T16:14:01
JavaScript
UTF-8
C++
false
false
3,380
cpp
#include <panda_safety/SphereListVisualizer.h> namespace nodes { SphereListVisualizer::SphereListVisualizer(const ros::NodeHandle &node_handle, const ros::NodeHandle &private_node_handle, ros::Rate rate) : node_handle(node_handle), private_node_handle(private_node_handle), rate(rate) { this->init(); } void SphereListVisualizer::init() { if (!private_node_handle.getParam(constants::CAMERA_ID, camera_id)) { throw std::runtime_error( "Parameter \"camera\" was not set when starting script! Specify which camera you are starting!"); } service = node_handle.advertiseService(constants::service_endpoints::SPHERE_LIST_DISPLAY + camera_id, &SphereListVisualizer::sphereListDisplayCallback, this); ROS_INFO("Created service server"); marker_pub = node_handle.advertise<visualization_msgs::Marker>("visualization_marker_" + camera_id, 10); float f = 0.0f; while (ros::ok()) { if (!points_frame_id.empty()) { visualization_msgs::Marker points; // Set the frame ID and timestamp. See the TF tutorials for information on these. points.header.frame_id = points_frame_id; points.header.stamp = ros::Time::now(); // Set the namespace and id for this marker. This serves to create a unique ID // Any marker sent with the same namespace and id will overwrite the old one points.ns = "points_" + camera_id; points.id = 0; // Set the marker type. Initially this is CUBE, and cycles between that and SPHERE, ARROW, and CYLINDER points.type = visualization_msgs::Marker::SPHERE_LIST; // Set the marker action. Options are ADD, DELETE, and new in ROS Indigo: 3 (DELETEALL) points.action = visualization_msgs::Marker::ADD; // Set the pose of the marker. This is a full 6DOF pose relative to the frame/time specified in the header points.pose.position.x = 0; points.pose.position.y = 0; points.pose.position.z = 0; points.pose.orientation.x = 0.0; points.pose.orientation.y = 0.0; points.pose.orientation.z = 0.0; points.pose.orientation.w = 1.0; // Set the scale of the marker -- 1x1x1 here means 1m on a side points.scale.x = 0.004; points.scale.y = 0.004; points.scale.z = 0.004; // Set the color -- be sure to set alpha to something non-zero! points.color.g = 1.0f; points.color.a = 1.0; ROS_DEBUG_STREAM("collision objects size: " << sphere_list.size()); points.points = sphere_list; // Publish the marker marker_pub.publish(points); } rate.sleep(); ros::spinOnce(); } } bool SphereListVisualizer::sphereListDisplayCallback(panda_msgs::SphereListDisplayMsgRequest &req, panda_msgs::SphereListDisplayMsgResponse &res) { ROS_INFO("In service callback"); ROS_INFO_STREAM("Collision points size: " << req.sphere_list.size()); sphere_list = req.sphere_list; points_frame_id = req.frame_id; return true; } } // namespace nodes int main(int argc, char **argv) { ros::init(argc, argv, constants::nodes::COLLISION_VISUALIZER); ros::NodeHandle node_handle(""); ros::NodeHandle private_node_handle("~"); nodes::SphereListVisualizer node(node_handle, private_node_handle, 30); return 0; }
[ "info@erdalpekel.de" ]
info@erdalpekel.de
65d4fe0cf0e5ea55fc2d31a221012cf608420a1b
29c804bd89c0865e8f8b1f1a54be35131655171a
/src/ParticleSystem.cpp
0265301b01c1beb0bf4db1bd7bee618560db41a9
[ "MIT" ]
permissive
IcedLeon/Introduction-to-3D-with-OpenGL
2aa2d6e41a9b3ca3ee95de65cda88db6ffd7c787
7e0edcb768d2e2b4b19cb5015a73335c60cd8f60
refs/heads/master
2020-04-06T04:30:14.772510
2017-05-25T13:56:24
2017-05-25T13:56:24
30,327,236
0
0
null
null
null
null
UTF-8
C++
false
false
865
cpp
#include "ParticleSystem.h" #include "ParticleEmitter.h" #include "ParticleUpdater.h" ParticleSystem::ParticleSystem(size_t a_MaxCount) { m_Count = a_MaxCount; m_oParticles.Generate(a_MaxCount); m_oAliveParticles.Generate(a_MaxCount); for (size_t i = NULL; i < a_MaxCount; ++i) { m_oParticles.m_pbAlive[i] = false; } } void ParticleSystem::Update(double a_dDeltaTime) { for (auto& em : m_voEmitters) { em->Emit(a_dDeltaTime, &m_oParticles); } for (size_t i = 0; i < m_Count; ++i) { m_oParticles.m_pvAcceleration[i] = vec4(0.0f); } for (auto& updt : m_voUpdaters) { updt->Update(a_dDeltaTime, &m_oParticles); } } void ParticleSystem::Reset() { m_oParticles.m_AliveCounter = NULL; } size_t ParticleSystem::ComputeMemoryUsage(const ParticleSystem& a_roParticle) { return 2 * ParticleData::ComputeMemoryUsage(a_roParticle.m_oParticles); }
[ "tommaso.galatolo@gmail.com" ]
tommaso.galatolo@gmail.com
7467ffd8c7447fe453e8ce1d3b9b4518b0ddba2e
f1ccee2c7ab3d39151c82ee58076e4198e5ab99d
/c++/auto-type.cpp
557f9dcb8472770b7d5de0a92cd6b223056165fe
[]
no_license
sreeramjeeyar/learningSeries
f2d3ebc857cfaca40badb0389de82de83e6c3b69
34a9c1c8ac7979fa614bef96006affe0dcbfbbba
refs/heads/master
2020-05-19T21:23:06.357631
2019-08-27T01:07:51
2019-08-27T01:07:51
185,222,637
1
0
null
2019-05-06T15:59:45
2019-05-06T15:22:45
null
UTF-8
C++
false
false
217
cpp
#include <iostream> #include<typeinfo> using namespace std; string func(){ return "string"; } int main( int argc, char ** argv ) { auto x=func(); cout<<x<<endl; cout << typeid(x).name() << endl; return 0; }
[ "noreply@github.com" ]
sreeramjeeyar.noreply@github.com
5d1710122be69610de068c8a4fa6010ed8818316
1464838e7e0cbd75befa563ee6e0b7e93925d963
/1099 - Not the Best.cpp
6a27a826abbdbf983a2839266f90af69b35c682f
[]
no_license
amlan086/Light-Oj-Solve
b5f51eb21878a1a3f663a8fab56e8f702d5066ff
f2fe2dd9fc2112d540ac508097b8f41dcec1d649
refs/heads/master
2020-03-09T16:39:36.507861
2016-08-05T13:37:47
2016-08-05T13:37:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,890
cpp
//BISMILLAHIRRAHMANIRRAHIM /* manus tar shopner soman boro Author :: Shakil Ahmed .............AUST_CSE27......... prob :: Type :: verdict:: */ #include <bits/stdc++.h> #define pf(a) printf("%d\n",a) #define pf2(a,b) printf("%d %d\n",a,b) #define pfcs(cs,a) printf("Case %d: %d\n",cs,a) #define sc(a) scanf("%d",&a) #define sc2(a,b) scanf("%d %d",&a,&b) #define pb push_back #define mp make_pair #define pi acos(-1.0) #define ff first #define LL long long #define ss second #define rep(i,n) for(i = 0; i < n; i++) #define REP(i,n) for(i=n;i>=0;i--) #define FOR(i,a,b) for(int i = a; i <= b; i++) #define ROF(i,a,b) for(int i = a; i >= b; i--) #define re return #define QI queue<int> #define SI stack<int> #define pii pair <int,int> #define MAX #define MOD #define INF 1<<30 #define SZ(x) ((int) (x).size()) #define ALL(x) (x).begin(), (x).end() #define sqr(x) ((x) * (x)) #define memo(a,b) memset((a),(b),sizeof(a)) #define G() getchar() #define MAX3(a,b,c) max(a,max(b,c)) double const EPS=3e-8; using namespace std; const int N=5005; int dist[N][2],n,R,con[N]; vector<pii> adj[N]; void Clear() { int i; for(i=1;i<=n;i++) { adj[i].clear(); dist[i][0]=dist[i][1]=INF; } } void adjust(int x,int dis) { if(dis<dist[x][0]) { dist[x][1]=dist[x][0]; dist[x][0]=dis; } else if(dist[x][0]!=dis) dist[x][1]=dis; } int Dijkstra() { // memo(dist,N); //printf("here\n"); memo(con,0); int i,j; dist[1][0]=0; for(i=1;i<=2*n;i++) { int u,mx=INF; for(j=1;j<=n;j++) { if(con[j]<2 && dist[j][con[j]]<mx) { mx=dist[j][con[j]]; u=j; } } int idx=con[u]; con[u]++; if(con[n]==2) break; for(j=0;j<adj[u].size();j++) { int to=adj[u][j].first; if(con[to]<2 && dist[to][1]>dist[u][idx]+adj[u][j].second) { adjust(to,dist[u][idx]+adj[u][j].second); } } } return dist[n][1]; } int main() { int cs,t,i; scanf("%d",&t); for(cs=1;cs<=t;cs++) { scanf("%d %d",&n,&R); Clear(); for(i=1;i<=R;i++) { int u,v,c; scanf("%d %d %d",&u,&v,&c); adj[u].pb(mp(v,c)); adj[v].pb(mp(u,c)); } printf("Case %d: %d\n",cs,Dijkstra()); } return 0; }
[ "noreply@github.com" ]
amlan086.noreply@github.com
c8d746be25fd364a8d2a726b764dafa68c4aaecf
4e718d513ce9c5d57984e1f504678ae6615d94a6
/URI Judge/URI Judge/1155.cpp
7c98e0bfe7cb5d3aaa91482c090dd5869a68ebd5
[ "MIT" ]
permissive
AhmedNasser1601/ProblemSolving
91377968d4d93e8d5dc790ebe83c9e907db31a99
383b14221ca34d52257e53dc7a5f966790ca8678
refs/heads/master
2023-08-06T12:56:18.551695
2021-10-03T09:48:20
2021-10-03T09:48:20
393,166,609
0
0
null
null
null
null
UTF-8
C++
false
false
271
cpp
//#include <iostream> //#include <stdio.h> //#include <iomanip> //#include <string> // //using namespace std; // //int main() { // float x = 0; // // for (float i = 1; i <= 100; ++i) // x += 1 / i; // // cout << fixed << setprecision(2) << x << endl; // // return 0; //}
[ "60184582+AhmedNasser1601@users.noreply.github.com" ]
60184582+AhmedNasser1601@users.noreply.github.com
92bf16a8e0bd28950b1b8b2f8122b6f9d4914535
f8b1dfccaef5a8f75567b527fc7c2f0a34e3877b
/uestc/c96/pj.cpp
ee003f74038774c49ee5070aacfaa8e64817dd18
[]
no_license
bamboohiko/problemSolve
e7e2a2c6e46a4d10ccfa54cffff3c9895b3ddb1b
cd3e9e5986325f5def4efe01975a950f6eaa6015
refs/heads/master
2021-01-17T06:39:42.502176
2017-09-13T14:30:08
2017-09-13T14:30:08
47,928,189
0
0
null
null
null
null
UTF-8
C++
false
false
1,554
cpp
#include<iostream> #include<cstdio> #include<map> #include<set> #include<vector> #include<stack> #include<queue> #include<string> #include<cstring> #include<sstream> #include<algorithm> #include<cmath> #define INF 0x3f3f3f3f #define eps 1e-8 #define pi acos(-1.0) using namespace std; typedef long long LL; const int maxn = 2e6 + 100; int q[maxn],a[maxn],sum[maxn]; bool cmp(int a,int b,int c,int _a,int _b,int _c) { if (a != _a) return a > _a; if (b != _b) return b < _b; return c < _c; } int main() { int n,k; scanf("%d%d",&n,&k); int ans = -1001,x,y; for (int i = 1;i <= n; i++) { scanf("%d",&a[i]); a[n+i] = a[i]; if (a[i] > ans) {ans = a[i];x = y = i;} } int l = 1,r = 1;q[1] = 0; for (int i = 1;i <= n+n; i++) { sum[i] = sum[i-1] + a[i]; while (l <= r && i-q[l] > k) { if (q[r] > q[l] && cmp(sum[q[r]] - sum[q[l]],q[l]+1,q[r]-q[l],ans,x,y-x+1)) { ans = sum[q[r]] - sum[q[l]]; x = q[l] + 1;y = q[r]; } l++; } while (l <= r && sum[i] < sum[q[r]]) r--; q[++r] = i; if (q[r] > q[l] && cmp(sum[q[r]] - sum[q[l]],q[l]+1,q[r]-q[l],ans,x,y-x+1)) { ans = sum[q[r]] - sum[q[l]]; x = q[l] + 1;y = q[r]; } } if (q[r] > q[l] && sum[q[r]]-sum[q[l]] > ans) { ans = sum[q[r]] - sum[q[l]]; x = q[l]+1,y = q[r]; } printf("%d %d %d\n",ans,x,(y-1)%n+1); return 0; }
[ "bamboohiko@163.com" ]
bamboohiko@163.com
e374a020755833c2196bc6dc9343cc94cba7d7c7
684a35add439b69b48793f4fe659423d43b0f57f
/MatrixMultiplication/main.cpp
aa370abcce83582b051764ac72ec6091aaecdf80
[]
no_license
beginner1986/MatrixMultiplication
039cca80e5c69b3bb5a4a71a0944703264298d02
6ea2ebb73a01e77ef820da62f023e881f808038e
refs/heads/master
2020-09-01T17:33:44.620824
2019-12-05T19:25:06
2019-12-05T19:25:06
218,965,210
0
0
null
null
null
null
WINDOWS-1250
C++
false
false
6,137
cpp
#include <iostream> #include <iomanip> #include <string> #include <chrono> #include <vector> #include <omp.h> #include "Matrix.h" double multiplyI(const Matrix& A, const Matrix& B, Matrix& result, int threadsNumber); double multiplyJ(const Matrix& A, const Matrix& B, Matrix& result, int threadsNumber); double multiplyK(const Matrix& A, const Matrix& B, Matrix& result, int threadsNumber); void printTable(double table[5][6]); int main() { // polish language support setlocale(LC_ALL, "polish"); std::cout << std::setprecision(5) << std::fixed; // read the matrices to multiply Matrix* A, * B; std::vector<int> sizes{ 100, 500, 1000, 2000 }; // result arrays rows initialization double timesI[5][6]; double timesJ[5][6]; double timesK[5][6]; // top - left field timesI[0][0] = 0; timesJ[0][0] = 0; timesK[0][0] = 0; // first column (sizes) for (size_t i=0; i<sizes.size(); i++) { timesI[i + 1][0] = sizes[i]; timesJ[i + 1][0] = sizes[i]; timesK[i + 1][0] = sizes[i]; } // test cases for (int numberOfThreads = 1, column = 1; numberOfThreads <= 16; numberOfThreads *= 2, column++) { // result arrays columns initialization timesI[0][column] = numberOfThreads; timesJ[0][column] = numberOfThreads; timesK[0][column] = numberOfThreads; for (size_t row=0; row<sizes.size(); row++) { int size = sizes[row]; std::string matrixAFileName = "a" + std::to_string(size); std::string matrixBFileName = "b" + std::to_string(size); std::string matrixCFileName = "c" + std::to_string(size); omp_set_num_threads(2); #pragma omp parallel { #pragma omp sections { #pragma omp section { A = new Matrix(matrixAFileName); } #pragma omp section { B = new Matrix(matrixBFileName); } } } // prepare the result matrix Matrix *C = new Matrix(A->getN(), B->getM()); // multiply the matrices, save result to file and count time timesI[row + 1][column] = multiplyI(*A, *B, *C, numberOfThreads); C->writeToFile(matrixCFileName + "i"); timesJ[row + 1][column] = multiplyJ(*A, *B, *C, numberOfThreads); C->writeToFile(matrixCFileName + "j"); timesK[row + 1][column] = multiplyK(*A, *B, *C, numberOfThreads); C->writeToFile(matrixCFileName + "k"); // free the memory delete A, B, C; } } // print the times std::cout << "i - loop:" << std::endl; printTable(timesI); std::cout << "j - loop:" << std::endl; printTable(timesJ); std::cout << "k - loop:" << std::endl; printTable(timesK); // hold the screen std::cin.get(); int temp; std::cin >> temp; return 0; } void printTable(double table[5][6]) { for (int i = 0; i < 5; i++) { for (int j = 0; j < 6; j++) { std::cout << (i==0 || j==0 ? std::setprecision(0) : std::setprecision(5)) << std::fixed << table[i][j] << "\t" << (table[i][j] > 10.0f ? "" : "\t"); } std::cout << std::endl; } std::cout << std::endl; } double multiplyI(const Matrix& A, const Matrix& B, Matrix &result, int threadsNumber) { // start time masurement auto startTime = std::chrono::system_clock::now(); // check multiplication correctness condition if (A.getN() != B.getM()) { std::cout << "Nie można pomnożyć tych macierzy!" << std::endl; exit(-1); } // perform the multiplication int i, j, k; omp_set_num_threads(threadsNumber); #pragma omp parallel shared(A, B, result) private(i, j, k) { #pragma omp for for (i = 0; i < A.getM(); i++) { for (j = 0; j < B.getN(); j++) { float temp = 0; for (k = 0; k < A.getN(); k++) { temp = temp + A.getAt(i, k) * B.getAt(k, j); } result.setAt(i, j, temp); } } }; // end time and time difference print auto endTime = std::chrono::system_clock::now(); std::chrono::duration<double> time = endTime - startTime; std::cout << "Pętla i" << "\t\t" << "Wymiar: " << A.getM() << "\t" << "wątków: " << threadsNumber << "\t" << "czas: " << time.count() << "s." << std::endl; return time.count(); } double multiplyJ(const Matrix& A, const Matrix& B, Matrix& result, int threadsNumber) { // start time masurement auto startTime = std::chrono::system_clock::now(); // check multiplication correctness condition if (A.getN() != B.getM()) { std::cout << "Nie można pomnożyć tych macierzy!" << std::endl; exit(-1); } // perform the multiplication int i, j, k; omp_set_num_threads(threadsNumber); for (i = 0; i < A.getM(); i++) { #pragma omp parallel shared(A, B, result, i) private(j, k) { #pragma omp for for (j = 0; j < B.getN(); j++) { float temp = 0; for (k = 0; k < A.getN(); k++) { temp = temp + A.getAt(i, k) * B.getAt(k, j); } result.setAt(i, j, temp); } } }; // end time and time difference print auto endTime = std::chrono::system_clock::now(); std::chrono::duration<double> time = endTime - startTime; std::cout << "Pętla j" << "\t\t" << "Wymiar: " << A.getM() << "\t" << "wątków: " << threadsNumber << "\t" << "czas: " << time.count() << "s." << std::endl; return time.count(); } double multiplyK(const Matrix& A, const Matrix& B, Matrix& result, int threadsNumber) { // start time masurement auto startTime = std::chrono::system_clock::now(); // check multiplication correctness condition if (A.getN() != B.getM()) { std::cout << "Nie można pomnożyć tych macierzy!" << std::endl; exit(-1); } // perform the multiplication int i, j, k; omp_set_num_threads(threadsNumber); for (i = 0; i < A.getM(); i++) { for (j = 0; j < B.getN(); j++) { float temp = 0; #pragma omp parallel shared(A, B, result, i, j, temp) private(k) { #pragma omp for for (k = 0; k < A.getN(); k++) { temp = temp + A.getAt(i, k) * B.getAt(k, j); } result.setAt(i, j, temp); } } }; // end time and time difference print auto endTime = std::chrono::system_clock::now(); std::chrono::duration<double> time = endTime - startTime; std::cout << "Pętla k" << "\t\t" << "Wymiar: " << A.getM() << "\t" << "wątków: " << threadsNumber << "\t" << "czas: " << time.count() << "s." << std::endl; return time.count(); }
[ "beginner1986@gmail.com" ]
beginner1986@gmail.com
203ec0a6504fe53b101c690b92c87c45cba6d420
b32ab8ff6cfcb2f1c12692773a37ab009d75526a
/randoms/random_std.cpp
1e5aa4bf5a3dc8f1aa9c3cc2f2a1eb7391bbb19b
[]
no_license
un44444444/magicbox
61a7035731ccba867e476896e6f0ac736941ce6b
982140f5b0bb17ef09b902720417d1baf94ecaaa
refs/heads/master
2020-05-27T15:42:12.679145
2014-11-24T07:33:09
2014-11-24T07:33:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,744
cpp
#include "random_std.h" //see http://www.cplusplus.com/reference/random/ #include <random>//require c++11 #include "seed.h" #include "utils/log.h" // CRandomGenerator class CRandomGenerator { public: static CRandomGenerator* Instance(int rstart, int rend); void ChangeParam(const std::string& params); int GenarateNumber(); protected: private: CRandomGenerator(int rstart, int rend); CRandomGenerator(const CRandomGenerator& rhs); ~CRandomGenerator(); private: std::default_random_engine* m_pGenerator; std::uniform_int_distribution<int>* m_pDistribution; }; CRandomGenerator* CRandomGenerator::Instance(int rstart, int rend) { static CRandomGenerator instance(rstart, rend); return &instance; } CRandomGenerator::CRandomGenerator(int rstart, int rend) { m_pGenerator = new std::default_random_engine(get_32bit_seed()); m_pDistribution = new std::uniform_int_distribution<int>(rstart, rend); } CRandomGenerator::~CRandomGenerator() { delete m_pGenerator; m_pGenerator = NULL; delete m_pDistribution; m_pDistribution = NULL; } void CRandomGenerator::ChangeParam(const std::string& params) { MAGICBOX_LOG_DEBUG(params); } int CRandomGenerator::GenarateNumber() { int number = (*m_pDistribution)(*m_pGenerator); return number; } // CRandomStd static CRandomGenerator* s_pInstance = NULL; CRandomStd::CRandomStd(int low, int high) { s_pInstance = CRandomGenerator::Instance(low, high); } CRandomStd::CRandomStd(int low, int high, const std::string& params) { s_pInstance = CRandomGenerator::Instance(low, high); s_pInstance->ChangeParam(params); } CRandomStd::~CRandomStd() { } int CRandomStd::RandomNumber() { return s_pInstance->GenarateNumber(); }
[ "un44444444@gmail.com" ]
un44444444@gmail.com
7e8156e0d777f6e5a7c4b170dcb683433eed4865
b637b60f765f77187f62838614ef5b0fc3f38783
/c++/setTest.cpp
45ef3b81815f5c400b7a40192c29f5ce04bd067d
[]
no_license
spacewander/AlgorithmAndDataStructure
3cdeb0e39a967b2cb05585cc856d2b4b11e5ad10
127220c713be1f1afa2bc5347053fb587675c948
refs/heads/master
2021-04-30T22:06:50.152285
2020-10-13T06:20:56
2020-10-13T06:20:56
28,530,308
2
3
null
2020-10-13T06:20:57
2014-12-27T06:28:21
JavaScript
UTF-8
C++
false
false
2,014
cpp
#include "test.h" #include "set.hpp" using namespace std; class Set : public ::testing::Test { protected: vector<int> a{1, 2, 3, 4}; vector<int> b{3, 4, 5, 6}; }; TEST_F(Set, merge) { vector<int> c(a.size() + b.size()); my::merge(a.begin(), a.end(), b.begin(), b.end(), c.begin()); vector<int> ab{1, 2, 3, 3, 4, 4, 5, 6}; EXPECT_EQ(ab, c); } TEST_F(Set, inplace_merge) { vector<pair<int, int> > pairs{ make_pair(8, 20), make_pair(10, 9), make_pair(10, 10), make_pair(8, 10), make_pair(10, 11), make_pair(20, 10), }; vector<pair<int, int> > merged = pairs; auto cp = [](const pair<int, int> &a, const pair<int, int> &b){ return a.first < b.first; }; my::inplace_merge(pairs.begin(), pairs.begin() + 3, pairs.end(), cp); std::inplace_merge(merged.begin(), merged.begin() + 3, merged.end(), cp); EXPECT_EQ(merged, pairs); } TEST_F(Set, includes) { EXPECT_FALSE(my::includes(a.begin(), a.end(), b.begin(), b.end(), less<int>())); vector<int> c{1, 2}; EXPECT_TRUE(my::includes(a.begin(), a.end(), c.begin(), c.end(), less<int>())); } TEST_F(Set, set_difference) { vector<int> c(2); my::set_difference(a.begin(), a.end(), b.begin(), b.end(), c.begin()); vector<int> diff{1, 2}; EXPECT_EQ(diff, c); } TEST_F(Set, set_intersection) { vector<int> c(2); my::set_intersection(a.begin(), a.end(), b.begin(), b.end(), c.begin()); vector<int> intersection{3, 4}; EXPECT_EQ(intersection, c); } TEST_F(Set, set_symmetric_difference) { vector<int> c(4); my::set_symmetric_difference(a.begin(), a.end(), b.begin(), b.end(), c.begin()); vector<int> symmetric_difference{1, 2, 5, 6}; EXPECT_EQ(symmetric_difference, c); } TEST_F(Set, set_union) { vector<int> c(6); my::set_union(a.begin(), a.end(), b.begin(), b.end(), c.begin()); vector<int> ab{1, 2, 3, 4, 5, 6}; EXPECT_EQ(ab, c); }
[ "spacewanderlzx@gmail.com" ]
spacewanderlzx@gmail.com
6333ac3a2c501dd2998c261cfc0f2ec84d85003e
87de63798f786e8f32c171554f16cc1cb05bd61f
/SystemModels/Connections/BloodTissue/BloodTissueCnFactory.cpp
e19cdc8bc001224e7682581cda6c6eb2546136a6
[]
no_license
avgolov/virtual-human
a0bd4d88b0c76f8f9c0fbf795e9c0e3ccff43d60
82636e04489efad9efe57077b8e6369d8cf5feff
refs/heads/master
2021-07-17T17:15:47.189088
2017-10-24T08:57:21
2017-10-24T08:57:21
108,100,427
1
0
null
null
null
null
UTF-8
C++
false
false
998
cpp
#include "BloodTissueCnFactory.h" #include "BaseBloodTissueCn.h" #include "BodyBloodBaseTissueCn.h" #include "../../Systems/TissueSystem/BaseTissueSys.h" #include "../../Systems/BloodSystem/BodyBloodSys.h" #include "../../Systems/BloodSystem/BodyBioChemBloodSys.h" #include "BodyBioChemTissueCn.h" namespace SystemModels { std::shared_ptr<IBloodTissueCn> BloodTissueCnFactory::Create(boost::shared_ptr<IBloodSys> system1, boost::shared_ptr<ITissueSys> system2) { if (dynamic_cast<BodyBloodSys*>(system1.get()) && dynamic_cast<BaseTissueSys*>(system2.get())) { return std::static_pointer_cast<IBloodTissueCn>(std::make_shared<BodyBloodBaseTissueCn>(system1, system2)); } if (dynamic_cast<BodyBioChemBloodSys*>(system1.get()) && dynamic_cast<BaseTissueSys*>(system2.get())) { return std::static_pointer_cast<IBloodTissueCn>(std::make_shared<BodyBioChemTissueCn>(system1, system2)); } return std::shared_ptr<IBloodTissueCn>(nullptr); } }
[ "golov.andrey@hotmail.com" ]
golov.andrey@hotmail.com
c311dc956b472f7fc72a2b5ad9b2257a0da2b950
9bc2462106be4df51f31e44e28ea6a78b42a3deb
/2019_05_11/b/src.cpp
3ee49129eb29e8a0b8d245ee1862c02e16dfb7a5
[]
no_license
ysuzuki19/atcoder
4c8128c8a7c7ed10fc5684b1157ab5513ba9c32e
0fbe0e41953144f24197b4dcd623ff04ef5bc4e4
refs/heads/master
2021-08-14T19:35:45.660024
2021-07-31T13:40:39
2021-07-31T13:40:39
178,597,227
0
0
null
null
null
null
UTF-8
C++
false
false
347
cpp
#include <bits/stdc++.h> using namespace std; int main(){ int i, j; int R, G, B, N; cin >> R >> G >> B >> N; int pat = 0; for(int r=0; r*R<=N; r++){ int ball = 0; for(int g=0; r*R+g*G<=N; g++){ ball = r*R + g*G; if((N-ball)/B>=0 && (N-ball)%B==0){ pat++; } } } cout << pat << endl; return 0; }
[ "msethuuh7@i.softbank.jp" ]
msethuuh7@i.softbank.jp
b789f20fbc927ca2aa0ccf232f47b61bc9df937e
ef946fb8bb11daac8eb1157ca0f6efe133924c88
/StRoot/StEvent/StRnDHit.h
8c816a2edb4db56aa46a4aaa08fd87f29428afeb
[]
no_license
jdbrice/StMtdTrgMaker
b91453cb08394c1bc92da56fad657730d17c3946
45f721394a9f153e7665c2fe390d741222dd4fee
refs/heads/master
2021-01-21T13:57:01.894549
2016-05-12T23:23:48
2016-05-12T23:23:48
54,059,023
0
0
null
null
null
null
UTF-8
C++
false
false
4,326
h
/*! * \class StRnDHit * \author Mike Miller and Andrew Rose, Jan 2006 */ /*************************************************************************** * * $Id: StRnDHit.h,v 2.2 2006/09/27 18:31:43 ullrich Exp $ * * Author: Mike Miller and Andrew Rose, Jan 2006 *************************************************************************** * * Description: This is an experimental class and not final yet * *************************************************************************** * * $Log: StRnDHit.h,v $ * Revision 2.2 2006/09/27 18:31:43 ullrich * Fixed setDouble() interface. Was sooo wrong. * * Revision 2.1 2006/01/19 21:42:06 ullrich * Initial Revision. * **************************************************************************/ #ifndef StRnDHit_hh #define StRnDHit_hh #include "StHit.h" #include "StMemoryPool.hh" #include "StEnumerations.h" class StRnDHit : public StHit { public: StRnDHit(); StRnDHit(const StThreeVectorF& position, const StThreeVectorF& error, unsigned int hwPosition, float charge, unsigned char trackRefCount = 0, unsigned short idTruth=0, unsigned short quality=0, unsigned short id =0, StDetectorId = kUnknownId); ~StRnDHit(); StDetectorId detector() const; short layer() const; short ladder() const; short wafer() const; int extraByte0() const; int extraByte1() const; int key() const; int volumeId() const; double double0() const; double double1() const; double double2() const; double double3() const; double double4() const; void setLayer(short); void setLadder(short); void setWafer(short); void setExtraByte0(int); void setExtraByte1(int); void setDetectorId(StDetectorId); void setKey(int); void setVolumeId(int); void setDouble0(double); void setDouble1(double); void setDouble2(double); void setDouble3(double); void setDouble4(double); void* operator new(size_t sz,void *p) { return p;} void* operator new(size_t) { return mPool.alloc(); } void operator delete(void* p) { mPool.free(p); } friend ostream& operator<<(ostream& os, const StRnDHit& h); protected: Short_t mLayer; ///Layer Short_t mLadder; ///Ladder Short_t mWafer; ///Wafer //Extras Int_t mExtraByte0; Int_t mExtraByte1; //info to get back to StMcHit pointer: Int_t mKey; ///key from StMcHit Int_t mVolumeId; ///VolumeId from StMcHit //and 5 overflow doubles Double_t mDouble0; Double_t mDouble1; Double_t mDouble2; Double_t mDouble3; Double_t mDouble4; // this has to go once the playing and testing is over. // should be hard wired in member function. StDetectorId mDetectorId; static StMemoryPool mPool; //! ClassDef(StRnDHit,1) }; inline short StRnDHit::layer() const {return mLayer;} inline short StRnDHit::ladder() const {return mLadder;} inline short StRnDHit::wafer() const {return mWafer;} inline int StRnDHit::extraByte0() const {return mExtraByte0;} inline int StRnDHit::extraByte1() const {return mExtraByte1;} inline int StRnDHit::key() const {return mKey;} inline int StRnDHit::volumeId() const {return mVolumeId;} inline double StRnDHit::double0() const {return mDouble0;} inline double StRnDHit::double1() const {return mDouble1;} inline double StRnDHit::double2() const {return mDouble2;} inline double StRnDHit::double3() const {return mDouble3;} inline double StRnDHit::double4() const {return mDouble4;} inline void StRnDHit::setLayer(short v) {mLayer = v;} inline void StRnDHit::setLadder(short v) {mLadder = v;} inline void StRnDHit::setWafer(short v) {mWafer = v;} inline void StRnDHit::setExtraByte0(int v) {mExtraByte0=v;} inline void StRnDHit::setExtraByte1(int v) {mExtraByte1=v;} inline void StRnDHit::setKey(int v) {mKey = v;} inline void StRnDHit::setVolumeId(int v) {mVolumeId=v;} inline void StRnDHit::setDouble0(double val) {mDouble0 = val;} inline void StRnDHit::setDouble1(double val) {mDouble1 = val;} inline void StRnDHit::setDouble2(double val) {mDouble2 = val;} inline void StRnDHit::setDouble3(double val) {mDouble3 = val;} inline void StRnDHit::setDouble4(double val) {mDouble4 = val;} #endif
[ "jdb12@rice.edu" ]
jdb12@rice.edu
434e7266cdf89ce0003e579e1dbcdc6d3a6ca235
67ca2eedf4831569f81ef1c746b6befc818be6fe
/OpenGL_6/OpenGL_6/dirLight.h
f0dc36a4de2f6ae11b336db7c8cc30690f3a469b
[]
no_license
arepina/openGL
94bfbeeb15ccd25f8a18e44fc610a2659dc7382f
d39f9d1b32cb0b73875f99b36d257182ca81c619
refs/heads/master
2021-09-08T12:55:15.543250
2018-03-09T20:34:30
2018-03-09T20:34:30
110,345,400
0
0
null
null
null
null
UTF-8
C++
false
false
553
h
#pragma once #include "shaders.h" /******************************** Class: CDirectionalLight Purpose: Support class for adding directional lights to scene. ********************************/ class CDirectionalLight { public: glm::vec3 vColor; // Color of directional light glm::vec3 vDirection; // and its direction float fAmbient; int iSkybox; void SetUniformData(CShaderProgram* spProgram, string sLightVarName); CDirectionalLight(); CDirectionalLight(glm::vec3 a_vColor, glm::vec3 a_vDirection, float a_fAmbient, int a_iSkybox); };
[ "anastasiya.repina2012@yandex.ru" ]
anastasiya.repina2012@yandex.ru
06fbd51e3f65289794e34dd85f50c655d51df1c2
7ea45377de05a91d447687c53e1a836cfaec4b11
/fb_hackercup/qualround_14/square_detector.cpp
9503763ace3d4e558e03fe0f742962de546cfe00
[]
no_license
saikrishna17394/Code
d2b71efe5e3e932824339149008c3ea33dff6acb
1213f951233a502ae6ecf2df337f340d8d65d498
refs/heads/master
2020-05-19T14:16:49.037709
2017-01-26T17:17:13
2017-01-26T17:17:13
24,478,656
0
0
null
null
null
null
UTF-8
C++
false
false
1,382
cpp
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <set> #include <map> #include <bitset> #include <cstring> #include <string> #include <cmath> #include <queue> #define lli long long int #define ii pair<long long int,long long int> #define mp make_pair #define mod 1000000007 #define inf 999999999 using namespace std; inline void inp(int &n ) {//fast input function n=0; int ch=getchar_unlocked(),sign=1; while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getchar_unlocked();} while( ch >= '0' && ch <= '9' ) n=(n<<3)+(n<<1)+ ch-'0', ch=getchar_unlocked(); n=n*sign; } int main() { freopen("square_detector.txt", "r", stdin); freopen("square_detector_out.txt", "w", stdout); int t,n,cnt,x,y,k; bool ok; string s[20]; inp(t); for(int a=1;a<=t;a++) { inp(n); for(int i=0;i<n;i++) cin>>s[i]; cnt=0; ok=true; for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { if(s[i][j]=='#') { cnt++; if(ok) { x=i; y=j; ok=false; } } } } k=sqrt(cnt); if(k*k!=cnt || x+k>n || y+k>n) { printf("Case #%d: NO\n",a); continue; } ok=false; for(int i=x;i<x+k;i++) { for(int j=y;j<y+k;j++) { if(s[i][j]=='.') { ok=true; break; } } if(ok) break; } if(ok) printf("Case #%d: NO\n",a); else printf("Case #%d: YES\n",a); } return 0; }
[ "saikrishna17394@gmail.com" ]
saikrishna17394@gmail.com
3f54101fdbf9cacf66c3525321d4d43d3efb7f66
9f81d77e028503dcbb6d7d4c0c302391b8fdd50c
/google/cloud/dataproc/v1/mocks/mock_cluster_controller_connection.h
ce69263271c9770ee5fc1b35988c45862b036667
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
googleapis/google-cloud-cpp
b96a6ee50c972371daa8b8067ddd803de95f54ba
178d6581b499242c52f9150817d91e6c95b773a5
refs/heads/main
2023-08-31T09:30:11.624568
2023-08-31T03:29:11
2023-08-31T03:29:11
111,860,063
450
351
Apache-2.0
2023-09-14T21:52:02
2017-11-24T00:19:31
C++
UTF-8
C++
false
false
3,756
h
// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Generated by the Codegen C++ plugin. // If you make any local changes, they will be lost. // source: google/cloud/dataproc/v1/clusters.proto #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_DATAPROC_V1_MOCKS_MOCK_CLUSTER_CONTROLLER_CONNECTION_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_DATAPROC_V1_MOCKS_MOCK_CLUSTER_CONTROLLER_CONNECTION_H #include "google/cloud/dataproc/v1/cluster_controller_connection.h" #include <gmock/gmock.h> namespace google { namespace cloud { namespace dataproc_v1_mocks { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN /** * A class to mock `ClusterControllerConnection`. * * Application developers may want to test their code with simulated responses, * including errors, from an object of type `ClusterControllerClient`. To do so, * construct an object of type `ClusterControllerClient` with an instance of * this class. Then use the Google Test framework functions to program the * behavior of this mock. * * @see [This example][bq-mock] for how to test your application with GoogleTest. * While the example showcases types from the BigQuery library, the underlying * principles apply for any pair of `*Client` and `*Connection`. * * [bq-mock]: @cloud_cpp_docs_link{bigquery,bigquery-read-mock} */ class MockClusterControllerConnection : public dataproc_v1::ClusterControllerConnection { public: MOCK_METHOD(Options, options, (), (override)); MOCK_METHOD( future<StatusOr<google::cloud::dataproc::v1::Cluster>>, CreateCluster, (google::cloud::dataproc::v1::CreateClusterRequest const& request), (override)); MOCK_METHOD( future<StatusOr<google::cloud::dataproc::v1::Cluster>>, UpdateCluster, (google::cloud::dataproc::v1::UpdateClusterRequest const& request), (override)); MOCK_METHOD(future<StatusOr<google::cloud::dataproc::v1::Cluster>>, StopCluster, (google::cloud::dataproc::v1::StopClusterRequest const& request), (override)); MOCK_METHOD(future<StatusOr<google::cloud::dataproc::v1::Cluster>>, StartCluster, (google::cloud::dataproc::v1::StartClusterRequest const& request), (override)); MOCK_METHOD( future<StatusOr<google::cloud::dataproc::v1::ClusterOperationMetadata>>, DeleteCluster, (google::cloud::dataproc::v1::DeleteClusterRequest const& request), (override)); MOCK_METHOD(StatusOr<google::cloud::dataproc::v1::Cluster>, GetCluster, (google::cloud::dataproc::v1::GetClusterRequest const& request), (override)); MOCK_METHOD(StreamRange<google::cloud::dataproc::v1::Cluster>, ListClusters, (google::cloud::dataproc::v1::ListClustersRequest request), (override)); MOCK_METHOD( future<StatusOr<google::cloud::dataproc::v1::DiagnoseClusterResults>>, DiagnoseCluster, (google::cloud::dataproc::v1::DiagnoseClusterRequest const& request), (override)); }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace dataproc_v1_mocks } // namespace cloud } // namespace google #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_DATAPROC_V1_MOCKS_MOCK_CLUSTER_CONTROLLER_CONNECTION_H
[ "noreply@github.com" ]
googleapis.noreply@github.com
6c04e1feb93288523640eda496459612a073b584
d96349b211a135bc63e828f186e3560c0d383197
/Cp2/2-2-3_exercise.cpp
a830ad8e56b3110b927ee7926b928c510bc84475
[]
no_license
masa-k0101/Self-Study_Cpp
116904e7a45d8d211e85b3e20cfbfc602dd866f4
1fdd3b0637274934e7730ca87a400bf2c97daf8f
refs/heads/master
2022-12-14T01:59:20.763522
2020-09-15T13:20:08
2020-09-15T13:20:08
263,053,847
0
0
null
null
null
null
UTF-8
C++
false
false
733
cpp
#include<iostream> namespace A { class box { private: double x,y,z; double v; public: box(double a, double b, double c); double store(); void vol(); }; box::box(double a, double b, double c) { x = a; y = b; z = c; } double box::store() { return v = x*y*z; } void box::vol() { std::cout << "Calicurate result of Box volume:" << store() << "\n"; } } main() { double i,j,k; std::cout << "Enter three length of box: "; std::cin >> i >> j >>k; A::box ob(i,j,k); ob.store(); ob.vol(); return 0; }
[ "noreply@github.com" ]
masa-k0101.noreply@github.com
d4d13b53a6e20ddd6e8a22515a13d02a9c123fb3
38477b69e2f499505f149f096dfe5f962bb7d33b
/VSProject/gSpan/gSpan/main.cpp
422217fdf90e44764baf9de11eba57f8d269bd86
[]
no_license
wsgan001/gSpan
0f2e03df43ec728c878d0bdf5606eacac65fbc27
2cc04b9358d3d1b27488a3027c6b5289afc211c9
refs/heads/master
2021-05-09T20:38:28.958306
2015-10-31T14:57:34
2015-10-31T14:57:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
391
cpp
#include "head.h" #include "Solver.h" Solver solver; void init() { solver.init("in.txt", 0.6); } void input() { solver.input(); } void solve() { solver.solve(); } void output() { solver.output(); } int main() { //freopen("debug.txt", "w", stdout); init(); input(); solve(); output(); return 0; } /* Test data set * Graph.data * cntGraph == 10000 * vn < 250 * en < 250 */
[ "xysmlx@163.com" ]
xysmlx@163.com
e1782d495b8422051cc6f022c75def4ad9183e71
01a42b69633daf62a2eb3bb70c5b1b6e2639aa5f
/SCUM_UI_HandsHolstersWidget3_functions.cpp
3a5926edb55e644262e8779a5377ac9703c30716
[]
no_license
Kehczar/scum_sdk
45db80e46dac736cc7370912ed671fa77fcb95cf
8d1770b44321a9d0b277e4029551f39b11f15111
refs/heads/master
2022-07-25T10:06:20.892750
2020-05-21T11:45:36
2020-05-21T11:45:36
265,826,541
1
0
null
null
null
null
UTF-8
C++
false
false
1,980
cpp
// Scum 3.79.22573 (UE 4.24) #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "../SDK.hpp" namespace Classes { //--------------------------------------------------------------------------- //Functions //--------------------------------------------------------------------------- // Function UI_HandsHolstersWidget3.UI_HandsHolstersWidget3_C.PreConstruct // (NetRequest, Exec, NetResponse, Static, NetMulticast, MulticastDelegate, Public, Private, Protected, NetClient, DLLImport, BlueprintEvent, BlueprintPure, NetValidate) // Parameters: // bool* IsDesignTime (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData) void UUI_HandsHolstersWidget3_C::STATIC_PreConstruct(bool* IsDesignTime) { static auto fn = UObject::FindObject<UFunction>("Function UI_HandsHolstersWidget3.UI_HandsHolstersWidget3_C.PreConstruct"); UUI_HandsHolstersWidget3_C_PreConstruct_Params params; params.IsDesignTime = IsDesignTime; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function UI_HandsHolstersWidget3.UI_HandsHolstersWidget3_C.ExecuteUbergraph_UI_HandsHolstersWidget3 // (Net, NetResponse, Private, Protected, NetServer, HasDefaults, DLLImport, BlueprintCallable, BlueprintEvent) // Parameters: // int* EntryPoint (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData) void UUI_HandsHolstersWidget3_C::ExecuteUbergraph_UI_HandsHolstersWidget3(int* EntryPoint) { static auto fn = UObject::FindObject<UFunction>("Function UI_HandsHolstersWidget3.UI_HandsHolstersWidget3_C.ExecuteUbergraph_UI_HandsHolstersWidget3"); UUI_HandsHolstersWidget3_C_ExecuteUbergraph_UI_HandsHolstersWidget3_Params params; params.EntryPoint = EntryPoint; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "65712402+Kehczar@users.noreply.github.com" ]
65712402+Kehczar@users.noreply.github.com
ba1fc2076acf7f64c281924d9288bf2248778ebb
32fad5d9d8c6a7ce11ed9e3480380b670d6267dd
/ch06/Exe_6.2526.cpp
0159808984c8effe010fc14c1c393e6248bb7572
[]
no_license
QuJia-Jessica/cpp
fc0d1bf1aadd462b5b8885353b4c460c23289511
d752000d1f6bc9295be2caaac0b15263a488cd54
refs/heads/main
2023-03-30T00:21:36.502340
2021-03-23T15:02:25
2021-03-23T15:02:25
346,953,402
0
0
null
2021-03-23T15:02:26
2021-03-12T05:40:33
null
UTF-8
C++
false
false
520
cpp
// //// Exercise 6.25: Write a main function that takes two arguments. //// Concatenate the supplied arguments and print the resulting string. //// //// Exercise 6.26: Write a program that accepts the options presented //// in this section. Print the values of the arguments passed to main. //// #include<iostream> #include<string> int main(int argc, char ** argv){ std::string str; for (int i; i != argc; ++i) str += std::string(argv[i]) + " "; std::cout << str << std::endl; return 0; }
[ "noreply@github.com" ]
QuJia-Jessica.noreply@github.com
7a2f5173ce25d70a7389141315d318697b8df4ed
85cce50c27d7bbd6d098ec0af7b5ec712ad6abd8
/CodeChef/C++/CookOff/COOK69_April16/CodeChef_MovieWKN.cpp
a27e9899bf80daa968e3b5aebacd14f59f3f6bf9
[]
no_license
saikiran03/competitive
69648adcf783183a6767caf6db2f63aa5be4aa25
c65e583c46cf14e232fdb5126db1492f958ba267
refs/heads/master
2020-04-06T07:04:06.577311
2016-10-05T08:28:19
2016-10-05T08:28:19
53,259,126
0
0
null
null
null
null
UTF-8
C++
false
false
948
cpp
#include <bits/stdc++.h> using namespace std; #define inf 1000000007 typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<vi> vii; typedef pair<int,int> ii; #define rf freopen("in.txt","r",stdin); #define wf freopen("out.txt","w",stdout); #define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define FOR(i,a,b) for(int i=a; i<=b; i++) #define tcase int __T; cin >> __T; while(__T--) #define rep(i,n) for(int i=0; i<n; i++) #define tr(it,x) for(auto it=x.begin(); it!=x.end(); it++) #define pb push_back #define all(x) x.begin(),x.end() int main(){ boost; int n; tcase{ cin >> n; int cnt,l[n],r[n],lr[n]; rep(i,n) cin >> l[i]; rep(i,n){ cin >> r[i]; lr[i] = r[i]*l[i]; } int* mx = max_element(lr,lr+n); if(count(lr,lr+n,*mx)>1){ mx = max_element(r,r+n); cout << mx-r+1 << endl; }else{ cout << mx-lr+1 << endl; } } }
[ "kiransai3284462@gmail.com" ]
kiransai3284462@gmail.com
23d4e041e02971b0902675df76d3832583d920f8
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/httpd/gumtree/httpd_new_hunk_2657.cpp
b3f2f72943d3cd278c6b173ec1eff036259eed5a
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
666
cpp
putLong((unsigned char *)&buf[0], ctx->crc); putLong((unsigned char *)&buf[4], ctx->stream.total_in); b = apr_bucket_pool_create(buf, VALIDATION_SIZE, r->pool, f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(ctx->bb, b); ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01384) "Zlib: Compressed %ld to %ld : URL %s", ctx->stream.total_in, ctx->stream.total_out, r->uri); /* leave notes for logging */ if (c->note_input_name) { apr_table_setn(r->notes, c->note_input_name,
[ "993273596@qq.com" ]
993273596@qq.com
a0d6c3c557f48cea04e4bd72def37ae1947a622c
3c65a5f203f2d4b02ff9c1bdd999c9e3b18007e7
/plugin/gui/custom_tooltip.cpp
d04cf5b96b8fb598d22c1018eca517c2c90991cf
[ "BSL-1.0" ]
permissive
cristivlas/zerobugs
07c81ceec27fd1191716e52b29825087baad39e4
5f080c8645b123d7887fd8a64f60e8d226e3b1d5
refs/heads/master
2020-03-19T17:20:35.491229
2018-06-09T20:17:55
2018-06-09T20:17:55
136,754,214
0
0
null
null
null
null
UTF-8
C++
false
false
4,640
cpp
// // $Id$ // // ------------------------------------------------------------------------- // This file is part of ZeroBugs, Copyright (c) 2010 Cristian L. Vlasceanu // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // ------------------------------------------------------------------------- // #include <assert.h> #include <iostream> #include <vector> #include "generic/temporary.h" #include "gtkmm/clist.h" #include "gtkmm/connect.h" #include "gtkmm/ctree.h" #include "gtkmm/flags.h" #include "gtkmm/label.h" #include "gtkmm/resize.h" #include "gtkmm/style.h" #include "gtkmm/widget.h" #include "gtkmm/window.h" #include "custom_tooltip.h" CustomToolTip::CustomToolTip(Gtk::Widget* w, GetTextAtPointer fn) : widget_(w) , getTextAtPointer_(fn) , hrow_(INIT_ROW_HANDLE) , hcol_(-1) , drawing_(false) { assert(w); assert(fn); w->add_events(Gdk_FLAG(POINTER_MOTION_MASK) | Gdk_FLAG(ENTER_NOTIFY_MASK) | Gdk_FLAG(LEAVE_NOTIFY_MASK) /* | Gdk_FLAG(BUTTON_PRESS_MASK) */); } CustomToolTip::~CustomToolTip() { } void CustomToolTip::reset_tooltip() { tooltip_.reset(); } #if !GTKMM_2 void CustomToolTip::position_tooltip(int x, int y) { assert(tooltip_.get()); // show the tooltip slightly off from the mouse x += 10; y += 10; // make sure that the tooltip is fully visible, // by forcing its coordinates inside the screen Gtk_adjust_coords_for_visibility(tooltip_, x, y); Gtk_move(tooltip_.get(), x, y); } #endif int CustomToolTip::on_pointer_motion(GdkEventMotion* event) { #if !GTKMM_2 // silence off compiler warnings about converting doubles to ints const int x_root = static_cast<int>(event->x_root); const int y_root = static_cast<int>(event->y_root); if (tooltip_.get()) { position_tooltip(x_root, y_root); } #endif assert(widget_); std::string text; if (!(*getTextAtPointer_)(*widget_, event->x, event->y, hrow_, hcol_, text)) { return 0; } #if (GTKMM_2) widget_->set_tooltip_text(text); #else // Gtk-1.2 gunk if (text.empty()) { tooltip_.reset(); hrow_ = INIT_ROW_HANDLE; hcol_ = -1; } else { tooltip_.reset(new Gtk::Window(Gtk_FLAG(WINDOW_POPUP))); assert(tooltip_.get()); tooltip_->set_name("tooltip"); tooltip_->set_border_width(3); Gtk_set_resizable(tooltip_, false); tooltip_->set_app_paintable(true); Gtk_CONNECT_0(tooltip_, expose_event, this, &CustomToolTip::on_paint_custom_tip); Gtk::Label* label = manage(new Gtk::Label(text, .0)); tooltip_->add(*label); label->set_line_wrap(false); label->set_justify(Gtk_FLAG(JUSTIFY_LEFT)); StylePtr style = CHKPTR(tooltip_->get_style())->copy(); // fixme: get the background color from the current theme style->set_bg(Gtk_FLAG(STATE_NORMAL), Gdk_Color("lightyellow")); style->set_fg(Gtk_FLAG(STATE_NORMAL), Gdk_Color("black")); Gtk_set_style(tooltip_, style); //move it out of sight, initially Gtk_move(tooltip_.get(), gdk_screen_width(), gdk_screen_height()); assert(tooltip_.get()); tooltip_->show_all(); position_tooltip(x_root, y_root); } #endif return 0; } int CustomToolTip::on_pointer_leave(GdkEventCrossing*) { #if GTKMM_2 widget_->set_has_tooltip(false); #else tooltip_.reset(); hrow_ = INIT_ROW_HANDLE; hcol_ = -1; #endif return 0; } int CustomToolTip::on_paint_custom_tip(GdkEventExpose* event) { if (drawing_) { return 0; } assert(event); assert(widget_); // otherwise how could we get this event? if (event->count == 0 && tooltip_.get()) { Temporary<bool> setFlag(drawing_, true); assert(tooltip_->get_style()); const GdkRectangle& r = event->area; gtk_paint_flat_box(GTKOBJ(tooltip_->get_style()), event->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, GTK_WIDGET(GTKOBJ(tooltip_)), "tooltip", r.x, r.y, r.width, r.height); //#ifdef GTKMM_2 // std::vector<Gtk::Widget*> children = tooltip_->get_children(); // gtk_widget_draw(GTKOBJ(children[0]), NULL); //#endif } return 0; } // vim: tabstop=4:softtabstop=4:expandtab:shiftwidth=4
[ "cvlasceanu@tableau.com" ]
cvlasceanu@tableau.com
720d3d04bff9fa2a6b6d87c2aa998c941b55a2c9
f16a6a1f0e53bd30fec3b97ffdde9f5eeae16fbd
/C++/practice/Multi table/add.cpp
8827f30410120d6db46cb05718a509b53ce53de1
[]
no_license
dungeonfighter/git
558444358a35dfe3b5fbecc9aeeb1171de532f15
6d1c635188fb1428002423730e813628737f72f2
refs/heads/master
2021-01-11T20:55:25.884789
2019-11-22T02:24:38
2019-11-22T02:24:38
79,209,682
0
0
null
null
null
null
UTF-8
C++
false
false
462
cpp
#include <iostream> using namespace std; /*==============================================================*/ void tem::pri(int num){ int count=0; while(count<=this->y){ for (int i = 1; i < this->x+1 ; ++i) { for (int j = 1+count; j <num+1+count ; ++j) { if(j<=y){ cout<<j<<"*"<<i<<"="<<j*i<<" ,"; } } cout<<endl; } count += num ; cout<<endl; } } /*==============================================================*/
[ "1103105339@gm.kuas.com" ]
1103105339@gm.kuas.com
ceec5f9861516c5e748ed114bbf807592374978c
91262d4e1279cea5c5f638777c355cb4c8243a4b
/Chapter-03/Puzzle/Source/Puzzle/PuzzlePlayerController.cpp
7ad42a77f73a37f20b4bf04d2834a8f1bbf5a70a
[ "MIT" ]
permissive
MENGJIANGTAO/Complete-Unreal-Engine-Game-Development-Guide
0aaf6c13bd23e6b83eaf747883862ed24cc195f4
76817acb3988c57db022a7bcd04a8e5ba8ebfecf
refs/heads/master
2022-03-07T08:12:40.657991
2019-11-18T11:27:01
2019-11-18T11:27:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
284
cpp
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved. #include "PuzzlePlayerController.h" APuzzlePlayerController::APuzzlePlayerController() { bShowMouseCursor = true; bEnableClickEvents = true; bEnableTouchEvents = true; DefaultMouseCursor = EMouseCursor::Crosshairs; }
[ "56333060+ashishjPackt@users.noreply.github.com" ]
56333060+ashishjPackt@users.noreply.github.com
3e3ee1c02c1f0bb339f772eca717b42ca598c35c
1c9c67d3923e61226f62c7d1b1571d7fb05fdfeb
/Systems/Comm.cpp
dbbb111aff4960f5fc6c37a6794ed1fd14e3f765
[ "MIT" ]
permissive
atrakeur/arduino-quadripod
3b05e4b7c53127ed60f80b6c6bb460558ad97f34
9577c10f2396e6636c433cf1195a452b1c04995c
refs/heads/master
2020-05-16T20:50:19.064842
2014-06-11T20:36:34
2014-06-11T20:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,020
cpp
#include <stdarg.h> #include "Arduino.h" #include "Comm.h" extern const char COMM_ERROR_STR[] = "ERROR"; extern const char COMM_ERROR_STR_NOERROR[] = "No error"; extern const char COMM_ERROR_STR_NODELIM[] = "No delimiter"; extern const char COMM_ERROR_STR_BUFFLEN[] = "Buf overflow"; void Comm::init() { inputUsed = 0; Serial.begin(9600); while (!Serial); //wait for serial ready } Command* Comm::recvCommand() { while(Serial.available() > 0) { int remSpace = COMM_COMMAND_BUFF - inputUsed; if (remSpace <= 0) { //invalidate command Comm::sendCommand(COMM_ERROR_STR, COMM_ERROR_STR_BUFFLEN); Comm::resetInputCommand(); //TODO discard overflow data? return NULL; } char data = (char)Serial.read(); if (data == '\n' || data == '\r') { //locate the delimiter int delimiter = -1; for (int i = 0; i < inputUsed; i++) { if (inputBuff[i] == ':') { delimiter = i; break; } } if (delimiter == -1) { //Invalid command Comm::sendCommand(COMM_ERROR_STR, COMM_ERROR_STR_NODELIM); Comm::resetInputCommand(); return NULL; } strncpy(input.key, inputBuff, delimiter); input.key[delimiter] = '\0'; strncpy(input.val, &inputBuff[delimiter + 1], inputUsed - delimiter - 1); input.val[inputUsed - delimiter - 1] = '\0'; Comm::resetInputCommand(); return &input; } else { inputBuff[inputUsed++] = data; } } return NULL; } void Comm::sendCommand(const char* key, const char* val, ...) { char buff[COMM_COMMAND_VAL]; va_list args; va_start(args, val); vsnprintf(buff, COMM_COMMAND_VAL, val, args); va_end(args); Serial.print(""); Serial.print(key); Serial.print(":"); Serial.print(buff); Serial.println(); } void Comm::sendError(const char* value, ...) { va_list args; va_start(args, value); Comm::sendCommand(COMM_ERROR_STR, value, args); va_end(args); } void Comm::resetInputCommand() { memset(inputBuff, '\0', COMM_COMMAND_KEY + COMM_COMMAND_VAL); inputUsed = 0; }
[ "atrakeur@gmail.com" ]
atrakeur@gmail.com
ce8547f60310f7c84bc0b8c90b9507e2eb2fd77c
600df3590cce1fe49b9a96e9ca5b5242884a2a70
/v8/src/interpreter/constant-array-builder.cc
d2b799562383dd87c5210509bff00061436d6573
[ "BSD-3-Clause", "SunPro", "bzip2-1.0.6" ]
permissive
metux/chromium-suckless
efd087ba4f4070a6caac5bfbfb0f7a4e2f3c438a
72a05af97787001756bae2511b7985e61498c965
refs/heads/orig
2022-12-04T23:53:58.681218
2017-04-30T10:59:06
2017-04-30T23:35:58
89,884,931
5
3
BSD-3-Clause
2022-11-23T20:52:53
2017-05-01T00:09:08
null
UTF-8
C++
false
false
8,196
cc
// Copyright 2015 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "src/interpreter/constant-array-builder.h" #include <functional> #include <set> #include "src/isolate.h" #include "src/objects-inl.h" namespace v8 { namespace internal { namespace interpreter { ConstantArrayBuilder::ConstantArraySlice::ConstantArraySlice( Zone* zone, size_t start_index, size_t capacity, OperandSize operand_size) : start_index_(start_index), capacity_(capacity), reserved_(0), operand_size_(operand_size), constants_(zone) {} void ConstantArrayBuilder::ConstantArraySlice::Reserve() { DCHECK_GT(available(), 0u); reserved_++; DCHECK_LE(reserved_, capacity() - constants_.size()); } void ConstantArrayBuilder::ConstantArraySlice::Unreserve() { DCHECK_GT(reserved_, 0u); reserved_--; } size_t ConstantArrayBuilder::ConstantArraySlice::Allocate( Handle<Object> object) { DCHECK_GT(available(), 0u); size_t index = constants_.size(); DCHECK_LT(index, capacity()); constants_.push_back(object); return index + start_index(); } Handle<Object> ConstantArrayBuilder::ConstantArraySlice::At( size_t index) const { DCHECK_GE(index, start_index()); DCHECK_LT(index, start_index() + size()); return constants_[index - start_index()]; } void ConstantArrayBuilder::ConstantArraySlice::InsertAt(size_t index, Handle<Object> object) { DCHECK_GE(index, start_index()); DCHECK_LT(index, start_index() + size()); constants_[index - start_index()] = object; } bool ConstantArrayBuilder::ConstantArraySlice::AllElementsAreUnique() const { std::set<Object*> elements; for (auto constant : constants_) { if (elements.find(*constant) != elements.end()) return false; elements.insert(*constant); } return true; } STATIC_CONST_MEMBER_DEFINITION const size_t ConstantArrayBuilder::k8BitCapacity; STATIC_CONST_MEMBER_DEFINITION const size_t ConstantArrayBuilder::k16BitCapacity; STATIC_CONST_MEMBER_DEFINITION const size_t ConstantArrayBuilder::k32BitCapacity; ConstantArrayBuilder::ConstantArrayBuilder(Zone* zone, Handle<Object> the_hole_value) : constants_map_(16, base::KeyEqualityMatcher<Address>(), ZoneAllocationPolicy(zone)), smi_map_(zone), smi_pairs_(zone), zone_(zone), the_hole_value_(the_hole_value) { idx_slice_[0] = new (zone) ConstantArraySlice(zone, 0, k8BitCapacity, OperandSize::kByte); idx_slice_[1] = new (zone) ConstantArraySlice( zone, k8BitCapacity, k16BitCapacity, OperandSize::kShort); idx_slice_[2] = new (zone) ConstantArraySlice( zone, k8BitCapacity + k16BitCapacity, k32BitCapacity, OperandSize::kQuad); } size_t ConstantArrayBuilder::size() const { size_t i = arraysize(idx_slice_); while (i > 0) { ConstantArraySlice* slice = idx_slice_[--i]; if (slice->size() > 0) { return slice->start_index() + slice->size(); } } return idx_slice_[0]->size(); } ConstantArrayBuilder::ConstantArraySlice* ConstantArrayBuilder::IndexToSlice( size_t index) const { for (ConstantArraySlice* slice : idx_slice_) { if (index <= slice->max_index()) { return slice; } } UNREACHABLE(); return nullptr; } Handle<Object> ConstantArrayBuilder::At(size_t index) const { const ConstantArraySlice* slice = IndexToSlice(index); if (index < slice->start_index() + slice->size()) { return slice->At(index); } else { DCHECK_LT(index, slice->capacity()); return the_hole_value(); } } Handle<FixedArray> ConstantArrayBuilder::ToFixedArray(Isolate* isolate) { // First insert reserved SMI values. for (auto reserved_smi : smi_pairs_) { InsertAllocatedEntry(reserved_smi.second, handle(reserved_smi.first, isolate)); } Handle<FixedArray> fixed_array = isolate->factory()->NewFixedArray( static_cast<int>(size()), PretenureFlag::TENURED); int array_index = 0; for (const ConstantArraySlice* slice : idx_slice_) { if (array_index == fixed_array->length()) { break; } DCHECK(array_index == 0 || base::bits::IsPowerOfTwo32(static_cast<uint32_t>(array_index))); // Different slices might contain the same element due to reservations, but // all elements within a slice should be unique. If this DCHECK fails, then // the AST nodes are not being internalized within a CanonicalHandleScope. DCHECK(slice->AllElementsAreUnique()); // Copy objects from slice into array. for (size_t i = 0; i < slice->size(); ++i) { fixed_array->set(array_index++, *slice->At(slice->start_index() + i)); } // Insert holes where reservations led to unused slots. size_t padding = std::min(static_cast<size_t>(fixed_array->length() - array_index), slice->capacity() - slice->size()); for (size_t i = 0; i < padding; i++) { fixed_array->set(array_index++, *the_hole_value()); } } DCHECK_EQ(array_index, fixed_array->length()); return fixed_array; } size_t ConstantArrayBuilder::Insert(Handle<Object> object) { return constants_map_ .LookupOrInsert(object.address(), ObjectHash(object.address()), [&]() { return AllocateIndex(object); }, ZoneAllocationPolicy(zone_)) ->value; } ConstantArrayBuilder::index_t ConstantArrayBuilder::AllocateIndex( Handle<Object> object) { for (size_t i = 0; i < arraysize(idx_slice_); ++i) { if (idx_slice_[i]->available() > 0) { return static_cast<index_t>(idx_slice_[i]->Allocate(object)); } } UNREACHABLE(); return kMaxUInt32; } ConstantArrayBuilder::ConstantArraySlice* ConstantArrayBuilder::OperandSizeToSlice(OperandSize operand_size) const { ConstantArraySlice* slice = nullptr; switch (operand_size) { case OperandSize::kNone: UNREACHABLE(); break; case OperandSize::kByte: slice = idx_slice_[0]; break; case OperandSize::kShort: slice = idx_slice_[1]; break; case OperandSize::kQuad: slice = idx_slice_[2]; break; } DCHECK(slice->operand_size() == operand_size); return slice; } size_t ConstantArrayBuilder::AllocateEntry() { return AllocateIndex(the_hole_value()); } void ConstantArrayBuilder::InsertAllocatedEntry(size_t index, Handle<Object> object) { DCHECK_EQ(the_hole_value().address(), At(index).address()); ConstantArraySlice* slice = IndexToSlice(index); slice->InsertAt(index, object); } OperandSize ConstantArrayBuilder::CreateReservedEntry() { for (size_t i = 0; i < arraysize(idx_slice_); ++i) { if (idx_slice_[i]->available() > 0) { idx_slice_[i]->Reserve(); return idx_slice_[i]->operand_size(); } } UNREACHABLE(); return OperandSize::kNone; } ConstantArrayBuilder::index_t ConstantArrayBuilder::AllocateReservedEntry( Smi* value) { index_t index = static_cast<index_t>(AllocateEntry()); smi_map_[value] = index; smi_pairs_.push_back(std::make_pair(value, index)); return index; } size_t ConstantArrayBuilder::CommitReservedEntry(OperandSize operand_size, Smi* value) { DiscardReservedEntry(operand_size); size_t index; auto entry = smi_map_.find(value); if (entry == smi_map_.end()) { index = AllocateReservedEntry(value); } else { ConstantArraySlice* slice = OperandSizeToSlice(operand_size); index = entry->second; if (index > slice->max_index()) { // The object is already in the constant array, but may have an // index too big for the reserved operand_size. So, duplicate // entry with the smaller operand size. index = AllocateReservedEntry(value); } DCHECK_LE(index, slice->max_index()); } return index; } void ConstantArrayBuilder::DiscardReservedEntry(OperandSize operand_size) { OperandSizeToSlice(operand_size)->Unreserve(); } } // namespace interpreter } // namespace internal } // namespace v8
[ "enrico.weigelt@gr13.net" ]
enrico.weigelt@gr13.net
ef736c0fcac01be5078ac2a2604cce1bc80fb8ae
83195bb76eb33ed93ab36c3782295e4a2df6f005
/Source/ToolCore/JSBind/JSBTypeScript.h
02afc7d1ba7fb5c9769610e7ef4e2cb7b4cc3c1c
[ "MIT", "BSD-3-Clause", "Zlib", "LicenseRef-scancode-openssl", "LicenseRef-scancode-khronos", "BSL-1.0", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "NTP" ]
permissive
MrRefactoring/AtomicGameEngine
ff227c054d3758bc1fbd5e502c382d7de81b0d47
9cd1bf1d4ae7503794cc3b84b980e4da17ad30bb
refs/heads/master
2020-12-09T07:24:48.735251
2020-01-11T14:03:29
2020-01-11T14:03:29
233,235,105
0
0
NOASSERTION
2020-01-11T13:21:19
2020-01-11T13:21:18
null
UTF-8
C++
false
false
1,851
h
// // Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // #pragma once #include <Atomic/Container/Str.h> using namespace Atomic; class JSBFunction; class JSBPackage; class JSBModule; namespace ToolCore { class JSBFunctionType; class JSBTypeScript { public: void Emit(JSBPackage* package, const String& path); private: String source_; void Begin(); void End(); void ExportFunction(JSBFunction* function); String GetScriptType(JSBFunctionType* ftype); void ExportModuleEnums(JSBModule* moduleName); void ExportModuleConstants(JSBModule* moduleName); void ExportModuleClasses(JSBModule* moduleName); void ExportModuleEvents(JSBModule* module); void WriteToFile(const String& path); JSBPackage* package_; }; }
[ "josh@galaxyfarfaraway.com" ]
josh@galaxyfarfaraway.com
fed16fa68c89b8d34dd6e794f81951573f9b0faa
84cd51502a8e091452de7ff63f729c6f762fec6f
/Study/SZPE/SZPE/Common.cpp
57f5e82a4bbdc5142c83c15207ff087897370702
[]
no_license
thinkingl/thinkingl-code-lib
4a5d8b431fed998cb1dd2e5f541a6a322880429e
75cb90a53c8bab8009c39b16d73913cf870c6d71
refs/heads/master
2022-12-25T08:32:00.813091
2022-12-14T06:18:51
2022-12-14T06:18:51
32,558,719
9
2
null
null
null
null
UTF-8
C++
false
false
46
cpp
#include "StdAfx.h" #include "Common.h"
[ "thinkingzx@076e9d56-d92b-0410-8186-f370c9e58ff5" ]
thinkingzx@076e9d56-d92b-0410-8186-f370c9e58ff5
0d0f12f4e7c94111fd9bce5f7e64d883e0ebbf23
7b8555b4c30b7b7daec43cf705cedd9ee8b74895
/BehaviorModel/StraightBehaviorModel.h
b168330ed0076b4ebdb402aec477e18ffa1331f7
[]
no_license
EniwaSentaiToshiking/etrobo-eniwa-sentai-toshiking
bd8fdbffdb2e883173d845c804bf004dd26a66e4
b34744f6bc05308f1bf754c9ef6702bbf4bd0759
refs/heads/master
2023-02-26T17:05:34.254633
2021-02-03T02:23:57
2021-02-03T02:23:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
463
h
/* * Created on Wed Feb 03 2021 * * Copyright (c) 2021 Kazuki Hamaguchi */ #pragma once #include "TemplateBehaviorModel.h" #include "StraightBehaviorModel.h" #include "WheelDeviceDriver.h" #include "StraightForwardOrBackward.h" class StraightBehaviorModel : public TemplateBehaviorModel { WheelDeviceDriver wheelDeviceDriver; public: void init(); void run(int pwm, StraightForwardOrBackward straightForwardOrBackward); void terminate(); };
[ "hamamatcha@gmail.com" ]
hamamatcha@gmail.com
3f62ed9896c5b3fc358bcc980ceea69b5674ec9b
3979ad10a1915fb7336eceb51ad807b4341dc4b6
/wink1.cpp
90278761d0a95619ca057f7bf9fe6369cef7a6b6
[]
no_license
tdonca/wink
ee536a476bcb0ebfc69abdc77159742847902573
61aee681485a906c7fbbc1d7b1e41db123c6b2f2
refs/heads/master
2021-08-28T15:24:11.284781
2017-12-12T15:58:16
2017-12-12T15:58:16
111,460,835
0
0
null
2017-12-12T15:49:55
2017-11-20T20:43:59
Makefile
UTF-8
C++
false
false
455
cpp
#include <opencv2/opencv.hpp> #include <iostream> #include "VideoStreamer.h" //when to include header files? int main(int argc, char* argv[]){ //create window cv::namedWindow("Wink", cv::WINDOW_NORMAL); cv::resizeWindow("Wink", 1600, 900); cv::moveWindow("Wink", 100, 900); //create video stream VideoStreamer stream{1600, 900}; //start streaming stream.startStream(0, "Wink"); std::cout << "Finished streaming." << std::endl; return 0; }
[ "tgdonca@gmail.com" ]
tgdonca@gmail.com
bb30f923d38a7e3550ddf01b71fb8eaeae37fc30
4c3cce59ac0552bbf95eeccfcd99538a36aa9337
/src/include/cui/cui.h
b452179c944ce266b04d19db88b5723399f211e0
[]
no_license
naota-inamoto/Altair
2f02ae47cefc1e920f9af8fd1fb76e665a8f82c9
e8fe97b919206270d037d4df0285a0c92c67a5f3
refs/heads/master
2020-05-30T08:58:18.197831
2020-02-16T09:50:55
2020-02-16T09:50:55
70,219,982
0
0
null
null
null
null
UTF-8
C++
false
false
1,783
h
/* * Copyright (C) 1995-2020 Naota Inamoto, * All rights reserved. * * For conditions of redistribution and reuse, * see the accompanying License-Altair.txt file */ #ifndef _AUI_CUI_H #define _AUI_CUI_H class AL_EXT_CLASS AUiProgramMgr : public AGm { public: AUiProgramMgr(); virtual ~AUiProgramMgr(); static AUiProgramMgr* Instance(); static AGmNode *CreateCommonClasses(); AGmNode* LibSearchPath(); AGmNode* LibList(); AGmNode* ProjectList(); int LoadLibrary(AGmNode *proj_root_class, AGmString *lib_name, AGmNode** lib); AGmNode *_lib_search_path; AGmNode *_lib_list; AGmNode *_proj_list; public: static int New(); static int Open(); static int _Open(AGmString *dir, AGmString *name); static int __Open(AGmString *path, AGmNode* proj, int inet=0); static int Save(AGmNode *root_class); static int SaveAs(AGmNode *root_class); static int _Save(AGmString *path, AGmNode *root); static void Exit(); static int MakeLibText(AGmNode *root_class, AGmNode *root); static int _MakeLibText(AGmFile*, AGmNode* root_class, AGmNode *root, int step); static int MakeLibGraph(AGmNode *root_class, AGmNode *root); static int MakeLibText2(AGmNode *root_class, AGmNode *classes); static int LoadLib(AGmNode *root_class, int tmp=0); static int _LoadLib(AGmFile*, AGmString *s, AGmNode *root_class, AGmNode** lib); static int _LoadLibText(AGmFile*, AGmString*, AGmNode *root_class, AGmNode *root, int, AGmNode **lib); static int _LoadLibGraph(AGmFile*, AGmNode *root_class, AGmNode *root, AGmNode **lib); static void CloseWindow(ADvWindow *aw); static void CloseAllWindows(); static int check_load; static int OpenProjectEditor(); static int IsReserveWord(AGmString*); // for garbage collection public: void GCmark(); }; #endif /* _AUI_CUI_H */
[ "naota_inamoto@yahoo.co.jp" ]
naota_inamoto@yahoo.co.jp
1a91e12e3448f2bac779fab407a6d071eb0499a5
562d2183cecd232559eb89d7f733bf1fe967768c
/Source/libClang/Source/lib/Target/ARM/ARMFrameLowering.h
f1146040568cdf1e1348d4ef8eba8c856a293006
[ "LicenseRef-scancode-arm-llvm-sga", "NCSA" ]
permissive
orcun-gokbulut/ze-externals-sources
f1fd970ed6161b8f7ac19d1991f44a720c0125e9
500a237d6e0ff6308db1e2e513ad9871ac4cda65
refs/heads/master
2023-09-01T19:44:32.292637
2021-10-13T14:26:53
2021-10-13T14:26:53
416,611,297
1
1
null
null
null
null
UTF-8
C++
false
false
3,258
h
//==-- ARMTargetFrameLowering.h - Define frame lowering for ARM --*- C++ -*-==// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // // //===----------------------------------------------------------------------===// #ifndef ARM_FRAMEINFO_H #define ARM_FRAMEINFO_H #include "llvm/Target/TargetFrameLowering.h" namespace llvm { class ARMSubtarget; class ARMFrameLowering : public TargetFrameLowering { protected: const ARMSubtarget &STI; public: explicit ARMFrameLowering(const ARMSubtarget &sti); /// emitProlog/emitEpilog - These methods insert prolog and epilog code into /// the function. void emitPrologue(MachineFunction &MF) const override; void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector<CalleeSavedInfo> &CSI, const TargetRegisterInfo *TRI) const override; bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector<CalleeSavedInfo> &CSI, const TargetRegisterInfo *TRI) const override; bool hasFP(const MachineFunction &MF) const override; bool hasReservedCallFrame(const MachineFunction &MF) const override; bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override; int getFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg) const override; int ResolveFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg, int SPAdj) const; int getFrameIndexOffset(const MachineFunction &MF, int FI) const override; void processFunctionBeforeCalleeSavedScan(MachineFunction &MF, RegScavenger *RS) const override; void adjustForSegmentedStacks(MachineFunction &MF) const override; private: void emitPushInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector<CalleeSavedInfo> &CSI, unsigned StmOpc, unsigned StrOpc, bool NoGap, bool(*Func)(unsigned, bool), unsigned NumAlignedDPRCS2Regs, unsigned MIFlags = 0) const; void emitPopInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector<CalleeSavedInfo> &CSI, unsigned LdmOpc, unsigned LdrOpc, bool isVarArg, bool NoGap, bool(*Func)(unsigned, bool), unsigned NumAlignedDPRCS2Regs) const; void eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override; }; } // End llvm namespace #endif
[ "orcun.gokbulut@zinek.xyz" ]
orcun.gokbulut@zinek.xyz
f890852eef4f6439203a779732e05a9197371554
7e2465414cdca35ea6b948392d1929da10db7427
/chapter_5_induction_and_recursion/5.4_recursive_algorithms/exercises/repo/solution_10.cpp
019b9765ee89ca34cfc085a3360c600d20037d69
[]
no_license
6guojun/discrete_mathematics_and_its_applications
244bcc0a033cc218a1ba88390c4ad957c66e939c
a41e905179f88b91b1402b515c01b09716db5142
refs/heads/master
2021-03-23T07:25:27.545525
2020-01-16T05:37:48
2020-01-16T05:37:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
913
cpp
/* Discrete Mathematics and Its Applications by Dr. Kenneth H. Rosen Chapter 5.4 Recursive Algorithms Solution 10 Rakesh Kumar, cpp.rakesh(at)gmail.com 17/07/2017 */ #include "common.h" #include <cstdio> #include <vector> int largest(const std::vector<int>& list, int n) { discrete_mathematics::Common<int> common; if (n == 0) return list[0]; else return common.max(list[n], largest(list, n - 1)); } inline void print(const std::vector<int>& list) { for (std::size_t i = 0; i < list.size(); ++i) printf("%d ", list[i]); printf("\n"); } void test() { discrete_mathematics::Common<int> common; std::vector<int> list; for (int i = 0; i < 10; ++i) list.push_back(common.random(1, 100)); print(list); printf("Largest element in the list == [%d]\n", largest(list, list.size() - 1)); } int main() { test(); return 0; }
[ "cpp.rakesh@gmail.com" ]
cpp.rakesh@gmail.com
cf9b6db226ac7351fa5115ae324bd00367adf3a7
a16da86a4b90cdae3963f6adc46315d7a9056cbb
/Source/UsefulFunctions.cpp
c2f7e0af679c42ce521b746da72bf915e43a3d66
[ "MIT", "Unlicense" ]
permissive
Project-3-UPC-DDV-BCN/Project3
0b18abfa21c97db1e036b4a20fa125e0243699d7
3fb345ce49485ccbc7d03fb320623df6114b210c
refs/heads/master
2021-07-15T10:55:35.559526
2018-10-19T14:35:14
2018-10-19T14:35:14
114,779,047
10
1
MIT
2018-04-23T21:26:45
2017-12-19T15:05:53
C++
UTF-8
C++
false
false
2,731
cpp
#include <ctype.h> #include "UsefulFunctions.h" #include <stdio.h> #include <cmath> #include <random> #include <limits> #include <stdlib.h> #include "Globals.h" #include "MathGeoLib\TransformOps.h" // Returns the angle between two points in degrees float AngleFromTwoPoints(float x1, float y1, float x2, float y2) { float deltaY = y2 - y1; float deltaX = x2 - x1; float angle = atan2(deltaY, deltaX) * RADTODEG; if (angle <= 180) return -angle; if (angle > 180) return angle / 2; } float NormalizeAngle(float angle) { if (angle > 360) { int multiplers = angle / 360; angle -= (360 * multiplers); } if (angle < -360) { int multiplers = abs(angle) / 360; angle += (360 * multiplers); } return angle; } float4x4 RotateArround(float4x4 to_rotate, float3 center, float angle_x, float angle_y, float angle_z) { float3 to_rotate_pos; Quat to_rotate_rot; float3 to_rotate_scal; to_rotate.Decompose(to_rotate_pos, to_rotate_rot, to_rotate_scal); float3 distance = to_rotate_pos - center; Quat X(to_rotate.WorldX(), angle_x * DEGTORAD); Quat Y(to_rotate.WorldY(), angle_y * DEGTORAD); Quat Z(to_rotate.WorldZ(), angle_z * DEGTORAD); distance = X.Transform(distance); distance = Y.Transform(distance); distance = Z.Transform(distance); float4x4 ret = to_rotate; ret[0][3] = distance.x + center.x; ret[1][3] = distance.y + center.y; ret[2][3] = distance.z + center.z; return ret; } float DistanceFromTwoPoints(float x1, float y1, float x2, float y2) { int distance_x = x2 - x1; int distance_y = y2 - y1; float sign = ((distance_x * distance_x) + (distance_y * distance_y)); float dist = abs((distance_x * distance_x) + (distance_y * distance_y)); if (sign > 0) return sqrt(dist); else return -sqrt(dist); } bool TextCmp(const char * text1, const char * text2) { bool ret = false; if (text1 == nullptr || text2 == nullptr) return false; if (strcmp(text1, text2) == 0) ret = true; return ret; } void TextCpy(char* destination, const char * origen) { if (origen != nullptr) { strcpy_s(destination, strlen(origen), origen); } } void Tokenize(std::string string, const char separator, std::list<std::string>& tokens) { int i = 0; const char* str = string.c_str(); while (*(str + i) != 0) { std::string temporal; while (*(str + i) != separator && *(str + i) && *(str + i) != '\n') { temporal.push_back(*(str + i)); i++; } tokens.push_back(temporal); if (*(str + i)) i++; } } std::string ToUpperCase(std::string str) { for (uint i = 0; i < str.size(); i++) { str[i] = toupper(str[i]); } return str; } std::string ToLowerCase(std::string str) { for (uint i = 0; i < str.size(); i++) { str[i] = tolower(str[i]); } return str; }
[ "gsunyercaldu@gmail.com" ]
gsunyercaldu@gmail.com
5130d1814aaf73c715a2ec5b6e53174696bbcf66
7ee8756eb4e1f10539b13b1fe4246bccc5d7416f
/tools/cgcomp/source/compiler.cpp
af1f5f87f0ab4b72d2499e83be80ea23f98fee29
[ "MIT" ]
permissive
andoma/PSL1GHT
dc0434d25c71ca38f7a278dc0d89fbc5c7490a5f
0fbf81fe13c19aa3f9cec62a0fc6a7b81f2ce758
refs/heads/master
2021-01-18T05:22:24.843892
2015-06-26T17:00:06
2015-06-26T17:00:06
1,261,063
4
5
null
null
null
null
UTF-8
C++
false
false
10,267
cpp
#include "types.h" #include "parser.h" #include "compiler.h" #define gen_op(o,t) \ ((NVFX_VP_INST_SLOT_##t<<7)|NVFX_VP_INST_##t##_OP_##o) #define arith(s,d,m,s0,s1,s2) \ nvfx_insn((s), 0, -1, (d), (m), (s0), (s1), (s2)) #define arith_ctor(ins,d,s0,s1,s2) \ nvfx_insn_ctor((ins), (d), (s0), (s1), (s2)) static INLINE s32 ffs(u32 u) { u32 i = 0; if(!(u&0xffffffff)) return 0; while(!(u&0x1)) { u >>= 1; i++; } return i + 1; } CCompiler::CCompiler() { m_nInputMask = 0; m_nOutputMask = 0; m_nInstructions = 0; m_nConsts = 0; m_rTemps = 0; m_nNumRegs = 1; m_rTempsDiscard = 0; m_pInstructions = NULL; m_pConstData = NULL; m_pCurInstruction = NULL; m_rTemp = NULL; m_rConst = NULL; } CCompiler::~CCompiler() { } void CCompiler::Prepare(CParser *pParser) { s32 high_const = -1,high_temp = -1; u32 i,j,nICount = pParser->GetInstructionCount(); struct nvfx_insn *insns = pParser->GetInstructions(); for(i=0;i<nICount;i++) { struct nvfx_insn *insn = &insns[i]; for(j=0;j<3;j++) { struct nvfx_src *src = &insn->src[j]; switch(src->reg.type) { case NVFXSR_TEMP: if((s32)src->reg.index>high_temp) high_temp = src->reg.index; break; case NVFXSR_CONST: if((s32)src->reg.index>high_const) high_const = src->reg.index; break; } } switch(insn->dst.type) { case NVFXSR_TEMP: if((s32)insn->dst.index>high_temp) high_temp = insn->dst.index; break; case NVFXSR_CONST: if((s32)insn->dst.index>high_const) high_const = insn->dst.index; break; } } if(++high_temp) { m_nNumRegs = high_temp; m_rTemp = (struct nvfx_reg*)calloc(high_temp,sizeof(struct nvfx_reg)); for(i=0;i<(u32)high_temp;i++) m_rTemp[i] = temp(); m_rTempsDiscard = 0; } if(++high_const) { m_rConst = (struct nvfx_reg*)calloc(high_const,sizeof(struct nvfx_reg)); for(i=0;i<(u32)high_const;i++) m_rConst[i] = constant(i,0.0f,0.0f,0.0f,0.0f); } } void CCompiler::Compile(CParser *pParser) { struct nvfx_src tmp; int i,nICount = pParser->GetInstructionCount(); struct nvfx_src none = nvfx_src(nvfx_reg(NVFXSR_NONE,0)); struct nvfx_insn tmp_insn,*insns = pParser->GetInstructions(); Prepare(pParser); for(i=0;i<nICount;i++) { struct nvfx_insn *insn = &insns[i]; switch(insn->op) { case OPCODE_ADD: emit_insn(gen_op(ADD,VEC),insn); break; case OPCODE_COS: emit_insn(gen_op(COS,SCA),insn); break; case OPCODE_DP3: emit_insn(gen_op(DP3,VEC),insn); break; case OPCODE_DP4: emit_insn(gen_op(DP4,VEC),insn); break; case OPCODE_POW: tmp = nvfx_src(temp()); tmp_insn = arith(0, tmp.reg, NVFX_VP_MASK_X, none, none, insn->src[0]); emit_insn(gen_op(LG2,SCA),&tmp_insn); tmp_insn = arith(0, tmp.reg, NVFX_VP_MASK_X, swz(tmp, X, X, X, X), insn->src[1], none); emit_insn(gen_op(MUL,VEC),&tmp_insn); tmp_insn = arith_ctor(insn, insn->dst, none, none, swz(tmp, X, X, X, X)); emit_insn(gen_op(EX2,SCA),&tmp_insn); break; case OPCODE_RSQ: emit_insn(gen_op(RSQ,SCA),insn); break; case OPCODE_MAD: emit_insn(gen_op(MAD,VEC),insn); break; case OPCODE_MAX: emit_insn(gen_op(MAX,VEC),insn); break; case OPCODE_MOV: emit_insn(gen_op(MOV,VEC),insn); break; case OPCODE_MUL: emit_insn(gen_op(MUL,VEC),insn); break; case OPCODE_END: if(m_nInstructions) m_pInstructions[m_nInstructions - 1].data[3] |= NVFX_VP_INST_LAST; else { tmp_insn = arith(0,none.reg,0,none,none,none); emit_insn(gen_op(NOP,VEC),&tmp_insn); m_pInstructions[m_nInstructions - 1].data[3] |= NVFX_VP_INST_LAST; } break; } release_temps(); } } void CCompiler::emit_insn(u8 opcode,struct nvfx_insn *insn) { u32 *hw; u32 slot = opcode>>7; u32 op = opcode&0x7f; m_pInstructions = (struct vertex_program_exec*)realloc(m_pInstructions,++m_nInstructions*sizeof(struct vertex_program_exec)); m_pCurInstruction = &m_pInstructions[m_nInstructions - 1]; memset(m_pCurInstruction,0,sizeof(struct vertex_program_exec)); hw = m_pCurInstruction->data; emit_dst(hw,slot,insn); emit_src(hw,0,&insn->src[0]); emit_src(hw,1,&insn->src[1]); emit_src(hw,2,&insn->src[2]); hw[0] |= (insn->cc_cond << NVFX_VP(INST_COND_SHIFT)); hw[0] |= (insn->cc_test << NVFX_VP(INST_COND_TEST_SHIFT)); hw[0] |= (insn->cc_test_reg << NVFX_VP(INST_COND_REG_SELECT_SHIFT)); hw[0] |= ((insn->cc_swz[0] << NVFX_VP(INST_COND_SWZ_X_SHIFT)) | (insn->cc_swz[1] << NVFX_VP(INST_COND_SWZ_Y_SHIFT)) | (insn->cc_swz[2] << NVFX_VP(INST_COND_SWZ_Z_SHIFT)) | (insn->cc_swz[3] << NVFX_VP(INST_COND_SWZ_W_SHIFT))); if(insn->cc_update) hw[0] |= NVFX_VP(INST_COND_UPDATE_ENABLE); if(insn->sat) { hw[0] |= NV40_VP_INST_SATURATE; } if (slot == 0) { hw[1] |= (op << NV40_VP_INST_VEC_OPCODE_SHIFT); hw[3] |= NV40_VP_INST_SCA_DEST_TEMP_MASK; hw[3] |= (insn->mask << NV40_VP_INST_VEC_WRITEMASK_SHIFT); } else { hw[1] |= (op << NV40_VP_INST_SCA_OPCODE_SHIFT); hw[0] |= NV40_VP_INST_VEC_DEST_TEMP_MASK ; hw[3] |= (insn->mask << NV40_VP_INST_SCA_WRITEMASK_SHIFT); } } void CCompiler::emit_dst(u32 *hw,u8 slot,struct nvfx_insn *insn) { struct nvfx_reg *dst = &insn->dst; switch(dst->type) { case NVFXSR_NONE: hw[3] |= NV40_VP_INST_DEST_MASK; if(slot==0) hw[0] |= NV40_VP_INST_VEC_DEST_TEMP_MASK; else hw[3] |= NV40_VP_INST_SCA_DEST_TEMP_MASK; break; case NVFXSR_TEMP: hw[3] |= NV40_VP_INST_DEST_MASK; if (slot == 0) hw[0] |= (dst->index << NV40_VP_INST_VEC_DEST_TEMP_SHIFT); else hw[3] |= (dst->index << NV40_VP_INST_SCA_DEST_TEMP_SHIFT); break; case NVFXSR_OUTPUT: switch (dst->index) { case NV30_VP_INST_DEST_CLP(0): dst->index = NVFX_VP(INST_DEST_FOGC); insn->mask = NVFX_VP_MASK_Y; m_nOutputMask |= (1 << 6); break; case NV30_VP_INST_DEST_CLP(1): dst->index = NVFX_VP(INST_DEST_FOGC); insn->mask = NVFX_VP_MASK_Z; m_nOutputMask |= (1 << 7); break; case NV30_VP_INST_DEST_CLP(2): dst->index = NVFX_VP(INST_DEST_FOGC); insn->mask = NVFX_VP_MASK_W; m_nOutputMask |= (1 << 8); break; case NV30_VP_INST_DEST_CLP(3): dst->index = NVFX_VP(INST_DEST_PSZ); insn->mask = NVFX_VP_MASK_Y; m_nOutputMask |= (1 << 9); break; case NV30_VP_INST_DEST_CLP(4): dst->index = NVFX_VP(INST_DEST_PSZ); insn->mask = NVFX_VP_MASK_Z; m_nOutputMask |= (1 << 10); break; case NV30_VP_INST_DEST_CLP(5): dst->index = NVFX_VP(INST_DEST_PSZ); insn->mask = NVFX_VP_MASK_W; m_nOutputMask |= (1 << 11); break; case NV40_VP_INST_DEST_COL0 : m_nOutputMask |= (1 << 0); break; case NV40_VP_INST_DEST_COL1 : m_nOutputMask |= (1 << 1); break; case NV40_VP_INST_DEST_BFC0 : m_nOutputMask |= (1 << 2); break; case NV40_VP_INST_DEST_BFC1 : m_nOutputMask |= (1 << 3); break; case NV40_VP_INST_DEST_FOGC : m_nOutputMask |= (1 << 4); break; case NV40_VP_INST_DEST_PSZ : m_nOutputMask |= (1 << 5); break; default: if(dst->index>=NV40_VP_INST_DEST_TC(0) && dst->index<=NV40_VP_INST_DEST_TC(7)) m_nOutputMask |= (1<<(dst->index - NV40_VP_INST_DEST_TC0 + 14)); break; } hw[3] |= (dst->index << NV40_VP_INST_DEST_SHIFT); if (slot == 0) { hw[0] |= NV40_VP_INST_VEC_RESULT; hw[0] |= NV40_VP_INST_VEC_DEST_TEMP_MASK; } else { hw[3] |= NV40_VP_INST_SCA_RESULT; hw[3] |= NV40_VP_INST_SCA_DEST_TEMP_MASK; } break; } } void CCompiler::emit_src(u32 *hw, u8 pos, struct nvfx_src *src) { u32 sr = 0; struct nvfx_relocation reloc; switch(src->reg.type) { case NVFXSR_TEMP: sr |= (NVFX_VP(SRC_REG_TYPE_TEMP) << NVFX_VP(SRC_REG_TYPE_SHIFT)); sr |= (src->reg.index << NVFX_VP(SRC_TEMP_SRC_SHIFT)); break; case NVFXSR_INPUT: sr |= (NVFX_VP(SRC_REG_TYPE_INPUT) << NVFX_VP(SRC_REG_TYPE_SHIFT)); m_nInputMask |= (1 << src->reg.index); hw[1] |= (src->reg.index << NVFX_VP(INST_INPUT_SRC_SHIFT)); break; case NVFXSR_CONST: sr |= (NVFX_VP(SRC_REG_TYPE_CONST) << NVFX_VP(SRC_REG_TYPE_SHIFT)); reloc.location = m_nInstructions - 1; reloc.target = src->reg.index; m_lConstRelocation.push_back(reloc); break; case NVFXSR_NONE: sr |= (NVFX_VP(SRC_REG_TYPE_INPUT) << NVFX_VP(SRC_REG_TYPE_SHIFT)); break; } if (src->negate) sr |= NVFX_VP(SRC_NEGATE); if (src->abs) hw[0] |= (1 << (21 + pos)); sr |= ((src->swz[0] << NVFX_VP(SRC_SWZ_X_SHIFT)) | (src->swz[1] << NVFX_VP(SRC_SWZ_Y_SHIFT)) | (src->swz[2] << NVFX_VP(SRC_SWZ_Z_SHIFT)) | (src->swz[3] << NVFX_VP(SRC_SWZ_W_SHIFT))); if(src->indirect) { if(src->reg.type == NVFXSR_CONST) hw[3] |= NVFX_VP(INST_INDEX_CONST); else if(src->reg.type == NVFXSR_INPUT) hw[0] |= NVFX_VP(INST_INDEX_INPUT); if(src->indirect_reg) hw[0] |= NVFX_VP(INST_ADDR_REG_SELECT_1); hw[0] |= src->indirect_swz << NVFX_VP(INST_ADDR_SWZ_SHIFT); } switch (pos) { case 0: hw[1] |= (((sr & NVFX_VP(SRC0_HIGH_MASK)) >> NVFX_VP(SRC0_HIGH_SHIFT)) << NVFX_VP(INST_SRC0H_SHIFT)); hw[2] |= ((sr & NVFX_VP(SRC0_LOW_MASK)) << NVFX_VP(INST_SRC0L_SHIFT)); break; case 1: hw[2] |= (sr << NVFX_VP(INST_SRC1_SHIFT)); break; case 2: hw[2] |= (((sr & NVFX_VP(SRC2_HIGH_MASK)) >> NVFX_VP(SRC2_HIGH_SHIFT)) << NVFX_VP(INST_SRC2H_SHIFT)); hw[3] |= ((sr & NVFX_VP(SRC2_LOW_MASK)) << NVFX_VP(INST_SRC2L_SHIFT)); break; } } struct nvfx_reg CCompiler::temp() { s32 idx = ffs(~m_rTemps) - 1; if(idx<0) return nvfx_reg(NVFXSR_NONE,0); m_rTemps |= (1<<idx); m_rTempsDiscard |= (1<<idx); if((s32)m_nNumRegs<idx) m_nNumRegs = idx; return nvfx_reg(NVFXSR_TEMP,idx); } void CCompiler::release_temps() { m_rTemps &= ~m_rTempsDiscard; m_rTempsDiscard = 0; } struct nvfx_reg CCompiler::constant(s32 pipe, f32 x, f32 y, f32 z, f32 w) { int idx; struct vertex_program_data *vpd; if(pipe>=0) { for(idx=0;idx<m_nConsts;idx++) { if(m_pConstData[idx].index==pipe) return nvfx_reg(NVFXSR_CONST,idx); } } idx = m_nConsts++; m_pConstData = (struct vertex_program_data*)realloc(m_pConstData,sizeof(struct vertex_program_data)*m_nConsts); vpd = &m_pConstData[idx]; vpd->index = pipe; vpd->value[0] = x; vpd->value[1] = y; vpd->value[2] = z; vpd->value[3] = w; return nvfx_reg(NVFXSR_CONST,idx); }
[ "shagkur@gmx.net" ]
shagkur@gmx.net
b63c02aab9a03a9d47f2c6241ed62216d796b8e7
eb663d5c73c9d74f0b5de618cdb0579587e86928
/test/src/Parameters_test.cpp
d4a673fef6ded3bc6aebdc99d266959f17560d47
[ "MIT" ]
permissive
andrsd/godzilla
e849bf5b66966d017437a2af5cf0dcc11cf543f9
296a10b39603a22a54053b009b3cb1c0b24d2008
refs/heads/main
2023-09-03T20:23:06.445778
2023-08-30T20:23:37
2023-08-30T20:23:37
123,453,473
5
0
MIT
2023-09-06T18:36:27
2018-03-01T15:27:17
C++
UTF-8
C++
false
false
2,158
cpp
#include "gtest/gtest.h" #include "Types.h" #include "Parameters.h" #include "Factory.h" using namespace godzilla; TEST(ParametersTest, get) { Parameters params = Object::parameters(); EXPECT_DEATH(params.get<int>("i"), "No parameter 'i' found."); } TEST(ParametersTest, param_value) { Parameters params; params.add_param<Real>("param", 12.34, "doco"); EXPECT_EQ(params.get<Real>("param"), 12.34); EXPECT_EQ(params.get_doc_string("param"), std::string("doco")); } TEST(ParametersTest, has_value) { Parameters params; params.add_param<Real>("param", 12.34, "doco"); EXPECT_EQ(params.has<Real>("param"), true); params.clear(); EXPECT_EQ(params.has<Real>("param"), false); } TEST(ParametersTest, assign) { Parameters params1; params1.add_param<Real>("param", 12.34, "doco"); Parameters params2 = params1; EXPECT_EQ(params2.has<Real>("param"), true); EXPECT_EQ(params2.get<Real>("param"), 12.34); EXPECT_EQ(params2.get_doc_string("param"), std::string("doco")); } TEST(ParametersTest, add_params) { Parameters params1; params1.add_param<Real>("p1", 12.34, "doco1"); Parameters params2; params1.add_param<Real>("p2", "doco2"); params1 += params2; EXPECT_EQ(params1.has<Real>("p1"), true); EXPECT_EQ(params1.get<Real>("p1"), 12.34); EXPECT_EQ(params1.get_doc_string("p1"), std::string("doco1")); EXPECT_EQ(params1.has<Real>("p2"), true); EXPECT_EQ(params1.get_doc_string("p2"), std::string("doco2")); } Parameters validParams1() { Parameters params; params.add_param<Real>("p", 78.56, "doco p"); return params; } TEST(ParametersTest, valid_params) { Parameters params1 = validParams1(); EXPECT_EQ(params1.get<Real>("p"), 78.56); EXPECT_EQ(params1.get_doc_string("p"), std::string("doco p")); } TEST(ParametersTest, empty_doc_str) { Parameters params = Object::parameters(); EXPECT_EQ(params.get_doc_string("i"), std::string("")); } TEST(ParametersTest, set_non_existing_param) { Parameters params = Object::parameters(); params.set<double>("d") = 1.23; EXPECT_EQ(params.get<double>("d"), 1.23); }
[ "andrsd@gmail.com" ]
andrsd@gmail.com
9115e56182268e51acf00edde09302b60a040fde
fd68135d1b76ea5233faf068bfeae623c6777825
/COMP051/LAB06/main.cpp
920a2d83ad03214a69e31717577e3645c9a27584
[]
no_license
Ambamore2000/UOP-COMP
bb1d226b969541739187803d475a57a7251993f9
5458bec19368695ac1fd072f8bef8ec1e2f91968
refs/heads/master
2021-01-03T17:23:10.517877
2020-04-24T16:45:10
2020-04-24T16:45:10
240,166,716
0
0
null
null
null
null
UTF-8
C++
false
false
1,072
cpp
#include <iostream> using namespace std; void find (char d[], int size, char c) { bool foundPosition = false; for (int x = 0; x < size; x++) { if (c == d[x]) { cout << "Found " << c << " at position " << x << "." << endl; foundPosition = true; } } if (!foundPosition) cout << "Character Array does NOT contain '" << c << "'!" << endl; } int main() { //#1 char letters[8]; //#2 for (int x = 0; x < sizeof(letters); x++) { cout << "Please enter letter #" << x << ": "; cin >> letters[x]; } //#3 cout << endl << "The word is "; for (int x = 0; x < sizeof(letters); x++) { cout << letters[x]; } //#4 cout << endl << "The word backwards is "; for (int x = sizeof(letters) - 1; x >= 0; x--) { cout << letters[x]; } //#b char searchChar; cout << endl << "What letter would you like to search for? "; cin >> searchChar; find(letters, sizeof(letters), searchChar); system("PAUSE"); return 0; }
[ "Andkim123@gmail.com" ]
Andkim123@gmail.com
5f319b5adec2517a82f2cfa97d6f0aeaed42ecfc
920177e9f2236c612aa406a0949accdfb1294104
/tools/pacotes/Inline-0.50/C/_Inline_test/lib/auto/_01syntax_t_5b3f/_01syntax_t_5b3f.inl
b852607dcedb598405d01e55a9036d7a9e4444d9
[]
no_license
franciellevargas/NewsCrawler
76dec8d426317d090bd618dd4d1deac8549b2343
6042648b28067338b3d7c15a23288c870b69b6b9
refs/heads/master
2022-05-01T07:58:57.938173
2016-11-06T03:03:18
2016-11-06T03:03:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
593
inl
md5 : 5b3f02a5689473a9f4268428bfe0f3cd name : _01syntax_t_5b3f version : "" language : C language_id : C installed : 0 date_compiled : Fri Jan 17 00:15:29 2014 inline_version : 0.5 ILSM : % module : Inline::C suffix : so type : compiled Config : % apiversion : ? archname : i686-linux-gnu-thread-multi-64int cc : cc ccflags : -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 ld : cc osname : linux osvers : 3.2.0-37-generic so : so version : 5.14.2
[ "erick@EricksComputer.local" ]
erick@EricksComputer.local
0a8cf629b423b5fb91e4a0d566740fed2a2aeca5
22d5d10c1f67efe97b8854760b7934d8e16d269b
/LeetCodeCPP/283. Move Zeroes/main.cpp
0d7db037d5f4149a4afd8f62fc20c6267ab70a22
[ "Apache-2.0" ]
permissive
18600130137/leetcode
42241ece7fce1536255d427a87897015b26fd16d
fd2dc72c0b85da50269732f0fcf91326c4787d3a
refs/heads/master
2020-04-24T01:48:03.049019
2019-10-17T06:02:57
2019-10-17T06:02:57
171,612,908
1
0
null
null
null
null
UTF-8
C++
false
false
1,400
cpp
// // main.cpp // 283. Move Zeroes // // Created by admin on 2019/7/5. // Copyright © 2019年 liu. All rights reserved. // #include <iostream> #include <vector> using namespace std; class Solution { public: void moveZeroes2(vector<int>& nums) { int m=nums.size(); int i=m-1; while(i>=0 && nums[i]==0){ i--; } for(;i>=0;i--){ if(nums[i]==0){ nums.erase(nums.begin()+i); nums.push_back(0); } } } void moveZeroes1(vector<int>& nums) { int m=nums.size(); int count0=0; for(int i=0;i<m;i++){ if(nums[i]==0){ count0++; } } nums.erase(remove(nums.begin(),nums.end(),0),nums.end()); for(int i=0;i<count0;i++){ nums.push_back(0); } } void moveZeroes(vector<int>& nums) { int m=nums.size(); int insertPos=0; for(int i=0;i<m;i++){ if(nums[i]!=0){ nums[insertPos++]=nums[i]; } } while(insertPos<m){ nums[insertPos++]=0; } } }; int main(int argc, const char * argv[]) { vector<int> input={0,1,0,3,12}; Solution so=Solution(); so.moveZeroes(input); for(auto i:input){ cout<<i<<" "; } cout<<endl; return 0; }
[ "guodongliu6@crediteses.cn" ]
guodongliu6@crediteses.cn
a717cabb75c5a5d9671f11a523b565710362ad6e
1bbfeca83bac53d22b1110ca7f6c9a28bc46c22e
/ru-olymp-train-winter-2007/Submits/070119p/18_42_20_08_B_6120.CPP
c5bc5a8ed0127c6fd96630c371291b1bc2527189
[]
no_license
stden/olymp
a633c1dfb1dd8d184a123d6da89f46163d5fad93
d85a4bb0b88797ec878b64db86ad8ec8854a63cd
refs/heads/master
2016-09-06T06:30:56.466755
2013-07-13T08:48:16
2013-07-13T08:48:16
5,158,472
1
0
null
null
null
null
UTF-8
C++
false
false
2,408
cpp
#include <algorithm> #include <cstdio> #include <cstdlib> #include <set> #include <utility> #include <vector> using namespace std; #define PB push_back #define MP make_pair #define FI first #define SE second #define maxn 125010 int N, X1[maxn], Y1[maxn], X2[maxn], Y2[maxn]; pair <int, int> Time; int Sign( long long X ) { return X > 0 ? 1 : X < 0 ? -1 : 0; } void Try( int i, int j ) { long long A1 = Y1[i] - Y2[i]; long long B1 = X2[i] - X1[i]; long long C1 = -(A1 * X1[i] + B1 * Y1[i]); long long A2 = Y1[j] - Y2[j]; long long B2 = X2[j] - X1[j]; long long C2 = -(A1 * X1[j] + B1 * Y1[j]); if (Sign(A1 * X1[j] + B1 * Y1[j] + C1) * Sign(A1 * X1[j] + B1 * Y2[j] + C1) <= 0 && Sign(A2 * X1[i] + B2 * Y1[i] + C2) * Sign(A2 * X1[i] + B2 * Y2[i] + C2) <= 0) { printf("YES\n"); printf("%d %d\n", i + 1, j + 1); exit(0); } } bool Func( int i, int j ) { double y1, y2; if (X1[i] != X2[i]) y1 = X1[i] + 1.0 * (Time.FI - X1[i]) * (Y2[i] - Y1[i]) / (X2[i] - X1[i]); else y1 = Y1[i]; if (X1[j] != X2[j]) y2 = X1[j] + 1.0 * (Time.FI - X1[j]) * (Y2[j] - Y1[j]) / (X2[j] - X1[j]); else y2 = Y1[j]; return y1 > y2; } class CCL { public: int i; CCL( int a ) { i = a; } }; bool operator < ( CCL i, CCL j ) { return Func(i.i, j.i); } int main( void ) { freopen("segments.in", "rt", stdin); freopen("segments.out", "wt", stdout); vector <pair<pair<int, int>, pair<int, int> > > Event; scanf("%d", &N); for (int i = 0; i < N; i++) { scanf("%d%d%d%d", &X1[i], &Y1[i], &X2[i], &Y2[i]); if (X1[i] > X2[i] || X1[i] == X2[i] && Y1[i] > Y2[i]) swap(X1[i], X2[i]), swap(Y1[i], Y2[i]); Event.PB(MP(MP(X1[i], Y1[i]), MP(-1, i))); Event.PB(MP(MP(X2[i], Y2[i]), MP(+1, i))); } sort(Event.begin(), Event.end()); set <CCL> Set; for (int i = 0; i < Event.size(); i++) { Time = Event[i].FI; if (Event[i].SE.FI == -1) Set.insert(CCL(Event[i].SE.SE)); else { set <CCL> :: iterator T = Set.find(CCL(Event[i].SE.SE)), T1 = T, T2 = T; int P1 = -1, P2 = -1; if (T1 != Set.begin()) P1 = (--T1)->i; if (++T2 != Set.end()) P2 = T2->i; if (P1 != -1) Try(P1, T->i); if (P2 != -1) Try(T->i, P2); if (P1 != -1 && P2 != -1) Try(P1, P2); Set.erase(T); } } printf("NO\n"); return 0; }
[ "super.denis@gmail.com" ]
super.denis@gmail.com
b6c10e1a1fdad05d30f01d51be9549200ef26d66
14da2a5b65d7d188b9ccbd18238ac02588df70be
/POJ3255.cpp
fd676652cb4bae8bd2dd69c0733bbc9529988c62
[]
no_license
sgc109/algorithm_practice
754f378634c68a29577abffb8371e58ac0433345
19fa107892754b227f8592aa9b6ae7fad175728e
refs/heads/master
2020-03-17T21:39:58.570520
2018-05-23T20:06:44
2018-05-23T20:06:44
133,968,628
0
0
null
null
null
null
UTF-8
C++
false
false
1,567
cpp
// #include <bits/stdc++.h> #include <set> #include <map> #include <cmath> #include <stack> #include <queue> #include <cstdio> #include <vector> #include <cstring> #include <utility> #include <iostream> #include <algorithm> #define pb push_back #define sz(v) ((int)(v).size()) #define all(v) (v).begin(), (v).end() using namespace std; typedef long long ll; const int mod = 1e9+7; const int inf = 0x3c3c3c3c; const long long infl = 0x3c3c3c3c3c3c3c3c; vector<int> dist[5003]; int V, E; vector<pair<int,int> > G[5003]; priority_queue<pair<int,int> > pq; int push(int node, int d){ for(int i = 0 ; i < sz(dist[node]); i++) if(dist[node][i] == d) return 0; if(sz(dist[node]) == 2 && dist[node][1] < d) return 0; dist[node].pb(d); sort(all(dist[node])); dist[node] = vector<int>(dist[node].begin(), dist[node].begin() + min(sz(dist[node]), 2)); return 1; } void dijkstra(int s, int e){ dist[s].pb(0); pq.push(make_pair(0, s)); while(!pq.empty()){ pair<int,int> p = pq.top(); pq.pop(); int curD = -p.first; int cur = p.second; if(dist[cur].back() < curD) continue; for(int i = 0 ; i < sz(G[cur]); i++){ pair<int,int> pp = G[cur][i]; int next = pp.first; int cost = curD + pp.second; if(!push(next, cost)) continue; pq.push(make_pair(-cost, next)); } } } int main() { scanf("%d %d", &V, &E); while(E--){ int a, b, c; scanf("%d %d %d", &a, &b, &c); G[a].pb(make_pair(b, c)); G[b].pb(make_pair(a, c)); } dijkstra(1, V); printf("%d", dist[V][1]); return 0; }
[ "sgc109@LAPTOP-KBAMD1MP.localdomain" ]
sgc109@LAPTOP-KBAMD1MP.localdomain
67d4b9692e929bf7f0fe380cc848438a30948ce1
d6720f9cb13c0233b76bc8a81717a83b40ae9830
/open/eMule/eMule/src/SharedFilesCtrl.h
867b39cdc4413bc8b4aae5777b0a5d0257be8f53
[]
no_license
EchoLiao/nalstudy
e4565aadf80ff70388225c4c92eb9bb22d85f384
869288a16e540520cadc28c82702e52f1c8396ac
refs/heads/master
2016-09-05T12:38:06.721690
2013-06-05T08:47:01
2013-06-05T08:47:01
33,391,633
0
0
null
null
null
null
GB18030
C++
false
false
3,098
h
//this file is part of eMule //Copyright (C)2002-2006 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / http://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License //as published by the Free Software Foundation; either //version 2 of the License, or (at your option) any later version. // //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. // //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #pragma once #include "MuleListCtrl.h" #include "TitleMenu.h" #include "ListCtrlItemWalk.h" #include "JavaScriptEscape.h" //Added by thilon on 206.08.28, 在线杀毒 class CSharedFileList; class CKnownFile; class CShareableFile; class CDirectoryItem; class CSharedFilesCtrl : public CMuleListCtrl, public CListCtrlItemWalk { friend class CSharedDirsTreeCtrl; DECLARE_DYNAMIC(CSharedFilesCtrl) public: CSharedFilesCtrl(); virtual ~CSharedFilesCtrl(); void Init(); void CreateMenues(); void ReloadFileList(); void AddFile(const CShareableFile* file); void RemoveFile(const CShareableFile* file, bool bDeletedFromDisk); void UpdateFile(const CShareableFile* file, bool bUpdateFileSummary = true); void Localize(); void ShowFilesCount(); void ShowComments(CShareableFile* file); void SetAICHHashing(uint32 nVal) { nAICHHashing = nVal; } void SetDirectoryFilter(CDirectoryItem* pNewFilter, bool bRefresh = true); protected: CTitleMenu m_SharedFilesMenu; CTitleMenu m_CollectionsMenu; CMenu m_PrioMenu; bool sortstat[4]; CImageList m_ImageList; CDirectoryItem* m_pDirectoryFilter; volatile uint32 nAICHHashing; JavaScriptEscape m_JavaScriptEscape; static int CALLBACK SortProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort); void OpenFile(const CShareableFile* file); void ShowFileDialog(CTypedPtrList<CPtrList, CShareableFile*>& aFiles, UINT uPshInvokePage = 0); void SetAllIcons(); int FindFile(const CShareableFile* pFile); virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); DECLARE_MESSAGE_MAP() afx_msg void OnSysColorChange(); afx_msg void OnColumnClick( NMHDR* pNMHDR, LRESULT* pResult); afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); afx_msg void OnNMDblclk(NMHDR *pNMHDR, LRESULT *pResult); afx_msg void OnGetDispInfo(NMHDR *pNMHDR, LRESULT *pResult); afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); //VeryCD Start //共享文件列表中的评论,added by Chocobo on 2006.09.01 afx_msg void OnCommentClick(NMHDR *pNMHDR, LRESULT *pResult); public: afx_msg void OnMouseMove(UINT nFlags, CPoint point); //VeryCD End };
[ "nuoerlz@da13e6bb-9c2c-a04c-5f4c-2d7d41371f5f" ]
nuoerlz@da13e6bb-9c2c-a04c-5f4c-2d7d41371f5f
617f5a2954bbdd65ab617dd645eb53f7d306ea36
e363b63383c617acc55c5b43bd0fa524d9e64dff
/game/client/swarm/asw_client_entities.cpp
03159252021e5c19ee06b70c2036b5a1936d67e7
[]
no_license
paralin/hl2sdk-dota
63a17b641e2cc9d6d030df9244c03d60e013737d
e0fe36f0132b36ba9b1ca56aa10f888f66e9b2bf
refs/heads/master
2016-09-09T22:37:57.509357
2014-04-09T13:26:01
2014-04-09T13:26:01
18,719,255
4
2
null
null
null
null
WINDOWS-1252
C++
false
false
950
cpp
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======// // // Purpose : Singleton manager for color correction on the client // // $NoKeywords: $ //===========================================================================// #include "cbase.h" #include "tier0/vprof.h" #include "asw_client_entities.h" #include "c_asw_camera_volume.h" #include "c_asw_snow_volume.h" #include "c_asw_scanner_noise.h" static CASW_Client_Entities s_ASW_Client_Entities; CASW_Client_Entities::CASW_Client_Entities() { } void CASW_Client_Entities::LevelInitPostEntity() { //C_ASW_Camera_Volume::RecreateAll(); C_ASW_Snow_Volume::RecreateAll(); //C_Sprite::RecreateAll(); C_ASW_Scanner_Noise::RecreateAll(); } void CASW_Client_Entities::LevelShutdownPreEntity() { //C_ASW_Camera_Volume::DestroyAll(); C_ASW_Snow_Volume::DestroyAll(); //C_Sprite::DestroyAll(); C_ASW_Scanner_Noise::DestroyAll(); }
[ "ds@alliedmods.net" ]
ds@alliedmods.net
5f7abd13c1a5fb2fcc866f0face73a387b338567
23d30f6b1de52e23730735b2dc79bb8b0f6bc74d
/tests/cpp/data/test_gradient_index_page_raw_format.cc
fa1a10faa8293a4055418fe36515e0525ac408b7
[ "Apache-2.0" ]
permissive
rapidsai/xgboost
d66ae03418ae61511a27b060956831d836e12df7
f5bf7ad4b5b06449e93500d98f41f0c9793db065
refs/heads/branch-23.02
2023-05-25T01:26:38.483612
2022-12-07T21:26:58
2022-12-07T21:26:58
156,279,925
30
18
Apache-2.0
2023-04-19T18:53:15
2018-11-05T20:39:47
C++
UTF-8
C++
false
false
1,708
cc
/*! * Copyright 2021 XGBoost contributors */ #include <gtest/gtest.h> #include "../../../src/common/column_matrix.h" #include "../../../src/data/gradient_index.h" #include "../../../src/data/sparse_page_source.h" #include "../helpers.h" namespace xgboost { namespace data { TEST(GHistIndexPageRawFormat, IO) { std::unique_ptr<SparsePageFormat<GHistIndexMatrix>> format{ CreatePageFormat<GHistIndexMatrix>("raw")}; auto m = RandomDataGenerator{100, 14, 0.5}.GenerateDMatrix(); dmlc::TemporaryDirectory tmpdir; std::string path = tmpdir.path + "/ghistindex.page"; auto batch = BatchParam{256, 0.5}; { std::unique_ptr<dmlc::Stream> fo{dmlc::Stream::Create(path.c_str(), "w")}; for (auto const &index : m->GetBatches<GHistIndexMatrix>(batch)) { format->Write(index, fo.get()); } } GHistIndexMatrix page; std::unique_ptr<dmlc::SeekStream> fi{dmlc::SeekStream::CreateForRead(path.c_str())}; format->Read(&page, fi.get()); for (auto const &gidx : m->GetBatches<GHistIndexMatrix>(batch)) { auto const &loaded = gidx; ASSERT_EQ(loaded.cut.Ptrs(), page.cut.Ptrs()); ASSERT_EQ(loaded.cut.MinValues(), page.cut.MinValues()); ASSERT_EQ(loaded.cut.Values(), page.cut.Values()); ASSERT_EQ(loaded.base_rowid, page.base_rowid); ASSERT_EQ(loaded.IsDense(), page.IsDense()); ASSERT_TRUE(std::equal(loaded.index.begin(), loaded.index.end(), page.index.begin())); ASSERT_TRUE(std::equal(loaded.index.Offset(), loaded.index.Offset() + loaded.index.OffsetSize(), page.index.Offset())); ASSERT_EQ(loaded.Transpose().GetTypeSize(), loaded.Transpose().GetTypeSize()); } } } // namespace data } // namespace xgboost
[ "noreply@github.com" ]
rapidsai.noreply@github.com
9d51be50491d58849dd72b38789d470293d13d74
c2a55f3b93300b99181a5aa29b2dfad2f2de701e
/Neural Network/src/facedetection.cpp
f75b252f3464fbd2de3c98e90ea2194b777ee4f4
[]
no_license
someideal/smartshoot
26c4c35f836919121ec907e8f27772a7226a0068
a83af09cd640ab58f98b5781918cb9afb751f764
refs/heads/master
2020-05-17T05:38:10.277125
2015-01-20T12:07:24
2015-01-20T12:07:24
25,111,221
0
0
null
null
null
null
UTF-8
C++
false
false
2,749
cpp
#include "../include/facedetection.h" using namespace cv; Mat facedetection::getFace(int index) { if(index>=0 &&index <catchedNum) {return reSize(_img_grey(faceRect[index]));} else{ return porkerFace; } } DETECT_RESULT facedetection::run(Mat *input,Mat *output) { vector<Rect> faceRectLocal; if (input==NULL ) { if(!input->data) { return ERROR;} return ERROR; } switch(mode){ case SUSPEND_MODE: return ERROR; case IMG_MODE: break; case VIDEO_MODE:break; default: ; } cvtColor(*input,_img_grey,CV_RGB2GRAY); equalizeHist(_img_grey,_img_grey); /* imshow("face",_img_grey); waitKey(0);//*/ //double scaleFactor=1.1;int minNeighbors=3;int flags=0; if(faceCascade.empty()){ return ERROR; } Size minSize(30,30) ;Size maxSize(3,3); // faceCascade.detectMultiScale(_img_grey,faceRectLocal, 1.1, 2, 0 |CASCADE_SCALE_IMAGE,Size(0, 0) ,Size(1, 1) ,); faceCascade.detectMultiScale(_img_grey,faceRectLocal, 1.1, 2, 0 |CASCADE_SCALE_IMAGE ,minSize); //|CASCADE_FIND_BIGGEST_OBJECT //|CASCADE_DO_ROUGH_SEARCH faceRect = faceRectLocal; catchedNum=faceRect.size(); if(catchedNum != 0 ) { if(output!=NULL) { *output=reSize(_img_grey(faceRect[0]),125); } return CATCHED; } else{ return NONE; } } Mat facedetection::reSize(Mat img,size_t sz) { Mat output; if(img.data && sz >0 && sz<=2048){ resize( img, output, Size(sz, sz), 0, 0, INTER_LINEAR); return output; }else{ return porkerFace; } } facedetection::facedetection() { catchedNum=0; cascadeFacePath="/root/downloads/opencv-3.0.0-beta/data/haarcascades/haarcascade_frontalface_alt.xml"; mode=SUSPEND_MODE; init(); } facedetection::~facedetection() { } bool facedetection::init() { if(!faceCascade.load(cascadeFacePath)){ mode=SUSPEND_MODE; return false; } else{ mode=IMG_MODE; return true; } }
[ "anywriting@163.com" ]
anywriting@163.com
7f66f3905b062167952f1d32c9138f0f2ffdd969
536c3a571b3056b71fa7156d0a2237b9332317ac
/source/PKB.cpp
daaf35571d25778b13cacc880e8a856dc0599e82
[]
no_license
CS3201-2/EmptyGeneralTesting
896f4f291eeae8fffa26648e0d592bc8c605ba65
3cdb8de54dc324d22fa8cf118d1b7f2b97d85a55
refs/heads/master
2016-09-06T08:15:26.731713
2015-09-18T14:11:07
2015-09-18T14:11:07
42,574,020
0
0
null
null
null
null
UTF-8
C++
false
false
1,024
cpp
#include "PKB.h" #include "AST.h" #include "Modifies.h" #include "Uses.h" #include "ProcTable.h" #include "VarTable.h" #include <string> #include <list> using namespace std; PKB::PKB() { } ProcTable& PKB::getProcTable(void) { return procTable; } VarTable& PKB::getVarTable(void) { return varTable; } Modifies& PKB::getModifies(void) { return modifies; } Uses& PKB::getUses(void) { return uses; } Follows& PKB::getFollows(void) { return follows; } Parent& PKB::getParent(void) { return parent; } AST& PKB::getAST(void) { return ast; } void PKB::addWhileList(int stmtLine) { if (find(whileList.begin(), whileList.end(), stmtLine) == whileList.end()) { whileList.push_back(stmtLine); } } void PKB::addAssignList(int stmtLine) { if (find(assignList.begin(), assignList.end(), stmtLine) == assignList.end()) { assignList.push_back(stmtLine); } } list<int> PKB::getWhileList(void) { return whileList; } list<int> PKB::getAssignList(void) { return assignList; } void PKB::setAST(AST a) { ast = a; }
[ "manika615@gmail.com" ]
manika615@gmail.com
de141e4638135bf0ab6be20b781276e47596313d
41b4adb10cc86338d85db6636900168f55e7ff18
/aws-cpp-sdk-ssm/source/model/ListCommandInvocationsResult.cpp
ef4d4067e166758cc2c069d4721976d0056f1a32
[ "JSON", "MIT", "Apache-2.0" ]
permissive
totalkyos/AWS
1c9ac30206ef6cf8ca38d2c3d1496fa9c15e5e80
7cb444814e938f3df59530ea4ebe8e19b9418793
refs/heads/master
2021-01-20T20:42:09.978428
2016-07-16T00:03:49
2016-07-16T00:03:49
63,465,708
1
1
null
null
null
null
UTF-8
C++
false
false
1,803
cpp
/* * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #include <aws/ssm/model/ListCommandInvocationsResult.h> #include <aws/core/utils/json/JsonSerializer.h> #include <aws/core/AmazonWebServiceResult.h> #include <aws/core/utils/UnreferencedParam.h> #include <utility> using namespace Aws::SSM::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; using namespace Aws; ListCommandInvocationsResult::ListCommandInvocationsResult() { } ListCommandInvocationsResult::ListCommandInvocationsResult(const AmazonWebServiceResult<JsonValue>& result) { *this = result; } ListCommandInvocationsResult& ListCommandInvocationsResult::operator =(const AmazonWebServiceResult<JsonValue>& result) { const JsonValue& jsonValue = result.GetPayload(); if(jsonValue.ValueExists("CommandInvocations")) { Array<JsonValue> commandInvocationsJsonList = jsonValue.GetArray("CommandInvocations"); for(unsigned commandInvocationsIndex = 0; commandInvocationsIndex < commandInvocationsJsonList.GetLength(); ++commandInvocationsIndex) { m_commandInvocations.push_back(commandInvocationsJsonList[commandInvocationsIndex].AsObject()); } } if(jsonValue.ValueExists("NextToken")) { m_nextToken = jsonValue.GetString("NextToken"); } return *this; }
[ "henso@amazon.com" ]
henso@amazon.com
7bf7081bf125a115ba0b367aaa1da675ae7c0313
8635b190093341b7e26b9c81628b36d52f35fb9d
/client/Reaper-Client/GetIP/GetIP.cpp
61929e6049b69e0f5ee24b2311b5110aa4f9657a
[ "WTFPL" ]
permissive
brianSchanbacher/reaper
4022bf5fc0e4b5de203af4a1c74f88667072a331
b429730d93ab27c9c2e2e4e44d4ebeed13a34a54
refs/heads/master
2021-09-13T03:15:51.794651
2018-04-24T12:06:31
2018-04-24T12:06:31
126,014,820
1
0
null
null
null
null
UTF-8
C++
false
false
1,221
cpp
#include "stdafx.h" #define _CRT_SECURE_NO_WARNINGS #define _WINSOCK_DEPRECATED_NO_WARNINGS #include <Windows.h> #include <WinSock2.h> #include <iphlpapi.h> #include <stdio.h> #include <malloc.h> #include <stdlib.h> #include <malloc.h> #include "GetIP.h" struct IPv4 { unsigned char b1, b2, b3, b4; }; char* GetIP(void) { struct IPv4 myIP; char szBuffer[1024]; #ifdef WIN32 WSADATA wsaData; WORD wVersionRequested = MAKEWORD(2, 0); if (::WSAStartup(wVersionRequested, &wsaData) != 0) return false; #endif if (gethostname(szBuffer, sizeof(szBuffer)) == SOCKET_ERROR) { #ifdef WIN32 WSACleanup(); #endif return false; } struct hostent *host = gethostbyname(szBuffer); if (host == NULL) { #ifdef WIN32 WSACleanup(); #endif return false; } //Obtain the computer's IP myIP.b1 = ((struct in_addr *)(host->h_addr))->S_un.S_un_b.s_b1; myIP.b2 = ((struct in_addr *)(host->h_addr))->S_un.S_un_b.s_b2; myIP.b3 = ((struct in_addr *)(host->h_addr))->S_un.S_un_b.s_b3; myIP.b4 = ((struct in_addr *)(host->h_addr))->S_un.S_un_b.s_b4; #ifdef WIN32 WSACleanup(); #endif char* retval = (char*)malloc(16); snprintf(retval, 16, "%d.%d.%d.%d", myIP.b1, myIP.b2, myIP.b3, myIP.b4); return retval; }
[ "bcampbell1120@gmail.com" ]
bcampbell1120@gmail.com
d1fa81f1cffd793de4a4a602ad7d1ba5367bba9c
7b250f1864ba6f9c0a2e89651df08986b3f68aac
/Bucket.h
d651772a0a03e9a9774d7cdc4c7d936f21f8740d
[]
no_license
schoettl/algodat2_2
4a25569561cc6dd30b46a5f950964d3b72e468a6
6d49f3e1ab429e7ea1991143d0b53cfdc3c13044
refs/heads/master
2020-06-06T18:44:59.696170
2014-12-25T10:02:25
2014-12-25T10:02:25
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,815
h
/* * Bucket.h * * Created on: 28.11.2014 * Author: jakob */ #ifndef BUCKET_H_ #define BUCKET_H_ #include <fstream> using namespace std; #include "Kunde.h" #define BUCKET_SIZE_IN_BYTES sizeof (Bucket<bucketSize>) template <unsigned bucketSize> class Bucket { public: Bucket(); // iterator zum zugriff auf slots oder so? fstream& read(fstream& istream, unsigned position); fstream& write(fstream& ostream, unsigned position) const; void clear(); friend class HashDat<bucketSize>; // C++11 class keyword is optional private: Kunde slots[bucketSize]; // array<Kunde, bucketSize> wäre besser, ist aber C++11 }; template <unsigned bucketSize> Bucket<bucketSize>::Bucket() { } template <unsigned bucketSize> fstream& Bucket<bucketSize>::read(fstream& istream, unsigned position) { istream.seekg(position); // cout << "reading at position " << position << endl; if (!istream) cout << "stream is not ok" << endl; for (int i = 0; i < bucketSize; i++) { slots[i].read(istream); } // istream.read((char*) this, BUCKET_SIZE_IN_BYTES); // geht auch, ist aber evtl. nicht portable. // Wenn ich gewusst hätte, dass bei C++ jedes Objekt auch Verwalungsinfos enthält, // haette ich statt `Kunde slots[]` `vector<Kunde> slots` verwendet. return istream; } template <unsigned bucketSize> fstream& Bucket<bucketSize>::write(fstream& ostream, unsigned position) const { ostream.seekp(position); // cout << "writing at position " << position << endl; for (int i = 0; i < bucketSize; i++) { slots[i].write(ostream); } // ostream.write((char*) this, BUCKET_SIZE_IN_BYTES); // geht auch, ist aber evtl. nicht portable return ostream; } template <unsigned bucketSize> void Bucket<bucketSize>::clear() { for (int i = 0; i < bucketSize; i++) { slots[i] = Kunde(); } } #endif /* BUCKET_H_ */
[ "jschoett@gmail.com" ]
jschoett@gmail.com
180439d0e4974d87050123c3c4f9a80fea348445
87d69ded7629a54220ceefcdf21449acf6a0d5a0
/extlib/sol2/sol2/forward.hpp
64df2c38e1ec610e67e0863c209eea2d1ca35173
[ "Apache-2.0" ]
permissive
F4r3n/FarenMediaLibrary
955e63f3c94bae9a0245cbfa2a2e0ff49c5d915d
a138ea5ec687e7252b63d5cb1bdbc06be02961aa
refs/heads/main
2023-08-08T20:25:27.094533
2023-08-07T12:56:55
2023-08-07T12:56:55
65,391,951
8
1
Apache-2.0
2023-08-15T15:37:24
2016-08-10T15:02:46
C
UTF-8
C++
false
false
36,766
hpp
// The MIT License (MIT) // Copyright (c) 2013-2020 Rapptz, ThePhD and contributors // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the rights to // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of // the Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. // Generated 2022-06-25 08:14:19.328625 UTC // This header was generated with sol v3.3.0 (revision eba86625) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP #define SOL_SINGLE_INCLUDE_FORWARD_HPP // beginning of sol/forward.hpp #ifndef SOL_FORWARD_HPP #define SOL_FORWARD_HPP // beginning of sol/version.hpp #include <sol2/config.hpp> #define SOL_VERSION_MAJOR 3 #define SOL_VERSION_MINOR 2 #define SOL_VERSION_PATCH 3 #define SOL_VERSION_STRING "3.2.3" #define SOL_VERSION ((SOL_VERSION_MAJOR * 100000) + (SOL_VERSION_MINOR * 100) + (SOL_VERSION_PATCH)) #define SOL_TOKEN_TO_STRING_POST_EXPANSION_I_(_TOKEN) #_TOKEN #define SOL_TOKEN_TO_STRING_I_(_TOKEN) SOL_TOKEN_TO_STRING_POST_EXPANSION_I_(_TOKEN) #define SOL_CONCAT_TOKENS_POST_EXPANSION_I_(_LEFT, _RIGHT) _LEFT##_RIGHT #define SOL_CONCAT_TOKENS_I_(_LEFT, _RIGHT) SOL_CONCAT_TOKENS_POST_EXPANSION_I_(_LEFT, _RIGHT) #define SOL_RAW_IS_ON(OP_SYMBOL) ((3 OP_SYMBOL 3) != 0) #define SOL_RAW_IS_OFF(OP_SYMBOL) ((3 OP_SYMBOL 3) == 0) #define SOL_RAW_IS_DEFAULT_ON(OP_SYMBOL) ((3 OP_SYMBOL 3) > 3) #define SOL_RAW_IS_DEFAULT_OFF(OP_SYMBOL) ((3 OP_SYMBOL 3 OP_SYMBOL 3) < 0) #define SOL_IS_ON(OP_SYMBOL) SOL_RAW_IS_ON(OP_SYMBOL ## _I_) #define SOL_IS_OFF(OP_SYMBOL) SOL_RAW_IS_OFF(OP_SYMBOL ## _I_) #define SOL_IS_DEFAULT_ON(OP_SYMBOL) SOL_RAW_IS_DEFAULT_ON(OP_SYMBOL ## _I_) #define SOL_IS_DEFAULT_OFF(OP_SYMBOL) SOL_RAW_IS_DEFAULT_OFF(OP_SYMBOL ## _I_) #define SOL_ON | #define SOL_OFF ^ #define SOL_DEFAULT_ON + #define SOL_DEFAULT_OFF - #if defined(SOL_BUILD_CXX_MODE) #if (SOL_BUILD_CXX_MODE != 0) #define SOL_BUILD_CXX_MODE_I_ SOL_ON #else #define SOL_BUILD_CXX_MODE_I_ SOL_OFF #endif #elif defined(__cplusplus) #define SOL_BUILD_CXX_MODE_I_ SOL_DEFAULT_ON #else #define SOL_BUILD_CXX_MODE_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_BUILD_C_MODE) #if (SOL_BUILD_C_MODE != 0) #define SOL_BUILD_C_MODE_I_ SOL_ON #else #define SOL_BUILD_C_MODE_I_ SOL_OFF #endif #elif defined(__STDC__) #define SOL_BUILD_C_MODE_I_ SOL_DEFAULT_ON #else #define SOL_BUILD_C_MODE_I_ SOL_DEFAULT_OFF #endif #if SOL_IS_ON(SOL_BUILD_C_MODE) #include <stddef.h> #include <stdint.h> #include <limits.h> #else #include <cstddef> #include <cstdint> #include <climits> #endif #if defined(SOL_COMPILER_VCXX) #if defined(SOL_COMPILER_VCXX != 0) #define SOL_COMPILER_VCXX_I_ SOL_ON #else #define SOL_COMPILER_VCXX_I_ SOL_OFF #endif #elif defined(_MSC_VER) #define SOL_COMPILER_VCXX_I_ SOL_DEFAULT_ON #else #define SOL_COMPILER_VCXX_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_COMPILER_GCC) #if defined(SOL_COMPILER_GCC != 0) #define SOL_COMPILER_GCC_I_ SOL_ON #else #define SOL_COMPILER_GCC_I_ SOL_OFF #endif #elif defined(__GNUC__) #define SOL_COMPILER_GCC_I_ SOL_DEFAULT_ON #else #define SOL_COMPILER_GCC_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_COMPILER_CLANG) #if defined(SOL_COMPILER_CLANG != 0) #define SOL_COMPILER_CLANG_I_ SOL_ON #else #define SOL_COMPILER_CLANG_I_ SOL_OFF #endif #elif defined(__clang__) #define SOL_COMPILER_CLANG_I_ SOL_DEFAULT_ON #else #define SOL_COMPILER_CLANG_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_COMPILER_EDG) #if defined(SOL_COMPILER_EDG != 0) #define SOL_COMPILER_EDG_I_ SOL_ON #else #define SOL_COMPILER_EDG_I_ SOL_OFF #endif #else #define SOL_COMPILER_EDG_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_COMPILER_MINGW) #if (SOL_COMPILER_MINGW != 0) #define SOL_COMPILER_MINGW_I_ SOL_ON #else #define SOL_COMPILER_MINGW_I_ SOL_OFF #endif #elif defined(__MINGW32__) #define SOL_COMPILER_MINGW_I_ SOL_DEFAULT_ON #else #define SOL_COMPILER_MINGW_I_ SOL_DEFAULT_OFF #endif #if SIZE_MAX <= 0xFFFFULL #define SOL_PLATFORM_X16_I_ SOL_ON #define SOL_PLATFORM_X86_I_ SOL_OFF #define SOL_PLATFORM_X64_I_ SOL_OFF #elif SIZE_MAX <= 0xFFFFFFFFULL #define SOL_PLATFORM_X16_I_ SOL_OFF #define SOL_PLATFORM_X86_I_ SOL_ON #define SOL_PLATFORM_X64_I_ SOL_OFF #else #define SOL_PLATFORM_X16_I_ SOL_OFF #define SOL_PLATFORM_X86_I_ SOL_OFF #define SOL_PLATFORM_X64_I_ SOL_ON #endif #define SOL_PLATFORM_ARM32_I_ SOL_OFF #define SOL_PLATFORM_ARM64_I_ SOL_OFF #if defined(SOL_PLATFORM_WINDOWS) #if (SOL_PLATFORM_WINDOWS != 0) #define SOL_PLATFORM_WINDOWS_I_ SOL_ON #else #define SOL_PLATFORM_WINDOWS_I_ SOL_OFF #endif #elif defined(_WIN32) #define SOL_PLATFORM_WINDOWS_I_ SOL_DEFAULT_ON #else #define SOL_PLATFORM_WINDOWS_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_PLATFORM_CYGWIN) #if (SOL_PLATFORM_CYGWIN != 0) #define SOL_PLATFORM_CYGWIN_I_ SOL_ON #else #define SOL_PLATFORM_CYGWIN_I_ SOL_ON #endif #elif defined(__CYGWIN__) #define SOL_PLATFORM_CYGWIN_I_ SOL_DEFAULT_ON #else #define SOL_PLATFORM_CYGWIN_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_PLATFORM_APPLE) #if (SOL_PLATFORM_APPLE != 0) #define SOL_PLATFORM_APPLE_I_ SOL_ON #else #define SOL_PLATFORM_APPLE_I_ SOL_OFF #endif #elif defined(__APPLE__) #define SOL_PLATFORM_APPLE_I_ SOL_DEFAULT_ON #else #define SOL_PLATFORM_APPLE_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_PLATFORM_UNIX) #if (SOL_PLATFORM_UNIX != 0) #define SOL_PLATFORM_UNIXLIKE_I_ SOL_ON #else #define SOL_PLATFORM_UNIXLIKE_I_ SOL_OFF #endif #elif defined(__unix__) #define SOL_PLATFORM_UNIXLIKE_I_ SOL_DEFAUKT_ON #else #define SOL_PLATFORM_UNIXLIKE_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_PLATFORM_LINUX) #if (SOL_PLATFORM_LINUX != 0) #define SOL_PLATFORM_LINUXLIKE_I_ SOL_ON #else #define SOL_PLATFORM_LINUXLIKE_I_ SOL_OFF #endif #elif defined(__LINUX__) #define SOL_PLATFORM_LINUXLIKE_I_ SOL_DEFAUKT_ON #else #define SOL_PLATFORM_LINUXLIKE_I_ SOL_DEFAULT_OFF #endif #define SOL_PLATFORM_APPLE_IPHONE_I_ SOL_OFF #define SOL_PLATFORM_BSDLIKE_I_ SOL_OFF #if defined(SOL_IN_DEBUG_DETECTED) #if SOL_IN_DEBUG_DETECTED != 0 #define SOL_DEBUG_BUILD_I_ SOL_ON #else #define SOL_DEBUG_BUILD_I_ SOL_OFF #endif #elif !defined(NDEBUG) #if SOL_IS_ON(SOL_COMPILER_VCXX) && defined(_DEBUG) #define SOL_DEBUG_BUILD_I_ SOL_ON #elif (SOL_IS_ON(SOL_COMPILER_CLANG) || SOL_IS_ON(SOL_COMPILER_GCC)) && !defined(__OPTIMIZE__) #define SOL_DEBUG_BUILD_I_ SOL_ON #else #define SOL_DEBUG_BUILD_I_ SOL_OFF #endif #else #define SOL_DEBUG_BUILD_I_ SOL_DEFAULT_OFF #endif // We are in a debug mode of some sort #if defined(SOL_NO_EXCEPTIONS) #if (SOL_NO_EXCEPTIONS != 0) #define SOL_EXCEPTIONS_I_ SOL_OFF #else #define SOL_EXCEPTIONS_I_ SOL_ON #endif #elif SOL_IS_ON(SOL_COMPILER_VCXX) #if !defined(_CPPUNWIND) #define SOL_EXCEPTIONS_I_ SOL_OFF #else #define SOL_EXCEPTIONS_I_ SOL_ON #endif #elif SOL_IS_ON(SOL_COMPILER_CLANG) || SOL_IS_ON(SOL_COMPILER_GCC) #if !defined(__EXCEPTIONS) #define SOL_EXCEPTIONS_I_ SOL_OFF #else #define SOL_EXCEPTIONS_I_ SOL_ON #endif #else #define SOL_EXCEPTIONS_I_ SOL_DEFAULT_ON #endif #if defined(SOL_NO_RTTI) #if (SOL_NO_RTTI != 0) #define SOL_RTTI_I_ SOL_OFF #else #define SOL_RTTI_I_ SOL_ON #endif #elif SOL_IS_ON(SOL_COMPILER_VCXX) #if !defined(_CPPRTTI) #define SOL_RTTI_I_ SOL_OFF #else #define SOL_RTTI_I_ SOL_ON #endif #elif SOL_IS_ON(SOL_COMPILER_CLANG) || SOL_IS_ON(SOL_COMPILER_GCC) #if !defined(__GXX_RTTI) #define SOL_RTTI_I_ SOL_OFF #else #define SOL_RTTI_I_ SOL_ON #endif #else #define SOL_RTTI_I_ SOL_DEFAULT_ON #endif #if defined(SOL_NO_THREAD_LOCAL) #if SOL_NO_THREAD_LOCAL != 0 #define SOL_USE_THREAD_LOCAL_I_ SOL_OFF #else #define SOL_USE_THREAD_LOCAL_I_ SOL_ON #endif #else #define SOL_USE_THREAD_LOCAL_I_ SOL_DEFAULT_ON #endif // thread_local keyword is bjorked on some platforms #if defined(SOL_ALL_SAFETIES_ON) #if SOL_ALL_SAFETIES_ON != 0 #define SOL_ALL_SAFETIES_ON_I_ SOL_ON #else #define SOL_ALL_SAFETIES_ON_I_ SOL_OFF #endif #else #define SOL_ALL_SAFETIES_ON_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_SAFE_GETTER) #if SOL_SAFE_GETTER != 0 #define SOL_SAFE_GETTER_I_ SOL_ON #else #define SOL_SAFE_GETTER_I_ SOL_OFF #endif #else #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_GETTER_I_ SOL_ON #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_GETTER_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_GETTER_I_ SOL_DEFAULT_OFF #endif #endif #if defined(SOL_SAFE_USERTYPE) #if SOL_SAFE_USERTYPE != 0 #define SOL_SAFE_USERTYPE_I_ SOL_ON #else #define SOL_SAFE_USERTYPE_I_ SOL_OFF #endif #else #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_USERTYPE_I_ SOL_ON #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_USERTYPE_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_USERTYPE_I_ SOL_DEFAULT_OFF #endif #endif #if defined(SOL_SAFE_REFERENCES) #if SOL_SAFE_REFERENCES != 0 #define SOL_SAFE_REFERENCES_I_ SOL_ON #else #define SOL_SAFE_REFERENCES_I_ SOL_OFF #endif #else #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_REFERENCES_I_ SOL_ON #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_REFERENCES_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_REFERENCES_I_ SOL_DEFAULT_OFF #endif #endif #if defined(SOL_SAFE_FUNCTIONS) #if SOL_SAFE_FUNCTIONS != 0 #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_ON #else #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_OFF #endif #elif defined (SOL_SAFE_FUNCTION_OBJECTS) #if SOL_SAFE_FUNCTION_OBJECTS != 0 #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_ON #else #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_OFF #endif #else #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_ON #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_DEFAULT_OFF #endif #endif #if defined(SOL_SAFE_FUNCTION_CALLS) #if SOL_SAFE_FUNCTION_CALLS != 0 #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_ON #else #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_OFF #endif #else #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_ON #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_DEFAULT_OFF #endif #endif #if defined(SOL_SAFE_PROXIES) #if SOL_SAFE_PROXIES != 0 #define SOL_SAFE_PROXIES_I_ SOL_ON #else #define SOL_SAFE_PROXIES_I_ SOL_OFF #endif #else #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_PROXIES_I_ SOL_ON #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_PROXIES_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_PROXIES_I_ SOL_DEFAULT_OFF #endif #endif #if defined(SOL_SAFE_NUMERICS) #if SOL_SAFE_NUMERICS != 0 #define SOL_SAFE_NUMERICS_I_ SOL_ON #else #define SOL_SAFE_NUMERICS_I_ SOL_OFF #endif #else #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_NUMERICS_I_ SOL_ON #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_NUMERICS_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_NUMERICS_I_ SOL_DEFAULT_OFF #endif #endif #if defined(SOL_ALL_INTEGER_VALUES_FIT) #if (SOL_ALL_INTEGER_VALUES_FIT != 0) #define SOL_ALL_INTEGER_VALUES_FIT_I_ SOL_ON #else #define SOL_ALL_INTEGER_VALUES_FIT_I_ SOL_OFF #endif #elif !SOL_IS_DEFAULT_OFF(SOL_SAFE_NUMERICS) && SOL_IS_OFF(SOL_SAFE_NUMERICS) // if numerics is intentionally turned off, flip this on #define SOL_ALL_INTEGER_VALUES_FIT_I_ SOL_DEFAULT_ON #else // default to off #define SOL_ALL_INTEGER_VALUES_FIT_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_SAFE_STACK_CHECK) #if SOL_SAFE_STACK_CHECK != 0 #define SOL_SAFE_STACK_CHECK_I_ SOL_ON #else #define SOL_SAFE_STACK_CHECK_I_ SOL_OFF #endif #else #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_SAFE_STACK_CHECK_I_ SOL_ON #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_SAFE_STACK_CHECK_I_ SOL_DEFAULT_ON #else #define SOL_SAFE_STACK_CHECK_I_ SOL_DEFAULT_OFF #endif #endif #if defined(SOL_NO_CHECK_NUMBER_PRECISION) #if SOL_NO_CHECK_NUMBER_PRECISION != 0 #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_OFF #else #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON #endif #elif defined(SOL_NO_CHECKING_NUMBER_PRECISION) #if SOL_NO_CHECKING_NUMBER_PRECISION != 0 #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_OFF #else #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON #endif #else #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON #elif SOL_IS_ON(SOL_SAFE_NUMERICS) #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_DEFAULT_ON #else #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_DEFAULT_OFF #endif #endif #if defined(SOL_STRINGS_ARE_NUMBERS) #if (SOL_STRINGS_ARE_NUMBERS != 0) #define SOL_STRINGS_ARE_NUMBERS_I_ SOL_ON #else #define SOL_STRINGS_ARE_NUMBERS_I_ SOL_OFF #endif #else #define SOL_STRINGS_ARE_NUMBERS_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_ENABLE_INTEROP) #if SOL_ENABLE_INTEROP != 0 #define SOL_USE_INTEROP_I_ SOL_ON #else #define SOL_USE_INTEROP_I_ SOL_OFF #endif #elif defined(SOL_USE_INTEROP) #if SOL_USE_INTEROP != 0 #define SOL_USE_INTEROP_I_ SOL_ON #else #define SOL_USE_INTEROP_I_ SOL_OFF #endif #else #define SOL_USE_INTEROP_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_NO_NIL) #if (SOL_NO_NIL != 0) #define SOL_NIL_I_ SOL_OFF #else #define SOL_NIL_I_ SOL_ON #endif #elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) || defined(__OBJC__) || defined(nil) #define SOL_NIL_I_ SOL_DEFAULT_OFF #else #define SOL_NIL_I_ SOL_DEFAULT_ON #endif #if defined(SOL_USERTYPE_TYPE_BINDING_INFO) #if (SOL_USERTYPE_TYPE_BINDING_INFO != 0) #define SOL_USERTYPE_TYPE_BINDING_INFO_I_ SOL_ON #else #define SOL_USERTYPE_TYPE_BINDING_INFO_I_ SOL_OFF #endif #else #define SOL_USERTYPE_TYPE_BINDING_INFO_I_ SOL_DEFAULT_ON #endif // We should generate a my_type.__type table with lots of class information for usertypes #if defined(SOL_AUTOMAGICAL_TYPES_BY_DEFAULT) #if (SOL_AUTOMAGICAL_TYPES_BY_DEFAULT != 0) #define SOL_DEFAULT_AUTOMAGICAL_USERTYPES_I_ SOL_ON #else #define SOL_DEFAULT_AUTOMAGICAL_USERTYPES_I_ SOL_OFF #endif #elif defined(SOL_DEFAULT_AUTOMAGICAL_USERTYPES) #if (SOL_DEFAULT_AUTOMAGICAL_USERTYPES != 0) #define SOL_DEFAULT_AUTOMAGICAL_USERTYPES_I_ SOL_ON #else #define SOL_DEFAULT_AUTOMAGICAL_USERTYPES_I_ SOL_OFF #endif #else #define SOL_DEFAULT_AUTOMAGICAL_USERTYPES_I_ SOL_DEFAULT_ON #endif // make is_automagical on/off by default #if defined(SOL_STD_VARIANT) #if (SOL_STD_VARIANT != 0) #define SOL_STD_VARIANT_I_ SOL_ON #else #define SOL_STD_VARIANT_I_ SOL_OFF #endif #else #if SOL_IS_ON(SOL_COMPILER_CLANG) && SOL_IS_ON(SOL_PLATFORM_APPLE) #if defined(__has_include) #if __has_include(<variant>) #define SOL_STD_VARIANT_I_ SOL_DEFAULT_ON #else #define SOL_STD_VARIANT_I_ SOL_DEFAULT_OFF #endif #else #define SOL_STD_VARIANT_I_ SOL_DEFAULT_OFF #endif #else #define SOL_STD_VARIANT_I_ SOL_DEFAULT_ON #endif #endif // make is_automagical on/off by default #if defined(SOL_NOEXCEPT_FUNCTION_TYPE) #if (SOL_NOEXCEPT_FUNCTION_TYPE != 0) #define SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_ SOL_ON #else #define SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_ SOL_OFF #endif #else #if defined(__cpp_noexcept_function_type) #define SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_ SOL_ON #elif SOL_IS_ON(SOL_COMPILER_VCXX) && (defined(_MSVC_LANG) && (_MSVC_LANG < 201403L)) // There is a bug in the VC++ compiler?? // on /std:c++latest under x86 conditions (VS 15.5.2), // compiler errors are tossed for noexcept markings being on function types // that are identical in every other way to their non-noexcept marked types function types... // VS 2019: There is absolutely a bug. #define SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_ SOL_OFF #else #define SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_ SOL_DEFAULT_ON #endif #endif // noexcept is part of a function's type #if defined(SOL_STACK_STRING_OPTIMIZATION_SIZE) && SOL_STACK_STRING_OPTIMIZATION_SIZE > 0 #define SOL_OPTIMIZATION_STRING_CONVERSION_STACK_SIZE_I_ SOL_STACK_STRING_OPTIMIZATION_SIZE #else #define SOL_OPTIMIZATION_STRING_CONVERSION_STACK_SIZE_I_ 1024 #endif #if defined(SOL_ID_SIZE) && SOL_ID_SIZE > 0 #define SOL_ID_SIZE_I_ SOL_ID_SIZE #else #define SOL_ID_SIZE_I_ 512 #endif #if defined(LUA_IDSIZE) && LUA_IDSIZE > 0 #define SOL_FILE_ID_SIZE_I_ LUA_IDSIZE #elif defined(SOL_ID_SIZE) && SOL_ID_SIZE > 0 #define SOL_FILE_ID_SIZE_I_ SOL_FILE_ID_SIZE #else #define SOL_FILE_ID_SIZE_I_ 2048 #endif #if defined(SOL_PRINT_ERRORS) #if (SOL_PRINT_ERRORS != 0) #define SOL_PRINT_ERRORS_I_ SOL_ON #else #define SOL_PRINT_ERRORS_I_ SOL_OFF #endif #else #if SOL_IS_ON(SOL_ALL_SAFETIES_ON) #define SOL_PRINT_ERRORS_I_ SOL_ON #elif SOL_IS_ON(SOL_DEBUG_BUILD) #define SOL_PRINT_ERRORS_I_ SOL_DEFAULT_ON #else #define SOL_PRINT_ERRORS_I_ SOL_OFF #endif #endif #if defined(SOL_DEFAULT_PASS_ON_ERROR) #if (SOL_DEFAULT_PASS_ON_ERROR != 0) #define SOL_DEFAULT_PASS_ON_ERROR_I_ SOL_ON #else #define SOL_DEFAULT_PASS_ON_ERROR_I_ SOL_OFF #endif #else #define SOL_DEFAULT_PASS_ON_ERROR_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_USING_CXX_LUA) #if (SOL_USING_CXX_LUA != 0) #define SOL_USE_CXX_LUA_I_ SOL_ON #else #define SOL_USE_CXX_LUA_I_ SOL_OFF #endif #elif defined(SOL_USE_CXX_LUA) #if (SOL_USE_CXX_LUA != 0) #define SOL_USE_CXX_LUA_I_ SOL_ON #else #define SOL_USE_CXX_LUA_I_ SOL_OFF #endif #else #define SOL_USE_CXX_LUA_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_USING_CXX_LUAJIT) #if (SOL_USING_CXX_LUA != 0) #define SOL_USE_CXX_LUAJIT_I_ SOL_ON #else #define SOL_USE_CXX_LUAJIT_I_ SOL_OFF #endif #elif defined(SOL_USE_CXX_LUAJIT) #if (SOL_USE_CXX_LUA != 0) #define SOL_USE_CXX_LUAJIT_I_ SOL_ON #else #define SOL_USE_CXX_LUAJIT_I_ SOL_OFF #endif #else #define SOL_USE_CXX_LUAJIT_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_NO_LUA_HPP) #if (SOL_NO_LUA_HPP != 0) #define SOL_USE_LUA_HPP_I_ SOL_OFF #else #define SOL_USE_LUA_HPP_I_ SOL_ON #endif #elif defined(SOL_USING_CXX_LUA) #define SOL_USE_LUA_HPP_I_ SOL_OFF #elif defined(__has_include) #if __has_include(<lua.hpp>) #define SOL_USE_LUA_HPP_I_ SOL_ON #else #define SOL_USE_LUA_HPP_I_ SOL_OFF #endif #else #define SOL_USE_LUA_HPP_I_ SOL_DEFAULT_ON #endif #if defined(SOL_CONTAINERS_START) #define SOL_CONTAINER_START_INDEX_I_ SOL_CONTAINERS_START #elif defined(SOL_CONTAINERS_START_INDEX) #define SOL_CONTAINER_START_INDEX_I_ SOL_CONTAINERS_START_INDEX #elif defined(SOL_CONTAINER_START_INDEX) #define SOL_CONTAINER_START_INDEX_I_ SOL_CONTAINER_START_INDEX #else #define SOL_CONTAINER_START_INDEX_I_ 1 #endif #if defined (SOL_NO_MEMORY_ALIGNMENT) #if (SOL_NO_MEMORY_ALIGNMENT != 0) #define SOL_ALIGN_MEMORY_I_ SOL_OFF #else #define SOL_ALIGN_MEMORY_I_ SOL_ON #endif #else #define SOL_ALIGN_MEMORY_I_ SOL_DEFAULT_ON #endif #if defined(SOL_USE_BOOST) #if (SOL_USE_BOOST != 0) #define SOL_USE_BOOST_I_ SOL_ON #else #define SOL_USE_BOOST_I_ SOL_OFF #endif #else #define SOL_USE_BOOST_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_USE_UNSAFE_BASE_LOOKUP) #if (SOL_USE_UNSAFE_BASE_LOOKUP != 0) #define SOL_USE_UNSAFE_BASE_LOOKUP_I_ SOL_ON #else #define SOL_USE_UNSAFE_BASE_LOOKUP_I_ SOL_OFF #endif #else #define SOL_USE_UNSAFE_BASE_LOOKUP_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_INSIDE_UNREAL) #if (SOL_INSIDE_UNREAL != 0) #define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_ON #else #define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_OFF #endif #else #if defined(UE_BUILD_DEBUG) || defined(UE_BUILD_DEVELOPMENT) || defined(UE_BUILD_TEST) || defined(UE_BUILD_SHIPPING) || defined(UE_SERVER) #define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_DEFAULT_ON #else #define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_DEFAULT_OFF #endif #endif #if defined(SOL_NO_COMPAT) #if (SOL_NO_COMPAT != 0) #define SOL_USE_COMPATIBILITY_LAYER_I_ SOL_OFF #else #define SOL_USE_COMPATIBILITY_LAYER_I_ SOL_ON #endif #else #define SOL_USE_COMPATIBILITY_LAYER_I_ SOL_DEFAULT_ON #endif #if defined(SOL_GET_FUNCTION_POINTER_UNSAFE) #if (SOL_GET_FUNCTION_POINTER_UNSAFE != 0) #define SOL_GET_FUNCTION_POINTER_UNSAFE_I_ SOL_ON #else #define SOL_GET_FUNCTION_POINTER_UNSAFE_I_ SOL_OFF #endif #else #define SOL_GET_FUNCTION_POINTER_UNSAFE_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_FUNCTION_CALL_VALUE_SEMANTICS) #if (SOL_FUNCTION_CALL_VALUE_SEMANTICS != 0) #define SOL_FUNCTION_CALL_VALUE_SEMANTICS_I_ SOL_ON #else #define SOL_FUNCTION_CALL_VALUE_SEMANTICS_I_ SOL_OFF #endif #else #define SOL_FUNCTION_CALL_VALUE_SEMANTICS_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_MINGW_CCTYPE_IS_POISONED) #if (SOL_MINGW_CCTYPE_IS_POISONED != 0) #define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_ON #else #define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_OFF #endif #elif SOL_IS_ON(SOL_COMPILER_MINGW) && defined(__GNUC__) && (__GNUC__ < 6) // MinGW is off its rocker in some places... #define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_DEFAULT_ON #else #define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_CHAR8_T) #if (SOL_CHAR8_T != 0) #define SOL_CHAR8_T_I_ SOL_ON #else #define SOL_CHAR8_T_I_ SOL_OFF #endif #else #if defined(__cpp_char8_t) #define SOL_CHAR8_T_I_ SOL_DEFAULT_ON #else #define SOL_CHAR8_T_I_ SOL_DEFAULT_OFF #endif #endif #if SOL_IS_ON(SOL_USE_BOOST) #include <boost/version.hpp> #if BOOST_VERSION >= 107500 // Since Boost 1.75.0 boost::none is constexpr #define SOL_BOOST_NONE_CONSTEXPR_I_ constexpr #else #define SOL_BOOST_NONE_CONSTEXPR_I_ const #endif // BOOST_VERSION #else // assume boost isn't using a garbage version #define SOL_BOOST_NONE_CONSTEXPR_I_ constexpr #endif #if defined(SOL2_CI) #if (SOL2_CI != 0) #define SOL2_CI_I_ SOL_ON #else #define SOL2_CI_I_ SOL_OFF #endif #else #define SOL2_CI_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_C_ASSERT) #define SOL_USER_C_ASSERT_I_ SOL_ON #else #define SOL_USER_C_ASSERT_I_ SOL_DEFAULT_OFF #endif #if defined(SOL_M_ASSERT) #define SOL_USER_M_ASSERT_I_ SOL_ON #else #define SOL_USER_M_ASSERT_I_ SOL_DEFAULT_OFF #endif // beginning of sol/prologue.hpp #if defined(SOL_PROLOGUE_I_) #error "[sol2] Library Prologue was already included in translation unit and not properly ended with an epilogue." #endif #define SOL_PROLOGUE_I_ 1 #if SOL_IS_ON(SOL_BUILD_CXX_MODE) #define _FWD(...) static_cast<decltype( __VA_ARGS__ )&&>( __VA_ARGS__ ) #if SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG) #define _MOVE(...) static_cast<__typeof( __VA_ARGS__ )&&>( __VA_ARGS__ ) #else #include <type_traits> #define _MOVE(...) static_cast<::std::remove_reference_t<( __VA_ARGS__ )>&&>( __VA_OPT__(,) ) #endif #endif // end of sol/prologue.hpp // beginning of sol/epilogue.hpp #if !defined(SOL_PROLOGUE_I_) #error "[sol2] Library Prologue is missing from this translation unit." #else #undef SOL_PROLOGUE_I_ #endif #if SOL_IS_ON(SOL_BUILD_CXX_MODE) #undef _FWD #undef _MOVE #endif // end of sol/epilogue.hpp // beginning of sol/detail/build_version.hpp #if defined(SOL_DLL) #if (SOL_DLL != 0) #define SOL_DLL_I_ SOL_ON #else #define SOL_DLL_I_ SOL_OFF #endif #elif SOL_IS_ON(SOL_COMPILER_VCXX) && (defined(DLL_) || defined(_DLL)) #define SOL_DLL_I_ SOL_DEFAULT_ON #else #define SOL_DLL_I_ SOL_DEFAULT_OFF #endif // DLL definition #if defined(SOL_HEADER_ONLY) #if (SOL_HEADER_ONLY != 0) #define SOL_HEADER_ONLY_I_ SOL_ON #else #define SOL_HEADER_ONLY_I_ SOL_OFF #endif #else #define SOL_HEADER_ONLY_I_ SOL_DEFAULT_OFF #endif // Header only library #if defined(SOL_BUILD) #if (SOL_BUILD != 0) #define SOL_BUILD_I_ SOL_ON #else #define SOL_BUILD_I_ SOL_OFF #endif #elif SOL_IS_ON(SOL_HEADER_ONLY) #define SOL_BUILD_I_ SOL_DEFAULT_OFF #else #define SOL_BUILD_I_ SOL_DEFAULT_ON #endif #if defined(SOL_UNITY_BUILD) #if (SOL_UNITY_BUILD != 0) #define SOL_UNITY_BUILD_I_ SOL_ON #else #define SOL_UNITY_BUILD_I_ SOL_OFF #endif #else #define SOL_UNITY_BUILD_I_ SOL_DEFAULT_OFF #endif // Header only library #if defined(SOL_C_FUNCTION_LINKAGE) #define SOL_C_FUNCTION_LINKAGE_I_ SOL_C_FUNCTION_LINKAGE #else #if SOL_IS_ON(SOL_BUILD_CXX_MODE) // C++ #define SOL_C_FUNCTION_LINKAGE_I_ extern "C" #else // normal #define SOL_C_FUNCTION_LINKAGE_I_ #endif // C++ or not #endif // Linkage specification for C functions #if defined(SOL_API_LINKAGE) #define SOL_API_LINKAGE_I_ SOL_API_LINKAGE #else #if SOL_IS_ON(SOL_DLL) #if SOL_IS_ON(SOL_COMPILER_VCXX) || SOL_IS_ON(SOL_PLATFORM_WINDOWS) || SOL_IS_ON(SOL_PLATFORM_CYGWIN) // MSVC Compiler; or, Windows, or Cygwin platforms #if SOL_IS_ON(SOL_BUILD) // Building the library #if SOL_IS_ON(SOL_COMPILER_GCC) // Using GCC #define SOL_API_LINKAGE_I_ __attribute__((dllexport)) #else // Using Clang, MSVC, etc... #define SOL_API_LINKAGE_I_ __declspec(dllexport) #endif #else #if SOL_IS_ON(SOL_COMPILER_GCC) #define SOL_API_LINKAGE_I_ __attribute__((dllimport)) #else #define SOL_API_LINKAGE_I_ __declspec(dllimport) #endif #endif #else // extern if building normally on non-MSVC #define SOL_API_LINKAGE_I_ extern #endif #elif SOL_IS_ON(SOL_UNITY_BUILD) // Built-in library, like how stb typical works #if SOL_IS_ON(SOL_HEADER_ONLY) // Header only, so functions are defined "inline" #define SOL_API_LINKAGE_I_ inline #else // Not header only, so seperately compiled files #define SOL_API_LINKAGE_I_ extern #endif #else // Normal static library #if SOL_IS_ON(SOL_BUILD_CXX_MODE) #define SOL_API_LINKAGE_I_ #else #define SOL_API_LINKAGE_I_ extern #endif #endif // DLL or not #endif // Build definitions #if defined(SOL_PUBLIC_FUNC_DECL) #define SOL_PUBLIC_FUNC_DECL_I_ SOL_PUBLIC_FUNC_DECL #else #define SOL_PUBLIC_FUNC_DECL_I_ SOL_API_LINKAGE_I_ #endif #if defined(SOL_INTERNAL_FUNC_DECL_) #define SOL_INTERNAL_FUNC_DECL_I_ SOL_INTERNAL_FUNC_DECL_ #else #define SOL_INTERNAL_FUNC_DECL_I_ SOL_API_LINKAGE_I_ #endif #if defined(SOL_PUBLIC_FUNC_DEF) #define SOL_PUBLIC_FUNC_DEF_I_ SOL_PUBLIC_FUNC_DEF #else #define SOL_PUBLIC_FUNC_DEF_I_ SOL_API_LINKAGE_I_ #endif #if defined(SOL_INTERNAL_FUNC_DEF) #define SOL_INTERNAL_FUNC_DEF_I_ SOL_INTERNAL_FUNC_DEF #else #define SOL_INTERNAL_FUNC_DEF_I_ SOL_API_LINKAGE_I_ #endif #if defined(SOL_FUNC_DECL) #define SOL_FUNC_DECL_I_ SOL_FUNC_DECL #elif SOL_IS_ON(SOL_HEADER_ONLY) #define SOL_FUNC_DECL_I_ #elif SOL_IS_ON(SOL_DLL) #if SOL_IS_ON(SOL_COMPILER_VCXX) #if SOL_IS_ON(SOL_BUILD) #define SOL_FUNC_DECL_I_ extern __declspec(dllexport) #else #define SOL_FUNC_DECL_I_ extern __declspec(dllimport) #endif #elif SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG) #define SOL_FUNC_DECL_I_ extern __attribute__((visibility("default"))) #else #define SOL_FUNC_DECL_I_ extern #endif #endif #if defined(SOL_FUNC_DEFN) #define SOL_FUNC_DEFN_I_ SOL_FUNC_DEFN #elif SOL_IS_ON(SOL_HEADER_ONLY) #define SOL_FUNC_DEFN_I_ inline #elif SOL_IS_ON(SOL_DLL) #if SOL_IS_ON(SOL_COMPILER_VCXX) #if SOL_IS_ON(SOL_BUILD) #define SOL_FUNC_DEFN_I_ __declspec(dllexport) #else #define SOL_FUNC_DEFN_I_ __declspec(dllimport) #endif #elif SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG) #define SOL_FUNC_DEFN_I_ __attribute__((visibility("default"))) #else #define SOL_FUNC_DEFN_I_ #endif #endif #if defined(SOL_HIDDEN_FUNC_DECL) #define SOL_HIDDEN_FUNC_DECL_I_ SOL_HIDDEN_FUNC_DECL #elif SOL_IS_ON(SOL_HEADER_ONLY) #define SOL_HIDDEN_FUNC_DECL_I_ #elif SOL_IS_ON(SOL_DLL) #if SOL_IS_ON(SOL_COMPILER_VCXX) #if SOL_IS_ON(SOL_BUILD) #define SOL_HIDDEN_FUNC_DECL_I_ extern __declspec(dllexport) #else #define SOL_HIDDEN_FUNC_DECL_I_ extern __declspec(dllimport) #endif #elif SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG) #define SOL_HIDDEN_FUNC_DECL_I_ extern __attribute__((visibility("default"))) #else #define SOL_HIDDEN_FUNC_DECL_I_ extern #endif #endif #if defined(SOL_HIDDEN_FUNC_DEFN) #define SOL_HIDDEN_FUNC_DEFN_I_ SOL_HIDDEN_FUNC_DEFN #elif SOL_IS_ON(SOL_HEADER_ONLY) #define SOL_HIDDEN_FUNC_DEFN_I_ inline #elif SOL_IS_ON(SOL_DLL) #if SOL_IS_ON(SOL_COMPILER_VCXX) #if SOL_IS_ON(SOL_BUILD) #define SOL_HIDDEN_FUNC_DEFN_I_ #else #define SOL_HIDDEN_FUNC_DEFN_I_ #endif #elif SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG) #define SOL_HIDDEN_FUNC_DEFN_I_ __attribute__((visibility("hidden"))) #else #define SOL_HIDDEN_FUNC_DEFN_I_ #endif #endif // end of sol/detail/build_version.hpp // end of sol/version.hpp #include <utility> #include <type_traits> #include <string_view> #if SOL_IS_ON(SOL_USE_CXX_LUA) || SOL_IS_ON(SOL_USE_CXX_LUAJIT) struct lua_State; #else extern "C" { struct lua_State; } #endif // C++ Mangling for Lua vs. Not namespace sol { enum class type; class stateless_reference; template <bool b> class basic_reference; using reference = basic_reference<false>; using main_reference = basic_reference<true>; class stateless_stack_reference; class stack_reference; template <typename A> class basic_bytecode; struct lua_value; struct proxy_base_tag; template <typename> struct proxy_base; template <typename, typename> struct table_proxy; template <bool, typename> class basic_table_core; template <bool b> using table_core = basic_table_core<b, reference>; template <bool b> using main_table_core = basic_table_core<b, main_reference>; template <bool b> using stack_table_core = basic_table_core<b, stack_reference>; template <typename base_type> using basic_table = basic_table_core<false, base_type>; using table = table_core<false>; using global_table = table_core<true>; using main_table = main_table_core<false>; using main_global_table = main_table_core<true>; using stack_table = stack_table_core<false>; using stack_global_table = stack_table_core<true>; template <typename> struct basic_lua_table; using lua_table = basic_lua_table<reference>; using stack_lua_table = basic_lua_table<stack_reference>; template <typename T, typename base_type> class basic_usertype; template <typename T> using usertype = basic_usertype<T, reference>; template <typename T> using stack_usertype = basic_usertype<T, stack_reference>; template <typename base_type> class basic_metatable; using metatable = basic_metatable<reference>; using stack_metatable = basic_metatable<stack_reference>; template <typename base_t> struct basic_environment; using environment = basic_environment<reference>; using main_environment = basic_environment<main_reference>; using stack_environment = basic_environment<stack_reference>; template <typename T, bool> class basic_function; template <typename T, bool, typename H> class basic_protected_function; using unsafe_function = basic_function<reference, false>; using safe_function = basic_protected_function<reference, false, reference>; using main_unsafe_function = basic_function<main_reference, false>; using main_safe_function = basic_protected_function<main_reference, false, reference>; using stack_unsafe_function = basic_function<stack_reference, false>; using stack_safe_function = basic_protected_function<stack_reference, false, reference>; using stack_aligned_unsafe_function = basic_function<stack_reference, true>; using stack_aligned_safe_function = basic_protected_function<stack_reference, true, reference>; using protected_function = safe_function; using main_protected_function = main_safe_function; using stack_protected_function = stack_safe_function; using stack_aligned_protected_function = stack_aligned_safe_function; #if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS) using function = protected_function; using main_function = main_protected_function; using stack_function = stack_protected_function; using stack_aligned_function = stack_aligned_safe_function; #else using function = unsafe_function; using main_function = main_unsafe_function; using stack_function = stack_unsafe_function; using stack_aligned_function = stack_aligned_unsafe_function; #endif using stack_aligned_stack_handler_function = basic_protected_function<stack_reference, true, stack_reference>; struct unsafe_function_result; struct protected_function_result; using safe_function_result = protected_function_result; #if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS) using function_result = safe_function_result; #else using function_result = unsafe_function_result; #endif template <typename base_t> class basic_object_base; template <typename base_t> class basic_object; template <typename base_t> class basic_userdata; template <typename base_t> class basic_lightuserdata; template <typename base_t> class basic_coroutine; template <typename base_t> class basic_packaged_coroutine; template <typename base_t> class basic_thread; using object = basic_object<reference>; using userdata = basic_userdata<reference>; using lightuserdata = basic_lightuserdata<reference>; using thread = basic_thread<reference>; using coroutine = basic_coroutine<reference>; using packaged_coroutine = basic_packaged_coroutine<reference>; using main_object = basic_object<main_reference>; using main_userdata = basic_userdata<main_reference>; using main_lightuserdata = basic_lightuserdata<main_reference>; using main_coroutine = basic_coroutine<main_reference>; using stack_object = basic_object<stack_reference>; using stack_userdata = basic_userdata<stack_reference>; using stack_lightuserdata = basic_lightuserdata<stack_reference>; using stack_thread = basic_thread<stack_reference>; using stack_coroutine = basic_coroutine<stack_reference>; struct stack_proxy_base; struct stack_proxy; struct variadic_args; struct variadic_results; struct stack_count; struct this_state; struct this_main_state; struct this_environment; class state_view; class state; template <typename T> struct as_table_t; template <typename T> struct as_container_t; template <typename T> struct nested; template <typename T> struct light; template <typename T> struct user; template <typename T> struct as_args_t; template <typename T> struct protect_t; template <typename F, typename... Policies> struct policy_wrapper; template <typename T> struct usertype_traits; template <typename T> struct unique_usertype_traits; template <typename... Args> struct types { typedef std::make_index_sequence<sizeof...(Args)> indices; static constexpr std::size_t size() { return sizeof...(Args); } }; template <typename T> struct derive : std::false_type { typedef types<> type; }; template <typename T> struct base : std::false_type { typedef types<> type; }; template <typename T> struct weak_derive { static bool value; }; template <typename T> bool weak_derive<T>::value = false; namespace stack { struct record; } #if SOL_IS_OFF(SOL_USE_BOOST) template <class T> class optional; template <class T> class optional<T&>; #endif using check_handler_type = int(lua_State*, int, type, type, const char*); } // namespace sol #define SOL_BASE_CLASSES(T, ...) \ namespace sol { \ template <> \ struct base<T> : std::true_type { \ typedef ::sol::types<__VA_ARGS__> type; \ }; \ } \ void a_sol3_detail_function_decl_please_no_collide() #define SOL_DERIVED_CLASSES(T, ...) \ namespace sol { \ template <> \ struct derive<T> : std::true_type { \ typedef ::sol::types<__VA_ARGS__> type; \ }; \ } \ void a_sol3_detail_function_decl_please_no_collide() #endif // SOL_FORWARD_HPP // end of sol/forward.hpp #endif // SOL_SINGLE_INCLUDE_FORWARD_HPP
[ "guillaume_k@hotmail.fr" ]
guillaume_k@hotmail.fr
134fa46ced2cca3da32a1083ea8b7b140636eae0
4c23be1a0ca76f68e7146f7d098e26c2bbfb2650
/ic8h18/0.006/FC6H12OOH-HO2
9fa129a765b1b6040941e70db2bf398b6230e0e7
[]
no_license
labsandy/OpenFOAM_workspace
a74b473903ddbd34b31dc93917e3719bc051e379
6e0193ad9dabd613acf40d6b3ec4c0536c90aed4
refs/heads/master
2022-02-25T02:36:04.164324
2019-08-23T02:27:16
2019-08-23T02:27:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
835
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 6 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "0.006"; object FC6H12OOH-HO2; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 0 0 0 0]; internalField uniform 0; boundaryField { boundary { type empty; } } // ************************************************************************* //
[ "jfeatherstone123@gmail.com" ]
jfeatherstone123@gmail.com
29992dd3d1e48d0518639530a6d1926683435d0f
4118f8eba9c1073074087cdaffebb95e0c1166cb
/src/exception.cpp
48afc096092d6e06ca81a139a66edef13462294e
[]
no_license
rajtyagi2718/tetris
08a402462dd06b070edc80e231b95df559a404e0
362c66473d9724662efecd98190159879cba9a6e
refs/heads/main
2023-07-14T17:24:50.175357
2021-08-31T16:51:28
2021-08-31T16:51:28
336,360,820
0
0
null
null
null
null
UTF-8
C++
false
false
460
cpp
#include "../include/exception.h" // BoardIndexException #include <sstream> // ostringstream #include <string> // to_string GameActionIndexException::GameActionIndexException(int index) : message{"agent action must be integer between [0, 4]."}, index{index} { message += " given action of " + std::to_string(index) + '.'; } const char* GameActionIndexException::what() const noexcept { return message.c_str(); }
[ "rajtyagi2718@gmail.com" ]
rajtyagi2718@gmail.com
20232bbea14e7a2bd136edf8cfb7b16c3d20f2ef
86f288b8f540b9e0e1d73b3893ae16ab04b37d80
/4.34/main.cpp
26a52f91bd791d0036973424e25ec0e0c00e326f
[]
no_license
jyfhbc/jiao_yufeng
2308415f4f2774e5592e800dcd242e337b7948c8
cc47f8338cfbb49ce760c734e34af1f5bbe83e21
refs/heads/master
2021-07-07T13:24:25.127585
2019-04-21T10:31:26
2019-04-21T10:31:26
154,145,711
0
0
null
null
null
null
GB18030
C++
false
false
234
cpp
#include <iostream> using namespace std; int main() { double a; double n=1; cout<<"输入非负整数:"; cin>>a; while(a!=0) { n=n*a; a=a-1; } cout<<"n!="<<n<<endl; return 0; }
[ "jiaoyufeng@outlook.com" ]
jiaoyufeng@outlook.com
fad6539f09f6f2fceb90f6edd5846bce7f0f7893
85d205d5dcd2465f3edc2e22caf86b8cce58cab0
/6_week/partition3.cpp
570ac60b969c16715e5af18f39064b1496d8dc04
[]
no_license
Mikefopf/Coursera-Algorithms_Data_Structures-course_1
971c00ebfebc5c5e3f5faa3339750d3825a4007b
140ca52b2c17cd5a66fb5d71e2c99b8f20007380
refs/heads/main
2023-02-28T13:29:16.580260
2021-02-14T11:53:28
2021-02-14T11:53:28
338,775,542
0
0
null
null
null
null
UTF-8
C++
false
false
1,801
cpp
#include <iostream> #include <vector> #include <algorithm> using namespace std; int partition3(vector<int> &A) { //write your code here int sum = 0; vector<int> to_maximise = vector<int>(4, 0); for (int i = 0; i < A.size(); ++i) { sum += A[i]; } if (sum % 3 != 0) { return 0; } sum /= 3; vector<vector<vector<vector<int>>>> opt_sol = vector<vector<vector<vector<int>>>>(A.size() + 1, vector<vector<vector<int>>>(sum + 1, vector<vector<int>>(sum + 1, vector<int>(sum + 1, 0)))); for (int j = 1; j < A.size() + 1; ++j) { for (int i1 = 0; i1 < sum + 1; ++i1) { for (int i2 = 0; i2 < sum + 1; ++i2) { for (int i3 = 0; i3 < sum + 1; ++i3) { to_maximise[0] = opt_sol[j - 1][i1][i2][i3]; to_maximise[1] = 0; to_maximise[2] = 0; to_maximise[3] = 0; if (i1 >= A[j - 1]) { to_maximise[1] = opt_sol[j - 1][i1 - A[j - 1]][i2][i3] + A[j - 1]; } if (i2 >= A[j - 1]) { to_maximise[2] = opt_sol[j - 1][i1][i2 - A[j - 1]][i3] + A[j - 1]; } if (i3 >= A[j - 1]) { to_maximise[3] = opt_sol[j - 1][i1][i2][i3 - A[j - 1]] + A[j - 1]; } opt_sol[j][i1][i2][i3] = *max_element(to_maximise.begin(), to_maximise.end()); } } } } if (opt_sol[A.size()][sum][sum][sum] == 3 * sum) { return 1; } return 0; } int main() { int n; std::cin >> n; vector<int> A(n); for (size_t i = 0; i < A.size(); ++i) { std::cin >> A[i]; } std::cout << partition3(A) << '\n'; }
[ "talmike@mail.ru" ]
talmike@mail.ru
9c28c82df92235b5594801d33c420300c9bcaa66
102611a4bb51d9b932d70dec95895ba6569b1a31
/Source/MeshGen/Public/MeshGenerator.h
f8ef0351c33d7179012f223bc88b5c84a2d2c4ad
[]
no_license
msb336/MeshGen
32bea9492e5edec8f6db5af7ddcbe62551287abb
44fa31d74c44623312da5d58340e37225d4d74ec
refs/heads/master
2020-05-17T03:32:40.208680
2019-06-17T18:54:45
2019-06-17T18:54:45
183,483,459
0
1
null
null
null
null
UTF-8
C++
false
false
1,538
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "GeneratorBase.h" #include "GeneratorFactory.h" #include "CoreMinimal.h" #include "GameFramework/Actor.h" #include "MeshGenerator.generated.h" UCLASS() class MESHGEN_API AMeshGenerator : public AActor { GENERATED_BODY() public: // Sets default values for this actor's properties AMeshGenerator(); private: protected: // Called when the game starts or when spawned virtual void BeginPlay() override; public: // Called every frame virtual void Tick(float DeltaTime) override; private: void update(); void loadFromConfig(); void getPlayerLocation(); void findAdjacentTiles(TileList& adjacent_tiles, const int& level_of_adjacency); RenderingActions getRenderingActions(); void renderTilesAsync(const TileList& tiles_to_render); void derenderTilesAsync(const TileList& tiles_to_derender); void inverseIntersection(const TileList& a, const TileList& b, TileList& unique_to_a, TileList& unique_to_b); //temporary void addWater(const FVector& location); private: std::unique_ptr<GeneratorBase> generator_; GeneratorFactory* generator_factory_ = new GeneratorFactory; std::string configuration_file_ = "MeshGen.ini"; GeneratorBase::ConfigurationSettings* configuration_settings_; Position player_location_; Tile2d player_tile_; TileList loaded_tiles_; TileList rendered_tiles_; private: UPROPERTY() UProceduralMeshComponent* procedural_mesh_component_; UPROPERTY() UMaterialInterface* material_; };
[ "v-mattbr@microsoft.com" ]
v-mattbr@microsoft.com
4861f142bb70ded6943255f8adc5a82f1135fd64
fe1fccfa1b240ae63129390fe3809a4620fcab50
/Win32++/samples/Notepad/src/Mainfrm.cpp
38dae7e226e8791637e0c25c6ca5d2fd4faeeda6
[]
no_license
wyrover/win32pp
d1f4e897818447ad101ce1fb5b61d0cbb591d421
750346ec826e75b26a7640b4632d04d0006f6d6a
refs/heads/master
2021-01-18T08:39:40.095782
2013-09-11T15:40:17
2013-09-11T15:40:17
31,368,732
1
0
null
2015-02-26T13:40:07
2015-02-26T13:40:07
null
UTF-8
C++
false
false
10,752
cpp
///////////////////////////////////////////////// // Mainfrm.cpp #include "stdafx.h" #include "mainfrm.h" #include <richedit.h> #include "resource.h" //For Visual C++ 6 and without a modern SDK #ifndef DWORD_PTR #define DWORD_PTR DWORD #endif // definitions for the CMainFrame class CMainFrame::CMainFrame() { m_strPathName = _T(""); SetView(m_RichView); // Set the registry key name, and load the initial window position // Use a registry key name like "CompanyName\\Application" LoadRegistrySettings(_T("Win32++\\Notepad Sample")); // Load the settings from the registry with 5 MRU entries LoadRegistryMRUSettings(5); } CMainFrame::~CMainFrame() { } void CMainFrame::OnInitialUpdate() { DragAcceptFiles(TRUE); SetWindowTitle(); m_RichView.SetFocus(); } LRESULT CMainFrame::OnNotify(WPARAM wParam, LPARAM lParam) { NMHDR* pNMH; pNMH = (LPNMHDR) lParam; switch (pNMH->code) { case EN_DROPFILES: { ENDROPFILES* ENDrop = (ENDROPFILES*)lParam; HDROP hDropInfo = (HDROP) ENDrop->hDrop; OnDropFiles(hDropInfo); } return TRUE; } return CFrame::OnNotify(wParam, lParam); } BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(lParam); switch (LOWORD(wParam)) { case IDM_FILE_NEW: OnFileNew(); return TRUE; case IDM_FILE_OPEN: OnFileOpen(); return TRUE; case IDM_FILE_SAVE: OnFileSave(); return TRUE; case IDM_FILE_SAVEAS: OnFileSaveAs(); return TRUE; case IDM_FILE_PRINT: OnFilePrint(); return TRUE; case IDM_EDIT_COPY: OnEditCopy(); return TRUE; case IDM_EDIT_PASTE: OnEditPaste(); return TRUE; case IDM_EDIT_CUT: OnEditCut(); return TRUE; case IDM_EDIT_DELETE: OnEditDelete(); return TRUE; case IDM_EDIT_REDO: OnEditRedo(); return TRUE; case IDM_EDIT_UNDO: OnEditUndo(); return TRUE; case IDM_FILE_EXIT: ::PostMessage(m_hWnd, WM_CLOSE, 0, 0); return TRUE; case IDW_VIEW_STATUSBAR: OnViewStatusBar(); return TRUE; case IDW_VIEW_TOOLBAR: OnViewToolBar(); return TRUE; case IDM_HELP_ABOUT: OnHelp(); return TRUE; case IDW_FILE_MRU_FILE1: case IDW_FILE_MRU_FILE2: case IDW_FILE_MRU_FILE3: case IDW_FILE_MRU_FILE4: case IDW_FILE_MRU_FILE5: { UINT nMRUIndex = LOWORD(wParam) - IDW_FILE_MRU_FILE1; CString strMRUText = GetMRUEntry(nMRUIndex); if (ReadFile(strMRUText)) m_strPathName = strMRUText; else RemoveMRUEntry(strMRUText); SetWindowTitle(); return TRUE; } } // switch cmd return FALSE; } // CMainFrame::OnCommand(...) void CMainFrame::OnFileNew() { m_RichView.SetWindowText(_T("")); m_strPathName = _T(""); SetWindowTitle(); m_RichView.SetFontDefaults(); m_RichView.SendMessage(EM_SETMODIFY, FALSE, 0); } void CMainFrame::OnFilePrint() { PRINTDLG pd; // Initialize PRINTDLG ZeroMemory(&pd, sizeof(pd)); pd.lStructSize = sizeof(pd); pd.hwndOwner = m_hWnd; pd.hDevMode = NULL; // Don't forget to free or store hDevMode pd.hDevNames = NULL; // Don't forget to free or store hDevNames pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC; pd.nCopies = 1; pd.nFromPage = 0xFFFF; pd.nToPage = 0xFFFF; pd.nMinPage = 1; pd.nMaxPage = 0xFFFF; pd.hwndOwner = m_hWnd; if (PrintDlg(&pd)==TRUE) { HDC hPrinterDC = pd.hDC; // This code basically taken from MS KB article Q129860 FORMATRANGE fr; int nHorizRes = ::GetDeviceCaps(hPrinterDC, HORZRES); int nVertRes = ::GetDeviceCaps(hPrinterDC, VERTRES); int nLogPixelsX = ::GetDeviceCaps(hPrinterDC, LOGPIXELSX); int nLogPixelsY = ::GetDeviceCaps(hPrinterDC, LOGPIXELSY); LONG lTextLength; // Length of document. LONG lTextPrinted; // Amount of document printed. // Ensure the printer DC is in MM_TEXT mode. ::SetMapMode ( hPrinterDC, MM_TEXT ); // Rendering to the same DC we are measuring. ZeroMemory(&fr, sizeof(fr)); fr.hdc = hPrinterDC; fr.hdcTarget = hPrinterDC; // Set up the page. int margin = 200; // 1440 TWIPS = 1 inch. fr.rcPage.left = fr.rcPage.top = margin; fr.rcPage.right = (nHorizRes/nLogPixelsX) * 1440 - margin; fr.rcPage.bottom = (nVertRes/nLogPixelsY) * 1440 - margin; // Set up margins all around. fr.rc.left = fr.rcPage.left ;//+ 1440; fr.rc.top = fr.rcPage.top ;//+ 1440; fr.rc.right = fr.rcPage.right ;//- 1440; fr.rc.bottom = fr.rcPage.bottom ;//- 1440; // Default the range of text to print as the entire document. fr.chrg.cpMin = 0; fr.chrg.cpMax = -1; m_RichView.SendMessage(EM_FORMATRANGE, true, (LPARAM)&fr); // Set up the print job (standard printing stuff here). DOCINFO di; ZeroMemory(&di, sizeof(di)); di.cbSize = sizeof(DOCINFO); di.lpszDocName = m_strPathName; // Do not print to file. di.lpszOutput = NULL; // Start the document. ::StartDoc(hPrinterDC, &di); GETTEXTLENGTHEX tl; tl.flags = GTL_NUMCHARS; // Find out real size of document in characters. lTextLength = (LONG)m_RichView.SendMessage(EM_GETTEXTLENGTHEX, (WPARAM)&tl, 0L); do { // Start the page. ::StartPage(hPrinterDC); // Print as much text as can fit on a page. The return value is // the index of the first character on the next page. Using TRUE // for the wParam parameter causes the text to be printed. lTextPrinted = (LONG)::SendMessage(m_RichView.GetHwnd(), EM_FORMATRANGE, true, (LPARAM)&fr); m_RichView.SendMessage(EM_DISPLAYBAND, 0, (LPARAM)&fr.rc); // Print last page. ::EndPage(hPrinterDC); // If there is more text to print, adjust the range of characters // to start printing at the first character of the next page. if (lTextPrinted < lTextLength) { fr.chrg.cpMin = (LONG)lTextPrinted; fr.chrg.cpMax = -1; } } while (lTextPrinted < lTextLength); // Tell the control to release cached information. m_RichView.SendMessage(EM_FORMATRANGE, false, 0L); ::EndDoc (hPrinterDC); // Delete DC when done. ::DeleteDC(hPrinterDC); } } void CMainFrame::OnEditCut() { m_RichView.SendMessage(WM_CUT, 0, 0); } void CMainFrame::OnEditCopy() { m_RichView.SendMessage(WM_COPY, 0, 0); } void CMainFrame::OnEditPaste() { m_RichView.SendMessage(EM_PASTESPECIAL, CF_TEXT, 0); } void CMainFrame::OnEditDelete() { m_RichView.SendMessage(WM_CLEAR, 0, 0); } void CMainFrame::OnEditRedo() { m_RichView.SendMessage(EM_REDO, 0, 0); } void CMainFrame::OnEditUndo() { m_RichView.SendMessage(EM_UNDO, 0, 0); } void CMainFrame::OnClose() { //Check for unsaved text BOOL bChanged = (BOOL)m_RichView.SendMessage(EM_GETMODIFY, 0, 0); if (bChanged) if (::MessageBox(NULL, _T("Save changes to this document"), _T("TextEdit"), MB_YESNO | MB_ICONWARNING) == IDYES) OnFileSave(); CFrame::OnClose(); } void CMainFrame::OnDropFiles(HDROP hDropInfo) { TCHAR szFileName[_MAX_PATH]; ::DragQueryFile((HDROP)hDropInfo, 0, (LPTSTR)szFileName, _MAX_PATH); ReadFile(szFileName); } BOOL CMainFrame::ReadFile(LPCTSTR szFileName) { // Open the file for reading CFile File; if (!File.Open(szFileName, OPEN_EXISTING)) { CString str = _T("Failed to load: "); str += szFileName; ::MessageBox(NULL, str, _T("Warning"), MB_ICONWARNING); return FALSE; } //Set default font and color m_RichView.SetFontDefaults(); EDITSTREAM es; es.dwCookie = (DWORD_PTR) File.GetHandle(); es.pfnCallback = (EDITSTREAMCALLBACK) MyStreamInCallback; m_RichView.SendMessage(EM_STREAMIN, SF_TEXT, (LPARAM)&es); //Clear the modified text flag m_RichView.SendMessage(EM_SETMODIFY, FALSE, 0); return TRUE; } BOOL CMainFrame::WriteFile(LPCTSTR szFileName) { // Open the file for writing CFile File; if (!File.Open(szFileName, CREATE_ALWAYS)) { CString str = _T("Failed to write: "); str += szFileName; ::MessageBox(NULL, str, _T("Warning"), MB_ICONWARNING); return FALSE; } EDITSTREAM es; es.dwCookie = (DWORD_PTR) File.GetHandle(); es.dwError = 0; es.pfnCallback = (EDITSTREAMCALLBACK) MyStreamOutCallback; m_RichView.SendMessage(EM_STREAMOUT, SF_TEXT, (LPARAM)&es); //Clear the modified text flag m_RichView.SendMessage(EM_SETMODIFY, FALSE, 0); return TRUE; } void CMainFrame::OnFileOpen() { // szFilters is a text string that includes two file name filters: // "*.my" for "MyType Files" and "*.*' for "All Files." CString Filters( _T("Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0\0"), 46); CFile File; CString str = File.OpenFileDialog(0, OFN_FILEMUSTEXIST, Filters, this); if (!str.IsEmpty()) { ReadFile(str); SetFileName(str); AddMRUEntry(str); SetWindowTitle(); } } void CMainFrame::OnFileSave() { if (m_strPathName == _T("")) OnFileSaveAs(); else WriteFile(m_strPathName); } void CMainFrame::OnFileSaveAs() { // szFilters is a text string that includes two file name filters: // "*.my" for "MyType Files" and "*.*' for "All Files." CString Filters(_T("Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0\0"), 46); CFile File; CString str = File.SaveFileDialog(0, OFN_OVERWRITEPROMPT, Filters, _T("txt"), this); if (!str.IsEmpty()) { WriteFile(str); SetFileName(str); AddMRUEntry(str); SetWindowTitle(); } } void CMainFrame::SetFileName(LPCTSTR szFilePathName) { //Truncate and save file name int i = lstrlen(szFilePathName)+1; while ((--i > 0) && (szFilePathName[i-1] != _T('\\'))); m_strPathName = szFilePathName+i; } void CMainFrame::SetWindowTitle() { CString Title; if (m_strPathName == _T("")) Title = _T("TextEdit - Untitled"); else Title = _T("TextEdit - ") + m_strPathName; SetWindowText(Title); } void CMainFrame::SetupToolBar() { // Define the resource IDs for the toolbar AddToolBarButton( IDM_FILE_NEW ); AddToolBarButton( IDM_FILE_OPEN ); AddToolBarButton( IDM_FILE_SAVE ); AddToolBarButton( 0 ); // Separator AddToolBarButton( IDM_EDIT_CUT ); AddToolBarButton( IDM_EDIT_COPY ); AddToolBarButton( IDM_EDIT_PASTE ); AddToolBarButton( 0 ); // Separator AddToolBarButton( IDM_FILE_PRINT ); AddToolBarButton( 0 ); // Separator AddToolBarButton( IDM_HELP_ABOUT ); } LRESULT CMainFrame::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { // switch (uMsg) // { // // } return WndProcDefault(uMsg, wParam, lParam); } DWORD CALLBACK CMainFrame::MyStreamInCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) { // Required for StreamIn if (!cb) return (1); *pcb = 0; if (!::ReadFile((HANDLE)(DWORD_PTR) dwCookie, pbBuff, cb, (LPDWORD)pcb, NULL)) ::MessageBox(NULL, _T("ReadFile Failed"), _T(""), MB_OK); return 0; } DWORD CALLBACK CMainFrame::MyStreamOutCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) { // Required for StreamOut if(!cb) return (1); *pcb = 0; if (!::WriteFile((HANDLE)(DWORD_PTR)dwCookie, pbBuff, cb, (LPDWORD)pcb, NULL)) ::MessageBox(NULL, _T("WriteFile Failed"), _T(""), MB_OK); return 0; }
[ "saybooboo@gmail.com" ]
saybooboo@gmail.com
888df86931863c9ba65d1632ee03af45498da523
24244185d57d9bfe928d2acf5ad202be210d0686
/TankWar/include/MiniMap.h
e6ac4d5ed74a01ca6bc9557fabc094807bfa7b0a
[]
no_license
AlexSunChen/The_Tank_Game
39aba453d07987981251aa1c5f38426568ceac42
023c332159763788a448b514886fd505ae846f15
refs/heads/master
2021-01-10T18:30:24.968882
2014-10-31T13:16:26
2014-10-31T13:16:26
21,394,674
0
0
null
null
null
null
UTF-8
C++
false
false
2,821
h
/* ----------------------------------------------------------------------------- *********************************************************************** filename: MiniMap.h created: 6/28/2014 author: Sun Chen ************************************************************************ ************************************************************************ ----------------------------------------------------------------------------- */ #pragma once #include <Ogre.h> #include "GUIManager.h" namespace Tank { // Rader size MINI_MAP_SIZE * MINI_MAP_SIZE const static float RADAR_SIZE = 145; // The initial X coordinate pixel radar screen const static float RADAR_POS_X = 10; // The initial Y coordinate pixel radar screen const static float RADAR_POS_Y = 10; // Size enemy in radar const static float RADAR_ENMEY_SIZE = 15; // The maximum range of the radar can detect const static float RADAR_MAX_RADIUS = 50; // Radar display radius const static float RADAR_RADIUS = RADAR_SIZE / 2; // Radar display radius squared const static float RADAR_RADIUS_POW_2 = RADAR_RADIUS * RADAR_RADIUS; // Rader mode enum MINIMAP_MODE { MINIMAP_OVERLOOK, // Bird view display MINIMAP_RADAR, // Radar Display }; class MiniMap { public: MiniMap(Ogre::SceneManager *sceneMgr, Ogre::SceneNode *baseNode, const Ogre::Vector3 &heightOffset); ~MiniMap(); void update(float timeSinceLastFrame); // Add the enemy's radar node void addPoint(const std::string &name); // Remove the enemy's radar node void removePoint(const std::string &name); // With a new enemy in the radar coordinates void updatePoint(const std::string &name, const Ogre::Vector3& pos); // Small map is visible void setVisible(bool visible); private: // Small Scale Map bool onZoomIn(const CEGUI::EventArgs& e) ; // Enlarge map bool onZoomOut(const CEGUI::EventArgs& e) ; // Small map display mode change bool onChangeMode(const CEGUI::EventArgs& e) ; // Overlook mode void createOverLookMode(const std::string &windowName); // Rader mode void createRadarMode(); void updateOverLook(float timeSinceLastFrame); void subscribeEvents(); void setBaseNode(Ogre::SceneNode *baseNode, const Ogre::Vector3 &heightOffset); void showOverLookMode(bool show); void showRadarMode(bool show); private: Ogre::SceneManager *mSceneMgr; Ogre::SceneNode *mBaseNode; Ogre::SceneNode *mCameraNode; Ogre::Camera *mCamera; Ogre::Vector3 mHeightOffset; float mZoomFactor; Ogre::Overlay *mOverlays; Ogre::OverlayContainer *mOverlayRadar; std::map<std::string, Ogre::OverlayElement*> mEnemys; MINIMAP_MODE mMode; }; }
[ "MacForCode" ]
MacForCode
b3f7e74e8fc82cc5c8cfb7adbc146ecf9e9fa7e4
cfd74a0d1f76dcba890d13b639c5e767249ae05e
/tests/testRobotModule.cpp
75ff448b405d4af9e8fe030d053d85cf15fd9298
[ "Qhull", "MIT", "BSD-3-Clause", "BSD-2-Clause" ]
permissive
jrl-umi3218/mc_rtc
4b2f640f439cf766a6d8c224fb803fecc2932c5a
59d714f2598393c5f94ae5395c26c834d2688a76
refs/heads/master
2023-08-31T16:02:25.586881
2023-08-30T11:40:46
2023-08-30T11:40:46
227,037,645
77
30
BSD-2-Clause
2023-09-14T12:04:18
2019-12-10T05:39:23
C++
UTF-8
C++
false
false
3,391
cpp
/* * Copyright 2015-2022 CNRS-UM LIRMM, CNRS-AIST JRL */ #include "utils.h" #include <mc_rbdyn/Robots.h> #include <boost/filesystem.hpp> namespace bfs = boost::filesystem; #include <boost/test/unit_test.hpp> #ifndef JVRC_DESCRIPTION_PATH # error "JVRC_DESCRIPTION_PATH must be defined to build this RobotModule" #endif #define JVRC_VAL(x) #x #define JVRC_VAL_VAL(x) JVRC_VAL(x) static std::string JVRC1_DATA = fmt::format(R"( path: "{}" name: jvrc1 fixed: false default_attitude: [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8275] forceSensors: - name: RightFootForceSensor parentBody: R_ANKLE_P_S X_p_f: rotation: [0, 0, 0] translation: [0, 0, 0] - name: LeftFootForceSensor parentBody: L_ANKLE_P_S X_p_f: rotation: [0, 0, 0] translation: [0, 0, 0] - name: RightHandForceSensor parentBody: R_WRIST_Y_S X_p_f: rotation: [0, 0, 0] translation: [0, 0, 0] - name: LeftHandForceSensor parentBody: L_WRIST_Y_S X_p_f: rotation: [0, 0, 0] translation: [0, 0, 0] bodySensors: - name: Accelerometer parentBody: PELVIS_S X_b_s: rotation: [0, 0, 0] translation: [0, 0, 0] - name: FloatingBase parentBody: PELVIS_S X_b_s: rotation: [0, 0, 0] translation: [0, 0, 0] grippers: - name: l_gripper joints: [L_UTHUMB] reverse_limits: true - name: r_gripper joints: [R_UTHUMB] reverse_limits: false frames: - name: Camera parent: NECK_P_S X_p_f: translation: [0, 0, 0.1] rotation: [3.14, 0, 3.14] - name: Camera_RGB parent: Camera_Depth X_p_f: translation: [-0.2, 0, 0] - name: Camera_Depth parent: Camera X_p_f: translation: [0.1, 0, 0] )", JVRC_VAL_VAL(JVRC_DESCRIPTION_PATH)); BOOST_AUTO_TEST_CASE(TestRobotModule) { auto config = makeConfigFile(JVRC1_DATA, ".yaml"); configureRobotLoader(); auto rm = mc_rbdyn::RobotLoader::get_robot_module("json", config); bfs::remove(config); auto robots = mc_rbdyn::loadRobot(*rm); const auto & robot = robots->robot(); // Check frames loading for(const auto & b : robot.mb().bodies()) { BOOST_REQUIRE(robot.hasFrame(b.name())); } for(const auto & s : robot.surfaces()) { BOOST_REQUIRE(robot.hasFrame(s.first)); } for(const auto & f : {"Camera", "Camera_RGB", "Camera_Depth"}) { BOOST_REQUIRE(robot.hasFrame(f)); } BOOST_REQUIRE(robot.frame("Camera").body() == "NECK_P_S"); BOOST_REQUIRE(robot.frame("Camera").parent()); BOOST_REQUIRE(robot.frame("Camera").parent()->name() == "NECK_P_S"); BOOST_REQUIRE(robot.frame("Camera_Depth").body() == "NECK_P_S"); BOOST_REQUIRE(robot.frame("Camera_Depth").parent()); BOOST_REQUIRE(robot.frame("Camera_Depth").parent()->name() == "Camera"); BOOST_REQUIRE(robot.frame("Camera_RGB").body() == "NECK_P_S"); BOOST_REQUIRE(robot.frame("Camera_RGB").parent()); BOOST_REQUIRE(robot.frame("Camera_RGB").parent()->name() == "Camera_Depth"); // Check grippers BOOST_REQUIRE(robot.module().grippers().size() == 2); // Check force sensors BOOST_REQUIRE(robot.forceSensors().size() == 4); for(const auto & fs : {"RightFootForceSensor", "LeftFootForceSensor", "RightHandForceSensor", "LeftHandForceSensor"}) { BOOST_REQUIRE(robot.hasForceSensor(fs)); } // Check body sensors BOOST_REQUIRE(robot.bodySensors().size() == 2); for(const auto & bs : {"Accelerometer", "FloatingBase"}) { BOOST_REQUIRE(robot.hasBodySensor(bs)); } }
[ "pierre.gergondet@gmail.com" ]
pierre.gergondet@gmail.com
79870863479279749e17995e9e16a5fde662e949
e8f30f981768b0c8bfb697369c422414641b12fa
/MyMusicPlayer/SetAttributesDlgDll.h
3b52add861b0044a2878d7ca127fd51c43c8badf
[]
no_license
niyudan/MusicPlayer
19dfbc44eabb4a47ef017803ee99c16e0fdc41ce
529e02ef3ab7cff8bee3bea88c86fef77d98cc89
refs/heads/master
2022-01-13T19:44:47.733892
2019-07-06T08:37:58
2019-07-06T08:37:58
null
0
0
null
null
null
null
GB18030
C++
false
false
513
h
// SetAttributesDlgDll.h : SetAttributesDlgDll DLL 的主头文件 // #pragma once #ifndef __AFXWIN_H__ #error "在包含此文件之前包含“stdafx.h”以生成 PCH 文件" #endif #include "resource.h" // 主符号 // CSetAttributesDlgDllApp // 有关此类实现的信息,请参阅 SetAttributesDlgDll.cpp // class CSetAttributesDlgDllApp : public CWinApp { public: CSetAttributesDlgDllApp(); // 重写 public: virtual BOOL InitInstance(); DECLARE_MESSAGE_MAP() };
[ "noreply@github.com" ]
niyudan.noreply@github.com
d5f9d23da98ac7ed37b8473e3df00de30b8df8ad
a4b1600ab4e757a253678f4587e39f22f75f1265
/cast/const.cpp
cc73f70ac5cc654d74dde9d907d630d662c11cf2
[]
no_license
chenchukun/CPP
44d8fb93b4fc54ac3c64394b2161044920e18117
bfb5074d8d777e04738451af798085a4437ab420
refs/heads/master
2021-09-09T17:24:43.410927
2018-03-18T13:34:40
2018-03-18T13:34:40
109,701,817
0
0
null
null
null
null
UTF-8
C++
false
false
430
cpp
// // Created by chenchukun on 18/2/2. // #include <iostream> using namespace std; int main() { int x = 10; const int *cpx = &x; // const_cast 可以去掉指向const的指针的const属性 int *px = const_cast<int*>(cpx); *px = 20; cout << x << endl; // 将const引用转为非const引用 const int &cx = x; int &xx = const_cast<int&>(cx); xx = 30; cout << x << endl; return 0; }
[ "916347678@qq.com" ]
916347678@qq.com
2c89f38f66c2167e1ff24648707499ae926a44c1
bdc41588737dc4ba34ef625e86d8807e7b04e631
/Source/basic.cpp
88988fe59905a421749afb623212df570d2016aa
[]
no_license
firodj/wxOgl
23a25c9856acf500cc35db00a35adbab614a0f5d
ffd8b9b16a072ebc5e767e6fb4996d50a0ebe7e8
refs/heads/master
2020-05-14T10:29:43.503698
2019-04-16T20:37:36
2019-04-16T20:37:36
181,762,806
2
0
null
null
null
null
UTF-8
C++
false
false
89,128
cpp
///////////////////////////////////////////////////////////////////////////// // Name: basic.cpp // Purpose: Basic OGL classes // Author: Julian Smart // Modified by: // Created: 12/07/98 // RCS-ID: $Id: basic.cpp,v 1.1 2007/03/28 15:15:56 frm Exp $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP #include "wx/wx.h" #endif #if wxUSE_PROLOGIO #include "wx/deprecated/wxexpr.h" #endif #ifdef new #undef new #endif #include <stdio.h> #include <ctype.h> #include "wx/ogl/ogl.h" // Control point types // Rectangle and most other shapes #define CONTROL_POINT_VERTICAL 1 #define CONTROL_POINT_HORIZONTAL 2 #define CONTROL_POINT_DIAGONAL 3 // Line #define CONTROL_POINT_ENDPOINT_TO 4 #define CONTROL_POINT_ENDPOINT_FROM 5 #define CONTROL_POINT_LINE 6 IMPLEMENT_DYNAMIC_CLASS(wxShapeTextLine, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxAttachmentPoint, wxObject) wxShapeTextLine::wxShapeTextLine(double the_x, double the_y, const wxString& the_line) { m_x = the_x; m_y = the_y; m_line = the_line; } wxShapeTextLine::~wxShapeTextLine() { } IMPLEMENT_ABSTRACT_CLASS(wxShapeEvtHandler, wxObject) wxShapeEvtHandler::wxShapeEvtHandler(wxShapeEvtHandler *prev, wxShape *shape) { m_previousHandler = prev; m_handlerShape = shape; } wxShapeEvtHandler::~wxShapeEvtHandler() { } // Creates a copy of this event handler. wxShapeEvtHandler* wxShapeEvtHandler::CreateNewCopy() { wxShapeEvtHandler* newObject = (wxShapeEvtHandler*) GetClassInfo()->CreateObject(); wxASSERT( (newObject != NULL) ); wxASSERT( (newObject->IsKindOf(CLASSINFO(wxShapeEvtHandler))) ); newObject->m_previousHandler = newObject; CopyData(*newObject); return newObject; } void wxShapeEvtHandler::OnDelete() { if (this != GetShape()) delete this; } void wxShapeEvtHandler::OnDraw(wxDC& dc) { if (m_previousHandler) m_previousHandler->OnDraw(dc); } void wxShapeEvtHandler::OnMoveLinks(wxDC& dc) { if (m_previousHandler) m_previousHandler->OnMoveLinks(dc); } void wxShapeEvtHandler::OnMoveLink(wxDC& dc, bool moveControlPoints) { if (m_previousHandler) m_previousHandler->OnMoveLink(dc, moveControlPoints); } void wxShapeEvtHandler::OnDrawContents(wxDC& dc) { if (m_previousHandler) m_previousHandler->OnDrawContents(dc); } void wxShapeEvtHandler::OnDrawBranches(wxDC& dc, bool erase) { if (m_previousHandler) m_previousHandler->OnDrawBranches(dc, erase); } void wxShapeEvtHandler::OnSize(double x, double y) { if (m_previousHandler) m_previousHandler->OnSize(x, y); } bool wxShapeEvtHandler::OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display) { if (m_previousHandler) return m_previousHandler->OnMovePre(dc, x, y, old_x, old_y, display); else return true; } void wxShapeEvtHandler::OnMovePost(wxDC& dc, double x, double y, double old_x, double old_y, bool display) { if (m_previousHandler) m_previousHandler->OnMovePost(dc, x, y, old_x, old_y, display); } void wxShapeEvtHandler::OnErase(wxDC& dc) { if (m_previousHandler) m_previousHandler->OnErase(dc); } void wxShapeEvtHandler::OnEraseContents(wxDC& dc) { if (m_previousHandler) m_previousHandler->OnEraseContents(dc); } void wxShapeEvtHandler::OnHighlight(wxDC& dc) { if (m_previousHandler) m_previousHandler->OnHighlight(dc); } void wxShapeEvtHandler::OnLeftClick(double x, double y, int keys, int attachment) { if (m_previousHandler) m_previousHandler->OnLeftClick(x, y, keys, attachment); } void wxShapeEvtHandler::OnLeftDoubleClick(double x, double y, int keys, int attachment) { if (m_previousHandler) m_previousHandler->OnLeftDoubleClick(x, y, keys, attachment); } void wxShapeEvtHandler::OnRightClick(double x, double y, int keys, int attachment) { if (m_previousHandler) m_previousHandler->OnRightClick(x, y, keys, attachment); } void wxShapeEvtHandler::OnDragLeft(bool draw, double x, double y, int keys, int attachment) { if (m_previousHandler) m_previousHandler->OnDragLeft(draw, x, y, keys, attachment); } void wxShapeEvtHandler::OnBeginDragLeft(double x, double y, int keys, int attachment) { if (m_previousHandler) m_previousHandler->OnBeginDragLeft(x, y, keys, attachment); } void wxShapeEvtHandler::OnEndDragLeft(double x, double y, int keys, int attachment) { if (m_previousHandler) m_previousHandler->OnEndDragLeft(x, y, keys, attachment); } void wxShapeEvtHandler::OnDragRight(bool draw, double x, double y, int keys, int attachment) { if (m_previousHandler) m_previousHandler->OnDragRight(draw, x, y, keys, attachment); } void wxShapeEvtHandler::OnBeginDragRight(double x, double y, int keys, int attachment) { if (m_previousHandler) m_previousHandler->OnBeginDragRight(x, y, keys, attachment); } void wxShapeEvtHandler::OnEndDragRight(double x, double y, int keys, int attachment) { if (m_previousHandler) m_previousHandler->OnEndDragRight(x, y, keys, attachment); } // Control points ('handles') redirect control to the actual shape, to make it easier // to override sizing behaviour. void wxShapeEvtHandler::OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys, int attachment) { if (m_previousHandler) m_previousHandler->OnSizingDragLeft(pt, draw, x, y, keys, attachment); } void wxShapeEvtHandler::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys, int attachment) { if (m_previousHandler) m_previousHandler->OnSizingBeginDragLeft(pt, x, y, keys, attachment); } void wxShapeEvtHandler::OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys, int attachment) { if (m_previousHandler) m_previousHandler->OnSizingEndDragLeft(pt, x, y, keys, attachment); } void wxShapeEvtHandler::OnDrawOutline(wxDC& dc, double x, double y, double w, double h) { if (m_previousHandler) m_previousHandler->OnDrawOutline(dc, x, y, w, h); } void wxShapeEvtHandler::OnDrawControlPoints(wxDC& dc) { if (m_previousHandler) m_previousHandler->OnDrawControlPoints(dc); } void wxShapeEvtHandler::OnEraseControlPoints(wxDC& dc) { if (m_previousHandler) m_previousHandler->OnEraseControlPoints(dc); } // Can override this to prevent or intercept line reordering. void wxShapeEvtHandler::OnChangeAttachment(int attachment, wxLineShape* line, wxList& ordering) { if (m_previousHandler) m_previousHandler->OnChangeAttachment(attachment, line, ordering); } IMPLEMENT_ABSTRACT_CLASS(wxShape, wxShapeEvtHandler) wxShape::wxShape(wxShapeCanvas *can) { m_eventHandler = this; SetShape(this); m_id = 0; m_formatted = false; m_canvas = can; m_xpos = 0.0; m_ypos = 0.0; m_pen = g_oglBlackPen; m_brush = wxWHITE_BRUSH; m_font = g_oglNormalFont; m_textColour = wxT("BLACK"); m_textColourName = wxT("BLACK"); m_visible = false; m_selected = false; m_attachmentMode = ATTACHMENT_MODE_NONE; m_spaceAttachments = true; m_disableLabel = false; m_fixedWidth = false; m_fixedHeight = false; m_drawHandles = true; m_sensitivity = OP_ALL; m_draggable = true; m_parent = NULL; m_formatMode = FORMAT_CENTRE_HORIZ | FORMAT_CENTRE_VERT; m_shadowMode = SHADOW_NONE; m_shadowOffsetX = 6; m_shadowOffsetY = 6; m_shadowBrush = wxBLACK_BRUSH; m_textMarginX = 5; m_textMarginY = 5; m_regionName = wxT("0"); m_centreResize = true; m_maintainAspectRatio = false; m_highlighted = false; m_rotation = 0.0; m_branchNeckLength = 10; m_branchStemLength = 10; m_branchSpacing = 10; m_branchStyle = BRANCHING_ATTACHMENT_NORMAL; // Set up a default region. Much of the above will be put into // the region eventually (the duplication is for compatibility) wxShapeRegion *region = new wxShapeRegion; m_regions.Append(region); region->SetName(wxT("0")); region->SetFont(g_oglNormalFont); region->SetFormatMode(FORMAT_CENTRE_HORIZ | FORMAT_CENTRE_VERT); region->SetColour(wxT("BLACK")); } wxShape::~wxShape() { if (m_parent) m_parent->GetChildren().DeleteObject(this); ClearText(); ClearRegions(); ClearAttachments(); if (m_canvas) m_canvas->RemoveShape(this); GetEventHandler()->OnDelete(); } void wxShape::SetHighlight(bool hi, bool recurse) { m_highlighted = hi; if (recurse) { wxNode *node = m_children.GetFirst(); while (node) { wxShape *child = (wxShape *)node->GetData(); child->SetHighlight(hi, recurse); node = node->GetNext(); } } } void wxShape::SetSensitivityFilter(int sens, bool recursive) { if (sens & OP_DRAG_LEFT) m_draggable = true; else m_draggable = false; m_sensitivity = sens; if (recursive) { wxNode *node = m_children.GetFirst(); while (node) { wxShape *obj = (wxShape *)node->GetData(); obj->SetSensitivityFilter(sens, true); node = node->GetNext(); } } } void wxShape::SetDraggable(bool drag, bool recursive) { m_draggable = drag; if (m_draggable) m_sensitivity |= OP_DRAG_LEFT; else if (m_sensitivity & OP_DRAG_LEFT) m_sensitivity = m_sensitivity - OP_DRAG_LEFT; if (recursive) { wxNode *node = m_children.GetFirst(); while (node) { wxShape *obj = (wxShape *)node->GetData(); obj->SetDraggable(drag, true); node = node->GetNext(); } } } void wxShape::SetDrawHandles(bool drawH) { m_drawHandles = drawH; wxNode *node = m_children.GetFirst(); while (node) { wxShape *obj = (wxShape *)node->GetData(); obj->SetDrawHandles(drawH); node = node->GetNext(); } } void wxShape::SetShadowMode(int mode, bool redraw) { if (redraw && GetCanvas()) { wxClientDC dc(GetCanvas()); GetCanvas()->PrepareDC(dc); Erase(dc); m_shadowMode = mode; Draw(dc); } else { m_shadowMode = mode; } } void wxShape::SetCanvas(wxShapeCanvas *theCanvas) { m_canvas = theCanvas; wxNode *node = m_children.GetFirst(); while (node) { wxShape *child = (wxShape *)node->GetData(); child->SetCanvas(theCanvas); node = node->GetNext(); } } void wxShape::AddToCanvas(wxShapeCanvas *theCanvas, wxShape *addAfter) { theCanvas->AddShape(this, addAfter); wxNode *node = m_children.GetFirst(); wxShape *lastImage = this; while (node) { wxShape *object = (wxShape *)node->GetData(); object->AddToCanvas(theCanvas, lastImage); lastImage = object; node = node->GetNext(); } } // Insert at front of canvas void wxShape::InsertInCanvas(wxShapeCanvas *theCanvas) { theCanvas->InsertShape(this); wxNode *node = m_children.GetFirst(); wxShape *lastImage = this; while (node) { wxShape *object = (wxShape *)node->GetData(); object->AddToCanvas(theCanvas, lastImage); lastImage = object; node = node->GetNext(); } } void wxShape::RemoveFromCanvas(wxShapeCanvas *theCanvas) { if (Selected()) Select(false); theCanvas->RemoveShape(this); wxNode *node = m_children.GetFirst(); while (node) { wxShape *object = (wxShape *)node->GetData(); object->RemoveFromCanvas(theCanvas); node = node->GetNext(); } } void wxShape::ClearAttachments() { wxNode *node = m_attachmentPoints.GetFirst(); while (node) { wxAttachmentPoint *point = (wxAttachmentPoint *)node->GetData(); delete point; node = node->GetNext(); } m_attachmentPoints.Clear(); } void wxShape::ClearText(int regionId) { if (regionId == 0) { m_text.DeleteContents(true); m_text.Clear(); m_text.DeleteContents(false); } wxNode *node = m_regions.Item(regionId); if (!node) return; wxShapeRegion *region = (wxShapeRegion *)node->GetData(); region->ClearText(); } void wxShape::ClearRegions() { wxNode *node = m_regions.GetFirst(); while (node) { wxShapeRegion *region = (wxShapeRegion *)node->GetData(); wxNode *next = node->GetNext(); delete region; delete node; node = next; } } void wxShape::AddRegion(wxShapeRegion *region) { m_regions.Append(region); } void wxShape::SetDefaultRegionSize() { wxNode *node = m_regions.GetFirst(); if (!node) return; wxShapeRegion *region = (wxShapeRegion *)node->GetData(); double w, h; GetBoundingBoxMin(&w, &h); region->SetSize(w, h); } bool wxShape::HitTest(double x, double y, int *attachment, double *distance) { // if (!sensitive) // return false; double width = 0.0, height = 0.0; GetBoundingBoxMin(&width, &height); if (fabs(width) < 4.0) width = 4.0; if (fabs(height) < 4.0) height = 4.0; width += (double)4.0; height += (double)4.0; // Allowance for inaccurate mousing double left = (double)(m_xpos - (width/2.0)); double top = (double)(m_ypos - (height/2.0)); double right = (double)(m_xpos + (width/2.0)); double bottom = (double)(m_ypos + (height/2.0)); int nearest_attachment = 0; // If within the bounding box, check the attachment points // within the object. if (x >= left && x <= right && y >= top && y <= bottom) { int n = GetNumberOfAttachments(); double nearest = 999999.0; // GetAttachmentPosition[Edge] takes a logical attachment position, // i.e. if it's rotated through 90%, position 0 is East-facing. for (int i = 0; i < n; i++) { double xp, yp; if (GetAttachmentPositionEdge(i, &xp, &yp)) { double l = (double)sqrt(((xp - x) * (xp - x)) + ((yp - y) * (yp - y))); if (l < nearest) { nearest = l; nearest_attachment = i; } } } *attachment = nearest_attachment; *distance = nearest; return true; } else return false; } // Format a text string according to the region size, adding // strings with positions to region text list static bool GraphicsInSizeToContents = false; // Infinite recursion elimination void wxShape::FormatText(wxDC& dc, const wxString& s, int i) { double w, h; ClearText(i); if (m_regions.GetCount() < 1) return; wxNode *node = m_regions.Item(i); if (!node) return; wxShapeRegion *region = (wxShapeRegion *)node->GetData(); // region->SetText(s); // don't set the formatted text yet, it will be done below region->m_regionText = s; dc.SetFont(* region->GetFont()); region->GetSize(&w, &h); wxStringList *stringList = oglFormatText(dc, s, (w-2*m_textMarginX), (h-2*m_textMarginY), region->GetFormatMode()); node = (wxNode*)stringList->GetFirst(); while (node) { wxChar *s = (wxChar *)node->GetData(); wxShapeTextLine *line = new wxShapeTextLine(0.0, 0.0, s); region->GetFormattedText().Append((wxObject *)line); node = node->GetNext(); } delete stringList; double actualW = w; double actualH = h; // Don't try to resize an object with more than one image (this case should be dealt // with by overriden handlers) if ((region->GetFormatMode() & FORMAT_SIZE_TO_CONTENTS) && (region->GetFormattedText().GetCount() > 0) && (m_regions.GetCount() == 1) && !GraphicsInSizeToContents) { oglGetCentredTextExtent(dc, &(region->GetFormattedText()), m_xpos, m_ypos, w, h, &actualW, &actualH); if ((actualW+2*m_textMarginX != w ) || (actualH+2*m_textMarginY != h)) { // If we are a descendant of a composite, must make sure the composite gets // resized properly wxShape *topAncestor = GetTopAncestor(); if (topAncestor != this) { // Make sure we don't recurse infinitely GraphicsInSizeToContents = true; wxCompositeShape *composite = (wxCompositeShape *)topAncestor; composite->Erase(dc); SetSize(actualW+2*m_textMarginX, actualH+2*m_textMarginY); Move(dc, m_xpos, m_ypos); composite->CalculateSize(); if (composite->Selected()) { composite->DeleteControlPoints(& dc); composite->MakeControlPoints(); composite->MakeMandatoryControlPoints(); } // Where infinite recursion might happen if we didn't stop it composite->Draw(dc); GraphicsInSizeToContents = false; } else { Erase(dc); SetSize(actualW+2*m_textMarginX, actualH+2*m_textMarginY); Move(dc, m_xpos, m_ypos); } SetSize(actualW+2*m_textMarginX, actualH+2*m_textMarginY); Move(dc, m_xpos, m_ypos); EraseContents(dc); } } oglCentreText(dc, &(region->GetFormattedText()), m_xpos, m_ypos, actualW-2*m_textMarginX, actualH-2*m_textMarginY, region->GetFormatMode()); m_formatted = true; } void wxShape::Recentre(wxDC& dc) { double w, h; GetBoundingBoxMin(&w, &h); int noRegions = m_regions.GetCount(); for (int i = 0; i < noRegions; i++) { wxNode *node = m_regions.Item(i); if (node) { wxShapeRegion *region = (wxShapeRegion *)node->GetData(); oglCentreText(dc, &(region->GetFormattedText()), m_xpos, m_ypos, w-2*m_textMarginX, h-2*m_textMarginY, region->GetFormatMode()); } } } bool wxShape::GetPerimeterPoint(double WXUNUSED(x1), double WXUNUSED(y1), double WXUNUSED(x2), double WXUNUSED(y2), double *WXUNUSED(x3), double *WXUNUSED(y3)) { return false; } void wxShape::SetPen(const wxPen *the_pen) { m_pen = the_pen; } void wxShape::SetBrush(const wxBrush *the_brush) { m_brush = the_brush; } // Get the top-most (non-division) ancestor, or self wxShape *wxShape::GetTopAncestor() { if (!GetParent()) return this; if (GetParent()->IsKindOf(CLASSINFO(wxDivisionShape))) return this; else return GetParent()->GetTopAncestor(); } /* * Region functions * */ void wxShape::SetFont(wxFont *the_font, int regionId) { m_font = the_font; wxNode *node = m_regions.Item(regionId); if (!node) return; wxShapeRegion *region = (wxShapeRegion *)node->GetData(); region->SetFont(the_font); } wxFont *wxShape::GetFont(int n) const { wxNode *node = m_regions.Item(n); if (!node) return NULL; wxShapeRegion *region = (wxShapeRegion *)node->GetData(); return region->GetFont(); } void wxShape::SetFormatMode(int mode, int regionId) { wxNode *node = m_regions.Item(regionId); if (!node) return; wxShapeRegion *region = (wxShapeRegion *)node->GetData(); region->SetFormatMode(mode); } int wxShape::GetFormatMode(int regionId) const { wxNode *node = m_regions.Item(regionId); if (!node) return 0; wxShapeRegion *region = (wxShapeRegion *)node->GetData(); return region->GetFormatMode(); } void wxShape::SetTextColour(const wxString& the_colour, int regionId) { m_textColour = wxTheColourDatabase->Find(the_colour); m_textColourName = the_colour; wxNode *node = m_regions.Item(regionId); if (!node) return; wxShapeRegion *region = (wxShapeRegion *)node->GetData(); region->SetColour(the_colour); } wxString wxShape::GetTextColour(int regionId) const { wxNode *node = m_regions.Item(regionId); if (!node) return wxEmptyString; wxShapeRegion *region = (wxShapeRegion *)node->GetData(); return region->GetColour(); } void wxShape::SetRegionName(const wxString& name, int regionId) { wxNode *node = m_regions.Item(regionId); if (!node) return; wxShapeRegion *region = (wxShapeRegion *)node->GetData(); region->SetName(name); } wxString wxShape::GetRegionName(int regionId) { wxNode *node = m_regions.Item(regionId); if (!node) return wxEmptyString; wxShapeRegion *region = (wxShapeRegion *)node->GetData(); return region->GetName(); } int wxShape::GetRegionId(const wxString& name) { wxNode *node = m_regions.GetFirst(); int i = 0; while (node) { wxShapeRegion *region = (wxShapeRegion *)node->GetData(); if (region->GetName() == name) return i; node = node->GetNext(); i ++; } return -1; } // Name all m_regions in all subimages recursively. void wxShape::NameRegions(const wxString& parentName) { int n = GetNumberOfTextRegions(); wxString buff; for (int i = 0; i < n; i++) { if (parentName.Length() > 0) buff << parentName << wxT(".") << i; else buff << i; SetRegionName(buff, i); } wxNode *node = m_children.GetFirst(); int j = 0; while (node) { buff.Empty(); wxShape *child = (wxShape *)node->GetData(); if (parentName.Length() > 0) buff << parentName << wxT(".") << j; else buff << j; child->NameRegions(buff); node = node->GetNext(); j ++; } } // Get a region by name, possibly looking recursively into composites. wxShape *wxShape::FindRegion(const wxString& name, int *regionId) { int id = GetRegionId(name); if (id > -1) { *regionId = id; return this; } wxNode *node = m_children.GetFirst(); while (node) { wxShape *child = (wxShape *)node->GetData(); wxShape *actualImage = child->FindRegion(name, regionId); if (actualImage) return actualImage; node = node->GetNext(); } return NULL; } // Finds all region names for this image (composite or simple). // Supply empty string list. void wxShape::FindRegionNames(wxStringList& list) { int n = GetNumberOfTextRegions(); for (int i = 0; i < n; i++) { wxString name(GetRegionName(i)); list.Add(name); } wxNode *node = m_children.GetFirst(); while (node) { wxShape *child = (wxShape *)node->GetData(); child->FindRegionNames(list); node = node->GetNext(); } } void wxShape::AssignNewIds() { // if (m_id == 0) m_id = wxNewId(); wxNode *node = m_children.GetFirst(); while (node) { wxShape *child = (wxShape *)node->GetData(); child->AssignNewIds(); node = node->GetNext(); } } void wxShape::OnDraw(wxDC& WXUNUSED(dc)) { } void wxShape::OnMoveLinks(wxDC& dc) { // Want to set the ends of all attached links // to point to/from this object wxNode *current = m_lines.GetFirst(); while (current) { wxLineShape *line = (wxLineShape *)current->GetData(); line->GetEventHandler()->OnMoveLink(dc); current = current->GetNext(); } } void wxShape::OnDrawContents(wxDC& dc) { double bound_x, bound_y; GetBoundingBoxMin(&bound_x, &bound_y); if (m_regions.GetCount() < 1) return; if (m_pen) dc.SetPen(* m_pen); wxShapeRegion *region = (wxShapeRegion *)m_regions.GetFirst()->GetData(); if (region->GetFont()) dc.SetFont(* region->GetFont()); dc.SetTextForeground(region->GetActualColourObject()); dc.SetBackgroundMode(wxTRANSPARENT); if (!m_formatted) { oglCentreText(dc, &(region->GetFormattedText()), m_xpos, m_ypos, bound_x-2*m_textMarginX, bound_y-2*m_textMarginY, region->GetFormatMode()); m_formatted = true; } if (!GetDisableLabel()) { oglDrawFormattedText(dc, &(region->GetFormattedText()), m_xpos, m_ypos, bound_x-2*m_textMarginX, bound_y-2*m_textMarginY, region->GetFormatMode()); } } void wxShape::DrawContents(wxDC& dc) { GetEventHandler()->OnDrawContents(dc); } void wxShape::OnSize(double WXUNUSED(x), double WXUNUSED(y)) { } bool wxShape::OnMovePre(wxDC& WXUNUSED(dc), double WXUNUSED(x), double WXUNUSED(y), double WXUNUSED(old_x), double WXUNUSED(old_y), bool WXUNUSED(display)) { return true; } void wxShape::OnMovePost(wxDC& WXUNUSED(dc), double WXUNUSED(x), double WXUNUSED(y), double WXUNUSED(old_x), double WXUNUSED(old_y), bool WXUNUSED(display)) { } void wxShape::OnErase(wxDC& dc) { if (!m_visible) return; // Erase links wxNode *current = m_lines.GetFirst(); while (current) { wxLineShape *line = (wxLineShape *)current->GetData(); line->GetEventHandler()->OnErase(dc); current = current->GetNext(); } GetEventHandler()->OnEraseContents(dc); } void wxShape::OnEraseContents(wxDC& dc) { if (!m_visible) return; double maxX, maxY, minX, minY; double xp = GetX(); double yp = GetY(); GetBoundingBoxMin(&minX, &minY); GetBoundingBoxMax(&maxX, &maxY); double topLeftX = (double)(xp - (maxX / 2.0) - 2.0); double topLeftY = (double)(yp - (maxY / 2.0) - 2.0); int penWidth = 0; if (m_pen) penWidth = m_pen->GetWidth(); dc.SetPen(GetBackgroundPen()); dc.SetBrush(GetBackgroundBrush()); dc.DrawRectangle(WXROUND(topLeftX - penWidth), WXROUND(topLeftY - penWidth), WXROUND(maxX + penWidth*2.0 + 4.0), WXROUND(maxY + penWidth*2.0 + 4.0)); } void wxShape::EraseLinks(wxDC& dc, int attachment, bool recurse) { if (!m_visible) return; wxNode *current = m_lines.GetFirst(); while (current) { wxLineShape *line = (wxLineShape *)current->GetData(); if (attachment == -1 || ((line->GetTo() == this && line->GetAttachmentTo() == attachment) || (line->GetFrom() == this && line->GetAttachmentFrom() == attachment))) line->GetEventHandler()->OnErase(dc); current = current->GetNext(); } if (recurse) { wxNode *node = m_children.GetFirst(); while (node) { wxShape *child = (wxShape *)node->GetData(); child->EraseLinks(dc, attachment, recurse); node = node->GetNext(); } } } void wxShape::DrawLinks(wxDC& dc, int attachment, bool recurse) { if (!m_visible) return; wxNode *current = m_lines.GetFirst(); while (current) { wxLineShape *line = (wxLineShape *)current->GetData(); if (attachment == -1 || (line->GetTo() == this && line->GetAttachmentTo() == attachment) || (line->GetFrom() == this && line->GetAttachmentFrom() == attachment)) line->Draw(dc); current = current->GetNext(); } if (recurse) { wxNode *node = m_children.GetFirst(); while (node) { wxShape *child = (wxShape *)node->GetData(); child->DrawLinks(dc, attachment, recurse); node = node->GetNext(); } } } // Returns true if pt1 <= pt2 in the sense that one point comes before another on an // edge of the shape. // attachmentPoint is the attachment point (= side) in question. // This is the default, rectangular implementation. bool wxShape::AttachmentSortTest(int attachmentPoint, const wxRealPoint& pt1, const wxRealPoint& pt2) { int physicalAttachment = LogicalToPhysicalAttachment(attachmentPoint); switch (physicalAttachment) { case 0: case 2: { return (pt1.x <= pt2.x) ; } case 1: case 3: { return (pt1.y <= pt2.y) ; } } return false; } bool wxShape::MoveLineToNewAttachment(wxDC& dc, wxLineShape *to_move, double x, double y) { if (GetAttachmentMode() == ATTACHMENT_MODE_NONE) return false; int newAttachment, oldAttachment; double distance; // Is (x, y) on this object? If so, find the new attachment point // the user has moved the point to bool hit = HitTest(x, y, &newAttachment, &distance); if (!hit) return false; EraseLinks(dc); if (to_move->GetTo() == this) oldAttachment = to_move->GetAttachmentTo(); else oldAttachment = to_move->GetAttachmentFrom(); // The links in a new ordering. wxList newOrdering; // First, add all links to the new list. wxNode *node = m_lines.GetFirst(); while (node) { newOrdering.Append(node->GetData()); node = node->GetNext(); } // Delete the line object from the list of links; we're going to move // it to another position in the list newOrdering.DeleteObject(to_move); double old_x = (double) -99999.9; double old_y = (double) -99999.9; node = newOrdering.GetFirst(); bool found = false; while (!found && node) { wxLineShape *line = (wxLineShape *)node->GetData(); if ((line->GetTo() == this && oldAttachment == line->GetAttachmentTo()) || (line->GetFrom() == this && oldAttachment == line->GetAttachmentFrom())) { double startX, startY, endX, endY; double xp, yp; line->GetEnds(&startX, &startY, &endX, &endY); if (line->GetTo() == this) { xp = endX; yp = endY; } else { xp = startX; yp = startY; } wxRealPoint thisPoint(xp, yp); wxRealPoint lastPoint(old_x, old_y); wxRealPoint newPoint(x, y); if (AttachmentSortTest(newAttachment, newPoint, thisPoint) && AttachmentSortTest(newAttachment, lastPoint, newPoint)) { found = true; newOrdering.Insert(node, to_move); } old_x = xp; old_y = yp; } node = node->GetNext(); } if (!found) newOrdering.Append(to_move); GetEventHandler()->OnChangeAttachment(newAttachment, to_move, newOrdering); return true; } void wxShape::OnChangeAttachment(int attachment, wxLineShape* line, wxList& ordering) { if (line->GetTo() == this) line->SetAttachmentTo(attachment); else line->SetAttachmentFrom(attachment); ApplyAttachmentOrdering(ordering); wxClientDC dc(GetCanvas()); GetCanvas()->PrepareDC(dc); MoveLinks(dc); if (!GetCanvas()->GetQuickEditMode()) GetCanvas()->Redraw(dc); } // Reorders the lines according to the given list. void wxShape::ApplyAttachmentOrdering(wxList& linesToSort) { // This is a temporary store of all the lines. wxList linesStore; wxNode *node = m_lines.GetFirst(); while (node) { wxLineShape *line = (wxLineShape *)node->GetData(); linesStore.Append(line); node = node->GetNext();; } m_lines.Clear(); node = linesToSort.GetFirst(); while (node) { wxLineShape *line = (wxLineShape *)node->GetData(); if (linesStore.Member(line)) { // Done this one linesStore.DeleteObject(line); m_lines.Append(line); } node = node->GetNext(); } // Now add any lines that haven't been listed in linesToSort. node = linesStore.GetFirst(); while (node) { wxLineShape *line = (wxLineShape *)node->GetData(); m_lines.Append(line); node = node->GetNext(); } } // Reorders the lines coming into the node image at this attachment // position, in the order in which they appear in linesToSort. // Any remaining lines not in the list will be added to the end. void wxShape::SortLines(int attachment, wxList& linesToSort) { // This is a temporary store of all the lines at this attachment // point. We'll tick them off as we've processed them. wxList linesAtThisAttachment; wxNode *node = m_lines.GetFirst(); while (node) { wxLineShape *line = (wxLineShape *)node->GetData(); wxNode *next = node->GetNext(); if ((line->GetTo() == this && line->GetAttachmentTo() == attachment) || (line->GetFrom() == this && line->GetAttachmentFrom() == attachment)) { linesAtThisAttachment.Append(line); delete node; node = next; } else node = node->GetNext(); } node = linesToSort.GetFirst(); while (node) { wxLineShape *line = (wxLineShape *)node->GetData(); if (linesAtThisAttachment.Member(line)) { // Done this one linesAtThisAttachment.DeleteObject(line); m_lines.Append(line); } node = node->GetNext(); } // Now add any lines that haven't been listed in linesToSort. node = linesAtThisAttachment.GetFirst(); while (node) { wxLineShape *line = (wxLineShape *)node->GetData(); m_lines.Append(line); node = node->GetNext(); } } void wxShape::OnHighlight(wxDC& WXUNUSED(dc)) { } void wxShape::OnLeftClick(double x, double y, int keys, int attachment) { if ((m_sensitivity & OP_CLICK_LEFT) != OP_CLICK_LEFT) { attachment = 0; double dist; if (m_parent) { m_parent->HitTest(x, y, &attachment, &dist); m_parent->GetEventHandler()->OnLeftClick(x, y, keys, attachment); } return; } } void wxShape::OnRightClick(double x, double y, int keys, int attachment) { if ((m_sensitivity & OP_CLICK_RIGHT) != OP_CLICK_RIGHT) { attachment = 0; double dist; if (m_parent) { m_parent->HitTest(x, y, &attachment, &dist); m_parent->GetEventHandler()->OnRightClick(x, y, keys, attachment); } return; } } double DragOffsetX = 0.0; double DragOffsetY = 0.0; void wxShape::OnDragLeft(bool draw, double x, double y, int keys, int attachment) { if ((m_sensitivity & OP_DRAG_LEFT) != OP_DRAG_LEFT) { attachment = 0; double dist; if (m_parent) { m_parent->HitTest(x, y, &attachment, &dist); m_parent->GetEventHandler()->OnDragLeft(draw, x, y, keys, attachment); } return; } wxClientDC dc(GetCanvas()); GetCanvas()->PrepareDC(dc); dc.SetLogicalFunction(OGLRBLF); wxPen dottedPen(*wxBLACK, 1, wxPENSTYLE_DOT); dc.SetPen(dottedPen); dc.SetBrush(* wxTRANSPARENT_BRUSH); double xx, yy; xx = x + DragOffsetX; yy = y + DragOffsetY; m_canvas->Snap(&xx, &yy); // m_xpos = xx; m_ypos = yy; double w, h; GetBoundingBoxMax(&w, &h); GetEventHandler()->OnDrawOutline(dc, xx, yy, w, h); } void wxShape::OnBeginDragLeft(double x, double y, int keys, int attachment) { if ((m_sensitivity & OP_DRAG_LEFT) != OP_DRAG_LEFT) { attachment = 0; double dist; if (m_parent) { m_parent->HitTest(x, y, &attachment, &dist); m_parent->GetEventHandler()->OnBeginDragLeft(x, y, keys, attachment); } return; } DragOffsetX = m_xpos - x; DragOffsetY = m_ypos - y; wxClientDC dc(GetCanvas()); GetCanvas()->PrepareDC(dc); // New policy: don't erase shape until end of drag. // Erase(dc); double xx, yy; xx = x + DragOffsetX; yy = y + DragOffsetY; m_canvas->Snap(&xx, &yy); // m_xpos = xx; m_ypos = yy; dc.SetLogicalFunction(OGLRBLF); wxPen dottedPen(*wxBLACK, 1, wxPENSTYLE_DOT); dc.SetPen(dottedPen); dc.SetBrush((* wxTRANSPARENT_BRUSH)); double w, h; GetBoundingBoxMax(&w, &h); GetEventHandler()->OnDrawOutline(dc, xx, yy, w, h); m_canvas->CaptureMouse(); } void wxShape::OnEndDragLeft(double x, double y, int keys, int attachment) { if (!m_draggable) return; m_canvas->ReleaseMouse(); if ((m_sensitivity & OP_DRAG_LEFT) != OP_DRAG_LEFT) { attachment = 0; double dist; if (m_parent) { m_parent->HitTest(x, y, &attachment, &dist); m_parent->GetEventHandler()->OnEndDragLeft(x, y, keys, attachment); } return; } wxClientDC dc(GetCanvas()); GetCanvas()->PrepareDC(dc); dc.SetLogicalFunction(wxCOPY); double xx = x + DragOffsetX; double yy = y + DragOffsetY; m_canvas->Snap(&xx, &yy); // canvas->Snap(&m_xpos, &m_ypos); // New policy: erase shape at end of drag. Erase(dc); Move(dc, xx, yy); if (m_canvas && !m_canvas->GetQuickEditMode()) m_canvas->Redraw(dc); } void wxShape::OnDragRight(bool draw, double x, double y, int keys, int attachment) { if ((m_sensitivity & OP_DRAG_RIGHT) != OP_DRAG_RIGHT) { attachment = 0; double dist; if (m_parent) { m_parent->HitTest(x, y, &attachment, &dist); m_parent->GetEventHandler()->OnDragRight(draw, x, y, keys, attachment); } return; } } void wxShape::OnBeginDragRight(double x, double y, int keys, int attachment) { if ((m_sensitivity & OP_DRAG_RIGHT) != OP_DRAG_RIGHT) { attachment = 0; double dist; if (m_parent) { m_parent->HitTest(x, y, &attachment, &dist); m_parent->GetEventHandler()->OnBeginDragRight(x, y, keys, attachment); } return; } } void wxShape::OnEndDragRight(double x, double y, int keys, int attachment) { if ((m_sensitivity & OP_DRAG_RIGHT) != OP_DRAG_RIGHT) { attachment = 0; double dist; if (m_parent) { m_parent->HitTest(x, y, &attachment, &dist); m_parent->GetEventHandler()->OnEndDragRight(x, y, keys, attachment); } return; } } void wxShape::OnDrawOutline(wxDC& dc, double x, double y, double w, double h) { double top_left_x = (double)(x - w/2.0); double top_left_y = (double)(y - h/2.0); double top_right_x = (double)(top_left_x + w); double top_right_y = (double)top_left_y; double bottom_left_x = (double)top_left_x; double bottom_left_y = (double)(top_left_y + h); double bottom_right_x = (double)top_right_x; double bottom_right_y = (double)bottom_left_y; wxPoint points[5]; points[0].x = WXROUND(top_left_x); points[0].y = WXROUND(top_left_y); points[1].x = WXROUND(top_right_x); points[1].y = WXROUND(top_right_y); points[2].x = WXROUND(bottom_right_x); points[2].y = WXROUND(bottom_right_y); points[3].x = WXROUND(bottom_left_x); points[3].y = WXROUND(bottom_left_y); points[4].x = WXROUND(top_left_x); points[4].y = WXROUND(top_left_y); dc.DrawLines(5, points); } void wxShape::Attach(wxShapeCanvas *can) { m_canvas = can; } void wxShape::Detach() { m_canvas = NULL; } void wxShape::Move(wxDC& dc, double x, double y, bool display) { double old_x = m_xpos; double old_y = m_ypos; if (!GetEventHandler()->OnMovePre(dc, x, y, old_x, old_y, display)) { // m_xpos = old_x; // m_ypos = old_y; return; } m_xpos = x; m_ypos = y; ResetControlPoints(); if (display) Draw(dc); MoveLinks(dc); GetEventHandler()->OnMovePost(dc, x, y, old_x, old_y, display); } void wxShape::MoveLinks(wxDC& dc) { GetEventHandler()->OnMoveLinks(dc); } void wxShape::Draw(wxDC& dc) { if (m_visible) { GetEventHandler()->OnDraw(dc); GetEventHandler()->OnDrawContents(dc); GetEventHandler()->OnDrawControlPoints(dc); GetEventHandler()->OnDrawBranches(dc); } } void wxShape::Flash() { if (GetCanvas()) { wxClientDC dc(GetCanvas()); GetCanvas()->PrepareDC(dc); dc.SetLogicalFunction(OGLRBLF); Draw(dc); dc.SetLogicalFunction(wxCOPY); Draw(dc); } } void wxShape::Show(bool show) { m_visible = show; wxNode *node = m_children.GetFirst(); while (node) { wxShape *image = (wxShape *)node->GetData(); image->Show(show); node = node->GetNext(); } } void wxShape::Erase(wxDC& dc) { GetEventHandler()->OnErase(dc); GetEventHandler()->OnEraseControlPoints(dc); GetEventHandler()->OnDrawBranches(dc, true); } void wxShape::EraseContents(wxDC& dc) { GetEventHandler()->OnEraseContents(dc); } void wxShape::AddText(const wxString& string) { wxNode *node = m_regions.GetFirst(); if (!node) return; wxShapeRegion *region = (wxShapeRegion *)node->GetData(); region->ClearText(); wxShapeTextLine *new_line = new wxShapeTextLine(0.0, 0.0, string); region->GetFormattedText().Append(new_line); m_formatted = false; } void wxShape::SetSize(double x, double y, bool WXUNUSED(recursive)) { SetAttachmentSize(x, y); SetDefaultRegionSize(); } void wxShape::SetAttachmentSize(double w, double h) { double scaleX; double scaleY; double width, height; GetBoundingBoxMin(&width, &height); if (width == 0.0) scaleX = 1.0; else scaleX = w/width; if (height == 0.0) scaleY = 1.0; else scaleY = h/height; wxNode *node = m_attachmentPoints.GetFirst(); while (node) { wxAttachmentPoint *point = (wxAttachmentPoint *)node->GetData(); point->m_x = (double)(point->m_x * scaleX); point->m_y = (double)(point->m_y * scaleY); node = node->GetNext(); } } // Add line FROM this object void wxShape::AddLine(wxLineShape *line, wxShape *other, int attachFrom, int attachTo, // The line ordering int positionFrom, int positionTo) { if (positionFrom == -1) { if (!m_lines.Member(line)) m_lines.Append(line); } else { // Don't preserve old ordering if we have new ordering instructions m_lines.DeleteObject(line); if (positionFrom < (int) m_lines.GetCount()) { wxNode* node = m_lines.Item(positionFrom); m_lines.Insert(node, line); } else m_lines.Append(line); } if (positionTo == -1) { if (!other->m_lines.Member(line)) other->m_lines.Append(line); } else { // Don't preserve old ordering if we have new ordering instructions other->m_lines.DeleteObject(line); if (positionTo < (int) other->m_lines.GetCount()) { wxNode* node = other->m_lines.Item(positionTo); other->m_lines.Insert(node, line); } else other->m_lines.Append(line); } #if 0 // Wrong: doesn't preserve ordering of shape already linked m_lines.DeleteObject(line); other->m_lines.DeleteObject(line); if (positionFrom == -1) m_lines.Append(line); else { if (positionFrom < m_lines.GetCount()) { wxNode* node = m_lines.Item(positionFrom); m_lines.Insert(node, line); } else m_lines.Append(line); } if (positionTo == -1) other->m_lines.Append(line); else { if (positionTo < other->m_lines.GetCount()) { wxNode* node = other->m_lines.Item(positionTo); other->m_lines.Insert(node, line); } else other->m_lines.Append(line); } #endif line->SetFrom(this); line->SetTo(other); line->SetAttachments(attachFrom, attachTo); } void wxShape::RemoveLine(wxLineShape *line) { if (line->GetFrom() == this) line->GetTo()->m_lines.DeleteObject(line); else line->GetFrom()->m_lines.DeleteObject(line); m_lines.DeleteObject(line); } #if wxUSE_PROLOGIO void wxShape::WriteAttributes(wxExpr *clause) { clause->AddAttributeValueString(_T("type"), GetClassInfo()->GetClassName()); clause->AddAttributeValue(_T("id"), m_id); if (m_pen) { int penWidth = m_pen->GetWidth(); int penStyle = m_pen->GetStyle(); if (penWidth != 1) clause->AddAttributeValue(_T("pen_width"), (long)penWidth); if (penStyle != wxPENSTYLE_SOLID) clause->AddAttributeValue(_T("pen_style"), (long)penStyle); wxString penColour = wxTheColourDatabase->FindName(m_pen->GetColour()); if (penColour == wxEmptyString) { wxString hex(oglColourToHex(m_pen->GetColour())); hex = wxString(_T("#")) + hex; clause->AddAttributeValueString(_T("pen_colour"), hex); } else if (penColour != _T("BLACK")) clause->AddAttributeValueString(_T("pen_colour"), penColour); } if (m_brush) { wxString brushColour = wxTheColourDatabase->FindName(m_brush->GetColour()); if (brushColour == wxEmptyString) { wxString hex(oglColourToHex(m_brush->GetColour())); hex = wxString(_T("#")) + hex; clause->AddAttributeValueString(_T("brush_colour"), hex); } else if (brushColour != _T("WHITE")) clause->AddAttributeValueString(_T("brush_colour"), brushColour); if (m_brush->GetStyle() != wxBRUSHSTYLE_SOLID) clause->AddAttributeValue(_T("brush_style"), (long)m_brush->GetStyle()); } // Output line ids int n_lines = m_lines.GetCount(); if (n_lines > 0) { wxExpr *list = new wxExpr(wxExprList); wxNode *node = m_lines.GetFirst(); while (node) { wxShape *line = (wxShape *)node->GetData(); wxExpr *id_expr = new wxExpr(line->GetId()); list->Append(id_expr); node = node->GetNext(); } clause->AddAttributeValue(_T("arcs"), list); } // Miscellaneous members if (m_attachmentMode != 0) clause->AddAttributeValue(_T("use_attachments"), (long)m_attachmentMode); if (m_sensitivity != OP_ALL) clause->AddAttributeValue(_T("sensitivity"), (long)m_sensitivity); if (!m_spaceAttachments) clause->AddAttributeValue(_T("space_attachments"), (long)m_spaceAttachments); if (m_fixedWidth) clause->AddAttributeValue(_T("fixed_width"), (long)m_fixedWidth); if (m_fixedHeight) clause->AddAttributeValue(_T("fixed_height"), (long)m_fixedHeight); if (m_shadowMode != SHADOW_NONE) clause->AddAttributeValue(_T("shadow_mode"), (long)m_shadowMode); if (m_centreResize != true) clause->AddAttributeValue(_T("centre_resize"), (long)0); clause->AddAttributeValue(_T("maintain_aspect_ratio"), (long) m_maintainAspectRatio); if (m_highlighted != false) clause->AddAttributeValue(_T("hilite"), (long)m_highlighted); if (m_parent) // For composite objects clause->AddAttributeValue(_T("parent"), (long)m_parent->GetId()); if (m_rotation != 0.0) clause->AddAttributeValue(_T("rotation"), m_rotation); if (!this->IsKindOf(CLASSINFO(wxLineShape))) { clause->AddAttributeValue(_T("neck_length"), (long) m_branchNeckLength); clause->AddAttributeValue(_T("stem_length"), (long) m_branchStemLength); clause->AddAttributeValue(_T("branch_spacing"), (long) m_branchSpacing); clause->AddAttributeValue(_T("branch_style"), (long) m_branchStyle); } // Write user-defined attachment points, if any if (m_attachmentPoints.GetCount() > 0) { wxExpr *attachmentList = new wxExpr(wxExprList); wxNode *node = m_attachmentPoints.GetFirst(); while (node) { wxAttachmentPoint *point = (wxAttachmentPoint *)node->GetData(); wxExpr *pointExpr = new wxExpr(wxExprList); pointExpr->Append(new wxExpr((long)point->m_id)); pointExpr->Append(new wxExpr(point->m_x)); pointExpr->Append(new wxExpr(point->m_y)); attachmentList->Append(pointExpr); node = node->GetNext(); } clause->AddAttributeValue(_T("user_attachments"), attachmentList); } // Write text regions WriteRegions(clause); } void wxShape::WriteRegions(wxExpr *clause) { // Output regions as region1 = (...), region2 = (...), etc // and formatted text as text1 = (...), text2 = (...) etc. int regionNo = 1; wxChar regionNameBuf[20]; wxChar textNameBuf[20]; wxNode *node = m_regions.GetFirst(); while (node) { wxShapeRegion *region = (wxShapeRegion *)node->GetData(); wxSprintf(regionNameBuf, _T("region%d"), regionNo); wxSprintf(textNameBuf, _T("text%d"), regionNo); // Original text and region attributes: // region1 = (regionName regionText x y width height minWidth minHeight proportionX proportionY // formatMode fontSize fontFamily fontStyle fontWeight textColour) wxExpr *regionExpr = new wxExpr(wxExprList); regionExpr->Append(new wxExpr(wxExprString, region->m_regionName)); regionExpr->Append(new wxExpr(wxExprString, region->m_regionText)); regionExpr->Append(new wxExpr(region->m_x)); regionExpr->Append(new wxExpr(region->m_y)); regionExpr->Append(new wxExpr(region->GetWidth())); regionExpr->Append(new wxExpr(region->GetHeight())); regionExpr->Append(new wxExpr(region->m_minWidth)); regionExpr->Append(new wxExpr(region->m_minHeight)); regionExpr->Append(new wxExpr(region->m_regionProportionX)); regionExpr->Append(new wxExpr(region->m_regionProportionY)); regionExpr->Append(new wxExpr((long)region->m_formatMode)); regionExpr->Append(new wxExpr((long)(region->m_font ? region->m_font->GetPointSize() : 10))); regionExpr->Append(new wxExpr((long)(region->m_font ? region->m_font->GetFamily() : wxDEFAULT))); regionExpr->Append(new wxExpr((long)(region->m_font ? region->m_font->GetStyle() : wxDEFAULT))); regionExpr->Append(new wxExpr((long)(region->m_font ? region->m_font->GetWeight() : wxNORMAL))); regionExpr->Append(new wxExpr(wxExprString, region->m_textColour)); // New members for pen colour/style regionExpr->Append(new wxExpr(wxExprString, region->m_penColour)); regionExpr->Append(new wxExpr((long)region->m_penStyle)); // Formatted text: // text1 = ((x y string) (x y string) ...) wxExpr *textExpr = new wxExpr(wxExprList); wxNode *textNode = region->m_formattedText.GetFirst(); while (textNode) { wxShapeTextLine *line = (wxShapeTextLine *)textNode->GetData(); wxExpr *list2 = new wxExpr(wxExprList); list2->Append(new wxExpr(line->GetX())); list2->Append(new wxExpr(line->GetY())); list2->Append(new wxExpr(wxExprString, line->GetText())); textExpr->Append(list2); textNode = textNode->GetNext(); } // Now add both attributes to the clause clause->AddAttributeValue(regionNameBuf, regionExpr); clause->AddAttributeValue(textNameBuf, textExpr); node = node->GetNext(); regionNo ++; } } void wxShape::ReadAttributes(wxExpr *clause) { clause->GetAttributeValue(_T("id"), m_id); wxRegisterId(m_id); clause->GetAttributeValue(_T("x"), m_xpos); clause->GetAttributeValue(_T("y"), m_ypos); // Input text strings (FOR COMPATIBILITY WITH OLD FILES ONLY. SEE REGION CODE BELOW.) ClearText(); wxExpr *strings = clause->AttributeValue(_T("text")); if (strings && strings->Type() == wxExprList) { m_formatted = true; // Assume text is formatted unless we prove otherwise wxExpr *node = strings->value.first; while (node) { wxExpr *string_expr = node; double the_x = 0.0; double the_y = 0.0; wxString the_string = wxEmptyString; // string_expr can either be a string, or a list of // 3 elements: x, y, and string. if (string_expr->Type() == wxExprString) { the_string = string_expr->StringValue(); m_formatted = false; } else if (string_expr->Type() == wxExprList) { wxExpr *first = string_expr->value.first; wxExpr *second = first ? first->next : (wxExpr*) NULL; wxExpr *third = second ? second->next : (wxExpr*) NULL; if (first && second && third && (first->Type() == wxExprReal || first->Type() == wxExprInteger) && (second->Type() == wxExprReal || second->Type() == wxExprInteger) && third->Type() == wxExprString) { if (first->Type() == wxExprReal) the_x = first->RealValue(); else the_x = (double)first->IntegerValue(); if (second->Type() == wxExprReal) the_y = second->RealValue(); else the_y = (double)second->IntegerValue(); the_string = third->StringValue(); } } wxShapeTextLine *line = new wxShapeTextLine(the_x, the_y, the_string); m_text.Append(line); node = node->next; } } wxString pen_string = wxEmptyString; wxString brush_string = wxEmptyString; int pen_width = 1; int pen_style = wxPENSTYLE_SOLID; int brush_style = wxBRUSHSTYLE_SOLID; m_attachmentMode = ATTACHMENT_MODE_NONE; clause->GetAttributeValue(_T("pen_colour"), pen_string); clause->GetAttributeValue(_T("text_colour"), m_textColourName); SetTextColour(m_textColourName); clause->GetAttributeValue(_T("region_name"), m_regionName); clause->GetAttributeValue(_T("brush_colour"), brush_string); clause->GetAttributeValue(_T("pen_width"), pen_width); clause->GetAttributeValue(_T("pen_style"), pen_style); clause->GetAttributeValue(_T("brush_style"), brush_style); int iVal = (int) m_attachmentMode; clause->GetAttributeValue(_T("use_attachments"), iVal); m_attachmentMode = iVal; clause->GetAttributeValue(_T("sensitivity"), m_sensitivity); iVal = (int) m_spaceAttachments; clause->GetAttributeValue(_T("space_attachments"), iVal); m_spaceAttachments = (iVal != 0); iVal = (int) m_fixedWidth; clause->GetAttributeValue(_T("fixed_width"), iVal); m_fixedWidth = (iVal != 0); iVal = (int) m_fixedHeight; clause->GetAttributeValue(_T("fixed_height"), iVal); m_fixedHeight = (iVal != 0); clause->GetAttributeValue(_T("format_mode"), m_formatMode); clause->GetAttributeValue(_T("shadow_mode"), m_shadowMode); iVal = m_branchNeckLength; clause->GetAttributeValue(_T("neck_length"), iVal); m_branchNeckLength = iVal; iVal = m_branchStemLength; clause->GetAttributeValue(_T("stem_length"), iVal); m_branchStemLength = iVal; iVal = m_branchSpacing; clause->GetAttributeValue(_T("branch_spacing"), iVal); m_branchSpacing = iVal; clause->GetAttributeValue(_T("branch_style"), m_branchStyle); iVal = (int) m_centreResize; clause->GetAttributeValue(_T("centre_resize"), iVal); m_centreResize = (iVal != 0); iVal = (int) m_maintainAspectRatio; clause->GetAttributeValue(_T("maintain_aspect_ratio"), iVal); m_maintainAspectRatio = (iVal != 0); iVal = (int) m_highlighted; clause->GetAttributeValue(_T("hilite"), iVal); m_highlighted = (iVal != 0); clause->GetAttributeValue(_T("rotation"), m_rotation); if (pen_string == wxEmptyString) pen_string = _T("BLACK"); if (brush_string == wxEmptyString) brush_string = _T("WHITE"); if (pen_string.GetChar(0) == '#') { wxColour col(oglHexToColour(pen_string.After('#'))); m_pen = wxThePenList->FindOrCreatePen(col, pen_width, (wxPenStyle)pen_style); } else m_pen = wxThePenList->FindOrCreatePen(pen_string, pen_width, (wxPenStyle)pen_style); if (!m_pen) m_pen = wxBLACK_PEN; if (brush_string.GetChar(0) == '#') { wxColour col(oglHexToColour(brush_string.After('#'))); m_brush = wxTheBrushList->FindOrCreateBrush(col, (wxBrushStyle)brush_style); } else m_brush = wxTheBrushList->FindOrCreateBrush(brush_string, (wxBrushStyle)brush_style); if (!m_brush) m_brush = wxWHITE_BRUSH; int point_size = 10; clause->GetAttributeValue(_T("point_size"), point_size); SetFont(oglMatchFont(point_size)); // Read user-defined attachment points, if any wxExpr *attachmentList = clause->AttributeValue(_T("user_attachments")); if (attachmentList) { wxExpr *pointExpr = attachmentList->GetFirst(); while (pointExpr) { wxExpr *idExpr = pointExpr->Nth(0); wxExpr *xExpr = pointExpr->Nth(1); wxExpr *yExpr = pointExpr->Nth(2); if (idExpr && xExpr && yExpr) { wxAttachmentPoint *point = new wxAttachmentPoint; point->m_id = (int)idExpr->IntegerValue(); point->m_x = xExpr->RealValue(); point->m_y = yExpr->RealValue(); m_attachmentPoints.Append((wxObject *)point); } pointExpr = pointExpr->GetNext(); } } // Read text regions ReadRegions(clause); } void wxShape::ReadRegions(wxExpr *clause) { ClearRegions(); // region1 = (regionName regionText x y width height minWidth minHeight proportionX proportionY // formatMode fontSize fontFamily fontStyle fontWeight textColour) int regionNo = 1; wxChar regionNameBuf[20]; wxChar textNameBuf[20]; wxExpr *regionExpr; wxExpr *textExpr = NULL; wxSprintf(regionNameBuf, _T("region%d"), regionNo); wxSprintf(textNameBuf, _T("text%d"), regionNo); m_formatted = true; // Assume text is formatted unless we prove otherwise while ((regionExpr = clause->AttributeValue(regionNameBuf)) != NULL) { /* * Get the region information * */ wxString regionName = wxEmptyString; wxString regionText = wxEmptyString; double x = 0.0; double y = 0.0; double width = 0.0; double height = 0.0; double minWidth = 5.0; double minHeight = 5.0; double m_regionProportionX = -1.0; double m_regionProportionY = -1.0; int formatMode = FORMAT_NONE; int fontSize = 10; int fontFamily = wxSWISS; int fontStyle = wxNORMAL; int fontWeight = wxNORMAL; wxString regionTextColour = wxEmptyString; wxString penColour = wxEmptyString; int penStyle = wxPENSTYLE_SOLID; if (regionExpr->Type() == wxExprList) { wxExpr *nameExpr = regionExpr->Nth(0); wxExpr *textExpr = regionExpr->Nth(1); wxExpr *xExpr = regionExpr->Nth(2); wxExpr *yExpr = regionExpr->Nth(3); wxExpr *widthExpr = regionExpr->Nth(4); wxExpr *heightExpr = regionExpr->Nth(5); wxExpr *minWidthExpr = regionExpr->Nth(6); wxExpr *minHeightExpr = regionExpr->Nth(7); wxExpr *propXExpr = regionExpr->Nth(8); wxExpr *propYExpr = regionExpr->Nth(9); wxExpr *formatExpr = regionExpr->Nth(10); wxExpr *sizeExpr = regionExpr->Nth(11); wxExpr *familyExpr = regionExpr->Nth(12); wxExpr *styleExpr = regionExpr->Nth(13); wxExpr *weightExpr = regionExpr->Nth(14); wxExpr *colourExpr = regionExpr->Nth(15); wxExpr *penColourExpr = regionExpr->Nth(16); wxExpr *penStyleExpr = regionExpr->Nth(17); regionName = nameExpr->StringValue(); regionText = textExpr->StringValue(); x = xExpr->RealValue(); y = yExpr->RealValue(); width = widthExpr->RealValue(); height = heightExpr->RealValue(); minWidth = minWidthExpr->RealValue(); minHeight = minHeightExpr->RealValue(); m_regionProportionX = propXExpr->RealValue(); m_regionProportionY = propYExpr->RealValue(); formatMode = (int) formatExpr->IntegerValue(); fontSize = (int)sizeExpr->IntegerValue(); fontFamily = (int)familyExpr->IntegerValue(); fontStyle = (int)styleExpr->IntegerValue(); fontWeight = (int)weightExpr->IntegerValue(); if (colourExpr) { regionTextColour = colourExpr->StringValue(); } else regionTextColour = _T("BLACK"); if (penColourExpr) penColour = penColourExpr->StringValue(); if (penStyleExpr) penStyle = (int)penStyleExpr->IntegerValue(); } wxFont *font = wxTheFontList->FindOrCreateFont(fontSize, fontFamily, (wxFontStyle)fontStyle, fontWeight); wxShapeRegion *region = new wxShapeRegion; region->SetProportions(m_regionProportionX, m_regionProportionY); region->SetFont(font); region->SetSize(width, height); region->SetPosition(x, y); region->SetMinSize(minWidth, minHeight); region->SetFormatMode(formatMode); region->SetPenStyle(penStyle); if (penColour != wxEmptyString) region->SetPenColour(penColour); region->m_textColour = regionTextColour; region->m_regionText = regionText; region->m_regionName = regionName; m_regions.Append(region); /* * Get the formatted text strings * */ textExpr = clause->AttributeValue(textNameBuf); if (textExpr && (textExpr->Type() == wxExprList)) { wxExpr *node = textExpr->value.first; while (node) { wxExpr *string_expr = node; double the_x = 0.0; double the_y = 0.0; wxString the_string = wxEmptyString; // string_expr can either be a string, or a list of // 3 elements: x, y, and string. if (string_expr->Type() == wxExprString) { the_string = string_expr->StringValue(); m_formatted = false; } else if (string_expr->Type() == wxExprList) { wxExpr *first = string_expr->value.first; wxExpr *second = first ? first->next : (wxExpr*) NULL; wxExpr *third = second ? second->next : (wxExpr*) NULL; if (first && second && third && (first->Type() == wxExprReal || first->Type() == wxExprInteger) && (second->Type() == wxExprReal || second->Type() == wxExprInteger) && third->Type() == wxExprString) { if (first->Type() == wxExprReal) the_x = first->RealValue(); else the_x = (double)first->IntegerValue(); if (second->Type() == wxExprReal) the_y = second->RealValue(); else the_y = (double)second->IntegerValue(); the_string = third->StringValue(); } } if (the_string) { wxShapeTextLine *line = new wxShapeTextLine(the_x, the_y, the_string); region->m_formattedText.Append(line); } node = node->next; } } regionNo ++; wxSprintf(regionNameBuf, _T("region%d"), regionNo); wxSprintf(textNameBuf, _T("text%d"), regionNo); } // Compatibility: check for no regions (old file). // Lines and divided rectangles must deal with this compatibility // theirselves. Composites _may_ not have any regions anyway. if ((m_regions.GetCount() == 0) && !this->IsKindOf(CLASSINFO(wxLineShape)) && !this->IsKindOf(CLASSINFO(wxDividedShape)) && !this->IsKindOf(CLASSINFO(wxCompositeShape))) { wxShapeRegion *newRegion = new wxShapeRegion; newRegion->SetName(_T("0")); m_regions.Append((wxObject *)newRegion); if (m_text.GetCount() > 0) { newRegion->ClearText(); wxNode *node = m_text.GetFirst(); while (node) { wxShapeTextLine *textLine = (wxShapeTextLine *)node->GetData(); wxNode *next = node->GetNext(); newRegion->GetFormattedText().Append((wxObject *)textLine); delete node; node = next; } } } } #endif void wxShape::Copy(wxShape& copy) { copy.m_id = m_id; copy.m_xpos = m_xpos; copy.m_ypos = m_ypos; copy.m_pen = m_pen; copy.m_brush = m_brush; copy.m_textColour = m_textColour; copy.m_centreResize = m_centreResize; copy.m_maintainAspectRatio = m_maintainAspectRatio; copy.m_attachmentMode = m_attachmentMode; copy.m_spaceAttachments = m_spaceAttachments; copy.m_highlighted = m_highlighted; copy.m_rotation = m_rotation; copy.m_textColourName = m_textColourName; copy.m_regionName = m_regionName; copy.m_sensitivity = m_sensitivity; copy.m_draggable = m_draggable; copy.m_fixedWidth = m_fixedWidth; copy.m_fixedHeight = m_fixedHeight; copy.m_formatMode = m_formatMode; copy.m_drawHandles = m_drawHandles; copy.m_visible = m_visible; copy.m_shadowMode = m_shadowMode; copy.m_shadowOffsetX = m_shadowOffsetX; copy.m_shadowOffsetY = m_shadowOffsetY; copy.m_shadowBrush = m_shadowBrush; copy.m_branchNeckLength = m_branchNeckLength; copy.m_branchStemLength = m_branchStemLength; copy.m_branchSpacing = m_branchSpacing; // Copy text regions copy.ClearRegions(); wxNode *node = m_regions.GetFirst(); while (node) { wxShapeRegion *region = (wxShapeRegion *)node->GetData(); wxShapeRegion *newRegion = new wxShapeRegion(*region); copy.m_regions.Append(newRegion); node = node->GetNext(); } // Copy attachments copy.ClearAttachments(); node = m_attachmentPoints.GetFirst(); while (node) { wxAttachmentPoint *point = (wxAttachmentPoint *)node->GetData(); wxAttachmentPoint *newPoint = new wxAttachmentPoint; newPoint->m_id = point->m_id; newPoint->m_x = point->m_x; newPoint->m_y = point->m_y; copy.m_attachmentPoints.Append((wxObject *)newPoint); node = node->GetNext(); } // Copy lines copy.m_lines.Clear(); node = m_lines.GetFirst(); while (node) { wxLineShape* line = (wxLineShape*) node->GetData(); copy.m_lines.Append(line); node = node->GetNext(); } } // Create and return a new, fully copied object. wxShape *wxShape::CreateNewCopy(bool resetMapping, bool recompute) { if (resetMapping) oglObjectCopyMapping.Clear(); wxShape* newObject = (wxShape*) GetClassInfo()->CreateObject(); wxASSERT( (newObject != NULL) ); wxASSERT( (newObject->IsKindOf(CLASSINFO(wxShape))) ); Copy(*newObject); if (GetEventHandler() != this) { wxShapeEvtHandler* newHandler = GetEventHandler()->CreateNewCopy(); newObject->SetEventHandler(newHandler); newObject->SetPreviousHandler(NULL); newHandler->SetPreviousHandler(newObject); newHandler->SetShape(newObject); } if (recompute) newObject->Recompute(); return newObject; } // Does the copying for this object, including copying event // handler data if any. Calls the virtual Copy function. void wxShape::CopyWithHandler(wxShape& copy) { Copy(copy); if (GetEventHandler() != this) { wxASSERT( copy.GetEventHandler() != NULL ); wxASSERT( copy.GetEventHandler() != (&copy) ); wxASSERT( GetEventHandler()->GetClassInfo() == copy.GetEventHandler()->GetClassInfo() ); GetEventHandler()->CopyData(* (copy.GetEventHandler())); } } // Default - make 6 control points void wxShape::MakeControlPoints() { double maxX, maxY, minX, minY; GetBoundingBoxMax(&maxX, &maxY); GetBoundingBoxMin(&minX, &minY); double widthMin = (double)(minX + CONTROL_POINT_SIZE + 2); double heightMin = (double)(minY + CONTROL_POINT_SIZE + 2); // Offsets from main object double top = (double)(- (heightMin / 2.0)); double bottom = (double)(heightMin / 2.0 + (maxY - minY)); double left = (double)(- (widthMin / 2.0)); double right = (double)(widthMin / 2.0 + (maxX - minX)); wxControlPoint *control = new wxControlPoint(m_canvas, this, CONTROL_POINT_SIZE, left, top, CONTROL_POINT_DIAGONAL); m_canvas->AddShape(control); m_controlPoints.Append(control); control = new wxControlPoint(m_canvas, this, CONTROL_POINT_SIZE, 0, top, CONTROL_POINT_VERTICAL); m_canvas->AddShape(control); m_controlPoints.Append(control); control = new wxControlPoint(m_canvas, this, CONTROL_POINT_SIZE, right, top, CONTROL_POINT_DIAGONAL); m_canvas->AddShape(control); m_controlPoints.Append(control); control = new wxControlPoint(m_canvas, this, CONTROL_POINT_SIZE, right, 0, CONTROL_POINT_HORIZONTAL); m_canvas->AddShape(control); m_controlPoints.Append(control); control = new wxControlPoint(m_canvas, this, CONTROL_POINT_SIZE, right, bottom, CONTROL_POINT_DIAGONAL); m_canvas->AddShape(control); m_controlPoints.Append(control); control = new wxControlPoint(m_canvas, this, CONTROL_POINT_SIZE, 0, bottom, CONTROL_POINT_VERTICAL); m_canvas->AddShape(control); m_controlPoints.Append(control); control = new wxControlPoint(m_canvas, this, CONTROL_POINT_SIZE, left, bottom, CONTROL_POINT_DIAGONAL); m_canvas->AddShape(control); m_controlPoints.Append(control); control = new wxControlPoint(m_canvas, this, CONTROL_POINT_SIZE, left, 0, CONTROL_POINT_HORIZONTAL); m_canvas->AddShape(control); m_controlPoints.Append(control); } void wxShape::MakeMandatoryControlPoints() { wxNode *node = m_children.GetFirst(); while (node) { wxShape *child = (wxShape *)node->GetData(); child->MakeMandatoryControlPoints(); node = node->GetNext(); } } void wxShape::ResetMandatoryControlPoints() { wxNode *node = m_children.GetFirst(); while (node) { wxShape *child = (wxShape *)node->GetData(); child->ResetMandatoryControlPoints(); node = node->GetNext(); } } void wxShape::ResetControlPoints() { ResetMandatoryControlPoints(); if (m_controlPoints.GetCount() < 1) return; double maxX, maxY, minX, minY; GetBoundingBoxMax(&maxX, &maxY); GetBoundingBoxMin(&minX, &minY); double widthMin = (double)(minX + CONTROL_POINT_SIZE + 2); double heightMin = (double)(minY + CONTROL_POINT_SIZE + 2); // Offsets from main object double top = (double)(- (heightMin / 2.0)); double bottom = (double)(heightMin / 2.0 + (maxY - minY)); double left = (double)(- (widthMin / 2.0)); double right = (double)(widthMin / 2.0 + (maxX - minX)); wxNode *node = m_controlPoints.GetFirst(); wxControlPoint *control = (wxControlPoint *)node->GetData(); control->m_xoffset = left; control->m_yoffset = top; node = node->GetNext(); control = (wxControlPoint *)node->GetData(); control->m_xoffset = 0; control->m_yoffset = top; node = node->GetNext(); control = (wxControlPoint *)node->GetData(); control->m_xoffset = right; control->m_yoffset = top; node = node->GetNext(); control = (wxControlPoint *)node->GetData(); control->m_xoffset = right; control->m_yoffset = 0; node = node->GetNext(); control = (wxControlPoint *)node->GetData(); control->m_xoffset = right; control->m_yoffset = bottom; node = node->GetNext(); control = (wxControlPoint *)node->GetData(); control->m_xoffset = 0; control->m_yoffset = bottom; node = node->GetNext(); control = (wxControlPoint *)node->GetData(); control->m_xoffset = left; control->m_yoffset = bottom; node = node->GetNext(); control = (wxControlPoint *)node->GetData(); control->m_xoffset = left; control->m_yoffset = 0; } void wxShape::DeleteControlPoints(wxDC *dc) { wxNode *node = m_controlPoints.GetFirst(); while (node) { wxControlPoint *control = (wxControlPoint *)node->GetData(); if (dc) control->GetEventHandler()->OnErase(*dc); m_canvas->RemoveShape(control); delete control; delete node; node = m_controlPoints.GetFirst(); } // Children of divisions are contained objects, // so stop here if (!IsKindOf(CLASSINFO(wxDivisionShape))) { node = m_children.GetFirst(); while (node) { wxShape *child = (wxShape *)node->GetData(); child->DeleteControlPoints(dc); node = node->GetNext(); } } } void wxShape::OnDrawControlPoints(wxDC& dc) { if (!m_drawHandles) return; dc.SetBrush(* wxBLACK_BRUSH); dc.SetPen(* wxBLACK_PEN); wxNode *node = m_controlPoints.GetFirst(); while (node) { wxControlPoint *control = (wxControlPoint *)node->GetData(); control->Draw(dc); node = node->GetNext(); } // Children of divisions are contained objects, // so stop here. // This test bypasses the type facility for speed // (critical when drawing) if (!IsKindOf(CLASSINFO(wxDivisionShape))) { node = m_children.GetFirst(); while (node) { wxShape *child = (wxShape *)node->GetData(); child->GetEventHandler()->OnDrawControlPoints(dc); node = node->GetNext(); } } } void wxShape::OnEraseControlPoints(wxDC& dc) { wxNode *node = m_controlPoints.GetFirst(); while (node) { wxControlPoint *control = (wxControlPoint *)node->GetData(); control->Erase(dc); node = node->GetNext(); } if (!IsKindOf(CLASSINFO(wxDivisionShape))) { node = m_children.GetFirst(); while (node) { wxShape *child = (wxShape *)node->GetData(); child->GetEventHandler()->OnEraseControlPoints(dc); node = node->GetNext(); } } } void wxShape::Select(bool select, wxDC* dc) { m_selected = select; if (select) { MakeControlPoints(); // Children of divisions are contained objects, // so stop here if (!IsKindOf(CLASSINFO(wxDivisionShape))) { wxNode *node = m_children.GetFirst(); while (node) { wxShape *child = (wxShape *)node->GetData(); child->MakeMandatoryControlPoints(); node = node->GetNext(); } } if (dc) GetEventHandler()->OnDrawControlPoints(*dc); } if (!select) { DeleteControlPoints(dc); if (!IsKindOf(CLASSINFO(wxDivisionShape))) { wxNode *node = m_children.GetFirst(); while (node) { wxShape *child = (wxShape *)node->GetData(); child->DeleteControlPoints(dc); node = node->GetNext(); } } } } bool wxShape::Selected() const { return m_selected; } bool wxShape::AncestorSelected() const { if (m_selected) return true; if (!GetParent()) return false; else return GetParent()->AncestorSelected(); } int wxShape::GetNumberOfAttachments() const { // Should return the MAXIMUM attachment point id here, // so higher-level functions can iterate through all attachments, // even if they're not contiguous. if (m_attachmentPoints.GetCount() == 0) return 4; else { int maxN = 3; wxNode *node = m_attachmentPoints.GetFirst(); while (node) { wxAttachmentPoint *point = (wxAttachmentPoint *)node->GetData(); if (point->m_id > maxN) maxN = point->m_id; node = node->GetNext(); } return maxN+1;; } } bool wxShape::AttachmentIsValid(int attachment) const { if (m_attachmentPoints.GetCount() == 0) { return ((attachment >= 0) && (attachment < 4)) ; } wxNode *node = m_attachmentPoints.GetFirst(); while (node) { wxAttachmentPoint *point = (wxAttachmentPoint *)node->GetData(); if (point->m_id == attachment) return true; node = node->GetNext(); } return false; } bool wxShape::GetAttachmentPosition(int attachment, double *x, double *y, int nth, int no_arcs, wxLineShape *line) { if (m_attachmentMode == ATTACHMENT_MODE_NONE) { *x = m_xpos; *y = m_ypos; return true; } else if (m_attachmentMode == ATTACHMENT_MODE_BRANCHING) { wxRealPoint pt, stemPt; GetBranchingAttachmentPoint(attachment, nth, pt, stemPt); *x = pt.x; *y = pt.y; return true; } else if (m_attachmentMode == ATTACHMENT_MODE_EDGE) { if (m_attachmentPoints.GetCount() > 0) { wxNode *node = m_attachmentPoints.GetFirst(); while (node) { wxAttachmentPoint *point = (wxAttachmentPoint *)node->GetData(); if (point->m_id == attachment) { *x = (double)(m_xpos + point->m_x); *y = (double)(m_ypos + point->m_y); return true; } node = node->GetNext(); } *x = m_xpos; *y = m_ypos; return false; } else { // Assume is rectangular double w, h; GetBoundingBoxMax(&w, &h); double top = (double)(m_ypos + h/2.0); double bottom = (double)(m_ypos - h/2.0); double left = (double)(m_xpos - w/2.0); double right = (double)(m_xpos + w/2.0); #if 0 /* bool isEnd = */ (line && line->IsEnd(this)); #endif int physicalAttachment = LogicalToPhysicalAttachment(attachment); // Simplified code switch (physicalAttachment) { case 0: { wxRealPoint pt = CalcSimpleAttachment(wxRealPoint(left, bottom), wxRealPoint(right, bottom), nth, no_arcs, line); *x = pt.x; *y = pt.y; break; } case 1: { wxRealPoint pt = CalcSimpleAttachment(wxRealPoint(right, bottom), wxRealPoint(right, top), nth, no_arcs, line); *x = pt.x; *y = pt.y; break; } case 2: { wxRealPoint pt = CalcSimpleAttachment(wxRealPoint(left, top), wxRealPoint(right, top), nth, no_arcs, line); *x = pt.x; *y = pt.y; break; } case 3: { wxRealPoint pt = CalcSimpleAttachment(wxRealPoint(left, bottom), wxRealPoint(left, top), nth, no_arcs, line); *x = pt.x; *y = pt.y; break; } default: { return false; } } return true; } } return false; } void wxShape::GetBoundingBoxMax(double *w, double *h) { double ww, hh; GetBoundingBoxMin(&ww, &hh); if (m_shadowMode != SHADOW_NONE) { ww += m_shadowOffsetX; hh += m_shadowOffsetY; } *w = ww; *h = hh; } // Returns true if image is a descendant of this composite bool wxShape::HasDescendant(wxShape *image) { if (image == this) return true; wxNode *node = m_children.GetFirst(); while (node) { wxShape *child = (wxShape *)node->GetData(); bool ans = child->HasDescendant(image); if (ans) return true; node = node->GetNext(); } return false; } // Clears points from a list of wxRealPoints, and clears list void wxShape::ClearPointList(wxList& list) { wxNode* node = list.GetFirst(); while (node) { wxRealPoint* pt = (wxRealPoint*) node->GetData(); delete pt; node = node->GetNext(); } list.Clear(); } // Assuming the attachment lies along a vertical or horizontal line, // calculate the position on that point. wxRealPoint wxShape::CalcSimpleAttachment(const wxRealPoint& pt1, const wxRealPoint& pt2, int nth, int noArcs, wxLineShape* line) { bool isEnd = (line && line->IsEnd(this)); // Are we horizontal or vertical? bool isHorizontal = (oglRoughlyEqual(pt1.y, pt2.y) == true); double x, y; if (isHorizontal) { wxRealPoint firstPoint, secondPoint; if (pt1.x > pt2.x) { firstPoint = pt2; secondPoint = pt1; } else { firstPoint = pt1; secondPoint = pt2; } if (m_spaceAttachments) { if (line && (line->GetAlignmentType(isEnd) == LINE_ALIGNMENT_TO_NEXT_HANDLE)) { // Align line according to the next handle along wxRealPoint *point = line->GetNextControlPoint(this); if (point->x < firstPoint.x) x = firstPoint.x; else if (point->x > secondPoint.x) x = secondPoint.x; else x = point->x; } else x = firstPoint.x + (nth + 1)*(secondPoint.x - firstPoint.x)/(noArcs + 1); } else x = (secondPoint.x - firstPoint.x)/2.0; // Midpoint y = pt1.y; } else { wxASSERT( oglRoughlyEqual(pt1.x, pt2.x) == true ); wxRealPoint firstPoint, secondPoint; if (pt1.y > pt2.y) { firstPoint = pt2; secondPoint = pt1; } else { firstPoint = pt1; secondPoint = pt2; } if (m_spaceAttachments) { if (line && (line->GetAlignmentType(isEnd) == LINE_ALIGNMENT_TO_NEXT_HANDLE)) { // Align line according to the next handle along wxRealPoint *point = line->GetNextControlPoint(this); if (point->y < firstPoint.y) y = firstPoint.y; else if (point->y > secondPoint.y) y = secondPoint.y; else y = point->y; } else y = firstPoint.y + (nth + 1)*(secondPoint.y - firstPoint.y)/(noArcs + 1); } else y = (secondPoint.y - firstPoint.y)/2.0; // Midpoint x = pt1.x; } return wxRealPoint(x, y); } // Return the zero-based position in m_lines of line. int wxShape::GetLinePosition(wxLineShape* line) { for (size_t i = 0; i < m_lines.GetCount(); i++) if ((wxLineShape*) (m_lines.Item(i)->GetData()) == line) return i; return 0; } // // |________| // | <- root // | <- neck // shoulder1 ->---------<- shoulder2 // | | | | | // <- branching attachment point N-1 // This function gets information about where branching connections go. // Returns false if there are no lines at this attachment. bool wxShape::GetBranchingAttachmentInfo(int attachment, wxRealPoint& root, wxRealPoint& neck, wxRealPoint& shoulder1, wxRealPoint& shoulder2) { int physicalAttachment = LogicalToPhysicalAttachment(attachment); // Number of lines at this attachment. int lineCount = GetAttachmentLineCount(attachment); if (lineCount == 0) return false; int totalBranchLength = m_branchSpacing * (lineCount - 1); root = GetBranchingAttachmentRoot(attachment); // Assume that we have attachment points 0 to 3: top, right, bottom, left. switch (physicalAttachment) { case 0: { neck.x = GetX(); neck.y = root.y - m_branchNeckLength; shoulder1.x = root.x - (totalBranchLength/2.0) ; shoulder2.x = root.x + (totalBranchLength/2.0) ; shoulder1.y = neck.y; shoulder2.y = neck.y; break; } case 1: { neck.x = root.x + m_branchNeckLength; neck.y = root.y; shoulder1.x = neck.x ; shoulder2.x = neck.x ; shoulder1.y = neck.y - (totalBranchLength/2.0) ; shoulder2.y = neck.y + (totalBranchLength/2.0) ; break; } case 2: { neck.x = GetX(); neck.y = root.y + m_branchNeckLength; shoulder1.x = root.x - (totalBranchLength/2.0) ; shoulder2.x = root.x + (totalBranchLength/2.0) ; shoulder1.y = neck.y; shoulder2.y = neck.y; break; } case 3: { neck.x = root.x - m_branchNeckLength; neck.y = root.y ; shoulder1.x = neck.x ; shoulder2.x = neck.x ; shoulder1.y = neck.y - (totalBranchLength/2.0) ; shoulder2.y = neck.y + (totalBranchLength/2.0) ; break; } default: { wxFAIL_MSG( wxT("Unrecognised attachment point in GetBranchingAttachmentInfo.") ); break; } } return true; } // n is the number of the adjoining line, from 0 to N-1 where N is the number of lines // at this attachment point. // Get the attachment point where the arc joins the stem, and also the point where the // the stem meets the shoulder. bool wxShape::GetBranchingAttachmentPoint(int attachment, int n, wxRealPoint& pt, wxRealPoint& stemPt) { int physicalAttachment = LogicalToPhysicalAttachment(attachment); wxRealPoint root, neck, shoulder1, shoulder2; GetBranchingAttachmentInfo(attachment, root, neck, shoulder1, shoulder2); // Assume that we have attachment points 0 to 3: top, right, bottom, left. switch (physicalAttachment) { case 0: { pt.y = neck.y - m_branchStemLength; pt.x = shoulder1.x + n*m_branchSpacing; stemPt.x = pt.x; stemPt.y = neck.y; break; } case 2: { pt.y = neck.y + m_branchStemLength; pt.x = shoulder1.x + n*m_branchSpacing; stemPt.x = pt.x; stemPt.y = neck.y; break; } case 1: { pt.x = neck.x + m_branchStemLength; pt.y = shoulder1.y + n*m_branchSpacing; stemPt.x = neck.x; stemPt.y = pt.y; break; } case 3: { pt.x = neck.x - m_branchStemLength; pt.y = shoulder1.y + n*m_branchSpacing; stemPt.x = neck.x; stemPt.y = pt.y; break; } default: { wxFAIL_MSG( wxT("Unrecognised attachment point in GetBranchingAttachmentPoint.") ); break; } } return true; } // Get the number of lines at this attachment position. int wxShape::GetAttachmentLineCount(int attachment) const { int count = 0; wxNode* node = m_lines.GetFirst(); while (node) { wxLineShape* lineShape = (wxLineShape*) node->GetData(); if ((lineShape->GetFrom() == this) && (lineShape->GetAttachmentFrom() == attachment)) count ++; else if ((lineShape->GetTo() == this) && (lineShape->GetAttachmentTo() == attachment)) count ++; node = node->GetNext(); } return count; } // This function gets the root point at the given attachment. wxRealPoint wxShape::GetBranchingAttachmentRoot(int attachment) { int physicalAttachment = LogicalToPhysicalAttachment(attachment); wxRealPoint root; double width, height; GetBoundingBoxMax(& width, & height); // Assume that we have attachment points 0 to 3: top, right, bottom, left. switch (physicalAttachment) { case 0: { root.x = GetX() ; root.y = GetY() - height/2.0; break; } case 1: { root.x = GetX() + width/2.0; root.y = GetY() ; break; } case 2: { root.x = GetX() ; root.y = GetY() + height/2.0; break; } case 3: { root.x = GetX() - width/2.0; root.y = GetY() ; break; } default: { wxFAIL_MSG( wxT("Unrecognised attachment point in GetBranchingAttachmentRoot.") ); break; } } return root; } // Draw or erase the branches (not the actual arcs though) void wxShape::OnDrawBranches(wxDC& dc, int attachment, bool erase) { int count = GetAttachmentLineCount(attachment); if (count == 0) return; wxRealPoint root, neck, shoulder1, shoulder2; GetBranchingAttachmentInfo(attachment, root, neck, shoulder1, shoulder2); if (erase) { dc.SetPen(*wxWHITE_PEN); dc.SetBrush(*wxWHITE_BRUSH); } else { dc.SetPen(*wxBLACK_PEN); dc.SetBrush(*wxBLACK_BRUSH); } // Draw neck dc.DrawLine((long) root.x, (long) root.y, (long) neck.x, (long) neck.y); if (count > 1) { // Draw shoulder-to-shoulder line dc.DrawLine((long) shoulder1.x, (long) shoulder1.y, (long) shoulder2.x, (long) shoulder2.y); } // Draw all the little branches int i; for (i = 0; i < count; i++) { wxRealPoint pt, stemPt; GetBranchingAttachmentPoint(attachment, i, pt, stemPt); dc.DrawLine((long) stemPt.x, (long) stemPt.y, (long) pt.x, (long) pt.y); if ((GetBranchStyle() & BRANCHING_ATTACHMENT_BLOB) && (count > 1)) { long blobSize=6; // dc.DrawEllipse((long) (stemPt.x + 0.5 - (blobSize/2.0)), (long) (stemPt.y + 0.5 - (blobSize/2.0)), blobSize, blobSize); dc.DrawEllipse((long) (stemPt.x - (blobSize/2.0)), (long) (stemPt.y - (blobSize/2.0)), blobSize, blobSize); } } } // Draw or erase the branches (not the actual arcs though) void wxShape::OnDrawBranches(wxDC& dc, bool erase) { if (m_attachmentMode != ATTACHMENT_MODE_BRANCHING) return; int count = GetNumberOfAttachments(); int i; for (i = 0; i < count; i++) OnDrawBranches(dc, i, erase); } // Only get the attachment position at the _edge_ of the shape, ignoring // branching mode. This is used e.g. to indicate the edge of interest, not the point // on the attachment branch. bool wxShape::GetAttachmentPositionEdge(int attachment, double *x, double *y, int nth, int no_arcs, wxLineShape *line) { int oldMode = m_attachmentMode; // Calculate as if to edge, not branch if (m_attachmentMode == ATTACHMENT_MODE_BRANCHING) m_attachmentMode = ATTACHMENT_MODE_EDGE; bool success = GetAttachmentPosition(attachment, x, y, nth, no_arcs, line); m_attachmentMode = oldMode; return success; } // Rotate the standard attachment point from physical (0 is always North) // to logical (0 -> 1 if rotated by 90 degrees) int wxShape::PhysicalToLogicalAttachment(int physicalAttachment) const { const double pi = M_PI ; int i; if (oglRoughlyEqual(GetRotation(), 0.0)) { i = physicalAttachment; } else if (oglRoughlyEqual(GetRotation(), (pi/2.0))) { i = physicalAttachment - 1; } else if (oglRoughlyEqual(GetRotation(), pi)) { i = physicalAttachment - 2; } else if (oglRoughlyEqual(GetRotation(), (3.0*pi/2.0))) { i = physicalAttachment - 3; } else // Can't handle -- assume the same. return physicalAttachment; if (i < 0) i += 4; return i; } // Rotate the standard attachment point from logical // to physical (0 is always North) int wxShape::LogicalToPhysicalAttachment(int logicalAttachment) const { const double pi = M_PI ; int i; if (oglRoughlyEqual(GetRotation(), 0.0)) { i = logicalAttachment; } else if (oglRoughlyEqual(GetRotation(), (pi/2.0))) { i = logicalAttachment + 1; } else if (oglRoughlyEqual(GetRotation(), pi)) { i = logicalAttachment + 2; } else if (oglRoughlyEqual(GetRotation(), (3.0*pi/2.0))) { i = logicalAttachment + 3; } else // Can't handle -- assume the same. return logicalAttachment; if (i > 3) i -= 4; return i; } void wxShape::Rotate(double WXUNUSED(x), double WXUNUSED(y), double theta) { const double pi = M_PI ; m_rotation = theta; if (m_rotation < 0.0) { m_rotation += 2*pi; } else if (m_rotation > 2*pi) { m_rotation -= 2*pi; } } wxPen wxShape::GetBackgroundPen() { if (GetCanvas()) { wxColour c = GetCanvas()->GetBackgroundColour(); return wxPen(c, 1, wxPENSTYLE_SOLID); } return * g_oglWhiteBackgroundPen; } wxBrush wxShape::GetBackgroundBrush() { if (GetCanvas()) { wxColour c = GetCanvas()->GetBackgroundColour(); return wxBrush(c, wxBRUSHSTYLE_SOLID); } return * g_oglWhiteBackgroundBrush; }
[ "firodj@gmail.com" ]
firodj@gmail.com
59bbfc9e49df44cdf812230663fd3a4ec430b0bc
1cfd3b99b898520bd8352fa5bd490207b5d2f2e8
/ProjetHorloge/ProjetHorloge/clavier.cpp
6ef1ac372828aecdc322bf3cac8375cc5950a39c
[]
no_license
Ahmed-Ysf/cpp_2
6e6aae09c39e4b0faf857aeb4707f79d83d1599e
9d8574cc0fb049d029b2aef4183337d31c04e9a9
refs/heads/master
2022-12-24T17:50:15.087615
2020-10-02T10:57:04
2020-10-02T10:57:04
300,584,719
0
0
null
null
null
null
UTF-8
C++
false
false
1,500
cpp
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * File: Clavier.cpp * Author: philippe * * Created on 31 décembre 2018, 17:11 */ #include <cstdio> #include "clavier.h" Clavier::Clavier() { struct termios etatCourant; tcgetattr(STDIN_FILENO, &etatInitial); etatCourant = etatInitial; etatCourant.c_lflag &= ~ICANON; etatCourant.c_lflag &= ~ECHO; etatCourant.c_lflag &= ~ISIG; etatCourant.c_oflag &= ~NL0; etatCourant.c_oflag &= ~CR0; etatCourant.c_oflag &= ~TAB0; etatCourant.c_oflag &= ~BS0; etatCourant.c_cc[VMIN] = 0; etatCourant.c_cc[VTIME] = 0; tcsetattr(STDIN_FILENO, TCSANOW, &etatCourant); read(STDIN_FILENO, &toucheAvant, 1); touche = toucheAvant; } Clavier::~Clavier() { tcsetattr(STDIN_FILENO, TCSANOW, &etatInitial); } TOUCHES_CLAVIER Clavier::ScruterClavier() { TOUCHES_CLAVIER retour = AUCUNE; char touche = 0; int test = read(STDIN_FILENO, &touche, 1); if (test != -1) { switch (touche) { case ' ': retour = MODE; break; case '+': retour = PLUS; break; case '-': retour = MOINS; break; case '\n': case '\r': retour = FIN; break; default: retour = AUCUNE; } } return retour; }
[ "ahmed683@hotmail.fr" ]
ahmed683@hotmail.fr
9d520ef9f85ccf0cff52a98ddf4280d0fd12d944
2e8b90c136a0c97e1176e11a1297272b9becd78f
/iqapi.h
8042d505d79d5f5f0eb9a0d20a38e027847385db
[]
no_license
thiru-libre/LibreRoot
80819645eafd5d65ed6fc1ede5d60db4dde77233
512c6dcdbb1b06bf3816528a1d26269864482a2d
refs/heads/master
2020-06-05T14:26:46.020977
2014-01-30T07:57:13
2014-01-30T07:57:13
null
0
0
null
null
null
null
WINDOWS-1250
C++
false
false
124,626
h
/*! \file iqapi.h */ #pragma once //#define IQAPI_EXPORTS // **************************************************************** // Version Information // **************************************************************** #define IQAPI_VERSION "1.7.48" #define IQAPI_RELEASE_DATE "(Dec 9, 2009)" // **************************************************************** // DLL Import / Export Defines // **************************************************************** #ifdef IQAPI_EXPORTS #define IQ_API __declspec(dllexport) #else #define IQ_API __declspec(dllimport) #endif // **************************************************************** // Internal Header files // **************************************************************** #ifdef IQAPI_USE_INTERNAL_FILES // #include "iqapi_lp_private.h" #include "A21Control.h" #endif // **************************************************************** // Include Files // **************************************************************** #include <windows.h> #include <stdlib.h> #pragma warning( disable : 4251 ) #include "iqapiDefines.h" #include "iqapiHndlBase.h" #include "iqapiHndlMatlab.h" #include "DualHeadBase.h" enum WHAT_VERSION_TO_CHECK { IQV_LEGACY_VERSION_ONLY // Check version for WIFI/BT/WiMax }; class IQ_API CA21Control; //#include "iqapiExternalDevices.h" // **************************************************************** // Internal define statement // **************************************************************** #define SERIAL_NUMBER_LEN 8 #define NUMBER_OF_FREQ_BAND 8 // **************************************************************** // Global Function Declarations // **************************************************************** //! Poly Fit IQ_API int iqapiGetPolyFitMax(int order, int numElements, double xValues[], double yValues[], double *maxXValue, double *maxYValue); //! Initializes API libraries /*! Initializes the API libraries and Matlab Run Time. Call this function once(and only once) before any other application that uses this API is called. */ IQ_API int iqapiInit(void); //! Terminates API libraries /*! Terminates the API libraries and Matlab Runtime. Call this function once (and only once) after each application that uses the API is run. */ IQ_API int iqapiTerm(void); //! Clear connection status, etc. /*! Causes the API to clear the current state of all IQapi connections. Call this function if you have to call the \c ConInit function for more than once in an application. You must call this function before you call the \c ConInit function for the second time. */ IQ_API int iqapiClearAll(void); //! Plot Data /*! Plots data in a Matlab Figure window. The function takes the following inputs: \param figNum Indicates the non-zero figure number. If the figure number does not exist, it will be created. \param x Indicates the pointer to the data for the x-axis. This value can be set to NULL. If this value is set to NULL, then x will be the index of y. \param y Indicates the pointer to the data for the y-axis. This value cannot be set to NULL. \param length Indicates the length of the data to which the y axis points to. This value also indicates the length of data to which the x axis points to, if the value of x is not NULL. \param title Indicates the NULL-terminated char string that points to the name of the plot. \param xtitle Indicates the NULL-terminated char string that points to the name on the x-axis of the plot. \param ytitle Indicates the NULL-terminated char string that points to the name on the y-axis of the plot. \param plotArgs Indicates the NULL-terminated char string that is created from an element comprised of any or all of the data contained in each of the following three columns, and has a value of NULL for default options: b blue \n g green \n r red \n c cyan \n m magenta \n y yellow \n k black \n . point \n o circle \n x x-mark \n + plus \n * star \n s square \n d diamond \n v triangle (down) \n ^ triangle (up) \n < triangle (left) \n > triangle (right) \n p pentagram \n h hexagram \n - solid \n : dotted \n -. dashdot \n -- dashed \n \param keepPlot It can be 0 or 1. \n For keepPlot =0, it will erase the previous plot before plotting the new data. \n For keepPlot =1, it will plot the new data on the same plot as the previous plot. \n */ IQ_API int iqapiPlot(int figNum, double *x, double *y, int length, char *plotArgs, char *title, char *xtitle, char *ytitle, int keepPlot=0); //! Get Version Information /*! Retrieves version information for various parts of the API. This function copies a maximum of \c nMaxChars into the buffer that the \c versionStr parameter points to. */ IQ_API int iqapiVersion(char *versionStr, int nMaxChars); // **************************************************************** // API Classes // **************************************************************** // //// **************************************************************** //// Modulation Wave Class //// **************************************************************** // ////! Specifies the analysis parameters for modulation wave. ///*! If a call to the \c hndl->GenerateWave() function is successful, the \c hndl->wave parameter will point to an \c iqapiModulationWave object which is used in a call to the \c hndl->SetWave() object. //*/ // //class IQ_API iqapiModulationWave //{ //public: // iqapiModulationWave(void); //!< Constructor // ~iqapiModulationWave(void); //!< Destructor // // int length[N_MAX_TESTERS]; //!< Integer array that represents the length of the \a real and \a imag vectors, with one integer for each VSA in the test systems. // // /*!< \c Length[0] indicates the length of \c real[0] and \c imag[0] vectors, which is the sample data returned from the first VSA (0). // */ // // double *real[N_MAX_TESTERS]; //!< Double pointer array that represents the (real) sample data captured on each VSA. // // /*!<The length of \c real[x] is indicated by \c length[x], where x is the VSA number minus one. For example, the test system 1 uses a value of \c real[0], test system 2 uses a value of \c real[1] etc. // */ // // double *imag[N_MAX_TESTERS]; //!< Double pointer array that represents the (imaginary) sample data captured on each VSA. // // /*!< The length of \c imag[x] is indicated by \c length[x], where x is the VSA number minus one. For example, the test system 1 uses a value of \c imag[0], test system 2 uses a value of \c imag[1] etc. // */ // // double sampleFreqHz[N_MAX_TESTERS]; //!< Double pointer array that represents the sample frequency of \c real and \c imag data. // // /*!<\c sampleFreqHz[x] is the sampling rate of \c real[x] and \c imag[x], where x is the VSA number minus one. For example, the test system 1 uses a value of \c sampleFreqHz[0], test system 2 uses a value of \c sampleFreqHz[1] etc. // */ // // char lastErr[MAX_LEN_ERR_TXT]; //!< Char array (\c hndl->wave->lastErr) that contains an error message if a call to the \c hndl->GenerateWave function fails. // // // //! A copy constructor that can be used to make a deep copy of an \c iqapiModulationWave object. // /*! Use this constructor when you wish to create a copy of an \c iqapiModulationWave object. // */ // iqapiModulationWave(const iqapiModulationWave &src); // // int Save(char *fileName); //!< Saves an \c iqapiModulationWave object to a \c .mod file(set by filename), which can be downloaded to a VSG via this API, or by the VSG panel in the IQsignal for MIMO application. // // /*!< This function returns 0 (\c IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). // */ // //}; //! Specifies the analysis parameters for modulation multi-wave class IQ_API iqapiModulationMultiWave : public iqapiModulationWave { public: iqapiModulationMultiWave() {compensationSinc = IQV_COMPENSATION_SINC; } ; ~iqapiModulationMultiWave() {}; char waveName[256]; // optional: define the name of the wave IQV_MULTI_WAVE_COMPENSATION_SINC compensationSinc; // default is 1 => do compensation sinc int lengthExtraForPadding; // Extra data length for padding }; // **************************************************************** // Spatial Map Matrix Class // **************************************************************** //!Specifies Spatial Mapping in generation of IEEE 802.11n signals. class IQ_API iqapiSpatialMap { public: iqapiSpatialMap(void); //!< Constructor ~iqapiSpatialMap(void); //!< Destructor int m; //!< Defines NTx int n; //!< Defines NStreams double real[16]; //!< Double pointer array that holds the real values for the Spatial Map Matrix. /*!< Values at indexes 0 through ((m*n)-1) must be set. The real values for the MxN dimensional matrix will be built column-wise from this array, i.e., col 1 first, col 2 next and so on, to col n. */ double imag[16]; //!< Double pointer array that holds the imaginary values for the Spatial Map Matrix. /*!< Values at indexes 0 through ((m*n)-1) must be set. The imaginary values for the MxN dimensional matrix will be built column-wise from this array, i.e., col 1 first, col 2 next and so on, to col n. */ }; // **************************************************************** // Wave Generator Parameters Class // **************************************************************** //! Specifies wave generation configuration parameters to be used during a call to the \c hndl->GenerateWave object. class IQ_API iqapiWaveGenParms { public: iqapiWaveGenParms(void); //!< Constructor. ~iqapiWaveGenParms(void); //!< Destructor. int mcsIndex; //!< Sets modulation and coding scheme. /*!< Defines the modulation (BPSK, 64-QAM etc.) and coding rate (1/2, 5/6 etc.) of the generated signal. The options follow the IEEE 802.11n standards specifications. \n \note Currently, the number of streams allowed is restricted to a maximum of four, and the modulation type is set to a maximum of 64-QAM.*/ int bandwidth; //!< Sets the bandwidth of the generated signal. /*!< The bandwidth values are as follows: \n 0=20 MHz \n 1=40 MHz \n The channel mapping follows the IEEE 802.11 standards specification. */ char *PSDU_mode; //!< Represents PSDU mode. /*!< Values for this field are as follows: \n \c random \n \c userdef \n \c userdef_withcrc \n This field is reserved for future use. */ int PSDU_lengthBytes; //!< Sets the length of payload in bytes double *PSDU_bits; //!< Sets the PSDU value /*!< This field is reserved for future use. */ //! Defines Matrix Q for Spatial Mapping /*! Dimension must be NTx x NStreams.*/ iqapiSpatialMap spatialMapMatr; int soundingPacketHTLTF; //!< Defines the sounding packet. /*!< Valid values are as follows: \n 0: no sounding packet (default) \n 2-4: number of HT-LTFs, if sounding packet is present. */ int aggregation; //!< Defines the aggregation bit in HT-SIG. /*!< This field is reserved for future use. */ int advancedCoding; //!< Defines the advanced coding bit in HT-SIG. /*!< This field is reserved for future use. */ int shortGI; //!< Defines the Short Guard Interval bit in HT-SIG. int legacyLength; //!< Defines the legacy length. /*!<-1: Length in legacy SIG is derived from HT-length. Otherwise, use this value for length field in legacy SIG.*/ short scramblerInit; //!< Defines the scrambler initialization value. /*!< Valid values are as follows: \n -1: Random scrambler init value \n 0 to 127: Scrambler init value */ //! Defines the cyclic shift in nanoseconds. /*! Cyclic shift on Tx chains > 1 (in nanoseconds). */ iqapiMeasurement *cyclicShiftnS; // change from double to iqapiMeasurement * double idleTimeuS; //!< Defines the idle time (filled with zeros) between generation of two packets /*!< Specified in microseconds */ char *type; //!< Defines the type of packet to generate. /*!< Currently, only EWC is supported. */ int greenField; //!< Indicates mode of operation /*!< Valid values are as follows: \n 0=mixed mode packet format; this is the default value \n 1=green field packet format. */ int soundingPacket; //!< Indicates that the packet is to be used for channel sounding /*!< Valid values are as follows: \n 0: no sounding packet; this is the default value \n 1-3: number of Extension HT-LTFs */ char *ofdmWindowType; //!< Indicates type of OFDM windowing /*!< Valid values are as follows; \n If the value is set to \c none, the first and last samples are multiplied by 1/2 \n If the value is set to \c raised cosine, the samples use the raised cosine filter \n If the value is set to \c straight line, the samples use the straight line filter */ int ofdmWindowLengthSamples; //!< Indicates length of the OFDM window /*!< Specified in number of samples (80 MHz) */ int stbc; //!< STBC field in HT-SIG field. /*!< Indicates the difference between the number of space-time streams and spatial streams. \n Valid values are as follows: \n 0=non-stbc \n 1=stbc */ int SetDefault(char *type);//!<Resets the parameters of an \c iqapiWaveGenParms object to default parameters. /*!< This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer object). */ private: int UnpackWaveParam(void *mx_result_in); }; // **************************************************************** // Class to use with reference generation functions // **************************************************************** //! Specifies classes that must be used with reference generation functions. class IQ_API iqapiResultFindPsduDataRef { public: int returnCode; char *message; iqapiResultFindPsduDataRef(void) //!< Constructor { returnCode = -99; // Invalid code message = NULL; } ~iqapiResultFindPsduDataRef(void) //!< Destructor { } }; // **************************************************************** // 802.16 (WiMAX) Analysis Parameters Class (Derived from iqapiAnalysis) // // type = '80216-2004' or '80216e-2005' // mode = '80216-2004' or '80216e-2005'or 'powerPacketDetect' // For powerPacketDetect, it will only measure power with packet detect. quicker to get power measurement with packet detect // // **************************************************************** //! Specifies the analysis parameters for testing devices that are compliant with the IEEE 802.16 standards specification. class IQ_API iqapiAnalysis80216 : public iqapiAnalysis { public: iqapiAnalysis80216(void); //!< Constructor ~iqapiAnalysis80216(void); //!< Destructor //! Specifies the required physical layer parameters for signals compliant with the IEEE 802.16 standards specification. struct PHY_80216 { double sigType; //!< Indicates the type of signal. Default: -1 /*!< Valid values are as follows: \n 1=downlink signal \n 2=uplink signal \n -1=auto-detect */ double bandwidthHz; //!< Indicates signal bandwidth. Default: -1 /*!< Valid values for the signal bandwidth are as follows: -1, 1.25, 1.5, 1.75, 2.5, 3, 3.5, 5, 5.5, 6, 7, 8.75, 10, 11, 12, 14, 15, 20 \n \note -1=auto detect */ double cyclicPrefix; //!< Indicates signal cyclic prefix ratio. Default: -1 /*!< Valid values for signal cyclic prefix ratio are as follows: -1, 1/4, 1/8, 1/16, 1/32 \n \note -1=auto detect */ double rateId; //!< Indicates signal modulation rate. Default: -1 /*!< Valid values for signal modulation rate are as follows: 0, 1, 2, 3, 4, 5, 6 and correspond to {BPSK 1/2, QPSK 1/2, QPSK 3/4, 16-QAM 1/2, 16-QAM 3/4, 64-QAM 2/3, 64-QAM 3/4}, respectively \n \note -1=auto detect */ double numSymbols; //!< Number of OFDM symbols in burst. Default: -1 /*!<-1=auto-detect */ } Phy; //! Specifies parameters for the acquisition of signals compliant with the IEEE 802.16 standards specification. struct ACQ_80216 { IQV_PH_CORR_ENUM phaseCorrect; //!< Specifies the phase tracking mode used for the analysis. Default: IQV_PH_CORR_SYM_BY_SYM /*!< Valid values are as follows: \n 1=Phase tracking off \n 2=Symbol by symbol phase tracking (fast){1, 2, 3} \n 3=10-symbol moving average (slow) (NOT supported currently)} */ IQV_CH_EST_ENUM channelCorrect; //!< Specifies the channel estimation and correction mode. Default: IQV_CH_EST_RAW /*!< Valid values are as follows: \n 1=Channel estimate based on long preamble symbol \n 3=Channel estimate based on whole burst */ IQV_FREQ_SYNC_ENUM freqCorrect; //!< Specifies the frequency offset correction mode. Default: IQV_FREQ_SYNC_LONG_TRAIN /*!< Valid values are as follows: \n 1=Does not perform frequency correction \n 2=performs frequency correction by using both coarse and fine frequency estimates \n 3=performs time-domain correction based on full packet measurement. */ IQV_SYM_TIM_ENUM timingCorrect; //!< Specifies the timing offset correction mode. Default: IQV_SYM_TIM_ON /*!< Valid values are as follows: \n 1=Does not perform timing correction \n 2=Correction for symbol clock offset */ IQV_AMPL_TRACK_ENUM amplitudeTrack; //!< Indicates whether symbol to symbol amplitude tracking is enabled. Default: IQV_AMPL_TRACK_OFF /*!<Valid values are as follows: \n 1=Disabled \n 2=Enabled */ } Acq; //! Specifies decoding parameters for the frame structure of signals compliant with the IEEE 802.16 standards specification. /*! This structure contains fields for setting the BSID, IUC, Frame Number and decode option for 802.16d signals. When decode is set to 1 (indicating that the packet should be fully decoded), the BSID, IUC and Frame Number fields are used, otherwise these fields are ignored. */ struct DEC_80216 { double decode; //!< Indicates whether bursts are decoded. Default: 0 /*!< Valid value are as follows: \n 0=disabled \n 1=enabled */ double bsid[4]; //!< Indicates the base station ID. Default: 0001 /*!< The Base Station ID is necessary to derandomize. Most Significant Bit must be represented first; example: [0111] */ double iuc[4]; //!< Indicates downlink or uplink interval usage code. Default: 0111 /*!< This downlink or uplink interval usage code ID is necessary to derandomize. Most Significant Bit must be represented first; example: [0111] */ double frameNum[4]; //!< Indicates frame number. This ID is necessary to derandomize. Default: 0001 /*!< This frame number ID is necessary to derandomize. Most Significant Bit must be represented first; example: [0111] */ } Dec; // Decoding Parameters... not used in this release. //! Used for non-auto-detect operations /*! Decoding parameters are reserved for future use. */ char *mapConfigFile; //!< Map configuration file /*!< \note For 802.16e analysis, a map configuration file (*.mcf) is required for non-auto-detect operation. Map configuration files can be created using the IQsignal for WiMAX GUI. */ int loggingMode; //!< Indicates the verbosity of the WiMAX analysis. Default: 0 (no logging) /*!<Valid values are as follows: \n 0=no logging \n 1=console (text to screen) logging \n 2=file \n 3=console and file logging \n Default value is 1. */ int masterRxSig; //!< Indicates the Rx signal used for detection/acquisition. Default: 1 (detection) /*!< Specifies which VSA signal should be used for detection/acquisition when analyzing MIMO signals. The default value is 1, which indicates that the signal captured by the first VSA is used. \n When MIMO signals are analyzed, this function specifies which signal must be used as the master signal. \n Valid values are as follows: \n 1=detection \n 2=acquisition. This field is reserved for future use \note The default value is 1 and must not be changed. */ int SetDefault(); private: int Unpack80216Analysis(void *mx_result_in); }; // **************************************************************** // Zigbee Analysis Parameters Class (Derived from iqapiAnalysis) // **************************************************************** //! Specifies Zigbee analysis parameters. class IQ_API iqapiAnalysisZigbee : public iqapiAnalysis { public: iqapiAnalysisZigbee( void); //!< Constructor ~iqapiAnalysisZigbee( void); //!< Destructor double sigType; //!< Specifies the signal type. Default: 1 (for OQPSK) /*!< Currently, only the default value of 1 (for OQPSK) is supported. Valid values are as follows: \n IQV_FREQ_SYNC_ENUM=Long Training (Signal type is long preamble) \n IQV_FREQ_SYNC_ENUM=Full Packet (Signal type is full packet) \n IQV_AMPL_TRACK_ENUM This function is reserved for future use. */ IQV_ZIGBEE_PH_CORR_ENUM phaseCorrect; // Symbol by Symbol phase correction. Default: IQV_ZIGBEE_PH_CORR_SYM_BY_SYM (only this choice is available) IQV_ZIGBEE_FREQ_SYNC_ENUM freqCorrect; // frequency synchronization on full data packet. Default: IQV_ZIGBEE_FREQ_SYNC_FULL_PACKET (Only this choice is available) IQV_AMPL_TRACK_ENUM amplitudeTrack; //!< Specifies the Amplitude Tracking mode. Default: IQV_AMPL_TRACK_OFF int SetDefault(); private: int UnpackZigbeeAnalysis(void *mx_result_in); }; // **************************************************************** // Generic multi-use MIMO Analysis Parameters Class (Derived from iqapiAnalysis) // **************************************************************** //! Specifies analysis parameters for signals that are compliant with the IEEE 802.11n standards specification. class IQ_API iqapiAnalysisMimo : public iqapiAnalysis { public: iqapiAnalysisMimo(void); //!< Constructor ~iqapiAnalysisMimo(void); //!< Destructor int enablePhaseCorr; //!< Phase Correlation Default: 1 (phase correction is enabled) /*!<Valid values are as follows: \n 0=phase correction is disabled \n 1=phase correction is enabled */ int enableSymTimingCorr; //!< Symbol Timing Error Default: 1 (symbol timing correction is enabled) /*!<Valid values are as follows: \n 0=symbol timing (symbol clock) correction is disabled \n 1=symbol timing (symbol clock) correction is enabled */ int enableAmplitudeTracking; //!< Amplitude Tracking Default: 0 (amplitude tracking is disabled) /*!<Valid values are as follows: \n 0=amplitude tracking is disabled \n 1=amplitude tracking is enabled */ int frequencyCorr; //!< Frequency Correlation Default: 2 (frequency correction on short and long legacy training fields) /*!<Valid values are as follows: \n 2=frequency correction on short and long legacy training fields \n 3=frequency correction based on full packet \n 4=frequency correction on signal fields (legacy and HT) in addition to short and long training fields */ int decodePSDU; //!< Decode PSDU Default: 1 (decode PSDU) /*!<Valid values are as follows: \n 0=skip decoding of PSDU (sufficient for EVM measurements) \n 1=decode PSDU */ int enableFullPacketChannelEst; //!< Full Packet Channel Estimation Default: 0 (channel estimate on long training fields) /*!<Valid values are as follows: \n 0= channel estimate on long training fields \n 1= reestimate channel on full packet before doing EVM calculation */ int enableMultipathEvm; //!< Enable Multipath EVM for MIMO (IQV_MIMO_ENABLE_MULTIPATH_EVM) Default: 0 (multipath) /*!<Valid values are as follows: \n 0=multipath \n 1=standard */ int useAllSignals; //!< Signals for Stream Analysis Default: 0 (use the first NStreams valid input signals for stream analysis) /*!< \n \note This setting is only relevant if more input signals than streams(*) are available. \n (*) To demodulate a MIMO signal with N streams, at least N different input signals are needed. If \c AnalysisParam.useAllSignals is set to 0 (default), the analysis is based on the first N valid input signals only. The order of preference is determined by the parameter \c Analysis.prefOrderSignals. If \c AnalysisParam.useAllSignals is set to 1, all input signals are used. Valid values are as follows: \n 0=use the first NStreams valid input signals for stream analysis \n 1=use all valid input signals for stream analysis */ int prefOrderSignals[N_MAX_TESTERS]; //!< Preference order used to select input signals if the \c useAllSignals parameter is set to a value of 0. Default: 1,2,3,4 (Use any permutation of the numbers 1,2,3, and 4) /*!< Specifies the sequence of input signals that must be used for analysis. If the number of available input signals (captures) are more than that is required to demodulate a MIMO signal, this parameter allows you to specify the sequence of the input signals that must be used for the analysis. \n \note The number of required captures is equal to the number of data streams in a MIMO signal. Valid values are as follows: \n Default: [1 2 3 4] Use any permutation of the numbers 1,2,3, and 4. \n As an example, when you analyze a one-stream signal with the \c useAllSignals parameter set to 0 and the \c prefOrderSignals parameter set to [2 1 3 4], the analysis first checks the capture from VSA 2 (input signal 2) for a valid signal. If the signal is valid, the analysis will be performed on capture from VSA 1 (input signal 1). If it is not valid, the next signal capture will be performed on capture 1. This process is continued until the required number of valid signals has been found or until all available captures have been checked. In this case, the required number of valid signals is one, because this analysis is on a one-stream signal. */ char *referenceFile; //!< Indicates name of the reference sequential_mimo analysis mode /*!< Valid values are as follows: \n \c composite \n \c sequential_mimo \n This parameter is ignored for NxN systems. */ int SetDefault(); //! Specifies fields for performing a MIMO analysis on a sequential MIMO data capture. struct SEQ_MIMO { int numSections; //!< Number of sections in capture Default: 0 /*!< \c numSections specifies the number of chains which are sequentially captured. The capture is then reshaped into dimensions numSections x (sectionLenSec + interSectionGapSec) before it is passed to the MIMO analysis. */ double sectionLenSec; //!< Length of each section Default: 0.0 /*!< Specified in seconds. */ double interSectionGapSec; //!< Spacing between sections Default: 0.0 /*!< Specified in seconds. */ double sectionGainDb[N_MAX_TESTERS]; //!< Gain compensation per section Default: 0,0,0,0 /*!< \note The analysis mode must be set to \c sequential_mimo when using the SEQ_MIMO structure with sequential data captures. */ } SequentialMimo; //!< Specifies fields for performing a MIMO analysis on a sequential MIMO data capture int loggingMode; //!< Indicates the verbosity of the MIMO analysis. Default: 0 (no logging) /*!<Valid values are as follows: \n 0=no logging \n 1=console (text to screen) logging \n 2=file \n 3=console and file logging \n Default value is 1. */ int packetFormat; //!< Indicates format of the MIMO packet Default: 0 (auto-detect mode) /*!< \n IQV_MIMO_PACKET_FORMAT=0 (auto-detect mode) \n IQV_MIMO_PACKET_FORMAT=1 (mixed mode format) \n IQV_MIMO_PACKET_FORMAT=2 (greenfield format) */ private: int UnpackMimoAnalysis(void *mx_result_in); }; // **************************************************************** // 802.11 a/g (OFDM) Specific Analysis Parameters Class (Derived from iqapiAnalysis) // **************************************************************** //! Specifies the analysis parameters for testing devices that are compliant with the IEEE 802.11 a/g (OFDM) standards specification. class IQ_API iqapiAnalysisOFDM : public iqapiAnalysis { public: /*! This class is used to specify OFDM analysis parameters. */ iqapiAnalysisOFDM(void); //!< Constructor ~iqapiAnalysisOFDM(void); //!< Destructor IQV_PH_CORR_ENUM ph_corr_mode; //!< Specifies the Phase Correlation mode. Default: IQV_PH_CORR_SYM_BY_SYM /*!< IQV_PH_CORR_OFF = 1 indicates phase correction off \n IQV_PH_CORR_SYM_BY_SYM = 2 indicates Symbol-by-symbol correction \n IQV_PH_CORR_MOVING_AVG = 3 moving avg. corr, 10 symbols */ IQV_CH_EST_ENUM ch_estimate; //!< Specifies the Channel Estimate mode. Default: IQV_CH_EST_RAW /*!< \n IQV_CH_EST_RAW = 1 Raw Ch Est, long train \n IQV_CH_EST_2ND_ORDER = 2 2nd Order Polyfit \n IQV_CH_EST_RAW_FULL = 3 Raw Ch Est, full packet */ IQV_SYM_TIM_ENUM sym_tim_corr; //!< Specifies the Symbol Timing Correction mode for SISO. Default: IQV_SYM_TIM_ON /*!< \n IQV_SYM_TIM_OFF = 1 Symbol Timing Correction Off \n IQV_SYM_TIM_ON = 2 Symbol Timing Correction On */ IQV_FREQ_SYNC_ENUM freq_sync; //!< Specifies the Frequency Sync mode. Default: IQV_FREQ_SYNC_LONG_TRAIN /*!< \n IQV_FREQ_SYNC_SHORT_TRAIN = 1 Short Training Symbol \n IQV_FREQ_SYNC_LONG_TRAIN = 2 Long Training Symbol \n IQV_FREQ_SYNC_FULL_PACKET = 3 /* Full Data Packet */ IQV_AMPL_TRACK_ENUM ampl_track; //!< Specifies the Amplitude Tracking mode. Default: IQV_AMPL_TRACK_OFF /*!< \n IQV_AMPL_TRACK_OFF = 1 Amplitude tracking off \n IQV_AMPL_TRACK_ON = 2 Amplitude tracking on */ IQV_OFDM_EVM_METHODS ofdmevmmethod; //!< Specifies the OFDM EVM Method. Default: IQV_OFDM_EVM_STANDARD /*!< IQV_OFDM_EVM_MULTIPATH &mdash; More tolerant of notches in the channel response \n IQV_OFDM_EVM_STANDARD &mdash; Standard 802.11 a/g EVM Method */ int OFDM_demod_on; //!< Specifies whether or not full data demodulation is done. Default: 1 /*!< Valid values are as follows: \n \c 0=does not perform demodulation \n \note This option is used for faster analysis performance; however, some of the results will not be available \n \c 1=performs full demodulation */ IQV_OFDM_MODE_ENUM OFDM_mode; //!< Specifies OFDM mode. Default: IQV_OFDM_80211_AG /*!< Valid vaues are as follows: \n IQV_OFDM_80211_AG \n IQV_OFDM_80211_AG_TURBO \n IQV_OFDM_ASTM_DSRC \n IQV_OFDM_QUARTER_RATE */ double frequencyOffsetHz; //!< Specifies Frequency offset. Default: 0 /*!< If the data capture was performed with a frequency offset (i.e., the VSA and DUT are not set to the same frequency), this field may be used to enable the analysis to compensate the signal with the offset by the specified amount, in Hz. */ int manual_pkt_start; //!< Bypasses the burst detection algorithm of the analysis when it is set to 1. Default: 0 /*!< When set to 1, this field can be used (effectively) to bypass the analysis‘ burst detection algorithm. It also indicates that the packet is starting within the first few samples of the data capture. */ IQV_VSA_NUM_ENUM vsaNum; //!< For MIMO case, tester can capture more than 1 data set. This parameter specifies which data set to be used for doing FFT analysis. Default data set to be analyzed is IQV_VSA_NUM_1 int SetDefault(); //!< Sets the analysis parameters to their default condition /*!< \note There must be a valid connection in order to use this function. Also, this function is called in the constructor of the class (i.e., \c SetDefault occurs when calling \c new for this object) */ private: int UnpackOFDMAnalysis(void *mx_result_in); }; // **************************************************************** // 802.11 b (DSSS) Specific Analysis Parameters Class (Derived from iqapiAnalysis) // **************************************************************** //! Specifies the analysis parameters for testing devices that are compliant with the IEEE 802.11b standards specification. class IQ_API iqapiAnalysis11b : public iqapiAnalysis { public: iqapiAnalysis11b(void); //!< Constructor. ~iqapiAnalysis11b(void); //!< Destructor. IQV_EQ_ENUM eq_taps; //!< Specifies the number of equalizer taps. Default: IQV_EQ_OFF /*!< \n IQV_EQ_OFF = 1 (Equalizer Off) \n IQV_EQ_5_TAPS = 5 (5 taps equalizer) \n IQV_EQ_7_TAPS = 7 (7 taps equalizer) \n IQV_EQ_9_TAPS = 9 (9 taps equalizer) */ IQV_DC_REMOVAL_ENUM DCremove11b_flag; //!< Specifies the DC removal mode. Default: IQV_DC_REMOVAL_OFF /*!< \n IQV_DC_REMOVAL_OFF = 0 (DC removal is off) \n IQV_DC_REMOVAL_ON = 1 (DC removal is on) */ IQV_11B_METHOD_ENUM method_11b; //!< Specifies the 11b EVM method. Default: IQV_11B_STANDARD_TX_ACC /*!< \n IQV_11B_STANDARD_TX_ACC = 1 (11b Std TX accuracy) \n IQV_11B_RMS_ERROR_VECTOR = 2 (Use 11b RMS error vector) */ double frequencyOffsetHz; //!< Enables analysis to handle frequency offset by a specified amount. Default: 0 /*!< This field enables analysis for preset frequency offsets, i.e., the VSA and DUT are not set to the same frequency. The frequency offset is specified in Hz. */ int manual_pkt_start; //!< Bypasses the burst detection algorithm of the analysis. Default: 0 /*!< If \c manual_pkt_start is set to 1, this field is used to effectively bypass the burst detection algorithm of the analysis and to indicate that the packet is starting within the first few samples of the data capture. */ IQV_VSA_NUM_ENUM vsaNum; //!< For MIMO case, tester can capture more than 1 data set. This parameter specifies which data set to be used for doing analysis. Default data set to be analyzed is IQV_VSA_NUM_1 int SetDefault(); private: int Unpack11bAnalysis(void *mx_result_in); }; // **************************************************************** // Bluetooth Specific Analysis Parameters Class (Derived from iqapiAnalysis) // **************************************************************** //! Specifies the analysis parameters for testing devices that are compliant with the bluetooth standards specification. class IQ_API iqapiAnalysisBluetooth : public iqapiAnalysis { public: iqapiAnalysisBluetooth(void); //!< Constructor ~iqapiAnalysisBluetooth(void); //!< Destructor double pwr_detect_gap_time; //!< Specifies the interval that is used to determine if power is present or not (sec). Default: 4e-6 /*!<Specified in seconds. */ double pwr_detect_diff; //!< Specifies the maximum power difference between packets that are expected to be detected. Default: 15 char *analysis_type; //!< Specifies what type of analysis to perform. Default: 'All' /*!<Valid values are as follows: \n \c PowerOnly \n \c 20dbBandwidthOnly \n \c PowerandFreq \n \c All This is the set default value. \n \c ACP only does the new ACP analysis \n \c AllPlus performs all the analyses that are done by ‘All’ plus the ACP analysis */ char syncWord[17]; //!< This field is reserved for future use Default: '0' double dataRate; //!< Sets the signal data rate, and should correspond to the input signal. Default: 0 /*!< Specified in Mbps. Valid values are as follows: 0, 1, 2 or 3 */ double fm_lowpass_F3dbHz; //!< Sets the bandwidth for the FM IF filter Default: 650000 /*!< IF bandwidth = 2 * fm_lowpass_F3dbHz Hz */ int SetDefault(); private: int UnpackBluetoothAnalysis(void *mx_result_in); }; // **************************************************************** // Wave Specific Analysis Parameters Class (Derived from iqapiAnalysis) // **************************************************************** //! Specifies Wave analysis parameters. class IQ_API iqapiAnalysisWave : public iqapiAnalysis { public: iqapiAnalysisWave(void); //!< Constructor ~iqapiAnalysisWave(void); //!< Destructor }; // **************************************************************** // Sidelobe Specific Analysis Parameters Class (Derived from iqapiAnalysis) // **************************************************************** //! Specifies Sidelobe analysis parameters. class IQ_API iqapiAnalysisSidelobe : public iqapiAnalysis { public: iqapiAnalysisSidelobe(void); //!< Constructor ~iqapiAnalysisSidelobe(void); //!< Destructor }; // **************************************************************** // Power Ramp Specific Analysis Parameters Class (Derived from iqapiAnalysis) // **************************************************************** //! Specifies Power Ramp analysis parameters. class IQ_API iqapiAnalysisPowerRamp : public iqapiAnalysis { public: /*! If the overloaded constructor for \c iqapiAnalysisPowerRamp is called with \c doOFDM set to true, then the analysis will be performed for an OFDM signal. Otherwise, the analysis will perform the analysis for an 11b signal. */ iqapiAnalysisPowerRamp(bool doOFDM); iqapiAnalysisPowerRamp(); //!< Constructor ~iqapiAnalysisPowerRamp(void); //!< Destructor }; // **************************************************************** // CW Specific Analysis Parameters Class (Derived from iqapiAnalysis) // **************************************************************** //! Specifies Continuous Wave analysis parameters. class IQ_API iqapiAnalysisCW : public iqapiAnalysis { public: iqapiAnalysisCW(void); //!< Constructor ~iqapiAnalysisCW(void); //!< Destructor }; // **************************************************************** // CCDF Specific Analysis Parameters Class (Derived from iqapiAnalysis) // **************************************************************** //! Specifies CCDF analysis parameters. class IQ_API iqapiAnalysisCCDF : public iqapiAnalysis { public: iqapiAnalysisCCDF(void);//!< Constructor ~iqapiAnalysisCCDF(void); //!< Destructor IQV_VSA_NUM_ENUM vsaNum; //!< For MIMO case, tester can capture more than 1 data set. This parameter specifies which data set to be used for doing analysis. Default data set to be analyzed is IQV_VSA_NUM_1 }; // **************************************************************** // Generic FFT Specific Analysis Parameters Class (Derived from iqapiAnalysis) // **************************************************************** //! Specifies FFT analysis parameters. class IQ_API iqapiAnalysisFFT : public iqapiAnalysis { public: iqapiAnalysisFFT(void); //!< Constructor ~iqapiAnalysisFFT(void); //!< Destructor double NFFT; //!< Specifies the number of points in FFT. Default: 0 int NFFT_over;//!< Specifies the minimum oversampling factor. Default: 2 double F_sample; //!< Specifies the sample frequency in Hz. Default: 80e6 /*!< \note This field will automatically become updated with the sample frequency in the \c hndl->data object. */ double Freq_start; //!< Specifies start frequency, in Hz, for the x-axis in returned results. Default: -33e6 /*!< If the input is less than minus one-half of the sampling frequency, this input is ignored. The default value is minus one-half of the sampling frequency. For example, if sampling frequency is 80 MHz, then the default value is -40 MHz. */ double Freq_stop; //!< Specifies stop frequency, in Hz, for the x-axis in returned results. Default: +33e6 /*!<If larger than half the input sampling frequency this input is ignored. The default value is equal to (freq_sample / 2) - freq_delta [half of the sampling frequency minus frequency_delta]. */ int Delta_freq; //!< Frequency increment in Hz for x axis in returned results. Default: -1 /*!< If larger than half the resolution bandwidth, this input is ignored. If the output vector would be larger than 2^15 elements, this input is also ignored. If ignored, the frequency increment is determined by internal algorithm on basis of window type, resolution bandwidth, and the \c nfft_over value. */ double res_bw; //!< This field is used to specify the resolution bandwidth in Hz. Default: 100000 char *window_type; //!< This field is used to specify the window type. Default: 'blackmanharris' /*!<Valid options are as follows: \n \li blackmanharris; this is the default value \n \li rectangular \n \li hanning */ double video_bw; //!< This field is used to specify the video bandwidth in Hz. Default: 1000 /*!< This setting is ignored in digital spectrum mode */ char *video_av_method; //!< This field is used to specify the video averaging method. For the digital spectrum mode, this value is "average"; for the classical spectrum mode, this value is either "clear write" or "max hold". Default: 'average' /*!< Description of values: \n average&mdash;digital PSD estimation algorithm based on averaging \n clear write&mdash;trace overwritten in each measurement \n max hold&mdash;maximum value taken over measurements */ IQV_SPECTRUM_ANALYSIS_MODE_ENUM spectrumAnalysisMode; //!< This field is used to specify spectrum analysis mode Default: IQV_DIGITAL_SPECTRUM_ANALYSIS_MODE /*!< Valid values are defined as follows: \n IQV_DIGITAL_SPECTRUM_ANALYSIS_MODE&mdash;FFT in digital mode \n IQV_ CLASSICAL_SPECTRUM_ANALYSIS_MODE&mdash;FFT in classical mode */ IQV_VSA_NUM_ENUM vsaNum; //!< For MIMO case, tester can capture more than 1 data set. This parameter specifies which data set to be used for doing FFT analysis. Default: IQV_VSA_NUM_1 virtual int SetDefault(); protected: virtual int UnpackFftAnalysis(void *mx_result_in); }; // **************************************************************** // Power Specific Analysis Parameters Class (Derived from iqapiAnalysis) // **************************************************************** //! Specifies Power analysis parameters. class IQ_API iqapiAnalysisPower : public iqapiAnalysis { public: iqapiAnalysisPower(void); //!< Constructor ~iqapiAnalysisPower(void); //!< Destructor double T_interval; //!< This field is used to specify the interval that is used to determine if power is present or not (sec). Default: 3.2e-6 double max_pow_diff_dB; //!< This filed is used to specify the maximum power difference between packets that are expected to be detected. Default: 15 IQV_VSA_NUM_ENUM vsaNum; //!< For MIMO case, tester can capture more than 1 data set. This parameter specifies which data set to be used for doing FFT analysis. Default: IQV_VSA_NUM_1 int SetDefault(); //!< Sets the analysis parameters to their default condition. Note that there must be a valid connection in order to use this function. Also, note that this function is called in the constructor of the class (ie, SetDefault will happen when calling /c new for this object). private: int UnpackPowerAnalysis(void *mx_result_in); }; // **************************************************************** // HT40 Analysis Parameters Class (Derived from iqapiAnalysis) // **************************************************************** //! Specifies parameters for the wideband FFT analysis of 40 MHz 802.11n signals. class IQ_API iqapiAnalysisHT40 : public iqapiAnalysis { friend class iqapiHndl; public: iqapiAnalysisHT40(void); //!< Constructor virtual ~iqapiAnalysisHT40(void); //!< Destructor static const double dbResolutionBWLowerLimit; IQV_WINDOW_TYPE_ENUM windowType; double dbResolutionBW; //!< It has to be greater or equal to 1000, Default: 100000 IQV_VSA_NUM_ENUM vsaNum; //!< For MIMO case, tester can capture more than 1 data set. This parameter specifies which data set to be used for doing FFT analysis. Default: IQV_VSA_NUM_1 int SetDefault(); }; class IQ_API iqapiAnalysisHT40Data3 : public iqapiAnalysisHT40 { public: iqapiAnalysisHT40Data3(void); //!< Constructor virtual ~iqapiAnalysisHT40Data3(void) {}; //!< Destructor }; // **************************************************************** // 80216 Results Class // type = '80216-2004' or '80216e-2005' // mode = '80216-2004' or '80216e-2005'or 'powerPacketDetect' // Note : // (1) If mode is 'powerPacketDetect', only the following result parameters are needed // => acquisition, type, avgPowerNoGapDb and errTxt // **************************************************************** //! Specifies analysis results generated using \c iqapiResult80216 objects. class IQ_API iqapiResult80216 : public iqapiResult { public: iqapiResult80216(void); //!< Constructor ~iqapiResult80216(void); //!< Destructor int packetDetection;//!< Indicates valid packet detection int acquisition; //!< Indicates valid packet acquisition int demodulation; //!< Indicates valid packet demodulation int completePacket; //!< Indicates that at least one complete packet was found by the analysis int fchHcs; //!< Indicates valid fchHcs char *errTxt; //!< Indicates possible warning and error messages. iqapiMeasurement *analyzedRange; //!< Indicates the start/stop pointers and the packet selected for analysis /*!< \c iqapiMeasurement is a data type used to return result values */ // power iqapiMeasurement *rxRmsPowerDb; //!< RMS power in dBm iqapiMeasurement *avgPowerNoGapDb; //!< Average power iqapiMeasurement *rxPreambleRmsPowerDb;//!< Preamble average power // FrameInfo iqapiMeasurement *sigType; //!< Indicates uplink or downlink burst iqapiMeasurement *numSymbols; //!< Indicates the number of symbols in the analyzed packet iqapiMeasurement *modOrder; //!< 802.16-2004 modOrder iqapiMeasurement *rateId; //!< 802.16-2004 rateId iqapiMeasurement *bandwidthHz; //!< 802.16-2004 bandwidth iqapiMeasurement *cyclicPrefix; //!< 802.16-2004 cyclic prefix iqapiMeasurement *numPreambleSymbols; //!< Indicates the number of preamble symbols // FrameInfo.Fch iqapiMeasurement *validHcs; //!< Indicates valid Hcs iqapiMeasurement *bits; //!< Indicates FramInfo.Fch bits iqapiMeasurement *bsid; //!< Base station ID iqapiMeasurement *frameNum; //!< 802.16-2004 frame number iqapiMeasurement *changeCount; //!< 802.16-2004 change count iqapiMeasurement *Bursts; //!< 802.16-2004 bursts // EVM Measurements iqapiMeasurement *evmAvgAll; //!< EVM Average (All) iqapiMeasurement *evmAvgData; //!< EVM Average (Data) iqapiMeasurement *evmAvgPilot; //!< EVM Average (Pilots) iqapiMeasurement *evmTones; //!< EVM per Tone iqapiMeasurement *evmSymbols; //!< EVM per Symbol iqapiMeasurement *evmCinrDb; //!< EVM Carrier to Interference and Carrier Noise Ratio (CINR in Db) iqapiMeasurement *avgUnmodData; //!< EVM of the unmodulated data carrier // Indexes iqapiMeasurement *dataTones; //!< Data tones iqapiMeasurement *pilotTones; //!< Pilot tones // Data iqapiMeasurement *demodSymbols; //!< Demodulated Symbols iqapiMeasurement *slicedSymbols; //!< Sliced Symbols iqapiMeasurement *validFec; //!< Valid Forward Error Correction iqapiMeasurement *MacPdu; //!< MAC PDU iqapiMeasurement *phaseNoiseDegRmsAll; //!< RMS phase noise in degrees iqapiMeasurement *phaseNoiseDegSymbols; //!< Phase noise per symbol iqapiMeasurement *freqOffsetTotalHz; //!< Frequency offset in Hz iqapiMeasurement *freqErrorHz; //!< Frequency error in Hz iqapiMeasurement *symClockErrorPpm; //!< Symbol clock error in PPM iqapiMeasurement *iqImbalAmplDb; //!< IQ Amplitude Imbalance in dB iqapiMeasurement *iqImbalPhaseDeg; //!< IQ Phase Imbalance in degrees iqapiMeasurement *channelEst; //!< Channel Estimate char *type; //!< Signal/analysis type iqapiMeasurement *dcLeakageDbc; //!< DC leakage in dBc per Rx; dimension 1 x NRx int numberOfZone; //!< Number of zones }; // **************************************************************** // Generic multi-use MIMO Results Class // **************************************************************** //! Specifies analysis results generated using \c iqapiAnalysisMimo objects class IQ_API iqapiResultMimo : public iqapiResult { public: iqapiResultMimo(void); //!< Constructor ~iqapiResultMimo(void); //!< Destructor int packetDetection; //!< Indicates valid packet start detected. int acquisition; //!< Indicates valid HT packet start detected. int demodulation; //!< Indicates streams demodulated (packet may be truncated) int completePacket; //!< Indicates a complete packet was demodulated bool htSigFieldCRC; //!< Indicates valid CRC on HT-SIG bool psduCRC; //!< Indicates valid CRC on PSDU char *errTxt; //!< Error messages text string if analysis failed iqapiMeasurement *analyzedRange; //!< Start and end point of signal part that was used to for analysis. The API picks the first packet in the input signal for analysis; following packets are ignored. iqapiMeasurement *idxAnalyzedSigs; //!< Indexes of input signals that were used for analysis. iqapiMeasurement *channelEst; //!< Channel estimate matrix; dimension NStreams x Ntones x NRx iqapiMeasurement *idxDataTones; //!< Index numbers of data tones in the result data (channelEst etc.); DC component is at index 1. iqapiMeasurement *idxPilotTones; //!< Index number of pilot tones in the result data (channel Est etc.); DC component is at index 1. iqapiMeasurement *evmAvgAll; //!< Averaged, per stream; dimension 1 xNStreams iqapiMeasurement *evmSymbols; //!< Per symbol and stream; dimension NStreams x NSymbols iqapiMeasurement *evmTones; //!< Per tone and stream; dimension NStreams x Ntones iqapiMeasurement *freqErrorHz; //!< Frequency error in Hz iqapiMeasurement *symClockErrorPpm; //!< Symbol clock error in ppm iqapiMeasurement *PhaseNoiseDeg_RmsAll; //!< RMS phase noise, over all received signals iqapiMeasurement *PhaseNoiseDeg_Symbols; //!< Per symbol and VSA signal; dimension NRx x Nsymbols iqapiMeasurement *CCDF_xPowerDb; //!< Complementary Cumulative Distribution Function. dB above average power (x-axis) iqapiMeasurement *CCDF_yProb; //!< Complementary Cumulative Distribution Function. Probability (y-axis) iqapiMeasurement *IQImbal_amplDb; //!< IQ gain imbalance in dB, per stream. iqapiMeasurement *IQImbal_phaseDeg; //!< IQ phase imbalance in degree, per stream. iqapiMeasurement *demodSymbols; //!<Complex demodulated symbols; dimension NTones x NSymbols X Nstreams iqapiMeasurement *slicedSymbols; //!< Sliced symbols iqapiMeasurement *psduBits; //!< Decoded PSDU bits iqapiMeasurement *serviceField; //!< Bits of service field iqapiMeasurement *preambleFreqErrorHz; //!< Preamble frequency error, in Hz iqapiMeasurement *preambleFreqErrorTimeUs; //!< Preamble frequency error versus time iqapiMeasurement *legacyBits; //!< Information from the legacy signal field: 24 bits iqapiMeasurement *legacyLength; //!< Information from the legacy signal field: value in length field as decimal number. iqapiMeasurement *legacyRate; //!< Information from the legacy signal field: data rate information. iqapiMeasurement *htSig1_bits; //!< Information from HT-SIG1:24 bits. iqapiMeasurement *htSig1_mcsIndex; //!< Information from HT-SIG1: MCS index as decimal number. iqapiMeasurement *htSig1_bandwidth; //!< Information from HT-SIG1: bandwidth (0) 20 MHz (1) 40 MHz. iqapiMeasurement *htSig1_htLength; //!< Information from HT-SIG1: value in length field as decimal number iqapiMeasurement *htSig2_bits; //!< Information from HT-SIG-2: 24 bits iqapiMeasurement *htSig2_aggregation; //!< Information from HT-SIG-2: aggregation iqapiMeasurement *htSig2_stbc; //!< Information from HT-SIG-2: 2 bits as decimal iqapiMeasurement *htSig2_advancedCoding; //!< Information from HT-SIG-2: advanced coding iqapiMeasurement *htSig2_shortGI; //!< Information from HT-SIG-2: short guard interval iqapiMeasurement *htSig2_numHTLF; //!< Information from HT-SIG-2: 2 bits as decimal number iqapiMeasurement *htSig2_soundingPacket; //!< Information from HT-SIG-2: sounding packet iqapiMeasurement *rateInfo_bandwidthMhz; //!< Bandwidth in MHz iqapiMeasurement *rateInfo_dataRateMbps; //!< Data rate in Mbps iqapiMeasurement *rateInfo_spatialStreams; //!< Number of spatial streams char *rateInfo_modulation; //!< Modulation type, i.e., '64 QAM' char *rateInfo_codingRate; //!< Coding rate, i.e., '3/4' iqapiMeasurement *rateInfo_spaceTimeStreams; //!< Indicates number of spatial streams. iqapiMeasurement *isolationDb; //!< Matrix indicating isolation between streams /*!<Column 1 is for Rx signal containing main power for stream 1, etc.; dimension NStreams x NStreams \n \note Isolation can only be measured with direct-mapping signals. \n Example: isolationDb = [0 -20; -25 0] - Stream 1 leaks into stream 2 signal with -20 dB - Stream 2 leaks into stream 1 signal with -25 dB */ iqapiMeasurement *dcLeakageDbc; //!< DC leakage in dBc per Rx; dimension 1 x NRx iqapiMeasurement *rxRmsPowerDb; //!< RMS power in dBm iqapiMeasurement *mainPathStreamPowerDb; //!< Main path power per stream (maximum element from each row in channel power matrix rxRmsPowerDb); dimension NStreams x 1 }; // **************************************************************** // OFDM Results Class // **************************************************************** //! Specifies analysis results generated with \c iqapiAnalysisOFDM objects. class IQ_API iqapiResultOFDM : public iqapiResult { public: iqapiResultOFDM(void); //!< Constructor ~iqapiResultOFDM(void); //!< Destructor int psduCrcFail; //!< 0 = PLCP CRC Check Failed int plcpCrcPass; //!< 1 = PLCP CRC Check Passed int dataRate; //!< Data rate in Mbps int numSymbols; //!< Number of symbols int numPsduBytes; //!< Number of bytes in PSDU iqapiMeasurement *evmAll; //!< EVM for entire frame iqapiMeasurement *evmData; //!< EVM for data part of frame iqapiMeasurement *evmPilot; //!< EVM for pilot part of frame iqapiMeasurement *psdu; //!< The PSDU data. 0/1 values. Includes the MAC Header and the FCS, if present. iqapiMeasurement *startPointers; //!< Provides the approximate starting locations of each packet detected in the input data. If no packet detected, this is an empty vector. iqapiMeasurement *stopPointers; // Reserved for future use iqapiMeasurement *hhEst; //!< 64 element complex vector that represents the FFT output of the 2 long symbols in the PLCP pre-amble of the OFDM signal. iqapiMeasurement *plcp; //!< PLCP (binary) data as 1/0s iqapiMeasurement *codingRate; //!< Coding rate. iqapiMeasurement *freqErr; //!< Frequency error iqapiMeasurement *clockErr; //!< Symbol Clock Error iqapiMeasurement *ampErr; //!< IQ Match Amplitude Error iqapiMeasurement *ampErrDb; //!< IQ Match Amplitude Error in dB iqapiMeasurement *phaseErr; //!< IQ Match Phase Error iqapiMeasurement *rmsPhaseNoise; //!< Frequency RMS Phase Noise iqapiMeasurement *rmsPowerNoGap; //!< Power RMS No Gap iqapiMeasurement *rmsPower; //!< Power RMS iqapiMeasurement *pkPower; //!< Power Peak iqapiMeasurement *rmsMaxAvgPower; //!< Power RMS Max. Average iqapiMeasurement *freq_vector; //!< Preamble frequency error iqapiMeasurement *freq_vector_time; //!< Preamble frequency error versus time iqapiMeasurement *evmSymbols; //!< the number of actually analyzed symbols }; // **************************************************************** // 802.11 b Results Class // **************************************************************** //! Specifies analysis results generated using \c iqapiAnalysis11b objects. class IQ_API iqapiResult11b : public iqapiResult { public: iqapiResult11b(void); //!< Constructor ~iqapiResult11b(void); //!< Destructor int lockedClock; //!< Locked Clock, see 802.11b standard int plcpCrcFail; //!< 1 = PLCP CRC Check Failed, 0 = PLCP CRC Check Passes int psduCrcFail; //!< 1 = PSDU CRC Check Failed, 0 = PSDU CRC Check Passes int longPreamble; //!< 1 = Long Preamble, 0 = Short Preamble int numPsduBytes; //!< Number of bytes in PSDU double bitRateInMHz; iqapiMeasurement *evmPk; //!< EVM peak value iqapiMeasurement *psdu; //!< The PSDU data. 0/1 values. Includes the MAC Header and the FCS, if present. iqapiMeasurement *startPointers; //!< Provides the approximate starting locations of each packet detected in the input data. If no packet detected, this is an empty vector. iqapiMeasurement *stopPointers; //!< Provides the approximate end location of each packet. iqapiMeasurement *selectedIndex; //!< Provides the start and end pointer for the packet selected by the analysis program for analysis. iqapiMeasurement *eye; //!< Represents the values of the In-phase receiver channel at 19 samples per chip. Can be used to plot the eye-diagram by plotting samples (0:18)+n*19 on the same plot. iqapiMeasurement *scramblerInit; //!< Scrambler Initialization. 7 element (or empty) Real vector is returned. iqapiMeasurement *plcp; //!< PLCP (binary) data as 1/0s iqapiMeasurement *bitRate; //!< Bit Rate, see 802.11b standards specification. iqapiMeasurement *modType; //!< Mod Type, see 802.11b standards specification. iqapiMeasurement *evmAll; //!< EVM for entire frame iqapiMeasurement *freqErr; //!< Frequency Error iqapiMeasurement *clockErr; //!< Symbol Clock Error iqapiMeasurement *ampErr; //!< IQ Match Amplitude Error iqapiMeasurement *ampErrDb; //!< IQ Match Amplitude Error in dB iqapiMeasurement *phaseErr; //!< IQ Match Phase Error iqapiMeasurement *rmsPhaseNoise; //!< Frequency RMS Phase Noise iqapiMeasurement *rmsPowerNoGap; //!< Power RMS No Gap iqapiMeasurement *rmsPower; //!< Power RMS iqapiMeasurement *pkPower; //!< Power Peak iqapiMeasurement *rmsMaxAvgPower; //!< Power RMS Max. Average iqapiMeasurement *freqErrTimeVect; //!< Frequency Error for the the entire packet plotted against time iqapiMeasurement *freqErrVect; //!< Frequency Error for the entire packet iqapiMeasurement *maxFreqErr; //!< The highest Frequency Error value for the entire packet iqapiMeasurement *loLeakageDb; //!< Lo Leakage iqapiMeasurement *evmInPlcp; //!< EVM in PLCP iqapiMeasurement *evmInPreamble; //!< EVM on preamble iqapiMeasurement *evmInPsdu; //!< EVM in PSDU iqapiMeasurement *evmErr; //!< EVM error }; // **************************************************************** // Wave Analysis Results Class // **************************************************************** //! Specifies results generated with \c iqapiResultWave objects. class IQ_API iqapiResultWave : public iqapiResult { public: iqapiResultWave(void); //!< Constructor ~iqapiResultWave(void); //!< Destructor iqapiMeasurement *dcDc; //!< Dc DC value iqapiMeasurement *dcRms; //!< DC RMS value iqapiMeasurement *dcMin; //!< DC Minimum value iqapiMeasurement *dcMax; //!< DC Maximum value iqapiMeasurement *dcPkToPk;//!< DC Peak to Peak value iqapiMeasurement *dcRmsI;//!< DC RMS for I channel iqapiMeasurement *dcRmsQ;//!< DC RMS for Q channel iqapiMeasurement *acDc; //!< AC DC value iqapiMeasurement *acRms; //!< AC RMS value iqapiMeasurement *acMin; //!< AC Minimum value iqapiMeasurement *acMax; //!< AC Maximum value iqapiMeasurement *acPkToPk;//!< AC Peak to Peak value iqapiMeasurement *acRmsI;//!< AC RMS for I Channel iqapiMeasurement *acRmsQ;//!< AC RMS for Q Channel iqapiMeasurement *rmsDb; //!< AC RMS value in dB }; // **************************************************************** // Sidelobe Results Class // **************************************************************** //! Specifies analysis results generated with \c iqapiAnalysisSidelobe objects. class IQ_API iqapiResultSidelobe : public iqapiResult { public: iqapiResultSidelobe(void); //!< Constructor ~iqapiResultSidelobe(void); //!< Destructor iqapiMeasurement *res_bw_Hz; //!< Resolution bandwidth in Hz iqapiMeasurement *fft_bin_size_Hz;//!< FFT Bin Size in Hz iqapiMeasurement *peak_center; //!< Peak Center in dB iqapiMeasurement *peak_1_left; //!< Peak 1st Lower Side Lobe in dB iqapiMeasurement *peak_2_left; //!< Peak 2nd Lower Side Lobe in dB iqapiMeasurement *peak_1_right; //!< Peak 1st Higher Side Lobe in dB iqapiMeasurement *peak_2_right; //!< Peak 2nd Higher Side Lobe in dB iqapiMeasurement *psd_dB; //!< PSD Plot data in dB }; // **************************************************************** // Power Ramp Results Class // **************************************************************** //! Specifies analysis results generated with \c iqapiAnalysisPowerRamp objects. class IQ_API iqapiResultPowerRamp : public iqapiResult { public: iqapiResultPowerRamp(void); //!< Constructor ~iqapiResultPowerRamp(void); //!< Destructor iqapiMeasurement *on_power_inst; //!< Instant power on ramp iqapiMeasurement *off_power_inst; //!< Instant power off ramp iqapiMeasurement *on_power_peak; //!< Power on ramp peak values iqapiMeasurement *off_power_peak; //!< Power off ramp peak values iqapiMeasurement *on_time_vect; //!< Power on ramp time vector iqapiMeasurement *off_time_vect; //!< Power off ramp time vector iqapiMeasurement *on_mask_x; //!< Power on ramp mask x-axis iqapiMeasurement *off_mask_x; //!< Power off ramp mask x-axis iqapiMeasurement *on_mask_y; //!< Power on mask y-axis iqapiMeasurement *off_mask_y; //!< Power off ramp mask y-axis iqapiMeasurement *on_time; //!< Ramp on time iqapiMeasurement *off_time; //!< Ramp off time }; // **************************************************************** // CW Analysis Results Class // **************************************************************** //! Specifies analysis results generated with \c iqapiAnalysisCW objects. class IQ_API iqapiResultCW : public iqapiResult { public: iqapiResultCW(void); //!< Constructor ~iqapiResultCW(void); //!< Destructor double frequency; //!< Frequency result }; // **************************************************************** // CCDF Results Class // **************************************************************** //! Specifies analysis results generated with \c iqapiAnalysisCCDF objects. class IQ_API iqapiResultCCDF : public iqapiResult { public: iqapiResultCCDF(void); //!< Constructor ~iqapiResultCCDF(void); //!< Destructor iqapiMeasurement *prob; //!< Real vector containing CCDF probability values (Y-axis of CCDF plot) iqapiMeasurement *power_rel_dB; //!< Real vector containing CCDF power relative to average power in dB values (X-axis of CCDF plot) iqapiMeasurement *percent_pow; //!< CCDF power percentage }; // **************************************************************** // FFT Results Class // **************************************************************** //! Specifies analysis results generated with \c iqapiAnalysisFFT objects. class IQ_API iqapiResultFFT : public iqapiResult { public: iqapiResultFFT(void); //!< Constructor ~iqapiResultFFT(void); //!< Destructor iqapiMeasurement *x; //!< X-axis values, typically frequency; vector is returned. iqapiMeasurement *y; //!< y-axis values, power in dBm. Vector is returned. char *x_string; //!< X-axis label. String value is returned. char *y_string; //!< Y-axis label. String value is returned. char *title; //!< Text for title. String value is returned. int valid; //!< Returns (value) whether results are valid or not. 1:valid, 0: invalid int warning; //!< Returns (value) that if equal to 1, indicates that the results should be looked at with caution. char *error; //!< Returns a text string that explains the reason for the valid flag being 0 or the warning flag beint 1. iqapiMeasurement *length; //!< Returns length of X and Y vectors above. iqapiMeasurement *res_bw; //!< Resolution bandwidth used in calculations. iqapiMeasurement *noise_bw; //!< Noise bandwidth used in calculations. May be different than resolution bandwidth. iqapiMeasurement *video_bw; //!< Video bandwidth used in calculation. iqapiMeasurement *Freq_start; //!< Start frequency in Hz. iqapiMeasurement *Freq_stop; //!< Stop frequency in Hz. iqapiMeasurement *Delta_freq; //!< Frequency increment in Hz. }; // **************************************************************** // HT40 Results Class // **************************************************************** //! Specifies analysis results generated with \c iqapiAnalysisHT40 objects. class IQ_API iqapiResultHT40 : public iqapiResult { public: int len_of_ffts; //the length of ffts iqapiResultFFT ** ffts; /// iqapiResultFFT *ffts[N_MAX_TESTER]; iqapiResultHT40(); //!< Constructor virtual ~iqapiResultHT40(); //!< Destructor }; // **************************************************************** // Power Analysis Results Class // **************************************************************** //! Specifies analysis results generated with \c iqapiAnalysisPower objects. class IQ_API iqapiResultPower : public iqapiResult { public: iqapiResultPower(void); //!< Constructor ~iqapiResultPower(void); //!< Destructor char *msg; //!< Possible warning and error messages, text string is returned. int valid; //!< Indicates valid results (1 valid, 0 invalid). iqapiMeasurement *start_loc; //!< Start location for each packet detected. iqapiMeasurement *stop_loc; //!< Stop location for each packet detected. iqapiMeasurement *start_sec; //!< Start time, in seconds, for each packet detected. iqapiMeasurement *stop_sec; //!< Stop time, in seconds, for each packet detected iqapiMeasurement *complete_burst; //!< Indicates complete packet (start/stop found). iqapiMeasurement *P_av_each_burst; //!< Average power of each burst iqapiMeasurement *P_pk_each_burst; //!< Peak power of each burst iqapiMeasurement *P_av_all; //!< Average power of whole capture iqapiMeasurement *P_peak_all; //!< Peak power of whole capture iqapiMeasurement *P_av_no_gap_all; //!< Average power, not counting gaps iqapiMeasurement *P_av_each_burst_dBm; //!< Average power of each burst in dBm iqapiMeasurement *P_pk_each_burst_dBm; //!< Peak power of each burst in dBm iqapiMeasurement *P_av_all_dBm; //!< Average power of whole capture in dBm iqapiMeasurement *P_peak_all_dBm; //!< Peak power of whole capture in dBm iqapiMeasurement *P_av_no_gap_all_dBm; //!< Average power, not counting gaps in dBm }; // **************************************************************** // Zigbee Results Class // **************************************************************** //! Specifies Zigbee analysis for the IEEE 802.15.4 standards specification wireless protocol. class IQ_API iqapiResultZigbee : public iqapiResult { public: iqapiResultZigbee( void); //!< Constructor ~iqapiResultZigbee( void); //!< Destructor int bValid; //!< A value of 1 indicates a valid analysis, 0 indicates a failed analysis. char *errTxt; //!< Contains possible error messages and warnings returned from the analysis. // members extracted from the IQsignal for Zigbee GUI iqapiMeasurement *rxPeakPower; //!< Peak linear power iqapiMeasurement *rxRmsPowerAll; //!< Average linear power of the whole signal iqapiMeasurement *rxRmsPowerNoGap; //!< Average linear power, excluding gaps between packets iqapiMeasurement *rxPeakPowerDbm; //!< Peak power in dBm iqapiMeasurement *rxRmsPowerAllDbm; //!< Average power of the whole signal, in dBm iqapiMeasurement *rxRmsPowerNoGapDbm; //!< Average power, excluding gaps between packets, in dBm int numSymbols; //!< Number of symbols in the PSDU // members extracted from the ResDem Structure // FrameInfo iqapiMeasurement *sigType; //!< Indicates the signal type, currently only 1 is returned (for OQPSK). iqapiMeasurement *fsWaveHz; //!< Indicates the sampling rate used in the analysis. iqapiMeasurement *overSampling; //!< Oversampling ratio per symbol. // EVM Measurements iqapiMeasurement *evmAll; //!< Average EVM for all symbols. iqapiMeasurement *evmAllOffset; //!< Average offset EVM for all symbols. iqapiMeasurement *evmSymbols; //!< EVM for each symbol in the PSDU. // Constellation iqapiMeasurement *constData; //!< Demodulated symbols in the PSDU. // Data iqapiMeasurement *phaseNoiseDegRmsAll; //!< RMS phase noise, in degrees. iqapiMeasurement *phaseNoiseDegError; //!< Phase noise in chip duration, in degrees. iqapiMeasurement *freqOffsetFineHz; //!< Frequency offset error, in Hz. iqapiMeasurement *symClockErrorPpm; //!< Symbol clock error in PPM iqapiMeasurement *eyeDiagramData; //!< Complex baseband signal in the form of eye diagram. iqapiMeasurement *eyeDiagramTime; //!< Time points corresponding to eyeDiagramData // Code Domain iqapiMeasurement *codeDomain; //!< Output of received signal matched with spreading sequences. /// iqapiMeasurement *avgPsdu; //!< Average physical service data unit /// iqapiMeasurement *avgShrPhr; //!< Average synchronization header and physical header iqapiMeasurement *evmPsdu; //!< Average physical service data unit iqapiMeasurement *evmShrPhr; //!< Average synchronization header and physical header iqapiMeasurement *evmAllLinear; iqapiMeasurement *evmPsduLinear; //!< Average physical service data unit in linear iqapiMeasurement *evmShrPhrLinear; //!< Average synchronization header and physical header iqapiMeasurement *evmAllOffsetLinear; //!< Average offset EVM in linear iqapiMeasurement *evmPsduOffsetLinear; //!< Average physical service data unit offset in linear iqapiMeasurement *evmShrPhrOffsetLinear; //!< Average synchronization header and physical header offset in linear iqapiMeasurement *demodSymbolsOversamp; char *type; //!< Indicates the type of analysis performed. }; // **************************************************************** // Bluetooth Analysis Results Class // **************************************************************** //! Specifies analysis results generated with \c iqapiAnalysisBluetooth objects. class IQ_API iqapiResultBluetooth : public iqapiResult { public: iqapiResultBluetooth(void); //!< Constructor ~iqapiResultBluetooth(void); //!< Destructor iqapiMeasurement *P_av_each_burst; //!< Average power of each burst detected, in mWatts. iqapiMeasurement *P_pk_each_burst; //!< Peak power of each burst detected, in mWatts. iqapiMeasurement *complete_burst; //!< Vector indicating whether or not each burst is complete. All elements are either (1: beginning and end transitions detected), or (0: burst is missing either beginning or end transition). iqapiMeasurement *start_sec; //!< Starting time of each burst, in seconds iqapiMeasurement *stop_sec; //!< End time of each burst, in seconds iqapiMeasurement *valid; //!< Flag indicating whether or not the power portion of the bluetooth analysis was successful (1), or not (0). iqapiMeasurement *freq_est; //!< Initial freq offset of each burst detected, in Hz. iqapiMeasurement *freqEstPacketPointer; //!< Pointers to which packet is pointed to in each element of freq_est. iqapiMeasurement *freq_drift; //!< Initial freq carrier drift of each burst detected, in Hz. iqapiMeasurement *freqDriftPacketPointer; //!< Pointers to which packet is pointed to in each element of freq_drift. iqapiMeasurement *bandwidth20dB; //!< 20dB bandwidth value Hz. iqapiMeasurement *deltaF1Average; //!< The measurement result for deltaF1Avg as specified in BLUETOOTH TEST SPECIFICATION Ver. 1.2/2.0/2.0 + EDR [vol 2] version 2.0.E.2. Requires 00001111 data pattern. Result in Hz. iqapiMeasurement *deltaF2Max; //!< The measurement result for deltaF2Max as specified in BLUETOOTH TEST SPECIFICATION Ver. 1.2/2.0/2.0 + EDR [vol 2] version 2.0.E.2. Requires alternating data pattern. Result in Hz. iqapiMeasurement *deltaF2Average; //!< The measurement result for deltaF2Avg as specified in BLUETOOTH TEST SPECIFICATION Ver. 1.2/2.0/2.0 + EDR [vol 2] version 2.0.E.2. Requires alternating data pattern. Result in Hz. iqapiMeasurement *deltaF2MaxAccess; //!< Similar to the measurement result for deltaF2Max as specified in BLUETOOTH TEST SPECIFICATION Ver. 1.2/2.0/2.0 + EDR [vol 2] version 2.0.E.2. Result measured from Access data. Result in Hz. iqapiMeasurement *deltaF2AvAccess; //!< Similar to the measurement result for deltaF2Avg as specified in BLUETOOTH TEST SPECIFICATION Ver. 1.2/2.0/2.0 + EDR [vol 2] version 2.0.E.2. Result measured from Access data. Result in Hz. iqapiMeasurement *EdrEVMAv; //!< RMS Differential EVM value (EDR only). iqapiMeasurement *EdrEVMpk; //!< Peak Differential EVM value (EDR only). iqapiMeasurement *EdrEVMvalid; //!< Indicates validity of EDR EVM Measurements. iqapiMeasurement *EdrPowDiffdB; //!< Relative power of EDR section to FM section of packet, in dB. iqapiMeasurement *freq_deviation; //!< Similar to the measurement result for deltaF1Avg as specified in BLUETOOTH TEST SPECIFICATION Ver. 1.2/2.0/2.0 + EDR [vol 2] version 2.0.E.2. Result measured from Header data. Result in Hz. iqapiMeasurement *freq_deviationpktopk; //!< Peak to Peak Frequency Deviation, in Hz during header. iqapiMeasurement *freqDeviationPointer; //!< Pointers to which packet is pointed to in each element of the above two measurements. iqapiMeasurement *freq_estHeader; //!< Estimates the Frequency Offset during the Header in Hz. iqapiMeasurement *EdrFreqExtremeEdronly; //!< Reports the extreme value of the frequency variation during DPSK in Hz. Does not include the offset during the header. iqapiMeasurement *EdrprobEVM99pass; //!< The percentage of symbols with EVM below the threshold. Threshold for 2 Mbps is 0.3 for 3 Mbps is 0.2. iqapiMeasurement *EdrEVMvsTime; //!< Max DEVM Average as specified in: BLUETOOTH TEST SPECIFICATION Ver. 1.2/2.0/2.0 + EDR [vol 2] version 2.0.E.2. iqapiMeasurement *validInput; //!< Indicates whether or not the input wave was valid. char *sCaution; //!< Possible error and warning messages. char *analysisType; //!< Indicates which analysis is performed. char *versionString; //!< Indicates the version of the BT analysis module. double dataRateDetect; //!< The detected data rate iqapiMeasurement *EdrFreqvsTime; //!< Enhanced data rate for frequency versus time iqapiMeasurement *maxfreqDriftRate; //!< 1 Mbps only, takes the maximum drift over specified time interval iqapiMeasurement *EdrFreqvsTimeLength; //!< Number of elements in EdrFreqvsTime iqapiMeasurement *EdrOmegaI; //!< \c Omega_i, same as \c freq_estHeader iqapiMeasurement *EdrExtremeOmega0; //!< Extreme value of \c Omega_0, same as \c EdrFreqExtremeEdronly iqapiMeasurement *EdrExtremeOmegaI0; //!< Extreme value of (Omega_0 + Omega_i) iqapiMeasurement *payloadErrors; //!< Reports the number of data errors in Payload. Not counting CRC. If -1, this value has not been calculated. If larger negative number, it reports the length of the payload data vector. This happens when the length of the payload vector is shorter than the length indicated in the payload header. int acpErrValid; //!< 1 if ACP results are valid. Otherwise, it will be 0. char *acpErrMsg; //!< Text string reporting error for ACP calc iqapiMeasurement *maxPowerAcpDbm; //!< Reports max power in 1 MHz bands at specific offsets from center frequency. The offset in MHz is given in sequenceDefinition. Method according to 5.1.8 TRM/CA/06/C iqapiMeasurement *maxPowerEdrDbm; //!< Reports max power in 1 MHz bands at specific offsets from center frequency. The power at 0 MHz offset and +/-1 MHz offset is calculated differently from above. maxPowerEDRdBm follows 5.1.15 TRM/CA/13/C iqapiMeasurement *meanNoGapPowerCenterDbm; //!< Mean power in 1 MHz band. Is no gap power, i.e. only averaged when signal exceeds threshold iqapiMeasurement *sequenceDefinition; //!< Offset in MHz for results in maxPowerACPdBm and maxPowerEDRdBm }; // **************************************************************** // Data Capture Class // **************************************************************** //! Specifies parameters to capture a signal. class IQ_API iqapiCapture : public iqapiSignalData { public: iqapiCapture(void); //!< Constructor ~iqapiCapture(void); //!< Destructor //Copy constructor iqapiCapture(const iqapiCapture &src); //!< A Copy Constructor that can be used to make a deep copy of an iqapiCapture object. Use this constructor when you wish to create a copy of an iqapiCapture object. iqapiCapture & operator = (const iqapiCapture & src); ////int length[N_MAX_TESTERS]; //!< This integer array represents the length of the real and imag vectors described below (one integer for each VSA in the LitePoint Test Instrument(s)). Length[0] indicates the length of \c real[0] and \c imag[0] and is the sample data returned from the first VSA (0). ////double *real[N_MAX_TESTERS]; //!< This double pointer array represents the (real) sample data captured on each VSA. The length of real[x] is indicated by length[x], where x is the VSA number (minus one). ////double *imag[N_MAX_TESTERS]; //!< This double pointer array represents the (imaginary) sample data captured on each VSA. The length of imag[x] is indicated by length[x], where x is the VSA number (minus one). ////double sampleFreqHz[N_MAX_TESTERS]; //!< This double array represents the sample frequency of real and imag. sampleFreqHz[x] is the sampling rate of real[x] and imag[x], where x is the VSA number (minus one). int adc_clip[N_MAX_TESTERS]; //!< This integer array indicates whether or not clipping occurred during the data capture stored in \c real and \c imag. \c adc_clip[x] indicates clipping in \c real[x] and \c imag[x], where x is the VSA number (minus one). // Text of last error char lastErr[MAX_LEN_ERR_TXT]; //!< Saves the iqapiCapture object to a \c .sig file, (set by filename) which can be read and analyzed by IQsignal for MIMO. This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). int Save(char *fileName) { return Save(fileName, IQV_DATA_IN_IQAPI); }; int Save(char *fileName, IQV_CAPTURE_DATA_HANDLING_ENUM captureDataHandling); //!< Saves the captured signal in a file (.sig) int SaveNormalize(char *fileName, IQV_CAPTURE_DATA_HANDLING_ENUM captureDataHandling = IQV_DATA_IN_IQAPI, int lengthOfNormFactorDb=0, double *normFactorDb=NULL); //!< Saves normalized captured signal to a file (typically, a \c .mod file); this file can be used as a generator file to download to the VSG. /*! Displays the signal contents of an \c iqapiCapture object during the debug and development phases. The data will first be converted to dBm before plotting. This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). */ int PlotPower(int figNum, char *plotArgs, int vsaNum); /// Internal use void SetCaptureType(IQV_CAPTURE_TYPE_ENUM capType); IQV_CAPTURE_TYPE_ENUM GetCaptureType(); double reserved[3]; private: int Save(char *fileName, enum IQV_SAVE_FILE_TYPE_ENUM eFileType, IQV_CAPTURE_DATA_HANDLING_ENUM captureDataHandling = IQV_DATA_IN_IQAPI, int lengthOfNormFactorDb=0, double *normFactorDb = NULL); IQV_CAPTURE_TYPE_ENUM captureType; }; // **************************************************************** // VSG Parameters Class - applies individually to each test system. // **************************************************************** //! Specifies transmitter parameters that are specific for each Vector Signal Generator. class IQ_API iqapiVsg { public: iqapiVsg(void); //!< Constructor ~iqapiVsg(void); //!< Destructor IQV_RF_ENABLE_ENUM enabled; //!< Enables or disables RF /*!< Available options are as follows; IQV_RF_DISABLED indicates that the RF is disabled. IQV_RF_ENABLED indicates that the RF is enabled */ IQV_PORT_ENUM port; //!< Represents RF N-connector port selection /*!< Available options are as follows: IQV_PORT_OFF = 1 indicates that the port is disabled. IQV_PORT_LEFT = 2 indicates that the RF uses the left port. IQV_PORT_RIGHT = 3 indicates that the RF uses the right port. */ IQV_SOURCE_ENUM source; //!< Represents the signal source of all VSGs. /*!< IQV_SOURCE_WAVE represents internal modulation from wave. IQV_SOURCE_SIGNAL_GENERATOR represents internal modulation from CW signal generator. IQV_SOURCE_UNDEFINED represents undefined default modulation source. */ double sineFreqHz;//!< This field represents the VSG signal generator's sine wave frequency. Only applies if source is set to IQV_SOURCE_SIGNAL_GENERATOR. double rfGainDb; //!< Represents RF gain in dB. double bbGainDb; //!< Represents BB gain in dB. double dcErrI; //!< Represents signal modulation DC offset (I Channel) double dcErrQ; //!< Represents signal modulation DC offset (Q Channel) double phaseErr; //!< Represents signal generator's phase error double gainErr; //!< Represents signal generator's gain error double delayErr; //!< Represents signal generator's delay error double cmvI; //!< Represents common mode voltage setting for the I channel double cmvQ; //!< Represents common mode voltage setting for the Q channel int powerOutOfRange;//!< Flag that indicates if VSG power level set by user is outside of valid range double fpgaLoadCalTable; //!< Specifies values for loading FPGA calibration table /*!< This parameter applies to the LitePoint test system hardware versions 1.6.x version or higher. \param[in] 0=Uses middleware compensation method; calibration is always available \param[in] 1=Uses FPGA real-time compensation; calibration may not be available \return 0=Tables have been downloaded \return -1=Tables are not available */ iqapiMeasurement *timeGapUpSec; //!< Position(s) in downloaded waveform where power should be turned on (in seconds) /*!< This is typically at the beginning of a packet; applies only if \c tx.gapPowerOff is true */ iqapiMeasurement *timeGapDnSec; //!< Position(s) in downloaded waveform where power should be turned off (in seconds) /*!< This is typically at the end of a packet; applies only if \c tx.gapPowerOff is true */ IQV_MIRROR_FREQ_ENUM mirrorFreq; // Added for 1.3.2.3 }; // **************************************************************** // Tx Parameters Class - applies to all test systems (except member vsg) // **************************************************************** //! Specifies parameters for transmitting signals. class IQ_API iqapiTx { public: iqapiTx(void); //!< Constructor ~iqapiTx(void); //!< Destructor IQV_INPUT_MOD_ENUM txMode; //!< Represents the VSG signal transmission mode /*!< Available options are as follows: IQV_INPUT_MOD_DAC_RF indicates RF transmit mode IQV_INPUT_MOD_DAC_BB indicates BB transmit mode IQV_INPUT_MOD_UNDEFINED indicates an undefined default value */ double rfFreqHz; //!< This field represents the RF frequency for the VSGs,in Hz. /*!< For IQview/flex/nxn systems valid values are in the 2.4 and 4.9-6.0 GHz ranges, in increments of 1 MHz. */ double sampleFreqHz; IQV_MODULATION_CONTROL_ENUM modulationMode; //!< Represents VSG modulation mode. /*!<Available options are as follows: IQV_WAVE_DL_MOD_DISABLE indicates that the modulation is halted after the wave file is downloaded unless it is in continuous Tx mode. IQV_WAVE_DL_MOD_ENABLE indicates that modulation is continued after the wav file is downloaded */ iqapiVsg *vsg[N_MAX_TESTERS]; //!< Represents individual VSG parameters IQV_GAP_POWER gapPowerOff; //!< Controls VSG power during signal gaps (idle time) /*!< Used for backward compatibility */ IQV_ALC_MODES alcMode; //!< Automatic level control IQV_VSG_TRIG triggerType;//!< VSG trigger IQV_VSG_TRIG_REARM triggerReArm; //!< Indicates if VSG needs to be re-armed after the trigger event double freqShiftHz; //!< Tx IF Frequency in Hz /*!< Before downloading to the VSG, the waveform is shifted by the indicated value in Hz; this can be used to get higher resolution on systems that support only 1 MHz resolution */ IQV_LO_PORT_ENUM c_loRfPort; //!< Indicates ENUM value for RF LO port /*!<RF LO is available for hardware versions 1.6.2 and higher */ IQV_LO_PORT_ENUM c_loIfPort; //!< Indicates ENUM value for IF LO port double waveIntervalSecs; //!< Used for padding the wave with zero by the \c waveIntervalSecs time; /*!<The default value is 0 */ }; // **************************************************************** // VSA Parameters Class - applies to each test system individually // **************************************************************** //! Specifies receiver parameters that are specific for each Vector Signal Analyzer. class IQ_API iqapiVsa { public: iqapiVsa(void); //!< Constructor ~iqapiVsa(void); //!< Destructor IQV_RF_ENABLE_ENUM enabled; //!< Specifies whether VSA RF input is enabled or disabled /*!< Available options are as follows: IQV_RF_DISABLED indicates that RF is disabled. IQV_RF_ENABLED indicates that RF is enabled. */ IQV_PORT_ENUM port; //!< Represents RF N-connector port selection /*!< Available options are as follows: IQV_PORT_OFF = 1 indicates that the port is disabled. IQV_PORT_LEFT = 2 indicates that the RF uses the left port. IQV_PORT_RIGHT = 3 indicates that the RF uses the right port. */ double rfAmplDb; //!< Represents the RF amplitude in dBm /*!< \note This parameter replaces the \a rfGainDb; parameter. */ double bbAmplDbv; //!< Represents the Baseband amplitude in dBV double bbGainDb; //!< Represents baseband gain in dB. IQV_MIRROR_FREQ_ENUM mirrorFreq; //!< Mirrors the center frequency in the frequency spectrum of the captured signal. Calculates the complex conjugate of the signal /*!< Available options are as follows: IQV_MIRROR_FREQ_DISABLED indicates that mirror frequency spectrum is disabled. IQV_MIRROR_FREQ_ENABLED indicates that mirror frequency spectrum is enabled. */ double extAttenDb; //!< Represents external attenuation in dB. }; // **************************************************************** // Rx Parameters Class - applies to all test system (except member vsa) // **************************************************************** //! Specifies parameters for receiving the signal. class IQ_API iqapiRx { public: iqapiRx(void); //!< Constructor ~iqapiRx(void); //!< Destructor IQV_INPUT_ADC_ENUM rxMode; //!< Capture mode for the VSAs. /*!< This field represents the capture mode for the VSAs. Available options are as follows: IQV_INPUT_ADC_RF, which represenst data captured from RF IQV_INPUT_ADC_BB, which represents data captured from base band IQV_INPUT_ADC_UNDEFINED, which represents undefined default value IQV_GET_RAW_DATA = -2, which represents getting the raw data with no compensation */ double rfFreqHz; //!< This field represents the RF Frequency for the VSAs,in Hz. /*!< For IQview/flex/nxn systems valid values are in the 2.4 and 4.9-6.0 GHz ranges, in increments of 1 MHz. */ double freqShiftHz; //!< This field represents the Rx IF frequency in Hz /*!< After capturing by the VSA(s), the signal is shifted by the indicated value; this can be used to analyze signals at intermediate frequencies not directly supported by the instrument */ /*Rx Intermediate Frequency for all VSAs*/ double samplingTimeSecs; //!< Sampling time, in seconds, for all VSAs. double sampleFreqHz; //!< ADC sampling frequency in Hz, for all VSAs. Recommended frequency is 80 MHz. IQV_TRIG_TYPE_ENUM triggerType; //!< This field represents the trigger type used for the VSA master. /*!<The VSA slaves (including the VSG master), are always triggered by the VSA master. */ double triggerLevelDb; //!< Signal (IF) trigger level in dB, relative to VSA master's \c rfAmplDb setting. double triggerPreTime; //!< Amount of data to capture before the trigger point, in seconds. double triggerTimeOut; //!< Trigger timeout in seconds. iqapiVsa *vsa[N_MAX_TESTERS]; //!< Parameters unique to each vsa IQV_RX_POWER_MODES powerMode; //!< Represents the AGC power mode. /*!< IQV_VSA_TYPE_0, where VSA Type 0 is the default value and represents RMS Power Mode. IQV_VSA_TYPE_1, where VSA Type 1 is the recommended value and represents Peak Power Mode. */ }; //! Specifies parameters for the signal frequency range. struct IQ_API iqapiFreqBands { double freqMin; //!< Indicates minimum signal frequency double freqMax; //!< Indicates maximum signal frequency }; //! Specifies parameters for VSA and VSG calibration; middleware table. class IQ_API mwTable { private: double *table; int numberOfRow; int numberOfCol; public: mwTable(); //!< Constructor ~mwTable(); //!< Destructor void SetTable(double *tbl); void SetNumberOfRow(int numOfRow) { numberOfRow = numOfRow; }; void SetNumberOfCol(int numOfCol) { numberOfCol = numOfCol; }; const double *GetTable() { return table; }; int GetNumberOfRow() { return numberOfRow;}; int GetNumberOfCol() { return numberOfCol;}; }; class IQ_API DualHead : public DualHeadBase { public: DualHead(iqapiHndlBase *hndl); ~DualHead(); bool SetToken (unsigned int token, unsigned int value); unsigned int GetToken (unsigned int token); void DoTesterExtraSetting(); }; // **************************************************************** // iqapi API Handle Class - Main Object // **************************************************************** //! Specifies parameters to control the test system hardware, perform signal analysis and generate waveform data. class IQ_API iqapiHndl : public iqapiHndlBase { private: int A21SequenceLimitation; public: iqapiHndl(void); //!< Constructor ~iqapiHndl(void); //!< Destructor // **************************************************************** // Connection Handling Functions // **************************************************************** int ConInit(char *ip1, IQV_CONNECTION_TYPE connectionType = IQV_CONNECTION_OTHER); //!< Connects to and initializes a single test system. /*!<Initializes a connection to a test system. The input must be a valid IP address, such as 192.168.100.254. This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). */ int ConInit(char *ip1, char *ip2); //!< Connects to and initializes two test systems. /*!<Initializes a connection to a test system unit that contains two IQnxn test systems. The input must be a valid IP address such as 192.168.100.254. This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). */ int ConInit(char *ip1, char *ip2, char *ip3);//!< Connects to and initializes three test systems. /*!< Initializes a connection to a test system unit that contains three IQnxn test systems. The input must be a valid IP address such as 192.168.100.254. This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). */ int ConInit(char *ip1, char *ip2, char *ip3, char *ip4); //!< Connects to and initializes four test systems. /*!< Initializes a connection to a test system unit that contains four IQnxn Test Instruments. The input must be a valid IP addresses such as 192.168.100.254. This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). */ int ConOpen(char *ip1=NULL, char *ip2=NULL, char *ip3=NULL, char *ip4=NULL, IQV_CONNECTION_TYPE connectionType = IQV_CONNECTION_OTHER); //!< Connects to or reconnects to the test systems. /*!< Reopens a connection to a test system which was previously established using the \c ConInit() function. This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). \note Entering IP addresses is optional. If the IP address has been provided previously by the \c ConInit() function, then you do not have to enter the IP address. */ int ConClose(); //!< Closes one or more connections to the test systems. /*!< Closes a connection to a test system which was previously established with the \c ConInit function or opened with the \c ConOpen() function. This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). */ bool ConValid(); //!< Indicates valid, open connection. /*!< Checks the validity of a connection to a test system. This function returns a value of true if the connection is open and valid, or false if the connection is closed or invalid. */ // Reserved for future use - DO NOT USE int ConInit2(char *ip1); //!< Connects to and initializes a single test system. This function is reserved for internal use. int ConInit2(char *ip1, char *ip2); //!< Connects to and initializes two test systems. This function is reserved for internal use. int ConInit2(char *ip1, char *ip2, char *ip3); //!< Connects to and initializes three test systems. This function is reserved for internal use. int ConInit2(char *ip1, char *ip2, char *ip3, char *ip4); //!< Connects to and initializes four test systems. This function is reserved for internal use. // End Reserved int GetAllVersions(char *version, int versionSize); //!< Gets all versions related to software and hardware of the test system int GetIqapiVersion(char *version, int versionSize); int GetHardwareVersion(char *buff, int bufflen); //!< Gets the hardware version of the test system. int GetFirmwareVersion(char *buff, int bufflen);//!< Gets the firmware version of the test system. int GetCalibrationDate(char *buff, int bufflen);//!< Gets the calibration date of the test system. int GetSerialNumber(char *buff, int bufflen); //!< Gets the serial number of the tester. buffer length has to be at least 9 in length. ex.: IQP00100 int IsAppLicSupported(char *AppLicNameToCheck, int *iSupport); //!< Checks if application license is valid /*!< The description of parameters is as follows: \n \c AppLicNameToCheck&mdash; checks the documentation for the name of an application license. \c WIMAX_CPP_API is an example of a name of an application license \n \c iSupport&mdash; indicates whether or not license is available \n 0=License is available \n 1=License is not available */ // **************************************************************** // Set-up and Configuration Functions // **************************************************************** int SetDefault();//!< Resets and initializes test systems /*!< Resets a test system, and initializes the associated objects in an \c iqapiHndl object. The test system and software are set to default conditions. \note This function does not have to be called after calling the \c ConInit() function. The \c ConInit() function resets and initializes the test system and therefore the SetDefault() function does not have to be called after calling the SetInit() function. This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). */ int SetTx(); //!< Sets Tx configuration /*!< Applies Tx settings to a test system, as configured in the \c iqapiTx object in \c iqapiHndl (\c hndl->tx). This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). */ int SetRx(); //!< Sets Rx configuration /*!< Applies Rx settings to a test system, as configured in the \c iqapiRx object in \c iqapiHndl (\c hndl->rx). This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). */ int FrameTx(int numFrames); //!< Starts frame Tx mode for the number of frames indicated in the \c numFrames parameter /*!< Transmits the number of frames indicated in the \c numFrames parameter from the test system VSG. \n The \c numFrames parameter can have an integer value between 1 and 65534. \n If \c numFrames=0, then the VSG resumes continuous transmission. \n This function returns a value of 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). */ int GetStatus(); //!< Retrieves hardware status from the test system. /*!< Retrieves the current hardware status of a test system. The hardware-related objects in \c iqapiHndl will become updated with the current settings on the hardware. This could be used, for instance, to detect if another application has changed some settings on the system. This function returns a value of 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). */ bool TxDone(int *errCode); //!< Indicates if the frame Tx mode is complete /*!< Retrieves the current Tx status of the VSGs in the test systems. This function returns true if a \c FrameTx() operation is done, or false if the VSGs are still transmitting (which will be the case during continuous Tx). The integer pointed to by \c errCode will become updated with the current error level, 0, (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). */ int Agc(bool AgcAll); //!< Performs autorange, optionally, individually for all test systems. /*!< Performs automatic gain control (AGC) on the VSAs in a test system. The \c iqapiRx objects of an \c iqapiHndl will get updated with the new settings, if successful. Setting the \c AgcAll value to \c TRUE causes an AGC to be performed on all the VSAs in the system; a value of \c FALSE causes an AGC to be performed only on the VSA Master. The remaining IQnxn Test Instrument VSAs will be set to the same value as the VSA Master. This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer) */ int SetTxRx(); //!< Sets Tx and Rx configurations /*!< Applies Tx and Rx settings to a test system, as configured in the \c iqapiTx and \c iqapiRx objects in \c iqapiHndl (\c hndl->tx and \c hndl->rx). This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). */ // **************************************************************** // Wave Generation and Downloading Functions // **************************************************************** int GenerateWave(iqapiWaveGenParms *waveGen); //!< Generates Tx modulation waveform /*!< Generates modulation data to be downloaded to the VSGs in a test system. If successful, the \c iqapiModulationWave object in \c iqapiHndl (hndl->wave) gets updated with the waveform data specified by the configuration in the \c waveGen parameter. This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). */ int SetWave(iqapiModulationWave *modWave = NULL); //!< Downloads waveform to the VSG using data generated by the GenerateWave() function /*!< Downloads the \c iqapiModulationWave object currently pointed to by the \c hndl->wave object, to the VSGs in a test system. \note If the number of streams is less than the number of test systems, zeros will be downloaded to the remaining VSG test system. Also, if the number of streams is greater than the number of test systems, the remaining streams will be ignored in the download. This function supports legacy IQview software \c .mod files as well as the IQapi software \c .mod files. This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). */ int SetWave(char *fileName); //!< Downloads waveform data to VSG loaded from a file /*!< Performs the same operations as \c SetWave, and additionally sets marker information in the VSG. This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). */ int SetWaveWithSegments(char *fileName); // **************************************************************** // Multi-wave add, download, select Functions // **************************************************************** int MultiWaveAddByFile(char *fileName, int *index); //!< Adds a waveform from a modulation file to cache int MultiWaveAddCw(double frequency, int *index, double*frequencyActual);//!< Adds a continuous waveform to cache int MultiWaveAddByWave(iqapiModulationMultiWave *multiwave, int *indexWave);//!< Adds a waveform from RAM to cache int MultiWaveDownload(); //!< Downloads a multi-waves from cache to active memory int MultiWaveSelect(int index); //!< Selects a waveform by index int MultiWaveClear(); //!< Clears all the cached waveforms; does not clear the waveform running on the VSG int MultiWaveGetDescription(); //!< Gets the description of the multiwave waveform int mulWaveDescNumOfWave; //!< Indicates description of the number of multiwaves double *mulWaveDescMenuIndexes; //!<Indicates the description of the menu indexes char mulWaveDescFull[32][256]; //!< Indicates description of the multiwave waveform char mulWaveDescMenuTxt[32][256]; //!< Indicates description of the menu text char mulWaveDescWaveName[32][256]; //!< Indicates description of the name of the multiwave waveform // **************************************************************** // Data Capture and Analysis Functions // **************************************************************** int Capture(); //!< Performs a data capture /*!< Performs a data capture using the current settings applied in \c hndl->rx. If successful, \c hndl->data will point to an \c iqapiCapture object which contains the sample data. This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). */ int Capture(int vsaNum); //!< Performs a data capture on a single VSA in an IQnxn test system configuration /*!< In an IQnxn configuration, this function performs a data capture using the current settings applied in a \c hndl->rx object, on only the requested VSA (as specified by \c vsaNum). If successful, the \c hndl->data object will point to an \c iqapiCapture object which contains the sample data. This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). */ int Capture(double sampleTimeSecs) //!< Performs a data capture of length indicated in the \c sampleTimeSecs parameter /*!< This function is implemented in the header file, and calls \c Capture(), but sets the sampling time first. */ { rx->samplingTimeSecs = sampleTimeSecs; SetRx(); return (Capture()); } // int Capture(iqapiCapture *userData); //!< Performs a data capture using the current settings applied to the \c hndl->rx object /*!< Performs a data capture using the current settings applied in \c hndl->rx. If successful, userData will point to an iqapiCapture object which contains the sample data. This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer) \note \c userData must be created before calling this function. */ int ContCapture(IQV_DC_CONT_ENUM mode, int vsaNum = 1); //!< Performs continuous data capture modes; this function is reserved for future use int Analyze(iqapiSignalData *userData); //!< Analyzes the data from the user using the current settings /*!< Performs analysis on the \c iqapiCapture object pointed to by \c userData, using the analysis parameters pointed to by the \c hndl->analysis object. If successful, the \c hndl->results object will point to a result object (derived from iqapiResult) of the type specified by the \c hndl->analysis object. For instance, if after a data capture \c hndl-analysis points to an \c iqapiAnalysisOFDM object, \c hndl->analyze object will cause \c hndl->results object to point to an object of type \c iqapiResultOFDM. This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). */ int Analyze(); //!< Analyzes the current capture buffer using the current settings /*!< Performs analysis on the \c iqapiCapture object pointed to by the \c hndl->data object, using the analysis parameters pointed to by the \c hndl->analysis object. If successful, the \c hndl->results object will point to a result object (derived from the \c iqapiResult object) of the type specified by the \c hndl->analysis object. For instance, if after a data capture the \c hndl-analysis object points to an \c iqapiAnalysisOFDM object, the \c hndl->analyze object will cause the \c hndl->results object to point to an object of type \c iqapiResultOFDM. This function returns 0 (IQAPI_ERR_OK) if successful; if it returns a value that is less than 0, then it indicates a warning and if it returns a value that is greater than 0, then it indicates an error (see IQAPI_ERR_CODES, or the \c hndl->lastErr buffer). */ int LoadSignalFile(char *fileName); //!< Loads a signal file int AnalyzeFftWide(double centerFrequency, double dbResolutionBW = 1e5, char *pcWindowType = "hanning", double offsetFreq = 50e6); //!< Performs a 120 MHz wide FFT measurement using three captures. The frequency of the middle capture is the value of the \c centerFrequency parameter /*!< The \c hndl->results object points to the \c analysisFFT object if successful */ // **************************************************************** // Multiport Test Adaptor Functions // **************************************************************** int MptaEnable(void); //!< Enables MPTA control int MptaDisable(void); //!< Disables MPTA control int MptaSetupSwitchCapture(MPTA_TX_TEST *tx_test); //!< Performs Sequential MIMO setup and capture int MptaSwitchCapture(void); //!< Performs Sequential MIMO capture only int MptaSetAttn(int port, double attn_dB, double freq_Hz, double *attnError = NULL); //!< Sets attenuation value to individual ports (0-3), and returns attenuation error int MptaSetAttn(double attn_dB, double freq_Hz, double *attnErrors = NULL ); //!< Sets attenuation value to all ports and returns attenuation error double MptaRxPer(MPTA_RX_TEST *rx_test); //!< Performs Rx PER test at specified signal level and returns a PER % value (0-100) double MptaRxSens(MPTA_RX_TEST *rx_test); //!< Performs sensitivity level test and returns sensitivity value (dBm) void MptaPrintDebug(bool bEnable); void MptaExtTrigger(double fTriggerLevel, double fFreq); bool MptaGetSerialNumber(char *serialNumber, int bufSize); //!< Gets serial number for all the connected devices int MptaGetNumberOfDevice(); //!< Gets number of devices (reserved for future use) bool MptaGetSettings(int port, double *attn_dB, double *freq_Hz, double *attnError); //!< Gets setting (attenuation, frequency and attenuation error) for the active device bool MptaSetActiveA21(const char *serialNumber); //!< Sets active A21 bool MptaAvailable(); //!< Checks if MPTA is available or not void MptaInit(bool createA21); //!< Initializes a flag that controls if the A21 control should be created or not during the connection initialization using \c ConInit /*!< \note If this function is not called, the default value of \c createA21Flag is true => A21 control will be created during ConInit(...) */ // **************************************************************** // iqapiHndl Misc Functions // **************************************************************** int MiscReqParm(char *parm, char *buff, unsigned int buff_len, int *ack = NULL, int testerNumber = 1);//!< This function is reserved for internal use int MiscSendCmd(char *cmd, int testerNumber = 1); //!< This function is reserved for internal use int MiscCmd(char *cmd, double input, double *output); //!< This function is reserved for internal use int MiscCmdLocalStatus(char *cmd, double input, double *output); //!< This function is reserved for internal use int MiscCmdNoStatus(char *cmd, char *input, char *output, unsigned int outputSize); //!< This function is reserved for internal use int MiscMwCmd(char *cmd, int index=-1, double value=-1); //!< This function is reserved for internal use bool IsHardwareVersion(IQV_HARDWARE_VERSION_ENUM hardwareVersion); //!< Check hardware version int CleanWave(double frameLenSec); //!< Saves clean \c *.mod file for WiMAX /*!< Saves the signal that was generated from the analysis results of a previously run Analyze() function call. This function works for WiMAX only. The \c frameLenSec &mdash; parameter specifies frame length of the generated waveform. */ int ExportPayload(char *fileName, char *type); //!< Exports pay load for different wireless standards. The \c Analyze() function must be called before calling this function. /*!< The parameter values are as follows: \n \c fileName &mdash; indicates the name of the file the user wants the payload to be written to. \n \c type &mdash; indicates the type of wireless standard. Supported wireless standards are as follows: \n OFDM (for 802.11 a/g) \n 802.11 n \n 802.11 b \n 80216-2004 \n 80216e-2005 \n Bluetooth */ int ExportSymbolData(char *fileName, bool binaryFormat); //!< Exports symbol data per subcarrier for WiMAX. The \c analysis function must be called before calling this function /*!< The parameter values are as follows: \n \c fileName &mdash; indicates the name of the file the user wants the symbol data to be written to. \n \c binaryFormat &mdash; indicates a value of "TRUE" or "FALSE" */ // **************************************************************** // iqapiHndl Firmware server // **************************************************************** // char serialNumber[SERIAL_NUMBER_LEN +1]; char pbPort[6]; int DeviceDiscover(char *SerialNumbers, int bufLen); // **************************************************************** // iqapiHndl Member Variables // **************************************************************** iqapiRx *rx; //!< Indicates test system Rx and VSA settings /*!< Represents the Rx settings in test system. The top level members represent parameters that apply to all VSAs in a test system. Members of the VSA object array apply uniquely to each test unit within a test system. */ iqapiTx *tx; //!< Indicates test system Tx and VSG settings /*!< Represents the Tx settings in a test system. The top level members represent parameters that apply to all VSGs in a LitePoint Test Instrument. Members of the vsg object array apply uniquely to each test unit within a test system. */ iqapiCapture *data; //!< Indicates local data capture storage /*!< Stores captured sample data and is used as input to the analysis functions. */ iqapiAnalysis *analysis; //!< Indicates local analysis parameters /*!< Performs a specific type of analysis and returns a specific type of analysis result; used by \c hndl->Analyze(). \note The \c iqapiAnalysis is a base class for the various Analysis classes and should NOT be used directly. */ iqapiResult *results; //!< Indicates local measurement results. /*!< If a call to \c hndl->Analyze() function is successful, the \c hndl->result object will point to a derived \c iqapiResult class. \note the \c iqapiResult object is a base class for the various Result classes and should NOT be used directly. */ iqapiModulationWave *wave; //!< Indicates local modulation wave for the VSG. /*!< If a call to a \c hndl->GenerateWave() function is successful, the \c hndl->wave object will point to an \c iqapiModulationWave object which will be used in a call to the \c hndl->SetWave() function. */ int nTesters; //!< Indicates number of connected test systems. /*!< This field indicates the number of test systems to which a connection is open. This field should not be changed by the user. */ // Defined in iqapiHndlBase: char lastErr[MAX_LEN_ERR_TXT]; //!< Indicates the last error message text. /*!< This field acts as an error buffer, containing the last error message generated by the API. It is useful during debug, when the error code does not (by itself) give enough information. The exact error is often described in this field. */ int connectionNumber; //!< Indicates connection number IQV_CAPTURE_DATA_HANDLING_ENUM captureDataHandling; //!< Indicates captured data. /*!< IQV_DATA_IN_MATLAB&mdash;In some cases, the user does not have to pass the data back from MATLAB to the \c iqapi function to test the application. To save time, the captured data is stored in MATLAB. All subsequent operations will be carried out on the captured data in MATLAB. \n IQV_DATA_IN_IQAPI&mdash;After data capture, a copy of the captured data can be obtained from the \c iqapi function in the object \c data */ int UnpackMeasurements(void *mx_result_in, bool skipCreateResult = false); //!< This function is reserved for internal use int SetApiMode(const char *key); //!< Internal use // Use with MiscMwCmd. mwTable calVsaTable; mwTable calVsgTable; char hwVersion[4]; //!< Hardware version number ///HT40Capture private: //Perform HT40 analysis: int AnalyzeHT40(); // available vsa frequency band from test system iqapiFreqBands vsaFreqBands[NUMBER_OF_FREQ_BAND]; public: //Perform combined data capture (HT40 capture): int Capture(IQV_CAPTURE_TYPE_ENUM captureType); //!< Use to capture HT40 int IsUsbConnected(); //!< Indicates that test system is connected via USB int IsLicenseAvailable(IQV_LICENSE_TYPE licenseType, bool *returnResult); //!< Checks if license is available int GetTesterFreqBand(IQV_FREQUENCY_BAND whichFreqBand, iqapiFreqBands *freqBands, unsigned int numberOfFreqBand); //!< Gets frequency band of the test system void SetLpcPath(char *litePointConnectionPath); //!< Set the path that is used to invoke LitePoint Connectivity server. Note: this LPC server is used to invoke fw_server.exe and GF_fwserver.exe for IQ201x in the same folder as LPC server char *GetLpcPath(); //!< Get the path that is used to invoke LitePoint Connectivity Server. int GetTemperature(IQV_VSA_NUM_ENUM vsaNum, double *paTemperature, double *ifTemperature, double *swTemperature, double *vsaGainTemperature, double *vsgGainOffsetTemperature); int UnpackTemperature(void *mx_result_in, double *paTemperature, double *ifTemperature, double *swTemperature, double *vsaGainTemperature, double *vsgGainOffsetTemperature); public: // **************************************************************** // Internal use functions // **************************************************************** int GetTxRfFreqHz(double *txRfFreqHz); //!< Get the current transmiter frequency // **************************************************************** // Private iqapiHndl Members // **************************************************************** private: bool connected; int DoConInit(char *ip1, char *ip2, char *ip3, char *ip4); int UnpackVsaVsg(void *mx_result); int PackVsaVsg(void **mx_input_in, void **mx_tx_in, void **mx_rx_in, void **mx_vsg_in, void **mx_vsa_in); int UnpackCapture(void *mx_result_in, bool UnpackCon = true, bool fromCapture = true, IQV_CAPTURE_DATA_HANDLING_ENUM captureDataHandling = IQV_DATA_IN_IQAPI, iqapiCapture *userData = NULL); int UnpackSingleCapture(void *mx_result_in); int PackCaptureAndAnalysis(void **mx_input_in, void **mx_dataCapture_in, void **mx_analysis_in, iqapiSignalData *userData = NULL); int PackWaveParams(void **mx_input_in, void **mx_params_in, void **mx_psdu_in, iqapiWaveGenParms *params); int UnpackModulationData(void *mx_result_in, iqapiModulationWave *wave); char *masterIP; int DoConInit2(char *ip1, char *ip2, char *ip3, char *ip4); int InvokeFWServerAndGetLocalIP(const char *ip1, char *LocalIPWithPort); int InvokeLPCServerAndGetLocalIP(char *ip1, char *sn1, char *ipWithPort, int sizeIpWithPort); int PrecheckTxRx(); int GetTesterInfo(char *testerCommand, char **unscrambleData); int Unscramble(char *scrambleData, char* unscambleData, unsigned int bufSize); int CreateFreqBand(const char *const unscrambleData, iqapiFreqBands *freqBands); void ResetLastErr(); int CheckVersion(WHAT_VERSION_TO_CHECK versionToCheck); int CheckVersionFw(WHAT_VERSION_TO_CHECK fwVersionToCheck); int CheckVersionFpga(WHAT_VERSION_TO_CHECK fwVersionToCheck); CA21Control *a21; bool createA21Flag; char *lpcPath; public: DualHead *pDualHead; //!< Dual head object for Wifi/BT/Wimax }; // Composite Reference Generation Function IQ_API int iqapiFindPsduDataRef(iqapiResultMimo *SigData, iqapiResultFindPsduDataRef *resultFindPsduDataRef, bool init); //!< Finds PSDU of data reference of composite MIMO // Composite Reference Generation Function IQ_API int iqapiWritePsduDataRef(char *txtFileName); //!< Exports PSDU data reference // Composite Reference Generation Function IQ_API int iqapiWriteDataRef(char *txtFileName, char *refFileName, char *type, int mcsIndex, IQV_MIMO_BANDWIDTH_MODES bw); //!< Exports data reference IQ_API int iqapiSaveMapConfigFile(char *mcfFileName); //!< Saves map configuration file
[ "thiru@thiru-desktop.(none)" ]
thiru@thiru-desktop.(none)
f836e32141c155dcdc70e38ac626b2e7adbe46e6
127c53f4e7e220f44dc82d910a5eed9ae8974997
/EngineSDK/kylinengine/ModelEditor/src/TerrainLayerOneEraserAction.cpp
ce66c9bd5530beefb374b9374bd78133a9648abe
[]
no_license
zhangf911/wxsj2
253e16265224b85cc6800176a435deaa219ffc48
c8e5f538c7beeaa945ed2a9b5a9b04edeb12c3bd
refs/heads/master
2020-06-11T16:44:14.179685
2013-03-03T08:47:18
2013-03-03T08:47:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,302
cpp
#include "TerrainLayerOneEraserAction.h" #include "SceneManipulator.h" #include "HitIndicator.h" #include "TerrainSelections.h" namespace Fairy{ TerrainLayerOneEraserAction::TerrainLayerOneEraserAction(SceneManipulator* sceneManipulator) : PaintAction(sceneManipulator) { mCurrentGrids = new GridSelection(getTerrain(),sceneManipulator); mHintModified = new GridSelection(getTerrain(),sceneManipulator); mModifiedGrids = new GridSelection(getTerrain(),sceneManipulator); } //----------------------------------------------------------------------- TerrainLayerOneEraserAction::~TerrainLayerOneEraserAction() { delete mCurrentGrids; delete mHintModified; delete mModifiedGrids; } //----------------------------------------------------------------------- const String& TerrainLayerOneEraserAction::getName(void) const { static const String name = "TerrainLayerOneEraserAction"; return name; } //----------------------------------------------------------------------- void TerrainLayerOneEraserAction::_buildHitIndicator(const Point& pt) { getSceneManipulator()->getHitIndicator("IntersectGrids")->setHitPoint(pt); getSceneManipulator()->getHitIndicator("IntersectPoint")->setHitPoint(pt); Ogre::Vector3 position; bool intersected = getSceneManipulator()->getTerrainIntersects(pt, position); if (!intersected) { mCurrentGrids->reset(); return; } getSceneManipulator()->_buildSelection(mCurrentGrids, position.x, position.z); } //----------------------------------------------------------------------- void TerrainLayerOneEraserAction::_onActive(bool active) { if (!active) { mHintModified->apply(); mHintModified->reset(); } } //----------------------------------------------------------------------- void TerrainLayerOneEraserAction::_onMove(const Point& pt) { mHintModified->apply(); mHintModified->reset(); _buildHitIndicator(pt); _doErase(mHintModified); } //----------------------------------------------------------------------- void TerrainLayerOneEraserAction::_onBegin(const Point& pt) { mHintModified->apply(); mHintModified->reset(); mModifiedGrids->reset(); _buildHitIndicator(pt); _doErase(mModifiedGrids); } //----------------------------------------------------------------------- void TerrainLayerOneEraserAction::_onDrag(const Point& pt) { _buildHitIndicator(pt); _doErase(mModifiedGrids); } //----------------------------------------------------------------------- void TerrainLayerOneEraserAction::_onEnd(const Point& pt, bool canceled) { /*if (canceled) { mModifiedGrids->apply(); }*/ doFinish(mModifiedGrids, canceled); mModifiedGrids->reset(); _buildHitIndicator(pt); } //----------------------------------------------------------------------- void TerrainLayerOneEraserAction::_doErase(GridSelection* modified) { const GridSelection::GridMap& grids = mCurrentGrids->getGrids(); bool anyModified = false; if (!grids.empty()) { for (GridSelection::GridMap::const_iterator it = grids.begin(); it != grids.end(); ++it) { const GridSelection::Grid& grid = it->second; TerrainData::GridInfo info = grid.info; if ( info.layers[1].pixmapId ) { info.layers[1].pixmapId = 0; info.layers[1].orientation = 0; } if (info == grid.info) continue; anyModified = true; modified->add(grid.x, grid.z); getTerrainData()->setGridInfo(grid.x, grid.z, info); } if (anyModified) { mCurrentGrids->notifyModified(); } } } }
[ "amwfhv@163.com" ]
amwfhv@163.com
2fb47cbc36038b9b969330cc56ebb210ad62e230
53d3217e7ad52b4f7861d77c1aa40f883b453b59
/Database Systems and Applications/lab3/client.cpp
a61166bdbb77b377e1d890f2270964eebe3f8ef1
[]
no_license
LazyTigerLi/Undergraduate_Programs
0ba1af89294930c17d20ce6aeceabc9a25bd10ac
109e9f40897532e91c8ecad7942fd6a982381050
refs/heads/master
2020-04-29T14:47:57.747961
2019-07-02T18:46:56
2019-07-02T18:46:56
176,207,897
0
0
null
null
null
null
UTF-8
C++
false
false
3,185
cpp
#include "client.h" Client::Client(QSqlDatabase database, QVector<QString> tableName, QWidget *parent) :Table(database,tableName,parent) { searchButton = new QPushButton("search",this); id = new QLineEdit(this); name = new QLineEdit(this); telephone = new QLineEdit(this); address = new QLineEdit(this); staffID = new QLineEdit(this); staffName = new QLineEdit(this); idLabel = new QLabel("ID",this); nameLabel = new QLabel("name",this); telephoneLabel = new QLabel("telephone",this); addressLabel = new QLabel("address",this); staffIDLabel = new QLabel("staff ID",this); staffNameLabel = new QLabel("staff name",this); connect(searchButton,SIGNAL(clicked(bool)),this,SLOT(search())); QHBoxLayout *layout = new QHBoxLayout; layout->addWidget(idLabel); layout->addWidget(id); layout->addWidget(nameLabel); layout->addWidget(name); layout->addWidget(telephoneLabel); layout->addWidget(telephone); layout->addWidget(addressLabel); layout->addWidget(address); layout->addWidget(staffIDLabel); layout->addWidget(staffID); layout->addWidget(staffNameLabel); layout->addWidget(staffName); layout->addWidget(searchButton); tableLayout[0]->addLayout(layout); setLayout(mainLayout); queryModel = new QSqlQueryModel(tableView[0]); } Client::~Client() {} void Client::search() { QString idQuery,nameQuery,telephoneQuery,addressQuery, staffIDQuery,staffNameQuery; if(id->text() == "")idQuery = ""; else idQuery = " `Client`.`ID` = '" + id->text() + "' and "; if(name->text() == "")nameQuery = ""; else nameQuery = " `Client`.`Name` = '" + name->text() + "' and "; if(telephone->text() == "")telephoneQuery = ""; else telephoneQuery = " `Client`.`telephone` = '" + telephone->text() + "' and "; if(address->text() == "")addressQuery = ""; else addressQuery = " `Client`.`Address` like '%" + address->text() + "%' and "; if(staffID->text() == "")staffIDQuery = ""; else staffIDQuery = " `Client`.`Staff ID` = '" + staffID->text() + "' and "; if(staffName->text() == "")staffNameQuery = ""; else staffNameQuery = " `Staff`.`Name` = '" + staffName->text() + "' and "; QString query; if(staffID->text() == "" && staffName->text() == "") query = "select * from `mydb`.`Client` where " + idQuery + nameQuery + telephoneQuery + addressQuery + " `Client`.`ID` is not null"; else query = "select `Client`.`ID`,`Client`.`Name`,`Client`.`Telephone`,`Client`.`Address`" ",`Client`.`Contact Name`,`Client`.`Contact Telephone`,`Client`.`Contact Email`" ",`Client`.`Relationship with Contact`,`Client`.`Staff ID`,`Staff`.`Name`" ",`Client`.`Relationship with Staff` from `mydb`.`Client`,`mydb`.`Staff` where" " `Client`.`Staff ID` = `Staff`.`ID` and " + idQuery + nameQuery + telephoneQuery + addressQuery + staffIDQuery + staffNameQuery + " `Client`.`ID` is not null"; qDebug("%s",qPrintable(query)); queryModel->setQuery(QSqlQuery(query,db)); tableView[0]->setModel(queryModel); }
[ "ln2016@mail.ustc.edu.cn" ]
ln2016@mail.ustc.edu.cn
cbf4d4ddad73c32be6b255267196f29d41355c7b
8c5ca1bee5f581cebea051f181725698ef3e4e31
/src/libtsduck/dtv/signalization/tsTablesLoggerFilterInterface.cpp
28f0057a5888335bee2429e0431881e3c772e83b
[ "BSD-2-Clause" ]
permissive
vtns/tsduck
1f914c799fcd3e758fbea144cbd7a14f95e17f00
2a7c923ef054d8f42fd4428efe905b033574f78f
refs/heads/master
2023-08-28T08:11:02.430223
2021-10-29T23:28:47
2021-10-29T23:28:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,696
cpp
//---------------------------------------------------------------------------- // // TSDuck - The MPEG Transport Stream Toolkit // Copyright (c) 2005-2021, Thierry Lelegard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF // THE POSSIBILITY OF SUCH DAMAGE. // //---------------------------------------------------------------------------- #include "tsTablesLoggerFilterInterface.h" ts::TablesLoggerFilterInterface::~TablesLoggerFilterInterface() { }
[ "thierry@lelegard.fr" ]
thierry@lelegard.fr
1342e0853ac34ee2a77c188f26aed0bc53f17b03
0e5da9e9535005c00eec1e3c798b5b23b755c2bf
/task13-Area of the Triangle,Rectangle & Width.cpp
3b4d26b8bb1078bf504c1bbea234ed4ada294096
[]
no_license
navidnayyem/C-Plus-Plus-Programming
89e391bef288392efa77b7c8136ca042a935b457
a97e78be4ada8207f213de271ec8d279d19b5a1d
refs/heads/master
2020-06-09T22:48:22.807932
2019-07-02T18:00:36
2019-07-02T18:00:36
193,522,140
0
0
null
null
null
null
UTF-8
C++
false
false
1,096
cpp
#include <iostream> using namespace std; class Areacal { public: int height, width, radius; Areacal() { height = 10; width = 9; } Areacal(Areacal &obj) { radius = obj.height; } void area(double x) { cout << "Area of Triangle: " << (x * (height*width)) << endl; } void area() { cout << "Area of Rectangle: " << (height*width) << endl; } void area(char x) { cout<<"Area of Circle: " << (3.14 * radius * radius) << endl;; } }; int main() { Areacal triangle, rectangle; Areacal circle(triangle); cout << "Height of Triangle: " << triangle.height << endl; cout << "Width of Triangle: " << triangle.width << endl; cout << "Height of Rectangle: " << rectangle.height << endl; cout << "Width of Rectangle: " << rectangle.width << endl; cout << "Radius of Circle: " << circle.radius << endl; triangle.area(0.5); rectangle.area(); circle.area('C'); return 0; }
[ "noreply@github.com" ]
navidnayyem.noreply@github.com
9a5fe809c9b77ac5a8f52f6ab32ee2da33ec9cb8
1f40e2b0f2ed7041a271108a3cb560029ce651cc
/src/libcaf_core/response_promise.cpp
8802617239a485db3f26e30dad9628558d3a1d13
[]
no_license
grantbrown/actor-framework-minimal
d47235cc55a5d888f9e885a1b1c0674cf6f17999
b55457f4b60db3a0667c866faa57f878810dd32d
refs/heads/master
2021-01-16T18:06:35.361320
2015-08-03T20:41:06
2015-08-03T20:41:06
40,146,615
0
1
null
null
null
null
UTF-8
C++
false
false
2,038
cpp
/****************************************************************************** * ____ _ _____ * * / ___| / \ | ___| C++ * * | | / _ \ | |_ Actor * * | |___ / ___ \| _| Framework * * \____/_/ \_|_| * * * * Copyright (C) 2011 - 2015 * * Dominik Charousset <dominik.charousset (at) haw-hamburg.de> * * * * Distributed under the terms and conditions of the BSD 3-Clause License or * * (at your option) under the terms and conditions of the Boost Software * * License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. * * * * If you did not receive a copy of the license files, see * * http://opensource.org/licenses/BSD-3-Clause and * * http://www.boost.org/LICENSE_1_0.txt. * ******************************************************************************/ #include <utility> #include "caf/local_actor.hpp" #include "caf/response_promise.hpp" namespace caf { response_promise::response_promise(const actor_addr& from, const actor_addr& to, const message_id& id) : from_(from), to_(to), id_(id) { CAF_ASSERT(id.is_response() || ! id.valid()); } void response_promise::deliver(message msg) const { if (! to_) { return; } auto to = actor_cast<abstract_actor_ptr>(to_); auto from = actor_cast<abstract_actor_ptr>(from_); to->enqueue(from_, id_, std::move(msg), from->host()); } } // namespace caf
[ "grant.brown73@gmail.com" ]
grant.brown73@gmail.com
5b203d9629654c156c70803e004ff6196cb848a5
ea138111941b791b5174f2a5065aa448507a8c1e
/M5StickC-master/src/AXP192.h
22f2441ab3233decfb0b8137313e7dfca5bf9ac4
[]
no_license
wasawas/MyM5StickC
ffa53a1131b4db31ea088616ba939982f3d1279c
69db20561d7874cf86f6ebee02cbec40c3df067d
refs/heads/master
2022-12-04T03:31:35.193818
2020-08-12T14:04:18
2020-08-12T14:04:18
285,023,331
2
0
null
null
null
null
UTF-8
C++
false
false
4,301
h
#ifndef __AXP192_H__ #define __AXP192_H__ #include <Wire.h> #include <Arduino.h> #define SLEEP_MSEC(us) (((uint64_t)us) * 1000L) #define SLEEP_SEC(us) (((uint64_t)us) * 1000000L) #define SLEEP_MIN(us) (((uint64_t)us) * 60L * 1000000L) #define SLEEP_HR(us) (((uint64_t)us) * 60L * 60L * 1000000L) #define ADC_RATE_025HZ (0b00 << 6) #define ADC_RATE_050HZ (0b01 << 6) #define ADC_RATE_100HZ (0b10 << 6) #define ADC_RATE_200HZ (0b11 << 6) #define CURRENT_100MA (0b0000) #define CURRENT_190MA (0b0001) #define CURRENT_280MA (0b0010) #define CURRENT_360MA (0b0011) #define CURRENT_450MA (0b0100) #define CURRENT_550MA (0b0101) #define CURRENT_630MA (0b0110) #define CURRENT_700MA (0b0111) #define VOLTAGE_4100MV (0b00 << 5) #define VOLTAGE_4150MV (0b01 << 5) #define VOLTAGE_4200MV (0b10 << 5) #define VOLTAGE_4360MV (0b11 << 5) #define VOLTAGE_OFF_2600MV (0b000) #define VOLTAGE_OFF_2700MV (0b001) #define VOLTAGE_OFF_2800MV (0b010) #define VOLTAGE_OFF_2900MV (0b011) #define VOLTAGE_OFF_3000MV (0b100) #define VOLTAGE_OFF_3100MV (0b101) #define VOLTAGE_OFF_3200MV (0b110) #define VOLTAGE_OFF_3300MV (0b111) class AXP192 { public: AXP192(); /** * LDO2: Display backlight * LDO3: Display Control * RTC: Always ON, Switch RTC charging. * DCDC1: Main rail. When not set the controller shuts down. * DCDC3: Use unknown * LDO0: MIC */ void begin(bool disableLDO2 = false, bool disableLDO3 = false, bool disableRTC = false, bool disableDCDC1 = false, bool disableDCDC3 = false, bool disableLDO0 = false); void ScreenBreath(uint8_t brightness); bool GetBatState(); uint8_t GetInputPowerStatus(); uint8_t GetBatteryChargingStatus(); void EnableCoulombcounter(void); void DisableCoulombcounter(void); void StopCoulombcounter(void); void ClearCoulombcounter(void); uint32_t GetCoulombchargeData(void); // Raw Data for Charge uint32_t GetCoulombdischargeData(void); // Raw Data for Discharge float GetCoulombData(void); // total in - total out and calc uint16_t GetVbatData(void) __attribute__((deprecated)); uint16_t GetIchargeData(void) __attribute__((deprecated)); uint16_t GetIdischargeData(void) __attribute__((deprecated)); uint16_t GetTempData(void) __attribute__((deprecated)); uint32_t GetPowerbatData(void) __attribute__((deprecated)); uint16_t GetVinData(void) __attribute__((deprecated)); uint16_t GetIinData(void) __attribute__((deprecated)); uint16_t GetVusbinData(void) __attribute__((deprecated)); uint16_t GetIusbinData(void) __attribute__((deprecated)); uint16_t GetVapsData(void) __attribute__((deprecated)); uint8_t GetBtnPress(void); // -- sleep void SetSleep(void); void DeepSleep(uint64_t time_in_us = 0); void LightSleep(uint64_t time_in_us = 0); uint8_t GetWarningLeve(void) __attribute__((deprecated)); public: void SetChargeVoltage( uint8_t ); void SetChargeCurrent( uint8_t ); void SetVOff( uint8_t voltage ); float GetBatVoltage(); float GetBatCurrent(); float GetVinVoltage(); float GetVinCurrent(); float GetVBusVoltage(); float GetVBusCurrent(); float GetTempInAXP192(); float GetBatPower(); float GetBatChargeCurrent(); float GetAPSVoltage(); float GetBatCoulombInput(); float GetBatCoulombOut(); uint8_t GetWarningLevel(void); void SetCoulombClear() __attribute__((deprecated)); // use ClearCoulombcounter instead void SetLDO2( bool State ); // Can turn LCD Backlight OFF for power saving void SetLDO3( bool State ); void SetGPIO0( bool State ); void SetAdcState(bool State); void SetAdcRate( uint8_t rate ); // -- Power Off void PowerOff(); // Power Maintained Storage void Read6BytesStorage( uint8_t *bufPtr ); void Write6BytesStorage( uint8_t *bufPtr ); private: void Write1Byte( uint8_t Addr , uint8_t Data ); uint8_t Read8bit( uint8_t Addr ); uint16_t Read12Bit( uint8_t Addr); uint16_t Read13Bit( uint8_t Addr); uint16_t Read16bit( uint8_t Addr ); uint32_t Read24bit( uint8_t Addr ); uint32_t Read32bit( uint8_t Addr ); void ReadBuff( uint8_t Addr , uint8_t Size , uint8_t *Buff ); }; #endif
[ "wasawas@Kids-Mac-6.local" ]
wasawas@Kids-Mac-6.local
85916f6d0d4b622c191a8965842bea2a7e568f87
85bc85669f49c0879b9965ec97b41d1f5fa0d28e
/NumberWithUnits.hpp
2ed63287897c8405849918be167fbab2a84eda01
[]
no_license
inbalcohen2/NumberWithUnits-a
82dad9a0b10503a0bda0014d70591be615042365
dce1402f3fbe128f8d0ddfde9a5cf6b3cc69c962
refs/heads/main
2023-04-08T19:48:06.218394
2021-04-21T15:59:37
2021-04-21T15:59:37
360,047,770
0
0
null
null
null
null
UTF-8
C++
false
false
2,595
hpp
#include <string> #include <fstream> #include <iostream> #include <unordered_map> using namespace std; namespace ariel{ class NumberWithUnits { private: double val; string str; double convert(const string& f ,const string& t , double val); friend bool check( NumberWithUnits const & l, NumberWithUnits const & r ); public: NumberWithUnits(double val ,string str){ this->val=val; this->str = str; } ~NumberWithUnits(){} static void read_units(ifstream& input); //************* + , += , + unry , - , -= , - unry ,* left, right * **************** friend NumberWithUnits operator+( NumberWithUnits const & l, NumberWithUnits const & r ); friend NumberWithUnits operator+( NumberWithUnits & val ); friend NumberWithUnits operator+=( NumberWithUnits& l, const NumberWithUnits& r ); friend NumberWithUnits operator-( NumberWithUnits const & l, NumberWithUnits const & r ); friend NumberWithUnits operator-(NumberWithUnits & val) ; friend NumberWithUnits operator-=( NumberWithUnits & l, NumberWithUnits const & r ); friend NumberWithUnits operator*(NumberWithUnits& l, double val); friend NumberWithUnits operator*(double val, NumberWithUnits& r); //***************** > >= < <= == != *************************** friend bool operator==( NumberWithUnits const & l, NumberWithUnits const & r ); friend bool operator!=( NumberWithUnits const & l, NumberWithUnits const & r ); friend bool operator<( NumberWithUnits const & l, NumberWithUnits const & r ); friend bool operator<=( NumberWithUnits const & l, NumberWithUnits const & r ); friend bool operator>( NumberWithUnits const & l, NumberWithUnits const & r ); friend bool operator>=( NumberWithUnits const & l, NumberWithUnits const & r ); //********************** ++ -- ******************************* friend NumberWithUnits operator--( NumberWithUnits & val, int ); friend NumberWithUnits & operator--( NumberWithUnits & val ); friend NumberWithUnits & operator++( NumberWithUnits & val ); friend NumberWithUnits operator++( NumberWithUnits & val, int ); //operator * //operator << friend ostream& operator<<(ostream& out, const NumberWithUnits& val); friend istream& operator>>(istream& input, NumberWithUnits& val); }; }
[ "noreply@github.com" ]
inbalcohen2.noreply@github.com
b99bfdaaa627b4e13ebf69b5df0a29e9ba931c9d
fb0e651a452e469637d101deb0c2245591410bd8
/SouthernForestBattle.cpp
cb9cd49d26f881b7570f477f58584dc6e12178df
[]
no_license
yabem/Vintage-RPG
a29e971cec37e4f33d2692c99d5a912d72b2e6c2
7ba44c6519329bb3a4d0b58b4984d9b595b0c4d5
refs/heads/master
2021-01-10T18:35:11.363008
2015-12-02T03:46:16
2015-12-02T03:46:16
27,652,933
0
0
null
null
null
null
UTF-8
C++
false
false
2,230
cpp
#include "SouthernForestBattle.h" SouthernForestBattle::SouthernForestBattle(ImageStore *imageStore , int layoutSize) : CustomAreaMap(imageStore , NULL , NULL , NULL , NULL , layoutSize){ } SouthernForestBattle::~SouthernForestBattle(){ } void SouthernForestBattle::loadLayers(){ Layer *backgroundLayer = new Layer(imageStore->getBitMap("desertRegion") , 15 , 20 , this->backgroundLayerLayout , 300); this->loadLayer(backgroundLayer); } void SouthernForestBattle::loadBackgroundLayerMapConfiguration(){ int backgroundLayerLayout[] ={ 150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150, 150,150, 114,114,114,114,114,114,114,114,114,114,114,114,114,114,114,114,114,114,114, 114, 152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,152, 152, 153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153, 153, 154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154, 154, 155,155,155,155,155,155,155,155,155,155,155,155,155,155,155,155,155,155,155, 155, 156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156, 156, 156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156, 156, 156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156, 156, 156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156, 156, 156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156, 156, 156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156, 156, 156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156, 156, 156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156, 156, 156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156, 156 }; this->backgroundLayerLayout = new int[this->layoutSize]; for(int i = 0 ; i < this->layoutSize ; i++) this->backgroundLayerLayout[i] = backgroundLayerLayout[i]; }
[ "username@users.noreply.github.com" ]
username@users.noreply.github.com
449bedf50e7a746e04757b52dd0d3c772c6fae5a
786de89be635eb21295070a6a3452f3a7fe6712c
/psddl_pdsdata/tags/V00-05-03/include/cspad.ddl.h
1f383ef8fb868706412e8f4e2b69e9492a815ef3
[]
no_license
connectthefuture/psdmrepo
85267cfe8d54564f99e17035efe931077c8f7a37
f32870a987a7493e7bf0f0a5c1712a5a030ef199
refs/heads/master
2021-01-13T03:26:35.494026
2015-09-03T22:22:11
2015-09-03T22:22:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
51,631
h
#ifndef PSDDLPDS_CSPAD_DDL_H #define PSDDLPDS_CSPAD_DDL_H 1 // *** Do not edit this file, it is auto-generated *** #include <vector> #include <iosfwd> #include <cstddef> #include "pdsdata/xtc/TypeId.hh" #include "ndarray/ndarray.h" namespace PsddlPds { namespace CsPad { enum { MaxQuadsPerSensor = 4 /**< Defines number of quadrants in a CsPad device. */ }; enum { ASICsPerQuad = 16 /**< Total number of ASICs in one quadrant. */ }; enum { RowsPerBank = 26 /**< Number of rows per readout bank? */ }; enum { FullBanksPerASIC = 7 /**< Number of full readout banks per one ASIC? */ }; enum { BanksPerASIC = 8 /**< Number of readout banks per one ASIC? */ }; enum { ColumnsPerASIC = 185 /**< Number of columns readout by single ASIC. */ }; enum { MaxRowsPerASIC = 194 /**< Maximum number of rows readout by single ASIC. */ }; enum { PotsPerQuad = 80 /**< Number of POTs? per single quadrant. */ }; enum { TwoByTwosPerQuad = 4 /**< Total number of 2x2s in single quadrant. */ }; enum { SectorsPerQuad = 8 /**< Total number of sectors (2x1) per single quadrant. */ }; /** Enum specifying different running modes. */ enum RunModes { NoRunning, RunButDrop, RunAndSendToRCE, RunAndSendTriggeredByTTL, ExternalTriggerSendToRCE, ExternalTriggerDrop, NumberOfRunModes, }; /** Enum specifying different data collection modes. */ enum DataModes { normal = 0, shiftTest = 1, testData = 2, reserved = 3, }; /** @class CsPadDigitalPotsCfg Class defining configuration for CsPad POTs? */ class CsPadDigitalPotsCfg { public: /** Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const uint8_t, 1> pots(const boost::shared_ptr<T>& owner) const { const uint8_t* data = &_pots[0]; return make_ndarray(boost::shared_ptr<const uint8_t>(owner, data), PotsPerQuad); } /** Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const uint8_t, 1> pots() const { return make_ndarray(&_pots[0], PotsPerQuad); } static uint32_t _sizeof() { return ((((0+(1*(PotsPerQuad)))+1)-1)/1)*1; } private: uint8_t _pots[PotsPerQuad]; }; /** @class CsPadReadOnlyCfg Class defining read-only configuration. */ class CsPadReadOnlyCfg { public: CsPadReadOnlyCfg() { } CsPadReadOnlyCfg(uint32_t arg__shiftTest, uint32_t arg__version) : _shiftTest(arg__shiftTest), _version(arg__version) { } uint32_t shiftTest() const { return _shiftTest; } uint32_t version() const { return _version; } static uint32_t _sizeof() { return 8; } private: uint32_t _shiftTest; uint32_t _version; }; /** @class ProtectionSystemThreshold */ class ProtectionSystemThreshold { public: ProtectionSystemThreshold() { } ProtectionSystemThreshold(uint32_t arg__adcThreshold, uint32_t arg__pixelCountThreshold) : _adcThreshold(arg__adcThreshold), _pixelCountThreshold(arg__pixelCountThreshold) { } uint32_t adcThreshold() const { return _adcThreshold; } uint32_t pixelCountThreshold() const { return _pixelCountThreshold; } static uint32_t _sizeof() { return 8; } private: uint32_t _adcThreshold; uint32_t _pixelCountThreshold; }; /** @class CsPadGainMapCfg Class defining ASIC gain map. */ class CsPadGainMapCfg { public: /** Array with the gain map for single ASIC. Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const uint16_t, 2> gainMap(const boost::shared_ptr<T>& owner) const { const uint16_t* data = &_gainMap[0][0]; return make_ndarray(boost::shared_ptr<const uint16_t>(owner, data), ColumnsPerASIC, MaxRowsPerASIC); } /** Array with the gain map for single ASIC. Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const uint16_t, 2> gainMap() const { return make_ndarray(&_gainMap[0][0], ColumnsPerASIC, MaxRowsPerASIC); } static uint32_t _sizeof() { return ((((0+(2*(ColumnsPerASIC)*(MaxRowsPerASIC)))+2)-1)/2)*2; } private: uint16_t _gainMap[ColumnsPerASIC][MaxRowsPerASIC]; /**< Array with the gain map for single ASIC. */ }; /** @class ConfigV1QuadReg Configuration data for single quadrant. */ class ConfigV1QuadReg { public: /** Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const uint32_t, 1> shiftSelect(const boost::shared_ptr<T>& owner) const { const uint32_t* data = &_shiftSelect[0]; return make_ndarray(boost::shared_ptr<const uint32_t>(owner, data), TwoByTwosPerQuad); } /** Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const uint32_t, 1> shiftSelect() const { return make_ndarray(&_shiftSelect[0], TwoByTwosPerQuad); } /** Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const uint32_t, 1> edgeSelect(const boost::shared_ptr<T>& owner) const { const uint32_t* data = &_edgeSelect[0]; return make_ndarray(boost::shared_ptr<const uint32_t>(owner, data), TwoByTwosPerQuad); } /** Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const uint32_t, 1> edgeSelect() const { return make_ndarray(&_edgeSelect[0], TwoByTwosPerQuad); } uint32_t readClkSet() const { return _readClkSet; } uint32_t readClkHold() const { return _readClkHold; } uint32_t dataMode() const { return _dataMode; } uint32_t prstSel() const { return _prstSel; } uint32_t acqDelay() const { return _acqDelay; } uint32_t intTime() const { return _intTime; } uint32_t digDelay() const { return _digDelay; } uint32_t ampIdle() const { return _ampIdle; } uint32_t injTotal() const { return _injTotal; } uint32_t rowColShiftPer() const { return _rowColShiftPer; } /** read-only configuration */ const CsPad::CsPadReadOnlyCfg& ro() const { return _readOnly; } const CsPad::CsPadDigitalPotsCfg& dp() const { return _digitalPots; } /** Gain map. */ const CsPad::CsPadGainMapCfg& gm() const { return _gainMap; } static uint32_t _sizeof() { return ((((((((((((((((((0+(4*(TwoByTwosPerQuad)))+(4*(TwoByTwosPerQuad)))+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+(CsPad::CsPadReadOnlyCfg::_sizeof()))+(CsPad::CsPadDigitalPotsCfg::_sizeof()))+(CsPad::CsPadGainMapCfg::_sizeof()))+4)-1)/4)*4; } private: uint32_t _shiftSelect[TwoByTwosPerQuad]; uint32_t _edgeSelect[TwoByTwosPerQuad]; uint32_t _readClkSet; uint32_t _readClkHold; uint32_t _dataMode; uint32_t _prstSel; uint32_t _acqDelay; uint32_t _intTime; uint32_t _digDelay; uint32_t _ampIdle; uint32_t _injTotal; uint32_t _rowColShiftPer; CsPad::CsPadReadOnlyCfg _readOnly; /**< read-only configuration */ CsPad::CsPadDigitalPotsCfg _digitalPots; CsPad::CsPadGainMapCfg _gainMap; /**< Gain map. */ }; /** @class ConfigV2QuadReg Configuration data for single quadrant. */ class ConfigV2QuadReg { public: /** Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const uint32_t, 1> shiftSelect(const boost::shared_ptr<T>& owner) const { const uint32_t* data = &_shiftSelect[0]; return make_ndarray(boost::shared_ptr<const uint32_t>(owner, data), TwoByTwosPerQuad); } /** Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const uint32_t, 1> shiftSelect() const { return make_ndarray(&_shiftSelect[0], TwoByTwosPerQuad); } /** Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const uint32_t, 1> edgeSelect(const boost::shared_ptr<T>& owner) const { const uint32_t* data = &_edgeSelect[0]; return make_ndarray(boost::shared_ptr<const uint32_t>(owner, data), TwoByTwosPerQuad); } /** Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const uint32_t, 1> edgeSelect() const { return make_ndarray(&_edgeSelect[0], TwoByTwosPerQuad); } uint32_t readClkSet() const { return _readClkSet; } uint32_t readClkHold() const { return _readClkHold; } uint32_t dataMode() const { return _dataMode; } uint32_t prstSel() const { return _prstSel; } uint32_t acqDelay() const { return _acqDelay; } uint32_t intTime() const { return _intTime; } uint32_t digDelay() const { return _digDelay; } uint32_t ampIdle() const { return _ampIdle; } uint32_t injTotal() const { return _injTotal; } uint32_t rowColShiftPer() const { return _rowColShiftPer; } uint32_t ampReset() const { return _ampReset; } uint32_t digCount() const { return _digCount; } uint32_t digPeriod() const { return _digPeriod; } /** read-only configuration */ const CsPad::CsPadReadOnlyCfg& ro() const { return _readOnly; } const CsPad::CsPadDigitalPotsCfg& dp() const { return _digitalPots; } /** Gain map. */ const CsPad::CsPadGainMapCfg& gm() const { return _gainMap; } static uint32_t _sizeof() { return (((((((((((((((((((((0+(4*(TwoByTwosPerQuad)))+(4*(TwoByTwosPerQuad)))+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+(CsPad::CsPadReadOnlyCfg::_sizeof()))+(CsPad::CsPadDigitalPotsCfg::_sizeof()))+(CsPad::CsPadGainMapCfg::_sizeof()))+4)-1)/4)*4; } private: uint32_t _shiftSelect[TwoByTwosPerQuad]; uint32_t _edgeSelect[TwoByTwosPerQuad]; uint32_t _readClkSet; uint32_t _readClkHold; uint32_t _dataMode; uint32_t _prstSel; uint32_t _acqDelay; uint32_t _intTime; uint32_t _digDelay; uint32_t _ampIdle; uint32_t _injTotal; uint32_t _rowColShiftPer; uint32_t _ampReset; uint32_t _digCount; uint32_t _digPeriod; CsPad::CsPadReadOnlyCfg _readOnly; /**< read-only configuration */ CsPad::CsPadDigitalPotsCfg _digitalPots; CsPad::CsPadGainMapCfg _gainMap; /**< Gain map. */ }; /** @class ConfigV3QuadReg Configuration data for single quadrant. */ class ConfigV3QuadReg { public: /** Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const uint32_t, 1> shiftSelect(const boost::shared_ptr<T>& owner) const { const uint32_t* data = &_shiftSelect[0]; return make_ndarray(boost::shared_ptr<const uint32_t>(owner, data), TwoByTwosPerQuad); } /** Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const uint32_t, 1> shiftSelect() const { return make_ndarray(&_shiftSelect[0], TwoByTwosPerQuad); } /** Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const uint32_t, 1> edgeSelect(const boost::shared_ptr<T>& owner) const { const uint32_t* data = &_edgeSelect[0]; return make_ndarray(boost::shared_ptr<const uint32_t>(owner, data), TwoByTwosPerQuad); } /** Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const uint32_t, 1> edgeSelect() const { return make_ndarray(&_edgeSelect[0], TwoByTwosPerQuad); } uint32_t readClkSet() const { return _readClkSet; } uint32_t readClkHold() const { return _readClkHold; } uint32_t dataMode() const { return _dataMode; } uint32_t prstSel() const { return _prstSel; } uint32_t acqDelay() const { return _acqDelay; } uint32_t intTime() const { return _intTime; } uint32_t digDelay() const { return _digDelay; } uint32_t ampIdle() const { return _ampIdle; } uint32_t injTotal() const { return _injTotal; } uint32_t rowColShiftPer() const { return _rowColShiftPer; } uint32_t ampReset() const { return _ampReset; } uint32_t digCount() const { return _digCount; } uint32_t digPeriod() const { return _digPeriod; } uint32_t biasTuning() const { return _biasTuning; } uint32_t pdpmndnmBalance() const { return _pdpmndnmBalance; } /** read-only configuration */ const CsPad::CsPadReadOnlyCfg& ro() const { return _readOnly; } const CsPad::CsPadDigitalPotsCfg& dp() const { return _digitalPots; } /** Gain map. */ const CsPad::CsPadGainMapCfg& gm() const { return _gainMap; } static uint32_t _sizeof() { return (((((((((((((((((((((((0+(4*(TwoByTwosPerQuad)))+(4*(TwoByTwosPerQuad)))+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+(CsPad::CsPadReadOnlyCfg::_sizeof()))+(CsPad::CsPadDigitalPotsCfg::_sizeof()))+(CsPad::CsPadGainMapCfg::_sizeof()))+4)-1)/4)*4; } private: uint32_t _shiftSelect[TwoByTwosPerQuad]; uint32_t _edgeSelect[TwoByTwosPerQuad]; uint32_t _readClkSet; uint32_t _readClkHold; uint32_t _dataMode; uint32_t _prstSel; uint32_t _acqDelay; uint32_t _intTime; uint32_t _digDelay; uint32_t _ampIdle; uint32_t _injTotal; uint32_t _rowColShiftPer; uint32_t _ampReset; uint32_t _digCount; uint32_t _digPeriod; uint32_t _biasTuning; uint32_t _pdpmndnmBalance; CsPad::CsPadReadOnlyCfg _readOnly; /**< read-only configuration */ CsPad::CsPadDigitalPotsCfg _digitalPots; CsPad::CsPadGainMapCfg _gainMap; /**< Gain map. */ }; /** @class ConfigV1 Configuration data for complete CsPad device. */ class ConfigV1 { public: enum { TypeId = Pds::TypeId::Id_CspadConfig /**< XTC type ID value (from Pds::TypeId class) */ }; enum { Version = 1 /**< XTC type version number */ }; uint32_t concentratorVersion() const { return _concentratorVersion; } uint32_t runDelay() const { return _runDelay; } uint32_t eventCode() const { return _eventCode; } uint32_t inactiveRunMode() const { return _inactiveRunMode; } uint32_t activeRunMode() const { return _activeRunMode; } uint32_t tdi() const { return _testDataIndex; } uint32_t payloadSize() const { return _payloadPerQuad; } uint32_t badAsicMask0() const { return _badAsicMask0; } uint32_t badAsicMask1() const { return _badAsicMask1; } uint32_t asicMask() const { return _AsicMask; } uint32_t quadMask() const { return _quadMask; } const CsPad::ConfigV1QuadReg& quads(uint32_t i0) const { return _quads[i0]; } uint32_t numAsicsRead() const; uint32_t numQuads() const; uint32_t numSect() const; static uint32_t _sizeof() { return ((((44+(CsPad::ConfigV1QuadReg::_sizeof()*(MaxQuadsPerSensor)))+4)-1)/4)*4; } /** Method which returns the shape (dimensions) of the data returned by quads() method. */ std::vector<int> quads_shape() const; private: uint32_t _concentratorVersion; uint32_t _runDelay; uint32_t _eventCode; uint32_t _inactiveRunMode; uint32_t _activeRunMode; uint32_t _testDataIndex; uint32_t _payloadPerQuad; uint32_t _badAsicMask0; uint32_t _badAsicMask1; uint32_t _AsicMask; uint32_t _quadMask; CsPad::ConfigV1QuadReg _quads[MaxQuadsPerSensor]; }; /** @class ConfigV2 Configuration data for complete CsPad device. */ class ConfigV2 { public: enum { TypeId = Pds::TypeId::Id_CspadConfig /**< XTC type ID value (from Pds::TypeId class) */ }; enum { Version = 2 /**< XTC type version number */ }; uint32_t concentratorVersion() const { return _concentratorVersion; } uint32_t runDelay() const { return _runDelay; } uint32_t eventCode() const { return _eventCode; } uint32_t inactiveRunMode() const { return _inactiveRunMode; } uint32_t activeRunMode() const { return _activeRunMode; } uint32_t tdi() const { return _testDataIndex; } uint32_t payloadSize() const { return _payloadPerQuad; } uint32_t badAsicMask0() const { return _badAsicMask0; } uint32_t badAsicMask1() const { return _badAsicMask1; } uint32_t asicMask() const { return _AsicMask; } uint32_t quadMask() const { return _quadMask; } uint32_t roiMasks() const { return _roiMask; } const CsPad::ConfigV1QuadReg& quads(uint32_t i0) const { return _quads[i0]; } uint32_t numAsicsRead() const; /** ROI mask for given quadrant */ uint32_t roiMask(uint32_t iq) const; /** Number of ASICs in given quadrant */ uint32_t numAsicsStored(uint32_t iq) const; /** Total number of quadrants in setup */ uint32_t numQuads() const; /** Total number of sections (2x1) in all quadrants */ uint32_t numSect() const; static uint32_t _sizeof() { return ((((48+(CsPad::ConfigV1QuadReg::_sizeof()*(MaxQuadsPerSensor)))+4)-1)/4)*4; } /** Method which returns the shape (dimensions) of the data returned by quads() method. */ std::vector<int> quads_shape() const; private: uint32_t _concentratorVersion; uint32_t _runDelay; uint32_t _eventCode; uint32_t _inactiveRunMode; uint32_t _activeRunMode; uint32_t _testDataIndex; uint32_t _payloadPerQuad; uint32_t _badAsicMask0; uint32_t _badAsicMask1; uint32_t _AsicMask; uint32_t _quadMask; uint32_t _roiMask; CsPad::ConfigV1QuadReg _quads[MaxQuadsPerSensor]; }; /** @class ConfigV3 Configuration data for complete CsPad device. */ class ConfigV3 { public: enum { TypeId = Pds::TypeId::Id_CspadConfig /**< XTC type ID value (from Pds::TypeId class) */ }; enum { Version = 3 /**< XTC type version number */ }; uint32_t concentratorVersion() const { return _concentratorVersion; } uint32_t runDelay() const { return _runDelay; } uint32_t eventCode() const { return _eventCode; } /** Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const CsPad::ProtectionSystemThreshold, 1> protectionThresholds(const boost::shared_ptr<T>& owner) const { const CsPad::ProtectionSystemThreshold* data = &_protectionThresholds[0]; return make_ndarray(boost::shared_ptr<const CsPad::ProtectionSystemThreshold>(owner, data), MaxQuadsPerSensor); } /** Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const CsPad::ProtectionSystemThreshold, 1> protectionThresholds() const { return make_ndarray(&_protectionThresholds[0], MaxQuadsPerSensor); } uint32_t protectionEnable() const { return _protectionEnable; } uint32_t inactiveRunMode() const { return _inactiveRunMode; } uint32_t activeRunMode() const { return _activeRunMode; } uint32_t tdi() const { return _testDataIndex; } uint32_t payloadSize() const { return _payloadPerQuad; } uint32_t badAsicMask0() const { return _badAsicMask0; } uint32_t badAsicMask1() const { return _badAsicMask1; } uint32_t asicMask() const { return _AsicMask; } uint32_t quadMask() const { return _quadMask; } uint32_t roiMasks() const { return _roiMask; } const CsPad::ConfigV1QuadReg& quads(uint32_t i0) const { return _quads[i0]; } uint32_t numAsicsRead() const; /** ROI mask for given quadrant */ uint32_t roiMask(uint32_t iq) const; /** Number of ASICs in given quadrant */ uint32_t numAsicsStored(uint32_t iq) const; /** Total number of quadrants in setup */ uint32_t numQuads() const; /** Total number of sections (2x1) in all quadrants */ uint32_t numSect() const; static uint32_t _sizeof() { return (((((((((((((((12+(CsPad::ProtectionSystemThreshold::_sizeof()*(MaxQuadsPerSensor)))+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+(CsPad::ConfigV1QuadReg::_sizeof()*(MaxQuadsPerSensor)))+4)-1)/4)*4; } /** Method which returns the shape (dimensions) of the data returned by quads() method. */ std::vector<int> quads_shape() const; private: uint32_t _concentratorVersion; uint32_t _runDelay; uint32_t _eventCode; CsPad::ProtectionSystemThreshold _protectionThresholds[MaxQuadsPerSensor]; uint32_t _protectionEnable; uint32_t _inactiveRunMode; uint32_t _activeRunMode; uint32_t _testDataIndex; uint32_t _payloadPerQuad; uint32_t _badAsicMask0; uint32_t _badAsicMask1; uint32_t _AsicMask; uint32_t _quadMask; uint32_t _roiMask; CsPad::ConfigV1QuadReg _quads[MaxQuadsPerSensor]; }; /** @class ConfigV4 Configuration data for complete CsPad device. */ class ConfigV4 { public: enum { TypeId = Pds::TypeId::Id_CspadConfig /**< XTC type ID value (from Pds::TypeId class) */ }; enum { Version = 4 /**< XTC type version number */ }; uint32_t concentratorVersion() const { return _concentratorVersion; } uint32_t runDelay() const { return _runDelay; } uint32_t eventCode() const { return _eventCode; } /** Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const CsPad::ProtectionSystemThreshold, 1> protectionThresholds(const boost::shared_ptr<T>& owner) const { const CsPad::ProtectionSystemThreshold* data = &_protectionThresholds[0]; return make_ndarray(boost::shared_ptr<const CsPad::ProtectionSystemThreshold>(owner, data), MaxQuadsPerSensor); } /** Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const CsPad::ProtectionSystemThreshold, 1> protectionThresholds() const { return make_ndarray(&_protectionThresholds[0], MaxQuadsPerSensor); } uint32_t protectionEnable() const { return _protectionEnable; } uint32_t inactiveRunMode() const { return _inactiveRunMode; } uint32_t activeRunMode() const { return _activeRunMode; } uint32_t tdi() const { return _testDataIndex; } uint32_t payloadSize() const { return _payloadPerQuad; } uint32_t badAsicMask0() const { return _badAsicMask0; } uint32_t badAsicMask1() const { return _badAsicMask1; } uint32_t asicMask() const { return _AsicMask; } uint32_t quadMask() const { return _quadMask; } uint32_t roiMasks() const { return _roiMask; } const CsPad::ConfigV2QuadReg& quads(uint32_t i0) const { return _quads[i0]; } uint32_t numAsicsRead() const; /** ROI mask for given quadrant */ uint32_t roiMask(uint32_t iq) const; /** Number of ASICs in given quadrant */ uint32_t numAsicsStored(uint32_t iq) const; /** Total number of quadrants in setup */ uint32_t numQuads() const; /** Total number of sections (2x1) in all quadrants */ uint32_t numSect() const; static uint32_t _sizeof() { return (((((((((((((((12+(CsPad::ProtectionSystemThreshold::_sizeof()*(MaxQuadsPerSensor)))+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+(CsPad::ConfigV2QuadReg::_sizeof()*(MaxQuadsPerSensor)))+4)-1)/4)*4; } /** Method which returns the shape (dimensions) of the data returned by quads() method. */ std::vector<int> quads_shape() const; private: uint32_t _concentratorVersion; uint32_t _runDelay; uint32_t _eventCode; CsPad::ProtectionSystemThreshold _protectionThresholds[MaxQuadsPerSensor]; uint32_t _protectionEnable; uint32_t _inactiveRunMode; uint32_t _activeRunMode; uint32_t _testDataIndex; uint32_t _payloadPerQuad; uint32_t _badAsicMask0; uint32_t _badAsicMask1; uint32_t _AsicMask; uint32_t _quadMask; uint32_t _roiMask; CsPad::ConfigV2QuadReg _quads[MaxQuadsPerSensor]; }; /** @class ConfigV5 Configuration data for complete CsPad device. */ class ConfigV5 { public: enum { TypeId = Pds::TypeId::Id_CspadConfig /**< XTC type ID value (from Pds::TypeId class) */ }; enum { Version = 5 /**< XTC type version number */ }; uint32_t concentratorVersion() const { return _concentratorVersion; } uint32_t runDelay() const { return _runDelay; } uint32_t eventCode() const { return _eventCode; } /** Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const CsPad::ProtectionSystemThreshold, 1> protectionThresholds(const boost::shared_ptr<T>& owner) const { const CsPad::ProtectionSystemThreshold* data = &_protectionThresholds[0]; return make_ndarray(boost::shared_ptr<const CsPad::ProtectionSystemThreshold>(owner, data), MaxQuadsPerSensor); } /** Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const CsPad::ProtectionSystemThreshold, 1> protectionThresholds() const { return make_ndarray(&_protectionThresholds[0], MaxQuadsPerSensor); } uint32_t protectionEnable() const { return _protectionEnable; } uint32_t inactiveRunMode() const { return _inactiveRunMode; } uint32_t activeRunMode() const { return _activeRunMode; } uint32_t internalTriggerDelay() const { return _internalTriggerDelay; } uint32_t tdi() const { return _testDataIndex; } uint32_t payloadSize() const { return _payloadPerQuad; } uint32_t badAsicMask0() const { return _badAsicMask0; } uint32_t badAsicMask1() const { return _badAsicMask1; } uint32_t asicMask() const { return _AsicMask; } uint32_t quadMask() const { return _quadMask; } uint32_t roiMasks() const { return _roiMask; } const CsPad::ConfigV3QuadReg& quads(uint32_t i0) const { return _quads[i0]; } uint32_t numAsicsRead() const; /** ROI mask for given quadrant */ uint32_t roiMask(uint32_t iq) const; /** Number of ASICs in given quadrant */ uint32_t numAsicsStored(uint32_t iq) const; /** Total number of quadrants in setup */ uint32_t numQuads() const; /** Total number of sections (2x1) in all quadrants */ uint32_t numSect() const; static uint32_t _sizeof() { return ((((((((((((((((12+(CsPad::ProtectionSystemThreshold::_sizeof()*(MaxQuadsPerSensor)))+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+(CsPad::ConfigV3QuadReg::_sizeof()*(MaxQuadsPerSensor)))+4)-1)/4)*4; } /** Method which returns the shape (dimensions) of the data returned by quads() method. */ std::vector<int> quads_shape() const; private: uint32_t _concentratorVersion; uint32_t _runDelay; uint32_t _eventCode; CsPad::ProtectionSystemThreshold _protectionThresholds[MaxQuadsPerSensor]; uint32_t _protectionEnable; uint32_t _inactiveRunMode; uint32_t _activeRunMode; uint32_t _internalTriggerDelay; uint32_t _testDataIndex; uint32_t _payloadPerQuad; uint32_t _badAsicMask0; uint32_t _badAsicMask1; uint32_t _AsicMask; uint32_t _quadMask; uint32_t _roiMask; CsPad::ConfigV3QuadReg _quads[MaxQuadsPerSensor]; }; /** @class ElementV1 CsPad data from single CsPad quadrant. */ class ConfigV1; class ConfigV2; class ConfigV3; class ConfigV4; class ConfigV5; class ElementV1 { public: enum { Nsbtemp = 4 /**< Number of the elements in _sbtemp array. */ }; /** Virtual channel number. */ uint32_t virtual_channel() const { return uint32_t(this->_word0 & 0x3); } /** Lane number. */ uint32_t lane() const { return uint32_t((this->_word0>>6) & 0x3); } uint32_t tid() const { return uint32_t((this->_word0>>8) & 0xffffff); } uint32_t acq_count() const { return uint32_t(this->_word1 & 0xffff); } uint32_t op_code() const { return uint32_t((this->_word1>>16) & 0xff); } /** Quadrant number. */ uint32_t quad() const { return uint32_t((this->_word1>>24) & 0x3); } /** Counter incremented on every event. */ uint32_t seq_count() const { return _seq_count; } uint32_t ticks() const { return _ticks; } uint32_t fiducials() const { return _fiducials; } /** Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const uint16_t, 1> sb_temp(const boost::shared_ptr<T>& owner) const { const uint16_t* data = &_sbtemp[0]; return make_ndarray(boost::shared_ptr<const uint16_t>(owner, data), Nsbtemp); } /** Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const uint16_t, 1> sb_temp() const { return make_ndarray(&_sbtemp[0], Nsbtemp); } uint32_t frame_type() const { return _frame_type; } /** Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const int16_t, 3> data(const CsPad::ConfigV1& cfg, const boost::shared_ptr<T>& owner) const { ptrdiff_t offset=32; const int16_t* data = (const int16_t*)(((char*)this)+offset); return make_ndarray(boost::shared_ptr<const int16_t>(owner, data), cfg.numAsicsRead()/2, ColumnsPerASIC, MaxRowsPerASIC*2); } /** Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const int16_t, 3> data(const CsPad::ConfigV2& cfg, const boost::shared_ptr<T>& owner) const { ptrdiff_t offset=32; const int16_t* data = (const int16_t*)(((char*)this)+offset); return make_ndarray(boost::shared_ptr<const int16_t>(owner, data), cfg.numAsicsRead()/2, ColumnsPerASIC, MaxRowsPerASIC*2); } /** Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const int16_t, 3> data(const CsPad::ConfigV3& cfg, const boost::shared_ptr<T>& owner) const { ptrdiff_t offset=32; const int16_t* data = (const int16_t*)(((char*)this)+offset); return make_ndarray(boost::shared_ptr<const int16_t>(owner, data), cfg.numAsicsRead()/2, ColumnsPerASIC, MaxRowsPerASIC*2); } /** Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const int16_t, 3> data(const CsPad::ConfigV4& cfg, const boost::shared_ptr<T>& owner) const { ptrdiff_t offset=32; const int16_t* data = (const int16_t*)(((char*)this)+offset); return make_ndarray(boost::shared_ptr<const int16_t>(owner, data), cfg.numAsicsRead()/2, ColumnsPerASIC, MaxRowsPerASIC*2); } /** Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const int16_t, 3> data(const CsPad::ConfigV5& cfg, const boost::shared_ptr<T>& owner) const { ptrdiff_t offset=32; const int16_t* data = (const int16_t*)(((char*)this)+offset); return make_ndarray(boost::shared_ptr<const int16_t>(owner, data), cfg.numAsicsRead()/2, ColumnsPerASIC, MaxRowsPerASIC*2); } /** Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const int16_t, 3> data(const CsPad::ConfigV1& cfg) const { ptrdiff_t offset=32; const int16_t* data = (const int16_t*)(((char*)this)+offset); return make_ndarray(data, cfg.numAsicsRead()/2, ColumnsPerASIC, MaxRowsPerASIC*2); } /** Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const int16_t, 3> data(const CsPad::ConfigV2& cfg) const { ptrdiff_t offset=32; const int16_t* data = (const int16_t*)(((char*)this)+offset); return make_ndarray(data, cfg.numAsicsRead()/2, ColumnsPerASIC, MaxRowsPerASIC*2); } /** Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const int16_t, 3> data(const CsPad::ConfigV3& cfg) const { ptrdiff_t offset=32; const int16_t* data = (const int16_t*)(((char*)this)+offset); return make_ndarray(data, cfg.numAsicsRead()/2, ColumnsPerASIC, MaxRowsPerASIC*2); } /** Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const int16_t, 3> data(const CsPad::ConfigV4& cfg) const { ptrdiff_t offset=32; const int16_t* data = (const int16_t*)(((char*)this)+offset); return make_ndarray(data, cfg.numAsicsRead()/2, ColumnsPerASIC, MaxRowsPerASIC*2); } /** Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const int16_t, 3> data(const CsPad::ConfigV5& cfg) const { ptrdiff_t offset=32; const int16_t* data = (const int16_t*)(((char*)this)+offset); return make_ndarray(data, cfg.numAsicsRead()/2, ColumnsPerASIC, MaxRowsPerASIC*2); } /** Returns section mask for this quadrant. Mask can contain up to 8 bits in the lower byte, total bit count gives the number of sections active. */ uint32_t sectionMask(const CsPad::ConfigV1& cfg) const; /** Returns section mask for this quadrant. Mask can contain up to 8 bits in the lower byte, total bit count gives the number of sections active. */ uint32_t sectionMask(const CsPad::ConfigV2& cfg) const; /** Returns section mask for this quadrant. Mask can contain up to 8 bits in the lower byte, total bit count gives the number of sections active. */ uint32_t sectionMask(const CsPad::ConfigV3& cfg) const; /** Returns section mask for this quadrant. Mask can contain up to 8 bits in the lower byte, total bit count gives the number of sections active. */ uint32_t sectionMask(const CsPad::ConfigV4& cfg) const; /** Returns section mask for this quadrant. Mask can contain up to 8 bits in the lower byte, total bit count gives the number of sections active. */ uint32_t sectionMask(const CsPad::ConfigV5& cfg) const; /** Common mode value for a given section, section number can be 0 to config.numAsicsRead()/2. Will return 0 for data read from XTC, may be non-zero after calibration. */ float common_mode(uint32_t section) const; static uint32_t _sizeof(const CsPad::ConfigV1& cfg) { return (((((((20+(2*(Nsbtemp)))+4)+(2*(cfg.numAsicsRead()/2)*( ColumnsPerASIC)*( MaxRowsPerASIC*2)))+(2*(2)))+4)-1)/4)*4; } static uint32_t _sizeof(const CsPad::ConfigV2& cfg) { return (((((((20+(2*(Nsbtemp)))+4)+(2*(cfg.numAsicsRead()/2)*( ColumnsPerASIC)*( MaxRowsPerASIC*2)))+(2*(2)))+4)-1)/4)*4; } static uint32_t _sizeof(const CsPad::ConfigV3& cfg) { return (((((((20+(2*(Nsbtemp)))+4)+(2*(cfg.numAsicsRead()/2)*( ColumnsPerASIC)*( MaxRowsPerASIC*2)))+(2*(2)))+4)-1)/4)*4; } static uint32_t _sizeof(const CsPad::ConfigV4& cfg) { return (((((((20+(2*(Nsbtemp)))+4)+(2*(cfg.numAsicsRead()/2)*( ColumnsPerASIC)*( MaxRowsPerASIC*2)))+(2*(2)))+4)-1)/4)*4; } static uint32_t _sizeof(const CsPad::ConfigV5& cfg) { return (((((((20+(2*(Nsbtemp)))+4)+(2*(cfg.numAsicsRead()/2)*( ColumnsPerASIC)*( MaxRowsPerASIC*2)))+(2*(2)))+4)-1)/4)*4; } private: uint32_t _word0; uint32_t _word1; uint32_t _seq_count; /**< Counter incremented on every event. */ uint32_t _ticks; uint32_t _fiducials; uint16_t _sbtemp[Nsbtemp]; uint32_t _frame_type; //int16_t _data[cfg.numAsicsRead()/2][ ColumnsPerASIC][ MaxRowsPerASIC*2]; //uint16_t _extra[2]; }; /** @class DataV1 CsPad data from whole detector. */ class ConfigV1; class ConfigV2; class ConfigV3; class ConfigV4; class ConfigV5; class DataV1 { public: enum { TypeId = Pds::TypeId::Id_CspadElement /**< XTC type ID value (from Pds::TypeId class) */ }; enum { Version = 1 /**< XTC type version number */ }; /** Data objects, one element per quadrant. The size of the array is determined by the numQuads() method of the configuration object. */ const CsPad::ElementV1& quads(const CsPad::ConfigV1& cfg, uint32_t i0) const { ptrdiff_t offset=0; const CsPad::ElementV1* memptr = (const CsPad::ElementV1*)(((const char*)this)+offset); size_t memsize = memptr->_sizeof(cfg); return *(const CsPad::ElementV1*)((const char*)memptr + (i0)*memsize); } /** Data objects, one element per quadrant. The size of the array is determined by the numQuads() method of the configuration object. */ const CsPad::ElementV1& quads(const CsPad::ConfigV2& cfg, uint32_t i0) const { ptrdiff_t offset=0; const CsPad::ElementV1* memptr = (const CsPad::ElementV1*)(((const char*)this)+offset); size_t memsize = memptr->_sizeof(cfg); return *(const CsPad::ElementV1*)((const char*)memptr + (i0)*memsize); } /** Data objects, one element per quadrant. The size of the array is determined by the numQuads() method of the configuration object. */ const CsPad::ElementV1& quads(const CsPad::ConfigV3& cfg, uint32_t i0) const { ptrdiff_t offset=0; const CsPad::ElementV1* memptr = (const CsPad::ElementV1*)(((const char*)this)+offset); size_t memsize = memptr->_sizeof(cfg); return *(const CsPad::ElementV1*)((const char*)memptr + (i0)*memsize); } /** Data objects, one element per quadrant. The size of the array is determined by the numQuads() method of the configuration object. */ const CsPad::ElementV1& quads(const CsPad::ConfigV4& cfg, uint32_t i0) const { ptrdiff_t offset=0; const CsPad::ElementV1* memptr = (const CsPad::ElementV1*)(((const char*)this)+offset); size_t memsize = memptr->_sizeof(cfg); return *(const CsPad::ElementV1*)((const char*)memptr + (i0)*memsize); } /** Data objects, one element per quadrant. The size of the array is determined by the numQuads() method of the configuration object. */ const CsPad::ElementV1& quads(const CsPad::ConfigV5& cfg, uint32_t i0) const { ptrdiff_t offset=0; const CsPad::ElementV1* memptr = (const CsPad::ElementV1*)(((const char*)this)+offset); size_t memsize = memptr->_sizeof(cfg); return *(const CsPad::ElementV1*)((const char*)memptr + (i0)*memsize); } static uint32_t _sizeof(const CsPad::ConfigV1& cfg) { return ((((0+(CsPad::ElementV1::_sizeof(cfg)*(cfg.numQuads())))+4)-1)/4)*4; } static uint32_t _sizeof(const CsPad::ConfigV2& cfg) { return ((((0+(CsPad::ElementV1::_sizeof(cfg)*(cfg.numQuads())))+4)-1)/4)*4; } static uint32_t _sizeof(const CsPad::ConfigV3& cfg) { return ((((0+(CsPad::ElementV1::_sizeof(cfg)*(cfg.numQuads())))+4)-1)/4)*4; } static uint32_t _sizeof(const CsPad::ConfigV4& cfg) { return ((((0+(CsPad::ElementV1::_sizeof(cfg)*(cfg.numQuads())))+4)-1)/4)*4; } static uint32_t _sizeof(const CsPad::ConfigV5& cfg) { return ((((0+(CsPad::ElementV1::_sizeof(cfg)*(cfg.numQuads())))+4)-1)/4)*4; } /** Method which returns the shape (dimensions) of the data returned by quads() method. */ std::vector<int> quads_shape(const CsPad::ConfigV1& cfg) const; /** Method which returns the shape (dimensions) of the data returned by quads() method. */ std::vector<int> quads_shape(const CsPad::ConfigV2& cfg) const; /** Method which returns the shape (dimensions) of the data returned by quads() method. */ std::vector<int> quads_shape(const CsPad::ConfigV3& cfg) const; /** Method which returns the shape (dimensions) of the data returned by quads() method. */ std::vector<int> quads_shape(const CsPad::ConfigV4& cfg) const; /** Method which returns the shape (dimensions) of the data returned by quads() method. */ std::vector<int> quads_shape(const CsPad::ConfigV5& cfg) const; private: //CsPad::ElementV1 _quads[cfg.numQuads()]; }; /** @class ElementV2 CsPad data from single CsPad quadrant. */ class ConfigV2; class ConfigV3; class ConfigV4; class ConfigV5; class ElementV2 { public: enum { Nsbtemp = 4 /**< Number of the elements in _sbtemp array. */ }; /** Virtual channel number. */ uint32_t virtual_channel() const { return uint32_t(this->_word0 & 0x3); } /** Lane number. */ uint32_t lane() const { return uint32_t((this->_word0>>6) & 0x3); } uint32_t tid() const { return uint32_t((this->_word0>>8) & 0xffffff); } uint32_t acq_count() const { return uint32_t(this->_word1 & 0xffff); } uint32_t op_code() const { return uint32_t((this->_word1>>16) & 0xff); } /** Quadrant number. */ uint32_t quad() const { return uint32_t((this->_word1>>24) & 0x3); } uint32_t seq_count() const { return _seq_count; } uint32_t ticks() const { return _ticks; } uint32_t fiducials() const { return _fiducials; } /** Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const uint16_t, 1> sb_temp(const boost::shared_ptr<T>& owner) const { const uint16_t* data = &_sbtemp[0]; return make_ndarray(boost::shared_ptr<const uint16_t>(owner, data), Nsbtemp); } /** Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const uint16_t, 1> sb_temp() const { return make_ndarray(&_sbtemp[0], Nsbtemp); } uint32_t frame_type() const { return _frame_type; } /** Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const int16_t, 3> data(const CsPad::ConfigV2& cfg, const boost::shared_ptr<T>& owner) const { ptrdiff_t offset=32; const int16_t* data = (const int16_t*)(((char*)this)+offset); return make_ndarray(boost::shared_ptr<const int16_t>(owner, data), cfg.numAsicsStored(this->quad())/2, ColumnsPerASIC, MaxRowsPerASIC*2); } /** Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const int16_t, 3> data(const CsPad::ConfigV3& cfg, const boost::shared_ptr<T>& owner) const { ptrdiff_t offset=32; const int16_t* data = (const int16_t*)(((char*)this)+offset); return make_ndarray(boost::shared_ptr<const int16_t>(owner, data), cfg.numAsicsStored(this->quad())/2, ColumnsPerASIC, MaxRowsPerASIC*2); } /** Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const int16_t, 3> data(const CsPad::ConfigV4& cfg, const boost::shared_ptr<T>& owner) const { ptrdiff_t offset=32; const int16_t* data = (const int16_t*)(((char*)this)+offset); return make_ndarray(boost::shared_ptr<const int16_t>(owner, data), cfg.numAsicsStored(this->quad())/2, ColumnsPerASIC, MaxRowsPerASIC*2); } /** Note: this overloaded method accepts shared pointer argument which must point to an object containing this instance, the returned ndarray object can be used even after this instance disappears. */ template <typename T> ndarray<const int16_t, 3> data(const CsPad::ConfigV5& cfg, const boost::shared_ptr<T>& owner) const { ptrdiff_t offset=32; const int16_t* data = (const int16_t*)(((char*)this)+offset); return make_ndarray(boost::shared_ptr<const int16_t>(owner, data), cfg.numAsicsStored(this->quad())/2, ColumnsPerASIC, MaxRowsPerASIC*2); } /** Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const int16_t, 3> data(const CsPad::ConfigV2& cfg) const { ptrdiff_t offset=32; const int16_t* data = (const int16_t*)(((char*)this)+offset); return make_ndarray(data, cfg.numAsicsStored(this->quad())/2, ColumnsPerASIC, MaxRowsPerASIC*2); } /** Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const int16_t, 3> data(const CsPad::ConfigV3& cfg) const { ptrdiff_t offset=32; const int16_t* data = (const int16_t*)(((char*)this)+offset); return make_ndarray(data, cfg.numAsicsStored(this->quad())/2, ColumnsPerASIC, MaxRowsPerASIC*2); } /** Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const int16_t, 3> data(const CsPad::ConfigV4& cfg) const { ptrdiff_t offset=32; const int16_t* data = (const int16_t*)(((char*)this)+offset); return make_ndarray(data, cfg.numAsicsStored(this->quad())/2, ColumnsPerASIC, MaxRowsPerASIC*2); } /** Note: this method returns ndarray instance which does not control lifetime of the data, do not use returned ndarray after this instance disappears. */ ndarray<const int16_t, 3> data(const CsPad::ConfigV5& cfg) const { ptrdiff_t offset=32; const int16_t* data = (const int16_t*)(((char*)this)+offset); return make_ndarray(data, cfg.numAsicsStored(this->quad())/2, ColumnsPerASIC, MaxRowsPerASIC*2); } /** Returns section mask for this quadrant. Mask can contain up to 8 bits in the lower byte, total bit count gives the number of sections active. */ uint32_t sectionMask(const CsPad::ConfigV2& cfg) const; /** Returns section mask for this quadrant. Mask can contain up to 8 bits in the lower byte, total bit count gives the number of sections active. */ uint32_t sectionMask(const CsPad::ConfigV3& cfg) const; /** Returns section mask for this quadrant. Mask can contain up to 8 bits in the lower byte, total bit count gives the number of sections active. */ uint32_t sectionMask(const CsPad::ConfigV4& cfg) const; /** Returns section mask for this quadrant. Mask can contain up to 8 bits in the lower byte, total bit count gives the number of sections active. */ uint32_t sectionMask(const CsPad::ConfigV5& cfg) const; /** Common mode value for a given section, section number can be 0 to config.numSect(). Will return 0 for data read from XTC, may be non-zero after calibration. */ float common_mode(uint32_t section) const; uint32_t _sizeof(const CsPad::ConfigV2& cfg) const { return (((((((20+(2*(Nsbtemp)))+4)+(2*(cfg.numAsicsStored(this->quad())/2)*( ColumnsPerASIC)*( MaxRowsPerASIC*2)))+(2*(2)))+4)-1)/4)*4; } uint32_t _sizeof(const CsPad::ConfigV3& cfg) const { return (((((((20+(2*(Nsbtemp)))+4)+(2*(cfg.numAsicsStored(this->quad())/2)*( ColumnsPerASIC)*( MaxRowsPerASIC*2)))+(2*(2)))+4)-1)/4)*4; } uint32_t _sizeof(const CsPad::ConfigV4& cfg) const { return (((((((20+(2*(Nsbtemp)))+4)+(2*(cfg.numAsicsStored(this->quad())/2)*( ColumnsPerASIC)*( MaxRowsPerASIC*2)))+(2*(2)))+4)-1)/4)*4; } uint32_t _sizeof(const CsPad::ConfigV5& cfg) const { return (((((((20+(2*(Nsbtemp)))+4)+(2*(cfg.numAsicsStored(this->quad())/2)*( ColumnsPerASIC)*( MaxRowsPerASIC*2)))+(2*(2)))+4)-1)/4)*4; } private: uint32_t _word0; uint32_t _word1; uint32_t _seq_count; uint32_t _ticks; uint32_t _fiducials; uint16_t _sbtemp[Nsbtemp]; uint32_t _frame_type; //int16_t _data[cfg.numAsicsStored(this->quad())/2][ ColumnsPerASIC][ MaxRowsPerASIC*2]; //uint16_t _extra[2]; }; /** @class DataV2 CsPad data from whole detector. */ class ConfigV2; class ConfigV3; class ConfigV4; class ConfigV5; class DataV2 { public: enum { TypeId = Pds::TypeId::Id_CspadElement /**< XTC type ID value (from Pds::TypeId class) */ }; enum { Version = 2 /**< XTC type version number */ }; /** Data objects, one element per quadrant. The size of the array is determined by the numQuads() method of the configuration object. */ const CsPad::ElementV2& quads(const CsPad::ConfigV2& cfg, uint32_t i0) const { const char* memptr = ((const char*)this)+0; for (uint32_t i=0; i != i0; ++ i) { memptr += ((const CsPad::ElementV2*)memptr)->_sizeof(cfg); } return *(const CsPad::ElementV2*)(memptr); } /** Data objects, one element per quadrant. The size of the array is determined by the numQuads() method of the configuration object. */ const CsPad::ElementV2& quads(const CsPad::ConfigV3& cfg, uint32_t i0) const { const char* memptr = ((const char*)this)+0; for (uint32_t i=0; i != i0; ++ i) { memptr += ((const CsPad::ElementV2*)memptr)->_sizeof(cfg); } return *(const CsPad::ElementV2*)(memptr); } /** Data objects, one element per quadrant. The size of the array is determined by the numQuads() method of the configuration object. */ const CsPad::ElementV2& quads(const CsPad::ConfigV4& cfg, uint32_t i0) const { const char* memptr = ((const char*)this)+0; for (uint32_t i=0; i != i0; ++ i) { memptr += ((const CsPad::ElementV2*)memptr)->_sizeof(cfg); } return *(const CsPad::ElementV2*)(memptr); } /** Data objects, one element per quadrant. The size of the array is determined by the numQuads() method of the configuration object. */ const CsPad::ElementV2& quads(const CsPad::ConfigV5& cfg, uint32_t i0) const { const char* memptr = ((const char*)this)+0; for (uint32_t i=0; i != i0; ++ i) { memptr += ((const CsPad::ElementV2*)memptr)->_sizeof(cfg); } return *(const CsPad::ElementV2*)(memptr); } /** Method which returns the shape (dimensions) of the data returned by quads() method. */ std::vector<int> quads_shape(const CsPad::ConfigV2& cfg) const; /** Method which returns the shape (dimensions) of the data returned by quads() method. */ std::vector<int> quads_shape(const CsPad::ConfigV3& cfg) const; /** Method which returns the shape (dimensions) of the data returned by quads() method. */ std::vector<int> quads_shape(const CsPad::ConfigV4& cfg) const; /** Method which returns the shape (dimensions) of the data returned by quads() method. */ std::vector<int> quads_shape(const CsPad::ConfigV5& cfg) const; private: //CsPad::ElementV2 _quads[cfg.numQuads()]; }; } // namespace CsPad } // namespace PsddlPds #endif // PSDDLPDS_CSPAD_DDL_H
[ "salnikov@SLAC.STANFORD.EDU@b967ad99-d558-0410-b138-e0f6c56caec7" ]
salnikov@SLAC.STANFORD.EDU@b967ad99-d558-0410-b138-e0f6c56caec7
b9f825e5275a53686416f347c1d14e9303d02e92
04fee3ff94cde55400ee67352d16234bb5e62712
/8.3/test/num.cpp
1744f4277c8e07d7f0d7ee80bd4e542541741335
[]
no_license
zsq001/oi-code
0bc09c839c9a27c7329c38e490c14bff0177b96e
56f4bfed78fb96ac5d4da50ccc2775489166e47a
refs/heads/master
2023-08-31T06:14:49.709105
2021-09-14T02:28:28
2021-09-14T02:28:28
218,049,685
1
0
null
null
null
null
UTF-8
C++
false
false
475
cpp
#include<iostream> #include<queue> typedef int int_; #define int long long using namespace std; int a[20000*10000]; priority_queue<int> q; int_ main() { freopen("num.in","r",stdin); freopen("num.out","w",stdout); int n,m,k; int cnt=0; cin>>n>>m>>k; cnt=min(n,min(m,k)); for(int i=1;i<=cnt;i++) { for(int j=1;j<=cnt;j++) { a[i*j]++; } } cnt=0; while(k--) { if(a[cnt]==0) cnt++; a[cnt]--; } cout<<cnt; return 0; }
[ "15276671309@163.com" ]
15276671309@163.com
93a8faa0f3fa53b73a0f843e43ed3d1a79359ca9
120526f47e2ecc1e4d8b45a5befb1f5a178003dd
/栈和队列/两栈共享空间.cpp
1a954264f20c5e5f61135ac36c3836f4074d1713
[]
no_license
summerKK/data_structure_and_algorithms
7d30861247e80c5ad372199230f23eadab482cbd
c21cda9563f01a3ab6f9431f683b98f6ddaef6b8
refs/heads/master
2020-12-01T05:36:26.761490
2020-01-01T16:05:44
2020-01-01T16:05:44
230,568,026
0
0
null
null
null
null
UTF-8
C++
false
false
1,479
cpp
// // Created by 陈思贝 on 2019/12/22. // #include <iostream> using namespace std; #define MAXSIZE 100 typedef int DATA_TYPE; typedef struct { DATA_TYPE data[MAXSIZE]; int top1; int top2; } StackList; void InitStackList(StackList &s) { s.top1 = -1; s.top2 = MAXSIZE; } void push(StackList &s, DATA_TYPE x, int stackNum) { if (s.top1 + 1 == s.top2) { printf("stack overflow"); exit(0); } if (stackNum == 1) { s.data[++s.top1] = x; } else { s.data[--s.top2] = x; } } void pop(StackList &s, DATA_TYPE *x, int stackNum) { if (stackNum == 1) { if (s.top1 == -1) { printf("stack empty"); exit(0); } *x = s.data[s.top1--]; } if (stackNum == 2) { if (s.top2 == MAXSIZE) { printf("stack empty"); exit(0); } *x = s.data[s.top2++]; } } int main() { StackList stackList; InitStackList(stackList); int i; push(stackList, 1, 1); push(stackList, 2, 1); push(stackList, 3, 1); pop(stackList, &i, 1); cout << i << endl; pop(stackList, &i, 1); cout << i << endl; pop(stackList, &i, 1); cout << i << endl; int j; push(stackList, 100, 2); push(stackList, 99, 2); push(stackList, 98, 2); pop(stackList, &j, 2); cout << j << endl; pop(stackList, &j, 2); cout << j << endl; pop(stackList, &j, 2); cout << j << endl; }
[ "su943515688@gmail.com" ]
su943515688@gmail.com
6f45619619745a4f81100b8cc4789f1dbe9865d7
caa72ac60e731d6982f310ac38838009f5de474e
/Opdracht9/insertNumbers.h
62d475397cb5b05f541b811de6dcd0329197fd34
[]
no_license
DannyvdMee/C-Plus-Plus--Portfolio
efe1f73ad116338141656178e988915748d190c5
0286d2534b019b5b9e3f7f05da0ba8eb1cbdc3f9
refs/heads/master
2020-03-28T23:34:25.905075
2018-09-25T07:07:59
2018-09-25T07:07:59
149,298,291
0
0
null
null
null
null
UTF-8
C++
false
false
416
h
// // Created by Danny van der Mee on 02/03/18. // #include <iostream> using namespace std; int *insertNumbers(); int numbers[4] = {}; int *insertNumbers() { cout << "Insert A: "; cin >> numbers[0]; cout << "\n"; cout << "Insert B: "; cin >> numbers[1]; cout << "\n"; cout << "Insert C: "; cin >> numbers[2]; cout << "\n"; cout << "Insert D: "; cin >> numbers[3]; cout << "\n"; return numbers; }
[ "danny.vandermee@edu-kw1c.nl" ]
danny.vandermee@edu-kw1c.nl
094e18e212fba84fc17325d779c7276956ba7231
b2527b0256448bba1795c3b3c766089b9e818c11
/training/2015.8.2/H.cpp
0eda9ce9a07050756619aa396cf9d9b50ad50132
[]
no_license
zxok365/melody-of-canon
0befe10647f2db88d852a2a9c7157578fea44e55
646b2df65cdeaa5aca28759dc0db4e1348b80a71
refs/heads/master
2016-09-16T17:03:47.020659
2016-03-29T12:13:46
2016-03-29T12:13:46
40,532,360
0
0
null
null
null
null
UTF-8
C++
false
false
754
cpp
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace std; const int N = 50005, INF = 0x3f3f3f3f; pair<int, int> link[N]; int ans[N]; int main() { int n, m, q, i, j, k; while (scanf("%d%d%d", &n, &m, &q) == 3) { for (i = 1; i <= m; ++ i) { scanf("%d%d", &j, &k); link[i] = make_pair(j,k); } sort(link + 1, link + m + 1); int a = INF, b = INF, now = m; for (i = n; i >= 1; -- i) { while (link[now].first == i && now > 0) { int c = link[now].second; if (c <= a) { b = a; a = c; } else if (c <= b) { b = c; } now--; } ans[i] = b; } for (i = 1; i <= q; ++ i) { scanf("%d", &j); printf("%d\n", max(j - ans[j], 0)); } } }
[ "zxjszy@126.com" ]
zxjszy@126.com
0d0f7a7484d51660d7ada9e5cd6f9c165b5ce9d1
f9878ed3b5cc55b1951a7e96b7ef65e605a98a1d
/pal/__bits/platform_sdk
303bec69c60e46f683b4927785c9ceb6745a2ed7
[ "MIT" ]
permissive
svens/pal
f6064877421df42d135b75bf105b708ba7f0065b
f84e64eabe1ad7ed872bb27dbc132b8f763251f2
refs/heads/master
2023-08-03T06:05:34.217203
2022-09-16T19:04:32
2022-09-16T19:04:32
251,578,528
0
0
MIT
2023-03-21T18:08:26
2020-03-31T11:06:12
C++
UTF-8
C++
false
false
763
#pragma once // -*- C++ -*- #if __pal_os_windows // included from header: assume nothing, leak nothing #if !defined(WIN32_LEAN_AND_MEAN) #define pal_WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #if !defined(NOMINMAX) #define pal_NOMINMAX #define NOMINMAX #endif #include <windows.h> #if defined(pal_WIN32_LEAN_AND_MEAN) #undef pal_WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN #endif #if defined(pal_NOMINMAX) #undef pal_NOMINMAX #undef NOMINMAX #endif #else // included from source, must be first #if defined(_WIN32) || defined(_WIN64) #define WIN32_LEAN_AND_MEAN #define WIN32_NO_STATUS #define NOMINMAX #include <windows.h> #undef WIN32_NO_STATUS #include <winternl.h> #include <ntstatus.h> #endif #endif
[ "sven@alt.ee" ]
sven@alt.ee
2bfa5266ff361443bcb956e63a811c2df1e107b9
3a2e0625022ac1704b4a71a889bfdf2c9506eb85
/parsing/Regex.hh
f7095f3601b4e997fe00d20ce17a11fcaf0c0c19
[]
no_license
rusign/Plazza
715074d380f2887036169a39d7b509f4588cf461
afe392da3d4c50f83b01dce6c5592065d169d791
refs/heads/master
2020-05-01T19:22:35.336926
2019-03-25T19:20:59
2019-03-25T19:20:59
177,647,303
0
0
null
null
null
null
UTF-8
C++
false
false
345
hh
#ifndef REGEX_HH_ # define REGEX_HH_ #include "Regex.hh" #include <regex.h> #include <iostream> #include <string> class Regex { public : Regex(void); ~Regex(void); bool checkEmail(const std::string &email); bool checkIp(const std::string &); private : regex_t _regexEmail; regex_t _regexIp; }; #endif
[ "nicolas.rusig@epitech.eu" ]
nicolas.rusig@epitech.eu