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
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
โŒ€
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
โŒ€
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
โŒ€
gha_language
stringclasses
141 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
115 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
66921d3d3390442fc417f14ab3db319c5c48b105
595f0f602f45665dff6500881a3d15c4f771946c
/src/bip38.h
6b6892cd7cac577a71135141265d1002af8014e1
[ "MIT" ]
permissive
refshare/refshare
1ac4a85746f34bc01153545cb4fda7461815c45f
891fc008b1568586ab83c336f46b8a4ec4ca0d2a
refs/heads/master
2022-07-15T13:29:09.110824
2020-05-11T15:05:53
2020-05-11T15:05:53
263,065,972
0
1
null
null
null
null
UTF-8
C++
false
false
1,499
h
// Copyright (c) 2017 The REFSHARE developers // Copyright (c) 2017 The PIVX developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_BIP38_H #define BITCOIN_BIP38_H #include "pubkey.h" #include "uint256.h" #include <string> /** 39 bytes - 78 characters * 1) Prefix - 2 bytes - 4 chars - strKey[0..3] * 2) Flagbyte - 1 byte - 2 chars - strKey[4..5] * 3) addresshash - 4 bytes - 8 chars - strKey[6..13] * 4) Owner Entropy - 8 bytes - 16 chars - strKey[14..29] * 5) Encrypted Part 1 - 8 bytes - 16 chars - strKey[30..45] * 6) Encrypted Part 2 - 16 bytes - 32 chars - strKey[46..77] */ void DecryptAES(uint256 encryptedIn, uint256 decryptionKey, uint256& output); void ComputePreFactor(std::string strPassphrase, std::string strSalt, uint256& prefactor); void ComputePassfactor(std::string ownersalt, uint256 prefactor, uint256& passfactor); bool ComputePasspoint(uint256 passfactor, CPubKey& passpoint); void ComputeSeedBPass(CPubKey passpoint, std::string strAddressHash, std::string strOwnerSalt, uint512& seedBPass); void ComputeFactorB(uint256 seedB, uint256& factorB); std::string BIP38_Encrypt(std::string strAddress, std::string strPassphrase, uint256 privKey, bool fCompressed); bool BIP38_Decrypt(std::string strPassphrase, std::string strEncryptedKey, uint256& privKey, bool& fCompressed); std::string AddressToBip38Hash(std::string address); #endif // BIP38_H
[ "you@example.com" ]
you@example.com
b184f28a418c98a6ad3c63bad3cee0307ad90823
8545d068c19b60cf7d27a45e175534a034700ab3
/WOFFCEdit/Camera.h
c4112bc1ea5458828721b2ea7b2595d49eff00b3
[]
no_license
charliegillies/WFFC-Edit
95b2dbf8aaf3016ca004a8ff79ff34915eaa4c2c
958421962eeccc71aa3576e9d7f524097a4cf416
refs/heads/master
2020-05-16T05:00:51.150648
2019-04-29T16:00:09
2019-04-29T16:00:09
182,796,108
0
0
null
2019-04-22T13:44:06
2019-04-22T13:44:06
null
UTF-8
C++
false
false
1,020
h
#pragma once #include <d3d11.h> #include "SimpleMath.h" struct InputCommands; class SceneObject; class Camera { private: DirectX::SimpleMath::Vector3 m_camPosition; DirectX::SimpleMath::Vector3 m_camOrientation; DirectX::SimpleMath::Vector3 m_camLookAt; DirectX::SimpleMath::Vector3 m_camLookDirection; DirectX::SimpleMath::Vector3 m_camRight; float m_camRotRate; float m_moveSpeed; HWND m_hwnd; public: Camera(); void setHWND(HWND hwnd); void handleInput(InputCommands const& commands, const float deltaTime, const SceneObject* so); bool moveTowards(const SceneObject* obj, const float time); DirectX::SimpleMath::Vector3 screenToWorld(int width, int height, DirectX::SimpleMath::Matrix worldMatrix) const; DirectX::SimpleMath::Matrix createViewMatrix(); DirectX::SimpleMath::Vector3 getDirection() const; DirectX::SimpleMath::Vector3 getPosition() const; DirectX::SimpleMath::Vector3 getLookAt() const; DirectX::SimpleMath::Vector3 getUp() const; std::wstring getDebugPosition() const; };
[ "charlie@hazardinteractive.com" ]
charlie@hazardinteractive.com
e13a5b3f7c08d6d7a9e785532221179048f3bc2b
006ff11fd8cfd5406c6f4318f1bafa1542095f2a
/Alignment/CommonAlignmentProducer/src/AlignmentTwoBoyDecayTrackSelector.cc
f901af53711c8fdfcf5fc27f07d9b4efa7df74a8
[]
permissive
amkalsi/cmssw
8ac5f481c7d7263741b5015381473811c59ac3b1
ad0f69098dfbe449ca0570fbcf6fcebd6acc1154
refs/heads/CMSSW_7_4_X
2021-01-19T16:18:22.857382
2016-08-09T16:40:50
2016-08-09T16:40:50
262,608,661
0
0
Apache-2.0
2020-05-09T16:10:07
2020-05-09T16:10:07
null
UTF-8
C++
false
false
10,315
cc
//Framework #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Utilities/interface/EDMException.h" //DataFormats #include <DataFormats/TrackReco/interface/Track.h> #include <DataFormats/METReco/interface/CaloMET.h> #include <DataFormats/Math/interface/deltaPhi.h> //STL #include <math.h> //ROOT #include "TLorentzVector.h" #include "Alignment/CommonAlignmentProducer/interface/AlignmentTwoBodyDecayTrackSelector.h" //TODO put those namespaces into functions? using namespace std; using namespace edm; // constructor ---------------------------------------------------------------- AlignmentTwoBodyDecayTrackSelector::AlignmentTwoBodyDecayTrackSelector(const edm::ParameterSet & cfg) : theMissingETSource("met") { LogDebug("Alignment") << "> applying two body decay Trackfilter ..."; theMassrangeSwitch = cfg.getParameter<bool>( "applyMassrangeFilter" ); if (theMassrangeSwitch){ theMinMass = cfg.getParameter<double>( "minXMass" ); theMaxMass = cfg.getParameter<double>( "maxXMass" ); theDaughterMass = cfg.getParameter<double>( "daughterMass" ); theCandNumber = cfg.getParameter<unsigned int>( "numberOfCandidates" );//Number of candidates to keep secThrBool = cfg.getParameter<bool> ( "applySecThreshold" ); thesecThr = cfg.getParameter<double>( "secondThreshold" ); LogDebug("Alignment") << "> Massrange min,max : " << theMinMass << "," << theMaxMass << "\n> Mass of daughter Particle : " << theDaughterMass; }else{ theMinMass = 0; theMaxMass = 0; theDaughterMass = 0; } theChargeSwitch = cfg.getParameter<bool>( "applyChargeFilter" ); if(theChargeSwitch){ theCharge = cfg.getParameter<int>( "charge" ); theUnsignedSwitch = cfg.getParameter<bool>( "useUnsignedCharge" ); if(theUnsignedSwitch) theCharge=std::abs(theCharge); LogDebug("Alignment") << "> Desired Charge, unsigned: "<<theCharge<<" , "<<theUnsignedSwitch; }else{ theCharge =0; theUnsignedSwitch = true; } theMissingETSwitch = cfg.getParameter<bool>( "applyMissingETFilter" ); if(theMissingETSwitch){ theMissingETSource = cfg.getParameter<InputTag>( "missingETSource" ); LogDebug("Alignment") << "> missing Et Source: "<< theMissingETSource; } theAcoplanarityFilterSwitch = cfg.getParameter<bool>( "applyAcoplanarityFilter" ); if(theAcoplanarityFilterSwitch){ theAcoplanarDistance = cfg.getParameter<double>( "acoplanarDistance" ); LogDebug("Alignment") << "> Acoplanar Distance: "<<theAcoplanarDistance; } } // destructor ----------------------------------------------------------------- AlignmentTwoBodyDecayTrackSelector::~AlignmentTwoBodyDecayTrackSelector() {} ///returns if any of the Filters is used. bool AlignmentTwoBodyDecayTrackSelector::useThisFilter() { return theMassrangeSwitch || theChargeSwitch || theAcoplanarityFilterSwitch; } // do selection --------------------------------------------------------------- AlignmentTwoBodyDecayTrackSelector::Tracks AlignmentTwoBodyDecayTrackSelector::select(const Tracks& tracks, const edm::Event& iEvent, const edm::EventSetup& iSetup) { Tracks result = tracks; if (theMassrangeSwitch) { if (theMissingETSwitch) result = checkMETMass(result,iEvent); else result = checkMass(result); } LogDebug("Alignment") << "> TwoBodyDecay tracks all,kept: " << tracks.size() << "," << result.size(); return result; } template<class T> struct higherTwoBodyDecayPt : public std::binary_function<T,T,bool> { bool operator()( const T& a, const T& b ) { return a.first > b.first ; } }; ///checks if the mass of the X is in the mass region AlignmentTwoBodyDecayTrackSelector::Tracks AlignmentTwoBodyDecayTrackSelector::checkMass(const Tracks& cands) const { Tracks result; LogDebug("Alignment") <<"> cands size : "<< cands.size(); if (cands.size()<2) return result; TLorentzVector track0; TLorentzVector track1; TLorentzVector mother; typedef pair<const reco::Track*,const reco::Track*> constTrackPair; typedef pair<double,constTrackPair> candCollectionItem; vector<candCollectionItem> candCollection; for (unsigned int iCand = 0; iCand < cands.size(); iCand++) { track0.SetXYZT(cands.at(iCand)->px(), cands.at(iCand)->py(), cands.at(iCand)->pz(), sqrt( cands.at(iCand)->p()*cands.at(iCand)->p() + theDaughterMass*theDaughterMass )); for (unsigned int jCand = iCand+1; jCand < cands.size(); jCand++) { track1.SetXYZT(cands.at(jCand)->px(), cands.at(jCand)->py(), cands.at(jCand)->pz(), sqrt( cands.at(jCand)->p()*cands.at(jCand)->p() + theDaughterMass*theDaughterMass )); if (secThrBool==true && track1.Pt() < thesecThr && track0.Pt()< thesecThr) continue; mother = track0 + track1; const reco::Track *trk1 = cands.at(iCand); const reco::Track *trk2 = cands.at(jCand); bool correctCharge = true; if (theChargeSwitch) correctCharge = this->checkCharge(trk1, trk2); bool acoplanarTracks = true; if (theAcoplanarityFilterSwitch) acoplanarTracks = this->checkAcoplanarity(trk1, trk2); if (mother.M() > theMinMass && mother.M() < theMaxMass && correctCharge && acoplanarTracks) { candCollection.push_back(candCollectionItem(mother.Pt(), constTrackPair(trk1, trk2))); } } } if (candCollection.size()==0) return result; sort(candCollection.begin(), candCollection.end(), higherTwoBodyDecayPt<candCollectionItem>()); std::map<const reco::Track*,unsigned int> uniqueTrackIndex; std::map<const reco::Track*,unsigned int>::iterator it; for (unsigned int i=0; i<candCollection.size() && i<theCandNumber; i++) { constTrackPair & trackPair = candCollection[i].second; it = uniqueTrackIndex.find(trackPair.first); if (it==uniqueTrackIndex.end()) { result.push_back(trackPair.first); uniqueTrackIndex[trackPair.first] = i; } it = uniqueTrackIndex.find(trackPair.second); if (it==uniqueTrackIndex.end()) { result.push_back(trackPair.second); uniqueTrackIndex[trackPair.second] = i; } } return result; } ///checks if the mass of the X is in the mass region adding missing E_T AlignmentTwoBodyDecayTrackSelector::Tracks AlignmentTwoBodyDecayTrackSelector::checkMETMass(const Tracks& cands,const edm::Event& iEvent) const { Tracks result; LogDebug("Alignment") <<"> cands size : "<< cands.size(); if (cands.size()==0) return result; TLorentzVector track; TLorentzVector met4; TLorentzVector mother; Handle<reco::CaloMETCollection> missingET; iEvent.getByLabel(theMissingETSource ,missingET); if (!missingET.isValid()) { LogError("Alignment")<< "@SUB=AlignmentTwoBodyDecayTrackSelector::checkMETMass" << "> could not optain missingET Collection!"; return result; } typedef pair<double,const reco::Track*> candCollectionItem; vector<candCollectionItem> candCollection; for (reco::CaloMETCollection::const_iterator itMET = missingET->begin(); itMET != missingET->end(); ++itMET) { met4.SetXYZT((*itMET).px(), (*itMET).py(), (*itMET).pz(), (*itMET).p()); for (unsigned int iCand = 0; iCand < cands.size(); iCand++) { track.SetXYZT(cands.at(iCand)->px(), cands.at(iCand)->py(), cands.at(iCand)->pz(), sqrt( cands.at(iCand)->p()*cands.at(iCand)->p() + theDaughterMass*theDaughterMass )); mother = track + met4; const reco::Track *trk = cands.at(iCand); const reco::CaloMET *met = &(*itMET); bool correctCharge = true; if (theChargeSwitch) correctCharge = this->checkCharge(trk); bool acoplanarTracks = true; if (theAcoplanarityFilterSwitch) acoplanarTracks = this->checkMETAcoplanarity(trk, met); if (mother.M() > theMinMass && mother.M() < theMaxMass && correctCharge && acoplanarTracks) { candCollection.push_back(candCollectionItem(mother.Pt(), trk)); } } } if (candCollection.size()==0) return result; sort(candCollection.begin(), candCollection.end(), higherTwoBodyDecayPt<candCollectionItem>()); std::map<const reco::Track*,unsigned int> uniqueTrackIndex; std::map<const reco::Track*,unsigned int>::iterator it; for (unsigned int i=0; i<candCollection.size() && i<theCandNumber; i++) { it = uniqueTrackIndex.find(candCollection[i].second); if (it==uniqueTrackIndex.end()) { result.push_back(candCollection[i].second); uniqueTrackIndex[candCollection[i].second] = i; } } return result; } ///checks if the mother has charge = [theCharge] bool AlignmentTwoBodyDecayTrackSelector::checkCharge(const reco::Track* trk1, const reco::Track* trk2)const { int sumCharge = trk1->charge(); if (trk2) sumCharge += trk2->charge(); if (theUnsignedSwitch) sumCharge = std::abs(sumCharge); if (sumCharge == theCharge) return true; return false; } ///checks if the [cands] are acoplanar (returns empty set if not) bool AlignmentTwoBodyDecayTrackSelector::checkAcoplanarity(const reco::Track* trk1, const reco::Track* trk2)const { if (fabs(deltaPhi(trk1->phi(),trk2->phi()-M_PI)) < theAcoplanarDistance) return true; return false; } ///checks if the [cands] are acoplanar (returns empty set if not) bool AlignmentTwoBodyDecayTrackSelector::checkMETAcoplanarity(const reco::Track* trk1, const reco::CaloMET* met)const { if (fabs(deltaPhi(trk1->phi(),met->phi()-M_PI)) < theAcoplanarDistance) return true; return false; } //===================HELPERS=================== ///print Information on Track-Collection void AlignmentTwoBodyDecayTrackSelector::printTracks(const Tracks& col) const { int count = 0; LogDebug("Alignment") << ">......................................"; for(Tracks::const_iterator it = col.begin();it < col.end();++it,++count){ LogDebug("Alignment") <<"> Track No. "<< count <<": p = ("<<(*it)->px()<<","<<(*it)->py()<<","<<(*it)->pz()<<")\n" <<"> pT = "<<(*it)->pt()<<" eta = "<<(*it)->eta()<<" charge = "<<(*it)->charge(); } LogDebug("Alignment") << ">......................................"; }
[ "giulio.eulisse@gmail.com" ]
giulio.eulisse@gmail.com
f65306227667cfa2aae6ccf934d57b7c88b1d289
15bd9209ca102e939320bd344491efbe16bd8458
/ESGenNPRestos/es_gennp_restos.cpp
a3cc164f5562e2f3e83d1bc82ef970e365283e00
[]
no_license
emilroy02/ESGenNP
cc6f0855bc47322c0aa75e770002283b68bb1f7a
708b4dfc67210418ab41516916c68ee607fa0f74
refs/heads/master
2023-01-21T21:31:01.021584
2019-11-22T09:21:16
2019-11-22T09:21:16
219,699,639
0
0
null
null
null
null
UTF-8
C++
false
false
2,519
cpp
#include "es_gennp_common.h" #define ESGC_EXPORTS #include "es_gennp.h" #include "es_gennp_core_init.h" #include "es_gennp_config_init.h" #include "es_gennp_service.h" #include "es_gennp_branding_restos.h" #include "es_gennp_library_restos.h" static ESGenNPService *pService = NULL; static std::shared_ptr<ESGenNPBranding> CreateBrandingRestos() { return std::make_shared<ESGenNPBrandingRestos>(); } static std::shared_ptr<ESGenNPLibrary> CreateLibraryRestos() { return std::make_shared<ESGenNPLibraryRestos>(); } class ESGenNPCoreConfigurator { public: ESGenNPCoreConfigurator () { ESCoreConfig cfg; cfg.pFNCreateBranding = CreateBrandingRestos; cfg.pFNCreateLibrary = CreateLibraryRestos; pService = ESGenNPCoreInit::ConfigureCore(cfg); } ~ESGenNPCoreConfigurator (){} }; static ESGenNPCoreConfigurator configurator; extern "C" { namespace ESGenNP { #define COMMON_PRECONDITION if (!pService) { return ESGC_ERR_NOT_INITIALIZED;} ESGC_API ESGCInit( void ) { COMMON_PRECONDITION return pService->ESGCInit(); } ESGC_API ESGCClose( void ) { COMMON_PRECONDITION return pService->ESGCClose(); } ESGC_API ESGCClientCreate( ESGC_CLIENT_HANDLE *phClientOut) { COMMON_PRECONDITION return pService->ESGCClientCreate(phClientOut); } ESGC_API ESGCClientConnect(ESGC_CLIENT_HANDLE hClient, const std::string &ipAddress, const uint16_t port) { COMMON_PRECONDITION return pService->ESGCClientConnect(hClient, ipAddress, port); } ESGC_API ESGCServerCreate( ESGC_SERVER_HANDLE *phServerOut) { COMMON_PRECONDITION return pService->ESGCServerCreate(phServerOut); } ESGC_API ESGCServerStart(ESGC_SERVER_HANDLE hServer) { COMMON_PRECONDITION return pService->ESGCServerStart(hServer); } ESGC_API ESGCServerStop(ESGC_SERVER_HANDLE hServer) { COMMON_PRECONDITION return pService->ESGCServerStop(hServer); } ESGC_API ESGCRegisterEvent(ESGC_EVENTSRC_HANDLE hEventSrc, ESGC_EVENT_TYPE type, ESGC_EVENT_HANDLE *phEventOut) { COMMON_PRECONDITION return pService->ESGCRegisterEvent(hEventSrc, type, phEventOut); } ESGC_API ESGCEventGetData(ESGC_EVENT_HANDLE hEvent, void *pBuffer, size_t *piSize, uint64_t iTimeout) { COMMON_PRECONDITION return pService->ESGCEventGetData(hEvent, pBuffer, piSize, iTimeout); } } }
[ "50533057+emilroy02@users.noreply.github.com" ]
50533057+emilroy02@users.noreply.github.com
52b09468911186ba91cb2a6e54591c717f20fcd6
1b06d5bf179f0d75a30a4b020dd88fc5b57a39bc
/Repository/Aspic/spi_monitor.cp
bad914d8d3fc5d16e951470a498dbcf21179322b
[]
no_license
ofirr/bill_full_cvs
b508f0e8956b5a81d6d6bca6160054d7eefbb2f1
128421e23c7eff22afe6292f88a01dbddd8b1974
refs/heads/master
2022-11-07T23:32:35.911516
2007-07-06T08:51:59
2007-07-06T08:51:59
276,023,188
0
0
null
null
null
null
UTF-8
C++
false
false
86,504
cp
/* SpiFcp Channel activity monitor William Silverman Last update by $Author: bill $ $Date: 2006/06/27 05:30:38 $ Currently locked by $Locker: $ $Revision: 1.29 $ $Source: /home/bill/Repository/Aspic/spi_monitor.cp,v $ Copyright (C) 1998, Weizmann Institute of Science - Rehovot, ISRAEL */ -monitor(initialize). -language([evaluate,compound,colon]). -export([get_public_channels/1, get_public_values/1, public_channels/1, public_channels/2, new_channel/3, new_channel/4, new_public_channel/4, options/2, public_object/3, reset/0, scheduler/1]). -include(spi_constants). RAN => 4. /* uniform 0..1 variate */ LN => 9. /* natural logarithm */ REALTIME => 12. MAXTIME => 99999999999999999999999999999999999999999999999999999999999.0. DEBUG(Note) => write_channel(debug_note(Note), Scheduler). DUMMY_CHANNEL(NewChannel) => (Schedule ? NewChannel : make_channel(Dummy, _) | new_channel(ChannelName, Channel, 0, SPI_DEFAULT_WEIGHT_NAME(SPI_DEFAULT_WEIGHT_INDEX), 0, _, Dummy, _, _, SpiOffsets), self). %STOPPED => DEBUG(stopped(Reply)). STOPPED => Reply = _. /* ** Arguments of SPIOFFSETS correspond to the C-executable (spicomm.c) ** sub-functions: Post, Close, Step, Index, Rate (see spi_constants.cp). ** ** To test one or more C-executables, set the other arguments "unbound" - e.g. ** ** SPIOFFSETS => {unbound, unbound, SpiOffset, SpiOffset, unbound} ** ** to allow the monitor to call the C step function and the C index function, ** and to execute the other operations with fcp code. Note that the ** C index function and the C rate function are not implemented in fcp for ** non-standard weighters. */ SPIOFFSETS => {SpiOffset, SpiOffset, SpiOffset, SpiOffset, SpiOffset}. %SPIOFFSETS => {unbound, unbound, unbound, unbound, unbound}. initialize(In) :- In =?= [] : true; In =\= [] : SpiOffset = _, Options = [3], % preset depth - others default Ordinal = 1, Randomize = 0, SpiOffsets = SPIOFFSETS, DefaultWeighter = SPI_DEFAULT_WEIGHT_NAME(SPI_DEFAULT_WEIGHT_INDEX) | processor # link(lookup(spicomm, SpiOffset), OkComm), check_spicomm(OkComm, SpiOffsets, SpiOffsets'), serve. check_spicomm(Ok, DefaultSpiOffsets, SpiOffsets) :- Ok =\= true : DefaultSpiOffsets = _, SpiOffsets = {unbound, unbound, unbound, unbound, unbound} | computation # comment(("No spicomm" : "No non-standard weighters.")); Ok =?= true : SpiOffsets = DefaultSpiOffsets. /* ** server monitors the input stream (In). ** ** It recognises: ** ** get_public_channels(SortedList?^) ** get_public_values(SortedList?^) ** public_channels(SortedList) ** public_channels(SortedList, Scheduler^) ** public_object(Name, Initial, Vector?^) ** new_channel(ChannelName, Channel, BaseRate) ** new_channel(ChannelName, Channel, ComputeWeight, BaseRate) ** options(New, Old?^) ** randomize ** record(List?^) ** reset ** reset(DefaultWeighter, Randomize, SpiOffsets, Ordinal) ** scheduler(Scheduler^) ** serialize ** spifunctions(List) ** status(List?^) ** ** and the debugging aids: ** ** debug(Debug?^) ** end_debug ** ** Monitor State ** ** Options - for spi_utils functions ** ** Parameters - {Channels, Values} ** Channels - sorted (bounded) list of public channels: ** {name,channel,baserate} ** {name,channel,computeweight,baserate} ** Values - sorted (bounded) list of public values: ** {name,value} ** Scheduler - Channel to Scheduling input ** Randomize - state of scheduling: 0 or SPI_RANDOM_FLAG ** ** Side-effects ** ** Close Scheduler at end of In or reset command. */ serve(In, Options, Ordinal, Randomize, SpiOffsets, DefaultWeighter) :- true : make_vector(OBJECT_ARITY, SpiTime, Outputs), store_vector(OBJECT_VALUES, TIME_INITIAL_VALUE, SpiTime), Channels = [{[], _, -1, ""}], NamedValues = [{TIME_OBJECT_NAME, SpiTime}, {[], _}], Parameters = {Channels, NamedValues} | arg(OBJECT_VALUES, Outputs, Values), arg(OBJECT_REQUESTS, Outputs, Requests), filter_time_requests(Requests?, Requests'), spi_object # monitor(TIME_OBJECT_NAME, _InitialValue, SpiTime, Values, Requests'?), processor # link(lookup(math, MathOffset), OkMath), server, start_scheduling. filter_time_requests(Requests, Filtered) :- Requests ? Close, Close =?= close(_False) | spitime_cant_do(Close), self; Requests ? Store, Store =?= store(_NewValue, _False) | spitime_cant_do(Store), self; Requests ? Other, otherwise : Filtered ! Other | self; Requests =?= [] : Filtered = []. spitime_cant_do(Request) :- arity(Request, Arity), arg(Arity, Request, False), we(False) : False = false; otherwise | fail(TIME_OBJECT_NAME - Request, forbidden). server(In, Options, Parameters, Scheduler) :- In ? debug(Debug) : Debug = Debug'?, write_channel(debug(Debug'), Scheduler) | self; In ? end_debug : write_channel(end_debug, Scheduler) | self; In ? end_record(Stream) : Stream = Stream'?, write_channel(end_record(Stream'), Scheduler) | self; In ? get_public_channels(List?^), Parameters =?= {Channels, _NamedValues} | copy_bounded(Channels, List), self; In ? get_public_values(List?^), Parameters =?= {_Channels, NamedValues} | copy_bounded(NamedValues, List), self; In ? public_channels(List) | merge_parameter_list(List, Parameters, Parameters', Scheduler, _), self; In ? public_channels(List, ReadyScheduler) | merge_parameter_list(List, Parameters, Parameters', Scheduler, ReadyScheduler), self; In ? public_object(Name, Initial, Vector?^) | merge_parameter_list(Name(Vector), Parameters, Parameters', Scheduler, Ready), wait_object_ready, self; In ? New , New = new_channel(_Creator, _Channel, _BaseRate) : write_channel(New, Scheduler) | self; In ? New , New = new_channel(_Creator, _Channel, _ComputeWeight, _BaseRate) : write_channel(New, Scheduler) | self; In ? options(New, Old) : Options' = New? | unify_without_failure(Options, Old), self; In ? randomize : write_channel(randomize(SPI_RANDOM_FLAG), Scheduler) | self; In ? record(Record) : Record = Record'?, write_channel(record(Record'), Scheduler) | self; In ? reset : write_channel(state(DefaultWeighter, Randomize, SpiOffsets, _Ordinal), Scheduler), In'' = [reset(DefaultWeighter?, Randomize?, SpiOffsets?, 1) | In'] | self; In ? reset(DefaultWeighter, Randomize, SpiOffsets, Ordinal), Parameters =?= {_Channels, NamedValues} : close_channel(Scheduler) | close_public_objects, serve; In ? scheduler(Scheduler^) | self; In ? serialize : write_channel(randomize(0), Scheduler) | self; In ? spifunctions(List) : write_channel(spifunctions(List), Scheduler) | self; In ? status(Status) : Status = Status'?, write_channel(status(Status'), Scheduler) | self; In ? Other, otherwise | self, fail(Other, unknown); In =?= [], Parameters =?= {_Channels, NamedValues} : Options = _, close_channel(Scheduler) | close_public_objects. close_public_objects(NamedValues) :- NamedValues ? _Name(Vector), arity(Vector, OBJECT_ARITY), read_vector(OBJECT_VALUES, Vector, _Value) : write_vector(OBJECT_REQUESTS, close(_), Vector) | self; /* If not a vector or different arity or unstored, just ignore it! */ NamedValues ? _Name(_Value), otherwise | self; NamedValues ? _Name(Variable), unknown(Variable) | self; NamedValues =?= [] : true. /***************************** Utilities ************************************/ /* merge_parameter_list ** ** Input: ** ** List - sorted list of: Name(Value) ** Name(Channel^, BaseRate) ** Name(Channel^, ComputeWeight, BaseRate) ** or: Name(Object) ** Parameters - {Channels, NamedValues} ** NamedValues - (bounded) sorted list of: Name(Value). ** Channels - (bounded) sorted list of: ** Name(Channel, BaseRate, ComputeWeight). ** Scheduler - FCP channel to scheduling monitor. ** ** Output: ** ** NewParameters - {NewChannels, NewNamedValues} ** NewNamedValues - updated named value list. ** NewChannels - updated channels list. ** ReadyScheduler - Scheduler. ** ** Processing: ** ** PriorNamedValue - Name of previous element of NamedValues - initially 0. ** PriorChannel - Name of previous element of Publics - initially 0. ** Merge (new) Named Channels to NewChannels, ** (new) Named Values to NewNamedValues ** Call scheduling to create each new Channel. ** Call computation to define each new named value (in list); ** do not define objects. */ merge_parameter_list(List, Parameters, NewParameters, Scheduler, ReadyScheduler) :- Parameters =?= {Channels, NamedValues} : PriorChannel = 0, PriorName = 0, NewParameters = {NewChannels?, NewNamedValues?} | merge_parameters. merge_parameters(List, Channels, NewChannels, PriorChannel, NamedValues, NewNamedValues, PriorName, Scheduler, ReadyScheduler) :- List =?= [] : PriorChannel = _, PriorName = _, ReadyScheduler = Scheduler, NewChannels = Channels, NewNamedValues = NamedValues; List =?= Name(Vector), string(Name), NamedValues =?= [Name(NamedValue) | _] : PriorChannel = _, PriorName = _, Vector = NamedValue, NewChannels = Channels, NewNamedValues = NamedValues, ReadyScheduler = Scheduler; List =?= Name(_), string(Name), NamedValues ? NamedValue, NamedValue = PriorName'(_), PriorName' @< Name : PriorName = _, NewNamedValues ! NamedValue | self; List ? Name(Value), string(Name), NamedValues ? NamedValue, NamedValue =?= Name(NameValue) : PriorName = _, Value = NameValue, NewNamedValues ! NamedValue, PriorName' = Name | self; List = [Name(_) | _], string(Name), NamedValues ? NamedValue, NamedValue = PriorName'(_), PriorName' @< Name : PriorName = _, NewNamedValues ! NamedValue | self; List =?= Name(Vector), string(Name), NamedValues =?= [Name1(_) | _], PriorName @< Name, Name @< Name1 : PriorChannel = _, NewChannels = Channels, NewNamedValues = [Name(Vector?) | NamedValues], ReadyScheduler = Scheduler; List ? Name(Value), string(Name), NamedValues =?= [Name1(_) | _], PriorName @< Name, Name @< Name1 : List'' = [Name(Value) | List'], NamedValues' = [Name(SystemValue) | NamedValues] | computation # dictionary(add, Name, SystemValue, Result), wait_name_added; List ? Name(NewChannel, BaseRate), string(Name), PriorChannel @< Name, we(NewChannel), Channels ? Public, Public = Name(SpiChannel, _ComputeWeight, BaseRate), vector(SpiChannel), read_vector(SPI_CHANNEL_REFS, SpiChannel, References), References++ : PriorChannel = _, NewChannel = SpiChannel, store_vector(SPI_CHANNEL_REFS, References', SpiChannel), NewChannels ! Public, PriorChannel' = Name | self; List ? Name(_NewChannel, BaseRate), string(Name), Channels ? Entry, Entry = Name(_SpiChannel, _ComputeWeight, OtherBaseRate), BaseRate =\= OtherBaseRate : NewChannels ! Entry | fail(public_channel(rate_conflict(Name - BaseRate =\= OtherBaseRate))), self; List = [Name(_NewChannel, _BaseRate) | _], string(Name), Channels ? Entry, Entry = PriorChannel'(_, _, _), PriorChannel' @< Name : PriorChannel = _, NewChannels ! Entry | self; List ? Name(NewChannel, BaseRate), string(Name), we(NewChannel), Channels =?= [Name1(_, _, _) | _], string(Name), PriorChannel @< Name, Name @< Name1 : NewChannel = NewChannel'?, List'' = [Name(NewChannel', BaseRate) | List'], Channels' = [Name(SpiChannel?, SPI_DEFAULT_WEIGHT_NAME, BaseRate) | Channels], write_channel(new_public_channel(Name, SpiChannel, SPI_DEFAULT_WEIGHT_NAME, BaseRate), Scheduler) | self; List ? Name(NewChannel, CW, BaseRate), string(Name), PriorChannel @< Name, we(NewChannel), Channels ? Public, Public = Name(SpiChannel, ComputeWeight, BaseRate), vector(SpiChannel), read_vector(SPI_CHANNEL_REFS, SpiChannel, References), References++ : PriorChannel = _, CW = ComputeWeight?, NewChannel = SpiChannel, store_vector(SPI_CHANNEL_REFS, References', SpiChannel), NewChannels ! Public, PriorChannel' = Name | self; List ? Name(_NewChannel, _ComputeWeight, BaseRate), string(Name), Channels ? Entry, Entry = Name(_SpiChannel, _, OtherBaseRate), BaseRate =\= OtherBaseRate : NewChannels ! Entry | fail(public_channel(rate_conflict(Name - BaseRate =\= OtherBaseRate))), self; List ? Name(_NewChannel, ComputeWeight, _BaseRate), string(Name), Channels ? Entry, Entry = Name(_SpiChannel, OtherComputeWeight, _), ComputeWeight =\= OtherComputeWeight : NewChannels ! Entry | fail(public_channel(compute_weight_conflict(Name - ComputeWeight =\= OtherComputeWeight))), self; List = [Name(_NewChannel, _ComputeWeight, _BaseRate) | _], string(Name), Channels ? Entry, Entry = PriorChannel'(_, _, _), PriorChannel' @< Name : PriorChannel = _, NewChannels ! Entry | self; List ? Name(NewChannel, ComputeWeight, BaseRate), string(Name), we(NewChannel), Channels =?= [Name1(_, _, _) | _], string(Name), PriorChannel @< Name, Name @< Name1 : NewChannel = NewChannel'?, List'' = [Name(NewChannel', ComputeWeight, BaseRate) | List'], Channels' = [Name(SpiChannel?, ComputeWeight, BaseRate) | Channels], write_channel(new_public_channel(Name, SpiChannel, ComputeWeight, BaseRate), Scheduler) | self; otherwise : PriorChannel = _, PriorName = _, ReadyScheduler = Scheduler, NewNamedValues = NamedValues, NewChannels = Channels | fail(merge_parameters(List)). wait_name_added(List, Channels, NewChannels, PriorChannel, NamedValues, NewNamedValues, PriorName, Scheduler, ReadyScheduler, Result) :- known(Result) | merge_parameters. wait_object_ready(Name, Initial, Vector, Ready) :- known(Ready), Name =\= TIME_OBJECT_NAME | spi_object # create(Name, Initial, Vector); otherwise : Initial = _, Name = _, Ready = _, Vector = _ . /* copy_bounded ** ** Input: ** ** Bounded = (bounded) list of {Name, Channel, BaseRate} ** ** Output: ** ** List - copied exluding bounding entry */ copy_bounded(Bounded, List) :- Bounded ? Entry, Bounded' =\= [] : List ! Entry | self; Bounded = [_] : List = []. /***************************** Scheduling ***********************************/ start_scheduling(Scheduler, MathOffset, Ordinal, SpiOffsets, DefaultWeighter, Randomize, OkMath, SpiTime):- OkMath =\= true : DefaultWeighter = _, MathOffset = _, Ordinal = _, Randomize = _, SpiOffsets = _, SpiTime = [], make_channel(Scheduler, _) | fail(math_offset(OkMath)); OkMath =?= true, info(REALTIME, Start_real_time) : Waiter ! machine(idle_wait(Wakeup), _Ok), make_channel(Scheduler, Schedule) | make_channel_anchor(based, BasedAnchor), make_channel_anchor(instantaneous, InstantaneousAnchor), processor # Waiter?, scheduling(Schedule, MathOffset, Ordinal, SpiOffsets, Waiter', Scheduler, _Recording, _Debug, SpiTime, true, Wakeup, DefaultWeighter, Randomize, {MAXTIME, _State}, Start_real_time, BasedAnchor, InstantaneousAnchor). make_channel_anchor(Name, Anchor) :- true : make_vector(CHANNEL_SIZE, Anchor, _), store_vector(SPI_BLOCKED, FALSE, Anchor), store_vector(SPI_CHANNEL_TYPE, SPI_CHANNEL_ANCHOR, Anchor), store_vector(SPI_CHANNEL_RATE, 0.0, Anchor), store_vector(SPI_CHANNEL_REFS, 1, Anchor), store_vector(SPI_SEND_ANCHOR, SendAnchor, Anchor), make_vector(2, LinksS, _), SendAnchor = {SPI_MESSAGE_ANCHOR, "", [], 0, 0, 0, [], LinksS, []}, store_vector(SPI_NEXT_MS, SendAnchor, LinksS), store_vector(SPI_PREVIOUS_MS, SendAnchor, LinksS), store_vector(SPI_SEND_WEIGHT, 0, Anchor), store_vector(SPI_RECEIVE_ANCHOR, ReceiveAnchor, Anchor), make_vector(2, LinksR, _), ReceiveAnchor = {SPI_MESSAGE_ANCHOR, "", [], 0, 0, 0, [], LinksR, []}, store_vector(SPI_NEXT_MS, ReceiveAnchor, LinksR), store_vector(SPI_PREVIOUS_MS, ReceiveAnchor, LinksR), store_vector(SPI_RECEIVE_WEIGHT, 0, Anchor), store_vector(SPI_WEIGHT_TUPLE, SPI_DEFAULT_WEIGHT_NAME(SPI_DEFAULT_WEIGHT_INDEX), Anchor), store_vector(SPI_NEXT_CHANNEL, Anchor, Anchor), store_vector(SPI_PREVIOUS_CHANNEL, Anchor, Anchor), store_vector(SPI_CHANNEL_NAME, Name, Anchor). /* ** scheduling monitors the stream generated using the scheduler channel. ** ** It recognises: ** ** close(ChannelTuple) ** close(ChannelTuple, Reply) ** cutoff(Now', State^) ** default_weighter(NewWeighter) ** input(Schedule?^, Schedule') ** new_channel(ChannelName, Channel^, BaseRate) ** new_channel(ChannelName, Channel^, ComputeWeight, BaseRate) ** new_public_channel(ChannelName, Channel, ComputeWeight, BaseRate) ** ordinal(Old?^, New) ** randomize(NewRandomize) ** record(Record?^) ** record_item(Item) ** end_record(Record'?^) ** start(Signature, OpList, Value, Chosen) ** start(Signature, OpList, Value, Chosen, Prefix) ** ** and the debugging aids: ** ** debug(Debug?^) ** end_debug ** diagnostic(ApplicationDiagnostic) ** spifunctions(CharacterCodes) ** pause(Continue) ** state(DefaultWeighter^, Randomize^, SpiOffsets^, Ordinal^) ** status(ListOf NamedDetails^) ** step ** step(Resume) ** ** Scheduler State: ** ** DefaultWeighter - assigned to new Channel, unless Weighter provide ** Ordinal - Unique index assigned to a private file - also in Status ** SpiOffsets - magic numbers (or "unknown") for C-coded functions ** ** Status: ** ** Cutoff 2-Tuple ** Limit - least upper bound of internal timer (SpiTime) - initially large ** Status - Variable set to Now time when Limit exceeded (see below) ** SpiTime - 0-based internal clock ** Start_real_time - real time when Cutoff set (Now = 0) - not in status list ** Waiting - waiting for Wakeup signal = true/false ** ** BasedAnchor - anchor for circular list of based-rate Channels ** InstantaneousAnchor - anchor for circular list of infinite rate Channels ** ** Signal: ** ** Wakeup - (usually) idle indicator; also communication completion ** ** Output (Streams): ** ** Debug - scheduling debugging info ** Record - recorded actions for analysis ** Waiter - Logix system requests to wait for idle ** ** Processing: ** ** Maintain time SpiTime (Now) ** ** Whenever the system becomes idle, execute(SpiOffset, {SPI_STEP, ...}) ** to select and complete a transmission (internal execute is used when ** the SPI function is unknown). ** ** Record: ** ** Changes to SpiTime (Now) ** Start Communication ** Complete Transmission */ STATUS => [anchors([BasedAnchor, InstantaneousAnchor]), cutoff_limit(CutoffLimit), cutoff_status(CutoffStatus?), debug(Debug?), spi_time(SpiTime), now(Now), ordinal(Ordinal), randomize(Randomize), record(Record?), waiting(Waiting), weighter(DefaultWeighter)]. scheduling(Schedule, MathOffset, Ordinal, SpiOffsets, Waiter, Scheduler, Record, Debug, SpiTime, Waiting, Wakeup, DefaultWeighter, Randomize, Cutoff, Start_real_time, BasedAnchor, InstantaneousAnchor) :- Schedule =?= [] : BasedAnchor = _, DefaultWeighter = _, InstantaneousAnchor = _, MathOffset = _, Ordinal = _, Randomize = _, Scheduler = _, SpiOffsets = _, SpiTime = _, Start_real_time = _, Waiting = _, Wakeup = _, close_vector(OBJECT_REQUESTS, SpiTime), Waiter = [], Record = [], Debug = [] | unify_without_failure(Cutoff, {_, []}); /* Close channels - i.e. decrement counts and release when unreferenced. */ Schedule ? close(Channels), known(Channels), arg(SPI_CLOSE, SpiOffsets, SpiOffset), SpiOffset =?= unbound : STOPPED | execute_close(Channels, Reply), self; Schedule ? close(Channels), known(Channels), arg(SPI_CLOSE, SpiOffsets, SpiOffset), SpiOffset =\= unbound : execute(SpiOffset, {SPI_CLOSE, Channels, Reply}), STOPPED | self; Schedule ? close(Channels, Reply?^), known(Channels), arg(SPI_CLOSE, SpiOffsets, SpiOffset), SpiOffset =?= unbound : STOPPED | execute_close(Channels, Reply), self; Schedule ? close(Channels, Reply?^), known(Channels), arg(SPI_CLOSE, SpiOffsets, SpiOffset), SpiOffset =\= unbound : execute(SpiOffset, {SPI_CLOSE, Channels, Reply}), STOPPED | self; /* Set the time limit - maximum value for SpiTime */ Schedule ? cutoff(Limit, State), Limit >= 0, State = State'?, info(REALTIME, Start_real_time') : Start_real_time = _, Cutoff' = {Limit, State'} | unify_without_failure(Cutoff, {_Limit, []}), continue_waiting + (Reply = true); Schedule ? default_weighter(Weighter), arg(SPI_INDEX, SpiOffsets, SpiOffset), SpiOffset =\= unbound | reset_default_weighter(SpiOffset, Weighter, DefaultWeighter, DefaultWeighter'), self; /* Splice input filter. */ Schedule ? input(Schedule'', Schedule'^) | self; /* Create a new channel. */ Schedule ? new_channel(ChannelName, Channel, BaseRate) | index_channel_name(ChannelName, Ordinal, ChannelName', Ordinal'), new_channel + (ComputeWeight = DefaultWeighter), continue_waiting; Schedule ? new_channel(ChannelName, Channel, ComputeWeight, BaseRate), string(ComputeWeight) | index_channel_name(ChannelName, Ordinal, ChannelName', Ordinal'), new_channel + (ComputeWeight = ComputeWeight(_)), continue_waiting; Schedule ? new_channel(ChannelName, Channel, ComputeWeight, BaseRate), tuple(ComputeWeight), arity(ComputeWeight) > 1 | index_channel_name(ChannelName, Ordinal, ChannelName', Ordinal'), new_channel, continue_waiting; Schedule ? new_public_channel(ChannelName, Channel, BaseRate) | new_channel + (ComputeWeight = DefaultWeighter), continue_waiting; Schedule ? new_public_channel(ChannelName, Channel, ComputeWeight, BaseRate), string(ComputeWeight) | new_channel + (ComputeWeight = ComputeWeight(_)), continue_waiting; Schedule ? new_public_channel(ChannelName, Channel, ComputeWeight, BaseRate), tuple(ComputeWeight), arity(ComputeWeight) > 1 | new_channel, continue_waiting; Schedule ? ordinal(Ordinal', Ordinal^) | self; /* Return the current head of the recording stream. */ Schedule ? record(Stream) : Stream = Record? | self; Schedule ? record_item(Item) : Record ! Item, Debug ! Item | self; /* Close the recording stream, and start a new one. */ Schedule ? end_record(Stream) : store_vector(OBJECT_VALUES, 0.0, SpiTime), Record = [], Stream = Record'? | self; /* Start a transmission process. */ Schedule ? Start, Start =?= start(PostId, OpList, Value, Chosen), known(OpList), arg(SPI_POST, SpiOffsets, SpiOffset), SpiOffset =?= unbound, tuple(PostId), arg(1, PostId, PName) : Record ! start(PName), Debug ! start(PostId) | execute_post, continue_waiting; Schedule ? Start, Start =?= start(PName, OpList, Value, Chosen), known(OpList), arg(SPI_POST, SpiOffsets, SpiOffset), SpiOffset =?= unbound, string(PName) : Record ! start(PName), Debug ! start(PName) | execute_post + (PostId = {PName}), continue_waiting; Schedule ? Start, Start =?= start(PId, OpList, Value, Chosen, Prefix), known(OpList), arg(SPI_POST, SpiOffsets, SpiOffset), SpiOffset =?= unbound, tuple(PId), arg(1, PId, PName), string(PName), string_to_dlist(PName, PNL, []), convert_to_string(Prefix, Prefix'), string_to_dlist(Prefix', PL, [CHAR_COLON | PNL]), list_to_string(PL, PrefixedId) : PostId = (Prefix' : PId), Record ! start(PrefixedId), Debug ! start(PostId) | execute_post, continue_waiting; Schedule ? Start, Start =?= start({PName}, OpList, Value, Chosen, Prefix), known(OpList), arg(SPI_POST, SpiOffsets, SpiOffset), SpiOffset =?= unbound, string(PName), string_to_dlist(PName, PNL, []), convert_to_string(Prefix, Prefix'), string_to_dlist(Prefix', PL, [CHAR_COLON | PNL]), list_to_string(PL, PrefixedId) : PostId = (Prefix' : {PName}), Record ! start(PrefixedId), Debug ! start(PostId) | execute_post, continue_waiting; Schedule ? Start, Start =?= start(PId, OpList, Value, Chosen), known(OpList), arg(SPI_POST, SpiOffsets, SpiOffset), SpiOffset =\= unbound, tuple(PId), arg(1, PId, PName), string(PName) : execute(SpiOffset, {SPI_POST, PId, OpList, Value, Chosen, Reply}), Record ! start(PName), Debug ! start(PId) | continue_waiting; Schedule ? Start, Start =?= start(PName, OpList, Value, Chosen), known(OpList), arg(SPI_POST, SpiOffsets, SpiOffset), SpiOffset =\= unbound, string(PName) : execute(SpiOffset, {SPI_POST, {PName}, OpList, Value, Chosen, Reply}), Record ! start(PName), Debug ! start(PName) | continue_waiting; Schedule ? Start, Start =?= start(PId, OpList, Value, Chosen, Prefix), known(OpList), arg(SPI_POST, SpiOffsets, SpiOffset), SpiOffset =\= unbound, tuple(PId), arg(1, PId, PName), string(PName), string_to_dlist(PName, PNL, []), convert_to_string(Prefix, Prefix'), string_to_dlist(Prefix', PL, [CHAR_COLON | PNL]), list_to_string(PL, PrefixedId) : PostId = (Prefix' : PId), execute(SpiOffset, {SPI_POST, PostId, OpList, Value, Chosen, Reply}), Record ! start(PrefixedId), Debug ! start(PostId) | continue_waiting; Schedule ? Start, Start =?= start(PName, OpList, Value, Chosen, Prefix), known(OpList), arg(SPI_POST, SpiOffsets, SpiOffset), SpiOffset =\= unbound, string(PName), string_to_dlist(PName, PNL, []), convert_to_string(Prefix, Prefix'), string_to_dlist(Prefix', PL, [CHAR_COLON | PNL]), list_to_string(PL, PrefixedId) : PostId = (Prefix' : {PName}), execute(SpiOffset, {SPI_POST, PostId, OpList, Value, Chosen, Reply}), Record ! start(PrefixedId), Debug ! start(PostId) | continue_waiting; Schedule ? update_references(Updates), Updates ? {Channel, Addend}, vector(Channel), arity(Channel, CHANNEL_SIZE), integer(Addend), Addend > 0, read_vector(SPI_CHANNEL_REFS, Channel, Refs), Refs += Addend, list(Updates') : store_vector(SPI_CHANNEL_REFS, Refs', Channel), Schedule'' = [update_references(Updates') | Schedule'] | self; Schedule ? update_references(Updates), Updates ? {Channel, Addend}, vector(Channel), arity(Channel, CHANNEL_SIZE), integer(Addend), Addend > 0, read_vector(SPI_CHANNEL_REFS, Channel, Refs), Refs += Addend, Updates' =?= [] : store_vector(SPI_CHANNEL_REFS, Refs', Channel) | self; /**************************** Debugging aids ********************************/ Schedule ? debug(Stream) : Stream = Debug? | self; Schedule ? debug_note(Note) : Debug ! Note | self; Schedule ? end_debug : Debug = [], Debug' = _ | self; Schedule ? diagnostic(Diagnostic) : Debug ! Diagnostic | screen # display(("Application Diagnostic" -> Diagnostic)), self; Schedule ? spifunctions(List), arity(SpiOffsets, Arity), make_tuple(Arity, SpiOffsets'), arg(SPI_CLOSE, SpiOffsets', Close), arg(SPI_POST, SpiOffsets', Post), arg(SPI_STEP, SpiOffsets', Step), arg(SPI_INDEX, SpiOffsets', Index), arg(SPI_RATE, SpiOffsets', Rate) : SpiOffsets = _, Close = Close'?, Post = Post'?, Step = Step'?, Index = Index'?, Rate = Rate'? | processor # link(lookup(spicomm, SpiOffset), _Ok), spifunctions, self; /**************************** Debugger aids *********************************/ /* Pause processing until Continue is set. */ Schedule ? pause(Continue), unknown(Wakeup) | pause_scheduling(Continue, Schedule', Schedule'', Waiting, Waiting', Wakeup, Wakeup', Start_real_time, Start_real_time'), self; Schedule ? state(DefaultWeighter^, Randomize^, SpiOffsets^, Ordinal^) | self; Schedule ? status(Status), read_vector(OBJECT_VALUES, SpiTime, Now), Cutoff = {CutoffLimit, CutoffStatus} : Status = STATUS | self; /* Step and resume */ Schedule ? step, unknown(Wakeup) : Schedule'' = [pause(resume) | Schedule'], Wakeup' = done | self; /* Step and pause processing until Continue is set. */ Schedule ? step(Continue), unknown(Wakeup) : Schedule'' = [pause(Continue) | Schedule'], Wakeup' = done | self; /***************************************************************************/ Schedule ? randomize(NewRandomize), Randomize' := NewRandomize /\ SPI_RANDOM_FLAG : Randomize = _ | self; Schedule ? Other, otherwise, unknown(Wakeup) | fail("unrecognized request" - Other), self; Wakeup =?= done, arg(SPI_STEP, SpiOffsets, SpiOffset), SpiOffset =?= unbound, arg(SPI_RATE, SpiOffsets, RateOffset), read_vector(OBJECT_VALUES, SpiTime, Now) : Waiting = _, Waiting' = false, store_vector(OBJECT_VALUES, Now'?, SpiTime) | sum_weights(BasedAnchor, RateOffset, 0, Total), logix_total(MathOffset, BasedAnchor, Now, Total, RateOffset, Now', Wakeup'), self; Wakeup =?= done, arg(SPI_STEP, SpiOffsets, SpiOffset), SpiOffset =\= unbound, read_vector(OBJECT_VALUES, SpiTime, Now) : Waiting = _, execute(SpiOffset, {SPI_STEP, Now, BasedAnchor, Now', Wakeup'}), store_vector(OBJECT_VALUES, Now'?, SpiTime), Debug ! step(Waiting, Wakeup, Wakeup'), Waiting' = false | self; /* * RCId refers to Request Channel Id (as of now, a string). * CNID refers to Channel Name Id (as of now a string or a 2-tuple). * CH refers to a spi-channel (as of now, a vector with 12 sub-channels). * PId refers to a process signature (the originator of a request). */ Wakeup =?= true(PId1, RCId1, CH1, PId2, RCId2, CH2), PId1 =\= (_ : _), PId2 =\= (_ : _), arg(1, PId1, PName1), arg(1, PId2, PName2), read_vector(OBJECT_VALUES, SpiTime, Now), read_vector(SPI_CHANNEL_NAME, CH1, CNId1), read_vector(SPI_CHANNEL_NAME, CH2, CNId2) : Waiting = _, Wakeup' = _, Waiter ! machine(idle_wait(Wakeup'), _Ok), Waiting' = true, Record = [Now, end(PName1(RCId1, SENT_ARROW, CNId1)), end(PName2(RCId2, RECEIVED_ARROW, CNId2)) | Record'?], Debug ! done(Now, PId1(RCId1, CH1), PId2(RCId2, CH2)) | self; Wakeup =?= true(PId1, RCId1, CH1, PId2, RCId2, CH2), PId1 = (Prefix1 : SId1), arg(1, SId1, PName1), string_to_dlist(PName1, PNL1, []), string_to_dlist(Prefix1, PX1, [CHAR_COLON | PNL1]), list_to_string(PX1, PrefixedName1), PId2 = (Prefix2 : SId2), arg(1, SId2, PName2), string_to_dlist(PName2, PNL2, []), string_to_dlist(Prefix2, PX2, [CHAR_COLON | PNL2]), list_to_string(PX2, PrefixedName2), read_vector(OBJECT_VALUES, SpiTime, Now), read_vector(SPI_CHANNEL_NAME, CH1, CNId1), read_vector(SPI_CHANNEL_NAME, CH2, CNId2) : Waiting = _, Wakeup' = _, Waiter ! machine(idle_wait(Wakeup'), _Ok), Waiting' = true, Record = [Now, end(PrefixedName1(RCId1, SENT_ARROW, CNId1)), end(PrefixedName2(RCId2, RECEIVED_ARROW, CNId2)) | Record'?], Debug ! done(Now, PId1(RCId1, CH1), PId2(RCId2, CH2)) | self; Wakeup =?= true, Cutoff =?= {CutoffLimit, CutoffStatus}, read_vector(OBJECT_VALUES, SpiTime, Now) : Waiting = _, Wakeup' = _, Waiting' = false, Idle = idle(Now), Record ! Idle, Debug ! Idle, CutoffStatus ! Idle, Cutoff' = {CutoffLimit, CutoffStatus'} | self; Cutoff = {CutoffLimit, CutoffStatus}, read_vector(OBJECT_VALUES, SpiTime, Now), Now >= CutoffLimit, info(REALTIME, End_real_time), Real_time := End_real_time - Start_real_time : BasedAnchor = _, InstantaneousAnchor = _, MathOffset = _, Schedule = _, Scheduler = _, Waiting = _, Wakeup = _, Waiter = [machine(idle_wait(Done), _Ok)], Record = [], Debug = [], CutoffStatus = (done @ Now: seconds = Real_time) | computation # display(CutoffStatus), wait_done. /* * Supply default actions for selected requests. * (Could improve (?) close(...) to actually close the channels.) */ wait_done(Schedule, DefaultWeighter, Randomize, SpiOffsets, Ordinal, Done, SpiTime) :- DUMMY_CHANNEL(new_channel(ChannelName, Channel, _Rate)); DUMMY_CHANNEL(new_channel(ChannelName, Channel, _Weight, _Rate)); DUMMY_CHANNEL(new_public_channel(ChannelName, Channel, _Weight, _Rate)); Schedule ? close(_, Reply) : Reply = [] | self; Schedule ? default_weighter(Weighter), arg(SPI_INDEX, SpiOffsets, SpiOffset), SpiOffset =\= unbound | reset_default_weighter(SpiOffset, Weighter, DefaultWeighter, DefaultWeighter'), self; Schedule ? diagnostic(_) | self; Schedule ? randomize(NewRandomize), Randomize' := NewRandomize /\ SPI_RANDOM_FLAG : Randomize = _ | self; Schedule ? Other, Other =\= close(_, _), Other =\= default_weighter(_), Other =\= diagnostic(_), Other =\= randomize(_), Other =\= new_channel(_, _, _), Other =\= new_channel(_, _, _, _), Other =\= new_public_channel(_, _, _, _) | self; unknown(Schedule), known(Done) : Schedule' = [] | self; Schedule =?= [] : Done = _, close_vector(OBJECT_REQUESTS, SpiTime) | self#reset(DefaultWeighter, Randomize, SpiOffsets, Ordinal). continue_waiting(Schedule, MathOffset, Ordinal, SpiOffsets, Waiter, Scheduler, Record, Debug, SpiTime, Waiting, Wakeup, DefaultWeighter, Randomize, Cutoff, Start_real_time, BasedAnchor, InstantaneousAnchor, Reply) :- /* Reply for spifcp transmission */ Reply =?= true(PId1, RCId1, CH1, PId2, RCId2, CH2), PId1 =\= (_ : _), PId2 =\= (_ : _), tuple(PId1), arg(1, PId1, PName1), tuple(PId2), arg(1, PId2, PName2), read_vector(OBJECT_VALUES, SpiTime, Now), read_vector(SPI_CHANNEL_NAME, CH1, CNId1), read_vector(SPI_CHANNEL_NAME, CH2, CNId2) : Record = [Now, end(PName1(RCId1, SENT_ARROW, CNId1)), end(PName2(RCId2, RECEIVED_ARROW, CNId2)) | Record'?], Debug ! done(Now, PId1(RCId1, CH1), PId2(RCId2, CH2)) | scheduling; /* Reply for biospi transmission */ Reply =?= true(PId1, RCId1, CH1, PId2, RCId2, CH2), PId1 = (Prefix1 : SId1), arg(1, SId1, PName1), string_to_dlist(PName1, PNL1, []), string_to_dlist(Prefix1, PX1, [CHAR_COLON | PNL1]), list_to_string(PX1, PrefixedName1), PId2 = (Prefix2 : SId2), arg(1, SId2, PName2), string_to_dlist(PName2, PNL2, []), string_to_dlist(Prefix2, PX2, [CHAR_COLON | PNL2]), list_to_string(PX2, PrefixedName2), read_vector(OBJECT_VALUES, SpiTime, Now), read_vector(SPI_CHANNEL_NAME, CH1, CNId1), read_vector(SPI_CHANNEL_NAME, CH2, CNId2) : Record = [Now, end(PrefixedName1(RCId1, SENT_ARROW, CNId1)), end(PrefixedName2(RCId2, RECEIVED_ARROW, CNId2)) | Record'?], Debug ! done(Now, PId1(RCId1, CH1), PId2(RCId2, CH2)) | scheduling; otherwise, Reply =\= true : Debug ! Reply | fail(continue_waiting - Reply), scheduling; Waiting =?= true, Reply =?= true : Debug ! ("Waiting = true, Reply = true, Wakeup" = Wakeup)| scheduling; Waiting =\= true, Reply =?= true : Wakeup = _, Waiter ! machine(idle_wait(Wakeup'), _Ok), Waiting' = true, Debug ! ("Reply = true", "Waiting" = Waiting, "Wakeup'" = Wakeup') | scheduling; /* check for paused. */ Reply =?= true, unknown(Waiting) : Debug ! ("Reply = true, unknown(Waiting), Waiting" = Waiting) | scheduling. pause_scheduling(Continue, Schedule, ResetSchedule, Waiting, ResetWaiting, Wakeup, ResetWakeup, Start_real_time, Reset_real_time) :- info(REALTIME, Pause_real_time), Biased_real_time := Start_real_time + Pause_real_time : SavedInput = SaveInput? | pause_continue. pause_continue(Continue, Schedule, ResetSchedule, Waiting, ResetWaiting, Wakeup, ResetWakeup, Biased_real_time, Reset_real_time, SavedInput, SaveInput) :- Schedule ? Input, Input =?= status(Status) : Status ! pausing, ResetSchedule ! status(Status') | self; Schedule ? Input, Input =\= status(_), unknown(Continue) : SaveInput ! Input | self; Schedule =?= [], unknown(Continue) : SavedInput = _, SavedInput' = [], Continue' = resume | self; Continue = step(Continue') : SaveInput ! pause(Continue'), Continue'' = resume | self; Continue =?= resume, info(REALTIME, Resume_real_time), Reset_real_time^ := Biased_real_time - Resume_real_time : ResetSchedule = SavedInput, SaveInput = Schedule, ResetWaiting = Waiting, Wakeup = ResetWakeup. index_channel_name(Name, Ordinal, Name', Ordinal') :- unknown(Name) : Name' = Name, Ordinal' = Ordinal; /* Transitional */ string(Name), string_to_dlist(Name, CS1, []), /* "public" for spifcp */ string_to_dlist("public.", CS2, _Tail) : CS1 = CS2, Ordinal' = Ordinal, Name' = Name; string(Name), string_to_dlist(Name, CS1, []), /* "public" for biospi */ string_to_dlist("public.", CS2, _Tail) : CS1 = CS2, Ordinal' = Ordinal, Name' = Name; /* drop - also next otherwise */ string(Name), otherwise, integer(Ordinal), Ordinal'^ := Ordinal + 1 : Name' = Name(Ordinal); string(Name), otherwise, real(Ordinal), Ordinal'^ := Ordinal + 0.000001 : Name' = Name(Ordinal); otherwise : Name' = Name, Ordinal' = Ordinal. spifunctions(List, SpiOffset, Close, Post, Step, Index, Rate) :- List ? CHAR_c : Close = SpiOffset? | self; List ? CHAR_p : Post = SpiOffset? | self; List ? CHAR_s : Step = SpiOffset? | self; List ? CHAR_i : Index = SpiOffset? | self; List ? CHAR_r : Rate = SpiOffset? | self; List ? Other, otherwise, list_to_string([CHAR_DOUBLE_QUOTE,Other,CHAR_DOUBLE_QUOTE], String) | fail(not_a_function - String), self; string(List), string_to_dlist(List, List', []) | self; List =?= [] : SpiOffset = _ | unify_without_failure(unbound, Close), unify_without_failure(unbound, Post), unify_without_failure(unbound, Step), unify_without_failure(unbound, Index), unify_without_failure(unbound, Rate); otherwise : List' = [] | fail(not_a_function(List)), self. new_channel(ChannelName, Channel, BaseRate, ComputeWeight, Randomize, Reply, Scheduler, BasedAnchor, InstantaneousAnchor, SpiOffsets) :- we(Channel), bitwise_or(SPI_UNKNOWN, Randomize, ChannelType), arg(SPI_INDEX, SpiOffsets, SpiOffset), SpiOffset =\= unbound, arg(1, ComputeWeight, WeighterName) : execute(SpiOffset, {SPI_INDEX, WeighterName, WeighterIndex, Result}), make_vector(CHANNEL_SIZE, Channel, _), store_vector(SPI_BLOCKED, FALSE, Channel), store_vector(SPI_CHANNEL_TYPE, ChannelType, Channel), store_vector(SPI_CHANNEL_RATE, 0.0, Channel), store_vector(SPI_CHANNEL_REFS, 1, Channel), store_vector(SPI_SEND_ANCHOR, SendAnchor, Channel), make_vector(2, LinksS, _), SendAnchor = {SPI_MESSAGE_ANCHOR, "", [], 0, 0, 0, [], LinksS, []}, store_vector(SPI_NEXT_MS, SendAnchor, LinksS), store_vector(SPI_PREVIOUS_MS, SendAnchor, LinksS), store_vector(SPI_SEND_WEIGHT, 0, Channel), store_vector(SPI_RECEIVE_ANCHOR, ReceiveAnchor, Channel), make_vector(2, LinksR, _), ReceiveAnchor = {SPI_MESSAGE_ANCHOR, "", [], 0, 0, 0, [], LinksR, []}, store_vector(SPI_NEXT_MS, ReceiveAnchor, LinksR), store_vector(SPI_PREVIOUS_MS, ReceiveAnchor, LinksR), store_vector(SPI_RECEIVE_WEIGHT, 0, Channel), store_vector(SPI_WEIGHT_TUPLE, WeighterTuple?, Channel), store_vector(SPI_NEXT_CHANNEL, Channel, Channel), store_vector(SPI_PREVIOUS_CHANNEL, Channel, Channel), store_vector(SPI_CHANNEL_NAME, ChannelName, Channel) | complete_weighter_tuple(Result, ComputeWeight, WeighterIndex, WeighterTuple, Result'), based_or_instantaneous; we(Channel), bitwise_or(SPI_UNKNOWN, Randomize, ChannelType), arg(SPI_INDEX, SpiOffsets, unbound), ComputeWeight =?= SPI_DEFAULT_WEIGHT_NAME(_) : make_vector(CHANNEL_SIZE, Channel, _), store_vector(SPI_BLOCKED, FALSE, Channel), store_vector(SPI_CHANNEL_TYPE, ChannelType, Channel), store_vector(SPI_CHANNEL_RATE, 0.0, Channel), store_vector(SPI_CHANNEL_REFS, 1, Channel), store_vector(SPI_SEND_ANCHOR, SendAnchor, Channel), make_vector(2, LinksS, _), SendAnchor = {SPI_MESSAGE_ANCHOR, "", [], 0, 0, 0, [], LinksS, []}, store_vector(SPI_NEXT_MS, SendAnchor, LinksS), store_vector(SPI_PREVIOUS_MS, SendAnchor, LinksS), store_vector(SPI_SEND_WEIGHT, 0, Channel), store_vector(SPI_RECEIVE_ANCHOR, ReceiveAnchor, Channel), make_vector(2, LinksR, _), ReceiveAnchor = {SPI_MESSAGE_ANCHOR, "", [], 0, 0, 0, [], LinksR, []}, store_vector(SPI_NEXT_MS, ReceiveAnchor, LinksR), store_vector(SPI_PREVIOUS_MS, ReceiveAnchor, LinksR), store_vector(SPI_RECEIVE_WEIGHT, 0, Channel), store_vector(SPI_WEIGHT_TUPLE, SPI_DEFAULT_WEIGHT_NAME(SPI_DEFAULT_WEIGHT_INDEX), Channel), store_vector(SPI_NEXT_CHANNEL, Channel, Channel), store_vector(SPI_PREVIOUS_CHANNEL, Channel, Channel), store_vector(SPI_CHANNEL_NAME, ChannelName, Channel) | based_or_instantaneous + (Result = true); otherwise : BasedAnchor = _, InstantaneousAnchor = _, Randomize = _, Scheduler = _, SpiOffsets = _, Reply = error(new_channel(ChannelName, Channel, BaseRate, ComputeWeight)). based_or_instantaneous(ChannelName, BaseRate, Result, Scheduler, Reply, Channel, BasedAnchor, InstantaneousAnchor) :- Result =?= true, BaseRate =?= infinite : BasedAnchor = _, store_vector(SPI_CHANNEL_TYPE, SPI_INSTANTANEOUS, Channel), Reply = Result, DEBUG((ChannelName: instantaneous)) | queue_channel(Channel, InstantaneousAnchor); Result =?= true, convert_to_real(BaseRate, RealRate), RealRate =< 0.0 : BasedAnchor = _, InstantaneousAnchor = _, store_vector(SPI_CHANNEL_TYPE, SPI_SINK, Channel), Reply = true, DEBUG((ChannelName: sink(unnatural(BaseRate)))); Result =?= true, convert_to_real(BaseRate, RealRate), RealRate > 0.0 : InstantaneousAnchor = _, store_vector(SPI_CHANNEL_RATE, RealRate, Channel), Reply = Result, DEBUG((ChannelName: based_channel)) | queue_channel(Channel, BasedAnchor); Result =?= true, otherwise : BasedAnchor = _, Channel = _, InstantaneousAnchor = _, Scheduler = _, store_vector(SPI_CHANNEL_TYPE, SPI_SINK, Channel), Reply = "invalid base rate"(ChannelName - BaseRate), DEBUG((ChannelName: sink(invalid(BaseRate)))); Result =\= true : BasedAnchor = _, BaseRate = _, Channel = _, ChannelName = _, InstantaneousAnchor = _, Scheduler = _, store_vector(SPI_CHANNEL_TYPE, SPI_SINK, Channel), Reply = Result, DEBUG((ChannelName : sink(Result))). complete_weighter_tuple(Reply, ComputeWeight, WeighterIndex, WeighterTuple, Reply1) :- Reply = true, arg(2, ComputeWeight, Index) : Index = WeighterIndex, WeighterTuple = ComputeWeight, Reply1 = Reply; Reply = true, otherwise : WeighterIndex = _, WeighterTuple = SPI_DEFAULT_WEIGHT_NAME(SPI_DEFAULT_WEIGHT_INDEX), Reply1 = Reply | fail(invalid_weighter_index(ComputeWeight)); Reply =\= true : ComputeWeight = _, WeighterIndex = _, WeighterTuple = SPI_DEFAULT_WEIGHT_NAME(SPI_DEFAULT_WEIGHT_INDEX), Reply1 = Reply. queue_channel(Channel, Anchor) :- read_vector(SPI_PREVIOUS_CHANNEL, Anchor, OldPrevious) : store_vector(SPI_PREVIOUS_CHANNEL, OldPrevious, Channel), store_vector(SPI_NEXT_CHANNEL, Anchor, Channel), store_vector(SPI_NEXT_CHANNEL, Channel, OldPrevious), store_vector(SPI_PREVIOUS_CHANNEL, Channel, Anchor). reset_default_weighter(SpiOffset, New, Old, Default) :- string(New) : execute(SpiOffset, {SPI_INDEX, New, Index, Reply}) | check_new_default + (New = New(_)); tuple(New), arg(1, New, Name) : execute(SpiOffset, {SPI_INDEX, Name, Index, Reply}) | check_new_default; otherwise : SpiOffset = _, Default = Old | fail(invalid_new_default_weighter(New)). check_new_default(Reply, Index, New, Old, Default) :- Reply =?= true, arg(2, New, Ix) : Old = _, Ix = Index, Default = New; Reply =?= true, otherwise : Default = Old | fail(mismatch_new_default_weighter_index(New - Index)); Reply =\= true : Index = _, Default = Old | fail(Reply(New)). /************************* execute - testing *********************************/ execute_post(MathOffset, PostId, OpList, Value, Chosen, Reply) :- true : Common = {PostId, Messages, Value, Chosen}, Messages = AddMessages? | post_pass0(OpList, Instantaneous, 0, Count, Ok), post_pass1, post_pass2. execute_close(Channels, Reply) :- tuple(Channels), N := arity(Channels) | close_channels(Channels, N, Reply). /************************** close procedures *********************************/ close_channels(Channels, N, Reply) :- N > 0, arg(N, Channels, Channel), N--, vector(Channel), read_vector(SPI_CHANNEL_REFS, Channel, Refs), Refs--, Refs' > 0 : store_vector(SPI_CHANNEL_REFS, Refs', Channel) | self; N > 0, arg(N, Channels, Channel), N--, vector(Channel), read_vector(SPI_CHANNEL_REFS, Channel, Refs), Refs--, Refs' =:= 0, read_vector(SPI_NEXT_CHANNEL, Channel, Next), read_vector(SPI_PREVIOUS_CHANNEL, Channel, Previous) : store_vector(SPI_CHANNEL_REFS, 0, Channel), store_vector(SPI_NEXT_CHANNEL, Next, Previous), store_vector(SPI_PREVIOUS_CHANNEL, Previous, Next), store_vector(SPI_NEXT_CHANNEL, Channel, Channel), store_vector(SPI_PREVIOUS_CHANNEL, Channel, Channel), Reply ! N | self; N > 0, arg(N, Channels, Channel), N--, vector(Channel), read_vector(SPI_CHANNEL_REFS, Channel, Refs), Refs--, Refs' < 0 : Reply = "Error - Problem in ReferenceCount"(Channel), Reply' = _ | self; N =< 0 : Channels = _, Reply = []; otherwise : Reply = close_failed(N, Channels). /************************ post procedures ********************************/ post_pass0(OpList, Instantaneous, Number, Count, Ok) :- OpList ? Operation, arg(SPI_MS_MULTIPLIER, Operation, Multiplier), integer(Multiplier), Multiplier > 0, arg(SPI_MS_CHANNEL, Operation, Channel), read_vector(SPI_CHANNEL_TYPE, Channel, ChannelType), bitwise_and(ChannelType, SPI_TYPE_MASK, SPI_INSTANTANEOUS), Number++ : Instantaneous ! Operation | self; OpList ? Operation, arg(SPI_MS_MULTIPLIER, Operation, Multiplier), integer(Multiplier), Multiplier > 0, arg(SPI_MS_CHANNEL, Operation, Channel), read_vector(SPI_CHANNEL_TYPE, Channel, ChannelType), bitwise_and(ChannelType, SPI_TYPE_MASK, SPI_BIMOLECULAR) | self; OpList ? Operation, arg(SPI_MS_MULTIPLIER, Operation, Multiplier), integer(Multiplier), Multiplier > 0, arg(SPI_MS_CHANNEL, Operation, Channel), read_vector(SPI_CHANNEL_TYPE, Channel, ChannelType), bitwise_and(ChannelType, SPI_TYPE_MASK, SPI_HOMODIMERIZED) | self; OpList ? Operation, arg(SPI_MS_MULTIPLIER, Operation, Multiplier), integer(Multiplier), Multiplier > 0, arg(SPI_MS_CHANNEL, Operation, Channel), read_vector(SPI_CHANNEL_TYPE, Channel, ChannelType), bitwise_and(ChannelType, SPI_TYPE_MASK, SPI_UNKNOWN), arg(SPI_MS_TYPE, Operation, MessageType), read_vector(SPI_WEIGHT_TUPLE, Channel, WeightTuple), arg(2, WeightTuple, Index), bitwise_and(ChannelType, SPI_RANDOM_FLAG, RandomFlag) : store_vector(SPI_CHANNEL_TYPE, FinalType, Channel) | update_channel_type, self; OpList =?= [] : Count = Number, Instantaneous = [], Ok = true; otherwise | post_pass0_skip. update_channel_type(Index, MessageType, RandomFlag, FinalType) :- Index =?= SPI_DEFAULT_WEIGHT_INDEX, MessageType =\= SPI_DIMER, bitwise_or(SPI_BIMOLECULAR, RandomFlag, ChannelType) : FinalType = ChannelType; Index =?= SPI_DEFAULT_WEIGHT_INDEX, MessageType =?= SPI_DIMER, bitwise_or(SPI_HOMODIMERIZED, RandomFlag, ChannelType) : FinalType = ChannelType; Index =\= SPI_DEFAULT_WEIGHT_INDEX, MessageType =\= SPI_DIMER, bitwise_or(SPI_BIMOLECULAR_PRIME, RandomFlag, ChannelType) : FinalType = ChannelType; Index =\= SPI_DEFAULT_WEIGHT_INDEX, MessageType =?= SPI_DIMER, bitwise_or(SPI_HOMODIMERIZED_PRIME, RandomFlag, ChannelType) : FinalType = ChannelType. post_pass0_skip(OpList, Instantaneous, Number, Count, Ok) :- OpList ? Operation, arg(SPI_MS_MULTIPLIER, Operation, Multiplier), integer(Multiplier), Multiplier =< 0 | post_pass0; OpList ? Operation, arg(SPI_MS_CHANNEL, Operation, Channel), read_vector(SPI_CHANNEL_TYPE, Channel, ChannelType), bitwise_and(ChannelType, SPI_TYPE_MASK, SPI_SINK) | post_pass0; otherwise : Count = Number, Instantaneous = [], Ok = invalid_transmission - OpList. post_pass1(MathOffset, Common, Instantaneous, Count, Ok, Ok1) :- Ok = true, Count-- =:= 1, Instantaneous ? Operation, Instantaneous' =?= [], arg(SPI_MS_CHANNEL, Operation, Channel), read_vector(SPI_CHANNEL_TYPE, Channel, ChannelType^) | post_instantaneous; Ok = true, Count-- > 1, Decrement := real(1)/Count : execute(MathOffset, {RAN, 0, Uniform}) | choose_instantaneous_operation(Uniform, Decrement, Instantaneous, Instantaneous', Operation, Channel, ChannelType), post_instantaneous; otherwise : Common = _, Count = _, Instantaneous = _, MathOffset = _, Ok1 = Ok . choose_instantaneous_operation(Uniform, Decrement, I1, I2, Operation, Channel, ChannelType) :- I1 ? Op, I1' =\= [], Uniform > Decrement, Uniform -= Decrement : I2 ! Op | self; I1 ? Op, otherwise, arg(SPI_MS_CHANNEL, Op, Ch), read_vector(SPI_CHANNEL_TYPE, Ch, CT) : Decrement = _, Uniform = _, Channel = Ch, ChannelType = CT, I2 = I1', Operation = Op. post_pass2(OpList, Reply, Common, Messages, AddMessages, Ok1) :- Ok1 =?= true, OpList ? Operation, arg(SPI_MS_CHANNEL, Operation, Channel), read_vector(SPI_CHANNEL_TYPE, Channel, Type), Type =\= SPI_SINK, arg(SPI_MS_MULTIPLIER, Operation, Multiplier), Multiplier > 0, arg(SPI_MS_TYPE, Operation, MessageType), arg(SPI_MS_CID, Operation, RCId), arg(SPI_MS_TAGS, Operation, Tags), arity(Operation) =:= SPI_MS_SIZE : AddMessages ! Message? | queue_message + (Ambient = []), self; Ok1 =?= true, OpList ? Operation, arg(SPI_MS_CHANNEL, Operation, Channel), read_vector(SPI_CHANNEL_TYPE, Channel, Type), Type =\= SPI_SINK, arg(SPI_MS_MULTIPLIER, Operation, Multiplier), Multiplier > 0, arg(SPI_MS_TYPE, Operation, MessageType), arg(SPI_MS_CID, Operation, RCId), arg(SPI_MS_TAGS, Operation, Tags), arity(Operation) =:= SPI_AMBIENT_MS_SIZE, arg(SPI_MS_AMBIENT, Operation, Ambient) : AddMessages ! Message? | queue_message, self; Ok1 =?= true, OpList ? Operation, arg(SPI_MS_CHANNEL, Operation, Channel), read_vector(SPI_CHANNEL_TYPE, Channel, Type), Type =\= SPI_SINK, arg(SPI_MS_MULTIPLIER, Operation, Multiplier), Multiplier =< 0 | self; Ok1 =?= true, OpList ? Operation, arg(SPI_MS_CHANNEL, Operation, Channel), read_vector(SPI_CHANNEL_TYPE, Channel, Type), Type =?= SPI_SINK | self; Ok1 =?= true, OpList =?= [] : Common = _, Messages = _, AddMessages = [], Reply = true; otherwise : Common = _, Messages = _, OpList = _, Reply = Ok1, AddMessages = []. /* * Suffix Q refers to a channel queue element. * Suffix R refers to a message request element. */ post_instantaneous(MathOffset, Common, Instantaneous, Count, Ok1, Operation, Channel, ChannelType) :- arity(Operation) =:= SPI_MS_SIZE, bitwise_and(ChannelType, SPI_RANDOM_FLAG, 0), arg(SPI_MS_TYPE, Operation, SPI_SEND), read_vector(SPI_RECEIVE_ANCHOR, Channel, EndR), arg(SPI_MESSAGE_LINKS, EndR, MessageLinks), read_vector(SPI_NEXT_MS, MessageLinks, Message) | do_instantaneous_transmit + (MTX = SPI_RECEIVE_TAG, Ambient = []); arity(Operation) =:= SPI_MS_SIZE, bitwise_and(ChannelType, SPI_RANDOM_FLAG, 0), arg(SPI_MS_TYPE, Operation, SPI_RECEIVE), read_vector(SPI_SEND_ANCHOR, Channel, EndR), arg(SPI_MESSAGE_LINKS, EndR, MessageLinks), read_vector(SPI_NEXT_MS, MessageLinks, Message) | do_instantaneous_transmit + (MTX = SPI_SEND_TAG, Ambient = []); arity(Operation) =:= SPI_MS_SIZE, bitwise_and(ChannelType, SPI_RANDOM_FLAG, SPI_RANDOM_FLAG), arg(SPI_MS_TYPE, Operation, SPI_SEND), read_vector(SPI_RECEIVE_ANCHOR, Channel, Anchor), read_vector(SPI_RECEIVE_WEIGHT, Channel, Weight) : execute(MathOffset, {RAN, 0, Uniform}) | post_instantaneous_random + (MTX = SPI_RECEIVE_TAG, Ambient = []); arity(Operation) =:= SPI_MS_SIZE, bitwise_and(ChannelType, SPI_RANDOM_FLAG, SPI_RANDOM_FLAG), arg(SPI_MS_TYPE, Operation, SPI_RECEIVE), read_vector(SPI_SEND_ANCHOR, Channel, Anchor), read_vector(SPI_SEND_WEIGHT, Channel, Weight) : execute(MathOffset, {RAN, 0, Uniform}) | post_instantaneous_random + (MTX = SPI_SEND_TAG, Ambient = []); arity(Operation) =:= SPI_AMBIENT_MS_SIZE, arg(SPI_MS_AMBIENT, Operation, Ambient), bitwise_and(ChannelType, SPI_RANDOM_FLAG, 0), arg(SPI_MS_TYPE, Operation, SPI_SEND), read_vector(SPI_RECEIVE_ANCHOR, Channel, EndR), arg(SPI_MESSAGE_LINKS, EndR, MessageLinks), read_vector(SPI_NEXT_MS, MessageLinks, Message) | do_instantaneous_transmit + (MTX = SPI_RECEIVE_TAG); arity(Operation) =:= SPI_AMBIENT_MS_SIZE, arg(SPI_MS_AMBIENT, Operation, Ambient), bitwise_and(ChannelType, SPI_RANDOM_FLAG, 0), arg(SPI_MS_TYPE, Operation, SPI_RECEIVE), read_vector(SPI_SEND_ANCHOR, Channel, EndR), arg(SPI_MESSAGE_LINKS, EndR, MessageLinks), read_vector(SPI_NEXT_MS, MessageLinks, Message) | do_instantaneous_transmit + (MTX = SPI_SEND_TAG); arity(Operation) =:= SPI_AMBIENT_MS_SIZE, arg(SPI_MS_AMBIENT, Operation, Ambient), bitwise_and(ChannelType, SPI_RANDOM_FLAG, SPI_RANDOM_FLAG), arg(SPI_MS_TYPE, Operation, SPI_SEND), read_vector(SPI_RECEIVE_ANCHOR, Channel, Anchor), read_vector(SPI_RECEIVE_WEIGHT, Channel, Weight) : execute(MathOffset, {RAN, 0, Uniform}) | post_instantaneous_random + (MTX = SPI_RECEIVE_TAG); arity(Operation) =:= SPI_AMBIENT_MS_SIZE, arg(SPI_MS_AMBIENT, Operation, Ambient), bitwise_and(ChannelType, SPI_RANDOM_FLAG, SPI_RANDOM_FLAG), arg(SPI_MS_TYPE, Operation, SPI_RECEIVE), read_vector(SPI_SEND_ANCHOR, Channel, Anchor), read_vector(SPI_SEND_WEIGHT, Channel, Weight) : execute(MathOffset, {RAN, 0, Uniform}) | post_instantaneous_random + (MTX = SPI_SEND_TAG); otherwise : Channel = _, ChannelType = _, Common = _, Count = _, Instantaneous = _, MathOffset = _, Ok1 = invalid_transmission - Operation. post_instantaneous_random(MathOffset, Common, Instantaneous, Count, Ok1, Operation, MTX, Ambient, Anchor, Uniform, Weight) :- Select := Uniform*Weight | choose_random_start(Anchor, Select, Message), do_instantaneous_transmit + (EndR = Message). do_instantaneous_transmit(MathOffset, Common, Instantaneous, Count, Ok1, Operation, MTX, Ambient, EndR, Message) :- arg(SPI_MS_CID, Message, RCIdQ), arg(SPI_MS_CHANNEL, Message, ChannelQ), arg(SPI_COMMON, Message, CommonQ), arg(MTX, Message, MessageTag), CommonQ = {PIdQ, MsList, ValueQ, ChosenQ}, Common = {PIdR, _MsList, ValueR, ChosenR}, arg(SPI_MS_CID, Operation, RCIdR), arg(SPI_MS_CHANNEL, Operation, ChannelR), arg(SPI_MS_TAGS, Operation, OperationTag), Ambient =?= [] : Count = _, EndR = _, Instantaneous = _, MathOffset = _, ValueQ = ValueR, ChosenQ = MessageTag, ChosenR = OperationTag, Ok1 = true(PIdQ, RCIdQ, ChannelQ, PIdR, RCIdR, ChannelR) | discount(MsList); arg(SPI_MS_CID, Message, RCIdQ), arg(SPI_MS_CHANNEL, Message, ChannelQ), arg(SPI_COMMON, Message, CommonQ), arg(MTX, Message, MessageTag), CommonQ = {PIdQ, MsList, ValueQ, ChosenQ}, Common = {PIdR, _MsList, ValueR, ChosenR}, arg(SPI_MS_CID, Operation, RCIdR), arg(SPI_MS_CHANNEL, Operation, ChannelR), arg(SPI_MS_TAGS, Operation, OperationTag), Ambient =\= [], arg(SPI_AMBIENT_CHANNEL, Message, AmbientQ), Ambient =\= AmbientQ : Count = _, EndR = _, Instantaneous = _, MathOffset = _, ValueQ = ValueR, ChosenQ = MessageTag, ChosenR = OperationTag, Ok1 = true(PIdQ, RCIdQ, ChannelQ, PIdR, RCIdR, ChannelR) | discount(MsList); Ambient =\= [], arg(SPI_AMBIENT_CHANNEL, Message, AmbientQ), Ambient =?= AmbientQ, arg(SPI_MESSAGE_LINKS, Message, MessageLinks), read_vector(SPI_NEXT_MS, MessageLinks, Message'), Message' =\= EndR | self; Ambient =\= [], arg(SPI_AMBIENT_CHANNEL, Message, AmbientQ), Ambient =?= AmbientQ, arg(SPI_MESSAGE_LINKS, Message, MessageLinks), read_vector(SPI_NEXT_MS, MessageLinks, Message'), Message' =?= EndR : Operation = _, MTX = _ | post_pass1 + (Ok = true); arg(SPI_COMMON, Message, CommonQ), arg(SPI_OP_CHOSEN, CommonQ, Chosen), not_we(Chosen), arg(SPI_MESSAGE_LINKS, Message, MessageLinks), read_vector(SPI_NEXT_MS, MessageLinks, Message'), Message' =\= EndR | self; arg(SPI_MS_TYPE, Message, SPI_MESSAGE_ANCHOR), arg(SPI_MESSAGE_LINKS, Message, MessageLinks), read_vector(SPI_NEXT_MS, MessageLinks, Message'), Message' =\= EndR | self; arg(SPI_MS_TYPE, Message, SPI_MESSAGE_ANCHOR), arg(SPI_MESSAGE_LINKS, Message, MessageLinks), read_vector(SPI_NEXT_MS, MessageLinks, Message'), Message' =?= EndR : Ambient = _, Operation = _, MTX = _ | post_pass1 + (Ok = true); % This can happen (to the monitor). Common = {_, _, _, Chosen}, not_we(Chosen) : Ambient = _, EndR = _, Operation = _, Message = _, MTX = _ | post_pass1 + (Ok = true); % This Message has the same Chosen as the Operation - % mixed communications which ARE NOT homodimerized. arg(SPI_COMMON, Message, CommonQ), CommonQ = {_, _, _, Chosen}, Common = {_, _, _, Chosen}, arg(SPI_MESSAGE_LINKS, Message, MessageLinks), read_vector(SPI_NEXT_MS, MessageLinks, Message'), Message' =\= EndR | self; arg(SPI_COMMON, Message, CommonQ), CommonQ = {_, _, _, Chosen}, Common = {_, _, _, Chosen}, arg(SPI_MESSAGE_LINKS, Message, MessageLinks), read_vector(SPI_NEXT_MS, MessageLinks, Message'), Message' =?= EndR : Ambient = _, Operation = _, MTX = _ | post_pass1 + (Ok = true). /*************************** step procedures *********************************/ sum_weights(Channel, RateOffset, Sum, Total) :- read_vector(SPI_NEXT_CHANNEL, Channel, Channel'), vector(Channel'), read_vector(SPI_CHANNEL_TYPE, Channel', Type), Type =?= SPI_CHANNEL_ANCHOR : RateOffset = _, Total = Sum; read_vector(SPI_NEXT_CHANNEL, Channel, Channel'), vector(Channel'), read_vector(SPI_BLOCKED, Channel', Blocked), Blocked =?= FALSE, read_vector(SPI_CHANNEL_TYPE, Channel', Type), bitwise_and(Type, SPI_PRIME_MASK, SPI_BIMOLECULAR), read_vector(SPI_CHANNEL_RATE, Channel', Rate), read_vector(SPI_SEND_WEIGHT, Channel', SendWeight), read_vector(SPI_RECEIVE_WEIGHT, Channel', ReceiveWeight), Sum += Rate*SendWeight*ReceiveWeight | self; read_vector(SPI_NEXT_CHANNEL, Channel, Channel'), vector(Channel'), read_vector(SPI_BLOCKED, Channel', Blocked), Blocked =?= FALSE, read_vector(SPI_CHANNEL_TYPE, Channel', Type), bitwise_and(Type, SPI_PRIME_MASK, SPI_HOMODIMERIZED), read_vector(SPI_DIMER_ANCHOR, Channel', Anchor), arg(SPI_MESSAGE_LINKS, Anchor, FirstLink), read_vector(SPI_NEXT_MS, FirstLink, Message), arg(SPI_MESSAGE_LINKS, Message, DimerLink), read_vector(SPI_NEXT_MS, DimerLink, DimerMs), arg(SPI_MS_TYPE, DimerMs, MsType), MsType =\= SPI_MESSAGE_ANCHOR, read_vector(SPI_CHANNEL_RATE, Channel', Rate), read_vector(SPI_DIMER_WEIGHT, Channel', DimerWeight), Sum += Rate*DimerWeight*(DimerWeight-1)/2 | self; read_vector(SPI_NEXT_CHANNEL, Channel, Channel'), vector(Channel'), read_vector(SPI_BLOCKED, Channel', Blocked), Blocked =?= FALSE, read_vector(SPI_CHANNEL_TYPE, Channel', Type), bitwise_and(Type, SPI_PRIME_FLAG, SPI_PRIME_FLAG) : execute(RateOffset, {SPI_RATE, Channel', Addend, Reply}) | prime_weight_cumulate(Reply, Addend, Sum, Sum'), self; otherwise, vector(Channel), read_vector(SPI_NEXT_CHANNEL, Channel, Channel'), vector(Channel') | self. prime_weight_cumulate(Reply, Addend, Sum, Cumulated) :- Reply =?= true, Sum += Addend : Cumulated = Sum'. logix_total(MathOffset, Anchor, Now, Total, RateOffset, NewNow, Wakeup) :- Total =< 0 : Anchor = _, MathOffset = _, RateOffset = _, NewNow = Now, Wakeup = true; Total > 0 : execute(MathOffset, {RAN, 0, Uniform1}), execute(MathOffset, {RAN, 0, Uniform2}), execute(MathOffset, {LN, Uniform2, NegativeExponential}) | logix_transmit. logix_transmit(RateOffset, Anchor, Now, Total, Uniform1, Uniform2, NegativeExponential, NewNow, Wakeup) :- Residue := Uniform1*Total, NewNow^ := Now - NegativeExponential/Total | select_channel + (Channel = Anchor). select_channel(RateOffset, Residue, Channel, Uniform1, Uniform2, Wakeup) :- read_vector(SPI_NEXT_CHANNEL, Channel, Channel'), read_vector(SPI_BLOCKED, Channel', Blocked), Blocked =?= FALSE, read_vector(SPI_CHANNEL_TYPE, Channel', Type), bitwise_and(Type, SPI_PRIME_MASK, SPI_BIMOLECULAR), read_vector(SPI_CHANNEL_RATE, Channel', Rate), read_vector(SPI_SEND_WEIGHT, Channel', SendWeight), SendWeight > 0, read_vector(SPI_RECEIVE_WEIGHT, Channel', ReceiveWeight), ReceiveWeight > 0, Residue -= Rate*SendWeight*ReceiveWeight, Residue' =< 0 : RateOffset = _ | do_bimolecular_transmit; read_vector(SPI_NEXT_CHANNEL, Channel, Channel'), read_vector(SPI_BLOCKED, Channel', Blocked), Blocked =?= FALSE, read_vector(SPI_CHANNEL_TYPE, Channel', Type), bitwise_and(Type, SPI_PRIME_MASK, SPI_BIMOLECULAR), read_vector(SPI_CHANNEL_RATE, Channel', Rate), read_vector(SPI_SEND_WEIGHT, Channel', SendWeight), SendWeight > 0, read_vector(SPI_RECEIVE_WEIGHT, Channel', ReceiveWeight), ReceiveWeight > 0, Residue -= Rate*SendWeight*ReceiveWeight, Residue' > 0 | self; read_vector(SPI_NEXT_CHANNEL, Channel, Channel'), read_vector(SPI_BLOCKED, Channel', Blocked), Blocked =?= FALSE, read_vector(SPI_CHANNEL_TYPE, Channel', Type), bitwise_and(Type, SPI_PRIME_MASK, SPI_HOMODIMERIZED), read_vector(SPI_DIMER_ANCHOR, Channel', Anchor), arg(SPI_MESSAGE_LINKS, Anchor, FirstLink), read_vector(SPI_NEXT_MS, FirstLink, Message), arg(SPI_MESSAGE_LINKS, Message, DimerLink), read_vector(SPI_NEXT_MS, DimerLink, DimerMs), arg(SPI_MS_TYPE, DimerMs, MsType), MsType =\= SPI_MESSAGE_ANCHOR, read_vector(SPI_CHANNEL_RATE, Channel', Rate), read_vector(SPI_DIMER_WEIGHT, Channel', DimerWeight), Residue -= Rate*DimerWeight*(DimerWeight-1)/2, Residue' =< 0 : RateOffset = _ | do_homodimerized_transmit; read_vector(SPI_NEXT_CHANNEL, Channel, Channel'), read_vector(SPI_BLOCKED, Channel', Blocked), Blocked =?= FALSE, read_vector(SPI_CHANNEL_TYPE, Channel', Type), bitwise_and(Type, SPI_PRIME_MASK, SPI_HOMODIMERIZED), read_vector(SPI_DIMER_ANCHOR, Channel', Anchor), arg(SPI_MESSAGE_LINKS, Anchor, FirstLink), read_vector(SPI_NEXT_MS, FirstLink, Message), arg(SPI_MESSAGE_LINKS, Message, DimerLink), read_vector(SPI_NEXT_MS, DimerLink, DimerMs), arg(SPI_MS_TYPE, DimerMs, MsType), MsType =\= SPI_MESSAGE_ANCHOR, read_vector(SPI_CHANNEL_RATE, Channel', Rate), read_vector(SPI_DIMER_WEIGHT, Channel', DimerWeight), Residue -= Rate*DimerWeight*(DimerWeight-1)/2, Residue' > 0 | self; read_vector(SPI_NEXT_CHANNEL, Channel, Channel'), vector(Channel'), read_vector(SPI_BLOCKED, Channel', Blocked), Blocked =?= FALSE, read_vector(SPI_CHANNEL_TYPE, Channel', Type), bitwise_and(Type, SPI_PRIME_FLAG, SPI_PRIME_FLAG), bitwise_and(Type, SPI_PRIME_MASK, Type') : execute(RateOffset, {SPI_RATE, Channel', Subtrahend, Reply}) | prime_weight_decrement; read_vector(SPI_NEXT_CHANNEL, Channel, Channel'), otherwise | self. prime_weight_decrement(RateOffset, Residue, Channel, Uniform1, Uniform2, Wakeup, Type, Subtrahend, Reply) :- Reply = true, Subtrahend =< 0 : Type = _ | select_channel; Reply = true, Subtrahend > 0, Residue -= Subtrahend, Residue' > 0 : Type = _ | select_channel; Reply = true, Subtrahend > 0, Residue -= Subtrahend, Residue' =< 0, Type =?= SPI_BIMOLECULAR_PRIME : RateOffset = _ | do_bimolecular_transmit; Reply = true, Subtrahend > 0, Residue -= Subtrahend, Residue' =< 0, Type =?= SPI_HOMODIMERIZED_PRIME : RateOffset = _ | do_homodimerized_transmit. /****** based transmit - complete a transmission for a pair of messages ******/ do_bimolecular_transmit(Channel, Uniform1, Uniform2, Wakeup) :- read_vector(SPI_SEND_ANCHOR, Channel, SendAnchor), read_vector(SPI_RECEIVE_ANCHOR, Channel, ReceiveAnchor), read_vector(SPI_CHANNEL_TYPE, Channel, Type), bitwise_and(Type, SPI_RANDOM_FLAG, 0), arg(SPI_MESSAGE_LINKS, SendAnchor, SendLinks), read_vector(SPI_NEXT_MS, SendLinks, Send), arg(SPI_MESSAGE_LINKS, ReceiveAnchor, ReceiveLinks), read_vector(SPI_NEXT_MS, ReceiveLinks, Receive) : Uniform1 = _, Uniform2 = _ | do_bimolecular_send(Channel, Wakeup, Send, Send, Receive, Receive); read_vector(SPI_SEND_ANCHOR, Channel, SendAnchor), read_vector(SPI_RECEIVE_ANCHOR, Channel, ReceiveAnchor), read_vector(SPI_CHANNEL_TYPE, Channel, Type), bitwise_and(Type, SPI_RANDOM_FLAG, SPI_RANDOM_FLAG), read_vector(SPI_SEND_WEIGHT, Channel, SendWeight), SendSelect := Uniform1*SendWeight, read_vector(SPI_RECEIVE_WEIGHT, Channel, ReceiveWeight), ReceiveSelect := Uniform2*ReceiveWeight | choose_random_start(SendAnchor, SendSelect, StartS), choose_random_start(ReceiveAnchor, ReceiveSelect, StartR), do_bimolecular_send(Channel, Wakeup, StartS, StartS, StartR, StartR). do_bimolecular_send(Channel, Wakeup, Send, EndSend, Receive, EndReceive) :- arg(SPI_MS_TYPE, Send, SPI_SEND), arg(SPI_MS_CID, Send, SendRCId), arg(SPI_MS_CHANNEL, Send, SendChannel), arg(SPI_SEND_TAG, Send, SendTag), arg(SPI_COMMON, Send, SendCommon), arg(SPI_AMBIENT_CHANNEL, Send, []), arg(SPI_MS_TYPE, Receive, SPI_RECEIVE), arg(SPI_MS_CID, Receive, ReceiveRCId), arg(SPI_MS_CHANNEL, Receive, ReceiveChannel), arg(SPI_RECEIVE_TAG, Receive, ReceiveTag), arg(SPI_COMMON, Receive, ReceiveCommon), SendCommon =?= {SendPId, SendList, SendValue, SendChosen}, ReceiveCommon =?= {ReceivePId, ReceiveList, ReceiveValue, ReceiveChosen} : Channel = _, EndReceive = _, EndSend = _, SendChosen = SendTag, ReceiveChosen = ReceiveTag, ReceiveValue = SendValue?, Wakeup = true(SendPId, SendRCId, SendChannel, ReceivePId, ReceiveRCId, ReceiveChannel) | discount(SendList), discount(ReceiveList); arg(SPI_MS_TYPE, Send, SPI_SEND), arg(SPI_MS_CHANNEL, Send, SendChannel), arg(SPI_SEND_TAG, Send, SendTag), arg(SPI_MS_CID, Send, SendRCId), arg(SPI_COMMON, Send, SendCommon), arg(SPI_AMBIENT_CHANNEL, Send, SendAmbient), SendAmbient =\= [], arg(SPI_MS_TYPE, Receive, SPI_RECEIVE), arg(SPI_MS_CID, Receive, ReceiveRCId), arg(SPI_MS_CHANNEL, Receive, ReceiveChannel), arg(SPI_RECEIVE_TAG, Receive, ReceiveTag), arg(SPI_COMMON, Receive, ReceiveCommon), ReceiveCommon =?= {ReceivePId, ReceiveList, ReceiveValue, ReceiveChosen}, SendCommon =?= {SendPId, SendList, SendValue, SendChosen}, arg(SPI_AMBIENT_CHANNEL, Receive, ReceiveAmbient), SendAmbient =\= ReceiveAmbient : Channel = _, EndReceive = _, EndSend = _, SendChosen = SendTag, ReceiveChosen = ReceiveTag, ReceiveValue = SendValue?, Wakeup = true(SendPId, SendRCId, SendChannel, ReceivePId, ReceiveRCId, ReceiveChannel) | discount(SendList), discount(ReceiveList); arg(SPI_MS_TYPE, Send, SPI_SEND), arg(SPI_AMBIENT_CHANNEL, Send, SendAmbient), SendAmbient =\= [], arg(SPI_AMBIENT_CHANNEL, Receive, ReceiveAmbient), SendAmbient =?= ReceiveAmbient, arg(SPI_MESSAGE_LINKS, Send, SendLinks), read_vector(SPI_NEXT_MS, SendLinks, Send') | bimolecular_send_blocked; arg(SPI_MS_TYPE, Send, SPI_SEND), arg(SPI_COMMON, Send, SendCommon), arg(SPI_MESSAGE_LINKS, Send, SendLinks), arg(SPI_COMMON, Receive, ReceiveCommon), % This Send has the same Chosen as the Receive - % mixed communications which ARE NOT homodimerized. SendCommon =?= {_, _, _, Chosen}, ReceiveCommon =?= {_, _, _, Chosen}, read_vector(SPI_NEXT_MS, SendLinks, Send') | bimolecular_send_blocked; arg(SPI_MS_TYPE, Send, SPI_MESSAGE_ANCHOR), arg(SPI_MESSAGE_LINKS, Send, SendLinks), read_vector(SPI_NEXT_MS, SendLinks, Send'), Send' =\= EndSend | self; arg(SPI_MS_TYPE, Send, SPI_MESSAGE_ANCHOR), arg(SPI_MESSAGE_LINKS, Send, SendLinks), read_vector(SPI_NEXT_MS, SendLinks, Send'), Send' =?= EndSend, arg(SPI_MESSAGE_LINKS, Receive, ReceiveLinks), read_vector(SPI_NEXT_MS, ReceiveLinks, Receive'), Receive' =\= EndReceive, arg(SPI_MS_TYPE, Receive', SPI_RECEIVE) | self; arg(SPI_MS_TYPE, Send, SPI_MESSAGE_ANCHOR), arg(SPI_MESSAGE_LINKS, Send, SendLinks), read_vector(SPI_NEXT_MS, SendLinks, Send'), Send' =?= EndSend, arg(SPI_MESSAGE_LINKS, Receive, ReceiveLinks), read_vector(SPI_NEXT_MS, ReceiveLinks, Receive'), Receive' =\= EndReceive, arg(SPI_MS_TYPE, Receive', SPI_MESSAGE_ANCHOR), arg(SPI_MESSAGE_LINKS, Receive', ReceiveLinks'), read_vector(SPI_NEXT_MS, ReceiveLinks', Receive''), Receive'' =\= EndReceive | self; arg(SPI_MS_TYPE, Send, SPI_MESSAGE_ANCHOR), arg(SPI_MESSAGE_LINKS, Send, SendLinks), read_vector(SPI_NEXT_MS, SendLinks, Send'), Send' =?= EndSend, arg(SPI_MESSAGE_LINKS, Receive, ReceiveLinks), read_vector(SPI_NEXT_MS, ReceiveLinks, Receive'), Receive' =?= EndReceive | store_vector(SPI_BLOCKED, TRUE, Channel), Wakeup = done; arg(SPI_MS_TYPE, Send, SPI_MESSAGE_ANCHOR), arg(SPI_MESSAGE_LINKS, Send, SendLinks), read_vector(SPI_NEXT_MS, SendLinks, Send'), Send' =?= EndSend, arg(SPI_MESSAGE_LINKS, Receive, ReceiveLinks), read_vector(SPI_NEXT_MS, ReceiveLinks, Receive'), Receive' =\= EndReceive, arg(SPI_MS_TYPE, Receive', SPI_RECEIVE) | self; arg(SPI_MS_TYPE, Send, SPI_MESSAGE_ANCHOR), arg(SPI_MESSAGE_LINKS, Send, SendLinks), read_vector(SPI_NEXT_MS, SendLinks, Send'), Send' =?= EndSend, arg(SPI_MESSAGE_LINKS, Receive, ReceiveLinks), read_vector(SPI_NEXT_MS, ReceiveLinks, Receive'), Receive' =\= EndReceive, arg(SPI_MS_TYPE, Receive', SPI_MESSAGE_ANCHOR), arg(SPI_MESSAGE_LINKS, Receive', ReceiveLinks'), read_vector(SPI_NEXT_MS, ReceiveLinks', Receive''), Receive'' =\= EndReceive | self; arg(SPI_MS_TYPE, Send, SPI_MESSAGE_ANCHOR), arg(SPI_MESSAGE_LINKS, Send, SendLinks), read_vector(SPI_NEXT_MS, SendLinks, Send'), Send' =?= EndSend, arg(SPI_MESSAGE_LINKS, Receive, ReceiveLinks), read_vector(SPI_NEXT_MS, ReceiveLinks, Receive'), Receive' =\= EndReceive, arg(SPI_MS_TYPE, Receive', SPI_MESSAGE_ANCHOR), arg(SPI_MESSAGE_LINKS, Receive', ReceiveLinks'), read_vector(SPI_NEXT_MS, ReceiveLinks', Receive''), Receive'' =?= EndReceive | store_vector(SPI_BLOCKED, TRUE, Channel), Wakeup = done /* otherwise | computation # spi_utils # show_value(channel = Channel,[],C), computation # spi_utils # show_value(send = Send, [3], S), computation # spi_utils # show_value(receive = Receive, [3], R), computation # spi_utils # show_value(endsend = EndSend, [3], ES), computation # spi_utils # show_value(endreceive = EndReceive, [3], ER), screen#display((C,S,R,ES,ER),length(0)) */ . bimolecular_send_blocked(Channel, Wakeup, Send, EndSend, Receive, EndReceive) :- Send =\= EndSend | do_bimolecular_send; Send =?= EndSend, arg(SPI_MESSAGE_LINKS, Receive, ReceiveLinks), read_vector(SPI_NEXT_MS, ReceiveLinks, Receive'), Receive' =\= EndReceive, arg(SPI_MS_TYPE, Receive', SPI_RECEIVE) | do_bimolecular_send; Send =?= EndSend, arg(SPI_MESSAGE_LINKS, Receive, ReceiveLinks), read_vector(SPI_NEXT_MS, ReceiveLinks, Receive'), Receive' =\= EndReceive, arg(SPI_MS_TYPE, Receive', SPI_MESSAGE_ANCHOR), arg(SPI_MESSAGE_LINKS, Receive', ReceiveLinks'), read_vector(SPI_NEXT_MS, ReceiveLinks', Receive''), Receive'' =\= EndReceive | do_bimolecular_send; otherwise : Receive = _, Send = _, EndReceive = _, EndSend = _, store_vector(SPI_BLOCKED, TRUE, Channel), Wakeup = done. do_homodimerized_transmit(Channel, Uniform1, Uniform2, Wakeup) :- read_vector(SPI_DIMER_ANCHOR, Channel, DimerAnchor), read_vector(SPI_CHANNEL_TYPE, Channel, Type), bitwise_and(Type, SPI_RANDOM_FLAG, 0), arg(SPI_MESSAGE_LINKS, DimerAnchor, DimerLinks), read_vector(SPI_NEXT_MS, DimerLinks, Receive), arg(SPI_MESSAGE_LINKS, Receive, ReceiveLinks), read_vector(SPI_NEXT_MS, ReceiveLinks, Dimer) : Uniform1 = _, Uniform2 = _ | do_homodimerized_send(Channel, Wakeup, Receive, Dimer, Dimer); read_vector(SPI_DIMER_ANCHOR, Channel, DimerAnchor), read_vector(SPI_CHANNEL_TYPE, Channel, Type), bitwise_and(Type, SPI_RANDOM_FLAG, SPI_RANDOM_FLAG), read_vector(SPI_DIMER_WEIGHT, Channel, DimerWeight), ReceiveSelect := Uniform1*DimerWeight, DimerSelect := Uniform2*DimerWeight | choose_random_start(DimerAnchor, ReceiveSelect, Receive), choose_random_start(DimerAnchor, DimerSelect, StartD), do_homodimerized_send(Channel, Wakeup, Receive, StartD, StartD). do_homodimerized_send(Channel, Wakeup, Receive, Dimer, EndDimer) :- arg(SPI_MS_TYPE, Receive, SPI_DIMER), arg(SPI_MS_TYPE, Dimer, SPI_DIMER), arg(SPI_MS_CID, Receive, ReceiveRCId), arg(SPI_MS_CHANNEL, Receive, ReceiveChannel), arg(SPI_RECEIVE_TAG, Receive, ReceiveTag), arg(SPI_COMMON, Receive, ReceiveCommon), arg(SPI_MS_CID, Dimer, DimerRCId), arg(SPI_MS_CHANNEL, Dimer, DimerChannel), arg(SPI_DIMER_TAG, Dimer, DimerTag), arg(SPI_COMMON, Dimer, DimerCommon), ReceiveCommon =?= {ReceivePId, ReceiveList, ReceiveValue, ReceiveChosen}, we(ReceiveChosen), DimerCommon =?= {DimerPId, DimerList, DimerValue, DimerChosen}, we(DimerChosen), arg(SPI_AMBIENT_CHANNEL, Receive, []) : Channel = _, EndDimer = _, ReceiveChosen = ReceiveTag, DimerChosen = DimerTag, ReceiveValue = DimerValue?, Wakeup = true(ReceivePId, ReceiveRCId, ReceiveChannel, DimerPId, DimerRCId, DimerChannel) | discount(ReceiveList), discount(DimerList); arg(SPI_MS_TYPE, Receive, SPI_DIMER), arg(SPI_MS_TYPE, Dimer, SPI_DIMER), arg(SPI_MS_CID, Receive, ReceiveRCId), arg(SPI_MS_CHANNEL, Receive, ReceiveChannel), arg(SPI_RECEIVE_TAG, Receive, ReceiveTag), arg(SPI_COMMON, Receive, ReceiveCommon), arg(SPI_MS_CID, Dimer, DimerRCId), arg(SPI_MS_CHANNEL, Dimer, DimerChannel), arg(SPI_DIMER_TAG, Dimer, DimerTag), arg(SPI_COMMON, Dimer, DimerCommon), ReceiveCommon =?= {ReceivePId, ReceiveList, ReceiveValue, ReceiveChosen}, we(ReceiveChosen), DimerCommon =?= {DimerPId, DimerList, DimerValue, DimerChosen}, we(DimerChosen), arg(SPI_AMBIENT_CHANNEL, Receive, ReceiveAmbient), ReceiveAmbient =\= [], arg(SPI_AMBIENT_CHANNEL, Dimer, DimerAmbient), ReceiveAmbient =\= DimerAmbient : Channel = _, EndDimer = _, ReceiveChosen = ReceiveTag, DimerChosen = DimerTag, ReceiveValue = DimerValue?, Wakeup = true(ReceivePId, ReceiveRCId, ReceiveChannel, DimerPId, DimerRCId, DimerChannel) | discount(ReceiveList), discount(DimerList); arg(SPI_MS_TYPE, Receive, SPI_DIMER), arg(SPI_MS_TYPE, Dimer, SPI_DIMER), arg(SPI_AMBIENT_CHANNEL, Receive, ReceiveAmbient), ReceiveAmbient =\= [], arg(SPI_AMBIENT_CHANNEL, Dimer, DimerAmbient), ReceiveAmbient =?= DimerAmbient, arg(SPI_MESSAGE_LINKS, Dimer, DimerLinks), read_vector(SPI_NEXT_MS, DimerLinks, Dimer'), Dimer' =\= EndDimer | self; arg(SPI_MS_TYPE, Receive, SPI_DIMER), arg(SPI_MS_TYPE, Dimer, SPI_DIMER), arg(SPI_AMBIENT_CHANNEL, Receive, ReceiveAmbient), ReceiveAmbient =\= [], arg(SPI_AMBIENT_CHANNEL, Dimer, DimerAmbient), ReceiveAmbient =?= DimerAmbient, arg(SPI_MESSAGE_LINKS, Dimer, DimerLinks), read_vector(SPI_NEXT_MS, DimerLinks, Dimer'), Dimer' =?= EndDimer : store_vector(SPI_BLOCKED, TRUE, Channel), Wakeup = done; % Test Receive has the same Chosen as Dimer - % communications which ARE homodimerized AND mixed. arg(SPI_MS_TYPE, Receive, SPI_DIMER), arg(SPI_MS_TYPE, Dimer, SPI_DIMER), arg(SPI_COMMON, Receive, ReceiveCommon), arg(SPI_COMMON, Dimer, DimerCommon), ReceiveCommon =?= {_, _, _, Chosen}, DimerCommon =?= {_, _, _, Chosen}, arg(SPI_MESSAGE_LINKS, Dimer, DimerLinks), read_vector(SPI_NEXT_MS, DimerLinks, Dimer'), Dimer' =\= EndDimer | self; arg(SPI_MS_TYPE, Receive, SPI_DIMER), arg(SPI_MS_TYPE, Dimer, SPI_DIMER), arg(SPI_COMMON, Receive, ReceiveCommon), arg(SPI_COMMON, Dimer, DimerCommon), ReceiveCommon =?= {_, _, _, Chosen}, DimerCommon =?= {_, _, _, Chosen}, arg(SPI_MESSAGE_LINKS, Dimer, DimerLinks), read_vector(SPI_NEXT_MS, DimerLinks, Dimer'), Dimer' =?= EndDimer : store_vector(SPI_BLOCKED, TRUE, Channel), Wakeup = done; % Skip the Anchor. arg(SPI_MS_TYPE, Receive, SPI_DIMER), arg(SPI_MS_TYPE, Dimer, SPI_MESSAGE_ANCHOR), arg(SPI_MESSAGE_LINKS, Dimer, DimerLinks), read_vector(SPI_NEXT_MS, DimerLinks, Dimer'), Dimer' =\= EndDimer | self; arg(SPI_MS_TYPE, Receive, SPI_DIMER), arg(SPI_MS_TYPE, Dimer, SPI_MESSAGE_ANCHOR), arg(SPI_MESSAGE_LINKS, Dimer, DimerLinks), read_vector(SPI_NEXT_MS, DimerLinks, Dimer'), Dimer' =?= EndDimer : store_vector(SPI_BLOCKED, TRUE, Channel), Wakeup = done /* ; otherwise | computation # spi_utils # show_value(channel = Channel,[],C), computation # spi_utils # show_value(receive = Receive, [3], R), computation # spi_utils # show_value(dimer = Dimer, [3], D), computation # spi_utils # show_value(enddimer = EndDimer, [3], ED), screen#display((C,R,D,ED),length(0)) */ . /***************************** Utilities ************************************/ choose_random_start(Message, Select, Start) :- arg(SPI_MESSAGE_LINKS, Message, Links), read_vector(SPI_NEXT_MS, Links, Message'), arg(SPI_MS_MULTIPLIER, Message', Multiplier), Select -= Multiplier, Select' > 0 | self; arg(SPI_MESSAGE_LINKS, Message, Links), read_vector(SPI_NEXT_MS, Links, Message'), arg(SPI_MS_MULTIPLIER, Message', Multiplier), Select -= Multiplier, Select' =< 0 : Start = Message'. discount(MsList) :- MsList ? Message, arg(SPI_MS_TYPE, Message, MessageType), arg(SPI_MS_CHANNEL, Message, Channel), arg(SPI_MS_MULTIPLIER, Message, Multiplier), arg(SPI_MESSAGE_LINKS, Message, Links), read_vector(SPI_NEXT_MS, Links, NextMessage), arg(SPI_MESSAGE_LINKS, NextMessage, NextLinks), read_vector(SPI_PREVIOUS_MS, Links, PreviousMessage), arg(SPI_MESSAGE_LINKS, PreviousMessage, PreviousLinks), MessageType = SPI_SEND, read_vector(SPI_SEND_WEIGHT, Channel, Weight), Weight -= Multiplier : store_vector(SPI_SEND_WEIGHT, Weight', Channel), store_vector(SPI_NEXT_MS, NextMessage, PreviousLinks), store_vector(SPI_PREVIOUS_MS, PreviousMessage, NextLinks) | self; MsList ? Message, arg(SPI_MS_TYPE, Message, MessageType), arg(SPI_MS_CHANNEL, Message, Channel), arg(SPI_MS_MULTIPLIER, Message, Multiplier), arg(SPI_MESSAGE_LINKS, Message, Links), read_vector(SPI_NEXT_MS, Links, NextMessage), arg(SPI_MESSAGE_LINKS, NextMessage, NextLinks), read_vector(SPI_PREVIOUS_MS, Links, PreviousMessage), arg(SPI_MESSAGE_LINKS, PreviousMessage, PreviousLinks), MessageType =?= SPI_RECEIVE, read_vector(SPI_RECEIVE_WEIGHT, Channel, Weight), Weight -= Multiplier : store_vector(SPI_RECEIVE_WEIGHT, Weight', Channel), store_vector(SPI_NEXT_MS, NextMessage, PreviousLinks), store_vector(SPI_PREVIOUS_MS, PreviousMessage, NextLinks) | self; MsList ? Message, arg(SPI_MS_TYPE, Message, MessageType), arg(SPI_MS_CHANNEL, Message, Channel), arg(SPI_MS_MULTIPLIER, Message, Multiplier), arg(SPI_MESSAGE_LINKS, Message, Links), read_vector(SPI_NEXT_MS, Links, NextMessage), arg(SPI_MESSAGE_LINKS, NextMessage, NextLinks), read_vector(SPI_PREVIOUS_MS, Links, PreviousMessage), arg(SPI_MESSAGE_LINKS, PreviousMessage, PreviousLinks), MessageType =?= SPI_DIMER, read_vector(SPI_DIMER_WEIGHT, Channel, Weight), Weight -= Multiplier : store_vector(SPI_DIMER_WEIGHT, Weight', Channel), store_vector(SPI_NEXT_MS, NextMessage, PreviousLinks), store_vector(SPI_PREVIOUS_MS, PreviousMessage, NextLinks) | self; MsList ? Other, otherwise | show#stuff(item, Other), show#stuff(end, MsList'), arg(3, Other, Channel), show#stuff(channel, Channel), self; MsList =?= [] | true. queue_message(MessageType, RCId, Channel, Multiplier, Tags, Ambient, Common, Message) :- MessageType =?= SPI_SEND, read_vector(SPI_SEND_WEIGHT, Channel, Weight), Weight += Multiplier, read_vector(SPI_SEND_ANCHOR, Channel, Anchor) : store_vector(SPI_SEND_WEIGHT, Weight', Channel), Message = {MessageType, RCId, Channel, Multiplier, Tags, 0, Common, Links?, Ambient} | queue_to_anchor; MessageType =?= SPI_RECEIVE, read_vector(SPI_RECEIVE_WEIGHT, Channel, Weight), Weight += Multiplier, read_vector(SPI_RECEIVE_ANCHOR, Channel, Anchor) : store_vector(SPI_RECEIVE_WEIGHT, Weight', Channel), Message = {MessageType, RCId, Channel, Multiplier, 0, Tags, Common, Links?, Ambient} | queue_to_anchor; MessageType =?= SPI_DIMER, read_vector(SPI_DIMER_WEIGHT, Channel, Weight), Weight += Multiplier, read_vector(SPI_DIMER_ANCHOR, Channel, Anchor), Tags = {SendTag, ReceiveTag} : store_vector(SPI_DIMER_WEIGHT, Weight', Channel), Message = {MessageType, RCId, Channel, Multiplier, SendTag, ReceiveTag, Common, Links?, Ambient} | queue_to_anchor. queue_to_anchor(Message, Anchor, Channel, Links) :- arg(SPI_MESSAGE_LINKS, Anchor, AnchorLinks), read_vector(SPI_PREVIOUS_MS, AnchorLinks, PreviousMessage), arg(SPI_MESSAGE_LINKS, PreviousMessage, PreviousLinks) : store_vector(SPI_BLOCKED, FALSE, Channel), make_vector(2, Links, _), store_vector(SPI_PREVIOUS_MS, PreviousMessage, Links), store_vector(SPI_NEXT_MS, Anchor, Links), store_vector(SPI_NEXT_MS, Message, PreviousLinks), store_vector(SPI_PREVIOUS_MS, Message, AnchorLinks). /* do_execute(Id, Offset, Command) :- true : execute(Offset, Command) | computation # spi_utils # show_value(do_execute(Id, Offset, Command),[5],O), screen#display(ok(O),wait(O)); otherwise | computation # spi_utils # show_value(do_execute(Id, Offset, Command),[5],O), screen#display(failed(O),wait(O)). */
[ "bill" ]
bill
51866e4b90ffe3e683a12c605029f80c60fdd399
10b63bd3cc42daa1c73beee6402d0935a47a8890
/Plugins/MyEditorUtils/Source/MyEditorUtils/Public/MyPropertyType/MyPropertyTypeCustomization.h
2db7ee8dd81087cd1d8824df32a907c7e57a0a9b
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
JanSeliv/Bomber
ca91395b4382f81471b9df04ddb6259f3fa3219e
3124fcca6075654f0f269dd4c5cd8b90579b0b52
refs/heads/master
2023-08-17T03:31:23.591004
2023-06-12T06:03:04
2023-06-12T06:03:04
188,085,654
78
20
MIT
2023-06-12T06:00:54
2019-05-22T17:37:20
C++
UTF-8
C++
false
false
5,374
h
// Copyright (c) Yevhenii Selivanov. #pragma once #include "IPropertyTypeCustomization.h" //--- #include "MyPropertyType/PropertyData.h" typedef class FMyPropertyTypeCustomization Super; /** * Overrides some property to make better experience avoiding any errors in properties by manual typing etc. * The FName Property is customised as button to select the value in a list. */ class MYEDITORUTILS_API FMyPropertyTypeCustomization : public IPropertyTypeCustomization { public: /** Is used to load and unload the Property Editor Module. */ inline static const FName PropertyEditorModule = TEXT("PropertyEditor"); /* --------------------------------------------------- * Public functions * --------------------------------------------------- */ /** * Called when the header of the property (the row in the details panel where the property is shown) * If nothing is added to the row, the header is not displayed * @param PropertyHandle Handle to the property being customized * @param HeaderRow A row that widgets can be added to * @param CustomizationUtils Utilities for customization */ virtual void CustomizeHeader(TSharedRef<IPropertyHandle> PropertyHandle, FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& CustomizationUtils) override; /** * Called when the children of the property should be customized or extra rows added. * @param PropertyHandle Handle to the property being customized * @param ChildBuilder A builder for adding children * @param CustomizationUtils Utilities for customization */ virtual void CustomizeChildren(TSharedRef<IPropertyHandle> PropertyHandle, IDetailChildrenBuilder& ChildBuilder, IPropertyTypeCustomizationUtils& CustomizationUtils) override; /** Get cached value contained in the property to be customized. */ FORCEINLINE FText GetCustomPropertyValue() const { return FText::FromString(CustomPropertyInternal.PropertyValue.ToString()); } /** Set the FName value into the property. * @see FMyPropertyTypeCustomization::MyPropertyHandleInternal. */ void SetCustomPropertyValue(FName Value); /** Set true to activate property, false to grey out it (read-only). */ void SetCustomPropertyEnabled(bool bEnabled); protected: /* --------------------------------------------------- * Protected properties * --------------------------------------------------- */ /** Contains data of hierarchically upper property which is chosen in editor module to customize its child property. */ FPropertyData ParentPropertyInternal = FPropertyData::Empty; /** Property data to be customized. It's property name has to be set in children's constructors. */ FPropertyData CustomPropertyInternal = FPropertyData::Empty; /** Contains data about all not custom child properties. */ TArray<FPropertyData> DefaultPropertiesInternal; /** The outer uobject of a property to be customized. */ TWeakObjectPtr<class UObject> MyPropertyOuterInternal = nullptr; /** The text widget that displays the chosen property value. */ TWeakPtr<class STextBlock> RowTextWidgetInternal = nullptr; /** Strings list of displayed values to be selected. */ TArray<TSharedPtr<FString>> SearchableComboBoxValuesInternal; /** Contains the widget row that displays values to be selected. * @see FMyPropertyTypeCustomization::SearchableComboBoxValuesInternal */ TWeakPtr<class SSearchableComboBox> SearchableComboBoxInternal = nullptr; /** Shared none string. Is selectable value in the searchable box. */ TWeakPtr<FString> NoneStringInternal = nullptr; /* --------------------------------------------------- * Protected functions * --------------------------------------------------- */ /** * Is called for each property on building its row. * @param ChildBuilder A builder for adding children. * @param PropertyData Data of a property to be customized. */ virtual void OnCustomizeChildren(IDetailChildrenBuilder& ChildBuilder, FPropertyData& PropertyData); /** * Is called on adding the custom property. * @param PropertyDisplayText The formatted (with spacers) title name of a row to be shown. * @param ChildBuilder A builder for adding children. * @see FMyPropertyTypeCustomization::CustomPropertyNameInternal */ virtual void AddCustomPropertyRow(const FText& PropertyDisplayText, IDetailChildrenBuilder& ChildBuilder); /** Set new values for the list of selectable members. * @see FMyPropertyTypeCustomization::SearchableComboBoxValuesInternal */ virtual void RefreshCustomProperty(); /** Is called to deactivate custom property. */ virtual void InvalidateCustomProperty(); /** Returns true if changing custom property currently is not forbidden. */ virtual bool IsAllowedEnableCustomProperty() const { return true; } /** * Callback for when the function selection has changed from the dropdown. Will call setter of custom property. * @param SelectedStringPtr The chosen string. * @param SelectInfo Additional information about a selection event. * @see FMyPropertyTypeCustomization::SetCustomPropertyValue(FName). */ void OnCustomPropertyChosen(TSharedPtr<FString> SelectedStringPtr, ESelectInfo::Type SelectInfo); /** Add an empty row once, so the users can clear the selection if they want. */ void InitSearchableComboBox(); /** Reset and remove all shared strings in array except 'None' string. */ void ResetSearchableComboBox(); };
[ "janseliw@gmail.com" ]
janseliw@gmail.com
59d68e07d1197e5c92d194abdec105b8feaa053d
6a5ebe5ee99f84755219fa6cdd6102646ab5bed1
/contest/A. Find Divisible.cpp
41f94f76e4ee354cc924cc0d6fca452654a682ff
[]
no_license
israt-urme/Codeforces
89be84f03b1e5ade0fd55119b42d43d99f8567e2
77ccae1604c7837e97d2592f07514ab6536cca63
refs/heads/master
2023-06-07T00:11:17.741535
2021-06-28T11:59:41
2021-06-28T11:59:41
381,008,669
0
0
null
null
null
null
UTF-8
C++
false
false
198
cpp
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; long long int l,r,x,y,i; while(n--) { cin>>l>>r; cout<<l<<" "<<l*2<<endl; } return 0; }
[ "urmejahan58@gmail.com" ]
urmejahan58@gmail.com
32396f65214b91726694246524432d735eabd2ce
a162fdf1ccbb98ca9ddac790a087dc5c95e3fd43
/include/entity/light.h
e3d1db894f8f7afb0d7ba3abe4940bdeda6b94d9
[ "MIT" ]
permissive
tobiasbu/raytracer
3f9c7a8eb516d3486d34b1a3ff44517c7b01b045
bc1db0c6aea504b2dc59520fe6245d523fb11ffa
refs/heads/master
2021-01-19T11:04:05.608699
2018-03-06T12:44:14
2018-03-06T12:44:14
87,923,949
4
0
null
null
null
null
UTF-8
C++
false
false
1,855
h
#ifndef _LIGHT_H_ #define _LIGHT_H_ #include "render/color.h" #include "math/vec3.h" #include "math/mat4.h" #include "entity/transform.h" #include "math/mathdef.hpp" class Light : public Transform { public: float intensity; // fallof Color color; int type = 0; Light() : color(Color::white), intensity(0.1f) { position = vec3(0, -1, -1); } virtual ~Light() {} virtual void illuminate(const vec3 & point, vec3 & lightDir, vec3 & lightColorIntensity, float & distance, float & radius) const = 0; virtual void updateTransform() { mat4 s = MatrixTransform::scale(mat4::identity, scale); mat4 t = MatrixTransform::translate(mat4::identity, position); mat4 r = MatrixTransform::rotate_x_deg(mat4::identity, angle.x); r = MatrixTransform::rotate_y_deg(r, angle.y); r = MatrixTransform::rotate_z_deg(r, angle.z); // transform o row-major is T * R * S // collum: //matrix = s * r * t; // another solution: precompute transformed object: only model matrix matrix = t; // * r); // compute inversed matrix inversedMatrix = mat4::inverse(matrix); calculateVectors(); } }; class DirectionalLight : public Light { public: vec3 direction; DirectionalLight(); DirectionalLight(const vec3 & position, const vec3 & targetDirection, const Color & color = Color::white, float intensity = 4); void illuminate(const vec3 & point, vec3 & lightDir, vec3 & lightColorIntensity, float & distance, float & radius) const; //void updateTransform(); void setDirection(const vec3 & dir); }; class PointLight : public Light { public: float range = 1; PointLight(); PointLight(const vec3 & position, const Color & color, float intensity = 4); void illuminate(const vec3 & point, vec3 & lightDir, vec3 & lightColorIntensity, float & distance, float & radius) const; //void updateTransform(); }; #endif
[ "flamenco.bluegrass@gmail.com" ]
flamenco.bluegrass@gmail.com
44d019c7bb8f218518aae7a873dba7a528747f63
de9f878d6e062dd7d60f9ab746aab7f5063ce251
/run/abl/fullScale/fullScaleTurbArRefined2/constant/polyMesh/boundary
189b56c110d67d3fd4b50f54c920e8c5cc6d157b
[]
no_license
stevietran/foam5
ba2c03a263fef2480045d51267159838d83b1a0c
256f7fd317b18df59208ffcd63e96d36e81bf62f
refs/heads/master
2021-10-27T19:43:03.709356
2019-04-19T06:54:30
2019-04-19T06:54:30
167,189,514
0
0
null
null
null
null
UTF-8
C++
false
false
1,687
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 5.x | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class polyBoundaryMesh; location "constant/polyMesh"; object boundary; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 6 ( frontField { type patch; nFaces 172; startFace 205628; } backField { type patch; nFaces 172; startFace 205800; } symPlane { type empty; inGroups 1(empty); nFaces 103200; startFace 205972; } sideField { type empty; inGroups 1(empty); nFaces 103200; startFace 309172; } ground { type wall; inGroups 1(wall); nFaces 600; startFace 412372; } top { type patch; nFaces 600; startFace 412972; } ) // ************************************************************************* //
[ "tranlevu001@e.ntu.edu.sg" ]
tranlevu001@e.ntu.edu.sg
2792174f5436fefff6147afec3171ef6c531d2a5
366d1b9a999aaa856a325ae80268af20b995babe
/src/shogun/statistical_testing/internals/InitPerKernel.cpp
960707e6d5a98c3ea39d5e200207654544fa45bb
[ "BSD-3-Clause", "DOC", "GPL-3.0-only" ]
permissive
karlnapf/shogun
bc3fcbeef377b8157bd8a9639211c2667b535846
eebce07a4309bb7e1d3a4f0981efd49e687533b6
refs/heads/develop
2020-04-05T22:46:38.369312
2019-07-09T08:59:14
2019-07-09T08:59:14
4,420,161
1
1
BSD-3-Clause
2018-09-04T10:50:41
2012-05-23T13:12:40
C++
UTF-8
C++
false
false
2,179
cpp
/* * Copyright (c) The Shogun Machine Learning Toolbox * Written (w) 2016 - 2017 Soumyajit De * 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. * * The views and conclusions contained in the software and documentation are those * of the authors and should not be interpreted as representing official policies, * either expressed or implied, of the Shogun Development Team. */ #include <shogun/kernel/Kernel.h> #include <shogun/statistical_testing/internals/InitPerKernel.h> using namespace shogun; using namespace internal; InitPerKernel::InitPerKernel(std::shared_ptr<CKernel>& kernel) : m_kernel(kernel) { } InitPerKernel::~InitPerKernel() { } InitPerKernel& InitPerKernel::operator=(CKernel* kernel) { SG_REF(kernel); m_kernel = std::shared_ptr<CKernel>(kernel, [](CKernel* ptr) { SG_UNREF(ptr); }); return *this; } InitPerKernel::operator CKernel*() const { return m_kernel.get(); }
[ "heavensdevil6909@gmail.com" ]
heavensdevil6909@gmail.com
2d0ac43f098bdf62be7402dd14eabc5830ba92da
40ae1b4dd9c8bb8afe70b32994219dea18fd40af
/lib/src/resource/make.h
8397662fa41cccb1266f67280cbedf3a64b7786d
[ "Apache-2.0" ]
permissive
gejza/xcdev
817fe25462e8d3ed1bc032123da464eedc3d1f2e
769b4f84bfb3e0972cc2aa743a0f70d271add138
refs/heads/master
2021-01-10T20:51:28.090672
2011-02-20T21:31:26
2011-02-20T21:31:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,442
h
/* File name: cbmake.h Date: 2010/12/05 21:07 Subversion: $Id: $ Author: Milan Dunghubel <milan@mfis.cz> Copyright (C) 2010 Milan Dunghubel <milan@mfis.cz> */ #ifndef _XC_CBMAKE_H_ #define _XC_CBMAKE_H_ #pragma once #include <memory> #include "cbdef.h" class DBMake_t; enum TableId_t { NS_TABLE = 2, STR_TABLE = 23, }; using namespace xc; class Output_t { public: virtual ~Output_t() {} virtual void add(uint32_t table, const void*, size_t, const void*, size_t) = 0; }; class Make_t { public: Make_t(Output_t& out); virtual ~Make_t(); void set_default(Lang_t lang) { this->_def_lang = lang; } // string StrId_t string(const char* str) { return this->string(this->_def_lang, str); } StrId_t string(Lang_t lang, const char* str); void string(const StrId_t id, Lang_t lang, const char* str); void string(const std::string& msgid, const std::string& msgstr, Lang_t lang); // hook //void hook(const char* name, const Callback_t& cb); // alias void alias(const char* route, Lang_t lang, const char* alias); Id_t add(const Menu_t& menu); void add(const Template_t& templ); // debug const char* get_lang(Lang_t lang); protected: Id_t seq() { return ++_curid; } private: Output_t& _out; Lang_t _def_lang; Id_t _curid; }; #endif // _XC_CBMAKE_H_ /* end of cbmake.h */
[ "gejza@gejza.net" ]
gejza@gejza.net
d6396a9f479955e4ed86937e7158790955ed26bd
2bcf5e8abe74cd6bad2d0c14c8a4a2527a085bb7
/devel/include/canbus/candata.h
8cdd709f1def7ada403eb10b1b34893215929b84
[]
no_license
mr-d-self-driving/ROS_Intell_Driving
2b05efd336a82cce9e3a1d7d4aab137d36f44a57
1781959b4c447ce8369f3fd2bb82f3708daee8cc
refs/heads/master
2022-01-12T15:54:23.729563
2019-06-11T10:01:02
2019-06-11T10:01:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,941
h
// Generated by gencpp from file canbus/candata.msg // DO NOT EDIT! #ifndef CANBUS_MESSAGE_CANDATA_H #define CANBUS_MESSAGE_CANDATA_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> namespace canbus { template <class ContainerAllocator> struct candata_ { typedef candata_<ContainerAllocator> Type; candata_() : id(0) , data() { data.assign(0); } candata_(const ContainerAllocator& _alloc) : id(0) , data() { (void)_alloc; data.assign(0); } typedef uint32_t _id_type; _id_type id; typedef boost::array<uint8_t, 8> _data_type; _data_type data; typedef boost::shared_ptr< ::canbus::candata_<ContainerAllocator> > Ptr; typedef boost::shared_ptr< ::canbus::candata_<ContainerAllocator> const> ConstPtr; }; // struct candata_ typedef ::canbus::candata_<std::allocator<void> > candata; typedef boost::shared_ptr< ::canbus::candata > candataPtr; typedef boost::shared_ptr< ::canbus::candata const> candataConstPtr; // constants requiring out of line definition template<typename ContainerAllocator> std::ostream& operator<<(std::ostream& s, const ::canbus::candata_<ContainerAllocator> & v) { ros::message_operations::Printer< ::canbus::candata_<ContainerAllocator> >::stream(s, "", v); return s; } } // namespace canbus namespace ros { namespace message_traits { // BOOLTRAITS {'IsFixedSize': True, 'IsMessage': True, 'HasHeader': False} // {'canbus': ['/home/silentroar/Desktop/ROS_Intell_Driving/src/canbus/msg'], 'std_msgs': ['/opt/ros/indigo/share/std_msgs/cmake/../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< ::canbus::candata_<ContainerAllocator> > : TrueType { }; template <class ContainerAllocator> struct IsFixedSize< ::canbus::candata_<ContainerAllocator> const> : TrueType { }; template <class ContainerAllocator> struct IsMessage< ::canbus::candata_<ContainerAllocator> > : TrueType { }; template <class ContainerAllocator> struct IsMessage< ::canbus::candata_<ContainerAllocator> const> : TrueType { }; template <class ContainerAllocator> struct HasHeader< ::canbus::candata_<ContainerAllocator> > : FalseType { }; template <class ContainerAllocator> struct HasHeader< ::canbus::candata_<ContainerAllocator> const> : FalseType { }; template<class ContainerAllocator> struct MD5Sum< ::canbus::candata_<ContainerAllocator> > { static const char* value() { return "2f636bf314749eeb00e7f85696286658"; } static const char* value(const ::canbus::candata_<ContainerAllocator>&) { return value(); } static const uint64_t static_value1 = 0x2f636bf314749eebULL; static const uint64_t static_value2 = 0x00e7f85696286658ULL; }; template<class ContainerAllocator> struct DataType< ::canbus::candata_<ContainerAllocator> > { static const char* value() { return "canbus/candata"; } static const char* value(const ::canbus::candata_<ContainerAllocator>&) { return value(); } }; template<class ContainerAllocator> struct Definition< ::canbus::candata_<ContainerAllocator> > { static const char* value() { return "uint32 id\n\ #uint32 timestamp\n\ uint8[8] data\n\ "; } static const char* value(const ::canbus::candata_<ContainerAllocator>&) { return value(); } }; } // namespace message_traits } // namespace ros namespace ros { namespace serialization { template<class ContainerAllocator> struct Serializer< ::canbus::candata_<ContainerAllocator> > { template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m) { stream.next(m.id); stream.next(m.data); } ROS_DECLARE_ALLINONE_SERIALIZER }; // struct candata_ } // namespace serialization } // namespace ros namespace ros { namespace message_operations { template<class ContainerAllocator> struct Printer< ::canbus::candata_<ContainerAllocator> > { template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::canbus::candata_<ContainerAllocator>& v) { s << indent << "id: "; Printer<uint32_t>::stream(s, indent + " ", v.id); s << indent << "data[]" << std::endl; for (size_t i = 0; i < v.data.size(); ++i) { s << indent << " data[" << i << "]: "; Printer<uint8_t>::stream(s, indent + " ", v.data[i]); } } }; } // namespace message_operations } // namespace ros #endif // CANBUS_MESSAGE_CANDATA_H
[ "dengzhongw@126.com" ]
dengzhongw@126.com
229b0831ae5f293cee1d21244c3afbbcafd2416c
49cf7c9e66c9b93423f5c1323f79e383c60b25bf
/puzzle_heur.cpp
2190ab593633b3a3fa1500ad8d2e016a44033d04
[]
no_license
sahilagar/Puzzle-Solver
aecdbd9d1303ca8be3170eef6b1814596a0a5278
3b8f227cd165c17616cd42598c21e73c7c725995
refs/heads/master
2021-07-04T13:57:21.505282
2017-09-27T16:51:21
2017-09-27T16:51:21
105,044,539
0
0
null
null
null
null
UTF-8
C++
false
false
752
cpp
#include "puzzle_heur.h" #include <cmath> using namespace std; int PuzzleManhattanHeuristic::compute(const Board& b) { int count = 0; for (int i = 1; i < b.size(); i++){ int numIndex = -1; for (int j = 0; j < b.size(); j++){ if (b[j] == i){ //find actual num index numIndex = j; break; } } int rCorrect = i/b.dim(); int cCorrect = i%b.dim(); int rActual = numIndex/b.dim(); int cActual = numIndex%b.dim(); count += abs(rActual - rCorrect) + abs(cActual - cCorrect); } return count; } int PuzzleOutOfPlaceHeuristic::compute(const Board& b) { int count = 0; for (int i=1; i < b.size(); i++) { if (b[i] != i){ count++; } } return count; } int PuzzleBFSHeuristic::compute(const Board& b) { return 0; }
[ "sahilagarwal@Sahils-MacBook-Pro.local" ]
sahilagarwal@Sahils-MacBook-Pro.local
704e9c468a5c73db069b877b3bbb42f064271dcc
0fccd1748ee7be55039e7bbfb4820197b5a85f0b
/2D Game Engine/2D Game Engine/MarkOfHunger.cpp
e10c74bf6b0334d998dc3423c51b32733a3a439d
[]
no_license
AustinChayka/C-Game
11d297ac5fd38a280da4701ec16c5e18f8680c58
56bd96fddc38cb4bfca6f69c37748b1417a51d8a
refs/heads/master
2022-02-13T02:39:14.724679
2019-05-30T22:10:43
2019-05-30T22:10:43
167,856,869
1
1
null
null
null
null
UTF-8
C++
false
false
617
cpp
#include "MarkOfHunger.h" #include "Particle.h" MarkOfHunger::MarkOfHunger() : Item("assets/Items/MarkOfHunger.png", "Mark of Hunger", "feed your soul") {} MarkOfHunger::~MarkOfHunger() {} void MarkOfHunger::OnKill(LevelManager * game, Player * p, GameObject * go) { if(rand() % 3 == 0) { p->Heal(1); Particle * particle; for(int i = 0; i < rand() % 5 + 7; i++) { particle = new Particle(go->GetXCenter() + rand() % 20 - 10, go->GetYCenter() + rand() % 20 - 10, 5, 5, 255, 0, 0, 100); particle->SetVY(-(rand() % 3 + 5)); particle->SetVX(rand() % 10 - 5); game->AddObject(particle); } } }
[ "austinchayka@gmail.com" ]
austinchayka@gmail.com
257e109cc0bc6baba7d73ddad1c0a57259d9f6f6
d40efadec5724c236f1ec681ac811466fcf848d8
/branches/Launcher_5_5/TabMOD.h
198cb2c57e1e21c2b40eba9a713bc0922ca5ea88
[]
no_license
svn2github/fs2open
0fcbe9345fb54d2abbe45e61ef44a41fa7e02e15
c6d35120e8372c2c74270c85a9e7d88709086278
refs/heads/master
2020-05-17T17:37:03.969697
2015-01-08T15:24:21
2015-01-08T15:24:21
14,258,345
0
0
null
null
null
null
UTF-8
C++
false
false
1,991
h
#if !defined(AFX_TABMOD_H__FB07B738_1087_4CB8_81B2_69E9FCC068FE__INCLUDED_) #define AFX_TABMOD_H__FB07B738_1087_4CB8_81B2_69E9FCC068FE__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // TabMOD.h : header file // #include <string> ///////////////////////////////////////////////////////////////////////////// // CTabMOD dialog class CTabMOD : public CDialog { // Construction public: CTabMOD(CWnd* pParent = NULL); // standard constructor void SetMOD(char *absolute_path); void GetModCommandLine(std::string &result); void GetActiveModName(char *result); void SetSettings(const std::string &flags); char *GetSettings(bool defaultSettings = false); void OnApply(int flags); void LoadSettings(int flags); // Dialog Data //{{AFX_DATA(CTabMOD) enum { IDD = IDD_MOD }; CStatic m_mod_image; //}}AFX_DATA // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CTabMOD) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: // Generated message map functions //{{AFX_MSG(CTabMOD) afx_msg void OnModSelect(); afx_msg void OnModNone(); afx_msg void OnModWebsite(); afx_msg void OnModForum(); afx_msg void OnDestroy(); //}}AFX_MSG DECLARE_MESSAGE_MAP() HBITMAP LoadBitmap(char * path); void SetMODImage(char *path); void SetModName(char *path, char *name); bool parse_ini_file(char * ini_name); void CheckModSetting(char *mod_string); private: HBITMAP MOD_bitmap; enum { INI_MOD_NAME, INI_IMAGE_NAME, INI_MOD_TEXT, INI_URL_WEBSITE, INI_URL_FORUM, INI_MOD_PRI, INI_MOD_SEC, INI_MAX }; bool mod_selected; char *ini_text[INI_MAX]; char m_absolute_text[MAX_PATH]; char m_active_mod_name[MAX_PATH]; }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_TABMOD_H__FB07B738_1087_4CB8_81B2_69E9FCC068FE__INCLUDED_)
[ "taylor@387891d4-d844-0410-90c0-e4c51a9137d3" ]
taylor@387891d4-d844-0410-90c0-e4c51a9137d3
0715e96633f1eed43ecacf2655500122e423df57
ab55b51d139b480ee094b8f124af53e29fb011f9
/common function/common_function.cpp
87abfcdc1c59c4b76b8450ee0cf131916f380627
[]
no_license
benson-zhang-sjtu/Leetcode
732f36748444f9237ac8eebaf60d50348f3d735c
6b7d1c46a7765fa20dc6d6898ecd1ed4f856e4a0
refs/heads/master
2021-01-12T12:20:06.000751
2016-11-14T07:06:14
2016-11-14T07:06:14
72,438,749
0
0
null
null
null
null
UTF-8
C++
false
false
450
cpp
#include<string> #include<vector> #include<sstream> // String Split Function from Evan Teran. http://stackoverflow.com/questions/236129/split-a-string-in-c void split(const string &s, char delim, vector<string> &elems) { stringstream ss; ss.str(s); string item; while (getline(ss, item, delim)) { elems.push_back(item); } } vector<string> split(const string &s, char delim) { vector<string> elems; split(s, delim, elems); return elems; }
[ "150576806@qq.com" ]
150576806@qq.com
2eb6aa9132fd0fd4b49550bb00964ef5d2c3b8f5
a1d860da5b160fa48b8ab62ea204e1cae6655c61
/SampleEnclave4CUDA/StorageEnclave/StorageEnclave.cpp
baec2b366d23db1c0f4019d3e902a4c40a328774
[]
no_license
ECS-251-W2020/final-project-group-4
813584f4812dbf8b37742e84d57df480b371bebf
1e5755b158585cfe810c4a9b9ce9768da831923c
refs/heads/master
2021-01-06T05:51:49.278306
2020-03-16T02:33:45
2020-03-16T02:33:45
241,226,884
2
1
null
null
null
null
UTF-8
C++
false
false
3,657
cpp
#include "StorageEnclave_t.h" #include "sgx_trts.h" #include "../CUDADemo/constant.h" unsigned char my_secret_arr[AES_NB] = {0}; unsigned char my_exp_key[AES_EXP_NB] = { 0 }; const unsigned char box_enclave[256] = { // 0 1 2 3 4 5 6 7 8 9 a b c d e f 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, // 0 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, // 1 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, // 2 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, // 3 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, // 4 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, // 5 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, // 6 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, // 7 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, // 8 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, // 9 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, // a 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, // b 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, // c 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, // d 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, // e 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 };// f // Round Keys const unsigned char rcon_enclave[10] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 }; void key_expansion_enclave(unsigned char* key, unsigned char* w) { unsigned char r, i, j, k, col[4]; col[0] = 0; col[1] = 0; col[2] = 0; col[3] = 0; // first round key is just the key for (j = 0; j < AES_NB; j++) { for (i = 0; i < 4; i++) { w[AES_NK * i + j] = key[AES_NK * i + j]; } } for (r = 1; r < AES_NR + 1; r++) { for (j = 0; j < AES_NK; j++) { for (i = 0; i < 4; i++) { if (j % AES_NK != 0) { col[i] = w[r * AES_NB + AES_NK * i + j - 1]; } else { col[i] = w[(r - 1) * AES_NB + AES_NK * i + AES_NK - 1]; } } if (j % AES_NK == 0) { // rotate 4 bytes in word k = col[0]; col[0] = col[1]; col[1] = col[2]; col[2] = col[3]; col[3] = k; col[0] = box_enclave[col[0]]; col[1] = box_enclave[col[1]]; col[2] = box_enclave[col[2]]; col[3] = box_enclave[col[3]]; col[0] = col[0] ^ rcon_enclave[r - 1]; } w[r * AES_NB + AES_NK * 0 + j] = w[(r - 1) * AES_NB + AES_NK * 0 + j] ^ col[0]; w[r * AES_NB + AES_NK * 1 + j] = w[(r - 1) * AES_NB + AES_NK * 1 + j] ^ col[1]; w[r * AES_NB + AES_NK * 2 + j] = w[(r - 1) * AES_NB + AES_NK * 2 + j] ^ col[2]; w[r * AES_NB + AES_NK * 3 + j] = w[(r - 1) * AES_NB + AES_NK * 3 + j] ^ col[3]; } } } void set_secret4(unsigned char* secret) { for (int i = 0; i < AES_NB; ++i) { my_secret_arr[i] = secret[i]; } key_expansion_enclave(my_secret_arr, my_exp_key); } void print_secret() { ocall_print_secret(my_secret_arr); } void copy_secret_to_device(void *devicePtr) { ocall_send_to_device(my_exp_key, devicePtr); }
[ "linmx0130@gmail.com" ]
linmx0130@gmail.com
d4c445f04fb098235dc9c27100e930fd0783f2cb
a3b306df800059a5b74975793251a28b8a5f49c7
/Graphs/LX-2/molecule_otsu = False/BioImageXD-1.0/vtkBXD/Processing/vtkExtTIFFReader.h
3085fae4c89f59de0f383badbece169fd1f68aa0
[]
no_license
giacomo21/Image-analysis
dc17ba2b6eb53f48963fad931568576fda4e1349
ea8bafa073de5090bd8f83fb4f5ca16669d0211f
refs/heads/master
2016-09-06T21:42:13.530256
2013-07-22T09:35:56
2013-07-22T09:35:56
11,384,784
1
1
null
null
null
null
UTF-8
C++
false
false
6,798
h
/*========================================================================= Program: Visualization Toolkit Module: $RCSfile: vtkExtTIFFReader.h,v $ Language: C++ Date: $Date: 2003/11/04 21:26:04 $ Version: $Revision: 1.28 $ Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. * Modified source versions must be plainly marked as such, and must not be misrepresented as being the original software. 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 AUTHORS 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. =========================================================================*/ /*========================================================================= Following modifications were made to original vtkTIFFReader by BioImageXD team Copyright (c) 2005 Kalle Pahajoki. Modifications for raw mode support Copyright (c) 2008 Lassi Paavolainen Support for multipage tiffs All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. * Modified source versions must be plainly marked as such, and must not be misrepresented as being the original software. 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 AUTHORS 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. =========================================================================*/ // .NAME vtkExtTIFFReader - read TIFF files // .SECTION Description // vtkExtTIFFReader is a source object that reads TIFF files. // It should be able to read most any TIFF file // // .SECTION See Also // vtkTIFFWriter #ifndef __vtkExtTIFFReader_h #define __vtkExtTIFFReader_h #include "vtkBXDProcessingWin32Header.h" #include "vtkImageReader2.h" //BTX class vtkExtTIFFReaderInternal; //ETX class VTK_BXD_PROCESSING_EXPORT vtkExtTIFFReader : public vtkImageReader2 { public: static vtkExtTIFFReader *New(); vtkTypeRevisionMacro(vtkExtTIFFReader,vtkImageReader2); virtual void PrintSelf(ostream& os, vtkIndent indent); // Description: // Is the given file name a tiff file file? virtual int CanReadFile(const char* fname); // Description: // Get the file extensions for this format. // Returns a string with a space separated list of extensions in // the format .extension virtual const char* GetFileExtensions() { return ".tif .tiff"; } // Description: // Return a descriptive name for the file format that might be useful // in a GUI. virtual const char* GetDescriptiveName() { return "TIFF"; } // Description: // Auxilary methods used by the reader internally. void InitializeColors(); vtkSetMacro(RawMode,int); vtkGetMacro(RawMode,int); vtkBooleanMacro(RawMode,int); //BTX enum { NOFORMAT, RGB, GRAYSCALE, PALETTE_RGB, PALETTE_GRAYSCALE, OTHER }; void ReadImageInternal( void *, void *outPtr, int *outExt, unsigned int size, int ); // Description: // Method to access internal image. Not to be used outside the class. vtkExtTIFFReaderInternal *GetInternalImage() { return this->InternalImage; } //ETX // Description: // Method to check if set TIFF file is multipage int GetNumberOfSubFiles() const; protected: vtkExtTIFFReader(); ~vtkExtTIFFReader(); void GetColor( int index, unsigned short *r, unsigned short *g, unsigned short *b ); unsigned int GetFormat(); virtual void ExecuteInformation(); virtual void ExecuteData(vtkDataObject *out); int RequestUpdateExtent ( vtkInformation* vtkNotUsed(request), vtkInformationVector** inputVector, vtkInformationVector* outputVector); void ReadGenericImage( void *out, unsigned int width, unsigned int height, unsigned int size ); int EvaluateImageAt( void*, void* ); private: vtkExtTIFFReader(const vtkExtTIFFReader&); // Not implemented. void operator=(const vtkExtTIFFReader&); // Not implemented. unsigned short *ColorRed; unsigned short *ColorGreen; unsigned short *ColorBlue; int TotalColors; unsigned int ImageFormat; vtkExtTIFFReaderInternal *InternalImage; int *InternalExtents; int RawMode; }; #endif
[ "fede.anne95@hotmail.it" ]
fede.anne95@hotmail.it
ffa815ce6cc0de319fff1413ad581dffa5330be7
cf7e0b065f3edbb38b4d8bdf4d63d51fc3b0106f
/src/ocio/src/core/Mutex.h
421ad29f59f0253cdb978d75ad5b4fde2b46c722
[ "BSD-3-Clause", "MIT", "Zlib" ]
permissive
appleseedhq/windows-deps
06478bc8ec8f4a9ec40399b763a038e5a76dfbf7
7955c4fa1c9e39080862deb84f5e4ddf0cf71f62
refs/heads/master
2022-11-21T07:16:35.646878
2019-12-11T19:46:46
2020-07-19T08:57:23
16,730,675
5
8
null
2020-07-19T08:57:25
2014-02-11T12:54:46
C++
UTF-8
C++
false
false
4,229
h
/* Copyright (c) 2003-2010 Sony Pictures Imageworks Inc., et al. All Rights Reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. * Neither the name of Sony Pictures Imageworks nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 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. */ #ifndef INCLUDED_OCIO_MUTEX_H #define INCLUDED_OCIO_MUTEX_H /* PTEX SOFTWARE Copyright 2009 Disney Enterprises, Inc. All rights reserved Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. * The names "Disney", "Walt Disney Pictures", "Walt Disney Animation Studios" or the names of its contributors may NOT be used to endorse or promote products derived from this software without specific prior written permission from Walt Disney Pictures. Disclaimer: THIS SOFTWARE IS PROVIDED BY WALT DISNEY PICTURES AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT AND TITLE ARE DISCLAIMED. IN NO EVENT SHALL WALT DISNEY PICTURES, THE COPYRIGHT HOLDER 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 BASED 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 DAMAGES. */ #include "Platform.h" // #define DEBUG_THREADING /** For internal use only */ OCIO_NAMESPACE_ENTER { #ifndef NDEBUG template <class T> class DebugLock : public T { public: DebugLock() : _locked(0) {} void lock() { T::lock(); _locked = 1; } void unlock() { assert(_locked); _locked = 0; T::unlock(); } bool locked() { return _locked != 0; } private: int _locked; }; #endif /** Automatically acquire and release lock within enclosing scope. */ template <class T> class AutoLock { public: AutoLock(T& m) : _m(m) { _m.lock(); } ~AutoLock() { _m.unlock(); } private: T& _m; }; #ifndef NDEBUG // add debug wrappers to mutex and spinlock typedef DebugLock<_Mutex> Mutex; typedef DebugLock<_SpinLock> SpinLock; #else typedef _Mutex Mutex; typedef _SpinLock SpinLock; #endif typedef AutoLock<Mutex> AutoMutex; typedef AutoLock<SpinLock> AutoSpin; } OCIO_NAMESPACE_EXIT #endif
[ "franz@appleseedhq.net" ]
franz@appleseedhq.net
8cc8a0ab618dfbdcea1d3c27db05fc053e1f28e5
b53f1953f5520e5208f34bb87d42d86ead33dba6
/src/Platform/Code/FactoryTool/GLAVS1A_IMEI_CODING_V0.20/Message.h
66ba3f5edef16925a01a9cca3316d5419d0206d1
[]
no_license
Jonkoping/data
e01b2ded3335742165ea3feb9c06e0d111ab5fb7
03de309b5f7998f394b2ed1d8b0bc0114ca686f3
refs/heads/master
2020-06-30T18:24:29.032625
2018-01-04T09:18:55
2018-01-04T09:18:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,312
h
#if !defined(AFX_MESSAGE_H__AC5068A9_1F8E_451D_AFB1_FFDEA02CF34F__INCLUDED_) #define AFX_MESSAGE_H__AC5068A9_1F8E_451D_AFB1_FFDEA02CF34F__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // Message.h : header file // #include "Label.h" ///////////////////////////////////////////////////////////////////////////// // CMessage dialog class CMessage : public CDialog { // Construction public: CMessage(CWnd* pParent = NULL); // standard constructor CBrush m_brush; // Dialog Data //{{AFX_DATA(CMessage) enum { IDD = IDD_DIALOG_MESSAGE }; CLabel m_ERROR; CButton m_OK; CLabel m_MESSAGE; //}}AFX_DATA // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CMessage) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: // Generated message map functions //{{AFX_MSG(CMessage) afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); virtual BOOL OnInitDialog(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_MESSAGE_H__AC5068A9_1F8E_451D_AFB1_FFDEA02CF34F__INCLUDED_)
[ "faulfish@gmail.com" ]
faulfish@gmail.com
8b4956d17cd20bc7c4ac95dc6189263562b05f31
04f51a5ff3f3228cad23d75599f7832a89b381df
/์นด์นด์˜ค/2020 KAKAO BLIND RECRUITMENT/๊ฐ€์‚ฌ ๊ฒ€์ƒ‰.cpp
19db7267cd137c20241b0661dde6fa94422e677b
[]
no_license
thsgustlr0318/algorithm
241fea5f6be7399a000262233533cc11708ca65d
f7cca5dd6b2f69223adebfc2d6299d13aedd3154
refs/heads/master
2021-02-12T03:46:41.521266
2020-05-06T15:38:18
2020-05-06T15:38:18
244,558,586
2
0
null
null
null
null
UTF-8
C++
false
false
2,952
cpp
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <map> #include <unordered_map> using namespace std; vector<string> v[10001], vr[10001]; //์ด๋ถ„ ํƒ์ƒ‰ //์ •ํ™•์„ฑ, ํšจ์œจ์„ฑ ๋ชจ๋‘ ํ†ต๊ณผ vector<int> solution(vector<string> words, vector<string> queries) { vector<int> answer; int wsize = words.size(), qsize = queries.size(); answer.resize(qsize); //๋‹จ์–ด ๊ธธ์ด์— ๋”ฐ๋ผ v์™€ vr(reverse)์— ๋‹จ์–ด ๋„ฃ์Œ for (int i = 0; i < wsize; i++) { int len = words[i].size(); v[len].push_back(words[i]); reverse(words[i].begin(), words[i].end()); vr[len].push_back(words[i]); } //v, vr ์ •๋ ฌ for (int i = 1; i <= 10000; i++) { if(!v[i].empty()) sort(v[i].begin(), v[i].end()); if(!vr[i].empty()) sort(vr[i].begin(), vr[i].end()); } //๋ชจ๋“  queries ๋‹จ์–ด ํƒ์ƒ‰ for (int i = 0; i < qsize; i++) { string cur = queries[i]; int len = cur.size(); bool flag = true; //๋งŒ์•ฝ ?๊ฐ€ ์ ‘๋‘์‚ฌ์— ์˜ค๋ฉด if (queries[i][0] == '?') { flag = false; reverse(cur.begin(), cur.end()); } string low = cur, upp = cur; //low: ?๋ฅผ a๋กœ, upp: ?๋ฅผ z๋กœ //lower_bound์™€ upper_bound๋กœ ์ด๋ถ„ํƒ์ƒ‰ replace(low.begin(), low.end(), '?', 'a'); replace(upp.begin(), upp.end(), '?', 'z'); if (flag) { auto it1 = lower_bound(v[len].begin(), v[len].end(), low); auto it2 = upper_bound(v[len].begin(), v[len].end(), upp); answer[i] = distance(v[len].begin(), it2) - distance(v[len].begin(), it1); } else { auto it1 = lower_bound(vr[len].begin(), vr[len].end(), low); auto it2 = upper_bound(vr[len].begin(), vr[len].end(), upp); answer[i] = distance(vr[len].begin(), it2) - distance(vr[len].begin(), it1); } } return answer; } int main() { vector<string> words = { "frodo", "front", "frost", "frozen", "frame", "kakao" }; vector<string> queries = {"fro??", "????o", "fr???", "fro???", "pro?"}; solution(words, queries); } //unordered_map //์ •ํ™•์„ฑ ํ†ต๊ณผ, ํšจ์œจ์„ฑ 3๊ฐœ ํ†ต๊ณผ /* vector<int> solution(vector<string> words, vector<string> queries) { vector<int> answer; unordered_map<string, int> m; int wordsize = words.size(), querysize = queries.size(); answer.resize(querysize); for (int i = 0; i < wordsize; i++) { string cur = words[i]; int len = words[i].size(); string temp = cur; m[cur]++; for (int i = 0; i < len; i++) { temp[i] = '?'; m[temp]++; } temp = cur; for (int i = len - 1; i > 0; i--) { temp[i] = '?'; m[temp]++; } } for (int i = 0; i < querysize; i++) { answer[i] = m[queries[i]]; } return answer; } }*/
[ "61684785+thsgustlr0318@users.noreply.github.com" ]
61684785+thsgustlr0318@users.noreply.github.com
42a8a896b7485afff4ef829ca7203c98d5d9a801
deb442f461c572cc4c241964ae1793f0b38767f8
/WorldFinals/2011/D/D.cc
377ee028272de77807fdd932b8ab20515f5cabbd
[]
no_license
yuha/ICPC
ef0c83bddf01f19db214d05a36dfc56a08f0192b
4073e03ef904c0b2f77424b836265a35632d3014
refs/heads/master
2021-01-10T19:20:55.143360
2012-08-09T05:26:47
2012-08-09T05:26:47
2,208,133
2
0
null
null
null
null
UTF-8
C++
false
false
6,101
cc
#include <iostream> #include <vector> #include <map> #include <cassert> #include <climits> #include <cstdlib> using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; #define IN(x) (2*(x)) #define OUT(x) (2*(x)+1) const int LARGE_COST = 10000; ostream& operator<<(ostream& out, const vi& v) { for (int i = 0; i < v.size(); ++i) { if (i) { out << ','; } out << v[i]; } return out; } // ้–‰่ทฏใ‚’๏ผ‘ใค่ฟ”ใ™ใ€‚ // ้–‰่ทฏใŒใชใ„ๅ ดๅˆใฏ false ใ‚’่ฟ”ใ™ใ€‚ bool findLoopFrom(int N, const vvi& capacity, const vvi& costs, const vvi& flow, int s, vi& path) { vi dists(2*N, INT_MAX / 1000); dists[s] = 0; bool changed = true; for (int k = 0; changed && k < 2*N; ++k) { changed = false; for (int i = 0; i < 2*N; ++i) { for (int j = 0; j < 2*N; ++j) { // i->j ใธ่กŒใ‘ใ‚‹๏ผŸ if (capacity[i][j] - flow[i][j] > 0) { if (dists[i] + costs[i][j] < dists[j]) { dists[j] = dists[i] + costs[i][j]; path[j] = i; changed = true; } } // i->j ใธใ€j->i ใ‚’ใ‚‚ใจใซๆˆปใ‚ŠใชใŒใ‚‰ใ„ใ‘ใ‚‹ if (flow[j][i] > 0) { if (dists[i] - costs[j][i] < dists[j]) { dists[j] = dists[i] - costs[j][i]; path[j] = -i - 1; changed = true; } } if (j == s && dists[s] < 0) { return true; } } } } // ่ฒ ใฎ้–‰่ทฏใŒใ‚ใ‚‹ๅ ดๅˆใฏๅฎŸ่กŒๅฏ่ƒฝ return dists[s] < 0; } // TODO: ใ“ใฎ้–ขๆ•ฐใฏ็พŽใ—ใใชใ„ bool findLoop(int N, const vvi& capacity, const vvi& costs, const vvi& flow, int& s, vi& path) { for (s = 0; s < 2*N; ++s) { bool foundLoop = true; while (foundLoop && findLoopFrom(N, capacity, costs, flow, s, path)) { foundLoop = false; // path ใ‚’ใŸใฉใฃใฆ s ใ‹ใ‚‰ๅง‹ใพใฃใฆใ„ใ‚‹ใ‹็ขบ่ช...... // TODO: ใ™ใ‚‹ๅฟ…่ฆใฏใชใ„ใ‚“ใ ใ‘ใฉ... vi visited(2*N, 0); int prev, curr = s; visited[curr] = true; while (true) { prev = curr; curr = path[prev]; if (curr >= 0) { } else { curr = -curr - 1; } if (visited[curr]) { if (curr == s) return true; break; } else { visited[curr] = true; } } if (foundLoop) return true; } } return false; } void maxFlow(int N, const vvi& capacity, const vvi& costs, vvi& flow) { int s; vi path(2*N); while (findLoop(N, capacity, costs, flow, s, path)) { int curr = s; do { int prev = curr; curr = path[prev]; if (curr >= 0) { // prev -> curr ใธใ€flow ใ‚’๏ผ‘ใคๅข—ใ‚„ใ™ใ€‚ flow[curr][prev] += 1; } else { curr = -curr - 1; // curr -> prev ใธใ€flow ใ‚’๏ผ‘ใคๆธ›ใ‚‰ใ™ใ€‚ flow[prev][curr] -= 1; } } while (curr != s); } } int solve(int N, int A, int B, int componentCount, vvi caps, const vvi& costs) { int ans = 0; vvi flow(2*N, vi(2*N)); for (int m = 0; m <= N; ++m) { // cout << "m = " << m << endl; // capacity ใ‚’ๆ›ดๆ–ฐ for (int i = 0; i < N; ++i) { caps[IN(i)][OUT(i)] = m; } maxFlow(N, caps, costs, flow); // ans ใฎๆ•ฐใ‚’ๆ•ฐใˆใ‚‹ int totalAns = 0; int totalCost = 0; for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { if (flow[OUT(i)][IN(j)]) { ++totalAns; // cout << "i -> j : " << i << " -> " << j << endl; totalCost += costs[OUT(i)][IN(j)]; // cout << 1 << ' '; } else { // cout << 0 << ' '; } } // cout << endl; } #if 0 cout << "component = " << componentCount << endl; cout << "totalAns = " << totalAns << endl; cout << "totalCost = " << totalCost << endl; cout << "required = " << (-componentCount * LARGE_COST) << endl; cout << "A, B, m = " << A << "," << B << "," << m << endl; cout << m * B << endl; cout << A * totalAns << endl; #endif // m <= A/B * totalAns if (m * B <= A * totalAns && ans < totalAns && totalCost <= -componentCount * LARGE_COST) ans = totalAns; } return ans; } int main(void) { int caseNo = 0; for (int N, A, B; cin >> N >> A >> B, (N || A || B); ) { vvi capacities(2*N, vi(2*N)); vvi costs(2*N, vi(2*N)); int componentCount = 0; for (int i = 0; i < N; ++i) { string s; cin >> s; for (int j = 0; j < N; ++j) { switch (s[j]) { case '/': break; case 'C': costs[OUT(i)][IN(j)] = -LARGE_COST; capacities[OUT(i)][IN(j)] = 1; ++componentCount; break; case '.': costs[OUT(i)][IN(j)] = -1; capacities[OUT(i)][IN(j)] = 1; break; default: cout << "!" << s[j] << endl; abort(); break; } } } int ans = solve(N, A, B, componentCount, capacities, costs) - componentCount; cout << "Case " << ++caseNo << ": "; if (ans < 0) cout << "impossible" << endl; else cout << ans << endl; } return 0; }
[ "mayah@mayah.jp" ]
mayah@mayah.jp
aa310cc58ec0eba67ee8662b25aa9350ff6ef331
b82e39723d9addefbee5231c6ba229049164a655
/example-advanced/src/ofApp.cpp
a862870bbfb3d3a97f39bbea6ea9ff7d7bf280d3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
shenhuashan/ofxSMTP
031cfc9d1db96b5895447672c70e83891beda7b1
2ea7a7af8a70b57e6e6b42932b699f3fa043a98f
refs/heads/master
2022-02-22T21:18:52.728193
2018-06-08T05:15:43
2018-06-08T05:15:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,020
cpp
// // Copyright (c) 2013 Christopher Baker <https://christopherbaker.net> // // SPDX-License-Identifier: MIT // #include "ofApp.h" void ofApp::setup() { ofSetLogLevel(OF_LOG_VERBOSE); // Register for SSL Context events. ofSSLManager::registerClientEvents(this); // Set the name of the recipient for this example. recipientEmail = "info@christopherbaker.net"; // Set the sender email and display name. senderEmail = "Christopher Baker <info@christopherbaker.net>"; // Load credentials and account settings from an xml or json file. // auto settings = ofxSMTP::Settings::loadFromXML("example-smtp-account-settings.xml"); auto settings = ofxSMTP::Settings::loadFromJSON("example-smtp-account-settings.json"); // See ofxSMTP::Settings for extensive configuration options. // Pass the settings to the client. smtp.setup(settings); // Register event callbacks for message delivery (or failure) events smtpDeliveryListener = smtp.events.onSMTPDelivery.newListener(this, &ofApp::onSMTPDelivery); smtpExceptionListener = smtp.events.onSMTPException.newListener(this, &ofApp::onSMTPException); } void ofApp::draw() { // Print some information about the state of the outbox. ofBackground(80); std::stringstream ss; ss << " Press <SPACEBAR> to Send Text" << std::endl; ss << " Press <a> to Send an Image" << std::endl; ss << "ofxSMTP: There are " + ofToString(smtp.getOutboxSize()) + " messages in your outbox."; ofDrawBitmapStringHighlight(ss.str(), 10, 20); } void ofApp::keyPressed(int key) { if (key == ' ') // Press spacebar for a simple send. { // Send a simple short message. smtp.send(recipientEmail, // Recipient email. senderEmail, // Sender email. "I'm trying out ofxSMTP!", // Subject line. "It works!"); // Message body. } else if(key == 'a') // Press 'a' for an advanced send with attachment. { // You can construct complex messages using POCO's MailMessage object. // See http://pocoproject.org/docs/Poco.Net.MailMessage.html auto message = std::make_shared<Poco::Net::MailMessage>(); // Encode the sender and set it. message->setSender(Poco::Net::MailMessage::encodeWord(senderEmail, "UTF-8")); // Mark the primary recipient and add them. message->addRecipient(Poco::Net::MailRecipient(Poco::Net::MailRecipient::PRIMARY_RECIPIENT, recipientEmail)); // Encode the subject and set it. message->setSubject(Poco::Net::MailMessage::encodeWord("I'm sending you an image using ofxSMTP!", "UTF-8")); // Poco::Net::MailMessage will take ownership of the *PartSource files, // so you don't have to worry about deleting the pointers. message->addContent(new Poco::Net::StringPartSource("Hello world! How about an image?")); // Poco::Net::MailMessage throws exceptions when a file is not found. // Thus, we need to add attachments in a try / catch block. try { message->addAttachment(Poco::Net::MailMessage::encodeWord("of.png","UTF-8"), new Poco::Net::FilePartSource(ofToDataPath("of.png", true))); } catch (const Poco::OpenFileException& exc) { ofLogError("ofApp::keyPressed") << exc.name() << " : " << exc.displayText(); } // Add an additional header, just because we can. message->add("X-Mailer", "ofxSMTP (https://github.com/bakercp/ofxSMTP)"); // Add the message to our outbox. smtp.send(message); } } void ofApp::onSMTPDelivery(std::shared_ptr<Poco::Net::MailMessage>& message) { ofLogNotice("ofApp::onSMTPDelivery") << "Message Sent: " << message->getSubject(); } void ofApp::onSMTPException(const ofxSMTP::ErrorArgs& evt) { ofLogError("ofApp::onSMTPException") << evt.error().displayText(); if (evt.message()) { ofLogError("ofApp::onSMTPException") << evt.message()->getSubject(); } } void ofApp::onSSLClientVerificationError(Poco::Net::VerificationErrorArgs& args) { ofLogNotice("ofApp::onClientVerificationError") << std::endl << ofToString(args); // If you want to proceed, you must allow the user to inspect the certificate // and set `args.setIgnoreError(true);` if they want to continue. // args.setIgnoreError(true); } void ofApp::onSSLPrivateKeyPassphraseRequired(std::string& passphrase) { // If you want to proceed, you must allow the user to input the assign the private key's // passphrase to the `passphrase` argument. For example: passphrase = ofSystemTextBoxDialog("Enter the Private Key Passphrase", ""); }
[ "me@christopherbaker.net" ]
me@christopherbaker.net
06c0352fde17494f0775b6a90edd760c473d395f
0caf30e643f78229a7ef8742cc1d5386bc045ec1
/programming-language/cpp/grid-service/NwfdMainApp/ProviderBase.h
2dbb9fe156d2505921d06d5e496ce7d78ff4a395
[]
no_license
AlexiaChen/Adrasteia
feb1957dd694f79315784000c6f73f35bc5ca18f
1b9b29d5565a41250119e42c47aa0a4a588cef9c
refs/heads/master
2020-11-29T11:59:50.580203
2018-09-09T10:49:10
2018-09-09T10:49:10
87,497,591
3
0
null
null
null
null
UTF-8
C++
false
false
3,152
h
๏ปฟ/************************************************************************* * Copyright (C), 2015, * XXXXXXXXXXX Co. * ๆ–‡ไปถๅ: ProviderBase.h * ไฝœ ่€…: zhangl ็‰ˆๆœฌ๏ผš1.0 ๆ—ฅ ๆœŸ๏ผš2015/05/08 * ๆ ่ฟฐ๏ผš็ผ“ๅญ˜ๅค„็†ๅŸบ็ฑป๏ผˆๆŽฅๅฃ๏ผ‰ * ๅ…ถ ไป–๏ผš * ๅŠŸ่ƒฝๅˆ—่กจ: * 1. ๅฎšไน‰็ผ“ๅญ˜ๅค„็†็š„ๅŸบๆœฌๆ“ไฝœๆ–นๆณ• * * ไฟฎๆ”นๆ—ฅๅฟ—๏ผš * No. ๆ—ฅๆœŸ ไฝœ่€… ไฟฎๆ”นๅ†…ๅฎน * 1 2015/05/13 zhangl ๆทปๅŠ Key-Value่ฏปๅ†™ๆ–นๆณ•๏ผˆfor MemCached/redis๏ผ‰ * 2 2015/05/15 zhangl ๆทปๅŠ memcached็š„็‰นๆฎŠ้”ๅค„็† *************************************************************************/ #ifndef PROVIDER_BASE_H #define PROVIDER_BASE_H #include "stdio.h" /************************************************************************/ /* ็ฑป ๅ๏ผš ProviderBase */ /* ็ˆถ ็ฑป๏ผš - */ /* ่ฏด ๆ˜Ž๏ผš ็ผ“ๅญ˜ๅค„็†ๅŸบ็ฑป */ /* ๆ ่ฟฐ๏ผš ๆ‰€ๆœ‰็ฑปๅž‹็š„็ผ“ๅญ˜้ƒฝ่ฆ็ปงๆ‰ฟๆญค็ฑป๏ผŒๅฎž็Žฐๅ…ถๆŽฅๅฃๅฎšไน‰็š„ๆ–นๆณ•๏ผŒๆ“ไฝœ็ผ“ๅญ˜ */ /************************************************************************/ class ProviderBase { public: ProviderBase(); virtual ~ProviderBase(); public: // ๅŸบๆœฌๅ†…ๅฎน void SetProviderName(const char *strProviderName); // ่ฟžๆŽฅ virtual bool SetConnectParam(const char *strServerIP, int nPortNo); virtual bool Connect(const char *strServerIP, int nPortNo); virtual bool Connect(); virtual void DisConnect(); virtual bool ReConnect(); virtual bool ConnectStatus(); // ๅขžๅˆ ๆ”นๆŸฅๆ“ไฝœ // 1ใ€ ๅŸบๆœฌๆ“ไฝœ virtual bool FlushDB(); virtual bool DelKey(const char * strKey); virtual bool IsExistsKey(const char * strKey); // 2ใ€Key-Value ๆ•ฐๆฎๅ†™/่ฏป(ไฝฟ็”จไบŽRedisๅ’ŒMemcached) virtual bool SetValue(const char * strKey, const char * szValue, int nValueSize, int nExpirationTime = 0); virtual bool AppendValue(const char * strKey, const char * szValue, int nValueSize); virtual char *GetValue(const char * strKey, int & nValueSize); // 3ใ€Redis Set็ฑปๅž‹ virtual bool AddSMember(const char * strKey, const char * strValue); virtual bool RemoveSMember(const char * strKey, const char * strValue); virtual bool GetSMembers(const char * strKey, char(*pValArray)[256], int &nCount); virtual bool IsSMember(const char * strKey, const char * strValue); // 4ใ€Redis hash็ฑปๅž‹ virtual bool SetHValue(const char * strKey, const char * strField, const char * strValue); virtual bool DelHField(const char * strKey, const char * strField); virtual bool GetHValue(const char * strKey, const char * strField, char * strValue); virtual char * GetHValue(const char * strKey, const char * strField); // 5ใ€็‰นๆฎŠๅค„็†๏ผˆfor memcached๏ผ‰ virtual bool LockKey(const char * strKey, int nExpirationTime = 1); virtual bool UnLockKey(const char *strKey); virtual int GetLastError(); public: char m_strProviderName[50]; // ๅ็งฐ char m_strServerIP[32]; // ็ผ“ๅญ˜ Server IPๅœฐๅ€ int m_nPortNo; // ็ผ“ๅญ˜ Server ็ซฏๅฃ bool m_bConStatus; // ่ฟžๆŽฅ็Šถๆ€ }; #endif //PROVIDER_BASE_H
[ "brainfvck@foxmail.com" ]
brainfvck@foxmail.com
39647b9606042e9148402b385fbc5e529999f387
da50cb2f2da79a0f9503d57f685d070543402311
/Source/CoopGame/Public/SHealthComponent.h
8298c5479807290144cbfbbca568e37e53b3364c
[]
no_license
vsensu/CoopGame
d9831951e79b63d7f764f8b9fe613f05fcea9a25
02961ef871cbf7996d6818b13c94bcb6cf68bdfa
refs/heads/master
2022-10-27T11:46:24.822795
2020-06-09T06:50:26
2020-06-09T06:50:26
267,760,381
0
0
null
null
null
null
UTF-8
C++
false
false
1,245
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "Components/ActorComponent.h" #include "SHealthComponent.generated.h" DECLARE_DYNAMIC_MULTICAST_DELEGATE_SixParams(FOnHealthChangedSignature, USHealthComponent*, HealthComp, float, Health, float, HealthDelta, const class UDamageType*, DamageType, class AController*, InstigatedBy, AActor*, DamageCauser); UCLASS( ClassGroup=(COOP), meta=(BlueprintSpawnableComponent) ) class COOPGAME_API USHealthComponent : public UActorComponent { GENERATED_BODY() public: // Sets default values for this component's properties USHealthComponent(); protected: // Called when the game starts virtual void BeginPlay() override; UPROPERTY(Replicated, BlueprintReadOnly, Category="HealthComponent") float Health; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="HealthComponent") float DefaultHealth; UFUNCTION() void HandleTakeAnyDamage(AActor* DamagedActor, float Damage, const class UDamageType* DamageType, class AController* InstigatedBy, AActor* DamageCauser); public: UPROPERTY(BlueprintAssignable, Category="Events") FOnHealthChangedSignature OnHealthChanged; };
[ "vsensu@foxmail.com" ]
vsensu@foxmail.com
45b72820b5c4e7fe09f04c6cf34982cda521d717
1664303ee9ca94a2d72a4a6b5aa567f569de8e25
/ArkDll/ArkLib.h
1976b17732b11f179f95b26be8ced6162baf9fc2
[]
no_license
laikun81/WpfApplication1
8c68fcfbf0893a76a04ee7a06ab63e5b1b09d192
2cd53ac229c7b2154ba555fa5acf8c0d76dbc37c
refs/heads/master
2021-01-25T10:00:31.983636
2016-01-23T16:33:08
2016-01-23T16:33:08
42,751,536
0
0
null
2016-01-23T16:33:09
2015-09-18T23:24:36
C#
UHC
C++
false
false
13,331
h
//////////////////////////////////////////////////////////////////////////////////////////////////// /// /// Ark Library Wrapper class /// /// @author parkkh /// @date Thursday, January 07, 2010 11:18:16 AM /// /// Copyright(C) 2008-2011 Bandisoft, All rights reserved. /// //////////////////////////////////////////////////////////////////////////////////////////////////// #ifndef _ARK_LIB_H_ #define _ARK_LIB_H_ #include "Ark.h" #ifdef _WIN64 # ifdef _DEBUG # define ARK_DLL_FILE_NAME _T("Ark64_d.dll") # define ARKZIP_DLL_FILE_NAME _T("ArkZip64_d.dll") # else # define ARK_DLL_FILE_NAME _T("Ark64.dll") # define ARKZIP_DLL_FILE_NAME _T("ArkZip64.dll") # endif # define ARK_DLL_RELEASE_FILE_NAME _T("Ark64.dll") # define ARKZIP_DLL_RELEASE_FILE_NAME _T("ArkZip64.dll") #elif defined(_WIN32) # ifdef _DEBUG # define ARK_DLL_FILE_NAME _T("Ark32_d.dll") # define ARKZIP_DLL_FILE_NAME _T("ArkZip32_d.dll") # else # define ARK_DLL_FILE_NAME _T("Ark32.dll") # define ARKZIP_DLL_FILE_NAME _T("ArkZip32.dll") # endif # define ARK_DLL_RELEASE_FILE_NAME _T("Ark32.dll") # define ARKZIP_DLL_RELEASE_FILE_NAME _T("ArkZip32.dll") #endif #ifndef _WIN32 # ifdef __APPLE__ # define ARK_DLL_FILE_NAME "./ark64.dylib" # else # if defined(__x86_64__) || defined(__ia64__) || defined(_M_AMD64) || defined(_M_IA64) || defined(_WIN64) || defined(__alpha__) || defined(__s390__) # define ARK_DLL_FILE_NAME "./ark64.so" # else # define ARK_DLL_FILE_NAME "./ark32.so" # endif # endif // __APPLE__ # define ARK_DLL_RELEASE_FILE_NAME ARK_DLL_FILE_NAME #endif // _WIN32 #define ARK_EXPORTED_FUNCTION_NAME "CreateArk" #define ARKCOMPRESSOR_EXPORTED_FUNCTION_NAME "CreateArkCompressor" #ifndef _WIN32 # include <dlfcn.h> # define HMODULE void* # define LoadLibrary(name) dlopen(name, RTLD_NOW | RTLD_GLOBAL) # define GetProcAddress(handle, func) dlsym(handle, func) # define FreeLibrary(handle) dlclose(handle) # include <string> #endif #ifndef _INC_TCHAR # ifdef _UNICODE # define _T(x) L##x # else # define _T(x) x # endif #endif #ifdef _UNICODE typedef const wchar_t* LPCTSTR; #else typedef const char* LPCTSTR; #endif typedef IArk* (*LPCREATEARK)(UINT32 version); typedef IArkCompressor* (*LPCREATEARKCOMPRESSOR)(UINT32 version); #ifndef ASSERT # include <stdio.h> # define ASSERT(x) printf("Assert at %s %d\n", __FILE__, __LINE__) #endif class CArkLib : public IArk { public : CArkLib() { m_hDll = NULL; m_pCreateArk = NULL; m_pCreateArkCompressor = NULL; m_pArk = NULL; } ~CArkLib() { Destroy(); } #ifndef _ARK_USE_AS_LIB // .dll ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ ARKERR Create(LPCTSTR szDllPathName) { if(m_hDll) {ASSERT(0); return ARKERR_ALREADY_DLL_CREATED;} m_hDll = LoadLibrary(szDllPathName); if(m_hDll==NULL) { m_hDll = LoadLibrary(ARK_DLL_RELEASE_FILE_NAME); if(m_hDll==NULL) { #ifndef _WIN32 printf("Load %s failed.(Reason: '%s')\n", szDllPathName, dlerror()); #endif ASSERT(0); return ARKERR_LOADLIBRARY_FAILED; } } m_pCreateArk = (LPCREATEARK)GetProcAddress(m_hDll, ARK_EXPORTED_FUNCTION_NAME); m_pCreateArkCompressor = (LPCREATEARKCOMPRESSOR)GetProcAddress(m_hDll, ARKCOMPRESSOR_EXPORTED_FUNCTION_NAME); if(m_pCreateArk==NULL) { #ifndef _WIN32 printf("dlsym() failed.(Reason: '%s')\n", dlerror()); #endif ASSERT(0); FreeLibrary(m_hDll); m_hDll = NULL; return ARKERR_GETPROCADDRESS_FAILED; } m_pArk = (m_pCreateArk)(ARK_LIBRARY_VERSION); if(m_pArk==NULL) { ASSERT(0); FreeLibrary(m_hDll); m_hDll = NULL; return ARKERR_INVALID_VERSION; } return ARKERR_NOERR; } #endif // not _ARK_USE_AS_LIB IArkCompressor* CreateCompressor() { return m_pCreateArkCompressor ? m_pCreateArkCompressor(ARK_LIBRARY_VERSION) : NULL; } /* IArk* _CreateNewArk() { return m_pCreateArk ? (m_pCreateArk)(ARK_LIBRARY_VERSION) : NULL; } */ IArk* GetIArk() { return m_pArk; } #ifdef _ARK_USE_AS_LIB // .lib ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ ARKERR CreateLib() { m_pArk = CreateArkLib(ARK_LIBRARY_VERSION); if(m_pArk==NULL) { ASSERT(0); return ARKERR_INVALID_VERSION; } return ARKERR_NOERR; } #endif BOOL32 IsCreated() { return m_pArk ? TRUE : FALSE; } void Destroy() { if(m_pArk) m_pArk->Release(); m_pArk = NULL; m_pCreateArk = NULL; if(m_hDll) FreeLibrary(m_hDll); m_hDll = NULL; } public : // IArk ARKMETHOD(void) Release() { Destroy(); } #ifndef _WIN32 // posix ์šฉ std::string ์ธํ„ฐํŽ˜์ด์Šค ARKMETHOD(BOOL32) Open(std::string name, std::string pass){ return Open(name.c_str(), pass.c_str()); } ARKMETHOD(BOOL32) Open(std::string name, const char* pass){ return Open(name.c_str(), pass); } ARKMETHOD(BOOL32) ExtractOneTo(int index,std::string dest){ return ExtractOneTo(index, dest.c_str()); }; ARKMETHOD(BOOL32) ExtractAllTo(std::string dest) { return ExtractAllTo(dest.c_str()); }; ARKMETHOD(BOOL32) ExtractMultiFileTo(std::string dest) { return ExtractMultiFileTo(dest.c_str()); } ARKMETHOD(ARK_FF) CheckFormat(std::string name) const { return CheckFormat(name.c_str()); } #endif ARKMETHOD(BOOL32) Open(LPCSTR filePath, LPCSTR password=NULL) { return m_pArk ? m_pArk->Open(filePath, password) : FALSE; } ARKMETHOD(BOOL32) Open(LPCWSTR filePath, LPCWSTR password=NULL) { return m_pArk ? m_pArk->Open(filePath, password) : FALSE; } ARKMETHOD(BOOL32) Open(ARKBYTE* src, int srcLen, LPCWSTR password=NULL) { return m_pArk ? m_pArk->Open(src, srcLen, password) : FALSE; } ARKMETHOD(BOOL32) Open(IArkSimpleInStream* srcStream, LPCWSTR password=NULL) { return m_pArk ? m_pArk->Open(srcStream, password) : FALSE; } ARKMETHOD(void) Close() { if(m_pArk) m_pArk->Close(); } ARKMETHOD(BOOL32) TestArchive() { return m_pArk ? m_pArk->TestArchive() : FALSE; } ARKMETHOD(ARK_FF) CheckFormat(LPCSTR filePath) const { return m_pArk ? m_pArk->CheckFormat(filePath) : ARK_FF_UNKNOWN; } ARKMETHOD(ARK_FF) CheckFormat(LPCWSTR filePath) const { return m_pArk ? m_pArk->CheckFormat(filePath) : ARK_FF_UNKNOWN; } ARKMETHOD(ARK_FF) CheckFormat(const unsigned char* buffer, int bufLen) const { return m_pArk ? m_pArk->CheckFormat(buffer, bufLen) : ARK_FF_UNKNOWN; } ARKMETHOD(void) SetPassword(LPCSTR password) { if(m_pArk) m_pArk->SetPassword(password); } ARKMETHOD(void) SetPassword(LPCWSTR password) { if(m_pArk) m_pArk->SetPassword(password); } ARKMETHOD(int) GetFileItemCount() const { return m_pArk ? m_pArk->GetFileItemCount() : 0; } ARKMETHOD(const SArkFileItem*) GetFileItem(int index) const { return m_pArk ? m_pArk->GetFileItem(index) : NULL; } ARKMETHOD(ARK_FF) GetFileFormat() const { return m_pArk ? m_pArk->GetFileFormat() : ARK_FF_UNKNOWN; } ARKMETHOD(BOOL32) IsBrokenArchive() const { return m_pArk ? m_pArk->IsBrokenArchive() : FALSE; } ARKMETHOD(BOOL32) IsEncryptedArchive() const { return m_pArk ? m_pArk->IsEncryptedArchive() : FALSE; } ARKMETHOD(BOOL32) IsSolidArchive() const { return m_pArk ? m_pArk->IsSolidArchive() : FALSE; } ARKMETHOD(BOOL32) IsOpened() const { return m_pArk ? m_pArk->IsOpened() : FALSE; } ARKMETHOD(BOOL32) ExtractAllTo(LPCSTR szDestPath) { return m_pArk ? m_pArk->ExtractAllTo(szDestPath) : FALSE; } ARKMETHOD(BOOL32) ExtractAllTo(LPCWSTR szDestPath) { return m_pArk ? m_pArk->ExtractAllTo(szDestPath) : FALSE; } ARKMETHOD(BOOL32) ExtractAllTo(IArkSimpleOutStream* pOutStream) { return m_pArk ? m_pArk->ExtractAllTo(pOutStream) : FALSE; } ARKMETHOD(BOOL32) ExtractOneTo(int index, LPCSTR szDestPath) { return m_pArk ? m_pArk->ExtractOneTo(index, szDestPath) : FALSE; } ARKMETHOD(BOOL32) ExtractOneTo(int index, LPCWSTR szDestPath) { return m_pArk ? m_pArk->ExtractOneTo(index, szDestPath) : FALSE; } ARKMETHOD(BOOL32) ExtractOneTo(int index, IArkSimpleOutStream* pOutStream) { return m_pArk ? m_pArk->ExtractOneTo(index, pOutStream) : FALSE; } ARKMETHOD(BOOL32) ExtractOneTo(int index, ARKBYTE* outBuf, int outBufLen) { return m_pArk ? m_pArk->ExtractOneTo(index, outBuf, outBufLen) : FALSE; } ARKMETHOD(BOOL32) ExtractOneAs(int index, LPCWSTR filePathName, WCHAR resultPathName[ARK_MAX_PATH]) { return m_pArk ? m_pArk->ExtractOneAs(index, filePathName, resultPathName) : FALSE; } ARKMETHOD(BOOL32) AddIndex2ExtractList(int nIndex) { return m_pArk ? m_pArk->AddIndex2ExtractList(nIndex) : FALSE; } ARKMETHOD(void) ClearExtractList() { if(m_pArk) m_pArk->ClearExtractList(); } ARKMETHOD(int) GetExtractListCount() const { return m_pArk ? m_pArk->GetExtractListCount() : 0; } ARKMETHOD(BOOL32) ExtractMultiFileTo(LPCSTR szDestPath) { return m_pArk ? m_pArk->ExtractMultiFileTo(szDestPath) : FALSE; } ARKMETHOD(BOOL32) ExtractMultiFileTo(LPCWSTR szDestPath, LPCWSTR szPath2Remove=NULL) { return m_pArk ? m_pArk->ExtractMultiFileTo(szDestPath, szPath2Remove) : FALSE; } ARKMETHOD(BOOL32) ExtractMultiFileTo(IArkSimpleOutStream* pOutStream) { return m_pArk ? m_pArk->ExtractMultiFileTo(pOutStream) : FALSE; } ARKMETHOD(BOOL32) SetEvent(IArkEvent* pProgress) { return m_pArk ? m_pArk->SetEvent(pProgress) : FALSE; } ARKMETHOD(ARKERR) GetLastError() const { return m_pArk ? m_pArk->GetLastError() : ARKERR_LIBRARY_NOT_LOADED ; } ARKMETHOD(UINT32) GetLastSystemError() const { return m_pArk ? m_pArk->GetLastSystemError() : 0 ; } ARKMETHOD(void) SetCodePage(SArkCodepage cp) { if(m_pArk) m_pArk->SetCodePage(cp); } ARKMETHOD(LPCWSTR) EncryptionMethod2Str(ARK_ENCRYPTION_METHOD method) const { return m_pArk ? m_pArk->EncryptionMethod2Str(method) : NULL; } ARKMETHOD(LPCWSTR) CompressionMethod2Str(ARK_COMPRESSION_METHOD method) const { return m_pArk ? m_pArk->CompressionMethod2Str(method) : NULL; } ARKMETHOD(LPCWSTR) FileFormat2Str(ARK_FF ff) const { return m_pArk ? m_pArk->FileFormat2Str(ff) : NULL; } ARKMETHOD(void) SetGlobalOpt(const SArkGlobalOpt& opt) { if(m_pArk) m_pArk->SetGlobalOpt(opt); } ARKMETHOD(INT64) GetArchiveFileSize() const { return m_pArk ? m_pArk->GetArchiveFileSize() : 0; } ARKMETHOD(INT64) GetArchiveStartPos() const { return m_pArk ? m_pArk->GetArchiveStartPos() : 0; } ARKMETHOD(LPCWSTR) GetFilePathName() const { return m_pArk ? m_pArk->GetFilePathName() : NULL; } ARKMETHOD(int) FindIndex(LPCWSTR szFileNameW, LPCSTR szFileNameA, BOOL32 bCaseSensitive) const { return m_pArk ? m_pArk->FindIndex(szFileNameW, szFileNameA, bCaseSensitive) : -1; } ARKMETHOD(LPCWSTR) GetArchiveComment() const { return m_pArk ?m_pArk->GetArchiveComment() : NULL; } ARKMETHOD(ARK_MULTIVOL_STYLE) GetMultivolStyle() const { return m_pArk ?m_pArk->GetMultivolStyle() : ARK_MULTIVOL_STYLE_NONE; } ARKMETHOD(int) GetMultivolCount() const { return m_pArk ?m_pArk->GetMultivolCount() : 0; } ARKMETHOD(LPCWSTR) GetMultivolFilePathName(int volume) const { return m_pArk ?m_pArk->GetMultivolFilePathName(volume) : NULL; } ARKMETHOD(BOOL32) DetectCurrentArchivesCodepage(SArkDetectCodepage& dcp) const { return m_pArk ?m_pArk->DetectCurrentArchivesCodepage(dcp) : FALSE; } ARKMETHOD(BOOL32) ChangeCurrentArchivesCodepage(int codePage) { return m_pArk ?m_pArk->ChangeCurrentArchivesCodepage(codePage) : FALSE; } ////////////////////////// // undocumented ARKMETHOD(LPCWSTR) _GetAlias() { return m_pArk ? m_pArk->_GetAlias() : NULL; } ARKMETHOD(void) _SetAlias(LPCWSTR szAlias) { if(m_pArk) m_pArk->_SetAlias(szAlias); } ARKMETHOD(const void*) _GetBondFileInfo() { return m_pArk ? m_pArk->_GetBondFileInfo() : 0; } ARKMETHOD(void) _SetUserKey(void* key) { if(m_pArk) m_pArk->_SetUserKey(key); } ARKMETHOD(UINT32) _CheckCRC32(LPCWSTR filePath) { return m_pArk ? m_pArk->_CheckCRC32(filePath) : 0; } ARKMETHOD(void*) _GetExtractor() { return m_pArk ? m_pArk->_GetExtractor(): NULL; } ARKMETHOD(void*) _GetInStream() { return m_pArk ? m_pArk->_GetInStream(): NULL; } ARKMETHOD(BOOL32) _DisableItem(int index) { return m_pArk ? m_pArk->_DisableItem(index): FALSE; } ARKMETHOD(void) _Test() { if(m_pArk) m_pArk->_Test(); } // for c++ builder only ARKMETHOD(BOOL32) _OpenW(LPCWSTR filePath, LPCWSTR password=NULL) { return m_pArk ? m_pArk->_OpenW(filePath, password) : FALSE; } ARKMETHOD(ARK_FF) _CheckFormatW(LPCWSTR filePath) const { return m_pArk ? m_pArk->_CheckFormatW(filePath) : ARK_FF_UNKNOWN; } ARKMETHOD(void) _SetPasswordW(LPCWSTR password) { if(m_pArk) m_pArk->_SetPasswordW(password); } ARKMETHOD(BOOL32) _ExtractAllToW(LPCWSTR folderPath) { return m_pArk ? m_pArk->_ExtractAllToW(folderPath) : FALSE; } ARKMETHOD(BOOL32) _ExtractOneToW(int index, LPCWSTR folderPath) { return m_pArk ? m_pArk->_ExtractOneToW(index, folderPath) : FALSE; } ARKMETHOD(BOOL32) _ExtractMultiFileToW(LPCWSTR szDestPath, LPCWSTR szPath2Remove=NULL) { return m_pArk ? m_pArk->_ExtractMultiFileToW(szDestPath, szPath2Remove) : FALSE; } private : HMODULE m_hDll; LPCREATEARK m_pCreateArk; LPCREATEARKCOMPRESSOR m_pCreateArkCompressor; IArk* m_pArk; }; #endif // _ARK_LIB_H_
[ "laikun81@gmail.com" ]
laikun81@gmail.com
cab6bca4eea5be100186e997cd577633e7a04b3e
037d518773420f21d74079ee492827212ba6e434
/blazetest/src/mathtest/smatsmatsub/MIbMIa.cpp
190d25c414e62d7c9a4f84bdf976dd55aa281a44
[ "BSD-3-Clause" ]
permissive
chkob/forked-blaze
8d228f3e8d1f305a9cf43ceaba9d5fcd603ecca8
b0ce91c821608e498b3c861e956951afc55c31eb
refs/heads/master
2021-09-05T11:52:03.715469
2018-01-27T02:31:51
2018-01-27T02:31:51
112,014,398
0
0
null
null
null
null
UTF-8
C++
false
false
3,922
cpp
//================================================================================================= /*! // \file src/mathtest/smatsmatsub/MIbMIa.cpp // \brief Source file for the MIbMIa sparse matrix/sparse matrix subtraction math test // // Copyright (C) 2012-2018 Klaus Iglberger - All Rights Reserved // // This file is part of the Blaze library. You can redistribute it and/or modify it under // the terms of the New (Revised) BSD License. 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. // 3. Neither the names of the Blaze development group nor the names of its contributors // may be used to endorse or promote products derived from this software without specific // prior written permission. // // 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 HOLDER 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. */ //================================================================================================= //************************************************************************************************* // Includes //************************************************************************************************* #include <cstdlib> #include <iostream> #include <blaze/math/IdentityMatrix.h> #include <blazetest/mathtest/Creator.h> #include <blazetest/mathtest/smatsmatsub/OperationTest.h> #include <blazetest/system/MathTest.h> //================================================================================================= // // MAIN FUNCTION // //================================================================================================= //************************************************************************************************* int main() { std::cout << " Running 'MIbMIa'..." << std::endl; using blazetest::mathtest::TypeA; using blazetest::mathtest::TypeB; try { // Matrix type definitions typedef blaze::IdentityMatrix<TypeA> MIa; typedef blaze::IdentityMatrix<TypeB> MIb; // Creator type definitions typedef blazetest::Creator<MIa> CMIa; typedef blazetest::Creator<MIb> CMIb; // Running tests with small matrices for( size_t i=0UL; i<=6UL; ++i ) { RUN_SMATSMATSUB_OPERATION_TEST( CMIb( i ), CMIa( i ) ); } // Running tests with large matrices RUN_SMATSMATSUB_OPERATION_TEST( CMIb( 67UL ), CMIa( 67UL ) ); RUN_SMATSMATSUB_OPERATION_TEST( CMIb( 128UL ), CMIa( 128UL ) ); } catch( std::exception& ex ) { std::cerr << "\n\n ERROR DETECTED during sparse matrix/sparse matrix subtraction:\n" << ex.what() << "\n"; return EXIT_FAILURE; } return EXIT_SUCCESS; } //*************************************************************************************************
[ "klaus.iglberger@gmail.com" ]
klaus.iglberger@gmail.com
f66a9d291d5b6ce6d4fe22062126fded9d521a27
be0204c1b95839adee1ad204be022be38e32e2d6
/Programmers/์ž๋ฌผ์‡ ์™€ ์—ด์‡ .cpp
57d3ff908b9e7018afc14f3e09dc57fada6c19e6
[]
no_license
tlsdorye/Problem-Solving
507bc8d3cf1865c10067ef2e8eb7cb2ee42e16dd
5c112d2238bfb1fc092612a76f10c7785ba86c78
refs/heads/master
2021-06-12T19:19:19.337092
2021-04-23T06:39:43
2021-04-23T06:39:43
179,432,390
4
0
null
null
null
null
UTF-8
C++
false
false
1,945
cpp
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <stack> using namespace std; vector<vector<int>> rotate(vector<vector<int>>& key); void print(vector<vector<int>>& map); bool check(vector<vector<int>>& map, vector<vector<int>>& key, int x, int y, int N); bool solution(vector<vector<int>> key, vector<vector<int>> lock) { int M = key.size(); int N = lock.size(); int K = N + 2 * M - 2; vector<vector<int>> map(K, vector<int>(K, 0)); for (int i = M - 1; i < N + M - 1; i++) for (int j = M - 1; j < N + M - 1; j++) map[i][j] = lock[i - M + 1][j - M + 1]; for (int k = 0; k < 4; k++) { key = rotate(key); //print(key); for (int i = 0; i < K - M + 1; i++) { bool flag = true; for (int j = 0; j < K - M + 1; j++) { if (!check(map, key, i, j, N)) { //printf("%2d %2d %2d: false\n", k, i, j); flag = false; } else { //printf("%2d %2d %2d: true\n", k, i, j); return true; } } if (flag) break; } } return false; } vector<vector<int>> rotate(vector<vector<int>>& key) { int M = key.size(); vector<vector<int>> ret(M, vector<int>(M, 0)); for (int i = 0; i < M; i++) for (int j = 0; j < M; j++) ret[i][j] = key[-j + M - 1][i]; return ret; } void print(vector<vector<int>>& map) { for (int i = 0; i < map.size(); i++, printf("\n")) for (int j = 0; j < map[i].size(); j++) printf("%d ", map[i][j]); } bool check(vector<vector<int>>& map, vector<vector<int>>& key, int x, int y, int N) { bool ret = true; int M = key.size(); for (int i = x; i < x + M; i++) for (int j = y; j < y + M; j++) map[i][j] += key[i - x][j - y]; for (int i = M - 1; i < N + M - 1; i++) { for (int j = M - 1; j < N + M - 1; j++) if (map[i][j] != 1) { ret = false; break; } if (!ret) break; } for (int i = x; i < x + M; i++) for (int j = y; j < y + M; j++) map[i][j] -= key[i - x][j - y]; return ret; }
[ "tlsdorye@gmail.com" ]
tlsdorye@gmail.com
6058d43c3fd909898abf19a33ecb0fe385a8285c
57a2ff675497083c6c126279d64da6caf10e1022
/include/RE/BSResource/Info.h
81ab6bb475ad050eb804f91932710700fb7f86b3
[ "MIT" ]
permissive
lfrazer/CommonLibVR
be07b8837034e069addae3309da872bb606bd585
0fabedac02c4d97b7d54199098561be8c0c666ef
refs/heads/master
2021-12-30T23:04:52.654616
2021-09-26T18:39:22
2021-09-26T18:39:22
252,837,323
7
7
MIT
2021-05-08T17:53:09
2020-04-03T20:45:36
C++
UTF-8
C++
false
false
248
h
#pragma once namespace RE { namespace BSResource { struct Info { public: // members FILETIME modifyTime; // 00 FILETIME createTime; // 08 LARGE_INTEGER fileSize; // 10 }; STATIC_ASSERT(sizeof(Info) == 0x18); } }
[ "ryan__mckenzie@hotmail.com" ]
ryan__mckenzie@hotmail.com
484e4864f1a965411f626116eae3985f9564c0fd
86542fb3d5cd67dd9db3321ce93fc08fb9836cd5
/include/opengm/inference/lp_inference.hxx
0e1877aedf5f34e610b3da3b6fdd8739646bb643
[ "MIT" ]
permissive
herr-biber/opengm
b9df4a15b8a589ffcbc35f73f58ebd9f078275d1
b4682520500b8fbe9f7b5ef008d162156d33b59c
refs/heads/master
2021-01-24T23:00:07.914480
2013-11-21T15:53:20
2013-11-21T15:53:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,463
hxx
#pragma once #ifndef OPENGM_GENERIC_LP_INFERENCE_HXX #define OPENGM_GENERIC_LP_INFERENCE_HXX #include <vector> #include <string> #include <sstream> #include <iostream> #include "opengm/opengm.hxx" #include "opengm/inference/visitors/visitor.hxx" #include "opengm/inference/inference.hxx" #include "opengm/datastructures/buffer_vector.hxx" #include "lp_inference_base.hxx" namespace opengm { template<class GM, class ACC,class LP_SOLVER> class LPInference : public LpInferenceBase<GM,ACC>, public Inference<GM, ACC> { public: enum Relaxation { FirstOrder,FirstOrder2 }; typedef ACC AccumulationType; typedef GM GraphicalModelType; OPENGM_GM_TYPE_TYPEDEFS; typedef opengm::ShapeWalker<typename FactorType::ShapeIteratorType> FactorShapeWalkerType; typedef VerboseVisitor<LPInference<GM,ACC,LP_SOLVER> > VerboseVisitorType; typedef EmptyVisitor<LPInference<GM,ACC,LP_SOLVER> > EmptyVisitorType; typedef TimingVisitor<LPInference<GM,ACC,LP_SOLVER> > TimingVisitorType; typedef LP_SOLVER LpSolverType; typedef typename LpSolverType::Parameter LpSolverParameter; typedef double LpValueType; typedef int LpIndexType; typedef double LpArgType; class Parameter { public: Parameter( const bool integerConstraint = false, const bool integerConstraintFactorVar = false, const LpSolverParameter & lpSolverParamter= LpSolverParameter(), const Relaxation relaxation = FirstOrder ) : integerConstraint_(integerConstraint), integerConstraintFactorVar_(integerConstraintFactorVar), lpSolverParameter_(lpSolverParamter), relaxation_(relaxation){ } bool integerConstraint_; bool integerConstraintFactorVar_; LpSolverParameter lpSolverParameter_; Relaxation relaxation_; }; LPInference(const GraphicalModelType&, const Parameter& = Parameter()); std::string name() const; const GraphicalModelType& graphicalModel() const; InferenceTermination infer(); void reset(); ValueType bound()const; ValueType value()const; template<class VisitorType> InferenceTermination infer(VisitorType&); void setStartingPoint(typename std::vector<LabelType>::const_iterator); virtual InferenceTermination arg(std::vector<LabelType>&, const size_t = 1) const ; template<class LPVariableIndexIterator,class CoefficientIterator> void addConstraint(LPVariableIndexIterator , LPVariableIndexIterator , CoefficientIterator ,const ValueType , const ValueType , const std::string & name = std::string() ); private: void setupLPObjective(); void addFirstOrderRelaxationConstraints(); const GraphicalModelType& gm_; Parameter param_; LpSolverType lpSolver_; std::vector<LabelType> gmArg_; }; template<class GM, class ACC, class LP_SOLVER> LPInference<GM,ACC,LP_SOLVER>::LPInference ( const GraphicalModelType& gm, const Parameter& parameter ) : LpInferenceBase<GM,ACC>(gm), gm_(gm), param_(parameter), lpSolver_(parameter.lpSolverParameter_), gmArg_(gm.numberOfVariables(),static_cast<LabelType>(0) ) { //std::cout<<"add var 1.\n"; // ADD VARIABLES TO LP SOLVER lpSolver_.addVariables(this->numberOfNodeLpVariables(), param_.integerConstraint_ ? LpSolverType::Binary : LpSolverType::Continous, 0.0,1.0 ); //std::cout<<"add var ho.\n"; lpSolver_.addVariables(this->numberOfFactorLpVariables(), param_.integerConstraintFactorVar_ ? LpSolverType::Binary : LpSolverType::Continous, 0.0,1.0 ); //std::cout<<"add var finished\n"; lpSolver_.addVarsFinished(); OPENGM_CHECK_OP(this->numberOfLpVariables(),==,lpSolver_.numberOfVariables(),""); // SET UP OBJECTIVE AND UPDATE MODEL (SINCE OBJECTIVE CHANGED) //std::cout<<"setupLPObjective.\n"; this->setupLPObjective(); //std::cout<<"setupLPObjectiveDone.\n"; lpSolver_.setObjectiveFinished(); // ADD CONSTRAINTS //std::cout<<"addConstraints.\n"; this->addFirstOrderRelaxationConstraints(); lpSolver_.updateConstraints(); //std::cout<<"setupConstraintsDone\n"; lpSolver_.setupFinished(); } template<class GM, class ACC, class LP_SOLVER> void LPInference<GM,ACC,LP_SOLVER>::setupLPObjective() { // max "value-table" size of factors // and buffer can store the "value-table" of any factor const IndexType maxFactorSize = findMaxFactorSize(gm_); ValueType * factorValBuffer = new ValueType[maxFactorSize]; // objective for lpNodeVariables for(IndexType vi = 0 ; vi<gm_.numberOfVariables();++vi){ if(this->hasUnary(vi)){ gm_[this->unaryFactorIndex(vi)].copyValues(factorValBuffer); for(LabelType label=0;label<gm_.numberOfLabels(vi);++label) lpSolver_.setObjective(this->lpNodeVi(vi,label),this->valueToMinSumValue(factorValBuffer[label])); } else{ for(LabelType label=0;label<gm_.numberOfLabels(vi);++label) lpSolver_.setObjective(this->lpNodeVi(vi,label),0.0); } } // objective for lpFactorVariables for(IndexType fi = 0; fi<gm_.numberOfFactors();++fi){ if(gm_[fi].numberOfVariables() > 1){ gm_[fi].copyValues(factorValBuffer); for(LabelType labelingIndex=0;labelingIndex<gm_[fi].size();++labelingIndex) lpSolver_.setObjective(this->lpFactorVi(fi,labelingIndex),this->valueToMinSumValue(factorValBuffer[labelingIndex])); } } // delete buffer which stored the "value-table" of any factor delete[] factorValBuffer; } template<class GM, class ACC, class LP_SOLVER> inline typename GM::ValueType LPInference<GM,ACC,LP_SOLVER>::bound() const { return static_cast<ValueType>(this->valueFromMinSumValue(lpSolver_.lpValue())); } template<class GM, class ACC, class LP_SOLVER> template<class LPVariableIndexIterator,class CoefficientIterator> void LPInference<GM,ACC,LP_SOLVER>::addConstraint( LPVariableIndexIterator lpVarBegin, LPVariableIndexIterator lpVarEnd, CoefficientIterator coeffBegin, const LPInference<GM,ACC,LP_SOLVER>::ValueType lowerBound, const LPInference<GM,ACC,LP_SOLVER>::ValueType upperBound, const std::string & name ){ lpSolver_.addConstraint(lpVarBegin,lpVarEnd,coeffBegin,lowerBound,upperBound,name); } template<class GM, class ACC, class LP_SOLVER> void LPInference<GM,ACC,LP_SOLVER>::addFirstOrderRelaxationConstraints(){ // set constraints UInt64Type constraintCounter = 0; // \sum_i \mu_i = 1 for(IndexType node = 0; node < gm_.numberOfVariables(); ++node) { lpSolver_.addConstraint(1.0,1.0); for(LabelType l = 0; l < gm_.numberOfLabels(node); ++l) { lpSolver_.addToConstraint(constraintCounter,this->lpNodeVi(node,l),1.0); } ++constraintCounter; } // \sum_i \mu_{f;i_1,...,i_n} - \mu{b;j}= 0 for(IndexType f = 0; f < gm_.numberOfFactors(); ++f) { if(gm_[f].numberOfVariables() > 1) { marray::Marray<UInt64Type> temp(gm_[f].shapeBegin(), gm_[f].shapeEnd()); UInt64Type counter = this->lpFactorVi(f,0); for(marray::Marray<UInt64Type>::iterator mit = temp.begin(); mit != temp.end(); ++mit) { *mit = counter++; } for(IndexType n = 0; n < gm_[f].numberOfVariables(); ++n) { IndexType node = gm_[f].variableIndex(n); for(LabelType l=0; l < gm_.numberOfLabels(node); ++l) { lpSolver_.addConstraint(0.0,0.0); lpSolver_.addToConstraint(constraintCounter,this->lpNodeVi(node,l),-1.0); marray::View<UInt64Type> view = temp.boundView(n, l); for(marray::View<UInt64Type>::iterator vit = view.begin(); vit != view.end(); ++vit) { OPENGM_CHECK_OP(*vit,>=,this->lpFactorVi(f,0)," "); lpSolver_.addToConstraint(constraintCounter,*vit,1.0); } ++constraintCounter; } } } } } template<class GM, class ACC, class LP_SOLVER> inline InferenceTermination LPInference<GM,ACC,LP_SOLVER>::infer() { EmptyVisitorType v; return infer(v); } template<class GM, class ACC, class LP_SOLVER> template<class VisitorType> InferenceTermination LPInference<GM,ACC,LP_SOLVER>::infer ( VisitorType& visitor ) { visitor.begin(); lpSolver_.optimize(); for(IndexType gmVi=0;gmVi<gm_.numberOfVariables();++gmVi){ const LabelType nLabels = gm_.numberOfLabels(gmVi); LpValueType maxVal = lpSolver_.lpArg(this->lpNodeVi(gmVi,0)); LabelType maxValLabel = 0; for(LabelType l=1;l<nLabels;++l){ const LabelType val =lpSolver_.lpArg(this->lpNodeVi(gmVi,l)); OPENGM_CHECK_OP(val,<=,1.0,""); OPENGM_CHECK_OP(val,>=,0.0,""); if(val>maxVal){ maxValLabel=l; maxVal=val; } } gmArg_[gmVi]=maxValLabel; } visitor.end(); return NORMAL; } template<class GM, class ACC, class LP_SOLVER> inline void LPInference<GM,ACC,LP_SOLVER>::reset() { throw RuntimeError("LPInference::reset() is not implemented yet"); } template<class GM, class ACC, class LP_SOLVER> inline void LPInference<GM,ACC,LP_SOLVER>::setStartingPoint ( typename std::vector<typename LPInference<GM,ACC,LP_SOLVER>::LabelType>::const_iterator begin ) { throw RuntimeError("setStartingPoint is not implemented for LPInference"); } template<class GM, class ACC, class LP_SOLVER> inline std::string LPInference<GM,ACC,LP_SOLVER>::name() const { return "LPInference"; } template<class GM, class ACC, class LP_SOLVER> inline const typename LPInference<GM,ACC,LP_SOLVER>::GraphicalModelType& LPInference<GM,ACC,LP_SOLVER>::graphicalModel() const { return gm_; } template<class GM, class ACC, class LP_SOLVER> inline typename GM::ValueType LPInference<GM,ACC,LP_SOLVER>::value() const { std::vector<LabelType> states; arg(states); return gm_.evaluate(states); } template<class GM, class ACC, class LP_SOLVER> inline InferenceTermination LPInference<GM,ACC,LP_SOLVER>::arg ( std::vector<LabelType>& x, const size_t N ) const { if(N==1) { x.resize(gm_.numberOfVariables()); for(size_t j=0; j<x.size(); ++j) { x[j]=gmArg_[j]; } return NORMAL; } else { return UNKNOWN; } } } // namespace opengm #endif // #ifndef OPENGM_GENERIC_LP_INFERENCE_HXX
[ "thorsten.beier@iwr.uni-heidelberg.de" ]
thorsten.beier@iwr.uni-heidelberg.de
8a6e1803e8f16808776a23a5a6bcbff91f8617e6
53d6b97a9432090454f683c210c78255a33da347
/point.hpp
3195d15a03b5d011a0d344eb34aafce59bf3bd7d
[]
no_license
Ligvest/SocobanQtOgl
2df44a8bb30f3377c05067549ea2bd2aff1b2346
d3e5339b10e22e56107b95bbf96ff8869413ebbc
refs/heads/master
2020-05-27T21:03:13.098212
2019-06-07T12:40:22
2019-06-07T12:40:22
188,790,016
0
0
null
null
null
null
UTF-8
C++
false
false
364
hpp
#ifndef POINT_HPP #define POINT_HPP class Point { public: Point(int iX, int iY); int x() const; void setX(int iX); int y() const; void setY(int iY); Point operator-(const Point& rightPoint) const; Point operator+(const Point& rightPoint) const; private: int iX_; int iY_; }; #endif // POINT_H
[ "ligvesto@gmail.com" ]
ligvesto@gmail.com
bdab3fdeffd05180d603fb7df4de2ec1a80176a2
1acaecec96efccb227b9fec39d1925dd17795928
/Apresentacao/Paginas/Logado/CadastrarNovoProduto.cpp
042795210de47f19a8f31e202af9b969321bafb1
[]
no_license
SAMXPS/TP1-UnB
45648feb2b14788c97f48a3cc1a4197b0217263a
bb47138226f5b514aa9130c9ff820214f3732dac
refs/heads/master
2023-01-29T10:23:07.944702
2020-12-04T02:01:19
2020-12-04T02:01:19
293,830,312
0
0
null
null
null
null
UTF-8
C++
false
false
2,055
cpp
#include "../../Paginas.h" #include <string.h> Pagina* CadastrarNovoProduto::mostrar(GerenciadorDePagina* apresentador) { Pagina* next = new PaginaInicialLogado(usuario); std::string CODIGO_DE_PRODUTO, CLASSE, EMISSOR, PRAZO, DATA, TAXA, HORARIO, VALOR_MINIMO; apresentador->escreveNoCentro("Cadastrar novo Produto"); apresentador->escreveNoCentro(""); apresentador->escreveNoCentro("Por favor, preencha os dados a seguir."); apresentador->escreveNoCentro(""); apresentador->escreveNoCentro("CODIGO_DE_PRODUTO: "); CODIGO_DE_PRODUTO = apresentador->lerInput(); apresentador->escreveNoCentro("CLASSE: "); CLASSE = apresentador->lerInput(); apresentador->escreveNoCentro("EMISSOR: "); EMISSOR = apresentador->lerInput(); apresentador->escreveNoCentro("PRAZO: "); PRAZO = apresentador->lerInput(); apresentador->escreveNoCentro("DATA DE VENCIMENTO: "); DATA = apresentador->lerInput(); apresentador->escreveNoCentro("TAXA: "); TAXA = apresentador->lerInput(); apresentador->escreveNoCentro("HORARIO: "); HORARIO = apresentador->lerInput(); apresentador->escreveNoCentro("VALOR_MINIMO: "); VALOR_MINIMO = apresentador->lerInput(); Produto* produto; try { produto = new Produto(CODIGO_DE_PRODUTO, CLASSE, EMISSOR, std::stoi(PRAZO), DATA, std::stod(TAXA), HORARIO, std::stoi(VALOR_MINIMO)); } catch (const std::invalid_argument&err) { return new PaginaErro(next, err.what()); } catch (...) { return new PaginaErro(next, "erro desconhecido."); } apresentador->limparTela(); if (apresentador->getServicos()->getGerenciadorDeProduto()->cadastrarProduto(*produto)) { apresentador->escreveNoCentro("Produto cadastrado com sucesso."); } else { apresentador->escreveNoCentro("Produto nao foi cadastrado. Algum problema no SQLite."); } apresentador->escreveNoCentro(""); apresentador->escreveNoCentro("Aperte enter para voltar"); apresentador->lerInput(); return next; }
[ "bsbcraftplays@gmail.com" ]
bsbcraftplays@gmail.com
881011b2897260c46e031f813734aceb72672439
21dd1ece27a68047f93bac2bdf9e6603827b1990
/VizKit-2 2.3/source/VisualObjectData.cpp
15b0fe05fa431eed37365738739924ea9a156126
[]
no_license
LupusDei/8LU-DSP
c626ce817b6b178c226c437537426f25597958a5
65860326bb89a36ff71871b046642b7dd45d5607
refs/heads/master
2021-01-17T21:51:19.971505
2010-09-24T15:08:01
2010-09-24T15:08:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,278
cpp
/* * Project: VizKit * Version: 2.3 * Date: 20090823 * File: VisualObjectData.cpp * */ /*************************************************************************** Copyright (c) 2004-2009 Heiko Wichmann (http://www.imagomat.de/vizkit) This software is provided 'as-is', without any expressed or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. ***************************************************************************/ #include "VisualObjectData.h" #include "VisualErrorHandling.h" #include "VisualNetwork.h" #include "VisualItemIdentifier.h" using namespace VizKit; VisualObjectData::VisualObjectData() { data = NULL; dataSizeAllocated = 0; dataSizeUsed = 0; dataSizeDeclared = 0; dataSizeDeclaredHasBeenSetBool = false; refCount = 1; hasObjectBool = true; itemIdentifier = new VisualItemIdentifier; isDownloadingBool = false; visualObjectMutex = new VisualObjectMutex; } VisualObjectData::VisualObjectData(const VisualItemIdentifier& anIdentifier) { itemIdentifier = new VisualItemIdentifier(anIdentifier); data = NULL; dataSizeAllocated = 0; dataSizeUsed = 0; dataSizeDeclared = 0; dataSizeDeclaredHasBeenSetBool = false; refCount = 1; hasObjectBool = true; isDownloadingBool = false; visualObjectMutex = new VisualObjectMutex; } VisualObjectData::~VisualObjectData() { if (data != NULL) { free(data); } delete itemIdentifier; delete visualObjectMutex; } VisualObjectData::VisualObjectData(const VisualObjectData& other) { this->copyObject(other); } VisualObjectData& VisualObjectData::operator=(const VisualObjectData& other) { if (this == &other) return *this; if (this->data != NULL) { free(this->data); } delete this->itemIdentifier; delete this->visualObjectMutex; this->visualObjectMutex = NULL; this->copyObject(other); return *this; } bool VisualObjectData::operator<(const VisualObjectData& other) const { return this->itemIdentifier < other.itemIdentifier; } bool VisualObjectData::operator>(const VisualObjectData& other) const { return this->itemIdentifier > other.itemIdentifier; } bool VisualObjectData::operator==(const VisualObjectData& other) const { return this->itemIdentifier == other.itemIdentifier; } bool VisualObjectData::operator!=(const VisualObjectData& other) const { return this->itemIdentifier != other.itemIdentifier; } const VisualItemIdentifier VisualObjectData::getIdentifier() const { return *(this->itemIdentifier); } bool VisualObjectData::addData(void* dataPtr, uint32 dataSize) { bool success = true; if (this->dataSizeAllocated < (this->dataSizeUsed + dataSize)) { while (this->dataSizeAllocated < (this->dataSizeUsed + dataSize)) { if (this->dataSizeAllocated == 0) { uint32 initialAllocationSize = dataSize; if ((this->dataSizeDeclaredHasBeenSetBool == true) && (this->dataSizeDeclared > dataSize)) { initialAllocationSize = this->dataSizeDeclared; } this->data = (char*)malloc(initialAllocationSize * sizeof(char)); this->dataSizeAllocated = initialAllocationSize; } else { if ((this->dataSizeDeclaredHasBeenSetBool == true) && (this->dataSizeDeclared >= this->dataSizeUsed + dataSize)) { this->dataSizeAllocated = this->dataSizeDeclared; } else { this->dataSizeAllocated *= 2; } this->data = (char*)realloc(this->data, this->dataSizeAllocated); if (this->data == NULL) { char errLog[256]; sprintf(errLog, "Err: Realloc failed in file: %s (line: %d) [%s])", __FILE__, __LINE__, __FUNCTION__); writeLog(errLog); } } } } memcpy(this->data + this->dataSizeUsed, dataPtr, dataSize); this->dataSizeUsed += dataSize; return success; } void VisualObjectData::freeData(void) { if (this->data) { free(this->data); this->data = NULL; this->dataSizeAllocated = 0; this->dataSizeUsed = 0; } } size_t VisualObjectData::getDataSizeUsed() { return this->dataSizeUsed; } size_t VisualObjectData::getDataSizeDeclared() { return this->dataSizeDeclared; } void VisualObjectData::setDataSizeDeclared(const size_t& aDataSizeDeclared) { this->dataSizeDeclared = aDataSizeDeclared; this->dataSizeDeclaredHasBeenSetBool = true; } bool VisualObjectData::dataSizeDeclaredHasBeenSet(void) { return this->dataSizeDeclaredHasBeenSetBool; } void VisualObjectData::release() { this->refCount--; } size_t VisualObjectData::getRefCount(void) { return this->refCount; } bool VisualObjectData::hasObject(){ return this->hasObjectBool; } bool VisualObjectData::isDownloading(void) { return this->isDownloadingBool; } void VisualObjectData::setIsDownloading(bool isDownloadingBoolean) { this->isDownloadingBool = isDownloadingBoolean; } void VisualObjectData::enterCriticalRegion() { this->visualObjectMutex->enterCriticalRegion(); } void VisualObjectData::exitCriticalRegion() { this->visualObjectMutex->exitCriticalRegion(); } void VisualObjectData::copyObject(const VisualObjectData& other) { this->itemIdentifier = new VisualItemIdentifier(*(other.itemIdentifier)); if (other.data != NULL) { this->data = (char*)malloc(other.dataSizeAllocated); memcpy(this->data, other.data, other.dataSizeUsed); } else { this->data = NULL; } this->visualObjectMutex = new VisualObjectMutex(*other.visualObjectMutex); this->dataSizeAllocated = other.dataSizeAllocated; this->dataSizeUsed = other.dataSizeUsed; this->dataSizeDeclared = other.dataSizeDeclared; this->dataSizeDeclaredHasBeenSetBool = other.dataSizeDeclaredHasBeenSetBool; this->refCount = other.refCount; this->hasObjectBool = other.hasObjectBool; }
[ "dougbradbury@doug-mbp15.local" ]
dougbradbury@doug-mbp15.local
b38c90b09967d05387ef94b5c859f981400c6cb1
95626140b639c93a5bc7d86c5ed7cead4d27372a
/Online Judge/HackerRank/Sherlock and Array.cpp
6aab97fb4ebb7f802135e58e39aa80b51eea3fb5
[]
no_license
asad-shuvo/ACM
059bed7f91261af385d1be189e544fe240da2ff2
2dea0ef7378d831097efdf4cae25fbc6f34b8064
refs/heads/master
2022-06-08T13:03:04.294916
2022-05-13T12:22:50
2022-05-13T12:22:50
211,629,208
0
0
null
null
null
null
UTF-8
C++
false
false
2,094
cpp
#include <bits/stdc++.h> using namespace std; string ltrim(const string &); string rtrim(const string &); vector<string> split(const string &); // Complete the balancedSums function below. string balancedSums(vector<int> arr) { int cm[arr.size()+5]; for(int i=0;i<arr.size();i++){ if(i==0){ cm[i]=arr[i]; continue; } cm[i]=arr[i]+cm[i-1]; } int f=0; for(int i=0;i<arr.size();i++){ int l=0,r=0; if(i==0){ l=0; r=cm[arr.size()-1]-cm[i]; } else if(i==arr.size()-1){ r=0; l=cm[i-1]; } else{ l=cm[i-1]; r=cm[arr.size()-1]-cm[i]; } if(l==r)f=1; } if(f==1)return "YES"; else return "NO"; } int main() { ofstream fout(getenv("OUTPUT_PATH")); string T_temp; getline(cin, T_temp); int T = stoi(ltrim(rtrim(T_temp))); for (int T_itr = 0; T_itr < T; T_itr++) { string n_temp; getline(cin, n_temp); int n = stoi(ltrim(rtrim(n_temp))); string arr_temp_temp; getline(cin, arr_temp_temp); vector<string> arr_temp = split(rtrim(arr_temp_temp)); vector<int> arr(n); for (int i = 0; i < n; i++) { int arr_item = stoi(arr_temp[i]); arr[i] = arr_item; } string result = balancedSums(arr); fout << result << "\n"; } fout.close(); return 0; } string ltrim(const string &str) { string s(str); s.erase( s.begin(), find_if(s.begin(), s.end(), not1(ptr_fun<int, int>(isspace))) ); return s; } string rtrim(const string &str) { string s(str); s.erase( find_if(s.rbegin(), s.rend(), not1(ptr_fun<int, int>(isspace))).base(), s.end() ); return s; } vector<string> split(const string &str) { vector<string> tokens; string::size_type start = 0; string::size_type end = 0; while ((end = str.find(" ", start)) != string::npos) { tokens.push_back(str.substr(start, end - start)); start = end + 1; } tokens.push_back(str.substr(start)); return tokens; }
[ "asad.shuvo.cse@gmail.com" ]
asad.shuvo.cse@gmail.com
abaef2cc8993419f58ca4f4e85acb415b20164b2
f23e3c03faf1ad3b51e2ce30d79479c12bfdfe58
/include/geneticalgorithm.hpp
8230a5edc9707002911167007a7450c53134f2d3
[ "MIT" ]
permissive
gitter-badger/headless-logic
1bb70322c320f38d92cf8f9e16f91228a3de7d17
54b6b1f5893df4214eda0a7be9cb3d2490117259
refs/heads/master
2020-12-27T21:32:08.174819
2016-08-24T22:05:58
2016-08-24T22:05:58
66,503,937
0
0
null
2016-08-24T22:19:22
2016-08-24T22:19:22
null
UTF-8
C++
false
false
9,315
hpp
/* * Copyright 2016 Stoned Xander * * 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 * * http://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. */ #ifndef HEADLESS_LOGIC_GENETIC_ALGORITHM #define HEADLESS_LOGIC_GENETIC_ALGORITHM #include <random> namespace Headless { namespace Logic { /** * Here are proposed some implementations of General Algorithms. * Currently available GAs are: * - Trivial. */ namespace GA { /** * Trivial GA. * 1. Generate first pool. * 2. Evaluate pool against a testing environment. * 3. Save the elite. * 4. Create new pool from elite using set of operators. * 5. Back to step 2 until error is superior to specified * or until generation number is inferior to specified. * * To this purpose, we need the following concepts : * @param <C> Candidates to be evaluated and modified. */ template <typename C> class Trivial { public: /** * Constructor. * @param pSize Pool Size. */ Trivial(unsigned int pSize) : _count(pSize) { _pool = new C*[pSize]; _score = new double[pSize]; } /** * Destructor. */ ~Trivial() { delete []_pool; delete []_score; } /** * Training. * @param <E> Creation and evaluation environment type. It must define * the following methods: * - void reserve(C**&, unsigned int) * - void release(C**, unsigned int) * - double evaluate (const C*) * - C* clone(const C*) * @param <... M> Set of operators/mutators types. A mutator must define * the following methods: * - double threshold() * - void mutate(C**, unsigned int, C*); * @param env Environment. * @param maxGen Maximum number of generations. * @param minErr Minimal accepable error. * @param eliteSize Percentage of the pool to be taken for creating the next pool. * @param store A store for results. * @param size Size of the storage and maximum number of exit candidate. * @param mutators Set of operators/mutators for new pool creation. * @return The number of candidates stored in the specified buffer. */ template <typename E, typename... M> int train(E* env, unsigned int maxGen, double minErr, double eliteSize, C** store, unsigned int size, M... mutators) { unsigned int eliteCount = _count * eliteSize; // We assume that the pool is empty and needs to be filled. env->reserve(_pool, _count); // Loop on generations. for(unsigned int g = 0; (g < maxGen) && (evaluate(env) > minErr); ++g) { // At this point, the pool is full and sorted. // Let's recycle candidates from eliteCount to _count - 1. #pragma omp parallel for for(unsigned int i = eliteCount; i < _count; ++i) { // Randomly choose a mutators. mutate(i, eliteCount, mutators...); } } unsigned int number = eliteCount < size ? eliteCount : size; for(unsigned int i = 0; i < number; ++i) { store[i] = env->clone(_pool[i]); } // Clean-up the pool. env->release(_pool, _count); return number; } private: /** * make a new offspring out of the available mutators. */ template <typename M, typename... O> void mutate(unsigned int pos, unsigned int count, M mutator, O... others) { std::random_device rd; std::mt19937 mt(rd()); std::uniform_real_distribution<double> dist(0.0, 1.0); double rnd = dist(mt); if(rnd < mutator->threshold()) { mutator->mutate(_pool, count, _pool[pos]); } else { mutate(pos, count, others...); } } template <typename M> void mutate(unsigned int pos, unsigned int count, M mutator) { mutator->mutate(_pool, count, _pool[pos]); } /** * Evaluate the pool against the environment. * @param <E> Environment type. * @param env Environment. * @return Minimal error. At return time, the pool is sorted * using candidates scores. */ template <typename E> double evaluate(E* env) { // Evaluate ... #pragma omp parallel for for(unsigned int i = 0; i < _count; ++i) { _score[i] = env->evaluate(_pool[i]); } // ... and sort. qsort(0, _count - 1); return _score[0]; } /** * Simple quick sort for our specific case. * @param lo Lower bound. * @param hi Higher bound. */ void qsort(unsigned int lo, unsigned int hi) { if(lo < hi) { // We don't make fat partitionning as we are manipulating // fine-grained over-distributed scores. We should not // have arrays of identical scores. unsigned int pivot = partition(lo, hi); if((pivot - lo) < (hi - (pivot + 1))) { qsort(lo, pivot); qsort(pivot + 1, hi); } else { qsort(pivot + 1, hi); qsort(lo, pivot); } } } unsigned int partition(unsigned int lo, unsigned int hi) { double pivot = _score[lo]; unsigned int i = lo - 1; unsigned int j = hi + 1; for(;;) { do { ++i; } while(_score[i] < pivot); do { --j; } while(_score[j] > pivot); if(i >= j) { return j; } double score = _score[i]; C* candidate = _pool[i]; _score[i] = _score[j]; _pool[i] = _pool[j]; _score[j] = score; _pool[j] = candidate; } return 0; // Should never happen. } private: /** * Candidate pool. */ C** _pool; /** * Pool score. */ double *_score; /** * Pool count. */ unsigned int _count; }; } // Namespace 'GA' } // Namespace 'Logic' } // Namespace 'Headless' #endif
[ "somerandomgamedev@gmail.com" ]
somerandomgamedev@gmail.com
7b06942a85b29cc538ba9cbf78fe0a7ef5eca062
054edeb9e6e6c2d112d19af2ebe07b2e0c6c04b0
/Micelle/include/CloudGenerator.h
4d32a0cff000751474969015d250d52b024d7881
[]
no_license
YuryUoL/DataSkeletonization
b6873d59c42bd1d42e517af153491c425cd0e95c
fd181dc076662d25a84a76dd067e343498206474
refs/heads/master
2020-03-31T21:28:14.359241
2019-03-15T12:42:54
2019-03-15T12:42:54
152,581,810
0
1
null
2018-11-19T10:07:09
2018-10-11T11:37:56
C++
UTF-8
C++
false
false
320
h
#ifndef CLOUDGENERATOR_H #define CLOUDGENERATOR_H #include "Definitions.h" #include "Graph.h" class CloudGenerator { public: CloudGenerator(); static void generatePoints(int n, MyGraphType & G, double epsilon, std::list<Point> & points); protected: private: }; #endif // CLOUDGENERATOR_H
[ "yura.elkin@gmail.com" ]
yura.elkin@gmail.com
b19f7e9aeb6cf9a7d64c9c606d042b3e4ad41a7c
7d1fa8db4712a57a2cab77a0d44340adbffbbdf6
/GPU_Programming_Assignment/cDirectionalLight.h
532a817195b2e04abaffcfe8594935f4baa9b086
[]
no_license
ben-kiddie/GPU-Programming-Assignment
f02a5ce15c1d1f8c414a3c24950a62f7d0c64930
a4914d49671325ea332102731059ec4042d0cd80
refs/heads/master
2023-08-16T02:29:13.976294
2021-10-11T15:00:58
2021-10-11T15:00:58
354,562,681
0
0
null
null
null
null
UTF-8
C++
false
false
475
h
#pragma once #include "cLight.h" class DirectionalLight : public Light { public: DirectionalLight(); DirectionalLight(GLfloat red, GLfloat green, GLfloat blue, GLfloat ambIntensity, GLfloat diffIntensity, GLfloat xDirection, GLfloat yDirection, GLfloat zDirection); ~DirectionalLight(); void UseLight(GLuint ambientIntensityLocation, GLuint ambientColourLocation, GLuint diffuseIntensityLocation, GLuint directionLocation); private: glm::vec3 mDirection; };
[ "76003977+ben-kiddie@users.noreply.github.com" ]
76003977+ben-kiddie@users.noreply.github.com
727ecd57d0082f883bbad100d586ae196da59b8c
75807296ab0ad2cc3a173d6a759985207ef5d24d
/arithmetic/1048.cpp
2c3a3f7ce1f6fc82d5939be4593919a958cc1f35
[]
no_license
p719967821/algorithm
af81a07efaa1ce2adc5a13c9d52523799acb8442
a02bd4a64b2a2596cdd3227b9c5229e0b77b7834
refs/heads/master
2021-03-20T13:36:47.306631
2020-03-14T14:06:18
2020-03-14T14:06:18
247,210,618
0
0
null
null
null
null
UTF-8
C++
false
false
960
cpp
/**็Ÿฉ้˜ต่ฟžไน˜**/ #include <iostream> #define N 101 using namespace std; int n; int row[N];//ๆฏไธช็Ÿฉ้˜ต็š„่กŒ int col[N];//ๆฏไธช็Ÿฉ้˜ต็š„ๅˆ— int s[N][N];//่ฎฐๅฝ•ๆœ€ๅฐ‘็š„ๆฌกๆ•ฐ void dp(); int main() { cin >> n; for(int i = 0; i < n; i++) { cin >> row[i] >> col[i]; } dp(); cout << s[0][n-1] << endl; return 0; } void dp() { int i,j,k,len; //ๅˆๅง‹ๅŒ– for(i = 0; i < n; i++) { for(j = 0; j < n; j++) { if(i == j) { s[i][j] = 0; } else { s[i][j] = INT_MAX; } } } //ๅผ€ๅง‹ไปŽๅบ•ๅ‘ไธŠ่ง„ๅˆ’ for(len = 1; len < n; len++) { for(i = 0,j = i + len; j < n; i++ , j++) { for(k = i; k < j; k++) { s[i][j] = min(s[i][j],s[i][k] + s[k+1][j] + row[i]*col[k]*col[j]); } } } }
[ "p719967821@163.com" ]
p719967821@163.com
cf92f700e6ef11683c0e98fa92ecb712ff6faf1d
9946a1c6e1291de309a8882891ca7fe42355710d
/src/parser.cpp
c7a84bbe3448e358e12f6d3e80e76a95452c0177
[]
no_license
kirbisity/carNoiseFinder
139b213ec792250fd1d90a97a716918a4a18b095
2a8b7e9f38c2f3e17fba006a5d3f17c1d1209159
refs/heads/master
2020-06-11T15:37:00.549721
2019-10-20T21:32:48
2019-10-20T21:32:48
194,012,250
0
0
null
null
null
null
UTF-8
C++
false
false
767
cpp
#include <sstream> #include <vector> #include <string> /* in current directory */ #include "parser.h" using namespace std; vector<double> parse_tabs(string line) { std::vector<double> tabs; vector<string> items = split(line); for (vector<string>::const_iterator i = items.begin(); i != items.end(); ++i) { double speedentry = -1; size_t idx = i->find("km/h", 0); if (idx != string::npos) { speedentry = atof(i->substr(0, (int)idx).c_str()); } if (*i == "idle") { speedentry = 0; } if (speedentry != -1) { tabs.push_back(speedentry); } } return tabs; } vector<string> split(string line) { stringstream ss(line); istream_iterator<string> begin(ss); istream_iterator<string> end; vector<string> items(begin, end); return items; }
[ "zhuy11@rpi.edu" ]
zhuy11@rpi.edu
462fa9f66728e67254badcb1f8ec734cc4e43e74
58457320f8ecc206f5c37a84fdeae32f2d8b692f
/SecondPushButton.cpp
57896975ec1878a7de49f18754f792e9eebaec86
[]
no_license
freedomgll/DeskCallQt
9dcffbe3f06537cf0b335453cdd1f371f3302f9c
cb5b1598cda1e65b372c341222c0eec15b5f36f1
refs/heads/master
2021-01-18T14:01:30.900037
2015-08-12T09:48:39
2015-08-12T09:48:39
39,882,671
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
1,312
cpp
#include "SecondPushButton.h" #include "FirstPushButton.h" #include <QMessageBox> #include <QtDebug> SecondPushButton::SecondPushButton(void) { } SecondPushButton::SecondPushButton(const QString & text, QString businessId, const QRect & rect, DeskCallQT * parent):CoderPushButton(text, rect, parent) { this->businessId = businessId; connect(this, SIGNAL(clicked()),this,SLOT(clickAction())); } SecondPushButton::~SecondPushButton(void) { } void SecondPushButton::clickAction() { if(this->text() == QStringLiteral("ยทยตยปร˜/Return")) { ConfigSql confSql = ConfigSql(); QList<classT> classList; foreach(QString regionid, this->parent->configSettings.RegionIDs) { classList.append(confSql.queryLClass(regionid)); } QList<QRect> lRects =ConfigUtils::CaculateButtonRects(classList.size(),this->parent->width(),this->parent->height(),this->parent->configSettings.postion); qDebug() << lRects; QList<CoderPushButton *> buttonList; for(int i = 0; i < classList.size(); ++i) { CoderPushButton *pushButton= new FirstPushButton(classList[i].classname, classList[i].classid, lRects[i], this->parent); buttonList.append(pushButton); } this->parent->RecreateButtonList(buttonList); } else { QMessageBox msgBox; msgBox.setText(this->businessId); msgBox.exec(); } }
[ "freedomgll@163.com" ]
freedomgll@163.com
6d016d68ee3475b6edfcedffe584b68b73b7f3f3
4c23be1a0ca76f68e7146f7d098e26c2bbfb2650
/ic8h18/0.009/CC5H10OOH-B
0ad74b9d185f0f7857aa19a185a907d826e6d578
[]
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
842
/*--------------------------------*- 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.009"; object CC5H10OOH-B; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 0 0 0 0]; internalField uniform 5.1425e-39; boundaryField { boundary { type empty; } } // ************************************************************************* //
[ "jfeatherstone123@gmail.com" ]
jfeatherstone123@gmail.com
7fa69f37669371d0bb6980a8a0837ac01def031e
c1d4b3313aa6e48bebfeb4e3cfb7b5eeb54ced86
/windows/cpp/samples/enc_mp4_avc_aac_push/stdafx.h
a233703f20cbec0ad838f3bdcdb9f1b66316d523
[ "MIT" ]
permissive
avblocks/avblocks-samples
447a15eed12d4ac03c929bc7b368fe37fadc0762
7388111a27c8110a9f7222e86e912fe38f444543
refs/heads/main
2021-06-04T13:41:30.387450
2021-02-01T00:28:09
2021-02-01T00:28:09
334,783,633
1
1
null
null
null
null
UTF-8
C++
false
false
511
h
// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #pragma once #include "targetver.h" #include <stdio.h> #include <tchar.h> #include <string> #include <iostream> #include <fstream> #include <sstream> #include <iomanip> #include <algorithm> #include <map> #include <assert.h> #include <Windows.h> #include <Shlwapi.h> #include <AVBlocks.h> #include <PrimoReference++.h>
[ "vkantchev@users.noreply.github.com" ]
vkantchev@users.noreply.github.com
b59330533c58091e1006616b872064f3c3bc362b
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_5688567749672960_0/C++/gawarkiewicz/solution.cpp
3adb842b91c4ff15a5fbcb1a51bca1492ec315ba
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
1,401
cpp
#include <iostream> #include <vector> #include <map> #include <queue> #include <tuple> using namespace std; long long rev(long long num) { long long ret = 0; while (num) { ret = ret * 10 + (num % 10); num /= 10; } return ret; } map<long long, int> brute() { map<long long, int> m; queue<tuple<long long, int>> q; q.push(make_tuple(1, 1)); m[1] = 1; while (!q.empty()) { auto p = q.front(); q.pop(); if (get<1>(p) > 10000) continue; auto n = get<0>(p); auto c = get<1>(p); auto n1 = n + 1; auto n2 = rev(n); if (m[n1] == 0) { m[n1] = c + 1; q.push(make_tuple(n1, c + 1)); } if (m[n2] == 0) { m[n2] = c + 1; q.push(make_tuple(n2, c + 1)); } } return m; } void learn() { auto m = brute(); cout << m.rbegin()->first << endl; // max long long allTo = 0; for (auto& p : m) { if (p.first != allTo + 1) break; allTo++; } cout << allTo << endl; /* vector<pair<int, long long>> m2; for (auto& p : m) { m2.push_back(make_pair(p.second, p.first)); } sort(m2.begin(), m2.end()); for (auto& p : m2) { cout << p.first << " " << p.second << endl; }*/ } int main() { //learn(); auto m = brute(); int N; cin >> N; for (int q = 1; q <= N; ++q) { long long T; cin >> T; cout << "Case #" << q << ": " << m[T] << endl; } return 0; }
[ "root@debian" ]
root@debian
9ed4f8cc291b3331538f97e7aa3b22215a021e95
dfd13ecff989c05937dc875fd910c3d1ba33ced8
/include/wx/dlimpexp.h
b745fe6fe70c2569d24ef03c210c176dc3ee329c
[]
no_license
thevisad/deps-wxWidgets
b306f3a0abce654ded29594014e1dc13e5f57823
56c92c2e17c7f361748bf1f52519b132e2cac33e
refs/heads/master
2021-01-16T20:47:07.548645
2013-10-23T17:41:15
2013-10-23T17:41:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
12,090
h
/* * Name: wx/dlimpexp.h * Purpose: Macros for declaring DLL-imported/exported functions * Author: Vadim Zeitlin * Modified by: * Created: 16.10.2003 (extracted from wx/defs.h) * Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org> * Licence: wxWindows licence */ /* This is a C file, not C++ one, do not use C++ comments here! */ #ifndef _WX_DLIMPEXP_H_ #define _WX_DLIMPEXP_H_ #if defined(HAVE_VISIBILITY) # define WXEXPORT __attribute__ ((visibility("default"))) # define WXIMPORT __attribute__ ((visibility("default"))) #elif defined(__WINDOWS__) /* __declspec works in BC++ 5 and later, Watcom C++ 11.0 and later as well as VC++. */ # if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__) || (defined(__WINDOWS__) && defined(__INTELC__)) # define WXEXPORT __declspec(dllexport) # define WXIMPORT __declspec(dllimport) /* While gcc also supports __declspec(dllexport), it creates unusably huge DLL files since gcc 4.5 (while taking horribly long amounts of time), see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43601. Because of this we rely on binutils auto export/import support which seems to work quite well for 4.5+. */ # elif defined(__GNUC__) && !wxCHECK_GCC_VERSION(4, 5) /* __declspec could be used here too but let's use the native __attribute__ instead for clarity. */ # define WXEXPORT __attribute__((dllexport)) # define WXIMPORT __attribute__((dllimport)) # endif #elif defined(__WXPM__) # if defined (__WATCOMC__) # define WXEXPORT __declspec(dllexport) /* __declspec(dllimport) prepends __imp to imported symbols. We do NOT want that! */ # define WXIMPORT # elif defined(__EMX__) # define WXEXPORT # define WXIMPORT # elif (!(defined(__VISAGECPP__) && (__IBMCPP__ < 400 || __IBMC__ < 400 ))) # define WXEXPORT _Export # define WXIMPORT _Export # endif #elif defined(__CYGWIN__) # define WXEXPORT __declspec(dllexport) # define WXIMPORT __declspec(dllimport) #endif /* for other platforms/compilers we don't anything */ #ifndef WXEXPORT # define WXEXPORT # define WXIMPORT #endif /* We support building wxWidgets as a set of several libraries but we don't support arbitrary combinations of libs/DLLs: either we build all of them as DLLs (in which case WXMAKINGDLL is defined) or none (it isn't). However we have a problem because we need separate WXDLLIMPEXP versions for different libraries as, for example, wxString class should be dllexported when compiled in wxBase and dllimported otherwise, so we do define separate WXMAKING/USINGDLL_XYZ constants for each component XYZ. */ #ifdef WXMAKINGDLL # if wxUSE_BASE # define WXMAKINGDLL_BASE # endif # define WXMAKINGDLL_NET # define WXMAKINGDLL_CORE # define WXMAKINGDLL_ADV # define WXMAKINGDLL_QA # define WXMAKINGDLL_HTML # define WXMAKINGDLL_GL # define WXMAKINGDLL_XML # define WXMAKINGDLL_XRC # define WXMAKINGDLL_AUI # define WXMAKINGDLL_PROPGRID # define WXMAKINGDLL_RIBBON # define WXMAKINGDLL_RICHTEXT # define WXMAKINGDLL_MEDIA # define WXMAKINGDLL_STC # define WXMAKINGDLL_WEBVIEW #endif /* WXMAKINGDLL */ /* WXDLLIMPEXP_CORE maps to export declaration when building the DLL, to import declaration if using it or to nothing at all if we don't use wxWin as DLL */ #ifdef WXMAKINGDLL_BASE # define WXDLLIMPEXP_BASE WXEXPORT # define WXDLLIMPEXP_DATA_BASE(type) WXEXPORT type # if defined(HAVE_VISIBILITY) # define WXDLLIMPEXP_INLINE_BASE WXEXPORT # else # define WXDLLIMPEXP_INLINE_BASE # endif #elif defined(WXUSINGDLL) # define WXDLLIMPEXP_BASE WXIMPORT # define WXDLLIMPEXP_DATA_BASE(type) WXIMPORT type # if defined(HAVE_VISIBILITY) # define WXDLLIMPEXP_INLINE_BASE WXIMPORT # else # define WXDLLIMPEXP_INLINE_BASE # endif #else /* not making nor using DLL */ # define WXDLLIMPEXP_BASE # define WXDLLIMPEXP_DATA_BASE(type) type # define WXDLLIMPEXP_INLINE_BASE #endif #ifdef WXMAKINGDLL_NET # define WXDLLIMPEXP_NET WXEXPORT # define WXDLLIMPEXP_DATA_NET(type) WXEXPORT type #elif defined(WXUSINGDLL) # define WXDLLIMPEXP_NET WXIMPORT # define WXDLLIMPEXP_DATA_NET(type) WXIMPORT type #else /* not making nor using DLL */ # define WXDLLIMPEXP_NET # define WXDLLIMPEXP_DATA_NET(type) type #endif #ifdef WXMAKINGDLL_CORE # define WXDLLIMPEXP_CORE WXEXPORT # define WXDLLIMPEXP_DATA_CORE(type) WXEXPORT type # if defined(HAVE_VISIBILITY) # define WXDLLIMPEXP_INLINE_CORE WXEXPORT # else # define WXDLLIMPEXP_INLINE_CORE # endif #elif defined(WXUSINGDLL) # define WXDLLIMPEXP_CORE WXIMPORT # define WXDLLIMPEXP_DATA_CORE(type) WXIMPORT type # if defined(HAVE_VISIBILITY) # define WXDLLIMPEXP_INLINE_CORE WXIMPORT # else # define WXDLLIMPEXP_INLINE_CORE # endif #else /* not making nor using DLL */ # define WXDLLIMPEXP_CORE # define WXDLLIMPEXP_DATA_CORE(type) type # define WXDLLIMPEXP_INLINE_CORE #endif #ifdef WXMAKINGDLL_ADV # define WXDLLIMPEXP_ADV WXEXPORT # define WXDLLIMPEXP_DATA_ADV(type) WXEXPORT type #elif defined(WXUSINGDLL) # define WXDLLIMPEXP_ADV WXIMPORT # define WXDLLIMPEXP_DATA_ADV(type) WXIMPORT type #else /* not making nor using DLL */ # define WXDLLIMPEXP_ADV # define WXDLLIMPEXP_DATA_ADV(type) type #endif #ifdef WXMAKINGDLL_QA # define WXDLLIMPEXP_QA WXEXPORT # define WXDLLIMPEXP_DATA_QA(type) WXEXPORT type #elif defined(WXUSINGDLL) # define WXDLLIMPEXP_QA WXIMPORT # define WXDLLIMPEXP_DATA_QA(type) WXIMPORT type #else /* not making nor using DLL */ # define WXDLLIMPEXP_QA # define WXDLLIMPEXP_DATA_QA(type) type #endif #ifdef WXMAKINGDLL_HTML # define WXDLLIMPEXP_HTML WXEXPORT # define WXDLLIMPEXP_DATA_HTML(type) WXEXPORT type #elif defined(WXUSINGDLL) # define WXDLLIMPEXP_HTML WXIMPORT # define WXDLLIMPEXP_DATA_HTML(type) WXIMPORT type #else /* not making nor using DLL */ # define WXDLLIMPEXP_HTML # define WXDLLIMPEXP_DATA_HTML(type) type #endif #ifdef WXMAKINGDLL_GL # define WXDLLIMPEXP_GL WXEXPORT #elif defined(WXUSINGDLL) # define WXDLLIMPEXP_GL WXIMPORT #else /* not making nor using DLL */ # define WXDLLIMPEXP_GL #endif #ifdef WXMAKINGDLL_XML # define WXDLLIMPEXP_XML WXEXPORT #elif defined(WXUSINGDLL) # define WXDLLIMPEXP_XML WXIMPORT #else /* not making nor using DLL */ # define WXDLLIMPEXP_XML #endif #ifdef WXMAKINGDLL_XRC # define WXDLLIMPEXP_XRC WXEXPORT #elif defined(WXUSINGDLL) # define WXDLLIMPEXP_XRC WXIMPORT #else /* not making nor using DLL */ # define WXDLLIMPEXP_XRC #endif #ifdef WXMAKINGDLL_AUI # define WXDLLIMPEXP_AUI WXEXPORT #elif defined(WXUSINGDLL) # define WXDLLIMPEXP_AUI WXIMPORT #else /* not making nor using DLL */ # define WXDLLIMPEXP_AUI #endif #ifdef WXMAKINGDLL_PROPGRID # define WXDLLIMPEXP_PROPGRID WXEXPORT # define WXDLLIMPEXP_DATA_PROPGRID(type) WXEXPORT type #elif defined(WXUSINGDLL) # define WXDLLIMPEXP_PROPGRID WXIMPORT # define WXDLLIMPEXP_DATA_PROPGRID(type) WXIMPORT type #else /* not making nor using DLL */ # define WXDLLIMPEXP_PROPGRID # define WXDLLIMPEXP_DATA_PROPGRID(type) type #endif #ifdef WXMAKINGDLL_RIBBON # define WXDLLIMPEXP_RIBBON WXEXPORT #elif defined(WXUSINGDLL) # define WXDLLIMPEXP_RIBBON WXIMPORT #else /* not making nor using DLL */ # define WXDLLIMPEXP_RIBBON #endif #ifdef WXMAKINGDLL_RICHTEXT # define WXDLLIMPEXP_RICHTEXT WXEXPORT #elif defined(WXUSINGDLL) # define WXDLLIMPEXP_RICHTEXT WXIMPORT #else /* not making nor using DLL */ # define WXDLLIMPEXP_RICHTEXT #endif #ifdef WXMAKINGDLL_MEDIA # define WXDLLIMPEXP_MEDIA WXEXPORT #elif defined(WXUSINGDLL) # define WXDLLIMPEXP_MEDIA WXIMPORT #else /* not making nor using DLL */ # define WXDLLIMPEXP_MEDIA #endif #ifdef WXMAKINGDLL_STC # define WXDLLIMPEXP_STC WXEXPORT # define WXDLLIMPEXP_DATA_STC(type) WXEXPORT type #elif defined(WXUSINGDLL) # define WXDLLIMPEXP_STC WXIMPORT # define WXDLLIMPEXP_DATA_STC(type) WXIMPORT type #else /* not making nor using DLL */ # define WXDLLIMPEXP_STC # define WXDLLIMPEXP_DATA_STC(type) type #endif #ifdef WXMAKINGDLL_WEBVIEW # define WXDLLIMPEXP_WEBVIEW WXEXPORT # define WXDLLIMPEXP_DATA_WEBVIEW(type) WXEXPORT type #elif defined(WXUSINGDLL) # define WXDLLIMPEXP_WEBVIEW WXIMPORT # define WXDLLIMPEXP_DATA_WEBVIEW(type) WXIMPORT type #else /* not making nor using DLL */ # define WXDLLIMPEXP_WEBVIEW # define WXDLLIMPEXP_DATA_WEBVIEW(type) type #endif /* GCC warns about using __attribute__ (and also __declspec in mingw32 case) on forward declarations while MSVC complains about forward declarations without __declspec for the classes later declared with it, so we need a separate set of macros for forward declarations to hide this difference: */ #if defined(HAVE_VISIBILITY) || (defined(__WINDOWS__) && defined(__GNUC__)) #define WXDLLIMPEXP_FWD_BASE #define WXDLLIMPEXP_FWD_NET #define WXDLLIMPEXP_FWD_CORE #define WXDLLIMPEXP_FWD_ADV #define WXDLLIMPEXP_FWD_QA #define WXDLLIMPEXP_FWD_HTML #define WXDLLIMPEXP_FWD_GL #define WXDLLIMPEXP_FWD_XML #define WXDLLIMPEXP_FWD_XRC #define WXDLLIMPEXP_FWD_AUI #define WXDLLIMPEXP_FWD_PROPGRID #define WXDLLIMPEXP_FWD_RIBBON #define WXDLLIMPEXP_FWD_RICHTEXT #define WXDLLIMPEXP_FWD_MEDIA #define WXDLLIMPEXP_FWD_STC #define WXDLLIMPEXP_FWD_WEBVIEW #else #define WXDLLIMPEXP_FWD_BASE WXDLLIMPEXP_BASE #define WXDLLIMPEXP_FWD_NET WXDLLIMPEXP_NET #define WXDLLIMPEXP_FWD_CORE WXDLLIMPEXP_CORE #define WXDLLIMPEXP_FWD_ADV WXDLLIMPEXP_ADV #define WXDLLIMPEXP_FWD_QA WXDLLIMPEXP_QA #define WXDLLIMPEXP_FWD_HTML WXDLLIMPEXP_HTML #define WXDLLIMPEXP_FWD_GL WXDLLIMPEXP_GL #define WXDLLIMPEXP_FWD_XML WXDLLIMPEXP_XML #define WXDLLIMPEXP_FWD_XRC WXDLLIMPEXP_XRC #define WXDLLIMPEXP_FWD_AUI WXDLLIMPEXP_AUI #define WXDLLIMPEXP_FWD_PROPGRID WXDLLIMPEXP_PROPGRID #define WXDLLIMPEXP_FWD_RIBBON WXDLLIMPEXP_RIBBON #define WXDLLIMPEXP_FWD_RICHTEXT WXDLLIMPEXP_RICHTEXT #define WXDLLIMPEXP_FWD_MEDIA WXDLLIMPEXP_MEDIA #define WXDLLIMPEXP_FWD_STC WXDLLIMPEXP_STC #define WXDLLIMPEXP_FWD_WEBVIEW WXDLLIMPEXP_WEBVIEW #endif /* for backwards compatibility, define suffix-less versions too */ #define WXDLLEXPORT WXDLLIMPEXP_CORE #define WXDLLEXPORT_DATA WXDLLIMPEXP_DATA_CORE /* MSVC up to 6.0 needs to be explicitly told to export template instantiations used by the DLL clients, use this macro to do it like this: template <typename T> class Foo { ... }; WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( Foo<int> ) (notice that currently we only need this for wxBase and wxCore libraries) */ #if defined(__VISUALC__) && (__VISUALC__ <= 1200) #ifdef WXMAKINGDLL_BASE #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl) \ template class WXDLLIMPEXP_BASE decl; #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl) \ template class WXDLLIMPEXP_CORE decl; #else /* We need to disable this warning when using this macro, as recommended by Microsoft itself: http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b168958 */ #pragma warning(disable:4231) #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl) \ extern template class WXDLLIMPEXP_BASE decl; #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl) \ extern template class WXDLLIMPEXP_CORE decl; #endif #else /* not VC <= 6 */ #define WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE(decl) #define WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE(decl) #endif /* VC6/others */ #endif /* _WX_DLIMPEXP_H_ */
[ "admin@rajko.info" ]
admin@rajko.info
daaa0a13aa163ede36bac38d824459892b879cec
8a2e417c772eba9cf4653d0c688dd3ac96590964
/prop-src/setltype.cc
39f66c50d6bf929478b0d17220a18817abb01551
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
romix/prop-cc
1a190ba6ed8922428352826de38efb736e464f50
3f7f2e4a4d0b717f4e4f3dbd4c7f9d1f35572f8f
refs/heads/master
2023-08-30T12:55:00.192286
2011-07-19T20:56:39
2011-07-19T20:56:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
13,964
cc
/////////////////////////////////////////////////////////////////////////////// // This file is generated automatically using Prop (version 2.4.0), // last updated on Jul 1, 2011. // The original source file is "..\..\prop-src\setltype.pcc". /////////////////////////////////////////////////////////////////////////////// #define PROP_TUPLE2_USED #include <propdefs.h> #line 1 "../../prop-src/setltype.pcc" /////////////////////////////////////////////////////////////////////////////// // // This file implements the type checker for the SETL-like sublanguage. // /////////////////////////////////////////////////////////////////////////////// #include "ir.h" #include "ast.h" #include "setl-ast.h" #include "setlgen.h" #include "type.h" #include "env.h" /////////////////////////////////////////////////////////////////////////////// // // Method to elaborate a definition. // /////////////////////////////////////////////////////////////////////////////// Env type_of( Def def, const Env& E) { return E; } /////////////////////////////////////////////////////////////////////////////// // // Method to elaborate a definition list. // /////////////////////////////////////////////////////////////////////////////// Env type_of( Defs defs, const Env& E) { return E; } /////////////////////////////////////////////////////////////////////////////// // // Method to unify two expressions type. // /////////////////////////////////////////////////////////////////////////////// Bool unify( Exp exp, Ty a, Ty b) { if (! unify(a,b)) { error( "%Ltype mismatch in expression: %f\n" "%Lexpecting '%T' but found '%T'\n", exp, a, b); return false; } else return true; } /////////////////////////////////////////////////////////////////////////////// // // Method to infer the type of an expression. // /////////////////////////////////////////////////////////////////////////////// Ty type_of( Exp exp, const Env& E) { Ty ty = NOty; #line 61 "../../prop-src/setltype.pcc" #line 121 "../../prop-src/setltype.pcc" { if (exp) { switch (exp->tag__) { case a_Exp::tag_LITERALexp: { #line 63 "../../prop-src/setltype.pcc" ty = type_of(_LITERALexp(exp)->LITERALexp); #line 63 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_IDexp: { #line 64 "../../prop-src/setltype.pcc" ty = mkvar(); #line 64 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_RELexp: { #line 73 "../../prop-src/setltype.pcc" ty = mkvar(); #line 73 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_DOTexp: { #line 74 "../../prop-src/setltype.pcc" ty = component_ty(type_of(_DOTexp(exp)->_1,E),_DOTexp(exp)->_2); #line 74 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_SELECTORexp: { #line 75 "../../prop-src/setltype.pcc" ty = component_ty(type_of(_SELECTORexp(exp)->_1,E),_SELECTORexp(exp)->_2); #line 75 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_DEREFexp: { #line 76 "../../prop-src/setltype.pcc" ty = mkvar(); #line 76 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_ARROWexp: { #line 77 "../../prop-src/setltype.pcc" ty = mkvar(); #line 77 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_INDEXexp: { #line 78 "../../prop-src/setltype.pcc" ty = mkvar(); #line 78 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_BINOPexp: { #line 79 "../../prop-src/setltype.pcc" ty = mkvar(); #line 79 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_PREFIXexp: { #line 80 "../../prop-src/setltype.pcc" ty = mkvar(); #line 80 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_POSTFIXexp: { #line 81 "../../prop-src/setltype.pcc" ty = mkvar(); #line 81 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_APPexp: { #line 82 "../../prop-src/setltype.pcc" ty = mkvar(); #line 82 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_ASSIGNexp: { #line 83 "../../prop-src/setltype.pcc" ty = mkvar(); #line 83 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_IFexp: { #line 84 "../../prop-src/setltype.pcc" ty = mkvar(); #line 84 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_TUPLEexp: { #line 85 "../../prop-src/setltype.pcc" return mktuplety(type_of(_TUPLEexp(exp)->TUPLEexp,E)); #line 85 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_EXTUPLEexp: { #line 86 "../../prop-src/setltype.pcc" return extuplety(type_of(_EXTUPLEexp(exp)->EXTUPLEexp,E)); #line 86 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_RECORDexp: { #line 88 "../../prop-src/setltype.pcc" #line 89 "../../prop-src/setltype.pcc" Tuple2<Ids, Tys> #line 89 "../../prop-src/setltype.pcc" t = type_of( _RECORDexp(exp)->RECORDexp, E); return mkrecordty( t._1, t._2, false); } break; case a_Exp::tag_LISTexp: { if (_LISTexp(exp)->_1) { #line 94 "../../prop-src/setltype.pcc" Tys head_tys = type_of( _LISTexp(exp)->_3, E); Ty tail_ty = type_of( _LISTexp(exp)->_4, E); Ty arg_ty = mkvar(); for_each (Ty, one_ty, head_tys) unify( exp, one_ty, arg_ty); Ty fun_ty = inst( _LISTexp(exp)->_1->cons_ty); ty = mkvar(); unify( exp, fun_ty, mkfunty( mktuplety( #line 102 "../../prop-src/setltype.pcc" #line 102 "../../prop-src/setltype.pcc" list_1_(arg_ty,list_1_(mkvar())) #line 102 "../../prop-src/setltype.pcc" #line 102 "../../prop-src/setltype.pcc" ), ty)); if (_LISTexp(exp)->_4 != NOexp) unify( exp, tail_ty, ty); #line 105 "../../prop-src/setltype.pcc" } else { L1:; #line 121 "../../prop-src/setltype.pcc" ty = NOty; #line 121 "../../prop-src/setltype.pcc" } } break; case a_Exp::tag_VECTORexp: { #line 106 "../../prop-src/setltype.pcc" return mkvar(); #line 106 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_CONSexp: { if (_CONSexp(exp)->_1) { if (_CONSexp(exp)->_3) { #line 69 "../../prop-src/setltype.pcc" Ty fun_ty = inst(_CONSexp(exp)->_1->cons_ty); ty = mkvar(); unify(exp,fun_ty,mkfunty(type_of(_CONSexp(exp)->_3,E),ty)); #line 72 "../../prop-src/setltype.pcc" } else { #line 67 "../../prop-src/setltype.pcc" ty = inst(_CONSexp(exp)->_1->cons_ty); #line 67 "../../prop-src/setltype.pcc" } } else { goto L1; } } break; case a_Exp::tag_CASTexp: { #line 107 "../../prop-src/setltype.pcc" type_of(_CASTexp(exp)->_2,E); return _CASTexp(exp)->_1; #line 107 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_QUALexp: { #line 108 "../../prop-src/setltype.pcc" return mkvar(); #line 108 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_EQexp: { #line 109 "../../prop-src/setltype.pcc" return bool_ty; #line 109 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_UNIFYexp: { #line 110 "../../prop-src/setltype.pcc" return NOty; #line 110 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_LTexp: { #line 111 "../../prop-src/setltype.pcc" return bool_ty; #line 111 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_HASHexp: { #line 112 "../../prop-src/setltype.pcc" return integer_ty; #line 112 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_THISCOSTexp: { #line 113 "../../prop-src/setltype.pcc" return integer_ty; #line 113 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_COSTexp: { #line 114 "../../prop-src/setltype.pcc" return integer_ty; #line 114 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_THISSYNexp: { #line 115 "../../prop-src/setltype.pcc" return _THISSYNexp(exp)->_2; #line 115 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_SYNexp: { #line 116 "../../prop-src/setltype.pcc" return _SYNexp(exp)->_3; #line 116 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_SENDexp: { #line 92 "../../prop-src/setltype.pcc" return mkvar(); #line 92 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_SETLexp: { #line 117 "../../prop-src/setltype.pcc" ty = NOty; #line 117 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_LISTCOMPexp: { #line 118 "../../prop-src/setltype.pcc" ty = NOty; #line 118 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_FORALLexp: { #line 119 "../../prop-src/setltype.pcc" ty = NOty; #line 119 "../../prop-src/setltype.pcc" } break; case a_Exp::tag_EXISTSexp: { #line 120 "../../prop-src/setltype.pcc" ty = NOty; #line 120 "../../prop-src/setltype.pcc" } break; default: { #line 65 "../../prop-src/setltype.pcc" _MARKEDexp(exp)->_1.set_loc(); ty = type_of(_MARKEDexp(exp)->_2,E); #line 65 "../../prop-src/setltype.pcc" } break; } } else { #line 62 "../../prop-src/setltype.pcc" ty = NOty; #line 62 "../../prop-src/setltype.pcc" } } #line 122 "../../prop-src/setltype.pcc" #line 122 "../../prop-src/setltype.pcc" ty = deref(ty); if (boxed(exp)) exp->ty = ty; return ty; } /////////////////////////////////////////////////////////////////////////////// // // Method to infer the type of an expression list. // /////////////////////////////////////////////////////////////////////////////// Tys type_of( Exps es, const Env& E) { #line 138 "../../prop-src/setltype.pcc" #line 140 "../../prop-src/setltype.pcc" { if (es) { #line 140 "../../prop-src/setltype.pcc" return list_1_(type_of(es->_1,E),type_of(es->_2,E)); #line 140 "../../prop-src/setltype.pcc" } else { #line 139 "../../prop-src/setltype.pcc" return nil_1_; #line 139 "../../prop-src/setltype.pcc" } } #line 141 "../../prop-src/setltype.pcc" #line 141 "../../prop-src/setltype.pcc" } /////////////////////////////////////////////////////////////////////////////// // // Method to infer the type of an labeled expression list. // /////////////////////////////////////////////////////////////////////////////// #line 150 "../../prop-src/setltype.pcc" Tuple2<Ids, Tys> #line 150 "../../prop-src/setltype.pcc" type_of( LabExps es, const Env& E) { Ids labels = #line 151 "../../prop-src/setltype.pcc" nil_1_ #line 151 "../../prop-src/setltype.pcc" #line 151 "../../prop-src/setltype.pcc" ; Tys tys = #line 152 "../../prop-src/setltype.pcc" #line 152 "../../prop-src/setltype.pcc" nil_1_ #line 152 "../../prop-src/setltype.pcc" #line 152 "../../prop-src/setltype.pcc" ; #line 153 "../../prop-src/setltype.pcc" #line 160 "../../prop-src/setltype.pcc" { for (;;) { if (es) { #line 156 "../../prop-src/setltype.pcc" labels = #line 157 "../../prop-src/setltype.pcc" #line 157 "../../prop-src/setltype.pcc" list_1_(es->_1.label,labels) #line 157 "../../prop-src/setltype.pcc" #line 157 "../../prop-src/setltype.pcc" ; tys = #line 158 "../../prop-src/setltype.pcc" #line 158 "../../prop-src/setltype.pcc" list_1_(type_of(es->_1.exp,E),tys) #line 158 "../../prop-src/setltype.pcc" #line 158 "../../prop-src/setltype.pcc" ; es = es->_2; #line 160 "../../prop-src/setltype.pcc" } else { goto L2; } } L2:; } #line 161 "../../prop-src/setltype.pcc" #line 161 "../../prop-src/setltype.pcc" return #line 162 "../../prop-src/setltype.pcc" #line 162 "../../prop-src/setltype.pcc" mkTuple2(labels,tys) #line 162 "../../prop-src/setltype.pcc" #line 162 "../../prop-src/setltype.pcc" ; } /////////////////////////////////////////////////////////////////////////////// // // Method to infer the type of a statement. // /////////////////////////////////////////////////////////////////////////////// void type_of (Stmt s, const Env& E) { #line 173 "../../prop-src/setltype.pcc" #line 185 "../../prop-src/setltype.pcc" { if (s) { switch (s->tag__) { case a_Stmt::tag_ASSIGNstmt: {} break; case a_Stmt::tag_BLOCKstmt: {} break; case a_Stmt::tag_WHILEstmt: {} break; case a_Stmt::tag_IFstmt: {} break; case a_Stmt::tag_MATCHstmt: {} break; case a_Stmt::tag_REWRITEstmt: {} break; case a_Stmt::tag_REPLACEMENTstmt: {} break; case a_Stmt::tag_FORALLstmt: {} break; default: {} break; } } else {} } #line 185 "../../prop-src/setltype.pcc" #line 185 "../../prop-src/setltype.pcc" } /////////////////////////////////////////////////////////////////////////////// // // Method to infer the type of a list of statements. // /////////////////////////////////////////////////////////////////////////////// void type_of( Stmts ss, const Env& E) { #line 196 "../../prop-src/setltype.pcc" #line 198 "../../prop-src/setltype.pcc" { for (;;) { if (ss) { #line 198 "../../prop-src/setltype.pcc" type_of( ss->_1, E); ss = ss->_2; #line 198 "../../prop-src/setltype.pcc" } else { goto L3; } } L3:; } #line 199 "../../prop-src/setltype.pcc" #line 199 "../../prop-src/setltype.pcc" } #line 201 "../../prop-src/setltype.pcc" /* ------------------------------- Statistics ------------------------------- Merge matching rules = yes Number of DFA nodes merged = 43 Number of ifs generated = 8 Number of switches generated = 2 Number of labels = 1 Number of gotos = 1 Adaptive matching = disabled Fast string matching = disabled Inline downcasts = disabled -------------------------------------------------------------------------- */
[ "aaronngray@gmail.com" ]
aaronngray@gmail.com
86553a230f372d90ccd00722cb96cabcf82a1a83
0841c948188711d194835bb19cf0b4dae04a5695
/mds/sources/center/src/centermdsmanager.cpp
66afa956be9567134a17f36c1ffe528ac247847b
[]
no_license
gjhbus/sh_project
0cfd311b7c0e167e098bc4ec010822f1af2d0289
1d4d7df4e92cff93aba9d28226d3dbce71639ed6
refs/heads/master
2020-06-15T16:11:33.335499
2016-06-15T03:41:22
2016-06-15T03:41:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,727
cpp
#include "centermdsmanager.h" CenterMdsManager::CenterMdsManager() { buffer_ = new uint8_t[0x10000]; buffer_len_ = 0x10000; db_backup_count_ = DEFAULT_BACKUP_COUNT; // mds backup count, include itself } CenterMdsManager::~CenterMdsManager() { Clear(); if ( buffer_ ) { delete [] buffer_; buffer_ = NULL; } } CenterMdsManager& CenterMdsManager::operator=(const CenterMdsManager &manager) { if ( this != &manager ) { Clear(); db_backup_count_ = manager.db_backup_count_; MdsList t = manager.mds_list_; for (MdsList::iterator i = t.begin(); i != t.end(); ++i) { Mds *tmp_mds = new Mds(); tmp_mds->key = (*i)->key; tmp_mds->bucket_bs = (*i)->bucket_bs; mds_list_.push_back(tmp_mds); mds_set_.insert((*i)->key); } } return *this; } bool CenterMdsManager::Add(const std::string &key) { FATAL("Conshash add mds(%s)", STR(key)); MdsSet::iterator it = mds_set_.find(key); if ( mds_set_.end() != it ) { WARN("Mds %s has inserted to manager", STR(key)); return false; } uint32_t mds_count = mds_list_.size() + 1; Mds *tmp_mds = new Mds(); tmp_mds->key = key; tmp_mds->bucket_bs.reset(); if ( 1 == mds_count ) { tmp_mds->bucket_bs.set(); mds_list_.push_back(tmp_mds); mds_set_.insert(key); return true; } for ( MdsList::iterator i = mds_list_.begin(); mds_list_.end() != i; ++i ) { uint32_t bucket_count = (*i)->bucket_bs.count(); uint32_t divisor = bucket_count / mds_count; uint32_t tmp_bucket_count = 0; for ( uint32_t j = 0; j < (*i)->bucket_bs.size() && tmp_bucket_count < divisor; ++j ) { if ( (*i)->bucket_bs.test(j) ) { (*i)->bucket_bs.reset(j); tmp_mds->bucket_bs.set(j); ++tmp_bucket_count; } } } mds_list_.push_back(tmp_mds); mds_set_.insert(key); return true; } bool CenterMdsManager::Remove(const std::string &key) { FATAL("Conshash remove mds(%s)", STR(key)); MdsSet::iterator it = mds_set_.find(key); if ( mds_set_.end() == it ) { WARN("Mds %s has removed from manager", STR(key)); return false; } MdsList::iterator i; for (i = mds_list_.begin(); mds_list_.end() != i; ++i) { if ( key == (*i)->key ) { break; } } if ( i == mds_list_.end() ) { return false; } if ( 1 == mds_list_.size() ) { delete *i; mds_list_.clear(); mds_set_.clear(); return true; } Mds *mds = (*i); mds_list_.erase(i); mds_set_.erase(key); uint32_t mds_count = mds_list_.size(); uint32_t bucket_count = mds->bucket_bs.count(); uint32_t divisor = bucket_count / mds_count; uint32_t j = 0; for ( i = mds_list_.begin(); mds_list_.end() != i; ++i ) { uint32_t tmp_bucket_count = 0; while ( j < mds->bucket_bs.size() && tmp_bucket_count < divisor ) { if ( mds->bucket_bs.test(j) ) { mds->bucket_bs.reset(j); (*i)->bucket_bs.set(j); ++tmp_bucket_count; } ++j; } } // distribute remain mds bucket to previous mdses in mds_list_ i = mds_list_.begin(); while ( j < mds->bucket_bs.size() ) { if ( mds->bucket_bs.test(j) ) { mds->bucket_bs.reset(j); (*i)->bucket_bs.set(j); ++i; if ( mds_list_.end() == i ) i = mds_list_.begin(); } ++j; } delete mds; return true; } BinaryParser::BigAVal *CenterMdsManager::Serialize() { uint8_t *output = buffer_; uint8_t *outend = output + buffer_len_; uint8_t *tmp_output; BinaryParser::AVal bv; BinaryParser::BigAVal pbv; uint32_t buf_len = BUCKET_COUNT / 8; if ( 0 != BUCKET_COUNT % 8 ) ++buf_len; char *buf = new char[buf_len]; // backup count output = BinaryParser::EncodeInt32(output, outend, db_backup_count_); // count of mds output = BinaryParser::EncodeInt32(output, outend, mds_list_.size()); for (MdsList::iterator i = mds_list_.begin(); i != mds_list_.end(); ++i) { // key of mds bv.val = (uint8_t*)STR((*i)->key); bv.len = (*i)->key.length(); tmp_output = BinaryParser::EncodeBuffer(output, outend, &bv); if ( !tmp_output ) { UpdateOutput(&output, &outend); output = BinaryParser::EncodeBuffer(output, outend, &bv); } else { output = tmp_output; } // bucket bitmap of mds memset(buf, 0, buf_len); uint32_t len = bitsToBuffer((*i)->bucket_bs, buf, buf_len); pbv.val = (uint8_t*)buf; pbv.len = len; tmp_output = BinaryParser::EncodeBigBuffer(output, outend, &pbv); if ( !tmp_output ) { UpdateOutput(&output, &outend); output = BinaryParser::EncodeBigBuffer(output, outend, &pbv); } else { output = tmp_output; } } delete []buf; bv_.val = buffer_; bv_.len = output - buffer_; return &bv_; } bool CenterMdsManager::Deserialize(const std::string &val) { Clear(); BinaryParser parser; parser.SetDecode((uint8_t *)STR(val)); std::string bits; db_backup_count_ = parser.DecodeInt32(); uint32_t mds_count = parser.DecodeInt32(); for (uint32_t i = 0; i < mds_count; i++) { Mds *mds = new Mds(); mds->key = parser.DecodeString(); bits = parser.DecodeBigString(); bufferToBits(STR(bits), bits.length(), mds->bucket_bs); mds_list_.push_back(mds); mds_set_.insert(mds->key); } FATAL("Deserialize conshash, mds list size(%u)", mds_list_.size()); return true; } void CenterMdsManager::Clear() { db_backup_count_ = DEFAULT_BACKUP_COUNT; for (MdsList::iterator i = mds_list_.begin(); i != mds_list_.end(); ++i) delete *i; mds_list_.clear(); mds_set_.clear(); } void CenterMdsManager::GetMdsChange(const std::tr1::unordered_map<std::string, ProcessCenter*> &config, std::vector<std::string> &add_list, std::vector<std::string> &remove_list) { add_list.clear(); remove_list.clear(); std::tr1::unordered_map<std::string, ProcessCenter*> del_mds = config; std::tr1::unordered_map<std::string, ProcessCenter*>::iterator it; for (MdsList::iterator i = mds_list_.begin(); i != mds_list_.end(); ++i) { it = del_mds.find((*i)->key); if ( del_mds.end() == it ) remove_list.push_back((*i)->key); else del_mds.erase(it); } FOR_UNORDERED_MAP(del_mds, std::string, ProcessCenter*, i) { add_list.push_back(MAP_KEY(i)); } } bool CenterMdsManager::Empty() { return mds_list_.empty(); } bool CenterMdsManager::Check() { std::bitset<BUCKET_COUNT> bucket_bs; bucket_bs.reset(); for ( MdsList::iterator i = mds_list_.begin(); mds_list_.end() != i; ++i ) { for ( uint32_t j = 0; j < (*i)->bucket_bs.size(); ++j ) { if ( (*i)->bucket_bs.test(j) ) { if ( bucket_bs.test(j) ) { WARN("Consthash error: bucket[%d] has been distributed, distribute to"\ " %s failed", j, STR((*i)->key)); return false; } bucket_bs.set(j); } } } if ( bucket_bs.count() != bucket_bs.size() ) { WARN("Consthash error: there exist buckets have not been distributed"); return false; } for ( MdsList::iterator i = mds_list_.begin(); mds_list_.end() != i; ++i ) { INFO("Mds(%s) bucket count(%d)", STR((*i)->key), (*i)->bucket_bs.count()); } return true; } void CenterMdsManager::UpdateOutput(uint8_t **output, uint8_t **outend) { buffer_len_ *= 2; uint8_t *tmp = new uint8_t[buffer_len_]; uint32_t pos = (*output)-buffer_; memcpy(tmp, buffer_, pos); delete[] buffer_; buffer_ = tmp; *output = buffer_ + pos; *outend = buffer_ + buffer_len_; }
[ "greatmiffa@gmail.com" ]
greatmiffa@gmail.com
84104d1e1b3357829e1657394372afdf159b0178
3ad968797a01a4e4b9a87e2200eeb3fb47bf269a
/MFC CodeGuru/tools/odbc_classgen/W/VCP/FastTest/FastTestView.h
cfb7e74f35a87f9343c5b69f23d8ffe3d9cc9cc3
[]
no_license
LittleDrogon/MFC-Examples
403641a1ae9b90e67fe242da3af6d9285698f10b
1d8b5d19033409cd89da3aba3ec1695802c89a7a
refs/heads/main
2023-03-20T22:53:02.590825
2020-12-31T09:56:37
2020-12-31T09:56:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,753
h
// FastTestView.h : interface of the CFastTestView class // ///////////////////////////////////////////////////////////////////////////// #if !defined(AFX_FASTTESTVIEW_H__7137DC99_B77C_11D1_AE72_0004AC31E75C__INCLUDED_) #define AFX_FASTTESTVIEW_H__7137DC99_B77C_11D1_AE72_0004AC31E75C__INCLUDED_ #if _MSC_VER >= 1000 #pragma once #endif // _MSC_VER >= 1000 #include "LocationsSet.h" class CFastTestView : public CListView { protected: // create from serialization only CFastTestView(); DECLARE_DYNCREATE(CFastTestView) // Attributes public: CFastTestDoc* GetDocument(); // Operations public: CLocationsSet* m_pLocationsSet; // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CFastTestView) public: virtual void OnDraw(CDC* pDC); // overridden to draw this view virtual BOOL PreCreateWindow(CREATESTRUCT& cs); protected: virtual void OnInitialUpdate(); // called first time after construct //}}AFX_VIRTUAL // Implementation public: virtual ~CFastTestView(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: // Generated message map functions protected: //{{AFX_MSG(CFastTestView) afx_msg void OnGetdispinfo(NMHDR* pNMHDR, LRESULT* pResult); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; #ifndef _DEBUG // debug version in FastTestView.cpp inline CFastTestDoc* CFastTestView::GetDocument() { return (CFastTestDoc*)m_pDocument; } #endif ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. #endif // !defined(AFX_FASTTESTVIEW_H__7137DC99_B77C_11D1_AE72_0004AC31E75C__INCLUDED_)
[ "pkedpekr@gmail.com" ]
pkedpekr@gmail.com
7988c1ec8e42adaa7cb0013284f5bf8c4eaa9180
ea065794fe1b35dbc7923d539b4f85bd41277c2b
/n_queens.cc
2386b4de07dc5444a7f61e39bf8ce4e2e2b819d5
[]
no_license
sergiovasquez122/EPI_SOLUTIONS
6e93e98ad8b0c3b8e0e162f5e8c04b7a6b24f47f
6e39cf2a981d34516fd1037d0ce3c65d0ebb4133
refs/heads/master
2022-12-09T17:55:48.066759
2020-08-15T01:33:50
2020-08-15T01:33:50
268,199,261
0
0
null
null
null
null
UTF-8
C++
false
false
1,146
cc
#include <algorithm> #include <iterator> #include <vector> #include "test_framework/generic_test.h" using std::vector; bool is_valid(vector<int>& partial, int candidate, int row){ for(int i = 0;i <= row - 1;++i){ if(candidate == partial[i] || std::abs(candidate - partial[i]) == row - i){ return false; } } return true; } void helper(vector<vector<int>>& result, vector<int>& partial, int row, int n){ if(row == n){ result.push_back(partial); return; } for(int i = 0;i < n;++i){ if(is_valid(partial, i, row)){ partial.push_back(i); helper(result, partial, row + 1, n); partial.pop_back(); } } } vector<vector<int>> NQueens(int n) { vector<vector<int>> result; vector<int> partial; helper(result, partial, 0, n); return result; } int main(int argc, char* argv[]) { std::vector<std::string> args{argv + 1, argv + argc}; std::vector<std::string> param_names{"n"}; return GenericTestMain(args, "n_queens.cc", "n_queens.tsv", &NQueens, UnorderedComparator{}, param_names); }
[ "sergiovasquez122@gmail.com" ]
sergiovasquez122@gmail.com
8ce30f14b330c0404cc2116ad87c73cf66606dbe
4005eca13ea7e1a635cd2396a1a0eaee2c0bcbc0
/tasks/tbb_overhead.cpp
5d765150ed292f1284f9c511e11fa7dbfc125faa
[ "BSL-1.0" ]
permissive
sithhell/hpxbenchmarks
9d2fe566373faab007d571953326cade63721703
3687081a1bab5ffa872576f4ff8267f32d4fcc85
refs/heads/master
2021-05-14T04:59:09.483841
2018-08-11T14:01:23
2018-08-11T14:01:23
116,657,438
1
0
null
null
null
null
UTF-8
C++
false
false
1,187
cpp
// Copyright (c) 2017-2018 Thomas Heller // // 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 <benchmark/benchmark.h> #include <tbb/tbb.h> #include <support/dummy.hpp> static void function_call_overhead(benchmark::State& state) { for (auto _: state) { dummy(); } } BENCHMARK(function_call_overhead)->UseRealTime(); struct dummy_task : tbb::task { tbb::task *execute() { dummy(); return nullptr; } }; static void tbb_overhead(benchmark::State& state) { for (auto _: state) { dummy_task &d = *new (tbb::task::allocate_root()) dummy_task(); tbb::task::spawn_root_and_wait(d); } } BENCHMARK(tbb_overhead)->UseRealTime(); #include <cstdlib> int main(int argc, char **argv) { benchmark::Initialize(&argc, argv); const char *env = std::getenv("NUM_THREADS"); std::string thread_env = env == nullptr ? "1": std::string(env); int num_threads = std::atoi(thread_env.c_str()); tbb::task_scheduler_init init(num_threads); benchmark::RunSpecifiedBenchmarks(); return 0; }
[ "thomas.heller@cs.fau.de" ]
thomas.heller@cs.fau.de
73e807b96d6354f32c01b626120c2deb5af8d652
60f8e23f9b3a1787ee9ccd98ac40b0993846a9e7
/GameProject/OpenGL/ClearEffect.h
2376c3aad6e629202d821498408184380ead3ec6
[]
no_license
reo1316hw/GameWork
d85ea08f886b67c4c44acc7863ce556a13040c6c
8732acb1ae4252d68713d07099172d628b11d393
refs/heads/main
2023-07-17T21:51:24.254196
2021-08-30T17:43:17
2021-08-30T17:43:17
362,292,162
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
734
h
/* @brief ใƒ—ใƒชใƒ—ใƒญใ‚ปใƒƒใ‚ต */ #pragma once /* @brief ใ‚คใƒณใ‚ฏใƒซใƒผใƒ‰ */ class ClearEffect : public ParticleEffectBase { public: /* @fn ใ‚ณใƒณใ‚นใƒˆใƒฉใ‚ฏใ‚ฟ @param _pos ใ‚ฏใƒชใ‚ขใ‚จใƒ•ใ‚งใ‚ฏใƒˆใฎ็”Ÿๆˆๅ ดๆ‰€ @param _vel ใ‚ฏใƒชใ‚ขใ‚จใƒ•ใ‚งใ‚ฏใƒˆใฎ้€Ÿๅบฆ @param _objectTag ใ‚ขใ‚ฟใƒƒใƒใ—ใŸใ‚ฒใƒผใƒ ใ‚ชใƒ–ใ‚ธใ‚งใ‚ฏใƒˆใฎใ‚ฟใ‚ฐ @param _sceneTag ใ‚ทใƒผใƒณใฎใ‚ฟใ‚ฐ */ ClearEffect(Vector3 _pos, Vector3 _vel, const Tag& _objectTag ,SceneBase::Scene _sceneTag); /* @fn ใƒ‡ใ‚นใƒˆใƒฉใ‚ฏใ‚ฟ */ ~ClearEffect() {}; /* @fn ใ‚ฏใƒชใ‚ขใ‚จใƒ•ใ‚งใ‚ฏใƒˆใฎใ‚ขใƒƒใƒ—ใƒ‡ใƒผใƒˆ @param _deltaTime ๆœ€ๅพŒใฎใƒ•ใƒฌใƒผใƒ ใ‚’ๅฎŒไบ†ใ™ใ‚‹ใฎใซ่ฆใ—ใŸๆ™‚้–“ */ void UpdateGameObject(float _deltaTime)override; private: };
[ "leohattori@icloud.com" ]
leohattori@icloud.com
99e87a1cd607da1f7ca52899b0bb70d711a71cc9
8a1a2fdd8fe6a1e6625d4fa4d28013be829856a2
/hw5/main_window.cpp
9e2467a188ff2f7559130b7b6b25eb5b53ec21dd
[]
no_license
bkwsuper24/Brian_Wang_Projects
dd3b11d6ce84fff85a693ec89171c399fd185196
19e1e20f34b8954b2ff6b677c2b53082b9b507b2
refs/heads/master
2021-01-10T14:18:50.476023
2015-10-26T10:03:42
2015-10-26T10:03:42
44,517,145
0
0
null
null
null
null
UTF-8
C++
false
false
13,596
cpp
#include "main_window.h" #include "datastore.h" #include "db_parser.h" #include "product_parser.h" #include "util.h" #include <sstream> #include <iostream> #include "msort.h" #include <fstream> Main_Window::Main_Window(std::string ifile) { parser.addProductParser(new ProductBookParser); parser.addProductParser(new ProductClothingParser); parser.addProductParser(new ProductMovieParser); if(parser.parse(ifile, ds)) { return; } currentuser = ds.UserVector[0]->getName(); //Title setWindowTitle("Amazon Shop"); // Overall layout OverallLayout = new QHBoxLayout(); //this is smaller layout within overall layout SearchOptionLayout = new QVBoxLayout(); OverallLayout->addLayout(SearchOptionLayout); //Terms text SearchTermsLabel = new QLabel("Search Terms"); SearchOptionLayout->addWidget(SearchTermsLabel); //Creating line edit to enter terms to search SearchTermsInput = new QLineEdit(); SearchOptionLayout->addWidget(SearchTermsInput); //Creating exclusive group check-box CheckboxLayout = new QHBoxLayout(); SearchOptionLayout->addLayout(CheckboxLayout); AND = new QRadioButton(tr("AND")); CheckboxLayout->addWidget(AND); OR = new QRadioButton(tr("OR")); CheckboxLayout->addWidget(OR); AND->setAutoExclusive(true); AND->setChecked(true); //Add the search button SearchButton = new QPushButton("SEARCH"); connect(SearchButton, SIGNAL(clicked()), this, SLOT(SEARCH())); SearchOptionLayout->addWidget(SearchButton); //Add the alphabetical merge-sort button SortOptionLayout = new QHBoxLayout(); SearchOptionLayout->addLayout(SortOptionLayout); AlphaSortButton = new QPushButton("Sort Search Alphabetically"); connect(AlphaSortButton, SIGNAL(clicked()), this, SLOT(AlphaSort())); SortOptionLayout->addWidget(AlphaSortButton); //Add the review merge-sort button ReviewSortButton = new QPushButton("Sort Search by Average Rating"); connect(ReviewSortButton, SIGNAL(clicked()), this, SLOT(RSort())); SortOptionLayout->addWidget(ReviewSortButton); //Create dropdown menu to select user UserDropdown = new QComboBox(); //iterating through user vector to print into menu for(unsigned int i=0; i<ds.getUserVector().size(); i++) { std::vector<User*> myVector= ds.getUserVector(); User* user= myVector[i]; QString qstr= QString::fromStdString(user->getName()); UserDropdown->addItem(qstr); } SearchOptionLayout->addWidget(UserDropdown); connect(UserDropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(filler(int))); //Horizontal layout for add and view cart buttons CartOptionLayout = new QHBoxLayout(); SearchOptionLayout->addLayout(CartOptionLayout); //Create add cart button AddCartButton = new QPushButton("Add-to-Cart"); connect(AddCartButton, SIGNAL(clicked()), this, SLOT(ADDCART())); CartOptionLayout->addWidget(AddCartButton); //Create view cart button ViewCartButton = new QPushButton("View-Cart"); connect(ViewCartButton, SIGNAL(clicked()), this, SLOT(VIEWCART())); CartOptionLayout->addWidget(ViewCartButton); //Enter valid file to save to text SaveLabel = new QLabel("Type valid file to save to"); SearchOptionLayout->addWidget(SaveLabel); //Creating line edit to enter terms to search SaveInput = new QLineEdit(); SearchOptionLayout->addWidget(SaveInput); //Save database to a file button SaveButton = new QPushButton("Save Text File"); connect(SaveButton, SIGNAL(clicked()), this, SLOT(SAVE())); SearchOptionLayout->addWidget(SaveButton); //Quit program button QuitButton = new QPushButton("QUIT"); connect(QuitButton, SIGNAL(clicked()), this, SLOT(QUIT())); SearchOptionLayout->addWidget(QuitButton); //Create product list and layout ProductLayout = new QVBoxLayout(); OverallLayout->addLayout(ProductLayout); //Create text for Products ProductsLabel = new QLabel("Products That Match Search"); ProductLayout->addWidget(ProductsLabel); //Create empty list that will have products from search ProductList = new QListWidget(); prodref = ProductList; connect(ProductList, SIGNAL(currentRowChanged(int)), this, SLOT(ProductChange(int))); ProductLayout->addWidget(ProductList); //Create review list and layout ReviewLayout = new QVBoxLayout(); OverallLayout->addLayout(ReviewLayout); //Create text for Reviews ReviewsLabel = new QLabel("Reviews of Product"); ReviewLayout->addWidget(ReviewsLabel); //Create empty list that will have reviews of products from search ReviewList = new QListWidget(); ReviewLayout->addWidget(ReviewList); //Create add reviews layout AddReviewLayout = new QVBoxLayout(); OverallLayout->addLayout(AddReviewLayout); //Create text for adding reviews AddReviewsLabel = new QLabel("Add a Review Section"); AddReviewLayout->addWidget(AddReviewsLabel); //Creating text for adding rating AddReviewsRating = new QLabel("Enter an integer between 1-5"); AddReviewLayout->addWidget(AddReviewsRating); //Creating line edit to enter rating of product RatingLine = new QLineEdit(); AddReviewLayout->addWidget(RatingLine); //Creating text for adding date AddReviewsDate = new QLabel("Enter a date: YYYY-MM-DD"); AddReviewLayout->addWidget(AddReviewsDate); //Creating line edit to enter date of product DateLine = new QLineEdit(); AddReviewLayout->addWidget(DateLine); //Creating text for string of text AddReviewsText = new QLabel("Type in review text"); AddReviewLayout->addWidget(AddReviewsText); //Creating line edit to enter string of text of product TextLine = new QLineEdit(); AddReviewLayout->addWidget(TextLine); AddReviewButton = new QPushButton("ADD REVIEW"); connect(AddReviewButton, SIGNAL(clicked()), this, SLOT(ADDREVIEW())); AddReviewLayout->addWidget(AddReviewButton); setLayout(OverallLayout); } Main_Window::~Main_Window() { } void Main_Window::SEARCH() { ProductList->clear(); ReviewList->clear(); if(SearchTermsInput->text().isEmpty() == true) { return; } std::stringstream ss((SearchTermsInput->text().toStdString())); std::string term; std::vector<std::string> terms; while(ss >> term) { term = convToLower(term); terms.push_back(term); } if(AND->isChecked()) { hits = ds.search(terms, 0); } else { hits = ds.search(terms, 1); } //int resultNo = 1; std::string temp; for(std::vector<Product*>::iterator it = hits.begin(); it != hits.end(); ++it) { temp = (*it)->displayString(); QString qs = QString::fromStdString(temp); ProductList->addItem(qs); } SearchTermsInput->setText(""); } //Comparator for sorting alphabetically struct AlphaProdSort { bool operator()(Product* a, Product* b) { return(a->getName() < b->getName()); } }; void Main_Window::AlphaSort() { ProductList->clear(); AlphaProdSort aps; if(hits.size()==0) { return; } else { mergeSort(hits, aps); std::string temp; for(std::vector<Product*>::iterator it = hits.begin(); it != hits.end(); ++it) { temp = (*it)->displayString(); QString qs = QString::fromStdString(temp); ProductList->addItem(qs); } } } //Comparator for sorting by average rating struct RatingProdSort { DStore ds; bool operator()(Product* a, Product* b) { std::vector<Review*> r1; std::vector<Review*> r2; double a1=0; double b1=0; double a1avg=0.0; double b1avg=0.0; std::map<std::string, std::vector<Review*> > temp; temp = ds.getReviewMap(); std::map<std::string, std::vector<Review*> >::iterator it = temp.find(a->getName()); if(it != temp.end()) { r1= it->second; } std::map<std::string, std::vector<Review*> >::iterator iter = temp.find(b->getName()); if(iter != temp.end()) { r2= iter->second; } if(r1.size()==0) { a1avg = 0.0; } else { for(unsigned int i=0; i<r1.size(); i++) { a1 += r1[i]->rating; } a1avg = a1/r1.size(); } if(r2.size()==0) { b1avg=0.0; } else { for(unsigned int i=0; i<r2.size(); i++) { b1 += r2[i]->rating; } b1avg = b1/r2.size(); } return(a1avg > b1avg); } }; void Main_Window::RSort() { RatingProdSort rps; rps.ds = ds; ProductList->clear(); if(hits.size()==0) { cout<<hits.size()<<endl; return; } else { mergeSort(hits, rps); for(unsigned int i=0; i<hits.size(); i++) { hits[i]->displayString(); QString qs = QString::fromStdString(hits[i]->displayString()); ProductList->addItem(qs); } } } void Main_Window::ADDCART() { if(productCount < 0) { return; } else { currentuser = UserDropdown->currentText().toStdString(); ds.addCart(currentuser, hits[productCount]); } } void Main_Window::filler(int index) { index4u = index; } void Main_Window::VIEWCART() { QWidget* CartBox = new QWidget(); currentuser = UserDropdown->currentText().toStdString(); CartBox->setWindowTitle(QString::fromStdString(currentuser)); QVBoxLayout* cartWindowLayout = new QVBoxLayout(); QLabel* cartWindowLabel = new QLabel("Shopping Cart"); cartWindowLayout->addWidget(cartWindowLabel); QListWidget* cartList = new QListWidget(); connect(cartList, SIGNAL(currentRowChanged(int)), this, SLOT(ReviewChange(int))); cartref = cartList; cartWindowLayout->addWidget(cartList); hits = ds.viewCart(currentuser); for(unsigned int i=0; i<hits.size(); i++) { std::string strtemp = (hits[i])->displayString(); QString qs = QString::fromStdString(strtemp); cartList->addItem(qs); } QPushButton* BuyButton = new QPushButton("Buy-Cart"); connect(BuyButton, SIGNAL(clicked()), this, SLOT(PUSHBUYBUTTON())); cartWindowLayout->addWidget(BuyButton); QPushButton* RemoveButton = new QPushButton("Remove-Cart"); connect(RemoveButton, SIGNAL(clicked()), this, SLOT(PUSHREMOVEBUTTON())); cartWindowLayout->addWidget(RemoveButton); QPushButton* CloseButton = new QPushButton("Close"); connect(CloseButton, SIGNAL(clicked()), CartBox, SLOT(close())); cartWindowLayout->addWidget(CloseButton); CartBox->setLayout(cartWindowLayout); CartBox->show(); } void Main_Window::SAVE() { if(SaveInput->text().isEmpty() == true) { QMessageBox::warning(this, "Error Save", "ENTER VALID FILENAME"); } else { std::string filename (SaveInput->text().toStdString()); std::ofstream ofile(filename.c_str()); ds.dump(ofile); ofile.close(); } SaveInput->clear(); } void Main_Window::QUIT() { QApplication::quit(); } void Main_Window::ADDREVIEW() { if(DateLine->text().isEmpty() || TextLine->text().isEmpty() || RatingLine->text().isEmpty()) { QMessageBox::warning(this, "Error Add Review", "ENTER SOMETHING IN DATE, TEXT REVIEW, AND RATING"); } else if(RatingLine->text().isEmpty() == false && (DateLine->text().isEmpty() == false && TextLine->text().isEmpty() == false)) { std::string date (DateLine->text().toStdString()); int rating1 (RatingLine->text().toInt()); std::string text (TextLine->text().toStdString()); if(rating1 <1 || rating1 >5) { QMessageBox::warning(this, "ERROR", "DID NOT ENTER VALID RATING RANGE"); } int position = 0; int position1 = 5; int position2 = 8; for(unsigned int i=0; i<6; i++) { if(date[i] == '-') { std::string year = date.substr(position,(i-position)); if(year.size() !=4) { QMessageBox::warning(this, "ERROR", "ENTER VALID YEAR RANGE AND FORMAT"); } position = i+1; } } for(unsigned int i=5; i<date.size(); i++) { if(date[i] == '-') { std:: string month = date.substr(position1, (i-position1)); if(month.size() != 2) { QMessageBox::warning(this, "ERROR", "ENTER VALID YEAR RANGE AND FORMAT"); } position = i+1; } } for(unsigned int i=8; i<date.size(); i++) { if(date[i] == '-') { std:: string month = date.substr(position2, (i-position2)); if(month.size() != 2) { QMessageBox::warning(this, "ERROR", "ENTER VALID MONTH/DAY RANGE AND FORMAT"); } position = i+1; } } Review *r = new Review(); r->prodName = hits[ProductList->currentRow()]->getName(); r->rating = rating1; r->date = date; r->reviewText = text; ds.addReview(r); displayReviews(); } DateLine->clear(); TextLine->clear(); RatingLine->clear(); } void Main_Window::ProductChange(int productcounter) { productCount = productcounter; if(productCount < 0) { return; } else { displayReviews(); } } void Main_Window::ReviewChange(int usercartcounter) { UserCount = usercartcounter; if(UserCount < 0) { return; } else { } } void Main_Window::displayReviews() { ReviewList->clear(); std::string name = hits[productCount]->getName(); std::map<std::string, std::vector <Review*> > reviewMap = ds.getReviewMap(); std::vector<Review*> reviews = reviewMap[name]; //msort(reviews, compname) for(unsigned int i=0; i<reviews.size(); i++) { std::ostringstream oss; oss << reviews[i]->rating << " " << reviews[i]->date << " " << reviews[i]->reviewText; std::string temp = oss.str(); QString qstr1 = QString::fromStdString(temp); ReviewList->addItem(qstr1); } } void Main_Window::PUSHBUYBUTTON() { ds.buyCart(currentuser); cartref->clear(); hits = ds.viewCart(currentuser); for(unsigned int i=0; i<hits.size(); i++) { std::string strtemp = (hits[i])->displayString(); QString qs = QString::fromStdString(strtemp); cartref->addItem(qs); } } void Main_Window::PUSHREMOVEBUTTON() { ds.removeCart(currentuser, UserCount); cartref->clear(); hits = ds.removeCart(currentuser, UserCount); for(unsigned int i=0; i<hits.size(); i++) { std::string strtemp = (hits[i])->displayString(); QString qs = QString::fromStdString(strtemp); cartref->addItem(qs); } }
[ "briankwa@usc.edu" ]
briankwa@usc.edu
65e979618d8ef79ba33d73b34c926ba96e7e26ce
8447d06d0d5da3db2b3aae926ec66409b38fb140
/3rdPartLib/DBow3/utils/bin_vocabulary.cc
208fb200b13b0b4b0d494139417f3ea2275ea24a
[ "BSD-2-Clause" ]
permissive
HKPolyU-UAV/FLVIS
60d0fecac6e10eb19a131d589a5c0ddf89198157
4ad31bbe5191ae2763c70a641c31337b1e06c9e2
refs/heads/master
2023-07-21T11:11:05.885918
2023-07-12T14:26:32
2023-07-12T14:26:32
197,144,164
145
37
BSD-2-Clause
2021-06-07T08:45:04
2019-07-16T07:33:55
C++
UTF-8
C++
false
false
453
cc
//Second step,creates the vocabulary from the set of features. It can be slow #include <iostream> #include <vector> // DBoW3 #include "DBoW3.h" // OpenCV #include <opencv2/core/core.hpp> using namespace DBoW3; using namespace std; // ---------------------------------------------------------------------------- int main(int argc,char **argv) { DBoW3::Vocabulary voc ("voc_all_datasets_orb.yml"); voc.save("voc_orb.dbow3"); }
[ "chensy1991@gmail.com" ]
chensy1991@gmail.com
62fc1eaf5fb92f446271d292826ed3516de699cf
c885982a50743ce23b052f9ca0fb62df975ac8d8
/apps-src/apps/librose/key.hpp
4a83ed3561853514b530171b3fccd169631427ba
[]
no_license
9cat/Rose
29db5bda442e7442aad5a34e68154a04c537e15d
d685ad558731ff381525f185d50bce87f786f65f
refs/heads/master
2020-12-25T03:50:56.880607
2016-06-26T14:15:50
2016-06-27T08:56:02
62,073,637
1
0
null
2016-06-27T17:10:36
2016-06-27T17:10:36
null
UTF-8
C++
false
false
1,089
hpp
/* $Id: key.hpp 46186 2010-09-01 21:12:38Z silene $ */ /* Copyright (C) 2003 - 2010 by David White <dave@whitevine.net> Part of the Battle for Wesnoth Project http://www.wesnoth.org/ 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. See the COPYING file for more details. */ #ifndef KEY_HPP_INCLUDED #define KEY_HPP_INCLUDED #include "SDL.h" /** * Class that keeps track of all the keys on the keyboard. * Whether any key is pressed or not can be found by using its * operator[]. Note though that it is generally better to use * key events to see when keys are pressed rather than to poll using * this object. */ class CKey { const Uint8 *key_list; public: CKey(); bool operator[](int k) const; // bool operator[](int k) const { return key_list[k] > 0; } }; #endif
[ "ancientcc@leagor.com" ]
ancientcc@leagor.com
6e09fe909390902591772961d24d4b0a56b1fcd2
de8ff7af5bf2d2945cc82c38330623fd19ee409e
/SRC/PMCLASS/include/winstd.hpp
56af10c2a2daf9b0a167473aee3b0f82ca920f51
[]
no_license
OS2World/DEV-SAMPLES-NET-TCPIP_Programming
eef5876ac0ee158633e3c5b3d9196897a9314013
f9c3b45662e57b51774e6aa7bfc6c49c3df5c591
refs/heads/master
2016-09-06T15:12:25.087804
2014-10-31T14:37:55
2014-10-31T14:37:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,587
hpp
//-------------- // C_WINDOW_STD \ //--------------------------------------------------------------------------- // All information contained in this file is Copyright (c) 1994-1995 by // NeoLogic Inc. All Rights Reserved // // This source code shall not be implemented, duplicated or used as the basis // for any product without prior written consent by NeoLogic Inc. // class C_WINDOW_STD : public C_WINDOW { private: char *szClassName; ULONG lFrameFlags; public: _Export C_WINDOW_STD( void ); _Export C_WINDOW_STD( T_MSG_TABLE *pxtMsg ); void _Export Create( int iID, char *szTitle ); void _Export GetSizePosition( int *piX, int *piY, int *piW, int *piL ); void _Export GetSize( int *piX, int *piY ); void _Export GetPosition( int *piW, int *piL ); void _Export SetSizePosition( int iX, int iY, int iCX, int iCY ); void _Export SetPosition( int iX, int iY ); void _Export SetSize( int iCX, int iCY ); void _Export SetTitle( char *szTitle ); void _Export GetTitle( char *szTitle, int iLength ); void _Export WCF_Standard( void ); void _Export WCF_Icon( void ); void _Export WCF_SysMenu( void ); void _Export WCF_Menu( void ); void _Export WCF_MinButton( void ); void _Export WCF_MaxButton( void ); void _Export WCF_TitleBar( void ); void _Export WCF_Border( void ); void _Export WCF_DialogBorder( void ); void _Export WCF_SizingBorder( void ); void _Export WCF_TaskList( void ); void _Export WCF_ShellPosition( void ); // Window Message Handlers virtual void * _Export MsgPaint( void *mp1, void *mp2 ); };
[ "martin@os2world.com" ]
martin@os2world.com
e1b034d5ee9ea850305777e6c3e00d21819aad27
8fce7da004a35a90d9497fddbadb229339a7e7d6
/Accelerometer.ino
e6840d1281031d3169fd977f5a376057caca6a6e
[]
no_license
ben-cunningham/quadcopter
6ea16e546981aaf80d7498cb806df7b86558b28e
b1e642aadedea16c3ce77914d25e36a97f31afb7
refs/heads/master
2021-01-01T05:59:42.037762
2014-09-06T23:43:40
2014-09-06T23:43:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,190
ino
#include "Wire.h" //map float values float mapfloat(float x, float in_min, float in_max, float out_min, float out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } void initAccel(){ //all values are correctly set from default } void calcAccelVals() { byte* data = readFromDevice(ACCEL, 0x02, 6); xRead = (((data[0] | (data[1] << 8))>>2) / 4096.0) - accelXOffset; yRead = (((data[2] | (data[3] << 8))>>2) / 4096.0) - accelYOffset; zRead = (((data[4] | (data[5] << 8))>>2) / 4096.0) - accelZOffset; //convert readings to angles accelVals[0] = RAD_TO_DEG * (atan2(yRead, zRead)); accelVals[1] = RAD_TO_DEG * (atan2(xRead, sqrt(yRead*yRead + zRead*zRead))); accelVals[2] = RAD_TO_DEG * (atan2(-yRead, -xRead) + PI); } //return accelerometer values from IMU float getXAccel() { return accelVals[0]; } float getYAccel() { return accelVals[1]; } float getZAccel() { return accelVals[2]; } void printAccelVals() { Serial.println("Accel vals: "); Serial.print("x: "); Serial.print(getXAccel()); Serial.print(" y: "); Serial.print(getYAccel()); Serial.print(" z:"); Serial.print(getZAccel()); Serial.println(); }
[ "benjamincunningham@Benjamins-MacBook-Pro.local" ]
benjamincunningham@Benjamins-MacBook-Pro.local
a46604855a9f51bb0d15d30a14b92cdbb1459c56
607a24dffd79cb50feb0c90d9b528ab01a694648
/MATERI BASIC/arraymultidemensibuiltin/main2.cpp
a09fb42f79184b51e9d3eb19181d13061ef07929
[]
no_license
yogadwiprasetyo/belajar-cpp
fa8b4b74a11f6fca9556beb116d1d0d890a43765
e676c0a78a9fdfacbca1e11a6b5370b1175945ed
refs/heads/master
2021-01-04T17:33:04.825013
2020-02-15T14:15:35
2020-02-15T14:15:35
240,688,168
0
0
null
null
null
null
UTF-8
C++
false
false
497
cpp
#include <iostream> using namespace std; // const = nilai pasti; void Printarray(int *ptrArray, int baris, int kolom){ int index = 0; for(int i = 0; i < baris; i++){ cout << "["; for(int j = 0; j < kolom; j++){ cout << (*ptrArray + index) << " "; index ++; } cout << "]" << endl; } } int main(){ // array multidimensi[baris][kolom] const int baris = 2; const int kolom = 3; int arrayMD[baris][kolom] = {0,1,2,3,4,5}; Printarray(*arrayMD, baris, kolom); return 0; }
[ "yprsty01@gmail.com" ]
yprsty01@gmail.com
f5fff986a30fc0c0f3ca0cccb2d95e015e550188
9ac0d5a496dc02b1b21976fd53c6d69ca1bc660e
/include/bauasian/post_processors/ssao_blur.hpp
857aad32fdabb75cc2f751f4864d8ec35f55917a
[]
no_license
karol-gruszczyk/graphics-engine
b38c0471f73cf97697c44788972101635b2a9025
98eda2ecb250ec408648c80c9a493354e68cf7fc
refs/heads/master
2021-01-17T09:53:31.244827
2017-01-24T09:31:50
2017-01-24T09:31:50
37,024,101
2
0
null
2016-06-02T16:48:21
2015-06-07T16:47:46
null
UTF-8
C++
false
false
264
hpp
#ifndef BAUASIAN_SSAO_BLUR_HPP #define BAUASIAN_SSAO_BLUR_HPP #include "area_filter.hpp" namespace bauasian { class SSAOBlur; } class bauasian::SSAOBlur : public AreaFilter { public: SSAOBlur(const glm::uvec2& size); }; #endif /* BAUASIAN_SSAO_BLUR_HPP */
[ "karol.gruszczyk@gmail.com" ]
karol.gruszczyk@gmail.com
a23ada77f7777fcb91b352cef905ade425889876
e5f2327b5652c248386f1ff6e472a66458897aaf
/Number communication/_1/_1.ino
6cdd8ba280e28ec025fe768536feac6c34049d4f
[]
no_license
jordipujolreu/Serial
2f28175fb9e402e98801c8e4b076f8d87cef51cc
c77ad9508bf6aab35a7dda7b0b69a74fd8a2ddfa
refs/heads/master
2020-05-23T07:49:52.974618
2017-03-02T21:48:07
2017-03-02T21:48:07
80,450,862
0
0
null
null
null
null
UTF-8
C++
false
false
2,019
ino
/********************************************************************************** ** ** ** SERIAL ** ** Number comunication ** ** NOM : Jordi Pujlreu Sala DATA: 13/2/17 ** **********************************************************************************/ //********** Includes ************************************************************* //********** Variables ******************************************************** float r1, r2; // variables for the R's float rSerie, rParalel; // variables for the results //********** Setup ************************************************************ void setup() { Serial.begin(9600); // initialize serial Serial.println("Entra el valor de r1 i r2 (separats per una coma)"); } //********** Loop ************************************************************* void loop() { while (Serial.available() > 0) { // if there's any serial available, read it r1 = Serial.parseInt();// look for valid int the incoming serial stream r2 = Serial.parseInt(); if (Serial.read() == '\n') { // quan presionem enter significa que hem acabat d'enviar dades Serial.print (" R1= "); //escriure els seguents missatges Serial.print (r1); Serial.print ("ohms"); Serial.print (" R2= "); Serial.print (r2); Serial.println ("ohms"); rSerie = r1 + r2 ; // operacions calcular rserie rParalel = r1*r2 / (r1+r2) ; //operacio per calcular rparalel Serial.print (" Rserie = ");//escriure.... Serial.print (rSerie); //resultat operaciรณ Serial.print ("ohms"); Serial.print (" rparalel = "); Serial.print (rParalel); Serial.println ("ohms"); Serial.println ("Entra nous valors per a r1 i r2 "); } } }
[ "jordipujolreu004@gmail.com" ]
jordipujolreu004@gmail.com
9044edcd25b634dd341b772a9c56fdee108502cb
3fd9bd50b5104929dd40ae8690e61399f2c68dd6
/sketch_sep27a/sketch_sep27a.ino
23703a104683fb98b85d730f50a19503bb3af87e
[]
no_license
KevinVanWezel/arduino
0ed9ebee74728f58335051b2cf088cf6b31e0090
e231348d00d5a4da591ef2a1b7b60731c92fe1db
refs/heads/master
2021-07-05T13:22:28.128708
2017-09-27T12:42:07
2017-09-27T12:42:07
105,016,680
0
0
null
null
null
null
UTF-8
C++
false
false
1,166
ino
int led1 = 1 ; int led2 = 2 ; int led3 = 3 ; int led4 = 4 ; int led5 = 5 ; int led6 = 6 ; int led7 = 7 ; int led8 = 8 ; void setup() { // put your setup code here, to run once: pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(led4, OUTPUT); pinMode(led5, OUTPUT); pinMode(led6, OUTPUT); pinMode(led7, OUTPUT); pinMode(led8, OUTPUT); } void loop() { // put your main code here, to run repeatedly: digitalWrite(led1, HIGH); delay(100); digitalWrite(led1, LOW); delay(100); digitalWrite(led2, HIGH); delay(100); digitalWrite(led2, LOW); delay(100); digitalWrite(led3, HIGH); delay(100); digitalWrite(led3, LOW); delay(100); digitalWrite(led4, HIGH); delay(100); digitalWrite(led4, LOW); delay(100); digitalWrite(led5, HIGH); delay(100); digitalWrite(led5, LOW); delay(100); digitalWrite(led6, HIGH); delay(100); digitalWrite(led6, LOW); delay(100); digitalWrite(led7, HIGH); delay(100); digitalWrite(led7, LOW); delay(100); digitalWrite(led8, HIGH); delay(100); digitalWrite(led8, LOW); delay(100); }
[ "21973@ma-web.nl" ]
21973@ma-web.nl
4e05d2078f857e944665dbeec944cbad56e3192d
ad91fdbc5eeb7ff63f9e62467a8e71f7eb5bc084
/20131123/main.cpp
46684c1613331aeca2f227ccd7eed4cad353daea
[]
no_license
suhyunx/xcode-files
e326bba767112d3d6fc33882a70758bd5d984c8d
8ff524ecd5c17b53dca26907bd9811a1c7fbef07
refs/heads/master
2022-11-28T08:55:26.207343
2020-08-08T14:28:49
2020-08-08T14:28:49
286,052,986
0
0
null
null
null
null
UTF-8
C++
false
false
1,279
cpp
// // main.cpp // 20131123 // // Created by JM Park on 13. 11. 23.. // Copyright (c) 2013๋…„ JM Park. All rights reserved. // #include <iostream> using namespace std; int main(int argc, const char * argv[]) { int x, y, z; int num1, num2, num3; int strike=0; int ball=0; int out=0; int count=0; x=4, y=5, z=9; while(1) { cout << " Write your numbers. " << endl; cin >> num1; cin >> num2; cin >> num3; if(x==num1) strike++; else if(x==num2 || num3) ball++; else out++; if(y==num2) strike++; else if(y==num1 || num3) ball++; else out++; if(z==num3) strike++; else if(z==num1 || z==num2) ball++; else out++; count++; if(strike==3) { cout << " It's Strike. Game Over.. " << endl; break; } cout << " Your Score is " << strike << " Strike " << ball << " Ball " << out << " Out " << endl; strike=0; ball=0; out=0; } }
[ "ktu9988@gmail.com" ]
ktu9988@gmail.com
791bf017d3de23b1d6c0ec134b8c4c93cac5fe32
cfb156de35a7f3987f88d6b025c762921f5e9931
/tests/libs/dl_preempt_library_1.cpp
b4d81d5ac04951cefd556f254a75f3e0fe8517c5
[ "Apache-2.0", "BSD-2-Clause" ]
permissive
aosp-mirror/platform_bionic
6faa82304cb67f3347a9b04f2f0eb712444d764a
143f3cea320becbfc836309fade5dfa1074731d0
refs/heads/master
2023-07-08T07:44:02.618070
2023-06-26T23:35:08
2023-06-26T23:35:08
65,830
300
131
null
2018-11-05T20:53:52
2008-10-21T18:19:55
Objective-C
UTF-8
C++
false
false
1,405
cpp
/* * Copyright (C) 2014 The Android Open Source Project * * 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 * * http://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. */ // This one should be preempted by the function // defined in the main executable. extern "C" int __attribute__((weak)) main_global_default_serial() { return 2716057; } // Even though this one is defined by the main // executable it should not be preempted // because of protected visibility extern "C" int __attribute__((weak, visibility("protected"))) main_global_protected_serial() { return 3370318; } extern "C" int main_global_default_get_serial() { return main_global_default_serial(); } extern "C" int main_global_protected_get_serial() { return main_global_protected_serial(); } // Trying to preempt functions from a DT_NEEDED .so extern "C" int lib_global_default_serial() { return 3370318; } extern "C" int lib_global_protected_serial() { return 2716057; }
[ "dimitry@google.com" ]
dimitry@google.com
26458df3c7796e19d81331b3d9993202437c6634
07530d760b44a90260f8b205903837ce60913704
/Course.h
f084d8b9a2b096a9c76621e1e365286e2eb8fa7b
[]
no_license
lance152/course_manager
28baf9899327c1edb6576cf1b2639b23008d6bf8
802f5f951f2a0c8c024dcb977664bb893357d655
refs/heads/master
2022-07-15T06:00:49.211898
2020-05-19T00:54:26
2020-05-19T00:54:26
264,558,044
0
0
null
null
null
null
UTF-8
C++
false
false
1,494
h
#ifndef _COURSE_H_ #define _COURSE_H_ #include <string> using namespace std; class Course{ //ๅ‹ๅ…ƒๅ‡ฝๆ•ฐ๏ผŒ่ฏปๅ–่พ“ๅ…ฅๅˆ›ๅปบๆ–ฐ็š„่ฏพ็จ‹ friend void read(istream &inputStream,Course &course); public: //ๆ— ๅ‚ๆ•ฐๆž„้€ ๅ‡ฝๆ•ฐ Course(); //ๆ นๆฎ่ฏพ็จ‹ๅ็งฐๅˆ›ๅปบ่ฏพ็จ‹ๅฏน่ฑก Course(const string& cName):Course(){ name = cName; }; //ๆ‹ท่ดๆž„้€ ๅ‡ฝๆ•ฐ Course(const Course& course); //ๆ‰“ๅฐ่ฏพ็จ‹ไฟกๆฏ virtual void PrintInfo() const; //่ฟ”ๅ›ž่ฏพ็จ‹ๅ็งฐ inline string GetName() const{return name;}; //่ฎพ็ฝฎ่ฏพ็จ‹ๅ็งฐ inline void SetName(const string& newName){name = newName;}; //่ฟ”ๅ›ž่ฏพ็จ‹id inline const int GetId() const{return id;}; //้‡่ฝฝ<<ๆ“ไฝœ็ฌฆ๏ผŒ็”จๆฅ่พ“ๅ‡บ่ฏพ็จ‹ไฟกๆฏ friend ostream& operator<<(ostream& out,const Course& course); protected: //่ฏพ็จ‹id int id; //่ฏพ็จ‹ๅ็งฐ string name; //่ฎพ็ฝฎ้™ๆ€ๅ˜้‡ๆฅๅˆ†้…id static int currentId; }; class ProjectCourse: public Course{ public: //่ฎพ็ฝฎๆ ‡็ญพ inline void SetTag(const string& newTag){tag = newTag;}; //่ฟ”ๅ›žๆ ‡็ญพ inline string GetTag() const {return tag;}; //ๆ‰“ๅฐ่ฏพ็จ‹ไฟกๆฏ virtual void PrintInfo() const override; private: string tag; }; class JudgeCourse: public Course{ public: //่ฎพ็ฝฎ้™ๆ—ถ inline void SetTime(int newTime) {time = newTime;}; //่ฟ”ๅ›ž้™ๆ—ถ inline int GetTime() {return time;}; //ๆ‰“ๅฐ่ฏพ็จ‹ไฟกๆฏ virtual void PrintInfo() const override; private: int time; //ๆœ‰ๆ—ถ้™ }; #endif
[ "lance9040@gmail.com" ]
lance9040@gmail.com
7da72c2f8815056707ac0a801690301eb707f093
def72bb78f131273126485c0000950d4f5aea6cc
/blurt_cpp_80211/qam.h
b268b66551f91c4760811e76b1f10c070e8e7e9e
[ "MIT" ]
permissive
nextime/blurt
f1a1dcf374b6ee910d02a50419cc1320a877e27c
be53c0b583c38e3fb4d5985b70e8819bd373f633
refs/heads/master
2020-12-11T05:27:12.191982
2013-11-04T07:37:09
2013-11-04T07:37:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
132
h
#ifndef QAM_H #define QAM_H #include "constellation.h" class QAM : public Constellation { public: QAM(size_t Nbpsc); }; #endif
[ "iannucci@mit.edu" ]
iannucci@mit.edu
346185ec5ef428af623668c7a71c752b1af0e0e4
0f34254882dc256377900fe8785af6e96a675395
/ReorderList/a.cpp
6ba06de0a9ed6af291ccefa62ad12427c711e4d3
[]
no_license
Shirish111/LeetCode
349a4f0de952691ad8c995d40df50a178a48d76e
49e10292579f9da5176bb55735c4b4792c0f302e
refs/heads/master
2022-04-28T20:09:53.545944
2020-04-30T20:13:28
2020-04-30T20:13:28
215,360,477
0
0
null
null
null
null
UTF-8
C++
false
false
2,031
cpp
// Reorder List // Given a singly linked list L: L0โ†’L1โ†’โ€ฆโ†’Ln-1โ†’Ln, // reorder it to: L0โ†’Lnโ†’L1โ†’Ln-1โ†’L2โ†’Ln-2โ†’โ€ฆ // You may not modify the values in the list's nodes, only nodes itself may be // changed. // Example 1: // Given 1->2->3->4, reorder it to 1->4->2->3. // Example 2: // Given 1->2->3->4->5, reorder it to 1->5->2->4->3. // Tags: list #include <bits/stdc++.h> using namespace std; // Definition for singly-linked list. struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} }; class Solution { public: void reorderList(ListNode *head) { // Find the middle Node in the list if (!head || !head->next) { return; } ListNode *fast, *pre_middle; pre_middle = head; fast = head; while (fast->next && fast->next->next) { pre_middle = pre_middle->next; fast = fast->next->next; } // Reverse Elements from Middle to End ListNode *p = pre_middle->next, *q = nullptr, *r = nullptr; while (p) { q = p->next; p->next = r; r = p; p = q; } pre_middle->next = nullptr; // Reorder ListNode *middle = r; p = head; while (middle) { q = p->next; r = middle->next; p->next = middle; middle->next = q; p = q; middle = r; } } }; ListNode *buildList(vector<int> &v) { ListNode *head = nullptr, *p; for (const auto &i : v) { if (head == nullptr) { head = new ListNode(i); p = head; } else { p->next = new ListNode(i); p = p->next; } } return head; } void printList(ListNode *l) { ListNode *p = l; while (p) { cout << p->val << " "; p = p->next; } cout << "\n"; } void solve() { vector<vector<int>> tc = {{1, 2, 3, 4}, {1, 2, 3, 4, 5}}; Solution s; for (auto &i : tc) { ListNode *l = buildList(i); printList(l); s.reorderList(l); printList(l); } } int main() { // cin.tie(NULL); // ios_base::sync_with_stdio(false); solve(); return 0; }
[ "shirishtogarla533@gmail.com" ]
shirishtogarla533@gmail.com
bf0bc4591d023a7f07917ba1ddbf70c90f95f812
1b8ae41e4e43429ba6c21b49fdfa7312ddee23b3
/dp_labs_and_solutions/dp_labs_and_solutions/dp_cpp_labs_and_solutions/null_object/solution/divide.h
f1d77ed20b18b618b22c6377a09844d41c02989a
[]
no_license
Technipire/Cpp
9f8476a944497b82ce425a3d9191acb74337a129
78d4c89385216865b9a9f475055fca1ff600d2a4
refs/heads/master
2021-05-01T16:31:45.977554
2017-04-03T00:02:01
2017-04-03T00:02:01
32,282,437
1
0
null
null
null
null
UTF-8
C++
false
false
298
h
// divide.h #ifndef divide_header #define divide_header #include "binary.h" class expression; class expression_visitor; class divide : public binary { public: divide(expression * a_operand1, expression * a_operand2); virtual void accept(expression_visitor & a_expression_visitor); }; #endif
[ "andyxian510@gmail.com" ]
andyxian510@gmail.com
43306ea63c7009e4538abdccb00820347543969f
97ca042c1dc26f37229b3786f911797d0be8b4c0
/TutSaludarGui/main.cpp
9bda6147ca5582824b499f998d0992b8eda04859
[]
no_license
eriDam/Qt_Cpp_Projects
d8dea941d6ab728cf47c418318eb24edbb80368a
80f8522a83e03e206ea300b96f5f8571710a474f
refs/heads/master
2016-09-05T14:55:40.339447
2015-03-28T09:36:29
2015-03-28T09:36:29
32,111,353
0
0
null
null
null
null
UTF-8
C++
false
false
305
cpp
#include "saludar.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv);//Secrea aplicacion de QT Saludar w; //Creo form a partir de clase w.show(); //Muestro form // w.setCaption("Nombres para Saludar"); //Asigno caption al form return a.exec(); }
[ "erika.c.caballero@gmail.com" ]
erika.c.caballero@gmail.com
112725500265dc1d4bc4c08d31491680df6ce34b
e076ec3c4809deca04b6fab23acdc908e9c570c6
/labs/oop/lab7/release/Tree.hpp
53016a49409c8a44bbf6b94ae0fa2871bb2495cb
[]
no_license
holmss/edu
f4e730a71f50209da63ee7bb3e5b88fcf651c318
9bc4fde5bd9791f190882845dac5be503304e400
refs/heads/master
2021-07-11T11:58:25.879566
2020-06-15T17:40:09
2020-06-15T17:40:09
155,772,585
0
1
null
2019-07-05T13:16:34
2018-11-01T20:35:06
Terra
UTF-8
C++
false
false
1,019
hpp
#ifndef TREE_H #define TREE_H #include "TIterator.hpp" #include "TTree.hpp" template <class T> class Tree { private: pTree root; static std::shared_ptr<TAllocationBlock> allocator; public: Tree(); ~Tree(); Iter<TTree<T>, T> begin(); Iter<TTree<T>, T> end(); template <class B> friend std::ostream& operator<<(std::ostream& os, const Tree<B>& node); void add(T* figure) { add(figure, root); } void add(T* figure, pTree node); void Remove(char* path) { Remove(get(path)); } void Remove(pTree node); void stream(std::ostream& os, const TTree<T>& node, int height) const; // template <class B> // friend std::ostream& operator<<(std::ostream& os, const TTree<B>& tree); pTree get(char* path); Tree* Sort(); pTree get() { return get("\0"); } std::shared_ptr<T> getItem(char* path) { return get(path)->value; } bool empty(); void* operator new(size_t size); void operator delete(void* p); }; #include "Tree.h" #endif // !TREE_H
[ "lera@localhost.localdomain" ]
lera@localhost.localdomain
d66a4d23036be7ed7de4ea16ebe5a1876ce8c101
f44aa00a6a5ac21279b70ca88842fd402ea91a4c
/src/Resources.cpp
9ba7284ea0c53918812319cacd80966d0f41e2d1
[]
no_license
devJudi/2048
4519070058570ff5d6d73c7dc5a46d4d7af2f68d
55b180e5e27c6ca24ab5d0116b96ab880e61c76c
refs/heads/master
2020-08-21T15:58:00.807196
2019-11-01T15:10:17
2019-11-01T15:10:17
216,193,495
0
0
null
2019-10-31T08:10:37
2019-10-19T11:10:56
C++
UTF-8
C++
false
false
186
cpp
#include "Resources.h" Resources::Resources() { //ctor } Resources::~Resources() { //dtor } void Resources::loadFonts() { fontPixel.loadFromFile("fonts/pixelFont.ttf"); }
[ "mikami383@gmail.com" ]
mikami383@gmail.com
005460a2103e1fdad90b8850972d3013c15218ee
5b53403815b2b2dd1fa68863f0c2dd28a9643151
/hacks/42.fr-session-keepalive.ino
3dcb6eb5d6ef6195becdcbbd62d4d2e3501d09e2
[ "WTFPL" ]
permissive
pchanumolu/dotfiles
93ce4d63eb60a392da15ebc6314ec5f7e3391af3
c09dd8dbc6502954cac69f7d762e1cbec3b7fff0
refs/heads/master
2020-04-02T16:18:40.912345
2018-09-26T08:32:03
2018-09-26T08:32:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
249
ino
/* ** Avoid 42.fr to disconnect ** sessions that exceed 42mn of ** log time ~ */ void setup() { Serial.begin(9600); delay(1000); } void loop() { /* Space is ok */ Keyboard.print(" "); /* Wait for 10 minutes */ delay(1000 * 60 * 10); }
[ "me@trosa.io" ]
me@trosa.io
4730efeb50494db5226769cea2fd584e0b1d36af
99c0c3e341bc21e4b4085eb47c9f71a8a939cc6b
/PyIlmBase/PyImath/PyImathAll.h
f6418669ceab117660bc32535568ef88106daad0
[ "BSD-3-Clause" ]
permissive
gatgui/openexr
fa3d9ee3bf5141cc317a4b0a76ba96b1ff0fcaa8
2794a27c5cbdb961250a906e1517d9e9f81ff579
refs/heads/develop
2021-07-04T22:30:46.964528
2021-06-05T14:09:47
2021-06-05T14:18:42
77,419,301
0
2
null
2016-12-27T02:24:41
2016-12-27T02:24:41
null
UTF-8
C++
false
false
1,940
h
/////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2001-2011, Industrial Light & Magic, a division of Lucas // Digital Ltd. LLC // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * 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. // * Neither the name of Industrial Light & Magic nor the names of // its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // 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. // /////////////////////////////////////////////////////////////////////////// #ifndef PYIMATHALL_H #define PYIMATHALL_H #include <PyImathExport.h> namespace PyImath { PYIMATH_EXPORT void register_all(); } #endif
[ "gatgui@gmail.com" ]
gatgui@gmail.com
298a5c60fd368ba02e6ca6a1092ffe0334494329
287dc1683f7e19a5239c2b8addbc8531809f9177
/mooc43-bobo-algo/Play-with-Algorithms-master/02-Sorting-Basic/Course Code (C++)/05-Insertion-Sort/SortTestHelper.h
12e0523c72d72e1cccfbf24c8af80b77cf73e6da
[ "Apache-2.0" ]
permissive
yaominzh/CodeLrn2019
ea192cf18981816c6adafe43d85e2462d4bc6e5d
adc727d92904c5c5d445a2621813dfa99474206d
refs/heads/master
2023-01-06T14:11:45.281011
2020-10-28T07:16:32
2020-10-28T07:16:32
164,027,453
2
0
Apache-2.0
2023-01-06T00:39:06
2019-01-03T22:02:24
C++
UTF-8
C++
false
false
1,893
h
// // Created by liuyubobobo on 7/13/16. // #ifndef INC_04_INSERTION_SORT_SORTTESTHELPER_H #define INC_04_INSERTION_SORT_SORTTESTHELPER_H #include <iostream> #include <algorithm> #include <string> #include <ctime> #include <cassert> using namespace std; namespace SortTestHelper { // ็”Ÿๆˆๆœ‰nไธชๅ…ƒ็ด ็š„้šๆœบๆ•ฐ็ป„,ๆฏไธชๅ…ƒ็ด ็š„้šๆœบ่Œƒๅ›ดไธบ[rangeL, rangeR] int *generateRandomArray(int n, int range_l, int range_r) { int *arr = new int[n]; srand(time(NULL)); for (int i = 0; i < n; i++) arr[i] = rand() % (range_r - range_l + 1) + range_l; return arr; } // ๆ‹ท่ดๆ•ดๅž‹ๆ•ฐ็ป„aไธญ็š„ๆ‰€ๆœ‰ๅ…ƒ็ด ๅˆฐไธ€ไธชๆ–ฐ็š„ๆ•ฐ็ป„, ๅนถ่ฟ”ๅ›žๆ–ฐ็š„ๆ•ฐ็ป„ int *copyIntArray(int a[], int n){ int *arr = new int[n]; //* ๅœจVSไธญ, copyๅ‡ฝๆ•ฐ่ขซ่ฎคไธบๆ˜ฏไธๅฎ‰ๅ…จ็š„, ่ฏทๅคงๅฎถๆ‰‹ๅŠจๅ†™ไธ€้forๅพช็Žฏ:) copy(a, a+n, arr); return arr; } // ๆ‰“ๅฐarrๆ•ฐ็ป„็š„ๆ‰€ๆœ‰ๅ†…ๅฎน template<typename T> void printArray(T arr[], int n) { for (int i = 0; i < n; i++) cout << arr[i] << " "; cout << endl; return; } // ๅˆคๆ–ญarrๆ•ฐ็ป„ๆ˜ฏๅฆๆœ‰ๅบ template<typename T> bool isSorted(T arr[], int n) { for (int i = 0; i < n - 1; i++) if (arr[i] > arr[i + 1]) return false; return true; } // ๆต‹่ฏ•sortๆŽ’ๅบ็ฎ—ๆณ•ๆŽ’ๅบarrๆ•ฐ็ป„ๆ‰€ๅพ—ๅˆฐ็ป“ๆžœ็š„ๆญฃ็กฎๆ€งๅ’Œ็ฎ—ๆณ•่ฟ่กŒๆ—ถ้—ด template<typename T> void testSort(const string &sortName, void (*sort)(T[], int), T arr[], int n) { clock_t startTime = clock(); sort(arr, n); clock_t endTime = clock(); cout << sortName << " : " << double(endTime - startTime) / CLOCKS_PER_SEC << " s"<<endl; assert(isSorted(arr, n)); return; } }; #endif //INC_04_INSERTION_SORT_SORTTESTHELPER_H
[ "mcuallen@gmail.com" ]
mcuallen@gmail.com
81ba7168835f079407e5300f8ff368664d3aa143
f2e027bf993bdad87b894d606c1bc8335c032c29
/fw/system_info.cc
04b070307375e24f1f1c8d2a6792fe4d1cceaa8d
[ "Apache-2.0" ]
permissive
mjbots/moteus
857546df67c4140a4c55ae73baab2077ada83849
da016eb5bb77c6d3a6cbc2191576579f26238a59
refs/heads/main
2023-08-08T22:02:53.352368
2023-08-08T15:00:02
2023-08-08T15:00:02
174,456,820
638
215
Apache-2.0
2023-05-06T16:05:15
2019-03-08T02:43:21
C++
UTF-8
C++
false
false
2,719
cc
// Copyright 2015-2022 Josh Pieper, jjp@pobox.com. // // 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 // // http://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. #include "fw/system_info.h" #include "mbed.h" #include "mjlib/base/inplace_function.h" #include "mjlib/base/visitor.h" #include "mjlib/micro/telemetry_manager.h" namespace moteus { volatile uint32_t SystemInfo::idle_count = 0; namespace { struct SystemInfoData { uint32_t pool_size = 0; uint32_t pool_available = 0; uint32_t idle_rate = 0; uint32_t can_reset_count = 0; // We deliberately start this counter near to int32 overflow so that // any applications that use it will likely have to handle it // properly. uint32_t ms_count = (1ull<<31) - 300000; template <typename Archive> void Serialize(Archive* a) { a->Visit(MJ_NVP(pool_size)); a->Visit(MJ_NVP(pool_available)); a->Visit(MJ_NVP(idle_rate)); a->Visit(MJ_NVP(can_reset_count)); a->Visit(MJ_NVP(ms_count)); } }; } class SystemInfo::Impl { public: Impl(mjlib::micro::Pool& pool, mjlib::micro::TelemetryManager& telemetry) : pool_(pool) { data_updater_ = telemetry.Register("system_info", &data_); } void PollMillsecond() { data_.ms_count++; ms_count_++; if (ms_count_ >= 10) { ms_count_ = 0; } else { return; } data_.pool_size = pool_.size(); data_.pool_available = pool_.available(); const auto this_idle_count = idle_count; data_.idle_rate = this_idle_count - last_idle_count_; last_idle_count_ = this_idle_count; data_updater_(); } void SetCanResetCount(uint32_t value) { data_.can_reset_count = value; } mjlib::micro::Pool& pool_; uint8_t ms_count_ = 0; uint32_t last_idle_count_ = 0; SystemInfoData data_; mjlib::base::inplace_function<void ()> data_updater_; }; SystemInfo::SystemInfo(mjlib::micro::Pool& pool, mjlib::micro::TelemetryManager& telemetry) : impl_(&pool, pool, telemetry) {} SystemInfo::~SystemInfo() {} void SystemInfo::PollMillisecond() { impl_->PollMillsecond(); } void SystemInfo::SetCanResetCount(uint32_t value) { impl_->SetCanResetCount(value); } uint32_t SystemInfo::millisecond_counter() const { return impl_->data_.ms_count; } }
[ "jjp@pobox.com" ]
jjp@pobox.com
c9d7da9807ce36acf189df4b8c77a298348243cd
2a61b02c26e77686e38cd9039e6f4b0530ddb7c9
/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_visualizer.h
5d4e5a764ed561b145d5bd83efba2d0785b1ff12
[ "MIT" ]
permissive
fly-pigTH/bitbots_thmos_meta
931413e86929751024013b8e35f87b799243e22c
f45ccc362dc689b69027be5b0d000d2a08580de4
refs/heads/master
2023-08-27T02:58:08.397650
2021-10-22T17:17:11
2021-10-22T17:17:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,888
h
#ifndef BITBOTS_QUINTIC_WALK_INCLUDE_BITBOTS_QUINTIC_WALK_WALK_VISUALIZER_H_ #define BITBOTS_QUINTIC_WALK_INCLUDE_BITBOTS_QUINTIC_WALK_WALK_VISUALIZER_H_ #include <ros/ros.h> #include <bitbots_quintic_walk/WalkDebug.h> #include <bitbots_quintic_walk/WalkEngineDebug.h> #include <bitbots_quintic_walk/walk_utils.h> #include <bitbots_quintic_walk/walk_engine.h> #include <tf2_eigen/tf2_eigen.h> #include <tf2/LinearMath/Vector3.h> #include <tf2/LinearMath/Quaternion.h> #include <tf2/LinearMath/Transform.h> #include <tf2/LinearMath/Matrix3x3.h> #include <tf2_geometry_msgs/tf2_geometry_msgs.h> #include <moveit/robot_state/robot_state.h> #include <moveit_msgs/RobotState.h> #include "bitbots_splines/abstract_visualizer.h" #include "bitbots_splines/abstract_ik.h" namespace bitbots_quintic_walk { class WalkVisualizer : public bitbots_splines::AbstractVisualizer { public: explicit WalkVisualizer(); void publishArrowMarker(std::string name_space, std::string frame, geometry_msgs::Pose pose, float r, float g, float b, float a); void publishEngineDebug(WalkResponse response); void publishIKDebug(WalkResponse response, robot_state::RobotStatePtr current_state, bitbots_splines::JointGoals joint_goals); void publishWalkMarkers(WalkResponse response); void init(robot_model::RobotModelPtr kinematic_model); private: int marker_id_; ros::Publisher pub_debug_; ros::Publisher pub_engine_debug_; ros::Publisher pub_debug_marker_; robot_model::RobotModelPtr kinematic_model_; std::string base_link_frame_, l_sole_frame_, r_sole_frame_; }; } // namespace bitbots_quintic_walk #endif //BITBOTS_QUINTIC_WALK_INCLUDE_BITBOTS_QUINTIC_WALK_WALK_VISUALIZER_H_
[ "759074800@qq.com" ]
759074800@qq.com
32542c5dffcd748ee2c06a0611c5d4f25d2a5b00
1b96b8a31f907a7a0b1d0159737bf208732f8a2d
/dev/so_5/priority.hpp
48f83a4c4656c03baa5890c78c8c0ea1ca0582e3
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
Stiffstream/sobjectizer
0903578015d99861ff851165acf978d4cb64096a
5035f9948632d8105d916a930263b3a55cf1e157
refs/heads/master
2023-07-11T08:39:22.618525
2023-07-10T10:21:43
2023-07-10T10:21:43
186,988,663
399
43
NOASSERTION
2020-05-24T13:31:50
2019-05-16T08:45:51
C++
UTF-8
C++
false
false
3,988
hpp
/* * SObjectizer-5 */ /*! * \file * \since * v.5.5.8 * * \brief Definition of priority type. */ #pragma once #include <type_traits> #include <stdexcept> #include <string> namespace so_5 { /*! * \since * v.5.5.8 * * \brief Definition of supported priorities. */ enum class priority_t : unsigned char { p_min = 0, p0 = p_min, p1, p2, p3, p4, p5, p6, p7, p_max = p7 }; /*! * \since * v.5.5.8 * * \brief Helper function for conversion from priority to size_t. */ inline std::size_t to_size_t( priority_t priority ) { return static_cast< std::size_t >( priority ); } /*! * \since * v.5.5.8 * * \brief Helper function for conversion from size_t to priority. * * \throw std::invalid_argument if \a v is out of range. */ inline priority_t to_priority_t( std::size_t v ) { if( !( v >= to_size_t(priority_t::p_min) && v <= to_size_t(priority_t::p_max) ) ) throw std::invalid_argument( "value to be converted to " "priority_t is out of range: " + std::to_string( v ) ); return static_cast< priority_t >( v ); } namespace prio { /*! * \name Constants with priority values. * \{ */ const priority_t p0 = priority_t::p0; const priority_t p1 = priority_t::p1; const priority_t p2 = priority_t::p2; const priority_t p3 = priority_t::p3; const priority_t p4 = priority_t::p4; const priority_t p5 = priority_t::p5; const priority_t p6 = priority_t::p6; const priority_t p7 = priority_t::p7; /*! * \} */ /*! * \since * v.5.5.8 * * \brief Default priority value. */ const priority_t default_priority = p0; /*! * \since * v.5.5.8 * * \brief Total count of priorities. */ const unsigned int total_priorities_count = static_cast< unsigned int >( p7 ) - static_cast< unsigned int >( p0 ) + 1; /*! * \since * v.5.5.8 * * \brief Is there higher priority? */ inline bool has_next( priority_t p ) { return p != priority_t::p_max; } /*! * \since * v.5.5.8 * * \brief Get the next priority value. * * \return next priority value if \a p is less than priority_t::p_max or * priority_t::p_max instead. */ inline priority_t next( priority_t p ) { using ut = std::underlying_type< priority_t >::type; return p < priority_t::p_max ? (static_cast< priority_t >( static_cast< ut >(p) + 1)) : priority_t::p_max; } /*! * \since * v.5.5.8 * * \brief Is there lower priority? */ inline bool has_prev( priority_t p ) { return p != priority_t::p_min; } /*! * \since * v.5.5.8 * * \brief Get the previous priority value. * * \return previous priority value if \a p is greater than priority_t::p_min or * priority_t::p_min instead. */ inline priority_t prev( priority_t p ) { using ut = std::underlying_type< priority_t >::type; return p > priority_t::p_min ? (static_cast< priority_t >(static_cast< ut >(p) - 1 )) : priority_t::p_min; } /*! * \since * v.5.5.8 * * \brief Does enumeration of all priorities. * * \note Performs enumeration from priority_t::p_min to priority_t::p_max * (inclusive). * * \tparam Lambda a lambda with the prototype: * \code return_type lambda(so_5::priority_t); * \endcode * Return value from that lambda will be ignored and discarded. * * \par Example: \code // Fill the new cooperation with agents with different priorities. env.introduce_coop( so_5::disp::prio_one_thread::strictly_ordered::make_dispatcher(env).binder(), [&]( so_5::coop_t & coop ) { so_5::prio::for_each_priority( [&]( so_5::priority_t prio ) { // Creation of new agent with next priority. coop.make_agent< my_prio_agent >( prio, ... ); } ); } ); \endcode */ template< typename Lambda > void for_each_priority( Lambda l ) { using ut = std::underlying_type< priority_t >::type; const auto min = static_cast< ut >( priority_t::p_min ); const auto max = static_cast< ut >( priority_t::p_max ); for( auto i = min; i <= max; ++i ) l( static_cast< priority_t >( i ) ); } } /* namespace prio */ } /* namespace so_5 */
[ "eao197@gmail.com" ]
eao197@gmail.com
402c4e7fb832cf951c3ba920b782faf23065cc92
9f9cbb082eac69bac1e7a44c944e40fc2eb7901d
/lesson-01/t-simple-tests/floor_sqrt.cpp
1535d0b924c1c874ab92466f68f0ac011ba84fbe
[]
no_license
dutow/elte-cpp-examples
af5f666aff9dbb164d4eee6da03a5b1bbdc78074
82cd4789a8c192aa2a80e2f24a16b2ca7aafec44
refs/heads/master
2021-01-10T12:23:12.311051
2016-04-21T17:41:55
2016-04-21T17:41:55
51,207,144
0
1
null
null
null
null
UTF-8
C++
false
false
681
cpp
#include "gtest/gtest.h" /** * Visszaadja a parameterkent megadott szam gyokenel kisebb vagy egyenlo legnagyobb egesz szamot */ unsigned int floor_sqrt(unsigned int number) { switch(number) { case 0: return 0; case 1: case 2: case 3: return 1; default: { return 2; // TODO } } } TEST(floor_sqrt, zero_is_zero) { EXPECT_EQ(0, floor_sqrt(0)); } TEST(floor_sqrt, one_is_one) { EXPECT_EQ(1, floor_sqrt(1)); } TEST(floor_sqrt, with_16) { EXPECT_EQ(4, floor_sqrt(16)); } TEST(floor_sqrt, with_26) { EXPECT_EQ(5, floor_sqrt(26)); } TEST(floor_sqrt, with_35) { EXPECT_EQ(5, floor_sqrt(35)); }
[ "zsolt.parragi@cancellar.hu" ]
zsolt.parragi@cancellar.hu
5a229c94ad8e2b3da6ccca7d86cd1db715ce713d
600df3590cce1fe49b9a96e9ca5b5242884a2a70
/blimp/net/blimp_message_pump.h
199ca51cd4346ca9f38ebae40b0c6cd6543c31db
[ "BSD-3-Clause" ]
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
2,517
h
// Copyright 2015 The Chromium 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 BLIMP_NET_BLIMP_MESSAGE_PUMP_H_ #define BLIMP_NET_BLIMP_MESSAGE_PUMP_H_ #include <memory> #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "blimp/net/blimp_net_export.h" #include "net/base/completion_callback.h" namespace net { class GrowableIOBuffer; } namespace blimp { class BlimpMessageProcessor; class ConnectionErrorObserver; class PacketReader; // Reads and deserializes incoming packets from |reader_|, and forwards parsed // BlimpMessages to |processor_|. When |processor_| is ready to take the next // message, the BlimpMessagePump reads the next packet. class BLIMP_NET_EXPORT BlimpMessagePump { public: // Caller ensures that |reader| outlives this object. explicit BlimpMessagePump(PacketReader* reader); ~BlimpMessagePump(); // Sets the processor which will take BlimpMessages. // Caller retains the ownership of |processor|. // The processor can be unset by passing a null pointer when no reads are // inflight, ie. after |processor_|->ProcessMessage() is called, but before // ProcessMessage() invokes its completion callback. void SetMessageProcessor(BlimpMessageProcessor* processor); void set_error_observer(ConnectionErrorObserver* observer) { error_observer_ = observer; } private: // Read next packet from |reader_|. void ReadNextPacket(); // Callback when next packet is ready in |buffer_|. void OnReadPacketComplete(int result); // Callback when |processor_| finishes processing a BlimpMessage. // Any values other than net::OK indicate that |processor_| has encountered an // error that should be handled. Currently all errors will cause the // connection to be dropped; in the future we will need to add more // sophisticated error handling logic here. // TODO(kmarshall): Improve error handling. void OnProcessMessageComplete(int result); PacketReader* reader_; ConnectionErrorObserver* error_observer_ = nullptr; BlimpMessageProcessor* processor_ = nullptr; scoped_refptr<net::GrowableIOBuffer> buffer_; bool read_inflight_ = false; // Used to abandon ProcessMessage completion callbacks if |this| is deleted. base::WeakPtrFactory<BlimpMessagePump> weak_factory_; DISALLOW_COPY_AND_ASSIGN(BlimpMessagePump); }; } // namespace blimp #endif // BLIMP_NET_BLIMP_MESSAGE_PUMP_H_
[ "enrico.weigelt@gr13.net" ]
enrico.weigelt@gr13.net
e76adf6bdc2517e2b7caf74f7a53f19d75c25627
8b7c22490f559648137e406f1264f1427275df5e
/src/engine/material.h
22a9929e4af78b2406c7d730ff31f3755c4b8918
[]
no_license
stbuehler/sea-crossing
4fe28d39e057f3b3051a00f1f75ded9c470d1ce9
be1f7ea75ed3d78c764c9538851233edeeaa1ec4
refs/heads/master
2021-01-16T21:26:03.944357
2013-09-03T15:40:39
2013-09-03T15:40:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
902
h
#ifndef material_h #define material_h #include "GLSLProgram.h" #include "texture.h" struct MaterialInfo { MaterialInfo() : id(0) {} int id; char* diff_path; char* spec_path; char* roughness_path; char* normal_path; }; class Material { private: int id; GLSLProgram *shaderProgram; Texture *diffuseMap; Texture *specularMap; Texture *roughnessMap; Texture *normalMap; public: ~Material(); Material(int,GLSLProgram*,Texture*,Texture*,Texture*,Texture*); // for later use, when some kind of editor allows to change material properties at runtime bool update(int,GLSLProgram*,Texture*,Texture*,Texture*,Texture*); void use(); int getId() {return id;} GLSLProgram* getShaderProgram() {return shaderProgram;} const Texture* getDiffuseMap() {return diffuseMap;} const Texture* getSpecularMap() {return specularMap;} const Texture* getNormalMap() {return normalMap;} }; #endif
[ "michael.becher.1990@googlemail.com" ]
michael.becher.1990@googlemail.com
7792860525bff845f1d1e0bdf3cbae543d2c09f4
d64d9c52f78d2b332791217a9e91bab7e8fa2599
/tests/unit/util/tagged.cpp
6058ff2c971f2210ac56ecf17184aa4382b5a1c8
[ "LicenseRef-scancode-free-unknown", "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
Jakub-Golinowski/hpx
a81c7cdbd8e1daf530d93d2dbafb69d899229efa
7c762ea235d5d7cde0d2686c84902016c33f2bec
refs/heads/master
2021-04-26T23:19:08.776815
2018-05-04T12:36:48
2018-05-04T12:36:48
123,970,854
1
0
BSL-1.0
2018-03-05T19:53:11
2018-03-05T19:53:11
null
UTF-8
C++
false
false
4,110
cpp
// Copyright (c) 2015 Hartmut Kaiser // // 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 <hpx/hpx_init.hpp> #include <hpx/util/tagged_pair.hpp> #include <hpx/util/tagged_tuple.hpp> #include <hpx/util/lightweight_test.hpp> #include <utility> #include <type_traits> struct A { A(int val = 0) : value_(val) {} int value_; }; struct B { B(int val = 0) : value_(val) {} int value_; }; struct C { C(int val = 0) : value_(val) {} int value_; }; HPX_DEFINE_TAG_SPECIFIER(tag1) // defines tag::tag1 HPX_DEFINE_TAG_SPECIFIER(tag2) // defines tag::tag2 HPX_DEFINE_TAG_SPECIFIER(tag3) // defines tag::tag3 void tagged_pair_test() { typedef hpx::util::tagged_pair<tag::tag1(A), tag::tag2(B)> pair; static_assert(std::is_same<typename pair::first_type, A>::value, ""); static_assert(std::is_same<typename pair::second_type, B>::value, ""); { pair p; static_assert(std::is_same<decltype(p.first), A>::value, ""); static_assert(std::is_same<decltype(p.second), B>::value, ""); static_assert(std::is_same< typename hpx::util::decay<decltype(p.tag1())>::type, A >::value, ""); static_assert(std::is_same< typename hpx::util::decay<decltype(p.tag2())>::type, B >::value, ""); } { pair p(42, 43); HPX_TEST_EQ(p.tag1().value_, 42); HPX_TEST_EQ(p.tag2().value_, 43); } { pair p(42, 43); HPX_TEST_EQ(hpx::util::get<0>(p).value_, 42); HPX_TEST_EQ(hpx::util::get<1>(p).value_, 43); } { pair p = hpx::util::make_tagged_pair<tag::tag1, tag::tag2>(42, 43); HPX_TEST_EQ(p.tag1().value_, 42); HPX_TEST_EQ(p.tag2().value_, 43); } { pair p = hpx::util::make_tagged_pair<tag::tag1, tag::tag2>( std::make_pair(42, 43)); HPX_TEST_EQ(p.tag1().value_, 42); HPX_TEST_EQ(p.tag2().value_, 43); } } void tagged_tuple_test() { typedef hpx::util::tagged_tuple<tag::tag1(A), tag::tag2(B), tag::tag3(C)> tuple; { tuple t; static_assert(std::is_same< typename hpx::util::tuple_element<0, tuple>::type, A >::value, ""); static_assert(std::is_same< typename hpx::util::tuple_element<1, tuple>::type, B >::value, ""); static_assert(std::is_same< typename hpx::util::tuple_element<2, tuple>::type, C >::value, ""); static_assert(std::is_same< typename hpx::util::decay<decltype(t.tag1())>::type, A >::value, ""); static_assert(std::is_same< typename hpx::util::decay<decltype(t.tag2())>::type, B >::value, ""); static_assert(std::is_same< typename hpx::util::decay<decltype(t.tag3())>::type, C >::value, ""); } { tuple t(42, 43, 44); HPX_TEST_EQ(t.tag1().value_, 42); HPX_TEST_EQ(t.tag2().value_, 43); HPX_TEST_EQ(t.tag3().value_, 44); } { tuple t(42, 43, 44); HPX_TEST_EQ(hpx::util::get<0>(t).value_, 42); HPX_TEST_EQ(hpx::util::get<1>(t).value_, 43); HPX_TEST_EQ(hpx::util::get<2>(t).value_, 44); } { using hpx::util::make_tagged_tuple; tuple t = make_tagged_tuple<tag::tag1, tag::tag2, tag::tag3>(42, 43, 44); HPX_TEST_EQ(t.tag1().value_, 42); HPX_TEST_EQ(t.tag2().value_, 43); HPX_TEST_EQ(t.tag3().value_, 44); } { using hpx::util::make_tagged_tuple; tuple t = make_tagged_tuple<tag::tag1, tag::tag2, tag::tag3>( hpx::util::make_tuple(42, 43, 44)); HPX_TEST_EQ(t.tag1().value_, 42); HPX_TEST_EQ(t.tag2().value_, 43); HPX_TEST_EQ(t.tag3().value_, 44); } } int main(int argc, char* argv[]) { tagged_pair_test(); tagged_tuple_test(); return hpx::util::report_errors(); }
[ "hartmut.kaiser@gmail.com" ]
hartmut.kaiser@gmail.com
66186f9e9ecc3eafc9267745758ee2d7d4699b30
0af64088bc45300c8eeb3b2fa47d4613a6e8a5be
/deps/nsparse/include/detail/util.h
1c2c63c67afcfeb97a374f87d8e83747d0a6e205
[ "MIT" ]
permissive
Krekep/cuBool
035fe0efd25295f8c434d90bdbe80a4291d8a9db
e59f8e0cb4adedae8e7ac449e05bef3c1815a7da
refs/heads/master
2023-04-15T10:43:26.899021
2021-04-18T08:14:24
2021-04-18T08:14:24
320,327,278
0
0
MIT
2021-04-05T09:55:11
2020-12-10T16:24:14
C++
UTF-8
C++
false
false
1,562
h
#pragma once #include <cmath> #include <ostream> #include <thrust/device_vector.h> namespace nsparse { namespace util { template <typename T> struct bucket_info_t { T row_id; T a_row_begin; T b_row_begin; T a_row_end; T b_row_end; }; template <typename T> T div(T m, T n) { return (m + n - 1) / n; } template <typename T> __device__ T nearest_pow_2(T m) { T res = 1; while (res < m) { res *= 2; } return res; } template <typename T> __device__ T warpReduceSum(T val) { for (T offset = warpSize / 2; offset > 0; offset /= 2) { val += __shfl_down_sync(0xffffffff, val, offset); } return val; } namespace detail { template <typename F> __global__ void kernel_call_impl(F functor) { functor(); } } // namespace detail template <typename G, typename B, typename F> void kernel_call(G grid, B block, F&& functor) { detail::kernel_call_impl<<<grid, block>>>(std::forward<decltype(functor)>(functor)); } template <typename T> void resize_and_fill_zeros(thrust::device_vector<T>& vec, size_t size) { vec.resize(size); cudaMemsetAsync(thrust::raw_pointer_cast(vec.data()), 0, sizeof(T) * size); } template <typename T> void fill_zeros(thrust::device_vector<T>& vec, size_t size) { cudaMemsetAsync(thrust::raw_pointer_cast(vec.data()), 0, sizeof(T) * size); } template <typename T> std::ostream& operator<<(std::ostream& os, const thrust::device_vector<T>& vec) { thrust::host_vector<T> h_vec = vec; for (auto item : h_vec) { os << item << " "; } return os; } } // namespace util } // namespace nsparse
[ "egororachyov5@gmail.com" ]
egororachyov5@gmail.com
c3e9b59736e167254d2c6e7b530882fb246648ef
1a29e46b23417e5949843845a93e5da383686190
/Lab 6/lab6.cpp
c970c94e85daeaef694302773d74322a1583f5e9
[]
no_license
JerryCyHu/Data-Structure
b81d9b3e703e4d2ac1d076e7fae5f1b5f213da9b
98c3e79e8ed67e0c8338964e6ff075185cdb207f
refs/heads/master
2022-03-21T21:52:09.515072
2019-11-27T22:18:54
2019-11-27T22:18:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,448
cpp
#include <iostream> #include <cmath> #include <list> #include "dslist.h" int main() { // ======================================= // CHECKPOINT 1 // create a list of the sqrt of the first 10 integers dslist<double> a; for (int i = 0; i < 10; ++i) a.push_back(sqrt(i)); // print out details of the list assert (a.size() == 10); assert (a.front() == 0); assert (a.back() == 3); dslist<double>::iterator itr; std::cout << "Elements = "; for (itr = a.begin(); itr != a.end(); ++itr) std::cout << " " << *itr; std::cout << std::endl; // clear out the list a.clear(); assert (a.size() == 0); // simple tests of push_front, pop_front, and pop_back a.push_front(5); a.push_back(7); a.push_front(3); a.push_back(9); assert (a.size() == 4); assert (*(a.begin()) == 3); assert (*(++a.begin()) == 5); assert (*(++(++a.begin())) == 7); assert (*(++(++(++a.begin()))) == 9); std::cout << "Elements = "; for (itr = a.begin(); itr != a.end(); ++itr) std::cout << " " << *itr; std::cout << std::endl; a.pop_back(); a.pop_front(); assert (a.size() == 2); assert (*(a.begin()) == 5); assert (*(++a.begin()) == 7); std::cout << "Elements = "; for (itr = a.begin(); itr != a.end(); ++itr) std::cout << " " << *itr; std::cout << std::endl; a.pop_back(); a.pop_front(); assert (a.size() == 0); assert (a.begin() == a.end()); return 0; }
[ "2540887746@qq.com" ]
2540887746@qq.com
c38e0863edf53e9e34484467aa57f217e85c934a
d2d6aae454fd2042c39127e65fce4362aba67d97
/build/iOS/Release/include/Fuse.Animations.SeekResult.h
d76c4a884ac893f5448fa09c00df1471320ffeee
[]
no_license
Medbeji/Eventy
de88386ff9826b411b243d7719b22ff5493f18f5
521261bca5b00ba879e14a2992e6980b225c50d4
refs/heads/master
2021-01-23T00:34:16.273411
2017-09-24T21:16:34
2017-09-24T21:16:34
92,812,809
2
0
null
null
null
null
UTF-8
C++
false
false
356
h
// This file was generated based on '../../AppData/Local/Fusetools/Packages/Fuse.Animations/0.46.1/$.uno'. // WARNING: Changes might be lost if you edit this file directly. #pragma once #include <Uno.Int.h> namespace g{ namespace Fuse{ namespace Animations{ // internal enum SeekResult :117 uEnumType* SeekResult_typeof(); }}} // ::g::Fuse::Animations
[ "medbeji@MacBook-Pro-de-MedBeji.local" ]
medbeji@MacBook-Pro-de-MedBeji.local
36aca25edd12d09cf1dc301e3122b0060872d010
5cb7cb560fc01c4a9a0cae53646d5b38facbba1c
/QNShortVideo-With-TuTu-iOS/PLShortVideoKit-master/Example/PLShortVideoKitDemo/EasyARSDK/easyar.framework/Headers/frame.hxx
d531ff16c92cd2e1b3caf55093062a3119b009d1
[ "MIT", "Apache-2.0" ]
permissive
pili-engineering/QNShortVideo-TuTu
3ad71a9be1494934c20509e03530ed2c904cf7b0
2a31b9d03cc000b36e6fb3e4d00090521fb7cd37
refs/heads/master
2021-07-18T17:03:55.316867
2019-05-29T10:52:14
2019-05-29T10:52:14
184,221,651
1
8
MIT
2020-06-23T04:16:30
2019-04-30T08:21:02
Objective-C
UTF-8
C++
false
false
9,268
hxx
//============================================================================================================================= // // EasyAR 2.2.0 // Copyright (c) 2015-2017 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved. // EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China // and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd. // //============================================================================================================================= #ifndef __EASYAR_FRAME_HXX__ #define __EASYAR_FRAME_HXX__ #include "easyar/types.hxx" #include "easyar/drawable.hxx" namespace easyar { class Frame : public Drawable { protected: easyar_Frame * cdata_ ; void init_cdata(easyar_Frame * cdata); virtual Frame & operator=(const Frame & data) { return *this; } //deleted public: Frame(easyar_Frame * cdata); virtual ~Frame(); Frame(const Frame & data); const easyar_Frame * get_cdata() const; easyar_Frame * get_cdata(); Frame(); Vec2I size(); double timestamp(); int index(); void images(/* OUT */ ListOfPointerOfImage * * Return); void targetInstances(/* OUT */ ListOfPointerOfTargetInstance * * Return); void text(/* OUT */ String * * Return); static void tryCastFromDrawable(Drawable * v, /* OUT */ Frame * * Return); }; #ifndef __EASYAR_LISTOFPOINTEROFIMAGE__ #define __EASYAR_LISTOFPOINTEROFIMAGE__ class ListOfPointerOfImage { private: easyar_ListOfPointerOfImage * cdata_; virtual ListOfPointerOfImage & operator=(const ListOfPointerOfImage & data) { return *this; } //deleted public: ListOfPointerOfImage(easyar_ListOfPointerOfImage * cdata); virtual ~ListOfPointerOfImage(); ListOfPointerOfImage(const ListOfPointerOfImage & data); const easyar_ListOfPointerOfImage * get_cdata() const; easyar_ListOfPointerOfImage * get_cdata(); ListOfPointerOfImage(easyar_Image * * begin, easyar_Image * * end); int size() const; Image * at(int index) const; }; #endif #ifndef __EASYAR_LISTOFPOINTEROFTARGETINSTANCE__ #define __EASYAR_LISTOFPOINTEROFTARGETINSTANCE__ class ListOfPointerOfTargetInstance { private: easyar_ListOfPointerOfTargetInstance * cdata_; virtual ListOfPointerOfTargetInstance & operator=(const ListOfPointerOfTargetInstance & data) { return *this; } //deleted public: ListOfPointerOfTargetInstance(easyar_ListOfPointerOfTargetInstance * cdata); virtual ~ListOfPointerOfTargetInstance(); ListOfPointerOfTargetInstance(const ListOfPointerOfTargetInstance & data); const easyar_ListOfPointerOfTargetInstance * get_cdata() const; easyar_ListOfPointerOfTargetInstance * get_cdata(); ListOfPointerOfTargetInstance(easyar_TargetInstance * * begin, easyar_TargetInstance * * end); int size() const; TargetInstance * at(int index) const; }; #endif } #endif #ifndef __IMPLEMENTATION_EASYAR_FRAME_HXX__ #define __IMPLEMENTATION_EASYAR_FRAME_HXX__ #include "easyar/frame.h" #include "easyar/drawable.hxx" #include "easyar/vector.hxx" #include "easyar/image.hxx" #include "easyar/target.hxx" namespace easyar { inline Frame::Frame(easyar_Frame * cdata) : Drawable(static_cast<easyar_Drawable *>(NULL)), cdata_(NULL) { init_cdata(cdata); } inline Frame::~Frame() { if (cdata_) { easyar_Frame__dtor(cdata_); cdata_ = NULL; } } inline Frame::Frame(const Frame & data) : Drawable(static_cast<easyar_Drawable *>(NULL)), cdata_(NULL) { easyar_Frame * cdata = NULL; easyar_Frame__retain(data.cdata_, &cdata); init_cdata(cdata); } inline const easyar_Frame * Frame::get_cdata() const { return cdata_; } inline easyar_Frame * Frame::get_cdata() { return cdata_; } inline void Frame::init_cdata(easyar_Frame * cdata) { cdata_ = cdata; { easyar_Drawable * cdata_inner = NULL; easyar_castFrameToDrawable(cdata, &cdata_inner); Drawable::init_cdata(cdata_inner); } } inline Frame::Frame() : Drawable(static_cast<easyar_Drawable *>(NULL)), cdata_(NULL) { easyar_Frame * _return_value_ = NULL; easyar_Frame__ctor(&_return_value_); init_cdata(_return_value_); } inline Vec2I Frame::size() { if (cdata_ == NULL) { return Vec2I(); } easyar_Vec2I _return_value_ = easyar_Frame_size(cdata_); return Vec2I(_return_value_.data[0], _return_value_.data[1]); } inline double Frame::timestamp() { if (cdata_ == NULL) { return double(); } double _return_value_ = easyar_Frame_timestamp(cdata_); return _return_value_; } inline int Frame::index() { if (cdata_ == NULL) { return int(); } int _return_value_ = easyar_Frame_index(cdata_); return _return_value_; } inline void Frame::images(/* OUT */ ListOfPointerOfImage * * Return) { if (cdata_ == NULL) { *Return = NULL; return; } easyar_ListOfPointerOfImage * _return_value_ = NULL; easyar_Frame_images(cdata_, &_return_value_); *Return = new ListOfPointerOfImage(_return_value_); } inline void Frame::targetInstances(/* OUT */ ListOfPointerOfTargetInstance * * Return) { if (cdata_ == NULL) { *Return = NULL; return; } easyar_ListOfPointerOfTargetInstance * _return_value_ = NULL; easyar_Frame_targetInstances(cdata_, &_return_value_); *Return = new ListOfPointerOfTargetInstance(_return_value_); } inline void Frame::text(/* OUT */ String * * Return) { if (cdata_ == NULL) { *Return = NULL; return; } easyar_String * _return_value_ = NULL; easyar_Frame_text(cdata_, &_return_value_); *Return = (_return_value_) == NULL ? NULL : new String(_return_value_); } inline void Frame::tryCastFromDrawable(Drawable * v, /* OUT */ Frame * * Return) { if (v == NULL) { *Return = NULL; return; } easyar_Frame * cdata = NULL; easyar_tryCastDrawableToFrame(v->get_cdata(), &cdata); if (cdata == NULL) { *Return = NULL; return; } *Return = new Frame(cdata); } #ifndef __IMPLEMENTATION_EASYAR_LISTOFPOINTEROFIMAGE__ #define __IMPLEMENTATION_EASYAR_LISTOFPOINTEROFIMAGE__ inline ListOfPointerOfImage::ListOfPointerOfImage(easyar_ListOfPointerOfImage * cdata) : cdata_(cdata) { } inline ListOfPointerOfImage::~ListOfPointerOfImage() { if (cdata_) { easyar_ListOfPointerOfImage__dtor(cdata_); cdata_ = NULL; } } inline ListOfPointerOfImage::ListOfPointerOfImage(const ListOfPointerOfImage & data) : cdata_(static_cast<easyar_ListOfPointerOfImage *>(NULL)) { easyar_ListOfPointerOfImage_copy(data.cdata_, &cdata_); } inline const easyar_ListOfPointerOfImage * ListOfPointerOfImage::get_cdata() const { return cdata_; } inline easyar_ListOfPointerOfImage * ListOfPointerOfImage::get_cdata() { return cdata_; } inline ListOfPointerOfImage::ListOfPointerOfImage(easyar_Image * * begin, easyar_Image * * end) : cdata_(static_cast<easyar_ListOfPointerOfImage *>(NULL)) { easyar_ListOfPointerOfImage__ctor(begin, end, &cdata_); } inline int ListOfPointerOfImage::size() const { return easyar_ListOfPointerOfImage_size(cdata_); } inline Image * ListOfPointerOfImage::at(int index) const { easyar_Image * _return_value_ = easyar_ListOfPointerOfImage_at(cdata_, index); easyar_Image__retain(_return_value_, &_return_value_); return (_return_value_ == NULL ? NULL : new Image(_return_value_)); } #endif #ifndef __IMPLEMENTATION_EASYAR_LISTOFPOINTEROFTARGETINSTANCE__ #define __IMPLEMENTATION_EASYAR_LISTOFPOINTEROFTARGETINSTANCE__ inline ListOfPointerOfTargetInstance::ListOfPointerOfTargetInstance(easyar_ListOfPointerOfTargetInstance * cdata) : cdata_(cdata) { } inline ListOfPointerOfTargetInstance::~ListOfPointerOfTargetInstance() { if (cdata_) { easyar_ListOfPointerOfTargetInstance__dtor(cdata_); cdata_ = NULL; } } inline ListOfPointerOfTargetInstance::ListOfPointerOfTargetInstance(const ListOfPointerOfTargetInstance & data) : cdata_(static_cast<easyar_ListOfPointerOfTargetInstance *>(NULL)) { easyar_ListOfPointerOfTargetInstance_copy(data.cdata_, &cdata_); } inline const easyar_ListOfPointerOfTargetInstance * ListOfPointerOfTargetInstance::get_cdata() const { return cdata_; } inline easyar_ListOfPointerOfTargetInstance * ListOfPointerOfTargetInstance::get_cdata() { return cdata_; } inline ListOfPointerOfTargetInstance::ListOfPointerOfTargetInstance(easyar_TargetInstance * * begin, easyar_TargetInstance * * end) : cdata_(static_cast<easyar_ListOfPointerOfTargetInstance *>(NULL)) { easyar_ListOfPointerOfTargetInstance__ctor(begin, end, &cdata_); } inline int ListOfPointerOfTargetInstance::size() const { return easyar_ListOfPointerOfTargetInstance_size(cdata_); } inline TargetInstance * ListOfPointerOfTargetInstance::at(int index) const { easyar_TargetInstance * _return_value_ = easyar_ListOfPointerOfTargetInstance_at(cdata_, index); easyar_TargetInstance__retain(_return_value_, &_return_value_); return (_return_value_ == NULL ? NULL : new TargetInstance(_return_value_)); } #endif } #endif
[ "hxiongan@gmail.com" ]
hxiongan@gmail.com
0e3bcd06b798f2955b7a1fdc36b396cae2a2fe2b
004b288aeabe99ddfc212df8232ca3cd527a341b
/lib/ah_chunks_to_symbols_impl.h
f238cdc4793e7bb6c002832878cda567cf5ad3d6
[]
no_license
zitouni/gr-ieee80211ah
1b604b5b86113d2095431027e9aa271b144d6d62
5be0061d33c724a14521f29949e397d7acd42a02
refs/heads/master
2021-01-19T05:29:12.583533
2016-08-22T13:19:48
2016-08-22T13:19:48
64,380,409
1
1
null
null
null
null
UTF-8
C++
false
false
1,841
h
/* -*- c++ -*- */ /* * Copyright 2016 <+YOU OR YOUR COMPANY+>. * * This 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 3, or (at your option) * any later version. * * This software 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 software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #ifndef INCLUDED_IEEE80211AH_AH_CHUNKS_TO_SYMBOLS_IMPL_H #define INCLUDED_IEEE80211AH_AH_CHUNKS_TO_SYMBOLS_IMPL_H #include <ieee80211ah/ah_chunks_to_symbols.h> namespace gr { namespace ieee80211ah { class ah_chunks_to_symbols_impl : public ah_chunks_to_symbols { private: // Nothing to declare in this block. public: ah_chunks_to_symbols_impl(); ~ah_chunks_to_symbols_impl(); // Where all the action really happens void forecast (int noutput_items, gr_vector_int &ninput_items_required); int work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); protected: static const gr_complex BPSK[2]; static const gr_complex QPSK[4]; static const gr_complex QAM16[16]; static const gr_complex QAM64[64]; static const gr_complex QAM256[256]; }; } // namespace ieee80211ah } // namespace gr #endif /* INCLUDED_IEEE80211AH_AH_CHUNKS_TO_SYMBOLS_IMPL_H */
[ "rzitouni@gmail.com" ]
rzitouni@gmail.com
1e6a0cdd0dd82e1ced27de099e9ef8cd82390d3c
23742c92955059c475ed00d83773806ad99dd565
/src/main.h
acb7919dcc103b3cba078449544c2f6d596e43bb
[ "MIT" ]
permissive
zygisau/Blockchain_project
a2c1a7709f420d71d6e1788a7e5e30ddbf7227ff
b50ee2fb9408a1064256edbc441e4109f356dcb5
refs/heads/master
2020-08-06T20:19:26.043677
2019-11-21T20:56:15
2019-11-21T20:56:15
213,140,712
0
0
null
null
null
null
UTF-8
C++
false
false
759
h
// // Created by zygisau on 2019-10-06. // #ifndef BLOCKCHAIN_MAIN_H #define BLOCKCHAIN_MAIN_H #include <iostream> #include <string> #include <vector> #include <random> #include <chrono> #include <fstream> #include <memory> #include <sstream> #include <list> #include <algorithm> #include <iterator> #include <functional> #include <unordered_map> using std::string; using std::vector; using std::cout; using std::endl; using std::ifstream; using std::unique_ptr; using std::shared_ptr; using std::weak_ptr; using std::list; using std::unordered_map; using std::make_pair; #include "../vendors/SHA-256/sha256.h" const auto HASH_FUNC = sha256; //#include "../vendors/ZA-256/ZA256.h" //const auto HASH_FUNC = zygisau::ZA256::hash; #endif //BLOCKCHAIN_MAIN_H
[ "zygimantasaugunas@gmail.com" ]
zygimantasaugunas@gmail.com
64390c0eb9bc34a4d61d84c727704daa81bc49c5
7b4d5523b10ce2e9396308bcb8072b267ca32f38
/src/portable_archive/slimarchive.hpp
65d8cc70259a9ced855e945c8b0d6972042adfdd
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "LicenseRef-scancode-public-domain", "BSL-1.0" ]
permissive
tstenner/liblsl
cd3cc54d9068d5cfb8fac5aab4d9c39e8d432ad0
1dc3e2dbdff3b36890beda1edbff5bc36ee0f4b6
refs/heads/master
2023-08-17T07:15:45.899442
2023-08-15T11:28:53
2023-08-15T11:28:53
123,417,459
2
1
MIT
2020-01-16T08:11:10
2018-03-01T10:07:46
C++
UTF-8
C++
false
false
6,021
hpp
#pragma once /// Small shim implementing the needed Boost serialization classes for liblsl #include <cstdint> #include <stdexcept> #include <streambuf> #include <type_traits> /// dummy #defines to prevent portable archive from loading additional boost archive parts #define NO_EXPLICIT_TEMPLATE_INSTANTIATION #define BOOST_ARCHIVE_SERIALIZER_INCLUDED #define BOOST_SERIALIZATION_REGISTER_ARCHIVE(typename) // forward declaration namespace lsl { class sample; } /// Maps LSL types to an index without needing full RTTI template <typename T> struct lsl_type_index {}; template <> struct lsl_type_index<lsl::sample> { static const int idx = 0; }; /// two classes used in unit tests template <> struct lsl_type_index<struct Testclass> { static const int idx = 1; }; template <> struct lsl_type_index<struct Testclass2> { static const int idx = 2; }; /// keep track of classes already seen once, needed for a field in Boost.Archive class serialized_class_tracker { bool seen_[3]{false}; public: /// Return true /if an instance of this class has already been (de)serialized before template <typename T> inline bool already_seen(const T &) { if (seen_[lsl_type_index<T>::idx]) return true; seen_[lsl_type_index<T>::idx] = true; return false; } }; namespace lslboost { #ifndef BOOST_INTEGER_HPP /// Maps a type size in bits to the corresponding uintXY_t type template <int Size> struct uint_t {}; template <> struct uint_t<8> { using least = uint8_t; }; template <> struct uint_t<16> { using least = uint16_t; }; template <> struct uint_t<32> { using least = uint32_t; }; template <> struct uint_t<64> { using least = uint64_t; }; #endif namespace archive { using library_version_type = uint8_t; inline library_version_type BOOST_ARCHIVE_VERSION() { return 17; } enum flags { no_header = 1, no_codecvt = 2 }; struct archive_exception : std::exception { archive_exception(int) {} enum errors { invalid_signature, unsupported_version, other_exception }; }; /// Common class to store flags class flagstore { int flags_; public: flagstore(int flags) : flags_(flags) {} int get_flags() const { return flags_; } }; template <typename Archive> struct basic_binary_oarchive : public flagstore { basic_binary_oarchive(int flags_) : flagstore(flags_) {} }; template <typename Archive> struct basic_binary_iarchive : public flagstore { basic_binary_iarchive(int flags_) : flagstore(flags_) {} }; /// Helper base class for calling methods of an descendant class, i.e. Archive::fn, not this->fn template <typename Archive> class archive_upcaster { public: archive_upcaster() { static_assert( std::is_base_of<typename std::remove_reference<decltype(*this)>::type, Archive>::value, "Archive must inherit from basic_binary_i/oprimitive"); } /** Return a reference to the actual archive implementation instead of the base class * * This is needed for most operations to call Archive::fn, not basic_binary_primitive::fn */ inline Archive &archive_impl() { return *((Archive *)this); } }; /* template<typename Archive> class basic_binary_primitive { std::streambuf &sb; }*/ template <typename Archive, typename CharT, typename OSTraits> class basic_binary_oprimitive : private serialized_class_tracker, private archive_upcaster<Archive> { std::streambuf &sb; /// calls Archive::serialize instead of this->serialize() template <typename T> Archive &delegate_save(const T &t) { this->archive_impl().save(t); return this->archive_impl(); } public: basic_binary_oprimitive(std::streambuf &sbuf, int) : archive_upcaster<Archive>(), sb(sbuf) {} template <typename T> void save_binary(const T *data, std::size_t bytes) { sb.sputn(reinterpret_cast<const char *>(data), bytes); } template <typename T> void save(const T &t) { save_binary<T>(&t, sizeof(T)); } void save(const std::string &s) { delegate_save(s.size()); save_binary(s.data(), s.size()); } template <typename T> std::enable_if_t<std::is_arithmetic<T>::value, Archive &> operator<<(const T &t) { return delegate_save(t); } Archive &operator<<(const std::string &t) { return delegate_save(t); } /// calls the `serialize()` member function if it exists template <typename T, void (T::*fn)(Archive &, uint32_t) const = &T::serialize> Archive &operator<<(const T &t) { if (!this->already_seen(t)) save<uint16_t>(0); t.serialize(this->archive_impl(), 0); return this->archive_impl(); } template <typename T> Archive &operator&(const T &t) { return this->archive_impl() << t; } }; template <class Archive, typename CharT, typename OSTraits> class basic_binary_iprimitive : private serialized_class_tracker, private archive_upcaster<Archive> { std::streambuf &sb; template <typename T> Archive &delegate_load(T &t) { this->archive_impl().load(t); return this->archive_impl(); } public: basic_binary_iprimitive(std::streambuf &sbuf, int) : archive_upcaster<Archive>(), sb(sbuf) {} /// Load raw binary data from the stream template <typename T> void load_binary(T *data, std::size_t bytes) { sb.sgetn(reinterpret_cast<char *>(data), bytes); } template <typename T> void load(T &t) { load_binary<T>(&t, sizeof(T)); } void load(std::string &s) { std::size_t size; delegate_load(size); char *data = new char[size]; load_binary(data, size); s.assign(data, size); delete[] data; } Archive &operator>>(std::string &t) { return delegate_load(t); } template <typename T> std::enable_if_t<std::is_arithmetic<T>::value, Archive &> operator>>(T &t) { return delegate_load(t); } /// calls the `serialize()` member function if it exists template <typename T, void (T::*fn)(Archive &, uint32_t) = &T::serialize> Archive &operator>>(T &t) { if (!this->already_seen(t)) { uint16_t dummy; load(dummy); } t.serialize(this->archive_impl(), 0); return this->archive_impl(); } template <typename T> Archive &operator&(T &t) { return this->archive_impl() >> t; } void set_library_version(int) {} }; } // namespace archive } // namespace lslboost
[ "ttstenner@gmail.com" ]
ttstenner@gmail.com
5afabe669a998707ef7cc964305dc901f9b150bc
4dd5d885768d911484954e084592efe369724637
/Source/Core/DX_12/DX_12RenderDevice.hpp
404e03f93a2233237066c9a249cef6de7dac8101
[ "MIT" ]
permissive
glowing-chemist/Bell
d160f71b905da0629fb67378352ad1a0fd014057
610078a36c831f11c923f34f3e72be0009fcf6a6
refs/heads/master
2022-01-16T22:59:59.179596
2021-12-23T11:28:16
2021-12-23T11:28:16
160,046,575
18
4
null
null
null
null
UTF-8
C++
false
false
3,501
hpp
#ifndef DX_12_RENDER_DEVICE_HPP #define DX_12_RENDER_DEVICE_HPP #include "Core/RenderDevice.hpp" #include "D3D12MemAlloc.h" #include <d3d12.h> #include <dxgi1_4.h> class DX_12RenderDevice : public RenderDevice { public: DX_12RenderDevice(ID3D12Device*, IDXGIAdapter* adapter, IDXGIFactory* deviceFactory, GLFWwindow*); ~DX_12RenderDevice(); virtual CommandContextBase* getCommandContext(const uint32_t index, const QueueType) override; virtual PipelineHandle compileGraphicsPipeline(const GraphicsTask& task, const RenderGraph& graph, const Shader& vertexShader, const Shader* geometryShader, const Shader* tessControl, const Shader* tessEval, const Shader& fragmentShader) override; virtual PipelineHandle compileComputePipeline(const ComputeTask& task, const RenderGraph& graph, const Shader& compuetShader) override; virtual void startFrame() override; virtual void endFrame() override; virtual void destroyImage(ImageBase& image) override; virtual void destroyImageView(ImageViewBase& view) override; virtual void destroyBuffer(BufferBase& buffer) override; virtual void destroyShaderResourceSet(const ShaderResourceSetBase& set) override; virtual void setDebugName(const std::string&, const uint64_t, const uint64_t objectType) override; virtual void flushWait() const override; virtual void invalidatePipelines() override; virtual void submitContext(CommandContextBase*, const bool finalSubmission = false) override; virtual void swap() override; virtual size_t getMinStorageBufferAlignment() const override; virtual bool getHasCommandPredicationSupport() const override; virtual bool getHasAsyncComputeSupport() const override; virtual const std::vector<uint64_t>& getAvailableTimestamps() const override; virtual float getTimeStampPeriod() const override; void createResource( const D3D12_RESOURCE_DESC& desc, const D3D12MA::ALLOCATION_DESC& allocDesc, const D3D12_RESOURCE_STATES initialResourceState, ID3D12Resource** outImage, D3D12MA::Allocation** outImageMemory, D3D12_CLEAR_VALUE* clearValue = nullptr); ID3D12DescriptorHeap* createShaderInputDescriptorHeap(const uint32_t numDescriptors); D3D12MA::ALLOCATION_DESC getResourceAllocationDescription(const ImageUsage); D3D12MA::ALLOCATION_DESC getResourceAllocationDescription(const BufferUsage); ID3D12CommandQueue* getGraphicsQueue() { return mGraphicsQueue; } private: ID3D12Device6* mDevice; IDXGIAdapter3* mAdapter; GLFWwindow* mWindow; D3D12MA::Allocator* mMemoryManager; ID3D12CommandQueue* mGraphicsQueue; ID3D12CommandQueue* mComputeQueue; std::vector<ID3D12Fence*> mFrameComplete; std::vector<uint64_t> mTimeStamps; }; #endif
[ "olie.smit0@gmail.com" ]
olie.smit0@gmail.com
9e001fab92aac35d0d2176e653554b76ae5038e2
f6d7e45edebae52a00d7553dfcf7e4e33a5820df
/src/planner/vectorfield/VectorFieldPlanner.cpp
d65482d51bfe9916346f288053f2321c60e8c363
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
annadeichler/aikido
45bc7d62a81a1472dc74fee3219c825585c59972
dd5a99d31ff9b86bbf556b9db1e30733bbafdeed
refs/heads/master
2021-08-11T08:36:55.891504
2017-11-13T12:21:01
2017-11-13T12:21:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,834
cpp
#include <exception> #include <string> #include <aikido/planner/vectorfield/MoveEndEffectorOffsetVectorField.hpp> #include <aikido/planner/vectorfield/VectorFieldPlanner.hpp> #include <aikido/planner/vectorfield/VectorFieldPlannerExceptions.hpp> #include <aikido/planner/vectorfield/VectorFieldUtil.hpp> #include <aikido/statespace/dart/MetaSkeletonStateSpaceSaver.hpp> #include <aikido/trajectory/Spline.hpp> using aikido::statespace::dart::MetaSkeletonStateSpaceSaver; namespace aikido { namespace planner { namespace vectorfield { static void checkDofLimits( const aikido::statespace::dart::MetaSkeletonStateSpacePtr& stateSpace, Eigen::VectorXd const& q, Eigen::VectorXd const& qd) { using dart::dynamics::DegreeOfFreedom; std::stringstream ss; for (std::size_t i = 0; i < stateSpace->getMetaSkeleton()->getNumDofs(); ++i) { DegreeOfFreedom* const dof = stateSpace->getMetaSkeleton()->getDof(i); if (q[i] < dof->getPositionLowerLimit()) { ss << "DOF " << dof->getName() << " exceeds lower position limit: "; ss << q[i] << " < " << dof->getPositionLowerLimit(); throw DofLimitError(dof, ss.str()); } else if (q[i] > dof->getPositionUpperLimit()) { ss << "DOF " << dof->getName() << " exceeds upper position limit: "; ss << q[i] << " > " << dof->getPositionLowerLimit(); throw DofLimitError(dof, ss.str()); } else if (qd[i] < dof->getVelocityLowerLimit()) { ss << "DOF " << dof->getName() << " exceeds lower velocity limit: "; ss << qd[i] << " < " << dof->getVelocityLowerLimit(); throw DofLimitError(dof, ss.str()); } else if (qd[i] > dof->getVelocityUpperLimit()) { ss << "DOF " << dof->getName() << " exceeds upper velocity limit: "; ss << qd[i] << " > " << dof->getVelocityUpperLimit(); throw DofLimitError(dof, ss.str()); } } } //============================================================================== static void checkCollision( const aikido::statespace::dart::MetaSkeletonStateSpacePtr& stateSpace, const aikido::constraint::TestablePtr& constraint) { // Get current position auto state = stateSpace->getScopedStateFromMetaSkeleton(); // Throw a termination if in collision if (!constraint->isSatisfied(state)) { throw VectorFieldTerminated("state in collision"); } } //============================================================================== std::unique_ptr<aikido::trajectory::Spline> planPathByVectorField( const aikido::statespace::dart::MetaSkeletonStateSpacePtr& _stateSpace, const aikido::constraint::TestablePtr& _constraint, double _dt, const VectorFieldCallback& _vectorFiledCb, const VectorFieldStatusCallback& _statusCb) { auto saver = MetaSkeletonStateSpaceSaver(_stateSpace); DART_UNUSED(saver); dart::dynamics::MetaSkeletonPtr skeleton = _stateSpace->getMetaSkeleton(); if (skeleton->getPositionUpperLimits() == skeleton->getPositionLowerLimits()) { throw std::invalid_argument("State space volume zero"); } if (skeleton->getVelocityUpperLimits() == skeleton->getVelocityLowerLimits()) { throw std::invalid_argument("Velocity space volume zero"); } for (std::size_t i = 0; i < skeleton->getNumDofs(); ++i) { std::stringstream ss; if (skeleton->getPositionLowerLimit(i) > skeleton->getPositionUpperLimit(i)) { ss << "Position lower limit is larger than upper limit at DOF " << i; throw std::invalid_argument(ss.str()); } if (skeleton->getVelocityLowerLimit(i) > skeleton->getVelocityUpperLimit(i)) { ss << "Velocity lower limit is larger than upper limit at DOF " << i; throw std::invalid_argument(ss.str()); } } const std::size_t numDof = _stateSpace->getDimension(); std::vector<Knot> knots; VectorFieldPlannerStatus terminationStatus = VectorFieldPlannerStatus::CONTINUE; std::exception_ptr terminationError; int cacheIndex = -1; int index = 0; double t = 0; Eigen::VectorXd q = _stateSpace->getMetaSkeleton()->getPositions(); auto startState = _stateSpace->createState(); _stateSpace->convertPositionsToState(q, startState); Eigen::VectorXd dq(numDof); assert(static_cast<std::size_t>(q.size()) == numDof); do { // Evaluate the vector field. try { if (!_vectorFiledCb(_stateSpace, t, dq)) { throw VectorFieldTerminated("Failed evaluating VectorField."); } } catch (const VectorFieldTerminated& e) { terminationStatus = VectorFieldPlannerStatus::TERMINATE; terminationError = std::current_exception(); break; } if (static_cast<std::size_t>(dq.size()) != numDof) { throw std::length_error( "Vector field returned an incorrect number of DOF velocities."); } // TODO: This should be computed from the DOF resolutions. const std::size_t numSteps = 1; // Compute the number of collision checks we need. for (std::size_t istep = 0; istep < numSteps; ++istep) { try { checkDofLimits(_stateSpace, q, dq); _stateSpace->getMetaSkeleton()->setPositions(q); checkCollision(_stateSpace, _constraint); } catch (const VectorFieldTerminated& e) { terminationStatus = VectorFieldPlannerStatus::TERMINATE; terminationError = std::current_exception(); break; } // Insert the waypoint. assert(static_cast<std::size_t>(q.size()) == numDof); assert(static_cast<std::size_t>(dq.size()) == numDof); Knot knot; knot.mT = t; knot.mPositions = q; knot.mVelocities = dq; knots.push_back(knot); // Take a step. auto currentState = _stateSpace->createState(); _stateSpace->convertPositionsToState(q, currentState); auto deltaState = _stateSpace->createState(); _stateSpace->convertPositionsToState(_dt * dq, deltaState); auto nextState = _stateSpace->createState(); _stateSpace->compose(currentState, deltaState, nextState); _stateSpace->convertStateToPositions(nextState, q); t += _dt; index++; // Check if we should terminate. terminationStatus = _statusCb(_stateSpace, t); if (terminationStatus == VectorFieldPlannerStatus::CACHE_AND_CONTINUE || terminationStatus == VectorFieldPlannerStatus::CACHE_AND_TERMINATE) { cacheIndex = index; } } } while (terminationStatus != VectorFieldPlannerStatus::TERMINATE && terminationStatus != VectorFieldPlannerStatus::CACHE_AND_TERMINATE); if (cacheIndex >= 0) { // Print the termination condition. if (terminationError) { try { std::rethrow_exception(terminationError); } catch (const VectorFieldTerminated& e) { dtwarn << "[VectorFieldPlanner::Plan] Terminated early: " << e.what() << '\n'; return nullptr; } } return convertToSpline(knots, cacheIndex, _stateSpace); } // Re-throw whatever error caused planning to fail. else if (terminationError) { std::rethrow_exception(terminationError); } else { throw VectorFieldTerminated( "Planning was terminated by the StatusCallback."); } return nullptr; } //============================================================================== std::unique_ptr<aikido::trajectory::Spline> planToEndEffectorOffset( const aikido::statespace::dart::MetaSkeletonStateSpacePtr& _stateSpace, const dart::dynamics::BodyNodePtr& _bn, const aikido::constraint::TestablePtr& _constraint, const Eigen::Vector3d& _direction, double _distance, double _linearVelocity, double _linearTolerance, double _angularTolerance, double _linearGain, double _angularGain, double _timestep) { if (_distance < 0.) { std::stringstream ss; ss << "Distance must be non-negative; got " << _distance << "."; throw std::runtime_error(ss.str()); } if (_linearVelocity <= 0.0) { std::stringstream ss; ss << "Linear velocity must be positive; got " << _linearVelocity << "."; throw std::runtime_error(ss.str()); } if (_direction.norm() == 0.0) { throw std::runtime_error("Direction vector is a zero vector"); } Eigen::Vector3d velocity = _direction.normalized() * _linearVelocity; double duration = _distance / _linearVelocity; auto vectorfield = MoveEndEffectorOffsetVectorField( _bn, velocity, 0.0, duration, _timestep, _linearGain, _linearTolerance, _angularGain, _angularTolerance); return planPathByVectorField( _stateSpace, _constraint, _timestep, vectorfield, vectorfield); } } // namespace vectorfield } // namespace planner } // namespace aikido
[ "brianhou@users.noreply.github.com" ]
brianhou@users.noreply.github.com
47267d78daae4a705024df166ce9bbbf65a498c6
1bfc3919d3ad25ce7075b00114bb461154815110
/src/qt/optionsdialog.cpp
276ae5b2d61394170a8ab3b1396c26730b898f15
[ "MIT" ]
permissive
billetcoin/blt
705ab2fd772449735a5feadf1da934227500f5cc
7dcd673ca4e836290a637ed2b86da9d821e33fdc
refs/heads/master
2023-03-22T21:12:11.626219
2021-03-19T16:00:05
2021-03-19T16:00:05
271,081,298
3
6
MIT
2020-08-15T21:19:43
2020-06-09T18:34:47
C++
UTF-8
C++
false
false
13,088
cpp
// Copyright (c) 2011-2013 The Bitcoin developers // Copyright (c) 2017-2019 The Billetcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #if defined(HAVE_CONFIG_H) #include "config/billetcoin-config.h" #endif #include "optionsdialog.h" #include "ui_optionsdialog.h" #include "bitcoinunits.h" #include "guiutil.h" #include "obfuscation.h" #include "optionsmodel.h" #include "main.h" // for MAX_SCRIPTCHECK_THREADS #include "netbase.h" #include "txdb.h" // for -dbcache defaults #ifdef ENABLE_WALLET #include "wallet/wallet.h" // for CWallet::minTxFee #endif #include <boost/thread.hpp> #include <QDataWidgetMapper> #include <QDir> #include <QIntValidator> #include <QLocale> #include <QMessageBox> #include <QTimer> OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet) : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), ui(new Ui::OptionsDialog), model(0), mapper(0), fProxyIpValid(true) { ui->setupUi(this); GUIUtil::restoreWindowGeometry("nOptionsDialogWindow", this->size(), this); /* Main elements init */ ui->databaseCache->setMinimum(nMinDbCache); ui->databaseCache->setMaximum(nMaxDbCache); ui->threadsScriptVerif->setMinimum(-(int)boost::thread::hardware_concurrency()); ui->threadsScriptVerif->setMaximum(MAX_SCRIPTCHECK_THREADS); /* Network elements init */ #ifndef USE_UPNP ui->mapPortUpnp->setEnabled(false); #endif ui->proxyIp->setEnabled(false); ui->proxyPort->setEnabled(false); ui->proxyPort->setValidator(new QIntValidator(1, 65535, this)); connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyIp, SLOT(setEnabled(bool))); connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyPort, SLOT(setEnabled(bool))); ui->proxyIp->installEventFilter(this); ui->proxyPort->installEventFilter(this); /* Window elements init */ #ifdef Q_OS_MAC /* remove Window tab on Mac */ ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabWindow)); #endif /* remove Wallet tab and zPiv options in case of -disablewallet */ if (!enableWallet) { ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabWallet)); ui->verticalZpivOptionsWidget->hide(); ui->verticalZpivDisplayWidget->hide(); } /* Display elements init */ /* Number of displayed decimal digits selector */ QString digits; for (int index = 2; index <= 8; index++) { digits.setNum(index); ui->digits->addItem(digits, digits); } /* Theme selector static themes */ ui->theme->addItem(QString("Default"), QVariant("default")); /* Preferred Zerocoin Denominations */ ui->preferredDenom->addItem(QString(tr("Any")), QVariant("0")); ui->preferredDenom->addItem(QString("1"), QVariant("1")); ui->preferredDenom->addItem(QString("5"), QVariant("5")); ui->preferredDenom->addItem(QString("10"), QVariant("10")); ui->preferredDenom->addItem(QString("50"), QVariant("50")); ui->preferredDenom->addItem(QString("100"), QVariant("100")); ui->preferredDenom->addItem(QString("500"), QVariant("500")); ui->preferredDenom->addItem(QString("1000"), QVariant("1000")); ui->preferredDenom->addItem(QString("5000"), QVariant("5000")); /* Theme selector external themes */ boost::filesystem::path pathAddr = GetDataDir() / "themes"; QDir dir(pathAddr.string().c_str()); dir.setFilter(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot); QFileInfoList list = dir.entryInfoList(); for (int i = 0; i < list.size(); ++i) { QFileInfo fileInfo = list.at(i); ui->theme->addItem(fileInfo.fileName(), QVariant(fileInfo.fileName())); } /* Language selector */ QDir translations(":translations"); ui->lang->addItem(QString("(") + tr("default") + QString(")"), QVariant("")); foreach (const QString& langStr, translations.entryList()) { QLocale locale(langStr); /** check if the locale name consists of 2 parts (language_country) */ if(langStr.contains("_")) { /** display language strings as "native language - native country (locale name)", e.g. "Deutsch - Deutschland (de)" */ ui->lang->addItem(locale.nativeLanguageName() + QString(" - ") + locale.nativeCountryName() + QString(" (") + langStr + QString(")"), QVariant(langStr)); } else { /** display language strings as "native language (locale name)", e.g. "Deutsch (de)" */ ui->lang->addItem(locale.nativeLanguageName() + QString(" (") + langStr + QString(")"), QVariant(langStr)); } } ui->thirdPartyTxUrls->setPlaceholderText("https://example.com/tx/%s"); ui->unit->setModel(new BitcoinUnits(this)); /* Widget-to-option mapper */ mapper = new QDataWidgetMapper(this); mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit); mapper->setOrientation(Qt::Vertical); /* setup/change UI elements when proxy IP is invalid/valid */ connect(this, SIGNAL(proxyIpChecks(QValidatedLineEdit*, QLineEdit*)), this, SLOT(doProxyIpChecks(QValidatedLineEdit*, QLineEdit*))); } OptionsDialog::~OptionsDialog() { GUIUtil::saveWindowGeometry("nOptionsDialogWindow", this); delete ui; } void OptionsDialog::setModel(OptionsModel* model) { this->model = model; if (model) { /* check if client restart is needed and show persistent message */ if (model->isRestartRequired()) showRestartWarning(true); QString strLabel = model->getOverriddenByCommandLine(); if (strLabel.isEmpty()) strLabel = tr("none"); ui->overriddenByCommandLineLabel->setText(strLabel); mapper->setModel(model); setMapper(); mapper->toFirst(); /* keep consistency for action triggered elsewhere */ connect(model, SIGNAL(hideOrphansChanged(bool)), this, SLOT(updateHideOrphans(bool))); } /* warn when one of the following settings changes by user action (placed here so init via mapper doesn't trigger them) */ /* Main */ connect(ui->databaseCache, SIGNAL(valueChanged(int)), this, SLOT(showRestartWarning())); connect(ui->threadsScriptVerif, SIGNAL(valueChanged(int)), this, SLOT(showRestartWarning())); /* Wallet */ connect(ui->spendZeroConfChange, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning())); /* Network */ connect(ui->allowIncoming, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning())); connect(ui->connectSocks, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning())); /* Display */ connect(ui->digits, SIGNAL(valueChanged()), this, SLOT(showRestartWarning())); connect(ui->theme, SIGNAL(valueChanged()), this, SLOT(showRestartWarning())); connect(ui->lang, SIGNAL(valueChanged()), this, SLOT(showRestartWarning())); connect(ui->thirdPartyTxUrls, SIGNAL(textChanged(const QString&)), this, SLOT(showRestartWarning())); connect(ui->showMasternodesTab, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning())); } void OptionsDialog::setMapper() { /* Main */ mapper->addMapping(ui->bitcoinAtStartup, OptionsModel::StartAtStartup); mapper->addMapping(ui->threadsScriptVerif, OptionsModel::ThreadsScriptVerif); mapper->addMapping(ui->databaseCache, OptionsModel::DatabaseCache); // Zeromint Enabled mapper->addMapping(ui->checkBoxZeromintEnable, OptionsModel::ZeromintEnable); // Zeromint Addresses mapper->addMapping(ui->checkBoxZeromintAddresses, OptionsModel::ZeromintAddresses); // Zerocoin mint percentage mapper->addMapping(ui->zeromintPercentage, OptionsModel::ZeromintPercentage); // Zerocoin preferred denomination mapper->addMapping(ui->preferredDenom, OptionsModel::ZeromintPrefDenom); /* Wallet */ mapper->addMapping(ui->spendZeroConfChange, OptionsModel::SpendZeroConfChange); mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures); mapper->addMapping(ui->spinBoxStakeSplitThreshold, OptionsModel::StakeSplitThreshold); /* Network */ mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP); mapper->addMapping(ui->allowIncoming, OptionsModel::Listen); mapper->addMapping(ui->connectSocks, OptionsModel::ProxyUse); mapper->addMapping(ui->proxyIp, OptionsModel::ProxyIP); mapper->addMapping(ui->proxyPort, OptionsModel::ProxyPort); /* Window */ #ifndef Q_OS_MAC mapper->addMapping(ui->minimizeToTray, OptionsModel::MinimizeToTray); mapper->addMapping(ui->minimizeOnClose, OptionsModel::MinimizeOnClose); #endif /* Display */ mapper->addMapping(ui->digits, OptionsModel::Digits); mapper->addMapping(ui->theme, OptionsModel::Theme); mapper->addMapping(ui->theme, OptionsModel::Theme); mapper->addMapping(ui->lang, OptionsModel::Language); mapper->addMapping(ui->unit, OptionsModel::DisplayUnit); mapper->addMapping(ui->thirdPartyTxUrls, OptionsModel::ThirdPartyTxUrls); mapper->addMapping(ui->checkBoxHideZeroBalances, OptionsModel::HideZeroBalances); mapper->addMapping(ui->checkBoxHideOrphans, OptionsModel::HideOrphans); /* Masternode Tab */ mapper->addMapping(ui->showMasternodesTab, OptionsModel::ShowMasternodesTab); } void OptionsDialog::enableOkButton() { /* prevent enabling of the OK button when data modified, if there is an invalid proxy address present */ if (fProxyIpValid) setOkButtonState(true); } void OptionsDialog::disableOkButton() { setOkButtonState(false); } void OptionsDialog::setOkButtonState(bool fState) { ui->okButton->setEnabled(fState); } void OptionsDialog::on_resetButton_clicked() { if (model) { // confirmation dialog QMessageBox::StandardButton btnRetVal = QMessageBox::question(this, tr("Confirm options reset"), tr("Client restart required to activate changes.") + "<br><br>" + tr("Client will be shutdown, do you want to proceed?"), QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel); if (btnRetVal == QMessageBox::Cancel) return; /* reset all options and close GUI */ model->Reset(); QApplication::quit(); } } void OptionsDialog::on_okButton_clicked() { mapper->submit(); pwalletMain->MarkDirty(); accept(); } void OptionsDialog::on_cancelButton_clicked() { reject(); } void OptionsDialog::showRestartWarning(bool fPersistent) { ui->statusLabel->setStyleSheet("QLabel { color: red; }"); if (fPersistent) { ui->statusLabel->setText(tr("Client restart required to activate changes.")); } else { ui->statusLabel->setText(tr("This change would require a client restart.")); // clear non-persistent status label after 10 seconds // Todo: should perhaps be a class attribute, if we extend the use of statusLabel QTimer::singleShot(10000, this, SLOT(clearStatusLabel())); } } void OptionsDialog::clearStatusLabel() { ui->statusLabel->clear(); } void OptionsDialog::updateHideOrphans(bool fHide) { if(ui->checkBoxHideOrphans->isChecked() != fHide) ui->checkBoxHideOrphans->setChecked(fHide); } void OptionsDialog::doProxyIpChecks(QValidatedLineEdit* pUiProxyIp, QLineEdit* pUiProxyPort) { const std::string strAddrProxy = pUiProxyIp->text().toStdString(); CService addrProxy; // Check for a valid IPv4 / IPv6 address if (!(fProxyIpValid = LookupNumeric(strAddrProxy.c_str(), addrProxy))) { disableOkButton(); pUiProxyIp->setValid(false); ui->statusLabel->setStyleSheet("QLabel { color: red; }"); ui->statusLabel->setText(tr("The supplied proxy address is invalid.")); return; } // Check proxy port if (!pUiProxyPort->hasAcceptableInput()){ disableOkButton(); ui->statusLabel->setStyleSheet("QLabel { color: red; }"); ui->statusLabel->setText(tr("The supplied proxy port is invalid.")); return; } proxyType checkProxy = proxyType(addrProxy); if (!checkProxy.IsValid()) { disableOkButton(); ui->statusLabel->setStyleSheet("QLabel { color: red; }"); ui->statusLabel->setText(tr("The supplied proxy settings are invalid.")); return; } enableOkButton(); ui->statusLabel->clear(); } bool OptionsDialog::eventFilter(QObject* object, QEvent* event) { if (event->type() == QEvent::FocusOut) { if (object == ui->proxyIp || object == ui->proxyPort) { emit proxyIpChecks(ui->proxyIp, ui->proxyPort); } } return QDialog::eventFilter(object, event); } void OptionsDialog::setCurrentIndex(int index) { ui->tabWidget->setCurrentIndex(index); }
[ "cortezhashfarm@gmail.com" ]
cortezhashfarm@gmail.com
383652f12713f3308a9eec1423552d8694e1b5aa
0da7fec56f63012180d848b1e72bada9f6984ef3
/PocketDjVu_root/libdjvu/DjVuInfo.cpp
47f8ae699da766a485fc7f73cba83dde521e3f93
[]
no_license
UIKit0/pocketdjvu
a34fb2b8ac724d25fab7a0298942db1755098b25
4c0c761e6a3d3628440fb4fb0a9c54e5594807d9
refs/heads/master
2021-01-20T12:01:16.947853
2010-05-03T12:29:44
2010-05-03T12:29:44
32,293,688
0
0
null
null
null
null
UTF-8
C++
false
false
5,873
cpp
//C- -*- C++ -*- //C- ------------------------------------------------------------------- //C- DjVuLibre-3.5 //C- Copyright (c) 2002 Leon Bottou and Yann Le Cun. //C- Copyright (c) 2001 AT&T //C- //C- This software is subject to, and may be distributed under, the //C- GNU General Public License, Version 2. The license should have //C- accompanied the software or you may obtain a copy of the license //C- from the Free Software Foundation at http://www.fsf.org . //C- //C- This program is distributed in the hope that it will be useful, //C- but WITHOUT ANY WARRANTY; without even the implied warranty of //C- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //C- GNU General Public License for more details. //C- //C- DjVuLibre-3.5 is derived from the DjVu(r) Reference Library //C- distributed by Lizardtech Software. On July 19th 2002, Lizardtech //C- Software authorized us to replace the original DjVu(r) Reference //C- Library notice by the following text (see doc/lizard2002.djvu): //C- //C- ------------------------------------------------------------------ //C- | DjVu (r) Reference Library (v. 3.5) //C- | Copyright (c) 1999-2001 LizardTech, Inc. All Rights Reserved. //C- | The DjVu Reference Library is protected by U.S. Pat. No. //C- | 6,058,214 and patents pending. //C- | //C- | This software is subject to, and may be distributed under, the //C- | GNU General Public License, Version 2. The license should have //C- | accompanied the software or you may obtain a copy of the license //C- | from the Free Software Foundation at http://www.fsf.org . //C- | //C- | The computer code originally released by LizardTech under this //C- | license and unmodified by other parties is deemed "the LIZARDTECH //C- | ORIGINAL CODE." Subject to any third party intellectual property //C- | claims, LizardTech grants recipient a worldwide, royalty-free, //C- | non-exclusive license to make, use, sell, or otherwise dispose of //C- | the LIZARDTECH ORIGINAL CODE or of programs derived from the //C- | LIZARDTECH ORIGINAL CODE in compliance with the terms of the GNU //C- | General Public License. This grant only confers the right to //C- | infringe patent claims underlying the LIZARDTECH ORIGINAL CODE to //C- | the extent such infringement is reasonably necessary to enable //C- | recipient to make, have made, practice, sell, or otherwise dispose //C- | of the LIZARDTECH ORIGINAL CODE (or portions thereof) and not to //C- | any greater extent that may be necessary to utilize further //C- | modifications or combinations. //C- | //C- | The LIZARDTECH ORIGINAL CODE is provided "AS IS" WITHOUT WARRANTY //C- | OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED //C- | TO ANY WARRANTY OF NON-INFRINGEMENT, OR ANY IMPLIED WARRANTY OF //C- | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. //C- +------------------------------------------------------------------ // // $Id: DjVuInfo.cpp,v 1.10 2005/12/24 12:45:01 leonb Exp $ // $Name: release_3_5_17 $ #ifdef HAVE_CONFIG_H # include "config.h" #endif #if NEED_GNUG_PRAGMAS # pragma implementation #endif #include "DjVuInfo.h" #include "GException.h" #include "ByteStream.h" #include "GString.h" #ifdef HAVE_NAMESPACES namespace DJVU { # ifdef NOT_DEFINED // Just to fool emacs c++ mode } #endif #endif // ---------------------------------------- // CLASS DJVUINFO #define STRINGIFY(x) STRINGIFY_(x) #define STRINGIFY_(x) #x DjVuInfo::DjVuInfo() : width(0), height(0), #ifdef DJVUVERSION_FOR_OUTPUT version(DJVUVERSION_FOR_OUTPUT), #else version(DJVUVERSION), #endif dpi(300), gamma(2.2), orientation(0) { } void DjVuInfo::decode(ByteStream &bs) { // Set to default values width = 0; height = 0; version = DJVUVERSION; dpi = 300; gamma = 2.2; orientation=0; // Read data unsigned char buffer[10]; int size = bs.readall((void*)buffer, sizeof(buffer)); if (size == 0) G_THROW( ByteStream::EndOfFile ); if (size < 5) G_THROW( ERR_MSG("DjVuInfo.corrupt_file") ); // Analyze data with backward compatibility in mind! if (size>=2) width = (buffer[0]<<8) + buffer[1]; if (size>=4) height = (buffer[2]<<8) + buffer[3]; if (size>=5) version = buffer[4]; if (size>=6 && buffer[5]!=0xff) version = (buffer[5]<<8) + buffer[4]; if (size>=8 && buffer[7]!=0xff) dpi = (buffer[7]<<8) + buffer[6]; if (size>=9) gamma = 0.1 * buffer[8]; int flags=0; if (size>=10) flags = buffer[9]; // Fixup if (gamma<0.3) gamma=0.3; if (gamma>5.0) gamma=5.0; if (dpi < 25 || dpi > 6000) dpi = 300; switch (flags & 0x7) { case 6: orientation=1; break; case 2: orientation=2; break; case 5: orientation=3; break; default: orientation=0; break; } } void DjVuInfo::encode(ByteStream &bs) { bs.write16(width); bs.write16(height); bs.write8(version & 0xff); bs.write8(version >> 8); bs.write8(dpi & 0xff); bs.write8(dpi >> 8); bs.write8((int)(10.0*gamma+0.5) ); unsigned char flags; switch (orientation) { default: flags=0; break; case 1: flags=6; break; case 2: flags=2; break; case 3: flags=5; break; } bs.write8(flags); } unsigned int DjVuInfo::get_memory_usage() const { return sizeof(DjVuInfo); } GUTF8String DjVuInfo::get_paramtags(void) const { GUTF8String retval; if(orientation) retval+="<PARAM name=\"ROTATE\" value=\"" +GUTF8String(((4-orientation)%4)*90)+"\" />\n"; if(dpi) retval+="<PARAM name=\"DPI\" value=\"" +GUTF8String(dpi)+"\" />\n"; if(gamma) retval+="<PARAM name=\"GAMMA\" value=\"" +GUTF8String(gamma)+"\" />\n"; return retval; } void DjVuInfo::writeParam(ByteStream &str_out) const { str_out.writestring(get_paramtags()); } #ifdef HAVE_NAMESPACES } # ifndef NOT_USING_DJVU_NAMESPACE using namespace DJVU; # endif #endif
[ "Igor.Solovyov@84cd470b-3125-0410-acc3-039690e87181" ]
Igor.Solovyov@84cd470b-3125-0410-acc3-039690e87181
fd6f7c911f7b6f745f8a205762950dff958db436
4c8428e5871d60a523a9a585df668a7cde3d4af4
/fd_traversal.cc
e35229ff0f5a88befb7a4d6d1eef0f4e1b732d5f
[]
no_license
mstone/vscan
2d8814de092993fee09c952d88ba32c3ebb2daa0
5b93a35e77cac010e8aed2ea9b824a06e968a293
refs/heads/master
2016-09-11T03:23:52.135891
2011-04-20T16:08:50
2011-04-20T16:08:52
1,371,831
8
6
null
null
null
null
UTF-8
C++
false
false
7,514
cc
/* Copyright (c) 2011 Akamai Technologies, Inc. */ #include "system.hh" #include "cgen.h" #include "log.h" #include "encode.h" #include "decode.h" #include "decider.h" #include "scanner_mode.h" #include "config.h" #include "path_dir_pair.h" #include "counter.h" #include "traversal.h" #include "fd_traversal.h" #include "scanner.h" #include "scannable.h" #include "fd_scannable.h" #include "fake_fdopendir.h" FDTraversal::FDTraversal() : root_path_(""), worklist_(), decider_(NULL), prev_dir_(NULL), counter_(NULL), scanner_(NULL) {} FDTraversal::~FDTraversal() {} int FDTraversal::Init(Counter* counter, struct path_dir_pair root, const Decider * decider, Scanner* scanner) { CHK(worklist_.size() != 0, "non-empty traversal", out_error); CHK(counter == NULL, "null counter", out_error); CHK(root.dir == NULL, "null root.dir", out_error); CHK(decider == NULL, "null decider", out_error); CHK(scanner == NULL, "null scanner", out_error); counter_ = counter; worklist_.push_back(root); decider_ = decider; scanner_ = scanner; root_path_ = root.path; counter_->num_dirs = 1; // for the root dir counter_->num_files = 0; counter_->num_interesting = 0; return 0; out_error: return 1; } int FDTraversal::get_next_dirent(int* dfd, struct dirent** dip) { int ret; /* ret is for recording errors encountered by readdir_r */ struct dirent* di; /* di is for restoring *dip after readdir_r sets *dip = NULL. */ while(worklist_.size() > 0) { /* 0. Get a directory */ struct path_dir_pair p = worklist_.front(); /* 1. If it's new, make it current. */ if (prev_dir_ != p.dir) { *dfd = dirfd(p.dir); prev_dir_ = p.dir; } /* 2. Sanity-check dip and p.dir, save *dip, and reset p.dir. */ TST(dip == NULL, errno = EINVAL, "tried use a null dip", out_error); TST(p.dir == NULL, errno = EINVAL, "tried to read a null dir", out_error); di = *dip; /* 3. readdir_r() and handle errors. */ ret = readdir_r(p.dir, *dip, dip); // alternately, scandir TST(ret > 0, errno = ret, "readdir_r failed", out_error); TST(ret < 0, errno = EINVAL, "readdir_r went crazy", out_error); /* 4. If you finished the current directory, try again; otherwise, return. */ if (*dip == NULL) { worklist_.pop_front(); closedir(p.dir); *dip = di; } else { *dfd = dirfd(p.dir); return 0; } } /* 5. Signal that iteration is complete by setting *dip = NULL. */ *dip = NULL; return 0; out_error: return 1; } int FDTraversal::go(bool* done) { struct dirent di; struct dirent* dip = &di; int fd, dfd; struct stat st; CHK(get_next_dirent(&dfd, &dip) != 0, "unable to get next dirent", out_error); if (dip == NULL) { ostringstream oss; oss << uri_encode(root_path_); string qpath = oss.str(); write_c_line(&cout, qpath, counter_); *done = true; return 0; } else { *done = false; } // TRACE: // dbg_print_current_path("now", di.d_name); if (di.d_type != DT_DIR && di.d_type != DT_REG && di.d_type != DT_LNK && di.d_type != DT_UNKNOWN) return 0; if (strlen(di.d_name) > 0 && di.d_name[0] == '.') return 0; fd = -1; counter_->num_files += 1; if (di.d_type == DT_DIR) return go_dir(dfd, di, fd, st); else if (di.d_type == DT_REG) return go_reg(dfd, di, fd, st); else if (di.d_type == DT_LNK) return go_lnk(dfd, di, false, st); if (di.d_type == DT_UNKNOWN) { CHK(fstatat(dfd, di.d_name, &st, AT_SYMLINK_NOFOLLOW) == -1, "unable to stat fd", out_error); if (S_ISDIR(st.st_mode)) return go_dir(dfd, di, fd, st); if (S_ISLNK(st.st_mode)) return go_lnk(dfd, di, true, st); if (S_ISREG(st.st_mode)) return go_reg(dfd, di, fd, st); } return 0; out_error: return 1; } int FDTraversal::go_dir(int dfd, const struct dirent& di, int fd, const struct stat&) { struct path_dir_pair p; DIR* dir; int newfd; counter_->num_files -= 1; counter_->num_dirs += 1; if (fd == -1) { LET(fd = openat(dfd, di.d_name, O_RDONLY), fd == -1, "unable to open dir; skipping", skip, "path: ^^ %d\n", dbg_print_current_path("eio-go-dir", di.d_name)); LET(dir = fake_fdopendir(fd), dir == NULL, "unable to fake_fdopendir", out_error); } else { LET(dir = fake_fdopendir(fd), dir == NULL, "unable to fake_fdopendir", out_error); } LET(newfd = dirfd(dir), newfd == -1, "unable to dirfd new dir", out_error); CHK(newfd != fd && fd != -1 && close(fd) == -1, "unable to close old fd", out_error); p.path = string(di.d_name), p.dir = dir; worklist_.push_front(p); skip: return 0; out_error: return 1; } int FDTraversal::go_reg(int dfd, const struct dirent& di, int fd, const struct stat& st) { int ret = 0; bool should_scan; struct stat st2 = st; FDScannable sc_fd; StringPiece frag = di.d_name; CHK(decider_->Decide(di, fd != -1, st2, &should_scan) != 0, "unable to decide whether to scan di", out_error); if ( ! should_scan) goto cleanup; if (fd == -1) { LET(fd = openat(dfd, di.d_name, O_RDONLY | O_NOFOLLOW), fd == -1, "unable to open reg file", cleanup, "Path: ^^ %d\n", dbg_print_current_path("eopen-reg-file", di.d_name)); CHK(fstat(fd, &st2) == -1, "unable to stat fd", out_error); CHK(decider_->Decide(di, fd != -1, st2, &should_scan) != 0, "unable to decide whether to scan di", out_error); if ( ! should_scan) goto cleanup; } CHK(sc_fd.Init(this, &frag, (uint64_t)st2.st_size, fd) != 0, "unable to init fd-scannable", out_error); CHK(scanner_->scan(&sc_fd) != 0, "unable to scan fd-scannable", out_error); CHK(sc_fd.Destroy() != 0, "unable to destroy fd-scannable", out_error); ret = 0; goto cleanup; out_error: ret = 1; goto cleanup; cleanup: if (fd != -1) { TST(close(fd) == -1, fd = -1, "unable to close fd", out_error); } return ret; } int FDTraversal::go_lnk(int dfd, const struct dirent& di, bool has_st, struct stat& st) { bool should_scan; StringPiece frag; string path2; int fd = -1; frag = di.d_name; if (!has_st) { CHK(fstatat(dfd, di.d_name, &st, AT_SYMLINK_NOFOLLOW) == -1, "unable to lstat link", out_error); } CHK(decider_->Decide(di, true, st, &should_scan) != 0, "unable to decide whether to scan di", out_error); if ( ! should_scan) goto skip; LET(fd = openat(dfd, di.d_name, O_RDONLY), fd == -1, "unable to open reg file", skip, "Path: ^^ %d\n", dbg_print_current_path("eopen-reg-file", di.d_name)); CHK(fstat(fd, &st) == -1, "unable to stat fd", out_error); if (S_ISREG(st.st_mode)) return go_reg(dfd, di, fd, st); return 0; out_error: if (fd != -1) { TST(close(fd) == -1, fd = -1, "unable to close fd", out_error); } return 1; skip: return 0; } int FDTraversal::dbg_print_current_path(const char* msg, const char* frag) const { string qpath; StringPiece spfrag(frag); CHK(get_quoted_path(&spfrag, &qpath) != 0, "unable to get quoted path", out_error); fprintf(stderr, "E %s path %s\n", msg, qpath.c_str()); return 0; out_error: return 1; } int FDTraversal::get_quoted_path(void* traversal_datum, string* qpath) const { StringPiece* frag = reinterpret_cast<StringPiece*>(traversal_datum); ostringstream oss; list<struct path_dir_pair>::const_reverse_iterator it, ie, first; first = worklist_.rbegin(); for(it = worklist_.rbegin(), ie = worklist_.rend(); it != ie; ++it) { if (it != first) oss << "/"; oss << uri_encode(it->path); } oss << "/" << uri_encode(*frag); *qpath = oss.str(); return 0; }
[ "mistone@akamai.com" ]
mistone@akamai.com
0d937edd94437cf9269235f6f2870e8cd36422df
ef76d1b825c7853f05fa833f9e8d7f45ba633357
/Iterator/Iterator.cpp
f9d1790f45d9b48ef9d144f6608150f9d01212fe
[]
no_license
StabCrab/SchoolLabs
3995d21323d568071ced95bb7bacecc443f96ad4
9aab9f80ce14c4066bed7e7e14f7069429efb0b9
refs/heads/master
2021-07-10T11:11:11.287248
2019-03-20T12:49:05
2019-03-20T12:49:05
133,848,063
1
0
null
null
null
null
UTF-8
C++
false
false
575
cpp
// // Created by trykr on 12.12.2018. // #include <iostream> #include <set> #include <iterator> using namespace std; int main() { int n, x; set <int> Set; set<int>:: iterator it; cin >> n; for (int i = 0; i < n; i++) { cin >> x; Set.insert(x); } it = Set.begin(); cout << *it; it = Set.end(); it--; cout << *it; for (int i = 0; i < Set.size(); i++) cout << *it << " "; cin >> x; it = Set.find(x); if (it != Set.end()) { cout << "yes"; } else cout <<"no"; }
[ "trykrop@gmail.com" ]
trykrop@gmail.com
c58c4e8498c06cca97be15a6a7c7f7a4ae871e55
47d95bb1d456ed3c5186c8caad5f0eea9d43be9b
/git-int/gitint-shell.cpp
91cc303c5cc50c257bbddc99b198e17e0bca6bde
[]
no_license
roberthung88/Object-Oriented
33b196ccc84cfe65c4b791020824bc6f1bee0685
6da8df35b0892c3416dfc90176357ad9e18587c6
refs/heads/master
2022-09-14T04:25:21.208210
2020-05-22T23:38:14
2020-05-22T23:38:14
266,226,951
0
0
null
null
null
null
UTF-8
C++
false
false
691
cpp
#include <iostream> #include "gitint.h" // Add any necessary headers using namespace std; void print_exception_message(const std::string& what_msg); int main() { GitInt g; string cmd_line; bool quit = false; const string PROMPT_STARTER = "$ "; g.print_menu(); while(!quit){ cout << PROMPT_STARTER; getline(cin, cmd_line); try { quit = g.process_command(cmd_line); } catch (std::string exception) { print_exception_message(exception); } } return 0; } void print_exception_message(const std::string& what_msg) { cout << "Error - " << what_msg << endl; }
[ "juipohun@usc.edu" ]
juipohun@usc.edu
d2b45641f8b235b74810e39181221bdb7d8b34d5
5a7ffda92f7518f0392efbed028476c7fb61e15f
/stepik_cpp/First_Course/string/main.cpp
f278815ea82cee84ea5ea1728c04b22df9db448d
[]
no_license
Ukio-G/study_cpp
989cdd33969fbd621f3857e8abd9a1f3bb301212
004deee88d1d817c7a4dc1faa0cda3eb7e105300
refs/heads/master
2022-12-22T11:17:49.302062
2022-12-21T19:55:38
2022-12-21T19:55:38
247,478,919
1
0
null
null
null
null
UTF-8
C++
false
false
378
cpp
#include <iostream> #include <cstddef> // size_t #include <cstring> // strlen, strcpy struct String { String(const char *str = ""); size_t size; char *str; }; String::String(const char *str) : size(strlen(str)), str(new char[size+1]){ strcpy(this->str,str); this->str[size] = '\0'; } int main(int argc, char const *argv[]) { String str = "C-style string"; return 0; }
[ "nik3207974@ya.ru" ]
nik3207974@ya.ru
3352159af9ec4faf67dcd6f1b968b10c8a5f899c
35529931e528fe79275e36252f2c23a600b77cd3
/app/src/main/cpp/JavaCallHelper.h
0c47de361a49b38c1e50133fec386a1354125172
[]
no_license
lgq895767507/QuickPlay
8d2ac296a5b0449d81251b0ad4d83ab204879f2a
fe605d12fce0f215ff6cc84a2c74d8598e6e48b0
refs/heads/master
2020-07-11T21:46:24.283171
2019-08-27T07:53:52
2019-08-27T07:53:52
204,650,347
0
0
null
null
null
null
UTF-8
C++
false
false
611
h
// // Created by Administrator on 2019/6/4. // #ifndef PALYERWANGYI_JAVACALLHELPER_H #define PALYERWANGYI_JAVACALLHELPER_H #include <jni.h> class JavaCallHelper { public: JavaCallHelper(JavaVM *_javaVM, JNIEnv *_env, jobject &_jobj); ~JavaCallHelper(); void onError(int thread, int code); void onParpare(int thread); void onProgress(int thread, int progress); private: JavaVM *javaVM; JNIEnv *env; jobject jobj; jmethodID jmid_prepare; jmethodID jmid_error; jmethodID jmid_progress; }; #endif //PALYERWANGYI_JAVACALLHELPER_H
[ "liuguoqing@aihuishou.com" ]
liuguoqing@aihuishou.com
8b2a9106a9f5ff795515e1a36cf6c03644126c18
5d83739af703fb400857cecc69aadaf02e07f8d1
/Archive2/f0/eb82ad8d237988/main.cpp
a75c149765b86ea8e5905b622de5b6eba96b331d
[]
no_license
WhiZTiM/coliru
3a6c4c0bdac566d1aa1c21818118ba70479b0f40
2c72c048846c082f943e6c7f9fa8d94aee76979f
refs/heads/master
2021-01-01T05:10:33.812560
2015-08-24T19:09:22
2015-08-24T19:09:22
56,789,706
3
0
null
null
null
null
UTF-8
C++
false
false
886
cpp
#include <iostream> #include <string> #include <utility> struct A { struct Tag{}; std::string name; int value; A (const std::string& n, int v) : name(n), value(v) {} A (const std::string& n, int v, Tag) : name(n), value(v) {std::cout << "Constructor with Tag called.\n";} }; struct B : A {using A::A;}; struct C : B {using B::B;}; struct D : C { char special; template < typename ... ARGS > D( const std::string& n, int v, char s, ARGS&&... args ) : C( n, v, std::forward<ARGS>(args)... ), special(s) {} }; struct E : B { double special; template < typename ... ARGS > E( const std::string& n, int v, double d, ARGS&&... args ) : B( n, v, std::forward<ARGS>(args)... ), special(d) {} }; int main() { A a("a", 1, A::Tag{}); B b("a", 2, A::Tag{}); C c("c", 3, A::Tag{}); D d("d", 4, 'd', A::Tag{}); E e("e", 5, 3.14, A::Tag{}); }
[ "francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df" ]
francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df
162b5af3f830a2b2df23b246b48be0520afc5a1e
6f617e5a798ff9f55983cecba2378d8c5b65ff7c
/node_modules/uws/src/WebSocket.h
346ba574a6290aac6a19700b6ba072481d6c79d5
[ "Zlib" ]
permissive
farshidrezaei/Chat
f12c555464a9c3118d560c0e57fb48f34a4ac16f
aae3042e9650dc8f1d58728716379cc51804181e
refs/heads/master
2022-02-24T02:57:38.917666
2022-02-09T12:01:40
2022-02-09T12:01:40
94,820,417
4
0
null
null
null
null
UTF-8
C++
false
false
2,931
h
#ifndef WEBSOCKET_UWS_H #define WEBSOCKET_UWS_H #include "WebSocketProtocol.h" #include "Socket.h" namespace uWS { template <bool isServer> struct Group; template <const bool isServer> struct WIN32_EXPORT WebSocket : protected uS::Socket { struct Data : uS::SocketData, WebSocketProtocol<isServer> { std::string fragmentBuffer, controlBuffer; enum CompressionStatus : char { DISABLED, ENABLED, COMPRESSED_FRAME } compressionStatus; bool hasOutstandingPong = false; Data(bool perMessageDeflate, uS::SocketData *socketData) : uS::SocketData(*socketData) { compressionStatus = perMessageDeflate ? CompressionStatus::ENABLED : CompressionStatus::DISABLED; } }; WebSocket(uS::Socket s = nullptr) : uS::Socket(s) { } struct PreparedMessage { char *buffer; size_t length; int references; void(*callback)(void *webSocket, void *data, bool cancelled, void *reserved); }; using uS::Socket::getUserData; using uS::Socket::setUserData; using uS::Socket::getAddress; using uS::Socket::Address; void transfer(Group<isServer> *group) { ((Group<isServer> *) getSocketData()->nodeData)->removeWebSocket(p); uS::Socket::transfer((uS::NodeData *) group, [](uv_poll_t *p) { uS::Socket s(p); ((Group<isServer> *) s.getSocketData()->nodeData)->addWebSocket(s); }); } uv_poll_t *getPollHandle() const {return p;} void terminate(); void close(int code = 1000, char *message = nullptr, size_t length = 0); void ping(const char *message) {send(message, OpCode::PING);} void send(const char *message, OpCode opCode = OpCode::TEXT) {send(message, strlen(message), opCode);} void send(const char *message, size_t length, OpCode opCode, void(*callback)(void *webSocket, void *data, bool cancelled, void *reserved) = nullptr, void *callbackData = nullptr); static PreparedMessage *prepareMessage(char *data, size_t length, OpCode opCode, bool compressed, void(*callback)(void *webSocket, void *data, bool cancelled, void *reserved) = nullptr); void sendPrepared(PreparedMessage *preparedMessage, void *callbackData = nullptr); static void finalizeMessage(PreparedMessage *preparedMessage); bool operator==(const WebSocket &other) const {return p == other.p;} bool operator<(const WebSocket &other) const {return p < other.p;} private: friend class uS::Socket; template <bool> friend struct Group; static void onData(uS::Socket s, char *data, int length); static void onEnd(uS::Socket s); }; } namespace std { template <bool isServer> struct hash<uWS::WebSocket<isServer>> { std::size_t operator()(const uWS::WebSocket<isServer> &webSocket) const { return std::hash<uv_poll_t *>()(webSocket.getPollHandle()); } }; } #endif // WEBSOCKET_UWS_H
[ "farshid.net1@yahoo.com" ]
farshid.net1@yahoo.com
2175cefdf21adc08ceeb8afb555316ddd9244822
49c44b0436a42fc3a53261f1df1014941f4882ba
/hw3d/BufferResource.h
2463e6c432e8e2414c06151d97e0e3221a54cc16
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
Black-Pixel-Cat/hw3d
eed37c270a3fe481707f3fe77b79bb640e6b0acc
eee6198c4858c216b9c93b04dc20ae1d254c79a4
refs/heads/master
2023-08-24T01:50:56.333285
2021-09-02T13:21:18
2021-09-02T13:21:18
393,624,072
1
0
null
2021-08-07T08:23:36
2021-08-07T08:20:56
null
UTF-8
C++
false
false
324
h
#pragma once #include "ConditionalNoexcept.h" class Graphics; namespace Bind { class BufferResource { public: virtual ~BufferResource() = default; virtual void BindAsBuffer( Graphics& ) noxnd = 0; virtual void BindAsBuffer( Graphics&,BufferResource* ) noxnd = 0; virtual void Clear( Graphics& ) noxnd = 0; }; }
[ "ray_kun@hotmail.com" ]
ray_kun@hotmail.com
85eb77008db888777e71d34b53f399b25de6bccb
dcf3b364645a1c6ce9c0ac17bfa3f1a4c7b9b7ae
/server/Apps/FightServer/GameLogic.h
54478836c72df0fff7a15520f53e253bd757d647
[]
no_license
cu8Fsuz/Kurumi
73235466850f66461b82ca362d00a087fdaf9baf
aaa3e4fca3205686bbb5b02662dffac6d6f0d1c8
refs/heads/master
2023-07-24T14:01:47.828798
2021-09-01T03:41:04
2021-09-01T03:41:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,611
h
#pragma once #include "game/GGameWorld.h" #include "GamePlayer.h" #include "GameProto.h" // ๆœๅŠกๅ™จๆธธๆˆๅŒๆญฅ้€ป่พ‘ class GameLogic { public: GameLogic(); ~GameLogic(); err::Code init(const GGameWorldInitArgs &args, const ::google::protobuf::RepeatedPtrField< ::svr_msg::FightRoleSpawnInfo >& roles); void update(float dt); // ่Žทๅ–ๅฝ“ๅ‰้€ป่พ‘ๅธง uint32_t getGameLogicFrame() const; // ่Žทๅ–ๅฝ“ๅ‰็Šถๆ€ int32_t getGameStatus() const; public: err::Code joinCode(uint32_t sessionID, const msg::JoinFightReq& req); void doJoin(uint32_t sessionID, const msg::JoinFightReq& req); void exitGame(int64_t playerID); err::Code exitGameWithSessionID(uint32_t sessionID); public: G_SYNTHESIZE_PASS_BY_REF(GGameWorldInitArgs, m_initArgs, InitArgs); G_SYNTHESIZE(bool, m_isFinish, IsFinish); G_SYNTHESIZE(int32_t, m_uuid, uuid); protected: void pingUpdate(float dt); void update_WaitConnect(float dt); void update_Ready(float dt); void update_Run(float dt); void update_Wait(float dt); GamePlayer* getPlayerBySessionID(uint32_t sessionID); // ่Žทๅ–้€ป่พ‘ๅธงๆœ€ๆ…ข็š„ไธ€ไธช็Žฉๅฎถ GamePlayer* getSlowestPlayer(); bool containPlayer(int64_t playerID); void sendToAllPlayer(MessageID msgID, const ::google::protobuf::MessageLite& msg); // ๅนฟๆ’ญๆ‰€ๆœ‰็ŽฉๅฎถๅŠ ่ฝฝไฟกๆฏ void sendLoadingPercentToAllPlayer(); // ๅ‘็ŽฉๅฎถๆŽจๅธง void pushFrameInfo(uint32_t startFrame, uint32_t sessionID); protected: void onMsg_RunNextFrameReq(uint32_t sessionID, const msg::RunNextFrameReq& req); void onMsg_PlayerLoadingReq(uint32_t sessionID, const msg::PlayerLoadingReq& req); void onMsg_Pong(uint32_t sessionID, const msg::Pong& req); private: std::unique_ptr<GGameWorld> m_world; GNetService* m_pNetService; GApplication* m_pApplication; // ๆœฌๅฑ€ๆธธๆˆ็Žฉๅฎถๆ•ฐ้‡ int32_t m_playerCount; std::unique_ptr<GamePlayer> m_players[G_FIGHT_MAX_PLAYER_COUNT]; std::set<int64_t> m_playerIDSet; enum RUN_STATE { WAIT_CONNECT = 0, // ็ญ‰ๅพ…ๅฎขๆˆท็ซฏ่ฟžๆŽฅๆœๅŠกๅ™จ READY, // ๅ‡†ๅค‡็Šถๆ€,็ญ‰ๅพ…็Žฉๅฎถๅ…จ้ƒจๅ‡†ๅค‡ๅฎŒๆฏ• RUN, // ๆญฃๅธธ่ฟ่กŒ็Šถๆ€ WAIT // ็ญ‰ๅพ…็Šถๆ€,็ญ‰ๅพ…้€ป่พ‘ๅธงๆœ€ๆ…ข็š„ๅฎขๆˆท็ซฏ่ทŸไธŠๆœๅŠกๅ™จ้€ป่พ‘ๅธง }; RUN_STATE m_state; float m_waitTime; // ๆธธๆˆๆœ€ๅŽไธ€ๆฌกๆ‰ง่กŒ้€ป่พ‘ๆ—ถ้—ด float m_lastRunTime; // ๆธธๆˆ็ดฏ่ฎก่ฟ่กŒๆ—ถ้—ด float m_accumilatedTime; msg::PlayerRecords m_pastRecords; //std::vector<msg::PlayerFrameInput*> m_curFrameInputs; msg::RunNextFrameAck m_runNextFrameAckCache; msg::PlayerFrameInput* m_pCacheFrameInputs[G_FIGHT_MAX_PLAYER_COUNT]; float m_pingTime; float m_pingPushTime; };
[ "www.tkzc@foxmail.com" ]
www.tkzc@foxmail.com
62eebfea848587478ff383beee45ce30e19e796c
14d1a24f4e3b687b64a928d7e77737047bfb6a78
/WinApi/WndProc.cpp
f6cc56b0745454505e918acf9956ea9244002ca5
[]
no_license
chan328/WinAPI
612969832fdda3daf0498254a896da89c1c158e3
9fa57e4dc8b1d54cf8c46ce31517668f3bcb7736
refs/heads/master
2020-03-28T06:01:08.312821
2018-09-16T12:13:28
2018-09-16T12:13:28
147,809,285
0
0
null
null
null
null
UHC
C++
false
false
2,976
cpp
// WndProc // ๋ฉ”์‹œ์ง€ ์ฒ˜๋ฆฌ ํ•จ์ˆ˜๋ž€ ๋ฉ”์‹œ์ง€๊ฐ€ ๋ฐœ์ƒํ•  ๋Œ€ ๋ฐ˜์‘์„ ์ฒ˜๋ฆฌํ•˜๋Š” ์ผ์„ ํ•˜๋ฉฐ // WinMain ํ•จ์ˆ˜์™€๋Š” ๋ณ„๋„๋กœ WndProc์ด๋ผ๋Š” ์ด๋ฆ„์œผ๋กœ ์กด์žฌํ•œ๋‹ค. // ์œˆ๋„์šฐ ํ”„๋กœ์‹œ์ €(Window Procedure)๋ผ๋Š” ๋œป์„ ๊ฐ€์ง€๊ณ ์žˆ์ง€๋งŒ, ์œˆ๋“œ ํ”„๋ก์ด๋ผ๊ณ  ์ฝ๋Š”๋‹ค. // WndProc์€ WinMain์—์„œ ํ˜ธ์ถœํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹Œ ์œˆ๋„์šฐ์ฆˆ์— ์˜ํ•ด ํ˜ธ์ถœ๋œ๋‹ค. // WinMain๋‚ด์˜ ๋ฉ”์‹œ์ง€ ๋ฃจํ”„๋Š” ๋ฉ”์‹œ์ง€๋ฅผ ๋ฉ”์‹œ์ง€ ์ฒ˜๋ฆฌ ํ•จ์ˆ˜๋กœ ๋ฐฐ๋‚ด์ฃผ๊ธฐ๋งŒ ํ•  ๋ฟ์ด๋ฉฐ // WndProc์€ ๋ฉ”์‹œ์ง€๊ฐ€ ์ž…๋ ฅ๋˜๋ฉด ์œˆ๋„์šฐ์ฆˆ์— ์˜ํ•ด ํ˜ธ์ถœ์ด ๋˜์–ด ๋ฉ”์‹œ์ง€๋ฅผ ์ฒ˜๋ฆฌํ•จ. // ์ด๋ ‡๊ฒŒ ์šด์˜์ฒด์ œ์— ์˜ํ•ด ํ˜ธ์ถœ๋˜๋Š” ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ๋‚ด์˜ ํ•จ์ˆ˜๋ฅผ CallBakc(์ฝœ๋ฐฑ ํ•จ์ˆ˜)๋ผ๊ณ  ํ•œ๋‹ค. // WndProc์˜ ์ธ์ˆ˜๋Š” ๋ชจ๋‘ 4๊ฐœ์ด๋ฉฐ MSG๊ตฌ์กฐ์ฒด์˜ ๋ฉค๋ฒ„ 4๊ฐœ์™€ ๋™์ผํ•˜๋‹ค. // hWnd๋Š” ๋ฉ”์‹œ์ง€๋ฅผ ๋ฐ›์„ ์œˆ๋„์šฐ์˜ ํ•ธ๋“ค์ด๋ฉฐ // iMessage๋Š” ์–ด๋–ค ์ข…๋ฅ˜์˜ ๋ฉ”์‹œ์ง€์ธ๊ฐ€, ์ฆ‰ ์–ด๋–ค ๋ณ€ํ™”๊ฐ€ ๋ฐœ์ƒํ–ˆ๋Š”๊ฐ€์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๊ฐ€์ง„๋‹ค. // ex) iMessage๊ฐ€ WM_MOVE๋ฉด ์œˆ๋„์šฐ์˜ ์œ„์น˜๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ์Œ์„ ์•Œ๋ฆฌ๊ณ  WM_DESTROY๋ฉด // ์œˆ๋„์šฐ๊ฐ€ ํŒŒ๊ดด๋˜์—ˆ์Œ์„ ์•Œ๋ฆฌ๋Š” ๊ฒƒ์ด๋‹ค. //wParam, IParam์€ iMessage์˜ ๋ฉ”์‹œ์ง€์— ๋”ฐ๋ฅธ ๋ถ€๊ฐ€์ ์ธ ์ •๋ณด๋ฅผ ๊ฐ€์ง„๋‹ค. // WndProc์˜ ๊ตฌ์กฐ๋Š” ๋Œ€์ฒด๋กœ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํ˜•ํƒœ๋ฅผ ๊ฐ€์ง„๋‹ค. ๋ฉ”์‹œ์ง€์˜ ์ข…๋ฅ˜์— ๋”ฐ๋ผ // ๋‹ค์ค‘๋ถ„๊ธฐํ•˜์—ฌ ๋ฉ”์‹œ์ง€๋ณ„๋กœ ์ฒ˜๋ฆฌ๋ฅผ ์ง„ํ–‰ํ•œ๋‹ค. switch (iMessage) { case Msg1: // Msg1 ๋ฉ”์‹œ์ง€๊ฐ€ ์ „๋‹ฌ๋˜๋ฉด ์ฒ˜๋ฆฌ 1์„ ํ•œ ํ›„ ๋ฆฌํ„ดํ•˜๊ณ  char "์ฒ˜๋ฆฌ1"; break; case Msg2: // Msg2 ๋ฉ”์‹œ์ง€๊ฐ€ ์ „๋‹ฌ๋˜๋ฉด ์ฒ˜๋ฆฌ 2๋ฅผ ํ•œ ํ›„ ๋ฆฌํ„ดํ•œ๋‹ค. char "์ฒ˜๋ฆฌ2"; break; case Msg3: // case ๋ฌธ์€ ๋ฉ”์‹œ์ง€๊ฐ€ ์ „๋‹ฌ๋œ ๋งŒํผ ๋ฐ˜๋ณต๋œ๋‹ค. char "์ฒ˜๋ฆฌ3"; break; default: return DefWindowProc(...); break; // DefWindwoProc ํ•จ์ˆ˜๋Š” WndProc์—์„œ ์ฒ˜๋ฆฌํ•˜์ง€ ์•Š์€ ๋‚˜๋จธ์ง€ ๋ฉ”์‹œ์ง€์— ๋Œ€ํ•œ // ์ฒ˜๋ฆฌ๋ฅผ ํ•ด์ค€๋‹ค. } // ์˜ˆ๋ฅผ ๋“ค์–ด ์‹œ์Šคํ…œ ๋ฉ”๋‰ด๋ฅผ ๋”๋ธ”ํด๋ฆญํ•˜๋ฉด ํ”„๋กœ๊ทธ๋žจ์ด ์ข…๋ฃŒ๋˜๋Š”๋ฐ ์ด๋Ÿฐ ์ฒ˜๋ฆฌ๋Š” ๋ณ„๋„๋กœ // ์ฒ˜๋ฆฌ ํ•˜์ง€ ์•Š์•„๋„ DefWindowProc์œผ๋กœ ๋„˜๊ฒจ์ฃผ๊ธฐ๋งŒ ํ•˜๋ฉด ๋œ๋‹ค. // ์˜ˆ์ œ์˜ ๋ฉ”์‹œ์ง€ ์ฒ˜๋ฆฌ ํ•จ์ˆ˜๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋˜์–ด์žˆ๋‹ค. LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { switch (iMessage) { case WM_DESTROY: PostQuitMessage(0); return 0; } return(DefWindowProc(hWnd, iMessage, wParam, IParam)); } // ์œ„ ์˜ˆ์ œ๋Š” WM_DESTROY ๋ฉ”์‹œ์ง€๋งŒ์„ ์ฒ˜๋ฆฌํ•˜๊ณ  ์žˆ์œผ๋ฉฐ ๋‚˜๋จธ์ง€ ๋ฉ”์‹œ์ง€์— ๋Œ€ํ•ด์„œ๋Š” // DefWindowProc์— ๋งก๊ธด๋‹ค. WndProc์—์„œ ์ด ๋ฉ”์‹œ์ง€๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด PostQuitMessage ํ•จ์ˆ˜๋ฅผ // ํ˜ธ์ถœํ•˜์—ฌ WM_QUIT ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ธ๋‹ค. WM_QUIT ๋ฉ”์‹œ์ง€๊ฐ€ ์ž…๋ ฅ๋˜๋ฉด ๋ฉ”์‹œ์ง€ ๋ฃจํ”„์˜ // GetMessage ํ•จ์ˆ˜ ๋ฆฌํ„ด๊ฐ’์ด False๊ฐ€ ๋˜์–ด ํ”„๋กœ๊ทธ๋žจ์ด ์ข…๋ฃŒํ•œ๋‹ค. // WM_DESTROY ์ด์™ธ์˜ ๋ฉ”์‹œ์ง€๋Š” ๋ชจ๋‘ DefWindowProc ํ•จ์ˆ˜๋กœ ์ „๋‹ฌ๋˜๋ฉฐ ์ด ํ•จ์ˆ˜์—์„œ // ๋””ํดํŠธ ์ฒ˜๋ฆฌ๋ฅผ ์ˆ˜ํ–‰ํ•ด ์ค€๋‹ค. WndProc์€ ๋ฉ”์‹œ์ง€๋ฅผ ์ฒ˜๋ฆฌํ–ˆ์„ ๊ฒฝ์šฐ ๋ฐ˜๋“œ์‹œ 0์„ return // ํ•ด์ค˜์•ผ ํ•œ๋‹ค.
[ "rkdcks020328@gmail.com" ]
rkdcks020328@gmail.com
e267c17616dbaa91ca08d3f528e7b454dbd4ab2e
be10415b7ecdc3c546d360b073fb2cbd2dc38f32
/src/genwit.h
5b1c10110751280b65b06b39af7682dcabc698d8
[ "MIT" ]
permissive
socialtradercoin/sctr-core
40b796e5b11a9f2ae6617cd3c78ca9aed672b04b
3f1429b41049b810b57256419f7d5d8401db25a3
refs/heads/master
2020-06-01T01:10:24.774556
2019-06-06T11:43:46
2019-06-06T11:43:46
190,571,325
0
0
null
null
null
null
UTF-8
C++
false
false
1,461
h
// Copyright (c) 2015-2018 The PIVX developers // Copyright (c) 2019 The SocialTrader developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef SCTR_GENWIT_H #define SCTR_GENWIT_H #include <iostream> #include "bloom.h" #include "libzerocoin/Denominations.h" #include "net.h" class CGenWit { public: CGenWit(); CGenWit(const CBloomFilter &filter, int startingHeight, libzerocoin::CoinDenomination den, int requestNum, CBigNum accWitValue = 0); bool isValid(int chainActiveHeight); ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { READWRITE(filter); filter.setNotFull(); READWRITE(startingHeight); READWRITE(den); READWRITE(requestNum); READWRITE(accWitValue); } const CBloomFilter &getFilter() const; int getStartingHeight() const; libzerocoin::CoinDenomination getDen() const; int getRequestNum() const; CNode *getPfrom() const; void setPfrom(CNode *pfrom); const CBigNum &getAccWitValue() const; const std::string toString() const; private: CBloomFilter filter; int startingHeight; libzerocoin::CoinDenomination den; int requestNum; CBigNum accWitValue; CNode* pfrom; }; #endif //SCTR_GENWIT_H
[ "socialtraderdev@gmail.com" ]
socialtraderdev@gmail.com