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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8e98a5a42d688f11962af7b40b91770650b488a3 | bad36c1f43de268040144fa92771329f1c4b9028 | /1014.cpp | 5b68308fd043da415ca4ee335e0b8cab46239305 | [] | no_license | Rindonn/PAT | 9292d12f4128e9f34f802c90bc6a85be95344dbe | f2704a963f0cd42596d27bb9e698ba4e1b608a30 | refs/heads/master | 2023-06-22T20:14:40.124305 | 2018-05-30T14:16:43 | 2018-05-30T14:16:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,587 | cpp | /*
* @Author: 凛冬
* @Date: 2018-05-30
* @Last Modified by: 凛冬
* @Last Modified time: 2018-05-30
*/
#include <iostream>
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <cmath>
using namespace std;
int main(){
char str1[61];
char str2[61];
cin.getline(str1,61);
cin.getline(str2,61);
char str3[61];
char str4[61];
cin.getline(str3,61);
cin.getline(str4,61);
int a;
int count=0;
for(a=0;a<60;a++){
if(str1[a]>='A'&&str1[a]<='G'&&count==0)
{
if(str1[a]==str2[a])
{
switch(str1[a])
{
case 'A':cout<<"MON ";
break;
case 'B':cout<<"TUE ";
break;
case 'C':cout<<"WED ";
break;
case 'D':cout<<"THU ";
break;
case 'E':cout<<"FRI ";
break;
case 'F':cout<<"SAT ";
break;
case 'G':cout<<"SUN ";
break;
}
count++;
a++;
}
}
if((str1[a]>='A'&&str1[a]<='N'&&count==1)||(str1[a]>='0'&&str1[a]<='9'&&count==1))
{
if(str1[a]==str2[a])
{
switch(str1[a])
{
case '0':cout<<"00:";
break;
case '1':cout<<"01:";
break;
case '2':cout<<"02:";
break;
case '3':cout<<"03:";
break;
case '4':cout<<"04:";
break;
case '5':cout<<"05:";
break;
case '6':cout<<"06:";
break;
case '7':cout<<"07:";
break;
case '8':cout<<"08:";
break;
case '9':cout<<"09:";
break;
case 'A':cout<<"10:";
break;
case 'B':cout<<"11:";
break;
case 'C':cout<<"12:";
break;
case 'D':cout<<"13:";
break;
case 'E':cout<<"14:";
break;
case 'F':cout<<"15:";
break;
case 'G':cout<<"16:";
break;
case 'H':cout<<"17:";
break;
case 'I':cout<<"18:";
break;
case 'J':cout<<"19:";
break;
case 'K':cout<<"20:";
break;
case 'L':cout<<"21:";
break;
case 'M':cout<<"22:";
break;
case 'N':cout<<"23:";
break;
}
count++;
a++;
}
}
if(count==2)
{
break;
}
}
for(a=0;a<=59;a++){
if((str3[a]>='a'&&str3[a]<='z')||(str3[a]>='A'&&str3[a]<='Z'))
{
if(str3[a]==str4[a])
{
if(a<10){
cout<<"0";
cout<<a;
return 0;
}
else
{
cout<<a;
return 0;
}
}
}
}
return 0;
} | [
"384693801@qq.com"
] | 384693801@qq.com |
4396dc8c2c66d3857441a11be90566654d251b3d | b3439873c106d69b6ae8110c36bcd77264e8c5a7 | /server/Common/Packets/GCMissionList.cpp | dd56abc6dbb7ff20bcca8213cb90121454b5efdb | [] | no_license | cnsuhao/web-pap | b41356411dc8dad0e42a11e62a27a1b4336d91e2 | 7c9b1f49d9ba8d8e40f8fddae829c2e414ccfeca | refs/heads/master | 2021-05-28T01:01:18.122567 | 2013-11-19T06:49:41 | 2013-11-19T06:49:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,512 | cpp | #include "stdafx.h"
// GCMissionList.cpp
//
/////////////////////////////////////////////////////
#include "GCMissionList.h"
using namespace Packets;
BOOL GCMissionList::Read( SocketInputStream& iStream )
{
__ENTER_FUNCTION
iStream.Read( (CHAR*)(&m_ObjID), sizeof(m_ObjID));
iStream.Read( (CHAR*)(&m_uMissionListFlags), sizeof(m_uMissionListFlags) );
iStream.Read( (CHAR*)(&m_listMission), sizeof(_MISSION_LIST));
//BYTE i;
//for ( i = 0; i < MAX_CHAR_MISSION_NUM; i++ )
//{
// if ( m_uMissionListFlags & (0x00000001 << i) )
// {
// iStream.Read( (CHAR*)(&m_listMission.m_aMission[i]), sizeof(_OWN_MISSION));
// }
//}
return TRUE ;
__LEAVE_FUNCTION
return FALSE ;
}
BOOL GCMissionList::Write( SocketOutputStream& oStream )const
{
__ENTER_FUNCTION
oStream.Write( (CHAR*)(&m_ObjID), sizeof(m_ObjID));
oStream.Write( (CHAR*)(&m_uMissionListFlags), sizeof(m_uMissionListFlags) );
oStream.Write( (CHAR*)(&m_listMission), sizeof(_MISSION_LIST));
//BYTE i;
//for ( i = 0; i < MAX_CHAR_MISSION_NUM; i++ )
//{
// if ( m_uMissionListFlags & (0x00000001 << i) )
// {
// oStream.Write( (CHAR*)(&m_listMission.m_aMission[i]), sizeof(_OWN_MISSION));
// }
//}
return TRUE ;
__LEAVE_FUNCTION
return FALSE ;
}
UINT GCMissionList::Execute( Player* pPlayer )
{
__ENTER_FUNCTION
return GCMissionListHandler::Execute( this, pPlayer ) ;
__LEAVE_FUNCTION
return FALSE ;
}
| [
"viticm@126.com"
] | viticm@126.com |
08d10cdb86235d6198adf62e971e2a69918565f5 | 7ce3445a70b37f9dcdf3d5689348c7bd06e9dc15 | /Source/HowTo_AutoCamera/Mover.h | 990749fef0cc2f6679fb1f3444df3e7df59c8027 | [] | no_license | jpyepez/UE4AutoCamera | 98e1f0f926c0b123db512e630ba205d0bf467922 | 8a0da6308d7065d641287ca24efeadeb422309f9 | refs/heads/master | 2021-08-14T16:46:37.254546 | 2017-11-16T08:09:54 | 2017-11-16T08:09:54 | 110,413,818 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 538 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Mover.generated.h"
UCLASS()
class HOWTO_AUTOCAMERA_API AMover : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AMover();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
float RunningTime;
};
| [
"jpyepezimc@gmail.com"
] | jpyepezimc@gmail.com |
2405342dd22421410a376768b7164fcb07602e2e | c51febc209233a9160f41913d895415704d2391f | /library/ATF/LPSTYLESTRUCT.hpp | 03283a6d81654ef0f2113174c1208ed9b5110a14 | [
"MIT"
] | permissive | roussukke/Yorozuya | 81f81e5e759ecae02c793e65d6c3acc504091bc3 | d9a44592b0714da1aebf492b64fdcb3fa072afe5 | refs/heads/master | 2023-07-08T03:23:00.584855 | 2023-06-29T08:20:25 | 2023-06-29T08:20:25 | 463,330,454 | 0 | 0 | MIT | 2022-02-24T23:15:01 | 2022-02-24T23:15:00 | null | UTF-8 | C++ | false | false | 263 | hpp | // This file auto generated by plugin for ida pro. Generated code only for x64. Please, dont change manually
#pragma once
#include <common/common.h>
#include <tagSTYLESTRUCT.hpp>
START_ATF_NAMESPACE
typedef tagSTYLESTRUCT *LPSTYLESTRUCT;
END_ATF_NAMESPACE
| [
"b1ll.cipher@yandex.ru"
] | b1ll.cipher@yandex.ru |
45d6aeb574ee11cfd77bc5cc38ffab0eb912f52c | 117761fd24cb1ab05d581e88304beec24143e680 | /goblin/whattodo_menu.hpp | 66479575800375a02599bd3ae8fee05c2398dd3b | [] | no_license | NineDayGame/NineDayGame | 0d944bb1a17dfc1200331e32f2fcaa2fe422d8b4 | 2a30ed7a02a99d7789f54ed5848598a6f8d7c00d | refs/heads/master | 2021-01-01T18:55:06.919599 | 2011-02-28T05:40:26 | 2011-02-28T05:40:26 | 1,386,782 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 409 | hpp | #ifndef WHATTODO_MENU_HPP
#define WHATTODO_MENU_HPP
#include "inventory_menu.hpp"
#include "entity.hpp"
#include "item.hpp"
class WhatToDoMenu : public InventoryMenu
{
public:
typedef boost::shared_ptr<WhatToDoMenu> ShPtr;
WhatToDoMenu(GameState::ShPtr parent, Living::ShPtr player, int sx, int sy, int w, int h);
virtual ~WhatToDoMenu();
virtual void init(Entity::ShPtr e, Item::ShPtr i);
};
#endif
| [
"foxryan@gmail.com"
] | foxryan@gmail.com |
f1e5ed1460b4e9c860512677ab9ff9d8a91f50f5 | f7f70ce50ae5ee14771ae21c3d287797843764ca | /Source/Library/Language/Hlsl/Source/HlslLang.cpp | da382664379a547cdf0b80d4bcb68c317ea04555 | [
"MIT"
] | permissive | cschladetsch/KAI | b36757e52c0de072e87f2ba868cdee7fa69fe8de | c972934ce9254b881ede5be484f5d1ab93b7951e | refs/heads/master | 2023-03-04T07:34:53.945220 | 2023-02-24T17:28:01 | 2023-02-24T17:28:01 | 21,534,145 | 14 | 4 | null | 2017-02-28T02:12:34 | 2014-07-06T05:23:56 | C++ | UTF-8 | C++ | false | false | 1,066 | cpp | #include <fstream>
#include <KAI/Core/File.h>
#include "KAI/Executor/Executor.h"
#include "KAI/Language/Hlsl/HlslLang.h"
using namespace std;
KAI_BEGIN
void HlslLang::Print()
{
/*
cout << "Input--" << endl;
cout << lex->GetInput() << endl;
cout << "Lexer--" << endl;
lex->Print();
cout << "Parser--" << endl;
parse->Print();
cout << "Trans--" << endl;
cout << trans->Result() << endl;
*/
}
Pointer<Continuation> HlslLang::TranslateFile(const char *name, Structure st)
{
ifstream file(name, ios::binary);
if (!file)
return Object();
return Translate(ReadTextFile(name).c_str(), st);
}
Pointer<Continuation> HlslLang::Translate(const char *text, Structure st)
{
KAI_UNUSED_2(text, st);
return Object();
// trans = std::make_shared<Translator>(reg);
// trans->Translate(text);
//
// if (lex->Failed)
// Fail(lex->Error);
//
// if (parse->Failed)
// Fail(parse->Error);
//
// if (trans->Failed)
// Fail(trans->Error);
//
// return !Failed;
}
KAI_END
| [
"christian.schladetsch@gmail.com"
] | christian.schladetsch@gmail.com |
d73783707ff99907364094f0f38c71e8cbf6ebc9 | df256c2663bcd2a61fff9950759debd2760d0ce9 | /State/State/States/Stopped.h | da0e98d8aae570068c2252f2e662fe40efcda3cf | [
"BSD-2-Clause"
] | permissive | jayavardhanravi/DesignPatterns | d4adbb80c2b781affd531f8887c4634e35788353 | aa6a37790f447c7caf69c6a1a9c6107074309a03 | refs/heads/master | 2021-07-25T05:21:02.690532 | 2021-01-02T14:17:54 | 2021-01-02T14:17:54 | 233,955,558 | 15 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 307 | h | #pragma once
#include "RobotState.h"
#include "Ready.h"
#include "Shutdown.h"
class Stopped : public RobotState
{
public:
Stopped();
~Stopped();
bool StoppedRobot(Controller *);
bool ShutdownRobot(Controller *);
bool ReadyRobot(Controller *);
private:
std::unique_ptr<Stopped> state_ = nullptr;
};
| [
"8674552+jayavardhanravi@users.noreply.github.com"
] | 8674552+jayavardhanravi@users.noreply.github.com |
ddc24cb26e6f097cf6d581c59a702df127896e70 | ef9a782df42136ec09485cbdbfa8a56512c32530 | /branches/fasset2.3.2threads/src/livestock/diet.cpp | 2adab1ad5050de37ab708d7b2bec8632a6e6ca2d | [] | no_license | penghuz/main | c24ca5f2bf13b8cc1f483778e72ff6432577c83b | 26d9398309eeacbf24e3c5affbfb597be1cc8cd4 | refs/heads/master | 2020-04-22T15:59:50.432329 | 2017-11-23T10:30:22 | 2017-11-23T10:30:22 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,114 | cpp | /****************************************************************************\
$URL$
$LastChangedDate$
$LastChangedRevision$
$LastChangedBy$
\****************************************************************************/
// Class: diet
#include "../base/common.h"
#include "diet.h"
#include "../products/feedItem.h"
#include "../products/products.h"
#ifdef _STANDALONE
#include "../base/message.h"
#endif
// Functions for class diet
/**
* constructor
*/
diet::diet(const char * aName, const int aIndex, const base * aOwner)
: base(aName, aIndex, aOwner)
{
startDate = new bsTime();
normalfeedItemList = new cloneList <product>;
deficiencyfeedItemList= new cloneList <product>;
surplusfeedItemList= new cloneList <product>;
grazedItem = NULL;
housed = 0;
propRoughage = 0.0;
propGrazed = 0.0;
zeroGrazing=false;
}
/**
* clone
*/
diet* diet::clone() const
{
diet * aDiet = new diet();
aDiet->startDate=startDate->clone();
aDiet->normalfeedItemList=normalfeedItemList->clone();
aDiet->deficiencyfeedItemList=deficiencyfeedItemList->clone();
aDiet->surplusfeedItemList=surplusfeedItemList->clone();
aDiet->grazedItem = (feed_resource *) grazedItem->clone();
aDiet->housed = housed;
aDiet->zeroGrazing=zeroGrazing;
return aDiet;
}
/**
* destructor
*/
diet::~diet()
{
delete startDate;
if (normalfeedItemList) delete normalfeedItemList;
if (deficiencyfeedItemList) delete deficiencyfeedItemList;
if (surplusfeedItemList) delete surplusfeedItemList;
delete grazedItem;
}
/**
* Empty Class. Why do we have it?
*/
void diet::DailyUpdate()
{
}
/**
* Initialize diet from files
*/
void diet::ReadParameters(commonData * infile, bool isAutoFeed)
{
infile->setCritical(true);
autoFeed = isAutoFeed;
infile->FindSection(GetName(),GetIndex()); // find the correct place in the input file
int day,month;
int year = theTime[id].GetYear();
infile->FindItem("Day",&day);
infile->FindItem("Month",&month);
//input expected grazing intake (if appropriate)
infile->setCritical(false);
bool gotGrazing = false;
double grazing=0.0;
gotGrazing= infile->FindItem("Grazing",&grazing); //get amount DM grazed in kg
double grazingSFU=0.0;
if (!gotGrazing)
gotGrazing= infile->FindItem("GrazingSFU",&grazingSFU);
zeroGrazing=false;
infile->setCritical(true);
if (!gotGrazing)
{
infile->FindItem("propRoughage",&propRoughage);
gotGrazing= infile->FindItem("propGrazed",&propGrazed); //
if (propGrazed==-1)
zeroGrazing=true;
}
if (!gotGrazing)
theMessage[id]->FatalError("cattle diet: grazing amount cannot be input as both amount and SFUs");
if ((grazing>0.0)||(grazingSFU>0.0)|| (propGrazed>0.0) ||zeroGrazing)
{
int feedCode;
feedItem* aFeedItem;
string theItemName;
infile->setCritical(false);
feedCode=0;
infile->FindItem("FeedCode",&feedCode);
infile->FindItem("Item",&theItemName);
if ((feedCode==0)&&(theItemName==""))
theMessage[id]->FatalError("cattle diet: grazed feed type not defined by name or feed code");
if (feedCode>0)
aFeedItem = (feedItem*) theProducts[id]->GetProductElement(feedCode); //get default product info using feed code
else
aFeedItem = (feedItem*) theProducts[id]->GetProductElement(theItemName); //get default product info using name
grazedItem= new feed_resource(*aFeedItem);
grazedItem->SetObjType(feedItemObj);
if (autoFeed == true)
grazedItem->Setamount(-1.0); //will be overwritten later if autoFeed is true
else if (grazingSFU>0)
{
grazing = grazingSFU/aFeedItem->GetfeedUnitsPerItemUnit(); //convert to tonnes FW
grazedItem->Setamount(grazing);
}
else
grazedItem->Setamount(grazing);
grazedItem->SetIsSupplement(false);
infile->setCritical(true);
}
infile->FindItem("Housed",&housed);
startDate->SetTime(day, month, year);
string namestr;
char Indexstr[10];
sprintf(Indexstr,"(%d)",Index);
namestr=(string) GetName()+Indexstr+"."+"Normal.Supplement";
int first,num;
infile->setCritical(false);
if (!autoFeed)
infile->getSectionsNumbers(namestr,&first,&num); //count the number of supplements available in this period
else
{
first=0;
num=1;
}
infile->setCritical(true);
for(int inx=first;inx<=(first+num);inx++)
{
infile->FindSection(namestr.c_str(),inx); // find the correct place in the input file
normalfeedItemList->InsertLast(LoadFeedItem(infile,autoFeed)); //load feed items into the feed item list
}
infile->setCritical(false);
namestr=(string) GetName()+Indexstr+"."+"Deficiency.Supplement";
infile->getSectionsNumbers(namestr,&first,&num); //count the number of deficiency supplements
for(int inx=first;inx<=(first+num);inx++)
{
infile->FindSection(namestr.c_str(),inx); // find the correct place in the input file
deficiencyfeedItemList->InsertLast(LoadFeedItem(infile,autoFeed)); //load feed items into the feed item list
}
namestr=(string) GetName()+Indexstr+"."+"Surplus.Supplement";
infile->getSectionsNumbers( namestr,&first,&num); //count the number of surplus supplements
for(int inx=first;inx<=(first+num);inx++)
{
infile->FindSection(namestr.c_str(),inx); // find the correct place in the input file
surplusfeedItemList->InsertLast(LoadFeedItem(infile,autoFeed)); //load feed items into the feed item list
}
infile->setCritical(true);
}
/**
* Grazing or not
*/
bool diet::IsGrazing()
{
if (grazedItem)
{
if (grazedItem->GetAmount()>0.0)
return true;
else
return false;
}
else
return false;
};
/*
* Loads the amount of each feed, finds the information about feed composition and convert from feedItem to feed_resource
*/
feed_resource* diet::LoadFeedItem(commonData * infile,bool autoFeed)
{
feed_resource* feed_resourceClone=new feed_resource();
feedItem* aFeedItem;
double amount=-1.0;
string theItemName;
int feedCode=0;
double SFUamount=-1.0;
infile->setCritical(false);
infile->FindItem("Item",&theItemName);
infile->FindItem("Amount",&amount);
infile->FindItem("SFUamount",&SFUamount);
infile->FindItem("FeedCode",&feedCode);
infile->setCritical(true);
if ((SFUamount>0)&&(amount>0))
theMessage[id]->FatalError("cattle diet: feed amount cannot be input as both amount and SFUs");
if ((SFUamount==-1.0)&&(amount==-1.0)&&(!autoFeed))
theMessage[id]->FatalError("cattle diet: feed amount not specified as amount fresh weight or amount of SFUs");
if ((feedCode==0)&&(theItemName==""))
theMessage[id]->FatalError("cattle diet: feed type not defined by name or feed code");
if (feedCode>0)
aFeedItem = (feedItem*) theProducts[id]->GetProductElement(feedCode); //get default product info using feed code
else
aFeedItem = (feedItem*) theProducts[id]->GetProductElement(theItemName); //get default product info using name
if (!autoFeed)
{
if (SFUamount>0)
amount = SFUamount/aFeedItem->GetfeedUnitsPerItemUnit(); //convert to tonnes FW
else
amount /= (aFeedItem->GetdryMatter() * 1000.0);
}
else
amount = -1.0;
if ((amount>0.0)||(autoFeed))
{
feed_resourceClone = new feed_resource(*aFeedItem); // LEAK (bmp) !!!
feed_resourceClone->SetObjType(feedItemObj);
feed_resourceClone->Setamount(amount);
feed_resourceClone->SetIsSupplement(true);
}
else theMessage[id]->FatalError("cattle diet: feed amount cannot be zero");
feed_resourceClone->GotItAll();
return feed_resourceClone;
};
/*
* Get grazed feed required (kg DM/day)
*/
double diet::GetGrazingFeedRequirement(bool zeroGrazed)
{
double grazedFeedReq = 0.0;
if (grazedItem && (zeroGrazed==zeroGrazing))
grazedFeedReq=grazedItem->GetAmount() * grazedItem->GetdryMatter();
return grazedFeedReq;
};
void diet::ShowDiet(fstream * fs, bool header)
{
if (header)
{
*fs << "Date" << "\t";
if (grazedItem)
*fs << "Code" << "\t" << "DM" << "\t" << "FE" << "\t" << "ME" << "\t";
*fs << "housed" << "\t" << "propRoughage" << "\t" << "propGrazed" << "\t";
for (int i=0; i<normalfeedItemList->NumOfNodes();i++)
*fs << "Code" << "\t" << "DM" << "\t" << "FE" << "\t" << "ME" << "\t";
if (deficiencyfeedItemList->NumOfNodes()>0)
{
for (int i=0; i<deficiencyfeedItemList->NumOfNodes();i++)
*fs << "Code" << "\t" << "DM" << "\t" << "FE" << "\t" << "ME" << "\t";
}
if (surplusfeedItemList->NumOfNodes()>0)
{
for (int i=0; i<surplusfeedItemList->NumOfNodes();i++)
*fs << "Code" << "\t" << "DM" << "\t" << "FE" << "\t" << "ME" << "\t";
}
}
else
{
*fs << startDate->GetYear() << "-" << startDate->GetMonth() << "-" << startDate->GetDay() << "\t";
if (grazedItem)
{
*fs << grazedItem->GetCode()<< "\t";
*fs << 1000.0 * grazedItem->GetAmount()* grazedItem->GetdryMatter()<< "\t";
*fs << grazedItem->GetAmount() * grazedItem->GetfeedUnitsPerItemUnit()<< "\t";
*fs << grazedItem->GetAmount() * grazedItem->GetME()<< "\t";
}
else
*fs << "0" << "\t"<< "0.0" << "\t"<< "0.0" << "\t"<< "0.0" << "\t";
*fs << housed << "\t";
*fs << propRoughage << "\t";
*fs << propGrazed << "\t";
for (int i=0; i<normalfeedItemList->NumOfNodes();i++)
{
feedItem * aFeedItem= ((feedItem *)normalfeedItemList->ElementAtNumber(i));
*fs << aFeedItem->GetCode()<< "\t";
*fs << 1000.0 * aFeedItem->GetAmount()* aFeedItem->GetdryMatter()<< "\t";
*fs << aFeedItem->GetAmount() * aFeedItem->GetfeedUnitsPerItemUnit()<< "\t";
*fs << aFeedItem->GetAmount() * aFeedItem->GetME()<< "\t";
}
if (deficiencyfeedItemList->NumOfNodes()>0)
{
for (int i=0; i<deficiencyfeedItemList->NumOfNodes();i++)
{
feedItem * aFeedItem= ((feedItem *)deficiencyfeedItemList->ElementAtNumber(i));
*fs << aFeedItem->GetCode()<< "\t";
*fs << 1000.0 * aFeedItem->GetAmount()* aFeedItem->GetdryMatter()<< "\t";
*fs << aFeedItem->GetAmount() * aFeedItem->GetfeedUnitsPerItemUnit()<< "\t";
*fs << aFeedItem->GetAmount() * aFeedItem->GetME()<< "\t";
}
}
else
for (int i=0; i<2;i++)
*fs << "0" << "\t"<< "0.0" << "\t"<< "0.0" << "\t"<< "0.0" << "\t";
if (surplusfeedItemList->NumOfNodes()>0)
{
for (int i=0; i<surplusfeedItemList->NumOfNodes();i++)
{
feedItem * aFeedItem= ((feedItem *)surplusfeedItemList->ElementAtNumber(i));
*fs << aFeedItem->GetCode()<< "\t";
*fs << 1000.0 * aFeedItem->GetAmount()* aFeedItem->GetdryMatter()<< "\t";
*fs << aFeedItem->GetAmount() * aFeedItem->GetfeedUnitsPerItemUnit()<< "\t";
*fs << aFeedItem->GetAmount() * aFeedItem->GetME()<< "\t";
}
}
else
for (int i=0; i<2;i++)
*fs << "0" << "\t"<< "0.0" << "\t"<< "0.0" << "\t"<< "0.0" << "\t";
}
}
/**
* If normalfeedItemList and aList have the same item that item in normalfeedItemList's amount would be updated
*/
void diet::GetRoughageRequired(linkList <product> * aList, double numberOfAnimals)
{
// double amount;
for(int i=0;i<aList->NumOfNodes();i++)
{
product * aProduct = aList->ElementAtNumber(i);
for(int j=0;j<normalfeedItemList->NumOfNodes();j++)
{
product * aRequireProduct = normalfeedItemList->ElementAtNumber(j);
if (!((feedItem*) aProduct)->GetCode() == ((feedItem*) aRequireProduct)->GetCode())
aProduct->Setamount(aProduct->GetAmount()+numberOfAnimals*aRequireProduct->GetAmount());
}
}
};
/**
* return the amount of Silage multiplier by numberOfAnimals
*/
double diet::GetGrassSilageRequired(double numberOfAnimals)
{
double amount=0.0;
//product * aProduct;
for(int j=0;j<normalfeedItemList->NumOfNodes();j++)
{
product * aProduct = normalfeedItemList->ElementAtNumber(j);
if (((feedItem*) aProduct)->GetCode() == 565)
amount+=numberOfAnimals*aProduct->GetAmount();
}
return amount;
};
/*
* Returns winter silage requirement in tonnes DM
*/
double diet::GetSilageRequired(double numberOfAnimals, int startCode, int endCode)
{
double amount=0.0;
// product * aProduct;
for(int j=0;j<normalfeedItemList->NumOfNodes();j++)
{
feedItem * aProduct = ((feedItem*) normalfeedItemList->ElementAtNumber(j));
int code = aProduct->GetCode();
if ((code >= startCode) && (code <= endCode))
amount+=numberOfAnimals*aProduct->GetAmount() * aProduct->GetdryMatter();
}
return amount;
};
/**
* Empty all list
*/
void diet::ClearLists()
{
if (normalfeedItemList)
delete normalfeedItemList;
if (deficiencyfeedItemList)
delete deficiencyfeedItemList;
if (surplusfeedItemList)
delete surplusfeedItemList;
delete grazedItem;
}
/**
*
*/
void diet::CreateDefaultDiets(double differentiation)
{
feedItem *aConcFeed;
feedItem *aRoughFeed;
feedItem * afeedItem;
aRoughFeed = ((feedItem *) FindConservedRoughageFeed());
aConcFeed = ((feedItem *) FindConcentrateFeed());
// surplus feed list.
afeedItem = new feedItem(*aConcFeed);
afeedItem->SetObjType(feedItemObj);
afeedItem->Setamount((1-differentiation) *afeedItem->GetAmount());
surplusfeedItemList->InsertLast(afeedItem); //load feed items into the feed item list
afeedItem = new feedItem(*aRoughFeed);
afeedItem->SetObjType(feedItemObj);
surplusfeedItemList->InsertLast(afeedItem); //load feed items into the feed item list
// deficiency feed list.
afeedItem = new feedItem(*aConcFeed);
afeedItem->SetObjType(feedItemObj);
afeedItem->Setamount((1+differentiation)*afeedItem->GetAmount());
deficiencyfeedItemList->InsertLast(afeedItem); //load feed items into the feed item list
afeedItem = new feedItem(*aRoughFeed);
afeedItem->SetObjType(feedItemObj);
deficiencyfeedItemList->InsertLast(afeedItem); //load feed items into the feed item list
};
/**
* Find the first instance of roughage in normalfeedItemList
*/
product* diet::FindConservedRoughageFeed()
{
int j=0;
product * aProduct=new product();
bool gotRough=false;
while ((j<normalfeedItemList->NumOfNodes())&&(!gotRough))
{
aProduct = normalfeedItemList->ElementAtNumber(j);
if (((feedItem*) aProduct)->GetfeedCategory() == 2)
gotRough=true;
j++;
}
if (!gotRough)
theMessage[id]->FatalError("diet: FindConservedRoughageFeed - feed not found");
return aProduct;
};
/**
* Find the first instance of Concentrate in normalfeedItemList
*/
product* diet::FindConcentrateFeed()
{
int j=0;
product * aProduct=new product();
bool gotConc=false;
while ((j<normalfeedItemList->NumOfNodes())&&(!gotConc))
{
aProduct = normalfeedItemList->ElementAtNumber(j);
if (((feedItem*) aProduct)->GetfeedCategory() == 1)
gotConc=true;
j++;
}
if (!gotConc)
theMessage[id]->FatalError("diet: FindConcentrateFeed - feed not found");
return aProduct;
};
product* diet::FindGrazedFeed()
{
if (grazedItem)
return grazedItem;
else
return NULL;
};
| [
"sai@agro.au.dk"
] | sai@agro.au.dk |
c0864bed9a9481a969d190291af7e77a2cb01734 | de7e771699065ec21a340ada1060a3cf0bec3091 | /analysis/common/src/java/org/apache/lucene/analysis/hunspell/package-info.cpp | 8ea54be0e3e3535be39693ddbbc670a0e4557173 | [] | no_license | sraihan73/Lucene- | 0d7290bacba05c33b8d5762e0a2a30c1ec8cf110 | 1fe2b48428dcbd1feb3e10202ec991a5ca0d54f3 | refs/heads/master | 2020-03-31T07:23:46.505891 | 2018-12-08T14:57:54 | 2018-12-08T14:57:54 | 152,020,180 | 7 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 102 | cpp | using namespace std;
#include "package-info.h"
namespace org::apache::lucene::analysis::hunspell
{
} | [
"smamunr@fedora.localdomain"
] | smamunr@fedora.localdomain |
be67a21d6235a0baa8618541fea1228afe031a90 | 3ca14675ee14a7f327e452f5c9fb8c5211c67482 | /sources/Bomberman/ECS/Systems/RemovableSystem.hpp | e01476c5ff72f322555750c112cd3928d1164852 | [] | no_license | eliemoriceau/bomberman | 2d671a384eeeaf1b69fee46ba9ceacad18cd8bef | 5f798468810e1302ed8048ca6dc2bb8ef268eddb | refs/heads/main | 2023-08-13T20:21:10.369797 | 2021-09-17T08:00:37 | 2021-09-17T08:00:37 | 407,455,912 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 222 | hpp | /*
** EPITECH PROJECT, 2022
** Indie
** File description:
** Created by elie,
*/
#pragma once
#include "System.hpp"
namespace ECS {
class RemovableSystem : public System {
public:
void update();
};
} | [
"elie.moriceau@epitech.eu"
] | elie.moriceau@epitech.eu |
9c89aabf507dec9328e4a7a631a327e8a3e5d3c4 | bcfd3336ae1dcac5e6f3b9e2154caad199043b27 | /src/scp/QuorumSetUtils.h | 5822a94bfe51894962b2b7f52c179817378f53b7 | [
"MIT",
"BSD-3-Clause",
"BSL-1.0",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause"
] | permissive | acgchain/acg-core | 58ba9d4e0dd147c45a51b33017d75402cdce9531 | 098676521a3211ab702d5f473510dc07e60467e2 | refs/heads/master | 2020-07-26T11:57:58.634134 | 2019-10-08T03:39:28 | 2019-10-08T03:39:28 | 208,636,187 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 491 | h | // Copyright 2016 Stellar Development Foundation and contributors. Licensed
// under the Apache License, Version 2.0. See the COPYING file at the root
// of this distribution or at http://www.apache.org/licenses/LICENSE-2.0
#pragma once
#include "xdr/Stellar-SCP.h"
namespace acg
{
bool isQuorumSetSane(SCPQuorumSet const& qSet, bool extraChecks);
// normalize the quorum set, optionally removing idToRemove
void normalizeQSet(SCPQuorumSet& qSet, NodeID const* idToRemove = nullptr);
}
| [
"ubuntu@ip-172-31-20-103.ap-southeast-1.compute.internal"
] | ubuntu@ip-172-31-20-103.ap-southeast-1.compute.internal |
abf85193a0b8ab17b47dcd9685036b4bd5913912 | 8f98f3a6565d9eb31d03885b89a758bffafb9572 | /src/qt/transactiontablemodel.h | e144b9f393dc01a2cd36bb7ae605e7f3207c11dd | [
"MIT"
] | permissive | TeamEmpireCoin/EmpireCoin | 8167485f612950076f56828a816cfb52f35c4085 | 212b22821ad8ba0eec08aa9b460624f9937a92a5 | refs/heads/master | 2021-01-18T21:33:13.149110 | 2016-06-15T16:02:05 | 2016-06-15T16:02:05 | 47,073,059 | 2 | 2 | null | 2016-01-17T11:59:44 | 2015-11-29T17:30:40 | C++ | UTF-8 | C++ | false | false | 2,949 | h | // Copyright (c) 2011-2013 The EmpireCoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef TRANSACTIONTABLEMODEL_H
#define TRANSACTIONTABLEMODEL_H
#include <QAbstractTableModel>
#include <QStringList>
class CWallet;
class TransactionTablePriv;
class TransactionRecord;
class WalletModel;
/** UI model for the transaction table of a wallet.
*/
class TransactionTableModel : public QAbstractTableModel
{
Q_OBJECT
public:
explicit TransactionTableModel(CWallet* wallet, WalletModel *parent = 0);
~TransactionTableModel();
enum ColumnIndex {
Status = 0,
Date = 1,
Type = 2,
ToAddress = 3,
Amount = 4
};
/** Roles to get specific information from a transaction row.
These are independent of column.
*/
enum RoleIndex {
/** Type of transaction */
TypeRole = Qt::UserRole,
/** Date and time this transaction was created */
DateRole,
/** Long description (HTML format) */
LongDescriptionRole,
/** Address of transaction */
AddressRole,
/** Label of address related to transaction */
LabelRole,
/** Net amount of transaction */
AmountRole,
/** Unique identifier */
TxIDRole,
/** Is transaction confirmed? */
ConfirmedRole,
/** Formatted amount, without brackets when unconfirmed */
FormattedAmountRole
};
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
private:
CWallet* wallet;
WalletModel *walletModel;
QStringList columns;
TransactionTablePriv *priv;
int cachedNumBlocks;
QString lookupAddress(const std::string &address, bool tooltip) const;
QVariant addressColor(const TransactionRecord *wtx) const;
QString formatTxStatus(const TransactionRecord *wtx) const;
QString formatTxDate(const TransactionRecord *wtx) const;
QString formatTxType(const TransactionRecord *wtx) const;
QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const;
QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true) const;
QString formatTooltip(const TransactionRecord *rec) const;
QVariant txStatusDecoration(const TransactionRecord *wtx) const;
QVariant txAddressDecoration(const TransactionRecord *wtx) const;
public slots:
void updateTransaction(const QString &hash, int status);
void updateConfirmations();
void updateDisplayUnit();
friend class TransactionTablePriv;
};
#endif // TRANSACTIONTABLEMODEL_H
| [
"x.madisco@yandex.com"
] | x.madisco@yandex.com |
9b0b11dacca9a3e494d54eb95db6f9f07492f048 | bd1fea86d862456a2ec9f56d57f8948456d55ee6 | /000/079/948/CWE134_Uncontrolled_Format_String__char_environment_w32_vsnprintf_62a.cpp | d0acc296cfe9f246849435812fd4991f32387936 | [] | no_license | CU-0xff/juliet-cpp | d62b8485104d8a9160f29213368324c946f38274 | d8586a217bc94cbcfeeec5d39b12d02e9c6045a2 | refs/heads/master | 2021-03-07T15:44:19.446957 | 2020-03-10T12:45:40 | 2020-03-10T12:45:40 | 246,275,244 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,444 | cpp | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE134_Uncontrolled_Format_String__char_environment_w32_vsnprintf_62a.cpp
Label Definition File: CWE134_Uncontrolled_Format_String.vasinks.label.xml
Template File: sources-vasinks-62a.tmpl.cpp
*/
/*
* @description
* CWE: 134 Uncontrolled Format String
* BadSource: environment Read input from an environment variable
* GoodSource: Copy a fixed string into data
* Sinks: w32_vsnprintf
* GoodSink: vsnprintf with a format string
* BadSink : vsnprintf without a format string
* Flow Variant: 62 Data flow: data flows using a C++ reference from one function to another in different source files
*
* */
#include <stdarg.h>
#include "std_testcase.h"
#ifndef _WIN32
#include <wchar.h>
#endif
namespace CWE134_Uncontrolled_Format_String__char_environment_w32_vsnprintf_62
{
#ifndef OMITBAD
/* bad function declaration */
void badSource(char * &data);
static void badVaSink(char * data, ...)
{
{
char dest[100] = "";
va_list args;
va_start(args, data);
/* POTENTIAL FLAW: Do not specify the format allowing a possible format string vulnerability */
vsnprintf(dest, 100-1, data, args);
va_end(args);
printLine(dest);
}
}
void bad()
{
char * data;
char dataBuffer[100] = "";
data = dataBuffer;
badSource(data);
badVaSink(data, data);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
void goodG2BSource(char * &data);
static void goodG2BVaSink(char * data, ...)
{
{
char dest[100] = "";
va_list args;
va_start(args, data);
/* POTENTIAL FLAW: Do not specify the format allowing a possible format string vulnerability */
vsnprintf(dest, 100-1, data, args);
va_end(args);
printLine(dest);
}
}
static void goodG2B()
{
char * data;
char dataBuffer[100] = "";
data = dataBuffer;
goodG2BSource(data);
goodG2BVaSink(data, data);
}
/* goodB2G uses the BadSource with the GoodSink */
void goodB2GSource(char * &data);
static void goodB2GVaSink(char * data, ...)
{
{
char dest[100] = "";
va_list args;
va_start(args, data);
/* FIX: Specify the format disallowing a format string vulnerability */
vsnprintf(dest, 100-1, "%s", args);
va_end(args);
printLine(dest);
}
}
static void goodB2G()
{
char * data;
char dataBuffer[100] = "";
data = dataBuffer;
goodB2GSource(data);
goodB2GVaSink(data, data);
}
void good()
{
goodG2B();
goodB2G();
}
#endif /* OMITGOOD */
} /* close namespace */
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
using namespace CWE134_Uncontrolled_Format_String__char_environment_w32_vsnprintf_62; /* so that we can use good and bad easily */
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
| [
"frank@fischer.com.mt"
] | frank@fischer.com.mt |
5551aa001ffe82f1b3dc6afaecad28290243ca5d | 3ff1fe3888e34cd3576d91319bf0f08ca955940f | /es/src/v20180416/model/LogstashPipelineInfo.cpp | fbf2babab50df20f07ad8bf2f8c133922d40868e | [
"Apache-2.0"
] | permissive | TencentCloud/tencentcloud-sdk-cpp | 9f5df8220eaaf72f7eaee07b2ede94f89313651f | 42a76b812b81d1b52ec6a217fafc8faa135e06ca | refs/heads/master | 2023-08-30T03:22:45.269556 | 2023-08-30T00:45:39 | 2023-08-30T00:45:39 | 188,991,963 | 55 | 37 | Apache-2.0 | 2023-08-17T03:13:20 | 2019-05-28T08:56:08 | C++ | UTF-8 | C++ | false | false | 11,360 | cpp | /*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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 <tencentcloud/es/v20180416/model/LogstashPipelineInfo.h>
using TencentCloud::CoreInternalOutcome;
using namespace TencentCloud::Es::V20180416::Model;
using namespace std;
LogstashPipelineInfo::LogstashPipelineInfo() :
m_pipelineIdHasBeenSet(false),
m_pipelineDescHasBeenSet(false),
m_configHasBeenSet(false),
m_statusHasBeenSet(false),
m_workersHasBeenSet(false),
m_batchSizeHasBeenSet(false),
m_batchDelayHasBeenSet(false),
m_queueTypeHasBeenSet(false),
m_queueMaxBytesHasBeenSet(false),
m_queueCheckPointWritesHasBeenSet(false)
{
}
CoreInternalOutcome LogstashPipelineInfo::Deserialize(const rapidjson::Value &value)
{
string requestId = "";
if (value.HasMember("PipelineId") && !value["PipelineId"].IsNull())
{
if (!value["PipelineId"].IsString())
{
return CoreInternalOutcome(Core::Error("response `LogstashPipelineInfo.PipelineId` IsString=false incorrectly").SetRequestId(requestId));
}
m_pipelineId = string(value["PipelineId"].GetString());
m_pipelineIdHasBeenSet = true;
}
if (value.HasMember("PipelineDesc") && !value["PipelineDesc"].IsNull())
{
if (!value["PipelineDesc"].IsString())
{
return CoreInternalOutcome(Core::Error("response `LogstashPipelineInfo.PipelineDesc` IsString=false incorrectly").SetRequestId(requestId));
}
m_pipelineDesc = string(value["PipelineDesc"].GetString());
m_pipelineDescHasBeenSet = true;
}
if (value.HasMember("Config") && !value["Config"].IsNull())
{
if (!value["Config"].IsString())
{
return CoreInternalOutcome(Core::Error("response `LogstashPipelineInfo.Config` IsString=false incorrectly").SetRequestId(requestId));
}
m_config = string(value["Config"].GetString());
m_configHasBeenSet = true;
}
if (value.HasMember("Status") && !value["Status"].IsNull())
{
if (!value["Status"].IsInt64())
{
return CoreInternalOutcome(Core::Error("response `LogstashPipelineInfo.Status` IsInt64=false incorrectly").SetRequestId(requestId));
}
m_status = value["Status"].GetInt64();
m_statusHasBeenSet = true;
}
if (value.HasMember("Workers") && !value["Workers"].IsNull())
{
if (!value["Workers"].IsUint64())
{
return CoreInternalOutcome(Core::Error("response `LogstashPipelineInfo.Workers` IsUint64=false incorrectly").SetRequestId(requestId));
}
m_workers = value["Workers"].GetUint64();
m_workersHasBeenSet = true;
}
if (value.HasMember("BatchSize") && !value["BatchSize"].IsNull())
{
if (!value["BatchSize"].IsUint64())
{
return CoreInternalOutcome(Core::Error("response `LogstashPipelineInfo.BatchSize` IsUint64=false incorrectly").SetRequestId(requestId));
}
m_batchSize = value["BatchSize"].GetUint64();
m_batchSizeHasBeenSet = true;
}
if (value.HasMember("BatchDelay") && !value["BatchDelay"].IsNull())
{
if (!value["BatchDelay"].IsUint64())
{
return CoreInternalOutcome(Core::Error("response `LogstashPipelineInfo.BatchDelay` IsUint64=false incorrectly").SetRequestId(requestId));
}
m_batchDelay = value["BatchDelay"].GetUint64();
m_batchDelayHasBeenSet = true;
}
if (value.HasMember("QueueType") && !value["QueueType"].IsNull())
{
if (!value["QueueType"].IsString())
{
return CoreInternalOutcome(Core::Error("response `LogstashPipelineInfo.QueueType` IsString=false incorrectly").SetRequestId(requestId));
}
m_queueType = string(value["QueueType"].GetString());
m_queueTypeHasBeenSet = true;
}
if (value.HasMember("QueueMaxBytes") && !value["QueueMaxBytes"].IsNull())
{
if (!value["QueueMaxBytes"].IsString())
{
return CoreInternalOutcome(Core::Error("response `LogstashPipelineInfo.QueueMaxBytes` IsString=false incorrectly").SetRequestId(requestId));
}
m_queueMaxBytes = string(value["QueueMaxBytes"].GetString());
m_queueMaxBytesHasBeenSet = true;
}
if (value.HasMember("QueueCheckPointWrites") && !value["QueueCheckPointWrites"].IsNull())
{
if (!value["QueueCheckPointWrites"].IsUint64())
{
return CoreInternalOutcome(Core::Error("response `LogstashPipelineInfo.QueueCheckPointWrites` IsUint64=false incorrectly").SetRequestId(requestId));
}
m_queueCheckPointWrites = value["QueueCheckPointWrites"].GetUint64();
m_queueCheckPointWritesHasBeenSet = true;
}
return CoreInternalOutcome(true);
}
void LogstashPipelineInfo::ToJsonObject(rapidjson::Value &value, rapidjson::Document::AllocatorType& allocator) const
{
if (m_pipelineIdHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "PipelineId";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(m_pipelineId.c_str(), allocator).Move(), allocator);
}
if (m_pipelineDescHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "PipelineDesc";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(m_pipelineDesc.c_str(), allocator).Move(), allocator);
}
if (m_configHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "Config";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(m_config.c_str(), allocator).Move(), allocator);
}
if (m_statusHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "Status";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, m_status, allocator);
}
if (m_workersHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "Workers";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, m_workers, allocator);
}
if (m_batchSizeHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "BatchSize";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, m_batchSize, allocator);
}
if (m_batchDelayHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "BatchDelay";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, m_batchDelay, allocator);
}
if (m_queueTypeHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "QueueType";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(m_queueType.c_str(), allocator).Move(), allocator);
}
if (m_queueMaxBytesHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "QueueMaxBytes";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(m_queueMaxBytes.c_str(), allocator).Move(), allocator);
}
if (m_queueCheckPointWritesHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "QueueCheckPointWrites";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, m_queueCheckPointWrites, allocator);
}
}
string LogstashPipelineInfo::GetPipelineId() const
{
return m_pipelineId;
}
void LogstashPipelineInfo::SetPipelineId(const string& _pipelineId)
{
m_pipelineId = _pipelineId;
m_pipelineIdHasBeenSet = true;
}
bool LogstashPipelineInfo::PipelineIdHasBeenSet() const
{
return m_pipelineIdHasBeenSet;
}
string LogstashPipelineInfo::GetPipelineDesc() const
{
return m_pipelineDesc;
}
void LogstashPipelineInfo::SetPipelineDesc(const string& _pipelineDesc)
{
m_pipelineDesc = _pipelineDesc;
m_pipelineDescHasBeenSet = true;
}
bool LogstashPipelineInfo::PipelineDescHasBeenSet() const
{
return m_pipelineDescHasBeenSet;
}
string LogstashPipelineInfo::GetConfig() const
{
return m_config;
}
void LogstashPipelineInfo::SetConfig(const string& _config)
{
m_config = _config;
m_configHasBeenSet = true;
}
bool LogstashPipelineInfo::ConfigHasBeenSet() const
{
return m_configHasBeenSet;
}
int64_t LogstashPipelineInfo::GetStatus() const
{
return m_status;
}
void LogstashPipelineInfo::SetStatus(const int64_t& _status)
{
m_status = _status;
m_statusHasBeenSet = true;
}
bool LogstashPipelineInfo::StatusHasBeenSet() const
{
return m_statusHasBeenSet;
}
uint64_t LogstashPipelineInfo::GetWorkers() const
{
return m_workers;
}
void LogstashPipelineInfo::SetWorkers(const uint64_t& _workers)
{
m_workers = _workers;
m_workersHasBeenSet = true;
}
bool LogstashPipelineInfo::WorkersHasBeenSet() const
{
return m_workersHasBeenSet;
}
uint64_t LogstashPipelineInfo::GetBatchSize() const
{
return m_batchSize;
}
void LogstashPipelineInfo::SetBatchSize(const uint64_t& _batchSize)
{
m_batchSize = _batchSize;
m_batchSizeHasBeenSet = true;
}
bool LogstashPipelineInfo::BatchSizeHasBeenSet() const
{
return m_batchSizeHasBeenSet;
}
uint64_t LogstashPipelineInfo::GetBatchDelay() const
{
return m_batchDelay;
}
void LogstashPipelineInfo::SetBatchDelay(const uint64_t& _batchDelay)
{
m_batchDelay = _batchDelay;
m_batchDelayHasBeenSet = true;
}
bool LogstashPipelineInfo::BatchDelayHasBeenSet() const
{
return m_batchDelayHasBeenSet;
}
string LogstashPipelineInfo::GetQueueType() const
{
return m_queueType;
}
void LogstashPipelineInfo::SetQueueType(const string& _queueType)
{
m_queueType = _queueType;
m_queueTypeHasBeenSet = true;
}
bool LogstashPipelineInfo::QueueTypeHasBeenSet() const
{
return m_queueTypeHasBeenSet;
}
string LogstashPipelineInfo::GetQueueMaxBytes() const
{
return m_queueMaxBytes;
}
void LogstashPipelineInfo::SetQueueMaxBytes(const string& _queueMaxBytes)
{
m_queueMaxBytes = _queueMaxBytes;
m_queueMaxBytesHasBeenSet = true;
}
bool LogstashPipelineInfo::QueueMaxBytesHasBeenSet() const
{
return m_queueMaxBytesHasBeenSet;
}
uint64_t LogstashPipelineInfo::GetQueueCheckPointWrites() const
{
return m_queueCheckPointWrites;
}
void LogstashPipelineInfo::SetQueueCheckPointWrites(const uint64_t& _queueCheckPointWrites)
{
m_queueCheckPointWrites = _queueCheckPointWrites;
m_queueCheckPointWritesHasBeenSet = true;
}
bool LogstashPipelineInfo::QueueCheckPointWritesHasBeenSet() const
{
return m_queueCheckPointWritesHasBeenSet;
}
| [
"tencentcloudapi@tencent.com"
] | tencentcloudapi@tencent.com |
bbdc4fdcd3fcae84315a8f1b37567cd9b91bec50 | 48dd7abadcdad9dee7d944c669131ffceaaa457a | /ImageProcessing/INIT/gamma_correct.cpp | bf70f42cd651092db4637c4808117fdab63f4189 | [] | no_license | mattzen/cppRepos | 1160602bc627eaaff33e576f4d4e726d8aeb387f | 8d4c6ad4417cb7978fefffff6426e5be102dae5a | refs/heads/master | 2023-08-02T15:55:17.624108 | 2019-11-18T03:15:40 | 2019-11-18T03:15:40 | 222,325,763 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,619 | cpp |
// ================================================================
// gamma_correct.c - gamma correct.
// Written by Mateusz Zmijewski
// =====================================================================
#include "IP.h"
using namespace std;
// function prototype
void gamma_correct(imageP, double, imageP);
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// main:
//
int
main(int argc, char** argv)
{
double gamma;
imageP I1, I2;
// error checking: proper usage
if(argc != 4) {
cerr << "Usage: gamma_correct infile number outfile\n";
exit(1);
}
// read input image (I1) and reserve space for output (I2)
I1 = IP_readImage(argv[1]);
I2 = NEWIMAGE;
// read gamma
gamma = atoi(argv[2]);
//apply function
gamma_correct(I1,gamma,I2);
//save new image into I2
IP_saveImage(I2,argv[3]);
// free up image structures/memory
IP_freeImage(I1);
IP_freeImage(I2);
return 1;
}
//qrtz:
void
gamma_correct(imageP I1, double gamma,imageP I2)
{
int i, total;
uchar *in, *out, lut[256];
// total number of pixels in image
total = I1->width * I1->height;
// init I2 dimensions and buffer
I2->width = I1->width;
I2->height = I1->height;
I2->image = (uchar *) malloc(total);
if(I2->image == NULL) {
cerr << "thr: Insufficient memory\n";
exit(1);
}
// init lookup table
for(i=0; i<256 ; i++) {
lut[i] = 256*pow((double)i/256,1.0/gamma);
}
// visit all input pixels and apply lut to threshold
in = I1->image; // input image buffer
out = I2->image; // output image buffer
for(i=0; i<total; i++) out[i] = lut[ in[i] ];
}
| [
"mattzy90@hotmail.com"
] | mattzy90@hotmail.com |
57ef691fa29cd28aa8d52fb267e8a766b8cb87b9 | fc48cd25cd7a6a1061a15826c4d5502bee88fe2a | /MyDungreed/MyDungreed/NormalEffect.cpp | 87ca1383a06cf8fdc3bee84d38464c0ca350b5ec | [] | no_license | Daruria/CopyProject | 9e3b5ba0f607930b6f58104e9eb52c4f04e2f98f | 672bc7c90aff617d2aa5f087e77f30129565d9a0 | refs/heads/master | 2022-11-20T12:19:03.801310 | 2020-07-26T17:02:55 | 2020-07-26T17:02:55 | 282,668,688 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,767 | cpp | #include "stdafx.h"
#include "NormalEffect.h"
#include "ScrollManager.h"
CNormalEffect::CNormalEffect():
m_fAngle(0.f),
m_fSpeed(0.f),
m_iFrame(0),
m_iMaxFrame(0),
m_dwFrameTime(0),
m_dwFrameMaxTime(0),
m_strKey("")
{
}
CNormalEffect::~CNormalEffect()
{
Release();
}
void CNormalEffect::Initialize()
{
m_dwFrameTime = GetTickCount();
m_dwFrameMaxTime = 100;
m_iFrame = 0;
m_bLife = true;
}
int CNormalEffect::Update()
{
if (m_iMaxFrame == 1)
{
if (m_dwFrameTime + m_dwFrameMaxTime < GetTickCount())
m_bLife = false;
return 0;
}
if (m_dwFrameTime + m_dwFrameMaxTime < GetTickCount())
{
m_iFrame++;
if (m_iFrame >= m_iMaxFrame) m_bLife = false;
m_dwFrameTime = GetTickCount();
}
m_tInfo.fx += cosf(m_fAngle) * m_fSpeed;
m_tInfo.fy += sinf(m_fAngle) * m_fSpeed;
return 0;
}
void CNormalEffect::LateUpdate()
{
}
void CNormalEffect::Render(HDC hDC)
{
HDC hMemDC = FIND_BITMAP_DC(m_strKey);
POSITION tPos = CScrollManager::WorldToScreen(m_tInfo);
if (tPos.fx + m_tInfo.icx / 2 < 0 || tPos.fx - m_tInfo.icx / 2 > WINCX)
return;
if (tPos.fy + m_tInfo.icy / 2 < 0 || tPos.fy - m_tInfo.icy / 2 > WINCY)
return;
SIZE tSize = GET_BITMAP_SIZE(m_strKey);
BOOL bRender = TRUE;
if (hMemDC)
bRender = GdiTransparentBlt(hDC,
static_cast<int>(tPos.fx - m_tInfo.icx * m_fRatio / 2),
static_cast<int>(tPos.fy - m_tInfo.icy * m_fRatio / 2),
static_cast<int>(m_tInfo.icx * m_fRatio),
static_cast<int>(m_tInfo.icy * m_fRatio),
hMemDC,
m_tInfo.icx * m_iFrame, 0, m_tInfo.icx, m_tInfo.icy, RGB(255, 0, 255));
else
CAN_NOT_FOUND_BITMAP(hDC, static_cast<int>(tPos.fx - m_tInfo.icx / 2), static_cast<int>(tPos.fy - m_tInfo.icy / 2), m_tInfo.icx, m_tInfo.icy);
int iA = 0;
}
void CNormalEffect::Release()
{
}
| [
"56038721+Daruria@users.noreply.github.com"
] | 56038721+Daruria@users.noreply.github.com |
5f3063060609f5d2732ecb783ff5c70d1b8918dc | 2bf7fa88e9db79ad96fc62f9dda8d586efb1cc5b | /navigation/ca_safety_controller/src/nodelet.cpp | 6f813311882ba463a9c1ce09156558c614f8ee4a | [] | permissive | ivanpauno/create_autonomy | 3111556667317f077d506c66a2d7d3f31373f409 | 7c3810761d12f064f15459458529ec20ff28f89d | refs/heads/kinetic-devel | 2021-07-06T02:51:07.138626 | 2019-11-08T13:24:05 | 2019-11-08T13:24:05 | 210,257,141 | 0 | 0 | BSD-3-Clause | 2019-11-27T20:06:04 | 2019-09-23T03:29:23 | C++ | UTF-8 | C++ | false | false | 3,634 | cpp | /*
* Copyright (c) 2012, Yujin Robot.
* 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 Yujin Robot 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.
*/
/**
* @file /ca_safety_controller/src/nodelet.cpp
*
* @brief Implementation for Create's safety controller nodelet
*
* @author Marcus Liebhardt, Yujin Robot
*
**/
/*****************************************************************************
** Includes
*****************************************************************************/
#include <nodelet/nodelet.h>
#include <pluginlib/class_list_macros.h>
#include <ecl/threads/thread.hpp>
#include "ca_safety_controller/safety_controller.hpp"
namespace ca
{
class SafetyControllerNodelet : public nodelet::Nodelet
{
public:
SafetyControllerNodelet() : shutdown_requested_(false) { };
~SafetyControllerNodelet()
{
NODELET_DEBUG_STREAM("Waiting for update thread to finish.");
shutdown_requested_ = true;
update_thread_.join();
}
virtual void onInit()
{
ros::NodeHandle nh = this->getPrivateNodeHandle();
// resolve node(let) name
std::string name = nh.getUnresolvedNamespace();
int pos = name.find_last_of('/');
name = name.substr(pos + 1);
NODELET_INFO_STREAM("Initialising nodelet... [" << name << "]");
controller_.reset(new SafetyController(nh, name));
if (controller_->init())
{
NODELET_INFO_STREAM("Create initialised. Spinning up update thread ... [" << name << "]");
update_thread_.start(&SafetyControllerNodelet::update, *this);
NODELET_INFO_STREAM("Nodelet initialised. [" << name << "]");
}
else
{
NODELET_ERROR_STREAM("Couldn't initialise nodelet! Please restart. [" << name << "]");
}
}
private:
void update()
{
ros::Rate spin_rate(10);
controller_->enable(); // enable the controller when loading the nodelet
while (! shutdown_requested_ && ros::ok())
{
controller_->spin();
spin_rate.sleep();
}
}
boost::shared_ptr<SafetyController> controller_;
ecl::Thread update_thread_;
bool shutdown_requested_;
};
} // namespace ca
PLUGINLIB_EXPORT_CLASS(ca::SafetyControllerNodelet,
nodelet::Nodelet);
| [
"emiliano_borghi@hotmail.com"
] | emiliano_borghi@hotmail.com |
7aad8fcda24f6040df002e45e623290f7886cba9 | 30b8561243cff67f758633327004cb378e5c5cef | /source/include/NGE/Geometry/Basic/Basic.hpp | 6154ba79c046e14d0cc74a363b5f4e7576e6aa6b | [] | no_license | tkubicz/ngengine | 56a7235de0c799f541d47841380da6fd90d3abed | 75413c8b77587e5ec8f03164fa9b5dcd7697c0c6 | refs/heads/master | 2021-01-12T06:02:57.202296 | 2016-06-15T16:42:43 | 2016-06-15T16:42:43 | 77,282,542 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,632 | hpp | /*
* File: Basic.hpp
* Author: tku
*
* Created on 3 listopad 2013, 04:32
*/
#ifndef BASIC_HPP
#define BASIC_HPP
#include "NGE/Geometry/Mesh.hpp"
namespace NGE {
namespace Geometry {
namespace Basic {
class Basic : public Geometry::Mesh {
public:
/**
* Metoda inicjująca obiekt.
* Metoda inicjuje obiekt tzn. wywołuje metody InitializeGeometry(), InitializeVBO() i InitializeVBA().
* @return true - jeżeli wszystko się powiodło, w przeciwnym razie false.
*/
virtual bool Initialize() = 0;
/**
* Metoda aktualizująca obiekt.
* @param deltaTime
*/
virtual void Update(float deltaTime) = 0;
/**
* Metoda renderująca obiekt
*/
virtual void Render() = 0;
protected:
/**
* Metoda inicjująca geometrię.
* Uzupełnia wektory wierzchołków, tekstur, wektorów normalnych, indeksów i kolorów.
* @return true - jeżeli wszystko się powiodło, w przeciwnym razie false.
*/
virtual bool InitializeGeometry() = 0;
/**
* Metoda inicjująca Vertex Buffer Objects.
* Metoda generująca bufory i wypełniająca je danymi.
* @return true - jeżeli wszystko się powiodło, w przeciwnym razie false.
*/
virtual bool InitializeVBO() = 0;
/**
* Metoda inicjująca Vertex Buffer Arrays.
* Metoda generuje VBA i przypisuje do nich bufory obiektów wygenerowane przy pomocy
* metody InitializeVBO().
* @return true - jeżeli wszystko się powiodło, w przeciwnym razie false.
*/
virtual bool InitializeVBA() = 0;
};
}
}
}
#endif /* BASIC_HPP */
| [
"tymoteusz.kubicz@gmail.com"
] | tymoteusz.kubicz@gmail.com |
aacbd23d4cb7a74eca51fed034bdab4cfc150173 | b0b943b56c27f952926e3e164bd2c97854970230 | /MFCShowVideoTest/VideoInfo.h | c8a7565f27e770e7253a1ca5955121e4ea86d4f1 | [] | no_license | 1219797100/MFCShowVideoTest | 6c10478af5f4d895540a22f7e1cc8d806a249880 | f3c3b9981e06c1a1f546f573482920bc5f353300 | refs/heads/master | 2020-05-15T03:46:55.957102 | 2019-04-18T11:19:59 | 2019-04-18T11:19:59 | 182,073,175 | 1 | 0 | null | 2019-04-18T11:12:43 | 2019-04-18T11:12:43 | null | UTF-8 | C++ | false | false | 322 | h | #pragma once
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#include "CvvImage.h"
class CVideoInfo
{
public:
CvCapture* m_pCapture;
IplImage* m_pFrameImage;
char s_Pictrldir[200];
double m_FrameWidth;
double m_FrameHeight;
public:
CVideoInfo(void);
public:
~CVideoInfo(void);
};
| [
"cqswzqcj@163.com"
] | cqswzqcj@163.com |
929359b8bff4603c7643431549d54cf08f291ee7 | 7c5d7fb6a64df1a118a64bdf6087ecf395a3a722 | /data/russia-team-f/sources/105-f-8.cpp | 2fe1d3a68d0dbb98a5f8dcfd143b23e10d0883d8 | [] | no_license | alexhein189/code-plagiarism-detector | e66df71c46cc5043b6825ef76a940b658c0e5015 | 68d21639d4b37bb2c801befe6f7ce0007d7eccc5 | refs/heads/master | 2023-03-18T06:02:45.508614 | 2016-05-04T14:29:57 | 2016-05-04T14:54:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,504 | cpp | #include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
using namespace std;
typedef long double ld;
const int maxN = 5000;
const ld Pi = atan(1.0) * 4;
int n, m;
bool Less(ld a, ld b)
{
return (b - a > 1e-13);
}
bool Gr(ld a, ld b)
{
return Less(b, a);
}
bool Eq(ld a, ld b)
{
return !Less(a, b) && !Less(b, a);
}
bool GrOrEq (ld a, ld b)
{
return Gr(a, b) || Eq(a, b);
}
ld sqr (ld a)
{
return a * a;
}
ld myAbs (ld a)
{
if (Eq(a, 0))
return 0;
if (Less(a, 0))
return -a;
return a;
}
ld mySqrt (ld a)
{
if (Eq(a, 0))
return 0;
return sqrt(a);
}
struct point
{
ld x, y;
point () {}
point (ld x_, ld y_)
{
x = x_;
y = y_;
}
void scan ()
{
cin >> x >> y;
}
void print()
{
cout << x << " " << y << "\n";
}
ld vect (point a)
{
return x * a.y - y * a.x;
}
ld scal (point a)
{
return x * a.x + y * a.y;
}
point operator - (point a)
{
return point (x - a.x, y - a.y);
}
point operator + (point a)
{
return point (x + a.x, y + a.y);
}
point operator * (ld a)
{
return point (x * a, y * a);
}
ld len()
{
return mySqrt(sqr(x) + sqr(y));
}
point ort()
{
return point (-y, x);
}
point norm()
{
ld l = len();
return point(x / l, y / l);
}
bool equal (point a)
{
return (Eq(x - a.x, 0) && Eq(y - a.y, 0));
}
};
bool intersectLineWithCircle (point A, point a, point O, ld r, point *P1, point *P2)
{
ld hlen = myAbs(a.vect(O - A) / a.len());
point h = a.norm() * a.norm().scal(O - A);
point H = A + h;
if (Less(r, hlen))
return false;
ld len = mySqrt(sqr(r) - sqr(hlen));
*P1 = H + (a.norm() * len);
*P2 = H - (a.norm() * len);
return true;
}
bool inSegment (point P, point A, point B)
{
if (!Eq((B - A).vect(P - A), 0))
return false;
if (GrOrEq((B - A).scal(P - A), 0) && GrOrEq((A - B).scal(P - B), 0))
return true;
return false;
}
int intersectSegmentWithCircle(point A, point B, point O, ld r, point *P1, point *P2)
{
int cnt = 0;
if (!intersectLineWithCircle(A, (B - A), O, r, P1, P2))
return 0;
if (inSegment(*P1, A, B))
cnt++;
if (inSegment(*P2, A, B))
{
if (cnt == 0)
swap(*P1, *P2);
cnt++;
}
return cnt;
}
point A[maxN], X;
point B[maxN];
int ind;
int main()
{
freopen("polygon.in", "r", stdin);
freopen("polygon.out", "w", stdout);
cout << fixed << setprecision(10);
cin >> n;
for (int i = 0; i < n; i++)
A[i].scan();
cin >> m;
for (int i = 0; i < m; i++)
{
ind = 0;
X.scan();
for (int j = 0; j < n; j++)
{
if (A[j].equal(A[(j + 1) % n]))
continue;
point P1, P2;
int cnt = intersectSegmentWithCircle(A[j], A[(j + 1) % n], A[0], (X - A[0]).len(), &P1, &P2);
if (cnt > 0)
{
B[ind++] = (P1 - A[0]);
}
if (cnt == 2)
{
B[ind++] = (P2 - A[0]);
}
}
X = X - A[0];
ld ans1 = 1000, ans2 = 0;
for (int j = 0; j < ind; j++)
{
ld angle = atan2(X.vect(B[j]), X.scal(B[j]));
if (Less(angle, 0))
angle += 2 * Pi;
if (angle < ans1)
ans1 = angle;
if (angle > ans2)
ans2 = angle;
}
if (ind == 0)
{
ans1 = 2 * Pi;
ans2 = 2 * Pi;
ans1 = ans1 * 180 / Pi;
ans2 = ans2 * 180 / Pi;
cout << ans1 << " " << ans2 << "\n";
continue;
}
ans1 = ans1 * 180 / Pi;
ans2 = (2 * Pi - ans2) * 180 / Pi;
cout << ans1 << " " << ans2 << "\n";
}
return 0;
} | [
"shk.slava@gmail.com"
] | shk.slava@gmail.com |
85e731bb5fbbe20c1b03e9d651b859630d11a85c | 18af68b691f3e60413881e17c514b6b8333a2f85 | /micron_code/3d_visualization.cpp | 993a1baee51102e8027dcd33e0ad6874bad230de | [] | no_license | aravindvenu7/MicronProject | beec4132e42dd2cff9d4306e00bc4d1d691deb68 | 7f939adcbe65737d33d7fc0dd720b8abb173d97a | refs/heads/main | 2023-05-21T00:23:03.680536 | 2021-06-03T12:56:09 | 2021-06-03T12:56:09 | 359,710,956 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,418 | cpp | // Copyright (c) 2017 Simone Foti <simofoti@gmail.com>
#include "3d_visualization.h"
#include <vector>
#include <opencv2/viz.hpp>
cv::viz::Viz3d viz_elem("show_cloud");
void showCloud(cv::Mat M) {
cv::viz::Viz3d viz_elem("show_cloud");
viz_elem.setBackgroundColor(cv::viz::Color::black());
//viz_elem.showWidget("coosys", cv::viz::WCoordinateSystem());
viz_elem.showWidget("cloud", cv::viz::WCloud(M, cv::viz::Color::white()));
viz_elem.spin();
}
void showCloud(std::list<cv::Point3d> list_of_points) {
std::vector<cv::Point3d> vec_pts(list_of_points.begin(),
list_of_points.end());
cv::viz::Viz3d viz_elem("show_cloud");
viz_elem.setBackgroundColor(cv::viz::Color::black());
//viz_elem.showWidget("coosys", cv::viz::WCoordinateSystem());
viz_elem.showWidget(
"cloud", cv::viz::WCloud(cv::Mat(vec_pts), cv::viz::Color::white()));
//viz_elem.showImage(cv::Mat(vec_pts));
viz_elem.spin();
std::cout << "here inside show cloud" << std::endl;
}
void showCloudandcloud(std::list<cv::Point3d> list_of_points1, std::list<cv::Point3d> list_of_points2) {
list_of_points1.splice(list_of_points1.end(), list_of_points2);
std::vector<cv::Point3d> vec_pts(list_of_points1.begin(),
list_of_points1.end());
cv::viz::Viz3d viz_elem("show_cloud");
viz_elem.setBackgroundColor(cv::viz::Color::black());
//viz_elem.showWidget("coosys", cv::viz::WCoordinateSystem());
viz_elem.showWidget(
"cloud", cv::viz::WCloud(cv::Mat(vec_pts), cv::viz::Color::white()));
//viz_elem.showImage(cv::Mat(vec_pts));
viz_elem.spinOnce(1, true);
}
void showCloudAndTip(std::list<cv::Point3d>& list_of_points, const cv::Point3d& micron_tip) {
std::vector<cv::Point3d> vec_pts(list_of_points.begin(),
list_of_points.end());
viz_elem.setBackgroundColor(cv::viz::Color::black());
cv::viz::WCloud* cloud = new cv::viz::WCloud(cv::Mat(vec_pts), cv::viz::Color::white());
cv::viz::WSphere* tip = new cv::viz::WSphere(micron_tip, 1000, 10, cv::viz::Color::red());
viz_elem.showWidget("cloud", *cloud);
viz_elem.showWidget("point", *tip);
viz_elem.spinOnce(1, true);
}
/*
void showCloudAllBranches(std::list<Branch> all_branches, cv::Mat warp_matrix) {
std::list<cv::Point3d> all_points;
for (const auto& it : all_branches) {
Branch3d currentBranch(it, warp_matrix);
all_points.splice(all_points.end(),
findAllCrfsOfBranchMean3(currentBranch));
}
showCloud(all_points);
}
*/
| [
"aravindvenugopal19@gmail.com"
] | aravindvenugopal19@gmail.com |
67c4b45034839368bc1b3a69659c2944f0f5ed87 | f67bc52b0cccf2e45cba37a35262f6835de49196 | /Presentations/2020/12.December/17/TicTacToe/TicTacToe/TicTacToeGame.h | 999e1a603cdaa1eabe11e98413cda1375f9eb730 | [
"MIT"
] | permissive | lmsasu/MLReadingGroup | f7dc0b01f1997f80b3448895979694255e36fd2c | a17d2d62b4c7940b9829fc52eb0167847f9e7491 | refs/heads/master | 2021-06-16T07:29:57.243299 | 2021-02-12T05:42:43 | 2021-02-12T05:42:43 | 155,562,672 | 13 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 60 | h | #pragma once
class TicTacToeGame
{
public:
void Run();
};
| [
"k_arpi2004@yahoo.co.uk"
] | k_arpi2004@yahoo.co.uk |
f1184f33d185482104a733f0333121330ba25974 | a79f0fa7bff3f396971345b03f57fe0a12059bf0 | /Classes/HelloWorldScene.h | 6ca7d0c053675c5598642dbef47e48debaf1ed71 | [] | no_license | 253627764/Runfield | 26618f114a9623d25ec5c1909ab92f49559137cb | c29f6276b033ac03ec5bb7d78673d20cc231ff65 | refs/heads/master | 2021-01-12T21:17:20.743676 | 2013-11-24T18:11:03 | 2013-11-24T18:11:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,385 | h | #ifndef __HELLOWORLD_SCENE_H__
#define __HELLOWORLD_SCENE_H__
#include "cocos2d.h"
#include "Terrain.h"
#include "Path.h"
#include "Shadow.h"
#include "Forest.h"
#include<vector>
class HelloWorld: public cocos2d::CCLayer {
public:
HelloWorld();
~HelloWorld();
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
virtual bool init();
virtual void onEnter();
virtual void onExit();
// there's no 'id' in cpp, so we recommend returning the class instance pointer
static cocos2d::CCScene* scene();
// a selector callback
void menuCloseCallback(CCObject* pSender);
// implement the "static node()" method manually
CREATE_FUNC(HelloWorld)
;
virtual void keyBackClicked();
void ccTouchesBegan(cocos2d::CCSet* pTouches, cocos2d::CCEvent* pEvent);
void ccTouchesEnded(cocos2d::CCSet* pTouches, cocos2d::CCEvent* pEvent);
void ccTouchesCancelled(cocos2d::CCSet* pTouches, cocos2d::CCEvent* pEvent);
private:
void loadTextures();
void tick(float dt);
void updateLevel(long st, float offset, float yoff, int gap);
void updateSky(long st, float yoff);
void updateMountain(float offset, float yoff);
void reset();
long getCurTimeInMilliSeconds();
void playMusic(float volume, bool isLooped, std::list<std::string> musicList);
/**
* 狐狸的动画做到第几帧。默认为第一帧
*/
int animFrame;
/**
* 当前动画持续的时间
*/
int animTime;
/**
* 当狐狸的关键帧改变时,记录当前的动画时间
*/
int lastAnimTime;
/**
* 上一帧动画开始的时间
*/
long lastAnimFrameTime;
float lastY;
float lastYoff;std::list<cocos2d::CCPoint> locations;
int gameOverTime;
long titleScreenTime;
/**
* 上一帧绘制完成的时间
*/
long lastFrameTime;
/**
* 当前帧率
*/
int fps;
/**
* 平均帧率
*/
int avgFps;
/**
* 当前帧率是否较低
*/
bool slow;
int totalFrameTime;
/**
* 已经绘制的帧数
*/
int frame;
/**
* 是否发生点击事件
*/
bool down;
/**
* 地面水平偏移距离
*/
float offset;
/**
* 地面水平移动速度
*/
float speed;
/**
* 狐狸的y坐标
*/
float y;
/**
* 地面垂直移动速度
*/
float vy;
/**
* 跃起动作的持续时长
*/
int jump;
/**
* 狐狸是否已经落地
*/
bool onground;
/**
* 当前取得的分数
*/
int points;
/**
* 游戏是否已经开始
*/
bool gameStarted;
/**
* 游戏是否结束
*/
bool gameOver;
/**
* 游戏分数记录
*/
int record;
/**
* 旧的游戏分数记录
*/
int oldRecord;
/**
* 是否正在启动加速
*/
bool wasBoosting;
/**
* 是否正在加速中
*/
bool wasBooming;
Terrain* _terrain;
cocos2d::CCSprite* _sky;
cocos2d::CCSprite* _mountain;
cocos2d::CCLabelTTF* _pointsText;
cocos2d::CCLabelTTF* _recordText;
cocos2d::CCLabelTTF* _instText;
Path* _path;
cocos2d::CCSprite* _fox;
cocos2d::CCSprite* _inst;
Shadow* _shadow;
Forest* _forest;
Forest* _forest2;
Forest* _fgFront;
cocos2d::CCSprite* _title;
cocos2d::CCLabelTTF* _failedTipText;
cocos2d::CCLabelTTF* _newRecordText;
cocos2d::CCLayerColor* _mask;
std::list<std::string> _jumpMusic;
std::list<std::string> _failMusic;
std::list<std::string> _landingMusic;
std::list<std::string> _boostsMusic;
std::list<std::string> _boomMusic;
};
#endif // __HELLOWORLD_SCENE_H__
| [
"reactor.lau@gmail.com"
] | reactor.lau@gmail.com |
4d9417205052485365ee3a3f5ce1322323a3858c | d94e2681b6bdaf30c9ee086141a88f9ce9088239 | /task/task3-3/stack.h | 6f20b9daa1022183cccac5288f823717ef90a36b | [] | no_license | Leo-Jiangsu/CppStudy | 937486bd43a6404be4a3867893c9e86a2ea21de7 | 3232a6fd8235a5ca07e2960bcef142efb8775e0e | refs/heads/master | 2023-07-09T18:32:43.361744 | 2021-08-20T10:46:00 | 2021-08-20T10:46:00 | 395,623,987 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 566 | h | #ifndef STACK_H_
#define STACK_H_
class Stack
{
public:
Stack(unsigned int size = 10)
: size_(size),
top_index_(-1),
element_(new int[size]())
{}
~Stack()
{
delete [] element_;
}
void Push(int data);
void Pop();
int top() const
{
return element_[top_index_];
}
bool empty() const
{
return top_index_ == -1;
}
bool full() const
{
return top_index_ == size_;
}
private:
int size_;
int top_index_;
int *element_;
};
#endif
| [
"976851951@qq.com"
] | 976851951@qq.com |
c3413732883f20d617a7b2dcd7bf8aa0510edbed | 5a406fc517d9c0dfe96164e155f508e1842120f0 | /OCTLib/code/simple_lin_interpl_FFT.cpp | b2880da4692b514a2219c55bb56ba252a0a19cf1 | [
"BSD-3-Clause-Clear"
] | permissive | rosmir/octlab | e41bd3a370d3bc25378f35227e440f2c28db3794 | a035478daea64f5b120debde9783c23e356df88b | refs/heads/master | 2020-04-14T11:01:32.405277 | 2019-10-27T16:51:25 | 2019-10-27T16:51:25 | 17,990,670 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 9,550 | cpp | /*******************************************************************************
* $Id: simple_lin_interpl_FFT.cpp 25 2010-01-19 05:47:46Z rosmir $
* Copyright (C) 2010 Stepan A. Baranov (stepan@baranov.su)
* All rights reserved.
* web-site: www.OCTLab.org
* ***** ******* *****
* Use of this source code is governed by a Clear BSD-style license that can be
* found on the https://github.com/rosmir/octlab/blob/master/LICENSE web-page or
* in the COPYRIGHT.TXT file
*******************************************************************************/
// standard headers
#include <functional>
#include <algorithm>
#include <map>
// common header
#include "./OCTLib.h"
// need for FFT analysis
#include "./fftw3.h"
// for DLL export
extern "C" {
DllExport I8 OL_smpl_lin_fft_u8(U32, U32, U32, U32, I8, I8, DBL *, U8 *,
DBL *, DBL *);
DllExport I8 OL_smpl_lin_fft_i16(U32, U32, U32, U32, I8, I8, DBL *, I16 *,
DBL *, DBL *);
DllExport I8 OL_smpl_lin_fft_u16(U32, U32, U32, U32, I8, I8, DBL *, U16 *,
DBL *, DBL *);
DllExport I8 OL_smpl_lin_fft_i32(U32, U32, U32, U32, I8, I8, DBL *, I32 *,
DBL *, DBL *);
DllExport I8 OL_smpl_lin_fft_u32(U32, U32, U32, U32, I8, I8, DBL *, U32 *,
DBL *, DBL *);
DllExport I8 OL_smpl_lin_fft_sgl(U32, U32, U32, U32, I8, I8, DBL *, SGL *,
DBL *, DBL *);
DllExport I8 OL_smpl_lin_fft_dbl(U32, U32, U32, U32, I8, I8, DBL *, DBL *,
DBL *, DBL *);
}
/* simple linear interpolation + FFT main function
PURPOSE:
calculate simple FFT (using fftw_plan_r2r_1d() function call from FFTW
library) for RAW B-scan pre-processed using known (actual) laser spectrum
(wavelengths vs time/spatial indexes). Read description for
lin_interpl_FFT.cpp file for more details.
INPUTS:
X - number of elements in each row (RAW A-line size)
Y - number of rows (# of RAW A-lines)
start_index - first index for spectrum (left RAW A-line cut-off)
end_index - last index for spectrum (right RAW A-line cut-off)
hann_flag - flag for Hanning window [4]
dB_flag - flag for scale: linear or dB (20log())
spectrum - pointer to line with spectrum in wavelengths (nm)
in - pointer to buffer with RAW B-scan before FFT (size: X * Y)
OUTPUTS:
intensity - pointer to buffer contained intensities, structural B-scan
(size: ((end_index - start_index) / 2) * Y)
phase - pointer to buffer contained phases, phase B-scan
(size: ((end_index - start_index) / 2) * Y)
RREMARKS:
note that this function does not return Im and Re parts after FFT. Use
lin_interpl_FFT.cpp file to obtain them.
*/
template <typename T1>
I8 simple_lin_fft(U32 X, U32 Y, U32 start_index, U32 end_index, I8 hann_flag,
I8 dB_flag, DBL *spectrum, T1 *in, DBL *intensity,
DBL *phase) {
// initialize map
map<DBL, I32> spectrum_map;
I32 size = end_index - start_index;
// simple checks
if (size < 3) return EXIT_FAILURE;
DBL *hann_win = static_cast<DBL *>(fftw_malloc(sizeof(DBL) * size));
I32 *li = static_cast<I32 *>(fftw_malloc(sizeof(I32) * (size - 2)));
DBL *p = static_cast<DBL *>(fftw_malloc(sizeof(DBL) * (size - 2)));
// create FFTW plan
fftw_plan fft_p = fftw_plan_r2r_1d(size, intensity, phase, FFTW_R2HC,
FFTW_ESTIMATE);
I32 width = static_cast<I32>(size/2);
I32 j, z;
// load wavelength spectrum
for (z = 0; z < size; z++) spectrum_map.insert(DI_Pair(spectrum[z], z));
DBL start_wavenumber = 1 / spectrum[0];
// linear wavenumber step
DBL wavenumber_step = (start_wavenumber - (1 / spectrum[size - 1])) / \
(size - 1);
// Hanning window for first and last elements
if (hann_flag)
hann_win[0] = hann_win[size - 1] = 0.0;
else
hann_win[0] = hann_win[size - 1] = 1.0;
// Hanning window for all other elements and coefficients and indexes for
// linear interpolation
#pragma omp parallel for default(shared) private(z)
for (z = 1; z < size - 1; z++) {
if (hann_flag)
hann_win[z] = 0.5 * (1 - cos(kTwoPi * z / size));
else
hann_win[z] = 1.0;
// nonlinear wavelength corresponding to linear wavenumber
DBL nl = 1 / (start_wavenumber - wavenumber_step * z);
// close spectrum wavelength (its index) from left side
li[z - 1] = find_index(&spectrum_map, nl);
// the relative distance (in range 0...1) between linear and nonlinear
// wavelengths calculated before
p[z - 1] = (nl - spectrum[li[z - 1]]) / \
(spectrum[li[z - 1] + 1] - spectrum[li[z - 1]]);
}
// parallel run by A-lines
#pragma omp parallel for default(shared) private(j)
for (j = 0; j < static_cast<I32>(Y); j++) {
DBL *tmp_fft_in = static_cast<DBL *>(fftw_malloc(sizeof(DBL) * size));
DBL *tmp_fft_out = static_cast<DBL *>(fftw_malloc(sizeof(DBL) * size));
U32 pos = j * width;
U32 _pos = j * X + start_index;
// linear interpolation: keep first and last elements
tmp_fft_in[0] = hann_win[0] * in[_pos];
tmp_fft_in[size - 1] = hann_win[size - 1] * in[_pos + size - 1];
// linear interpolation
// new value for calculated nonlinear wavelength but linear in wavenumber
for (I32 i = 0; i < size - 2; i++)
tmp_fft_in[i + 1] = hann_win[i + 1] * ((1 - p[i]) * in[_pos + li[i]] + \
p[i] * in[_pos + li[i] + 1]);
// perform FFT using FFTW3 library
fftw_execute_r2r(fft_p, tmp_fft_in, tmp_fft_out);
// ZERO components
if (dB_flag)
intensity[pos] = 20 * log10(abs(tmp_fft_out[0]));
else
intensity[pos] = tmp_fft_out[0];
phase[pos] = 0.0;
// construct intensity and phase information
for (I32 pos1 = 1, pos2 = size - 1; pos1 < width; pos1++, pos2--) {
// intensity
if (dB_flag)
intensity[pos + pos1] = 20 * log10(sqrt(tmp_fft_out[pos1] * \
tmp_fft_out[pos1] + tmp_fft_out[pos2] * \
tmp_fft_out[pos2]));
else
intensity[pos + pos1] = sqrt(tmp_fft_out[pos1] * tmp_fft_out[pos1] + \
tmp_fft_out[pos2] * tmp_fft_out[pos2]);
// phase
phase[pos + pos1] = atan2(tmp_fft_out[pos2], tmp_fft_out[pos1]);
}
fftw_free(tmp_fft_in);
fftw_free(tmp_fft_out);
} // end of parallel code
fftw_destroy_plan(fft_p);
fftw_free(hann_win);
fftw_free(li);
fftw_free(p);
return EXIT_SUCCESS;
}
/************OL_smpl_lin_fft************/
// simple linear interpolation + FFT for U8
I8 OL_smpl_lin_fft_u8(U32 X, U32 Y, U32 start_index, U32 end_index,
I8 hann_flag, I8 dB_flag, DBL *spectrum, U8 *in,
DBL *intensity, DBL *phase) {
return simple_lin_fft(X, Y, start_index, end_index, hann_flag, dB_flag,
spectrum, in, intensity, phase);
}
// simple linear interpolation + FFT for I16
I8 OL_smpl_lin_fft_i16(U32 X, U32 Y, U32 start_index, U32 end_index,
I8 hann_flag, I8 dB_flag, DBL *spectrum, I16 *in,
DBL *intensity, DBL *phase) {
return simple_lin_fft(X, Y, start_index, end_index, hann_flag, dB_flag,
spectrum, in, intensity, phase);
}
// simple linear interpolation + FFT for U16
I8 OL_smpl_lin_fft_u16(U32 X, U32 Y, U32 start_index, U32 end_index,
I8 hann_flag, I8 dB_flag, DBL *spectrum, U16 *in,
DBL *intensity, DBL *phase) {
return simple_lin_fft(X, Y, start_index, end_index, hann_flag, dB_flag,
spectrum, in, intensity, phase);
}
// simple linear interpolation + FFT for I32
I8 OL_smpl_lin_fft_i32(U32 X, U32 Y, U32 start_index, U32 end_index,
I8 hann_flag, I8 dB_flag, DBL *spectrum, I32 *in,
DBL *intensity, DBL *phase) {
return simple_lin_fft(X, Y, start_index, end_index, hann_flag, dB_flag,
spectrum, in, intensity, phase);
}
// simple linear interpolation + FFT for U32
I8 OL_smpl_lin_fft_u32(U32 X, U32 Y, U32 start_index, U32 end_index,
I8 hann_flag, I8 dB_flag, DBL *spectrum, U32 *in,
DBL *intensity, DBL *phase) {
return simple_lin_fft(X, Y, start_index, end_index, hann_flag, dB_flag,
spectrum, in, intensity, phase);
}
// simple linear interpolation + FFT for SGL
I8 OL_smpl_lin_fft_sgl(U32 X, U32 Y, U32 start_index, U32 end_index,
I8 hann_flag, I8 dB_flag, DBL *spectrum, SGL *in,
DBL *intensity, DBL *phase) {
return simple_lin_fft(X, Y, start_index, end_index, hann_flag, dB_flag,
spectrum, in, intensity, phase);
}
// simple linear interpolation + FFT for DBL
I8 OL_smpl_lin_fft_dbl(U32 X, U32 Y, U32 start_index, U32 end_index,
I8 hann_flag, I8 dB_flag, DBL *spectrum, DBL *in,
DBL *intensity, DBL *phase) {
return simple_lin_fft(X, Y, start_index, end_index, hann_flag, dB_flag,
spectrum, in, intensity, phase);
}
/*******************************************************************************
Checked by http://google-styleguide.googlecode.com/svn/trunk/cpplint/cpplint.py
*******************************************************************************/
| [
"stepan@baranov.us"
] | stepan@baranov.us |
7cfa199a449a3396ca6a9d44e1d6b91660516931 | fc3aa9ea0af827ceb1ae33af7edffeaa90750f45 | /src/EffectVCPU.cpp | ff1290c8d59b41f983dc6480afabd1dce05d7d60 | [] | no_license | nutti/GameEngine | 6ef06624970e4889220ad1dfa4c8105119bdd465 | 2b4f09465ecfcf0ed778ada7dbfe96aaa840d479 | refs/heads/master | 2016-09-05T09:06:20.595686 | 2014-03-09T11:30:55 | 2014-03-09T11:30:55 | 5,918,684 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,881 | cpp | #include "EffectVCPU.h"
#include <MAPIL/MAPIL.h>
#include "ScriptEffect.h"
#include "Enemy.h"
#include "Stage.h"
#include "SpriteBatch.h"
namespace GameEngine
{
EffectVCPU::EffectVCPU() : VM::VCPU()
{
}
EffectVCPU::~EffectVCPU()
{
}
void EffectVCPU::Init( VM::Data* pData, ScriptEffectData* pEffectData )
{
m_pData = pData;
m_pEffectData = pEffectData;
VM::VCPU::Init();
}
void EffectVCPU::SysPlayBGM()
{
Pop();
int id = m_pEffectData->m_pResourceMap->m_pStageResourceMap->m_BGMMap[ Top().m_Integer ];
MAPIL::PlayStreamingBuffer( id );
}
void EffectVCPU::SysStopBGM()
{
Pop();
int id = m_pEffectData->m_pResourceMap->m_pStageResourceMap->m_BGMMap[ Top().m_Integer ];
MAPIL::StopStreamingBuffer( id );
}
void EffectVCPU::SysGetScriptEffectReg()
{
Pop();
int reg = Top().m_Integer;
Pop();
int id = Top().m_Integer;
Pop();
MAPIL::Assert( id < sizeof( m_pEffectData->m_Regs ) / sizeof( m_pEffectData->m_Regs[ 0 ] ), -1 );
Push( m_pEffectData->m_Regs[ id ] );
}
void EffectVCPU::SysGetEnemyPosX()
{
Pop();
std::shared_ptr < Enemy > raw = m_pEffectData->m_ParentEnemy.lock();
if( raw ){
#if defined ( USE_FLOATING_POINT )
float x;
float y;
raw->GetPos( &x, &y );
Push( x );
#elif defined ( USE_GAME_UNIT )
GameUnit x;
GameUnit y;
raw->GetPos( &x, &y );
Push( x.GetFloat() );
#endif
}
else{
Push( -1000.0f );
}
}
void EffectVCPU::SysGetEnemyPosY()
{
Pop();
std::shared_ptr < Enemy > raw = m_pEffectData->m_ParentEnemy.lock();
if( raw ){
#if defined ( USE_FLOATING_POINT )
float x;
float y;
raw->GetPos( &x, &y );
Push( x );
#elif defined ( USE_GAME_UNIT )
GameUnit x;
GameUnit y;
raw->GetPos( &x, &y );
Push( y.GetFloat() );
#endif
}
else{
Push( -1000.0f );
}
}
void EffectVCPU::SysGetEnemyPosXGU()
{
Pop();
std::shared_ptr < Enemy > raw = m_pEffectData->m_ParentEnemy.lock();
if( raw ){
GameUnit x;
GameUnit y;
raw->GetPos( &x, &y );
Push( x.GetRawValue() );
}
else{
Push( 0 );
}
}
void EffectVCPU::SysGetEnemyPosYGU()
{
Pop();
std::shared_ptr < Enemy > raw = m_pEffectData->m_ParentEnemy.lock();
if( raw ){
GameUnit x;
GameUnit y;
raw->GetPos( &x, &y );
Push( y.GetRawValue() );
}
else{
Push( 0 );
}
}
void EffectVCPU::SysEnemyAlive()
{
Pop();
std::shared_ptr < Enemy > raw = m_pEffectData->m_ParentEnemy.lock();
if( raw ){
Push( 1 );
}
else{
Push( 0 );
}
}
void EffectVCPU::SysEnemyInSkillMode()
{
Pop();
std::shared_ptr < Enemy > raw = m_pEffectData->m_ParentEnemy.lock();
if( !raw ){
Push( 0 );
return;
}
Push( raw->IsInSkillMode() );
}
void EffectVCPU::SysGetScriptEffectCounter()
{
Pop();
Push( m_pEffectData->m_Counter );
}
void EffectVCPU::SysDrawTextureAtlasPSR()
{
Pop();
float angle = Top().m_Float;
Pop();
float sy = Top().m_Float;
Pop();
float sx = Top().m_Float;
Pop();
float y = Top().m_Float;
Pop();
float x = Top().m_Float;
Pop();
int id = Top().m_Integer;
Pop();
ResourceMap::TextureAtlas atlas = m_pEffectData->m_pResourceMap->m_pStageResourceMap->m_TexAtlasMap[ id ];
MAPIL::DrawClipedTexture( m_pEffectData->m_pResourceMap->m_pStageResourceMap->m_TextureMap[ atlas.m_TexID ],
x, y, sx, sy, angle,
atlas.m_X, atlas.m_Y, atlas.m_X + atlas.m_Width, atlas.m_Y + atlas.m_Height );
}
void EffectVCPU::SysDrawTextureAtlasPSRC()
{
Pop();
int color = RetPop().m_Integer;
float angle = RetPop().m_Float;
float sy = RetPop().m_Float;
float sx = RetPop().m_Float;
float y = RetPop().m_Float;
float x = RetPop().m_Float;
int id = RetPop().m_Integer;
ResourceMap::TextureAtlas atlas = m_pEffectData->m_pResourceMap->m_pStageResourceMap->m_TexAtlasMap[ id ];
MAPIL::DrawClipedTexture( m_pEffectData->m_pResourceMap->m_pStageResourceMap->m_TextureMap[ atlas.m_TexID ],
x, y, sx, sy, angle,
atlas.m_X, atlas.m_Y, atlas.m_X + atlas.m_Width, atlas.m_Y + atlas.m_Height,
true, color );
}
void EffectVCPU::SysDrawTextureAtlasBlendingPSR()
{
Pop();
float angle = RetPop().m_Float;
float sy = RetPop().m_Float;
float sx = RetPop().m_Float;
float y = RetPop().m_Float;
float x = RetPop().m_Float;
int alphaMode = RetPop().m_Integer;
int id = RetPop().m_Integer;
ResourceMap::TextureAtlas atlas = m_pEffectData->m_pResourceMap->m_pStageResourceMap->m_TexAtlasMap[ id ];
AddToAtlasSpriteBatch( false, alphaMode, id, x, y, sx, sy, angle );
}
void EffectVCPU::SysDrawTextureAtlasBlendingPSRC()
{
Pop();
int color = RetPop().m_Integer;
float angle = RetPop().m_Float;
float sy = RetPop().m_Float;
float sx = RetPop().m_Float;
float y = RetPop().m_Float;
float x = RetPop().m_Float;
int alphaMode = RetPop().m_Integer;
int id = RetPop().m_Integer;
ResourceMap::TextureAtlas atlas = m_pEffectData->m_pResourceMap->m_pStageResourceMap->m_TexAtlasMap[ id ];
AddToAtlasSpriteBatch( false, alphaMode, id, x, y, sx, sy, angle, true, color );
}
void EffectVCPU::SysDrawClipedTextureAtlasP()
{
Pop();
float cy2 = Top().m_Float;
Pop();
float cx2 = Top().m_Float;
Pop();
float cy1 = Top().m_Float;
Pop();
float cx1 = Top().m_Float;
Pop();
float y = Top().m_Float;
Pop();
float x = Top().m_Float;
Pop();
int id = Top().m_Integer;
Pop();
ResourceMap::TextureAtlas atlas = m_pEffectData->m_pResourceMap->m_pStageResourceMap->m_TexAtlasMap[ id ];
MAPIL::DrawClipedTexture( m_pEffectData->m_pResourceMap->m_pStageResourceMap->m_TextureMap[ atlas.m_TexID ],
x, y, 1.0f, 1.0f, 0.0f,
atlas.m_X + cx1, atlas.m_Y + cy1, atlas.m_X + cx2, atlas.m_Y + cy2 );
}
void EffectVCPU::SysDrawClipedTextureAtlasPSR()
{
Pop();
float cy2 = Top().m_Float;
Pop();
float cx2 = Top().m_Float;
Pop();
float cy1 = Top().m_Float;
Pop();
float cx1 = Top().m_Float;
Pop();
float angle = Top().m_Float;
Pop();
float sy = Top().m_Float;
Pop();
float sx = Top().m_Float;
Pop();
float y = Top().m_Float;
Pop();
float x = Top().m_Float;
Pop();
int id = Top().m_Integer;
Pop();
ResourceMap::TextureAtlas atlas = m_pEffectData->m_pResourceMap->m_pStageResourceMap->m_TexAtlasMap[ id ];
MAPIL::DrawClipedTexture( m_pEffectData->m_pResourceMap->m_pStageResourceMap->m_TextureMap[ atlas.m_TexID ],
x, y, sx, sy, angle,
atlas.m_X + cx1, atlas.m_Y + cy1, atlas.m_X + cx2, atlas.m_Y + cy2 );
}
void EffectVCPU::SysDrawClipedTextureAtlasPSRC()
{
Pop();
float cy2 = RetPop().m_Float;
float cx2 = RetPop().m_Float;
float cy1 = RetPop().m_Float;
float cx1 = RetPop().m_Float;
int color = RetPop().m_Integer;
float angle = RetPop().m_Float;
float sy = RetPop().m_Float;
float sx = RetPop().m_Float;
float y = RetPop().m_Float;
float x = RetPop().m_Float;
int id = RetPop().m_Integer;
ResourceMap::TextureAtlas atlas = m_pEffectData->m_pResourceMap->m_pStageResourceMap->m_TexAtlasMap[ id ];
MAPIL::DrawClipedTexture( m_pEffectData->m_pResourceMap->m_pStageResourceMap->m_TextureMap[ atlas.m_TexID ],
x, y, sx, sy, angle,
atlas.m_X + cx1, atlas.m_Y + cy1, atlas.m_X + cx2, atlas.m_Y + cy2, true, color );
}
void EffectVCPU::SysDrawClipedTextureAtlasBlendingP()
{
Pop();
float cy2 = Top().m_Float;
Pop();
float cx2 = Top().m_Float;
Pop();
float cy1 = Top().m_Float;
Pop();
float cx1 = Top().m_Float;
Pop();
float y = Top().m_Float;
Pop();
float x = Top().m_Float;
Pop();
int alphaMode = Top().m_Integer;
Pop();
int id = Top().m_Integer;
Pop();
ResourceMap::TextureAtlas atlas = m_pEffectData->m_pResourceMap->m_pStageResourceMap->m_TexAtlasMap[ id ];
AddToAtlasSpriteBatch( false, alphaMode, id, x, y, 0.0f, 0.0f, 0.0f );
}
void EffectVCPU::SysDrawClipedTextureAtlasBlendingPSR()
{
Pop();
float cy2 = RetPop().m_Float;
float cx2 = RetPop().m_Float;
float cy1 = RetPop().m_Float;
float cx1 = RetPop().m_Float;
float angle = RetPop().m_Float;
float sy = RetPop().m_Float;
float sx = RetPop().m_Float;
float y = RetPop().m_Float;
float x = RetPop().m_Float;
int alphaMode = RetPop().m_Integer;
int id = RetPop().m_Integer;
ResourceMap::TextureAtlas atlas = m_pEffectData->m_pResourceMap->m_pStageResourceMap->m_TexAtlasMap[ id ];
AddToAtlasSpriteBatch( false, alphaMode, id, x, y, sx, sy, angle );
}
void EffectVCPU::SysDrawClipedTextureAtlasBlendingPSRC()
{
Pop();
float cy2 = RetPop().m_Float;
float cx2 = RetPop().m_Float;
float cy1 = RetPop().m_Float;
float cx1 = RetPop().m_Float;
int color = RetPop().m_Integer;
float angle = RetPop().m_Float;
float sy = RetPop().m_Float;
float sx = RetPop().m_Float;
float y = RetPop().m_Float;
float x = RetPop().m_Float;
int alphaMode = RetPop().m_Integer;
int id = RetPop().m_Integer;
ResourceMap::TextureAtlas atlas = m_pEffectData->m_pResourceMap->m_pStageResourceMap->m_TexAtlasMap[ id ];
AddToAtlasSpriteBatch( false, alphaMode, id, cx1, cy1, cx2, cy2, x, y, sx, sy, angle, true, color );
}
void EffectVCPU::SysTerminateScriptEffect()
{
Pop();
m_pEffectData->m_StatusFlags.set( ScriptEffectData::TERMINATED );
}
void EffectVCPU::SysGetScriptEffectPosX()
{
Pop();
Push( m_pEffectData->m_PosX );
}
void EffectVCPU::SysGetScriptEffectPosY()
{
Pop();
Push( m_pEffectData->m_PosY );
}
void EffectVCPU::SysPlaySE()
{
Pop();
int id = m_pEffectData->m_pResourceMap->m_pStageResourceMap->m_SEMap[ RetPop().m_Integer ];
MAPIL::PlayStaticBuffer( id );
}
void EffectVCPU::SysStopSE()
{
Pop();
int id = m_pEffectData->m_pResourceMap->m_pStageResourceMap->m_SEMap[ RetPop().m_Integer ];
MAPIL::StopStaticBuffer( id );
}
void EffectVCPU::OpSysCall( int val )
{
switch( val ){
case VM::SYS_GET_SCRIPT_EFFECT_REG:
SysGetScriptEffectReg();
break;
case VM::SYS_GET_SCRIPT_EFFECT_COUNTER:
SysGetScriptEffectCounter();
break;
case VM::SYS_ENEMY_GET_POSX:
SysGetEnemyPosX();
break;
case VM::SYS_ENEMY_GET_POSY:
SysGetEnemyPosY();
break;
case VM::SYS_ENEMY_ALIVE:
SysEnemyAlive();
break;
case VM::SYS_ENEMY_IN_SKILL_MODE:
SysEnemyInSkillMode();
break;
case VM::SYS_ENEMY_GET_POSX_GU:
SysGetEnemyPosXGU();
break;
case VM::SYS_ENEMY_GET_POSY_GU:
SysGetEnemyPosYGU();
break;
case VM::SYS_DRAW_TEXTURE_ATLAS_PSR:
SysDrawTextureAtlasPSR();
break;
case VM::SYS_DRAW_TEXTURE_ATLAS_PSRC:
SysDrawTextureAtlasPSRC();
break;
case VM::SYS_DRAW_TEXTURE_ATLAS_BLENDING_PSRC:
SysDrawTextureAtlasBlendingPSRC();
break;
case VM::SYS_DRAW_TEXTURE_ATLAS_BLENDING_PSR:
SysDrawTextureAtlasBlendingPSR();
break;
case VM::SYS_DRAW_CLIPED_TEXTURE_ATLAS_P:
SysDrawClipedTextureAtlasP();
break;
case VM::SYS_DRAW_CLIPED_TEXTURE_ATLAS_PSR:
SysDrawClipedTextureAtlasPSR();
break;
case VM::SYS_DRAW_CLIPED_TEXTURE_ATLAS_PSRC:
SysDrawClipedTextureAtlasPSRC();
break;
case VM::SYS_DRAW_CLIPED_TEXTURE_ATLAS_BLENDING_P:
SysDrawClipedTextureAtlasBlendingP();
break;
case VM::SYS_DRAW_CLIPED_TEXTURE_ATLAS_BLENDING_PSR:
SysDrawClipedTextureAtlasBlendingPSR();
break;
case VM::SYS_DRAW_CLIPED_TEXTURE_ATLAS_BLENDING_PSRC:
SysDrawClipedTextureAtlasBlendingPSRC();
break;
case VM::SYS_TERMINATE_SCRIPT_EFFECT:
SysTerminateScriptEffect();
break;
case VM::SYS_GET_SCRIPT_EFFECT_POS_X:
SysGetScriptEffectPosX();
break;
case VM::SYS_GET_SCRIPT_EFFECT_POS_Y:
SysGetScriptEffectPosY();
break;
case VM::SYS_PLAY_BGM:
SysPlayBGM();
break;
case VM::SYS_STOP_BGM:
SysStopBGM();
break;
case VM::SYS_PLAY_SE:
SysPlaySE();
break;
case VM::SYS_STOP_SE:
SysStopSE();
break;
default:
VM::VCPU::OpSysCall( val );
break;
}
}
} | [
"nutti.metro@gmail.com"
] | nutti.metro@gmail.com |
f55e841db325d532048a1eb8014d9ac5fa63f316 | 9b7f8b025d3932939b333ff62f88159f9ff0b490 | /maths/fast_pow.cpp | 2ea1ec16f0c73dfc6ce65c416191a2190a4c258a | [] | no_license | afAditya/Competitive-Coding | b43b64e2ab12a3839a9822e1ec4d9b38620ee251 | 378fe8b8a95cb1419953052857291cc3afbe3fe4 | refs/heads/master | 2023-08-21T19:47:31.385873 | 2021-10-19T05:50:54 | 2021-10-19T05:50:54 | 418,787,747 | 0 | 0 | null | 2021-10-19T05:47:47 | 2021-10-19T05:47:46 | null | UTF-8 | C++ | false | false | 253 | cpp | #include<bits/stdc++.h>
using namespace std;
int fastPower(int a, int b){
int res = 1;
while(b > 0){
if( (b&1) != 0) {
res = res * a;
}
a = a * a;
b = b >> 1;
}
return res;
}
int main() {
int m=5,n=2;
cout<<fastPower(m,n);
} | [
"adityasinghrajput971@gmail.com"
] | adityasinghrajput971@gmail.com |
4003a19110082eb3849434f8685cfa2c3619aeee | 444a9480bce2035565332d4d4654244c0b5cd47b | /research/cv/PaDiM/ascend_310_infer/src/main.cc | 4cd23dd18c86035a13a0fb1e6ea1eaf4c093a2a0 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-proprietary-license"
] | permissive | mindspore-ai/models | 7ede9c6454e77e995e674628204e1c6e76bd7b27 | eab643f51336dbf7d711f02d27e6516e5affee59 | refs/heads/master | 2023-07-20T01:49:34.614616 | 2023-07-17T11:43:18 | 2023-07-17T11:43:18 | 417,393,380 | 301 | 92 | Apache-2.0 | 2023-05-17T11:22:28 | 2021-10-15T06:38:37 | Python | UTF-8 | C++ | false | false | 4,546 | cc | /**
* Copyright 2022 Huawei Technologies Co., Ltd
*
* 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 <sys/time.h>
#include <gflags/gflags.h>
#include <dirent.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <iosfwd>
#include <vector>
#include <fstream>
#include <sstream>
#include "include/api/model.h"
#include "include/api/context.h"
#include "include/api/types.h"
#include "include/api/serialization.h"
#include "include/dataset/execute.h"
#include "include/dataset/vision.h"
#include "inc/utils.h"
using mindspore::Context;
using mindspore::Serialization;
using mindspore::Model;
using mindspore::Status;
using mindspore::MSTensor;
using mindspore::dataset::Execute;
using mindspore::ModelType;
using mindspore::GraphCell;
using mindspore::kSuccess;
DEFINE_string(mindir_path, "", "mindir path");
DEFINE_string(input_path, ".", "input path");
DEFINE_string(result_path, ".", "result_path");
DEFINE_string(time_path, ".", "time_path");
DEFINE_int32(device_id, 0, "device id");
int main(int argc, char **argv) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
if (RealPath(FLAGS_mindir_path).empty()) {
std::cout << "Invalid mindir" << std::endl;
return 1;
}
auto context = std::make_shared<Context>();
auto ascend310 = std::make_shared<mindspore::Ascend310DeviceInfo>();
ascend310->SetDeviceID(FLAGS_device_id);
context->MutableDeviceInfo().push_back(ascend310);
mindspore::Graph graph;
Serialization::Load(FLAGS_mindir_path, ModelType::kMindIR, &graph);
Model model;
Status ret = model.Build(GraphCell(graph), context);
if (ret != kSuccess) {
std::cout << "ERROR: Build failed." << std::endl;
return 1;
}
std::vector<MSTensor> model_inputs = model.GetInputs();
if (model_inputs.empty()) {
std::cout << "Invalid model, inputs is empty." << std::endl;
return 1;
}
auto input_files = GetAllFiles(FLAGS_input_path);
if (input_files.empty()) {
std::cout << "ERROR: input data empty." << std::endl;
return 1;
}
std::map<double, double> costTime_map;
size_t size = input_files.size();
for (size_t i = 0; i < size; ++i) {
struct timeval start = {0};
struct timeval end = {0};
double startTimeMs;
double endTimeMs;
std::vector<MSTensor> inputs;
std::vector<MSTensor> outputs;
std::cout << "Start predict " << std::endl;
std::cout << "input files:" << input_files[i] << std::endl;
auto input = ReadFileToTensor(input_files[i]);
inputs.emplace_back(model_inputs[0].Name(), model_inputs[0].DataType(), model_inputs[0].Shape(),
input.Data().get(), input.DataSize());
gettimeofday(&start, nullptr);
ret = model.Predict(inputs, &outputs);
gettimeofday(&end, nullptr);
if (ret != kSuccess) {
std::cout << "Predict file failed." << std::endl;
return 1;
}
startTimeMs = (1.0 * start.tv_sec * 1000000 + start.tv_usec) / 1000;
endTimeMs = (1.0 * end.tv_sec * 1000000 + end.tv_usec) / 1000;
costTime_map.insert(std::pair<double, double>(startTimeMs, endTimeMs));
WriteResult(FLAGS_result_path, input_files[i], outputs);
}
double average = 0.0;
int inferCount = 0;
for (auto iter = costTime_map.begin(); iter != costTime_map.end(); iter++) {
double diff = 0.0;
diff = iter->second - iter->first;
average += diff;
inferCount++;
}
average = average / inferCount;
std::stringstream timeCost;
timeCost << "NN inference cost average time: "<< average << " ms of infer_count " << inferCount << std::endl;
std::cout << "NN inference cost average time: "<< average << "ms of infer_count " << inferCount << std::endl;
std::string fileName = FLAGS_time_path + std::string("/test_perform_static.txt");
std::ofstream fileStream(fileName.c_str(), std::ios::trunc);
fileStream << timeCost.str();
fileStream.close();
costTime_map.clear();
return 0;
}
| [
"2875794302@qq.com"
] | 2875794302@qq.com |
4440f8b9292d951e97133c70a9d117d4a0a3dcd6 | 79c22c41efdf703d1831d610b45489d5cabd231e | /src/Map.h | db12164de605ec23a8c4df7c45f31d3a76108258 | [] | no_license | XenoAmess/LZHRA | 47c110a82f7518515e21f3ce4013a4b2b7f465ac | 61552483cbb1f180ba091f524319913cef47ef29 | refs/heads/master | 2021-03-27T17:24:00.959353 | 2019-03-18T04:06:35 | 2019-03-18T04:06:35 | 123,705,083 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,095 | h | /*
* Trie,makes to replace std::map,but actually use much too memory (although runs a little faster)
*
*/
#ifndef MAP_H_
#define MAP_H_
#include"Common.h"
struct MapNode {
MapNode* father;
MapNode* sons[2];
List* val;
MapNode* buildSon(unsigned char index) {
sons[index] = new MapNode(this);
return sons[index];
}
MapNode(MapNode* father = NULL) {
val = NULL;
this->father = father;
sons[0] = NULL;
sons[1] = NULL;
}
void clear() {
if (sons[0] != NULL) {
sons[0]->clear();
delete sons[0];
}
if (sons[1] != NULL) {
sons[1]->clear();
delete sons[1];
}
if (val != NULL) {
val->clear();
delete val;
}
sons[0] = NULL;
sons[1] = NULL;
}
};
struct Map {
MapNode* head;
Map() {
head = new MapNode(NULL);
}
~Map() {
clear();
}
void clear() {
head->clear();
}
List & operator [](size_t val) {
MapNode* nowpos = head;
unsigned char nowbit;
do {
nowbit = (val & (size_t) 1);
val >>= 1;
if (nowpos->sons[nowbit] == NULL) {
nowpos->buildSon(nowbit);
}
nowpos = nowpos->sons[nowbit];
} while (val);
if (nowpos->val == NULL)
nowpos->val = new List();
return *nowpos->val;
}
// List & operator [](size_t val) {
// MapNode* nowfather = head;
// unsigned int nowbit = 0;
// MapNode* nowpos = nowfather->sons[nowbit];
// while (val) {
// nowbit = (val & (size_t) 1) ? 1 : 0;
// //std::cout << val << " " << nowbit << std::endl;
// val >>= 1;
// if (nowpos == NULL) {
// nowpos = nowfather->buildSon(nowbit);
// }
// nowfather = nowpos;
// nowpos = nowfather->sons[nowbit];
// }
// if (nowpos == NULL) {
// nowpos = nowfather->buildSon(nowbit);
// }
// if (nowpos->val == NULL)
// nowpos->val = new List();
// std::cout << std::endl << std::endl;
// return *nowpos->val;
// }
bool find(size_t val) {
MapNode* nowpos = head;
unsigned char nowbit;
do {
nowbit = (val & (size_t) 1);
val >>= 1;
if (nowpos->sons[nowbit] == NULL) {
return false;
}
nowpos = nowpos->sons[nowbit];
} while (val);
return true;
}
};
#endif /* MAP_H_ */
| [
"my-name@chromium.org"
] | my-name@chromium.org |
cc599930db6e337caba11ace78c1bb44a343345b | 807933598ab844fa931cceede24cbb27b49f5609 | /src/common_types.h | 37a6c93157b98c9f2e991a2cf812a839bf6f4e73 | [
"MIT"
] | permissive | wwylele/teakra | 141853b714ac854949da8f8f760c5ace73c619b4 | 01db7cdd00aabcce559a8dddce8798dabb71949b | refs/heads/master | 2022-03-09T03:24:26.822596 | 2022-02-24T01:04:10 | 2022-02-24T01:04:10 | 119,041,479 | 74 | 14 | MIT | 2022-02-24T01:04:12 | 2018-01-26T10:57:39 | C++ | UTF-8 | C++ | false | false | 1,041 | h | #pragma once
#include <cstdint>
using u8 = std::uint8_t;
using u16 = std::uint16_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;
using s8 = std::int8_t;
using s16 = std::int16_t;
using s32 = std::int32_t;
using s64 = std::int64_t;
template <typename T>
constexpr unsigned BitSize() {
return sizeof(T) * 8; // yeah I know I shouldn't use 8 here.
}
template <typename T>
constexpr T SignExtend(const T value, unsigned bit_count) {
const T mask = static_cast<T>(1ULL << bit_count) - 1;
const bool sign_bit = ((value >> (bit_count - 1)) & 1) != 0;
if (sign_bit) {
return value | ~mask;
}
return value & mask;
}
template <unsigned bit_count, typename T>
constexpr T SignExtend(const T value) {
static_assert(bit_count <= BitSize<T>(), "bit_count larger than bitsize of T");
return SignExtend(value, bit_count);
}
inline constexpr u16 BitReverse(u16 value) {
u16 result = 0;
for (u32 i = 0; i < 16; ++i) {
result |= ((value >> i) & 1) << (15 - i);
}
return result;
}
| [
"wwylele@gmail.com"
] | wwylele@gmail.com |
ed2d6a2afd8e785046b19036579bdde4afed56d8 | 70e0667e2281db6f67ac44a179164474a588dd3c | /cyber/common/file.h | f09b5d128c19b7e9cbc24f92ee38cf56046c5a81 | [
"Apache-2.0"
] | permissive | L-Net-1992/apollo_windows | dd06bfaf648179c9334b87d1aa8dc11878a78a83 | 78db2493b7356f012ec5342c27c11ff592c664c5 | refs/heads/master | 2023-03-17T15:13:11.221761 | 2020-05-04T13:41:37 | 2020-05-04T14:28:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,022 | h | /******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.
*****************************************************************************/
/**
* @file
*/
#ifndef CYBER_COMMON_FILE_H_
#define CYBER_COMMON_FILE_H_
#include <dirent.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <cstdio>
#include <fstream>
#include <string>
#include <vector>
#include "cyber/common/log.h"
#include "google/protobuf/io/zero_copy_stream_impl.h"
#include "google/protobuf/text_format.h"
#include "cyber/platform/macros.h"
/**
* @namespace apollo::common::util
* @brief apollo::common::util
*/
namespace apollo {
namespace cyber {
namespace common {
// file type: file or directory
enum FileType { TYPE_FILE, TYPE_DIR };
bool SetProtoToASCIIFile(const google::protobuf::Message &message,
int file_descriptor);
/**
* @brief Sets the content of the file specified by the file_name to be the
* ascii representation of the input protobuf.
* @param message The proto to output to the specified file.
* @param file_name The name of the target file to set the content.
* @return If the action is successful.
*/
bool SetProtoToASCIIFile(const google::protobuf::Message &message,
const std::string &file_name);
/**
* @brief Parses the content of the file specified by the file_name as ascii
* representation of protobufs, and merges the parsed content to the
* proto.
* @param file_name The name of the file to parse whose content.
* @param message The proto to carry the parsed content in the specified file.
* @return If the action is successful.
*/
bool GetProtoFromASCIIFile(const std::string &file_name,
google::protobuf::Message *message);
/**
* @brief Sets the content of the file specified by the file_name to be the
* binary representation of the input protobuf.
* @param message The proto to output to the specified file.
* @param file_name The name of the target file to set the content.
* @return If the action is successful.
*/
bool SetProtoToBinaryFile(const google::protobuf::Message &message,
const std::string &file_name);
/**
* @brief Parses the content of the file specified by the file_name as binary
* representation of protobufs, and merges the parsed content to the
* proto.
* @param file_name The name of the file to parse whose content.
* @param message The proto to carry the parsed content in the specified file.
* @return If the action is successful.
*/
bool GetProtoFromBinaryFile(const std::string &file_name,
google::protobuf::Message *message);
/**
* @brief Parses the content of the file specified by the file_name as a
* representation of protobufs, and merges the parsed content to the
* proto.
* @param file_name The name of the file to parse whose content.
* @param message The proto to carry the parsed content in the specified file.
* @return If the action is successful.
*/
bool GetProtoFromFile(const std::string &file_name,
google::protobuf::Message *message);
/**
* @brief Get file content as string.
* @param file_name The name of the file to read content.
* @param content The file content.
* @return If the action is successful.
*/
bool GetContent(const std::string &file_name, std::string *content);
/**
* @brief Get absolute path by concatenating prefix and relative_path.
* @return The absolute path.
*/
std::string CYBER_API GetAbsolutePath(const std::string &prefix,
const std::string &relative_path);
/**
* @brief Check if the path exists.
* @param path a file name, such as /a/b/c.txt
* @return If the path exists.
*/
bool PathExists(const std::string &path);
/**
* @brief Check if the directory specified by directory_path exists
* and is indeed a directory.
* @param directory_path Directory path.
* @return If the directory specified by directory_path exists
* and is indeed a directory.
*/
bool DirectoryExists(const std::string &directory_path);
/**
* @brief Expand path pattern to matched paths.
* @param pattern Path pattern, which may contain wildcards [?*].
* @return Matched path list.
*/
std::vector<std::string> Glob(const std::string &pattern);
/**
* @brief Copy a file.
* @param from The file path to copy from.
* @param to The file path to copy to.
* @return If the action is successful.
*/
bool CopyFile(const std::string &from, const std::string &to);
/**
* @brief Copy a directory.
* @param from The path to copy from.
* @param to The path to copy to.
* @return If the action is successful.
*/
bool CopyDir(const std::string &from, const std::string &to);
/**
* @brief Copy a file or directory.
* @param from The path to copy from.
* @param to The path to copy to.
* @return If the action is successful.
*/
bool Copy(const std::string &from, const std::string &to);
/**
* @brief Check if a specified directory specified by directory_path exists.
* If not, recursively create the directory (and its parents).
* @param directory_path Directory path.
* @return If the directory does exist or its creation is successful.
*/
bool EnsureDirectory(const std::string &directory_path);
/**
* @brief Remove all the files under a specified directory. Note that
* sub-directories are NOT affected.
* @param directory_path Directory path.
* @return If the action is successful.
*/
bool RemoveAllFiles(const std::string &directory_path);
/**
* @brief List sub-paths.
* @param directory_path Directory path.
* @param d_type Sub-path type, DT_DIR for directory, or DT_REG for file.
* @return A vector of sub-paths, without the directory_path prefix.
*/
std::vector<std::string> ListSubPaths(const std::string &directory_path,
const unsigned char d_type = DT_DIR);
std::string GetFileName(const std::string &path,
const bool remove_extension = false);
std::string GetCurrentPath();
// delete file including file or directory
bool DeleteFile(const std::string &filename);
bool GetType(const std::string &filename, FileType *type);
bool CreateDir(const std::string &dir);
} // namespace common
} // namespace cyber
} // namespace apollo
#endif // CYBER_COMMON_FILE_H_
| [
"mjopenglsdl@gmail.com"
] | mjopenglsdl@gmail.com |
6a4e348808670beaf22bb2c983959623baa283d3 | 69a82af4b0358ff5b5cb68377cc08be35dad9c95 | /InMemoryDB/DBWrapper/DBWrapper.h | e934f8bd07e5a655ca3902b05db863af85fab9c0 | [] | no_license | karthikpm10/Object-Oriented-Design | caba03b4c9b74cbdcf460d69eae089878e47f9ea | fede865b4cd3da31126c59ef4516c8e58289a70a | refs/heads/master | 2021-09-10T18:53:03.413812 | 2018-02-08T06:13:19 | 2018-02-08T06:13:19 | 109,552,273 | 0 | 1 | null | 2018-03-31T05:02:17 | 2017-11-05T04:41:26 | C++ | UTF-8 | C++ | false | false | 11,603 | h | #pragma once
//////////////////////////////////////////////////////////////////////////////
// DBWrapper.h - key/value pair in-memory database //
// //
// Karthik Palepally Muniyappa,CSE687 - Object Oriented Design, Spring 2017 //
// //
//////////////////////////////////////////////////////////////////////////////
/*
Module Operations:
==================
This module defines an DBWrapper Class
DBWrapper class defines functions to:
store an element in the memory map
delete an element in the memory map
update an element for an existing key
show the element of a key
show the contents of the unordered map
persist the contents of the db to an xml file
load the db from the xml file
query the db based on various parameters
Public Interface:
=================
using Key = std::string;
using Keys = std::vector<Key>;
bool insertElement(string key, string typeName, string category, string desc, vector<string> children, Data dataValue);//insert an element into the db
bool removeElement(string key);//remove an element from the db
void showDB();// show the contents of the db
bool updateElement(string key, string paramName, string paramValue,bool add=true);// update the db element
bool updateElement(string key, Data paramValue);//update the element
Element<Data> getRecord(vector<string> Keys, string key);//get the element of a specified key
vector<string> getDBKeys();//get all the db keys
vector<string> getChildren(vector<string> Keys, string key);// get the children of a specified key
vector<string> query(vector<string> Keys, string regEX, string paramName="default");// query the db and return the keys
vector<string> unionKeys(vector<string> keys1, vector<string> keys2);//return the union of two key set
vector<string> queryTimeInterval(vector<string> Keys, string startTime, string endTime = "default");// query based on time and date the element was return in the db
bool LoadDBfromXmlStr(std::string xmlFpath);//load the db from the xml file
DBWrapper(string xmlFPath,int persistCounter=20)//constructor which accepts the xml file path and the counter after which the db contents will be persisted
* Required Files:
* ---------------
* - NoSqlDb.h
* - Convert.h
* Build Process:
* --------------
* devenv DBWrapper.sln /debug rebuild
*
* Maintenance History:
* --------------------
ver 0.1 : 2nd Feb 2017
*
/*
* -
*/
#include "../NoSqlDb/NoSqlDb.h"
#include "../Convert/Convert.h"
#include<algorithm>
#include<regex>
#include <time.h>
using namespace std;
template<typename Data>
class DBWrapper
{
private:
NoSqlDb<Data> db;
Element<Data> updateChild(Element<Data> element, string child, bool add);
public:
bool insertElement(string key, string typeName, string category, string desc, vector<string> children, Data dataValue);
bool removeElement(string key);
void showDB();
bool updateElement(string key, string paramName, string paramValue, bool add = true);
bool updateElement(string key, Data paramValue);
Element<Data> getRecord(vector<string> Keys, string key);
vector<string> getDBKeys();
vector<string> getChildren(vector<string> Keys, string key);
vector<string> query(vector<string> Keys, string regEX, string paramName = "default");
vector<string> unionKeys(vector<string> keys1, vector<string> keys2);
vector<string> queryTimeInterval(vector<string> Keys, string startTime, string endTime = "default");
bool LoadDBfromXmlStr(std::string xmlFpath);
bool writeDBToFile(std::string xmlFpath);
//accepts xmlpath of the file where the contents of the db will be wriiten and read, and a persistence counter,
//after reaching the limit, the contents wiwll be written to file
DBWrapper(string xmlFPath, int persistCounter = 20)
{
db.setxmlFilePath(xmlFPath);
cout << "\n*************************Requirement 6: Setting the Number of writes after which the db contents are persisted on line 33 of DBWrapper.h******************************\n";
db.setPersistCounter(persistCounter);
}
};
//updates the child vector of the elements
template<typename Data>
Element<Data> DBWrapper<Data>::updateChild(Element<Data> element, string child, bool add)
{
vector<string> childrens = element.children;
if (add)
{
childrens.push_back(child);
}
else
{
childrens.erase(remove(childrens.begin(), childrens.end(), child), childrens.end());
}
element.children = childrens;
return element;
}
//inserts the element into the db
template<typename Data>
bool DBWrapper<Data>::insertElement(string key, string typeName, string category, string desc, vector<string> children, Data dataValue)
{
bool flag = false;
try
{
time_t currentTime;
Element<Data> element;
element.name = typeName;
element.category = category;
element.description = desc;
element.children = children;
element.data = dataValue;
element.timeDate = time(¤tTime);
cout << "\n**********************Requirement 3: addition of key/value pairs********************************\n";
flag = db.save(key, element);
cout << "\nkey=" << key << " saved in DB\n";
}
catch (std::exception& ex)
{
std::cout << "Exception " << ex.what();
}
return flag;
}
//deletes the key from the db
template<typename Data>
bool DBWrapper<Data>::removeElement(string key_delete)
{
bool flag = false;
try
{
flag = db.removeElement(key_delete);
vector<string> keys = db.keys();
for (string key : keys)
{
Element<Data> element = db.value(key);
vector<string> childrens = element.children;
vector<string> tempChildrens = childrens;
//iterating over children, to update the children vector of other elements
for (string child : childrens)
{
if (child == key_delete)
{
tempChildrens.erase(remove(tempChildrens.begin(), tempChildrens.end(), key_delete), tempChildrens.end());
}
}
element.children = tempChildrens;
db.updateElement(key, element);
}
}
catch (std::exception& ex)
{
std::cout << "Exception " << ex.what();
}
return flag;
}
//displays the contents of the db
template<typename Data>
void DBWrapper<Data>::showDB()
{
try
{
std::cout << "\n Retrieving elements from NoSqlDb";
std::cout << "\n ------------------------------------------\n";
std::cout << "\n size of db = " << db.count() << "\n";
vector<string> keys = db.keys();
for (string key : keys)
{
cout << "\n " << key << ":";
cout << db.value(key).show();
}
std::cout << "\n\n";
}
catch (std::exception& ex)
{
std::cout << "Exception " << ex.what();
}
}
//updates the element based on the paramName
template<typename Data>
bool DBWrapper<Data>::updateElement(string key, string paramName, string paramValue, bool add)
{
try
{
bool updateDB = true;
Element<Data> element = db.value(key);
if (string(element.name) != "")
{
if (paramName == "name")
element.name = paramValue;
else if (paramName == "category")
element.category = paramValue;
else if (paramName == "description")
element.description = paramValue;
else if (paramName == "children")
element = updateChild(element, paramValue, add);
// else if (paramName == "parent")
//element.parent = paramValue;
else
{
cout << "Invalid Param Name";
updateDB = false;
return false;
}
if (updateDB)
{
db.updateElement(key, element);
return true;
}
}
return false;
}
catch (std::exception& ex)
{
std::cout << "Exception " << ex.what();
return false;
}
}
//updates the data value of the element
template<typename Data>
bool DBWrapper<Data>::updateElement(string key, Data paramValue)
{
bool flag = false;
try
{
Element<Data> element = db.value(key);
if (string(element.name) != "")
{
element.data = paramValue;
flag = db.updateElement(key, element);
}
}
catch (std::exception& ex)
{
std::cout << "Exception " << ex.what();
}
return flag;
}
//gets the element of the key
template<typename Data>
Element<Data> DBWrapper<Data>::getRecord(vector<string> Keys, string key)
{
Element<Data> record;
try
{
for (string DBKey : Keys)
{
if (DBKey == key)
{
record = db.value(key);
}
}
}
catch (std::exception& ex)
{
std::cout << "Exception " << ex.what();
}
return record;
}
//returnss the db keys
template<typename Data>
vector<string> DBWrapper<Data>::getDBKeys()
{
return db.keys();
}
//returns the children of the key
template<typename Data>
vector<string> DBWrapper<Data>::getChildren(vector<string> Keys, string key)
{
vector<string> children;
try
{
regex regexp(key);
for (string DBKey : Keys)
{
if (regex_match(DBKey, regexp))
{
children = db.value(key).children;
}
}
}
catch (std::exception& ex)
{
std::cout << "Exception " << ex.what();
}
return children;
}
//queries the element parameters based on the regular expression given
template<typename Data>
vector<string> DBWrapper<Data>::query(vector<string> Keys, string regEX, string paramName)
{
cout << "*************************Requirement 12: Queries Implemented using Reg ex line 316 of DBWrapper.h*******************************";
vector<string> matchedKeys;
try
{
regex regexp(regEX);
string searchParam;
for (string DBKey : Keys)
{
if (paramName == "ItemName")
searchParam = db.value(DBKey).name;
else if (paramName == "category")
searchParam = db.value(DBKey).category;
else if (paramName == "description")
searchParam = db.value(DBKey).description;
else if (paramName == "data")
searchParam = Convert<Data>::toString(db.value(DBKey).data);
else
{
if (paramName == "default")
{
if (regex_match(DBKey, regexp))
{
matchedKeys.push_back(DBKey);
}
}
}
if (regex_match(searchParam, regexp))
matchedKeys.push_back(DBKey);
}
}
catch (std::exception& ex)
{
std::cout << "Exception " << ex.what();
}
return matchedKeys;
}
// returns the union of two key vectors
template<typename Data>
vector<string> DBWrapper<Data>::unionKeys(vector<string> keys1, vector<string> keys2)
{
try
{
for (string key1 : keys1)
{
bool contains = false;
for (string key2 : keys2)
{
if (key1 == key2)
contains = true;
}
if (!contains)
keys2.push_back(key1);
}
}
catch (std::exception& ex)
{
std::cout << "Exception " << ex.what();
}
return keys2;
}
//queries based on time date of element
template<typename Data>
vector<string> DBWrapper<Data>::queryTimeInterval(vector<string> Keys, string startTime, string endTime)
{
vector<string> returnKeys;
try
{
time_t currentTime;
time_t startTimeobj = db.DateTimeFromString(startTime.c_str());
time_t endTimeobj = (endTime != "default" ? db.DateTimeFromString(endTime.c_str()) : time(¤tTime));
for (string DBKey : Keys)
{
time_t elemTime = db.value(DBKey).timeDate;
if ((elemTime > startTimeobj) && (elemTime <= endTimeobj))
{
returnKeys.push_back(DBKey);
}
}
}
catch (std::exception& ex)
{
std::cout << "Exception " << ex.what();
}
return returnKeys;
}
//persists db from xml file
template<typename Data>
bool DBWrapper<Data>::LoadDBfromXmlStr(std::string xmlFpath)
{
try
{
db.DBfromXmlStr(xmlFpath);
return true;
}
catch (std::exception& ex)
{
std::cout << "Exception " << ex.what();
}
return false;
}
//writes the contents of db to a file
template<typename Data>
bool DBWrapper<Data>::writeDBToFile(std::string xmlFpath)
{
try
{
db.DBtoXmlStr(xmlFpath);
return true;
}
catch (std::exception& ex)
{
std::cout << "Exception " << ex.what();
}
return false;
}
| [
"karthikpm10@gmail.com"
] | karthikpm10@gmail.com |
670fdb2dd68937aed3e2e2ed2ddbcbe97a40fd52 | 4bcc9806152542ab43fc2cf47c499424f200896c | /tensorflow/compiler/mlir/tools/kernel_gen/transforms/same_shape_propagation.cc | 1e422f6ab88c70ef2774536523d1d3dfab8adc81 | [
"Apache-2.0",
"LicenseRef-scancode-generic-cla",
"BSD-2-Clause"
] | permissive | tensorflow/tensorflow | 906276dbafcc70a941026aa5dc50425ef71ee282 | a7f3934a67900720af3d3b15389551483bee50b8 | refs/heads/master | 2023-08-25T04:24:41.611870 | 2023-08-25T04:06:24 | 2023-08-25T04:14:08 | 45,717,250 | 208,740 | 109,943 | Apache-2.0 | 2023-09-14T20:55:50 | 2015-11-07T01:19:20 | C++ | UTF-8 | C++ | false | false | 14,082 | cc | /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
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 file contains the analysis and transformation to rewrite kernel
// functions such that they use a single set of arguments for the strides and
// sizes of operands with equal shapes.
#include <memory>
#include <tuple>
#include <utility>
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/EquivalenceClasses.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Debug.h"
#include "mlir/Dialect/Func/IR/FuncOps.h" // from @llvm-project
#include "mlir/Dialect/GPU/IR/GPUDialect.h" // from @llvm-project
#include "mlir/Dialect/LLVMIR/LLVMDialect.h" // from @llvm-project
#include "mlir/IR/AsmState.h" // from @llvm-project
#include "mlir/IR/BuiltinTypes.h" // from @llvm-project
#include "mlir/IR/MLIRContext.h" // from @llvm-project
#include "mlir/IR/Value.h" // from @llvm-project
#include "mlir/Support/LLVM.h" // from @llvm-project
#include "tensorflow/compiler/mlir/tools/kernel_gen/ir/tf_framework_ops.h"
#include "tensorflow/compiler/mlir/tools/kernel_gen/transforms/passes.h"
#include "tensorflow/compiler/xla/mlir_hlo/lhlo/IR/lhlo_ops.h"
#define DEBUG_TYPE "kernel-gen-shapes"
namespace {
using mlir::ArrayRef;
using mlir::SmallVector;
using mlir::Value;
/// Represents a value or constant. Used to unify operands for operations that
/// take both ssa values and attributes.
struct ValueOrConst {
explicit ValueOrConst(Value v) : value_or_constant(v), is_constant(false) {}
explicit ValueOrConst(int64_t c) : value_or_constant(c), is_constant(true) {}
Value value() const {
assert(!is_constant);
return value_or_constant.value;
}
int64_t constant() const {
assert(is_constant);
return value_or_constant.constant;
}
bool isConstant() const { return is_constant; }
private:
union ValueOrConstStorage {
explicit ValueOrConstStorage(Value v) : value(v) {}
explicit ValueOrConstStorage(size_t c) : constant(c) {}
Value value;
int64_t constant;
} value_or_constant;
bool is_constant;
};
llvm::hash_code hash_value(ValueOrConst value) {
return value.isConstant() ? static_cast<llvm::hash_code>(value.constant())
: mlir::hash_value(value.value());
}
bool operator==(ValueOrConst lhs, ValueOrConst rhs) {
if (lhs.isConstant()) {
return rhs.isConstant() && lhs.constant() == rhs.constant();
} else {
return !rhs.isConstant() && lhs.value() == rhs.value();
}
}
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
const ValueOrConst &value) {
if (value.isConstant()) {
os << value.constant();
} else {
Value val = value.value();
mlir::AsmState asm_state(
val.getParentRegion()->getParentOfType<mlir::func::FuncOp>());
val.printAsOperand(os, asm_state);
}
return os;
}
/// Represents a shape, as either a single SSA value that represents the entire
/// shape vector or as a vector of SSA values representing scalars.
struct ShapeValue {
explicit ShapeValue(Value vector)
: shape({ValueOrConst{vector}}), is_vector(true) {}
explicit ShapeValue(ValueOrConst vector) : shape({vector}), is_vector(true) {
assert(!vector.isConstant());
}
template <typename T>
explicit ShapeValue(T values)
: shape(values.begin(), values.end()), is_vector(false) {}
ValueOrConst vector() const {
assert(is_vector);
return shape.front();
}
ArrayRef<ValueOrConst> scalars() const {
assert(!is_vector);
return llvm::ArrayRef(shape);
}
bool isVector() const { return is_vector; }
private:
SmallVector<ValueOrConst, 4> shape;
bool is_vector;
};
llvm::hash_code hash_value(ShapeValue shape) {
return shape.isVector() ? hash_value(shape.vector())
: hash_value(shape.scalars());
}
bool operator==(ShapeValue lhs, ShapeValue rhs) {
if (lhs.isVector()) {
return rhs.isVector() && lhs.vector() == rhs.vector();
} else {
return !rhs.isVector() && lhs.scalars() == rhs.scalars();
}
}
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
const ShapeValue &shape) {
if (shape.isVector()) {
os << shape.vector();
return os;
}
os << "[";
bool first = true;
for (auto scalar : shape.scalars()) {
if (!first) {
os << ", ";
}
first = false;
os << scalar;
}
os << "]";
return os;
}
} // namespace
namespace llvm {
template <>
struct DenseMapInfo<ShapeValue> {
static ShapeValue getEmptyKey() {
return ShapeValue(DenseMapInfo<mlir::Value>::getEmptyKey());
}
static ShapeValue getTombstoneKey() {
return ShapeValue(DenseMapInfo<mlir::Value>::getTombstoneKey());
}
static unsigned getHashValue(ShapeValue shape) { return hash_value(shape); }
static bool isEqual(ShapeValue LHS, ShapeValue RHS) { return LHS == RHS; }
};
} // namespace llvm
namespace mlir {
namespace kernel_gen {
namespace transforms {
namespace {
#define GEN_PASS_DEF_PROPAGATESHAPEKNOWLEDGETOKERNELS
#include "tensorflow/compiler/mlir/tools/kernel_gen/transforms/kernel_gen_passes.h.inc"
// A basic shape equality inference. This should be superceeded by a proper
// inference once available. Until then, we just build this out to the needs of
// the kernel generator project.
class ShapeEqualityKnowledge {
public:
/// Checks all operations for potential shape equality of their respective
/// results.
void build(func::FuncOp function) {
function.walk([&](Operation *op) {
if (auto reshape = dyn_cast<memref::ReshapeOp>(op)) {
registerAssociation(ShapeValue{(Value)reshape.getShape()},
reshape.getResult());
return;
}
if (auto cast = dyn_cast<memref::ReinterpretCastOp>(op)) {
// Only support fully dynamic sizes for now.
// TODO(herhut): Fix once the op has canonicalizers that break this.
for (unsigned int p = 0, e = cast.getResultRank(); p < e; ++p) {
if (!cast.isDynamicSize(p)) {
return;
}
}
registerAssociation(ShapeValue{cast.getSizes()}, cast.getResult());
return;
}
if (auto alloc = dyn_cast<memref::AllocOp>(op)) {
SmallVector<ValueOrConst, 4> shape;
ShapedType type = alloc.getResult().getType().cast<ShapedType>();
fillShapeFromAllocLike(alloc.getDynamicSizes(), type, shape);
registerAssociation(ShapeValue{shape}, alloc.getResult());
return;
}
if (auto alloc = dyn_cast<tf_framework::TFAllocOp>(op)) {
// Construct a symbol representing the allocated shape.
SmallVector<ValueOrConst, 4> shape;
ShapedType type = alloc.getResult().getType().cast<ShapedType>();
fillShapeFromAllocLike(alloc.getDynSizes(), type, shape);
registerAssociation(ShapeValue{shape}, alloc.getResult());
return;
}
});
}
/// Checks whether `one` and `other` are known to have the same shape and
/// strides.
bool haveSameShape(Value one, Value other) {
return equal_shapes_.isEquivalent(one.getAsOpaquePointer(),
other.getAsOpaquePointer());
}
private:
static void fillShapeFromAllocLike(mlir::OperandRange operands,
ShapedType type,
SmallVectorImpl<ValueOrConst> &shape) {
assert(type.hasRank());
auto dynamic_sizes = operands.begin();
for (auto extent : type.getShape()) {
shape.push_back(ShapedType::isDynamic(extent)
? ValueOrConst{*(dynamic_sizes++)}
: ValueOrConst{extent});
}
}
/// Registers the value `value` to have the shape represented by `shape`. If
/// `shape` has been registered before, place `value` into the same
/// equivalence class. Otherwise register `value` as an equivalence class of
/// its own.
void registerAssociation(ShapeValue shape, Value value) {
LLVM_DEBUG({ llvm::dbgs() << "Processing " << value << "\n"; });
auto insert_symbolic = symbolic_shapes_.insert({shape, value});
if (insert_symbolic.second) {
LLVM_DEBUG({ llvm::dbgs() << "New symbolic shape " << shape << "\n"; });
equal_shapes_.insert(value.getAsOpaquePointer());
// We have seen this symbolic shape for the first time. Try to match it
// with a vector or shape we already know and alias classes if possible.
// This could be based on shape dialect if we weren't late in the
// lowering.
tryEvaluateShapeToRoot(shape, value);
} else {
auto rep = insert_symbolic.first->second;
LLVM_DEBUG({ llvm::dbgs() << "Aliasing with rep " << rep << "\n"; });
equal_shapes_.unionSets(rep.getAsOpaquePointer(),
value.getAsOpaquePointer());
}
}
/// Follows the definition chains of the ShapeValue `shape` to identify cases
/// where `shape` is derived from some other value's shape. In such case, the
/// equivalence classes of that other value and `value` are unioned.
/// This is based on pattern matching and not complete.
void tryEvaluateShapeToRoot(ShapeValue shape, Value value) {
// Just some pattern matching for common cases here.
if (!shape.isVector()) {
// Patterns that revolve around scalars.
// Check whether the scalars are all dim operations for some other memref.
Value candidate;
bool all_are_dimops =
llvm::all_of(llvm::enumerate(shape.scalars()), [&candidate](auto p) {
ValueOrConst val = p.value();
if (val.isConstant()) return false;
auto dimOp = val.value().getDefiningOp<memref::DimOp>();
if (!dimOp) return false;
if (!candidate) candidate = dimOp.getSource();
auto index = dimOp.getConstantIndex();
if (!index.has_value()) return false;
return candidate == dimOp.getSource() && p.index() == index.value();
});
if (all_are_dimops && candidate) {
equal_shapes_.unionSets(candidate.getAsOpaquePointer(),
value.getAsOpaquePointer());
}
}
}
// These are values with identical shapes (or rather their opaque pointers).
llvm::EquivalenceClasses<void *> equal_shapes_;
// A map from a value that encodes a shape to a value that has this shape.
llvm::DenseMap<ShapeValue, Value> symbolic_shapes_;
};
/// For arguments to kernels that have the same shape, use the stride and
/// shape information of the left-most argument inside of the kernel function.
/// That way, llvm can CSE index computations on same-shaped inputs.
struct PropagateShapeKnowledgeToKernels
: public impl::PropagateShapeKnowledgeToKernelsBase<
PropagateShapeKnowledgeToKernels> {
void runOnOperation() override {
ShapeEqualityKnowledge knowledge;
knowledge.build(getOperation());
getOperation().walk([&](gpu::LaunchFuncOp launch) {
auto module = launch->getParentOfType<ModuleOp>();
auto kernel = module.lookupSymbol<LLVM::LLVMFuncOp>(launch.getKernel());
if (!kernel || kernel.isExternal()) return;
llvm::SmallVector<std::pair<Value, int>, 4> seen_memrefs;
// Position of the kernel argument we are currently at.
int kernel_p = 0;
for (auto operand : launch.getKernelOperands()) {
auto memref = operand.getType().dyn_cast<MemRefType>();
if (!memref) {
// Scalar argument, advance kernel position by one.
kernel_p++;
continue;
}
for (auto previous : seen_memrefs) {
if (!knowledge.haveSameShape(operand, previous.first)) {
continue;
}
auto previous_type = previous.first.getType().cast<MemRefType>();
// We use the first equality found and replace uses of corresponding
// size and (potentially) stride information here.
auto args_to_replace = memref.getRank();
// If both memrefs have identity layouts, we can also reuse the
// strides here, as they are the identity strides and hence fully
// determinded by the shape.
if (previous_type.getLayout().isIdentity() &&
memref.getLayout().isIdentity()) {
args_to_replace *= 2;
}
int previous_args_pos = previous.second;
auto previous_args = kernel.getArguments()
.drop_front(previous_args_pos + 3)
.take_front(args_to_replace);
auto current_args = kernel.getArguments()
.drop_front(kernel_p + 3)
.take_front(args_to_replace);
for (auto pair : llvm::zip(previous_args, current_args)) {
mlir::BlockArgument prev, curr;
std::tie(prev, curr) = pair;
curr.replaceAllUsesWith(prev);
}
break;
}
seen_memrefs.push_back({operand, kernel_p});
// Advance base, aligned, offset, strides and sizes many arguments.
kernel_p += memref.getRank() * 2 + 3;
}
});
}
};
} // namespace
std::unique_ptr<OperationPass<func::FuncOp>>
CreatePropagateShapeKnowledgeToKernels() {
return std::make_unique<PropagateShapeKnowledgeToKernels>();
}
} // namespace transforms
} // namespace kernel_gen
} // namespace mlir
| [
"gardener@tensorflow.org"
] | gardener@tensorflow.org |
11df8cb6e9827cb3d14b6633e96d2fa6f1e4a864 | 83b436628ea2c33589de186907294f4f49b5f746 | /BZOJ/Finished Tasks/BZOJ_1113.cpp | 3d2003f5994b91bb170b7fdcc5e309918720c20d | [] | no_license | bill125/OI | 728162511a1b90bda8e63b4d4f9d670147d298a9 | ffd1c94ff0e340ed0770ad48d99ab05290605007 | refs/heads/master | 2020-05-31T14:04:55.314839 | 2014-06-02T05:06:57 | 2014-06-02T05:06:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,580 | cpp | #include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <queue>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef double db;
#define rep(i,n) for (int i = 0;i < n;++i)
#define repD(i,n) for (int i = n-1;i >= 0;--i)
#define For(i,a,b) for (int i = a;i <= b;++i)
#define ForD(i,a,b) for (int i = a;i >= b;--i)
#define ForS(i,a,b,step) for (int i = a;i != b;i += step)
#define ForE(i,a) for (int i = h[a];i != -1;i = E[i].next)
#define ForV(i,a) for (__typeof (a.begin()) i = a.begin();i != a.end();++i)
#define fill(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define gi gI()
const int inf = ~0U>>1,maxn = 250000+10;
int n,l = 0;
int Stack[maxn];
void setIO(string name) {
#ifndef ONLINE_JUDGE
string in = name + ".in";
string out = name + ".out";
freopen(in.c_str() , "r" , stdin);
freopen(out.c_str() , "w" , stdout);
#endif
}
int gI() {
char c = getchar();
while ((c < '0' || c > '9') && c != '-') c = getchar();
int p = 0,flag = 1;
if (c == '-') flag = -1,c = getchar();
while (c >= '0' && c <= '9') p = p*10 + c-'0',c = getchar();
return p*flag;
}
int Pop_Stack(int b) {
int last = -1,cnt = 0;
while (l && Stack[l] > b) {
if (Stack[l] != last) ++ cnt;
last = Stack[l--];
}
return cnt;
}
int main() {
setIO("test");
scanf("%d", &n);
int ans = 0;
rep(i,n) {
int a = gi,b = gi;
ans += Pop_Stack(b);
Stack[++l] = b;
}
ans += Pop_Stack(-1);
printf("%d\n", ans);
return 0;
}
| [
"bill125@gmail.com"
] | bill125@gmail.com |
e283229278986f19beb2c39dba2f71937d2371ef | 3042631cbb0fe0594adfba0f073de6d30cf02ff7 | /prj2-server/Server_GS.cpp | d0ba07d20bea90071ab89dcf867c6a1b36a9d93a | [] | no_license | ryanleek/2017_DataStructure_Final | 7f36b7a1bfd164cb62b22c59afbc8d2ac3920717 | 2b30ba9f3e1826de65fd8f84b7bd5260596a8278 | refs/heads/master | 2021-08-30T15:37:13.452138 | 2017-12-18T13:38:38 | 2017-12-18T13:38:38 | null | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 4,937 | cpp | #include "Server.h"
bool Server::recvall(int index, char* data, int totalbytes)
{
int bytesrecieved = 0;
while (bytesrecieved < totalbytes)
{
int RetnCheck = recv(connections[index].socket, data, totalbytes - bytesrecieved, NULL);
if (RetnCheck == SOCKET_ERROR)
return false;
bytesrecieved += RetnCheck;
}
return true;
}
bool Server::sendall(int index, char* data, int totalbytes)
{
int bytessent = 0;
while (bytessent < totalbytes)
{
int RetnCheck = send(connections[index].socket, data + bytessent, totalbytes - bytessent, NULL);
if (RetnCheck == SOCKET_ERROR)
return false;
bytessent += RetnCheck;
}
return true;
}
// 정수를 전송하며 성공했는지 확인
bool Server::SendInt(int index, int _int)
{
int RetnCheck = send(connections[index].socket, (char*)&_int, sizeof(int), NULL);
if (RetnCheck == SOCKET_ERROR) // 전송에 실패
return false;
return true;
}
// 패킷을 전송하며 성공했는지 확인
bool Server::SendPacket(int index, Packet _packettype)
{
int RetnCheck = send(connections[index].socket, (char*)&_packettype, sizeof(Packet), NULL);
if (RetnCheck == SOCKET_ERROR) // 전송에 실패
return false;
return true;
}
// 메시지를 송신하며 성공했는지 확인
bool Server::SendMsg(int index, string &_string)
{
if (!SendPacket(index, P_ChatMessage)) // 패킷 전송에 실패
return false;
int bufferlength = _string.size();
if (!SendInt(index, bufferlength)) // 버퍼 길이 전송에 실패
return false;
int RetnCheck = send(connections[index].socket, _string.c_str(), bufferlength, NULL);
if (RetnCheck == SOCKET_ERROR) // string 버퍼 전송에 실패
return false;
return true;
}
// 아이디를 송신하며 성공했는지 확인
bool Server::SendID(int index, string &_string)
{
if (!SendPacket(index, P_ID)) // 패킷 전송에 실패
return false;
int bufferlength = _string.size();
if (!SendInt(index, bufferlength)) // 버퍼 길이 전송에 실패
return false;
int RetnCheck = send(connections[index].socket, _string.c_str(), bufferlength, NULL);
if (RetnCheck == SOCKET_ERROR) // string 버퍼 전송에 실패
return false;
return true;
}
// 패스워드를 송신하며 성공했는지 확인
bool Server::SendPW(int index, string &_string)
{
if (!SendPacket(index, P_PW)) // 패킷 전송에 실패
return false;
int bufferlength = _string.size();
if (!SendInt(index, bufferlength)) // 버퍼 길이 전송에 실패
return false;
int RetnCheck = send(connections[index].socket, _string.c_str(), bufferlength, NULL);
if (RetnCheck == SOCKET_ERROR) // string 버퍼 전송에 실패
return false;
return true;
}
// 친구 아이디를 송신하며 성공했는지 확인
bool Server::SendFriend(int index, string &_string)
{
if (!SendPacket(index, P_Friend)) // 패킷 전송에 실패
return false;
int bufferlength = _string.size();
if (!SendInt(index, bufferlength)) // 버퍼 길이 전송에 실패
return false;
int RetnCheck = send(connections[index].socket, _string.c_str(), bufferlength, NULL);
if (RetnCheck == SOCKET_ERROR) // string 버퍼 전송에 실패
return false;
return true;
}
// 방 아이디를 송신하며 성공했는지 확인
bool Server::SendRoomID(int index, string &_string)
{
if (!SendPacket(index, P_ChatRoom)) // 패킷 전송에 실패
return false;
int bufferlength = _string.size();
if (!SendInt(index, bufferlength)) // 버퍼 길이 전송에 실패
return false;
int RetnCheck = send(connections[index].socket, _string.c_str(), bufferlength, NULL);
if (RetnCheck == SOCKET_ERROR) // string 버퍼 전송에 실패
return false;
return true;
}
// 정수를 수신하며 성공했는지 확인
bool Server::GetInt(int index, int &_int)
{
int RetnCheck = recv(connections[index].socket, (char*)&_int, sizeof(int), NULL);
if (RetnCheck == SOCKET_ERROR) // 수신에 실패
return false;
return true;
}
// 패킷을 수신하며 성공했는지 확인
bool Server::GetPacket(int index, Packet &_packettype)
{
int RetnCheck = recv(connections[index].socket, (char*)&_packettype, sizeof(Packet), NULL);
if (RetnCheck == SOCKET_ERROR) // 전송에 실패
return false;
return true;
}
// 메세지를 수신하며 성공했는지 확인
bool Server::GetString(int index, string &_string)
{
int bufferlength; // 버퍼의 길이를 저장
if (!GetInt(index, bufferlength)) // 버퍼의 길이를 가져오고 변수에 저장한다
return false;
char* buffer = new char[bufferlength + 1]; // 버퍼의 메모리 할당
buffer[bufferlength] = '\0';
int RetnCheck = recv(connections[index].socket, buffer, bufferlength, NULL); // 메세지 수신
_string = buffer; // string을 받은 메세지로 설정
delete[] buffer; // memory leak을 막기 위해 버퍼의 메모리 해제
if (RetnCheck == SOCKET_ERROR) // 소켓 연결 에러 발생
return false;
return true;
}
| [
"30751720+ryanleek@users.noreply.github.com"
] | 30751720+ryanleek@users.noreply.github.com |
6d9073fd1fa9aab9a63e847f9e021fec7cc9d4a9 | 1668deb08746c2e20ffad917741a6263677e56ce | /LeetCode/Easy/height checker.cpp | 7c40af7d93d87493288105af65d9847ba70f24b7 | [] | no_license | sakshi0461/Data-Structure-And-Algo | ebad88097f8cc5b45d175fe96a0258e39f76d352 | daa1703b34c8d281243c7846c5382e840b9927cb | refs/heads/master | 2022-12-04T08:15:17.094571 | 2020-08-21T19:43:32 | 2020-08-21T19:43:32 | 281,624,148 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 365 | cpp | class Solution {
public:
int heightChecker(vector<int>& heights) {
vector<int>num=heights;
sort(heights.begin(),heights.end());
int count=0;
for(int i=0;i<num.size();i++){
if(num[i]!=heights[i])
count++;
}
return count;
}
}; | [
"iec2018046@iiita.ac.in"
] | iec2018046@iiita.ac.in |
2aed6ce2389bccf27bf1c460e063d7a0836e316f | 692968a4cf79173b721e5ce0764fe62c97cf183b | /sceneTest/rawdatareader.cpp | 6d8eb90eb9e85d128ab548c92e6ed5ecab41088f | [] | no_license | YuryArnold/CodeSamples | ddc9e49094b7f3809f681d5d3783055c477bb011 | 26324297acbccaa8fe00b49b762d9e81506b8b13 | refs/heads/master | 2023-04-30T23:35:00.003700 | 2023-04-20T01:56:37 | 2023-04-20T01:56:37 | 238,295,739 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,179 | cpp | #include "rawdatareader.h"
#include <QDataStream>
#include <QDebug>
RawDataReader::RawDataReader(QObject *parent) : QObject (parent)
{
numbOfPointsPortion = 1000;
}
RawDataReader::~RawDataReader()
{
}
void RawDataReader::parseDataFromFile()
{
int cntOfPoints = 0;
QPair<int16_t,int16_t> data;
QFile file(pathToRawFile);
file.open(QIODevice::ReadOnly);
QDataStream in(&file);
in.setByteOrder(in.LittleEndian);
while(!in.atEnd()){
if(cntOfPoints == numbOfPointsPortion){
emit parsedData(points);
//just sleep for some time
QThread::msleep(200);
cntOfPoints = 0;
points.clear();
}
in>>data;
points.append(data);
cntOfPoints++;
}
if(!points.isEmpty()){
emit parsedData(points);
points.clear();
}
file.close();
qDebug()<<"Reading of points Are finished!";
}
void RawDataReader::setNumberOfPointsPerTransfer(int _numbOfPointsPortion)
{
numbOfPointsPortion = _numbOfPointsPortion;
}
void RawDataReader::setPathToFile(QString _pathToRawFile)
{
pathToRawFile = _pathToRawFile;
parseDataFromFile();
}
| [
"tmtm.com"
] | tmtm.com |
fff7e2b33e4fcf1293f008cc75e7f6fe0a7825e3 | c74e77aed37c97ad459a876720e4e2848bb75d60 | /800-899/818/(30947816)[WRONG_ANSWER]D[ b'Multicolored Cars' ].cpp | d580b2d9b75c77e67117a23c99f57e7f4cabb070 | [] | no_license | yashar-sb-sb/my-codeforces-submissions | aebecf4e906a955f066db43cb97b478d218a720e | a044fccb2e2b2411a4fbd40c3788df2487c5e747 | refs/heads/master | 2021-01-21T21:06:06.327357 | 2017-11-14T21:20:28 | 2017-11-14T21:28:39 | 98,517,002 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 517 | cpp | #include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
typedef long double ldb;
typedef pair<int,int> pii;
int M[1000001];
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
int n, A;
cin>>n>>A;
int B;
cin>>B;
if(B == A)
return cout<<-1<<endl, 0;
++M[B];
for(int i = 1; i < n; ++i)
{
int inp;
cin>>inp;
if(M[A] > M[B])
return cout<<-1<<endl, 0;
}
cout<<B<<endl;
return 0;
}
| [
"yashar_sb_sb@yahoo.com"
] | yashar_sb_sb@yahoo.com |
d3d8f6b2cb84ddb9f1967f903e594a47319f6970 | 765d6788c1d123174e5df5afcd318fadd3c14ec6 | /Warzone-Reborn/LazyImporter.h | 709ea2b4d23665d38116151022e7b96b1a37d6ea | [] | no_license | ZENOMODzOFC/Warzone-Reborn | c654c4e928fc95fdc1d4e3209a05c1be95337284 | 12d00676b8bd1e242faf0a1e9553791a443992ce | refs/heads/master | 2023-02-06T23:17:08.498622 | 2020-12-30T08:45:01 | 2020-12-30T08:45:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,743 | h | #pragma once
#ifndef LAZY_IMPORTER_HPP
#define LAZY_IMPORTER_HPP
#define iat(name) \
::li::detail::lazy_function<::li::detail::khash(#name), decltype(&name)>()
#define LI_FN_DEF(name) ::li::detail::lazy_function<::li::detail::khash(#name), name>()
#define LI_MODULE(name) ::li::detail::lazy_module<::li::detail::khash(name)>()
// NOTE only std::forward is used from this header.
// If there is a need to eliminate this dependency the function itself is very small.
#include <utility>
#include <cstddef>
#include <intrin.h>
#ifndef LAZY_IMPORTER_NO_FORCEINLINE
#if defined(_MSC_VER)
#define LAZY_IMPORTER_FORCEINLINE __forceinline
#elif defined(__GNUC__) && __GNUC__ > 3
#define LAZY_IMPORTER_FORCEINLINE inline __attribute__((__always_inline__))
#else
#define LAZY_IMPORTER_FORCEINLINE inline
#endif
#else
#define LAZY_IMPORTER_FORCEINLINE inline
#endif
#ifdef LAZY_IMPORTER_CASE_INSENSITIVE
#define LAZY_IMPORTER_TOLOWER(c) (c >= 'A' && c <= 'Z' ? (c | (1 << 5)) : c)
#else
#define LAZY_IMPORTER_TOLOWER(c) (c)
#endif
namespace li {
namespace detail {
template<class First, class Second>
struct pair {
First first;
Second second;
};
namespace win {
struct LIST_ENTRY_T {
const char* Flink;
const char* Blink;
};
struct UNICODE_STRING_T {
unsigned short Length;
unsigned short MaximumLength;
wchar_t* Buffer;
};
struct PEB_LDR_DATA_T {
unsigned long Length;
unsigned long Initialized;
const char* SsHandle;
LIST_ENTRY_T InLoadOrderModuleList;
};
struct PEB_T {
unsigned char Reserved1[2];
unsigned char BeingDebugged;
unsigned char Reserved2[1];
const char* Reserved3[2];
PEB_LDR_DATA_T* Ldr;
};
struct LDR_DATA_TABLE_ENTRY_T {
LIST_ENTRY_T InLoadOrderLinks;
LIST_ENTRY_T InMemoryOrderLinks;
LIST_ENTRY_T InInitializationOrderLinks;
const char* DllBase;
const char* EntryPoint;
union {
unsigned long SizeOfImage;
const char* _dummy;
};
UNICODE_STRING_T FullDllName;
UNICODE_STRING_T BaseDllName;
LAZY_IMPORTER_FORCEINLINE const LDR_DATA_TABLE_ENTRY_T*
load_order_next() const noexcept
{
return reinterpret_cast<const LDR_DATA_TABLE_ENTRY_T*>(
InLoadOrderLinks.Flink);
}
};
struct IMAGE_DOS_HEADER { // DOS .EXE header
unsigned short e_magic; // Magic number
unsigned short e_cblp; // Bytes on last page of file
unsigned short e_cp; // Pages in file
unsigned short e_crlc; // Relocations
unsigned short e_cparhdr; // Size of header in paragraphs
unsigned short e_minalloc; // Minimum extra paragraphs needed
unsigned short e_maxalloc; // Maximum extra paragraphs needed
unsigned short e_ss; // Initial (relative) SS value
unsigned short e_sp; // Initial SP value
unsigned short e_csum; // Checksum
unsigned short e_ip; // Initial IP value
unsigned short e_cs; // Initial (relative) CS value
unsigned short e_lfarlc; // File address of relocation table
unsigned short e_ovno; // Overlay number
unsigned short e_res[4]; // Reserved words
unsigned short e_oemid; // OEM identifier (for e_oeminfo)
unsigned short e_oeminfo; // OEM information; e_oemid specific
unsigned short e_res2[10]; // Reserved words
long e_lfanew; // File address of new exe header
};
struct IMAGE_FILE_HEADER {
unsigned short Machine;
unsigned short NumberOfSections;
unsigned long TimeDateStamp;
unsigned long PointerToSymbolTable;
unsigned long NumberOfSymbols;
unsigned short SizeOfOptionalHeader;
unsigned short Characteristics;
};
struct IMAGE_EXPORT_DIRECTORY {
unsigned long Characteristics;
unsigned long TimeDateStamp;
unsigned short MajorVersion;
unsigned short MinorVersion;
unsigned long Name;
unsigned long Base;
unsigned long NumberOfFunctions;
unsigned long NumberOfNames;
unsigned long AddressOfFunctions; // RVA from base of image
unsigned long AddressOfNames; // RVA from base of image
unsigned long AddressOfNameOrdinals; // RVA from base of image
};
struct IMAGE_DATA_DIRECTORY {
unsigned long VirtualAddress;
unsigned long Size;
};
struct IMAGE_OPTIONAL_HEADER64 {
unsigned short Magic;
unsigned char MajorLinkerVersion;
unsigned char MinorLinkerVersion;
unsigned long SizeOfCode;
unsigned long SizeOfInitializedData;
unsigned long SizeOfUninitializedData;
unsigned long AddressOfEntryPoint;
unsigned long BaseOfCode;
unsigned long long ImageBase;
unsigned long SectionAlignment;
unsigned long FileAlignment;
unsigned short MajorOperatingSystemVersion;
unsigned short MinorOperatingSystemVersion;
unsigned short MajorImageVersion;
unsigned short MinorImageVersion;
unsigned short MajorSubsystemVersion;
unsigned short MinorSubsystemVersion;
unsigned long Win32VersionValue;
unsigned long SizeOfImage;
unsigned long SizeOfHeaders;
unsigned long CheckSum;
unsigned short Subsystem;
unsigned short DllCharacteristics;
unsigned long long SizeOfStackReserve;
unsigned long long SizeOfStackCommit;
unsigned long long SizeOfHeapReserve;
unsigned long long SizeOfHeapCommit;
unsigned long LoaderFlags;
unsigned long NumberOfRvaAndSizes;
IMAGE_DATA_DIRECTORY DataDirectory[16];
};
struct IMAGE_OPTIONAL_HEADER32 {
unsigned short Magic;
unsigned char MajorLinkerVersion;
unsigned char MinorLinkerVersion;
unsigned long SizeOfCode;
unsigned long SizeOfInitializedData;
unsigned long SizeOfUninitializedData;
unsigned long AddressOfEntryPoint;
unsigned long BaseOfCode;
unsigned long BaseOfData;
unsigned long ImageBase;
unsigned long SectionAlignment;
unsigned long FileAlignment;
unsigned short MajorOperatingSystemVersion;
unsigned short MinorOperatingSystemVersion;
unsigned short MajorImageVersion;
unsigned short MinorImageVersion;
unsigned short MajorSubsystemVersion;
unsigned short MinorSubsystemVersion;
unsigned long Win32VersionValue;
unsigned long SizeOfImage;
unsigned long SizeOfHeaders;
unsigned long CheckSum;
unsigned short Subsystem;
unsigned short DllCharacteristics;
unsigned long SizeOfStackReserve;
unsigned long SizeOfStackCommit;
unsigned long SizeOfHeapReserve;
unsigned long SizeOfHeapCommit;
unsigned long LoaderFlags;
unsigned long NumberOfRvaAndSizes;
IMAGE_DATA_DIRECTORY DataDirectory[16];
};
struct IMAGE_NT_HEADERS {
unsigned long Signature;
IMAGE_FILE_HEADER FileHeader;
#ifdef _WIN64
IMAGE_OPTIONAL_HEADER64 OptionalHeader;
#else
IMAGE_OPTIONAL_HEADER32 OptionalHeader;
#endif
};
} // namespace win
// hashing stuff
struct hash_t {
using value_type = unsigned long;
constexpr static value_type offset = 2166136261;
constexpr static value_type prime = 16777619;
constexpr static unsigned long long prime64 = prime;
LAZY_IMPORTER_FORCEINLINE constexpr static value_type single(value_type value,
char c) noexcept
{
return static_cast<hash_t::value_type>(
(value ^ LAZY_IMPORTER_TOLOWER(c)) *
static_cast<unsigned long long>(prime));
}
};
template<class CharT = char>
LAZY_IMPORTER_FORCEINLINE constexpr hash_t::value_type
khash(const CharT* str, hash_t::value_type value = hash_t::offset) noexcept
{
return (*str ? khash(str + 1, hash_t::single(value, *str)) : value);
}
template<class CharT = char>
LAZY_IMPORTER_FORCEINLINE hash_t::value_type hash(const CharT* str) noexcept
{
hash_t::value_type value = hash_t::offset;
for (;;) {
char c = *str++;
if (!c)
return value;
value = hash_t::single(value, c);
}
}
LAZY_IMPORTER_FORCEINLINE hash_t::value_type hash(
const win::UNICODE_STRING_T& str) noexcept
{
auto first = str.Buffer;
const auto last = first + (str.Length / sizeof(wchar_t));
auto value = hash_t::offset;
for (; first != last; ++first)
value = hash_t::single(value, static_cast<char>(*first));
return value;
}
LAZY_IMPORTER_FORCEINLINE pair<hash_t::value_type, hash_t::value_type> hash_forwarded(
const char* str) noexcept
{
pair<hash_t::value_type, hash_t::value_type> module_and_function{
hash_t::offset, hash_t::offset
};
for (; *str != '.'; ++str)
hash_t::single(module_and_function.first, *str);
++str;
for (; *str; ++str)
hash_t::single(module_and_function.second, *str);
return module_and_function;
}
// some helper functions
LAZY_IMPORTER_FORCEINLINE const win::PEB_T* peb() noexcept
{
#if defined(_WIN64)
return reinterpret_cast<const win::PEB_T*>(__readgsqword(0x60));
#elif defined(_WIN32)
return reinterpret_cast<const win::PEB_T*>(__readfsdword(0x30));
#else
#error Unsupported platform. Open an issue and I'll probably add support.
#endif
}
LAZY_IMPORTER_FORCEINLINE const win::PEB_LDR_DATA_T* ldr()
{
return reinterpret_cast<const win::PEB_LDR_DATA_T*>(peb()->Ldr);
}
LAZY_IMPORTER_FORCEINLINE const win::IMAGE_NT_HEADERS* nt_headers(
const char* base) noexcept
{
return reinterpret_cast<const win::IMAGE_NT_HEADERS*>(
base + reinterpret_cast<const win::IMAGE_DOS_HEADER*>(base)->e_lfanew);
}
LAZY_IMPORTER_FORCEINLINE const win::IMAGE_EXPORT_DIRECTORY* image_export_dir(
const char* base) noexcept
{
return reinterpret_cast<const win::IMAGE_EXPORT_DIRECTORY*>(
base + nt_headers(base)->OptionalHeader.DataDirectory->VirtualAddress);
}
LAZY_IMPORTER_FORCEINLINE const win::LDR_DATA_TABLE_ENTRY_T* ldr_data_entry() noexcept
{
return reinterpret_cast<const win::LDR_DATA_TABLE_ENTRY_T*>(
ldr()->InLoadOrderModuleList.Flink);
}
struct exports_directory {
const char* _base;
const win::IMAGE_EXPORT_DIRECTORY* _ied;
unsigned long _ied_size;
public:
using size_type = unsigned long;
LAZY_IMPORTER_FORCEINLINE
exports_directory(const char* base) noexcept : _base(base)
{
const auto ied_data_dir = nt_headers(base)->OptionalHeader.DataDirectory[0];
_ied = reinterpret_cast<const win::IMAGE_EXPORT_DIRECTORY*>(
base + ied_data_dir.VirtualAddress);
_ied_size = ied_data_dir.Size;
}
LAZY_IMPORTER_FORCEINLINE explicit operator bool() const noexcept
{
return reinterpret_cast<const char*>(_ied) != _base;
}
LAZY_IMPORTER_FORCEINLINE size_type size() const noexcept
{
return _ied->NumberOfNames;
}
LAZY_IMPORTER_FORCEINLINE const char* base() const noexcept { return _base; }
LAZY_IMPORTER_FORCEINLINE const win::IMAGE_EXPORT_DIRECTORY* ied() const noexcept
{
return _ied;
}
LAZY_IMPORTER_FORCEINLINE const char* name(size_type index) const noexcept
{
return reinterpret_cast<const char*>(
_base + reinterpret_cast<const unsigned long*>(
_base + _ied->AddressOfNames)[index]);
}
LAZY_IMPORTER_FORCEINLINE const char* address(size_type index) const noexcept
{
const auto* const rva_table =
reinterpret_cast<const unsigned long*>(_base + _ied->AddressOfFunctions);
const auto* const ord_table = reinterpret_cast<const unsigned short*>(
_base + _ied->AddressOfNameOrdinals);
return _base + rva_table[ord_table[index]];
}
LAZY_IMPORTER_FORCEINLINE bool is_forwarded(const char* export_address) const
noexcept
{
const auto ui_ied = reinterpret_cast<const char*>(_ied);
return (export_address > ui_ied && export_address < ui_ied + _ied_size);
}
};
struct safe_module_enumerator {
using value_type = const detail::win::LDR_DATA_TABLE_ENTRY_T;
value_type* value;
value_type* const head;
LAZY_IMPORTER_FORCEINLINE safe_module_enumerator() noexcept
: value(ldr_data_entry()), head(value)
{}
LAZY_IMPORTER_FORCEINLINE void reset() noexcept { value = head; }
LAZY_IMPORTER_FORCEINLINE bool next() noexcept
{
value = value->load_order_next();
return value != head;
}
};
struct unsafe_module_enumerator {
using value_type = const detail::win::LDR_DATA_TABLE_ENTRY_T*;
value_type value;
LAZY_IMPORTER_FORCEINLINE unsafe_module_enumerator() noexcept
: value(ldr_data_entry())
{}
LAZY_IMPORTER_FORCEINLINE void reset() noexcept { value = ldr_data_entry(); }
LAZY_IMPORTER_FORCEINLINE bool next() noexcept
{
value = value->load_order_next();
return true;
}
};
// provides the cached functions which use Derive classes methods
template<class Derived, class DefaultType = void*>
class lazy_base {
protected:
// This function is needed because every templated function
// with different args has its own static buffer
LAZY_IMPORTER_FORCEINLINE static void*& _cache() noexcept
{
static void* value = nullptr;
return value;
}
public:
template<class T = DefaultType>
LAZY_IMPORTER_FORCEINLINE static T safe() noexcept
{
return Derived::template get<T, safe_module_enumerator>();
}
template<class T = DefaultType, class Enum = unsafe_module_enumerator>
LAZY_IMPORTER_FORCEINLINE static T cached() noexcept
{
auto& cached = _cache();
if (!cached)
cached = Derived::template get<void*, Enum>();
return (T)(cached);
}
template<class T = DefaultType>
LAZY_IMPORTER_FORCEINLINE static T safe_cached() noexcept
{
return cached<T, safe_module_enumerator>();
}
};
template<hash_t::value_type Hash>
struct lazy_module : lazy_base<lazy_module<Hash>> {
template<class T = void*, class Enum = unsafe_module_enumerator>
LAZY_IMPORTER_FORCEINLINE static T get() noexcept
{
Enum e;
do {
if (hash(e.value->BaseDllName) == Hash)
return (T)(e.value->DllBase);
} while (e.next());
return {};
}
};
template<hash_t::value_type Hash, class T>
struct lazy_function : lazy_base<lazy_function<Hash, T>, T> {
using base_type = lazy_base<lazy_function<Hash, T>, T>;
template<class... Args>
LAZY_IMPORTER_FORCEINLINE decltype(auto) operator()(Args&&... args) const
{
#ifndef LAZY_IMPORTER_CACHE_OPERATOR_PARENS
return get()(std::forward<Args>(args)...);
#else
return cached()(std::forward<Args>(args)...);
#endif
}
template<class F = T, class Enum = unsafe_module_enumerator>
LAZY_IMPORTER_FORCEINLINE static F get() noexcept
{
// for backwards compatability.
// Before 2.0 it was only possible to resolve forwarded exports when
// this macro was enabled
#ifdef LAZY_IMPORTER_RESOLVE_FORWARDED_EXPORTS
return forwarded<F, Enum>();
#else
Enum e;
do {
const exports_directory exports(e.value->DllBase);
if (exports) {
auto export_index = exports.size();
while (export_index--)
if (hash(exports.name(export_index)) == Hash)
return (F)(exports.address(export_index));
}
} while (e.next());
return {};
#endif
}
template<class F = T, class Enum = unsafe_module_enumerator>
LAZY_IMPORTER_FORCEINLINE static F forwarded() noexcept
{
detail::win::UNICODE_STRING_T name;
hash_t::value_type module_hash = 0;
auto function_hash = Hash;
Enum e;
do {
name = e.value->BaseDllName;
name.Length -= 8; // get rid of .dll extension
if (!module_hash || hash(name) == module_hash) {
const exports_directory exports(e.value->DllBase);
if (exports) {
auto export_index = exports.size();
while (export_index--)
if (hash(exports.name(export_index)) == function_hash) {
const auto addr = exports.address(export_index);
if (exports.is_forwarded(addr)) {
auto hashes = hash_forwarded(
reinterpret_cast<const char*>(addr));
function_hash = hashes.second;
module_hash = hashes.first;
e.reset();
break;
}
return (F)(addr);
}
}
}
} while (e.next());
return {};
}
template<class F = T>
LAZY_IMPORTER_FORCEINLINE static F forwarded_safe() noexcept
{
return forwarded<F, safe_module_enumerator>();
}
template<class F = T, class Enum = unsafe_module_enumerator>
LAZY_IMPORTER_FORCEINLINE static F forwarded_cached() noexcept
{
auto& value = base_type::_cache();
if (!value)
value = forwarded<void*, Enum>();
return (F)(value);
}
template<class F = T>
LAZY_IMPORTER_FORCEINLINE static F forwarded_safe_cached() noexcept
{
return forwarded_cached<F, safe_module_enumerator>();
}
template<class F = T, bool IsSafe = false, class Module>
LAZY_IMPORTER_FORCEINLINE static F in(Module m) noexcept
{
if (IsSafe && !m)
return {};
const exports_directory exports((const char*)(m));
if (IsSafe && !exports)
return {};
for (unsigned long i{};; ++i) {
if (IsSafe && i == exports.size())
break;
if (hash(exports.name(i)) == Hash)
return (F)(exports.address(i));
}
return {};
}
template<class F = T, class Module>
LAZY_IMPORTER_FORCEINLINE static F in_safe(Module m) noexcept
{
return in<F, true>(m);
}
template<class F = T, bool IsSafe = false, class Module>
LAZY_IMPORTER_FORCEINLINE static F in_cached(Module m) noexcept
{
auto& value = base_type::_cache();
if (!value)
value = in<void*, IsSafe>(m);
return (F)(value);
}
template<class F = T, class Module>
LAZY_IMPORTER_FORCEINLINE static F in_safe_cached(Module m) noexcept
{
return in_cached<F, true>(m);
}
template<class F = T>
LAZY_IMPORTER_FORCEINLINE static F nt() noexcept
{
return in<F>(ldr_data_entry()->load_order_next()->DllBase);
}
template<class F = T>
LAZY_IMPORTER_FORCEINLINE static F nt_safe() noexcept
{
return in_safe<F>(ldr_data_entry()->load_order_next()->DllBase);
}
template<class F = T>
LAZY_IMPORTER_FORCEINLINE static F nt_cached() noexcept
{
return in_cached<F>(ldr_data_entry()->load_order_next()->DllBase);
}
template<class F = T>
LAZY_IMPORTER_FORCEINLINE static F nt_safe_cached() noexcept
{
return in_safe_cached<F>(ldr_data_entry()->load_order_next()->DllBase);
}
};
}
} // namespace li::detail
#endif // include guard | [
"63737942+zirconiium@users.noreply.github.com"
] | 63737942+zirconiium@users.noreply.github.com |
52768bee1ff45448101d453c58e7f838c79de1b6 | d645db5569db9a94e2353399b222d46620f6ea8f | /P6/Effects.cpp | f53a02562a0e1291c1d8fbd4a8325063b0cfa541 | [] | no_license | DrEvilBrain/CS3113 | 6c6741e7c6d765e4a3eb9ae9231c3da32e617903 | dc2675446badd2b2a89012dbdbc445213f0ece34 | refs/heads/main | 2023-05-11T12:34:31.405832 | 2021-05-12T21:58:27 | 2021-05-12T21:58:27 | 337,232,067 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,638 | cpp | #include "Effects.h"
Effects::Effects(glm::mat4 projectionMatrix, glm::mat4 viewMatrix)
{
// Non textured Shader
program.Load("shaders/vertex.glsl", "shaders/fragment.glsl");
program.SetProjectionMatrix(projectionMatrix);
program.SetViewMatrix(viewMatrix);
currentEffect = NONE;
alpha = 0;
speed = 1;
}
void Effects::DrawOverlay()
{
glUseProgram(program.programID);
float vertices[] = { -0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5 };
glVertexAttribPointer(program.positionAttribute, 2, GL_FLOAT, false, 0, vertices);
glEnableVertexAttribArray(program.positionAttribute);
glDrawArrays(GL_TRIANGLES, 0, 6);
glDisableVertexAttribArray(program.positionAttribute);
}
void Effects::Start(EffectType effectType, float effectSpeed)
{
currentEffect = effectType;
speed = effectSpeed;
switch (currentEffect)
{
case NONE:
break;
case FADEIN:
alpha = 1.0f;
break;
case FADEOUT:
alpha = 0.0f;
break;
}
}
void Effects::Update(float deltaTime)
{
switch (currentEffect)
{
case NONE:
break;
case FADEIN:
alpha -= deltaTime * speed;
if (alpha <= 0)
{
currentEffect = NONE;
}
break;
case FADEOUT:
alpha += deltaTime * speed;
break;
}
}
void Effects::Render()
{
glm::mat4 modelMatrix = glm::mat4(1.0f);
switch (currentEffect)
{
case NONE:
break;
case FADEOUT:
case FADEIN:
modelMatrix = glm::scale(modelMatrix, glm::vec3(10, 10, 1));
program.SetModelMatrix(modelMatrix);
program.SetColor(0, 0, 0, alpha);
DrawOverlay();
break;
}
}
| [
"drevilbrain@gmail.com"
] | drevilbrain@gmail.com |
8a151930cad10b8a9d388f2d773c2cc49ac73593 | 64e4fabf9b43b6b02b14b9df7e1751732b30ad38 | /src/chromium/gen/gen_combined/services/device/public/mojom/screen_orientation.mojom-blink-test-utils.h | 1d3632cdc4257da0f3e360a477ddc9b13fc0e0cb | [
"BSD-3-Clause"
] | permissive | ivan-kits/skia-opengl-emscripten | 8a5ee0eab0214c84df3cd7eef37c8ba54acb045e | 79573e1ee794061bdcfd88cacdb75243eff5f6f0 | refs/heads/master | 2023-02-03T16:39:20.556706 | 2020-12-25T14:00:49 | 2020-12-25T14:00:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,072 | h | // Copyright 2019 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 SERVICES_DEVICE_PUBLIC_MOJOM_SCREEN_ORIENTATION_MOJOM_BLINK_TEST_UTILS_H_
#define SERVICES_DEVICE_PUBLIC_MOJOM_SCREEN_ORIENTATION_MOJOM_BLINK_TEST_UTILS_H_
#include "services/device/public/mojom/screen_orientation.mojom-blink.h"
#include "third_party/blink/public/platform/web_common.h"
namespace device {
namespace mojom {
namespace blink {
class BLINK_PLATFORM_EXPORT ScreenOrientationInterceptorForTesting : public ScreenOrientation {
virtual ScreenOrientation* GetForwardingInterface() = 0;
void LockOrientation(::blink::WebScreenOrientationLockType orientation, LockOrientationCallback callback) override;
void UnlockOrientation() override;
};
class BLINK_PLATFORM_EXPORT ScreenOrientationAsyncWaiter {
public:
explicit ScreenOrientationAsyncWaiter(ScreenOrientation* proxy);
~ScreenOrientationAsyncWaiter();
void LockOrientation(
::blink::WebScreenOrientationLockType orientation, ::device::mojom::blink::ScreenOrientationLockResult* out_result);
private:
ScreenOrientation* const proxy_;
DISALLOW_COPY_AND_ASSIGN(ScreenOrientationAsyncWaiter);
};
class BLINK_PLATFORM_EXPORT ScreenOrientationListenerInterceptorForTesting : public ScreenOrientationListener {
virtual ScreenOrientationListener* GetForwardingInterface() = 0;
void IsAutoRotateEnabledByUser(IsAutoRotateEnabledByUserCallback callback) override;
};
class BLINK_PLATFORM_EXPORT ScreenOrientationListenerAsyncWaiter {
public:
explicit ScreenOrientationListenerAsyncWaiter(ScreenOrientationListener* proxy);
~ScreenOrientationListenerAsyncWaiter();
void IsAutoRotateEnabledByUser(
bool* out_enabled);
private:
ScreenOrientationListener* const proxy_;
DISALLOW_COPY_AND_ASSIGN(ScreenOrientationListenerAsyncWaiter);
};
} // namespace blink
} // namespace mojom
} // namespace device
#endif // SERVICES_DEVICE_PUBLIC_MOJOM_SCREEN_ORIENTATION_MOJOM_BLINK_TEST_UTILS_H_ | [
"trofimov_d_a@magnit.ru"
] | trofimov_d_a@magnit.ru |
b94f3b74c221d3cfdf10eb184058b5bf5ab581dd | 9a94e85ef2820d626cd76123b9aa49190c991003 | /HSPF_MRO_ANDR/build/iOS/Preview/include/Fuse.Controls.SafeEdgePanel.h | b01d91119a9174523664f69032e1483930c1ac86 | [] | no_license | jaypk-104/FUSE | 448db1717a29052f7b551390322a6167dfea34cd | 0464afa07998eea8de081526a9337bd9af42dcf3 | refs/heads/master | 2023-03-13T14:32:43.855977 | 2021-03-18T01:57:10 | 2021-03-18T01:57:10 | 348,617,284 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,052 | h | // This file was generated based on /usr/local/share/uno/Packages/Fuse.Controls.Panels/1.12.0/SafeEdgePanel.uno.
// WARNING: Changes might be lost if you edit this file directly.
#pragma once
#include <Fuse.Animations.IResize.h>
#include <Fuse.Binding.h>
#include <Fuse.Controls.Panel.h>
#include <Fuse.Drawing.ISurfaceDrawable.h>
#include <Fuse.IActualPlacement.h>
#include <Fuse.INotifyUnrooted.h>
#include <Fuse.IProperties.h>
#include <Fuse.ISourceLocation.h>
#include <Fuse.ITemplateSource.h>
#include <Fuse.Node.h>
#include <Fuse.Scripting.IScriptObject.h>
#include <Fuse.Triggers.Actions.ICollapse.h>
#include <Fuse.Triggers.Actions.IHide.h>
#include <Fuse.Triggers.Actions.IShow.h>
#include <Fuse.Visual.h>
#include <Uno.Collections.ICollection-1.h>
#include <Uno.Collections.IEnumerable-1.h>
#include <Uno.Collections.IList-1.h>
#include <Uno.Float4.h>
#include <Uno.UX.IPropertyListener.h>
namespace g{namespace Fuse{namespace Controls{struct SafeEdgePanel;}}}
namespace g{namespace Fuse{namespace Reactive{struct WindowCaps;}}}
namespace g{namespace Uno{namespace UX{struct PropertyObject;}}}
namespace g{namespace Uno{namespace UX{struct Selector;}}}
namespace g{
namespace Fuse{
namespace Controls{
// public sealed class SafeEdgePanel
// {
::g::Fuse::Controls::Panel_type* SafeEdgePanel_typeof();
void SafeEdgePanel__ctor_7_fn(SafeEdgePanel* __this);
void SafeEdgePanel__get_ExtraPadding_fn(SafeEdgePanel* __this, ::g::Uno::Float4* __retval);
void SafeEdgePanel__set_ExtraPadding_fn(SafeEdgePanel* __this, ::g::Uno::Float4* value);
void SafeEdgePanel__get_MinEdgePadding_fn(SafeEdgePanel* __this, ::g::Uno::Float4* __retval);
void SafeEdgePanel__set_MinEdgePadding_fn(SafeEdgePanel* __this, ::g::Uno::Float4* value);
void SafeEdgePanel__New4_fn(SafeEdgePanel** __retval);
void SafeEdgePanel__OnPropertyChanged2_fn(SafeEdgePanel* __this, ::g::Uno::UX::PropertyObject* sender, ::g::Uno::UX::Selector* name);
void SafeEdgePanel__OnRooted_fn(SafeEdgePanel* __this);
void SafeEdgePanel__OnUnrooted_fn(SafeEdgePanel* __this);
void SafeEdgePanel__get_Padding1_fn(SafeEdgePanel* __this, ::g::Uno::Float4* __retval);
void SafeEdgePanel__set_Padding1_fn(SafeEdgePanel* __this, ::g::Uno::Float4* value);
void SafeEdgePanel__get_PadEdges_fn(SafeEdgePanel* __this, int32_t* __retval);
void SafeEdgePanel__set_PadEdges_fn(SafeEdgePanel* __this, int32_t* value);
void SafeEdgePanel__UpdatePadding_fn(SafeEdgePanel* __this);
struct SafeEdgePanel : ::g::Fuse::Controls::Panel
{
uStrong< ::g::Fuse::Reactive::WindowCaps*> _caps;
int32_t _padEdges;
::g::Uno::Float4 _extraPadding;
::g::Uno::Float4 _minEdgePadding;
void ctor_7();
::g::Uno::Float4 ExtraPadding();
void ExtraPadding(::g::Uno::Float4 value);
::g::Uno::Float4 MinEdgePadding();
void MinEdgePadding(::g::Uno::Float4 value);
::g::Uno::Float4 Padding1();
void Padding1(::g::Uno::Float4 value);
int32_t PadEdges();
void PadEdges(int32_t value);
void UpdatePadding();
static SafeEdgePanel* New4();
};
// }
}}} // ::g::Fuse::Controls
| [
"sommelier0052@gmail.com"
] | sommelier0052@gmail.com |
292d710a0ddac736a33163516f925cbe22dab9a5 | c7ea1b3b93a04a7ef9b1f2811f6abf3c4f59a01f | /PAT/A1106 Lowest Price in Supply Chain.cpp | 2e0a290f1c20a0f5976d706c5657457ecb5b458b | [] | no_license | TicoHsueh/PAT_Practice | f020a8c59dfbdf2576efe71dcb8ee020954ed598 | c440a832bec389fdd51183b7f935d49274029474 | refs/heads/master | 2020-07-12T22:36:05.530341 | 2020-03-25T15:22:38 | 2020-03-25T15:22:38 | 204,924,128 | 0 | 1 | null | 2020-03-25T15:22:39 | 2019-08-28T12:15:31 | C++ | UTF-8 | C++ | false | false | 858 | cpp | #include "bits/stdc++.h"
#define MAXN 100010
#define INF 100000000
using namespace std;
int n;
double p,r;
vector<int> Adj[MAXN];
int minLay = INF;
int numOfLay[MAXN];
void DFS(int index,int layer)
{
if(Adj[index].size()==0){
if(layer<minLay){
minLay = layer;
numOfLay[layer] = 1;
}else if(layer==minLay){
numOfLay[layer]++;
}
return ;
}
for(int i=0;i<Adj[index].size();i++){
DFS(Adj[index][i],layer+1);
}
}
int main()
{
cin>>n>>p>>r;
r /= 100;
for(int i=0;i<n;i++){
int num,e;
cin>>num;
for(int j=0;j<num;j++){
cin>>e;
Adj[i].push_back(e);
}
}
fill(numOfLay,numOfLay+n,0);
DFS(0,0);
cout<<minLay<<endl;
printf("%.4f %d\n",p*pow(1+r,minLay),numOfLay[minLay]);
return 0;
}
| [
"HsuehBo@outlook.com"
] | HsuehBo@outlook.com |
fdb80b0ba63efa6ef34f0e160a899dbbb67b1370 | 69aab86a56c78cdfb51ab19b8f6a71274fb69fba | /Code/inc/HUD/GameLabel.h | c02b1a30360757d07577132c67accdb068352cba | [
"BSD-3-Clause"
] | permissive | zc5872061/wonderland | 89882b6062b4a2d467553fc9d6da790f4df59a18 | b6e0153eaa65a53abdee2b97e1289a3252b966f1 | refs/heads/master | 2021-01-25T10:44:13.871783 | 2011-08-11T20:12:36 | 2011-08-11T20:12:36 | 38,088,714 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,847 | h | /*
* GameLabel.h
*
* Created on: 2011-01-10
* Author: artur.m
*/
#ifndef GAMELABEL_H_
#define GAMELABEL_H_
#include "GameControl.h"
#include "GamePanel.h"
#include "MathHelper.h"
#include "GameBitmap.h"
#include "GameCommon.h"
#include <string>
#include <vector>
#include <memory>
class GamePanel;
class GameLabel : public GameControl
{
public:
virtual std::string getType() const { return "GameLabel"; }
static shared_ptr<GameLabel> spawn(const Rectangle& rect);
virtual ~GameLabel();
void setText(const std::string& text);
const std::string& getText() const;
void setTextVerticalAlignment(Common::VerticalAlignment align);
Common::VerticalAlignment getTextVerticalAlignment() const { return m_vAlign; }
void setTextHorizontalAlignment(Common::HorizontalAlignment align);
Common::HorizontalAlignment getTextHorizontalAlignment() const { return m_hAlign; }
void setTextAlignment(Common::HorizontalAlignment hAlign, Common::VerticalAlignment vAlign);
void setTextColor(unsigned char r, unsigned char g, unsigned char b);
Common::Color getTextColor() const { return m_color; }
int getTextSize() const { return m_fontSize; }
void setFontSize(int size);
private:
GameLabel(const Rectangle& bounds);
void initialize();
void cleanOldText();
// Creates the bitmap which holds the rendered by FreeType text
void createBitmap();
// Updates the color of the text in the rendered bitmap
void updateColor();
private:
static int s_instances;
std::string m_text;
std::string m_bitmapId;
Common::HorizontalAlignment m_hAlign;
Common::VerticalAlignment m_vAlign;
Common::Color m_color;
int m_fontSize;
};
#endif /* GAMELABEL_H_ */
| [
"Artur.S.Mazurek@gmail.com"
] | Artur.S.Mazurek@gmail.com |
b81b26d435812f289d4b93e6eadc3ce968fafdfe | edbaf7821dd1541cab6658a345be56a88191557d | /src/sword.cpp | 8c811a91f762fda6d0931d27a546db26dc052543 | [] | no_license | jeremyelkayam/Warriors | 18853864b41374e83869aea7715e7eb8fbad9579 | a619f8ba3cf7349bbeddb260152678754f58e13a | refs/heads/master | 2023-06-10T03:30:47.299407 | 2023-06-01T22:42:15 | 2023-06-01T22:42:15 | 37,489,756 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 733 | cpp | //
// Created by jeremyelkayam on 9/26/20.
//
#include "sword.hpp"
Sword::Sword(float xcor, float ycor, sf::Texture &texture, float warrior_width, sf::Color warrior_color)
: Entity(xcor,ycor,texture) {
color = warrior_color;
active = false;
//Set our sprite's coordinates to the center of the warrior to which it belongs.
sf::FloatRect sprite_rect=sprite.getLocalBounds();
sprite.setOrigin(sprite_rect.left - warrior_width,
sprite_rect.top + sprite_rect.height/2);
}
void Sword::update(float xcor, float ycor, float angle){
sprite.setPosition(xcor,ycor);
//convert the sword's angle into degrees because SFML likes degrees for some reason
angle *= 180 / M_PI;
sprite.setRotation(angle);
} | [
"jeremyelkayam@gmail.com"
] | jeremyelkayam@gmail.com |
1a29133629bcc396e3869100288688f1b41527e6 | 88ae8695987ada722184307301e221e1ba3cc2fa | /chrome/browser/sync/session_sync_service_factory_unittest.cc | 64f72fa693e98227bad036c4a5473ad094ce54bb | [
"BSD-3-Clause"
] | permissive | iridium-browser/iridium-browser | 71d9c5ff76e014e6900b825f67389ab0ccd01329 | 5ee297f53dc7f8e70183031cff62f37b0f19d25f | refs/heads/master | 2023-08-03T16:44:16.844552 | 2023-07-20T15:17:00 | 2023-07-23T16:09:30 | 220,016,632 | 341 | 40 | BSD-3-Clause | 2021-08-13T13:54:45 | 2019-11-06T14:32:31 | null | UTF-8 | C++ | false | false | 1,440 | cc | // Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/sync/session_sync_service_factory.h"
#include "chrome/common/webui_url_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
namespace {
const char kValidUrl[] = "http://www.example.com";
const char kInvalidUrl[] = "invalid.url";
TEST(SessionSyncServiceFactoryTest, ShouldSyncURL) {
EXPECT_TRUE(
SessionSyncServiceFactory::ShouldSyncURLForTesting(GURL(kValidUrl)));
EXPECT_TRUE(SessionSyncServiceFactory::ShouldSyncURLForTesting(
GURL("other://anything")));
EXPECT_TRUE(SessionSyncServiceFactory::ShouldSyncURLForTesting(
GURL("chrome-other://anything")));
EXPECT_FALSE(
SessionSyncServiceFactory::ShouldSyncURLForTesting(GURL(kInvalidUrl)));
EXPECT_FALSE(SessionSyncServiceFactory::ShouldSyncURLForTesting(
GURL("file://anything")));
EXPECT_FALSE(SessionSyncServiceFactory::ShouldSyncURLForTesting(
GURL(chrome::kChromeUIVersionURL)));
EXPECT_FALSE(SessionSyncServiceFactory::ShouldSyncURLForTesting(
GURL("chrome-native://anything")));
EXPECT_FALSE(SessionSyncServiceFactory::ShouldSyncURLForTesting(
GURL("chrome-distiller://anything")));
EXPECT_FALSE(SessionSyncServiceFactory::ShouldSyncURLForTesting(
GURL("chrome-untrusted://anything")));
}
} // namespace
| [
"jengelh@inai.de"
] | jengelh@inai.de |
d036b140ccc658fae9970c3276c377b9b10b7692 | 40712dc426dfb114dfabe5913b0bfa08ab618961 | /Extras/wxWidgets-2.9.0/src/gtk/mdi.cpp | a37cb4035d1bf9482e35119bef8fbaf6a82faf0f | [] | no_license | erwincoumans/dynamica | 7dc8e06966ca1ced3fc56bd3b655a40c38dae8fa | 8b5eb35467de0495f43ed929d82617c21d2abecb | refs/heads/master | 2021-01-17T05:53:34.958159 | 2015-02-10T18:34:11 | 2015-02-10T18:34:11 | 31,622,543 | 7 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 13,204 | cpp | /////////////////////////////////////////////////////////////////////////////
// Name: src/gtk/mdi.cpp
// Purpose:
// Author: Robert Roebling
// Id: $Id: mdi.cpp 59523 2009-03-14 01:24:45Z FM $
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#if wxUSE_MDI
#include "wx/mdi.h"
#ifndef WX_PRECOMP
#include "wx/intl.h"
#include "wx/menu.h"
#endif
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// "switch_page"
//-----------------------------------------------------------------------------
extern "C" {
static void
gtk_mdi_page_change_callback( GtkNotebook *WXUNUSED(widget),
GtkNotebookPage *page,
gint WXUNUSED(page_num),
wxMDIParentFrame *parent )
{
// send deactivate event to old child
wxMDIChildFrame *child = parent->GetActiveChild();
if (child)
{
wxActivateEvent event1( wxEVT_ACTIVATE, false, child->GetId() );
event1.SetEventObject( child);
child->HandleWindowEvent( event1 );
}
// send activate event to new child
wxMDIClientWindowBase *client_window = parent->GetClientWindow();
if ( !client_window )
return;
child = NULL;
wxWindowList::compatibility_iterator node = client_window->GetChildren().GetFirst();
while ( node )
{
wxMDIChildFrame *child_frame = wxDynamicCast( node->GetData(), wxMDIChildFrame );
// child_frame can be NULL when this is called from dtor, probably
// because g_signal_connect (m_widget, "switch_page", (see below)
// isn't deleted early enough
if ( child_frame && child_frame->m_page == page )
{
child = child_frame;
break;
}
node = node->GetNext();
}
if (!child)
return;
wxActivateEvent event2( wxEVT_ACTIVATE, true, child->GetId() );
event2.SetEventObject( child);
child->HandleWindowEvent( event2 );
}
}
//-----------------------------------------------------------------------------
// wxMDIParentFrame
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame,wxFrame)
void wxMDIParentFrame::Init()
{
m_justInserted = false;
}
bool wxMDIParentFrame::Create(wxWindow *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name )
{
if ( !wxFrame::Create( parent, id, title, pos, size, style, name ) )
return false;
m_clientWindow = OnCreateClient();
if ( !m_clientWindow->CreateClient(this, GetWindowStyleFlag()) )
return false;
return true;
}
void wxMDIParentFrame::OnInternalIdle()
{
/* if a MDI child window has just been inserted
it has to be brought to the top in idle time. we
simply set the last notebook page active as new
pages can only be appended at the end */
if (m_justInserted)
{
GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->m_widget);
gtk_notebook_set_current_page( notebook, g_list_length( notebook->children ) - 1 );
/* need to set the menubar of the child */
wxMDIChildFrame *active_child_frame = GetActiveChild();
if (active_child_frame != NULL)
{
wxMenuBar *menu_bar = active_child_frame->m_menuBar;
if (menu_bar)
{
menu_bar->SetInvokingWindow(active_child_frame);
}
}
m_justInserted = false;
return;
}
wxFrame::OnInternalIdle();
wxMDIChildFrame *active_child_frame = GetActiveChild();
bool visible_child_menu = false;
wxWindowList::compatibility_iterator node = m_clientWindow->GetChildren().GetFirst();
while (node)
{
wxMDIChildFrame *child_frame = wxDynamicCast( node->GetData(), wxMDIChildFrame );
if ( child_frame )
{
wxMenuBar *menu_bar = child_frame->m_menuBar;
if ( menu_bar )
{
if (child_frame == active_child_frame)
{
if (menu_bar->Show(true))
{
menu_bar->SetInvokingWindow( child_frame );
}
visible_child_menu = true;
}
else
{
if (menu_bar->Show(false))
{
menu_bar->UnsetInvokingWindow( child_frame );
}
}
}
}
node = node->GetNext();
}
/* show/hide parent menu bar as required */
if ((m_frameMenuBar) &&
(m_frameMenuBar->IsShown() == visible_child_menu))
{
if (visible_child_menu)
{
m_frameMenuBar->Show( false );
m_frameMenuBar->UnsetInvokingWindow( this );
}
else
{
m_frameMenuBar->Show( true );
m_frameMenuBar->SetInvokingWindow( this );
}
}
}
void wxMDIParentFrame::DoGetClientSize(int* width, int* height) const
{
wxFrame::DoGetClientSize(width, height);
if (height)
{
wxMDIChildFrame* active_child_frame = GetActiveChild();
if (active_child_frame)
{
wxMenuBar* menubar = active_child_frame->m_menuBar;
if (menubar && menubar->IsShown())
{
GtkRequisition req;
gtk_widget_size_request(menubar->m_widget, &req);
*height -= req.height;
if (*height < 0) *height = 0;
}
}
}
}
wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const
{
if (!m_clientWindow) return NULL;
GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->m_widget);
if (!notebook) return NULL;
gint i = gtk_notebook_get_current_page( notebook );
if (i < 0) return NULL;
GtkNotebookPage* page = (GtkNotebookPage*) (g_list_nth(notebook->children,i)->data);
if (!page) return NULL;
wxWindowList::compatibility_iterator node = m_clientWindow->GetChildren().GetFirst();
while (node)
{
if ( wxPendingDelete.Member(node->GetData()) )
return NULL;
wxMDIChildFrame *child_frame = wxDynamicCast( node->GetData(), wxMDIChildFrame );
if (!child_frame)
return NULL;
if (child_frame->m_page == page)
return child_frame;
node = node->GetNext();
}
return NULL;
}
void wxMDIParentFrame::ActivateNext()
{
if (m_clientWindow)
gtk_notebook_next_page( GTK_NOTEBOOK(m_clientWindow->m_widget) );
}
void wxMDIParentFrame::ActivatePrevious()
{
if (m_clientWindow)
gtk_notebook_prev_page( GTK_NOTEBOOK(m_clientWindow->m_widget) );
}
//-----------------------------------------------------------------------------
// wxMDIChildFrame
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxFrame)
BEGIN_EVENT_TABLE(wxMDIChildFrame, wxFrame)
EVT_ACTIVATE(wxMDIChildFrame::OnActivate)
EVT_MENU_HIGHLIGHT_ALL(wxMDIChildFrame::OnMenuHighlight)
END_EVENT_TABLE()
void wxMDIChildFrame::Init()
{
m_menuBar = NULL;
m_page = NULL;
}
bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
wxWindowID id,
const wxString& title,
const wxPoint& WXUNUSED(pos),
const wxSize& size,
long style,
const wxString& name)
{
m_mdiParent = parent;
m_title = title;
return wxWindow::Create(parent->GetClientWindow(), id,
wxDefaultPosition, size,
style, name);
}
wxMDIChildFrame::~wxMDIChildFrame()
{
delete m_menuBar;
// wxMDIClientWindow does not get redrawn properly after last child is removed
if (m_parent && m_parent->GetChildren().size() <= 1)
gtk_widget_queue_draw(m_parent->m_widget);
}
void wxMDIChildFrame::SetMenuBar( wxMenuBar *menu_bar )
{
wxASSERT_MSG( m_menuBar == NULL, "Only one menubar allowed" );
m_menuBar = menu_bar;
if (m_menuBar)
{
wxMDIParentFrame *mdi_frame = (wxMDIParentFrame*)m_parent->GetParent();
m_menuBar->SetParent( mdi_frame );
/* insert the invisible menu bar into the _parent_ mdi frame */
m_menuBar->Show(false);
gtk_box_pack_start(GTK_BOX(mdi_frame->m_mainWidget), m_menuBar->m_widget, false, false, 0);
gtk_box_reorder_child(GTK_BOX(mdi_frame->m_mainWidget), m_menuBar->m_widget, 0);
gulong handler_id = g_signal_handler_find(
m_menuBar->m_widget,
GSignalMatchType(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA),
g_signal_lookup("size_request", GTK_TYPE_WIDGET),
0, NULL, NULL, m_menuBar);
if (handler_id != 0)
g_signal_handler_disconnect(m_menuBar->m_widget, handler_id);
gtk_widget_set_size_request(m_menuBar->m_widget, -1, -1);
}
}
wxMenuBar *wxMDIChildFrame::GetMenuBar() const
{
return m_menuBar;
}
GtkNotebook *wxMDIChildFrame::GTKGetNotebook() const
{
wxMDIClientWindow * const
client = wxStaticCast(GetParent(), wxMDIClientWindow);
wxCHECK( client, NULL );
return GTK_NOTEBOOK(client->m_widget);
}
void wxMDIChildFrame::Activate()
{
GtkNotebook * const notebook = GTKGetNotebook();
wxCHECK_RET( notebook, "no parent notebook?" );
gint pageno = gtk_notebook_page_num( notebook, m_widget );
gtk_notebook_set_current_page( notebook, pageno );
}
void wxMDIChildFrame::OnActivate( wxActivateEvent& WXUNUSED(event) )
{
}
void wxMDIChildFrame::OnMenuHighlight( wxMenuEvent& event )
{
#if wxUSE_STATUSBAR
wxMDIParentFrame *mdi_frame = (wxMDIParentFrame*)m_parent->GetParent();
if ( !ShowMenuHelp(event.GetMenuId()) )
{
// we don't have any help text for this item, but may be the MDI frame
// does?
mdi_frame->OnMenuHighlight(event);
}
#endif // wxUSE_STATUSBAR
}
void wxMDIChildFrame::SetTitle( const wxString &title )
{
if ( title == m_title )
return;
m_title = title;
GtkNotebook * const notebook = GTKGetNotebook();
wxCHECK_RET( notebook, "no parent notebook?" );
gtk_notebook_set_tab_label_text(notebook, m_widget, wxGTK_CONV( title ) );
}
//-----------------------------------------------------------------------------
// wxMDIClientWindow
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxWindow)
wxMDIClientWindow::~wxMDIClientWindow()
{
// disconnect our handler because our ~wxWindow (which is going to be called
// after this dtor) will call DestroyChildren(); in turns our children
// ~wxWindow dtors will call wxWindow::Show(false) and this will generate
// a call to gtk_mdi_page_change_callback with an invalid parent
// (because gtk_mdi_page_change_callback expects a wxMDIClientWindow but
// at that point of the dtor chain we are a simple wxWindow!)
g_signal_handlers_disconnect_by_func(m_widget,
(gpointer)gtk_mdi_page_change_callback,
GetParent());
}
bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style)
{
if ( !PreCreation( parent, wxDefaultPosition, wxDefaultSize ) ||
!CreateBase( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
style, wxDefaultValidator, "wxMDIClientWindow" ))
{
wxFAIL_MSG( "wxMDIClientWindow creation failed" );
return false;
}
m_widget = gtk_notebook_new();
g_object_ref(m_widget);
g_signal_connect (m_widget, "switch_page",
G_CALLBACK (gtk_mdi_page_change_callback), parent);
gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 );
m_parent->DoAddChild( this );
PostCreation();
Show( true );
return true;
}
void wxMDIClientWindow::AddChildGTK(wxWindowGTK* child)
{
wxMDIChildFrame* child_frame = static_cast<wxMDIChildFrame*>(child);
wxString s = child_frame->GetTitle();
if ( s.empty() )
s = _("MDI child");
GtkWidget *label_widget = gtk_label_new( s.mbc_str() );
gtk_misc_set_alignment( GTK_MISC(label_widget), 0.0, 0.5 );
GtkNotebook* notebook = GTK_NOTEBOOK(m_widget);
gtk_notebook_append_page( notebook, child->m_widget, label_widget );
child_frame->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data);
wxMDIParentFrame* parent_frame = static_cast<wxMDIParentFrame*>(GetParent());
parent_frame->m_justInserted = true;
}
#endif // wxUSE_MDI
| [
"erwin.coumans@e05b9ecc-110c-11df-b47a-af0d17c1a499"
] | erwin.coumans@e05b9ecc-110c-11df-b47a-af0d17c1a499 |
0c1509858efeb92a7db07d00ec78abc94079b28c | 50edab9babae446ac188df34a8c37d4fa537e946 | /libccif/src/bp/DeleteFlowReq.h | e852eb28a367d1a33ab8ddafa5932efc79203d7c | [] | no_license | krishnact/projects | e1cae86e05d30ad6bd4935ba7e4c25985f58d5d1 | 940a17ffa42afc28dbd8af2656e3611b87033116 | refs/heads/master | 2020-12-24T13:36:24.259601 | 2019-10-31T14:54:36 | 2019-10-31T14:54:36 | 24,039,232 | 0 | 0 | null | 2020-10-13T02:36:47 | 2014-09-15T02:04:17 | C++ | UTF-8 | C++ | false | false | 3,779 | h | #ifndef ORG_HIMALAY_CCIF_DELETEFLOWREQ
#define ORG_HIMALAY_CCIF_DELETEFLOWREQ
//@Generated(date = "Mon Feb 01 22:30:18 EST 2016")
// Copyright (2012) Krishna C Tripathi. All rights reserved.
//
// You are not allowed to read/copy/distribute following code without explicit written authorization from Krishna C Tripathi
//
#include "stdio.h"
#include "runtime.h"
#include "boost/shared_ptr.hpp"
#include "APDUHeader.h" //header for org.himalay.ccif.APDUHeader
#include "APDUBaseFactory.h"
/**
* Definitions for enclosing type
*/
#define org_himalay_ccif_DeleteFlowReq__USE_SMART_PTR
#ifdef org_himalay_ccif_DeleteFlowReq__USE_SMART_PTR
#include "boost/shared_ptr.hpp"
#define org_himalay_ccif_DeleteFlowReq__PTR_TYPE boost::shared_ptr<DeleteFlowReq>
#define org_himalay_ccif_DeleteFlowReq__NEW(x) {/** Serious **/x = org_himalay_ccif_DeleteFlowReq__PTR_TYPE(new DeleteFlowReq()); }
#define org_himalay_ccif_DeleteFlowReq__INIT(x)
#define org_himalay_ccif_DeleteFlowReq__DELETE(x)
#else
#define org_himalay_ccif_DeleteFlowReq__PTR_TYPE DeleteFlowReq*
#define org_himalay_ccif_DeleteFlowReq__NEW(x) {x= new DeleteFlowReq();}
#define org_himalay_ccif_DeleteFlowReq__INIT(x) x=NULL;
#define org_himalay_ccif_DeleteFlowReq__DELETE(x) {delete(x);x=NULL;}
#endif
/**
* Definitions for inline types
*/
//#ifndef ArrayList
#ifdef org_himalay_ccif_DeleteFlowReq__USE_SMART_PTR
#define ArrayList(x) SmartPtrList<x>
#define ArrayList_iterator(x) SmartPtrList<x>::iterator
#include "SmartPtrList.h"
#else
#define ArrayList(x) BinMessagePtrList
#define ArrayList_iterator(x) BinMessagePtrList::iterator
#include "BinMessagePtrList.h"
#endif
//#endif
// Namespace
namespace org {
namespace himalay {
namespace ccif {
using namespace ::org::himalay::msgs::runtime;
using namespace org::himalay::ccif;
using namespace org::himalay::msgs::runtime;
#ifdef org_himalay_ccif_DeleteFlowReq__USE_SMART_PTR
class DeleteFlowReq;
typedef ::boost::shared_ptr<DeleteFlowReq> DeleteFlowReqPtr;
#endif
class DeleteFlowReq :public APDUBaseFactory::APDUBase { //Concrete type is DeleteFlowReq
// public:
// long references;
public:
// members variables
// header ---
public:
org_himalay_ccif_APDUHeader__PTR_TYPE header ;
// length ---
public:
ui8 length ;
// flowId ---
public:
int flowId ;
public:
DeleteFlowReq (); // throws Exception
virtual ~DeleteFlowReq ();
public:
int readNoHeader(DataInputStream& istream);// throws IOException
public:
int read(DataInputStream& istream);// throws IOException
public:
int write(DataOutputStream& ostream);// throws IOException
public:
int dump(DumpContext& dc);// throws IOException
// Getter for header
// public: org_himalay_ccif_APDUHeader__PTR_TYPE getHeader();
// Setter for header
// public: void setHeader(org_himalay_ccif_APDUHeader__PTR_TYPE val);
// Getter for length
// public: ui8 getLength();
// Setter for length
// public: void setLength(ui8 val);
// Getter for flowId
// public: ui24 getFlowId();
// Setter for flowId
// public: void setFlowId(ui24 val);
public:
int getSize();// throws IOException
public:
void setHeader(org_himalay_ccif_APDUHeader__PTR_TYPE header);
public:
org_himalay_ccif_APDUHeader__PTR_TYPE getHeader();
};
#ifdef org_himalay_ccif_DeleteFlowReq__USE_SMART_PTR
void intrusive_ptr_add_ref(org::himalay::ccif::DeleteFlowReq* p);
void intrusive_ptr_release(org::himalay::ccif::DeleteFlowReq* p);
#endif
}
}
}
#undef ArrayList
#undef ArrayList_iterator
#endif // ORG_HIMALAY_CCIF_DELETEFLOWREQ
// End of code | [
"krishnact@himalay.org"
] | krishnact@himalay.org |
61a5c4d74891e71e23bb55758dbf2718d7bf2e5a | f8724feecc6ff9070a2f282cb68fbfe7d407b6b6 | /WebDL/MyForm.h | 3fd93e887bb7948952f65cd0d70e8602e3c0a4f6 | [] | no_license | pratyush997/WebDL | 7063acfd66ab4f2f59eb608b1dd9998ef39926ee | 0c82eb074daf78a4efe77d9450c15ce89b314a0e | refs/heads/master | 2020-04-10T03:59:48.612089 | 2016-09-06T19:46:22 | 2016-09-06T19:46:22 | 51,861,173 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,321 | h | #pragma once
namespace WebDL {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for MyForm
/// </summary>
public ref class MyForm : public System::Windows::Forms::Form
{
public:
MyForm(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ go;
protected:
private: System::Windows::Forms::TextBox^ urlbox;
protected:
private: System::Windows::Forms::TextBox^ initialNo;
private: System::Windows::Forms::TextBox^ finalNo;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::PictureBox^ pictureBox1;
private: System::Windows::Forms::CheckBox^ cmd;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::Button^ help;
private: System::Windows::Forms::Button^ downloads;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(MyForm::typeid));
this->go = (gcnew System::Windows::Forms::Button());
this->urlbox = (gcnew System::Windows::Forms::TextBox());
this->initialNo = (gcnew System::Windows::Forms::TextBox());
this->finalNo = (gcnew System::Windows::Forms::TextBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
this->cmd = (gcnew System::Windows::Forms::CheckBox());
this->label5 = (gcnew System::Windows::Forms::Label());
this->help = (gcnew System::Windows::Forms::Button());
this->downloads = (gcnew System::Windows::Forms::Button());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->BeginInit();
this->SuspendLayout();
//
// go
//
this->go->Enabled = false;
this->go->Location = System::Drawing::Point(234, 165);
this->go->Name = L"go";
this->go->Size = System::Drawing::Size(75, 23);
this->go->TabIndex = 5;
this->go->Text = L"Go";
this->go->UseVisualStyleBackColor = true;
this->go->Click += gcnew System::EventHandler(this, &MyForm::go_Click);
//
// urlbox
//
this->urlbox->Location = System::Drawing::Point(84, 56);
this->urlbox->MaxLength = 200;
this->urlbox->Name = L"urlbox";
this->urlbox->Size = System::Drawing::Size(155, 20);
this->urlbox->TabIndex = 1;
this->urlbox->TextChanged += gcnew System::EventHandler(this, &MyForm::textBox1_TextChanged);
//
// initialNo
//
this->initialNo->Enabled = false;
this->initialNo->Location = System::Drawing::Point(84, 87);
this->initialNo->MaxLength = 999;
this->initialNo->Name = L"initialNo";
this->initialNo->Size = System::Drawing::Size(44, 20);
this->initialNo->TabIndex = 2;
this->initialNo->TextChanged += gcnew System::EventHandler(this, &MyForm::initialNo_TextChanged);
//
// finalNo
//
this->finalNo->Enabled = false;
this->finalNo->Location = System::Drawing::Point(84, 116);
this->finalNo->MaxLength = 999;
this->finalNo->Name = L"finalNo";
this->finalNo->Size = System::Drawing::Size(44, 20);
this->finalNo->TabIndex = 3;
this->finalNo->TextChanged += gcnew System::EventHandler(this, &MyForm::finalNo_TextChanged);
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(16, 61);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(46, 13);
this->label1->TabIndex = 5;
this->label1->Text = L"Website";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(15, 90);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(51, 13);
this->label2->TabIndex = 6;
this->label2->Text = L"Initial No.";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(15, 118);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(49, 13);
this->label3->TabIndex = 7;
this->label3->Text = L"Final No.";
//
// pictureBox1
//
this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox1.Image")));
this->pictureBox1->Location = System::Drawing::Point(147, 200);
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->Size = System::Drawing::Size(33, 35);
this->pictureBox1->TabIndex = 9;
this->pictureBox1->TabStop = false;
this->pictureBox1->Click += gcnew System::EventHandler(this, &MyForm::pictureBox1_Click);
//
// cmd
//
this->cmd->AutoSize = true;
this->cmd->Enabled = false;
this->cmd->Location = System::Drawing::Point(259, 194);
this->cmd->Name = L"cmd";
this->cmd->Size = System::Drawing::Size(50, 17);
this->cmd->TabIndex = 4;
this->cmd->Text = L"CMD";
this->cmd->UseVisualStyleBackColor = true;
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(45, 21);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(235, 13);
this->label5->TabIndex = 12;
this->label5->Text = L"Mass download webpages from sequential URL.";
//
// help
//
this->help->Location = System::Drawing::Point(19, 165);
this->help->Name = L"help";
this->help->Size = System::Drawing::Size(75, 23);
this->help->TabIndex = 6;
this->help->Text = L"Help";
this->help->UseVisualStyleBackColor = true;
this->help->Click += gcnew System::EventHandler(this, &MyForm::help_Click);
//
// downloads
//
this->downloads->Location = System::Drawing::Point(126, 165);
this->downloads->Name = L"downloads";
this->downloads->Size = System::Drawing::Size(75, 23);
this->downloads->TabIndex = 13;
this->downloads->Text = L"Downloads";
this->downloads->UseVisualStyleBackColor = true;
this->downloads->Click += gcnew System::EventHandler(this, &MyForm::downloads_Click_1);
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(322, 243);
this->Controls->Add(this->downloads);
this->Controls->Add(this->help);
this->Controls->Add(this->label5);
this->Controls->Add(this->cmd);
this->Controls->Add(this->pictureBox1);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->finalNo);
this->Controls->Add(this->initialNo);
this->Controls->Add(this->urlbox);
this->Controls->Add(this->go);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedSingle;
this->Icon = (cli::safe_cast<System::Drawing::Icon^>(resources->GetObject(L"$this.Icon")));
this->MaximizeBox = false;
this->MinimizeBox = false;
this->Name = L"MyForm";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = L"WebDL";
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
this->initialNo->Enabled = true;
}
private: System::Void initialNo_TextChanged(System::Object^ sender, System::EventArgs^ e) {
this->finalNo->Enabled = true;
}
private: System::Void finalNo_TextChanged(System::Object^ sender, System::EventArgs^ e) {
this->go->Enabled = true;
this->cmd->Enabled= true;
}
private: System::Void go_Click(System::Object^ sender, System::EventArgs^ e) {
// Input set
int ini, fin;
ini = System::Convert::ToInt16(initialNo->Text);
fin = System::Convert::ToInt16(finalNo->Text);
String^ url;
url = (urlbox->Text);
//System::IO::File::Create("job.bat"); // Batch File Creation
System::IO::StreamWriter^ writer = gcnew System::IO::StreamWriter("job.bat"); //open the file for writing.
for (int i = ini; i <= fin; i++)
{
writer->WriteLine("\nwget --continue --directory-prefix=\"C:\\WebDL\\Webpages\" --html-extension --no-cookies --output-document=\"C:\\WebDL\\Webpages\\""" + i + ".html\" --convert-links --user-agent=\"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.99 Safari/533.4\" \"" + url + i + "\"\r\n");
//Sorry for such a long string.
}
writer->Close();
MessageBox::Show("Script Creation is done.\nExecution will begin now.");
MessageBoxButtons::OK;
if (cmd)
{
System::Diagnostics::Process::Start("cmd", "/c job.bat &PAUSE"); // Can't use +xyz one.
}
else
{
System::Diagnostics::Process::Start("cmd", "/c job.bat");
}
}
private: System::Void pictureBox1_Click(System::Object^ sender, System::EventArgs^ e) {
System::Diagnostics::Process::Start("https://github.com/pratyush997");
}
private: System::Void help_Click(System::Object^ sender, System::EventArgs^ e) {
MessageBox::Show("Sample : -\t\t\tVersion : 1.0\n\nWebsite : www.google.com/X \n\tWhere 'X' - Sequential Page\n\nInitial No : 2\n\nFinal No : 50\n");
//MessageBox::Show("Downloads Directory : - C:\WebDL\Webpages"); // Gotta fix it asap.
}
private: System::Void downloads_Click_1(System::Object^ sender, System::EventArgs^ e) {
System::Diagnostics::Process::Start("explorer","C:\\WebDL\\Webpages");
}
};
}
| [
"pratyush997@outlook.com"
] | pratyush997@outlook.com |
57ad0de2c0ea27b734ebd6fd08dcc068f87fb356 | e9193e13e5788952fd40abe65fa3ca6143369114 | /src/sst/elements/memHierarchy/testcpu/standardCPU.cc | 43d1c4835f266e88b18967483b49bd20bba61b6d | [
"BSD-3-Clause"
] | permissive | SalvatoreDiGirolamo/sst-elements | 00ea1786b3ef59dfbc9035ff98b68076c4fc90b6 | 8a491cf7149c400220b7bfcdf4de1fed6715ba7c | refs/heads/master | 2022-02-25T14:43:11.971363 | 2022-01-30T00:01:25 | 2022-01-30T00:01:25 | 217,837,549 | 0 | 0 | NOASSERTION | 2019-10-27T10:19:31 | 2019-10-27T10:19:31 | null | UTF-8 | C++ | false | false | 14,867 | cc | // Copyright 2009-2021 NTESS. Under the terms
// of Contract DE-NA0003525 with NTESS, the U.S.
// Government retains certain rights in this software.
//
// Copyright (c) 2009-2021, NTESS
// All rights reserved.
//
// Portions are copyright of other developers:
// See the file CONTRIBUTORS.TXT in the top level directory
// the distribution for more information.
//
// This file is part of the SST software package. For license
// information, see the LICENSE file in the top level directory of the
// distribution.
#include <sst_config.h>
#include "testcpu/standardCPU.h"
#include <sst/core/params.h>
#include <sst/core/simulation.h>
#include <sst/core/interfaces/stringEvent.h>
#include "util.h"
using namespace SST;
using namespace SST::Interfaces;
using namespace SST::MemHierarchy;
using namespace SST::Statistics;
/* Constructor */
standardCPU::standardCPU(ComponentId_t id, Params& params) :
Component(id), rng(id, 13)
{
// Restart the RNG to ensure completely consistent results
// Seed with user-provided seed
uint32_t z_seed = params.find<uint32_t>("rngseed", 7);
rng.restart(z_seed, 13);
out.init("", params.find<unsigned int>("verbose", 1), 0, Output::STDOUT);
bool found;
/* Required parameter - memFreq */
memFreq = params.find<int>("memFreq", 0, found);
if (!found) {
out.fatal(CALL_INFO, -1,"%s, Error: parameter 'memFreq' was not provided\n",
getName().c_str());
}
/* Required parameter - memSize */
UnitAlgebra memsize = params.find<UnitAlgebra>("memSize", UnitAlgebra("0B"), found);
if ( !found ) {
out.fatal(CALL_INFO, -1, "%s, Error: parameter 'memSize' was not provided\n",
getName().c_str());
}
if (!(memsize.hasUnits("B"))) {
out.fatal(CALL_INFO, -1, "%s, Error: memSize parameter requires units of 'B' (SI OK). You provided '%s'\n",
getName().c_str(), memsize.toString().c_str() );
}
maxAddr = memsize.getRoundedValue() - 1;
mmioAddr = params.find<uint64_t>("mmio_addr", "0", found);
if (found) {
sst_assert(mmioAddr > maxAddr, CALL_INFO, -1, "incompatible parameters: mmio_addr must be >= memSize (mmio above physical memory addresses).\n");
}
maxOutstanding = params.find<uint64_t>("maxOutstanding", 10);
/* Required parameter - opCount */
ops = params.find<uint64_t>("opCount", 0, found);
sst_assert(found, CALL_INFO, -1, "%s, Error: parameter 'opCount' was not provided\n", getName().c_str());
/* Frequency of different ops */
unsigned readf = params.find<unsigned>("read_freq", 25);
unsigned writef = params.find<unsigned>("write_freq", 75);
unsigned flushf = params.find<unsigned>("flush_freq", 0);
unsigned flushinvf = params.find<unsigned>("flushinv_freq", 0);
unsigned customf = params.find<unsigned>("custom_freq", 0);
unsigned llscf = params.find<unsigned>("llsc_freq", 0);
unsigned mmiof = params.find<unsigned>("mmio_freq", 0);
if (mmiof != 0 && mmioAddr == 0) {
out.fatal(CALL_INFO, -1, "%s, Error: mmio_freq is > 0 but no mmio device has been specified via mmio_addr\n", getName().c_str());
}
high_mark = readf + writef + flushf + flushinvf + customf + llscf + mmiof; /* Numbers less than this and above other marks indicate read */
if (high_mark == 0) {
out.fatal(CALL_INFO, -1, "%s, Error: The input doesn't indicate a frequency for any command type.\n", getName().c_str());
}
write_mark = writef; /* Numbers less than this indicate write */
flush_mark = write_mark + flushf; /* Numbers less than this indicate flush */
flushinv_mark = flush_mark + flushinvf; /* Numbers less than this indicate flush-inv */
custom_mark = flushinv_mark + customf; /* Numbers less than this indicate flush */
llsc_mark = custom_mark + llscf; /* Numbers less than this indicate LL-SC */
mmio_mark = llsc_mark + mmiof; /* Numbers less than this indicate MMIO read or write */
noncacheableRangeStart = params.find<uint64_t>("noncacheableRangeStart", 0);
noncacheableRangeEnd = params.find<uint64_t>("noncacheableRangeEnd", 0);
noncacheableSize = noncacheableRangeEnd - noncacheableRangeStart;
maxReqsPerIssue = params.find<uint32_t>("reqsPerIssue", 1);
if (maxReqsPerIssue < 1) {
out.fatal(CALL_INFO, -1, "%s, Error: StandardCPU cannot issue less than one request at a time...fix your input deck\n", getName().c_str());
}
// Tell the simulator not to end until we OK it
registerAsPrimaryComponent();
primaryComponentDoNotEndSim();
//set our clock
std::string clockFreq = params.find<std::string>("clock", "1GHz");
clockHandler = new Clock::Handler<standardCPU>(this, &standardCPU::clockTic);
clockTC = registerClock( clockFreq, clockHandler );
/* Find the interface the user provided in the Python and load it*/
memory = loadUserSubComponent<StandardMem>("memory", ComponentInfo::SHARE_NONE, clockTC, new StandardMem::Handler<standardCPU>(this, &standardCPU::handleEvent));
if (!memory) {
out.fatal(CALL_INFO, -1, "Unable to load memHierarchy.standardInterface subcomponent; check that 'memory' slot is filled in input.\n");
}
clock_ticks = 0;
requestsPendingCycle = registerStatistic<uint64_t>("pendCycle");
num_reads_issued = registerStatistic<uint64_t>("reads");
num_writes_issued = registerStatistic<uint64_t>("writes");
if (noncacheableSize != 0) {
noncacheableReads = registerStatistic<uint64_t>("readNoncache");
noncacheableWrites = registerStatistic<uint64_t>("writeNoncache");
}
if (flushf != 0 ) {
num_flushes_issued = registerStatistic<uint64_t>("flushes");
}
if (flushinvf != 0) {
num_flushinvs_issued = registerStatistic<uint64_t>("flushinvs");
}
if (customf != 0) {
num_custom_issued = registerStatistic<uint64_t>("customReqs");
}
if (llscf != 0) {
num_llsc_issued = registerStatistic<uint64_t>("llsc");
num_llsc_success = registerStatistic<uint64_t>("llsc_success");
}
ll_issued = false;
}
void standardCPU::init(unsigned int phase)
{
memory->init(phase);
}
void standardCPU::setup() {
memory->setup();
lineSize = memory->getLineSize();
}
void standardCPU::finish() { }
// incoming events are scanned and deleted
void standardCPU::handleEvent(StandardMem::Request *req)
{
std::map<uint64_t, std::pair<SimTime_t,std::string>>::iterator i = requests.find(req->getID());
if ( requests.end() == i ) {
out.fatal(CALL_INFO, -1, "Event (%" PRIx64 ") not found!\n", req->getID());
} else {
SimTime_t et = getCurrentSimTime() - i->second.first;
if (i->second.second == "StoreConditional" && req->getSuccess())
num_llsc_success->addData(1);
requests.erase(i);
}
delete req;
}
bool standardCPU::clockTic( Cycle_t )
{
++clock_ticks;
// Histogram bin the requests pending per cycle
requestsPendingCycle->addData((uint64_t) requests.size());
// communicate?
if ((0 != ops) && (0 == (rng.generateNextUInt32() % memFreq))) {
if ( requests.size() < maxOutstanding ) {
// yes, communicate
// create event
// x4 to prevent splitting blocks
uint32_t reqsToSend = 1;
if (maxReqsPerIssue > 1) reqsToSend += rng.generateNextUInt32() % maxReqsPerIssue;
if (reqsToSend > (maxOutstanding - requests.size())) reqsToSend = maxOutstanding - requests.size();
if (reqsToSend > ops) reqsToSend = ops;
for (int i = 0; i < reqsToSend; i++) {
StandardMem::Addr addr = rng.generateNextUInt64();
std::vector<uint8_t> data;
data.resize(4);
data[0] = (addr >> 24) & 0xff;
data[1] = (addr >> 16) & 0xff;
data[2] = (addr >> 8) & 0xff;
data[3] = (addr >> 0) & 0xff;
uint32_t instNum = rng.generateNextUInt32() % high_mark;
uint64_t size = 4;
std::string cmdString = "Read";
Interfaces::StandardMem::Request* req;
if (ll_issued) {
req = createSC();
}else if (instNum < write_mark) {
req = createWrite(addr);
} else if (instNum < flush_mark) {
req = createFlush(addr);
} else if (instNum < flushinv_mark) {
req = createFlushInv(addr);
} else if (instNum < custom_mark) {
} else if (instNum < llsc_mark) {
req = createLL(addr);
} else if (instNum < mmio_mark) {
bool opType = rng.generateNextUInt32() % 2;
if (opType) {
req = createMMIORead();
} else {
req = createMMIOWrite();
}
} else {
req = createRead(addr);
}
if (req->needsResponse()) {
requests[req->getID()] = std::make_pair(getCurrentSimTime(), cmdString);
}
memory->send(req);
ops--;
}
}
}
// Check whether to end the simulation
if ( 0 == ops && requests.empty() ) {
out.verbose(CALL_INFO, 1, 0, "StandardCPU: Test Completed Successfuly\n");
primaryComponentOKToEndSim();
return true; // Turn our clock off while we wait for any other CPUs to end
}
// return false so we keep going
return false;
}
/* Methods for sending different kinds of requests */
StandardMem::Request* standardCPU::createWrite(Addr addr) {
addr = ((addr % maxAddr)>>2) << 2;
// Dummy payload
std::vector<uint8_t> data;
data.resize(4);
data[0] = (addr >> 24) & 0xff;
data[1] = (addr >> 16) & 0xff;
data[2] = (addr >> 8) & 0xff;
data[3] = (addr >> 0) & 0xff;
StandardMem::Request* req = new Interfaces::StandardMem::Write(addr, data.size(), data);
num_writes_issued->addData(1);
if (addr >= noncacheableRangeStart && addr < noncacheableRangeEnd) {
req->setNoncacheable();
noncacheableWrites->addData(1);
}
out.verbose(CALL_INFO, 2, 0, "%s: %" PRIu64 " Issued %sWrite for address 0x%" PRIx64 "\n", getName().c_str(), ops, req->getNoncacheable() ? "Noncacheable " : "", addr);
return req;
}
StandardMem::Request* standardCPU::createRead(Addr addr) {
addr = ((addr % maxAddr)>>2) << 2;
StandardMem::Request* req = new Interfaces::StandardMem::Read(addr, 4);
num_reads_issued->addData(1);
if (addr >= noncacheableRangeStart && addr < noncacheableRangeEnd) {
req->setNoncacheable();
noncacheableReads->addData(1);
}
out.verbose(CALL_INFO, 2, 0, "%s: %" PRIu64 " Issued %sRead for address 0x%" PRIx64 "\n", getName().c_str(), ops, req->getNoncacheable() ? "Noncacheable " : "", addr);
return req;
}
StandardMem::Request* standardCPU::createFlush(Addr addr) {
addr = ((addr % (maxAddr - noncacheableSize)>>2) << 2);
if (addr >= noncacheableRangeStart && addr < noncacheableRangeEnd)
addr += noncacheableRangeEnd;
addr = addr - (addr % lineSize);
StandardMem::Request* req = new Interfaces::StandardMem::FlushAddr(addr, lineSize, false, 10);
num_flushes_issued->addData(1);
out.verbose(CALL_INFO, 2, 0, "%s: %" PRIu64 " Issued FlushAddr for address 0x%" PRIx64 "\n", getName().c_str(), ops, addr);
return req;
}
StandardMem::Request* standardCPU::createFlushInv(Addr addr) {
addr = ((addr % (maxAddr - noncacheableSize)>>2) << 2);
if (addr >= noncacheableRangeStart && addr < noncacheableRangeEnd)
addr += noncacheableRangeEnd;
addr = addr - (addr % lineSize);
StandardMem::Request* req = new Interfaces::StandardMem::FlushAddr(addr, lineSize, true, 10);
num_flushinvs_issued->addData(1);
out.verbose(CALL_INFO, 2, 0, "%s: %" PRIu64 " Issued FlushAddrInv for address 0x%" PRIx64 "\n", getName().c_str(), ops, addr);
return req;
}
StandardMem::Request* standardCPU::createLL(Addr addr) {
// Addr needs to be a cacheable range
Addr cacheableSize = maxAddr + 1 - noncacheableRangeEnd + noncacheableRangeStart;
addr = (addr % (cacheableSize >> 2)) << 2;
if (addr >= noncacheableRangeStart && addr < noncacheableRangeEnd) {
addr += noncacheableRangeEnd;
}
// Align addr
addr = (addr >> 2) << 2;
StandardMem::Request* req = new Interfaces::StandardMem::LoadLink(addr, 4);
// Set these so we issue a matching sc
ll_addr = addr;
ll_issued = true;
out.verbose(CALL_INFO, 2, 0, "%s: %" PRIu64 " Issued LoadLink for address 0x%" PRIx64 "\n", getName().c_str(), ops, addr);
return req;
}
StandardMem::Request* standardCPU::createSC() {
std::vector<uint8_t> data;
data.resize(4);
data[0] = (ll_addr >> 24) & 0xff;
data[1] = (ll_addr >> 16) & 0xff;
data[2] = (ll_addr >> 8) & 0xff;
data[3] = (ll_addr >> 0) & 0xff;
StandardMem::Request* req = new Interfaces::StandardMem::StoreConditional(ll_addr, data.size(), data);
num_llsc_issued->addData(1);
ll_issued = false;
out.verbose(CALL_INFO, 2, 0, "%s: %" PRIu64 " Issued StoreConditional for address 0x%" PRIx64 "\n", getName().c_str(), ops, ll_addr);
return req;
}
StandardMem::Request* standardCPU::createMMIOWrite() {
bool posted = rng.generateNextUInt32() % 2;
int32_t payload = rng.generateNextInt32();
payload >>= 16; // Shrink the number a bit
int32_t payload_cp = payload;
std::vector<uint8_t> data;
for (int i = 0; i < sizeof(int32_t); i++) {
data.push_back(payload & 0xFF);
payload >>=8;
}
StandardMem::Request* req = new Interfaces::StandardMem::Write(mmioAddr, sizeof(int32_t), data, posted);
out.verbose(CALL_INFO, 2, 0, "%s: %" PRIu64 " Issued MMIO Write for address 0x%" PRIx64 " with payload %d\n", getName().c_str(), ops, mmioAddr, payload_cp);
return req;
}
StandardMem::Request* standardCPU::createMMIORead() {
StandardMem::Request* req = new Interfaces::StandardMem::Read(mmioAddr, sizeof(int32_t));
out.verbose(CALL_INFO, 2, 0, "%s: %" PRIu64 " Issued MMIO Read for address 0x%" PRIx64 "\n", getName().c_str(), ops, mmioAddr);
return req;
}
void standardCPU::emergencyShutdown() {
if (out.getVerboseLevel() > 1) {
if (out.getOutputLocation() == Output::STDOUT)
out.setOutputLocation(Output::STDERR);
out.output("MemHierarchy::standardCPU %s\n", getName().c_str());
out.output(" Outstanding events: %zu\n", requests.size());
out.output("End MemHierarchy::standardCPU %s\n", getName().c_str());
}
}
| [
"grvosku@sandia.gov"
] | grvosku@sandia.gov |
15b8be05ac2d07b7c29c5a769dd0474defb1af29 | e763b855be527d69fb2e824dfb693d09e59cdacb | /aws-cpp-sdk-codedeploy/source/model/ListDeploymentGroupsResult.cpp | 8894bb99ef927de580c2ce4570f4e8383b5d321a | [
"MIT",
"Apache-2.0",
"JSON"
] | permissive | 34234344543255455465/aws-sdk-cpp | 47de2d7bde504273a43c99188b544e497f743850 | 1d04ff6389a0ca24361523c58671ad0b2cde56f5 | refs/heads/master | 2023-06-10T16:15:54.618966 | 2018-05-07T23:32:08 | 2018-05-07T23:32:08 | 132,632,360 | 1 | 0 | Apache-2.0 | 2023-06-01T23:20:47 | 2018-05-08T15:56:35 | C++ | UTF-8 | C++ | false | false | 1,958 | cpp | /*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#include <aws/codedeploy/model/ListDeploymentGroupsResult.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/AmazonWebServiceResult.h>
#include <aws/core/utils/StringUtils.h>
#include <aws/core/utils/UnreferencedParam.h>
#include <utility>
using namespace Aws::CodeDeploy::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
using namespace Aws;
ListDeploymentGroupsResult::ListDeploymentGroupsResult()
{
}
ListDeploymentGroupsResult::ListDeploymentGroupsResult(const Aws::AmazonWebServiceResult<JsonValue>& result)
{
*this = result;
}
ListDeploymentGroupsResult& ListDeploymentGroupsResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result)
{
const JsonValue& jsonValue = result.GetPayload();
if(jsonValue.ValueExists("applicationName"))
{
m_applicationName = jsonValue.GetString("applicationName");
}
if(jsonValue.ValueExists("deploymentGroups"))
{
Array<JsonValue> deploymentGroupsJsonList = jsonValue.GetArray("deploymentGroups");
for(unsigned deploymentGroupsIndex = 0; deploymentGroupsIndex < deploymentGroupsJsonList.GetLength(); ++deploymentGroupsIndex)
{
m_deploymentGroups.push_back(deploymentGroupsJsonList[deploymentGroupsIndex].AsString());
}
}
if(jsonValue.ValueExists("nextToken"))
{
m_nextToken = jsonValue.GetString("nextToken");
}
return *this;
}
| [
"henso@amazon.com"
] | henso@amazon.com |
e36530f1875f3f3d4fe041c42ea17f1d56fcf1a6 | 28ca4fe10b0b9a4ae917b665acf3545f7fb7c613 | /main.ino | bae4c9e5a25cc8993ddfa817d4b8ecc2dc03d936 | [] | no_license | eoinoreilly30/autonomous-mobot | 54175556947438d7fbb72725b11d4cf06c1d23c1 | c940d35cb8d48fd5e1f1ad920004ea178b5dd01f | refs/heads/master | 2021-08-17T16:16:29.041989 | 2020-05-13T23:45:32 | 2020-05-13T23:45:32 | 181,191,300 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 24,780 | ino | // Libraries used in BFS algorithm
#include <StackList.h>
#include <QueueArray.h>
/////////////////////////////////////////////////////////////////////////
// Wifi variables
////////////////////////////////////////////////////////////////////////
#ifndef __CC3200R1M1RGC__
#include <SPI.h>
#endif
#include <WiFi.h>
char ssid[] = "NETGEAR65";
char password[] = "littlecello367";
IPAddress server(192,168,1,2);
WiFiClient client;
////////////////////////////////////////////////////////////////////////
// Motor Control variables
////////////////////////////////////////////////////////////////////////
int rightMotorPWM = 40;
int rightMotorPhase = 39;
int leftMotorPWM = 38;
int leftMotorPhase = 34;
int motorOffset = 4;
int speedVal = 220; //180
int harderTurn = 220;
int medTurn = 130;
int softTurn = 70;
int turnOnSpotVal = 130; // 90
////////////////////////////////////////////////////////////////////////
// Sensor variables
////////////////////////////////////////////////////////////////////////
int AnalogValue[5] = {0,0,0,0,0};
int sensorOnOff[5] = {0,0,0,0,0};
int AnalogPin[5] = {A9, A11, A13, A8, A14};
int distanceSensorPin = 2;
int distanceThreshold = 680;
int threshold = 150;
bool reachedWhiteMark = false;
bool lost = false;
unsigned long currentTime;
////////////////////////////////////////////////////////////////////////////////////
// Breadth First Search Variables
////////////////////////////////////////////////////////////////////////////////////
bool marked[8];
int edgeTo[8]; // parent array
StackList<int> path;
int current = 0;
int cameFrom = 4;
int dest;
bool edge[8][8] = { // Track stored as a truth table
// 0 1 2 3 4 5 6 7
/*0*/ {false, false, false, false, true, false, true, false},
/*1*/ {false, false, false, false, false, false, true, true},
/*2*/ {false, false, false, true, false, false, true, false},
/*3*/ {false, false, true, false, false, false, false, true},
/*4*/ {true, false, false, false, false, false, false, true},
/*5*/ {false, false, false, false, false, false, false, false},
/*6*/ {true, true, true, false, false, false, false, false},
/*7*/ {false, true, false, true, true, false, false, false},
};
////////////////////////////////////////////////////////////////////////////////////
// Setup
////////////////////////////////////////////////////////////////////////////////////
void setup() {
Serial.begin(9600);
Serial.println("Begin");
pinMode(distanceSensorPin, INPUT);
// Wifi setup
connectToServer();
// drive to 0 checkpoint
drive();
stopLine();
reachedWhiteMark = false;
}
////////////////////////////////////////////////////////////////////////////
// Main Loop
////////////////////////////////////////////////////////////////////////////
void loop(){
// send current location and receive next destination
receiveDest(current);
// find shortest routes to all checkpoints
breadthFirstSearch(current);
// find shortest route to the specified destination
// but if dest == 5, first go to 7, then 5
if(dest == 5){
pathTo(7);
}
else {
pathTo(dest);
}
// 'path' contains the checkpoints to get to the destination
while(!path.isEmpty()) {
// conditions for each checkpoint on track, based on the direction you are approaching them
switch(path.pop()) {
case 0:
if(current == 0){
drive();
}
else if(current == 4){
if(cameFrom == 0){
turn180();
drive();
}
else if(cameFrom == 7){
drive();
}
current = 0;
cameFrom = 4;
}
else if(current == 6){
if(cameFrom == 1){
turn90RightSix();
drive();
}
else if(cameFrom == 2){
drive();
}
current = 0;
cameFrom = 6;
}
break;
case 1:
if(current == 6){
if(cameFrom == 0){
turn90Left();
drive();
}
else if(cameFrom == 2){
turn90Right();
drive();
}
current = 1;
cameFrom = 6;
}
else if(current == 7){
if(cameFrom == 4){
turn90Right();
drive();
}
else if(cameFrom == 3){
turn90Left();
drive();
}
current = 1;
cameFrom = 7;
}
break;
case 2:
if(current == 3){
if(cameFrom == 2){
turn180();
drive();
}
else if(cameFrom == 7){
drive();
}
current = 2;
cameFrom = 3;
}
else if(current == 6){
if(cameFrom == 1){
turn90LeftSix();
drive();
}
else if(cameFrom == 0){
drive();
}
current = 2;
cameFrom = 6;
}
break;
case 3:
if(current == 2){
if(cameFrom == 6){
drive();
}
else if(cameFrom == 3){
turn180();
drive();
}
current = 3;
cameFrom = 2;
}
else if(current == 7){
if(cameFrom == 4){
drive();
}
else if(cameFrom == 1){
turn90Right();
drive();
}
current = 3;
cameFrom = 7;
}
break;
case 4:
if(current == 0){
if(cameFrom == 6){
drive();
}
else if(cameFrom == 4){
turn180();
drive();
}
current = 4;
cameFrom = 0;
}
else if(current == 7){
if(cameFrom == 3){
drive();
}
else if(cameFrom == 1){
turn90Left();
drive();
}
current = 4;
cameFrom = 7;
}
break;
case 6:
if(current == 0){
if(cameFrom == 4){
drive();
}
else if(cameFrom == 6){
turn180();
drive();
}
current = 6;
cameFrom = 0;
}
else if(current == 1){
if(cameFrom == 7){
drive();
}
else if(cameFrom == 6){
turn180();
drive();
}
current = 6;
cameFrom = 1;
}
else if(current == 2){
if(cameFrom == 3){
drive();
}
else if(cameFrom == 6){
turn180();
drive();
}
current = 6;
cameFrom = 2;
}
break;
case 7:
if(current == 4){
if(cameFrom == 0){
drive();
}
else if(cameFrom == 7){
turn180();
drive();
}
current = 7;
cameFrom = 4;
}
else if(current == 1){
if(cameFrom == 6){
drive();
}
else if(cameFrom == 7){
turn180();
drive();
}
current = 7;
cameFrom = 1;
}
else if(current == 3){
if(cameFrom == 2){
drive();
}
else if(cameFrom == 7){
turn180();
drive();
}
current = 7;
cameFrom = 3;
}
break;
}
reachedWhiteMark = false;
}
// when the above while loop exits, the destination is reached
stopLine();
// if 5 was the destination, drive to 5 using distance sensor
if(dest == 5){
if(cameFrom == 4){
turn90Left();
}
else if(cameFrom == 3){
turn90Right();
}
else if(cameFrom == 1){
park();
}
park();
}
}
// this function uses the distance sensor to park at the wall
void park(){
// first drive up the remaining white line
while(!isLost()){
readValues();
if(sensorOnOff[0] == 0 && sensorOnOff[1] == 0 && sensorOnOff[2] == 1 && sensorOnOff[3] == 0 && sensorOnOff[4] == 0){ // 0 0 1 0 0
forward();
}
else if(sensorOnOff[0] == 0 && sensorOnOff[1] == 1 && sensorOnOff[2] == 0 && sensorOnOff[3] == 0 && sensorOnOff[4] == 0){ // 0 1 0 0 0
turnLeft(medTurn);
}
else if(sensorOnOff[0] == 0 && sensorOnOff[1] == 0 && sensorOnOff[2] == 0 && sensorOnOff[3] == 1 && sensorOnOff[4] == 0){ // 0 0 0 1 0
turnRight(medTurn);
}
else if(sensorOnOff[0] == 0 && sensorOnOff[1] == 1 && sensorOnOff[2] == 1 && sensorOnOff[3] == 0 && sensorOnOff[4] == 0){ // 0 1 1 0 0
turnLeft(softTurn);
}
else if(sensorOnOff[0] == 0 && sensorOnOff[1] == 0 && sensorOnOff[2] == 1 && sensorOnOff[3] == 1 && sensorOnOff[4] == 0){ // 0 0 1 1 0
turnRight(softTurn);
}
}
// then keep driving forward into the wild
while(readDistanceSensor() < distanceThreshold){
forward();
}
// stop and update server
stopLine();
receiveDest(5);
}
////////////////////////////////////////////////////////////////////////////
// Path finding algorithm
////////////////////////////////////////////////////////////////////////////
void breadthFirstSearch(int node){
// reset variables
for(int i=0; i<8; i++){
edgeTo[i] = 0;
marked[i] = false;
}
// 'marked' means the node has been visited
marked[node] = true;
// 'q' contains the unexplored nodes
QueueArray<int> q;
q.push(node);
while(!q.isEmpty()){
// take a node...
int v = q.pop();
// and explore each neighbour of 'v'
for(int i=0; i<8; i++){
// first check if they are connected
if(edge[v][i] || edge[i][v]){
// then check if they have been visited before
if(!marked[i]){
marked[i] = true;
q.push(i);
// store the parent of current node 'i' as 'v'
edgeTo[i] = v;
}
}
}
}
}
// traverse back up minimum spanning tree
void pathTo(int destination) {
for(int i=destination; i != current; i = edgeTo[i]){
path.push(i);
if(path.peek() == current){
break;
}
}
}
////////////////////////////////////////////////////////////////////////////
// Wifi functions
////////////////////////////////////////////////////////////////////////////
void connectToServer(){
Serial.print("Attempting to connect to Network named: ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while ( WiFi.status() != WL_CONNECTED);
Serial.println("\nYou're connected to the network");
Serial.println("Waiting for an ip address");
while (WiFi.localIP() == INADDR_NONE);
Serial.println("\nIP Address obtained");
printWifiStatus();
}
void receiveDest(int currentPos){
Serial.println("\nStarting connection to server...");
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println("connected to server");
// Make a HTTP request:
String messageToSend = "POST /mobilerobotics/api/position/tag/?group=2&pos=";
messageToSend += String(currentPos);
messageToSend += " HTTP/1.1";
Serial.println("Sending message...");
client.println(messageToSend);
client.println("Host: energia.nu");
client.println("Connection: close");
client.println();
}
// Read reply from server
char buffer[255] = {0};
while (!client.available()) {}; // Wait for connection to be available...
if (client.available()) {
client.read((uint8_t*)buffer, client.available());
}
String finalMessage = buffer;
Serial.println("Full message received:");
Serial.println(finalMessage);
Serial.println("End of received");
// Extract next destination by splitting up the string
String jsonMessage = finalMessage.substring(finalMessage.indexOf("{"), finalMessage.length()-1);
String nextPosition = jsonMessage.substring(16, 17);
// end of trip, do nothing
if(nextPosition.equals("T")){
while(true);
}
// otherwise convert to integer and store in dest
dest = nextPosition.toInt();
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting from server.");
client.stop();
}
}
void printWifiStatus() {
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
}
////////////////////////////////////////////////////////////////////////////
// Line following functions
////////////////////////////////////////////////////////////////////////////
// this function just follows the white line and returns when a checkpoint is reached
void drive() {
while(reachedWhiteMark == false){
readValues();
//normal operation
if(sensorOnOff[0] == 0 && sensorOnOff[1] == 0 && sensorOnOff[2] == 1 && sensorOnOff[3] == 0 && sensorOnOff[4] == 0){ // 0 0 1 0 0
lost = false;
forward();
}
else if(sensorOnOff[0] == 0 && sensorOnOff[1] == 1 && sensorOnOff[2] == 0 && sensorOnOff[3] == 0 && sensorOnOff[4] == 0){ // 0 1 0 0 0
lost = false;
turnLeft(medTurn);
}
else if(sensorOnOff[0] == 0 && sensorOnOff[1] == 0 && sensorOnOff[2] == 0 && sensorOnOff[3] == 1 && sensorOnOff[4] == 0){ // 0 0 0 1 0
lost = false;
turnRight(medTurn);
}
else if(sensorOnOff[0] == 0 && sensorOnOff[1] == 1 && sensorOnOff[2] == 1 && sensorOnOff[3] == 0 && sensorOnOff[4] == 0){ // 0 1 1 0 0
lost = false;
turnLeft(softTurn);
}
else if(sensorOnOff[0] == 0 && sensorOnOff[1] == 0 && sensorOnOff[2] == 1 && sensorOnOff[3] == 1 && sensorOnOff[4] == 0){ // 0 0 1 1 0
lost = false;
turnRight(softTurn);
}
else if(sensorOnOff[0] == 1 && sensorOnOff[1] == 1 && sensorOnOff[2] == 0 && sensorOnOff[3] == 0 && sensorOnOff[4] == 0){ // 1 1 0 0 0
lost = false;
turnLeftHard();
}
else if(sensorOnOff[0] == 0 && sensorOnOff[1] == 0 && sensorOnOff[2] == 0 && sensorOnOff[3] == 1 && sensorOnOff[4] == 1){ // 0 0 0 1 1
lost = false;
turnRightHard();
}
else if(sensorOnOff[0] == 1 && sensorOnOff[1] == 0 && sensorOnOff[2] == 0 && sensorOnOff[3] == 0 && sensorOnOff[4] == 0){ // 1 0 0 0 0
lost = false;
turnLeftHard();
}
else if(sensorOnOff[0] == 0 && sensorOnOff[1] == 0 && sensorOnOff[2] == 0 && sensorOnOff[3] == 0 && sensorOnOff[4] == 1){ // 0 0 0 0 1
lost = false;
turnRightHard();
}
// checkpoint reached, therefore stop just after white line
else if(isAtStopLine()){
lost = false;
// wait until we have drove past the white mark
while(isAtStopLine());
Serial.println("Reached white mark");
reachedWhiteMark = true;
}
// if car has lost the white line, wait for 1000ms before driving backwards
else if(isLost()){
// first time we are lost, record the time, break
if(lost == false){
currentTime = millis();
lost = true;
}
// only if we are lost for more than 1000 milliseconds, reverse
else if(millis() - currentTime >= 1000){
stopLine();
while(isLost()){
reverse();
}
}
}
}
}
// returns true if the sensors detect a checkpoint
bool isAtStopLine(){
readValues();
if(sensorOnOff[0] == 1 && sensorOnOff[1] == 1 && sensorOnOff[2] == 1 && sensorOnOff[3] == 1 && sensorOnOff[4] == 1){ // 1 1 1 1 1
return true;
}
else if(sensorOnOff[0] == 1 && sensorOnOff[1] == 1 && sensorOnOff[2] == 1 && sensorOnOff[3] == 0 && sensorOnOff[4] == 0){ // 1 1 1 0 0
return true;
}
else if(sensorOnOff[0] == 0 && sensorOnOff[1] == 0 && sensorOnOff[2] == 1 && sensorOnOff[3] == 1 && sensorOnOff[4] == 1){ // 0 0 1 1 1
return true;
}
else if(sensorOnOff[0] == 0 && sensorOnOff[1] == 1 && sensorOnOff[2] == 1 && sensorOnOff[3] == 1 && sensorOnOff[4] == 1){ // 0 1 1 1 1
return true;
}
else if(sensorOnOff[0] == 1 && sensorOnOff[1] == 1 && sensorOnOff[2] == 1 && sensorOnOff[3] == 1 && sensorOnOff[4] == 0){ // 1 1 1 1 0
return true;
}
return false;
}
// returns true if the sensors detect the normal straight line
// the function is used in the 180 degree turning function
bool isAtStraightLine(){
readValues();
if(sensorOnOff[0] == 0 && sensorOnOff[1] == 0 && sensorOnOff[2] == 1 && sensorOnOff[3] == 0 && sensorOnOff[4] == 0){ // 0 0 1 0 0
return true;
}
else if(sensorOnOff[0] == 0 && sensorOnOff[1] == 1 && sensorOnOff[2] == 0 && sensorOnOff[3] == 0 && sensorOnOff[4] == 0){ // 0 1 0 0 0
return true;
}
else if(sensorOnOff[0] == 0 && sensorOnOff[1] == 0 && sensorOnOff[2] == 0 && sensorOnOff[3] == 1 && sensorOnOff[4] == 0){ // 0 0 0 1 0
return true;
}
return false;
}
// returns true if lost
bool isLost(){
readValues();
if(sensorOnOff[0] == 0 && sensorOnOff[1] == 0 && sensorOnOff[2] == 0 && sensorOnOff[3] == 0 && sensorOnOff[4] == 0){
return true;
}
return false;
}
// reads the line sensor values
void readValues(){
//take sampleAmount sets of readings
int AnalogAverage[5] = {0,0,0,0,0};
int sampleAmount = 50;
for(int i=0; i<sampleAmount; i++){
for (int j=0; j<5; j++){
AnalogAverage[j] += analogRead(AnalogPin[j]);
}
}
//average them by dividing by sampleAmount
for(int i=0; i<5; i++){
AnalogValue[i] = AnalogAverage[i] / sampleAmount;
if(AnalogValue[i] <= threshold)
sensorOnOff[i] = 1;
else
sensorOnOff[i] = 0;
}
}
// reads the sharp distance sensor
int readDistanceSensor(){
return analogRead(distanceSensorPin);
}
//////////////////////////////////////////////////////////////////////////////
// Motor control functions
//////////////////////////////////////////////////////////////////////////////
void forward(){
digitalWrite(rightMotorPhase, LOW); //forward
digitalWrite(leftMotorPhase, LOW ); //forward
analogWrite(rightMotorPWM, speedVal - motorOffset); // set speed of motor
analogWrite(leftMotorPWM, speedVal); // set speed of motor
}
void turnLeft(int leftTurnOffset){
digitalWrite(rightMotorPhase, LOW); //forward
digitalWrite(leftMotorPhase, LOW ); //forward
analogWrite(rightMotorPWM, speedVal); // set speed of motor
analogWrite(leftMotorPWM, speedVal - leftTurnOffset); // set speed of motor
}
void turnRight(int rightTurnOffset){
digitalWrite(rightMotorPhase, LOW); //forward
digitalWrite(leftMotorPhase, LOW ); //forward
analogWrite(rightMotorPWM, speedVal - rightTurnOffset); // set speed of motor
analogWrite(leftMotorPWM, speedVal); // set speed of motor
}
void turnLeftHard(){
digitalWrite(rightMotorPhase, LOW); //forward
digitalWrite(leftMotorPhase, LOW ); //forward
analogWrite(rightMotorPWM, harderTurn); // set speed of motor
analogWrite(leftMotorPWM, 0); // set speed of motor
}
void turnRightHard(){
digitalWrite(rightMotorPhase, LOW); //forward
digitalWrite(leftMotorPhase, LOW ); //forward
analogWrite(rightMotorPWM, 0); // set speed of motor
analogWrite(leftMotorPWM, harderTurn); // set speed of motor
}
void stopLine(){
analogWrite(rightMotorPWM, 0); // set speed of motor
analogWrite(leftMotorPWM, 0); // set speed of motor
Serial.println("Stop"); // Display motor direction
}
void turn180(){
//clockwise turn
digitalWrite(rightMotorPhase, HIGH); //backward
digitalWrite(leftMotorPhase, LOW ); //forward
while(sensorOnOff[4] == 0){
analogWrite(rightMotorPWM, turnOnSpotVal); // set speed of motor
analogWrite(leftMotorPWM, turnOnSpotVal); // set speed of motor
Serial.println("Turning 180"); // Display motor direction
readValues();
}
while(sensorOnOff[3] == 0){
analogWrite(rightMotorPWM, turnOnSpotVal); // set speed of motor
analogWrite(leftMotorPWM, turnOnSpotVal); // set speed of motor
Serial.println("Turning 180"); // Display motor direction
readValues();
}
while(sensorOnOff[2] == 0){
analogWrite(rightMotorPWM, turnOnSpotVal); // set speed of motor
analogWrite(leftMotorPWM, turnOnSpotVal); // set speed of motor
Serial.println("Turning 180"); // Display motor direction
readValues();
}
while(sensorOnOff[1] == 0){
analogWrite(rightMotorPWM, turnOnSpotVal); // set speed of motor
analogWrite(leftMotorPWM, turnOnSpotVal); // set speed of motor
Serial.println("Turning 180"); // Display motor direction
readValues();
}
while(sensorOnOff[0] == 0){
analogWrite(rightMotorPWM, turnOnSpotVal); // set speed of motor
analogWrite(leftMotorPWM, turnOnSpotVal); // set speed of motor
Serial.println("Turning 180"); // Display motor direction
readValues();
}
while(!isAtStraightLine()){
analogWrite(rightMotorPWM, turnOnSpotVal); // set speed of motor
analogWrite(leftMotorPWM, turnOnSpotVal); // set speed of motor
Serial.println("Turning 180"); // Display motor direction
readValues();
}
}
void turn90Right(){
digitalWrite(rightMotorPhase, HIGH); //backward
digitalWrite(leftMotorPhase, LOW ); //forward
while(sensorOnOff[1] == 0){
analogWrite(rightMotorPWM, turnOnSpotVal); // set speed of motor
analogWrite(leftMotorPWM, turnOnSpotVal); // set speed of motor
Serial.println("Turning Right"); // Display motor direction
readValues();
}
while(sensorOnOff[0] == 0){
analogWrite(rightMotorPWM, turnOnSpotVal); // set speed of motor
analogWrite(leftMotorPWM, turnOnSpotVal); // set speed of motor
Serial.println("Turning Right"); // Display motor direction
readValues();
}
while(sensorOnOff[0] == 1){
analogWrite(rightMotorPWM, turnOnSpotVal); // set speed of motor
analogWrite(leftMotorPWM, turnOnSpotVal); // set speed of motor
Serial.println("Turning Right"); // Display motor direction
readValues();
}
while(sensorOnOff[2] == 0){
analogWrite(rightMotorPWM, turnOnSpotVal); // set speed of motor
analogWrite(leftMotorPWM, turnOnSpotVal); // set speed of motor
Serial.println("Turning Right"); // Display motor direction
readValues();
}
}
void turn90Left(){
digitalWrite(rightMotorPhase, LOW); //forward
digitalWrite(leftMotorPhase, HIGH ); //backward
while(sensorOnOff[0] == 0){
analogWrite(rightMotorPWM, turnOnSpotVal); // set speed of motor
analogWrite(leftMotorPWM, turnOnSpotVal); // set speed of motor
Serial.println("Turning Left"); // Display motor direction
readValues();
}
while(sensorOnOff[1] == 0){
analogWrite(rightMotorPWM, turnOnSpotVal); // set speed of motor
analogWrite(leftMotorPWM, turnOnSpotVal); // set speed of motor
Serial.println("Turning Left"); // Display motor direction
readValues();
}
}
// special case for checkpoint 6
void turn90RightSix(){
digitalWrite(rightMotorPhase, HIGH); //backward
digitalWrite(leftMotorPhase, LOW ); //forward
while(sensorOnOff[3] == 0){
analogWrite(rightMotorPWM, turnOnSpotVal); // set speed of motor
analogWrite(leftMotorPWM, turnOnSpotVal); // set speed of motor
Serial.println("Turning Right"); // Display motor direction
readValues();
}
}
// special case for checkpoint 6
void turn90LeftSix(){
digitalWrite(rightMotorPhase, LOW); //forward
digitalWrite(leftMotorPhase, HIGH ); //backward
while(sensorOnOff[1] == 0){
analogWrite(rightMotorPWM, turnOnSpotVal); // set speed of motor
analogWrite(leftMotorPWM, turnOnSpotVal); // set speed of motor
Serial.println("Turning Right"); // Display motor direction
readValues();
}
}
void reverse(){
digitalWrite(rightMotorPhase, HIGH); //reverse
digitalWrite(leftMotorPhase, HIGH ); //reverse
analogWrite(rightMotorPWM, speedVal - motorOffset); // set speed of motor
analogWrite(leftMotorPWM, speedVal); // set speed of motor
Serial.println("Reverse"); // Display motor direction
}
| [
"eoinoreilly30@gmail.com"
] | eoinoreilly30@gmail.com |
cf40e88110fe077f39c8ffc5680f05a3e3ac561a | 8e073ed35d182c51c5519a4ac1e8ffb9d7614dbb | /TouchGFX/generated/gui_generated/src/screen_screen/screenViewBase.cpp | 1b391b731c2d655bbd1d8a0c4dbd00b59469a6f9 | [] | no_license | jshxcn/project-test | bcc672014a76504473bfbe7033573c0aff3cced2 | d548ace772d44011de69236b24d53a3f6d985589 | refs/heads/master | 2022-12-08T11:35:36.732245 | 2020-08-31T08:17:03 | 2020-08-31T08:17:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,300 | cpp | /*********************************************************************************/
/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/
/*********************************************************************************/
#include <gui_generated/screen_screen/screenViewBase.hpp>
#include <touchgfx/Color.hpp>
#include "BitmapDatabase.hpp"
#include <texts/TextKeysAndLanguages.hpp>
screenViewBase::screenViewBase()
{
box1.setPosition(0, 0, 480, 320);
box1.setColor(touchgfx::Color::getColorFrom24BitRGB(33, 18, 106));
buttonWithLabel2.setXY(155, 114);
buttonWithLabel2.setBitmaps(touchgfx::Bitmap(BITMAP_BLUE_BUTTONS_ROUND_EDGE_SMALL_ID), touchgfx::Bitmap(BITMAP_BLUE_BUTTONS_ROUND_EDGE_SMALL_PRESSED_ID));
buttonWithLabel2.setLabelText(touchgfx::TypedText(T_SINGLEUSEID2));
buttonWithLabel2.setLabelColor(touchgfx::Color::getColorFrom24BitRGB(255, 255, 255));
buttonWithLabel2.setLabelColorPressed(touchgfx::Color::getColorFrom24BitRGB(255, 255, 255));
buttonWithLabel1.setXY(310, 0);
buttonWithLabel1.setBitmaps(touchgfx::Bitmap(BITMAP_BLUE_BUTTONS_ROUND_EDGE_SMALL_ID), touchgfx::Bitmap(BITMAP_BLUE_BUTTONS_ROUND_EDGE_SMALL_PRESSED_ID));
buttonWithLabel1.setLabelText(touchgfx::TypedText(T_SINGLEUSEID1));
buttonWithLabel1.setLabelColor(touchgfx::Color::getColorFrom24BitRGB(255, 255, 255));
buttonWithLabel1.setLabelColorPressed(touchgfx::Color::getColorFrom24BitRGB(255, 255, 255));
buttonWithLabel3.setXY(0, 260);
buttonWithLabel3.setBitmaps(touchgfx::Bitmap(BITMAP_BLUE_BUTTONS_ROUND_EDGE_SMALL_ID), touchgfx::Bitmap(BITMAP_BLUE_BUTTONS_ROUND_EDGE_SMALL_PRESSED_ID));
buttonWithLabel3.setLabelText(touchgfx::TypedText(T_SINGLEUSEID3));
buttonWithLabel3.setLabelColor(touchgfx::Color::getColorFrom24BitRGB(255, 255, 255));
buttonWithLabel3.setLabelColorPressed(touchgfx::Color::getColorFrom24BitRGB(255, 255, 255));
toggleButton1.setXY(0, 0);
toggleButton1.setBitmaps(touchgfx::Bitmap(BITMAP_BLUE_TOGGLEBARS_TOGGLE_ROUND_LARGE_BUTTON_OFF_ID), touchgfx::Bitmap(BITMAP_BLUE_TOGGLEBARS_TOGGLE_ROUND_LARGE_BUTTON_ON_ID));
add(box1);
add(buttonWithLabel2);
add(buttonWithLabel1);
add(buttonWithLabel3);
add(toggleButton1);
}
void screenViewBase::setupScreen()
{
}
| [
"harkja@hanmail.net"
] | harkja@hanmail.net |
16d61836d419b847c36f1bdb8fd58b55cce96002 | 339d9e00297cac7fba1d95dfe72a3f515a2d3995 | /offb_test/devel/include/mavros_msgs/VFR_HUD.h | 5db484e7fbab1bacead727c9fdba79571511997c | [] | no_license | pjw9195/drone-offb_test | 5c88f2647d9b436c86cceb5737169638c7833e84 | ff6f908ebf34e9587fbda7bd40442400b45e7290 | refs/heads/master | 2020-04-03T21:53:13.696528 | 2019-07-19T04:38:57 | 2019-07-19T04:38:57 | 155,585,681 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 7,496 | h | // Generated by gencpp from file mavros_msgs/VFR_HUD.msg
// DO NOT EDIT!
#ifndef MAVROS_MSGS_MESSAGE_VFR_HUD_H
#define MAVROS_MSGS_MESSAGE_VFR_HUD_H
#include <string>
#include <vector>
#include <map>
#include <ros/types.h>
#include <ros/serialization.h>
#include <ros/builtin_message_traits.h>
#include <ros/message_operations.h>
#include <std_msgs/Header.h>
namespace mavros_msgs
{
template <class ContainerAllocator>
struct VFR_HUD_
{
typedef VFR_HUD_<ContainerAllocator> Type;
VFR_HUD_()
: header()
, airspeed(0.0)
, groundspeed(0.0)
, heading(0)
, throttle(0.0)
, altitude(0.0)
, climb(0.0) {
}
VFR_HUD_(const ContainerAllocator& _alloc)
: header(_alloc)
, airspeed(0.0)
, groundspeed(0.0)
, heading(0)
, throttle(0.0)
, altitude(0.0)
, climb(0.0) {
(void)_alloc;
}
typedef ::std_msgs::Header_<ContainerAllocator> _header_type;
_header_type header;
typedef float _airspeed_type;
_airspeed_type airspeed;
typedef float _groundspeed_type;
_groundspeed_type groundspeed;
typedef int16_t _heading_type;
_heading_type heading;
typedef float _throttle_type;
_throttle_type throttle;
typedef float _altitude_type;
_altitude_type altitude;
typedef float _climb_type;
_climb_type climb;
typedef boost::shared_ptr< ::mavros_msgs::VFR_HUD_<ContainerAllocator> > Ptr;
typedef boost::shared_ptr< ::mavros_msgs::VFR_HUD_<ContainerAllocator> const> ConstPtr;
}; // struct VFR_HUD_
typedef ::mavros_msgs::VFR_HUD_<std::allocator<void> > VFR_HUD;
typedef boost::shared_ptr< ::mavros_msgs::VFR_HUD > VFR_HUDPtr;
typedef boost::shared_ptr< ::mavros_msgs::VFR_HUD const> VFR_HUDConstPtr;
// constants requiring out of line definition
template<typename ContainerAllocator>
std::ostream& operator<<(std::ostream& s, const ::mavros_msgs::VFR_HUD_<ContainerAllocator> & v)
{
ros::message_operations::Printer< ::mavros_msgs::VFR_HUD_<ContainerAllocator> >::stream(s, "", v);
return s;
}
} // namespace mavros_msgs
namespace ros
{
namespace message_traits
{
// BOOLTRAITS {'IsFixedSize': False, 'IsMessage': True, 'HasHeader': True}
// {'geographic_msgs': ['/opt/ros/kinetic/share/geographic_msgs/cmake/../msg'], 'sensor_msgs': ['/opt/ros/kinetic/share/sensor_msgs/cmake/../msg'], 'std_msgs': ['/opt/ros/kinetic/share/std_msgs/cmake/../msg'], 'mavros_msgs': ['/home/jinwoo/offboard_test/src/mavros/mavros_msgs/msg'], 'geometry_msgs': ['/opt/ros/kinetic/share/geometry_msgs/cmake/../msg'], 'uuid_msgs': ['/opt/ros/kinetic/share/uuid_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< ::mavros_msgs::VFR_HUD_<ContainerAllocator> >
: FalseType
{ };
template <class ContainerAllocator>
struct IsFixedSize< ::mavros_msgs::VFR_HUD_<ContainerAllocator> const>
: FalseType
{ };
template <class ContainerAllocator>
struct IsMessage< ::mavros_msgs::VFR_HUD_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::mavros_msgs::VFR_HUD_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::mavros_msgs::VFR_HUD_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::mavros_msgs::VFR_HUD_<ContainerAllocator> const>
: TrueType
{ };
template<class ContainerAllocator>
struct MD5Sum< ::mavros_msgs::VFR_HUD_<ContainerAllocator> >
{
static const char* value()
{
return "1f55e210c3d39fe105d44d8dc963655f";
}
static const char* value(const ::mavros_msgs::VFR_HUD_<ContainerAllocator>&) { return value(); }
static const uint64_t static_value1 = 0x1f55e210c3d39fe1ULL;
static const uint64_t static_value2 = 0x05d44d8dc963655fULL;
};
template<class ContainerAllocator>
struct DataType< ::mavros_msgs::VFR_HUD_<ContainerAllocator> >
{
static const char* value()
{
return "mavros_msgs/VFR_HUD";
}
static const char* value(const ::mavros_msgs::VFR_HUD_<ContainerAllocator>&) { return value(); }
};
template<class ContainerAllocator>
struct Definition< ::mavros_msgs::VFR_HUD_<ContainerAllocator> >
{
static const char* value()
{
return "# Metrics typically displayed on a HUD for fixed wing aircraft\n\
#\n\
# VFR_HUD message\n\
\n\
std_msgs/Header header\n\
float32 airspeed # m/s\n\
float32 groundspeed # m/s\n\
int16 heading # degrees 0..360\n\
float32 throttle # normalized to 0.0..1.0\n\
float32 altitude # MSL\n\
float32 climb # current climb rate m/s\n\
\n\
================================================================================\n\
MSG: std_msgs/Header\n\
# Standard metadata for higher-level stamped data types.\n\
# This is generally used to communicate timestamped data \n\
# in a particular coordinate frame.\n\
# \n\
# sequence ID: consecutively increasing ID \n\
uint32 seq\n\
#Two-integer timestamp that is expressed as:\n\
# * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\
# * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\
# time-handling sugar is provided by the client library\n\
time stamp\n\
#Frame this data is associated with\n\
# 0: no frame\n\
# 1: global frame\n\
string frame_id\n\
";
}
static const char* value(const ::mavros_msgs::VFR_HUD_<ContainerAllocator>&) { return value(); }
};
} // namespace message_traits
} // namespace ros
namespace ros
{
namespace serialization
{
template<class ContainerAllocator> struct Serializer< ::mavros_msgs::VFR_HUD_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
{
stream.next(m.header);
stream.next(m.airspeed);
stream.next(m.groundspeed);
stream.next(m.heading);
stream.next(m.throttle);
stream.next(m.altitude);
stream.next(m.climb);
}
ROS_DECLARE_ALLINONE_SERIALIZER
}; // struct VFR_HUD_
} // namespace serialization
} // namespace ros
namespace ros
{
namespace message_operations
{
template<class ContainerAllocator>
struct Printer< ::mavros_msgs::VFR_HUD_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::mavros_msgs::VFR_HUD_<ContainerAllocator>& v)
{
s << indent << "header: ";
s << std::endl;
Printer< ::std_msgs::Header_<ContainerAllocator> >::stream(s, indent + " ", v.header);
s << indent << "airspeed: ";
Printer<float>::stream(s, indent + " ", v.airspeed);
s << indent << "groundspeed: ";
Printer<float>::stream(s, indent + " ", v.groundspeed);
s << indent << "heading: ";
Printer<int16_t>::stream(s, indent + " ", v.heading);
s << indent << "throttle: ";
Printer<float>::stream(s, indent + " ", v.throttle);
s << indent << "altitude: ";
Printer<float>::stream(s, indent + " ", v.altitude);
s << indent << "climb: ";
Printer<float>::stream(s, indent + " ", v.climb);
}
};
} // namespace message_operations
} // namespace ros
#endif // MAVROS_MSGS_MESSAGE_VFR_HUD_H
| [
"pjw9195@naver.com"
] | pjw9195@naver.com |
720cfec3c2280b439c9dd540b32a8fa65aadfdc1 | 9508e06b39b258fc676ff1e8055cca5c1527e1d0 | /src/Log.h | aedd084b68092529dda92ff91c0d4fdb807fd96b | [] | no_license | fritzb/moderncpp | de00567a6138d5b930b90eb4057e9822457f5588 | 26d93ab3a5a26365dfd71f2d23cf9275ca2893c3 | refs/heads/master | 2020-05-16T12:37:58.851159 | 2019-06-20T23:08:12 | 2019-06-20T23:08:12 | 183,051,167 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,333 | h | /*
* $Id: Log.h,v 1.1 2005/12/05 02:07:19 fzb Exp $
*
* Log.h --
*
* Fritz Budiyanto, October 2005
*
*/
#ifndef __LOG_H__
#define __LOG_H__
#include <string>
#include <stdio.h>
#include <stdarg.h>
#ifdef DEBUG
#define DEBUG_DEFAULT true
#else
#define DEBUG_DEFAULT false
#endif
class Log {
public:
// Types
enum Priority {
Error,
Debug
};
static const bool DebugDefault = DEBUG_DEFAULT;
// Accessor
bool debug() const { return debug_; }
// Mutator
void debugIs(bool d) { debug_ = d; }
void entryNew(Priority prio,
const std::string &name,
const std::string &funcName,
const char *format, ...) {
va_list args;
if (prio == Debug) {
if (!debug_) {
return;
}
}
va_start(args, format);
fprintf(stderr, "[%s] %s.%s: ",
moduleName_.c_str(),
name.c_str(),
funcName.c_str());
vfprintf(stderr, format, args);
va_end(args);
}
// Constructor/Destructor
Log(std::string moduleName) :debug_(DebugDefault) { moduleName_ = moduleName; }
private:
std::string moduleName_;
bool debug_;
};
#endif /* __LOG_H__ */
/* end of file */
| [
"fritzbx@icloud.com"
] | fritzbx@icloud.com |
468a7e8cfd565bc9299858784219cd2b0f97e5b2 | 41575c498b7197e97b12a8ce2a880047df363cc3 | /src/local/inp/win32/Driver.hpp | e83fa5de7c99e16690afefd7809f12b1b4068e89 | [] | no_license | gongfuPanada/page | f00a6f9015b4aad79398f0df041613ab28be405b | fa2ccdef4b33480c2ac5f872d717323f45618a34 | refs/heads/master | 2021-01-15T22:09:34.836791 | 2013-03-23T18:54:13 | 2013-03-23T18:54:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,221 | hpp | /**
* @section license
*
* Copyright (c) 2006-2013 David Osborn
*
* Permission is granted to use and redistribute this software in source and
* binary form, with or without modification, subject to the following
* conditions:
*
* 1. Redistributions in source form 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, and in the same
* place and form as other copyright, license, and disclaimer information.
*
* As a special exception, distributions of derivative works in binary form may
* include an acknowledgement in place of the above copyright notice, this list
* of conditions, and the following disclaimer in the documentation and/or other
* materials provided with the distribution, and in the same place and form as
* other acknowledgements, similar in substance to the following:
*
* Portions of this software are based on the work of David Osborn.
*
* This software is provided "as is", without any express or implied warranty.
* In no event will the authors be liable for any damages arising out of the use
* of this software.
*/
#ifndef page_local_inp_win32_Driver_hpp
# define page_local_inp_win32_Driver_hpp
# include <windows.h> // DWORD, HWND, LONG, LPARAM, UINT{,_PTR}, WPARAM
# include "../Driver.hpp"
namespace page
{
namespace wnd { namespace win32 { class Window; }}
namespace inp
{
namespace win32
{
struct Driver : inp::Driver
{
// construct
explicit Driver(wnd::win32::Window &);
// window access
wnd::win32::Window &GetWindow();
const wnd::win32::Window &GetWindow() const;
private:
// state query
State Poll() const;
// cursor mode modifiers
void DoSetCursorMode(CursorMode);
void ShowCursor(bool);
// system cursor state
math::Vector<2, unsigned> GetRawCursorPosition() const;
math::Vector<2, int> GetRawCursorTranslation() const;
bool GetMouseButton(Button) const;
// cursor update
void UpdateCursor();
// inspiration notification
void OnImbue(const ui::Interface *);
// window signal handlers
void OnFocus(bool focus);
void OnMessage(UINT, WPARAM, LPARAM);
void OnMove(const math::Vector<2, int> &);
void OnSize(const math::Vector<2, unsigned> &);
boost::signals::scoped_connection focusCon, messageCon, moveCon, sizeCon;
// window message handlers
void OnButtonDown(Button, WPARAM, LPARAM);
void OnButtonUp(Button, WPARAM, LPARAM);
void OnMouseMove(WPARAM, LPARAM);
void OnMouseWheel(WPARAM, LPARAM);
// mouse state
void ResetMouseState();
void ResetMouseState(const math::Vector<2> &position);
void ResetMouseDrag(const math::Vector<2> &position);
// mouse repeat timer
void StartMouseRepeatTimer();
void StopMouseRepeatTimer();
// mouse repeat timer handling
void OnMouseRepeatTimer();
static void CALLBACK MouseRepeatTimerRouter(HWND, UINT, UINT_PTR, DWORD);
// vector normalization
math::Vector<2> NormClientVector(const math::Vector<2, int> &) const;
math::Vector<2> NormScreenVector(const math::Vector<2, int> &) const;
// MSH_MOUSEWHEEL message
UINT mshMousewheel;
// system limits
struct Limits
{
// construct
Limits();
UINT doubleTime;
math::Vector<2, unsigned> doubleRange, dragRange;
unsigned repeatDelay;
DWORD repeatSpeed;
} limits;
// cursor state
struct Cursor
{
// construct
Cursor();
enum Icon
{
noIcon,
arrowIcon,
themeIcon
} icon;
bool visible;
math::Vector<2, unsigned> pointPosition;
} cursor;
// mouse state
struct Mouse
{
// construct
Mouse();
bool down, dragging, _double, ignoreDown;
Button downButton;
LONG downTime;
math::Vector<2, unsigned> downPosition;
float deltaScroll;
// repeating
bool repeating;
UINT_PTR repeatTimer;
} mouse;
};
}
}
}
#endif
| [
"davidcosborn@gmail.com"
] | davidcosborn@gmail.com |
23439271e1ff33361a8a8edb6832116b5dc9285a | aeeb9442e954f6955dd832637bd4991503c20377 | /src/au_uav_ros/src/simPlaneObject.cpp | 3e3a71ff8dbff2c3b5c254c95039cdc8eee2a19f | [] | no_license | Idianale/au_uav_pkg | 8ad46b04c72e320bc58333ae5371ef58188635b9 | e38b06eef33d34c96a2d32ea2f6aed735a0d73d8 | refs/heads/master | 2021-05-31T22:46:18.812867 | 2016-06-07T16:10:25 | 2016-06-07T16:10:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,366 | cpp | #include "au_uav_ros/simPlaneObject.h"
using namespace au_uav_ros;
#define MAXIMUM_TURNING_ANGLE 22.5 //degrees
SimPlaneObject::SimPlaneObject(void) : PlaneObject() {
simSpeed = 1;
}
SimPlaneObject::SimPlaneObject(struct waypoint wp) : PlaneObject(wp) {
this->speed = MPS_SPEED;
simSpeed = 1;
}
void SimPlaneObject::setSimSpeed(double _simSpeed) {
simSpeed = _simSpeed;
}
double SimPlaneObject::getSimSpeed(void) const {
return this->simSpeed;
}
bool SimPlaneObject::simulate(au_uav_ros::Telemetry *telem) {
fillTelemetryUpdate(telem);
return true;
}
bool SimPlaneObject::handleNewCommand(au_uav_ros::Command newCommand) {
if(this->id != newCommand.planeID)
{
return false;
}
if (newCommand.commandID == COMMAND_AVOID_WP || newCommand.commandID == COMMAND_NORMAL_WP) {
setCurrentDest(newCommand.latitude,
newCommand.longitude,
newCommand.altitude);
}
return true;
}
bool SimPlaneObject::fillTelemetryUpdate(au_uav_ros::Telemetry *update) {
//difference in latitudes in radians
double lat1 = currentLoc.latitude*DEGREES_TO_RADIANS;
double long1 = currentLoc.longitude*DEGREES_TO_RADIANS;
double lat2, long2;
if (this->currentDest != INVALID_WP) {
lat2 = currentDest.latitude*DEGREES_TO_RADIANS;
long2 = currentDest.longitude*DEGREES_TO_RADIANS;
}else {
lat2 = normalPath.front().latitude*DEGREES_TO_RADIANS;
long2 = normalPath.front().longitude*DEGREES_TO_RADIANS;
}
double deltaLat = lat2 - lat1;
double deltaLong = long2 - long1;
//calculate bearing from current position to destination
double y = sin(deltaLong)*cos(lat2);
double x = cos(lat1)*sin(lat2) - sin(lat1)*cos(lat2)*cos(deltaLong);
this->targetBearing = atan2(y, x)*RADIANS_TO_DEGREES;
//calculate the real bearing based on our maximum angle change
//first create a temporary bearing that is the same as bearing but at a different numerical value
double tempBearing = -1000;
if((this->targetBearing) < 0)
{
tempBearing = this->targetBearing + 360;
}
else
{
tempBearing = this->targetBearing - 360;
}
double diff1 = abs(this->currentBearing - this->targetBearing);
double diff2 = abs(this->currentBearing - tempBearing);
//check for easy to calculate values first
if(diff1 < (MAXIMUM_TURNING_ANGLE*simSpeed) || diff2 < (MAXIMUM_TURNING_ANGLE*simSpeed))
{
//the difference is less than our maximum angle, set it to the bearing
this->currentBearing = this->targetBearing;
}
else
{
//we have a larger difference than we can turn, so turn our maximum
double mod;
if(diff1 < diff2)
{
if(this->targetBearing > this->currentBearing) mod = (MAXIMUM_TURNING_ANGLE*simSpeed);
else mod = 0 - (MAXIMUM_TURNING_ANGLE*simSpeed);
}
else
{
if(tempBearing > this->currentBearing) mod = (MAXIMUM_TURNING_ANGLE*simSpeed);
else mod = 0 - (MAXIMUM_TURNING_ANGLE*simSpeed);
}
//add our mod, either +22.5 or -22.5
this->currentBearing = this->currentBearing + mod;
//tweak the value to keep it between -180 and 180
if(this->currentBearing > 180) this->currentBearing = this->currentBearing - 360;
if(this->currentBearing <= -180) this->currentBearing = this->currentBearing + 360;
}
//time to calculate the new positions, God help us
/*
Algorithm for updating position:
1) Estimate new latitude using basic trig and this equation:
lat2 = lat1 + (MPS_SPEED*cos(bearing))*METERS_TO_LATITUDE
2) Use law of haversines to find the new longitude
haversin(c) = haversin(a-b) + sin(a)*sin(b)*haversin(C)
where haversin(x) = (sin(x/2.0))^2
where c = MPS_SPEED/EARTH_RADIUS (radians)
where a = 90 - lat1 (degrees)
where b = 90 - lat2 (degrees)
where C = the change in longitude, what we are solving for
C = 2.0 * arcsin(sqrt((haversin(c) - haversin(a-b))/(sin(a)*sin(b))))
*/
//1) Estimate new latitude using basic trig and this equation
this->currentLoc.latitude = lat1*RADIANS_TO_DEGREES + ((MPS_SPEED*simSpeed)*cos(this->currentBearing*DEGREES_TO_RADIANS))*METERS_TO_LATITUDE;
//2) Use the law of haversines to find the new longitude
double temp = pow(sin(((MPS_SPEED*simSpeed)/EARTH_RADIUS)/2.0), 2); //TODO verify
temp = temp - pow(sin((this->currentLoc.latitude*DEGREES_TO_RADIANS - lat1)/2.0), 2);
temp = temp / (sin(M_PI/2.0 - lat1)*sin((M_PI/2.0)-this->currentLoc.latitude*DEGREES_TO_RADIANS));
temp = 2.0 * RADIANS_TO_DEGREES * asin(sqrt(temp));
//depending on bearing, we should be either gaining or losing longitude
if(currentBearing > 0)
{
this->currentLoc.longitude += temp;
}
else
{
this->currentLoc.longitude -= temp;
}
this->distanceToDestination = distanceBetween(this->currentLoc, this->currentDest);
update->planeID = this->id;
update->currentLatitude = this->currentLoc.latitude;
update->currentLongitude = this->currentLoc.longitude;
update->currentAltitude = this->currentLoc.altitude;
update->destLatitude = this->currentDest.latitude;
update->destLongitude = this->currentDest.longitude;
update->destAltitude = this->currentDest.altitude;
update->currentWaypointIndex = this->currentWaypointIndex;
this->speed = MPS_SPEED*simSpeed;
update->groundSpeed = this->speed;
//TODO: charge name to currentBearing
update->targetBearing = this->currentBearing;
update->distanceToDestination = this->distanceToDestination;
update->telemetryHeader.stamp = ros::Time::now();
updateTime();
return true;
}
| [
"viki@c3po.(none)"
] | viki@c3po.(none) |
db6826dc50924a0f1a1715266b110dedde822eb3 | cf5ab3d9fc28fce297591ff12d760e152547ecc1 | /metabuilder/examples/mobileapp/src/platform/ios/platform_ios.cpp | cfd231b9dd2c1f3c9740b0db123445440810d305 | [
"MIT"
] | permissive | kjmac123/metabuilder | 19a1275f9913c8fa28507d176cf0f52050df0b2f | 71cba48d03241d5e2f8b5c96ef9139693f9bd1ad | refs/heads/master | 2020-05-18T11:36:20.393044 | 2019-03-09T15:11:24 | 2019-03-09T15:11:24 | 17,400,788 | 8 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 695 | cpp |
#include "core.h"
#include "platform/platform.h"
#include <mach/mach_time.h>
namespace Platform
{
static F64 g_machTimeToNs;
static mach_timebase_info_data_t g_timebase;
void Init()
{
mach_timebase_info(&g_timebase);
g_machTimeToNs = ((F64)g_timebase.numer / (F64)g_timebase.denom);
}
void Shutdown()
{
}
void LogErrorNewLine(const char* str)
{
printf("%s\n", str);
}
void LogInfoNewLine(const char* str)
{
printf("%s\n", str);
}
void LogDebugNewLine(const char* str)
{
printf("%s\n", str);
}
F64 GetSystemTicksToSecondsScale()
{
return 1.0 / F64(MB_SECONDS_TO_NANOSECONDS) * g_machTimeToNs;
}
U64 GetSystemTicks()
{
return mach_absolute_time();
}
}
| [
"kjmac123@gmail.com"
] | kjmac123@gmail.com |
3143305992c2cf200131b8f1d6d32a15b83adbbf | 089077acd7dc512a1afde017692382b0b9ada02f | /SmartHSR/TinySolid/OpenSolid.h | 22b41ecd12afc6534588c4f4c1fb7fca5f3174e0 | [] | no_license | lizzyly7/SmartDraw | 6830b172cebcf2005366b7438d771af3faa137cf | cb891dbe66d75bbb3f692fce72e91402e1c97010 | refs/heads/main | 2023-04-19T05:54:52.948266 | 2021-05-04T11:02:01 | 2021-05-04T11:02:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,622 | h | /********************************************************************
created: 2004/01/16
created: 16:1:2004 13:46
filename: D:\Project\PlantWAVE\OpenSolid\OpenSolid.h
file path: D:\Project\PlantWAVE\OpenSolid
file base: OpenSolid
file ext: h
author:
purpose:
*********************************************************************/
#ifndef __OPENSOLID_H__
#define __OPENSOLID_H__
#include <SQLib.h>
#include <queue>
using namespace std;
#ifndef DLL_EXPORT
#define DLL_EXPORT __declspec(dllexport)
#endif
class DLL_EXPORT COpenSolid{
public:
COpenSolid();
virtual ~COpenSolid();
public:
const int GetNumOfCurveSegments();
void SetNumOfCurveSegments(int nSegments);
PSQPRIMITIVE CreatePlaneSurface(PSQPRIMITIVE pPrimitive);
PSQPRIMITIVE CreateConeSurface(PSQPRIMITIVE pPrimitive);
PSQPRIMITIVE CreateTorusSurface(PSQPRIMITIVE pPrimitive);
PSQPRIMITIVE CreateSphereSurface(PSQPRIMITIVE pPrimitive);
PSQPRIMITIVE CreateSolid(PSQPRIMITIVE pPrimitive);
PSQPRIMITIVE CreateSurface(PSQPRIMITIVE pPrimitive);
PSQPRIMITIVE CreateArc(PSQPRIMITIVE pPrimitive);
PSQPRIMITIVE CreateFacets(PPOINT_T pptPoints,int nParts,int nPoints,const SQHEADER& hdr);
void ComputeVolume(PSQPRIMITIVE pPrimitive);
void Pure();
protected:
bool PossibleBeCone(PSQPRIMITIVE pPrimitive);
bool PossibleBeDome(PSQPRIMITIVE pPrimitive);
bool PossibleBeSphere(PSQPRIMITIVE pPrimitive);
PSQPRIMITIVE NewPrimitive();
bool DeletePrimitive(PSQPRIMITIVE pPrimitive);
private:
int m_nCurveSegments;
queue<PSQPRIMITIVE> m_quePrimitivePool;
list<PSQPRIMITIVE>* m_plstPrimitive;
};
extern COpenSolid theOpenSolid;
#endif | [
"humkyung@atools.co.kr"
] | humkyung@atools.co.kr |
a77eb246288f44e1a9c8a61e79d663866e21dc0e | 407ea15ce5e6fd6c113d565ad71d6cebfe287cd1 | /src/clamav_engine.h | 420098b3595a7785983cc5dee12e12d21229d297 | [
"Apache-2.0"
] | permissive | pombredanne/libclamav_test | c6c548961c44fd86de1581bc1725b73a0844df01 | 033863e6a418e14fdf37a8e3fb5848c815419bb8 | refs/heads/master | 2020-05-19T17:28:22.946690 | 2018-06-01T09:00:57 | 2018-06-01T09:00:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,511 | h | #ifndef CLAMAV_ENGIN_H_
#define CLAMAV_ENGIN_H_
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include <string>
#include <map>
#include <vector>
#include "clamav.h"
enum ClamavScanStat
{
kScanStatIsVIRUS = 10,
kScanStatNotVIRUS,
kScanStatUnknow,
};
struct ClamavScanResult
{
const char *virname;
unsigned long int size;
uint8_t stat;
char type[40];
ClamavScanResult()
: virname("")
, size(0)
, stat(0)
{
//type[0] = 0;
memset(type, 0, sizeof(type));
}
};
//TODO, enable more settings
struct ClamavSettings
{
long long max_file_size;
long long max_scan_size;
int ReMatchAlgorithm;
std::string tmp_file_dir;
ClamavSettings()
: max_file_size(0)
, max_scan_size(0)
, ReMatchAlgorithm(kReMatchAlgorithm_None)\
, tmp_file_dir("")
{
}
};
// ClamAV Virus Database : CVD
struct ClamavVDInfo
{
std::string name;
struct cl_cvd* info;
};
static inline std::string CVDInfoList2String(std::vector<ClamavVDInfo>& v)
{
std::vector<ClamavVDInfo>::iterator it;
std::string res_str;
char buf[1024];
for (it = v.begin(); it != v.end(); it++)
{
snprintf(buf, sizeof buf,
"vd name :%s\n"
"time :%s\n"
"version :%u\n"
"sigs :%u\n"
"fl :%u\n"
"md5 :%s\n"
"builder :%s\n"
"stime :%u\n\n"
, it->name.c_str()
, it->info->time
, it->info->version
, it->info->sigs
, it->info->fl
, it->info->md5
, it->info->builder
, it->info->stime
);
res_str += std::string(buf);
}
return res_str;
}
//typedef off_t (*clcb_pread)(void* handle, void *buf, size_t count, off_t offset)
class ClamavEngine
{
public:
explicit ClamavEngine(const char* path);
~ClamavEngine();
static std::string getClamavVersion();
static void enableDebug();
int buildEngine(ClamavSettings* av_settings = NULL);
int reBuildEngine(ClamavSettings* av_settings = NULL);
int ScanFmap(void* ptr, size_t len, ClamavScanResult* result, uint32_t scan_opt);
int scanFileFd(int fd, ClamavScanResult* result, uint32_t scan_opt);
int scanFileFdRaw(int fd, ClamavScanResult* result);
int scanFileFdStd(int fd, ClamavScanResult* result);
int getSettings();
int setSettings(ClamavSettings* settings);
int checkDatebaseChanged();
uint32_t scanSettingMask(const char* setting_section);
const std::string& getErrInfo()
{
return err_info_;
}
uint64_t getSigNum()
{
return sig_num_;
}
std::vector<ClamavVDInfo>& getCVDInfoList()
{
return cvd_info_list_;
}
private:
struct cmp_str
{
bool operator()(const char* a, const char* b) const
{
return strcmp(a, b) < 0;
}
};
void settingMaskInit();
std::map<const char*, uint32_t, cmp_str> setting_mask_map_;
private:
std::string err_info_;
uint64_t sig_num_;
private:
std::string db_path_;
std::vector<ClamavVDInfo> cvd_info_list_;
struct cl_engine* engine_;
struct cl_stat* dbstat_;
};
#endif
| [
"realzhangm@163.com"
] | realzhangm@163.com |
ea9333a46a3f9bd34be03f23ba1a40fb26f4f0d7 | 75aab49ae1002249ff1b79276fa910498fd72bc6 | /合并石子.cpp | 1a4a385d58e74231c90b80cb18d21bb406a22d7f | [] | no_license | huang7262/lqb | 8f3347795b7d0208ab2d02c276a9e11e618133e6 | 562d23973f5cf8ec59c2f101fb43f7579f5a3e01 | refs/heads/master | 2020-03-21T09:35:20.174504 | 2017-10-28T09:55:10 | 2017-10-28T09:55:10 | 138,407,514 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,330 | cpp | /*问题描述
* 在一条直线上有n堆石子,每堆有一定的数量,每次可以将两堆相邻的石子合并,合并后放在两堆的中间位置,合并的费用为两堆石子的总数。求把所有石子合并成一堆的最小花费。
* 输入格式
* 输入第一行包含一个整数n,表示石子的堆数。
* 接下来一行,包含n个整数,按顺序给出每堆石子的大小 。
* 输出格式
* 输出一个整数,表示合并的最小花费。
* 样例输入
* 5
* 1 2 3 4 5
* 样例输出
* 33
* 数据规模和约定
* 1<=n<=1000, 每堆石子至少1颗,最多10000颗。*/
#include <iostream>
using namespace std;
const int MAXN = 1000;
int main()
{
int n;
int dp[MAXN][MAXN] = {0};
cin >> n;
for(int i = 0; i != n; i++){
cin >> dp[i][i];
}
for(int i = 0; i+1 != n; i++){
for(int j = i+1; j != n; j++)
dp[i][j] = dp[i][j-1] + dp[j][j];
}
for(int j = 2; j != n; j++){
for(int i = 0; i+j != n; i++){
int minAns;
if(dp[i][i+j-1] <= dp[i+1][i+j])
minAns = dp[i][i+j-1];
else
minAns = dp[i+1][i+j];
for(int m = i+2; m < i+j; m++){
if(dp[i][m-1] + dp[m][i+j] < minAns){
minAns = dp[i][m-1] + dp[m][i+j];
}
}
dp[i][i+j] += minAns;
}
}
cout << dp[0][n-1] << endl;
return 0;
}
| [
"wy5251702@qq.com"
] | wy5251702@qq.com |
72aca89ebde83415e199a363b809c4ec1729d195 | cfa21acecb795e3dc168efa9029ecf86cd058d3f | /ConvexHull/main.cpp | e27ac0496e3bf2068489e682d3439c241f8b3823 | [] | no_license | kbjjun0707/Algorithm | 88c74770a25475bd2579a1b50f22e85a6de70ebe | 2a0c66dc616d830a2122a9ed61c1afb5f954b934 | refs/heads/master | 2021-01-19T20:11:58.586894 | 2017-04-18T02:46:35 | 2017-04-18T02:46:35 | 88,494,693 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 2,651 | cpp | #include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
struct Point2f {
float x, y;
Point2f(const Point2f &src) {
this->x = src.x; this->y = src.y;
}
Point2f(float x = 0, float y = 0) {
this->x = x; this->y = y;
}
Point2f operator-(const Point2f &b) {
return Point2f(this->x - b.x, this->y - b.y);
}
void operator=(const Point2f &b) {
this->x = b.x; this->y = b.y;
}
};
bool LeftBottomComp(const Point2f &a, const Point2f &b) {
if (a.x == b.x)
return a.y < b.y;
return a.x < b.x;
}
Point2f g_stdPt;
bool AngleComp(const Point2f &a, const Point2f &b) {
if (((a.y - g_stdPt.y) / (a.x - g_stdPt.x)) == ((b.y - g_stdPt.y) / (b.x - g_stdPt.x))) {
return (((a.y - g_stdPt.y)*(a.y - g_stdPt.y) + (a.x - g_stdPt.x)*(a.x - g_stdPt.x)) <
((b.y - g_stdPt.y)*(b.y - g_stdPt.y) + (b.x - g_stdPt.x)*(b.x - g_stdPt.x)));
}
return (((a.y - g_stdPt.y) / (a.x - g_stdPt.x)) < ((b.y - g_stdPt.y) / (b.x - g_stdPt.x)));
}
// u, v는 벡터
int det(const Point2f &u, const Point2f &v) {
return ((u.x * v.y) - (u.y * v.x));
}
// det < 0 이면 ccw, det > 0 cw, det == 0 평행
int det(Point2f &a, Point2f &b, Point2f &c) {
return det(Point2f(b - a), Point2f(c - b));
}
void convexHull(const std::vector<Point2f> &p_Datas, std::vector<Point2f> &dst, std::vector<Point2f> &noncoverage = std::vector<Point2f>()) {
dst.clear();
noncoverage.clear();
int size = p_Datas.size();
if (size <= 3) {
for (auto it : p_Datas)
dst.push_back(it);
return;
}
std::vector<Point2f> Datas;
for (auto it : p_Datas)
Datas.push_back(it);
std::sort(Datas.begin(), Datas.end(), LeftBottomComp);
g_stdPt = Datas[0]; // 각도를 구할기준점 설정
std::sort(Datas.begin()+1, Datas.end(), AngleComp);
Point2f p1 = Datas[0], p2 = Datas[1], p3;
dst.push_back(p1);
dst.push_back(p2);
// i == 정렬된 배열의 인덱스
// top == convexhull로 판단, 저장하는 배열의 맨 위 인덱스
int i = 2, top = 1;
while (i < size) {
p1 = dst[top - 1];
p2 = dst[top - 0];
p3 = Datas[i];
if (det(p1, p2, p3) >= 0) {
dst.push_back(p3);
i++;
top++;
} else {
noncoverage.push_back(dst.back());
dst.pop_back();
top--;
}
}
}
int main() {
FILE *fp;
fopen_s(&fp, "input.txt", "r");
int num = 0;
float a, b;
fscanf_s(fp, "%d", &num);
std::vector<Point2f> datas; // 점들 저장소
for (int i = 0; i < num; i++) {
fscanf_s(fp, "%f %f", &a, &b);
datas.push_back(Point2f(a, b));
}
fclose(fp);
std::vector<Point2f> convexhullPoints;
convexHull(datas, convexhullPoints);
for (auto it : convexhullPoints) {
cout << it.x << ", " << it.y << endl;
}
return 0;
} | [
"kbjjun0707@naver.com"
] | kbjjun0707@naver.com |
7f38b94e836ad0d1a9367296fa2cf6a09216e1f6 | 839b0b1508840c45ef4ffad5e103e358fb821b94 | /src/StreetKombat/SpecialComponent.cpp | ac81d5ad1cc508174804a5ae8b814a181719a7e4 | [] | no_license | renanmms/StreetKombat | a74979b24adb43de3427cfacc8106ef6d1f44188 | 2c42d0a5f9aad9f276293cf95c5dd0896aa1a9b8 | refs/heads/master | 2023-05-04T02:37:10.041669 | 2021-05-29T20:40:28 | 2021-05-29T20:40:28 | 366,177,844 | 0 | 0 | null | 2021-05-29T01:34:21 | 2021-05-10T21:16:46 | C++ | UTF-8 | C++ | false | false | 1,361 | cpp | #include "SpecialComponent.h"
#include "Component.h"
#include "Special.h"
SpecialComponent::SpecialComponent(Character* owner, std::vector<int> activationSequence)
:Component(owner,110)
,owner(owner)
,mCurrentState(0)
,mLastKeyTime(0)
,deltaTime(0)
,mRechargeTime(0)
,mActivationSequence(activationSequence)
{
}
void SpecialComponent::Update(float deltaTime)
{
this->deltaTime = deltaTime;
}
void SpecialComponent::ProcessInput(const uint8_t* keyState)
{
// ------ Atualiza tempo de recarga da habilidade
mRechargeTime -= deltaTime;
if (mRechargeTime > 0) return;
// ------ Atualiza o tempo desde a ultima tecla
mLastKeyTime += deltaTime;
// ------ Verifica se passou do tempo minimo
if (mLastKeyTime > 0.2f)
{
// ------ Se a tecla correta foi pressionada
if (keyState[mActivationSequence[mCurrentState]])
{
// --- Atualiza o estado
mCurrentState++;
// --- Verifica se o jogador acertou a sequencia completa
if (mCurrentState == mActivationSequence.size())
{
new Special(owner->GetGame(), owner);
mRechargeTime = 1;
}
// --- Se o estado for final, volta pro inicio
mCurrentState = mCurrentState % mActivationSequence.size();
// --- Reset no tempo da ultima tecla apertada
mLastKeyTime = 0;
}
}
// ------ Verifica se passou do tempo maximo
if (mLastKeyTime > 1.0f)
{
mCurrentState = 0;
}
}
| [
"12pedro07@gmail.com"
] | 12pedro07@gmail.com |
6a1f8976f72c2db220066272b0d384da21fef1e2 | 4a8f783118bd1bba8023f5dbd499b08e1822ce93 | /src/Domain/ElementLogicalCoordinates.cpp | 052fed6230e849f927b1a6bf293400c85cce6506 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | denyzamelchor/spectre | 8db0757005dea9bb53cd7bd68ee8d11551705da4 | 1c1b72fbf464827788dbbdb8782a8251a2921c48 | refs/heads/develop | 2020-04-26T05:57:25.244454 | 2019-06-22T04:11:17 | 2019-06-22T04:11:17 | 155,779,028 | 0 | 0 | NOASSERTION | 2018-11-01T21:38:07 | 2018-11-01T21:38:06 | null | UTF-8 | C++ | false | false | 4,549 | cpp | // Distributed under the MIT License.
// See LICENSE.txt for details.
#include "ElementLogicalCoordinates.hpp"
#include <array>
#include <memory>
#include <unordered_map>
#include <utility>
#include <vector>
#include "DataStructures/IdPair.hpp"
#include "DataStructures/Tensor/Tensor.hpp" // IWYU pragma: keep
#include "DataStructures/Tensor/TypeAliases.hpp"
#include "Domain/BlockId.hpp" // IWYU pragma: keep
#include "Domain/ElementId.hpp" // IWYU pragma: keep
#include "Domain/Side.hpp"
#include "Utilities/GenerateInstantiations.hpp"
#include "Utilities/Gsl.hpp"
#include "Utilities/MakeArray.hpp"
namespace {
// Define this alias so we don't need to keep typing this monster.
template <size_t Dim>
using block_logical_coord_holder =
IdPair<domain::BlockId, tnsr::I<double, Dim, typename ::Frame::Logical>>;
} // namespace
template <size_t Dim>
std::unordered_map<ElementId<Dim>, ElementLogicalCoordHolder<Dim>>
element_logical_coordinates(const std::vector<ElementId<Dim>>& element_ids,
const std::vector<block_logical_coord_holder<Dim>>&
block_coord_holders) noexcept {
// Temporarily put results here in data structures that allow
// push_back, because we don't know the sizes of the output
// DataVectors ahead of time.
std::vector<std::array<std::vector<double>, Dim>> x_element_logical(
element_ids.size());
std::vector<std::vector<size_t>> offsets(element_ids.size());
// Loop over points
for (size_t offset = 0; offset < block_coord_holders.size(); ++offset) {
const auto& block_id = block_coord_holders[offset].id;
const auto& x_block_logical = block_coord_holders[offset].data;
// Need to loop over elements, because the block doesn't know
// things like the refinement_level of each element.
for (size_t index = 0; index < element_ids.size(); ++index) {
const auto& element_id = element_ids[index];
if (element_id.block_id() == block_id.get_index()) {
// This element is in this block; now check if the point is in
// this element.
bool is_contained = true;
auto x_elem = make_array<Dim>(0.0);
for (size_t d = 0; d < Dim; ++d) {
const double up =
gsl::at(element_id.segment_ids(), d).endpoint(Side::Upper);
const double lo =
gsl::at(element_id.segment_ids(), d).endpoint(Side::Lower);
const double x_block_log = x_block_logical.get(d);
if (x_block_log < lo or x_block_log > up) {
is_contained = false;
break;
}
// Map to element coords
gsl::at(x_elem, d) = (2.0 * x_block_log - up - lo) / (up - lo);
}
if (is_contained) {
for (size_t d = 0; d < Dim; ++d) {
gsl::at(x_element_logical[index], d).push_back(gsl::at(x_elem, d));
}
offsets[index].push_back(offset);
// Found a matching element, so we don't need to check other
// elements.
break;
}
}
}
}
// Now we know how many points are in each element, so we can
// put the intermediate results into the final data structure.
std::unordered_map<ElementId<Dim>, ElementLogicalCoordHolder<Dim>> result;
for (size_t index = 0; index < element_ids.size(); ++index) {
const size_t num_grid_pts = x_element_logical[index][0].size();
if (num_grid_pts > 0) {
tnsr::I<DataVector, Dim, Frame::Logical> tmp(num_grid_pts);
std::vector<size_t> off(num_grid_pts);
for (size_t s = 0; s < num_grid_pts; ++s) {
for (size_t d = 0; d < Dim; ++d) {
tmp.get(d)[s] = gsl::at(x_element_logical[index], d)[s];
}
off[s] = offsets[index][s];
}
result.emplace(element_ids[index], ElementLogicalCoordHolder<Dim>{
std::move(tmp), std::move(off)});
}
}
return result;
}
/// \cond
#define DIM(data) BOOST_PP_TUPLE_ELEM(0, data)
#define INSTANTIATE(_, data) \
template std::unordered_map<ElementId<DIM(data)>, \
ElementLogicalCoordHolder<DIM(data)>> \
element_logical_coordinates( \
const std::vector<ElementId<DIM(data)>>& element_ids, \
const std::vector<block_logical_coord_holder<DIM(data)>>& \
block_coord_holders) noexcept;
GENERATE_INSTANTIATIONS(INSTANTIATE, (1, 2, 3))
#undef DIM
#undef INSTANTIATE
/// \endcond
| [
"scheel@tapir.caltech.edu"
] | scheel@tapir.caltech.edu |
6cd72988cb37f842e5f057ec741eb5f1db7c2984 | 5bb3a45942b6c6812c93a7ebcebc69f05d4581cc | /demo/src/main.cpp | a9712f72932b35c8af0734faea44cf6583721bb8 | [] | no_license | fenghaotong/cmake-study | de5ff51a46f4e5335c65de46a728cb8efd322c32 | a127e51d83ed320523240655d1eed399ee95d5fa | refs/heads/master | 2023-07-18T15:58:49.816077 | 2021-09-17T03:19:46 | 2021-09-17T03:19:46 | 393,227,483 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,753 | cpp | #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <winsock2.h>
#include <iphlpapi.h>
// Link with Iphlpapi.lib
#pragma comment(lib, "IPHLPAPI.lib")
#define WORKING_BUFFER_SIZE 15000
#define MAX_TRIES 3
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
using namespace std;
/* Note: could also use malloc() and free() */
int __cdecl main(int argc, char **argv)
{
/* Declare and initialize variables */
DWORD dwSize = 0;
DWORD dwRetVal = 0;
unsigned int i = 0;
// Set the flags to pass to GetAdaptersAddresses
ULONG flags = GAA_FLAG_INCLUDE_PREFIX;
// default to unspecified address family (both)
ULONG family = AF_UNSPEC;
LPVOID lpMsgBuf = NULL;
PIP_ADAPTER_ADDRESSES pAddresses = NULL;
ULONG outBufLen = 0;
ULONG Iterations = 0;
PIP_ADAPTER_ADDRESSES pCurrAddresses = NULL;
PIP_ADAPTER_UNICAST_ADDRESS pUnicast = NULL;
PIP_ADAPTER_ANYCAST_ADDRESS pAnycast = NULL;
PIP_ADAPTER_MULTICAST_ADDRESS pMulticast = NULL;
IP_ADAPTER_DNS_SERVER_ADDRESS *pDnServer = NULL;
IP_ADAPTER_PREFIX *pPrefix = NULL;
if (argc != 2) {
printf(" Usage: getadapteraddresses family\n");
printf(" getadapteraddresses 4 (for IPv4)\n");
printf(" getadapteraddresses 6 (for IPv6)\n");
printf(" getadapteraddresses A (for both IPv4 and IPv6)\n");
exit(1);
}
if (atoi(argv[1]) == 4)
family = AF_INET;
else if (atoi(argv[1]) == 6)
family = AF_INET6;
printf("Calling GetAdaptersAddresses function with family = ");
if (family == AF_INET)
printf("AF_INET\n");
if (family == AF_INET6)
printf("AF_INET6\n");
if (family == AF_UNSPEC)
printf("AF_UNSPEC\n\n");
// Allocate a 15 KB buffer to start with.
outBufLen = WORKING_BUFFER_SIZE;
do {
pAddresses = (IP_ADAPTER_ADDRESSES *) MALLOC(outBufLen);
if (pAddresses == NULL) {
printf
("Memory allocation failed for IP_ADAPTER_ADDRESSES struct\n");
exit(1);
}
dwRetVal =
GetAdaptersAddresses(family, flags, NULL, pAddresses, &outBufLen);
if (dwRetVal == ERROR_BUFFER_OVERFLOW) {
FREE(pAddresses);
pAddresses = NULL;
} else {
break;
}
Iterations++;
} while ((dwRetVal == ERROR_BUFFER_OVERFLOW) && (Iterations < MAX_TRIES));
DWORD recvTotal, sendTotal;
recvTotal = sendTotal = 0;
if (dwRetVal == NO_ERROR) {
// If successful, output some information from the data we received
pCurrAddresses = pAddresses;
while (pCurrAddresses) {
MIB_IFROW *pIfRow = NULL;
pIfRow = (MIB_IFROW *) malloc(sizeof(MIB_IFROW));
SecureZeroMemory((PVOID)pIfRow, sizeof(MIB_IFROW));
pIfRow->dwIndex = pCurrAddresses->IfIndex;
int dwRetVal = GetIfEntry(pIfRow);
cout << "***************sent:" << pIfRow->dwOutOctets << "***************recv:" << pIfRow->dwInOctets << endl;
recvTotal += pIfRow->dwInOctets;
sendTotal += pIfRow->dwOutOctets;
printf("\tLength of the IP_ADAPTER_ADDRESS struct: %ld\n",
pCurrAddresses->Length);
printf("\tIfIndex (IPv4 interface): %u\n", pCurrAddresses->IfIndex);
printf("\tAdapter name: %s\n", pCurrAddresses->AdapterName);
pUnicast = pCurrAddresses->FirstUnicastAddress;
if (pUnicast != NULL) {
for (i = 0; pUnicast != NULL; i++)
pUnicast = pUnicast->Next;
printf("\tNumber of Unicast Addresses: %d\n", i);
} else
printf("\tNo Unicast Addresses\n");
pAnycast = pCurrAddresses->FirstAnycastAddress;
if (pAnycast) {
for (i = 0; pAnycast != NULL; i++)
pAnycast = pAnycast->Next;
printf("\tNumber of Anycast Addresses: %d\n", i);
} else
printf("\tNo Anycast Addresses\n");
pMulticast = pCurrAddresses->FirstMulticastAddress;
if (pMulticast) {
for (i = 0; pMulticast != NULL; i++)
pMulticast = pMulticast->Next;
printf("\tNumber of Multicast Addresses: %d\n", i);
} else
printf("\tNo Multicast Addresses\n");
pDnServer = pCurrAddresses->FirstDnsServerAddress;
if (pDnServer) {
for (i = 0; pDnServer != NULL; i++)
pDnServer = pDnServer->Next;
printf("\tNumber of DNS Server Addresses: %d\n", i);
} else
printf("\tNo DNS Server Addresses\n");
printf("\tDNS Suffix: %wS\n", pCurrAddresses->DnsSuffix);
printf("\tDescription: %wS\n", pCurrAddresses->Description);
printf("\tFriendly name: %wS\n", pCurrAddresses->FriendlyName);
if (pCurrAddresses->PhysicalAddressLength != 0) {
printf("\tPhysical address: ");
for (i = 0; i < (int) pCurrAddresses->PhysicalAddressLength;
i++) {
if (i == (pCurrAddresses->PhysicalAddressLength - 1))
printf("%.2X\n",
(int) pCurrAddresses->PhysicalAddress[i]);
else
printf("%.2X-",
(int) pCurrAddresses->PhysicalAddress[i]);
}
}
printf("\tFlags: %ld\n", pCurrAddresses->Flags);
printf("\tMtu: %lu\n", pCurrAddresses->Mtu);
printf("\tIfType: %ld\n", pCurrAddresses->IfType);
printf("\tOperStatus: %ld\n", pCurrAddresses->OperStatus);
printf("\tIpv6IfIndex (IPv6 interface): %u\n",
pCurrAddresses->Ipv6IfIndex);
printf("\tZoneIndices (hex): ");
for (i = 0; i < 16; i++)
printf("%lx ", pCurrAddresses->ZoneIndices[i]);
printf("\n");
printf("\tTransmit link speed: %I64u\n", pCurrAddresses->TransmitLinkSpeed);
printf("\tReceive link speed: %I64u\n", pCurrAddresses->ReceiveLinkSpeed);
pPrefix = pCurrAddresses->FirstPrefix;
if (pPrefix) {
for (i = 0; pPrefix != NULL; i++)
pPrefix = pPrefix->Next;
printf("\tNumber of IP Adapter Prefix entries: %d\n", i);
} else
printf("\tNumber of IP Adapter Prefix entries: 0\n");
printf("\n");
free(pIfRow);
pCurrAddresses = pCurrAddresses->Next;
}
} else {
printf("Call to GetAdaptersAddresses failed with error: %d\n",
dwRetVal);
if (dwRetVal == ERROR_NO_DATA)
printf("\tNo addresses were found for the requested parameters\n");
else {
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, dwRetVal, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
// Default language
(LPTSTR) & lpMsgBuf, 0, NULL)) {
printf("\tError: %s", lpMsgBuf);
LocalFree(lpMsgBuf);
if (pAddresses)
FREE(pAddresses);
exit(1);
}
}
}
cout << "***************sentTotal:" << sendTotal << "***************recvTotal:" << recvTotal << endl;
if (pAddresses) {
FREE(pAddresses);
}
return 0;
} | [
"fenghaotong@datagrand.com"
] | fenghaotong@datagrand.com |
befdc33643d15443e317e137c5549e32e2d91fd4 | dc23eb8e14659ab8bb62001a3b3323cb50c2a8ef | /system/testing/gtest_extras/Isolate.h | aca409d904476456eac80825140028c600163951 | [] | no_license | wudeven/cells-android10 | e49c0c830da7041313289349e160385df5d12ef8 | d18dfa3ab597a37b8b71a14f094ba5b8afc75a93 | refs/heads/master | 2023-08-16T06:47:55.804251 | 2021-10-16T05:41:01 | 2021-10-16T05:41:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,035 | h | /*
* Copyright (C) 2017 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.
*/
#pragma once
#include <poll.h>
#include <stdint.h>
#include <sys/types.h>
#include <map>
#include <memory>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#include "Color.h"
#include "Options.h"
#include "Test.h"
namespace android {
namespace gtest_extras {
class Isolate {
public:
Isolate(const Options& options, const std::vector<const char*>& child_args)
: options_(options), child_args_(child_args) {}
void EnumerateTests();
int Run();
private:
struct ResultsType {
const char* color;
const char* prefix;
const char* list_desc;
const char* title;
bool (*match_func)(const Test&);
void (*print_func)(const Options&, const Test&);
};
size_t CheckTestsFinished();
void CheckTestsTimeout();
int ChildProcessFn(const std::tuple<std::string, std::string>& test);
void HandleSignals();
void LaunchTests();
void ReadTestsOutput();
void RunAllTests();
void PrintFooter(uint64_t elapsed_time_ns);
void PrintResults(size_t total, const ResultsType& results, std::string* footer);
void WriteXmlResults(uint64_t elapsed_time_ns, time_t start_time);
static std::string GetTestName(const std::tuple<std::string, std::string>& test) {
return std::get<0>(test) + std::get<1>(test);
}
const Options& options_;
const std::vector<const char*>& child_args_;
size_t total_suites_ = 0;
size_t total_tests_ = 0;
size_t total_disable_tests_ = 0;
size_t total_pass_tests_;
size_t total_xpass_tests_;
size_t total_fail_tests_;
size_t total_xfail_tests_;
size_t total_timeout_tests_;
size_t total_slow_tests_;
size_t total_skipped_tests_;
size_t cur_test_index_ = 0;
uint64_t slow_threshold_ns_;
uint64_t deadline_threshold_ns_;
std::vector<std::tuple<std::string, std::string>> tests_;
std::vector<Test*> running_;
std::vector<pollfd> running_pollfds_;
std::vector<size_t> running_indices_;
std::unordered_map<pid_t, std::unique_ptr<Test>> running_by_pid_;
std::map<size_t, Test*> running_by_test_index_;
std::map<size_t, std::unique_ptr<Test>> finished_;
static constexpr useconds_t MIN_USECONDS_WAIT = 1000;
static ResultsType SlowResults;
static ResultsType XpassFailResults;
static ResultsType FailResults;
static ResultsType TimeoutResults;
static ResultsType SkippedResults;
};
} // namespace gtest_extras
} // namespace android
| [
"jianglin@xdja.com"
] | jianglin@xdja.com |
8642e7c51cbce6efc1fdf17834a7fc4630b7ab8b | f76606b4e7ea1c34dd6b99a1ea6991c79e5592e0 | /src/elements/mupmedia.h | 57cfa34a3dc842f574034804509d259754dbb735 | [] | no_license | oleglite/MUP | 5bc31e34c1f16131c05984991d933c58bb8a1467 | 346ae80396bfc048835ffe0807e35fe703f960d8 | refs/heads/master | 2021-01-10T19:54:41.851887 | 2012-06-01T16:39:23 | 2012-06-01T16:39:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 292 | h | #ifndef MUPMEDIA_H
#define MUPMEDIA_H
#include "mupelement.h"
class MupMedia : public MupElement
{
public:
MupMedia(const QString& label, bool isSingle = false);
protected:
virtual QString groupElementOpenTag();
virtual QString groupElementCloseTag();
};
#endif // MUPMEDIA_H
| [
"beloglazov.oleg@gmail.com"
] | beloglazov.oleg@gmail.com |
8d221743a7a058653f826b3a0ead43c4656a948c | 05f8bb5289d3056ad7e4e20f05cfc98294838a1c | /tools/toy/mlir/ShapeInferencePass.cpp | cf3e492989b0f6f7cb1cb55487713720e1cfe6b5 | [
"MIT"
] | permissive | quantapix/qnarre | 72fc18d605dfa5db8a056016a7e5cbb2b19ad2da | a37ccb61338ce3d733c0f0ec1c9d40000b93132d | refs/heads/main | 2023-08-30T23:25:16.401972 | 2023-08-29T00:43:52 | 2023-08-29T00:43:52 | 178,420,195 | 2 | 0 | Apache-2.0 | 2021-09-27T21:56:01 | 2019-03-29T14:26:31 | Python | UTF-8 | C++ | false | false | 4,150 | cpp | //===- ShapeInferencePass.cpp - Shape Inference ---------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file implements a Function level pass performing interprocedural
// propagation of array shapes through function specialization.
//
//===----------------------------------------------------------------------===//
#include "mlir/Pass/Pass.h"
#include "toy/Dialect.h"
#include "toy/Passes.h"
#include "toy/ShapeInferenceInterface.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#define DEBUG_TYPE "shape-inference"
using namespace mlir;
using namespace toy;
/// Include the auto-generated definitions for the shape inference interfaces.
#include "toy/ShapeInferenceOpInterfaces.cpp.inc"
namespace {
/// The ShapeInferencePass is a pass that performs intra-procedural
/// shape inference.
///
/// Algorithm:
///
/// 1) Build a worklist containing all the operations that return a
/// dynamically shaped tensor: these are the operations that need shape
/// inference.
/// 2) Iterate on the worklist:
/// a) find an operation to process: the next ready operation in the
/// worklist has all of its arguments non-generic,
/// b) if no operation is found, break out of the loop,
/// c) remove the operation from the worklist,
/// d) infer the shape of its output from the argument types.
/// 3) If the worklist is empty, the algorithm succeeded.
///
struct ShapeInferencePass
: public mlir::PassWrapper<ShapeInferencePass, OperationPass<toy::FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ShapeInferencePass)
void runOnOperation() override {
auto f = getOperation();
// Populate the worklist with the operations that need shape inference:
// these are operations that return a dynamic shape.
llvm::SmallPtrSet<mlir::Operation *, 16> opWorklist;
f.walk([&](mlir::Operation *op) {
if (returnsDynamicShape(op))
opWorklist.insert(op);
});
// Iterate on the operations in the worklist until all operations have been
// inferred or no change happened (fix point).
while (!opWorklist.empty()) {
// Find the next operation ready for inference, that is an operation
// with all operands already resolved (non-generic).
auto nextop = llvm::find_if(opWorklist, allOperandsInferred);
if (nextop == opWorklist.end())
break;
Operation *op = *nextop;
opWorklist.erase(op);
// Ask the operation to infer its output shapes.
LLVM_DEBUG(llvm::dbgs() << "Inferring shape for: " << *op << "\n");
if (auto shapeOp = dyn_cast<ShapeInference>(op)) {
shapeOp.inferShapes();
} else {
op->emitError("unable to infer shape of operation without shape "
"inference interface");
return signalPassFailure();
}
}
// If the operation worklist isn't empty, this indicates a failure.
if (!opWorklist.empty()) {
f.emitError("Shape inference failed, ")
<< opWorklist.size() << " operations couldn't be inferred\n";
signalPassFailure();
}
}
/// A utility method that returns if the given operation has all of its
/// operands inferred.
static bool allOperandsInferred(Operation *op) {
return llvm::all_of(op->getOperandTypes(), [](Type operandType) {
return operandType.isa<RankedTensorType>();
});
}
/// A utility method that returns if the given operation has a dynamically
/// shaped result.
static bool returnsDynamicShape(Operation *op) {
return llvm::any_of(op->getResultTypes(), [](Type resultType) {
return !resultType.isa<RankedTensorType>();
});
}
};
} // namespace
/// Create a Shape Inference pass.
std::unique_ptr<mlir::Pass> mlir::toy::createShapeInferencePass() {
return std::make_unique<ShapeInferencePass>();
}
| [
"quantapix@gmail.com"
] | quantapix@gmail.com |
17743b5d7726cd72043489de9e37cf55b8d8cdb2 | d5208f8f6e5970b207b5c3cbcfcaa7e86da408d9 | /src/SSVStart/GameSystem/Timers/TimerStatic.cpp | 41516a114ec4584f5480630a1d3e5aa7ab756111 | [
"AFL-3.0",
"LicenseRef-scancode-unknown-license-reference",
"AFL-2.1"
] | permissive | respu/SSVStart | 023a821785b70556e07fb59c708bd633c18bf9aa | d369067fe7832cf29ef5c294b4e0a3a5d7d77177 | refs/heads/master | 2020-12-25T05:47:36.049350 | 2013-06-12T20:12:11 | 2013-06-12T20:12:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,212 | cpp | #include "SSVStart/GameSystem/Timers/TimerStatic.h"
#include "SSVStart/GameSystem/GameWindow.h"
namespace ssvs
{
StaticTimer::StaticTimer(GameWindow& mGameWindow, float mStep, float mTimeSlice, float mMaxLoops) : TimerBase(mGameWindow), step{mStep}, timeSlice{mTimeSlice}, maxLoops{mMaxLoops} { }
StaticTimer::~StaticTimer() { }
void StaticTimer::runUpdate()
{
loops = 0;
time += frameTime;
while(time >= timeSlice && loops < maxLoops)
{
gameWindow.runUpdate(step);
time -= timeSlice;
++loops;
}
}
float StaticTimer::getStep() const { return step; }
float StaticTimer::getTimeSlice() const { return timeSlice; }
float StaticTimer::getMaxLoops() const { return maxLoops; }
float StaticTimer::getTime() const { return time; }
float StaticTimer::getLoops() const { return loops; }
void StaticTimer::setStep(float mStep) { step = mStep; }
void StaticTimer::setTimeSlice(float mTimeSlice) { timeSlice = mTimeSlice; }
void StaticTimer::setMaxLoops(float mMaxLoops) { maxLoops = mMaxLoops; }
StaticTimer& createStaticTimer(GameWindow& mGameWindow, float mStep, float mSpeed, float mMaxLoops) { return *(new StaticTimer{mGameWindow, mStep, mSpeed, mMaxLoops}); }
}
| [
"vittorio.romeo@outlook.com"
] | vittorio.romeo@outlook.com |
4daa820e8e0392268c3bd4888472f653e5dfb47f | 0c51500f87101f13c471f0c310e9451a87adc714 | /nfdrs/cnfdrs.h | 9509a570e6e509f3ad755f97b768c8b01619491b | [
"LicenseRef-scancode-public-domain",
"Unlicense"
] | permissive | firelab/wfips | a5e589fde41579e87008a7900a87692ec985e529 | 6b3bd4934d281ebb31164bd242a57079a82053b0 | refs/heads/master | 2020-05-01T06:03:41.792664 | 2017-01-27T19:31:55 | 2017-01-27T19:31:55 | 14,540,320 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 5,747 | h | /******************************************************************************
*
* $Id: cnfdrs.h 79 2012-07-26 15:36:43Z kyle.shannon $
*
* Project: NFDRS library
* Purpose:
* Author: Stu Britan <stu at fire dot org>
*
******************************************************************************
*
* THIS SOFTWARE WAS DEVELOPED AT THE ROCKY MOUNTAIN RESEARCH STATION (RMRS)
* MISSOULA FIRE SCIENCES LABORATORY BY EMPLOYEES OF THE FEDERAL GOVERNMENT
* IN THE COURSE OF THEIR OFFICIAL DUTIES. PURSUANT TO TITLE 17 SECTION 105
* OF THE UNITED STATES CODE, THIS SOFTWARE IS NOT SUBJECT TO COPYRIGHT
* PROTECTION AND IS IN THE PUBLIC DOMAIN. RMRS MISSOULA FIRE SCIENCES
* LABORATORY ASSUMES NO RESPONSIBILITY WHATSOEVER FOR ITS USE BY OTHER
* PARTIES, AND MAKES NO GUARANTEES, EXPRESSED OR IMPLIED, ABOUT ITS QUALITY,
* RELIABILITY, OR ANY OTHER CHARACTERISTIC.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
/*
#ifdef BUILD_CNFDRSDLL
#define CNFDRSDLL_EXPORT __declspec(dllexport)
#else
#define CNFDRSDLL_EXPORT __declspec(dllimport)
#endif
#pragma once
*/
#ifdef WIN32
#ifdef nfdrs_EXPORTS
#define CNFDRSDLL_EXPORT __declspec(dllexport)
#else
#define CNFDRSDLL_EXPORT __declspec(dllimport)
#endif
#else
#define CNFDRSDLL_EXPORT
#endif
typedef const char* LPCSTR;
class NFDRCalc;
class CNFDRSDLL_EXPORT CNFDRS
{
public:
CNFDRS();
~CNFDRS();
double fCalcDaylightHours(short iLat, short iJulian);
short iCalcIndexes(short iWS, short iSlopeCls, double * fROS, int * iSC, double * fERC, double * fFL, int * iFIL, int * iBI);
short iCalcAdjustMC1(short iMonth, short iExposure, short iAspect, short iSite, short iSlope30, short iHour);
short iCalcIC(short iTemp, short iSOW, double fMC1, double fROS, int * iIC);
short iDoAdjustMC1(short iAdjust);
short iGetFuelBed(int * iSA1, int * iSA10, int * iSA100, int * iSA1000, int * iSAWOOD, int * iSAHERB, double * fW1,
double * fW10, double * fW100, double * fW1000, double * fWWOOD, double * fWHERB, double * fWDROUGHT,
double * fDEPTH, int * iMXD, int * iHD, int * iSCM, double * fWNDFC, double * fWNDFCMin, double * fWNDFCMax);
short iGetFuelModel(int * iFM);
short iSetFuelBed(short iSA1, short iSA10, short iSA100, short iSA1000, short iSAWOOD, short iSAHERB, double fW1, double fW10, double fW100, double fW1000, double fWWOOD, double fWHERB, double fWDROUGHT, double fWDEPTH, short iMXD, short iHD, short iSCM, double fWNDFC, double fWNDFCMin, double fWNDFCMax);
short iSetFuelModel(short iFM, short iNFMAS);
short iSetMoistures(double fMC1, double fMC10, double fMC100, double fMC1000, double fMCWood, double fMCHerb, short iRainEvent, short iKBDI, short iGreenHerb, short iGreenWoody, short iSeason, short iSOW);
short iInitialize(short iNFDRSVersion, short iClimateClass, short iJulianLookFreeze, short iJulianGreenUp, short iLat, short iHerbAnnual, short iWoodyDeciduous, short iOneIsTen, double fStart100, double fStart1000, short iStartKBDI, double fAvgPrecip);
short iCalcMoist(short iInit, short iTemp, short iRH, short iMaxTemp, short iMaxRH, short iMinTemp, short iMinRH,
short iPrecipDur, double fPrecipAmt, short iSOW, double f10stick, short iJulian, short iYear,
short iDeclareGreenUp, short iDeclareFreeze, short iGreenHerb, short iGreenWoody, short iSeason,
double * f1, double * f10, double * f100, double * f1000, double * fHerb, double * fWood,
int * iStage, double * fGren, double * fX1000, int * iRainEvent, int * iKBDI);
short iCalcKBDI(double fPrecipAmt, short iMaxTemp, double fCummPrecip, short iYKBDI, double fAvgPrecip);
short LoadState(LPCSTR fileName);
short SaveState(LPCSTR fileName);
double GetL1();
double GetL10();
double GetL100();
double GetL1000();
double GetLHerb();
double GetLWood();
double GetLDrought();
short GetSG1();
short GetSG10();
short GetSG100();
short GetSG1000();
short GetSGHerb();
short GetSGWood();
short GetHD();
short GetMXD();
short GetSCM();
double GetWindFC();
double GetDepth();
short SetNFDRSVersion(short version);
short iCalcMoistWetFlag(short iInit, short iTemp, short iRH, short iMaxTemp, short iMaxRH, short iMinTemp,
short iMinRH, short iPrecipDur, double fPrecipAmt, short iSOW, double f10stick, short iJulian, short iYear,
short iDeclareGreenUp, short iDeclareFreeze, short iGreenHerb, short iGreenWoody, short iSeason,
int iWetFlag, double * f1, double * f10, double * f100, double * f1000, double * fHerb, double * fWood,
int * iStage, double * fGren, double * fX1000, int * iRainEvent, int * iKBDI);
short iSetAnnualInit(short iJulianGreenUp, double fStart1000, short iStartKBDI);
short iSetJulianShrubDormant(short iJulianDormant);
private:
NFDRCalc *m_nfdrs;
};
| [
"kyle@pobox.com"
] | kyle@pobox.com |
06dcbf59227f84a460f4cf793088c9477454b7ce | 4d0166c58be6a031c695295ded4192cfac202fc3 | /bin/mac64/cpp/obj/include/com/haxepunk/graphics/atlas/_AtlasData/AtlasDataType_Impl_.h | 2ee624e069954ae98a7870e4c809d6adafc3dd07 | [] | no_license | tobyalden/worry | 8d1262c91fa0cb491e917492baf9ce0a5fc45d1a | ebb9892175c92772142e3d48f3d4571132670863 | refs/heads/master | 2021-01-10T02:44:23.673599 | 2016-03-24T01:40:57 | 2016-03-26T02:08:12 | 53,271,643 | 0 | 2 | null | 2016-03-27T22:42:13 | 2016-03-06T19:19:26 | C++ | UTF-8 | C++ | false | false | 2,340 | h | #ifndef INCLUDED_com_haxepunk_graphics_atlas__AtlasData_AtlasDataType_Impl_
#define INCLUDED_com_haxepunk_graphics_atlas__AtlasData_AtlasDataType_Impl_
#ifndef HXCPP_H
#include <hxcpp.h>
#endif
HX_DECLARE_CLASS4(com,haxepunk,graphics,atlas,AtlasData)
HX_DECLARE_CLASS5(com,haxepunk,graphics,atlas,_AtlasData,AtlasDataType_Impl_)
HX_DECLARE_CLASS3(openfl,_legacy,display,BitmapData)
HX_DECLARE_CLASS3(openfl,_legacy,display,IBitmapDrawable)
namespace com{
namespace haxepunk{
namespace graphics{
namespace atlas{
namespace _AtlasData{
class HXCPP_CLASS_ATTRIBUTES AtlasDataType_Impl__obj : public hx::Object{
public:
typedef hx::Object super;
typedef AtlasDataType_Impl__obj OBJ_;
AtlasDataType_Impl__obj();
Void __construct();
public:
inline void *operator new( size_t inSize, bool inContainer=false,const char *inName="com.haxepunk.graphics.atlas._AtlasData.AtlasDataType_Impl_")
{ return hx::Object::operator new(inSize,inContainer,inName); }
static hx::ObjectPtr< AtlasDataType_Impl__obj > __new();
static Dynamic __CreateEmpty();
static Dynamic __Create(hx::DynamicArray inArgs);
//~AtlasDataType_Impl__obj();
HX_DO_RTTI_ALL;
static bool __GetStatic(const ::String &inString, Dynamic &outValue, hx::PropertyAccess inCallProp);
static void __register();
::String __ToString() const { return HX_HCSTRING("AtlasDataType_Impl_","\x2f","\x50","\xda","\x8c"); }
static ::com::haxepunk::graphics::atlas::AtlasData _new( ::com::haxepunk::graphics::atlas::AtlasData data);
static Dynamic _new_dyn();
static ::com::haxepunk::graphics::atlas::AtlasData toAtlasData( ::com::haxepunk::graphics::atlas::AtlasData this1);
static Dynamic toAtlasData_dyn();
static ::com::haxepunk::graphics::atlas::AtlasData fromString( ::String s);
static Dynamic fromString_dyn();
static ::com::haxepunk::graphics::atlas::AtlasData fromBitmapData( ::openfl::_legacy::display::BitmapData bd);
static Dynamic fromBitmapData_dyn();
static ::com::haxepunk::graphics::atlas::AtlasData fromAtlasData( ::com::haxepunk::graphics::atlas::AtlasData data);
static Dynamic fromAtlasData_dyn();
};
} // end namespace com
} // end namespace haxepunk
} // end namespace graphics
} // end namespace atlas
} // end namespace _AtlasData
#endif /* INCLUDED_com_haxepunk_graphics_atlas__AtlasData_AtlasDataType_Impl_ */
| [
"toby@Tobys-MacBook-Pro.local"
] | toby@Tobys-MacBook-Pro.local |
258ed4d0c87f82596d00ff95288293294495be8f | 4ead26a90177ec360d2c92e3b9a513fa94eb268a | /src/instrument_reader.cpp | 40f44dcab89a685104b47870ec6918038dd3a8be | [
"MIT"
] | permissive | jose-navarro/astrolabe | f509fbec917b5ec94b48e9d383c46dd0d4f2d395 | 95482bf4ecd7c22e0bcef18aeae0d8b828b3327c | refs/heads/master | 2020-04-07T12:43:41.193990 | 2019-12-09T12:54:35 | 2019-12-09T12:54:35 | 156,842,123 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,623 | cpp | /** \file instrument_reader.cpp
\brief Implementation file for instrument_reader.hpp.
\ingroup ASTROLABE_data_IO
*/
#include "instrument_reader.hpp"
int
instrument_reader::
close
(void)
{
{
int status;
status = 0;
// If we were already closed, we'll simply ignore the request.
if (!data_channel_is_open_) return status;
if (data_channel_is_socket_)
{
if (socket_reader_ != NULL)
{
status = socket_reader_->close();
delete socket_reader_;
socket_reader_ = NULL;
}
}
else
{
if (file_reader_ != NULL)
{
status = file_reader_->close();
delete file_reader_;
file_reader_ = NULL;
}
}
data_channel_is_open_ = false;
return status;
}
}
bool
instrument_reader::
data_channel_is_file
(void)
{
{
return !data_channel_is_socket_;
}
}
bool
instrument_reader::
data_channel_is_socket
(void)
{
{
return data_channel_is_socket_;
}
}
instrument_reader::
instrument_reader
(void)
{
{
data_channel_is_open_ = false;
data_channel_is_set_ = false;
data_channel_is_socket_ = false;
file_reader_ = NULL;
is_eof_ = false;
is_header_filename_set_ = false;
is_metadata_read_ = false;
is_schema_filename_set_ = false;
header_file_ = "";
schema_file_ = "";
socket_reader_ = NULL;
socket_works_in_server_mode_ = true;
}
}
instrument_reader::
~instrument_reader
(void)
{
{
// Close the reader if still open.
if (data_channel_is_open_) close();
}
}
int
instrument_reader::
get_metadata
(int& total_metadata_warnings,
int& total_metadata_errors)
{
{
int data_channel_format; // Format of the data (file, socket...) to read.
vector<string> error_description; // To build full error messages.
gp_utils gp; // Utilitary class. Used to format error messages
// in our case.
int retcode; // Return code.
string error_message; // A full error message.
string error_tag; // Tag in the input header file where an error has
// been found.
// Don't try to retrieve metadata if it's already been retrieved or
// we've already opened (open()) the underlying data channel.
if ((is_metadata_read_) | (data_channel_is_open_)) return 1;
//
// We need at least the name of the astrolabe header file. If
// not set, we must report an error.
//
if (!is_header_filename_set_) return 2;
// It looks like everything is correct. Set the total number of issues to 0.
total_metadata_warnings = 0;
total_metadata_errors = 0;
//
// We have to parse the file containing the astrolabe header with
// the description of the data channel (socket, file...).
//
// We'll may use the parser in two different ways; this depends on having
// or not a schema file.
//
if (is_schema_filename_set_)
{
// We've got an schema to check the input file.
header_parser_.set_parser_parameters(header_file_, schema_file_, &header_data_);
}
else
{
// No schema available. We'll work in "unsafe" mode.
header_parser_.set_parser_parameters_developer(header_file_, &header_data_);
}
// We are ready to parse...
header_parser_.parse();
//
// Check if warnings of errors have been detected and set the return
// code accordingly.
//
total_metadata_warnings = header_parser_.warnings_dim();
total_metadata_errors = header_parser_.errors_dim();
retcode = 0;
if ((total_metadata_warnings != 0) | (total_metadata_errors != 0)) retcode = 3;
//
// We indicate that the metadata has been retrieved, no matter the what
// the return code is. This is to avoid repeated calls to this method.
//
is_metadata_read_ = true;
//
// Load some metadata from our own purposes. Only if we could
// read it correctly!
//
if (total_metadata_errors == 0)
{
data_channel_format = header_data_.get_device_format();
data_channel_is_socket_ = (data_channel_format == gp_astrolabe_header_file_data::GP_ASTROLABE_HEADER_FORMAT_IS_SOCKET);
}
// That's all.
return retcode;
}
}
int
instrument_reader::
get_metadata_errors
(list<string>& list_of_errors)
{
{
int i;
string message;
int total_items;
list_of_errors.clear();
total_items = header_parser_.errors_dim();
for (i = 0; i < total_items; i++)
{
message = header_parser_.errors_get(i);
list_of_errors.push_back(message);
}
return total_items;
}
}
int
instrument_reader::
get_metadata_warnings
(list<string>& list_of_warnings)
{
{
int i;
string message;
int total_items;
list_of_warnings.clear();
total_items = header_parser_.warnings_dim();
for (i = 0; i < total_items; i++)
{
message = header_parser_.warnings_get(i);
list_of_warnings.push_back(message);}
return total_items;
}
}
bool
instrument_reader::
is_eof
(void)
const
{
{
return is_eof_;
}
}
bool
instrument_reader::
is_open
(void)
const
{
{
return data_channel_is_open_;
}
}
int
instrument_reader::
open
(void)
{
{
string data_channel_filename;
string chunk_filename;
const char* host;
int port;
int status;
// If the data channel is already open, report an error.
if (data_channel_is_open_) return 1;
//
// Now, check what kind of underlying data channel we are
// going to deal with.
//
if (data_channel_is_socket_)
{
// Working with sockets.
// Get the host, if any.
host = NULL;
if (header_data_.is_set_device_server()) host = (header_data_.get_device_server()).c_str();
// We must retrieve the port used to connect.
port = header_data_.get_device_port();
// Check that server or client mode plus host and port make the right combination.
if (!socket_works_in_server_mode_)
{
// We want the socket reader work as a client, that is, starting
// itself the connection. Therefore, we need not only a port number
// but also a host name or IP addresss...
if (host == NULL) return 2;
}
// Create the socket reader.
try
{
socket_reader_ = new instrument_socket_reader();
}
catch (...)
{
// Unable to open.
return 2;
}
// Open the socket connection.
status = socket_reader_->open(host, port, socket_works_in_server_mode_);
if (status != 0) return status;
// We've opened the underlying data channel!!!
data_channel_is_open_ = true;
}
else
{
//
// Retrieve the name of the "general" external file that will keep (in fact,
// possibly split into chunks) the actual data.
//
data_channel_filename = header_data_.get_device_file_name();
//
// Set up the segmented_file_utils object that will take care of generating
// the names of the chunk files making the "general" underlying data file.
//
chunk_names_generator_.set_mode_read(data_channel_filename, false);
//
// Get the name of the first chunk making the general file.
// Note that if the next call fails, it will mean that the
// actual chunk files are not located in the same folder
// than the astrolabe header file or that these chunks
// do not exist or that are named incorrectly.
//
status = chunk_names_generator_.get_next_filename(chunk_filename);
if (status != 0) return 2; // Unable to open data channel.
//
// Instantiate the file reader.
//
file_reader_ = new instrument_file_reader_txt_forward();
//
// We may now try to open the actual underlying file using
// the reader (whatever it is) just created. This should never
// fail, since our chunk filenames generator already has checked
// that these chunks do exist. However, we'll check...
//
status = file_reader_->open(chunk_filename.c_str());
if (status != 0) return status;
// We've opened the underlying data channel!!!
data_channel_is_open_ = true;
}
// That's all!
return 0;
}
}
int
instrument_reader::
read_active_flag
(bool& active)
{
{
int status;
if (data_channel_is_socket_)
{
// Sockets.
status = socket_reader_->read_active_flag(active);
}
else
{
// Files.
status = file_reader_->read_active_flag(active);
}
return status;
}
}
int
instrument_reader::
read_identifier
(char*& identifier,
int id_len)
{
{
if (data_channel_is_socket_)
{
// Sockets
return socket_reader_->read_identifier(identifier, id_len);
}
else
{
// Files.
return file_reader_->read_identifier(identifier, id_len);
}
}
}
int
instrument_reader::
read_l_data
(int n_tag_values,
double*& the_tags,
int n_expectation_values,
double*& the_expectations,
int& n_covariance_values_found,
double*& the_covariance_values)
{
{
if (data_channel_is_socket_)
{
// Sockets.
return socket_reader_->read_l_data(n_tag_values, the_tags,
n_expectation_values, the_expectations,
n_covariance_values_found, the_covariance_values);
}
else
{
// Files.
return file_reader_->read_l_data(n_tag_values, the_tags,
n_expectation_values, the_expectations,
n_covariance_values_found, the_covariance_values);
}
}
}
int
instrument_reader::
read_instance_id
(int& instance_identifier)
{
{
if (data_channel_is_socket_)
{
// Sockets.
return socket_reader_->read_instance_id(instance_identifier);
}
else
{
// Files
return file_reader_->read_instance_id(instance_identifier);
}
}
}
int
instrument_reader::
read_time
(double& time)
{
{
int status;
if (data_channel_is_socket_)
{
// Sockets.
status = socket_reader_->read_time(time);
}
else
{
// Files.
status = file_reader_->read_time(time);
}
// Check how things went.
if (status != 0) return status;
// That's all.
return 0;
}
}
int
instrument_reader::
read_type
(char& record_type)
{
{
string chunk_filename;
int status;
if (data_channel_is_socket_)
{
// Sockets.
status = socket_reader_->read_type(record_type);
if (status == 1) is_eof_ = true;
return status;
}
else
{
// Files.
//
// Use the file generic file reader's read_type method to actually
// read the type.
//
status = file_reader_->read_type(record_type);
//
// Note that the following test is inside a while loop; this strange
// way of testing tries to cover the situation where a series of chunk
// files are empty, so opening the next chunk will raise again
// an end of file condition.
//
// The look is broken either when a chunk is opened and its first type
// value read correctly or when NO more chunks are available.
//
while (status == 1)
{
//
// This is an end-of-file condition. Since we're working with split
// files (chunks) we must try to open the next one instead of returning
// directly this flag. Only when no more files are available we'll
// return and "end-of-file" code.
//
//
// First, close the current reader. This could return an error code,
// that we'll rewrite as "error closing / opening current / next chunk".
//
status = file_reader_->close();
delete file_reader_;
file_reader_ = NULL;
if (status != 0) return 7;
//
// Generate the name for the next chunk.
//
// If we've got an error here, it means that there are no more files
// to read, so we'll return the end-of-file condition.
//
status = chunk_names_generator_.get_next_filename(chunk_filename);
if (status != 0)
{
is_eof_ = true;
return 1; // End of file (no more chunks are available).
}
//
// Instantiate the file reader.
//
file_reader_ = new instrument_file_reader_txt_forward();
//
// Open the new chunk. If this fails, we'll return an
// "error closing / opening current / next chunk".
//
status = file_reader_->open(chunk_filename.c_str());
if (status != 0) return 7;
//
// Now we must read the type from the new chunk!
//
status = file_reader_->read_type(record_type);
}
//
// At this point we may have a correct type read or an error code that
// will never be an end-of-file condition. Whatever it is, we may
// safely return.
//
// If the type was correctly read, the status will be 0; if we've had
// a problem, it will not be an end of file, but some other kind of
// problem that we must report.
//
return status;
}
}
}
int
instrument_reader::
set_data_channel
(bool socket_works_in_server_mode)
{
{
if ((data_channel_is_set_) | (data_channel_is_open_))
{
// It is not possible to set the filename once it's been opened.
return 1;
}
// Copy the socket server mode flag.
socket_works_in_server_mode_ = socket_works_in_server_mode;
data_channel_is_set_ = true;
// That's all.
return 0;
}
}
int
instrument_reader::
set_header_file
(const char* header_file_name)
{
{
int status;
int total_errors;
int total_warnings;
if (header_file_name == NULL)
{
// We need a filename.
return 1;
}
if ((is_header_filename_set_) | (data_channel_is_open_))
{
// It is not possible to set the filename once it's been opened.
return 2;
}
// Copy the input file name and set control flags.
header_file_ = header_file_name;
is_header_filename_set_ = true;
// Let's load the metadata!!!
status = get_metadata(total_warnings, total_errors);
//
// If errors or warnings have been detected, report the issue. The
// caller module may retrieve the amount and list of warnings or
// errors using get_metadata_warnings() and get_metadata_errors()
// respectively.
//
if (status != 0) return 3;
// That's all.
return 0;
}
}
int
instrument_reader::
set_schema_file
(const char* schema_file_name)
{
{
if (schema_file_name == NULL)
{
// We need a filename.
return 1;
}
if (is_header_filename_set_)
{
//
// It is not possible to set the name of the XML schema if the
// name of the astrolabe header file has already been set.
//
return 2;
}
// Copy the input file name and set control flags.
schema_file_ = schema_file_name;
is_schema_filename_set_ = true;
return 0;
}
}
| [
"jose.navarro@cttc.es"
] | jose.navarro@cttc.es |
ec833d062a0c1f53d91393f0d8786ef5e9ccc13c | 3c761ddfeadde07c39f033b12457fe490df6339f | /moneyhub2.2/BankUI/UIControl/BaseClass/MouseObjContainer.h | 0b5688d291618c4400cd6effc408f6c8408d7610 | [] | no_license | 3660628/chtmoneyhub | d8fe22cef017d7a12b4c582667b6484af01032d2 | 7861d387a49edfe395379c1450df18cb1b8658f2 | refs/heads/master | 2021-01-02T09:20:08.263263 | 2012-01-11T08:32:20 | 2012-01-11T08:32:20 | 33,034,456 | 2 | 1 | null | null | null | null | GB18030 | C++ | false | false | 3,280 | h | #pragma once
// 之所以要弄这么一个类,主要是需要传递一些数据,模板类实例化之后,就不好写成指针的形式了
class CBaseProperties
{
public:
CBaseProperties() : m_bIsInWindow(false), m_iAlwaysStatus(0), m_iContainerType(-1), m_bIsPushDownButtonDown(false) {}
bool IsInWindow() const { return m_iAlwaysStatus > 0 ? true : m_bIsInWindow; }
void SetContainerType(int iType) { m_iContainerType = iType; }
ButtonStatus GetStatus() const
{
return IsInWindow() ? ((m_iContainerType == 0 && m_bIsPushDownButtonDown) ? Btn_MouseDown : Btn_MouseOver) : Btn_MouseOut;
}
int m_iAlwaysStatus;
bool m_bIsInWindow;
int m_iContainerType;
bool m_bIsPushDownButtonDown;
};
template <class T>
class ATL_NO_VTABLE CMouseObjContainer : public CBaseProperties
{
public:
void RegisterMouseObjChild(HWND hWnd, bool bAutoUpdate)
{
m_ChildWndSet.insert(std::make_pair(hWnd, bAutoUpdate));
T *pT = static_cast<T*>(this);
::SendMessage(hWnd, WM_USER + 0x000f, 0, (LPARAM)pT->m_hWnd);
}
void SetAlwaysOn(bool bFlag)
{
m_iAlwaysStatus = bFlag ? 1 : 0;
InvalidateAll();
}
private:
void InvalidateAll()
{
T *pT = static_cast<T*>(this);
pT->Invalidate();
for (ChildWindowSet::iterator it = m_ChildWndSet.begin(); it != m_ChildWndSet.end(); it++)
if (it->second)
::InvalidateRect(it->first, NULL, FALSE);
}
BEGIN_MSG_MAP_EX(T)
MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
MESSAGE_HANDLER(WM_MOUSELEAVE, OnMouseLeave)
MESSAGE_HANDLER_EX(WM_USER + 0x000f, OnMouseMoveChild)
MESSAGE_HANDLER_EX(WM_USER + 0x000e, OnSetAlwaysOnOrOff)
END_MSG_MAP()
LRESULT OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
bHandled = FALSE;
T *pT = static_cast<T*>(this);
if (!m_bIsInWindow)
{
TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT), TME_LEAVE, pT->m_hWnd };
::TrackMouseEvent(&tme);
m_bIsInWindow = true;
InvalidateAll();
}
return 0;
}
LRESULT OnMouseLeave(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
{
bHandled = FALSE;
POINT pt;
::GetCursorPos(&pt);
HWND hMouseWnd = ::WindowFromPoint(pt);
if (m_ChildWndSet.find(hMouseWnd) == m_ChildWndSet.end() || ::SendMessage(hMouseWnd, WM_USER + 0x000e, 0, MAKELPARAM(pt.x, pt.y)) == 0)
{
m_bIsInWindow = false;
InvalidateAll();
}
return 0;
}
LRESULT OnMouseMoveChild(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
T *pT = static_cast<T*>(this);
if (wParam == 0)
{
POINT pt;
::GetCursorPos(&pt);
HWND hMouseWnd = ::WindowFromPoint(pt);
if (hMouseWnd != pT->m_hWnd && m_ChildWndSet.find(hMouseWnd) == m_ChildWndSet.end())
{
m_bIsInWindow = false;
InvalidateAll();
}
else
{
TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT), TME_LEAVE, pT->m_hWnd };
::TrackMouseEvent(&tme);
}
}
else
{
if (!m_bIsInWindow)
{
m_bIsInWindow = true;
InvalidateAll();
}
}
return 0;
}
LRESULT OnSetAlwaysOnOrOff(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
SetAlwaysOn(wParam != 0);
return 0;
}
private:
typedef std::map<HWND, bool> ChildWindowSet;
ChildWindowSet m_ChildWndSet;
};
| [
"robustwell@218c79bb-c378-f353-48b6-e0d4b39d76f1"
] | robustwell@218c79bb-c378-f353-48b6-e0d4b39d76f1 |
a2570a06245d4a738bb073dd646f8f37f3024c31 | 91a882547e393d4c4946a6c2c99186b5f72122dd | /Source/XPSP1/NT/ds/adsi/novellnw/cschema.hxx | 7edc575e9938390edfea554435e02f7287c880c6 | [] | no_license | IAmAnubhavSaini/cryptoAlgorithm-nt5src | 94f9b46f101b983954ac6e453d0cf8d02aa76fc7 | d9e1cdeec650b9d6d3ce63f9f0abe50dabfaf9e2 | refs/heads/master | 2023-09-02T10:14:14.795579 | 2021-11-20T13:47:06 | 2021-11-20T13:47:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,629 | hxx |
typedef struct _PropertyInfo
{
LPTSTR szPropertyName;
BSTR bstrOID;
BSTR bstrSyntax;
long lMaxRange;
long lMinRange;
BOOL fMultiValued;
DWORD dwFlags;
DWORD dwInfoLevel;
DWORD dwSyntaxId;
}PROPERTYINFO, *PPROPERTYINFO, *LPPROPERTYINFO;
typedef struct _ClassInfo
{
BSTR bstrName;
const GUID *pCLSID;
const GUID *pPrimaryInterfaceGUID;
BSTR bstrOID;
BOOL fAbstract;
BSTR bstrMandatoryProperties;
BSTR bstrOptionalProperties;
BSTR bstrPossSuperiors;
BSTR bstrContainment;
BOOL fContainer;
BSTR bstrHelpFileName;
long lHelpFileContext;
PROPERTYINFO *aPropertyInfo;
DWORD cPropertyInfo;
} CLASSINFO;
typedef struct _SyntaxInfo
{
BSTR bstrName;
long lOleAutoDataType;
} SYNTAXINFO;
extern DWORD g_cNWCOMPATClasses;
extern CLASSINFO g_aNWCOMPATClasses[];
extern DWORD g_cNWCOMPATSyntax;
extern SYNTAXINFO g_aNWCOMPATSyntax[];
HRESULT MakeVariantFromStringList(
BSTR bstrList,
VARIANT *pvVariant );
class CNWCOMPATSchema;
class CNWCOMPATSchema : INHERIT_TRACKING,
public CCoreADsObject,
public ISupportErrorInfo,
public IADs,
public IADsContainer
{
public:
/* IUnknown methods */
STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID FAR* ppvObj) ;
DECLARE_STD_REFCOUNTING
/* Other methods */
DECLARE_IDispatch_METHODS
NW_DECLARE_ISupportErrorInfo_METHODS
DECLARE_IADs_METHODS
DECLARE_IADsContainer_METHODS
/* Constructors, Destructors .... */
CNWCOMPATSchema::CNWCOMPATSchema();
CNWCOMPATSchema::~CNWCOMPATSchema();
static HRESULT CNWCOMPATSchema::CreateSchema(
BSTR bstrParent,
BSTR bstrName,
CCredentials &Credentials,
DWORD dwObjectState,
REFIID riid,
void **ppvObj );
static HRESULT CNWCOMPATSchema::AllocateSchemaObject(
CNWCOMPATSchema **ppSchema );
protected:
CDispatchMgr FAR * _pDispMgr;
VARIANT _vFilter;
CCredentials _Credentials;
};
class CNWCOMPATClass : INHERIT_TRACKING,
public CCoreADsObject,
public ISupportErrorInfo,
public IADsClass
{
public:
/* IUnknown methods */
STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID FAR* ppvObj) ;
DECLARE_STD_REFCOUNTING
/* Other methods */
DECLARE_IDispatch_METHODS
NW_DECLARE_ISupportErrorInfo_METHODS
DECLARE_IADs_METHODS
DECLARE_IADsClass_METHODS
/* Constructors, Destructors, .... */
CNWCOMPATClass::CNWCOMPATClass();
CNWCOMPATClass::~CNWCOMPATClass();
static HRESULT CNWCOMPATClass::CreateClass(
BSTR bstrParent,
CLASSINFO *pClassInfo,
DWORD dwObjectState,
REFIID riid,
void **ppvObj );
static HRESULT CNWCOMPATClass::AllocateClassObject(
CNWCOMPATClass **ppClass );
protected:
CDispatchMgr FAR * _pDispMgr;
VARIANT _vFilter;
DWORD _cPropertyInfo;
PROPERTYINFO *_aPropertyInfo;
/* Properties */
BSTR _bstrCLSID;
BSTR _bstrOID;
BSTR _bstrPrimaryInterface;
VARIANT_BOOL _fAbstract;
VARIANT _vMandatoryProperties;
VARIANT _vOptionalProperties;
VARIANT _vPossSuperiors;
VARIANT _vContainment;
VARIANT_BOOL _fContainer;
BSTR _bstrHelpFileName;
long _lHelpFileContext;
};
class CNWCOMPATProperty : INHERIT_TRACKING,
public CCoreADsObject,
public ISupportErrorInfo,
public IADsProperty
{
public:
/* IUnknown methods */
STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID FAR* ppvObj) ;
DECLARE_STD_REFCOUNTING
/* Other methods */
DECLARE_IDispatch_METHODS
NW_DECLARE_ISupportErrorInfo_METHODS
DECLARE_IADs_METHODS
DECLARE_IADsProperty_METHODS
/* Constructors, Destructors, ... */
CNWCOMPATProperty::CNWCOMPATProperty();
CNWCOMPATProperty::~CNWCOMPATProperty();
static HRESULT CNWCOMPATProperty::CreateProperty(
BSTR bstrParent,
PROPERTYINFO *pPropertyInfo,
DWORD dwObjectState,
REFIID riid,
void **ppvObj );
static HRESULT CNWCOMPATProperty::AllocatePropertyObject(
CNWCOMPATProperty **ppProperty );
protected:
CDispatchMgr FAR * _pDispMgr;
/* Properties */
BSTR _bstrOID;
BSTR _bstrSyntax;
long _lMaxRange;
long _lMinRange;
VARIANT_BOOL _fMultiValued;
};
class CNWCOMPATSyntax : INHERIT_TRACKING,
public CCoreADsObject,
public ISupportErrorInfo,
public IADsSyntax
{
public:
/* IUnknown methods */
STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID FAR* ppvObj) ;
DECLARE_STD_REFCOUNTING
/* Other methods */
DECLARE_IDispatch_METHODS
NW_DECLARE_ISupportErrorInfo_METHODS
DECLARE_IADs_METHODS
DECLARE_IADsSyntax_METHODS
/* Constructors, Destructors, ... */
CNWCOMPATSyntax::CNWCOMPATSyntax();
CNWCOMPATSyntax::~CNWCOMPATSyntax();
static HRESULT CNWCOMPATSyntax::CreateSyntax(
BSTR bstrParent,
SYNTAXINFO *pSyntaxInfo,
DWORD dwObjectState,
REFIID riid,
void **ppvObj );
static HRESULT CNWCOMPATSyntax::AllocateSyntaxObject(
CNWCOMPATSyntax **ppSyntax );
protected:
CDispatchMgr FAR * _pDispMgr;
/* Properties */
long _lOleAutoDataType;
};
| [
"support@cryptoalgo.cf"
] | support@cryptoalgo.cf |
eb7757a8cfe16766bb604438bc5af65460320123 | 7f041147e9a40340a446832b134172a871d90e34 | /demo/zfsrc/ZFFramework_test/ZFCore_test/ZFCore_ZFObserverGroup_test.cpp | 506612984a26dcbf7af67619f03323befb1a8318 | [
"MIT"
] | permissive | ZFFramework/ZFFramework | cf5eaff500b30469e9a7f975a23812b05147442f | f7b6daed830232e3d883e1520d097f8422c38800 | refs/heads/master | 2023-08-31T21:38:34.437769 | 2023-08-30T10:31:08 | 2023-08-30T10:31:08 | 43,946,097 | 60 | 22 | null | null | null | null | UTF-8 | C++ | false | false | 3,698 | cpp | #include "ZFCore_test.h"
ZF_NAMESPACE_GLOBAL_BEGIN
zfclass ZFCore_ZFObserverGroup_test : zfextend ZFFramework_test_TestCase {
ZFOBJECT_DECLARE(ZFCore_ZFObserverGroup_test, ZFFramework_test_TestCase)
ZFOBSERVER_EVENT(ZFObserverGroupTest0)
ZFOBSERVER_EVENT(ZFObserverGroupTest1)
protected:
zfoverride
virtual void testCaseOnStart(void) {
zfsuper::testCaseOnStart();
zfblockedAlloc(v_zfstring, testObserver0, "testObserver0");
ZFObserver testObserver1;
ZFObject *testObserver2 = zfAlloc(v_zfstring, "testObserver2");
zfblockedAlloc(v_zfstring, testObserver3, "testObserver3");
ZFObject *owner = zfAlloc(ZFObject);
ZFLISTENER(observer
) {
zfLogTrim() << zfargs.sender() << " " << ZFIdMapNameForId(zfargs.eventId());
} ZFLISTENER_END()
ZFObserverGroup(this, testObserver0)
.observerAdd(zfself::EventZFObserverGroupTest0(), observer)
.observerAdd(zfself::EventZFObserverGroupTest1(), observer)
;
ZFObserverGroup(this, testObserver1)
.observerAdd(zfself::EventZFObserverGroupTest0(), observer)
.observerAdd(zfself::EventZFObserverGroupTest1(), observer)
;
ZFObserverGroup(this, testObserver2)
.observerAdd(zfself::EventZFObserverGroupTest0(), observer)
.observerAdd(zfself::EventZFObserverGroupTest1(), observer)
;
ZFObserverGroup(owner, testObserver3)
.observerAdd(zfself::EventZFObserverGroupTest0(), observer)
.observerAdd(zfself::EventZFObserverGroupTest1(), observer)
;
this->testCaseOutput("before remove, all observer should be called");
testObserver0->observerNotify(zfself::EventZFObserverGroupTest0());
testObserver0->observerNotify(zfself::EventZFObserverGroupTest1());
testObserver1.observerNotify(zfself::EventZFObserverGroupTest0());
testObserver1.observerNotify(zfself::EventZFObserverGroupTest1());
testObserver2->observerNotify(zfself::EventZFObserverGroupTest0());
testObserver2->observerNotify(zfself::EventZFObserverGroupTest1());
testObserver3->observerNotify(zfself::EventZFObserverGroupTest0());
testObserver3->observerNotify(zfself::EventZFObserverGroupTest1());
this->testCaseOutputSeparator();
zfRelease(owner);
this->testCaseOutput("owner released, all related observer should be removed");
testObserver3->observerNotify(zfself::EventZFObserverGroupTest0());
testObserver3->observerNotify(zfself::EventZFObserverGroupTest1());
this->testCaseOutputSeparator();
zfRelease(testObserver2);
this->testCaseOutput("target released, all related observer should be removed");
this->testCaseOutputSeparator();
ZFObserverGroupRemove(this);
this->testCaseOutput("after remove, all observer should be removed");
testObserver0->observerNotify(zfself::EventZFObserverGroupTest0());
testObserver0->observerNotify(zfself::EventZFObserverGroupTest1());
testObserver1.observerNotify(zfself::EventZFObserverGroupTest0());
testObserver1.observerNotify(zfself::EventZFObserverGroupTest1());
testObserver3->observerNotify(zfself::EventZFObserverGroupTest0());
testObserver3->observerNotify(zfself::EventZFObserverGroupTest1());
this->testCaseStop();
}
};
ZFOBJECT_REGISTER(ZFCore_ZFObserverGroup_test)
ZFOBSERVER_EVENT_REGISTER(ZFCore_ZFObserverGroup_test, ZFObserverGroupTest0)
ZFOBSERVER_EVENT_REGISTER(ZFCore_ZFObserverGroup_test, ZFObserverGroupTest1)
ZF_NAMESPACE_GLOBAL_END
| [
"z@zsaber.com"
] | z@zsaber.com |
d1aa9f6bc956343c7475566b2ff7efcf92297b9c | 868da0c4a384082f015ecb01f98ebd4c5a06ba07 | /algorithms/anagram/anagram.cpp | 27a4bfc8af7ed3f8d821bb507245e6d097c12c08 | [] | no_license | datumbrain/cpplibs | deff2395fa87c0970fe2e9d0db00213e760f564b | 01c1dedc8acfc18f0510a88175d34b560cb85586 | refs/heads/master | 2021-04-15T19:12:16.447573 | 2018-07-06T07:29:34 | 2018-07-06T07:29:34 | 94,587,290 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 869 | cpp | #include <iostream>
#include <fstream>
using namespace std;
#define ALPHABETS_LENGTH 26
int anagram[ALPHABETS_LENGTH];
int main () {
ifstream fin("./anagram_input");
if (!fin) {
cout << "Input file not found.";
return 1;
}
char ch;
for (int i = 0 ; i < ALPHABETS_LENGTH ; i++)
anagram[i] = 0;
do {
fin.get(ch);
if (fin.eof())
break;
if (ch >= 'a' && ch <= 'z') {
anagram[static_cast<int>(ch) - static_cast<int>('a')]++;
}
} while (true);
for (int i = 0 ; i < ALPHABETS_LENGTH ; i++) {
if (anagram[i] == 0)
continue;
cout << "Occurance of " << static_cast<char>(i + 'a')
<< " is " << anagram[i] << (anagram[i] > 1 ? " times." : " time.") << endl;
}
if (fin)
fin.close();
return 0;
}
| [
"fsdqui@gmail.com"
] | fsdqui@gmail.com |
49af80b4966f2779348584e68e462dc73484113f | be72da9e96f0be4ca2f3ff204e972d2a98442f52 | /FileManager.h | 529939b0d9bfda36af31cfa2aa5a8a8c785d87d1 | [] | no_license | easyhooon/Basic-Major-Project-2 | 44654b79bc05798d3d65c1fc893d24da3fc0d0a6 | 0bbde1883d4b45992ff48201955ecd2a085a4681 | refs/heads/main | 2023-01-21T01:01:13.627710 | 2020-12-03T09:03:21 | 2020-12-03T09:03:21 | 318,132,621 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 233 | h | #pragma once
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
//파일 스트림 부모 클래스
class FileManager {
public:
void fileSave(string fileName) {
}
void fileLoad(string fileName) {
}
}; | [
"51016231+easyhooon@users.noreply.github.com"
] | 51016231+easyhooon@users.noreply.github.com |
7b8885cebe72a664d863633cc3e3f1a6ee18960d | 63480c2926743ef75310e8b604b3ff110b493241 | /QML_SeaBattle/cbattlefield.cpp | 9f2f51d4c83cdb66ac77c5300facf99148d2df4c | [] | no_license | lmd-luxoft/labwork-RuslanSan | f5e6a13ddd7cc666c9f2f2da6fe489c56f97c5d1 | c3f99e54b6e86620110cd894fa9aabeae9550042 | refs/heads/main | 2023-03-12T04:39:10.238198 | 2021-03-03T07:12:14 | 2021-03-03T07:12:14 | 339,020,257 | 0 | 0 | null | 2021-02-15T09:07:14 | 2021-02-15T09:07:10 | null | UTF-8 | C++ | false | false | 2,795 | cpp | #include "cbattlefield.h"
#include "cships.h"
#include <algorithm>
const quint8 C_amountOfRows = 10;
CBattleField::CBattleField(QObject *parent) : QObject(parent),
m_amountOfRows(C_amountOfRows),
m_playerIsComputer(false),
m_availableCells(),
m_firedCells(),
m_ships(C_amountOfRows, C_amountOfRows)
{
for (int i=0; i< C_amountOfRows*C_amountOfRows; ++i) {
m_availableCells.push_back(i);
}
}
CShips& CBattleField::ships() {
return m_ships;
}
const std::vector<quint8> &CBattleField::availableCells() const
{
return m_availableCells;
}
void CBattleField::fire(quint8 x, quint8 y)
{
quint8 state=CShip::Undefined;
if (x>0 && y>0 && x <= C_amountOfRows && y <= C_amountOfRows) {
quint8 index = (y-1)*C_amountOfRows + (x-1);
auto it= std::find( m_firedCells.begin(), m_firedCells.end(), index);
if (it == m_firedCells.end() ) {
m_firedCells.push_back(index);
it= std::find( m_availableCells.begin(), m_availableCells.end(), index);
if (it != m_availableCells.end())
m_availableCells.erase(it);
CShip* pShip = m_ships.isShipPresentAtPos(x, y);
if (pShip) {
pShip->DestroyOnePart();
state = (pShip->state() != CShip::Destroyed) ? CShip::Broken : CShip::Destroyed;
if (CShip::Destroyed == state) {
showShipInState( pShip, CShip::Destroyed);
emit shipDestroyed();
if (m_ships.amountOfDestoyedShips() == m_ships.amountOfShips())
emit allShipDestroyed();
}
}
if (CShip::Destroyed != state)
emit setCellValue(x, y, state);
emit afterFire( m_playerIsComputer );
}
}
}
quint8 CBattleField::amountOfRows() const
{
return m_amountOfRows;
}
quint8 CBattleField::amountOfShips() const
{
return m_ships.amountOfShips();
}
quint8 CBattleField::amountOfDestroyedShips() const
{
return m_ships.amountOfDestoyedShips();
}
bool CBattleField::isPlayerComputer() const
{
return m_playerIsComputer;
}
void CBattleField::setPlayerIsComputer(bool playerIsComputer)
{
m_playerIsComputer = playerIsComputer;
}
void CBattleField::showShipInState(const CShip *pShip, quint8 state)
{
if (pShip) {
quint8 xd(0), yd(0);
for (auto i=0; i<pShip->size(); i++) {
if (CShip::Horizontal == pShip->direction()) {
xd=i; }
else {
yd=i; }
emit setCellValue(pShip->x()+xd, pShip->y()+yd, state);
}
}
}
void CBattleField::showShips()
{
for(const CShip ship: m_ships.ships()) {
showShipInState( &ship, CShip::Normal);
}
}
| [
"russanemail@gmail.com"
] | russanemail@gmail.com |
03811b6caa6e1e51421ebce83973866a9de064fa | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_5634947029139456_0/C++/Amtrix/gcja.cpp | 4431dd2f61c90426c58634a7df92e55033fd4820 | [] | 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,932 | cpp | #include <bits/stdc++.h>
using namespace std;
const int maxn = 200;
int n,m;
string w[maxn], goal[maxn];
vector<int>flip;
int main() {
freopen("Ulaz.txt","r",stdin);
freopen("Izlaz10.txt","w",stdout);
ios_base::sync_with_stdio(false);
int tests; cin >> tests;
for (int t = 1; t <= tests; ++t) {
flip.clear();
cin >> n >> m;
for (int i = 0; i < n; ++i) cin >> w[i];
for (int i = 0; i < n; ++i) cin >> goal[i];
for (int i = 0; i < n; ++i)
for (int j = 0; j < m; ++j)
w[i][j] -= '0', goal[i][j] -= '0';
sort(goal, goal + n);
vector<string> possible;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
string str = "";
for (int k = 0; k < m; ++k)
str += string(1,(w[i][k]+goal[j][k])%2);
possible.push_back(str);
}
}
int minsol = 1e9;
for (int i = 0; i < possible.size(); ++i) {
int cnt = 0;
for (int j = 0; j < m; ++j) {
cnt += int(possible[i][j]);
for (int k = 0; k < n && possible[i][j]; ++k)
w[k][j] = 1 - w[k][j];
}
sort(w, w + n);
bool ok = 1;
for (int j = 0; j < n; ++j)
for (int k = 0; k < m; ++k)
if (w[j][k] != goal[j][k]) ok = 0;
if (ok)
minsol = min(minsol, cnt);
for (int j = 0; j < m; ++j) {
cnt += int(possible[i][j]);
for (int k = 0; k < n && possible[i][j]; ++k)
w[k][j] = 1 - w[k][j];
}
}
cout << "Case #" << t << ": ";
if (minsol == 1e9) cout << "NOT POSSIBLE" << endl;
else cout << minsol << endl;
}
}
| [
"eewestman@gmail.com"
] | eewestman@gmail.com |
8378e3049a32c6e399d0fc9bee044e0430b99c5a | 0182e48af6ad4574de1c3ec0ebf03fec3fabb46d | /Lab11/Lab11/Client.cpp | 0241905b96061cdac234692de3dbdbde919b2489 | [] | no_license | ahmedtahami/OOPF20 | e75744a7cf3a1bf9afff643eb369524623c4d0ad | 3a5b9a85fcfdbbe578c8c8e54e9303e141384ca1 | refs/heads/master | 2023-02-28T05:44:54.753890 | 2021-02-03T18:17:11 | 2021-02-03T18:17:11 | 335,711,358 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,254 | cpp | #include "Client.h"
#include<iostream>
#include<string>
using namespace std;
Client::Client() : Person(){
Employement = nullptr;
Account account{};
}
Client::Client(const Client& ref) : Person(ref) {
account = ref.account;
Employement = cpyDeep(ref.Employement);
}
Client::Client(char* name, char* address, char* phoneNumber, char* titile, Account account) : Person(name, address, phoneNumber) {
Employement = cpyDeep(titile);
account = account;
}
void Client::UpdateAccountInfo(char* accountNo, char* accountype, double balance) {
account.setAccountNo(accountNo);
account.setAccountType(accountype);
account.setBalance(balance);
}
void Client::setEmployeementTitle(char* title) {
Employement = cpyDeep(title);
}
void Client::Withdraw(double amount) {
account - amount;
}
void Client::Deposit(double amount) {
account + amount;
}
void Client::Display() {
Person::Display();
cout << "Title : " << Employement << endl;
account.Display();
}
char* Client::cpyDeep(char* arr) {
int size = strlen(arr) + 1;
char* temp = new char[size];
for (int i = 0; i < size; i++)
{
*(temp + i) = *(arr + i);
}
*(temp + (size - 1)) = '\0';
return temp;
}
Client::~Client() {
if (Employement)
{
delete[] Employement;
Employement = nullptr;
}
} | [
"ahmedtahami@outlook.com"
] | ahmedtahami@outlook.com |
77daf8b2240a1fdc22aee30ceac0b3838a43bd9d | e9d407e7586c18612f68acb5c3d2056743e35150 | /Perlin-Noise/Source/WaveOsc.cpp | c500fc4d5235132983116d83d96bf9e26b055f7a | [] | no_license | lennartnicolas/perlin-noise | df094740698f0a305d4e69eba9be760d1cae8a62 | 047f8088328fb7612aa9f019a9201cc493af7f01 | refs/heads/main | 2023-03-25T06:28:31.216518 | 2021-03-16T12:01:52 | 2021-03-16T12:01:52 | 345,111,255 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,303 | cpp | /*
==============================================================================
WaveOsc.cpp
Created: 11 Mar 2021 1:24:06pm
Author: Lennart Krebs
==============================================================================
*/
#include "WaveOsc.h"
WaveOsc::WaveOsc(const juce::AudioSampleBuffer& wavetableToUse) : wavetable(wavetableToUse),
tableSize(wavetable.getNumSamples() - 1)
{
jassert (wavetable.getNumChannels() == 1);
}
void WaveOsc::setFrequency(float frequency, float sampleRate)
{
auto tableSizeOverSampleRate = (float) tableSize / sampleRate;
tableDelta = frequency * tableSizeOverSampleRate;
}
void WaveOsc::setWavetable(const juce::AudioSampleBuffer& newWavetable)
{
wavetable = newWavetable;
}
float WaveOsc::getNextSample() noexcept
{
auto index0 = (unsigned int) currentIndex;
auto index1 = index0 + 1;
auto frac = currentIndex - (float) index0;
auto* table = wavetable.getReadPointer (0);
auto value0 = table[index0];
auto value1 = table[index1];
auto currentSample = value0 + frac * (value1 - value0);
if ((currentIndex += tableDelta) > (float) tableSize){
currentIndex -= (float) tableSize;
}
return currentSample * _level;
}
| [
"contact@lennartnicolas.de"
] | contact@lennartnicolas.de |
ec278ee893d1b0034ace4b55a177cfc383675b60 | 5b6d9fd23804dea9adb4b4d78cf2eff9c0eb3b05 | /Chapter_10/task_2/Person.hpp | 6212dd2cc42bb47c1dec853877e8411cf5b7853a | [] | no_license | gosowski/PrimerPlusCPP | 410067d94865535544a36120a2a0856f8a9056a5 | 8c654f4e5d3087e85a4b0294bb548e4c2e504bba | refs/heads/master | 2021-09-14T09:40:55.958871 | 2018-05-11T14:00:12 | 2018-05-11T14:00:12 | 125,866,520 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 541 | hpp | #ifndef PERSON_H
#define PERSON_H
#include <iostream>
#include <string.h>
class Person {
private:
static const int LIMIT = 256;
std::string lname;
char fname[LIMIT];
public:
Person() {
lname = "";
fname[0] = '\0';
}
Person(const std::string &ln, const char *fn = "HejU") {
lname = ln;
strcpy(fname, fn);
}
void show() const {
std::cout<<lname<<" | "<<fname<<std::endl;
}
void formalShow() const {
std::cout<<fname<<" | "<<lname<<std::endl;
}
};
#endif | [
"osowski.grzegorz@gmail.com"
] | osowski.grzegorz@gmail.com |
3b92499cc3a4230f08dfe1b4ea8c421c44ec2b92 | 0a5645154953b0a09d3f78753a1711aaa76928ff | /common/c/nbpal/src/linux/myplaces/palcontacts.cpp | 5d061796895c63e494dd08cb3c7ee82be2d6bf0e | [] | no_license | GENIVI/navigation-next | 3a6f26063350ac8862b4d0e2e9d3522f6f249328 | cb8f7ec5ec4c78ef57aa573315b75960b2a5dd36 | refs/heads/master | 2023-08-04T17:44:45.239062 | 2023-07-25T19:22:19 | 2023-07-25T19:22:19 | 116,230,587 | 17 | 11 | null | 2018-05-18T20:00:38 | 2018-01-04T07:43:22 | C++ | UTF-8 | C++ | false | false | 3,106 | cpp | /*
Copyright (c) 2018, TeleCommunication Systems, 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.
* Neither the name of the TeleCommunication Systems, Inc., 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 TELECOMMUNICATION SYSTEMS, INC.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.
*/
/*!--------------------------------------------------------------------------
@file palcontacts.c
*/
/*
(C) Copyright 2012 by TeleCommunication Systems, Inc.
The information contained herein is confidential, proprietary
to TeleCommunication Systems, Inc., and considered a trade secret as
defined in section 499C of the penal code of the State of
California. Use of this information by anyone other than
authorized employees of TeleCommunication Systems, is granted only
under a written non-disclosure agreement, expressly
prescribing the scope and manner of such use.
---------------------------------------------------------------------------*/
/*! @{ */
#include "palcontacts.h"
#include "palstdlib.h"
#include "pal.h"
#include "paltypes.h"
#include "palstdlib.h"
#include "palmyplaces.h"
using namespace std;
struct PAL_Contacts
{
// Contacts* pContacts;
};
PAL_DEF PAL_Error
PAL_ContactsCreate(PAL_Instance* /*pal*/, PAL_Contacts** /*contacts*/)
{
return PAL_ErrUnsupported;
}
PAL_DEF PAL_Error
PAL_ContactsDestroy(PAL_Contacts* /*contacts*/)
{
return PAL_ErrUnsupported;
}
PAL_DEF PAL_Error
PAL_ContactsGet(PAL_Contacts* /*contacts*/, char* /*filter*/, PAL_MyPlace** /*myPlacesArray*/, int* /*myPlaceCount*/)
{
return PAL_ErrUnsupported;
}
PAL_DEF PAL_Error
PAL_ContactsAdd(PAL_Contacts* /*contacts*/, PAL_MyPlace* /*myPlace*/)
{
return PAL_ErrUnsupported;
}
PAL_DEF PAL_Error
PAL_ContactsClear(PAL_Contacts* /*contacts*/)
{
return PAL_ErrUnsupported;
}
/*! @{ */
| [
"caavula@telecomsys.com"
] | caavula@telecomsys.com |
389e11003aefca03875d9deb25d8b82fdbcab1e4 | e0e025b0b186e047461d2d74ea5fa84fb8a21f7b | /.history/8_cosuri_20210307084423.cpp | f6ab7a6510355cf37f50df8ae625c3f282de8732 | [] | no_license | xKristee29/1nfo | fbd4b9c1b50f45fbd10b968f39d342a47a007da7 | 1aa9ec38f24a54c76cab8d94212bd33df616082d | refs/heads/main | 2023-03-20T02:04:51.730374 | 2021-03-08T20:24:55 | 2021-03-08T20:24:55 | 345,783,580 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 193 | cpp | #include <bits/stdc++.h>
using namespace std;
ifstream f("cosuri.in");
ofstream g("cosuri.out");
multiset<int> s;
int n,cerinta;
int main(){
f>>cerinta>>n;
if(cerin)
return 0;
} | [
"c90717489@gmail.com"
] | c90717489@gmail.com |
9558f01830aab7f0f440044ba4e6c25b3b736d1a | 948f4e13af6b3014582909cc6d762606f2a43365 | /testcases/juliet_test_suite/testcases/CWE36_Absolute_Path_Traversal/s03/CWE36_Absolute_Path_Traversal__wchar_t_connect_socket_fopen_65b.cpp | 184cd765127b7c6a3b854a3b539c075986ed8267 | [] | no_license | junxzm1990/ASAN-- | 0056a341b8537142e10373c8417f27d7825ad89b | ca96e46422407a55bed4aa551a6ad28ec1eeef4e | refs/heads/master | 2022-08-02T15:38:56.286555 | 2022-06-16T22:19:54 | 2022-06-16T22:19:54 | 408,238,453 | 74 | 13 | null | 2022-06-16T22:19:55 | 2021-09-19T21:14:59 | null | UTF-8 | C++ | false | false | 2,126 | cpp | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE36_Absolute_Path_Traversal__wchar_t_connect_socket_fopen_65b.cpp
Label Definition File: CWE36_Absolute_Path_Traversal.label.xml
Template File: sources-sink-65b.tmpl.cpp
*/
/*
* @description
* CWE: 36 Absolute Path Traversal
* BadSource: connect_socket Read data using a connect socket (client side)
* GoodSource: Full path and file name
* Sinks: fopen
* BadSink : Open the file named in data using fopen()
* Flow Variant: 65 Data/control flow: data passed as an argument from one function to a function in a different source file called via a function pointer
*
* */
#include "std_testcase.h"
#ifndef _WIN32
#include <wchar.h>
#endif
#ifdef _WIN32
#include <winsock2.h>
#include <windows.h>
#include <direct.h>
#pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */
#define CLOSE_SOCKET closesocket
#else /* NOT _WIN32 */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define CLOSE_SOCKET close
#define SOCKET int
#endif
#define TCP_PORT 27015
#define IP_ADDRESS "127.0.0.1"
#ifdef _WIN32
#define FOPEN _wfopen
#else
#define FOPEN fopen
#endif
namespace CWE36_Absolute_Path_Traversal__wchar_t_connect_socket_fopen_65
{
#ifndef OMITBAD
void badSink(wchar_t * data)
{
{
FILE *pFile = NULL;
/* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
pFile = FOPEN(data, L"wb+");
if (pFile != NULL)
{
fclose(pFile);
}
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
void goodG2BSink(wchar_t * data)
{
{
FILE *pFile = NULL;
/* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
pFile = FOPEN(data, L"wb+");
if (pFile != NULL)
{
fclose(pFile);
}
}
}
#endif /* OMITGOOD */
} /* close namespace */
| [
"yzhang0701@gmail.com"
] | yzhang0701@gmail.com |
46291ee6bf499d203114bdb8a35583840a69b169 | d61f2cac3bd9ed39f95184b89dd40952c6482786 | /testCase/results/16/U | 97f3ceef398bea897f04a24c8b23512e95f09faf | [] | no_license | karimimp/PUFoam | 4b3a5b427717aa0865889fa2342112cc3d24ce66 | 9d16e06d63e141607491219924018bea99cbb9e5 | refs/heads/master | 2022-06-24T08:51:18.370701 | 2022-04-28T18:33:03 | 2022-04-28T18:33:03 | 120,094,729 | 6 | 3 | null | 2022-04-27T09:46:38 | 2018-02-03T13:43:52 | C++ | UTF-8 | C++ | false | false | 26,983 | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 3.0.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "16";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField nonuniform List<vector>
800
(
(4.0702234e-06 0.00034996352 0)
(4.6656018e-06 0.00035266166 0)
(4.1020677e-06 0.0003531179 0)
(3.4337497e-06 0.00035311445 0)
(2.853998e-06 0.00035300751 0)
(2.3883153e-06 0.00035298962 0)
(1.9169204e-06 0.00035301881 0)
(1.4091487e-06 0.00035306024 0)
(8.6344247e-07 0.000353095 0)
(2.9091457e-07 0.00035311433 0)
(-2.9112899e-07 0.00035311433 0)
(-8.6362076e-07 0.000353095 0)
(-1.4092618e-06 0.00035306023 0)
(-1.9169761e-06 0.00035301879 0)
(-2.3883473e-06 0.0003529896 0)
(-2.8540665e-06 0.00035300748 0)
(-3.4339137e-06 0.00035311444 0)
(-4.1023721e-06 0.00035311789 0)
(-4.6660406e-06 0.00035266166 0)
(-4.0705084e-06 0.00034996349 0)
(1.9887472e-06 0.00064328553 0)
(2.2403477e-06 0.00064820563 0)
(2.6352285e-06 0.00064927875 0)
(2.6731108e-06 0.00064939218 0)
(2.4136194e-06 0.00064927682 0)
(2.1306487e-06 0.00064924945 0)
(1.7478968e-06 0.00064928173 0)
(1.2989752e-06 0.00064933411 0)
(8.0075675e-07 0.00064937984 0)
(2.7054333e-07 0.00064940548 0)
(-2.7082733e-07 0.00064940548 0)
(-8.0100413e-07 0.00064937983 0)
(-1.2991605e-06 0.00064933408 0)
(-1.7480269e-06 0.00064928168 0)
(-2.1307565e-06 0.00064924938 0)
(-2.4137556e-06 0.00064927675 0)
(-2.673328e-06 0.00064939211 0)
(-2.6355348e-06 0.0006492787 0)
(-2.2407262e-06 0.00064820562 0)
(-1.9889786e-06 0.00064328552 0)
(1.7169989e-06 0.0012024474 0)
(1.8357054e-06 0.0012093479 0)
(2.0325728e-06 0.0012107795 0)
(2.2517604e-06 0.0012109781 0)
(2.1298353e-06 0.0012109196 0)
(1.9771432e-06 0.0012109675 0)
(1.6691142e-06 0.0012110705 0)
(1.2594199e-06 0.0012111846 0)
(7.8177774e-07 0.0012112729 0)
(2.6478996e-07 0.00121132 0)
(-2.6507596e-07 0.00121132 0)
(-7.8202995e-07 0.0012112729 0)
(-1.2596182e-06 0.0012111845 0)
(-1.6692617e-06 0.0012110705 0)
(-1.9772645e-06 0.0012109674 0)
(-2.1299724e-06 0.0012109195 0)
(-2.2519515e-06 0.001210978 0)
(-2.0327993e-06 0.0012107795 0)
(-1.8359369e-06 0.0012093479 0)
(-1.7171305e-06 0.0012024475 0)
(-4.301715e-07 0.0017561669 0)
(-6.2614049e-07 0.0017653596 0)
(1.024346e-06 0.0017667676 0)
(1.9502812e-06 0.0017671071 0)
(2.0712808e-06 0.0017672046 0)
(2.0460572e-06 0.0017674026 0)
(1.7617989e-06 0.0017676288 0)
(1.3402029e-06 0.0017678276 0)
(8.33066e-07 0.0017679659 0)
(2.8216365e-07 0.0017680365 0)
(-2.8240904e-07 0.0017680365 0)
(-8.3328404e-07 0.0017679658 0)
(-1.3403751e-06 0.0017678276 0)
(-1.7619254e-06 0.0017676288 0)
(-2.0461471e-06 0.0017674025 0)
(-2.0713687e-06 0.0017672046 0)
(-1.9503977e-06 0.0017671071 0)
(-1.0244662e-06 0.0017667676 0)
(6.2606702e-07 0.0017653597 0)
(4.3014542e-07 0.001756167 0)
(-1.2264617e-06 0.0022532031 0)
(-1.5446196e-06 0.0022658825 0)
(7.3992521e-07 0.0022679331 0)
(2.3890406e-06 0.0022688859 0)
(2.5798138e-06 0.0022694434 0)
(2.5266563e-06 0.0022699623 0)
(2.1500249e-06 0.0022703795 0)
(1.6126077e-06 0.0022706793 0)
(9.9195395e-07 0.0022708658 0)
(3.3444147e-07 0.0022709571 0)
(-3.346316e-07 0.0022709571 0)
(-9.9211947e-07 0.0022708658 0)
(-1.6127315e-06 0.0022706792 0)
(-2.1501002e-06 0.0022703795 0)
(-2.5266917e-06 0.0022699622 0)
(-2.5798457e-06 0.0022694434 0)
(-2.3890765e-06 0.0022688859 0)
(-7.3994315e-07 0.0022679331 0)
(1.5446385e-06 0.0022658826 0)
(1.2264772e-06 0.0022532032 0)
(-9.2243996e-07 0.0026767511 0)
(-5.9689988e-07 0.0026922034 0)
(2.4355824e-06 0.0026973308 0)
(4.3267316e-06 0.0026993972 0)
(4.1754818e-06 0.0027007101 0)
(3.7651345e-06 0.0027016188 0)
(3.0260559e-06 0.0027021846 0)
(2.1880698e-06 0.0027025268 0)
(1.3198538e-06 0.0027027138 0)
(4.4163723e-07 0.0027027975 0)
(-4.4180862e-07 0.0027027975 0)
(-1.3199951e-06 0.0027027138 0)
(-2.1881662e-06 0.0027025267 0)
(-3.026096e-06 0.0027021846 0)
(-3.7651281e-06 0.0027016188 0)
(-4.1755009e-06 0.0027007101 0)
(-4.3267368e-06 0.0026993972 0)
(-2.4355455e-06 0.0026973308 0)
(5.9690566e-07 0.0026922035 0)
(9.2242101e-07 0.0026767511 0)
(2.9011244e-06 0.0030060551 0)
(7.9497176e-06 0.0030258563 0)
(1.0368735e-05 0.0030321354 0)
(9.4493093e-06 0.003035032 0)
(7.6618008e-06 0.0030369899 0)
(6.161731e-06 0.0030380895 0)
(4.614875e-06 0.0030386593 0)
(3.1989912e-06 0.0030389717 0)
(1.8832377e-06 0.0030391186 0)
(6.2250345e-07 0.0030391773 0)
(-6.22719e-07 0.0030391773 0)
(-1.8834147e-06 0.0030391186 0)
(-3.1991151e-06 0.0030389716 0)
(-4.6149365e-06 0.0030386593 0)
(-6.1617252e-06 0.0030380895 0)
(-7.6618474e-06 0.00303699 0)
(-9.4493299e-06 0.0030350321 0)
(-1.0368684e-05 0.0030321355 0)
(-7.949728e-06 0.0030258565 0)
(-2.9011478e-06 0.0030060551 0)
(5.6733567e-05 0.0032964062 0)
(7.8303285e-05 0.0033544984 0)
(4.9031259e-05 0.0033596976 0)
(3.3036102e-05 0.0033616543 0)
(2.2370201e-05 0.0033638747 0)
(1.5599e-05 0.0033647899 0)
(1.0742087e-05 0.0033651429 0)
(7.055434e-06 0.0033653196 0)
(4.0156129e-06 0.0033653778 0)
(1.3037085e-06 0.003365409 0)
(-1.3039791e-06 0.003365409 0)
(-4.015817e-06 0.0033653778 0)
(-7.0555391e-06 0.0033653197 0)
(-1.0742089e-05 0.003365143 0)
(-1.5598891e-05 0.0033647901 0)
(-2.2370147e-05 0.0033638751 0)
(-3.3036037e-05 0.0033616547 0)
(-4.9031077e-05 0.0033596981 0)
(-7.8303099e-05 0.003354499 0)
(-5.6733435e-05 0.0032964066 0)
(0.00029359059 0.003032476 0)
(0.00045152607 0.0033901639 0)
(0.00034669463 0.0034057045 0)
(0.0002452386 0.0033893536 0)
(0.0001701562 0.0033792948 0)
(0.00011760171 0.003373143 0)
(7.9948426e-05 0.0033696865 0)
(5.1727724e-05 0.0033678389 0)
(2.9087414e-05 0.0033669136 0)
(9.4131111e-06 0.0033665671 0)
(-9.4138081e-06 0.003366567 0)
(-2.9088038e-05 0.0033669136 0)
(-5.1728069e-05 0.0033678389 0)
(-7.9948383e-05 0.0033696866 0)
(-0.00011760136 0.0033731434 0)
(-0.0001701556 0.0033792954 0)
(-0.00024523757 0.0033893541 0)
(-0.0003466933 0.003405705 0)
(-0.00045152455 0.0033901645 0)
(-0.00029358965 0.003032477 0)
(0.00036399148 0.0023226275 0)
(0.00072189929 0.0032329255 0)
(0.00071625901 0.0033941065 0)
(0.00060014976 0.0033872143 0)
(0.00046627794 0.0033522619 0)
(0.0003462425 0.0033203982 0)
(0.00024627148 0.0032971885 0)
(0.00016371184 0.0032819506 0)
(9.3488748e-05 0.0032729556 0)
(3.0515271e-05 0.0032687623 0)
(-3.0517422e-05 0.0032687621 0)
(-9.3490732e-05 0.0032729548 0)
(-0.00016371341 0.0032819497 0)
(-0.00024627249 0.0032971876 0)
(-0.00034624275 0.0033203979 0)
(-0.00046627779 0.003352262 0)
(-0.00060014922 0.0033872145 0)
(-0.00071625835 0.0033941064 0)
(-0.00072189893 0.0032329256 0)
(-0.00036399139 0.0023226271 0)
(0.00024204382 0.0018114763 0)
(0.00058516861 0.0030188359 0)
(0.00069243943 0.003394878 0)
(0.00065409485 0.0034795516 0)
(0.00055245554 0.003467246 0)
(0.00043498153 0.0034293473 0)
(0.00032213006 0.0033916214 0)
(0.00021990134 0.0033624265 0)
(0.0001276017 0.0033434482 0)
(4.2003863e-05 0.003334171 0)
(-4.2006878e-05 0.0033341706 0)
(-0.00012760444 0.0033434464 0)
(-0.00021990374 0.0033624248 0)
(-0.0003221317 0.0033916195 0)
(-0.00043498257 0.0034293462 0)
(-0.00055245625 0.0034672454 0)
(-0.0006540951 0.0034795512 0)
(-0.00069243937 0.0033948769 0)
(-0.00058516878 0.003018835 0)
(-0.00024204403 0.0018114752 0)
(0.0001367147 0.0014759037 0)
(0.00039888043 0.0027964897 0)
(0.00054702035 0.0033425363 0)
(0.00056877358 0.0035334744 0)
(0.00051469768 0.0035706979 0)
(0.00042651075 0.0035482027 0)
(0.00032782905 0.0035094575 0)
(0.00022964196 0.0034737428 0)
(0.00013543314 0.0034484679 0)
(4.4947801e-05 0.0034356469 0)
(-4.494984e-05 0.0034356464 0)
(-0.00013543482 0.0034484656 0)
(-0.00022964318 0.0034737402 0)
(-0.00032783034 0.0035094545 0)
(-0.00042651157 0.0035482006 0)
(-0.00051469783 0.0035706964 0)
(-0.00056877356 0.0035334732 0)
(-0.00054702018 0.003342535 0)
(-0.00039888046 0.0027964883 0)
(-0.00013671489 0.0014759023 0)
(7.2235253e-05 0.0012723268 0)
(0.00025092344 0.0026000879 0)
(0.00039233823 0.0032505543 0)
(0.00044253495 0.0035313868 0)
(0.00042493712 0.0036241797 0)
(0.00036841394 0.0036290869 0)
(0.00029295855 0.0036003727 0)
(0.00021026563 0.0035661575 0)
(0.00012596283 0.0035394962 0)
(4.2119683e-05 0.0035254149 0)
(-4.2119454e-05 0.0035254142 0)
(-0.00012596288 0.0035394937 0)
(-0.0002102658 0.0035661539 0)
(-0.00029295858 0.0036003692 0)
(-0.00036841352 0.0036290839 0)
(-0.00042493667 0.0036241775 0)
(-0.00044253426 0.003531385 0)
(-0.00039233757 0.003250553 0)
(-0.00025092354 0.0026000867 0)
(-7.223542e-05 0.0012723256 0)
(3.730812e-05 0.0011546609 0)
(0.00015167021 0.0024536846 0)
(0.00026616508 0.0031590857 0)
(0.00032221093 0.0035047576 0)
(0.00032593331 0.0036464543 0)
(0.00029419743 0.0036812793 0)
(0.00024127493 0.0036681726 0)
(0.00017710952 0.0036408747 0)
(0.000107667 0.0036167244 0)
(3.624424e-05 0.0036033471 0)
(-3.6241412e-05 0.0036033461 0)
(-0.00010766456 0.0036167215 0)
(-0.00017710772 0.0036408707 0)
(-0.00024127302 0.0036681689 0)
(-0.00029419531 0.003681276 0)
(-0.00032593159 0.0036464515 0)
(-0.00032220909 0.0035047557 0)
(-0.0002661634 0.0031590846 0)
(-0.00015167001 0.0024536839 0)
(-3.7308481e-05 0.0011546601 0)
(1.9522746e-05 0.0010871839 0)
(9.0558484e-05 0.0023531834 0)
(0.00017487342 0.0030842122 0)
(0.0002249318 0.0034723858 0)
(0.00023817658 0.003651872 0)
(0.00022285382 0.003713532 0)
(0.00018794322 0.0037171251 0)
(0.00014083299 0.0036992256 0)
(8.6780257e-05 0.003679843 0)
(2.9389089e-05 0.0036684249 0)
(-2.9384588e-05 0.0036684239 0)
(-8.6775965e-05 0.0036798399 0)
(-0.00014082919 0.0036992216 0)
(-0.00018793943 0.003717121 0)
(-0.00022285025 0.0037135283 0)
(-0.00023817351 0.0036518693 0)
(-0.0002249292 0.0034723843 0)
(-0.00017487157 0.0030842118 0)
(-9.0557746e-05 0.0023531833 0)
(-1.9522668e-05 0.0010871838 0)
(1.055981e-05 0.0010480149 0)
(5.4292914e-05 0.0022865565 0)
(0.00011298363 0.0030278642 0)
(0.00015290278 0.0034421755 0)
(0.00016847403 0.0036486182 0)
(0.00016274464 0.0037318679 0)
(0.00014074329 0.0037506318 0)
(0.00010745514 0.00374244 0)
(6.7036227e-05 0.0037286401 0)
(2.2826016e-05 0.0037197395 0)
(-2.2820186e-05 0.0037197387 0)
(-6.7030869e-05 0.0037286371 0)
(-0.00010745037 0.0037424361 0)
(-0.00014073867 0.0037506275 0)
(-0.00016274021 0.0037318642 0)
(-0.00016847035 0.0036486158 0)
(-0.00015289963 0.0034421748 0)
(-0.00011298115 0.0030278647 0)
(-5.4291838e-05 0.0022865572 0)
(-1.0559684e-05 0.0010480152 0)
(5.9273828e-06 0.0010248593 0)
(3.2917759e-05 0.0022431884 0)
(7.2483051e-05 0.0029875546 0)
(0.00010227932 0.0034172574 0)
(0.0001166113 0.0036419575 0)
(0.00011585021 0.0037414305 0)
(0.00010245793 0.0037727332 0)
(7.954923e-05 0.0037733068 0)
(5.0183199e-05 0.0037649372 0)
(1.7171272e-05 0.0037586071 0)
(-1.7165262e-05 0.0037586064 0)
(-5.017761e-05 0.0037649344 0)
(-7.9543899e-05 0.0037733033 0)
(-0.00010245268 0.0037727293 0)
(-0.00011584534 0.0037414269 0)
(-0.00011660714 0.0036419553 0)
(-0.00010227577 0.0034172573 0)
(-7.248052e-05 0.0029875558 0)
(-3.2916624e-05 0.00224319 0)
(-5.9270675e-06 0.0010248599 0)
(3.4352212e-06 0.0010109097 0)
(2.0216405e-05 0.0022152115 0)
(4.644325e-05 0.0029596402 0)
(6.7801779e-05 0.0033981677 0)
(7.9579666e-05 0.0036348397 0)
(8.1013691e-05 0.0037459732 0)
(7.3076582e-05 0.003787028 0)
(5.7588824e-05 0.0037948957 0)
(3.6691979e-05 0.0037912886 0)
(1.2610013e-05 0.003787288 0)
(-1.2604511e-05 0.0037872873 0)
(-3.6686582e-05 0.0037912863 0)
(-5.7583485e-05 0.0037948924 0)
(-7.3071773e-05 0.0037870246 0)
(-8.1009113e-05 0.0037459702 0)
(-7.957555e-05 0.0036348379 0)
(-6.7798333e-05 0.0033981679 0)
(-4.6440345e-05 0.0029596421 0)
(-2.0215093e-05 0.0022152137 0)
(-3.4351205e-06 0.0010109102 0)
(2.0381108e-06 0.0010023643 0)
(1.2560621e-05 0.0021971996 0)
(2.981215e-05 0.0029406668 0)
(4.474496e-05 0.0033841789 0)
(5.3820573e-05 0.0036285571 0)
(5.5955766e-05 0.003747833 0)
(5.1349657e-05 0.0037961676 0)
(4.0998201e-05 0.0038097829 0)
(2.635081e-05 0.0038100831 0)
(9.0916124e-06 0.0038080407 0)
(-9.0867724e-06 0.0038080401 0)
(-2.6346157e-05 0.0038100811 0)
(-4.0993921e-05 0.0038097799 0)
(-5.1345405e-05 0.0037961644 0)
(-5.595178e-05 0.0037478305 0)
(-5.3817071e-05 0.0036285559 0)
(-4.4741895e-05 0.0033841796 0)
(-2.9810093e-05 0.0029406696 0)
(-1.2559725e-05 0.0021972023 0)
(-2.0378768e-06 0.0010023647 0)
(1.2257238e-06 0.00099706289 0)
(7.8730666e-06 0.0021855851 0)
(1.9190841e-05 0.002927898 0)
(2.947204e-05 0.0033742029 0)
(3.6192158e-05 0.0036234951 0)
(3.8313187e-05 0.0037483524 0)
(3.56861e-05 0.0038019679 0)
(2.8817254e-05 0.0038199428 0)
(1.8663298e-05 0.003823303 0)
(6.461254e-06 0.0038228238 0)
(-6.4577952e-06 0.0038228233 0)
(-1.8659706e-05 0.0038233011 0)
(-2.8813888e-05 0.0038199404 0)
(-3.5682608e-05 0.0038019653 0)
(-3.8309793e-05 0.0037483502 0)
(-3.6189333e-05 0.0036234945 0)
(-2.9469637e-05 0.0033742043 0)
(-1.9189211e-05 0.0029279014 0)
(-7.8725175e-06 0.0021855881 0)
(-1.2256997e-06 0.00099706334 0)
(7.4047148e-07 0.00099374752 0)
(4.9621841e-06 0.002178077 0)
(1.2385406e-05 0.0029193498 0)
(1.9397544e-05 0.0033672112 0)
(2.4245617e-05 0.0036196253 0)
(2.60669e-05 0.0037482641 0)
(2.4592622e-05 0.0038056348 0)
(2.005478e-05 0.0038268258 0)
(1.3074467e-05 0.0038325026 0)
(4.5401218e-06 0.0038332256 0)
(-4.5375985e-06 0.0038332253 0)
(-1.3071782e-05 0.003832501 0)
(-2.005217e-05 0.0038268242 0)
(-2.4590158e-05 0.0038056328 0)
(-2.6064586e-05 0.0037482627 0)
(-2.4243312e-05 0.0036196255 0)
(-1.9395542e-05 0.0033672133 0)
(-1.2383996e-05 0.0029193539 0)
(-4.9615867e-06 0.0021780803 0)
(-7.4047774e-07 0.00099374797 0)
(4.4552624e-07 0.0009916662 0)
(3.1342509e-06 0.0021732129 0)
(8.0053886e-06 0.0029136442 0)
(1.2759395e-05 0.0033623673 0)
(1.6196175e-05 0.0036167643 0)
(1.76478e-05 0.0037479469 0)
(1.6835107e-05 0.0038079498 0)
(1.3845371e-05 0.0038314647 0)
(9.0778367e-06 0.0038388514 0)
(3.1605914e-06 0.0038404731 0)
(-3.159026e-06 0.0038404729 0)
(-9.0762347e-06 0.0038388501 0)
(-1.3843635e-05 0.0038314634 0)
(-1.6833577e-05 0.0038079483 0)
(-1.7646528e-05 0.003747946 0)
(-1.6194926e-05 0.0036167653 0)
(-1.2758275e-05 0.0033623701 0)
(-8.0045297e-06 0.0029136486 0)
(-3.1341164e-06 0.0021732169 0)
(-4.457102e-07 0.00099166708 0)
(2.6500306e-07 0.00099035971 0)
(1.9781307e-06 0.0021700583 0)
(5.1752914e-06 0.0029098426 0)
(8.3853029e-06 0.0033590381 0)
(1.0792111e-05 0.0036146962 0)
(1.1898605e-05 0.003747582 0)
(1.1460886e-05 0.0038094105 0)
(9.4952626e-06 0.0038345788 0)
(6.2563795e-06 0.0038432032 0)
(2.1831789e-06 0.0038454827 0)
(-2.1824658e-06 0.0038454826 0)
(-6.2558431e-06 0.0038432024 0)
(-9.4944876e-06 0.0038345775 0)
(-1.1460114e-05 0.0038094094 0)
(-1.1898053e-05 0.0037475817 0)
(-1.0791204e-05 0.0036146976 0)
(-8.3843809e-06 0.0033590414 0)
(-5.174568e-06 0.0029098472 0)
(-1.9780323e-06 0.0021700626 0)
(-2.6521982e-07 0.00099036135 0)
(1.5419852e-07 0.00098954274 0)
(1.2432633e-06 0.0021680128 0)
(3.3410311e-06 0.0029073136 0)
(5.5018014e-06 0.0033567631 0)
(7.1723589e-06 0.003613224 0)
(7.992143e-06 0.0037472465 0)
(7.7643485e-06 0.0038103314 0)
(6.4745967e-06 0.0038366617 0)
(4.2847541e-06 0.0038461691 0)
(1.498229e-06 0.0038489221 0)
(-1.4979712e-06 0.0038489219 0)
(-4.2845911e-06 0.0038461686 0)
(-6.474437e-06 0.0038366607 0)
(-7.7641634e-06 0.0038103304 0)
(-7.991911e-06 0.0037472467 0)
(-7.1718838e-06 0.0036132257 0)
(-5.5011729e-06 0.0033567667 0)
(-3.3404411e-06 0.0029073184 0)
(-1.2435776e-06 0.0021680171 0)
(-1.5472177e-07 0.00098954483 0)
(8.6995514e-08 0.0009890358 0)
(7.7622637e-07 0.0021666885 0)
(2.1503333e-06 0.0029056341 0)
(3.6007066e-06 0.0033552156 0)
(4.752525e-06 0.003612188 0)
(5.3482709e-06 0.0037469674 0)
(5.2365095e-06 0.0038109109 0)
(4.3919594e-06 0.0038380502 0)
(2.9175088e-06 0.0038481802 0)
(1.0217446e-06 0.0038512692 0)
(-1.0223542e-06 0.0038512689 0)
(-2.9181755e-06 0.0038481796 0)
(-4.3924761e-06 0.0038380495 0)
(-5.2368579e-06 0.00381091 0)
(-5.3485823e-06 0.0037469674 0)
(-4.7525024e-06 0.0036121894 0)
(-3.6004995e-06 0.0033552192 0)
(-2.1498487e-06 0.0029056394 0)
(-7.7611835e-07 0.0021666933 0)
(-8.7251466e-08 0.00098903805 0)
(4.6328303e-08 0.00098872473 0)
(4.7933248e-07 0.0021658339 0)
(1.3774476e-06 0.0029045217 0)
(2.3485707e-06 0.0033541675 0)
(3.1385087e-06 0.0036114651 0)
(3.5652562e-06 0.0037467478 0)
(3.5162222e-06 0.0038112748 0)
(2.9649061e-06 0.0038389731 0)
(1.9762098e-06 0.0038495377 0)
(6.9302637e-07 0.0038528629 0)
(-6.9407779e-07 0.0038528624 0)
(-1.9775483e-06 0.0038495369 0)
(-2.965993e-06 0.0038389723 0)
(-3.5170461e-06 0.0038112737 0)
(-3.5659496e-06 0.0037467471 0)
(-3.1386984e-06 0.003611466 0)
(-2.3483596e-06 0.0033541705 0)
(-1.3772382e-06 0.0029045269 0)
(-4.7954719e-07 0.0021658394 0)
(-4.662525e-08 0.00098872741 0)
(2.2461387e-08 0.00098853702 0)
(2.9176188e-07 0.0021652854 0)
(8.7680405e-07 0.0029037873 0)
(1.5249472e-06 0.0033534602 0)
(2.0641297e-06 0.0036109644 0)
(2.366755e-06 0.0037465804 0)
(2.3506023e-06 0.0038115026 0)
(1.9922595e-06 0.0038395848 0)
(1.332153e-06 0.0038504503 0)
(4.674909e-07 0.0038539396 0)
(-4.6940704e-07 0.0038539392 0)
(-1.3337846e-06 0.0038504493 0)
(-1.9935167e-06 0.0038395833 0)
(-2.3520714e-06 0.003811501 0)
(-2.3680025e-06 0.0037465791 0)
(-2.0645632e-06 0.0036109647 0)
(-1.5248417e-06 0.0033534625 0)
(-8.7647083e-07 0.0029037921 0)
(-2.9182711e-07 0.002165291 0)
(-2.2692596e-08 0.00098853995 0)
(8.8795063e-09 0.00098842671 0)
(1.7422393e-07 0.0021649359 0)
(5.5337196e-07 0.0029033041 0)
(9.8444981e-07 0.0033529845 0)
(1.3512148e-06 0.0036106194 0)
(1.5645446e-06 0.0037464554 0)
(1.5646047e-06 0.0038116443 0)
(1.3324322e-06 0.0038399888 0)
(8.9368207e-07 0.003851061 0)
(3.1370205e-07 0.0038546638 0)
(-3.1606913e-07 0.0038546635 0)
(-8.9577902e-07 0.0038510599 0)
(-1.3344225e-06 0.0038399867 0)
(-1.5664472e-06 0.0038116423 0)
(-1.5660241e-06 0.0037464536 0)
(-1.3522912e-06 0.0036106189 0)
(-9.8507458e-07 0.003352986 0)
(-5.5352586e-07 0.0029033086 0)
(-1.7418503e-07 0.0021649413 0)
(-8.8778621e-09 0.00098842964 0)
(1.2774961e-09 0.00098836429 0)
(1.0090579e-07 0.0021647155 0)
(3.4550425e-07 0.0029029878 0)
(6.3148661e-07 0.0033526658 0)
(8.8026005e-07 0.0036103831 0)
(1.0296272e-06 0.0037463641 0)
(1.0367773e-06 0.0038117318 0)
(8.8690035e-07 0.0038402544 0)
(5.9654174e-07 0.0038514685 0)
(2.0919996e-07 0.0038551494 0)
(-2.1263365e-07 0.0038551489 0)
(-5.9961441e-07 0.0038514668 0)
(-8.8980026e-07 0.0038402518 0)
(-1.0394984e-06 0.0038117295 0)
(-1.0319089e-06 0.0037463616 0)
(-8.8182863e-07 0.0036103818 0)
(-6.3254795e-07 0.0033526665 0)
(-3.4609107e-07 0.0029029916 0)
(-1.0097474e-07 0.0021647203 0)
(-1.1385007e-09 0.00098836693 0)
(-2.6320211e-09 0.0009883307 0)
(5.5956969e-08 0.0021645779 0)
(2.1317802e-07 0.002902782 0)
(4.0252284e-07 0.0033524534 0)
(5.7046699e-07 0.0036102219 0)
(6.7433131e-07 0.0037462983 0)
(6.8397829e-07 0.0038117859 0)
(5.8792036e-07 0.0038404287 0)
(3.9626144e-07 0.0038517393 0)
(1.3846066e-07 0.0038554736 0)
(-1.4282856e-07 0.003855473 0)
(-4.0053979e-07 0.0038517374 0)
(-5.9195223e-07 0.0038404258 0)
(-6.8786747e-07 0.0038117829 0)
(-6.7785136e-07 0.0037462952 0)
(-5.7304646e-07 0.0036102198 0)
(-4.0415022e-07 0.0033524531 0)
(-2.1437207e-07 0.0029027847 0)
(-5.6432451e-08 0.002164582 0)
(2.8424608e-09 0.00098833279 0)
(-3.9290842e-09 0.00098831437 0)
(2.9699456e-08 0.002164493 0)
(1.2994139e-07 0.0029026487 0)
(2.5480242e-07 0.0033523121 0)
(3.6819864e-07 0.0036101122 0)
(4.4056938e-07 0.0037462511 0)
(4.5016811e-07 0.0038118187 0)
(3.884101e-07 0.0038405427 0)
(2.6197353e-07 0.0038519189 0)
(9.0940418e-08 0.0038556896 0)
(-9.6250561e-08 0.003855689 0)
(-2.675895e-07 0.0038519169 0)
(-3.9389655e-07 0.0038405398 0)
(-4.5516962e-07 0.0038118156 0)
(-4.4504725e-07 0.0037462475 0)
(-3.7197541e-07 0.0036101093 0)
(-2.5756068e-07 0.0033523109 0)
(-1.3171773e-07 0.0029026504 0)
(-3.0177908e-08 0.0021644964 0)
(4.0945288e-09 0.00098831592 0)
(-4.2274353e-09 0.00098830788 0)
(1.4724e-08 0.0021644413 0)
(7.8690301e-08 0.0029025624 0)
(1.6122936e-07 0.0033522184 0)
(2.3805473e-07 0.003610038 0)
(2.8795995e-07 0.0037462175 0)
(2.961291e-07 0.0038118385 0)
(2.5629864e-07 0.0038406173 0)
(1.7257373e-07 0.0038520382 0)
(5.8852592e-08 0.0038558338 0)
(-6.5862698e-08 0.003855833 0)
(-1.7983857e-07 0.0038520363 0)
(-2.6281089e-07 0.0038406145 0)
(-3.019863e-07 0.0038118355 0)
(-2.9348623e-07 0.0037462138 0)
(-2.4299609e-07 0.0036100344 0)
(-1.6530804e-07 0.003352216 0)
(-8.1254805e-08 0.002902563 0)
(-1.5337206e-08 0.0021644438 0)
(4.441581e-09 0.00098830897 0)
(-3.6551005e-09 0.0009883063 0)
(6.9672714e-09 0.00216441 0)
(4.8492813e-08 0.0029025065 0)
(1.0360894e-07 0.0033521558 0)
(1.5573958e-07 0.0036099878 0)
(1.9010104e-07 0.0037461941 0)
(1.9612899e-07 0.0038118511 0)
(1.699494e-07 0.0038406669 0)
(1.1407768e-07 0.0038521179 0)
(3.7836943e-08 0.0038559302 0)
(-4.5866055e-08 0.0038559295 0)
(-1.2231442e-07 0.0038521161 0)
(-1.7798604e-07 0.0038406639 0)
(-2.0375565e-07 0.0038118476 0)
(-1.9714377e-07 0.0037461899 0)
(-1.6215516e-07 0.0036099833 0)
(-1.0875659e-07 0.0033521526 0)
(-5.1676922e-08 0.0029025056 0)
(-7.9098485e-09 0.002164411 0)
(3.810675e-09 0.00098830697 0)
(-2.6874728e-09 0.00098830642 0)
(4.1120026e-09 0.00216439 0)
(3.2304871e-08 0.0029024692 0)
(7.0393411e-08 0.0033521135 0)
(1.0604333e-07 0.0036099536 0)
(1.2927224e-07 0.0037461784 0)
(1.3329554e-07 0.0038118598 0)
(1.1508674e-07 0.0038407006 0)
(7.6666129e-08 0.0038521719 0)
(2.4218497e-08 0.0038559959 0)
(-3.3176814e-08 0.0038559952 0)
(-8.5482245e-08 0.0038521702 0)
(-1.2389877e-07 0.0038406975 0)
(-1.4181616e-07 0.003811856 0)
(-1.3724219e-07 0.0037461736 0)
(-1.1320752e-07 0.0036099485 0)
(-7.6351419e-08 0.0033521093 0)
(-3.6444639e-08 0.0029024665 0)
(-5.3003873e-09 0.0021643891 0)
(2.9454445e-09 0.0009883067 0)
(-1.4013757e-09 0.00098830629 0)
(4.9406733e-09 0.0021643753 0)
(2.6709372e-08 0.0029024426 0)
(5.429687e-08 0.0033520843 0)
(7.8866715e-08 0.0036099305 0)
(9.4001747e-08 0.0037461686 0)
(9.5357928e-08 0.0038118669 0)
(8.1117821e-08 0.0038407248 0)
(5.3198976e-08 0.0038522101 0)
(1.5531394e-08 0.0038560417 0)
(-2.5628698e-08 0.003856041 0)
(-6.3112358e-08 0.0038522082 0)
(-9.1064039e-08 0.0038407215 0)
(-1.0499847e-07 0.0038118628 0)
(-1.0339974e-07 0.003746163 0)
(-8.7354555e-08 0.0036099246 0)
(-6.1069195e-08 0.0033520785 0)
(-3.1341519e-08 0.0029024382 0)
(-6.3293754e-09 0.0021643727 0)
(1.6708774e-09 0.00098830581 0)
(2.0910498e-10 0.00098830483 0)
(9.3182763e-09 0.0021643623 0)
(2.9987267e-08 0.0029024222 0)
(5.1366622e-08 0.0033520633 0)
(6.835932e-08 0.0036099157 0)
(7.7071963e-08 0.0037461639 0)
(7.5026491e-08 0.0038118746 0)
(6.2071018e-08 0.0038407446 0)
(3.9502963e-08 0.0038522395 0)
(1.0155015e-08 0.0038560761 0)
(-2.143387e-08 0.0038560756 0)
(-5.0350252e-08 0.0038522372 0)
(-7.2728012e-08 0.0038407411 0)
(-8.5704841e-08 0.0038118702 0)
(-8.728995e-08 0.0037461578 0)
(-7.7612472e-08 0.0036099087 0)
(-5.8700871e-08 0.0033520563 0)
(-3.4497117e-08 0.0029024158 0)
(-1.0855854e-08 0.0021643578 0)
(-2.3242794e-10 0.0009883032 0)
(2.7352109e-09 0.00098830484 0)
(1.7036112e-08 0.0021643533 0)
(4.028521e-08 0.0029024101 0)
(5.9048556e-08 0.0033520541 0)
(7.0363344e-08 0.0036099132 0)
(7.3186342e-08 0.0037461703 0)
(6.7225302e-08 0.0038118902 0)
(5.2893121e-08 0.003840769 0)
(3.2244492e-08 0.0038522705 0)
(7.4140894e-09 0.0038561107 0)
(-1.9344872e-08 0.0038561101 0)
(-4.4302737e-08 0.0038522684 0)
(-6.4670613e-08 0.0038407658 0)
(-7.8719355e-08 0.0038118859 0)
(-8.4189271e-08 0.0037461639 0)
(-8.0145185e-08 0.0036099053 0)
(-6.6921607e-08 0.0033520453 0)
(-4.5597273e-08 0.0029024013 0)
(-1.916936e-08 0.0021643464 0)
(-2.9370221e-09 0.00098830231 0)
(7.7304629e-09 0.00098828225 0)
(3.1274535e-08 0.0021643213 0)
(5.960986e-08 0.0029023819 0)
(7.6160303e-08 0.0033520336 0)
(8.1987403e-08 0.0036099011 0)
(7.8784913e-08 0.0037461663 0)
(6.7706798e-08 0.0038118933 0)
(5.050758e-08 0.003840778 0)
(2.9236217e-08 0.0038522836 0)
(5.6735815e-09 0.0038561261 0)
(-1.8722042e-08 0.0038561253 0)
(-4.2325143e-08 0.0038522816 0)
(-6.3390837e-08 0.0038407747 0)
(-8.0050697e-08 0.0038118886 0)
(-9.0132241e-08 0.0037461592 0)
(-9.2036302e-08 0.0036098921 0)
(-8.423042e-08 0.0033520228 0)
(-6.494018e-08 0.0029023705 0)
(-3.3543885e-08 0.0021643118 0)
(-8.0597638e-09 0.00098827898 0)
(1.9228937e-08 0.00098825062 0)
(5.5046765e-08 0.0021642583 0)
(8.3773557e-08 0.0029023287 0)
(9.6097268e-08 0.0033519923 0)
(9.6310077e-08 0.0036098697 0)
(8.7431139e-08 0.0037461424 0)
(7.1423755e-08 0.0038118747 0)
(5.1023814e-08 0.0038407625 0)
(2.8634616e-08 0.0038522702 0)
(4.7854455e-09 0.0038561135 0)
(-1.9345668e-08 0.0038561126 0)
(-4.2822144e-08 0.0038522678 0)
(-6.5005638e-08 0.0038407589 0)
(-8.4586808e-08 0.0038118689 0)
(-9.9412171e-08 0.0037461339 0)
(-1.0703946e-07 0.0036098589 0)
(-1.0478648e-07 0.0033519793 0)
(-8.9615721e-08 0.0029023143 0)
(-5.75448e-08 0.002164246 0)
(-1.9561349e-08 0.00098824616 0)
(2.4321946e-08 0.00098816362 0)
(6.476766e-08 0.0021642149 0)
(9.1134153e-08 0.0029023113 0)
(1.0135648e-07 0.0033519962 0)
(1.0002658e-07 0.0036098908 0)
(8.9169559e-08 0.0037461776 0)
(7.1326225e-08 0.0038119192 0)
(4.9898855e-08 0.0038408122 0)
(2.7276801e-08 0.0038523214 0)
(4.178925e-09 0.0038561654 0)
(-1.9035982e-08 0.0038561646 0)
(-4.1993694e-08 0.0038523189 0)
(-6.4549806e-08 0.003840808 0)
(-8.5211116e-08 0.0038119115 0)
(-1.0135141e-07 0.0037461674 0)
(-1.1063352e-07 0.0036098782 0)
(-1.1045004e-07 0.0033519801 0)
(-9.7407582e-08 0.0029022929 0)
(-6.7684252e-08 0.0021641986 0)
(-2.5040021e-08 0.00098815705 0)
)
;
boundaryField
{
Wall
{
type fixedValue;
value uniform (0 0 0);
}
frontAndBack
{
type empty;
}
atmosphere
{
type pressureInletOutletVelocity;
value nonuniform List<vector>
20
(
(2.4321946e-08 0.00098816362 0)
(6.476766e-08 0.0021642149 0)
(9.1134153e-08 0.0029023113 0)
(1.0135648e-07 0.0033519962 0)
(1.0002658e-07 0.0036098908 0)
(8.9169559e-08 0.0037461776 0)
(7.1326225e-08 0.0038119192 0)
(4.9898855e-08 0.0038408122 0)
(2.7276801e-08 0.0038523214 0)
(4.178925e-09 0.0038561654 0)
(-1.9035982e-08 0.0038561646 0)
(-4.1993694e-08 0.0038523189 0)
(-6.4549806e-08 0.003840808 0)
(-8.5211116e-08 0.0038119115 0)
(-1.0135141e-07 0.0037461674 0)
(-1.1063352e-07 0.0036098782 0)
(-1.1045004e-07 0.0033519801 0)
(-9.7407582e-08 0.0029022929 0)
(-6.7684252e-08 0.0021641986 0)
(-2.5040021e-08 0.00098815705 0)
)
;
}
}
// ************************************************************************* //
| [
"mohsenk@outlook.com"
] | mohsenk@outlook.com | |
d9336fc8aa6b348fa8f06b690de395f76f3fa73e | c8c5d95ab92252595b27a534c92246b66b9a0ad0 | /server/include/distributions.h | 8c72228add1ec1b112f2737b21de3bf9978139a6 | [] | no_license | ronalanto03/algorithms-scheduling-simulator | c63864d66da98bcc18238ffc6aef7050f0ad6bd1 | 878074abf255089501050a4bf7fab905fc78e201 | refs/heads/master | 2021-01-24T11:28:15.485016 | 2016-10-25T23:48:02 | 2016-10-25T23:48:02 | 70,206,457 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,139 | h | /**
* @file distributions.h
* @brief Declaracion de las estructura Distribution
* @author Ronald Sulbaran. ronalanto03@gmail.com.
* @date 24-05-2013
*/
#ifndef DISTRIBUTIONS_H
#define DISTRIBUTIONS_H
#include<cmath>
#include <random>
#include <chrono>
/**
* @struct DistributionData
* @brief Distribuciones usadas para hacer las simulaciones.
*/
class Distribution
{
private:
std::default_random_engine generator;/**< Motor de números aleatorios que genera números pseudo-aleatorios*/
double lamda;/**< Parametro lamda de la distribucion exponencial*/
std::uniform_real_distribution<double> * distribution_u;/**< Distribución de números aleatorios que produce valores de punto flotante de acuerdo con una distribución uniforme*/
std::normal_distribution<double> * distribution_n;/**< Distribución de números aleatorios que produce valores de punto flotante de acuerdo con una distribución normal*/
public:
enum Type
{
constant = 0,
uniform = 1,
exponential = 2,
normal = 3
};
enum Type t;
/**
* @brief Constructor parametrico
* @param _t tipo de generador
* @param _t a usado de diferentes formas dependiendo del tipo de distribucion
* @param _t b usado de diferentes formas dependiendo del tipo de distribucion
*/
Distribution(enum Type _t,double a, double b,double seed);
/**
* @brief Borra la memoria ocupada por el generador asociado a la distribucion
*/
~Distribution();
/**
* @return un numero aleatorio distribuido de acuerdo a la distribucion elegida
*/
inline double getVal()
{
switch(t)
{
case constant:
return lamda;
case uniform:
return (*distribution_u)(generator);
case exponential:
return -log((*distribution_u)(generator))*lamda;
case normal:
return (*distribution_n)(generator);
}
return 0.0;//This should not ever be reached
}
};
#endif
| [
"ronalanto03@gmail.com"
] | ronalanto03@gmail.com |
643698604ef62af7c92e3151c7ba5f3bb5f2ebbc | ec8e370551e1549e04ba76870f5a9cbf80e25f97 | /src/simulation/Buildings.cpp | ef95175a9415ece9af47ffb0b37c630cf8fc1821 | [] | no_license | jmc734/OpenEaagles | 7c3ea87417ac6b4b29bd1130ddb849d8cec12aa3 | e28efd40555651261f4dbccc7fd618e524f999aa | refs/heads/master | 2020-12-25T11:41:31.620244 | 2015-08-31T17:25:37 | 2015-08-31T17:25:37 | 41,508,946 | 0 | 0 | null | 2015-08-27T20:10:29 | 2015-08-27T20:10:29 | null | UTF-8 | C++ | false | false | 1,516 | cpp | #include "openeaagles/simulation/Buildings.h"
#include "openeaagles/basic/List.h"
#include "openeaagles/basic/osg/Matrix"
#include "openeaagles/basic/units/Angles.h"
namespace Eaagles {
namespace Simulation {
//==============================================================================
// class Building
//==============================================================================
IMPLEMENT_EMPTY_SLOTTABLE_SUBCLASS(Building,"Building")
EMPTY_SERIALIZER(Building)
//------------------------------------------------------------------------------
// Constructor(s)
//------------------------------------------------------------------------------
Building::Building()
{
STANDARD_CONSTRUCTOR()
static Basic::String generic("GenericBuilding");
setType(&generic);
}
//------------------------------------------------------------------------------
// copyData(), deleteData() -- copy (delete) member data
//------------------------------------------------------------------------------
void Building::copyData(const Building& org, const bool)
{
BaseClass::copyData(org);
}
void Building::deleteData()
{
}
//-----------------------------------------------------------------------------
// getMajorType() -- Returns the player's major type
//-----------------------------------------------------------------------------
unsigned int Building::getMajorType() const
{
return BUILDING;
}
} // End Simulation namespace
} // End Eaagles namespace
| [
"doug@openeaagles.org"
] | doug@openeaagles.org |
64cac577d618f25b4934cda55bd45dedbc869e88 | 66a237cf903be1caacfc0e4098431bbdf7088fc8 | /external/GamePlay/gameplay/src/Node.h | 229ddfc02ddb23648a2b1238c67865506d5eb5b2 | [
"Apache-2.0"
] | permissive | brucelevis/platformer | 95abcb0f63adf64d7f641ba2239b7adb12c1903f | 9d794338ac4d18ac439b5b47bab3cfeb538f79bb | refs/heads/master | 2023-03-20T07:29:48.784013 | 2017-09-03T16:48:06 | 2017-09-03T16:48:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 26,051 | h | #ifndef NODE_H_
#define NODE_H_
#include "Transform.h"
#include "ScriptTarget.h"
#include "Model.h"
#include "Sprite.h"
#include "TileSet.h"
#include "Text.h"
#include "Form.h"
#include "ParticleEmitter.h"
#include "Camera.h"
#include "Light.h"
#include "PhysicsRigidBody.h"
#include "PhysicsCollisionObject.h"
#include "BoundingBox.h"
#include "AIAgent.h"
namespace gameplay
{
class Scene;
class Camera;
class Light;
class AudioSource;
class AIAgent;
class Drawable;
/**
* Defines a hierarchical structure of objects in 3D transformation spaces.
*
* This object allow you to attach components to a scene such as:
* Drawable's(Model, Camera, Light, PhysicsCollisionObject, AudioSource, etc.
*
* @see http://gameplay3d.github.io/GamePlay/docs/file-formats.html#wiki-Node
*/
class Node : public Transform, public Ref
{
friend class Scene;
friend class SceneLoader;
friend class Bundle;
friend class MeshSkin;
friend class Light;
GP_SCRIPT_EVENTS_START();
GP_SCRIPT_EVENT(update, "<Node>f");
GP_SCRIPT_EVENT(messageReceived, "<Node><AIMessage>");
GP_SCRIPT_EVENT(stateEnter, "<Node><AIState>");
GP_SCRIPT_EVENT(stateExit, "<Node><AIState>");
GP_SCRIPT_EVENT(stateUpdate, "<Node><AIState>f");
GP_SCRIPT_EVENTS_END();
public:
/**
* Defines the types of nodes.
*/
enum Type
{
NODE = 1,
JOINT
};
/**
* Creates a new node with the specified ID.
*
* @param id The ID for the new node.
* @script{create}
*/
static Node* create(const char* id = NULL);
/**
* Extends ScriptTarget::getTypeName() to return the type name of this class.
*
* @return The type name of this class: "Node"
* @see ScriptTarget::getTypeName()
*/
const char* getTypeName() const;
/**
* Gets the identifier for the node.
*
* @return The node identifier.
*/
const char* getId() const;
/**
* Sets the identifier for the node.
*
* @param id The identifier to set for the node.
*/
void setId(const char* id);
/**
* Returns the type of the node.
*/
virtual Node::Type getType() const;
/**
* Adds a child node.
*
* @param child The child to add.
*/
virtual void addChild(Node* child);
/**
* Removes a child node.
*
* @param child The child to remove.
*/
virtual void removeChild(Node* child);
/**
* Removes all child nodes.
*/
virtual void removeAllChildren();
/**
* Returns the first child for this node.
*
* @return The first child.
*/
Node* getFirstChild() const;
/**
* Returns the first sibling of this node.
*
* @return The first sibling.
*/
Node* getNextSibling() const;
/**
* Returns the previous sibling to this node.
*
* @return The previous sibling.
*/
Node* getPreviousSibling() const;
/**
* Returns the parent of this node.
*
* @return The parent.
*/
Node* getParent() const;
/**
* Returns the number of direct children of this item.
*
* @return The number of children.
*/
unsigned int getChildCount() const;
/**
* Gets the top level node in this node's parent hierarchy.
*/
Node* getRootNode() const;
/**
* Returns the first child node that matches the given ID.
*
* This method checks the specified ID against its immediate child nodes
* but does not check the ID against itself.
* If recursive is true, it also traverses the Node's hierarchy with a breadth first search.
*
* @param id The ID of the child to find.
* @param recursive True to search recursively all the node's children, false for only direct children.
* @param exactMatch true if only nodes whose ID exactly matches the specified ID are returned,
* or false if nodes that start with the given ID are returned.
*
* @return The Node found or NULL if not found.
*/
Node* findNode(const char* id, bool recursive = true, bool exactMatch = true) const;
/**
* Returns all child nodes that match the given ID.
*
* @param id The ID of the node to find.
* @param nodes A vector of nodes to be populated with matches.
* @param recursive true if a recursive search should be performed, false otherwise.
* @param exactMatch true if only nodes whose ID exactly matches the specified ID are returned,
* or false if nodes that start with the given ID are returned.
*
* @return The number of matches found.
* @script{ignore}
*/
unsigned int findNodes(const char* id, std::vector<Node*>& nodes, bool recursive = true, bool exactMatch = true) const;
/**
* Gets the scene this node is currenlty within.
*
* @return The scene.
*/
virtual Scene* getScene() const;
/**
* Sets a tag on this Node.
*
* tags can be used for a variety of purposes within a game. For example,
* a tag called "transparent" can be added to nodes, to indicate which nodes in
* a scene are transparent. This tag can then be read during rendering to sort
* transparent and opaque objects for correct drawing order.
*
* Setting a tag to NULL removes the tag from the Node.
*
* @param name Name of the tag to set.
* @param value Optional value of the tag (empty string by default).
*/
void setTag(const char* name, const char* value = "");
/**
* Returns the value of the custom tag with the given name.
*
* @param name Name of the tag to return.
*
* @return The value of the given tag, or NULL if the tag is not set.
*/
const char* getTag(const char* name) const;
/**
* Determines if a custom tag with the specified name is set.
*
* @param name Name of the tag to query.
*
* @return true if the tag is set, false otherwise.
*/
bool hasTag(const char* name) const;
/**
* Sets if the node is enabled in the scene.
*
* @param enabled if the node is enabled in the scene.
*/
void setEnabled(bool enabled);
/**
* Gets if the node is enabled in the scene.
*
* @return if the node is enabled in the scene.
*/
bool isEnabled() const;
/**
* Gets if the node inherently enabled.
*
* @return if components attached on this node should be running.
*/
bool isEnabledInHierarchy() const;
/**
* Called to update the state of this Node.
*
* This method is called by Scene::update(float) to update the state of all active
* nodes in a scene. A Node is considered active if Node::isActive() returns true.
*
* If any scripts are attached to the node, their update event will be fired.
*
* @param elapsedTime Elapsed time in milliseconds.
*/
void update(float elapsedTime);
/**
* Returns whether the transformation of this node is static.
*
* Nodes that have static rigid bodies attached to them are considered static.
*
* @return True if the transformation of this Node is static, false otherwise.
*
* @see Transform::isStatic()
*/
bool isStatic() const;
/**
* Gets the world matrix corresponding to this node.
*
* @return The world matrix of this node.
*/
virtual const Matrix& getWorldMatrix() const;
/**
* Gets the world view matrix corresponding to this node.
*
* @return The world view matrix of this node.
*/
const Matrix& getWorldViewMatrix() const;
/**
* Gets the inverse transpose world matrix corresponding to this node.
*
* This matrix is typically used to transform normal vectors into world space.
*
* @return The inverse world matrix of this node.
*/
const Matrix& getInverseTransposeWorldMatrix() const;
/**
* Gets the inverse transpose world view matrix corresponding to this node.
*
* This matrix is typically used to transform normal vectors into view space.
*
* @return The inverse world view matrix of this node.
*/
const Matrix& getInverseTransposeWorldViewMatrix() const;
/**
* Gets the view matrix corresponding to this node based
* on the scene's active camera.
*
* @return The view matrix of this node.
*/
const Matrix& getViewMatrix() const;
/**
* Gets the inverse view matrix corresponding to this node based
* on the scene's active camera.
*
* @return The inverse view matrix of this node.
*/
const Matrix& getInverseViewMatrix() const;
/**
* Gets the projection matrix corresponding to this node based
* on the scene's active camera.
*
* @return The projection matrix of this node.
*/
const Matrix& getProjectionMatrix() const;
/**
* Gets the view * projection matrix corresponding to this node based
* on the scene's active camera.
*
* @return The view * projection matrix of this node.
*/
const Matrix& getViewProjectionMatrix() const;
/**
* Gets the inverse view * projection matrix corresponding to this node based
* on the scene's active camera.
*
* @return The inverse view * projection matrix of this node.
*/
const Matrix& getInverseViewProjectionMatrix() const;
/**
* Gets the world * view * projection matrix corresponding to this node based
* on the scene's active camera.
*
* @return The world * view * projection matrix of this node.
*/
const Matrix& getWorldViewProjectionMatrix() const;
/**
* Gets the translation vector (or position) of this Node in world space.
*
* @return The world translation vector.
*/
Vector3 getTranslationWorld() const;
/**
* Gets the translation vector (or position) of this Node in view space.
*
* @return The view space translation vector.
*/
Vector3 getTranslationView() const;
/**
* Returns the forward vector of the Node in world space.
*
* @return The forward vector in world space.
*/
Vector3 getForwardVectorWorld() const;
/**
* Returns the forward vector of the Node in view space.
*
* @return The forward vector in view space.
*/
Vector3 getForwardVectorView() const;
/**
* Returns the right vector of the Node in world space.
*
* @return The right vector in world space.
*/
Vector3 getRightVectorWorld() const;
/**
* Returns the up vector of the Node in world space.
*
* @return The up vector in world space.
*/
Vector3 getUpVectorWorld() const;
/**
* Returns the translation vector of the currently active camera for this node's scene.
*
* @return The translation vector of the scene's active camera.
*/
Vector3 getActiveCameraTranslationWorld() const;
/**
* Returns the view-space translation vector of the currently active camera for this node's scene.
*
* @return The translation vector of the scene's active camera, in view-space.
*/
Vector3 getActiveCameraTranslationView() const;
/**
* Gets the first animation in the node hierarchy with the specified ID.
*
* @param id The ID of the animation to get. Returns the first animation if ID is NULL.
* @return The first animation with the specified ID.
*/
Animation* getAnimation(const char* id = NULL) const;
/**
* Gets the drawable object attached to this node.
*
* @return The drawable component attached to this node.
*/
Drawable* getDrawable() const;
/**
* Set the drawable object to be attached to this node
*
* This is typically a Model, ParticleEmiiter, Form, Terrrain, Sprite, TileSet or Text.
*
* This will increase the reference count of the new drawble and decrease
* the reference count of the old drawable.
*
* @param drawable The new drawable component. May be NULL.
*/
void setDrawable(Drawable* drawable);
/**
* Gets the camera attached to this node.
*
* @return Gets the camera attached to this node.
*/
Camera* getCamera() const;
/**
* Attaches a camera to this node.
*
* This will increase the reference count of the new camera and decrease
* the reference count of the old camera.
*
* @param camera The new camera. May be NULL.
*/
void setCamera(Camera* camera);
/**
* Get the light attached to this node.
*
* @return The light attached to this node.
*/
Light* getLight() const;
/**
* Attaches a light to this node.
*
* This will increase the reference count of the new light and decrease
* the reference count of the old light.
*
* @param light The new light. May be NULL.
*/
void setLight(Light* light);
/**
* Gets the audio source attached to this node.
*
* @return The audio source attached to this node.
*/
AudioSource* getAudioSource() const;
/**
* Attaches an audio source to this node.
*
* This will increase the reference count of the new audio source and decrease
* the reference count of the old audio source.
*
* @param audio The new audio source. May be NULL.
*/
void setAudioSource(AudioSource* audio);
/**
* Returns the pointer to this node's physics collision object.
*
* The type of the returned collision object can be queried using
* the PhysicsCollisionObject::getType() method.
*
* @return The pointer to this node's physics collision object.
*/
PhysicsCollisionObject* getCollisionObject() const;
/**
* Sets (or disables) the physics collision object for this node.
*
* The supported collision object types include rigid bodies, ghost objects,
* characters, vehicles, and vehicle wheels.
*
* Rigid bodies are used to represent most physical objects in a game. The important
* feature of rigid bodies is that they can be simulated by the physics system as other
* rigid bodies or collision objects collide with them. To support this physics simulation,
* rigid bodies require additional parameters, such as mass, friction and restitution to
* define their physical features. These parameters can be passed into the
* 'rigidBodyParameters' parameter.
*
* Vehicles consist of a rigid body with wheels. The rigid body parameters can be passed-in
* via the 'rigidBodyParameters' parameter, and wheels can be added to the vehicle.
*
* Ghost objects are a simple type of collision object that are not simulated. By default
* they pass through other objects in the scene without affecting them. Ghost objects do
* receive collision events however, which makes them useful for representing non-simulated
* entities in a game that still require collision events, such as volumetric triggers,
* power-ups, etc.
*
* Characters are an extension of ghost objects which provide a number of additional features
* for animating and moving characters within a game. Characters are represented as ghost
* objects instead of rigid bodies to allow more direct control over character movement,
* since attempting to model a physics character with a simulated rigid body usually results
* in unresponsive and unpredictable character movement. Unlike normal ghost objects,
* characters to react to other characters and rigid bodies in the world. Characters react
* to gravity and collide (and respond) with rigid bodies to allow them to walk on the ground,
* slide along walls and walk up/down slopes and stairs.
*
* @param type The type of the collision object to set; to disable the physics
* collision object, pass PhysicsCollisionObject::NONE.
* @param shape Definition of a physics collision shape to be used for this collision object.
* Use the static shape methods on the PhysicsCollisionShape class to specify a shape
* definition, such as PhysicsCollisionShape::box().
* @param rigidBodyParameters If type is PhysicsCollisionObject::RIGID_BODY or
* PhysicsCollisionObject::VEHICLE, this must point to a valid rigid body
* parameters object containing information about the rigid body;
* otherwise, this parameter may be NULL.
* @param group Group identifier of the object for collision filtering.
* @param mask Bitmask to filter groups of objects to collide with this one.
*/
PhysicsCollisionObject* setCollisionObject(PhysicsCollisionObject::Type type,
const PhysicsCollisionShape::Definition& shape = PhysicsCollisionShape::box(),
PhysicsRigidBody::Parameters* rigidBodyParameters = NULL,
int group = PHYSICS_COLLISION_GROUP_DEFAULT,
int mask = PHYSICS_COLLISION_MASK_DEFAULT);
/**
* Sets the physics collision object for this node using the data from the Properties object defined at the specified URL,
* where the URL is of the format "<file-path>.<extension>#<namespace-id>/<namespace-id>/.../<namespace-id>"
* (and "#<namespace-id>/<namespace-id>/.../<namespace-id>" is optional).
*
* @param url The URL pointing to the Properties object defining the physics collision object.
*/
PhysicsCollisionObject* setCollisionObject(const char* url);
PhysicsCollisionObject* setCollisionObject(Properties* properties);
/**
* Gets the AI agent assigned to this node
*
* @return The AI agent for this node.
*/
AIAgent* getAgent() const;
/**
* Sets the AI agent for this node.
*
* @param agent The AI agent to set.
*/
void setAgent(AIAgent* agent);
/**
* Gets the user object assigned to this node.
*
* @return The user object assigned object to this node.
*/
Ref* getUserObject() const;
/**
* Sets a user object to be assigned object to this node.
*
* @param obj The user object assigned object to this node.
*/
void setUserObject(Ref* obj);
/**
* Returns the bounding sphere for the Node, in world space.
*
* The bounding sphere for a node represents the area, in world
* space, that the node contains. This includes the space occupied
* by any child nodes as well as the space occupied by any data
* inside the node (such as models).
*
* Bounding spheres for nodes are rough approximations of the data
* contained within a node and they are intended for visibility
* testing or first-pass intersection testing only. They are not
* appropriate for accurate collision detection since they most often
* do not tightly contain a node's content.
*
* A node that does not occupy any space will return a bounding sphere
* with a center point equal to the node translation and a radius of zero.
*
* @return The world-space bounding sphere for the node.
*/
const BoundingSphere& getBoundingSphere() const;
/**
* Clones the node and all of its child nodes.
*
* @return A new node.
* @script{create}
*/
Node* clone() const;
protected:
/**
* Constructor.
*/
Node(const char* id);
/**
* Destructor.
*/
virtual ~Node();
/**
* Clones a single node and its data but not its children.
*
* @param context The clone context.
*
* @return Pointer to the newly created node.
*/
virtual Node* cloneSingleNode(NodeCloneContext &context) const;
/**
* Recursively clones this node and its children.
*
* @param context The clone context.
*
* @return The newly created node.
*/
Node* cloneRecursive(NodeCloneContext &context) const;
/**
* Copies the data from this node into the given node.
*
* @param node The node to copy the data to.
* @param context The clone context.
*/
void cloneInto(Node* node, NodeCloneContext &context) const;
/**
* Removes this node from its parent.
*/
void remove();
/**
* Called when this Node's transform changes.
*/
void transformChanged();
/**
* Called when this Node's hierarchy changes.
*/
void hierarchyChanged();
/**
* Marks the bounding volume of the node as dirty.
*/
void setBoundsDirty();
/**
* Returns the first child node that matches the given ID.
*
* This method checks the specified ID against its immediate child nodes
* but does not check the ID against itself.
* If recursive is true, it also traverses the Node's hierarchy with a breadth first search.
*
* @param id The ID of the child to find.
* @param recursive True to search recursively all the node's children, false for only direct children.
* @param exactMatch true if only nodes whose ID exactly matches the specified ID are returned,
* or false if nodes that start with the given ID are returned.
* @param skipSkin Set true to skip skin hierarchy, initial find may set false to include skin hierarchy.
*
* @return The Node found or NULL if not found.
*/
Node* findNode(const char* id, bool recursive, bool exactMatch, bool skipSkin) const;
/**
* Returns all child nodes that match the given ID.
*
* @param id The ID of the node to find.
* @param nodes A vector of nodes to be populated with matches.
* @param recursive true if a recursive search should be performed, false otherwise.
* @param exactMatch true if only nodes whose ID exactly matches the specified ID are returned,
* or false if nodes that start with the given ID are returned.
* @param skipSkin Set true to skip skin hierarchy, initial find may set false to include skin hierarchy.
*
* @return The number of matches found.
* @script{ignore}
*/
unsigned int findNodes(const char* id, std::vector<Node*>& nodes, bool recursive, bool exactMatch, bool skipSkin) const;
private:
/**
* Hidden copy constructor.
*/
Node(const Node& copy);
/**
* Hidden copy assignment operator.
*/
Node& operator=(const Node&);
protected:
/** The scene this node is attached to. */
Scene* _scene;
/** The nodes id. */
std::string _id;
/** The nodes first child. */
Node* _firstChild;
/** The nodes next sibiling. */
Node* _nextSibling;
/** The nodes previous sibiling. */
Node* _prevSibling;
/** The nodes parent. */
Node* _parent;
/** The number of child nodes. */
unsigned int _childCount;
/** If this node is enabled. Maybe different if parent is enabled/disabled. */
bool _enabled;
/** Tags assigned to this node. */
std::map<std::string, std::string>* _tags;
/** The drawble component attached to this node. */
Drawable* _drawable;
/** The camera component attached to this node. */
Camera* _camera;
/** The light component attached to this node. */
Light* _light;
/** The audio source component attached to this node. */
AudioSource* _audioSource;
/** The collision object component attached to this node. */
PhysicsCollisionObject* _collisionObject;
/** The AI agent component attached to this node. */
mutable AIAgent* _agent;
/** The user object component attached to this node. */
Ref* _userObject;
/** The world matrix for this node. */
mutable Matrix _world;
/** The bounding sphere for this node. */
mutable BoundingSphere _bounds;
/** The dirty bits used for optimization. */
mutable int _dirtyBits;
};
/**
* NodeCloneContext represents the context data that is kept when cloning a node.
* The NodeCloneContext is used to make sure objects don't get cloned twice.
*/
class NodeCloneContext
{
public:
/**
* Constructor.
*/
NodeCloneContext();
/**
* Destructor.
*/
~NodeCloneContext();
/**
* Finds the cloned animation of the given animation or NULL if this animation was not registered with this context.
*
* @param animation The animation to search for the cloned copy of.
*
* @return The cloned animation or NULL if not found.
*/
Animation* findClonedAnimation(const Animation* animation);
/**
* Registers the cloned animation with this context so that it doesn't get cloned twice.
*
* @param original The pointer to the original animation.
* @param clone The pointer to the cloned animation.
*/
void registerClonedAnimation(const Animation* original, Animation* clone);
/**
* Finds the cloned node of the given node or NULL if this node was not registered with this context.
*
* @param node The node to search for the cloned copy of.
*
* @return The cloned node or NULL if not found.
*/
Node* findClonedNode(const Node* node);
/**
* Registers the cloned node with this context so that it doens't get cloned twice.
*
* @param original The pointer to the original node.
* @param clone The pointer to the cloned node.
*/
void registerClonedNode(const Node* original, Node* clone);
private:
/**
* Hidden copy constructor.
*/
NodeCloneContext(const NodeCloneContext&);
/**
* Hidden copy assignment operator.
*/
NodeCloneContext& operator=(const NodeCloneContext&);
std::map<const Animation*, Animation*> _clonedAnimations;
std::map<const Node*, Node*> _clonedNodes;
};
}
#endif
| [
"louis.mclaughlin@yahoo.co.uk"
] | louis.mclaughlin@yahoo.co.uk |
abcf183193d5f2f0794013db3cf77b2a5bc4d2da | 575692cb329ebfe1a2d44ae21d4033973009683a | /src/JD.cpp | c2d46bb4d3b1d0c76861bfe579de2d96f108c18b | [] | no_license | StuckInLoop/sxtwl_swig_py | 145e1dd1906068e527c5dd7b3994d25b3106fe43 | 8080b88d2f86897e1f980ef43b720fbb20ba8e30 | refs/heads/master | 2020-07-25T06:16:58.096236 | 2017-11-30T15:04:31 | 2017-11-30T15:04:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,787 | cpp | #include "JD.h"
#include "const.h"
#include <cstring>
//公历转儒略日
long double JD::DD2JD(int y, uint8_t m, long double d)
{
int n = 0, G = 0;
//判断是否为格里高利历日1582*372+10*31+15
if (y * 372 + m * 31 + (int)(d) >= 588829)
{
G = 1;
}
if (m <= 2)
{
m += 12, y--;
}
//加百年闰
if (G)
{
n = int2(y / 100), n = 2 - n + int(n / 4);
}
return int2(365.25*(y + 4716)) + int2(30.6001*(m + 1)) + d + n - 1524.5;
}
//儒略日数转公历
Time JD::JD2DD(int jd)
{
Time r;
int D = int2(jd + 0.5);
float F = jd + 0.5 - D, c; //取得日数的整数部份A及小数部分F
if (D >= 2299161)
{
c = int((D - 1867216.25) / 36524.25), D += 1 + c - int2(c / 4);
}
D += 1524; r.Y = int2((D - 122.1) / 365.25);//年数
D -= int2(365.25*r.Y); r.M = int2(D / 30.601); //月数
D -= int2(30.601*r.M); r.D = D; //日数
if (r.M > 13)
{
r.M -= 13, r.Y -= 4715;
}
else
{
r.M -= 1, r.Y -= 4716;
}
//日的小数转为时分秒
F *= 24; r.h = int2(F); F -= r.h;
F *= 60; r.m = int2(F); F -= r.m;
F *= 60; r.s = F;
return r;
}
long double JD::toJD(Time& time)
{
return JD::DD2JD(time.Y, time.M, time.D + ((time.s / 60 + time.m) / 60 + time.h) / 24);
}
//提取jd中的时间(去除日期);
std::string JD::timeStr(long double jd)
{
int h, m, s;
jd += 0.5; jd = (jd - int2(jd));
s = int2(jd * 86400 + 0.5);
h = int2(s / 3600); s -= h * 3600;
m = int2(s / 60); s -= m * 60;
std::string ret = "";
char buff[11];
memset(buff, 0, 11);
sprintf(buff, "0%d", h);
ret.append(buff + strlen(buff) - 2);
ret += ":";
memset(buff, 0, 11);
sprintf(buff, "0%d", m);
ret.append(buff + strlen(buff) - 2);
ret += ":";
memset(buff, 0, 11);
sprintf(buff, "0%d", s);
ret.append(buff + strlen(buff) - 2);
return ret;
}
| [
"2462787827@qq.com"
] | 2462787827@qq.com |
ddc391bb26d4435d9459f2d70acfb73a19d5e8d7 | 67297d0d85b09eb479fd84cd5a75a0af07a25496 | /doSymaFly/doSymaFly/doSymaFly.ino | ab71a2d4a6a4e779fb584c9509b9ac4444f78449 | [] | no_license | surferran/toys | 94d62452c9b0b4413c8bbd2221c6a1ce54bc47de | 44003a601f6144b35b8f51d30f03d0a81bb38dbf | refs/heads/master | 2021-01-10T03:05:48.324900 | 2016-01-29T13:03:13 | 2016-01-29T13:03:13 | 50,661,282 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 265 | ino | /*
Name: doSymaFly.ino
Created: 11/19/2015 9:34:07 PM
Author: Ran_the_User
*/
// the setup function runs once when you press reset or power the board
void setup() {
}
// the loop function runs over and over again until power down or reset
void loop() {
}
| [
"surferran@yahoo.com"
] | surferran@yahoo.com |
31568d0f836d137f63967072d2469027147ae9b3 | ff5313a6e6c9f9353f7505a37a57255c367ff6af | /wtl_hello/stdafx.h | e18df8bf55c9af71f7658ce5cb6d1d00bf5297aa | [] | no_license | badcodes/vc6 | 467d6d513549ac4d435e947927d619abf93ee399 | 0c11d7a81197793e1106c8dd3e7ec6b097a68248 | refs/heads/master | 2016-08-07T19:14:15.611418 | 2011-07-09T18:05:18 | 2011-07-09T18:05:18 | 1,220,419 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,454 | h | // stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__19DE612F_4674_42AE_B6FB_36E8EA9BB2D5__INCLUDED_)
#define AFX_STDAFX_H__19DE612F_4674_42AE_B6FB_36E8EA9BB2D5__INCLUDED_
// Change these values to use different versions
#define WINVER 0x0400
//#define _WIN32_WINNT 0x0400
#define _WIN32_IE 0x0400
#define _RICHEDIT_VER 0x0100
#include <atlbase.h>
#include <atlapp.h>
extern CAppModule _Module;
/*
#define _WTL_SUPPORT_SDK_ATL3
// Support for VS2005 Express & SDK ATL
#ifdef _WTL_SUPPORT_SDK_ATL3
#define _CRT_SECURE_NO_DEPRECATE
#pragma conform(forScope, off)
#pragma comment(linker, "/NODEFAULTLIB:atlthunk.lib")
#endif // _WTL_SUPPORT_SDK_ATL3
#include <atlbase.h>
// Support for VS2005 Express & SDK ATL
#ifdef _WTL_SUPPORT_SDK_ATL3
namespace ATL
{
inline void * __stdcall __AllocStdCallThunk()
{
return ::HeapAlloc(::GetProcessHeap(), 0, sizeof(_stdcallthunk));
}
inline void __stdcall __FreeStdCallThunk(void *p)
{
::HeapFree(::GetProcessHeap(), 0, p);
}
};
#endif // _WTL_SUPPORT_SDK_ATL3
*/
#include <atlwin.h>
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__19DE612F_4674_42AE_B6FB_36E8EA9BB2D5__INCLUDED_)
| [
"eotect@gmail.com"
] | eotect@gmail.com |
2436b11a50a90e7832ef49dab107400a485a34f6 | 5256b82f743a0aab3ec1eb51103c66c77374ff53 | /src/UKNCBTL.TB/stdafx.cpp | fb6b79a1d86d912f16560e44e56f8f921d3bd838 | [] | no_license | arma-gast/ukncbtl | cdfe37f07edcf020dce24df43aee52b58af49230 | 6c271114054b4cd2b422c5e1756a032f46fb4de7 | refs/heads/master | 2020-03-29T14:01:19.332066 | 2015-03-16T19:39:07 | 2015-03-16T19:39:07 | 33,125,833 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 296 | cpp | // stdafx.cpp : source file that includes just the standard includes
// TestBench.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| [
"nzeemin@gmail.com@d259c8a2-7647-0410-94c4-d9ba3b64c92c"
] | nzeemin@gmail.com@d259c8a2-7647-0410-94c4-d9ba3b64c92c |
2c30282209774e64ddd20d11ae32ceb31e83f5a7 | fe2836176ca940977734312801f647c12e32a297 | /Codeforces/Gym/2014-2015 Samara SAU ACM ICPC Quarterfinal Qualification Contest/G/main.cpp | 318d681c19537f791ddfdb48767433c9a792e21b | [] | no_license | henrybear327/Sandbox | ef26d96bc5cbcdc1ce04bf507e19212ca3ceb064 | d77627dd713035ab89c755a515da95ecb1b1121b | refs/heads/master | 2022-12-25T16:11:03.363028 | 2022-12-10T21:08:41 | 2022-12-10T21:08:41 | 53,817,848 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 261 | cpp | #include <bits/stdc++.h>
int main()
{
int N, S;
scanf("%d %d", &N, &S);
int ans = 0;
for (int i = 0; i < N; i++) {
int a;
scanf("%d", &a);
ans += S % a;
S /= a;
}
printf("%d\n", ans + S);
return 0;
}
| [
"henrybear327@gmail.com"
] | henrybear327@gmail.com |
24388a9158b0a0b7111afa1fe9742f3631e8d8e7 | bd73c74a097f803e961c93998f8e2ba385534a75 | /Sistema_de_Control__distancia_/Sistema_de_Control__distancia_.ino | 1cbb94939afb4a62080ece097416df66d674af96 | [] | no_license | mjdvr23/MicroMouse | b27b0f0ab8bfcbea2a19491c8a09be70e5945ca3 | 6bfbdaccb097607d1e84c072f4c9135ec69b61b5 | refs/heads/master | 2021-01-10T06:40:36.623921 | 2016-01-29T13:05:42 | 2016-01-29T13:05:42 | 44,977,609 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,733 | ino | #define in_1 5 // Left drive motor pin
#define in_2 10 // Left reverse motor pin
#define in_3 9 // Rigth drive motor pin
#define in_4 6 //Right reverse motor pin
#define xOR_LeftPin 3
#define xOR_RightPin 2
#define encoder_B_PinLeft 13
#define encoder_B_PinRight 4
int encoder_PosLeft = 0;
int encoder_PosRight = 0;
int encoder_PrevPos_Left;
int encoder_PrevPos_Right;
int xOR_Value_Left;
int xOR_Value_Right;
int xOR_PrevValue_Left;
int xOR_PrevValue_Right;
int encoder_B_Value_Left = HIGH;
int encoder_B_Value_Right;
int encoder_B_PrevValue_Left;
int encoder_B_PrevValue_Right;
int encoder_A_Value_Left = HIGH;
int encoder_A_Value_Right;
int encoder_A_PrevValue_Left;
int encoder_A_PrevValue_Right;
//int encoderPrevPosLeft = 0;
//int encoderPrevPosRight = 0;
int ticksPies = 832;
int ticksUnidad = 453;
int pies =4;
boolean start = true;
int pwm =180;
double unidad = 12; // pulgadas
int ticksIdeal = pies * ticksPies;
int ticksCalculadosLeft;
int ticksCalculadosRight;
void setup() {
// put your setup code here, to run once:
pinMode (in_1, OUTPUT);
pinMode (in_2, OUTPUT);
pinMode (in_3, OUTPUT);
pinMode (in_4, OUTPUT);
pinMode(encoder_B_PinLeft, INPUT);
pinMode(encoder_B_PinRight, INPUT);
pinMode(xOR_LeftPin, INPUT);
digitalWrite(xOR_LeftPin , HIGH);
pinMode(xOR_RightPin, INPUT);
digitalWrite(xOR_RightPin, HIGH);
attachInterrupt(digitalPinToInterrupt(xOR_LeftPin), readxORLeft, CHANGE);
attachInterrupt(digitalPinToInterrupt(xOR_RightPin), readxORRight, CHANGE);
Serial.begin(9600);
forward(true,true);
}
void loop() {
// put your main code here, to run repeatedly:
ticksCalculadosLeft = encoder_PosLeft;
ticksCalculadosRight = encoder_PosRight;
reviserLeft();
reviserRight();
checkEncoders();
//printEncoderValue();
}
void reviserLeft() {
if (ticksIdeal != ticksCalculadosLeft)
equalizerLeft();
}
void equalizerLeft() {
if (ticksIdeal - ticksCalculadosLeft > 0)
forward(true, false);
else if (ticksIdeal - ticksCalculadosLeft < 0)
reverse(true, false);
else
pause(true, false);
}
void reviserRight() {
if (ticksIdeal != ticksCalculadosRight)
equalizerRight();
}
void equalizerRight() {
if (ticksIdeal - ticksCalculadosRight > 0)
forward(false, true);
else if (ticksIdeal - ticksCalculadosRight < 0)
reverse(false, true);
else
pause(false, true);
}
void readxORLeft () {
xOR_PrevValue_Left = xOR_Value_Left;
encoder_A_PrevValue_Left = encoder_A_Value_Left;
encoder_B_PrevValue_Left = encoder_B_Value_Left;
xOR_Value_Left = digitalRead(xOR_LeftPin);
encoder_B_Value_Left = digitalRead(encoder_B_PinLeft);
encoder_A_Value_Left = xOR_Value_Left ^ encoder_B_Value_Left;
encoder_PrevPos_Left = encoder_PosLeft;
if ((encoder_B_Value_Left ^ encoder_A_PrevValue_Left) & ~(encoder_A_Value_Left ^ encoder_B_PrevValue_Left)) {
encoder_PosLeft++;
}
else {
encoder_PosLeft--;
}
}
void readxORRight() {
xOR_PrevValue_Right = xOR_Value_Right;
encoder_A_PrevValue_Right = encoder_A_Value_Right;
encoder_B_PrevValue_Right = encoder_B_Value_Right;
xOR_Value_Right = digitalRead(xOR_RightPin);
encoder_B_Value_Right = digitalRead(encoder_B_PinRight);
encoder_A_Value_Right = xOR_Value_Right ^ encoder_B_Value_Right;
encoder_PrevPos_Right = encoder_PosRight;
if ((encoder_B_Value_Right ^ encoder_A_PrevValue_Right) & ~(encoder_A_Value_Right ^ encoder_B_PrevValue_Right)) {
encoder_PosRight--;
}
else {
encoder_PosRight++;
}
}
void printEncoderValue() {
Serial.print("Left Encoder is: ");
Serial.print(" ");
Serial.print(encoder_PosLeft);
Serial.print(" ");
Serial.print(" Right Encoder is: ");
Serial.print(" ");
Serial.println(encoder_PosRight);
}
void forward(boolean left, boolean right) {
if (left) {
analogWrite(in_1, pwm);
}
if (right) {
analogWrite(in_3, pwm);
}
}
void reverse(boolean left, boolean right) {
if (left) {
analogWrite(in_2, pwm);
}
if (right) {
analogWrite(in_4, pwm);
}
}
void pause(boolean left, boolean right) {
if (left) {
digitalWrite(in_1, LOW);
}
digitalWrite(in_2, LOW);
if (right) {
digitalWrite(in_3, LOW);
}
digitalWrite(in_4, LOW);
}
void left() {
analogWrite(in_1, 0);
analogWrite(in_2, 0);
analogWrite(in_3, pwm);
analogWrite(in_4, 0);
}
void right() {
analogWrite(in_1, pwm);
analogWrite(in_2, 0);
analogWrite(in_3, 0);
analogWrite(in_4, 0);
}
void checkEncoders() {
if (encoder_PosRight < encoder_PosLeft) {
forward(true, false);
}
else if (encoder_PosRight > encoder_PosLeft) {
forward(false, true);
}
else
forward(true, true);
}
| [
"mikaeldelvalle@Mikaels-MBP.cpe.libertypr.com"
] | mikaeldelvalle@Mikaels-MBP.cpe.libertypr.com |
8fd5c8451d027a0907e326ad0834cbd207b1cda5 | a7b78ab632b77d1ed6b7e1fa46c33eda7a523961 | /test/core/test2.4.3/test.cc | 066d429e9ad8bd657f971b0898fa453447653003 | [
"BSD-2-Clause"
] | permissive | frovedis/frovedis | 80b830da4f3374891f3646a2298d71a3f42a1b2d | 875ae298dfa84ee9815f53db5bf7a8b76a379a6f | refs/heads/master | 2023-05-12T20:06:44.165117 | 2023-04-29T08:30:36 | 2023-04-29T08:30:36 | 138,103,263 | 68 | 13 | BSD-2-Clause | 2018-12-20T10:46:53 | 2018-06-21T01:17:51 | C++ | UTF-8 | C++ | false | false | 815 | cc | #include <frovedis.hpp>
#define BOOST_TEST_MODULE FrovedisTest
#include <boost/test/unit_test.hpp>
using namespace frovedis;
using namespace std;
std::vector<int> duplicate(int i) {
std::vector<int> v;
v.push_back(i); v.push_back(i);
return v;
}
BOOST_AUTO_TEST_CASE( frovedis_test )
{
int argc = 1;
char** argv = NULL;
use_frovedis use(argc, argv);
// filling sample input and output vectors
std::vector<int> v, ref_out;
for(size_t i = 1; i <= 8; i++) v.push_back(i);
for(size_t i = 1; i <= 8; i++) {
ref_out.push_back(i);
ref_out.push_back(i);
}
// testing for dvector::flat_map
auto d1 = frovedis::make_dvector_scatter(v);
auto d2 = d1.flat_map(duplicate);
auto r = d2.gather();
// confirming flattened vector with expected output
BOOST_CHECK(r == ref_out);
}
| [
"t-araki@dc.jp.nec.com"
] | t-araki@dc.jp.nec.com |
695f8caa3a3d984bc919fd0de36035eee7fbb281 | 0a708978050bca0c4bd51183614f83344918f900 | /Recursion/03_Spiral_Matrix/Cpp/main.cpp | c5d3d6712a2255d8bcb8b3cc0888bdb11fbd3a6d | [] | no_license | UHM-PANDA/Mock-Interview-Problems | f34d71ae58ddf609952bfa3eabd77b8eeb31e17b | db526f1ffa676878d7955b57560c4e37ef638156 | refs/heads/main | 2023-03-20T18:22:47.360198 | 2021-03-11T11:52:00 | 2021-03-11T11:52:00 | 305,627,179 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 231 | cpp | #include <iostream>
#inlcude <vector>
#include "spiral.hpp"
int main(int artgc, char** argv){
std::vector<std::vector<int>> in = {{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}};
spiral_matrix(in);
return 0;
} | [
"kgooding@hawaii.edu"
] | kgooding@hawaii.edu |
94ee135c52670f28ed6731c16ac4e2c6d8dd7a77 | a4515918f56dd7ab527e4999aa7fce818b6dd6f6 | /Algorithms/Search/Linear_search.cpp | 897bcf357ee8e7709bd5d43d0740d0fb91db3c4b | [
"MIT"
] | permissive | rathoresrikant/HacktoberFestContribute | 0e2d4692a305f079e5aebcd331e8df04b90f90da | e2a69e284b3b1bd0c7c16ea41217cc6c2ec57592 | refs/heads/master | 2023-06-13T09:22:22.554887 | 2021-10-27T07:51:41 | 2021-10-27T07:51:41 | 151,832,935 | 102 | 901 | MIT | 2023-06-23T06:53:32 | 2018-10-06T11:23:31 | C++ | UTF-8 | C++ | false | false | 630 | cpp | #include<iostream>
#include<algorithm>
using namespace std;
int main()
{
unsigned long long int n,i,*arr;
long long int x;
int flag=1;
cout<<"Enter the size of the array which you want to search: ";
cin>>n;
arr= new long long int [n];
for(i=0;i<n;i++)
{
cin>>arr[i];
}
//not sorting as it will take nlog(n) instead of n incase of searching without sorting
cout<<endl<<"Enter the number to search: ";
cin>>x;
for(i=0;i<n;i++)
{
if(arr[i]==x)
{
cout<<"The point is present in position "<<i;
flag=0;
break;
}
}
if(flag==1)
{
cout<<"The point is not present"<<endl;
}
delete [] arr;
return 0;
} | [
"thearkamitra@gmail.com"
] | thearkamitra@gmail.com |
73bc0daba4fdd31ee59de753db52a41a3d310493 | a3d6556180e74af7b555f8d47d3fea55b94bcbda | /content/browser/android/additional_navigation_params_utils.cc | c1e04d1e5098047eb7fd135e9b4e7e7d431eaa46 | [
"BSD-3-Clause"
] | permissive | chromium/chromium | aaa9eda10115b50b0616d2f1aed5ef35d1d779d6 | a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c | refs/heads/main | 2023-08-24T00:35:12.585945 | 2023-08-23T22:01:11 | 2023-08-23T22:01:11 | 120,360,765 | 17,408 | 7,102 | BSD-3-Clause | 2023-09-10T23:44:27 | 2018-02-05T20:55:32 | null | UTF-8 | C++ | false | false | 3,263 | cc | // Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/android/additional_navigation_params_utils.h"
#include "base/android/unguessable_token_android.h"
#include "base/numerics/safe_conversions.h"
#include "content/public/android/content_jni_headers/AdditionalNavigationParamsUtils_jni.h"
namespace content {
base::android::ScopedJavaLocalRef<jobject> CreateJavaAdditionalNavigationParams(
JNIEnv* env,
base::UnguessableToken initiator_frame_token,
int initiator_process_id,
absl::optional<base::UnguessableToken> attribution_src_token,
absl::optional<network::AttributionReportingRuntimeFeatures>
runtime_features) {
return Java_AdditionalNavigationParamsUtils_create(
env,
base::android::UnguessableTokenAndroid::Create(env,
initiator_frame_token),
initiator_process_id,
attribution_src_token ? base::android::UnguessableTokenAndroid::Create(
env, attribution_src_token.value())
: nullptr,
runtime_features ? runtime_features->ToEnumBitmask() : 0);
}
absl::optional<blink::LocalFrameToken>
GetInitiatorFrameTokenFromJavaAdditionalNavigationParams(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& j_object) {
if (!j_object) {
return absl::nullopt;
}
auto optional_token =
base::android::UnguessableTokenAndroid::FromJavaUnguessableToken(
env, Java_AdditionalNavigationParamsUtils_getInitiatorFrameToken(
env, j_object));
if (optional_token) {
return blink::LocalFrameToken(optional_token.value());
}
return absl::nullopt;
}
int GetInitiatorProcessIdFromJavaAdditionalNavigationParams(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& j_object) {
if (!j_object) {
return false;
}
return Java_AdditionalNavigationParamsUtils_getInitiatorProcessId(env,
j_object);
}
absl::optional<blink::AttributionSrcToken>
GetAttributionSrcTokenFromJavaAdditionalNavigationParams(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& j_object) {
if (!j_object) {
return absl::nullopt;
}
auto java_token = Java_AdditionalNavigationParamsUtils_getAttributionSrcToken(
env, j_object);
if (!java_token) {
return absl::nullopt;
}
auto optional_token =
base::android::UnguessableTokenAndroid::FromJavaUnguessableToken(
env, java_token);
if (optional_token) {
return blink::AttributionSrcToken(optional_token.value());
}
return absl::nullopt;
}
network::AttributionReportingRuntimeFeatures
GetAttributionRuntimeFeaturesFromJavaAdditionalNavigationParams(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& j_object) {
if (!j_object) {
return network::AttributionReportingRuntimeFeatures();
}
return network::AttributionReportingRuntimeFeatures::FromEnumBitmask(
base::checked_cast<uint64_t>(
Java_AdditionalNavigationParamsUtils_getAttributionRuntimeFeatures(
env, j_object)));
}
} // namespace content
| [
"chromium-scoped@luci-project-accounts.iam.gserviceaccount.com"
] | chromium-scoped@luci-project-accounts.iam.gserviceaccount.com |
67d9b014346ee1f1ecce697fb7edbeae410b94b2 | 1af656c548d631368638f76d30a74bf93550b1d3 | /chrome/browser/ui/ash/chrome_keyboard_ui_unittest.cc | 01f2c211ee8067e4f9dadc81e4712fefe8c4ee32 | [
"BSD-3-Clause"
] | permissive | pineal/chromium | 8d246c746141ef526a55a0b387ea48cd4e7d42e8 | e6901925dd5b37d55accbac55564f639bf4f788a | refs/heads/master | 2023-03-17T05:50:14.231220 | 2018-10-24T20:11:12 | 2018-10-24T20:11:12 | 154,564,128 | 1 | 0 | NOASSERTION | 2018-10-24T20:20:43 | 2018-10-24T20:20:43 | null | UTF-8 | C++ | false | false | 1,388 | cc | // Copyright 2017 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.
#include "chrome/browser/ui/ash/chrome_keyboard_ui.h"
#include <memory>
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/test_chrome_web_ui_controller_factory.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_controller.h"
#include "url/gurl.h"
namespace {
class ChromeKeyboardUITest : public ChromeRenderViewHostTestHarness {
public:
ChromeKeyboardUITest() = default;
~ChromeKeyboardUITest() override = default;
void SetUp() override {
ChromeRenderViewHostTestHarness::SetUp();
chrome_keyboard_ui_ = std::make_unique<ChromeKeyboardUI>(profile());
}
void TearDown() override {
chrome_keyboard_ui_.reset();
ChromeRenderViewHostTestHarness::TearDown();
}
protected:
std::unique_ptr<ChromeKeyboardUI> chrome_keyboard_ui_;
};
} // namespace
// Ensure ChromeKeyboardContentsDelegate is successfully constructed and has
// a valid aura::Window after calling LoadKeyboardWindow().
TEST_F(ChromeKeyboardUITest, ChromeKeyboardContentsDelegate) {
aura::Window* window =
chrome_keyboard_ui_->LoadKeyboardWindow(base::DoNothing());
EXPECT_TRUE(window);
}
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.