blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
5
146
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
7
license_type
stringclasses
2 values
repo_name
stringlengths
6
79
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
4 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.07k
426M
star_events_count
int64
0
27
fork_events_count
int64
0
12
gha_license_id
stringclasses
3 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
6 values
src_encoding
stringclasses
26 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
1 class
length_bytes
int64
20
6.28M
extension
stringclasses
20 values
content
stringlengths
20
6.28M
authors
sequencelengths
1
16
author_lines
sequencelengths
1
16
2dbe2652a57d0747e7857e4b8b317e0377dc28e4
2112057af069a78e75adfd244a3f5b224fbab321
/branches/refactor/src_root/include/common/file/file.h
8a2337303c8899658172eaee610c4f008c1ea58a
[]
no_license
blockspacer/ireon
120bde79e39fb107c961697985a1fe4cb309bd81
a89fa30b369a0b21661c992da2c4ec1087aac312
refs/heads/master
2023-04-15T00:22:02.905112
2010-01-07T20:31:07
2010-01-07T20:31:07
null
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
6,405
h
/* Copyright (C) 2005 ireon.org developers council * portions (C) Radon Labs GmbH, www.nebuladevice.org * $Id: file.h 304 2005-11-26 21:24:27Z llyeli $ * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ /** * @file file.h * Crossplatform file wrapper. */ #ifndef _FILE_H #define _FILE_H #include "file/filetime.h" #ifdef __XBxX__ #include "xbox/nxbwrapper.h" #elif defined(__WIN32__) #define WIN32_LEAN_AND_MEAN #include <winbase.h> #else #include <stdio.h> #endif class CFS; //------------------------------------------------------------------------------ class CFile { public: CFile(); /// destructor virtual ~CFile(); public: /// start point for seeking in file enum SeekType { CURRENT, START, END, }; /// does the file physically exist on disk? virtual bool exists(const char* fileName) const; /// opens a file virtual bool open(const char* fileName, const char* accessMode); /// closes the file virtual void close(); /// writes some bytes to the file virtual int write(const void* buffer, int numBytes); /// reads some bytes from the file virtual int read(void* buffer, int numBytes); /// gets actual position in file virtual int tell() const; /// sets new position in file virtual bool seek(int byteOffset, SeekType origin); /// is the file at the end virtual bool eof() const; /// get size of file in bytes virtual int getSize() const; /// writes a String to the file bool putS(const char* buffer); /// reads a String from the file String getS(int numChars); /// get current line number (incremented by PutS() and GetS()) int getLineNumber() const; /// determines whether the file is opened bool isOpen() const; /// append one file to another file virtual int appendFile(CFile* other); /// get the last write time virtual FileTime getLastWriteTime() const; /// write a 32bit int to the file void putInt(int &val); /// write a 16bit int to the file void putShort(short &val); /// write a 8bit int to the file void putChar(char &val); /// write a float to the file void putFloat(float &val); /// write a double to the file void putDouble(double &val); /// read a 32 bit int from the file void getInt(int &val); /// read a signed 16 bit int from the file void getShort(short &val); /// read an unsigned 16 bit int from the file void getUShort(ushort &val); /// read a 8 bit int from the file void getChar(char &val); /// read a float from the file void getFloat(float &val); /// read a double from the file void getDouble(double &val); /// flush file void flush(); public: ///Operators // bool void wrt( bool b ) { putChar((char&)b); } void operator<<( bool& b ) { putChar((char&)b); } void operator>>( bool& b ) { getChar((char&)b); } // byte void wrt( byte b ) { putChar((char&)b); } void operator<<( byte& b ) { putChar((char&)b); } void operator>>( byte& b ) { getChar((char&)b); } // char void wrt( char c ) { putChar(c); } void operator<<( char& c ) { putChar(c); } void operator>>( char& c ) { getChar(c); } // ushort void wrt( ushort i ) { putShort((short&)i); } void operator<<( ushort& i ) { putShort((short&)i); } void operator>>( ushort& i ) { getUShort(i); } // short void wrt( short i ) { putShort(i); } void operator<<( short& i ) { putShort(i); } void operator>>( short& i ) { getShort(i); } // uint void wrt( uint i ) { putInt((int&)i); } void operator<<( uint& i ) { putInt((int&)i); } void operator>>( uint& i ) { getInt((int&)i); } // uint void wrt( unsigned long i ) { putInt((int&)i); } void operator<<( unsigned long& i ) { putInt((int&)i); } void operator>>( unsigned long& i ) { getInt((int&)i); } // int void wrt( int i ) { putInt(i); } void operator<<( int& i ) { putInt(i); } void operator>>( int& i ) { getInt(i); } // double void wrt( double i ) { write( (char*)&i, sizeof(i) ); } void operator<<( double& i ) { write((char*)&i, sizeof(i) ); } void operator>>( double& i ) { read((char*)&i,sizeof(i)); } // int64 void wrt( int64 i ) { write((char*)&i,sizeof(i)); } void operator<<( int64& i ) { write((char*)&i, sizeof(i) ); } void operator>>( int64& i ) { read((char*)&i, sizeof(i)); } // Строка void operator<<( const char* str ); void operator>>( char* str ); void operator<<( const String& str) { operator<<( str.c_str() ); } void operator>>( String& str ); int readStrLen(); protected: ushort m_lineNumber; bool m_isOpen; #ifdef __WIN32__ // win32 file handle HANDLE m_handle; #else // ansi c file pointer FILE* m_fp; #endif }; inline bool CFile::isOpen() const { return this->m_isOpen; } inline int CFile::getLineNumber() const { return this->m_lineNumber; } inline void CFile::putInt(int &val) { write(&val, sizeof(val)); } inline void CFile::putShort(short &val) { write(&val, sizeof(val)); } inline void CFile::putChar(char &val) { write(&val, sizeof(val)); } inline void CFile::putFloat(float &val) { write(&val, sizeof(val)); } inline void CFile::putDouble(double &val) { write(&val, sizeof(val)); } inline void CFile::getInt(int &val) { this->read(&val, sizeof(val)); } inline void CFile::getShort(short &val) { this->read(&val, sizeof(val)); } inline void CFile::getUShort(ushort &val) { this->read(&val, sizeof(val)); } inline void CFile::getChar(char &val) { this->read(&val, sizeof(val)); } inline void CFile::getFloat(float &val) { this->read(&val, sizeof(val)); } inline void CFile::getDouble(double &val) { this->read(&val, sizeof(val)); } #endif
[ [ [ 1, 249 ] ] ]
c35726672cf51a2e792dcd6a17d8b5b8c141c18e
44db48cc516623a52391749be8d2211427391969
/gingacc-mmi/include/DFBMultimodalInputEvent.h
e6f061b5eb6c1fa7abeaa3d78f99d7f3f8c29810
[]
no_license
wincax88/ginga-multimodal
d787052bc4b96006dfe63436b55ec0b2c882249c
4448fdb3043f7b8c0b8c6a6d6cf3f8179b8ecdf1
refs/heads/master
2021-01-17T21:03:58.222493
2011-10-17T13:55:03
2011-10-17T13:55:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,323
h
/****************************************************************************** Este arquivo eh parte da implementacao do ambiente declarativo do middleware Ginga (Ginga-NCL). Copyright (C) 2009 UFSCar/Lince, Todos os Direitos Reservados. Este programa eh software livre; voce pode redistribui-lo e/ou modificah-lo sob os termos da Licenca Publica Geral GNU versao 2 conforme publicada pela Free Software Foundation. Este programa eh distribuido na expectativa de que seja util, porem, SEM NENHUMA GARANTIA; nem mesmo a garantia implicita de COMERCIABILIDADE OU ADEQUACAO A UMA FINALIDADE ESPECIFICA. Consulte a Licenca Publica Geral do GNU versao 2 para mais detalhes. Voce deve ter recebido uma copia da Licenca Publica Geral do GNU versao 2 junto com este programa; se nao, escreva para a Free Software Foundation, Inc., no endereco 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. Para maiores informacoes: [email protected] http://www.ncl.org.br http://www.ginga.org.br http://lince.dc.ufscar.br http://www.icmc.usp.br/php/laboratorio.php?origem=icmc&id_lab=3&nat=icmc ****************************************************************************** This file is part of the declarative environment of middleware Ginga (Ginga-NCL) Copyright (C) 2009 UFSCar/Lince, Todos os Direitos Reservados. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for more details. You should have received a copy of the GNU General Public License version 2 along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA For further information contact: [email protected] [email protected] http://www.ncl.org.br http://www.ginga.org.br http://lince.dc.ufscar.br *******************************************************************************/ /** * @file DFBMultimodalInputEvent.h * @author Diogo de Carvalho Pedrosa * @author José Augusto Costa Martins Júnior * @date 29-01-10 */ #ifndef DFBMULTIMODALINPUTEVENT_H #define DFBMULTIMODALINPUTEVENT_H #include "../../gingacc-system/include/io/interface/input/dfb/DFBGInputEvent.h" using namespace ::br::pucrio::telemidia::ginga::core::system::io; #include <map> using namespace std; namespace br{ namespace ufscar{ namespace lince{ namespace ginga{ namespace core{ namespace mmi{ /** * Classe responsável por encapsular um MultimodalInputEvent em um DFBUserEvent * para permitir que esse tipo de evento também faça uso do uso do EventBuffer * já existente. */ class DFBMultimodalInputEvent : public DFBGInputEvent { public: /** * Constrói um evento multimodal de entrada. * @param event Evento do tipo DFBUserEvent. */ DFBMultimodalInputEvent(void* event); /** * Destrói um evento multimodal de entrada. */ ~DFBMultimodalInputEvent(); }; } } } } } } #endif /*DFBMULTIMODALINPUTEVENT_H*/
[ [ [ 1, 100 ] ] ]
0de6b87930fa2e5b10dc3168f9c1882b73dd924a
3970f1a70df104f46443480d1ba86e246d8f3b22
/imebra/src/imebra/include/transformsChain.h
21b7660302e5f279cf1c04c4c81a7b02b9090005
[]
no_license
zhan2016/vimrid
9f8ea8a6eb98153300e6f8c1264b2c042c23ee22
28ae31d57b77df883be3b869f6b64695df441edb
refs/heads/master
2021-01-20T16:24:36.247136
2009-07-28T18:32:31
2009-07-28T18:32:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,860
h
/* 0.0.46 Imebra: a C++ dicom library. Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 by Paolo Brandoli This program is free software; you can redistribute it and/or modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 for more details. You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 along with this program; If not, see http://www.gnu.org/licenses/ ------------------- If you want to use Imebra commercially then you have to buy the commercial license available at http://puntoexe.com After you buy the commercial license then you can use Imebra according to the terms described in the Imebra Commercial License Version 1. A copy of the Imebra Commercial License Version 1 is available in the documentation pages. Imebra is available at http://puntoexe.com The author can be contacted by email at [email protected] or by mail at the following address: Paolo Brandoli Preglov trg 6 1000 Ljubljana Slovenia */ /*! \file transformsChain.h \brief Declaration of the class transformsChain. */ #if !defined(imebraTransformsChain_5DB89BFD_F105_45e7_B9D9_3756AC93C821__INCLUDED_) #define imebraTransformsChain_5DB89BFD_F105_45e7_B9D9_3756AC93C821__INCLUDED_ #include <list> #include "transform.h" namespace puntoexe { namespace imebra { namespace transforms { /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /// \brief Executes a sequence of transforms. /// /// Before calling doTransform, specify the sequence /// by calling addTransform(). /// Each specified transforms take the output of the /// previous transform as input. /// /// When all the transforms have been defined, call /// endTransformsChain(). /// /// The first defined transform takes the input images /// defined in the transformsChain object, the last /// defined transforms uses the output images defined /// in the transformsChain object. /// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// class transformsChain: public transform { public: transformsChain(); // Declare an input image for the transform /////////////////////////////////////////////////////////// virtual void declareInputImage(long imageNumber, ptr<image> pInputImage); // Declare an output image for the transform /////////////////////////////////////////////////////////// virtual void declareOutputImage(long imageNumber, ptr<image> pOutputImage); // Set the dataset to use for the transformations /////////////////////////////////////////////////////////// virtual void declareDataSet(ptr<dataSet> pDataSet); // Start the transform /////////////////////////////////////////////////////////// virtual void doTransform(); /// \brief Add a transform to the transforms chain. /// /// The added transform will take the output of the /// previously added transform as an input image and will /// supply its output to the next added transform or as /// an output of the transformsChain if it is the /// last added transform. /// /// After all the transforms have been added the /// application must call endTransformsChain() before /// calling doTransform(). /// /// @param pTransform the transform to be added to /// transformsChain /// /////////////////////////////////////////////////////////// void addTransform(ptr<transform> pTransform); /// \brief Returns true if no transform has been defined /// /// @return true if the transforms chain is empty and will /// not perform any transformation /// /////////////////////////////////////////////////////////// virtual bool isEmpty(); /// \brief Tells to the transformsChain object that no more /// transforms will be added to the chain. /// /// This function MUST be called after all the transforms /// have been added to the chain by addTransform() and /// before calling doTransform(). /// /////////////////////////////////////////////////////////// void endTransformsChain(); protected: typedef std::list<ptr<transform> > tTransformsList; tTransformsList m_transformsList; bool m_bEndTransformsChainCalled; }; } // namespace transforms } // namespace imebra } // namespace puntoexe #endif // !defined(imebraTransformsChain_5DB89BFD_F105_45e7_B9D9_3756AC93C821__INCLUDED_)
[ [ [ 1, 152 ] ] ]
d3469314bd4eba2de7c9761f4e029c8361a4004b
1c84fe02ecde4a78fb03d3c28dce6fef38ebaeff
/Sound.h
637cf97d50a89797c6100b7df5808ef313798f81
[]
no_license
aadarshasubedi/beesiege
c29cb8c3fce910771deec5bb63bcb32e741c1897
2128b212c5c5a68e146d3f888bb5a8201c8104f7
refs/heads/master
2016-08-12T08:37:10.410041
2007-12-16T20:57:33
2007-12-16T20:57:33
36,995,410
0
0
null
null
null
null
UTF-8
C++
false
false
816
h
#ifndef SOUND_H_ #define SOUND_H_ #include <fmod.hpp> #include "SoundDesc.h" #include "CharacterAttribute.h" class NxVec3; class GameCharacter; class Sound : public CharacterAttribute { friend class SoundManager; NiDeclareRTTI; public: // plays sound void Play(); // pauses sound void Pause(); // resumes sound void Resume(); // stops sound void Stop(); // updates the sound's 3d attributes void Update(float fTime); private: // private Ctor / Dtor (to be used by SoundManager) Sound(GameCharacter *owner, SoundDescPtr spDesc, FMOD::Sound* sound); ~Sound(); // sound descriptor SoundDescPtr m_spDesc; // FMOD sound pointer FMOD::Sound* m_pFMODSound; // FMOD channel pointer FMOD::Channel* m_pFMODChannel; }; NiSmartPointer(Sound); #endif
[ [ [ 1, 43 ] ] ]
93a18811bafc61efd9fe6d3b65f682ceea6162fa
563e71cceb33a518f53326838a595c0f23d9b8f3
/v3/ProcCity/ProcCity/Util/Random.h
a2978cf45b81d5d5814270caf3b90e728686da9c
[]
no_license
fabio-miranda/procedural
3d937037d63dd16cd6d9e68fe17efde0688b5a0a
e2f4b9d34baa1315e258613fb0ea66d1235a63f0
refs/heads/master
2021-05-28T18:13:57.833985
2009-10-07T21:09:13
2009-10-07T21:09:13
39,636,279
1
1
null
null
null
null
UTF-8
C++
false
false
454
h
#ifndef RANDOM_H #define RANDOM_H #include <iostream> #include <ctime> #include <cstdlib> using namespace std; static class Random { public: static void Init(int seed){ //srand((unsigned)time(0)); srand(seed); } static int Next(int bottom, int top){ int range = (top - bottom) +1; int int_random = bottom + int(range * rand()/(RAND_MAX + 1.0)); return int_random; } }; #endif
[ "fabiom@01b71de8-32d4-11de-96ab-f16d9912eac9" ]
[ [ [ 1, 37 ] ] ]
fd30dd2d91b308162ec9f87e3c46b01263703e8e
2b22f15f98445a111743441075e8e6934eecf632
/MogreTool/MogreWpf.Interop/AssemblyInfo.cpp
fed5bccc7bb8f935150634ddef03914ee47d0a35
[]
no_license
andyhebear/likeleon
74c9270d6cf06e2d36816654d072e06913690e81
3e5695dead033cf3b72192d56ba48be7b7afd69a
refs/heads/master
2020-04-06T06:38:33.375592
2010-05-18T01:40:58
2010-05-18T01:40:58
41,660,347
1
0
null
null
null
null
UTF-8
C++
false
false
1,364
cpp
#include "stdafx.h" using namespace System; using namespace System::Reflection; using namespace System::Runtime::CompilerServices; using namespace System::Runtime::InteropServices; using namespace System::Security::Permissions; // // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. // [assembly:AssemblyTitleAttribute("MogreWpfInterop")]; [assembly:AssemblyDescriptionAttribute("")]; [assembly:AssemblyConfigurationAttribute("")]; [assembly:AssemblyCompanyAttribute("Fred Land")]; [assembly:AssemblyProductAttribute("MogreWpfInterop")]; [assembly:AssemblyCopyrightAttribute("Copyright (c) Fred Land 2008")]; [assembly:AssemblyTrademarkAttribute("")]; [assembly:AssemblyCultureAttribute("")]; // // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the value or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly:AssemblyVersionAttribute("1.0.*")]; [assembly:ComVisible(false)]; [assembly:CLSCompliantAttribute(true)]; [assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];
[ "likeleon@a2a70008-d901-af86-2ea6-1ad5e87d510c" ]
[ [ [ 1, 40 ] ] ]
f5e921003c8d4e34ee00c6f42b38a49838fa58ef
465943c5ffac075cd5a617c47fd25adfe496b8b4
/ATCRUN.CPP
da0e1e17dfe622f3755489bc21fbba5a0d46c9c7
[]
no_license
paulanthonywilson/airtrafficcontrol
7467f9eb577b24b77306709d7b2bad77f1b231b7
6c579362f30ed5f81cabda27033f06e219796427
refs/heads/master
2016-08-08T00:43:32.006519
2009-04-09T21:33:22
2009-04-09T21:33:22
172,292
1
0
null
null
null
null
UTF-8
C++
false
false
1,868
cpp
# include "atcrun.h" void ATCrun::Start (ExternalFileSys *FileSys){ clock_t start_t; ATC *atc; RadarScreen *Radar; CmndInput *Input; AirborneInformation *AirInfo; HoldingInformation *HoldingInfo; CrashInformation *CrashInfo; UpdatesScreen *UpdatesScr; TimeScreen *TimeScr; ScoreScreen *ScoreScr; char c; textmode (ATC_TEXT_MODE); textbackground (BLUE); clrscr (); atc = new ATC(FileSys->Enviro()); //Create Screens (must have THREE areas!) Radar = new RadarScreen (atc->Enviro()->Lmarks()); Input = new CmndInput (atc->Enviro()->Lmarks(), atc->Traf()); AirInfo = new AirborneInformation (atc->Traf()); HoldingInfo = new HoldingInformation (atc->Traf()); ScoreScr = new ScoreScreen(); TimeScr = new TimeScreen(); UpdatesScr = new UpdatesScreen(); CrashInfo = new CrashInformation(); Radar->Refresh(); start_t=clock(); do { assert (!atc->Traf()->Crashed()); Input->Update(); HoldingInfo->Refresh(); AirInfo->Refresh(); ScoreScr->Refresh (atc->Score()); UpdatesScr->Refresh (atc->NoOfUpdates()); while ((clock()-start_t)/CLK_TCK < (atc->Enviro()->TParameters()->UpdateInterval() * atc->NoOfUpdates()) && !atc->Termination()){ //enter commands Input->ProcessInput(); TimeScr->Refresh ((clock() - start_t)/CLK_TCK); } Radar->UnDisplayPlanes (atc->Traf()); atc->AdvanceSys(); //redraw screens Radar->DisplayPlanes (atc->Traf()); }while ( ! atc->Termination() ); //Crash message here if (ATCStatus::Finished == False) { CrashInfo->Display (atc->Traf()); } textmode (C80); _setcursortype (_NORMALCURSOR); clrscr(); // FileSys->UpdateTopTen(atc->Score(),(clock()-start_t)/CLK_TCK); delete atc; delete Radar; delete Input; delete AirInfo; delete HoldingInfo; }
[ [ [ 1, 95 ] ] ]
e07c4e16b9aa4e368d9e62645e422d8af4cfaf23
a92598d0a8a2e92b424915d2944212f2f13e7506
/PtRPG/Classes/Scene/GameScene.h
4e37455a188489c868b9408494f4993d2c3e7527
[ "MIT" ]
permissive
peteo/RPG_Learn
0cc4facd639bd01d837ac56cf37a07fe22c59211
325fd1802b14e055732278f3d2d33a9577608c39
refs/heads/master
2021-01-23T11:07:05.050645
2011-12-12T08:47:27
2011-12-12T08:47:27
2,299,148
2
0
null
null
null
null
UTF-8
C++
false
false
2,751
h
/* * GameScene.h * PtRPG * * Created by Peteo on 11-9-26. * Copyright 2011 The9. All rights reserved. * */ #ifndef __GAME_SCENE_H__ #define __GAME_SCENE_H__ #include "CCPlatformConfig.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #include "PtLink_Android.h" #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include "PtLink.h" #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) #include "PtLink.h" #endif #include "PtMap.h" #include "PtCharacter.h" #include "cocos2d.h" USING_NS_CC; #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) class GameScene : public CCLayer #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) class GameScene : public CCLayer ,public PhotonListener #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) class GameScene : public CCLayer ,public PhotonListener #endif { public: virtual ~GameScene(); // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone virtual bool init(); // there's no 'id' in cpp, so we recommand to return the exactly class pointer static cocos2d::CCScene* scene(); // implement the "static node()" method manually LAYER_NODE_FUNC(GameScene); virtual void registerWithTouchDispatcher(void); virtual bool ccTouchBegan(CCTouch* touch, CCEvent* event); virtual void ccTouchMoved(CCTouch* touch, CCEvent* event); virtual void ccTouchEnded(CCTouch* touch, CCEvent* event); private: PtMap *_tileMap; PtCharacter *_playerChar; CCRect _dDown1; CCRect _dDown2; CCRect _dUp1; CCRect _dUp2; CCRect _dLeft; CCRect _dRight; float _loopSpeed; CCArray *_npcarray; CCArray *_RemoteplayerArray; PtLink *_Link; bool _bIsEnterWorlded; private: // Camera Helper Methods void followPlayer(void * sender); void centerCamera(CCPoint point); void moveCameraByTile(CCPoint point ,int duration); void moveCameraToPos(CCPoint point ,int duration); // Textbox Actions void displayTextbox(CCString * displayText); // Map Change void mapChange(void * sender); // Methods for Event Checking void checkForEvent(); //void triggerNPCEvent(PtNpc * npc ,int lookDirection); // Loops and Tick Methods void gameLoop(ccTime dt); void textBoxUpdate(ccTime dt); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) public: void onOperationResponse(const ExitGames::OperationResponse& operationResponse); void onStatusChanged(int statusCode); void onEvent(const ExitGames::EventData& eventData); void debugReturn(PhotonPeer_DebugLevel debugLevel, const ExitGames::JString& string); #endif }; #endif // __GAME_SCENE_H__
[ [ [ 1, 118 ] ] ]
bbbe0017b8eef25d1c047008e8857252c2ba7475
71381bcdb9299e23b97fa4f28bcc868fa02c4c25
/model.h
e81206c39773a37b164f5f2d34f6c6ee87a3e4a3
[]
no_license
jsoffer/distsim
e00a95d9cd88ef60d8ad1092e684b78b7cc17e97
16fa0ab22f529ae2510961dec3c80a968eaa5c4b
refs/heads/master
2021-01-15T22:29:33.928018
2009-10-16T04:15:54
2009-10-16T04:15:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,019
h
// Archivo: model.h // intefaz de la clase 'Model' // R. Marcelin J. (02/08/99) // esta es una version modificada que extiende la definicion de la clase // MODELO, para permitir la concatenacion de automatas (29/10/01). #if !defined(__MODEL_) #define __MODEL_ #include "event.h" #include "linklist.cc" //#include "intset.h" class Process; /* no puedo incluir process.h, dep. mutua */ class Model { public: Model(); // constructor ~Model(); // destructor virtual void init(); virtual void init(int pid); void transmit(Event *e); // envia evento void transmitAll(Event *e); virtual void receive(Event *e); // recibe event friend class Process; protected: Process *myProcess; // proceso a cargo int me; LinkList<int> *neighbors; LinkList<Model *> partners; // esta es la modificacion float clock; }; #endif
[ [ [ 1, 37 ] ] ]
2b059e2f01a4bae607b2e8f9663af1c9a177e004
7a310d01d1a4361fd06b40a74a2afc8ddc23b4d3
/src/MainFrame_Skin.cpp
232673ac9949ba8ee07b195036d0ca495e5b0e9e
[]
no_license
plus7/DonutG
b6fec6111d25b60f9a9ae5798e0ab21bb2fa28f6
2d204c36f366d6162eaf02f4b2e1b8bc7b403f6b
refs/heads/master
2020-06-01T15:30:31.747022
2010-08-21T18:51:01
2010-08-21T18:51:01
767,753
1
2
null
null
null
null
SHIFT_JIS
C++
false
false
8,444
cpp
/** * @file MainFrame_Skin.cpp * @brief CMainFrame の スキン関係の処理. * @note * +++ MainFrame.cpp から分離. */ #include "stdafx.h" #include "MainFrame.h" #if defined USE_ATLDBGMEM #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif // =========================================================================== // スキン関係 void CMainFrame::InitSkin() { setMainFrameBg(CSkinOption::s_nMainFrameBgColor); //+++ メインフレームのBg設定. initCurrentIcon(); //+++ アイコン m_CmdBar.setMenuBarStyle(m_hWndToolBar, false); //+++ メニュー (FEVATWHの短名にするか否か) m_MDITab.SetDrawStyle(CSkinOption::s_nTabStyle); //タブ m_ReBar.RefreshSkinState(); //ReBar m_wndStatusBar.ReloadSkin( CSkinOption::s_nStatusStyle //ステータスバー , CSkinOption::s_nStatusTextColor , CSkinOption::s_nStatusBackColor); setMainFrameCaptionSw(CSkinOption::s_nMainFrameCaption); //+++ メインフレームのキャプションの有無. } HRESULT CMainFrame::OnSkinChange() { InvalidateRect(NULL, TRUE); //メッセージをブロードキャストするべきか CSkinOption::GetProfile(); setMainFrameBg(CSkinOption::s_nMainFrameBgColor); //+++ メインフレームのBg設定. initCurrentIcon(); //+++ アイコン m_CmdBar.setMenuBarStyle(m_hWndToolBar, true); //+++ メニュー m_ReBar.RefreshSkinState(); //ReBar m_CmdBar.InvalidateRect(NULL, TRUE); //メニューバー m_MDITab.ReloadSkin(CSkinOption::s_nTabStyle); //タブ m_ToolBar.ReloadSkin(); //ツールバー m_AddressBar.ReloadSkin(CSkinOption::s_nComboStyle); //アドレスバー m_SearchBar.ReloadSkin(CSkinOption::s_nComboStyle); //検索バー m_LinkBar.InvalidateRect(NULL, TRUE); //リンクバー m_ExplorerBar.ReloadSkin(); //エクスプローラバー m_ExplorerBar.m_PanelBar.ReloadSkin(); //パネルバー m_ExplorerBar.m_PluginBar.ReloadSkin(); //プラグインバー m_wndStatusBar.ReloadSkin(CSkinOption::s_nStatusStyle //ステータスバー , CSkinOption::s_nStatusTextColor , CSkinOption::s_nStatusBackColor); setMainFrameCaptionSw(CSkinOption::s_nMainFrameCaption); //+++ キャプション //リフレッシュ InvalidateRect(NULL, TRUE); return 0; } #if 1 //+++ メインフレームのCaption on/off void CMainFrame::setMainFrameCaptionSw(int sw) { if (sw == 0) { //+++ キャプションを外す場合 ModifyStyle(WS_CAPTION, 0); } else { ModifyStyle(0, WS_CAPTION); //+++ キャプションをつける場合. } m_mcCmdBar.SetExMode(sw ? 0/*有*/ : m_hWnd/*無*/); SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED); } #endif ///+++ 現在のスキンのアイコンを(再)設定. /// ※ HICON の開放ってしなくてよい? 駄目でリークしてる?...winのリソース管理ってようわかんね.... void CMainFrame::initCurrentIcon() { //+++ xp ビジュアルスタイルを一時的にoff #if 1 //+++ uxtheme.dll の関数の呼び出し方を変更. UxTheme_Wrap::SetWindowTheme(m_hWnd, L" ", L" "); #else CTheme theme; theme.SetWindowTheme(m_hWnd, L" ", L" "); #endif /*static*/ HICON hIcon = 0; //if (hIcon) // ::CloseHandle(hIcon); //hIcon = 0; CString strDir = _GetSkinDir(); m_strIcon = strDir + "MainFrameBig.ico"; if (Misc::IsExistFile(m_strIcon) == 0) m_strIcon = strDir + "icon.ico"; if (Misc::IsExistFile(m_strIcon)) hIcon = (HICON)::LoadImage(ModuleHelper::GetResourceInstance(), m_strIcon, IMAGE_ICON, 32, 32, LR_SHARED|LR_LOADFROMFILE ); if (hIcon == 0) { m_strIcon.Empty(); hIcon = (HICON)::LoadImage(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR); } if (hIcon) ::SetClassLongPtr(m_hWnd, GCLP_HICON , (LONG_PTR)hIcon ); //::CloseHandle(hIcon); /*static*/ HICON hIconSm = 0; //if (hIconSm) // ::CloseHandle(hIconSm); //hIconSm = 0; m_strIconSm = strDir + "MainFrameSmall.ico"; if (Misc::IsExistFile(m_strIconSm) == 0) m_strIconSm = strDir + "icon.ico"; if (Misc::IsExistFile(m_strIconSm)) hIconSm = (HICON)::LoadImage(ModuleHelper::GetResourceInstance(), m_strIconSm, IMAGE_ICON, 16, 16, LR_SHARED|LR_LOADFROMFILE); if (hIconSm == 0) { m_strIconSm.Empty(); hIconSm = (HICON)::LoadImage(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); } if (hIconSm) ::SetClassLongPtr(m_hWnd, GCLP_HICONSM, (LONG_PTR)hIconSm ); //::CloseHandle(hIconSm); //+++ XPのビジュアルスタイルに戻す...これはいらないかも #if 1 //+++ uxtheme.dll の関数の呼び出し方を変更. UxTheme_Wrap::SetWindowTheme(m_hWnd, 0, 0); #else theme.SetWindowTheme(m_hWnd, 0, 0); #endif } //+++ メインフレームのBg設定. void CMainFrame::setMainFrameBg(int bgColor) { m_nBgColor = bgColor; CString strPath = _GetSkinDir() + _T("bg.bmp"); m_bmpBg.Attach( AtlLoadBitmapImage(strPath.GetBuffer(0), LR_LOADFROMFILE) ); } ///+++ bg描画 bool CMainFrame::drawMainFrameBg(HDC hDC) { #if 1 //+++ bgタイルのみ if (m_bmpBg.m_hBitmap) { // bg画像を敷き詰めて表示 DrawBmpBg_Tile(hDC); return 1; } else if (m_nBgColor >= 0) { // 色指定があれば、その色でべた塗り HBRUSH hBrushBg = CreateSolidBrush(COLORREF(m_nBgColor)); RECT rect; GetClientRect(&rect); ::FillRect( hDC, &rect, hBrushBg ); DeleteObject(hBrushBg); return 1; } return 0; #else //+++ 背景色とbgが同時に表示される必要があるとき if (m_nBgColor < 0 || m_bmpBg.m_hBitmap == 0) return 0; if (m_nBgColor >= 0) { HBRUSH hBrushBg = CreateSolidBrush(COLORREF(m_nBgColor)); RECT rect; GetClientRect(&rect); ::FillRect( hDC, &rect, hBrushBg ); DeleteObject(hBrushBg); } if (m_bmpBg.m_hBitmap) { //if (m_nBgStyle == SKIN_BG_STYLE_TILE) DrawBmpBg_Tile(hDC); //else if (m_nBGStyle == SKN_BG_STYLE_STRETCH) //DrawBmpBg_Stretch(hDC); } return 1; #endif } //+++ bg描画(敷き詰めるタイプ) void CMainFrame::DrawBmpBg_Tile(HDC hDC) { CRect rc; GetClientRect(&rc); CDC dcSrc; dcSrc.CreateCompatibleDC(hDC); HBITMAP hOldbmpSrc = dcSrc.SelectBitmap(m_bmpBg.m_hBitmap); SIZE size; m_bmpBg.GetSize(size); DWORD srcW = size.cx; DWORD srcH = size.cy; DWORD dstW = rc.Width(); DWORD dstH = rc.Height(); for (unsigned y = 0; y < dstH; y += srcH) { for (unsigned x = 0; x < dstW; x += srcW) { ::BitBlt(hDC, x, y, srcW, srcH, dcSrc, 0, 0, SRCCOPY); } } dcSrc.SelectBitmap(hOldbmpSrc); } #if 0 //+++ 画面の更新がようわからないので、拡縮は止め //+++ 元画像を拡大して表示. void CMainFrame::DrawBmpBg_Stretch(HDC hDC) { CRect rc; GetClientRect(&rc); #if 0 InvalidateRect(rc, TRUE); UpdateWindow(); #endif CDC dcSrc; dcSrc.CreateCompatibleDC(hDC); HBITMAP hOldbmpSrc = dcSrc.SelectBitmap(m_bmpBg.m_hBitmap); SIZE size; m_bmpBg.GetSize(size); DWORD srcW = size.cx; DWORD srcH = size.cy; double srcR = double(srcW) / double(srcH); DWORD dstW = rc.Width(); DWORD dstH = rc.Height(); double dstR = double(dstW) / double(dstH); if (dstR > srcR) { //+++ 描画範囲のほうが、元画像よりも横長 srcH = DWORD( srcH * srcR / dstR ); } else if (dstR < srcR) { //+++ 描画範囲のほうが、元画像よりも縦長 srcW = DWORD( srcW * dstR / srcR ); } ::StretchBlt(hDC, 0, 0, dstW, dstH, dcSrc , 0, 0, srcW, srcH, SRCCOPY); dcSrc.SelectBitmap(hOldbmpSrc); //ValidateRect(NULL); } #endif //public: #if 0 //+++ あとで HICON CMainFrame::LoadIcon4AboutDialog() { int w = ::GetSystemMetrics(SM_CXICON); int h = ::GetSystemMetrics(SM_CYICON); HICON hIcon = 0; #if 1 if (IsExistFile(m_strIcon)) hIcon = (HICON)::LoadImage(ModuleHelper::GetResourceInstance(), m_strIcon, IMAGE_ICON, w, h, LR_SHARED|LR_LOADFROMFILE); if (hIcon == 0) #endif hIcon = (HICON)::LoadImage(ModuleHelper::GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, w, h, LR_DEFAULTCOLOR ); return hIcon; } #endif
[ [ [ 1, 270 ] ] ]
c27cd4c39d57547fd3a541e13c82ace8eb806828
c3179c7c5b2f2fa84498f6b645563e5a7a04f17b
/shared/fileio/fileio.h
e22b8ae253a650c9bb3ce063ba5109fa8e3082e6
[]
no_license
joshmg/key
843214a5f8b5f60124cf94b7fe1fe82e46b575a8
02b634d26e7b4ec8346de318cec0641bc6bb52cd
refs/heads/master
2021-01-01T17:05:36.078466
2010-09-30T06:03:55
2010-09-30T06:03:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,746
h
// File: fileio.h // Written by Joshua Green #ifndef FILEIO_H #define FILEIO_H #include <string> #pragma comment(lib, "shared/fileio/fileio.lib") // -------------------------------------------------------------- CLASS FILEIO -------------------------------------------------------------- // // + open(string filename) // // + close() // // + is_open() // // + write(string data) // // + write(int data) // // + pos() // // - returns the current file position within the file // // + seek(long long int pos) // // - sets the current file position within the file // // - returns the current file position successfully set within the file // // + seek(string "END") // // - sets the current file position to the end of the file // // - the only acceptable value is "END" // // - returns the current file position successfully set within the file // // + read(long int length, string delim="") // // - reads length characters from current file position or until delim is reached // // - advances the file position pointer // // - if left empty, delim isn't checked // // - delim can be a string of characters or a single character // // - a length value of less than zero is replaced with the size of the file // // + size() // // - returns the size of the file // // + flush() // // - forces all modified data from buffer to the file // // + filename() // // - returns the name of the file // // + rm() // // - aborts any modified buffers from being written // // - closes the file // // - removes the file permanantly from the hard disk // // + mv(string new_name) // // - permanantly renames the file on the hard disk to new_name // // + NOTES: // // - the read and write buffer sizes can be set by modifying BUFFER_SIZE within fileio // // ------------------------------------------------------------------------------------------------------------------------------------------ // class fileio { private: FILE* _file; long long int _size; // size of the actual file long long int _pointer; // the user's position in the file (extendable by buffer) bool _open; static const int BUFFER_SIZE = 1024*5; int _bufferfilled; // bytes used inside _buffer char *_buffer; // data queued for writing char *_rdbuffer; // data queued for reading long long int _rdpos; // position in file where _rdbuffer starts int _rdfilled; // bytes used inside _rdbuffer std::string _filename; // stored filename long long int _put(char* data, int size); void _refresh_size(); void _flush(); void _open_file(const std::string&, const std::string&); void _clear(); public: fileio(); ~fileio(); bool open(std::string filename); bool open(std::string filename, std::string mode); void close(); bool is_open(); // Writes to a buffer until buffer overflow: long long int write(const std::string &data); long long int write(int data); long long int pos(); long long int seek(long long int pos); long long int seek(std::string pos); std::string read(long int length, std::string delim=""); std::string read(long int length, char delim); long long int size(); long long int flush(); std::string filename(); void rm(); // Remove/Delete void mv(const std::string &new_name); // Move/Rename // Debug Functions: void file_dump(); void fpos_dump(); void buffer_dump(); void data_dump(); }; // class handles deliminator checking class delim_checker { private: std::string _delim, _matched; int index; public: delim_checker(const std::string &delim); bool found(); // found() returns false if delim length is zero bool next(char c); // returns true if delim is matched, appends c to delim void clean(std::string &data); // removes delim from data void reset(); // resets delim_checker to unitialized delim void set(const std::string &delim); // set the delim after a reset or empty initialization }; #endif
[ [ [ 1, 110 ] ] ]
ed6a3b026e641dd0227bb723018434610d486f4a
0f40e36dc65b58cc3c04022cf215c77ae31965a8
/src/apps/wiseml/examples/wiseml_example_processor.h
a2084b3b952ed11a3888750dd9eaa58ccf46c3f2
[ "MIT", "BSD-3-Clause" ]
permissive
venkatarajasekhar/shawn-1
08e6cd4cf9f39a8962c1514aa17b294565e849f8
d36c90dd88f8460e89731c873bb71fb97da85e82
refs/heads/master
2020-06-26T18:19:01.247491
2010-10-26T17:40:48
2010-10-26T17:40:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,636
h
/************************************************************************ ** This file is part of the network simulator Shawn. ** ** Copyright (C) 2004-2010 by the SwarmNet (www.swarmnet.de) project ** ** Shawn is free software; you can redistribute it and/or modify it ** ** under the terms of the BSD License. Refer to the shawn-licence.txt ** ** file in the root of the Shawn source tree for further details. ** ************************************************************************/ #ifndef __SHAWN_APPS_WISEML_EXAMPLES_PROCESSOR_H #define __SHAWN_APPS_WISEML_EXAMPLES_PROCESSOR_H #include "_apps_enable_cmake.h" #ifdef ENABLE_WISEML #ifdef ENABLE_EXAMPLES #include "apps/examples/processor/helloworld_processor.h" #include "apps/wiseml/sensors/wiseml_string_sensor.h" #include "apps/reading/sensors/sensor_keeper.h" #include <set> #include <string> using namespace std; namespace wiseml { /** * An example processor which shows how to use WiseML sensors. */ class WisemlExampleProcessor : public helloworld::HelloworldProcessor { public: WisemlExampleProcessor(); virtual ~WisemlExampleProcessor(); virtual void boot( void ) throw(); virtual void work( void ) throw(); protected: string old_value_; int writer_battery_; WisemlStringSensor* some_sensor_; SimulationController* sim_controller_; reading::SensorKeeper* sensor_keeper_; WisemlStringSensor* get_string_sensor(std::string capability); void value_changed(); }; } #endif #endif #endif
[ [ [ 1, 50 ] ] ]
1e06eb834afe075635f659746ed2d265e97ab25a
e183ce20fbe6db6d7459375dad4992d0c8ddbb8f
/FixedCamera.cpp
7ce7a148d23d2f78fca2207f1315a96dc02c97fe
[]
no_license
zinking/gedouyouxi
4303fc74c6e30cc1986bd216f0a190fa4788b085
25c07af3028aef1b11d5ada6180c871ce0f5406a
refs/heads/master
2021-01-23T06:35:39.166519
2008-08-05T09:09:03
2008-08-05T09:09:03
32,133,246
0
0
null
null
null
null
UTF-8
C++
false
false
177
cpp
#include "FixedCamera.h" FixedCamera::FixedCamera() { x = y = -100; z = 100; dx = dy = 50; dz = 0; ux = uy = 0; uz = 1; } FixedCamera::~FixedCamera() { }
[ "zinking3@a02204cc-6053-0410-81e9-d35f966e8b48" ]
[ [ [ 1, 15 ] ] ]
2379de9b7db50cc32582d44e3200e792784ba960
ef356dbd697546b63c1c4c866db4f410ecf1c226
/CACertStore.hpp
7189be85d19de784302f10409498983eae35ad8d
[]
no_license
jondos/Mix
d5e7ab0f6ca4858b300341fb17e56af9106ffb65
8e0ebd9490542472197eca4b7c9974618df6f1de
refs/heads/master
2023-09-03T12:55:23.983398
2010-01-04T14:52:26
2010-01-04T14:52:26
425,933,032
0
0
null
null
null
null
UTF-8
C++
false
false
2,578
hpp
/* Copyright (c) 2000, The JAP-Team 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 University of Technology Dresden, Germany 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 REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE */ #ifndef __CA_CERTSTORE__ #define __CA_CERTSTORE__ #ifndef ONLY_LOCAL_PROXY #include "CACertificate.hpp" #define XML_X509DATA 2 struct __t_certstore_list { CACertificate* pCert; struct __t_certstore_list* next; }; typedef struct __t_certstore_list CERTSTORE_ENTRY; typedef CERTSTORE_ENTRY* LP_CERTSTORE_ENTRY; class CACertStore { public: CACertStore(); ~CACertStore(); SINT32 add(CACertificate* cert); CACertificate* getFirst(); CACertificate* getNext(); UINT32 getNumber(){return m_cCerts;} CACertificate* verifyMixCert(DOMNode* mixNode); SINT32 encode(UINT8* buff,UINT32* bufflen,UINT32 type); SINT32 encode(DOMElement* & elemnRoot,XERCES_CPP_NAMESPACE::DOMDocument* doc); static CACertStore* decode(UINT8* buff,UINT32 bufflen,UINT32 type); static CACertStore* decode(const DOMNode* node, UINT32 type); private: LP_CERTSTORE_ENTRY m_pCertList; UINT32 m_cCerts; LP_CERTSTORE_ENTRY m_pCurrent; }; #endif #endif //ONLY_LOCAL_PROXY
[ "rolf@f4013887-1060-43d1-a937-9d2a4c6f27f8" ]
[ [ [ 1, 61 ] ] ]
ee13f36258ce3979665f6d316c90d950dde6e455
17306081dd4865faa69377c5fc7f6c11c676fac0
/UserInfo.h
f9e01093afaf43060e277f4af2c7ed4120cdfd43
[]
no_license
jongha/myfirstmate
e1ee3547c66481ba28114e0126c49ca7e6c604f4
1663df04b305b4110c12c57f8c9241fcd64088f1
refs/heads/master
2021-01-23T20:49:48.437887
2010-09-28T05:11:04
2010-09-28T05:11:04
32,111,906
0
0
null
null
null
null
UTF-8
C++
false
false
508
h
// UserInfo.h: interface for the CUserInfo class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_USERINFO_H__FAD6D1E7_9C59_4DE1_B2D7_15480783D2CB__INCLUDED_) #define AFX_USERINFO_H__FAD6D1E7_9C59_4DE1_B2D7_15480783D2CB__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 class CUserInfo { public: CUserInfo(); virtual ~CUserInfo(); }; #endif // !defined(AFX_USERINFO_H__FAD6D1E7_9C59_4DE1_B2D7_15480783D2CB__INCLUDED_)
[ [ [ 1, 19 ] ] ]
20de058a3ba89ad480d0ce0f8694684cfa3fce3a
4d5ee0b6f7be0c3841c050ed1dda88ec128ae7b4
/src/nvimage/openexr/src/IlmThread/IlmThreadWin32.cpp
5b067806f9d3788b61d6ed3e0ce2e5b2d937bad4
[]
no_license
saggita/nvidia-mesh-tools
9df27d41b65b9742a9d45dc67af5f6835709f0c2
a9b7fdd808e6719be88520e14bc60d58ea57e0bd
refs/heads/master
2020-12-24T21:37:11.053752
2010-09-03T01:39:02
2010-09-03T01:39:02
56,893,300
0
1
null
null
null
null
UTF-8
C++
false
false
2,851
cpp
/////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2005, Industrial Light & Magic, a division of Lucas // Digital Ltd. LLC // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Industrial Light & Magic nor the names of // its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // /////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- // // class Thread -- implementation for Windows // //----------------------------------------------------------------------------- #include "IlmThread.h" #include "Iex.h" #include <iostream> #include <assert.h> namespace IlmThread { bool supportsThreads () { return true; } namespace { unsigned __stdcall threadLoop (void * t) { reinterpret_cast<Thread*>(t)->run(); _endthreadex (0); return 0; } } // namespace Thread::Thread () { // empty } Thread::~Thread () { DWORD status = ::WaitForSingleObject (_thread, INFINITE); assert (status == WAIT_OBJECT_0); BOOL ok = ::CloseHandle (_thread); assert (ok); } void Thread::start () { unsigned id; _thread = (HANDLE)::_beginthreadex (0, 0, &threadLoop, this, 0, &id); if (_thread == 0) Iex::throwErrnoExc ("Cannot create new thread (%T)."); } } // namespace IlmThread
[ "castano@0f2971b0-9fc2-11dd-b4aa-53559073bf4c" ]
[ [ [ 1, 95 ] ] ]
fef45bca1f3fa01ef98c8764608b13e4a0abe390
10c14a95421b63a71c7c99adf73e305608c391bf
/gui/core/qset.h
84275b180ed293fbdb0d462794a4aa1b26a0fb11
[]
no_license
eaglezzb/wtlcontrols
73fccea541c6ef1f6db5600f5f7349f5c5236daa
61b7fce28df1efe4a1d90c0678ec863b1fd7c81c
refs/heads/master
2021-01-22T13:47:19.456110
2009-05-19T10:58:42
2009-05-19T10:58:42
33,811,815
0
0
null
null
null
null
UTF-8
C++
false
false
13,796
h
/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information ([email protected]) ** ** This file is part of the QtCore module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Commercial License Agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at [email protected]. ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QSET_H #define QSET_H // #include <QtCore/qhash.h> #include "core/qhash.h" QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Gui) template <class T> class QSet { typedef QHash<T, QHashDummyValue> Hash; public: inline QSet() {} inline QSet(const QSet<T> &other) : q_hash(other.q_hash) {} inline QSet<T> &operator=(const QSet<T> &other) { q_hash = other.q_hash; return *this; } inline bool operator==(const QSet<T> &other) const { return q_hash == other.q_hash; } inline bool operator!=(const QSet<T> &other) const { return q_hash != other.q_hash; } inline int size() const { return q_hash.size(); } inline bool isEmpty() const { return q_hash.isEmpty(); } inline int capacity() const { return q_hash.capacity(); } inline void reserve(int size); inline void squeeze() { q_hash.squeeze(); } inline void detach() { q_hash.detach(); } inline bool isDetached() const { return q_hash.isDetached(); } inline void setSharable(bool sharable) { q_hash.setSharable(sharable); } inline void clear() { q_hash.clear(); } inline bool remove(const T &value) { return q_hash.remove(value) != 0; } inline bool contains(const T &value) const { return q_hash.contains(value); } class const_iterator; class iterator { typedef QHash<T, QHashDummyValue> Hash; typename Hash::iterator i; friend class const_iterator; public: typedef std::bidirectional_iterator_tag iterator_category; typedef ptrdiff_t difference_type; typedef T value_type; typedef const T *pointer; typedef const T &reference; inline iterator() {} inline iterator(typename Hash::iterator o) : i(o) {} inline iterator(const iterator &o) : i(o.i) {} inline iterator &operator=(const iterator &o) { i = o.i; return *this; } inline const T &operator*() const { return i.key(); } inline const T *operator->() const { return &i.key(); } inline bool operator==(const iterator &o) const { return i == o.i; } inline bool operator!=(const iterator &o) const { return i != o.i; } inline bool operator==(const const_iterator &o) const { return i == o.i; } inline bool operator!=(const const_iterator &o) const { return i != o.i; } inline iterator &operator++() { ++i; return *this; } inline iterator operator++(int) { iterator r = *this; ++i; return r; } inline iterator &operator--() { --i; return *this; } inline iterator operator--(int) { iterator r = *this; --i; return r; } inline iterator operator+(int j) const { return i + j; } inline iterator operator-(int j) const { return i - j; } inline iterator &operator+=(int j) { i += j; return *this; } inline iterator &operator-=(int j) { i -= j; return *this; } }; class const_iterator { typedef QHash<T, QHashDummyValue> Hash; typename Hash::const_iterator i; friend class iterator; public: typedef std::bidirectional_iterator_tag iterator_category; typedef ptrdiff_t difference_type; typedef T value_type; typedef const T *pointer; typedef const T &reference; inline const_iterator() {} inline const_iterator(typename Hash::const_iterator o) : i(o) {} inline const_iterator(const const_iterator &o) : i(o.i) {} inline const_iterator(const iterator &o) : i(o.i) {} inline const_iterator &operator=(const const_iterator &o) { i = o.i; return *this; } inline const T &operator*() const { return i.key(); } inline const T *operator->() const { return &i.key(); } inline bool operator==(const const_iterator &o) const { return i == o.i; } inline bool operator!=(const const_iterator &o) const { return i != o.i; } inline const_iterator &operator++() { ++i; return *this; } inline const_iterator operator++(int) { const_iterator r = *this; ++i; return r; } inline const_iterator &operator--() { --i; return *this; } inline const_iterator operator--(int) { const_iterator r = *this; --i; return r; } inline const_iterator operator+(int j) const { return i + j; } inline const_iterator operator-(int j) const { return i - j; } inline const_iterator &operator+=(int j) { i += j; return *this; } inline const_iterator &operator-=(int j) { i -= j; return *this; } }; // STL style inline iterator begin() { return q_hash.begin(); } inline const_iterator begin() const { return q_hash.begin(); } inline const_iterator constBegin() const { return q_hash.constBegin(); } inline iterator end() { return q_hash.end(); } inline const_iterator end() const { return q_hash.end(); } inline const_iterator constEnd() const { return q_hash.constEnd(); } iterator erase(iterator i) { return q_hash.erase(reinterpret_cast<typename Hash::iterator &>(i)); } // more Qt typedef iterator Iterator; typedef const_iterator ConstIterator; inline int count() const { return q_hash.count(); } inline const_iterator insert(const T &value) // ### Qt 5: should return an 'iterator' { return static_cast<typename Hash::const_iterator>(q_hash.insert(value, QHashDummyValue())); } iterator find(const T &value) { return q_hash.find(value); } const_iterator find(const T &value) const { return q_hash.find(value); } inline const_iterator constFind(const T &value) const { return find(value); } QSet<T> &unite(const QSet<T> &other); QSet<T> &intersect(const QSet<T> &other); QSet<T> &subtract(const QSet<T> &other); // STL compatibility typedef T key_type; typedef T value_type; typedef value_type *pointer; typedef const value_type *const_pointer; typedef value_type &reference; typedef const value_type &const_reference; typedef ptrdiff_t difference_type; typedef int size_type; inline bool empty() const { return isEmpty(); } // comfort inline QSet<T> &operator<<(const T &value) { insert(value); return *this; } inline QSet<T> &operator|=(const QSet<T> &other) { unite(other); return *this; } inline QSet<T> &operator|=(const T &value) { insert(value); return *this; } inline QSet<T> &operator&=(const QSet<T> &other) { intersect(other); return *this; } inline QSet<T> &operator&=(const T &value) { QSet<T> result; if (contains(value)) result.insert(value); return (*this = result); } inline QSet<T> &operator+=(const QSet<T> &other) { unite(other); return *this; } inline QSet<T> &operator+=(const T &value) { insert(value); return *this; } inline QSet<T> &operator-=(const QSet<T> &other) { subtract(other); return *this; } inline QSet<T> &operator-=(const T &value) { remove(value); return *this; } inline QSet<T> operator|(const QSet<T> &other) const { QSet<T> result = *this; result |= other; return result; } inline QSet<T> operator&(const QSet<T> &other) const { QSet<T> result = *this; result &= other; return result; } inline QSet<T> operator+(const QSet<T> &other) const { QSet<T> result = *this; result += other; return result; } inline QSet<T> operator-(const QSet<T> &other) const { QSet<T> result = *this; result -= other; return result; } #if QT_VERSION < 0x050000 // ### Qt 5: remove inline QSet<T> operator|(const QSet<T> &other) { QSet<T> result = *this; result |= other; return result; } inline QSet<T> operator&(const QSet<T> &other) { QSet<T> result = *this; result &= other; return result; } inline QSet<T> operator+(const QSet<T> &other) { QSet<T> result = *this; result += other; return result; } inline QSet<T> operator-(const QSet<T> &other) { QSet<T> result = *this; result -= other; return result; } #endif QList<T> toList() const; inline QList<T> values() const { return toList(); } static QSet<T> fromList(const QList<T> &list); private: Hash q_hash; }; template <class T> Q_INLINE_TEMPLATE void QSet<T>::reserve(int asize) { q_hash.reserve(asize); } template <class T> Q_INLINE_TEMPLATE QSet<T> &QSet<T>::unite(const QSet<T> &other) { QSet<T> copy(other); typename QSet<T>::const_iterator i = copy.constEnd(); while (i != copy.constBegin()) { --i; insert(*i); } return *this; } template <class T> Q_INLINE_TEMPLATE QSet<T> &QSet<T>::intersect(const QSet<T> &other) { QSet<T> copy1(*this); QSet<T> copy2(other); typename QSet<T>::const_iterator i = copy1.constEnd(); while (i != copy1.constBegin()) { --i; if (!copy2.contains(*i)) remove(*i); } return *this; } template <class T> Q_INLINE_TEMPLATE QSet<T> &QSet<T>::subtract(const QSet<T> &other) { QSet<T> copy1(*this); QSet<T> copy2(other); typename QSet<T>::const_iterator i = copy1.constEnd(); while (i != copy1.constBegin()) { --i; if (copy2.contains(*i)) remove(*i); } return *this; } template <typename T> Q_OUTOFLINE_TEMPLATE QList<T> QSet<T>::toList() const { QList<T> result; typename QSet<T>::const_iterator i = constBegin(); while (i != constEnd()) { result.append(*i); ++i; } return result; } template <typename T> Q_OUTOFLINE_TEMPLATE QSet<T> QList<T>::toSet() const { QSet<T> result; result.reserve(size()); for (int i = 0; i < size(); ++i) result.insert(at(i)); return result; } template <typename T> QSet<T> QSet<T>::fromList(const QList<T> &list) { return list.toSet(); } template <typename T> QList<T> QList<T>::fromSet(const QSet<T> &set) { return set.toList(); } Q_DECLARE_SEQUENTIAL_ITERATOR(Set) template <typename T> class QMutableSetIterator { typedef typename QSet<T>::iterator iterator; QSet<T> *c; iterator i, n; inline bool item_exists() const { return n != c->constEnd(); } public: inline QMutableSetIterator(QSet<T> &container) : c(&container) { c->setSharable(false); i = c->begin(); n = c->end(); } inline ~QMutableSetIterator() { c->setSharable(true); } inline QMutableSetIterator &operator=(QSet<T> &container) { c->setSharable(true); c = &container; c->setSharable(false); i = c->begin(); n = c->end(); return *this; } inline void toFront() { i = c->begin(); n = c->end(); } inline void toBack() { i = c->end(); n = i; } inline bool hasNext() const { return c->constEnd() != i; } inline const T &next() { n = i++; return *n; } inline const T &peekNext() const { return *i; } inline bool hasPrevious() const { return c->constBegin() != i; } inline const T &previous() { n = --i; return *n; } inline const T &peekPrevious() const { iterator p = i; return *--p; } inline void remove() { if (c->constEnd() != n) { i = c->erase(n); n = c->end(); } } inline const T &value() const { Q_ASSERT(item_exists()); return *n; } inline bool findNext(const T &t) { while (c->constEnd() != (n = i)) if (*i++ == t) return true; return false; } inline bool findPrevious(const T &t) { while (c->constBegin() != i) if (*(n = --i) == t) return true; n = c->end(); return false; } }; QT_END_NAMESPACE QT_END_HEADER #endif // QSET_H
[ "zhangyinquan@0feb242a-2539-11de-a0d7-251e5865a1c7" ]
[ [ [ 1, 353 ] ] ]
a985dda67178a28011fbceed46b4512a1b479ed5
6465630c9428b9ac8edfd64c317304555714f26f
/HSN-Demo2/C-EntranceDet/TestServer.cpp
6cf3dd7bf118b94d1ab445ff092a06528b541e79
[]
no_license
vchu/ee125
738f51cd0b9ab41b936dbc1ce9da803acd35c1c2
59f9a1f84c08cfbe18bc844364c8df24294e8c1e
refs/heads/master
2021-01-13T01:49:00.218357
2008-11-20T23:49:03
2008-11-20T23:49:03
34,265,337
0
0
null
null
null
null
UTF-8
C++
false
false
1,824
cpp
#include "..\..\HSN-Demo2\C-Server\_Socket.h" #include <process.h> #include <string> #include <iostream> #include <fstream> #include <queue> #include <cstdlib> #include <direct.h> using namespace std; queue<char *> dataQueue; bool PathExists(char* pathtocheck) { int ret = _chdir(pathtocheck) ; return (ret == 0) ; } unsigned __stdcall Answer(void* a) { Socket* s = (Socket*) a; unsigned char r[1024] ; int len=0; while (1) { s->ReceiveBytes(len, r); printf("\n Len=%d\n",len); if (len==0 || len==-1) break; std::cout<<"\nClient sent:"; char* temp = (char *) malloc(len); for (int i = 0 ; i<len; i++){ printf("%d ",r[i]); temp[i] = r[i]; } dataQueue.push(temp); char* parseData = dataQueue.front(); int ID = parseData[0]; char* IDstr= (char *) malloc(4); char* folderpath= (char *) malloc(256); sprintf(IDstr, "%d", ID); sprintf(folderpath, "C:\\%s", IDstr); if(!PathExists(folderpath)){ mkdir(folderpath); } char * temp1 = (char *) malloc(256); sprintf(temp1, "%d", parseData[1]); char * filename = (char *) malloc(256); sprintf(filename, "%s\\%s", folderpath, temp1); printf("\n filename is: %s", filename); std::ofstream myFile (filename, ios::out | ios::binary); std::string blah= parseData; myFile.write (parseData, len); myFile.close(); //for (int j=0; j< len; j++){ // printf("%d ", test[j]); //} dataQueue.pop(); delete parseData; } delete s; return 0; } int main(int argc, char* argv[]) { std::cout<< "Initializing server at port 2000"; SocketServer in(2000,5); while (1) { printf("HeLLo thread"); Socket* s=in.Accept(); unsigned ret; printf("Good bye thread"); _beginthreadex(0,0,Answer,(void*) s,0,&ret); } return 0; }
[ "chemb0t@c7e5bc68-916c-11dd-99c3-0167725eca9f", "duckeegoboom@c7e5bc68-916c-11dd-99c3-0167725eca9f" ]
[ [ [ 1, 35 ], [ 37, 45 ], [ 47, 84 ] ], [ [ 36, 36 ], [ 46, 46 ] ] ]
7c7dc514cd0caa4e89ddcb601f8cdb2948c4b7d9
d752d83f8bd72d9b280a8c70e28e56e502ef096f
/FugueDLL/Virtual Machine/Operations/Variables/StructureOps.h
251d29518af0d382d4c96c9b2f494db0a2008ed1
[]
no_license
apoch/epoch-language.old
f87b4512ec6bb5591bc1610e21210e0ed6a82104
b09701714d556442202fccb92405e6886064f4af
refs/heads/master
2021-01-10T20:17:56.774468
2010-03-07T09:19:02
2010-03-07T09:19:02
34,307,116
0
0
null
null
null
null
UTF-8
C++
false
false
5,427
h
// // The Epoch Language Project // FUGUE Virtual Machine // // Operations for working with structures // #pragma once // Dependencies #include "Virtual Machine/Core Entities/Operation.h" #include "Virtual Machine/Core Entities/Types/Structure.h" namespace VM { namespace Operations { // // Operation for reading a member out of a structure // class ReadStructure : public Operation, public SelfAware<ReadStructure> { // Allow nested readstructure ops to peek into us for type information public: friend class ReadStructureIndirect; // Construction public: ReadStructure(const std::wstring& varname, const std::wstring& membername); // Operation interface public: virtual void ExecuteFast(ExecutionContext& context); virtual RValuePtr ExecuteAndStoreRValue(ExecutionContext& context); virtual EpochVariableTypeID GetType(const ScopeDescription& scope) const; virtual size_t GetNumParameters(const VM::ScopeDescription& scope) const { return 0; } // Additional inspection public: const std::wstring& GetAssociatedIdentifier() const { return VarName; } const std::wstring& GetMemberName() const { return MemberName; } // Internal tracking private: const std::wstring& VarName; const std::wstring& MemberName; }; // // Operation for reading a member out of a structure returned by an operation on the stack // class ReadStructureIndirect : public Operation, public SelfAware<ReadStructureIndirect> { // Construction public: ReadStructureIndirect(const std::wstring& membername, VM::Operation* priorop); // Operation interface public: virtual void ExecuteFast(ExecutionContext& context); virtual RValuePtr ExecuteAndStoreRValue(ExecutionContext& context); virtual EpochVariableTypeID GetType(const ScopeDescription& scope) const; virtual size_t GetNumParameters(const VM::ScopeDescription& scope) const { return 1; } // Additional helpers public: IDType WalkInstructionsForReadStruct(const ScopeDescription& scope, Operation* op) const; IDType WalkInstructionsForTypeHint(const ScopeDescription& scope) const; const std::wstring& GetMemberName() const { return MemberName; } // Internal tracking private: const std::wstring& MemberName; VM::Operation* PriorOp; }; // // Operation for writing a structure member's value // class AssignStructure : public Operation, public SelfAware<AssignStructure> { // Construction public: AssignStructure(const std::wstring& varname, const std::wstring& membername); // Operation interface public: virtual void ExecuteFast(ExecutionContext& context); virtual RValuePtr ExecuteAndStoreRValue(ExecutionContext& context); virtual EpochVariableTypeID GetType(const ScopeDescription& scope) const; virtual size_t GetNumParameters(const VM::ScopeDescription& scope) const { return 1; } // Additional inspection public: const std::wstring& GetAssociatedIdentifier() const { return VarName; } const std::wstring& GetMemberName() const { return MemberName; } // Internal tracking private: const std::wstring& VarName; const std::wstring& MemberName; }; // // Operation for writing a structure member's value // This variant allows us to write to reference-bound locations, // which makes nested structure manipulation possible. // class AssignStructureIndirect : public Operation, public SelfAware<AssignStructureIndirect> { // Construction public: AssignStructureIndirect(const std::wstring& membername); // Operation interface public: virtual void ExecuteFast(ExecutionContext& context); virtual RValuePtr ExecuteAndStoreRValue(ExecutionContext& context); virtual EpochVariableTypeID GetType(const ScopeDescription& scope) const; virtual size_t GetNumParameters(const VM::ScopeDescription& scope) const { return 2; } // Additional inspection public: const std::wstring& GetMemberName() const { return MemberName; } // Internal tracking private: const std::wstring& MemberName; }; // // Operation for binding a temporary reference to a structure member. // Primarily used for working with nested structures. // class BindStructMemberReference : public Operation, public SelfAware<BindStructMemberReference> { // Construction public: BindStructMemberReference(const std::wstring& membername); BindStructMemberReference(const std::wstring& varname, const std::wstring& membername); // Operation interface public: virtual void ExecuteFast(ExecutionContext& context); virtual RValuePtr ExecuteAndStoreRValue(ExecutionContext& context); virtual EpochVariableTypeID GetType(const ScopeDescription& scope) const; virtual size_t GetNumParameters(const VM::ScopeDescription& scope) const { return (Chained ? 1 : 0); } // Additional inspection public: const std::wstring& GetAssociatedIdentifier() const { return *VarName; } const std::wstring& GetMemberName() const { return MemberName; } bool IsChained() const { return Chained; } // Internal tracking private: const std::wstring* VarName; const std::wstring& MemberName; bool Chained; }; } }
[ "[email protected]", "don.apoch@localhost" ]
[ [ [ 1, 35 ], [ 38, 67 ], [ 70, 77 ], [ 79, 99 ], [ 102, 133 ], [ 136, 163 ], [ 166, 190 ] ], [ [ 36, 37 ], [ 68, 69 ], [ 78, 78 ], [ 100, 101 ], [ 134, 135 ], [ 164, 165 ] ] ]
b117ff62a419c2ebef89946883b647bd0845a1e5
6ee200c9dba87a5d622c2bd525b50680e92b8dab
/Autumn/WrapperDX/Texture/Sampler/Sampler.cpp
6b1c5031583b2437fdc4d63a21195c5bce23ce1c
[]
no_license
Ishoa/bizon
4dbcbbe94d1b380f213115251e1caac5e3139f4d
d7820563ab6831d19e973a9ded259d9649e20e27
refs/heads/master
2016-09-05T11:44:00.831438
2010-03-10T23:14:22
2010-03-10T23:14:22
32,632,823
0
0
null
null
null
null
UTF-8
C++
false
false
100
cpp
#include "stdafx.h" #ifndef _SAMPLER_ #include "WrapperDX/Texture/Sampler/Sampler.h" #endif
[ "edouard.roge@ab19582e-f48f-11de-8f43-4547254af6c6" ]
[ [ [ 1, 6 ] ] ]
ac756c5b943590c0ca98428e8192ebb60eec6388
f2385a5a332401269b27f91a9d259c2395c3016c
/AirHockey_FinalFramework/pospeskometer/Pak.cpp
6909db8d1a5443c4a9db9aa7af09b14103ef22e9
[]
no_license
mohamedAAhassan/airhockey
33fe436131f6f693425ba3e83da2f53605388aac
35ce7c457f5c3ab2a2620deb5b8b844eca235071
refs/heads/master
2021-01-01T05:45:20.237879
2009-10-15T11:33:11
2009-10-15T11:33:11
56,930,383
0
0
null
null
null
null
UTF-8
C++
false
false
1,163
cpp
#include "Pak.h" #include <stdio.h> #include <cmath> #include "stdafx.h" Pak::Pak() {} Pak::Pak(Point2 start, Point2 gibanje1, double radij, double frik, bool glavni, char* ime1){ pozicija=start; gibanje=gibanje1; r=radij; trenje=frik; jeglavni=glavni; ime=ime1; trk=11; } Pak::~Pak() {} void Pak::UpdatePos() { pozicija=pozicija+gibanje; gibanje=gibanje*trenje; trk++; } Point2 Pak::getPos() { return pozicija; } Point2 Pak::getDir() { return gibanje; } void Pak::setDir(double a, double b) { gibanje.setX(a); gibanje.setY(b); } void Pak::setPos(double a, double b){ pozicija.setX(a); pozicija.setY(b); } void Pak::setPos(Point2 a){ pozicija.setX(a.getX()); pozicija.setY(a.getY()); } double Pak::getFri(){return trenje;} double Pak::getRad(){return r;} void Pak::setRad(double ra){r=ra;} void Pak::setFri(double fri){trenje=fri;} void Pak::setLastPos(double a, double b) { lastpos.setX(a); lastpos.setY(b); } Point2 Pak::getLastPos(){ return lastpos; } char* Pak::getIme() { return ime; } int Pak::getLastTrk() { return trk; } void Pak::setLastTrk() { trk=0; }
[ "aljosa.osep@07432978-1335-11de-a4db-e31d5fa7c4f0" ]
[ [ [ 1, 64 ] ] ]
b134ee1ec476966afe5b30b98af994176cac6c6c
f2b4a9d938244916aa4377d4d15e0e2a6f65a345
/Game/BattlePF.cpp
0f66c11c6dd96e876f193e8c74ffc0fb0a0cd2e2
[ "Apache-2.0" ]
permissive
notpushkin/palm-heroes
d4523798c813b6d1f872be2c88282161cb9bee0b
9313ea9a2948526eaed7a4d0c8ed2292a90a4966
refs/heads/master
2021-05-31T19:10:39.270939
2010-07-25T12:25:00
2010-07-25T12:25:00
62,046,865
2
1
null
null
null
null
UTF-8
C++
false
false
13,472
cpp
/* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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 "stdafx.h" #ifdef _DEEP_DEBUG_ # define new DEBUG_NEW #endif #include "BattlePF.h" const sint16 HEX_NEBS[2][2][3][2] = { { {{1,-1},{1,0},{1,1}}, {{0,-1},{-1,0},{0,1}} },{ {{0,-1},{1,0},{0,1}}, {{-1,-1},{-1,0},{-1,1}} } }; ////////////////////////////////////////////////////////////////////////// inline uint32 CellsDelta(sint32 px1, sint32 py1, sint32 px2, sint32 py2) { uint32 dx = iABS(px1 - px2); uint32 dy = iABS(py1 - py2); if ( (dx & 1) == 0 ) ++dy; return dx+(dy>>1); } ////////////////////////////////////////////////////////////////////////// void CalculatePath(iBattleGroup* pGroup, iPoint& dstPoint, uint8& orient) { check (dstPoint.x >= 0 && dstPoint.x < 13 && dstPoint.y >= 0 && dstPoint.y < 11); sint16 px = (sint16)dstPoint.x; sint16 py = (sint16)dstPoint.y; const iBattleGroup::iDistMap& dm = pGroup->DistMap(); uint8 cost = dm.GetAt(px,py).dirs[orient].val; sint32 speed = pGroup->Speed(); if (pGroup->TransType() == TRANS_FLY) { sint16 tgtX, tgtY; uint32 tgtIdx = 0xFFFF; ODS(iFormat(_T("--Processing unit at %d,%d:\n"), pGroup->Pos().x, pGroup->Pos().y).CStr()); // Locate nearest acceptable cell iPoint np; for (sint16 yy=0; yy<dm.GetHeight(); ++yy) { np.y = yy; for (sint16 xx=0; xx<dm.GetWidth(); ++xx) { np.x = xx; for (uint8 dd = 0; dd<2; ++dd) { if (pGroup->Pos() != np && dm.GetAt(xx,yy).dirs[dd].val <= pGroup->Speed() && pGroup->CanMove(xx,yy) && (pGroup->PassMap().GetAt(xx,yy) & 0x7F) != CT_MOAT){ uint32 nidx = CellsDelta(xx, yy, px, py); ODS(iFormat(_T("\tCan move at %d,%d with idx %d: "), xx, yy, nidx).CStr()); if (nidx < tgtIdx) { tgtX = xx; tgtY = yy; orient = dd; tgtIdx = nidx; ODS(_T("Ok\n")); } else { ODS(_T("No\n")); } } } } } ODS(iFormat(_T("--Found cell at %d,%d.\n"), tgtX, tgtY).CStr()); //check(pGroup->Pos().x != tgtX || pGroup->Pos().y != tgtY); px = tgtX; py = tgtY; } else if (pGroup->TransType() == TRANS_WALK) { if (pGroup->Size() == 1) { while (cost > speed && pGroup->CanMove(px,py)) { sint16 sv = py&1; uint8 dd = dm.GetAt(px,py).dirs[orient].dir; uint8 d = dd >> 1; uint8 o = !(dd & 0x1); sint16 npx = px + HEX_NEBS[sv][o][d][0]; sint16 npy = py + HEX_NEBS[sv][o][d][1]; if (orient == o) orient = !orient; px = npx; py = npy; cost = dm.GetAt(px,py).dirs[o].val; } } else { while (cost > speed && pGroup->CanMove(px,py)) { sint16 sv = py&1; uint8 dd = dm.GetAt(px,py).dirs[orient].dir; uint8 d = dd >> 1; uint8 o = !(dd & 0x1); sint16 npx = px + HEX_NEBS[sv][o][d][0]; sint16 npy = py + HEX_NEBS[sv][o][d][1]; uint8 ncost = dm.GetAt(npx,npy).dirs[!o].val; sint16 rx = px + TAIL_OFFSET[!o]; sint16 ry = py; if (dm.IsValidPos(rx,ry)) { uint8 rdd = dm.GetAt(rx,ry).dirs[!orient].dir; uint8 rd = rdd >> 1; uint8 ro = !(rdd & 0x1); sint16 rnpx = px + HEX_NEBS[sv][!o][d][0]; sint16 rnpy = py + HEX_NEBS[sv][!o][d][1]; if (dm.IsValidPos(rnpx,rnpy) && dm.GetAt(rnpx,rnpy).dirs[o].val < ncost) { npx = rnpx; npy = rnpy; ncost = dm.GetAt(rnpx,rnpy).dirs[o].val; orient = !orient; } } px = npx; py = npy; cost = ncost; } } } else { // unknown transportation type check(0); } dstPoint.x = px; dstPoint.y = py; } /* * Path finding */ iBattlePF::iBattlePF(iBattleGroup* pGroup) : m_pGroup(pGroup) { } static int counter = 0; static int tcounter = 0; struct iOpenCell { iOpenCell(sint16 _px, sint16 _py, uint8 _dir, uint32 _step) : px(_px), py(_py), dir(_dir), step(_step) {} sint16 px, py; uint32 step; uint8 dir; }; void iBattlePF::PropagateDown(sint16 px, sint16 py, uint8 dir, uint32 step, bool bFull) { iSimpleArray<iOpenCell> openCells; uint32 curCell = 0; sint32 speed = m_pGroup->Speed(); bool bFlying = m_pGroup->TransType() == TRANS_FLY; // Add origin cell openCells.Add(iOpenCell(px, py, dir, step)); while (curCell < openCells.GetSize()) { iOpenCell cell = openCells[curCell++]; // process current cell uint8 qdir = (cell.dir & 0x1); // 1 if ( (!bFull && cell.step > speed) ) continue; // 2 uint8& pmc = m_pGroup->PassMap().GetAt(cell.px,cell.py); uint8 tt = (pmc&0x7F); // 3 if ( cell.step && (tt != CT_PASSABLE && tt != CT_BRIDGE && tt != CT_MOAT && !bFlying)) continue; // 4 if ( cell.step && (!bFlying || (tt == CT_PASSABLE || tt == CT_BRIDGE || tt == CT_MOAT)) && (cell.step <= speed || bFull) ) pmc |= 0x80; sint16 sv = cell.py&1; iBattleGroup::iDistCell& dc = m_pGroup->DistMap().GetAt(cell.px,cell.py); // add nebs to open list for (uint32 yy=0; yy<2; ++yy) { if (dc.dirs[qdir].val > cell.step) { dc.dirs[qdir].val = cell.step; dc.dirs[qdir].dir = cell.dir; uint32 nstep = cell.step+1; bool bhpass = (cell.step && tt == CT_MOAT && bFull && !bFlying); if (bhpass) nstep = cell.step + 20; if (nstep < 0xFF && (!cell.step || tt != CT_MOAT || bFlying || bhpass)) { for (uint32 xx=0; xx<3; ++xx) { sint16 npx = cell.px+HEX_NEBS[sv][qdir][xx][0]; sint16 npy = cell.py+HEX_NEBS[sv][qdir][xx][1]; if (m_pGroup->PassMap().IsValidPos(npx,npy)) openCells.Add(iOpenCell(npx, npy, ((2-xx)<<1) | qdir, nstep)); } } } qdir = !qdir; } } /* iters_cur++; uint8 qdir = (dir & 0x1); bool bFlying = m_pGroup->TransType() == TRANS_FLY; counter++; // 1 if ( (!bFull && step > m_pGroup->Speed()) ) return; // 2 uint8& pmc = m_pGroup->PassMap().GetAt(px,py); uint8 tt = (pmc&0x7F); // 3 if ( step && (tt != CT_PASSABLE && tt != CT_BRIDGE && tt != CT_MOAT && !bFlying)) return; // 4 if (step && (!bFlying || (tt == CT_PASSABLE || tt == CT_BRIDGE || tt == CT_MOAT)) && (step <= m_pGroup->Speed() || bFull)) pmc |= 0x80; sint16 sv = py&1; iBattleGroup::iDistCell& dc = m_pGroup->DistMap().GetAt(px,py); for (uint32 yy=0; yy<2; ++yy) { if (dc.dirs[qdir].val > step) { dc.dirs[qdir].val = step; dc.dirs[qdir].dir = dir; uint32 nstep = step+1; bool bhpass = (step && tt == CT_MOAT && bFull && !bFlying); if (bhpass) nstep = step + 20; if (nstep < 0xFF && (!step || tt != CT_MOAT || bFlying || bhpass)) { for (uint32 xx=0; xx<3; ++xx) { sint16 npx = px+HEX_NEBS[sv][qdir][xx][0]; sint16 npy = py+HEX_NEBS[sv][qdir][xx][1]; if (m_pGroup->PassMap().IsValidPos(npx,npy)) PropagateDown(npx,npy, ((2-xx)<<1) | qdir,nstep, bFull); } } } qdir = !qdir; }*/ } void iBattlePF::PropagateDown2(sint16 px, sint16 py, uint8 dir, uint32 step, bool bFull) { iSimpleArray<iOpenCell> openCells; uint32 curCell = 0; sint32 speed = m_pGroup->Speed(); bool bFlying = m_pGroup->TransType() == TRANS_FLY; // Add origin cell openCells.Add(iOpenCell(px, py, dir, step)); while (curCell < openCells.GetSize()) { iOpenCell cell = openCells[curCell++]; // process current cell uint8 qdir = (cell.dir & 0x1); sint16 tpx = cell.px+TAIL_OFFSET[qdir]; sint16 tpy = cell.py; if (!m_pGroup->PassMap().IsValidPos(cell.px,cell.py) || !m_pGroup->PassMap().IsValidPos(tpx,tpy) || (!bFull && cell.step > speed)) continue; // 2 uint8 c = (m_pGroup->PassMap().GetAt(cell.px,cell.py)&0x7F); uint8 tc = (m_pGroup->PassMap().GetAt(tpx,tpy)&0x7F); // 3 if ( cell.step && (( (c != CT_PASSABLE && c != CT_BRIDGE && c != CT_MOAT) || (tc != CT_PASSABLE && tc != CT_BRIDGE && tc != CT_MOAT)) && !bFlying) ) continue; // 5 sint16 sv = cell.py&1; // add nebs to open list for (uint32 yy=0; yy<2; ++yy) { iBattleGroup::iDistCell& dc = m_pGroup->DistMap().GetAt(cell.px,cell.py); if (dc.dirs[qdir].val > cell.step) { dc.dirs[qdir].val = cell.step; dc.dirs[qdir].dir = cell.dir; if ((cell.step <= speed || bFull) && (!bFlying || ((c == CT_PASSABLE || c == CT_BRIDGE || c == CT_MOAT) && (tc == CT_PASSABLE || tc == CT_BRIDGE || tc == CT_MOAT)))) m_pGroup->PassMap().GetAt(cell.px,cell.py) |= 0x80; if (!cell.step || c != CT_MOAT || bFlying) { for (uint32 xx=0; xx<3; ++xx) { sint16 npx = cell.px+HEX_NEBS[sv][qdir][xx][0]; sint16 npy = cell.py+HEX_NEBS[sv][qdir][xx][1]; if (m_pGroup->PassMap().IsValidPos(npx,npy)) openCells.Add(iOpenCell(npx, npy, ((2-xx)<<1) | qdir, cell.step+1)); } } } cell.px = tpx; qdir = !qdir; } } /* iters_cur++; // 1 uint8 qdir = (dir & 0x1); sint16 tpx = px+TAIL_OFFSET[qdir]; sint16 tpy = py; bool bFlying = m_pGroup->TransType() == TRANS_FLY; if (!m_pGroup->PassMap().IsValidPos(px,py) || !m_pGroup->PassMap().IsValidPos(tpx,tpy) || (!bFull && step > m_pGroup->Speed())) return; // 2 uint8 c = (m_pGroup->PassMap().GetAt(px,py)&0x7F); uint8 tc = (m_pGroup->PassMap().GetAt(tpx,tpy)&0x7F); // 3 if ( step && (( (c != CT_PASSABLE && c != CT_BRIDGE && c != CT_MOAT) || (tc != CT_PASSABLE && tc != CT_BRIDGE && tc != CT_MOAT)) && !bFlying) ) return; // 5 sint16 sv = py&1; for (uint32 yy=0; yy<2; ++yy) { iBattleGroup::iDistCell& dc = m_pGroup->DistMap().GetAt(px,py); if (dc.dirs[qdir].val > step) { dc.dirs[qdir].val = step; dc.dirs[qdir].dir = dir; if ((step <= m_pGroup->Speed() || bFull) && (!bFlying || ((c == CT_PASSABLE || c == CT_BRIDGE || c == CT_MOAT) && (tc == CT_PASSABLE || tc == CT_BRIDGE || tc == CT_MOAT)))) m_pGroup->PassMap().GetAt(px,py) |= 0x80; if (!step || c != CT_MOAT || bFlying) { for (uint32 xx=0; xx<3; ++xx) { sint16 npx = px+HEX_NEBS[sv][qdir][xx][0]; sint16 npy = py+HEX_NEBS[sv][qdir][xx][1]; if (m_pGroup->PassMap().IsValidPos(npx,npy)) PropagateDown2(npx,npy, ((2-xx)<<1) | qdir,step+1, bFull); } } } px = tpx; qdir = !qdir; }*/ } void iBattlePF::MakeDistMap(bool bFull) { // move and melee m_pGroup->DistMap().FillMem(iBattleGroup::iDistCell()); tcounter++; if (m_pGroup->Size() == 1) { PropagateDown((sint16)m_pGroup->Pos().x,(sint16)m_pGroup->Pos().y,m_pGroup->Orient(), 0, bFull); } else { PropagateDown2((sint16)m_pGroup->Pos().x,(sint16)m_pGroup->Pos().y,m_pGroup->Orient(), 0, bFull); } } void iBattlePF::MakePath1(const iPoint& pos, uint8 dir, iBattleActList& actList) { sint16 px = (sint16)pos.x; sint16 py = (sint16)pos.y; const iBattleGroup::iDistMap& dm = m_pGroup->DistMap(); uint8 cost = dm.GetAt(px,py).dirs[dir].val; while (cost) { sint16 sv = py&1; uint8 dd = dm.GetAt(px,py).dirs[dir].dir; uint8 d = dd >> 1; uint8 o = !(dd & 0x1); sint16 npx = px + HEX_NEBS[sv][o][d][0]; sint16 npy = py + HEX_NEBS[sv][o][d][1]; if (dir == o) { actList.PushAction(new iBattleAct_Rotate(m_pGroup)); dir = !dir; } actList.PushAction(new iBattleAct_Move(m_pGroup, iPoint(px,py))); px = npx; py = npy; cost = dm.GetAt(px,py).dirs[0].val; } // Initial (start point) rotate if (dir != m_pGroup->Orient()) actList.PushAction(new iBattleAct_Rotate(m_pGroup)); } void iBattlePF::MakePath2(const iPoint& pos, uint8 dir, bool bMove, iBattleActList& actList) { sint16 px = (sint16)pos.x; sint16 py = (sint16)pos.y; const iBattleGroup::iDistMap& dm = m_pGroup->DistMap(); uint8 cost = dm.GetAt(px,py).dirs[dir].val; if ( cost == 0xFF ) { dir = !dir; if (bMove) { actList.PushAction(new iBattleAct_Rotate(m_pGroup)); cost = dm.GetAt(px,py).dirs[dir].val; } } check(cost != 0xFF); while (cost) { sint16 sv = py&1; uint8 dd = dm.GetAt(px,py).dirs[dir].dir; uint8 d = dd >> 1; uint8 o = !(dd & 0x1); sint16 npx, npy; if ( dir == o ){ npx = px + HEX_NEBS[sv][!o][d][0]; npy = py + HEX_NEBS[sv][!o][d][1]; px += TAIL_OFFSET[o]; dir = !dir; actList.PushAction(new iBattleAct_Rotate(m_pGroup)); } else { npx = px + HEX_NEBS[sv][o][d][0]; npy = py + HEX_NEBS[sv][o][d][1]; } actList.PushAction(new iBattleAct_Move(m_pGroup, iPoint(px,py))); px = npx; py = npy; cost = dm.GetAt(px,py).dirs[!o].val; } // Initial (start point) rotate if (dir != m_pGroup->Orient()) actList.PushAction(new iBattleAct_Rotate(m_pGroup)); } bool iBattlePF::MakePath(const iPoint& pos, uint8 dir, bool bMove, iBattleActList& actList) { if (m_pGroup->DistMap().GetAt(pos.x,pos.y).data == 0xFFFF) return false; if (m_pGroup->Size() == 1) MakePath1(pos, dir, actList); else MakePath2(pos, dir, bMove, actList); return true; }
[ "palmheroesteam@2c21ad19-eed7-4c86-9350-8a7669309276" ]
[ [ [ 1, 424 ] ] ]
652a8b70911d49c8026210d6706486c4a025feb9
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/spirit/example/fundamental/matching_tags.cpp
efc4c94509e5a1aaf70ffcea1aeb9f1df778bb58
[ "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
willrebuild/flyffsf
e5911fb412221e00a20a6867fd00c55afca593c7
d38cc11790480d617b38bb5fc50729d676aef80d
refs/heads/master
2021-01-19T20:27:35.200154
2011-02-10T12:34:43
2011-02-10T12:34:43
32,710,780
3
0
null
null
null
null
UTF-8
C++
false
false
3,644
cpp
/*============================================================================= Copyright (c) 2002-2003 Joel de Guzman http://spirit.sourceforge.net/ Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ //////////////////////////////////////////////////////////////////////////// // // HTML/XML like tag matching grammar // Demonstrates phoenix and closures and parametric parsers // This is discussed in the "Closures" chapter in the Spirit User's Guide. // // [ JDG 6/30/2002 ] // //////////////////////////////////////////////////////////////////////////// #include <boost/spirit/core.hpp> #include <boost/spirit/attribute.hpp> #include <iostream> #include <string> //////////////////////////////////////////////////////////////////////////// using namespace std; using namespace boost::spirit; using namespace phoenix; //////////////////////////////////////////////////////////////////////////// // // HTML/XML like tag matching grammar // //////////////////////////////////////////////////////////////////////////// struct tags_closure : boost::spirit::closure<tags_closure, string> { member1 tag; }; struct tags : public grammar<tags> { template <typename ScannerT> struct definition { definition(tags const& /*self*/) { element = start_tag >> *element >> end_tag; start_tag = '<' >> lexeme_d [ (+alpha_p) [ // construct string from arg1 and arg2 lazily // and assign to element.tag element.tag = construct_<string>(arg1, arg2) ] ] >> '>'; end_tag = "</" >> f_str_p(element.tag) >> '>'; } rule<ScannerT, tags_closure::context_t> element; rule<ScannerT> start_tag, end_tag; rule<ScannerT, tags_closure::context_t> const& start() const { return element; } }; }; //////////////////////////////////////////////////////////////////////////// // // Main program // //////////////////////////////////////////////////////////////////////////// int main() { cout << "/////////////////////////////////////////////////////////\n\n"; cout << "\t\tHTML/XML like tag matching parser demo \n\n"; cout << "/////////////////////////////////////////////////////////\n\n"; cout << "Type an HTML/XML like nested tag input...or [q or Q] to quit\n\n"; cout << "Example: <html><head></head><body></body></html>\n\n"; tags p; // Our parser string str; while (getline(cin, str)) { if (str.empty() || str[0] == 'q' || str[0] == 'Q') break; parse_info<> info = parse(str.c_str(), p, space_p); if (info.full) { cout << "-------------------------\n"; cout << "Parsing succeeded\n"; cout << "-------------------------\n"; } else { cout << "-------------------------\n"; cout << "Parsing failed\n"; cout << "stopped at: \": " << info.stop << "\"\n"; cout << "-------------------------\n"; } } cout << "Bye... :-) \n\n"; return 0; }
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 115 ] ] ]
38f7042c3d60411ded075d4fd922bbb778d38bbd
2ffa21338b74e20a80cb7c468e4578fd66554700
/src/exceptions.h
ce2c1ce47471ec7d8ee800010697045f3b51f9cc
[]
no_license
vojtajina/ctu-bruch-jina-par-pmt
f22d9b1ad8e2555510edadf6ddcbd75e2c49dd47
303a512510da7f1ac0842f9a0581b593dc96d3e8
refs/heads/master
2021-01-23T02:29:36.426275
2010-10-04T21:38:48
2010-10-04T21:38:48
32,126,700
0
0
null
null
null
null
UTF-8
C++
false
false
1,824
h
#ifndef EXCEPTIONS_H #define EXCEPTIONS_H /** * @file exceptions.h * @brief Definition and implementation of all exceptions */ #include <exception> #include <stdio.h> using namespace std; /** * @class InvalidPositionException * @author Vojta Jina * @date 04/04/10 * @brief This exception is thrown when someone refers to invalid position. * @brief Invalid position is out of field range of the configuration. */ class InvalidPositionException: public exception { private: char message[50]; public: InvalidPositionException(int position) { sprintf(message, "This position(%d) is invalid !", position); } virtual const char* what() const throw() { return message; } }; /** * @class InvalidPriorityException * @author Vojta Jina * @date 04/16/2010 * @brief This exception is thrown when someone uses out of range priority */ class InvalidPriorityException: public exception { private: char message[50]; public: InvalidPriorityException(int priority) { sprintf(message, "This priority(%d) is invalid !", priority); } virtual const char* what() const throw() { return message; } }; /** * @class InvalidArgumentsException * @author Vojta Jina * @date 10/04/2010 * @brief Invalid input command arguments */ class InvalidArgumentException: public exception { private: char message[50]; public: InvalidArgumentException(char* invalidArg) { if (invalidArg) sprintf(message, "Invalid argument \"%s\"", invalidArg); else sprintf(message, "%s", "To few arguments"); } virtual const char* what() const throw() { return message; } }; #endif // EXCEPTIONS_H
[ "vojta.jina@f71fc35e-9e61-cdbf-5a40-9e5a3efe5e49" ]
[ [ [ 1, 91 ] ] ]
91a1ef94ba744096e7f3559766d0d5c9aee15a93
f31ae209ab2842872fc28680caac3c0aefa12afa
/geometry/MatrixArithmetic.cpp
a2bcf651be7636311d53271612db083423576afc
[]
no_license
alyshamsy/cs8501
9ee5f3a0b18b60ebdb7373fe36a63a951f58155c
06432825f0bdef863091808328f21d1bed19223d
refs/heads/master
2016-09-06T08:30:25.691989
2010-10-27T23:37:05
2010-10-27T23:37:05
32,115,437
0
0
null
null
null
null
UTF-8
C++
false
false
5,045
cpp
#include "MatrixArithmetic.h" #include <iostream> using namespace std; MatrixArithmetic::MatrixArithmetic() { } MatrixArithmetic::~MatrixArithmetic() { } bool MatrixArithmetic::is_matrix_square(Matrix& A) { if(A.get_rows() == A.get_columns()) return true; else return false; } Matrix MatrixArithmetic::generate_square_matrix(Matrix& current_matrix) { int number_of_rows = current_matrix.get_rows(); int number_of_columns = current_matrix.get_columns(); int size = min(number_of_rows, number_of_columns); Matrix square_matrix; for(int i = 0; i < size; i++) { for(int j = 0; j < size; j++) square_matrix.set_matrix_element(i, j, current_matrix.get_matrix_element(i, j)); } return square_matrix; } Matrix MatrixArithmetic::generate_identity_matrix(int size) { Matrix identity_matrix(0.0, size, size); for(int i = 0; i < size; i++) { for(int j = 0; j < size; j++) { if(i == j) identity_matrix.set_matrix_element(i, j, 1); } } return identity_matrix; } Matrix MatrixArithmetic::generate_row_vector(Vertex& current_vertex) { Matrix row_vector(0.0, 1, 3); row_vector.set_matrix_element(0, 0, current_vertex.x); row_vector.set_matrix_element(0, 1, current_vertex.y); row_vector.set_matrix_element(0, 2, current_vertex.z); return row_vector; } Matrix MatrixArithmetic::generate_column_vector(Vertex& current_vertex) { Matrix column_vector(0.0, 3, 1); column_vector.set_matrix_element(0, 0, current_vertex.x); column_vector.set_matrix_element(1, 0, current_vertex.y); column_vector.set_matrix_element(2, 0, current_vertex.z); return column_vector; } Matrix MatrixArithmetic::get_matrix_transpose(Matrix& current_matrix) { int rows = current_matrix.get_rows(); int columns = current_matrix.get_columns(); Matrix transpose(0.0, rows, columns); for(int i = 0; i < rows; i++) { for(int j = 0; j < columns; j++) transpose.set_matrix_element(i, j, current_matrix.get_matrix_element(j, i)); } return transpose; } Matrix MatrixArithmetic::do_scalar_multiplication(int scalar, Matrix& current_matrix) { int rows = current_matrix.get_rows(); int columns = current_matrix.get_columns(); Matrix scaled_matrix(0.0, rows, columns); for(int i = 0; i < rows; i++) { for(int j = 0; j < columns; j++) scaled_matrix.set_matrix_element(i, j, scalar*current_matrix.get_matrix_element(i, j)); } return scaled_matrix; } Matrix operator+(Matrix& A, Matrix& B) { int rows_a = A.get_rows(); int columns_a = A.get_columns(); int rows_b = B.get_rows(); int columns_b = B.get_columns(); //if(rows_a == rows_b && columns_a == columns_b) Matrix added_matrix(0.0, rows_a, columns_a); for(int i = 0; i < rows_a; i++) { for(int j = 0; j < columns_a; j++) added_matrix.set_matrix_element(i, j, A.get_matrix_element(i, j)+B.get_matrix_element(i, j)); } return added_matrix; } Matrix operator-(Matrix& A, Matrix& B) { int rows_a = A.get_rows(); int columns_a = A.get_columns(); int rows_b = B.get_rows(); int columns_b = B.get_columns(); //if(rows_a == rows_b && columns_a == columns_b) Matrix subtracted_matrix(0.0, rows_a, columns_a); for(int i = 0; i < rows_a; i++) { for(int j = 0; j < columns_a; j++) subtracted_matrix.set_matrix_element(i, j, A.get_matrix_element(i, j)-B.get_matrix_element(i, j)); } return subtracted_matrix; } Matrix operator*(Matrix& A, Matrix& B) { int rows_a = A.get_rows(); int columns_a = A.get_columns(); int rows_b = B.get_rows(); int columns_b = B.get_columns(); //if(columns_a == rows_b) double element = 0.0; Matrix multiplied_matrix(0.0, rows_a, columns_b); for(int i = 0; i < rows_a; i++) { for(int j = 0; j <columns_b; j++) { for(int k = 0; k < columns_a; k++) { element += A.get_matrix_element(i, k) * B.get_matrix_element(k, j); } multiplied_matrix.set_matrix_element(i, j, element); } } return multiplied_matrix; } double MatrixArithmetic::get_dot_product(Matrix& A, Matrix& B) { double dot_product = 0.0; int rows = A.get_rows(); int columns = A.get_columns(); for(int i = 0; i < rows; i++) { for(int j = 0; j < columns; j++) dot_product += A.get_matrix_element(i, j) * B.get_matrix_element(j, i); } return dot_product; } Matrix MatrixArithmetic::get_cross_product(Matrix&A, Matrix& B) { Matrix cross_product(0.0, 3, 1); double element = (A.get_matrix_element(0, 1)*B.get_matrix_element(0, 2)) - (A.get_matrix_element(0, 2)*B.get_matrix_element(0, 1)); cross_product.set_matrix_element(0, 0, element); element = (A.get_matrix_element(0, 2)*B.get_matrix_element(0, 0)) - (A.get_matrix_element(0, 0)*B.get_matrix_element(0, 2)); cross_product.set_matrix_element(0, 0, element); element = (A.get_matrix_element(0, 2)*B.get_matrix_element(0, 0)) - (A.get_matrix_element(0, 0)*B.get_matrix_element(0, 2)); cross_product.set_matrix_element(0, 0, element); return cross_product; }
[ "aly.shamsy@701c5031-9793-ad4f-f4d9-d7398babfd84" ]
[ [ [ 1, 182 ] ] ]
808c7230f70a0142553db7cfa06f954c60eb518f
5f41a9d36008ef931c7b068ec0e05175beb1e82b
/task big.cpp
9848bdbdfd44fa5a380ca4c711e4bfb40ce087cb
[]
no_license
zootella/backup
438af7bbe4c7cdc453b6983de48f498104bf9d3f
806271bdf84795a990558c90f932b9bf7f7971bd
refs/heads/master
2021-01-10T21:04:27.693788
2011-12-26T23:39:16
2011-12-26T23:39:16
146,246
2
0
null
null
null
null
UTF-8
C++
false
false
4,321
cpp
// Include statements #include <windows.h> #include <windef.h> #include <atlstr.h> #include <shlobj.h> #include "resource.h" #include "program.h" #include "class.h" #include "function.h" // Global objects extern handleitem Handle; // A new thread starts running this function // Perform the job tasks DWORD WINAPI Tasks() { // Break the text into lines that aren't blank string s = JobTasks(); while (is(s) && JobContinue()) { string line; split(s, L"\r\n", &line, &s); line = trim(line, L" "); if (is(line)) { // Parse the line into parts string task, source, destination; string parse = line; split(parse, L"\"", &task, &parse); split(parse, L"\"", &source, &parse); split(parse, L"\"", &parse, &destination); task = trim(task, L" "); // Trim spaces source = trim(source, L" "); destination = trim(destination, L" ", L"\""); // Trim spaces and remove trailing quote task = off(task, L"\\", Reverse); // Remove trailing backslashes, "C:\" becomes "C:" so we can put on "\folder" later source = off(source, L"\\", Reverse); destination = off(destination, L"\\", Reverse); // Run the task if (task == L"Hash") TaskHash(source); else if (task == L"Delete") TaskDelete(source); else if (task == L"Copy") TaskCopy(source, destination); else if (task == L"Compare") TaskCompare(source, destination); else if (task == L"Update") TaskUpdate(source, destination, false); else if (task == L"Update Compare") TaskUpdate(source, destination, true); else JobError(L"Cannot " + line); // Unknown task } } // The job is done JobDone(); // Let the thread exit return 0; } // Hash folder void TaskHash(read path) { // Make sure path is to a folder if (!DiskFolder(path, false, false)) { JobError(make(L"Cannot hash \"", path, L"\"")); return; } // Create and open a file to list the hashes string s = LogPath(make(L"Hash ", saydate(L";"), L" ", sayguid())); HANDLE log = LogOpen(s, make(L"Hash of \"", path, L"\"")); if (!log) { JobError(make(L"Cannot write \"", s, L"\"")); return; } // Hash folder TaskHashFolder(path, path, log); // Root and folder are the same path // Write the footer and close the file LogClose(log); } // Delete path void TaskDelete(read path) { // Make sure path is to a folder we can edit if (!DiskFolder(path, false, true)) { JobError(make(L"Cannot write \"", path, L"\"")); return; } // Delete path TaskDeleteFolder(path); } // Copy source to destination void TaskCopy(read source, read destination) { // Make sure source is to a folder, and make folders to destination and confirm we can write there if (!DiskFolder(source, false, false)) { JobError(make(L"Cannot read \"", source, L"\"")); return; } if (!DiskFolder(destination, true, true)) { JobError(make(L"Cannot write \"", destination, + L"\"")); return; } // Copy source to destination TaskCopyFolder(source, destination, false); // false to not also compare } // Compare source to destination void TaskCompare(read source, read destination) { // Make sure source and destination are to folders we can read if (!DiskFolder(source, false, false)) { JobError(make(L"Cannot read \"", source, L"\"")); return; } if (!DiskFolder(destination, false, false)) { JobError(make(L"Cannot read \"", destination, L"\"")); return; } // Compare source to destination TaskCompareFolder(source, destination); } // Update source to destination, true to compare each file after we copy it void TaskUpdate(read source, read destination, bool compare) { // Make sure source is to a folder, and make folders to destination and confirm we can write there if (!DiskFolder(source, false, false)) { JobError(make(L"Cannot read \"", source, L"\"")); return; } if (!DiskFolder(destination, true, true)) { JobError(make(L"Cannot write \"", destination, L"\"")); return; } // Perform the two tasks that make up the update TaskUpdateClear(source, destination); // Clear the destination of extra and different files and folders TaskUpdateFill(source, destination, compare); // Copy missing files and folders in the destination from the source }
[ "Kevin@machine.(none)", "[email protected]" ]
[ [ [ 1, 22 ], [ 25, 29 ], [ 39, 40 ], [ 48, 57 ], [ 76, 79 ], [ 81, 82 ], [ 84, 89 ], [ 92, 100 ], [ 103, 111 ], [ 114, 118 ] ], [ [ 23, 24 ], [ 30, 38 ], [ 41, 47 ], [ 58, 75 ], [ 80, 80 ], [ 83, 83 ], [ 90, 91 ], [ 101, 102 ], [ 112, 113 ] ] ]
0f220ed1e8ddd4ba7b20a2ef6f8239b71195ff71
6e563096253fe45a51956dde69e96c73c5ed3c18
/os/AX_Thread_Tss.inl
767457a74188661eae98700bd0d7a2a144d13704
[]
no_license
15831944/phoebemail
0931b76a5c52324669f902176c8477e3bd69f9b1
e10140c36153aa00d0251f94bde576c16cab61bd
refs/heads/master
2023-03-16T00:47:40.484758
2010-10-11T02:31:02
2010-10-11T02:31:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,394
inl
#include "AX_Thread_Tss.h" template <class TYPE> inline AX_TSS<TYPE>::~AX_TSS (void) { #ifdef _WIN32 cleanup(0); #endif if (this->once_ != 0) { //AX_OS::thr_key_detach (this->key_, this); AX_OS::thr_keyfree (this->key_); } } template <class TYPE>inline AX_TSS<TYPE>::AX_TSS (TYPE *ts_obj) : once_ (0) { ts_init(); AX_OS::thr_key_set(this->key_,(void *) ts_obj); //printf("AX_Thread::setspecific "); } template <class TYPE> inline int AX_TSS<TYPE>::ts_init (void) { int result = AX_OS::thr_key_create(&key_,&cleanup); return result; } template <class TYPE> inline TYPE * AX_TSS<TYPE>::ts_object (void) const { return (TYPE*)AX_OS::thr_key_get(key_); } template <class TYPE> inline int AX_TSS<TYPE>::ts_object (TYPE *type) { return AX_OS::thr_key_set(key_,(void *)type); } template <class TYPE> inline TYPE * AX_TSS<TYPE>::ts_get (void) const { return AX_OS::thr_key_get(key_); } template <class TYPE> inline TYPE * AX_TSS<TYPE>::make_TSS_TYPE (void) const { TYPE *temp = 0; temp = new TYPE; return temp; } template <class TYPE> inline void AX_TSS<TYPE>::dump (void) const { this->keylock_.dump (); } template <class TYPE> inline void AX_TSS<TYPE>::cleanup (void *ptr) { //printf("cleanup "); // Cast this to the concrete TYPE * so the destructor gets called. //delete (TYPE *) ptr; }
[ "guoqiao@a83c37f4-16cc-5f24-7598-dca3a346d5dd" ]
[ [ [ 1, 73 ] ] ]
2ac85748700542db5a5c5f644ba575a858263bf8
651639abcfc06818971a0296944703b3dd050e8d
/Rifle3.cpp
98618c52348e24fcb319a3c3fd5fd19d64675d53
[]
no_license
reanag/snailfight
5256dc373e3f3f3349f77c7e684cb0a52ccc5175
c4f157226faa31d526684233f3c5cd4572949698
refs/heads/master
2021-01-19T07:34:17.122734
2010-01-20T17:16:36
2010-01-20T17:16:36
34,893,173
0
0
null
null
null
null
UTF-8
C++
false
false
986
cpp
#include "Rifle3.hpp" //the red rifle Rifle3::Rifle3(RenderWindow* window, b2World* World, TempObjectHandler* toh, float PositionX, float PositionY, int Ammunition):Weapon(window, World, toh, PositionX, PositionY, Ammunition){ damage=5; clipsize=12; clip=clipsize; ammunition=Ammunition-clip; firespeed=0.2; CreateBody(PositionX,PositionY); LoadImage("contents/Rifle3.png", weaponImg, WeaponSp); WeaponSp.SetCenter(weaponshapeDef.vertices[2].x+1,weaponshapeDef.vertices[2].y); LoadImage("contents/tt2.png", muzzleImg, MuzzleSp); MuzzleSp.SetCenter(3,87); MuzzleSp.SetScale(0.5,0.5); LoadSound("contents/Sound 629 fire 8.wav", WeaponFireSoundBuffer, WeaponFireSound); LoadSound("contents/Sound 649 load 8.wav", WeaponReloadSoundBuffer, WeaponReloadSound); LoadSound("contents/Sound 837 clip out 1.wav", WeaponOutOfAmmoSoundBuffer, WeaponOutOfAmmoSound); }
[ "[email protected]@96fa20d8-dc45-11de-8f20-5962d2c82ea8", "[email protected]@96fa20d8-dc45-11de-8f20-5962d2c82ea8" ]
[ [ [ 1, 1 ], [ 4, 4 ], [ 8, 10 ], [ 12, 12 ], [ 14, 15 ], [ 19, 19 ] ], [ [ 2, 3 ], [ 5, 7 ], [ 11, 11 ], [ 13, 13 ], [ 16, 18 ] ] ]
d5d4cb57551361e62014ffa88fb9b34c05b0e0fd
ce262ae496ab3eeebfcbb337da86d34eb689c07b
/SEFoundation/SEComputationalGeometry/SERVector3.inl
45e94716a70ff31ff2908ac4c63893b669d4e65a
[]
no_license
pizibing/swingengine
d8d9208c00ec2944817e1aab51287a3c38103bea
e7109d7b3e28c4421c173712eaf872771550669e
refs/heads/master
2021-01-16T18:29:10.689858
2011-06-23T04:27:46
2011-06-23T04:27:46
33,969,301
0
0
null
null
null
null
UTF-8
C++
false
false
4,695
inl
// Swing Engine Version 1 Source Code // Most of techniques in the engine are mainly based on David Eberly's // Wild Magic 4 open-source code.The author of Swing Engine learned a lot // from Eberly's experience of architecture and algorithm. // Several sub-systems are totally new,and others are re-implimented or // re-organized based on Wild Magic 4's sub-systems. // Copyright (c) 2007-2010. All Rights Reserved // // Eberly's permission: // Geometric Tools, Inc. // http://www.geometrictools.com // Copyright (c) 1998-2006. All Rights Reserved // // This library is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation; either version 2.1 of the License, or (at // your option) any later version. The license is available for reading at // the location: // http://www.gnu.org/copyleft/lgpl.html //---------------------------------------------------------------------------- template <int ISIZE> SERVector3<ISIZE>::SERVector3() { // the vector is uninitialized } //---------------------------------------------------------------------------- template <int ISIZE> SERVector3<ISIZE>::SERVector3(const SERVector3& rV) { m_aTuple[0] = rV.m_aTuple[0]; m_aTuple[1] = rV.m_aTuple[1]; m_aTuple[2] = rV.m_aTuple[2]; } //---------------------------------------------------------------------------- #ifndef SE_USING_VC70 template <int ISIZE> SERVector3<ISIZE>::SERVector3(const SETRVector<3, ISIZE>& rV) { m_aTuple[0] = rV[0]; m_aTuple[1] = rV[1]; m_aTuple[2] = rV[2]; } #endif //---------------------------------------------------------------------------- template <int ISIZE> SERVector3<ISIZE>::SERVector3(const SETRational<ISIZE>& rX, const SETRational<ISIZE>& rY, const SETRational<ISIZE>& rZ) { m_aTuple[0] = rX; m_aTuple[1] = rY; m_aTuple[2] = rZ; } //---------------------------------------------------------------------------- template <int ISIZE> SERVector3<ISIZE>& SERVector3<ISIZE>::operator=(const SERVector3& rV) { m_aTuple[0] = rV.m_aTuple[0]; m_aTuple[1] = rV.m_aTuple[1]; m_aTuple[2] = rV.m_aTuple[2]; return *this; } //---------------------------------------------------------------------------- #ifndef SE_USING_VC70 template <int ISIZE> SERVector3<ISIZE>& SERVector3<ISIZE>::operator=(const SETRVector<3, ISIZE>& rV) { m_aTuple[0] = rV[0]; m_aTuple[1] = rV[1]; m_aTuple[2] = rV[2]; return *this; } #endif //---------------------------------------------------------------------------- template <int ISIZE> SETRational<ISIZE> SERVector3<ISIZE>::X() const { return m_aTuple[0]; } //---------------------------------------------------------------------------- template <int ISIZE> SETRational<ISIZE>& SERVector3<ISIZE>::X() { return m_aTuple[0]; } //---------------------------------------------------------------------------- template <int ISIZE> SETRational<ISIZE> SERVector3<ISIZE>::Y() const { return m_aTuple[1]; } //---------------------------------------------------------------------------- template <int ISIZE> SETRational<ISIZE>& SERVector3<ISIZE>::Y() { return m_aTuple[1]; } //---------------------------------------------------------------------------- template <int ISIZE> SETRational<ISIZE> SERVector3<ISIZE>::Z() const { return m_aTuple[2]; } //---------------------------------------------------------------------------- template <int ISIZE> SETRational<ISIZE>& SERVector3<ISIZE>::Z() { return m_aTuple[2]; } //---------------------------------------------------------------------------- template <int ISIZE> SETRational<ISIZE> SERVector3<ISIZE>::Dot(const SERVector3& rV) const { return m_aTuple[0]*rV.m_aTuple[0] + m_aTuple[1]*rV.m_aTuple[1] + m_aTuple[2]*rV.m_aTuple[2]; } //---------------------------------------------------------------------------- template <int ISIZE> SERVector3<ISIZE> SERVector3<ISIZE>::Cross(const SERVector3& rV) const { return SERVector3<ISIZE>( m_aTuple[1]*rV.m_aTuple[2] - m_aTuple[2]*rV.m_aTuple[1], m_aTuple[2]*rV.m_aTuple[0] - m_aTuple[0]*rV.m_aTuple[2], m_aTuple[0]*rV.m_aTuple[1] - m_aTuple[1]*rV.m_aTuple[0]); } //---------------------------------------------------------------------------- template <int ISIZE> SETRational<ISIZE> SERVector3<ISIZE>::TripleScalar(const SERVector3& rU, const SERVector3& rV) const { return Dot(rU.Cross(rV)); } //----------------------------------------------------------------------------
[ "[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac" ]
[ [ [ 1, 136 ] ] ]
a6a6f0f305bc913f4e978f332840ac2bd0658984
8d3bc2c1c82dee5806c4503dd0fd32908c78a3a9
/tools/xsi/src/xsi_nel_export/std_pch.h
48a24aad9e162c0159f10250b8e022fd8678e206
[]
no_license
ryzom/werewolf2
2645d169381294788bab9a152c4071061063a152
a868205216973cf4d1c7d2a96f65f88360177b69
refs/heads/master
2020-03-22T20:08:32.123283
2010-03-05T21:43:32
2010-03-05T21:43:32
140,575,749
0
0
null
null
null
null
UTF-8
C++
false
false
9,996
h
/* Copyright, 2003 Neverborn Entertainment. * This file is part of our XSI Plugins. * The XSI Plugins are free software, you can redistribute them and/or modify * them under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2, or (at your option) * any later version. * XSI Plugins are distributed WITHOUT ANY WARRANTY or implied warranty of * MERCHANTABILITY. See the GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with the XSI Plugins; see the file COPYING. If not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ #ifndef NEL_TOOLS_PCH_H #define NEL_TOOLS_PCH_H // // Windows Includes // #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstdarg> #include <ctime> #include <cerrno> #include <malloc.h> #include <winsock2.h> #include <atlbase.h> #include <shlobj.h> // // STLPort Includes // #include <algorithm> #include <bitset> #include <deque> #include <exception> #include <hash_map> #include <hash_set> #include <iterator> #include <iostream> #include <list> #include <map> #include <queue> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> // // XML Includes // #include <libxml/parser.h> // // XSI Includes // #include <xsi_actionsource.h> #include <xsi_animationsourceitem.h> #include <xsi_animsource.h> #include <xsi_application.h> #include <xsi_argument.h> #include <xsi_argumenthandler.h> #include <xsi_arrayparameter.h> #include <xsi_base.h> #include <xsi_boolarray.h> #include <xsi_camera.h> #include <xsi_camerarig.h> #include <xsi_chainbone.h> #include <xsi_chaineffector.h> #include <xsi_chainelement.h> #include <xsi_chainroot.h> #include <xsi_clip.h> #include <xsi_clipcontainer.h> #include <xsi_clipeffect.h> #include <xsi_clipeffectitem.h> #include <xsi_cliprelation.h> #include <xsi_cluster.h> #include <xsi_clusterproperty.h> #include <xsi_color.h> #include <xsi_comapihandler.h> #include <xsi_command.h> #include <xsi_consthistory.h> #include <xsi_constraint.h> #include <xsi_context.h> #include <xsi_controlpoint.h> #include <xsi_customoperator.h> #include <xsi_customproperty.h> #include <xsi_decl.h> #include <xsi_desktop.h> #include <xsi_dictionary.h> #include <xsi_directed.h> #include <xsi_doublearray.h> #include <xsi_edge.h> #include <xsi_envelope.h> #include <xsi_expression.h> #include <xsi_facet.h> #include <xsi_factory.h> #include <xsi_fcurve.h> #include <xsi_fcurvekey.h> #include <xsi_filter.h> #include <xsi_geometry.h> #include <xsi_graphicsequencer.h> #include <xsi_graphicsequencercontext.h> #include <xsi_griddata.h> #include <xsi_group.h> #include <xsi_image.h> #include <xsi_imageclip2.h> #include <xsi_imageclip.h> #include <xsi_inputport.h> #include <xsi_joint.h> #include <xsi_kinematics.h> #include <xsi_kinematicstate.h> #include <xsi_knot.h> #include <xsi_layer.h> #include <xsi_layout.h> #include <xsi_library.h> #include <xsi_light.h> #include <xsi_lightrig.h> #include <xsi_longarray.h> #include <xsi_mappeditem.h> #include <xsi_material.h> #include <xsi_math.h> #include <xsi_matrix3.h> #include <xsi_matrix4.h> #include <xsi_menu.h> #include <xsi_menuitem.h> #include <xsi_miuserdata_defs.h> #include <xsi_mixer.h> #include <xsi_model.h> #include <xsi_null.h> #include <xsi_nurbscurve.h> #include <xsi_nurbscurvelist.h> #include <xsi_nurbsdata.h> #include <xsi_nurbssample.h> #include <xsi_nurbssurface.h> #include <xsi_nurbssurfacemesh.h> #include <xsi_ogllight.h> #include <xsi_oglmaterial.h> #include <xsi_ogltexture.h> #include <xsi_operator.h> #include <xsi_outputport.h> #include <xsi_parameter.h> #include <xsi_particle.h> #include <xsi_particleattribute.h> #include <xsi_particlecloud.h> #include <xsi_particlecloudprimitive.h> #include <xsi_particletype.h> #include <xsi_pass.h> #include <xsi_plugin.h> #include <xsi_pluginitem.h> #include <xsi_pluginregistrar.h> #include <xsi_point.h> #include <xsi_polygonface.h> #include <xsi_polygonmesh.h> #include <xsi_polygonnode.h> #include <xsi_port.h> #include <xsi_portgroup.h> #include <xsi_ppgeventcontext.h> #include <xsi_ppgitem.h> #include <xsi_ppglayout.h> #include <xsi_preferences.h> #include <xsi_primitive.h> #include <xsi_progressbar.h> #include <xsi_project.h> #include <xsi_projectitem.h> #include <xsi_property.h> #include <xsi_proxyparameter.h> #include <xsi_quaternion.h> #include <xsi_ref.h> #include <xsi_rig.h> #include <xsi_rotation.h> #include <xsi_rtshaders.h> #include <xsi_sample.h> #include <xsi_scene.h> #include <xsi_sceneitem.h> #include <xsi_segment.h> #include <xsi_selection.h> #include <xsi_shader.h> #include <xsi_shapeclip.h> #include <xsi_shapekey.h> #include <xsi_siobject.h> #include <xsi_source.h> #include <xsi_statickinematicstate.h> #include <xsi_staticsource.h> #include <xsi_status.h> #include <xsi_string.h> #include <xsi_subcomponent.h> #include <xsi_texture.h> #include <xsi_texturelayer.h> #include <xsi_texturelayerport.h> #include <xsi_time.h> #include <xsi_timecontrol.h> #include <xsi_track.h> #include <xsi_transformation.h> #include <xsi_transition.h> #include <xsi_triangle.h> #include <xsi_trianglevertex.h> #include <xsi_uiobject.h> #include <xsi_uipersistable.h> #include <xsi_uitoolkit.h> #include <xsi_updatecontext.h> #include <xsi_userdatablob.h> #include <xsi_userdatamap.h> #include <xsi_uv.h> #include <xsi_value.h> #include <xsi_vector3.h> #include <xsi_vector4.h> #include <xsi_vertex.h> #include <xsi_vertexcolor.h> #include <xsi_view.h> #include <xsi_viewcontext.h> #include <xsi_viewnotification.h> #include <xsi_x3dobject.h> // // XSI Utilities // #include <SIBCArray.h> // // Remove Default MIN & MAX // #undef min #undef max // // NeL Misc Includes // #include <nel/misc/aabbox.h> #include <nel/misc/algo.h> #include <nel/misc/bit_mem_stream.h> #include <nel/misc/bit_set.h> #include <nel/misc/config_file.h> #include <nel/misc/command.h> #include <nel/misc/common.h> #include <nel/misc/displayer.h> #include <nel/misc/events.h> #include <nel/misc/event_server.h> #include <nel/misc/event_listener.h> #include <nel/misc/fast_mem.h> #include <nel/misc/file.h> #include <nel/misc/hierarchical_timer.h> #include <nel/misc/i_xml.h> #include <nel/misc/line.h> #include <nel/misc/matrix.h> #include <nel/misc/mem_displayer.h> #include <nel/misc/mem_stream.h> #include <nel/misc/o_xml.h> #include <nel/misc/path.h> #include <nel/misc/plane.h> #include <nel/misc/polygon.h> #include <nel/misc/progress_callback.h> #include <nel/misc/quat.h> #include <nel/misc/report.h> #include <nel/misc/rgba.h> #include <nel/misc/sha1.h> #include <nel/misc/smart_ptr.h> #include <nel/misc/stream.h> #include <nel/misc/stream_inline.h> #include <nel/misc/string_common.h> #include <nel/misc/string_mapper.h> #include <nel/misc/system_info.h> #include <nel/misc/thread.h> #include <nel/misc/types_nl.h> #include <nel/misc/time_nl.h> #include <nel/misc/uv.h> #include <nel/misc/value_smoother.h> #include <nel/misc/vector.h> #include <nel/misc/vectord.h> #include <nel/misc/vector_2d.h> // // NeL 3D Includes // #include <3d/animation.h> #include <3d/animated_material.h> #include <3d/coarse_mesh_manager.h> #include <3d/index_buffer.h> #include <3d/lod_character_shape.h> #include <3d/material.h> #include <3d/mesh_base.h> #include <3d/mesh_base_instance.h> #include <3d/mesh_blender.h> #include <3d/mesh_block_manager.h> #include <3d/mesh_geom.h> #include <3d/mesh.h> #include <3d/mesh_instance.h> #include <3d/mesh_mrm.h> #include <3d/mesh_mrm_instance.h> #include <3d/mesh_mrm_skinned.h> #include <3d/mesh_mrm_skinned_instance.h> #include <3d/mesh_multi_lod.h> #include <3d/mesh_multi_lod_instance.h> #include <3d/mesh_morpher.h> #include <3d/mesh_vertex_program.h> #include <3d/meshvp_per_pixel_light.h> #include <3d/meshvp_wind_tree.h> #include <3d/mrm_builder.h> #include <3d/mrm_internal.h> #include <3d/mrm_level_detail.h> #include <3d/mrm_mesh.h> #include <3d/mrm_parameters.h> #include <3d/patch.h> #include <3d/quad_grid.h> #include <3d/register_3d.h> #include <3d/scene.h> #include <3d/scene_user.h> #include <3d/shape.h> #include <3d/shape_bank.h> #include <3d/skeleton_model.h> #include <3d/skeleton_shape.h> #include <3d/stripifier.h> #include <3d/tangent_space_build.h> #include <3d/texture_cube.h> #include <3d/texture_file.h> #include <3d/transform_shape.h> #include <3d/vegetable_shape.h> #include <3d/vertex_buffer.h> #include <3d/water_model.h> #include <3d/water_shape.h> #include <3d/water_height_map.h> #include <3d/water_pool_manager.h> #include <nel/3d/animation_time.h> #include <nel/3d/u_animation.h> #include <nel/3d/u_animation_set.h> #include <nel/3d/u_camera.h> #include <nel/3d/u_cloud_scape.h> #include <nel/3d/u_driver.h> #include <nel/3d/u_instance.h> #include <nel/3d/u_instance_group.h> #include <nel/3d/u_landscape.h> #include <nel/3d/u_light.h> #include <nel/3d/u_material.h> #include <nel/3d/u_scene.h> #include <nel/3d/u_shape.h> #include <nel/3d/u_skeleton.h> #include <nel/3d/u_texture.h> #include <nel/3d/u_text_context.h> #include <nel/3d/u_track.h> #include <nel/3d/u_particle_system_instance.h> #include <nel/3d/u_play_list.h> #include <nel/3d/u_play_list_manager.h> #include <nel/3d/u_point_light.h> // // NeL Sound Includes // #include <nel/sound/u_audio_mixer.h> #include <nel/sound/u_listener.h> #include <nel/sound/u_source.h> // // MySQL Includes // #include <mysql.h> // // Angel Script Includes // #include <angelscript.h> // // Our Includes // #include "singleton.h" #endif
[ [ [ 1, 392 ] ] ]
f7693dc4a5d65a80b1bfd08e144f6974ae4b6e87
9a48be80edc7692df4918c0222a1640545384dbb
/Libraries/Boost1.40/libs/graph/example/knights-tour.cpp
5a191a143ee53c66986d17d218a258ccddf79673
[ "Artistic-2.0", "LicenseRef-scancode-public-domain", "BSL-1.0" ]
permissive
fcrick/RepSnapper
05e4fb1157f634acad575fffa2029f7f655b7940
a5809843f37b7162f19765e852b968648b33b694
refs/heads/master
2021-01-17T21:42:29.537504
2010-06-07T05:38:05
2010-06-07T05:38:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,490
cpp
//======================================================================= // Copyright 2001 Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee, // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) //======================================================================= #include <boost/config.hpp> #include <stdlib.h> #include <iostream> #include <stack> #include <queue> #include <boost/operators.hpp> #include <boost/graph/breadth_first_search.hpp> #include <boost/graph/visitors.hpp> #include <boost/property_map/property_map.hpp> using namespace boost; typedef std::pair < int, int > Position; Position knight_jumps[8] = { Position(2, -1), Position(1, -2), Position(-1, -2), Position(-2, -1), Position(-2, 1), Position(-1, 2), Position(1, 2), Position(2, 1) }; Position operator + (const Position & p1, const Position & p2) { return Position(p1.first + p2.first, p1.second + p2.second); } struct knights_tour_graph; struct knight_adjacency_iterator: public boost::forward_iterator_helper < knight_adjacency_iterator, Position, std::ptrdiff_t, Position *, Position > { knight_adjacency_iterator() { } knight_adjacency_iterator(int ii, Position p, const knights_tour_graph & g) : m_pos(p), m_g(&g), m_i(ii) { valid_position(); } Position operator *() const { return m_pos + knight_jumps[m_i]; } void operator++ () { ++m_i; valid_position(); } bool operator == (const knight_adjacency_iterator & x) const { return m_i == x. m_i; } protected: void valid_position(); Position m_pos; const knights_tour_graph * m_g; int m_i; }; struct knights_tour_graph { typedef Position vertex_descriptor; typedef std::pair < vertex_descriptor, vertex_descriptor > edge_descriptor; typedef knight_adjacency_iterator adjacency_iterator; typedef void out_edge_iterator; typedef void in_edge_iterator; typedef void edge_iterator; typedef void vertex_iterator; typedef int degree_size_type; typedef int vertices_size_type; typedef int edges_size_type; typedef directed_tag directed_category; typedef disallow_parallel_edge_tag edge_parallel_category; typedef adjacency_graph_tag traversal_category; knights_tour_graph(int n): m_board_size(n) { } int m_board_size; }; int num_vertices(const knights_tour_graph & g) { return g.m_board_size * g.m_board_size; } void knight_adjacency_iterator::valid_position() { Position new_pos = m_pos + knight_jumps[m_i]; while (m_i < 8 && (new_pos.first < 0 || new_pos.second < 0 || new_pos.first >= m_g->m_board_size || new_pos.second >= m_g->m_board_size)) { ++m_i; new_pos = m_pos + knight_jumps[m_i]; } } std::pair < knights_tour_graph::adjacency_iterator, knights_tour_graph::adjacency_iterator > adjacent_vertices(knights_tour_graph::vertex_descriptor v, const knights_tour_graph & g) { typedef knights_tour_graph::adjacency_iterator Iter; return std::make_pair(Iter(0, v, g), Iter(8, v, g)); } struct compare_first { template < typename P > bool operator() (const P & x, const P & y) { return x.first < y.first; } }; template < typename Graph, typename TimePropertyMap > bool backtracking_search(Graph & g, typename graph_traits < Graph >::vertex_descriptor src, TimePropertyMap time_map) { typedef typename graph_traits < Graph >::vertex_descriptor Vertex; typedef std::pair < int, Vertex > P; std::stack < P > S; int time_stamp = 0; S.push(std::make_pair(time_stamp, src)); while (!S.empty()) { Vertex x; tie(time_stamp, x) = S.top(); put(time_map, x, time_stamp); // all vertices have been visited, success! if (time_stamp == num_vertices(g) - 1) return true; bool deadend = true; typename graph_traits < Graph >::adjacency_iterator i, end; for (tie(i, end) = adjacent_vertices(x, g); i != end; ++i) if (get(time_map, *i) == -1) { S.push(std::make_pair(time_stamp + 1, *i)); deadend = false; } if (deadend) { put(time_map, x, -1); S.pop(); tie(time_stamp, x) = S.top(); while (get(time_map, x) != -1) { // unwind stack to last unexplored vertex put(time_map, x, -1); S.pop(); tie(time_stamp, x) = S.top(); } } } // while (!S.empty()) return false; } template < typename Vertex, typename Graph, typename TimePropertyMap > int number_of_successors(Vertex x, Graph & g, TimePropertyMap time_map) { int s_x = 0; typename graph_traits < Graph >::adjacency_iterator i, end; for (tie(i, end) = adjacent_vertices(x, g); i != end; ++i) if (get(time_map, *i) == -1) ++s_x; return s_x; } template < typename Graph, typename TimePropertyMap > bool warnsdorff(Graph & g, typename graph_traits < Graph >::vertex_descriptor src, TimePropertyMap time_map) { typedef typename graph_traits < Graph >::vertex_descriptor Vertex; typedef std::pair < int, Vertex > P; std::stack < P > S; int time_stamp = 0; S.push(std::make_pair(time_stamp, src)); while (!S.empty()) { Vertex x; tie(time_stamp, x) = S.top(); put(time_map, x, time_stamp); // all vertices have been visited, success! if (time_stamp == num_vertices(g) - 1) return true; // Put adjacent vertices into a local priority queue std::priority_queue < P, std::vector < P >, compare_first > Q; typename graph_traits < Graph >::adjacency_iterator i, end; int num_succ; for (tie(i, end) = adjacent_vertices(x, g); i != end; ++i) if (get(time_map, *i) == -1) { num_succ = number_of_successors(*i, g, time_map); Q.push(std::make_pair(num_succ, *i)); } bool deadend = Q.empty(); // move vertices from local priority queue to the stack for (; !Q.empty(); Q.pop()) { tie(num_succ, x) = Q.top(); S.push(std::make_pair(time_stamp + 1, x)); } if (deadend) { put(time_map, x, -1); S.pop(); tie(time_stamp, x) = S.top(); while (get(time_map, x) != -1) { // unwind stack to last unexplored vertex put(time_map, x, -1); S.pop(); tie(time_stamp, x) = S.top(); } } } // while (!S.empty()) return false; } struct board_map { typedef int value_type; typedef Position key_type; typedef read_write_property_map_tag category; board_map(int *b, int n):m_board(b), m_size(n) { } friend int get(const board_map & ba, Position p); friend void put(const board_map & ba, Position p, int v); friend std::ostream & operator << (std::ostream & os, const board_map & ba); private: int *m_board; int m_size; }; int get(const board_map & ba, Position p) { return ba.m_board[p.first * ba.m_size + p.second]; } void put(const board_map & ba, Position p, int v) { ba.m_board[p.first * ba.m_size + p.second] = v; } std::ostream & operator << (std::ostream & os, const board_map & ba) { for (int i = 0; i < ba.m_size; ++i) { for (int j = 0; j < ba.m_size; ++j) os << get(ba, Position(i, j)) << "\t"; os << std::endl; } return os; } int main(int argc, char *argv[]) { int N; if (argc == 2) N = atoi(argv[1]); else N = 8; knights_tour_graph g(N); int * board = new int[num_vertices(g)]; board_map chessboard(board, N); for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) put(chessboard, Position(i, j), -1); bool ret = warnsdorff(g, Position(0, 0), chessboard); if (ret) for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) std::cout << get(chessboard, Position(i, j)) << "\t"; std::cout << std::endl; } else std::cout << "method failed" << std::endl; return 0; }
[ "metrix@Blended.(none)" ]
[ [ [ 1, 342 ] ] ]
2e8b3d6336eb4716c40f9bae6a76e80dc6b62482
6253ab92ce2e85b4db9393aa630bde24655bd9b4
/Common/LidarClusterInterface/LidarClusterClient.cpp
bb1de7a5b24e491c4beacbb33093c1b113ea2edb
[]
no_license
Aand1/cornell-urban-challenge
94fd4df18fd4b6cc6e12d30ed8eed280826d4aed
779daae8703fe68e7c6256932883de32a309a119
refs/heads/master
2021-01-18T11:57:48.267384
2008-10-01T06:43:18
2008-10-01T06:43:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,716
cpp
#include "LidarClusterClient.h" typedef unsigned int uint; LidarClusterClient::LidarClusterClient(const char* multicast_ip,const USHORT port){ udp_params params = udp_params(); params.remote_ip = inet_addr(multicast_ip); params.local_port = port; params.reuse_addr = true; conn = new udp_connection (params); conn->set_callback (MakeDelegate(this,&LidarClusterClient::UDPCallback),conn); sequenceNumber=0; dropCount=0; packetCount=0; printf("LidarCluster RX Interface Initialized. %s:%d\r\n",multicast_ip,port); } LidarClusterClient::~LidarClusterClient (){ delete conn; } void LidarClusterClient::SetCallback(LidarClusterCallbackType callback, void* arg) { this->callback = callback; this->callback_arg = arg; } void LidarClusterClient::UDPCallback(udp_message& msg, udp_connection* conn, void* arg){ packetCount++; if(msg.len < sizeof(ClusterPacketHdr)) return; // packet too small! if(msg.data[0] != CLUSTER_PACKET_TYPE) return; // don't know how to handle anything but scan data packets ClusterPacketHdr * hdr = (ClusterPacketHdr*)msg.data; size_t calced_size = sizeof(ClusterPacketHdr) + hdr->numPts*sizeof(ClusterPacketPoint) + hdr->numClusters*sizeof(ClusterPacketCluster); if(msg.len!=calced_size) return; // ERRROR! size mismatch int rxSequenceNumber= (int)hdr->packetNum; dropCount += (rxSequenceNumber-(sequenceNumber+1)); sequenceNumber = rxSequenceNumber; vector<v3f> pts; uint i; for(i=0;i<hdr->numPts;i++){ ClusterPacketPoint* p = (ClusterPacketPoint*)(msg.data+sizeof(ClusterPacketHdr)+i*sizeof(ClusterPacketPoint)); v3f pt = v3f((float)p->X/100.f,(float)p->Y/100.f,(float)p->Z/100.f); pts.push_back(pt); } vector<LidarCluster> ret; for(i=0;i<hdr->numClusters;i++){ ClusterPacketCluster* c = (ClusterPacketCluster*)(msg.data+sizeof(ClusterPacketHdr)+hdr->numPts*sizeof(ClusterPacketPoint)+i*sizeof(ClusterPacketCluster)); LidarCluster lc; lc.stable = (c->flags&0x01)?false:true; lc.leftOccluded = (c->flags&0x02)?true:false; lc.rightOccluded = (c->flags&0x04)?true:false; lc.highObstacle = (c->flags&0x08)?true:false; for(uint j=c->firstPtIndex;j<=c->lastPtIndex;j++) lc.pts.push_back(pts[j]); ret.push_back(lc); } double vts = (double)hdr->tsSeconds + (double)hdr->tsTicks/10000.0; if (!(callback.empty())) callback(ret, vts, callback_arg); if (packetCount%100==0) { #ifdef PRINT_PACKET_COUNT_DEBUG printf("LC: Packets: %d Seq: %d Dropped: %d Drop Rate: %f \r\n",packetCount,sequenceNumber,dropCount,((float)dropCount/(float)packetCount)*100.0f); #endif packetCount=0; dropCount=0; } }
[ "anathan@5031bdca-8e6f-11dd-8a4e-8714b3728bc5" ]
[ [ [ 1, 76 ] ] ]
a1445838ea2a775bfa5aaa3ee08e7959af9718e6
d54d8b1bbc9575f3c96853e0c67f17c1ad7ab546
/hlsdk-2.3-p3/multiplayer/dlls/egon.cpp
2e7a229b412927f8285c50d1d80d9e615a73ce50
[]
no_license
joropito/amxxgroup
637ee71e250ffd6a7e628f77893caef4c4b1af0a
f948042ee63ebac6ad0332f8a77393322157fa8f
refs/heads/master
2021-01-10T09:21:31.449489
2010-04-11T21:34:27
2010-04-11T21:34:27
47,087,485
1
0
null
null
null
null
UTF-8
C++
false
false
13,352
cpp
/*** * * Copyright (c) 1996-2002, Valve LLC. All rights reserved. * * This product contains software technology licensed from Id * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * All Rights Reserved. * * Use, distribution, and modification of this source code and/or resulting * object code is restricted to non-commercial enhancements to products from * Valve LLC. All other use, distribution, or modification is prohibited * without written permission from Valve LLC. * ****/ #if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) #include "extdll.h" #include "util.h" #include "cbase.h" #include "player.h" #include "monsters.h" #include "weapons.h" #include "nodes.h" #include "effects.h" #include "customentity.h" #include "gamerules.h" #define EGON_PRIMARY_VOLUME 450 #define EGON_BEAM_SPRITE "sprites/xbeam1.spr" #define EGON_FLARE_SPRITE "sprites/XSpark1.spr" #define EGON_SOUND_OFF "weapons/egon_off1.wav" #define EGON_SOUND_RUN "weapons/egon_run3.wav" #define EGON_SOUND_STARTUP "weapons/egon_windup2.wav" #define EGON_SWITCH_NARROW_TIME 0.75 // Time it takes to switch fire modes #define EGON_SWITCH_WIDE_TIME 1.5 enum egon_e { EGON_IDLE1 = 0, EGON_FIDGET1, EGON_ALTFIREON, EGON_ALTFIRECYCLE, EGON_ALTFIREOFF, EGON_FIRE1, EGON_FIRE2, EGON_FIRE3, EGON_FIRE4, EGON_DRAW, EGON_HOLSTER }; LINK_ENTITY_TO_CLASS( weapon_egon, CEgon ); void CEgon::Spawn( ) { Precache( ); m_iId = WEAPON_EGON; SET_MODEL(ENT(pev), "models/w_egon.mdl"); m_iDefaultAmmo = EGON_DEFAULT_GIVE; FallInit();// get ready to fall down. } void CEgon::Precache( void ) { PRECACHE_MODEL("models/w_egon.mdl"); PRECACHE_MODEL("models/v_egon.mdl"); PRECACHE_MODEL("models/p_egon.mdl"); PRECACHE_MODEL("models/w_9mmclip.mdl"); PRECACHE_SOUND("items/9mmclip1.wav"); PRECACHE_SOUND( EGON_SOUND_OFF ); PRECACHE_SOUND( EGON_SOUND_RUN ); PRECACHE_SOUND( EGON_SOUND_STARTUP ); PRECACHE_MODEL( EGON_BEAM_SPRITE ); PRECACHE_MODEL( EGON_FLARE_SPRITE ); PRECACHE_SOUND ("weapons/357_cock1.wav"); m_usEgonFire = PRECACHE_EVENT ( 1, "events/egon_fire.sc" ); m_usEgonStop = PRECACHE_EVENT ( 1, "events/egon_stop.sc" ); } BOOL CEgon::Deploy( void ) { m_deployed = FALSE; m_fireState = FIRE_OFF; return DefaultDeploy( "models/v_egon.mdl", "models/p_egon.mdl", EGON_DRAW, "egon" ); } int CEgon::AddToPlayer( CBasePlayer *pPlayer ) { if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) { MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); WRITE_BYTE( m_iId ); MESSAGE_END(); return TRUE; } return FALSE; } void CEgon::Holster( int skiplocal /* = 0 */ ) { m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; SendWeaponAnim( EGON_HOLSTER ); EndAttack(); } int CEgon::GetItemInfo(ItemInfo *p) { p->pszName = STRING(pev->classname); p->pszAmmo1 = "uranium"; p->iMaxAmmo1 = URANIUM_MAX_CARRY; p->pszAmmo2 = NULL; p->iMaxAmmo2 = -1; p->iMaxClip = WEAPON_NOCLIP; p->iSlot = 3; p->iPosition = 2; p->iId = m_iId = WEAPON_EGON; p->iFlags = 0; p->iWeight = EGON_WEIGHT; return 1; } #define EGON_PULSE_INTERVAL 0.1 #define EGON_DISCHARGE_INTERVAL 0.1 float CEgon::GetPulseInterval( void ) { return EGON_PULSE_INTERVAL; } float CEgon::GetDischargeInterval( void ) { return EGON_DISCHARGE_INTERVAL; } BOOL CEgon::HasAmmo( void ) { if ( m_pPlayer->ammo_uranium <= 0 ) return FALSE; return TRUE; } void CEgon::UseAmmo( int count ) { if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] >= count ) m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= count; else m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] = 0; } void CEgon::Attack( void ) { // don't fire underwater if ( m_pPlayer->pev->waterlevel == 3 ) { if ( m_fireState != FIRE_OFF || m_pBeam ) { EndAttack(); } else { PlayEmptySound( ); } return; } UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); Vector vecAiming = gpGlobals->v_forward; Vector vecSrc = m_pPlayer->GetGunPosition( ); int flags; #if defined( CLIENT_WEAPONS ) flags = FEV_NOTHOST; #else flags = 0; #endif switch( m_fireState ) { case FIRE_OFF: { if ( !HasAmmo() ) { m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.25; PlayEmptySound( ); return; } m_flAmmoUseTime = gpGlobals->time;// start using ammo ASAP. PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usEgonFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, m_fireState, m_fireMode, 1, 0 ); m_shakeTime = 0; m_pPlayer->m_iWeaponVolume = EGON_PRIMARY_VOLUME; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1; pev->fuser1 = UTIL_WeaponTimeBase() + 2; pev->dmgtime = gpGlobals->time + GetPulseInterval(); m_fireState = FIRE_CHARGE; } break; case FIRE_CHARGE: { Fire( vecSrc, vecAiming ); m_pPlayer->m_iWeaponVolume = EGON_PRIMARY_VOLUME; if ( pev->fuser1 <= UTIL_WeaponTimeBase() ) { PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usEgonFire, 0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, m_fireState, m_fireMode, 0, 0 ); pev->fuser1 = 1000; } if ( !HasAmmo() ) { EndAttack(); m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0; } } break; } } void CEgon::PrimaryAttack( void ) { m_fireMode = FIRE_WIDE; Attack(); } void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) { Vector vecDest = vecOrigSrc + vecDir * 2048; edict_t *pentIgnore; TraceResult tr; pentIgnore = m_pPlayer->edict(); Vector tmpSrc = vecOrigSrc + gpGlobals->v_up * -8 + gpGlobals->v_right * 3; // ALERT( at_console, "." ); UTIL_TraceLine( vecOrigSrc, vecDest, dont_ignore_monsters, pentIgnore, &tr ); if (tr.fAllSolid) return; #ifndef CLIENT_DLL CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); if (pEntity == NULL) return; if ( g_pGameRules->IsMultiplayer() ) { if ( m_pSprite && pEntity->pev->takedamage ) { m_pSprite->pev->effects &= ~EF_NODRAW; } else if ( m_pSprite ) { m_pSprite->pev->effects |= EF_NODRAW; } } #endif float timedist; switch ( m_fireMode ) { case FIRE_NARROW: #ifndef CLIENT_DLL if ( pev->dmgtime < gpGlobals->time ) { // Narrow mode only does damage to the entity it hits ClearMultiDamage(); if (pEntity->pev->takedamage) { pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgEgonNarrow, vecDir, &tr, DMG_ENERGYBEAM ); } ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev); if ( g_pGameRules->IsMultiplayer() ) { // multiplayer uses 1 ammo every 1/10th second if ( gpGlobals->time >= m_flAmmoUseTime ) { UseAmmo( 1 ); m_flAmmoUseTime = gpGlobals->time + 0.1; } } else { // single player, use 3 ammo/second if ( gpGlobals->time >= m_flAmmoUseTime ) { UseAmmo( 1 ); m_flAmmoUseTime = gpGlobals->time + 0.166; } } pev->dmgtime = gpGlobals->time + GetPulseInterval(); } #endif timedist = ( pev->dmgtime - gpGlobals->time ) / GetPulseInterval(); break; case FIRE_WIDE: #ifndef CLIENT_DLL if ( pev->dmgtime < gpGlobals->time ) { // wide mode does damage to the ent, and radius damage ClearMultiDamage(); if (pEntity->pev->takedamage) { pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgEgonWide, vecDir, &tr, DMG_ENERGYBEAM | DMG_ALWAYSGIB); } ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev); if ( g_pGameRules->IsMultiplayer() ) { // radius damage a little more potent in multiplayer. ::RadiusDamage( tr.vecEndPos, pev, m_pPlayer->pev, gSkillData.plrDmgEgonWide/4, 128, CLASS_NONE, DMG_ENERGYBEAM | DMG_BLAST | DMG_ALWAYSGIB ); } if ( !m_pPlayer->IsAlive() ) return; if ( g_pGameRules->IsMultiplayer() ) { //multiplayer uses 5 ammo/second if ( gpGlobals->time >= m_flAmmoUseTime ) { UseAmmo( 1 ); m_flAmmoUseTime = gpGlobals->time + 0.2; } } else { // Wide mode uses 10 charges per second in single player if ( gpGlobals->time >= m_flAmmoUseTime ) { UseAmmo( 1 ); m_flAmmoUseTime = gpGlobals->time + 0.1; } } pev->dmgtime = gpGlobals->time + GetDischargeInterval(); if ( m_shakeTime < gpGlobals->time ) { UTIL_ScreenShake( tr.vecEndPos, 5.0, 150.0, 0.75, 250.0 ); m_shakeTime = gpGlobals->time + 1.5; } } #endif timedist = ( pev->dmgtime - gpGlobals->time ) / GetDischargeInterval(); break; } if ( timedist < 0 ) timedist = 0; else if ( timedist > 1 ) timedist = 1; timedist = 1-timedist; UpdateEffect( tmpSrc, tr.vecEndPos, timedist ); } void CEgon::UpdateEffect( const Vector &startPoint, const Vector &endPoint, float timeBlend ) { #ifndef CLIENT_DLL if ( !m_pBeam ) { CreateEffect(); } m_pBeam->SetStartPos( endPoint ); m_pBeam->SetBrightness( 255 - (timeBlend*180) ); m_pBeam->SetWidth( 40 - (timeBlend*20) ); if ( m_fireMode == FIRE_WIDE ) m_pBeam->SetColor( 30 + (25*timeBlend), 30 + (30*timeBlend), 64 + 80*fabs(sin(gpGlobals->time*10)) ); else m_pBeam->SetColor( 60 + (25*timeBlend), 120 + (30*timeBlend), 64 + 80*fabs(sin(gpGlobals->time*10)) ); UTIL_SetOrigin( m_pSprite->pev, endPoint ); m_pSprite->pev->frame += 8 * gpGlobals->frametime; if ( m_pSprite->pev->frame > m_pSprite->Frames() ) m_pSprite->pev->frame = 0; m_pNoise->SetStartPos( endPoint ); #endif } void CEgon::CreateEffect( void ) { #ifndef CLIENT_DLL DestroyEffect(); m_pBeam = CBeam::BeamCreate( EGON_BEAM_SPRITE, 40 ); m_pBeam->PointEntInit( pev->origin, m_pPlayer->entindex() ); m_pBeam->SetFlags( BEAM_FSINE ); m_pBeam->SetEndAttachment( 1 ); m_pBeam->pev->spawnflags |= SF_BEAM_TEMPORARY; // Flag these to be destroyed on save/restore or level transition m_pBeam->pev->flags |= FL_SKIPLOCALHOST; m_pBeam->pev->owner = m_pPlayer->edict(); m_pNoise = CBeam::BeamCreate( EGON_BEAM_SPRITE, 55 ); m_pNoise->PointEntInit( pev->origin, m_pPlayer->entindex() ); m_pNoise->SetScrollRate( 25 ); m_pNoise->SetBrightness( 100 ); m_pNoise->SetEndAttachment( 1 ); m_pNoise->pev->spawnflags |= SF_BEAM_TEMPORARY; m_pNoise->pev->flags |= FL_SKIPLOCALHOST; m_pNoise->pev->owner = m_pPlayer->edict(); m_pSprite = CSprite::SpriteCreate( EGON_FLARE_SPRITE, pev->origin, FALSE ); m_pSprite->pev->scale = 1.0; m_pSprite->SetTransparency( kRenderGlow, 255, 255, 255, 255, kRenderFxNoDissipation ); m_pSprite->pev->spawnflags |= SF_SPRITE_TEMPORARY; m_pSprite->pev->flags |= FL_SKIPLOCALHOST; m_pSprite->pev->owner = m_pPlayer->edict(); if ( m_fireMode == FIRE_WIDE ) { m_pBeam->SetScrollRate( 50 ); m_pBeam->SetNoise( 20 ); m_pNoise->SetColor( 50, 50, 255 ); m_pNoise->SetNoise( 8 ); } else { m_pBeam->SetScrollRate( 110 ); m_pBeam->SetNoise( 5 ); m_pNoise->SetColor( 80, 120, 255 ); m_pNoise->SetNoise( 2 ); } #endif } void CEgon::DestroyEffect( void ) { #ifndef CLIENT_DLL if ( m_pBeam ) { UTIL_Remove( m_pBeam ); m_pBeam = NULL; } if ( m_pNoise ) { UTIL_Remove( m_pNoise ); m_pNoise = NULL; } if ( m_pSprite ) { if ( m_fireMode == FIRE_WIDE ) m_pSprite->Expand( 10, 500 ); else UTIL_Remove( m_pSprite ); m_pSprite = NULL; } #endif } void CEgon::WeaponIdle( void ) { ResetEmptySound( ); if ( m_flTimeWeaponIdle > gpGlobals->time ) return; if ( m_fireState != FIRE_OFF ) EndAttack(); int iAnim; float flRand = RANDOM_FLOAT(0,1); if ( flRand <= 0.5 ) { iAnim = EGON_IDLE1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } else { iAnim = EGON_FIDGET1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3; } SendWeaponAnim( iAnim ); m_deployed = TRUE; } void CEgon::EndAttack( void ) { bool bMakeNoise = false; if ( m_fireState != FIRE_OFF ) //Checking the button just in case!. bMakeNoise = true; PLAYBACK_EVENT_FULL( FEV_GLOBAL | FEV_RELIABLE, m_pPlayer->edict(), m_usEgonStop, 0, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, 0.0, 0.0, bMakeNoise, 0, 0, 0 ); m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0; m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; m_fireState = FIRE_OFF; DestroyEffect(); } class CEgonAmmo : public CBasePlayerAmmo { void Spawn( void ) { Precache( ); SET_MODEL(ENT(pev), "models/w_chainammo.mdl"); CBasePlayerAmmo::Spawn( ); } void Precache( void ) { PRECACHE_MODEL ("models/w_chainammo.mdl"); PRECACHE_SOUND("items/9mmclip1.wav"); } BOOL AddAmmo( CBaseEntity *pOther ) { if (pOther->GiveAmmo( AMMO_URANIUMBOX_GIVE, "uranium", URANIUM_MAX_CARRY ) != -1) { EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); return TRUE; } return FALSE; } }; LINK_ENTITY_TO_CLASS( ammo_egonclip, CEgonAmmo ); #endif
[ "joropito@23c7d628-c96c-11de-a380-73d83ba7c083" ]
[ [ [ 1, 568 ] ] ]
6b4acb0eca1e3cc7acb605b3bcf13e1e2e68b190
681bb5f9936ef6f437ffe6fb340ea68b40b5505a
/logging/log_provider_file.cpp
e34bcafe79c4d26de8fcc35bf00505aecb346fd0
[]
no_license
wingrime/zme7
d08d131b667dc31683a2fd23f65c9d46b87e92c7
c6fac20b8033ed9c791c188c3e9298285a8fe524
refs/heads/master
2021-01-23T13:50:02.331808
2011-10-01T20:19:34
2011-10-01T20:19:34
2,496,406
0
0
null
null
null
null
UTF-8
C++
false
false
575
cpp
#include "log_stdafx.h" #include "log_provider_file.h" cLogError cLogProviderFile::OutputHandle(LPLOGSTR lpStrOut) { if (lpOutHandle) { fprintf(lpOutHandle,"%s\n",lpStrOut); fflush(lpOutHandle); return LOG_ERR_SUCCESS; } return LOG_ERR_FAILL; } cLogError cLogProviderFile::Init(LPLOGSTR OutFile) { lpOutHandle = fopen(OutFile,"wt"); if (lpOutHandle == NULL) return LOG_ERR_FAILL; return LOG_ERR_SUCCESS; } cLogError cLogProviderFile::Release() { if (lpOutHandle) { fclose(lpOutHandle); return LOG_ERR_SUCCESS; } return LOG_ERR_FAILL; }
[ [ [ 1, 28 ] ] ]
4e87346580663fa95d4b16e764b98beb041882e9
1d5c2ff3350d099bf57049a3a66915d7ba91c39f
/ConnectionProgressDialog.cpp
8f5579d0da2a2237636db3d288d27df6f1d8e8e2
[]
no_license
kjk/moriarty-sm
f73f9a4f5e1ac9bfa923fdcfd1fc7a308d5db057
75cfa46e60e75c6054549800270601448ab5b3b9
refs/heads/master
2021-01-20T06:20:11.762112
2005-10-17T15:39:11
2005-10-17T15:39:11
18,798
2
0
null
null
null
null
UTF-8
C++
false
false
5,098
cpp
#include "ConnectionProgressDialog.h" #include "InfoMan.h" #include "InfoManGlobals.h" #include "LookupManager.h" #include "InfoManConnection.h" #include <SysUtils.hpp> #include <ExtendedEvent.hpp> #include <Text.hpp> using namespace DRA; ConnectionProgressDialog::ConnectionProgressDialog(AutoDeleteOption ad, InfoManConnection* conn): Dialog(ad, false, SHIDIF_SIPDOWN), lookupManager_(*GetLookupManager()), connectionToEnqueue_(conn) { assert(NULL != conn); setSizeToInputPanel(false); } bool ConnectionProgressDialog::handleInitDialog(HWND focus_widget_handle, long init_param) { extEventHelper_.start(handle()); progressBar_.attachControl(handle(), IDC_CONNECTION_PROGRESS); progressBytesText_.attachControl(handle(), IDC_PROGRESS_BYTES); Dialog::handleInitDialog(focus_widget_handle, init_param); status_t err = connectionToEnqueue_->enqueue(); assert(errNone == err); handleScreenSizeChange(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); progressBar_.setRange(0, 100); updateProgress(); return true; } ConnectionProgressDialog* ConnectionProgressDialog::create(HWND parent, InfoManConnection* conn) { ConnectionProgressDialog* dlg = new_nt ConnectionProgressDialog(autoDelete, conn); if (NULL == dlg) return NULL; bool res = dlg->Dialog::create(GetInstance(), IDD_CONNECTION_PROGRESS, parent); if (!res) { delete dlg; return NULL; } return dlg; } long ConnectionProgressDialog::showModal(HWND owner, InfoManConnection* conn) { ConnectionProgressDialog dlg(autoDeleteNot, conn); return dlg.Dialog::showModal(GetInstance(), IDD_CONNECTION_PROGRESS, owner); } long ConnectionProgressDialog::handleCommand(ushort notify_code, ushort id, HWND sender) { switch (id) { case IDCANCEL: { bool active = lookupManager_.connectionManager().active(); lookupManager_.abortConnections(); extEventHelper_.stop(); EndDialog(handle(), IDCANCEL); if (!active) return messageHandled; LookupFinishedEventData* data = new_nt LookupFinishedEventData(); if (NULL != data) { data->result = lookupResultConnectionCancelledByUser; ExtEventSendObject(extEventLookupFinished, data); } return messageHandled; } } return Dialog::handleCommand(notify_code, id, sender); } long ConnectionProgressDialog::handleResize(UINT sizeType, ushort width, ushort height) { anchorChild(IDC_PROGRESS_TEXT, anchorRight, SCALEX(20), anchorNone, 0); progressBar_.anchor(anchorRight, SCALEX(20), anchorNone, 0); progressBytesText_.anchor(anchorRight, SCALEX(20), anchorNone, 0); anchorChild(IDCANCEL, anchorLeft, SCALEX(86), anchorNone, 0); return Dialog::handleResize(sizeType, width, height); } long ConnectionProgressDialog::handleExtendedEvent(LPARAM& event) { LookupManager* lm = GetLookupManager(); lm->handleLookupEvent(event); switch (ExtEventGetID(event)) { case extEventLookupStarted: case extEventLookupProgress: updateProgress(); return messageHandled; case extEventLookupFinished: { const LookupFinishedEventData* data = LookupFinishedData(event); extEventHelper_.stop(); EndDialog(handle(), IDOK); ExtEventRepost(event); return messageHandled; } } return Dialog::handleExtendedEvent(event); } void ConnectionProgressDialog::updateProgress() { char_t buffer[32]; LookupManager::Guard g(lookupManager_); uint_t percent = lookupManager_.percentProgress(); if (LookupManager::percentProgressDisabled == percent) { progressBar_.hide(); // TODO: add pretty formatting of bytes if (0 == lookupManager_.bytesProgress()) progressBytesText_.hide(); else { tprintf(buffer, TEXT("Progress: %lu bytes."), lookupManager_.bytesProgress()); progressBytesText_.setCaption(buffer); progressBytesText_.show(); } } else { progressBytesText_.hide(); progressBar_.setPosition(percent); progressBar_.show(); } if (NULL == lookupManager_.statusText || 0 == Len(lookupManager_ .statusText)) SetDlgItemText(handle(), IDC_PROGRESS_TEXT, TEXT("Please wait...")); else SetDlgItemText(handle(), IDC_PROGRESS_TEXT, lookupManager_.statusText); update(); } void ConnectionProgressDialog::handleScreenSizeChange(ulong_t w, ulong_t h) { Rect r; bounds(r); if (r.width() + SCALEX(4) != long(w)) { r.x() = SCALEX(2); r.setWidth(w - SCALEX(4)); setBounds(r, repaintWidget); } }
[ "andrzejc@9579cb1a-affb-0310-8771-bc50cd49e4fc" ]
[ [ [ 1, 159 ] ] ]
f3eb6163be87dc04a02ed9a9172486f326f48960
b2155efef00dbb04ae7a23e749955f5ec47afb5a
/demo/common/BaseApp.cpp
f71dbf3bdbfdbbf9154f6f0021785fead15c5c03
[]
no_license
zjhlogo/originengine
00c0bd3c38a634b4c96394e3f8eece86f2fe8351
a35a83ed3f49f6aeeab5c3651ce12b5c5a43058f
refs/heads/master
2021-01-20T13:48:48.015940
2011-04-21T04:10:54
2011-04-21T04:10:54
32,371,356
1
0
null
null
null
null
UTF-8
C++
false
false
2,275
cpp
/*! * \file BaseApp.cpp * \date 8-18-2010 10:50:41 * * * \author zjhlogo ([email protected]) */ #include "BaseApp.h" #include <OECore/IOECore.h> #include <OEUI/IOEUIRenderSystem.h> CBaseApp::CBaseApp() { Init(); } CBaseApp::~CBaseApp() { Destroy(); } void CBaseApp::Init() { m_pCamera = NULL; m_pFPS = NULL; } void CBaseApp::Destroy() { // TODO: } bool CBaseApp::Initialize() { m_pCamera = new CCamera(); if (!m_pCamera) return false; IOENode* pRootNode = g_pOECore->GetRootNode(); if (!pRootNode) return false; IOENode* pCameraNode = pRootNode->GetChildNode(TS("Camera")); if (!pCameraNode) return false; m_pCamera->SetTargetNode(pCameraNode); m_pFPS = new CFPSWindow(g_pOEUIRenderSystem->GetScreen()); if (!m_pFPS) return false; if (!UserDataInit()) return false; g_pOEUIRenderSystem->GetScreen()->SetChildWindowLayer(m_pFPS, COEUIWindow::WL_FRONT); return true; } void CBaseApp::Terminate() { UserDataTerm(); SAFE_DELETE(m_pCamera); } void CBaseApp::PreUpdate(float fDetailTime) { m_pCamera->Update(fDetailTime); } void CBaseApp::PostUpdate(float fDetailTime) { // TODO: } void CBaseApp::ResetCameraPosRot(IOEModel* pModel) { IOEMesh* pMesh = pModel->GetRenderData()->GetMesh(TS("MainMesh")); m_pCamera->InitFromBBox(pMesh->GetBoundingBoxMin(), pMesh->GetBoundingBoxMax()); } void CBaseApp::ResetCameraPosRot(const CVector3& vPos, float fRotY, float fRotX) { m_pCamera->MoveTo(vPos); m_pCamera->RotateTo(fRotY, fRotX); } void CBaseApp::ResetCameraPosRot(const CVector3& vPos, const CQuaternion& qRot) { m_pCamera->MoveTo(vPos); float x, y, z; COEMath::GetEulerAngle(x, y, z, qRot); m_pCamera->RotateTo(y, x); } void CBaseApp::SetMovementSpeed(float fSpeed) { m_pCamera->SetMovementSpeed(fSpeed); } float CBaseApp::GetMovementSpeed() { return m_pCamera->GetMovementSpeed(); } void CBaseApp::SetRotationSpeed(float fSpeed) { m_pCamera->SetRotationSpeed(fSpeed); } float CBaseApp::GetRotationSpeed() { return m_pCamera->GetRotationSpeed(); } void CBaseApp::ShowFPS(bool bShow) { m_pFPS->ShowFPS(bShow); } void CBaseApp::ShowCameraPosRot(bool bShow) { m_pFPS->ShowCameraPosRot(bShow); }
[ "zjhlogo@fdcc8808-487c-11de-a4f5-9d9bc3506571" ]
[ [ [ 1, 120 ] ] ]
2bfde6e6037617e691db35eae37b0318462bd632
a4859141cc6b22cc80055678fb4aaa261a958570
/src/BipartiteGraph_old.hpp
1b219ca0772af8fce1caad737b7a99dc4a51e858
[]
no_license
csce622/bbgl
7ac377355331afe7e69631b4e8d66478db04f542
80a7b4f4ab8cae07542e6d449bdabfbe7efe2a73
refs/heads/master
2021-01-01T16:56:11.105311
2010-12-01T17:52:12
2010-12-01T17:52:12
1,009,649
0
0
null
null
null
null
UTF-8
C++
false
false
7,068
hpp
#ifndef _BIPARTITEGRAPH_H #define _BIPARTITEGRAPH_H #include<iostream> #include<conio.h> #include<vector> #include<map> #include<algorithm> #include"graph_traits_BG_old.hpp" using namespace std; namespace bipartite_old { template<class TypeOne, class TypeTwo> class BipartiteGraph { //private: //typedef pair<TypeOne, vector<int>> type_one_vertex; //typedef pair<TypeTwo, vector<int>> type_two_vertex; public: //vector<type_one_vertex> type_one_vertices; //vector<type_two_vertex> type_two_vertices; //vertex one descriptoe is simply the type of vertex one //vertex two descriptor is simply the type of vertex two typedef TypeOne vertex_type_one_descriptor; typedef TypeTwo vertex_type_two_descriptor; //Edges are differentiated based on source and destination //A type one edge is defined when source is of type one and destination is of type two //A type two edge is defined when source is of type two and destination is of type one typedef pair<TypeOne, TypeTwo> EdgeTypeOne; //type of Type one edge typedef pair<TypeTwo, TypeOne> EdgeTypeTwo; //type of Type two edge //Each edge descriptor is a pair type with source as its first type and destination as its second type typedef EdgeTypeOne edge_type_one_descriptor; typedef EdgeTypeTwo edge_type_two_descriptor; typedef map<TypeOne, vector<TypeTwo>> map_vertices_type_one; typedef map<TypeTwo, vector<TypeOne>> map_vertices_type_two; map_vertices_type_one vertices_type_one; map_vertices_type_two vertices_type_two; }; //Adds a vertex of type one to bipartite graph. template <class BpGraph> bool add_vertex_type_one(BpGraph &bpGraph, typename graph_traits_BG<BpGraph>::vertex_type_one_descriptor key) { typedef typename BpGraph::map_vertices_type_one map_vertices_type_one; typedef vector<graph_traits_BG<BpGraph>::vertex_type_two_descriptor> vec_two_type; typedef pair<typename graph_traits_BG<BpGraph>::vertex_type_one_descriptor, vec_two_type> pair_to_insert; vec_two_type emptyVec; pair<map_vertices_type_one::iterator, bool> is_not_exist = bpGraph.vertices_type_one.insert(pair_to_insert(key, emptyVec)); return is_not_exist.second; } //Adds a vertex of type one to bipartite graph. template <class BpGraph> bool add_vertex_type_two(BpGraph &bpGraph, typename graph_traits_BG<BpGraph>::vertex_type_two_descriptor key) { typedef typename BpGraph::map_vertices_type_two map_vertices_type_two; typedef vector<graph_traits_BG<BpGraph>::vertex_type_one_descriptor> vec_one_type; typedef pair<typename graph_traits_BG<BpGraph>::vertex_type_two_descriptor, vec_one_type> pair_to_insert; vec_one_type emptyVec; pair<map_vertices_type_two::iterator, bool> is_not_exist = bpGraph.vertices_type_two.insert(pair_to_insert(key, emptyVec)); return is_not_exist.second; } template <class BpGraph> bool add_edge_type_one(BpGraph& bpGraph, typename graph_traits_BG<BpGraph>::vertex_type_one_descriptor sourceVertex, typename graph_traits_BG<BpGraph>::vertex_type_two_descriptor destinationVertex) { bool edge_doesnt_exists = false; typedef typename BpGraph::map_vertices_type_one map_vertices_type_one; //map type of vertices type one typedef typename BpGraph::map_vertices_type_two map_vertices_type_two; //map type of verices type two typedef graph_traits_BG<BpGraph>::vertex_type_one_descriptor sourceVertexType; typedef graph_traits_BG<BpGraph>::vertex_type_two_descriptor destinationVertexType; typedef vector<destinationVertexType> destinationVectorType; destinationVectorType destVector; destVector.push_back(destinationVertex); //check whether source exist or not in Vertex map of source type pair<map_vertices_type_one::iterator, bool> is_not_exist = bpGraph.vertices_type_one.insert(pair<sourceVertexType, destinationVectorType>(sourceVertex, destVector)); if(!is_not_exist.second) { //We are here means source exists, now we should check whether destination exists in adjacency list of source. destinationVectorType::iterator iter = find(bpGraph.vertices_type_one[sourceVertex].begin(), bpGraph.vertices_type_one[sourceVertex].end(), destinationVertex); //if condition below is true, means destination is not there in adjacency list of source. hence pushback destination if(iter == bpGraph.vertices_type_one[sourceVertex].end()) { bpGraph.vertices_type_one[sourceVertex].push_back(destinationVertex); edge_doesnt_exists = true; } } else edge_doesnt_exists = true; //try to find destination vertex in type two vertices typedef vector<sourceVertexType> sourceVectorType; sourceVectorType srcvector; pair<map_vertices_type_two::iterator, bool> is_two_not_exist = bpGraph.vertices_type_two.insert(pair<destinationVertexType, sourceVectorType>(destinationVertex, srcvector)); return edge_doesnt_exists; } template <class BpGraph> bool add_edge_type_two(BpGraph& bpGraph, typename graph_traits_BG<BpGraph>::vertex_type_two_descriptor sourceVertex, typename graph_traits_BG<BpGraph>::vertex_type_one_descriptor destinationVertex) { bool edge_doesnt_exists = false; typedef typename BpGraph::map_vertices_type_one map_vertices_type_one; //map type of vertices type one typedef typename BpGraph::map_vertices_type_two map_vertices_type_two; //map type of verices type two typedef graph_traits_BG<BpGraph>::vertex_type_two_descriptor sourceVertexType; typedef graph_traits_BG<BpGraph>::vertex_type_one_descriptor destinationVertexType; typedef vector<destinationVertexType> destinationVectorType; destinationVectorType destVector; destVector.push_back(destinationVertex); //check whether source exists or not in Vertex map of source type pair<map_vertices_type_two::iterator, bool> is_not_exist = bpGraph.vertices_type_two.insert(pair<sourceVertexType, destinationVectorType>(sourceVertex, destVector)); if(!is_not_exist.second) { //We are here means source exists, now we should check whether destination exists in adjacency list of source. destinationVectorType::iterator iter = find(bpGraph.vertices_type_two[sourceVertex].begin(), bpGraph.vertices_type_two[sourceVertex].end(), destinationVertex); //if condition below is true, means destination is not there in adjacency list of source. hence pushback destination if(iter == bpGraph.vertices_type_two[sourceVertex].end()) { bpGraph.vertices_type_two[sourceVertex].push_back(destinationVertex); edge_doesnt_exists = true; } } else edge_doesnt_exists = true; //try to find destination vertex in type one vertices typedef vector<sourceVertexType> sourceVectorType; sourceVectorType srcvector; pair<map_vertices_type_one::iterator, bool> is_one_not_exist = bpGraph.vertices_type_one.insert(pair<destinationVertexType, sourceVectorType>(destinationVertex, srcvector)); return edge_doesnt_exists; } } #endif
[ [ [ 1, 173 ] ] ]
36cbb31c8de3ba1c71e6333cfc50443810126cf5
ef23e388061a637f82b815d32f7af8cb60c5bb1f
/src/mame/includes/djmain.h
1685059b3983b69b2ee3dadf73bcb7e8ad855be6
[]
no_license
marcellodash/psmame
76fd877a210d50d34f23e50d338e65a17deff066
09f52313bd3b06311b910ed67a0e7c70c2dd2535
refs/heads/master
2021-05-29T23:57:23.333706
2011-06-23T20:11:22
2011-06-23T20:11:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
693
h
class djmain_state : public driver_device { public: djmain_state(running_machine &machine, const driver_device_config_base &config) : driver_device(machine, config) { } int m_sndram_bank; UINT8 *m_sndram; int m_turntable_select; UINT8 m_turntable_last_pos[2]; UINT16 m_turntable_pos[2]; UINT8 m_pending_vb_int; UINT16 m_v_ctrl; UINT32 m_obj_regs[0xa0/4]; const UINT8 *m_ide_user_password; const UINT8 *m_ide_master_password; UINT32 *m_obj_ram; }; /*----------- defined in video/djmain.c -----------*/ SCREEN_UPDATE( djmain ); VIDEO_START( djmain ); void djmain_tile_callback(running_machine& machine, int layer, int *code, int *color, int *flags);
[ "Mike@localhost" ]
[ [ [ 1, 26 ] ] ]
90315232cb0c6ecea417f70342c11b60d12e960c
b2d46af9c6152323ce240374afc998c1574db71f
/cursovideojuegos/theflostiproject/3rdParty/boost/libs/config/test/has_nanosleep_pass.cpp
67ca92d173ea645e1f8bdc3512983abb39731bb9
[]
no_license
bugbit/cipsaoscar
601b4da0f0a647e71717ed35ee5c2f2d63c8a0f4
52aa8b4b67d48f59e46cb43527480f8b3552e96d
refs/heads/master
2021-01-10T21:31:18.653163
2011-09-28T16:39:12
2011-09-28T16:39:12
33,032,640
0
0
null
null
null
null
UTF-8
C++
false
false
1,179
cpp
// This file was automatically generated on Sun Jul 25 11:47:49 GMTDT 2004, // by libs/config/tools/generate // Copyright John Maddock 2002-4. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org/libs/config for the most recent version. // Test file for macro BOOST_HAS_NANOSLEEP // This file should compile, if it does not then // BOOST_HAS_NANOSLEEP should not be defined. // see boost_has_nanosleep.ipp for more details // Do not edit this file, it was generated automatically by // ../tools/generate from boost_has_nanosleep.ipp on // Sun Jul 25 11:47:49 GMTDT 2004 // Must not have BOOST_ASSERT_CONFIG set; it defeats // the objective of this file: #ifdef BOOST_ASSERT_CONFIG # undef BOOST_ASSERT_CONFIG #endif #include <boost/config.hpp> #include "test.hpp" #ifdef BOOST_HAS_NANOSLEEP #include "boost_has_nanosleep.ipp" #else namespace boost_has_nanosleep = empty_boost; #endif int main( int, char *[] ) { return boost_has_nanosleep::test(); }
[ "ohernandezba@71d53fa2-cca5-e1f2-4b5e-677cbd06613a" ]
[ [ [ 1, 39 ] ] ]
b32f70bef2b20810caa2446bce914be314e778a9
b8fbe9079ce8996e739b476d226e73d4ec8e255c
/src/engine/rb_scene/jmove.h
fab45a1c33313283c427907aaba4b5c6d0a91b1a
[]
no_license
dtbinh/rush
4294f84de1b6e6cc286aaa1dd48cf12b12a467d0
ad75072777438c564ccaa29af43e2a9fd2c51266
refs/heads/master
2021-01-15T17:14:48.417847
2011-06-16T17:41:20
2011-06-16T17:41:20
41,476,633
1
0
null
2015-08-27T09:03:44
2015-08-27T09:03:44
null
UTF-8
C++
false
false
1,093
h
//****************************************************************************/ // File: JMove.h // Date: 22.09.2005 // Author: Ruslan Shestopalyuk //****************************************************************************/ #ifndef __JMOVE_H__ #define __JMOVE_H__ //****************************************************************************/ // Class: JMove // Desc: Moving animation //****************************************************************************/ class JMove : public JAnimation { PolyLine2 m_Path; bool m_bClosed; bool m_bSmooth; float m_Speed; public: JMove (); virtual void Render (); virtual void PostRender (); virtual void DrawBounds (); expose( JMove ) { parent(JAnimation); field( "Path", m_Path ); field( "Speed", m_Speed ); field( "Closed", m_bClosed ); field( "Smooth", m_bSmooth ); } }; // class JMove #endif // __JMOVE_H__
[ [ [ 1, 38 ] ] ]
8ab7a40b1f5bbdfc45251be60d8abb331e68ad81
2bcfdc7adc9d794391e0f79e4dab5c481ca5a09b
/applications/hac01/src/gui/heatingcontrol.cpp
5e154ee00434bf8dad496207aaf2af015135d94b
[]
no_license
etop-wesley/hac
592912a7c4023ba8bd2c25ae5de9c18d90c79b0b
ab82cb047ed15346c25ce01faff00815256b00b7
refs/heads/master
2021-01-02T22:45:32.603368
2010-09-01T08:38:01
2010-09-01T08:38:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,543
cpp
//#define QT_NO_DEBUG_OUTPUT #include <QDebug> #include <QSignalMapper> #include "heatingcontrol.h" #include "ui_heatingcontrol.h" HeatingControl::HeatingControl(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f), ui(new Ui::HeatingControl) { qDebug() << "HeatingControl::HeatingControl"; ui->setupUi(this); QPixmap normalPixmap; QPixmap activePixmap; QPalette pal; normalPixmap.load(":/hac01/images/button-background-normal-64x64.png"); activePixmap.load(":/hac01/images/button-background-active-64x64.png"); pal = ui->tempUpButton->palette(); pal.setBrush(QPalette::Button, normalPixmap); pal.setBrush(QPalette::Light, activePixmap); ui->tempUpButton->setPalette(pal); ui->tempUpButton->setPaletteBrushPanel(true); pal = ui->tempDownButton->palette(); pal.setBrush(QPalette::Button, normalPixmap); pal.setBrush(QPalette::Light, activePixmap); ui->tempDownButton->setPalette(pal); ui->tempDownButton->setPaletteBrushPanel(true); normalPixmap.load(":/hac01/images/button-background-normal-128x64.png"); activePixmap.load(":/hac01/images/button-background-active-128x64.png"); pal = ui->startButton->palette(); pal.setBrush(QPalette::Button, normalPixmap); pal.setBrush(QPalette::Light, activePixmap); ui->startButton->setPalette(pal); ui->startButton->setPaletteBrushPanel(true); pal = ui->stopButton->palette(); pal.setBrush(QPalette::Button, normalPixmap); pal.setBrush(QPalette::Light, activePixmap); ui->stopButton->setPalette(pal); ui->stopButton->setPaletteBrushPanel(true); /* QIcon icon; icon.addFile(":/HAC01/button-background-normal-64x64.png", QSize(), QIcon::Normal); icon.addFile(":/HAC01/button-background-active-64x64.png", QSize(), QIcon::Active); if (!icon.isNull()) { ui->tempUpButton->setAutoFillBackground(false); ui->tempUpButton->setBackgroundIcon(icon); ui->tempDownButton->setAutoFillBackground(false); ui->tempDownButton->setBackgroundIcon(icon); } else { qDebug() << "Can not found button-background-64x64.png"; } icon.addFile(":/HAC01/button-background-normal-128x64.png", QSize(), QIcon::Normal); icon.addFile(":/HAC01/button-background-active-128x64.png", QSize(), QIcon::Active); if (!icon.isNull()) { ui->startButton->setAutoFillBackground(false); ui->startButton->setBackgroundIcon(icon); ui->stopButton->setAutoFillBackground(false); ui->stopButton->setBackgroundIcon(icon); } else { qDebug() << "Can not found button-background-128x64.png"; } */ QSignalMapper *buttonsSignalMapper = new QSignalMapper(this); connect(ui->tempUpButton, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->tempUpButton, ui->tempUpButton->objectName()); connect(ui->tempDownButton, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->tempDownButton, ui->tempDownButton->objectName()); connect(ui->startButton, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->startButton, ui->startButton->objectName()); connect(ui->stopButton, SIGNAL(clicked()), buttonsSignalMapper, SLOT(map())); buttonsSignalMapper->setMapping(ui->stopButton, ui->stopButton->objectName()); connect(buttonsSignalMapper, SIGNAL(mapped(const QString &)), this, SLOT(OnButtonClicked(const QString &))); } HeatingControl::~HeatingControl() { qDebug() << "HeatingControl::~HeatingControl"; delete ui; } void HeatingControl::changeEvent(QEvent *e) { QWidget::changeEvent(e); switch (e->type()) { case QEvent::LanguageChange: ui->retranslateUi(this); break; default: break; } } static int temp = 27; void HeatingControl::OnButtonClicked(const QString &name) { qDebug() << "AcControl::OnButtonClicked" << name; if (name == "tempUpButton" || name == "tempDownButton") { temp += (name == "tempUpButton" ? 1 : -1); if (temp > 30) temp = 30; if (temp < 16) temp = 16; ui->setTempLabel->setText(QString::number(temp)); } else if (name == "startButton" || name == "stopButton") { if (name == "startButton") ui->stopButton->setChecked(false); else if (name == "stopButton") ui->startButton->setChecked(false); } }
[ "wesley@debian.(none)" ]
[ [ [ 1, 126 ] ] ]
6210b64582d220d6b538fcd6c92077aaec7b8fc5
ce262ae496ab3eeebfcbb337da86d34eb689c07b
/SEFoundation/SEComputationalGeometry/SEConvexHull1.h
f83164fdcadcacaaee167d4dd38c19e4897a96fc
[]
no_license
pizibing/swingengine
d8d9208c00ec2944817e1aab51287a3c38103bea
e7109d7b3e28c4421c173712eaf872771550669e
refs/heads/master
2021-01-16T18:29:10.689858
2011-06-23T04:27:46
2011-06-23T04:27:46
33,969,301
0
0
null
null
null
null
UTF-8
C++
false
false
2,814
h
// Swing Engine Version 1 Source Code // Most of techniques in the engine are mainly based on David Eberly's // Wild Magic 4 open-source code.The author of Swing Engine learned a lot // from Eberly's experience of architecture and algorithm. // Several sub-systems are totally new,and others are re-implimented or // re-organized based on Wild Magic 4's sub-systems. // Copyright (c) 2007-2010. All Rights Reserved // // Eberly's permission: // Geometric Tools, Inc. // http://www.geometrictools.com // Copyright (c) 1998-2006. All Rights Reserved // // This library is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation; either version 2.1 of the License, or (at // your option) any later version. The license is available for reading at // the location: // http://www.gnu.org/copyleft/lgpl.html #ifndef Swing_ConvexHull1_H #define Swing_ConvexHull1_H // A fancy class to compute the minimum and maximum of a collection of // real-valued numbers, but this provides some convenience for SEConvexHull2f // and SEConvexHull3f when the input point set has intrinsic dimension smaller // than the containing space. The interface of SEConvexHull1f is also the // model for those of SEConvexHull2f and SEConvexHull3f. #include "SEFoundationLIB.h" #include "SEConvexHull.h" namespace Swing { //---------------------------------------------------------------------------- // Description: // Author:Sun Che // Date:20081201 //---------------------------------------------------------------------------- class SE_FOUNDATION_API SEConvexHull1f : public SEConvexHullf { public: // The input to the constructor is the array of vertices you want to sort. // If you want SEConvexHull1f to delete the array during destruction, set // bOwner to 'true'. Otherwise, you own the array and must delete it // yourself. TO DO: The computation type is currently ignored by this // class. Add support for the various types later. SEConvexHull1f(int iVertexCount, float* afVertex, float fEpsilon, bool bOwner, SEQuery::Type eQueryType); virtual ~SEConvexHull1f(void); // The input vertex array. const float* GetVertices(void) const; // Support for streaming to/from disk. SEConvexHull1f(const char* acFilename); bool Load(const char* acFilename); bool Save(const char* acFilename) const; private: float* m_afVertex; class SE_FOUNDATION_API SESortedVertex { public: float Value; int Index; bool operator < (const SESortedVertex& rProj) const { return Value < rProj.Value; } }; }; } #endif
[ "[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac" ]
[ [ [ 1, 79 ] ] ]
5a028350584686d9332860d7b6a9a92ac43db61a
10dae5a20816dba197ecf76d6200fd1a9763ef97
/src/metapop.h
2414d9408cae83b0ff0269525983397b60170079
[]
no_license
peterdfields/quantiNEMO_Taylor2010
fd43aba9b1fcf504132494ff63d08a9b45b3f683
611b46bf89836c4327fe64abd7b4008815152c9f
refs/heads/master
2020-02-26T17:33:24.396350
2011-02-08T23:08:34
2011-02-08T23:08:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
17,257
h
/** @file metapop.h * * Copyright (C) 2006 Frederic Guillaume <[email protected]> * Copyright (C) 2008 Samuel Neuenschwander <[email protected]> * * quantiNEMO: * quantiNEMO is an individual-based, genetically explicit stochastic * simulation program. It was developed to investigate the effects of * selection, mutation, recombination, and drift on quantitative traits * with varying architectures in structured populations connected by * migration and located in a heterogeneous habitat. * * quantiNEMO is built on the evolutionary and population genetics * programming framework NEMO (Guillaume and Rougemont, 2006, Bioinformatics). * * * Licensing: * This file is part of quantiNEMO. * * quantiNEMO is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * quantiNEMO is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with quantiNEMO. If not, see <http://www.gnu.org/licenses/>. */ #ifndef metapopH #define metapopH #include "patch.h" class LCE; class LCE_Breed; class LCE_Disperse; //CLASS METAPOP /**Top class of the metapopulation structure, contains patches, implements the replicate and generation loops. * This class implements the two main loops of a simulation, the replicate and the generation loops. The replicate * loop iterates the generation loop which itself iterates the life cycle loop composed of the LCEs selected by the user. * The basic design for the metapopulation structure is a top-down chain of responsibility where the Metapop class * takes care of the patches it contains which are themselves concerned by the management of their individual containers. * The Individual class is only concerned by the management of its traits. Thereby, a metapopulation can be viewed * as an interleaving of containers where one container class takes care of its directly contained class only, * without knowledge of the upward container state. * The Metapop class thus implements methods used to manage and get information from the patches, to manage the parameters * necessary to build a population and to get the population state information. * <b>Population states:</b> given by the number and the position of the individuals (both spatially in demes and temporally * in age class containers). The Metapop::_currentAge flag is set according to the age state of the metapopulation. * The life cycle events modify that state by moving individuals between individuals containers within the metatpopulation. * The Metapop::_currentAge flag can contain the following age class bits as defined in types.h. * The OFFSPRNG (=1) age class bit is set whenever the offspring containers are not empty. The ADULTS (=2) age class bit is set * whenever the adult containers are not empty. The ALL (=3) age class is the addition of the previous tags and NONE (=0) is the negation of them. * The individual containers are stored in the patches and handled through the Patch class interface. Each age class is represented * by two containers, one for the males (index 0) and the other for the females (index 1). These containers are store in a table * and are accessed through their age class index as defined by the age_idx enum (see types.h). These indexes are as follows: * The OFFSPRNG age class has index OFFSx = 0, and the ADULTS age class has index ADLTx = 2. * */ class Metapop: public SimComponent, public IndFactory { private: /**The life cycle events*/ list < LCE* > _theCycle; /**The stat handler for the population stats*/ MetapopSH _statHandler; /**The Patch container*/ deque<Patch*> _vPatch; /** pointer to the breed LCE */ LCE_Breed* _pBreed_LCE; /** pointer to the disperse LCE */ LCE_Disperse* _pDisperse_LCE; Patch** _sample_pops; // array with pointer to patches used for stats and other outputs (do not delete the patches here) unsigned int _sample_pops_size; // size of the array void set_sample_pops(); // creates the array //parameters: /**Number of patches in the population.*/ unsigned int _patchNbr; /**Patch carrying capacity.*/ unsigned int _patchK; /**Sex specific carrying capacities.*/ unsigned int _patchKfem, _patchKmal; /**Patch population size.*/ unsigned int _patchN; /**Sex specific population sizes.*/ unsigned int _patchNfem, _patchNmal; /**Number of generations to iterate.*/ unsigned int _generations; /**Number of replicates to iterate.*/ unsigned int _replicates; //counters: /**The current generation in the generation loop, starts at 1.*/ unsigned int _currentGeneration; /**The current replicate in the replicate loop, starts at 1.*/ unsigned int _currentReplicate; // unsigned int Current_LC_Rank; /**The current age class, might be changed by the LCEs.*/ age_t _currentAge; /**Clock counter, for logging.**/ clock_t _meanReplElapsedTime; /**Generation counter, for logging.**/ unsigned int _meanGenLength; /** inital sex ratio */ double _sexInitRatio; // 0: only females => hermaphrodite; 0.5: f = m FileServices* _service; TSelection* _pSelection; // pointer to the selection stuff if needed int _selection_position; // when does selectiona acts?: // 0: reproductive success (fitness of adults, nbOffs in relation to adults) // 1: reproductive success (fitness of offsprings, nbOffs in relation to adults)) // 2: pre-dispersal regulation (offspring) // 3: post-dispersal regulation (adults) // 4: no selection at all (or when no quantitative traits are specified) int _selection_level; // 0: soft selection (patch level) // 1: soft selection (metapopulation level) // 2: hard selection (fitness is directly translated to survival/reproductive success) unsigned int _total_carrying_capacity; double** _density_threshold; // allows to change the disp rate depending on the density (0: patch, 1: density, 2: change) Param** _density_threshold_param; // pointer to the param unsigned int _density_threshold_nbChanges; public: Metapop(); virtual ~Metapop(); /**Inits the population parameters from the ParamSet and builds the pop (adds patches), the prototypes and the life cycle. Called at the start of each simulation, resets the individual garbage collector. @param traits the map of the selected trait prototypes from the SimBuilder @param LCEs the map of the selected LCEs from the SimBuilder @callgraph */ bool init( map< string, TTraitProto* >& traits, map< int, LCE* >& LCEs ); /** function which changes parameters over time */ void temporal_change(const int& gen); /**Called to empty the patches, individuals are move to the garbage collector.*/ void reset(); /**Called at the end of each simulation, empties the pop and the garbage collector, Individuals are destroyed.*/ void clear(); /**Creates the list of LCEs from the selected ones in the SimBuilder instance. \b Note: the LCEs inserted in the list are the LCE templates stored in the SimBuilder. They aren't copied or cloned. **/ void setLifeCycle(map< int, LCE* >& lifeCycle); ///@name Main loops ///@{ /**Replicate loop, iterates the life cycle \a _replicates times. @callgraph */ void Replicate_LOOP(); /** function which is executed before/after each replicate */ void executeBeforeEachReplicate(const int& rep); void executeAfterEachReplicate(const int& rep); /** function which is executed before/after each generation */ void executeBeforeEachGeneration(const int& gen); void executeAfterEachGeneration(const int& gen); /** function which prints the entire genetic map to a file named "genetic_map.txt" */ void printEntireGeneticMap(); /**Life cycle loop, executes the list of LCEs \a _generations times. @param startTime the starting time of the current replicate. @callgraph */ void Cycle(clock_t& startTime); ///@} void createPopulations(); ///@name Population builders ///@{ /** function to set the inital population sizes */ void setInitPopulationSizes(); void setInitPopulationSizes_1sex(); // selfing/cloning void setInitPopulationSizes_2sexes(); // for all other mating systems void setInitPopulationSizesOfPatches(); void setInitPopulationSizesOfPatches(TMatrix* popNfem); void setInitPopulationSizesOfPatches(sex_t SEX, TMatrix* popNmal); void setInitPopulationSizesOfPatches(TMatrix* popNfem, TMatrix* popNmal); /** function to set the carrying capacities */ void setCarryingCapacities(); void setCarryingCapacities_1sex(); // selfing/cloning void setCarryingCapacities_2sexes(); // for all other mating systems void setCarryingCapacitiesOfPatches(); void setCarryingCapacitiesOfPatches(TMatrix* popNfem); void setCarryingCapacitiesOfPatches(sex_t SEX, TMatrix* popNmal); void setCarryingCapacitiesOfPatches(TMatrix* popNfem, TMatrix* popNmal); /**Sets the first generation of each replicates. @callgraph */ void setPopulation (); void setPopulation_FSTAT (); // if genotypes are given by FSTAT file void set_pDisperse_LCE (LCE_Disperse* l) {_pDisperse_LCE = l;} void set_pBreed_LCE (LCE_Breed* l) {_pBreed_LCE = l;} ///@} /**Sets the Patch trait optima. @param optima a matrix containing the patches optima and intensity (see manual). */ void set_patch_parameter(const unsigned int& nbTrait, const string& name, const string& name_full, void (Patch::*pt2Func)(double*, sex_t)); void set_patch_value(const unsigned int& nbTrait, const double& value, sex_t SEX, void (Patch::*pt2Func)(double*, sex_t)); void set_patch_matrix(const unsigned int& nbTrait, TMatrix* m, sex_t SEX, const string& name, void (Patch::*pt2Func)(double*, sex_t)); ///@name Implementations ///@{ //SimComponent implementation: virtual void loadFileServices ( FileServices* loader ) {} virtual void loadStatServices ( StatServices* loader ) {loader->attach(&_statHandler);} /**Patch accessor, return the ith+1 patch in the metapop.*/ Patch* getPatch (unsigned int i) {return _vPatch[i];} /**A secure version of the getPatch() method.*/ Patch* getPatchPtr (unsigned int patch); deque<Individual*>* getAllIndividuals(); unsigned int getGenerations ( ) {return _generations;} unsigned int getReplicates ( ) {return _replicates;} unsigned int getPatchNbr ( ) {return _patchNbr;} unsigned int getPatchKFem ( ) {return _patchKfem;} unsigned int getPatchKMal ( ) {return _patchKmal;} unsigned int getPatchCapacity ( ) {return _patchK;} Patch** get_sample_pops ( ) {return _sample_pops;} unsigned int get_sample_pops_size ( ) {return _sample_pops_size;} /**Returns the mean processor time per replicate in seconds.*/ clock_t getMeanReplElapsedTime ( ) {return _meanReplElapsedTime;} /**Returns the mean number of generations performed per replicate.*/ unsigned int getMeanGenLength ( ) {return _meanGenLength;} LCE_Disperse* get_pDisperse_LCE ( ) {return _pDisperse_LCE;} LCE_Breed* get_pBreed_LCE ( ) {return _pBreed_LCE;} double get_sexInitRatio ( ) {return _sexInitRatio;} ///@} ///@name Population state interface ///@{ unsigned int getCurrentReplicate ( ) {return _currentReplicate;} unsigned int getCurrentGeneration ( ) {return _currentGeneration;} // unsigned int getCurrentRank ( ) {return Current_LC_Rank;} age_t getCurrentAge ( ) {return _currentAge;} /**Sets the age flag. @param age the current age. */ void setCurrentAge(age_t age) {_currentAge = age;} /**Checks if the population still contains at least one individual in any sex or age class.*/ bool isAlive( ) {return size() != 0;} /**Get the total number of individuals present in the population, all sex and age classes together.*/ unsigned int size( ) {return size(ALL);} /**Interface to get the size of a praticular age and sex class(es). @param AGE age class flags @param SEX sex class */ unsigned int size ( sex_t SEX, age_t AGE ); /**Interface to get the size of a praticular age and sex class within a patch. @param AGE age class flags @param SEX sex class @param deme the focal patch */ unsigned int size (sex_t SEX, age_t AGE, unsigned int deme); /**Simplified interface to get the size of both sexes of the appropriate age class(es) in the whole population. @param AGE age class flags */ unsigned int size ( age_t AGE ){ return size( FEM, AGE ) + size( MAL, AGE ); } /**Simplified interface to get the size of both sexes of the appropriate age class(es) in one patch. @param AGE age class flags @param deme the focal deme */ unsigned int size ( age_t AGE, unsigned int deme ){ return size( FEM, AGE, deme ) + size( MAL, AGE, deme ); } /**Returns a pointer to the appropriate individual. @param SEX sex class container index @param AGE age class container index @param at the index of the individual in its container @param deme the patch where to grab the individual*/ Individual* get (sex_t SEX, age_idx AGE, unsigned int at, unsigned int deme); /**Moves an individual from a deme to an other one, both demes sizes are modified. @param SEX sex class container index @param from_age age class container index in the deme of origin @param from_deme index of the deme of origin @param to_age age class container index in the destination deme @param to_deme index of the destination deme @param at index of the focal individual in the 'from' deme */ void move (sex_t SEX, age_idx from_age, unsigned int from_deme, age_idx to_age, unsigned int to_deme, unsigned int at); /** * @return the current replicate counter string */ string getReplicateCounter (); string getReplicateCounter_ (); string getReplicateCounter_r (); /** * @return the current generation counter string */ string getGenerationCounter (); string getGenerationCounter_ (); string getGenerationCounter_g (); /** returns tre if only one sex is used for the simulations */ void set_SexInitRatio(map< int,LCE* >& LCEs); void resize_nbPopulations(unsigned int nbPatch); void set_service(FileServices* ptr){_service=ptr;} FileServices* get_service(){return _service;} void set_replicates(unsigned int i) {_replicates = i;} void set_generations(unsigned int i) {_generations = i;} void regulate_selection_fitness_patch(age_idx AGE, unsigned int* Kmal=NULL, unsigned int* Kfem=NULL); void regulate_selection_fitness_metapop(age_idx AGE); void regulate_selection_fitness_hard(age_idx AGE); void set_total_carrying_capacity(); unsigned int get_total_carrying_capacity(){return _total_carrying_capacity;} TSelection* get_pSelection() {return _pSelection;} int get_selection_position() {return _selection_position;} int get_selection_level() {return _selection_level;} void set_selection_level(const int& i) {_selection_level = i;} /** functions for changing dispersal rate following pop density of a certain patch */ void change_disp_rate_after_density(const int& gen); void set_change_disp_rate_after_density(); void reset_dynamic_params(); ///@} }; inline unsigned int Metapop::size ( sex_t SEX, age_t AGE ){ unsigned int s = 0; for(unsigned int i = 0; i < _patchNbr; i++){ s += _vPatch[i]->size(SEX, AGE); } return s; } inline unsigned int Metapop::size (sex_t SEX, age_t AGE, unsigned int deme){ return getPatchPtr(deme)->size(SEX, AGE); } inline Individual* Metapop::get (sex_t SEX, age_idx AGE, unsigned int at, unsigned int deme){ return getPatchPtr(deme)->get(SEX, AGE, at); } inline void Metapop::move (sex_t SEX, age_idx from_age, unsigned int from_deme, age_idx to_age, unsigned int to_deme, unsigned int at){ _vPatch[to_deme]->add(SEX, to_age, get(SEX, from_age, at, from_deme)); _vPatch[from_deme]->remove(SEX, from_age, at); } #endif
[ [ [ 1, 411 ] ] ]
ee9d7bca034c9c6547956279063f591c250f26be
fc4946d917dc2ea50798a03981b0274e403eb9b7
/gentleman/gentleman/WindowsAPICodePack/WindowsAPICodePack/DirectX/DirectX/Direct3D10/D3D10ShaderReflectionType.cpp
d21eb96298e9314b8cfced88924191f23ebc1541
[]
no_license
midnite8177/phever
f9a55a545322c9aff0c7d0c45be3d3ddd6088c97
45529e80ebf707e7299887165821ca360aa1907d
refs/heads/master
2020-05-16T21:59:24.201346
2010-07-12T23:51:53
2010-07-12T23:51:53
34,965,829
3
2
null
null
null
null
UTF-8
C++
false
false
1,601
cpp
// Copyright (c) Microsoft Corporation. All rights reserved. #include "stdafx.h" #include "D3D10ShaderReflectionType.h" #include "D3D10ShaderReflectionType.h" using namespace msclr::interop; using namespace Microsoft::WindowsAPICodePack::DirectX::Direct3D10; ShaderTypeDescription ShaderReflectionType::Description::get() { ShaderTypeDescription desc; pin_ptr<ShaderTypeDescription> ptr = &desc; CommonUtils::VerifyResult(GetInterface<ID3D10ShaderReflectionType>()->GetDesc((D3D10_SHADER_TYPE_DESC*)ptr)); return desc; } ShaderReflectionType^ ShaderReflectionType::GetMemberTypeByIndex(UInt32 index) { ID3D10ShaderReflectionType* returnValue = GetInterface<ID3D10ShaderReflectionType>()->GetMemberTypeByIndex(static_cast<UINT>(index)); return returnValue == NULL ? nullptr : gcnew ShaderReflectionType(returnValue); } ShaderReflectionType^ ShaderReflectionType::GetMemberTypeByName(String^ name) { IntPtr ptr = Marshal::StringToHGlobalAnsi(name); try { ID3D10ShaderReflectionType * returnValue = GetInterface<ID3D10ShaderReflectionType>()->GetMemberTypeByName(static_cast<char*>(ptr.ToPointer())); return returnValue ? gcnew ShaderReflectionType(returnValue) : nullptr; } finally { Marshal::FreeHGlobal(ptr); } } String^ ShaderReflectionType::GetMemberTypeName(UInt32 index) { LPCSTR returnValue = GetInterface<ID3D10ShaderReflectionType>()->GetMemberTypeName(static_cast<UINT>(index)); return returnValue == NULL ? nullptr : gcnew String(returnValue); }
[ "lucemia@9e708c16-f4dd-11de-aa3c-59de0406b4f5" ]
[ [ [ 1, 46 ] ] ]
a34c792197a7bf7534be9e50e68c23a9ec6b5fcd
e1b7e9b25db81b2f25088fd741e28fbc4efaf5fe
/tmp/AutoSerial/autoserial-1.0.1/include/autoserial/autoserial_mpi.h
9255b7629fe97af359dc563b50abaf1a24df8351
[]
no_license
AaronMR/AaronMR_Robotic_Stack
c00260cf1b992806e58838688702ab240bf34233
34d5449f9ca0ffc08fac4f5d48a7c4db03bb018a
refs/heads/master
2020-03-29T21:42:23.501525
2011-02-23T17:07:29
2011-02-23T17:07:29
1,364,684
6
0
null
null
null
null
ISO-8859-2
C++
false
false
10,063
h
/* autoserial A cross-platform serialization and reflexion library for C++ objects Copyright (C) 2000-2008: Sebastian Gerlach Kenzan Technologies (http://www.kenzantech.com) Basile Schaeli (basile schaeli at a3 epfl ch) Mamy Fetiarison Peripheral Systems Laboratory Ecole Polytechnique Fédérale de Lausanne (EPFL) (http://lsp.epfl.ch) 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 names of "Kenzan Technologies", "Peripheral Systems Laboratory", "Ecole Polytechnique Fédérale de Lausanne (EPFL)", nor the names of the contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDERS ``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 COPYRIGHT HOLDERS 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 as_mpi.h \brief Binary data reader/writer Provides serialization functions for binary targets using MPI communication. */ #ifndef INCLUDED_AS_MPI_H #define INCLUDED_AS_MPI_H #include "autoserial.h" #include <mpi.h> #define MPI_BUFFER_LEN 512 #define MPI_FAILED(v) ((v)!=MPI_SUCCESS) namespace autoserial { //! Specialized BinaryWriter for MPI communication class MPIBinaryWriter : public BasicBinaryWriter { private: //! Destination process int dest; //! Communicator for sending messages MPI_Comm comm; int tag; protected: //! Flush the buffered data to output Result flush() { for(Size i=0;i<bufferCount;i++) { if (MPI_FAILED(MPI_Send(const_cast<void*>(buffers[i].data), buffers[i].length, MPI_BYTE, dest, tag, comm))) { printf("Failed send of buffer %d, size %d\n",i,buffers[i].length); return AS_MPISEND_FAIL; } } return AS_OK; } public: //! Constructor MPIBinaryWriter(int dest, MPI_Comm comm,int tag=0) { this->dest=dest; this->comm=comm; this->tag=tag; } }; //! Specialized BinaryReader for MPI communication class MPIBinaryReader : public BasicBinaryReader { private: //! Sending process of data to read int source; //! Message tag int tag; //! Status object MPI_Status *st; //! Local buffer for MPI messages char *mpiBuffer; //! Buffer size int mpiBufferSize; //! Index of unused data int mpiBufferIndex; //! Special value for empty buffers static const int EMPTY_INDEX = -1; //! Communicator for receiving messages MPI_Comm comm; private: //! Reset reader void reset() { mpiBufferIndex=EMPTY_INDEX; source=MPI_ANY_SOURCE; } protected: //! Flush the buffered data to output Result readBytes(void *buf, Size len) { int remainingLength = (int)len; char *outputBuffer = (char*)buf; while (remainingLength > 0) { // Check if there is data left in mpiBuffer if (mpiBufferIndex != EMPTY_INDEX) { int dataLeft = mpiBufferSize - mpiBufferIndex; if (dataLeft > remainingLength) // There is more data than we need { memcpy(outputBuffer, &mpiBuffer[mpiBufferIndex], remainingLength); mpiBufferIndex += remainingLength; return AS_OK; } else { memcpy(outputBuffer, &mpiBuffer[mpiBufferIndex], dataLeft); mpiBufferIndex = EMPTY_INDEX; outputBuffer += remainingLength; remainingLength -= dataLeft; // Next iteration exits loop if dataLeft was equal to remainingLength // and MPI_Recv the next message otherwise } } else // mpiBuffer is empty { int mpiMsgSize; if (MPI_FAILED(MPI_Probe(source, tag, comm, st))) return AS_MPIRECV_FAIL; if (MPI_FAILED(MPI_Get_count(st, MPI_BYTE, &mpiMsgSize))) return AS_MPIRECV_FAIL; source=st->MPI_SOURCE; // Receive directly into argument buffer if possible if (remainingLength >= mpiMsgSize) { if(MPI_FAILED(MPI_Recv(outputBuffer, mpiMsgSize, MPI_BYTE, source, st->MPI_TAG, comm, st))) { printf("MPI Receive error!\n"); return AS_MPIRECV_FAIL; } remainingLength-=mpiMsgSize; // Next iteration exits if remaniningLength was equal to mpiMsgSize, // and receives next message otherwise } else { assert(mpiBufferIndex == EMPTY_INDEX); // We must use a temporary buffer to store the message if (mpiBufferSize < mpiMsgSize) // Allocate/resize buffer as needed { if (mpiBuffer == NULL) mpiBuffer = (char*)malloc(mpiMsgSize); else mpiBuffer = (char*)realloc(mpiBuffer, mpiMsgSize); mpiBufferSize = mpiMsgSize; } // Offset index mpiBufferIndex = mpiBufferSize - mpiMsgSize; if(MPI_FAILED(MPI_Recv(mpiBuffer+mpiBufferIndex, mpiMsgSize, MPI_BYTE, source, st->MPI_TAG, comm, st))) { printf("MPI Receive error!\n"); return AS_MPIRECV_FAIL; } // Next iteration reads into buffer } } } return AS_OK; } public: //! Constructor MPIBinaryReader(int src, MPI_Comm comm, int tag, MPI_Status *st) { reset(); this->source=src; this->comm=comm; this->mpiBufferSize=0; this->mpiBuffer=NULL; this->tag=tag; this->st=st; } //! Destructor ~MPIBinaryReader() { if(mpiBuffer!=NULL) free(mpiBuffer); } }; //! Specialized MPI communicator for serialized objects class AutoserialCommunicator : public MPI::Comm { public: //! Constructor AutoserialCommunicator(MPI_Comm comm) : MPI::Comm(comm) { asComm=comm; } //! Send data to process dest Result Send(ISerializable &data, int dest, int tag) { MPIBinaryWriter mbw(dest,asComm,tag); return mbw.write(&data); } //! Receive an object from process src ISerializable* Recv(int src, int tag) { ISerializable *data; MPI_Status st; MPIBinaryReader mbr(src,asComm,tag,&st); if (AS_FAILED(mbr.read(&data))) return NULL; return data; } //! Receive an object from process src, with status ISerializable* Recv(int src, int tag, MPI::Status& st) { ISerializable *data; MPI_Status c_st=(MPI_Status)st; MPIBinaryReader mbr(src,asComm,tag,&c_st); if (AS_FAILED(mbr.read(&data))) return NULL; // Copy status content back into parameter st=c_st; return data; } //! Send data to process dest template<typename Type> Result Send(Type& data, int dest, int tag) { return Send(*(ISerializable*)&data,dest,tag); } //! Send data to process dest. Tag is Type index template<typename Type> Result Send(Type& data, int dest) { return Send(*(ISerializable*)&data,dest,(int)Type::getTypeIndex()); } //! Receive data from process src template<typename Type> Type *Recv(int src, int tag) { Type *data; MPI_Status st; MPIBinaryReader mbr(src,asComm,tag,&st); if (AS_FAILED(mbr.read((ISerializable**)&data))) return NULL; return data; } //! Receive data from process src template<typename Type> Type *Recv(int src, int tag, MPI::Status &st) { Type *data; MPI_Status c_st=(MPI_Status)st; MPIBinaryReader mbr(src,asComm,tag,&c_st); if (AS_FAILED(mbr.read((ISerializable**)&data))) return NULL; return data; } //! Receive data from process src. Tag is Type index. template<typename Type> Type *Recv(int src) { Type *data; MPIBinaryReader mbr(src,asComm,(int)Type::getTypeIndex(),MPI_STATUS_IGNORE); if (AS_FAILED(mbr.read((ISerializable**)&data))) return NULL; return data; } //! Receive data from process src. Tag is Type index. template<typename Type> Type *Recv(int src, MPI::Status &st) { Type *data; MPI_Status c_st=(MPI_Status)st; MPIBinaryReader mbr(src,asComm,(int)Type::getTypeIndex(),&c_st); if (AS_FAILED(mbr.read((ISerializable**)&data))) return NULL; return data; } private: //! MPI communicator MPI_Comm asComm; //! Return a clone of this object. Definition of virtual method. AutoserialCommunicator &Clone(void) const { return *(new AutoserialCommunicator(asComm)); } }; } // C interface //! Send data to process dest within the communicator comm int AS_MPI_Send(autoserial::ISerializable &data, int dest, int tag, MPI_Comm comm) { autoserial::MPIBinaryWriter mbw(dest,comm,tag); return mbw.write(&data); } //! Receive data from process src within the communicator comm int AS_MPI_Recv(autoserial::ISerializable *&data, int src, int tag, MPI_Comm comm, MPI_Status *st) { if(st!=MPI_STATUS_IGNORE) { autoserial::MPIBinaryReader mbr(src,comm,tag,st); return mbr.read(&data); } else { MPI_Status st; autoserial::MPIBinaryReader mbr(src,comm,tag,&st); return mbr.read(&data); // st is used within read() } } #endif
[ [ [ 1, 362 ] ] ]
641f0bcebfac4f780c081f48bb3fd9f098a36c39
a2904986c09bd07e8c89359632e849534970c1be
/topcoder/DancingSentence.cpp
db3a1ee24111b4ab71854722700b1c9731010877
[]
no_license
naturalself/topcoder_srms
20bf84ac1fd959e9fbbf8b82a93113c858bf6134
7b42d11ac2cc1fe5933c5bc5bc97ee61b6ec55e5
refs/heads/master
2021-01-22T04:36:40.592620
2010-11-29T17:30:40
2010-11-29T17:30:40
444,669
1
0
null
null
null
null
UTF-8
C++
false
false
2,514
cpp
// BEGIN CUT HERE // END CUT HERE #line 5 "DancingSentence.cpp" #include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <numeric> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> using namespace std; #define debug(p) cout << #p << "=" << p << endl; #define forv(i, v) for (int i = 0; i < (int)(v.size()); ++i) #define fors(i, s) for (int i = 0; i < (int)(s.length()); ++i) #define all(a) a.begin(), a.end() #define pb push_back class DancingSentence { public: string makeDancing(string sen) { string ret; int cnt=0; fors(i,sen){ if(sen[i]==' '){ ret += sen[i]; }else{ cnt++; if(cnt%2==1){ ret += toupper(sen[i]); }else{ ret += tolower(sen[i]); } } } return ret; } // BEGIN CUT HERE public: void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); } private: template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); } void verify_case(int Case, const string &Expected, const string &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } } void test_case_0() { string Arg0 = "This is a dancing sentence"; string Arg1 = "ThIs Is A dAnCiNg SeNtEnCe"; verify_case(0, Arg1, makeDancing(Arg0)); } void test_case_1() { string Arg0 = " This is a dancing sentence "; string Arg1 = " ThIs Is A dAnCiNg SeNtEnCe "; verify_case(1, Arg1, makeDancing(Arg0)); } void test_case_2() { string Arg0 = "aaaaaaaaaaa"; string Arg1 = "AaAaAaAaAaA"; verify_case(2, Arg1, makeDancing(Arg0)); } void test_case_3() { string Arg0 = "z"; string Arg1 = "Z"; verify_case(3, Arg1, makeDancing(Arg0)); } // END CUT HERE }; // BEGIN CUT HERE int main() { DancingSentence ___test; ___test.run_test(-1); } // END CUT HERE
[ "shin@CF-7AUJ41TT52JO.(none)" ]
[ [ [ 1, 76 ] ] ]
1b0ab7e99c40dd778e2e686765611fd838976ebb
016774685beb74919bb4245d4d626708228e745e
/lib/Collide/ozcollide/intr_boxbox.h
8e9943ab4c678803f7332acc3e33fc0dcddaf1ea
[]
no_license
sutuglon/Motor
10ec08954d45565675c9b53f642f52f404cb5d4d
16f667b181b1516dc83adc0710f8f5a63b00cc75
refs/heads/master
2020-12-24T16:59:23.348677
2011-12-20T20:44:19
2011-12-20T20:44:19
1,925,770
1
0
null
null
null
null
UTF-8
C++
false
false
1,155
h
/* OZCollide - Collision Detection Library Copyright (C) 2006 Igor Kravtchenko This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Contact the author: [email protected] */ #ifndef OZCOLLIDE_INTERSECTION_BOXBOX_H #define OZCOLLIDE_INTERSECTION_BOXBOX_H #ifndef OZCOLLIDE_PCH #include <ozcollide/ozcollide.h> #endif ENTER_NAMESPACE_OZCOLLIDE class Box; class OBB; OZCOLLIDE_API bool testIntersectionAABB_OBB(const Box &, const OBB &); LEAVE_NAMESPACE #endif
[ [ [ 1, 38 ] ] ]
ed3232e1ca8673848fc7c08b1fa12264a3c0461b
847cccd728e768dc801d541a2d1169ef562311cd
/src/Utils/test/TestMath.cpp
7605bbb352805623e3f15a3c3d8a16918afb3384
[]
no_license
aadarshasubedi/Ocerus
1bea105de9c78b741f3de445601f7dee07987b96
4920b99a89f52f991125c9ecfa7353925ea9603c
refs/heads/master
2021-01-17T17:50:00.472657
2011-03-25T13:26:12
2011-03-25T13:26:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,441
cpp
#include "Common.h" #include "UnitTests.h" #include "MathUtils.h" SUITE(MathUtils) { TEST(PI) { CHECK_CLOSE(3.1415926535897932384626433832795f, MathUtils::PI, numeric_limits<float>::epsilon()); CHECK_CLOSE(1.5707963267948966192313216916398f, MathUtils::HALF_PI, numeric_limits<float>::epsilon()); } TEST(AbsoluteValue) { CHECK_EQUAL(MathUtils::Abs((int32)11), 11); CHECK_EQUAL(MathUtils::Abs((int32)-11), 11); CHECK_EQUAL(MathUtils::Abs((float32)11.0f), 11.0f); CHECK_EQUAL(MathUtils::Abs((float32)-11.0f), 11.0f); CHECK_EQUAL(MathUtils::Abs(numeric_limits<float>::max()), numeric_limits<float>::max()); CHECK_EQUAL(MathUtils::Abs(numeric_limits<float>::min()), numeric_limits<float>::min()); CHECK_EQUAL(MathUtils::Abs(-numeric_limits<float>::max()), numeric_limits<float>::max()); CHECK_EQUAL(MathUtils::Abs(-numeric_limits<float>::min()), numeric_limits<float>::min()); CHECK_EQUAL(MathUtils::Abs(numeric_limits<float>::epsilon()), numeric_limits<float>::epsilon()); CHECK_EQUAL(MathUtils::Abs(-numeric_limits<float>::epsilon()), numeric_limits<float>::epsilon()); } TEST(Minimum) { CHECK_EQUAL(MathUtils::Min(1, 10), 1); CHECK_EQUAL(MathUtils::Min(-1, 10), -1); CHECK_EQUAL(MathUtils::Min(1, -10), -10); CHECK_EQUAL(MathUtils::Min(numeric_limits<float>::min(), numeric_limits<float>::max()), numeric_limits<float>::min()); CHECK_EQUAL(MathUtils::Min(numeric_limits<float>::min(), -numeric_limits<float>::max()), -numeric_limits<float>::max()); CHECK_EQUAL(MathUtils::Min(-numeric_limits<float>::min(), -numeric_limits<float>::max()), -numeric_limits<float>::max()); } TEST(Angle) { Vector2 v1(0,1); Vector2 v2(1,0); CHECK_CLOSE(MathUtils::HALF_PI, MathUtils::Angle(v1,v2), numeric_limits<float>::epsilon()); } TEST(AngleDistance) { CHECK_CLOSE(0, MathUtils::AngleDistance(MathUtils::HALF_PI, MathUtils::HALF_PI), numeric_limits<float>::epsilon()); CHECK_CLOSE(MathUtils::HALF_PI, MathUtils::AngleDistance(MathUtils::PI, MathUtils::HALF_PI), numeric_limits<float>::epsilon()); CHECK_CLOSE(MathUtils::HALF_PI, MathUtils::AngleDistance(-MathUtils::PI, MathUtils::HALF_PI), numeric_limits<float>::epsilon()); //not very nice precision but ok CHECK_CLOSE(MathUtils::HALF_PI + 1.0f, MathUtils::AngleDistance(-10*MathUtils::PI, MathUtils::HALF_PI + 1.0f), 0.000001f); CHECK_CLOSE(MathUtils::PI - 1.0f, MathUtils::AngleDistance(-20*MathUtils::PI, MathUtils::PI + 1.0f), 0.00001f); } TEST(IsAngleInRange) { CHECK(MathUtils::IsAngleInRange(MathUtils::HALF_PI, 0.0f, MathUtils::PI)); CHECK(MathUtils::IsAngleInRange(MathUtils::HALF_PI, 0.0f, MathUtils::HALF_PI)); CHECK(MathUtils::IsAngleInRange(0, 0.0f, MathUtils::HALF_PI)); CHECK(MathUtils::IsAngleInRange(MathUtils::HALF_PI, MathUtils::HALF_PI, MathUtils::HALF_PI)); CHECK(MathUtils::IsAngleInRange(MathUtils::HALF_PI, MathUtils::PI*2, MathUtils::HALF_PI*10)); } TEST(VectorFromAngle) { CHECK_EQUAL(MathUtils::VectorFromAngle(0, 1.0f).x, 1.0f); Vector2 vector(MathUtils::Random(0.0f, 10.0f), MathUtils::Random(0.0f, 10.0f)); float32 angle = MathUtils::Angle(vector,Vector2(1,0)); //lower precision CHECK_CLOSE(vector.x, MathUtils::VectorFromAngle(angle, vector.Length()).x, 0.0001f); CHECK_CLOSE(vector.y, MathUtils::VectorFromAngle(angle, vector.Length()).y, 0.0001f); } //TODO some tests are missing. }
[ [ [ 1, 8 ], [ 11, 18 ], [ 25, 31 ], [ 35, 36 ], [ 63, 66 ], [ 74, 74 ], [ 77, 77 ] ], [ [ 9, 10 ], [ 19, 24 ], [ 32, 34 ], [ 41, 41 ], [ 46, 48 ] ], [ [ 37, 40 ], [ 42, 45 ], [ 49, 62 ], [ 67, 73 ], [ 75, 76 ] ] ]
d5c52dc79dd002197070883598be0815bbde61ac
16d8b25d0d1c0f957c92f8b0d967f71abff1896d
/OblivionOnlineServer/PlayerManager.h
58c09c4339c1067ea3ac26b16a96623b09510318
[]
no_license
wlasser/oonline
51973b5ffec0b60407b63b010d0e4e1622cf69b6
fd37ee6985f1de082cbc9f8625d1d9307e8801a6
refs/heads/master
2021-05-28T23:39:16.792763
2010-05-12T22:35:20
2010-05-12T22:35:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
598
h
#pragma once #include "GlobalDefines.h" #include "Player.h" #include <stack> #include <set> class Entity; class EntityManager; class NetworkSystem; class PlayerManager : public std::set<Player *> { boost::mutex _lock; std::stack<UINT32> _playerIDs; EntityManager *_mgr; NetworkSystem *_net; UINT32 m_MasterClient; public: void AssignPlayerID(UINT32 ID); Player *GetPlayer(SOCKET connection); void RemovePlayer(Player *Player); EntityManager *GetEntityManager(){ return _mgr;} PlayerManager(EntityManager *manager,NetworkSystem *Network); ~PlayerManager(void); };
[ "obliviononline@2644d07b-d655-0410-af38-4bee65694944" ]
[ [ [ 1, 23 ] ] ]
2839818648e245de70c86dec7a0e2aa2943d1532
1960e1ee431d2cfd2f8ed5715a1112f665b258e3
/src/util/eventlogger.cpp
c52104dbc30a7038b97e8c5c534c49978fe80900
[]
no_license
BackupTheBerlios/bvr20983
c26a1379b0a62e1c09d1428525f3b4940d5bb1a7
b32e92c866c294637785862e0ff9c491705c62a5
refs/heads/master
2021-01-01T16:12:42.021350
2009-11-01T22:38:40
2009-11-01T22:38:40
39,518,214
0
0
null
null
null
null
UTF-8
C++
false
false
7,852
cpp
/* * $Id$ * * Windows DC class. * * Copyright (C) 2008 Dorothea Wachmann * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. */ #include "os.h" #include "util/eventlogger.h" #include "com/comserver.h" #include "util/logstream.h" #include "msgs.h" namespace bvr20983 { namespace util { EventLogger* EventLogger::m_pMe = NULL; /** * */ EventLogger* EventLogger::CreateInstance(LPCTSTR serviceName) { if( m_pMe==NULL ) m_pMe = new EventLogger(serviceName); return m_pMe; } /** * */ void EventLogger::DeleteInstance() { if( NULL!=m_pMe ) { if( NULL!=m_pMe ) delete m_pMe; m_pMe = NULL; } // of if } /** * */ EventLogger::EventLogger(LPCTSTR serviceName) : m_hEventSource(NULL) { m_hEventSource = ::RegisterEventSource(NULL, serviceName); if( NULL==m_hEventSource ) throw "Failed to register service."; } /** * */ EventLogger::~EventLogger() { if( NULL!=m_hEventSource ) ::DeregisterEventSource(m_hEventSource); m_hEventSource = NULL; } /** * */ void EventLogger::RegisterInRegistry(Registry& evtSrcRegKey,LPCTSTR serviceName) { TCHAR szModulePath[MAX_PATH]; COM::COMServer::GetModuleFileName(szModulePath,sizeof(szModulePath)/sizeof(szModulePath[0])); if( _tcslen(szModulePath)>0 && NULL!=serviceName ) { TString evtSrcRegKeyStr(_T("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\")); evtSrcRegKeyStr += serviceName; evtSrcRegKey.SetKeyPrefix(evtSrcRegKeyStr); OutputDebugFmt(_T("EventLogger::RegisterInRegistry(%s) <%s>\n"),serviceName,evtSrcRegKeyStr.c_str()); TString msiInprocServerName(_T("[!")); msiInprocServerName += evtSrcRegKey.GetComponentId(); msiInprocServerName += _T("]"); if( evtSrcRegKey.GetDumpType()==Registry::MSI || evtSrcRegKey.GetDumpType()==Registry::XML ) { evtSrcRegKey.SetValue(NULL,_T("EventMessageFile"),msiInprocServerName); evtSrcRegKey.SetValue(NULL,_T("CategoryMessageFile"),msiInprocServerName); } // of if else { evtSrcRegKey.SetValue(NULL,_T("EventMessageFile"),szModulePath); evtSrcRegKey.SetValue(NULL,_T("CategoryMessageFile"),szModulePath); } // of else evtSrcRegKey.SetValue(NULL,_T("TypesSupported"),EVENTLOG_ERROR_TYPE|EVENTLOG_INFORMATION_TYPE|EVENTLOG_WARNING_TYPE); evtSrcRegKey.SetValue(NULL,_T("CategoryCount"),3); } // of if } // of EventLogger::RegisterInRegistry() /** * */ void EventLogger::LogMessage(LPCTSTR logText) { LogEventMessage( logText, EVENT_GENERIC_INFORMATION); } /** * */ void EventLogger::LogError(LPCTSTR errText) { LogEventMessage( errText, EVENT_GENERIC_ERROR,EVENTLOG_ERROR_TYPE); } /** * */ void EventLogger::LogError(LPCTSTR errText, LPCTSTR extraText) { const int errTextLen = _tcslen(errText) + 1; const int extraTextLen = (extraText != NULL) ? _tcslen(extraText) : 0; const int totalTextLen = errTextLen + extraTextLen; LPTSTR fullText = (LPTSTR)calloc(totalTextLen,sizeof(TCHAR)); ::memset(fullText, 0, totalTextLen); _tcscpy_s(fullText,totalTextLen,errText); if( extraTextLen>0 ) _tcscpy_s(fullText + errTextLen,extraTextLen,extraText); LogEventMessage( fullText, EVENT_GENERIC_ERROR,EVENTLOG_ERROR_TYPE); free(fullText); } /** * */ void EventLogger::LogEventMessage(LPCTSTR messageText, int messageType, int eventlogType) { if( m_hEventSource!=NULL ) { LPCTSTR messages[1] = { messageText }; ::ReportEvent(m_hEventSource, eventlogType, CAT_COMMON, messageType, NULL, 1, 0, messages, NULL); } } /** * */ void EventLogger::LogFunctionError(LPCTSTR functionName) { LPTSTR messageText = NULL; ::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), (LPTSTR)&messageText, 0, NULL); LogFunctionMessage(functionName, messageText); ::LocalFree(messageText); } /** * */ void EventLogger::LogFunctionMessage(LPCTSTR functionName, LPCTSTR messageText) { LPCTSTR messages[2] = { functionName, messageText }; if( m_hEventSource!=NULL ) ::ReportEvent(m_hEventSource, EVENTLOG_ERROR_TYPE, 0, EVENT_FUNCTION_FAILED, NULL, 2, 0, messages, NULL); } /** * */ void EventLogger::LogInstall(LPCTSTR product,LPCTSTR component,BOOL install,HRESULT hr) { LPCTSTR messages[3] = { product,component,NULL }; LPTSTR hrErrorText = NULL; WORD eventType = SUCCEEDED(hr) ? EVENTLOG_SUCCESS : EVENTLOG_ERROR_TYPE; DWORD eventId = EVENT_COMPONENT_INSTALLED; if( install ) eventId = SUCCEEDED(hr) ? EVENT_COMPONENT_INSTALLED : EVENT_COMPONENT_INSTALLATIONFAILED; else eventId = SUCCEEDED(hr) ? EVENT_COMPONENT_UNINSTALLED : EVENT_COMPONENT_UNINSTALLATIONFAILED; if( FAILED(hr) ) { TCHAR errorMsg[1024]; ::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, hr, MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), (LPTSTR)&hrErrorText, 0, NULL); _stprintf_s(errorMsg,sizeof(errorMsg)/sizeof(errorMsg[0]),_T("%s[0x%lx]"),hrErrorText,hr); messages[2] = errorMsg; } // of if if( m_hEventSource!=NULL ) ::ReportEvent(m_hEventSource, eventType, CAT_INSTALL, eventId, NULL, 3, 0, messages, NULL); if( NULL!=hrErrorText ) ::LocalFree(hrErrorText); } // of LogInstall() } // of namespace util } // of namespace bvr20983 /** * exportwrapper */ STDAPI_(void) EvtLogMessage(LPCTSTR logText) { bvr20983::util::EventLogger::GetInstance()->LogMessage(logText); } STDAPI_(void) EvtLogError(LPCTSTR logText) { bvr20983::util::EventLogger::GetInstance()->LogError(logText); } STDAPI_(void) EvtLogError2(LPCTSTR logText, LPCTSTR extraText) { bvr20983::util::EventLogger::GetInstance()->LogError(logText,extraText); } STDAPI_(void) EvtLogEventMessage(LPCTSTR messageText, int messageType) { bvr20983::util::EventLogger::GetInstance()->LogEventMessage(messageText,messageType); } STDAPI_(void) EvtLogFunctionError(LPCTSTR functionName) { bvr20983::util::EventLogger::GetInstance()->LogFunctionError(functionName); } STDAPI_(void) EvtLogFunctionMessage(LPCTSTR functionName, LPCTSTR messageText) { bvr20983::util::EventLogger::GetInstance()->LogFunctionMessage(functionName,messageText); } STDAPI_(void) EvtLogInstall(LPCTSTR product,LPCTSTR component,BOOL install,HRESULT hr) { bvr20983::util::EventLogger::GetInstance()->LogInstall(product,component,install,hr); } /*==========================END-OF-FILE===================================*/
[ "dwachmann@01137330-e44e-0410-aa50-acf51430b3d2" ]
[ [ [ 1, 233 ] ] ]
8d186f709cd80f36a97d4ab17e3b13694e21e2ab
38926bfe477f933a307f51376dd3c356e7893ffc
/Source/GameDLL/TacticalAttachment.cpp
5d3ca1380739c5ae08c085b965d30600784d78f8
[]
no_license
richmondx/dead6
b0e9dd94a0ebb297c0c6e9c4f24c6482ef4d5161
955f76f35d94ed5f991871407f3d3ad83f06a530
refs/heads/master
2021-12-05T14:32:01.782047
2008-01-01T13:13:39
2008-01-01T13:13:39
null
0
0
null
null
null
null
WINDOWS-1250
C++
false
false
3,865
cpp
/************************************************************************* Crytek Source File. Copyright (C), Crytek Studios, 2001-2006. ------------------------------------------------------------------------- $Id$ $DateTime$ ------------------------------------------------------------------------- History: - 21:11:2005 15:45 : Created by Márcio Martins *************************************************************************/ #include "StdAfx.h" #include "TacticalAttachment.h" #include "Game.h" #include "Tactical.h" #include "Actor.h" //------------------------------------------------------------------------ CTacticalAttachment::CTacticalAttachment() { //m_targets.resize(0); } //------------------------------------------------------------------------ CTacticalAttachment::~CTacticalAttachment() { //m_targets.resize(0); } //------------------------------------------------------------------------ bool CTacticalAttachment::Init(IGameObject * pGameObject ) { if (!CItem::Init(pGameObject)) return false; return true; } //------------------------------------------------------------------------ void CTacticalAttachment::PostInit(IGameObject * pGameObject ) { CItem::PostInit(pGameObject); } //------------------------------------------------------------------------ void CTacticalAttachment::OnReset() { CItem::OnReset(); //m_targets.resize(0); } /*********************************************************** //------------------------------------------------------------------------ void CTacticalAttachment::AddTarget(EntityId trgId) { stl::push_back_unique(m_targets, trgId); } *************************************************************/ //------------------------------------------------------------------------ void CTacticalAttachment::OnAttach(bool attach) { CItem::OnAttach(attach); } /************************************************************ //------------------------------------------------------------------------ void CTacticalAttachment::RunEffectOnHumanTargets(STacEffect *effect, EntityId shooterId) { if (!effect) return; for (std::vector<EntityId>::const_iterator it=m_targets.begin(); it!=m_targets.end(); ++it) effect->Activate(*it, shooterId); m_targets.resize(0); } //------------------------------------------------------------------------ void CTacticalAttachment::RunEffectOnAlienTargets(STacEffect *effect, EntityId shooterId) { RunEffectOnHumanTargets(effect, shooterId); } *******************************************************************/ //------------------------------------------------------------------------ void CTacticalAttachment::SleepTarget(EntityId shooterId, EntityId targetId) { CActor *pActor = (CActor *)gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(targetId); if (pActor && pActor->CanSleep()) { IAISystem *pAISystem=gEnv->pAISystem; if (pAISystem) { if(IEntity* pEntity=pActor->GetEntity()) { if(IAIObject* pAIObj=pEntity->GetAI()) { IAISignalExtraData *pEData = pAISystem->CreateSignalExtraData(); // no leak - this will be deleted inside SendAnonymousSignal // try to retrieve the shooter position if (IEntity* pOwnerEntity = gEnv->pEntitySystem->GetEntity(shooterId)) pEData->point = pOwnerEntity->GetWorldPos(); else pEData->point = pEntity->GetWorldPos(); IAIActor* pAIActor = pAIObj->CastToIAIActor(); if(pAIActor) pAIActor->SetSignal(1,"TRANQUILIZED",0,pEData); } } } pActor->CreateScriptEvent("sleep", 0); pActor->GetGameObject()->SetPhysicalizationProfile(eAP_Sleep); // no dropping weapons for AI if(pActor->IsPlayer()) pActor->DropItem(pActor->GetCurrentItemId(), 1.0f, false); pActor->SetSleepTimer(12.5f); } }
[ [ [ 1, 125 ] ] ]
ff654cdc9b4eb39f102508885026ecc994e8f3d8
f8c4a7b2ed9551c01613961860115aaf427d3839
/src/cMouse.cpp
716c9993aa721406d550c65d95e82c9e27562f40
[]
no_license
ifgrup/mvj-grupo5
de145cd57d7c5ff2c140b807d2d7c5bbc57cc5a9
6ba63d89b739c6af650482d9c259809e5042a3aa
refs/heads/master
2020-04-19T15:17:15.490509
2011-12-19T17:40:19
2011-12-19T17:40:19
34,346,323
0
0
null
null
null
null
UTF-8
C++
false
false
7,601
cpp
#include "cMouse.h" #include "cLog.h" #include "cScene.h" #include <dxerr9.h> /************************************************************************ cMouse::Constructor() Initialize DI device *************************************************************************/ cMouse::cMouse(LPDIRECTINPUT8 pDI, HWND hwnd, bool isExclusive) { cLog *Log = cLog::Instance(); HRESULT hr; hr = pDI->CreateDevice(GUID_SysMouse, &m_pDIDev, NULL); if(FAILED(hr)) { Log->Error(hr,"Creating mouse device"); } hr = m_pDIDev->SetDataFormat(&c_dfDIMouse); if(FAILED(hr)) { Log->Error(hr,"Setting mouse data format"); } //DIMOUSESTATE Structure - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/input/ref/structs/dimousestate.asp DWORD flags; if (isExclusive) { flags = DISCL_FOREGROUND | DISCL_EXCLUSIVE | DISCL_NOWINKEY; } else { flags = DISCL_FOREGROUND | DISCL_NONEXCLUSIVE; //ShowCursor(false); } hr = m_pDIDev->SetCooperativeLevel(hwnd, flags); if (FAILED(hr)) { Log->Error(hr,"Setting mouse cooperative level"); } hr = m_pDIDev->Acquire(); if(FAILED(hr)) { Log->Error(hr,"Acquiring mouse"); } hr = m_pDIDev->GetDeviceState(sizeof(DIMOUSESTATE), &m_state); if(FAILED(hr)) { Log->Error(hr,"Getting mouse device state"); } SetPointer(NORMAL); SetSelection(SELECT_NOTHING); InitAnim(); } /*************************************************************************** cMouse::Destructor() Release DI device ***************************************************************************/ cMouse::~cMouse() { if(m_pDIDev) { m_pDIDev->Unacquire(); m_pDIDev->Release(); m_pDIDev = NULL; } } /****************************************************************************** cMouse::Read() Queuries the current state of the mouse and stores it in the member variables ********************************************************************************/ bool cMouse::Read() { cLog *Log = cLog::Instance(); HRESULT hr; hr = m_pDIDev->GetDeviceState(sizeof(DIMOUSESTATE), &m_state); if(FAILED(hr)) { Log->Error(hr,"Getting mouse device state"); hr = m_pDIDev->Acquire(); if(FAILED(hr)) { Log->Error(hr,"Acquiring mouse"); return false; } hr = m_pDIDev->GetDeviceState(sizeof(DIMOUSESTATE), &m_state); if(FAILED(hr)) { Log->Error(hr,"Getting mouse device state"); return false; } } x+=m_state.lX; y+=m_state.lY; switch(select) { case SELECT_NOTHING: if(x<0) x=0; else if(x>=SCREEN_RES_X) x=SCREEN_RES_X-1; if(y<0) y=0; else if(y>=SCREEN_RES_Y) y=SCREEN_RES_Y-1; break; case SELECT_SCENE: if(x<SCENE_Xo) x=SCENE_Xo; else if(x>=SCENE_Xf) x=SCENE_Xf-1; if(y<SCENE_Yo) y=SCENE_Yo; else if(y>=SCENE_Yf) y=SCENE_Yf-1; break; case SELECT_RADAR: if(x<RADAR_Xo) x=RADAR_Xo; else if(x>=RADAR_Xf) x=RADAR_Xf-1; if(y<RADAR_Yo) y=RADAR_Yo; else if(y>=RADAR_Yf) y=RADAR_Yf-1; break; } if((x<SCENE_Xf)&&(y>=SCENE_Yo)) { cx=(x-SCENE_Xo)>>5; cy=(y-SCENE_Yo)>>5; } else { cx=-1; cy=-1; } return true; } /****************************************************************************** cMouse::Acquire() Acquires mouse ********************************************************************************/ bool cMouse::Acquire() { cLog *Log = cLog::Instance(); HRESULT hr; hr = m_pDIDev->Acquire(); if(FAILED(hr)) { Log->Error(hr,"Acquiring mouse"); return false; } return true; } /****************************************************************************** cMouse::Unacquire() Unacquires mouse ********************************************************************************/ bool cMouse::Unacquire() { cLog *Log = cLog::Instance(); HRESULT hr; hr = m_pDIDev->Unacquire(); if(FAILED(hr)) { Log->Error(hr,"Unacquiring mouse"); return false; } return true; } /****************************************************************************** Mouse queries ********************************************************************************/ bool cMouse::ButtonDown(int button) { return (m_state.rgbButtons[button] & 0x80) ? true : false; } bool cMouse::ButtonUp(int button) { return (m_state.rgbButtons[button] & 0x80) ? false : true; } int cMouse::GetWheelMovement() { return m_state.lZ; } void cMouse::GetMovement(int *dx, int *dy) { *dx = m_state.lX; *dy = m_state.lY; } void cMouse::SetPosition(int xo, int yo) { x = xo; y = yo; } void cMouse::GetPosition(int *xpos, int *ypos) { *xpos = x; *ypos = y; } void cMouse::GetCell(int *xcell,int *ycell) { *xcell = cx; *ycell = cy; } void cMouse::SetPointer(int p) { pointer = p; } int cMouse::GetPointer() { return pointer; } void cMouse::SetSelection(int s) { select = s; } int cMouse::GetSelection() { return select; } void cMouse::SetSelectionPoint(int sx,int sy) { select_x = sx; select_y = sy; } void cMouse::GetSelectionPoint(int *sx,int *sy) { *sx = select_x; *sy = select_y; } /****************************************************************************** cMouse::GetRect() Get sprite pointer rectangle ********************************************************************************/ void cMouse::GetRect(RECT *rc,int *posx,int *posy) { switch(pointer) { case NORMAL: SetRect(rc,0,0,32,32); *posx= 0; *posy= 0; break; case MOVE: SetRect(rc,seq<<5, 96,(seq+1)<<5,128); *posx=-16; *posy=-16; break; case ATTACK: SetRect(rc,seq<<5,128,(seq+1)<<5,160); *posx=-16; *posy=-16; break; case SELECT: SetRect(rc,seq<<5, 64,(seq+1)<<5, 96); *posx=-16; *posy=-16; break; case MN: SetRect(rc,seq<<5,160,(seq+1)<<5,192); *posx=-16; *posy= 0; break; case MS: SetRect(rc,seq<<5,192,(seq+1)<<5,224); *posx=-16; *posy=-31; break; case ME: SetRect(rc,seq<<5,224,(seq+1)<<5,256); *posx=-31; *posy=-16; break; case MO: SetRect(rc,seq<<5,256,(seq+1)<<5,288); *posx= 0; *posy=-16; break; case MNE: SetRect(rc,seq<<5,288,(seq+1)<<5,320); *posx=-31; *posy= 0; break; case MSE: SetRect(rc,seq<<5,320,(seq+1)<<5,352); *posx=-31; *posy=-31; break; case MNO: SetRect(rc,seq<<5,352,(seq+1)<<5,384); *posx= 0; *posy= 0; break; case MSO: SetRect(rc,seq<<5,384,(seq+1)<<5,416); *posx= 0; *posy=-31; break; } delay++; if(delay>MDELAY) { seq++; if(pointer>=MN) { if(seq==16) seq=0; } else { if(seq==8) seq=0; } delay=0; } } /****************************************************************************** cMouse::In() Mouse position in rectangle ********************************************************************************/ bool cMouse::In(int xo,int yo,int xf,int yf) { return ((x>=xo)&&(x<xf)&&(y>=yo)&&(y<yf)) ? true : false; } /****************************************************************************** cMouse::InCell() Mouse position in same cell ********************************************************************************/ bool cMouse::InCell(cScene *Scene,int cellx,int celly) { return (((Scene->cx+cx)==cellx)&&((Scene->cy+cy)==celly)) ? 1 : 0; } /****************************************************************************** cMouse::InitAnim() Init animation control variables ********************************************************************************/ void cMouse::InitAnim() { seq=0; delay=0; }
[ "[email protected]@7a9e2121-179f-53cc-982f-8ee3039a786c" ]
[ [ [ 1, 309 ] ] ]
b1af7ca868fea83cbb7a60e844a765976bbc4895
d594bd23addf13174df822d912240cad83d83a35
/샘플소스/FwHookDrv_src/FirewallHooK/FirewallAppDoc.h
7e462f01a758723c13ce86254ede978e90b3653b
[]
no_license
fastmutex/hackerschool
3a9eb88cf0cea1e3c77409298f8ef6c4e6273432
79b657cf4fb1f675343c1ae928fffdd6bbfb2d22
refs/heads/master
2016-09-15T17:18:19.973089
2009-03-16T09:26:24
2009-03-16T09:26:24
32,825,757
3
1
null
null
null
null
UTF-8
C++
false
false
1,916
h
// FirewallAppDoc.h : interface of the CFirewallAppDoc class // ///////////////////////////////////////////////////////////////////////////// #if !defined(AFX_FIREWALLAPPDOC_H__615C5245_0FBE_434A_B124_2EAEB8BBD20B__INCLUDED_) #define AFX_FIREWALLAPPDOC_H__615C5245_0FBE_434A_B124_2EAEB8BBD20B__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "Rules.h" #define MAX_RULES 15 class CFirewallAppDoc : public CDocument { protected: // create from serialization only CFirewallAppDoc(); DECLARE_DYNCREATE(CFirewallAppDoc) // Attributes public: unsigned int nRules; RuleInfo rules[MAX_RULES]; // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CFirewallAppDoc) public: virtual BOOL OnNewDocument(); virtual void Serialize(CArchive& ar); //}}AFX_VIRTUAL // Implementation public: void DeleteRule(unsigned int position); void ResetRules(); int AddRule(unsigned long srcIp, unsigned long srcMask, unsigned short srcPort, unsigned long dstIp, unsigned long dstMask, unsigned short dstPort, unsigned int protocol, int action); virtual ~CFirewallAppDoc(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: // Generated message map functions protected: //{{AFX_MSG(CFirewallAppDoc) // NOTE - the ClassWizard will add and remove member functions here. // DO NOT EDIT what you see in these blocks of generated code ! //}}AFX_MSG DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_FIREWALLAPPDOC_H__615C5245_0FBE_434A_B124_2EAEB8BBD20B__INCLUDED_)
[ "give.bob@6014acd8-120a-11de-a371-4bb87e7649b8" ]
[ [ [ 1, 74 ] ] ]
7c0cd9cedf57804e5233375a395804ad0d9e3c1e
83904296a02c9ecd2868ff37f4fc0c77f09e1b26
/parser/public_grammar.h
7132c739e867db7b977083ab9f589dfcf0023603
[]
no_license
Coldiep/ezop
5aad951ef47b90f5ce5c2d82582d733deb13f04a
c463b7a554f66b291aa3f2497ebe8e93687758a4
refs/heads/master
2021-05-26T15:28:43.152483
2011-08-14T19:36:06
2011-08-14T19:36:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,473
h
#ifndef PUBLIC_GRAMMAR_H__ #define PUBLIC_GRAMMAR_H__ #include <list> #include <map> #include <iostream> #include <stdint.h> namespace parser { /*! * \brief Класс представляет интерфейсную грамматику парсера. * * Парсер использует оптимизированную для алгоритма синтаксического анализа * грамматику, определенную в классе Grammar. Эта грамматика генерируется * из ообъекта класса PublicGrammar. Таким образом, класс PublicGrammar * предоставляет интерфейс пользователю для добавления элементов в грамматику, * но добавленные элементы должны быть преобразованы во внутренний оптимальный * формат перед запуском алгоритма синтаксического анализа. */ class PublicGrammar { public: //! Тип идентфикатора словаря символов и правил грамматики. typedef uint32_t MapId; //! Тип списка идентификаторов словаря. typedef std::list<MapId> MapIdList; //! Значение неккоректного идентифкатора, заразервированного для внутренних целей. static const MapId kUnknownMapId = 0; /*! * \brief Класс, представляющий символ грамматики. * * Символ характеризуется именем, а также признаком того, является ли он * нетерминальным или нет. Каждый символ имеет уникальный идентификатор, * который является в словаре символов, хранящемся в грамматике. */ struct Symbol { const char* name_; //!> Имя символа в человекочитаемом виде. bool nonterminal_; //!< Признак того, что данный символ нетерминал. //! Конструктор по умолчанию. Symbol() : name_(NULL) {} //! Полная инициализация. Symbol( const char* name, bool nonterminal ) : name_(name) , nonterminal_(nonterminal) {} }; /*! * \brief Класс, представляющий правило контекстно-свободной грамматики. * * Правило содержит имя в читабельном для человка виде, а также * идентификатор символа в левой части правила и список идентификаторов * символов в правой части правила. Более конкретно: * A --> X1 X2 ... Xn * представляется в виде: * name_: A --> X1 X2 ... Xn * lhs_symbol_: MapId(A) * rhs_list_: MapId(X1), MapId(X2), ..., MapId(Xn). */ struct Rule { const char* name_; //!< Имя правила в читабельном для человека виде. int lhs_symbol_; //!< Идентификатор символа в левой части правила. MapIdList rhs_list_; //!< Список идентфикаторов символов в правой части правила. /*! * \brief Инициализация по умолчанию. * * Идентификатор в левой части правила инициализируется в нулем который представляет * значение, зарезервированное для того, чтобы держать инфомацию о некорректном * идентификаторе. */ Rule() : name_(NULL) , lhs_symbol_(kUnknownMapId) {} /*! * \brief Обычная инициализация. * * \param name Название правила в читабельном для человека виде. */ explicit Rule( const char* name ) : name_(name) , lhs_symbol_(kUnknownMapId) {} }; //! Тип словаря символов грамматики. typedef std::map<MapId, Symbol> SymbolTable; //! Тип словаря правил грамматики. typedef std::map<MapId, Rule> RuleTable; private: SymbolTable symbols_; //!< Словарь символов грамматики. RuleTable rules_; //!< Словарь правил грамматики. const char* grammar_name_; //!< Название грамматики в читабельном для человека виде. MapId max_sym_id_; //!< Максимальное значение идентификатора символа. MapId max_rule_id_; //!< Максимальное значение идентификатора правила. MapId min_sym_id_; //!< Минимальное значение идентификатора символа. MapId min_rule_id_; //!< Минимальное значение идентификатора правила. MapId num_of_terms_; //!< Число терминальных символов в грамматике. MapId num_of_nonterms_; //!< Число нетерминальных символов в грамматике. MapId start_symbol_; //!< Идентификатор начального нетерминала грамматики. public: /*! * /brief Инициализация грамматики. * * \param desc Описание грамматики в удобном для человека виде. */ explicit PublicGrammar( const char* desc ); //------------------- Методы для добавления элементов в грамматику -------------------------- /*! * \brief Добавление терминального символа. * * \param id Идентификатор символа. * \param name Имя символа для человека. */ void AddTerminal( MapId id, const char* name ); /*! * \brief Добавление нетерминального символа. * * \param id Идентификатор символа. * \param name Имя символа для человека. */ void AddNonterminal( MapId id, const char* name ); /*! * \brief Добавление правила. * * \param id Идентификатор правила. * \param name Имя символа для человека. */ void AddRule( MapId id, const char* name ); /*! * \brief Добавление символа в левой части правила. * * \param rule_id Идентификатор правила. * \param sym_id Идентификатор символа. */ void AddLhsSymbol( MapId rule_id, MapId sym_id ); /*! * \brief Добавление символа в правой части правила. * * \param rule_id Идентификатор правила. * \param sym_id Идентификатор символа. */ void AddRhsSymbol( MapId rule_id, MapId sym_id ); /*! * \brief Установка идентификатора начального нетерминала грамматики. * * \param id Идентификатор начального нетерминала. */ void SetStartSymbolId( MapId id ) { start_symbol_ = id; } //------------------------- Методы для получения информации о содержимом грамматики ---------------------------- //! Получение количества терминальных символов граммматики. MapId GetNumOfTerminals() const { return num_of_terms_; } //! Получение количества нетерминальных символов граммматики. MapId GetNumOfNonterminals() const { return num_of_nonterms_; } //! Получение максимального значения идентификатора символа. MapId GetMaxSymbolId() const { return max_sym_id_; } //! Получение максимального значения идентификатора правила. MapId GetMaxRuleId() const { return max_rule_id_; } //! Получение минимального значения идентификатора символа. MapId GetMinSymbolId() const { return min_sym_id_; } //! Получение минимального значения идентификатора правила. MapId GetMinRuleId() const { return min_rule_id_; } //! Получение разности между максимальным и минимальным значениями идентификатором символов. MapId GetSymbolIdInterval() const { return max_sym_id_ - min_sym_id_; } //! Получение разности между максимальным и минимальным значениями идентификатором правил символов. MapId GetRuleIdInterval() const { return max_rule_id_ - min_rule_id_; } //! Получение таблицы символов. const SymbolTable& GetSymbolTable() const { return symbols_; } //! Получение таблицы правил. const RuleTable& GetRuleTable() const { return rules_; } //! Получение идентификатора начального нетерминала грамматики. MapId GetStartSymbolId() const { return start_symbol_; } /*! * \brief Печать содержимого грамматики. * * \param out Поток, в который будет производиться печать. */ void Print( std::ostream& out ); }; } // namespace parser #endif // PUBLIC_GRAMMAR_H__
[ [ [ 1, 6 ], [ 23, 23 ], [ 47, 48 ], [ 53, 55 ], [ 83, 84 ], [ 93, 95 ], [ 98, 98 ], [ 106, 106 ], [ 111, 112 ], [ 114, 115 ], [ 197, 197 ], [ 200, 200 ], [ 203, 203 ], [ 206, 206 ], [ 216, 217 ] ], [ [ 7, 22 ], [ 24, 46 ], [ 49, 52 ], [ 56, 82 ], [ 85, 92 ], [ 96, 97 ], [ 99, 105 ], [ 107, 110 ], [ 113, 113 ], [ 116, 196 ], [ 198, 199 ], [ 201, 202 ], [ 204, 205 ], [ 207, 215 ], [ 218, 218 ] ] ]
6d6b69ef2e73a87e8d4733f6b81978f6518d4c18
54cacc105d6bacdcfc37b10d57016bdd67067383
/trunk/source/level/objects/components/CmpMovement.cpp
70ec3ad511d076af894594e20bbd266662286cf9
[]
no_license
galek/hesperus
4eb10e05945c6134901cc677c991b74ce6c8ac1e
dabe7ce1bb65ac5aaad144933d0b395556c1adc4
refs/heads/master
2020-12-31T05:40:04.121180
2009-12-06T17:38:49
2009-12-06T17:38:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
12,482
cpp
/*** * hesperus: CmpMovement.cpp * Copyright Stuart Golodetz, 2009. All rights reserved. ***/ #include "CmpMovement.h" #include <source/level/bounds/BoundsManager.h> #include <source/level/nav/NavDataset.h> #include <source/level/nav/NavLink.h> #include <source/level/nav/NavManager.h> #include <source/level/nav/NavMesh.h> #include <source/level/nav/NavMeshUtil.h> #include <source/level/nav/NavPolygon.h> #include <source/level/trees/OnionUtil.h> #include <source/math/geom/GeomUtil.h> #include "ICmpSimulation.h" namespace hesp { //#################### CONSTRUCTORS #################### CmpMovement::CmpMovement() : m_curNavPolyIndex(-1) {} //#################### STATIC FACTORY METHODS #################### IObjectComponent_Ptr CmpMovement::load(const Properties&) { return IObjectComponent_Ptr(new CmpMovement); } //#################### PUBLIC METHODS #################### bool CmpMovement::attempt_navmesh_acquisition(const std::vector<CollisionPolygon_Ptr>& polygons, const OnionTree_CPtr& tree, const NavMesh_CPtr& navMesh) { ICmpPosition_CPtr cmpPosition = m_objectManager->get_component(m_objectID, cmpPosition); assert(cmpPosition != NULL); const Vector3d& position = cmpPosition->position(); // Try and find a nav polygon, starting from the last known one. m_curNavPolyIndex = NavMeshUtil::find_nav_polygon(position, m_curNavPolyIndex, polygons, tree, navMesh); return m_curNavPolyIndex != -1; } void CmpMovement::check_dependencies() const { check_dependency<ICmpSimulation>(); } int CmpMovement::cur_nav_poly_index() const { return m_curNavPolyIndex; } void CmpMovement::move(const Vector3d& dir, double speed, int milliseconds, const std::vector<CollisionPolygon_Ptr>& polygons, const OnionTree_CPtr& tree, const NavManager_CPtr& navManager) { ICmpSimulation_Ptr cmpSimulation = m_objectManager->get_component(m_objectID, cmpSimulation); assert(cmpSimulation != NULL); Move move; move.dir = dir; move.mapIndex = m_objectManager->bounds_manager()->lookup_bounds_index(cmpSimulation->bounds_group(), cmpSimulation->posture()); move.timeRemaining = milliseconds / 1000.0; NavMesh_CPtr navMesh = navManager->dataset(move.mapIndex)->nav_mesh(); double oldTimeRemaining; do { oldTimeRemaining = move.timeRemaining; if(m_curTraversal) do_traverse_move(move, speed /* FIXME: Select the appropriate speed here */, polygons, navMesh); if(move.timeRemaining == 0) break; if(attempt_navmesh_acquisition(polygons, tree, navMesh)) do_navmesh_move(move, speed, polygons, tree, navMesh); else do_direct_move(move, speed, tree); } while(move.timeRemaining > 0 && oldTimeRemaining - move.timeRemaining > 0.0001); } double CmpMovement::run_speed() const { // FIXME: This should be loaded in. return 10.0; // in units/s } Properties CmpMovement::save() const { return Properties(); } /** @return true, if a collision occurred, or false otherwise */ bool CmpMovement::single_move(const Vector3d& dir, double speed, int milliseconds, const OnionTree_CPtr& tree) { // FIXME: The bool return here is unintuitive and should be replaced with something more sensible. ICmpSimulation_Ptr cmpSimulation = m_objectManager->get_component(m_objectID, cmpSimulation); assert(cmpSimulation != NULL); // Check to make sure we're not currently traversing a link: don't let the object be moved if we are. if(m_curTraversal) return true; Move move; move.dir = dir; move.mapIndex = m_objectManager->bounds_manager()->lookup_bounds_index(cmpSimulation->bounds_group(), cmpSimulation->posture()); move.timeRemaining = milliseconds / 1000.0; return do_direct_move(move, speed, tree); } void CmpMovement::set_navmesh_unacquired() { m_curNavPolyIndex = -1; } bool CmpMovement::traversing_link() const { return m_curTraversal != NULL; } double CmpMovement::walk_speed() const { // FIXME: This should be loaded in. return 5.0; // in units/s } //#################### PRIVATE METHODS #################### /** @return true, if a collision occurred, or false otherwise */ bool CmpMovement::do_direct_move(Move& move, double speed, const OnionTree_CPtr& tree) { bool collisionOccurred = false; ICmpSimulation_Ptr cmpSimulation = m_objectManager->get_component(m_objectID, cmpSimulation); assert(cmpSimulation != NULL); Vector3d source = cmpSimulation->position(); Vector3d dest = source + move.dir * speed * move.timeRemaining; // Check the ray against the tree. OnionUtil::Transition transition = OnionUtil::find_first_transition(move.mapIndex, source, dest, tree); switch(transition.classifier) { case OnionUtil::RAY_EMPTY: { // It's perfectly fine to let the object move along this ray, as it doesn't intersect a wall. break; } case OnionUtil::RAY_SOLID: { // We were on a wall (i.e. coplanar to it) prior to the move - prevent any further moves into the wall, // and update the move direction to allow sliding along the wall instead. update_move_direction_for_sliding(move); move.timeRemaining -= 0.001; // make this cost 1ms of time (otherwise the calling function will think we got stuck) return true; } case OnionUtil::RAY_TRANSITION_ES: { // Stop the object going into a wall. dest = *transition.location; collisionOccurred = true; // Record the transition plane. update_recent_planes(*transition.plane); // Update the move direction to allow sliding. update_move_direction_for_sliding(move); break; } case OnionUtil::RAY_TRANSITION_SE: { // This should never happen (since objects can't move into walls), but better let the object back into // the world if it does happen. break; } } cmpSimulation->set_position(dest); // Update the time remaining. double moveLength = source.distance(dest); double timeTaken = moveLength / speed; move.timeRemaining -= timeTaken; return collisionOccurred; } void CmpMovement::do_navmesh_move(Move& move, double speed, const std::vector<CollisionPolygon_Ptr>& polygons, const OnionTree_CPtr& tree, const NavMesh_CPtr& navMesh) { ICmpPosition_Ptr cmpPosition = m_objectManager->get_component(m_objectID, cmpPosition); assert(cmpPosition != NULL); // Step 1: Project the movement vector onto the plane of the current nav polygon. const NavPolygon& navPoly = *navMesh->polygons()[m_curNavPolyIndex]; int curColPolyIndex = navPoly.collision_poly_index(); const CollisionPolygon& curPoly = *polygons[curColPolyIndex]; Plane plane = make_plane(curPoly); move.dir = project_vector_onto_plane(move.dir, plane); if(move.dir.length_squared() > SMALL_EPSILON*SMALL_EPSILON) move.dir.normalize(); // Step 2: Check whether the new movement vector goes through the influence zone of any of the out navlinks. Vector3d source = cmpPosition->position(); Vector3d dest = source + move.dir * speed * move.timeRemaining; boost::optional<Vector3d> hit; int hitNavlink = -1; const std::vector<int>& links = navPoly.out_links(); for(std::vector<int>::const_iterator it=links.begin(), iend=links.end(); it!=iend; ++it) { const NavLink_Ptr& link = navMesh->links()[*it]; hit = link->hit_test(source, dest); if(hit) { hitNavlink = *it; #if 0 std::cout << "Hit navlink at " << *hit << ": "; link->output(std::cout); std::cout << '\n'; #endif break; } } // Step 3.a: If the new movement vector doesn't hit a navlink, check whether the other end of the movement vector is within the current polygon. // // - If yes, move there, set the time remaining to zero and return. // // - If no, do a direct move in the original direction, since we are either leaving the navmesh or hitting a wall. if(hitNavlink == -1) { if(point_in_polygon(dest, curPoly)) { cmpPosition->set_position(dest); move.timeRemaining = 0; } else { do_direct_move(move, speed, tree); } return; } // Step 3.b: If the new movement vector hits a navlink, move the point at which it first enters the influence zone, // and reduce the time remaining appropriately. Then, initiate the link traversal. // Move the object to the link entrance point. cmpPosition->set_position(*hit); // Update the time remaining. double moveLength = source.distance(*hit); double timeTaken = moveLength / speed; move.timeRemaining -= timeTaken; // Initiate the link traversal. m_curTraversal.reset(new Traversal(hitNavlink, *hit, 0)); } void CmpMovement::do_traverse_move(Move& move, double speed, const std::vector<CollisionPolygon_Ptr>& polygons, const NavMesh_CPtr& navMesh) { ICmpPosition_Ptr cmpPosition = m_objectManager->get_component(m_objectID, cmpPosition); assert(cmpPosition != NULL); Traversal_CPtr traversal = m_curTraversal; if(!traversal) return; NavLink_Ptr link = navMesh->links()[traversal->linkIndex]; double remaining = 1 - traversal->t; // % of link remaining double remainingTraversalTime = remaining * link->traversal_time(speed); // time to traverse remainder double availableTraversalTime = std::min(remainingTraversalTime, move.timeRemaining); // time to spend traversing if(availableTraversalTime >= remainingTraversalTime) { // Finish traversing the link: // Update the current nav polygon and clear the current traversal. m_curNavPolyIndex = link->dest_poly(); m_curTraversal.reset(); // Move to an exit point on the link. Vector3d dest = link->traverse(traversal->source, 1); cmpPosition->set_position(dest); move.timeRemaining -= remainingTraversalTime; #if 0 int colPolyIndex = navMesh->polygons()[link->dest_poly()]->collision_poly_index(); std::cout << "Linked to polygon (" << colPolyIndex << ',' << link->dest_poly() << ')' << std::endl; #endif // Move the object very slightly away from the navlink exit: this is a hack to prevent link loops. int destColPolyIndex = navMesh->polygons()[link->dest_poly()]->collision_poly_index(); const CollisionPolygon& destPoly = *polygons[destColPolyIndex]; Plane destPlane = make_plane(destPoly); Vector3d destDir = project_vector_onto_plane(move.dir, destPlane); dest += destDir * 0.001; if(point_in_polygon(dest, destPoly)) cmpPosition->set_position(dest); } else { // Work out how much further we've progressed and update the traversal field accordingly. double deltaT = (availableTraversalTime / remainingTraversalTime) * remaining; Traversal_CPtr newTraversal(new Traversal(traversal->linkIndex, traversal->source, traversal->t + deltaT)); m_curTraversal = newTraversal; // Move further along the link. Vector3d dest = link->traverse(newTraversal->source, newTraversal->t); cmpPosition->set_position(dest); move.timeRemaining = 0; } } void CmpMovement::update_move_direction_for_sliding(Move& move) { // Update the move direction to be along the wall (to allow sliding). To do this, we remove the // component of the movement which is normal to the wall. To find the wall we're on, we look at // all the 'recent' planes we've touched and choose one which we're trying to walk behind. ICmpSimulation_CPtr cmpSimulation = m_objectManager->get_component(m_objectID, cmpSimulation); assert(cmpSimulation != NULL); const Vector3d& source = cmpSimulation->position(); Vector3d dummyDest = source + move.dir; for(std::list<Plane>::const_iterator it=m_recentPlanes.begin(), iend=m_recentPlanes.end(); it!=iend; ++it) { if(classify_point_against_plane(dummyDest, *it) == CP_BACK) { move.dir = project_vector_onto_plane(move.dir, *it); if(move.dir.length() > SMALL_EPSILON) move.dir.normalize(); else move.timeRemaining = 0; break; } } } void CmpMovement::update_recent_planes(const Plane& plane) { ICmpSimulation_CPtr cmpSimulation = m_objectManager->get_component(m_objectID, cmpSimulation); assert(cmpSimulation != NULL); // Remove any recent planes which the object's no longer on. const Vector3d& position = cmpSimulation->position(); for(std::list<Plane>::iterator it=m_recentPlanes.begin(), iend=m_recentPlanes.end(); it!=iend;) { if(classify_point_against_plane(position, *it) == CP_COPLANAR) ++it; else it = m_recentPlanes.erase(it); } // Add the latest plane. m_recentPlanes.push_front(plane); } }
[ [ [ 1, 353 ] ] ]
099e0570ce8e2e62b8681f068196691d549780f5
611fc0940b78862ca89de79a8bbeab991f5f471a
/src/Teki/Boss/Majo/RollingApple.h
2d754229a26c01ac4c72e27ee59f85369302b679
[]
no_license
LakeIshikawa/splstage2
df1d8f59319a4e8d9375b9d3379c3548bc520f44
b4bf7caadf940773a977edd0de8edc610cd2f736
refs/heads/master
2021-01-10T21:16:45.430981
2010-01-29T08:57:34
2010-01-29T08:57:34
37,068,575
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
463
h
#pragma once #include "Apple.h" /* 床に落ちたら転がり始めるりんご */ class RollingApple : public Apple { public: RollingApple(int rXPx, int rYPx, int rType); ~RollingApple(); void RollIfHitGround(); void Kaiten(); void Move(); void Draw(); private: enum STATUS { FALL, ROLL }; STATUS mStatus; int mType; float mAngle; float mAngSp; // 設定定数 float APPLE_RLSP; float APPLE_KTSP; };
[ "lakeishikawa@c9935178-01ba-11df-8f7b-bfe16de6f99b" ]
[ [ [ 1, 35 ] ] ]
1a9412fd53619e72a24d6d4995a454cda2826b70
20c74d83255427dd548def97f9a42112c1b9249a
/include/copy.h
ce4fa94b7354d380d74c9c5236479082bb8b8d6f
[]
no_license
jonyzp/roadfighter
70f5c7ff6b633243c4ac73085685595189617650
d02cbcdcfda1555df836379487953ae6206c0703
refs/heads/master
2016-08-10T15:39:09.671015
2011-05-05T12:00:34
2011-05-05T12:00:34
54,320,171
0
0
null
null
null
null
UTF-8
C++
false
false
280
h
class CopyClass { int a; char *str; public: friend void display(); CopyClass(); CopyClass(int,char*); CopyClass(CopyClass const &); ~CopyClass(); void setA(int); int getA(); void setStr(char*); char* getStr(); };
[ [ [ 1, 17 ] ] ]
0d8c8ace8d7a7f96775f7c971cf6f7ed3a614844
c1b7571589975476405feab2e8b72cdd2a592f8f
/chopshop10/HealthMon166.cpp
6bbf175f073622901d71067c031f21d2f718073b
[]
no_license
chopshop-166/frc-2010
ea9cd83f85c9eb86cc44156f21894410a9a4b0b5
e15ceff05536768c29fad54fdefe65dba9a5fab5
refs/heads/master
2021-01-21T11:40:07.493930
2010-12-10T02:04:05
2010-12-10T02:04:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,908
cpp
/******************************************************************************* * Project : chopshop10 - 2010 Chopshop Robot Controller Code * File Name : HealthMon166.cpp * Owner : Software Group (FIRST Chopshop Team 166) * Creation Date : January 23, 2010 * Revision History : From Explorer with TortoiseSVN, Use "Show log" menu item * File Description : Code which monitors health of system *******************************************************************************/ /*----------------------------------------------------------------------------*/ /* Copyright (c) MHS Chopshop Team 166, 2010. All Rights Reserved. */ /*----------------------------------------------------------------------------*/ #include "WPILib.h" #include "HealthMon166.h" // To locally enable debug printing: set true, to disable false #define DPRINTF if(false)dprintf // Sample in memory buffer struct abuf166 { struct timespec tp; // Time of snapshot char healthstats[DASHBOARD_BUFFER_MAX]; // String }; // Memory Log class HealthMonLog : public MemoryLog166 { public: HealthMonLog() : MemoryLog166( sizeof(struct abuf166), HEALTHMON_CYCLE_TIME, "healthmon", "Seconds,Nanoseconds,Elapsed Time,Healthmon String\n" ) { return; }; ~HealthMonLog() {return;}; unsigned int DumpBuffer( // Dump the next buffer into the file char *nptr, // Buffer that needs to be formatted FILE *outputFile); // and then stored in this file unsigned int PutOne(char*); // Log values }; // Write one buffer into memory unsigned int HealthMonLog::PutOne(char* stats) { struct abuf166 *ob; // Output buffer // Get output buffer if ((ob = (struct abuf166 *)GetNextBuffer(sizeof(struct abuf166)))) { // Fill it in. clock_gettime(CLOCK_REALTIME, &ob->tp); strncpy(ob->healthstats, stats, DASHBOARD_BUFFER_MAX); return (sizeof(struct abuf166)); } // Did not get a buffer. Return a zero length return (0); } // Format the next buffer for file output unsigned int HealthMonLog::DumpBuffer(char *nptr, FILE *ofile) { struct abuf166 *ab = (struct abuf166 *)nptr; // Output the data into the file fprintf(ofile, "%u,%u,%4.5f,%s\n", ab->tp.tv_sec, ab->tp.tv_nsec, ((ab->tp.tv_sec - starttime.tv_sec) + ((ab->tp.tv_nsec-starttime.tv_nsec)/1000000000.)), ab->healthstats); // Done return (sizeof(struct abuf166)); } // task constructor Team166HealthMon::Team166HealthMon(void) { Start((char *)"166HealthMonTask", HEALTHMON_CYCLE_TIME); MyTaskIsEssential=false; return; }; // task destructor Team166HealthMon::~Team166HealthMon(void) { return; }; // Main function of the task int Team166HealthMon::Main(int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10) { Robot166 *lHandle; // Local handle Proxy166 *proxy; // Local proxy handle HealthMonLog sl; // log Team166Task *kickerTask; // Kicker task Team166Task *sonarTask; // Sonar task #if UsingCamera Team166Task *visionTask; // Vision task #endif Team166Task *bannerTask; // Banner task Team166Task *ballcontrolTask; // Ball Control task // Let the world know we're in DPRINTF(LOG_DEBUG,"In the 166 HealthMon task\n"); // Wait for Robot go-ahead (e.g. entering Autonomous or Tele-operated mode) WaitForGoAhead(); // Register our logger while(!(lHandle = Robot166::getInstance())) { Wait(T166_TA_WAIT_LENGTH); } lHandle->RegisterLogger(&sl); char* buffer = new char[DASHBOARD_BUFFER_MAX]; // Register each task while(!(proxy = Proxy166::getInstance())) { Wait(T166_TA_WAIT_LENGTH); } while(!(kickerTask = Team166Task::GetTaskHandle("166KickerTask"))) { Wait(T166_TA_WAIT_LENGTH); } while(!(sonarTask = Team166Task::GetTaskHandle("166SonarTask"))) { Wait(T166_TA_WAIT_LENGTH); } #if UsingCamera while(!(visionTask = Team166Task::GetTaskHandle("166VisionTask"))) { Wait(T166_TA_WAIT_LENGTH); } #endif while(!(bannerTask = Team166Task::GetTaskHandle("166BannerTask"))) { Wait(T166_TA_WAIT_LENGTH); } while(!(ballcontrolTask = Team166Task::GetTaskHandle("166BallControl"))) { Wait(T166_TA_WAIT_LENGTH); } // Whether the camera is up // General main loop (while in Autonomous or Tele mode) while ((lHandle->RobotMode == T166_AUTONOMOUS) || (lHandle->RobotMode == T166_OPERATOR)) { sprintf(buffer, "%c %c %c %c %c", kickerTask->GetStatus()[0], bannerTask->GetStatus()[0], sonarTask->GetStatus()[0], #if UsingCamera visionTask->GetStatus()[0], #else 'Z', #endif ballcontrolTask->GetStatus()[0] ); lHandle->DriverStationDisplay(buffer); // do stuff sl.PutOne(buffer); WaitForNextLoop(); } return (0); };
[ [ [ 1, 21 ], [ 24, 29 ], [ 36, 39 ], [ 41, 43 ], [ 45, 52 ], [ 54, 66 ], [ 71, 103 ], [ 105, 116 ], [ 118, 137 ], [ 141, 147 ], [ 149, 152 ], [ 154, 154 ], [ 156, 156 ], [ 158, 158 ], [ 160, 161 ], [ 163, 167 ] ], [ [ 22, 23 ], [ 30, 35 ], [ 40, 40 ], [ 44, 44 ], [ 53, 53 ], [ 67, 70 ], [ 104, 104 ], [ 117, 117 ], [ 138, 140 ], [ 148, 148 ], [ 153, 153 ], [ 155, 155 ], [ 157, 157 ], [ 159, 159 ], [ 162, 162 ] ] ]
7ff6b963c33d38d453f8335e5258ad69524fc5c9
abc5697d85b1d5362ed40ac2df326abbdc881637
/etudes/chern/pr1-4.cpp
4c03473606c8d7dcc45b030abefc3cce06085f2f
[]
no_license
artyrian/university
ec27123fd151cb8b8cce9187e4280538a08a2d1a
7a732c4e4c71da0bca1f766f34b8fff791e324e7
refs/heads/master
2021-01-13T02:24:14.751132
2011-07-11T14:55:09
2011-07-11T14:55:09
1,406,163
0
0
null
null
null
null
UTF-8
C++
false
false
2,254
cpp
/* Написать функцию process, принимающую два параметра: * неизменяемый вектор целых чисел v; * список целых чисел lst. * Функция должна удалить из списка lst элементы с номерами, заданными в векторе v. Элементы * списка нумеруются от 1. Номера элементов списка отражают позиции элементов на момент начала * работы программы. Если номер повторяется в массиве более одного раза, все вхождения, кроме * первого, игнорируются. Если число в массиве не является допустимым номером элемента в * списке, оно игнорируется. Для доступа к элементам массива и списка использовать только * итераторы.*/ #include <iostream> #include <vector> #include <iterator> #include <list> #include <algorithm> using namespace std; void process(vector<int> v, list<int> &lst) { vector<int>::iterator i = v.begin(); list<int>::iterator j = lst.begin(); int n = 1; sort(v.begin(),v.end()); for (i = v.begin(); i != v.end() && *i < 1; ++i) { //тут пусто } for ( ; i != v.end(); ++i) { if ((i != v.begin() && i[-1] != *i) || i == v.begin()) { for ( ; j != lst.end() && n != *i; ++j, ++n) { //тут тоже пусто } if (j == lst.end()) { return; } else { lst.erase(j); ++n; --j; ++j; } } } return; } int main() { vector<int> a(0); a.push_back(1); a.push_back(1); a.push_back(3); a.push_back(2); list<int> b(1,1); b.push_back(44); b.push_back(3333); b.push_back(123); process(a, b); copy(b.begin(), b.end(), ostream_iterator<int> (cout, " ")); cout << endl; return 0; }
[ [ [ 1, 63 ] ] ]
dbf751d0abcf807ac7acec636eae41e3378fe0fc
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/python/pyste/tests/wrappertest.h
add9bcb84367d52ac99c260fb3c42c507ac6ffa2
[ "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
willrebuild/flyffsf
e5911fb412221e00a20a6867fd00c55afca593c7
d38cc11790480d617b38bb5fc50729d676aef80d
refs/heads/master
2021-01-19T20:27:35.200154
2011-02-10T12:34:43
2011-02-10T12:34:43
32,710,780
3
0
null
null
null
null
UTF-8
C++
false
false
993
h
/* Copyright Bruno da Silva de Oliveira 2003. Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http:#www.boost.org/LICENSE_1_0.txt) */ #ifndef WRAPPER_TEST #define WRAPPER_TEST #include <vector> namespace wrappertest { inline std::vector<int> Range(int count) { std::vector<int> v; v.reserve(count); for (int i = 0; i < count; ++i){ v.push_back(i); } return v; } struct C { C() {} std::vector<int> Mul(int value) { std::vector<int> res; res.reserve(value); std::vector<int>::const_iterator it; std::vector<int> v(Range(value)); for (it = v.begin(); it != v.end(); ++it){ res.push_back(*it * value); } return res; } }; struct A { virtual int f() { return 1; }; }; inline int call_foo(A* a){ return a->f(); } } #endif
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 51 ] ] ]
67162541e7577c5474086f011f8ad2d8f4975371
7476d2c710c9a48373ce77f8e0113cb6fcc4c93b
/vaultserver/ScriptFunction.h
9de943dfe2f59884bc2fefbc4f76d7eebc4fce3d
[]
no_license
CmaThomas/Vault-Tec-Multiplayer-Mod
af23777ef39237df28545ee82aa852d687c75bc9
5c1294dad16edd00f796635edaf5348227c33933
refs/heads/master
2021-01-16T21:13:29.029937
2011-10-30T21:58:41
2011-10-30T22:00:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
564
h
#ifndef SCRIPTFUNCTION_H #define SCRIPTFUNCTION_H #include <string> #include "boost/any.hpp" #include "PAWN.h" using namespace std; typedef unsigned long long ( *ScriptFunc )(); typedef string ScriptFuncPAWN; class ScriptFunction { private: ScriptFunc fCpp; ScriptFuncPAWN fPawn; AMX* amx; protected: string def; bool pawn; ScriptFunction( ScriptFunc fCpp, string def ); ScriptFunction( ScriptFuncPAWN fPawn, AMX* amx, string def ); unsigned long long Call( const vector<boost::any>& args ); }; #endif
[ [ [ 1, 11 ], [ 13, 16 ], [ 21, 21 ], [ 25, 25 ], [ 28, 28 ], [ 30, 33 ] ], [ [ 12, 12 ], [ 17, 20 ], [ 22, 24 ], [ 26, 27 ], [ 29, 29 ] ] ]
6a449e14055c0dc7e52e707073014dc28b8bb4f0
94d9e8ec108a2f79068da09cb6ac903c16b77730
/sociarium/font.cpp
a77c4e28dd0b924b4c76b0f90c4b1cce3971ad72
[]
no_license
kiyoya/sociarium
d375c0e5abcce11ae4b087930677483d74864d09
b26c2c9cbd23c2f8ef219d0059e42370294865d1
refs/heads/master
2021-01-25T07:28:25.862346
2009-10-22T05:57:42
2009-10-22T05:57:42
318,115
1
0
null
null
null
null
UTF-8
C++
false
false
8,166
cpp
// s.o.c.i.a.r.i.u.m: font.cpp // HASHIMOTO, Yasuhiro (E-mail: hy @ sys.t.u-tokyo.ac.jp) /* Copyright (c) 2005-2009, HASHIMOTO, Yasuhiro, 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 University of Tokyo 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. */ #include <cassert> #include <string> #ifdef _MSC_VER #include <windows.h> #endif #include <boost/format.hpp> #include <FTGL/ftgl.h> #include "font.h" #include "menu_and_message.h" #include "../shared/msgbox.h" #include "../shared/win32api.h" namespace hashimoto_ut { using std::wstring; using std::tr1::shared_ptr; using namespace sociarium_project_menu_and_message; namespace sociarium_project_font { namespace { //////////////////////////////////////////////////////////////////////////////// // Priority sequence of default used fonts. #ifdef __APPLE__ #warning Not implemented: MAX_PATH char const FONT_OPTION[][255] = { "/Library/Fonts/ヒラギノ丸ゴ ProN W4.otf", "/Library/Fonts/Verdana.ttf", "/Library/Fonts/Arial.ttf" }; #elif _MSC_VER char const FONT_OPTION[][_MAX_PATH] = { "C:\\Windows\\Fonts\\meiryo.ttc", "C:\\Windows\\Fonts\\msgothic.ttc", "C:\\Windows\\Fonts\\arial.ttf" }; #else #error Not implemented #endif size_t const NUMBER_OF_FONT_OPTIONS #ifdef __APPLE__ = sizeof(FONT_OPTION)/sizeof(char[255]); #elif _MSC_VER = sizeof(FONT_OPTION)/sizeof(char[_MAX_PATH]); #else #error Not implemented #endif //////////////////////////////////////////////////////////////////////////////// int const default_face_size = 24; float const default_font_scale[FontScale::NUMBER_OF_FONT_SCALES] = { 0.01f, // FontScale::TINY 0.02f, // FontScale::SMALL 0.04f, // FontScale::NORMAL 0.08f, // FontScale::LARGE 0.16f // FontScale::XLARGE }; int font_scale_id[FontCategory::NUMBER_OF_CATEGORIES] = { FontScale::NORMAL, // FontCategory::NODE_NAME FontScale::SMALL, // FontCategory::EDGE_NAME FontScale::NORMAL, // FontCategory::COMMUNITY_NAME FontScale::SMALL, // FontCategory::COMMUNITY_EDGE_NAME FontScale::NORMAL // FontCategory::MISC }; //////////////////////////////////////////////////////////////////////////////// int font_type_id = FontType::POLYGON_FONT; // or FontType::TEXTURE_FONT; //////////////////////////////////////////////////////////////////////////////// shared_ptr<FTFont> font[FontCategory::NUMBER_OF_CATEGORIES]; //////////////////////////////////////////////////////////////////////////////// void set_font(shared_ptr<FTFont>& f, int type) { // Try to create a font object following the priority order of font options. for (size_t i=0; i<NUMBER_OF_FONT_OPTIONS; ++i) { switch (type) { case FontType::POLYGON_FONT: f.reset(new FTPolygonFont(FONT_OPTION[i])); break; case FontType::TEXTURE_FONT: f.reset(new FTTextureFont(FONT_OPTION[i])); break; default: assert(0 && "never reach"); } wstring const filename = mbcs2wcs(FONT_OPTION[i], strlen(FONT_OPTION[i])); if (!f->Error()) { if (f->FaceSize(default_face_size)) { if (f->CharMap(ft_encoding_unicode)) break; // Successfully finished. else if (i==NUMBER_OF_FONT_OPTIONS-1) { // No option available any more. throw (boost::wformat(L"%s: %s [ft_encoding_unicode]") %get_message(Message::FTGL_ERROR_CHARMAP) %filename.c_str()).str().c_str(); } else continue; // Try the next option. } else if (i==NUMBER_OF_FONT_OPTIONS-1) { // No option available any more. throw (boost::wformat(L"%s: %s [%d]") %get_message(Message::FTGL_ERROR_FACESIZE) %filename.c_str() %default_face_size).str().c_str(); } else continue; // Try the next option. } else if (i==NUMBER_OF_FONT_OPTIONS-1) { // No option available any more. throw (boost::wformat(L"%s") %get_message(Message::FTGL_ERROR_CREATE)).str().c_str(); } else continue; // Try the next option. } } } // The end of the anonymous namespace //////////////////////////////////////////////////////////////////////////////// void initialize(void) { set_font_type(font_type_id); } //////////////////////////////////////////////////////////////////////////////// int get_font_type(void) { return font_type_id; } void set_font_type(int type_id) { assert(0<=type_id && type_id<FontType::NUMBER_OF_FONT_TYPES); font_type_id = type_id; set_font(font[FontCategory::NODE_NAME], font_type_id); set_font(font[FontCategory::EDGE_NAME], font_type_id); set_font(font[FontCategory::COMMUNITY_NAME], font_type_id); set_font(font[FontCategory::COMMUNITY_EDGE_NAME], font_type_id); set_font(font[FontCategory::MISC], font_type_id); } //////////////////////////////////////////////////////////////////////////////// shared_ptr<FTFont> get_font(int category_id) { assert(0<=category_id && category_id<FontCategory::NUMBER_OF_CATEGORIES); return font[category_id]; } //////////////////////////////////////////////////////////////////////////////// float get_font_scale(int category_id) { assert(0<=category_id && category_id<FontCategory::NUMBER_OF_CATEGORIES); int const scale_id = font_scale_id[category_id]; assert(0<=scale_id && scale_id<FontScale::NUMBER_OF_FONT_SCALES); return default_font_scale[scale_id]; } void set_font_scale(int category_id, int scale_id) { assert(0<=category_id && category_id<FontCategory::NUMBER_OF_CATEGORIES); assert(0<=scale_id && scale_id<=FontScale::NUMBER_OF_FONT_SCALES); font_scale_id[category_id] = scale_id; } //////////////////////////////////////////////////////////////////////////////// float get_default_font_scale(int scale_id) { assert(0<=scale_id && scale_id<=FontScale::NUMBER_OF_FONT_SCALES); return default_font_scale[scale_id]; } } // The end of the namespace "sociarium_project_font" } // The end of the namespace "hashimoto_ut"
[ [ [ 1, 208 ] ] ]
d6ac339ef2a4aab4ea246d37ddef8c397ea884a9
1e976ee65d326c2d9ed11c3235a9f4e2693557cf
/StateManager.h
3e88486ecf66a037bbe43cb1c5ab1258ca76ff43
[]
no_license
outcast1000/Jaangle
062c7d8d06e058186cb65bdade68a2ad8d5e7e65
18feb537068f1f3be6ecaa8a4b663b917c429e3d
refs/heads/master
2020-04-08T20:04:56.875651
2010-12-25T10:44:38
2010-12-25T10:44:38
19,334,292
3
0
null
null
null
null
UTF-8
C++
false
false
3,984
h
// /* // * // * Copyright (C) 2003-2010 Alexandros Economou // * // * This file is part of Jaangle (http://www.jaangle.com) // * // * This Program is free software; you can redistribute it and/or modify // * it under the terms of the GNU General Public License as published by // * the Free Software Foundation; either version 2, or (at your option) // * any later version. // * // * This Program is distributed in the hope that it will be useful, // * but WITHOUT ANY WARRANTY; without even the implied warranty of // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // * GNU General Public License for more details. // * // * You should have received a copy of the GNU General Public License // * along with GNU Make; see the file COPYING. If not, write to // * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. // * http://www.gnu.org/copyleft/gpl.html // * // */ #ifndef _STATEMANAGER_H #define _STATEMANAGER_H #include "IStateChangeListener.h" #include <set> #include "TeenSpiritEnums.h" #include "TracksFilter.h" #include "DataRecords.h" #include "RecordCollectionSorter.h" class AppSettings; enum StateMessageEnum { SM_None, SM_MediaChanged, SM_PlayListChanged, SM_PlayerVolumeChanged, SM_PlayerSettingsChanged, SM_InfoChanged, SM_PictureChanged, SM_DatabaseUpdated, SM_TrackUpdated, SM_CollectionManagerEvent, SM_CurrentSectionChanged, SM_CurrentTrackChanged, SM_LocateTrackRequest, SM_SetQuickSearch }; //=== The Interface implementation that must inherit all the controls that listen to state changes class TSStateChangeListener: public IStateChangeListener { public: TSStateChangeListener(); virtual ~TSStateChangeListener(); }; class TSState { public: //enum SectionSelectionStyleEnum //{ // SSS_Normal, // SSS_QuickSearch, // SSS_Last //}; public: TSState(): trackListTrackID(0), // sectionSelectionStyle(SSS_Normal), bIsTrackListDirty(TRUE), locateTrackID(0) //m_pTrackList(NULL) {} ~TSState() {} //=== TS State is the common object that all GUI controls must see to modify their view. //=== The GUI concepts are: // Controls that modify the Tracks Filter (Producers). // - Music Browser (modifies activeTracksFilter, activeItemType) // - Quick Search Box (modifies activeTracksFilter) // Controls that display information based on that filter (Consumers) // - Track List (listens activeTracksFilter) (modifies activeItemType) // - Info Control (listens activeTracksFilter, activeItemType) // Controls that modify the current play state // - Player(s) (Producer) // Controls that display the current play state // - PlayerBar // - PlayList // - InfoControl //SectionSelectionStyleEnum sectionSelectionStyle; TracksFilter activeTracksFilter; //std::tstring quickSearchString; ItemTypeEnum activeItemType; SortOptionCollection sortOptionCollection; UINT trackListTrackID; BOOL bIsTrackListDirty; FullTrackRecordCollection& GetTrackList(); std::basic_string<TCHAR> quickSearchString; UINT locateTrackID; private: FullTrackRecordCollection m_trackList; }; class StateManager { public: StateManager(); virtual ~StateManager() {} public: virtual void RegisterStateChangeListener(IStateChangeListener& listener); virtual void UnRegisterStateChangeListener(IStateChangeListener& listener); virtual void SendMessage(UINT stateMessage); virtual void PostMessage(UINT stateMessage); virtual void HeartBeat(); TSState& GetState() {return m_state;} //BOOL LoadState(AppSettings& params); //BOOL SaveState(AppSettings& params); //void ClearState(); private: std::set<IStateChangeListener*> m_pListeners; TSState m_state; //UINT m_messageInQueue; std::set<UINT> m_messagesInQueue; DWORD m_MainThread; CCriticalSection m_cs; }; #endif
[ "outcast1000@dc1b949e-fa36-4f9e-8e5c-de004ec35678" ]
[ [ [ 1, 152 ] ] ]
b48e45f30c34ee634d051638bd90de1098e4e92d
8f816734df7cb71af9c009fa53eeb80a24687e63
/include/BaseCamera.h
db45060d51b90af95c38bb5a33ec91f2a5a15997
[]
no_license
terepe/rpgskyengine
46a3a09a1f4d07acf1a04a1bcefff2a9aabebf56
fbe0ddc86440025d9670fc39fb7ca72afa223953
refs/heads/master
2021-01-23T13:18:32.028357
2011-06-01T13:35:16
2011-06-01T13:35:16
35,915,383
0
0
null
null
null
null
GB18030
C++
false
false
2,878
h
#pragma once #include "Vec2D.h" #include "Vec3D.h" #include "Vec4D.h" #include "Matrix.h" #include "Common.h" class CBaseCamera { public: CBaseCamera(); virtual void FrameMove(float fElapsedTime) = 0; // Functions to change camera matrices virtual void Reset(); virtual void SetViewParams(Vec3D& vEyePt, Vec3D& vLookatPt); virtual void SetProjParams(float fFOV, int nWidth, int nHeight, float fNearPlane, float fFarPlane); virtual void SetFarClip(float fFarPlane); // Functions to change behavior virtual void SetDrag(bool bMovementDrag, float fTotalDragTimeToZero = 0.25f) { m_bMovementDrag = bMovementDrag; m_fTotalDragTimeToZero = fTotalDragTimeToZero; } virtual void SetScalers(float fRotationScaler = 0.01f, float fMoveScaler = 5.0f) { m_fRotationScaler = fRotationScaler; m_fMoveScaler = fMoveScaler; } // Functions to get state virtual CONST_GET_SET_VARIABLE(Matrix&, m_m,ViewMatrix); virtual CONST_GET_SET_VARIABLE(Matrix&, m_m,ProjMatrix); virtual CONST_GET_SET_VARIABLE(Vec3D&, m_v,EyePt); virtual CONST_GET_SET_VARIABLE(Vec3D&, m_v,LookAt); virtual CONST_GET_SET_VARIABLE(float, m_f,NearPlane); virtual CONST_GET_SET_VARIABLE(float, m_f,FarPlane); virtual CONST_GET_SET_VARIABLE(float, m_f,YawAngle); virtual CONST_GET_SET_VARIABLE(float, m_f,PitchAngle); virtual void addMouseDelta(Vec3D vMouseDelta){m_vMouseDelta+=vMouseDelta;} protected: // 更新周转率 virtual void UpdateVelocity(float fElapsedTime); Matrix m_mViewMatrix; // View matrix Matrix m_mProjMatrix; // Projection matrix Vec3D m_vMouseDelta; // Mouse relative delta smoothed over a few frames Vec3D m_vDefaultEye; // Default camera eye position Vec3D m_vDefaultLookAt; // Default LookAt position Vec3D m_vEyePt; // Camera eye position Vec3D m_vLookAt; // LookAt position float m_fYawAngle; // 摄像机(左右)偏航角度 float m_fPitchAngle; // 摄像机(上下)倾斜角度 Vec3D m_vVelocity; // 摄像机的周转率 bool m_bMovementDrag; // 是否运动托曳 If true, then camera movement will slow to a stop otherwise movement is instant Vec3D m_vVelocityDrag; // 托曳速率 Velocity drag force float m_fDragTimer; // 倒计时去运用托曳 Countdown timer to apply drag float m_fTotalDragTimeToZero; // 托曳总时间 Time it takes for velocity to go from full to 0 Vec3D m_vRotVelocity; // Velocity of camera float m_fFOV; // Field of view int m_nSceneWidth; int m_nSceneHeight; float m_fAspect; // Aspect ratio float m_fNearPlane; // Near plane float m_fFarPlane; // Far plane float m_fRotationScaler; // Scaler for rotation float m_fMoveScaler; // Scaler for movement bool m_bEnableYAxisMovement; // If true, then camera can move in the y-axis };
[ "rpgsky.com@97dd8ffa-095c-11df-8772-5d79768f539e" ]
[ [ [ 1, 72 ] ] ]
cb6e12f066c5802379784acc1fb9cbd0dc9620f4
353bd39ba7ae46ed521936753176ed17ea8546b5
/src/layer2_support/script/src/axsc_register.cpp
68e69556ba4da406226e049ad1c2c33383a31b1f
[]
no_license
d0n3val/axe-engine
1a13e8eee0da667ac40ac4d92b6a084ab8a910e8
320b08df3a1a5254b776c81775b28fa7004861dc
refs/heads/master
2021-01-01T19:46:39.641648
2007-12-10T18:26:22
2007-12-10T18:26:22
32,251,179
1
0
null
null
null
null
UTF-8
C++
false
false
1,671
cpp
/** * @file * Add functions, vars, objects, methods, properties, etc ... * @author Ricard Pillosu <d0n3val\@gmail.com> * @date 27 May 2004 */ #include "axsc_stdafx.h" /** * Add a global var access to the script */ AXSC_API int axsc_register_variable( const char* declaration, void* address ) { // check params AXE_ASSERT( NULL != declaration && NULL != address ); // check current state AXE_ASSERT( NULL != state.engine ); AXE_ASSERT( AXSC_EXEC_STATE_INIT == state.execution_state ); int res = state.engine->RegisterGlobalProperty( declaration, address ); check_return_value( res ); return( AXE_TRUE ); } /** * Add a global function to the script */ AXSC_API int axsc_register_function( const char* declaration, asUPtr function ) { // check params AXE_ASSERT( NULL != declaration ); // check current state AXE_ASSERT( NULL != state.engine ); AXE_ASSERT( AXSC_EXEC_STATE_INIT == state.execution_state ); int res = state.engine->RegisterGlobalFunction( declaration, function, asCALL_CDECL ); check_return_value( res ); return( AXE_TRUE ); } /** * Registers the main string factory */ AXSC_API int axsc_register_string_factory( const char* data_type, asUPtr function ) { // check params AXE_ASSERT( NULL != data_type ); // check current state AXE_ASSERT( NULL != state.engine ); AXE_ASSERT( AXSC_EXEC_STATE_INIT == state.execution_state ); int res = state.engine->RegisterStringFactory( data_type, function, asCALL_CDECL ); check_return_value( res ); return( AXE_TRUE ); } /* $Id: axsc_register.cpp,v 1.3 2004/09/20 21:28:13 doneval Exp $ */
[ "d0n3val@2cff7946-3f3c-0410-b79f-f9b517ddbf54" ]
[ [ [ 1, 63 ] ] ]
21d59e091917002768b18822d3bc5eeb6353b4d5
2b80036db6f86012afcc7bc55431355fc3234058
/src/core/audio/IPlayer.h
ac37218a4d90ad2bf6894cf66555e42201185160
[ "BSD-3-Clause" ]
permissive
leezhongshan/musikcube
d1e09cf263854bb16acbde707cb6c18b09a0189f
e7ca6a5515a5f5e8e499bbdd158e5cb406fda948
refs/heads/master
2021-01-15T11:45:29.512171
2011-02-25T14:09:21
2011-02-25T14:09:21
null
0
0
null
null
null
null
ISO-8859-9
C++
false
false
2,992
h
////////////////////////////////////////////////////////////////////////////// // Copyright © 2007, Daniel Önnerby // // 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 author nor the names of other 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. // ////////////////////////////////////////////////////////////////////////////// #pragma once #include <core/config.h> #include <core/audio/IBuffer.h> ////////////////////////////////////////////////////////////////////////////// namespace musik { namespace core { namespace audio { ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////// ///\brief ///Interface for the audio::Player to make IOuput plugins be able to make callbacks ////////////////////////////////////////// class IPlayer{ public: ////////////////////////////////////////// ///\brief ///Release the specific buffer from the output ////////////////////////////////////////// virtual void ReleaseBuffer(IBuffer *buffer) = 0; ////////////////////////////////////////// ///\brief ///Notifies the Player that there may be buffer ///ready to be released in the output plugin. ////////////////////////////////////////// virtual void Notify() = 0; }; ////////////////////////////////////////////////////////////////////////////// } } } //////////////////////////////////////////////////////////////////////////////
[ "onnerby@6a861d04-ae47-0410-a6da-2d49beace72e", "[email protected]@6a861d04-ae47-0410-a6da-2d49beace72e", "urioxis@6a861d04-ae47-0410-a6da-2d49beace72e" ]
[ [ [ 1, 1 ], [ 3, 34 ], [ 41, 45 ], [ 48, 51 ], [ 53, 58 ] ], [ [ 2, 2 ], [ 35, 40 ], [ 47, 47 ], [ 52, 52 ], [ 59, 64 ] ], [ [ 46, 46 ] ] ]
4643ffb2c45479d99ab1e3b129ed9a11f8313bf1
368acbbc055ee3a84dd9ce30777ae3bbcecec610
/project/jni/third_party/fcollada/FCollada_FREE_3.05B/FCollada/FUtils/FUFunctor.h
2898fb312bbff18e5ce9f6633785b95f78ea62f7
[ "MIT", "LicenseRef-scancode-x11-xconsortium-veillard" ]
permissive
jcayzac/androido3d
298559ebbe657482afe6b3b616561a1127320388
18e0a4cd4799b06543588cf7bea33f12500fb355
HEAD
2016-09-06T06:31:09.984535
2011-09-17T09:47:51
2011-09-17T09:47:51
1,816,466
6
0
null
null
null
null
UTF-8
C++
false
false
15,494
h
/* Copyright (C) 2005-2007 Feeling Software Inc. Portions of the code are: Copyright (C) 2005-2007 Sony Computer Entertainment America MIT License: http://www.opensource.org/licenses/mit-license.php */ /* This file was taken off the Protect project on 26-09-2005 */ #ifndef _FU_FUNCTOR_H_ #define _FU_FUNCTOR_H_ /** A functor with no arguments. @ingroup FUtils */ template<class ReturnType> class IFunctor0 { public: /** Destructor. */ virtual ~IFunctor0() {} /** Calls the functor. @return Implementation-dependant. */ virtual ReturnType operator()() const = 0; /** Checks whether this functor points towards the given member function. @param object The object which holds the member function. @param function The member function. @return Whether this functor points towards the given member function. */ virtual bool Compare(void* object, void* function) const = 0; /** Returns a copy of this functor */ virtual IFunctor0<ReturnType>* Copy() const = 0; }; /** A functor with no arguments. @ingroup FUtils */ template<class Class, class ReturnType> class FUFunctor0 : public IFunctor0<ReturnType> { private: Class* m_pObject; ReturnType (Class::*m_pFunction) (); public: /** Constructor. @param object An object. @param function A member function of this object. */ FUFunctor0(Class* object, ReturnType (Class::*function) ()) { m_pObject = object; m_pFunction = function; } /** Destructor. */ virtual ~FUFunctor0() {} /** Calls the functor. @return Implementation-dependant. */ virtual ReturnType operator()() const { return ((*m_pObject).*m_pFunction)(); } /** Checks whether this functor points towards the given member function. @param object The object which holds the member function. @param function The member function. @return Whether this functor points towards the given member function. */ virtual bool Compare(void* object, void* function) const { return object == m_pObject && (size_t)function == *(size_t*)&m_pFunction; } /** Returns a copy of this functor */ virtual IFunctor0<ReturnType>* Copy() const { return new FUFunctor0<Class, ReturnType>(m_pObject, m_pFunction); } }; /** Shortcut for new FUFunctor0<>. @param o An object. @param function A member function. */ template <class ClassName, class ReturnType> inline FUFunctor0<ClassName, ReturnType>* NewFUFunctor0(ClassName* o, ReturnType (ClassName::*function) ()) { return new FUFunctor0<ClassName, ReturnType>(o, function); } /** A pseudo-functor with no arguments, specialized for static functions. @ingroup FUtils */ template<class ReturnType> class FUStaticFunctor0 : public IFunctor0<ReturnType> { private: ReturnType (*m_pFunction) (); public: /** Constructor. @param function A static function. */ FUStaticFunctor0(ReturnType (*function) ()) { m_pFunction = function; } /** Destructor. */ virtual ~FUStaticFunctor0() {} /** Calls the functor. @return Implementation-dependant. */ virtual ReturnType operator()() const { return (*m_pFunction)(); } /** Checks whether this pseudo-functor points towards the given function. @param UNUSED Unused. @param function The static function. @return Whether this pseudo-functor points towards the given function. */ virtual bool Compare(void* UNUSED(object), void* function) const { return function==m_pFunction; } /** Returns a copy of this functor */ virtual IFunctor0<ReturnType>* Copy() const { return new FUStaticFunctor0<ReturnType>(m_pFunction); } }; /** A functor with one argument. @ingroup FUtils */ template<class Arg1, class ReturnType> class IFunctor1 { public: /** Destructor. */ virtual ~IFunctor1() {} /** Calls the functor. @param argument1 A first argument. @return Implementation-dependant. */ virtual ReturnType operator()(Arg1 argument1) const = 0; /** Checks whether this functor points towards the given member function. @param object The object which holds the member function. @param function The member function. @return Whether this functor points towards the given member function. */ virtual bool Compare(void* object, void* function) const = 0; /** Returns a copy of this functor */ virtual IFunctor1<Arg1, ReturnType>* Copy() const = 0; }; /** A functor with one arguments. @ingroup FUtils */ template<class Class, class Arg1, class ReturnType> class FUFunctor1 : public IFunctor1<Arg1, ReturnType> { private: Class* m_pObject; ReturnType (Class::*m_pFunction) (Arg1); public: /** Constructor. @param object An object. @param function A member function of this object. */ FUFunctor1(Class* object, ReturnType (Class::*function) (Arg1)) { m_pObject = object; m_pFunction = function; } /** Destructor. */ virtual ~FUFunctor1() {} /** Calls the functor. @param argument1 A first argument. @return Implementation-dependant. */ virtual ReturnType operator()(Arg1 argument1) const { return ((*m_pObject).*m_pFunction)(argument1); } /** Checks whether this functor points towards the given member function. @param object The object which holds the member function. @param function The member function. @return Whether this functor points towards the given member function. */ virtual bool Compare(void* object, void* function) const { return object == m_pObject && (size_t)function == *(size_t*)(size_t)&m_pFunction; } /** Returns a copy of this functor */ virtual IFunctor1<Arg1, ReturnType>* Copy() const { return new FUFunctor1<Class, Arg1, ReturnType>(m_pObject, m_pFunction); } }; /** Shortcut for new FUFunctor1<>. @param o An object. @param function A member function. */ template <class ClassName, class Argument1, class ReturnType> inline FUFunctor1<ClassName, Argument1, ReturnType>* NewFUFunctor1(ClassName* o, ReturnType (ClassName::*function) (Argument1)) { return new FUFunctor1<ClassName, Argument1, ReturnType>(o, function); } /** A pseudo-functor with one arguments, specialized for static functions. @ingroup FUtils */ template<class Arg1, class ReturnType> class FUStaticFunctor1 : public IFunctor1<Arg1, ReturnType> { private: ReturnType (*m_pFunction) (Arg1); public: /** Constructor. @param function A static function. */ FUStaticFunctor1(ReturnType (*function) (Arg1)) { m_pFunction = function; } /** Destructor. */ virtual ~FUStaticFunctor1() {} /** Calls the functor. @param argument1 A first argument. @return Implementation-dependant. */ virtual ReturnType operator()(Arg1 argument1) const { return (*m_pFunction)(argument1); } /** Checks whether this pseudo-functor points towards the given function. @param UNUSED Unused. @param function The static function. @return Whether this pseudo-functor points towards the given function. */ virtual bool Compare(void* UNUSED(object), void* function) const { return (size_t)function == *(size_t*)(size_t)&m_pFunction; } /** Returns a copy of this functor */ virtual IFunctor1<Arg1, ReturnType>* Copy() const { return new FUStaticFunctor1<Arg1, ReturnType>(m_pFunction); } }; /** A functor with two arguments. @ingroup FUtils */ template<class Arg1, class Arg2, class ReturnType> class IFunctor2 { public: /** Destructor. */ virtual ~IFunctor2() {} /** Calls the functor. @param argument1 A first argument. @param argument2 A second argument. @return Implementation-dependant. */ virtual ReturnType operator()(Arg1 argument1, Arg2 argument2) const = 0; /** Checks whether this functor points towards the given member function. @param object The object which holds the member function. @param function The member function. @return Whether this functor points towards the given member function. */ virtual bool Compare(void* object, void* function) const = 0; /** Returns a copy of this functor */ virtual IFunctor2<Arg1, Arg2, ReturnType>* Copy() const = 0; }; /** A functor with two arguments. @ingroup FUtils */ template<class Class, class Arg1, class Arg2, class ReturnType> class FUFunctor2 : public IFunctor2<Arg1, Arg2, ReturnType> { private: Class* m_pObject; ReturnType (Class::*m_pFunction) (Arg1, Arg2); public: /** Constructor. @param object An object. @param function A member function of this object. */ FUFunctor2(Class* object, ReturnType (Class::*function) (Arg1, Arg2)) { m_pObject = object; m_pFunction = function; } /** Destructor. */ virtual ~FUFunctor2() {} /** Calls the functor. @param argument1 A first argument. @param argument2 A second argument. @return Implementation-dependant. */ virtual ReturnType operator()(Arg1 argument1, Arg2 argument2) const { return ((*m_pObject).*m_pFunction)(argument1, argument2); } /** Checks whether this functor points towards the given member function. @param object The object which holds the member function. @param function The member function. @return Whether this functor points towards the given member function. */ virtual bool Compare(void* object, void* function) const { return object == m_pObject && (size_t)function == *(size_t*)(size_t)&m_pFunction; } /** Returns a copy of this functor */ virtual IFunctor2<Arg1, Arg2, ReturnType>* Copy() const { return new FUFunctor2<Class, Arg1, Arg2, ReturnType>(m_pObject, m_pFunction); } }; /** Shortcut for new FUFunctor2<>. @param o An object. @param function A member function. */ template <class ClassName, class Argument1, class Argument2, class ReturnType> inline FUFunctor2<ClassName, Argument1, Argument2, ReturnType>* NewFUFunctor2(ClassName* o, ReturnType (ClassName::*function) (Argument1, Argument2)) { return new FUFunctor2<ClassName, Argument1, Argument2, ReturnType>(o, function); } /** A pseudo-functor with two arguments, specialized for static functions. @ingroup FUtils */ template<class Arg1, class Arg2, class ReturnType> class FUStaticFunctor2 : public IFunctor2<Arg1, Arg2, ReturnType> { private: ReturnType (*m_pFunction) (Arg1, Arg2); public: /** Constructor. @param function A static function. */ FUStaticFunctor2(ReturnType (*function) (Arg1, Arg2)) { m_pFunction = function; } /** Destructor. */ virtual ~FUStaticFunctor2() {} /** Calls the functor. @param argument1 A first argument. @param argument2 A second argument. @return Implementation-dependant. */ virtual ReturnType operator()(Arg1 argument1, Arg2 argument2) const { return (*m_pFunction)(argument1, argument2); } /** Checks whether this pseudo-functor points towards the given function. @param UNUSED Unused. @param function The static function. @return Whether this pseudo-functor points towards the given function. */ virtual bool Compare(void* UNUSED(object), void* function) const { return (size_t)function == *(size_t*)(size_t)&m_pFunction; } /** Returns a copy of this functor */ virtual IFunctor2<Arg1, Arg2, ReturnType>* Copy() const { return new FUStaticFunctor2<Arg1, Arg2, ReturnType>(m_pFunction); } }; /** A functor with three arguments. @ingroup FUtils */ template<class Arg1, class Arg2, class Arg3, class ReturnType> class IFunctor3 { public: /** Destructor. */ virtual ~IFunctor3() {} /** Calls the functor. @param argument1 A first argument. @param argument2 A second argument. @param argument3 A third argument. @return Implementation-dependant. */ virtual ReturnType operator()(Arg1 argument1, Arg2 argument2, Arg3 argument3) const = 0; /** Checks whether this functor points towards the given member function. @param object The object which holds the member function. @param function The member function. @return Whether this functor points towards the given member function. */ virtual bool Compare(void* object, void* function) const = 0; /** Returns a copy of this functor */ virtual IFunctor3<Arg1, Arg2, Arg3, ReturnType>* Copy() const = 0; }; /** A functor with three arguments. @ingroup FUtils */ template<class Class, class Arg1, class Arg2, class Arg3, class ReturnType> class FUFunctor3 : public IFunctor3<Arg1, Arg2, Arg3, ReturnType> { private: Class* m_pObject; ReturnType (Class::*m_pFunction) (Arg1, Arg2, Arg3); public: /** Constructor. @param object An object. @param function A member function of this object. */ FUFunctor3(Class* object, ReturnType (Class::*function) (Arg1, Arg2, Arg3)) { m_pObject = object; m_pFunction = function; } /** Destructor. */ virtual ~FUFunctor3() {} /** Calls the functor. @param argument1 A first argument. @param argument2 A second argument. @param argument3 A third argument. @return Implementation-dependant. */ virtual ReturnType operator()(Arg1 argument1, Arg2 argument2, Arg3 argument3) const { return ((*m_pObject).*m_pFunction)(argument1, argument2, argument3); } /** Checks whether this functor points towards the given member function. @param object The object which holds the member function. @param function The member function. @return Whether this functor points towards the given member function. */ virtual bool Compare(void* object, void* function) const { return object == m_pObject && (size_t)function == *(size_t*)(size_t)&m_pFunction; } /** Returns a copy of this functor */ virtual IFunctor3<Arg1, Arg2, Arg3, ReturnType>* Copy() const { return new FUFunctor3<Class, Arg1, Arg2, Arg3, ReturnType>(m_pObject, m_pFunction); }; }; /** Shortcut for new FUFunctor2<>. @param o An object. @param function A member function. */ template <class ClassName, class Argument1, class Argument2, class Argument3, class ReturnType> inline FUFunctor3<ClassName, Argument1, Argument2, Argument3, ReturnType>* NewFUFunctor3(ClassName* o, ReturnType (ClassName::*function) (Argument1, Argument2, Argument3)) { return new FUFunctor3<ClassName, Argument1, Argument2, Argument3, ReturnType>(o, function); } /** A pseudo-functor with three arguments, specialized for static functions. @ingroup FUtils */ template<class Arg1, class Arg2, class Arg3, class ReturnType> class FUStaticFunctor3 : public IFunctor3<Arg1, Arg2, Arg3, ReturnType> { private: ReturnType (*m_pFunction) (Arg1, Arg2, Arg3); public: /** Constructor. @param function A static function. */ FUStaticFunctor3(ReturnType (*function) (Arg1, Arg2, Arg3)) { m_pFunction = function; } /** Destructor. */ virtual ~FUStaticFunctor3() {} /** Calls the functor. @param argument1 A first argument. @param argument2 A second argument. @param argument3 A third argument. @return Implementation-dependant. */ virtual ReturnType operator()(Arg1 argument1, Arg2 argument2, Arg3 argument3) const { return (*m_pFunction)(argument1, argument2, argument3); } /** Checks whether this pseudo-functor points towards the given function. @param UNUSED Unused. @param function The static function. @return Whether this pseudo-functor points towards the given function. */ virtual bool Compare(void* UNUSED(object), void* function) const { return function==m_pFunction; } /** Returns a copy of this functor */ virtual IFunctor3<Arg1, Arg2, Arg3, ReturnType>* Copy() const { return new FUStaticFunctor3<Arg1, Arg2, Arg3, ReturnType>(m_pFunction); }; }; #endif //_FU_FUNCTOR_H_
[ [ [ 1, 458 ] ] ]
9bb0e0d506c3be7264a00417635fbb088f553b43
c429fca28382ea6d1a9f9fa09bced48b4154b008
/List/List.h
6334667357ca383ac28a2e2b95e70759a5054d7a
[]
no_license
akamel001/Data-Structures
b8c60148719bb6bafe14611a1dd24d6a10ccdd23
e04b8434ccde4c99cfac25cbee05375421b7620f
refs/heads/master
2016-09-05T23:14:05.073009
2011-11-21T22:54:04
2011-11-21T22:54:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,427
h
/******************************************************************** * * Name: Abdelrahman Kamel * * Date:February 27, 2009 * * Filename: List.h * * Description: This file contains the implementation of * a list class, link class, and list_iterator class. All * three clases and member functions are implemented in this * file. * * Implementation: The list class was implemented with the help of * 3 constructors, and 12 member functions. However the link class * was implemented with 1 constructor and 2 friend functions. The * list_iterator class has 8 member functions and 3 constructors. * These classes utilize the operator -> in the implementation of * its member functions. * *******************************************************************/ #ifndef LIST_H #define LIST_H // List.h - a doubly-linked list #include <algorithm> using namespace std; // forward declaration of classes defined in this header template <class T> class List; template <class T> class Link; template <class T> class List_iterator; template <class T> class List { public: typedef List_iterator<T> iterator; List(); List(const List & l); ~List(); bool empty() const {return first_link == 0;} unsigned int size() const; T & back() const {return last_link -> value;} T & front() const {return first_link -> value;} void push_front(const T & x); void push_back(const T & x); void pop_front(); void pop_back(); iterator begin() const {return iterator(first_link);} iterator end() const {return iterator(last_link -> next_link);} void add(const iterator & pos, const List<T> & newList); void insert(iterator pos, const T & x); // insert x before pos void erase(iterator & pos); // pos must be valid after erase() returns private: Link<T> * first_link; Link<T> * last_link; unsigned int my_size; };//class list /******************************************************************* * * Discription: This function takes as its a list as its explicit * perameter and a pointer to a link position. Then the function * procedes to add the explicit list to the implicit list at the * pointer position. * * Implementation: This function was implemented using the List * copy constructor. Once a copy of the explicit list is made, * then we modify the next_link and prev_link accordingly. * After we make the modifications then we update the list size. * * Time complexity: The time coplexity of this function is O(1) * *******************************************************************/ template <class T> void List<T>::add(const iterator & pos, const List<T> & newList) { //modified on march 24, 2009: added static to tempList //static creates tempList and distroys it at the end of main scope not this scope static List<T> tempList = newList; Link<T> * current = pos.current_link; Link<T> * pos_right_link = current -> next_link; current -> next_link = tempList.first_link; tempList.first_link -> prev_link = current; if( pos_right_link != 0) { pos_right_link -> prev_link = tempList.last_link; tempList.last_link -> next_link = pos_right_link; } if(pos == last_link) last_link = newList.last_link; my_size += tempList.my_size; } template <class T> List<T>::List() { first_link = 0; last_link = 0; my_size = 0; }//list constructor template <class T> void List<T>::erase(iterator & pos) { Link<T> * current = pos.current_link; Link<T> * left = current -> prev_link; Link<T> * right = current -> next_link; if(left == 0 && right == 0) { first_link = 0; last_link =0; my_size =0; delete current; return; } if(left == 0) { right -> prev_link =0; first_link = right; } if(right == 0) { left -> next_link = 0; last_link = left; } if( left != 0 && right != 0) { left -> next_link = right; right -> prev_link = left; } delete current; --my_size; }//erase template <class T> void List<T>::pop_front() { Link<T> * temp_first_link = first_link; first_link = first_link -> next_link; if( first_link != 0) first_link -> prev_link = 0; else last_link = 0; delete temp_first_link; --my_size; }//pop_front template <class T> void List<T>::pop_back() { Link<T> * temp_last_link = last_link; last_link = last_link -> prev_link; if(last_link != 0 ) last_link -> next_link = 0; else { first_link = 0; } delete temp_last_link; --my_size; }//pop_back template <class T> int unsigned List<T>::size() const { int elements=0; Link<T> * ptr = first_link; for(;ptr;ptr=ptr->next_link) elements++; return elements; }//size template <class T> List<T>::List(const List & l) { first_link = 0; last_link = 0; my_size = 0; for (Link<T> * current = l.first_link; current != 0; current = current -> next_link) push_back(current -> value); }//list copy constructor template <class T> List<T>::~List() { Link<T> * newFirst = first_link; Link<T> * next; while(newFirst != 0) { next = newFirst -> next_link; delete newFirst; newFirst = next; } }//list destructor template <class T> void List<T>::insert( iterator pos, const T & x) { Link<T> * newLink = new Link<T>(x); Link<T> * current = pos.current_link; newLink -> next_link = current; newLink -> prev_link = current -> prev_link; current -> prev_link = newLink; current = newLink -> prev_link; if(current !=0) current -> next_link = newLink; else first_link = newLink; ++my_size; }//insert template <class T> void List<T>::push_back(const T & x) { Link<T> * newLink = new Link<T>(x); if(first_link == 0) first_link = last_link = newLink; else { newLink -> next_link = 0; newLink -> prev_link = last_link; last_link -> next_link = newLink; last_link = newLink; } ++my_size; }//push_back template <class T> void List<T>::push_front(const T & value) { Link<T> * newLink = new Link<T>(value); if(first_link == 0) first_link = last_link = newLink; else { newLink -> next_link = first_link; first_link -> prev_link = newLink; first_link = newLink; } ++my_size; }//push_front template <class T> class Link { private: Link(const T & x): value(x), next_link(0), prev_link(0) {} T value; Link<T> * next_link; Link<T> * prev_link; friend class List<T>; friend class List_iterator<T>; };//class link template <class T> class List_iterator { public: typedef List_iterator<T> iterator; List_iterator(Link<T> * source_link): current_link(source_link) { } List_iterator(): current_link(0) { } List_iterator(List_iterator<T> * source_iterator): current_link(source_iterator.current_link) { } T & operator*(){return (*current_link).value;} // dereferencing operator iterator & operator=(const iterator & rhs){ current_link = rhs.current_link; return *this;} bool operator==(const iterator & rhs) const {return current_link == rhs.current_link;} bool operator!=(const iterator & rhs) const {return current_link != rhs.current_link;} iterator & operator++(); // pre-increment, ex. ++it iterator operator++(int); // post-increment, ex. it++ iterator & operator--(); // pre-decrement iterator operator--(int); // post-decrement protected: Link<T> * current_link; friend class List<T>; };//class List_iterator template <class T> List_iterator<T> & List_iterator<T>::operator--() { current_link = current_link -> prev_link; return *this; }//pre-decrement operator-- template <class T> List_iterator<T> List_iterator<T>::operator--(int) { List_iterator<T> clone(*this); --(*this); return clone; }//post-decrement operator-- template <class T> List_iterator<T> & List_iterator<T>::operator++() // pre-increment { current_link = current_link -> next_link; return *this; }//pre-increment operator++ template <class T> List_iterator<T> List_iterator<T>::operator++(int) // post-increment { List_iterator<T> copy(*this); ++(*this); return copy; }//post-increment operator++ #endif
[ [ [ 1, 350 ] ] ]
8e69d867b1488254254976c22eca6cd21da8cf86
028d6009f3beceba80316daa84b628496a210f8d
/connectivity/com.nokia.tcf/native/TCFNative/TCFProtOST/TCFProtOST.cpp
93faf5d9ab17638457805e9bd21b2d690004070c
[]
no_license
JamesLinus/oss.FCL.sftools.dev.ide.carbidecpp
fa50cafa69d3e317abf0db0f4e3e557150fd88b3
4420f338bc4e522c563f8899d81201857236a66a
refs/heads/master
2020-12-30T16:45:28.474973
2010-10-20T16:19:31
2010-10-20T16:19:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,225
cpp
/* * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: * */ // TCFProtOST.cpp : Defines the entry point for the DLL application. // #include "stdafx.h" #include "TCFProtOST.h" #include "OSTProtocol.h" static const char* pProtocol="ost"; static COSTProtocol* pProtocolClass=NULL; BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; } TCFPROTOST_API const char* RegisterProtocol() { return pProtocol; } TCFPROTOST_API CBaseProtocol* CreateProtocol() { pProtocolClass = new COSTProtocol(); return pProtocolClass; }
[ "none@none" ]
[ [ [ 1, 52 ] ] ]
beccdd66a39f5c94b522481eff00587338ffef08
7575692fd3800ec48e7c941cdd40210d02ca96d0
/advanced-cpp-pa5/advanced-cpp-pa5/Account.h
2d29286ae9ca733940f22dab09346dac37aaf6c0
[]
no_license
husamMaruf/advanced-programming-2011
bf577a8cc51d53599ed032c22ae31fc15db217fb
db285ae560495bd051400f0e372a2eec2434afe1
refs/heads/master
2021-01-10T10:12:46.760433
2011-05-21T17:00:12
2011-05-21T17:00:12
36,380,809
2
0
null
null
null
null
UTF-8
C++
false
false
812
h
#pragma once #include "Observer.h" #include "Subject.h" #include "cDate_t.h" typedef int AccountType; class AccountImpl; class Account : public Observer { public: Account(Subject* subject, AccountType accountType, int accountNumber, int savingPeriod, double percentOnDeposit, const cDate_t& openingDate); Account(Subject* subject, AccountType accountType, int accountNumber, int savingPeriod, double percentOnDeposit); virtual ~Account(); virtual void Update(Subject* ChngSubject); int getSavingPeriod() const; const cDate_t& getOpeningDate() const; double getPercentOnDeposit() const; AccountType getAccountType() const; void postMessage(const std::string& message); int getAccountNumber() const; protected: AccountImpl* accountImpl; };
[ "dankilman@a7c0e201-94a5-d3f3-62b2-47f0ba67a830", "[email protected]" ]
[ [ [ 1, 4 ], [ 7, 7 ], [ 9, 12 ], [ 14, 14 ], [ 16, 18 ], [ 20, 27 ] ], [ [ 5, 6 ], [ 8, 8 ], [ 13, 13 ], [ 15, 15 ], [ 19, 19 ], [ 28, 29 ] ] ]
210151dd2aebd82d523a8b8b595cbe3426330591
5c2692b5fc656d76da15d58644ee3b8f37dde70b
/Symbol.hpp
05040e0b6f556bfc555624f55c9fc0eaffe594a8
[]
no_license
synaptek/as2java
dd0cd6bd5e85980f05f8fe960ab112c6c9c7c73a
6002a68903205163ac602f49086086b1e3c3d0d1
refs/heads/master
2021-01-10T03:12:01.629817
2010-05-18T21:11:25
2010-05-18T21:11:25
47,868,555
0
0
null
null
null
null
UTF-8
C++
false
false
1,968
hpp
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ // as2java - ActionScript to Java Converter // // Copyright (C) 2001 - 2010 Tony Richards // // This file is licensed under the terms of the MIT license, which can be found // at this address: http://en.wikipedia.org/wiki/MIT_License //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ #ifndef AS2JAVA_SYMBOL_HPP_INCLUDED #define AS2JAVA_SYMBOL_HPP_INCLUDED #include <boost/noncopyable.hpp> #include <string> //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ class Class; class Symbol : public boost::noncopyable { /// @name Types /// @{ public: enum SymbolType { VARIABLE, METHOD, CLASS }; /// @} /// @name Symbol implementation /// @{ public: const std::string& getName() const { return m_name; } /// Get the type of field or the return type of a method const std::string& getType() const { return m_type; } void setType(const std::string& _type) { m_type = _type; } const Class* getClass() const { return m_pClass; } bool isPublic() const { return m_isPublic; } bool isStatic() const { return m_isStatic; } SymbolType getSymbolType() const { return m_symbolType; } /// @} /// @name 'Structors /// @{ public: Symbol(Class* _pClass, const std::string& _name, bool _static, bool _public, SymbolType _symbolType); virtual ~Symbol(); /// @} /// @name Member Variables /// @{ private: Class* m_pClass; std::string m_name; std::string m_type; bool m_isStatic; bool m_isPublic; SymbolType m_symbolType; /// @} }; // class Symbol //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ #endif // AS2JAVA_SYMBOL_HPP_INCLUDED
[ "sgtflame@Sullivan" ]
[ [ [ 1, 71 ] ] ]
0a47396cccf84b70d7ca1ec00f3e5cd4dcfda981
d86a6f4267cebad1b91991bd8c6a6d129b849044
/vvvv plugins/polyfitND/PluginTemplateCpp/PolyValND.cpp
2c86757736a6cae4eda2673b4833688ce9843113
[]
no_license
aurialLoop/kimchiandchips
e925c5d62b35be14460e71ed0d070f229782b677
012a8aeb2ed11461ecc5308fe4fb4feea53a7e96
refs/heads/master
2021-01-01T06:04:23.221712
2011-06-23T12:16:05
2011-06-23T12:16:05
33,194,904
0
0
null
null
null
null
UTF-8
C++
false
false
4,107
cpp
// // // P O L Y A L // // #include "stdafx.h" #include "PolyValND.h" using namespace System; using namespace VVVV::PluginInterfaces::V1; using namespace std; namespace PolyFitND { PolyValND::PolyValND() { } PolyValND::~PolyValND() { } void PolyValND::SetPluginHost(IPluginHost ^ Host) { this->FHost = Host; array<String ^> ^ arr = gcnew array<String ^>(1); FHost->CreateValueInput("Input",1,arr,TSliceMode::Dynamic,TPinVisibility::True,this->vPinInInput); FHost->CreateValueOutput("Output",1,arr,TSliceMode::Dynamic,TPinVisibility::True,this->vPinOutOutput); FHost->CreateValueInput("Input Dimensions", 1, arr, TSliceMode::Dynamic, TPinVisibility::True,this->vPinDimensionsIn); vPinDimensionsIn->SetSubType(1,MAX_DIMENSIONS,1,3,false,false,true); FHost->CreateValueInput("Output Dimensions", 1, arr, TSliceMode::Dynamic, TPinVisibility::True,this->vPinDimensionsOut); vPinDimensionsOut->SetSubType(1,MAX_DIMENSIONS,1,3,false,false,true); FHost->CreateValueInput("Coefficients",1,arr,TSliceMode::Dynamic,TPinVisibility::True,this->vPinInCoefficients); FHost->CreateValueInput("Bases indicies",1,arr,TSliceMode::Dynamic,TPinVisibility::True,vPinInBasisIndicies); vPinInBasisIndicies->SetSubType(0,MAX_ORDER,1,0,false,false,true); _boolConfigChanged=true; } void PolyValND::Configurate(IPluginConfig^ Input) { } void PolyValND::Evaluate(int SpreadMax) { if (vPinDimensionsIn->PinIsChanged || vPinDimensionsOut->PinIsChanged) { changeDimensions(); _boolConfigChanged=true; } // we should change this so poly isn't forced to evaluate if (_boolConfigChanged || vPinInInput->PinIsChanged || vPinInBasisIndicies->PinIsChanged || vPinInCoefficients->PinIsChanged) { evaluatePoly(); _boolConfigChanged=false; } } void PolyValND::changeDimensions() { double currentDimensionsIn, currentDimensionsOut; vPinDimensionsIn->GetValue(0,currentDimensionsIn); vPinDimensionsOut->GetValue(0,currentDimensionsOut); dimensionsIn = int(currentDimensionsIn); dimensionsOut = int(currentDimensionsOut); } void PolyValND::evaluatePoly() { double output; double basis; double coefficient; double *ptDataIn; double *ptBasesIn; int nDataPoints = vPinInInput->SliceCount / dimensionsIn; int nBases = vPinInBasisIndicies->SliceCount / dimensionsIn; int nDataSets; if (nBases*dimensionsOut!=0) nDataSets = vPinInCoefficients->SliceCount / (nBases * dimensionsOut); else nDataSets = 0; //temporary variables per basis inner loop double dataIn; int basisIn; //set output slicecount vPinOutOutput->SliceCount = nDataPoints * dimensionsOut * nDataSets; //get pointers to data vPinInBasisIndicies->GetValuePointer(nBases * dimensionsIn, ptBasesIn); vPinInInput->GetValuePointer(nDataSets * nDataPoints * dimensionsIn, ptDataIn); for (int iDataSet=0; iDataSet<nDataSets; ++iDataSet) { for (int iDataPoint=0; iDataPoint<nDataPoints; ++iDataPoint) { // render slice for each output dimension (loop through output dimensions) for (int iDimensionOut=0; iDimensionOut<dimensionsOut; ++iDimensionOut) { output=0; for (int iBasis = 0; iBasis<nBases; iBasis++) { basis=1; // build up basis (loop through input dimensions for (int iDimensionIn=0; iDimensionIn<dimensionsIn; ++iDimensionIn) { dataIn = *(ptDataIn + iDimensionIn + (iDataPoint*dimensionsIn)); basisIn = *(ptBasesIn + (iBasis*dimensionsIn+iDimensionIn)); basis *= pow(dataIn, basisIn); } // read in coefficients vPinInCoefficients->GetValue(iDataSet*nBases*dimensionsOut + iBasis*dimensionsOut + iDimensionOut, coefficient); output += basis * coefficient; } vPinOutOutput->SetValue(dimensionsOut*nDataPoints*iDataSet + dimensionsOut*iDataPoint + iDimensionOut, output); } } } } }
[ "elliot.woods@52398a2f-5f8c-4237-c580-2f6807e5d9c9" ]
[ [ [ 1, 148 ] ] ]
d3aa4e6613fb25214034d48e7565d0054e4d1ede
0f7af923b9d3a833f70dd5ab6f9927536ac8e31c
/ elistestserver/MySocket.h
08fdc43dfb4bf5ca31a729de329619e2ad4a9759
[]
no_license
empiredan/elistestserver
c422079f860f166dd3fcda3ced5240d24efbd954
cfc665293731de94ff308697f43c179a4a2fc2bb
refs/heads/master
2016-08-06T07:24:59.046295
2010-01-25T16:40:32
2010-01-25T16:40:32
32,509,805
0
0
null
null
null
null
UTF-8
C++
false
false
1,447
h
#if !defined(AFX_MYSOCKET_H__B2852606_6492_4CA2_BB0B_48F6A5B7E1A5__INCLUDED_) #define AFX_MYSOCKET_H__B2852606_6492_4CA2_BB0B_48F6A5B7E1A5__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // MySocket.h : header file // #include "Data.h" #define SOCK_RECEIVE_HEADER 0x0001 #define SOCK_RECEIVE_BODY 0x0002 ///////////////////////////////////////////////////////////////////////////// // MySocket command target class CELISTestServerDlg; class MySocket : public CAsyncSocket { // Attributes public: // Operations public: MySocket(); virtual ~MySocket(); // Overrides public: void SetParent(CELISTestServerDlg* pDlg); CELISTestServerDlg* m_pELISTestServerDlg; // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(MySocket) public: virtual void OnAccept(int nErrorCode); virtual void OnReceive(int nErrorCode); virtual void OnClose(int nErrorCode); //}}AFX_VIRTUAL // Generated message map functions //{{AFX_MSG(MySocket) // NOTE - the ClassWizard will add and remove member functions here. //}}AFX_MSG // Implementation protected: private: }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_MYSOCKET_H__B2852606_6492_4CA2_BB0B_48F6A5B7E1A5__INCLUDED_)
[ "zwusheng@3065b396-e208-11de-81d3-db62269da9c1" ]
[ [ [ 1, 56 ] ] ]
aa4041ea36a6a4c6bf720b081b420691489fd685
593b85562f3e570a5a6e75666d8cd1c535daf3b6
/Source/Wrappers/CSGD_TextureManager.cpp
5ec3ce7adc9eeb553800965194cff1af290c51e3
[]
no_license
rayjohannessen/songofalbion
fc62c317d829ceb7c215b805fed4276788a22154
83d7e87719bfb3ade14096d4969aa32c524c1902
refs/heads/master
2021-01-23T13:18:10.028635
2011-02-13T00:23:37
2011-02-13T00:23:37
32,121,693
1
0
null
null
null
null
UTF-8
C++
false
false
14,423
cpp
//////////////////////////////////////////////////////// // File : "CSGD_TextureManager.cpp" // // Author : Jensen Rivera (JR) // // Date Created : 6/26/2006 // // Purpose : Wrapper class for Direct3D. //////////////////////////////////////////////////////// /* Disclaimer: This source code was developed for and is the property of: Full Sail University Game Development Curriculum 2008-2009 and Full Sail Real World Education Game Design Curriculum 2000-2008 Full Sail students may not redistribute this code, but may use it in any project for educational purposes. */ #include "stdafx.h" #include "CSGD_TextureManager.h" #include <assert.h> // code in assertions gets compiled out in Release mode #pragma warning (disable : 4996) CSGD_TextureManager CSGD_TextureManager::m_Instance; /////////////////////////////////////////////////////////////////// // Function: "CSGD_TextureManager(Constructor)" /////////////////////////////////////////////////////////////////// CSGD_TextureManager::CSGD_TextureManager(void) { m_lpDevice = NULL; m_lpSprite = NULL; } /////////////////////////////////////////////////////////////////// // Function: "CSGD_TextureManager(Destructor)" /////////////////////////////////////////////////////////////////// CSGD_TextureManager::~CSGD_TextureManager(void) { } /////////////////////////////////////////////////////////////////// // Function: "GetInstance" // // Last Modified: 6/26/2006 // // Input: void // // Return: An instance to this class. // // Purpose: Gets an instance to this class. /////////////////////////////////////////////////////////////////// CSGD_TextureManager *CSGD_TextureManager::GetInstance(void) { return &m_Instance; } /////////////////////////////////////////////////////////////////// // Function: "InitTextureManager" // // Last Modified: 8/29/2006 // // Input: lpDevice - A pointer to the Direct3D device. // lpSprite - A pointer to the sprite object. // // Return: true, if successful. // // Purpose: Initializes the texture manager. /////////////////////////////////////////////////////////////////// bool CSGD_TextureManager::InitTextureManager(LPDIRECT3DDEVICE9 lpDevice, LPD3DXSPRITE lpSprite) { m_lpDevice = lpDevice; m_lpDevice->AddRef(); m_lpSprite = lpSprite; m_lpSprite->AddRef(); return (m_lpDevice && m_lpSprite) ? true : false; } /////////////////////////////////////////////////////////////////// // Function: "Shutdown" // // Last Modified: 10/29/2008 // // Input: void // // Return: void // // Purpose: Unloads all the loaded textures and // releases references to sprite and d3d devices. /////////////////////////////////////////////////////////////////// void CSGD_TextureManager::Shutdown(void) { for (unsigned int i = 0; i < m_Textures.size(); i++) { // Remove ref. m_Textures[i].ref = 0; // Release the texture if it's not being used. SAFE_RELEASE(m_Textures[i].texture); m_Textures[i].filename[0] = '\0'; } // Clear the list of all loaded textures. m_Textures.clear(); // Release our references to the sprite interface and d3d device SAFE_RELEASE(m_lpSprite); SAFE_RELEASE(m_lpDevice); } /////////////////////////////////////////////////////////////////// // Function: "LoadTexture" // // Last Modified: 10/29/2008 // // Input: szFilename - The file to load. // dwColorkey - The color key to use on the texture (use D3DCOLOR_XRGB() Macro). // NOTE: 0 = no color key (which will use the alpha from the image instead) // // Return: The id to the texture that was loaded or found, -1 if it failed. // // NOTE: The function searches to see if the texture was already loaded // and returns the id if it was. // // Purpose: To load a texture from a file. // // NOTE: Image dimensions must be a power of 2 (i.e. 256x64). // // Supports .bmp, .dds, .dib, .hdr, .jpg, .pfm, .png, // .ppm, and .tga files. /////////////////////////////////////////////////////////////////// int CSGD_TextureManager::LoadTexture(const char* szFilename, DWORD dwColorkey) { // Make sure the filename is valid. if (!szFilename) return -1; // Make sure the texture isn't already loaded. for (unsigned int i = 0; i < m_Textures.size(); i++) { // compare strings without caring about upper or lowercase. if (stricmp(szFilename, m_Textures[i].filename) == 0) // 0 means they are equal. { m_Textures[i].ref++; // add a reference to this texture. return i; // return the index. } } // Look for an open spot. int nID = -1; for (unsigned int i = 0; i < m_Textures.size(); i++) { if (m_Textures[i].ref == 0) { nID = i; break; } } // if we didn't find an open spot, load it in a new one if (nID == -1) { // A temp texture object. TEXTURE loaded; // Copy the filename of the loaded texture. strcpy(loaded.filename, szFilename); // Load the texture from the given file. HRESULT hr = 0; if (FAILED(hr = D3DXCreateTextureFromFileEx(m_lpDevice, szFilename, 0, 0, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, dwColorkey, 0, 0, &loaded.texture))) { // Failed. char szBuffer[256] = {0}; sprintf(szBuffer, "Failed to Create Texture - %s", szFilename); MessageBox(0, szBuffer, "TextureManager Error", MB_OK); return -1; } // AddRef. loaded.ref = 1; // Get surface description (to find Width/Height of the texture) D3DSURFACE_DESC d3dSurfDesc; ZeroMemory(&d3dSurfDesc, sizeof(d3dSurfDesc)); loaded.texture->GetLevelDesc(0, &d3dSurfDesc); // Remember the Width and Height loaded.Width = d3dSurfDesc.Width; loaded.Height = d3dSurfDesc.Height; // Put the texture into the list. m_Textures.push_back(loaded); // Return the nID of the texture. return (int)m_Textures.size() - 1; } // we found an open spot else { // Make sure the texture has been released. SAFE_RELEASE(m_Textures[nID].texture); // Copy the filename of the loaded texture. strcpy(m_Textures[nID].filename, szFilename); // Load the texture from the given file. HRESULT hr = 0; if (FAILED(hr = D3DXCreateTextureFromFileEx(m_lpDevice, szFilename, 0, 0, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, dwColorkey, 0, 0, &m_Textures[nID].texture))) { // Failed. char szBuffer[256] = {0}; sprintf(szBuffer, "Failed to Create Texture - %s", szFilename); MessageBox(0, szBuffer, "TextureManager Error", MB_OK); return -1; } // Get surface description (to find Width/Height of the texture) D3DSURFACE_DESC d3dSurfDesc; ZeroMemory(&d3dSurfDesc, sizeof(d3dSurfDesc)); m_Textures[nID].texture->GetLevelDesc(0, &d3dSurfDesc); // Remember the Width and Height m_Textures[nID].Width = d3dSurfDesc.Width; m_Textures[nID].Height = d3dSurfDesc.Height; // AddRef m_Textures[nID].ref = 1; // Return the nID of the texture. return nID; } } /////////////////////////////////////////////////////////////////// // Function: "UnloadTexture" // // Last Modified: 10/29/2008 // // Input: nID - The id to the texture to release. // // Return: void // // Purpose: Releases a reference to a given texture. When the // reference to the texture is zero, the texture is // released from memory. /////////////////////////////////////////////////////////////////// void CSGD_TextureManager::UnloadTexture(int nID) { // Make sure the nID is in range. assert(nID > -1 && nID < (int)m_Textures.size() && "nID is out of range"); // Remove ref. m_Textures[nID].ref--; // Release the texture if it's not being used. if (m_Textures[nID].ref <= 0) { // Do a lazy delete and leave this spot empty SAFE_RELEASE(m_Textures[nID].texture); m_Textures[nID].filename[0] = '\0'; m_Textures[nID].ref = 0; } } /////////////////////////////////////////////////////////////////// // Function: "GetTextureWidth" // // Last Modified: 9/21/2006 // // Input: nID - The id to the texture who's width you want. // // Return: The width of the given texture. // // Purpose: Gets the width of a specified texture. /////////////////////////////////////////////////////////////////// int CSGD_TextureManager::GetTextureWidth(int nID) { // Make sure the nID is in range. assert(nID > -1 && nID < (int)m_Textures.size() && "nID is out of range"); // Make sure that the texture is valid assert(m_Textures[nID].texture !=NULL && "Texture is NULL. Possible unloaded Texture."); return m_Textures[nID].Width; } /////////////////////////////////////////////////////////////////// // Function: "GetTextureHeight" // // Last Modified: 9/21/2006 // // Input: nID - The id to the texture who's height you want. // // Return: The height of the given texture. // // Purpose: Gets the height of a specified texture. /////////////////////////////////////////////////////////////////// int CSGD_TextureManager::GetTextureHeight(int nID) { // Make sure the nID is in range. assert(nID > -1 && nID < (int)m_Textures.size() && "nID is out of range"); // Make sure that the texture is valid assert(m_Textures[nID].texture != NULL && "Texture is NULL. Possible unloaded Texture."); return m_Textures[nID].Height; } /////////////////////////////////////////////////////////////////// // Function: "DrawTexture" // // Last Modified: 10/29/2008 // // Input: nID - The id of the texture to draw. // nX - The x position to draw the texture at. // nY - The y position to draw the texture at. // fScaleX - How much to scale the texture in the x. // fScaleY - How much to scale the texture in the y. // pSection - The section of the bitmap to draw. // fRotCenterX - The x center to apply the rotation from. // fRotCenterY - The y center to apply the rotation from. // fRotation - How much to rotate the texture. // dwColor - The color to apply to the texture (use D3DCOLOR_XRGB() Macro). // // Return: true if successful. // // Purpose: Draws a texture to the screen. // // NOTE: Drawing a section of an image will only work properly if // that image is a power of 2! /////////////////////////////////////////////////////////////////// // bool CSGD_TextureManager::Draw(int nID, int nX, int nY, float fScaleX, float fScaleY, // rect* rect, /*float fRotCenterX, float fRotCenterY, float fRotation,*/ DWORD dwColor) // { // RECT* pSection = NULL; /*pSection->left = 0; pSection->bottom = 0; pSection->top = 0; pSection->right = 0; */ // if (rect) // { // pSection = new RECT; // pSection->bottom = (LONG)rect->bottom; pSection->top = (LONG)rect->top; // pSection->left = (LONG)rect->left; pSection->right = (LONG)rect->right; // } // // // Make sure the nID is in range. // assert(nID > -1 && nID < (int)m_Textures.size() && "nID is out of range"); // // // Make sure that the texture is valid // assert(m_Textures[nID].texture != NULL && "Attempting to draw released texture id"); // // // Make sure the sprite was created and we have a valid texture. // if (!m_lpSprite) // return false; // // D3DXMATRIX scale; // //D3DXMATRIX rotation; // D3DXMATRIX translate; // D3DXMATRIX combined; // // // Initialize the Combined matrix. // D3DXMatrixIdentity(&combined); // // // Rotate the sprite. // //D3DXMatrixTranslation(&translate, -fRotCenterX, -fRotCenterY, 0.0f); // //combined *= translate; // //D3DXMatrixRotationZ(&rotation, fRotation); // //combined *= rotation; // //D3DXMatrixTranslation(&translate, fRotCenterX, fRotCenterY, 0.0f); // //combined *= translate; // // // Scale the sprite. // D3DXMatrixScaling(&scale, fScaleX, fScaleY, 1.0f); // combined *= scale; // // // Translate the sprite // D3DXMatrixTranslation(&translate, (float)nX, (float)nY, 0.0f); // combined *= translate; // // // Apply the transform. // m_lpSprite->SetTransform(&combined); // // // Draw the sprite. // if (FAILED(m_lpSprite->Draw(m_Textures[nID].texture, pSection, NULL, NULL, dwColor))) // DXERROR("Failed to draw the texture."); // // // Move the world back to identity. // D3DXMatrixIdentity(&combined); // m_lpSprite->SetTransform(&combined); // if (pSection) // delete pSection; // // success. // return true; // } bool CSGD_TextureManager::Render(int nID, int nX, int nY, float nZ, float fScaleX, float fScaleY, rect* const rect, float fRotCenterX, float fRotCenterY, float fRotation, DWORD dwColor) { RECT* pSection = NULL; if (rect) { pSection = new RECT; pSection->bottom = (LONG)rect->bottom; pSection->top = (LONG)rect->top; pSection->left = (LONG)rect->left; pSection->right = (LONG)rect->right; } // Make sure the nID is in range. assert(nID > -1 && nID < (int)m_Textures.size() && "nID is out of range"); // Make sure that the texture is valid assert(m_Textures[nID].texture != NULL && "Attempting to draw released texture id"); // Make sure the sprite was created and we have a valid texture. if (!m_lpSprite) return false; D3DXMATRIX scale; D3DXMATRIX rotation; D3DXMATRIX translate; D3DXMATRIX combined; // Initialize the Combined matrix. D3DXMatrixIdentity(&combined); // Rotate the sprite. D3DXMatrixTranslation(&translate, -fRotCenterX, -fRotCenterY, 0.0f); combined *= translate; D3DXMatrixRotationZ(&rotation, fRotation); combined *= rotation; D3DXMatrixTranslation(&translate, fRotCenterX, fRotCenterY, 0.0f); combined *= translate; // Scale the sprite. D3DXMatrixScaling(&scale, fScaleX, fScaleY, 1.0f); combined *= scale; // Translate the sprite D3DXMatrixTranslation(&translate, (float)nX, (float)nY, (float)nZ); combined *= translate; // Apply the transform. m_lpSprite->SetTransform(&combined); // Draw the sprite. if (FAILED(m_lpSprite->Draw(m_Textures[nID].texture, pSection, NULL, NULL, dwColor))) DXERROR("Failed to draw the texture."); // Move the world back to identity. D3DXMatrixIdentity(&combined); m_lpSprite->SetTransform(&combined); if(pSection) delete pSection; // success. return true; } #pragma warning (default : 4996)
[ "AllThingsCandid@cb80bfb0-ca38-a83e-6856-ee7c686669b9" ]
[ [ [ 1, 463 ] ] ]
02303d920ecf8112e26960fa105171a50fac9d69
5095bbe94f3af8dc3b14a331519cfee887f4c07e
/apsim/Plant/source/Phenology/CWVernalPhase.h
e286c8ad71789dc6fbfcfa7e85791020fb4d9311
[]
no_license
sativa/apsim_development
efc2b584459b43c89e841abf93830db8d523b07a
a90ffef3b4ed8a7d0cce1c169c65364be6e93797
refs/heads/master
2020-12-24T06:53:59.364336
2008-09-17T05:31:07
2008-09-17T05:31:07
64,154,433
0
0
null
null
null
null
UTF-8
C++
false
false
1,563
h
#ifndef CWVernalPhaseH #define CWVernalPhaseH #include "Phase.h" class CWVernalPhase : public Phase // A CERES WHEAT vernalisation phase. { protected: float vern_eff; float photop_eff; float cumvd; float dlt_cumvd; float vern_sens; float photop_sens; float dlt_tt; float twilight; // twilight in angular distance between // sunset and end of twilight - altitude // of sun. (deg) interpolationFunction y_tt; void vernalisation(); float crown_temp_nwheat(float maxt, float mint, float snow); float wheat_vernaliz_days(float g_maxt //Daily maximum Temperature ,float g_mint //Daily minimum temperature ,float tempcr //Crown temperature ,float //g_snow //Snow depth of the day (mm) ,float g_cumvd); float wheat_vernaliz_effect(float p_vern_sens ,float cumvd ,float dlt_cumvd ,float reqvd); float wheat_photoperiod_effect(float photoperiod, float p_photop_sen); virtual float TT() {return dlt_tt;} public: CWVernalPhase(ScienceAPI& scienceAPI, plantInterface& p, const string& stage_name); virtual void reset(void); virtual void process(); virtual void read(); }; #endif
[ "hol353@8bb03f63-af10-0410-889a-a89e84ef1bc8" ]
[ [ [ 1, 45 ] ] ]
4f5dd749f28be3dee3bd38881a3cfeb15ccdbec5
eb8a27a2cc7307f0bc9596faa4aa4a716676c5c5
/WinEdition/browser-lcc/jscc/src/v8/v8/src/ic.h
b4b96663d142f635895e1480ba234d58dc6982f7
[ "BSD-3-Clause", "bzip2-1.0.6", "LicenseRef-scancode-public-domain", "Artistic-2.0", "Artistic-1.0" ]
permissive
baxtree/OKBuzzer
c46c7f271a26be13adcf874d77a7a6762a8dc6be
a16e2baad145f5c65052cdc7c767e78cdfee1181
refs/heads/master
2021-01-02T22:17:34.168564
2011-06-15T02:29:56
2011-06-15T02:29:56
1,790,181
0
0
null
null
null
null
UTF-8
C++
false
false
21,626
h
// Copyright 2006-2009 the V8 project authors. 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 Google 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 THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef V8_IC_H_ #define V8_IC_H_ #include "macro-assembler.h" namespace v8 { namespace internal { // IC_UTIL_LIST defines all utility functions called from generated // inline caching code. The argument for the macro, ICU, is the function name. #define IC_UTIL_LIST(ICU) \ ICU(LoadIC_Miss) \ ICU(KeyedLoadIC_Miss) \ ICU(CallIC_Miss) \ ICU(KeyedCallIC_Miss) \ ICU(StoreIC_Miss) \ ICU(StoreIC_ArrayLength) \ ICU(SharedStoreIC_ExtendStorage) \ ICU(KeyedStoreIC_Miss) \ /* Utilities for IC stubs. */ \ ICU(LoadCallbackProperty) \ ICU(StoreCallbackProperty) \ ICU(LoadPropertyWithInterceptorOnly) \ ICU(LoadPropertyWithInterceptorForLoad) \ ICU(LoadPropertyWithInterceptorForCall) \ ICU(KeyedLoadPropertyWithInterceptor) \ ICU(StoreInterceptorProperty) \ ICU(TypeRecordingUnaryOp_Patch) \ ICU(TypeRecordingBinaryOp_Patch) \ ICU(CompareIC_Miss) // // IC is the base class for LoadIC, StoreIC, CallIC, KeyedLoadIC, // and KeyedStoreIC. // class IC { public: // The ids for utility called from the generated code. enum UtilityId { #define CONST_NAME(name) k##name, IC_UTIL_LIST(CONST_NAME) #undef CONST_NAME kUtilityCount }; // Looks up the address of the named utility. static Address AddressFromUtilityId(UtilityId id); // Alias the inline cache state type to make the IC code more readable. typedef InlineCacheState State; // The IC code is either invoked with no extra frames on the stack // or with a single extra frame for supporting calls. enum FrameDepth { NO_EXTRA_FRAME = 0, EXTRA_CALL_FRAME = 1 }; // Construct the IC structure with the given number of extra // JavaScript frames on the stack. IC(FrameDepth depth, Isolate* isolate); // Get the call-site target; used for determining the state. Code* target() { return GetTargetAtAddress(address()); } inline Address address(); // Compute the current IC state based on the target stub, receiver and name. static State StateFrom(Code* target, Object* receiver, Object* name); // Clear the inline cache to initial state. static void Clear(Address address); // Computes the reloc info for this IC. This is a fairly expensive // operation as it has to search through the heap to find the code // object that contains this IC site. RelocInfo::Mode ComputeMode(); // Returns if this IC is for contextual (no explicit receiver) // access to properties. bool IsContextual(Handle<Object> receiver) { if (receiver->IsGlobalObject()) { return SlowIsContextual(); } else { ASSERT(!SlowIsContextual()); return false; } } bool SlowIsContextual() { return ComputeMode() == RelocInfo::CODE_TARGET_CONTEXT; } // Determines which map must be used for keeping the code stub. // These methods should not be called with undefined or null. static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object, JSObject* holder); static inline InlineCacheHolderFlag GetCodeCacheForObject(JSObject* object, JSObject* holder); static inline JSObject* GetCodeCacheHolder(Object* object, InlineCacheHolderFlag holder); protected: Address fp() const { return fp_; } Address pc() const { return *pc_address_; } Isolate* isolate() const { return isolate_; } #ifdef ENABLE_DEBUGGER_SUPPORT // Computes the address in the original code when the code running is // containing break points (calls to DebugBreakXXX builtins). Address OriginalCodeAddress(); #endif // Set the call-site target. void set_target(Code* code) { SetTargetAtAddress(address(), code); } #ifdef DEBUG static void TraceIC(const char* type, Handle<Object> name, State old_state, Code* new_target, const char* extra_info = ""); #endif Failure* TypeError(const char* type, Handle<Object> object, Handle<Object> key); Failure* ReferenceError(const char* type, Handle<String> name); // Access the target code for the given IC address. static inline Code* GetTargetAtAddress(Address address); static inline void SetTargetAtAddress(Address address, Code* target); private: // Frame pointer for the frame that uses (calls) the IC. Address fp_; // All access to the program counter of an IC structure is indirect // to make the code GC safe. This feature is crucial since // GetProperty and SetProperty are called and they in turn might // invoke the garbage collector. Address* pc_address_; Isolate* isolate_; DISALLOW_IMPLICIT_CONSTRUCTORS(IC); }; // An IC_Utility encapsulates IC::UtilityId. It exists mainly because you // cannot make forward declarations to an enum. class IC_Utility { public: explicit IC_Utility(IC::UtilityId id) : address_(IC::AddressFromUtilityId(id)), id_(id) {} Address address() const { return address_; } IC::UtilityId id() const { return id_; } private: Address address_; IC::UtilityId id_; }; class CallICBase: public IC { protected: CallICBase(Code::Kind kind, Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate), kind_(kind) {} public: MUST_USE_RESULT MaybeObject* LoadFunction(State state, Code::ExtraICState extra_ic_state, Handle<Object> object, Handle<String> name); protected: Code::Kind kind_; bool TryUpdateExtraICState(LookupResult* lookup, Handle<Object> object, Code::ExtraICState* extra_ic_state); MUST_USE_RESULT MaybeObject* ComputeMonomorphicStub( LookupResult* lookup, State state, Code::ExtraICState extra_ic_state, Handle<Object> object, Handle<String> name); // Update the inline cache and the global stub cache based on the // lookup result. void UpdateCaches(LookupResult* lookup, State state, Code::ExtraICState extra_ic_state, Handle<Object> object, Handle<String> name); // Returns a JSFunction if the object can be called as a function, // and patches the stack to be ready for the call. // Otherwise, it returns the undefined value. Object* TryCallAsFunction(Object* object); void ReceiverToObjectIfRequired(Handle<Object> callee, Handle<Object> object); static void Clear(Address address, Code* target); friend class IC; }; class CallIC: public CallICBase { public: explicit CallIC(Isolate* isolate) : CallICBase(Code::CALL_IC, isolate) { ASSERT(target()->is_call_stub()); } // Code generator routines. static void GenerateInitialize(MacroAssembler* masm, int argc) { GenerateMiss(masm, argc); } static void GenerateMiss(MacroAssembler* masm, int argc); static void GenerateMegamorphic(MacroAssembler* masm, int argc); static void GenerateNormal(MacroAssembler* masm, int argc); }; class KeyedCallIC: public CallICBase { public: explicit KeyedCallIC(Isolate* isolate) : CallICBase(Code::KEYED_CALL_IC, isolate) { ASSERT(target()->is_keyed_call_stub()); } MUST_USE_RESULT MaybeObject* LoadFunction(State state, Handle<Object> object, Handle<Object> key); // Code generator routines. static void GenerateInitialize(MacroAssembler* masm, int argc) { GenerateMiss(masm, argc); } static void GenerateMiss(MacroAssembler* masm, int argc); static void GenerateMegamorphic(MacroAssembler* masm, int argc); static void GenerateNormal(MacroAssembler* masm, int argc); }; class LoadIC: public IC { public: explicit LoadIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { ASSERT(target()->is_load_stub()); } MUST_USE_RESULT MaybeObject* Load(State state, Handle<Object> object, Handle<String> name); // Code generator routines. static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } static void GeneratePreMonomorphic(MacroAssembler* masm) { GenerateMiss(masm); } static void GenerateMiss(MacroAssembler* masm); static void GenerateMegamorphic(MacroAssembler* masm); static void GenerateNormal(MacroAssembler* masm); // Specialized code generator routines. static void GenerateArrayLength(MacroAssembler* masm); static void GenerateStringLength(MacroAssembler* masm, bool support_wrappers); static void GenerateFunctionPrototype(MacroAssembler* masm); private: // Update the inline cache and the global stub cache based on the // lookup result. void UpdateCaches(LookupResult* lookup, State state, Handle<Object> object, Handle<String> name); // Stub accessors. Code* megamorphic_stub() { return isolate()->builtins()->builtin( Builtins::kLoadIC_Megamorphic); } static Code* initialize_stub() { return Isolate::Current()->builtins()->builtin( Builtins::kLoadIC_Initialize); } Code* pre_monomorphic_stub() { return isolate()->builtins()->builtin( Builtins::kLoadIC_PreMonomorphic); } static void Clear(Address address, Code* target); friend class IC; }; class KeyedLoadIC: public IC { public: explicit KeyedLoadIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { ASSERT(target()->is_keyed_load_stub() || target()->is_external_array_load_stub()); } MUST_USE_RESULT MaybeObject* Load(State state, Handle<Object> object, Handle<Object> key); // Code generator routines. static void GenerateMiss(MacroAssembler* masm); static void GenerateRuntimeGetProperty(MacroAssembler* masm); static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } static void GeneratePreMonomorphic(MacroAssembler* masm) { GenerateMiss(masm); } static void GenerateGeneric(MacroAssembler* masm); static void GenerateString(MacroAssembler* masm); static void GenerateIndexedInterceptor(MacroAssembler* masm); // Bit mask to be tested against bit field for the cases when // generic stub should go into slow case. // Access check is necessary explicitly since generic stub does not perform // map checks. static const int kSlowCaseBitFieldMask = (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor); private: // Update the inline cache. void UpdateCaches(LookupResult* lookup, State state, Handle<Object> object, Handle<String> name); // Stub accessors. static Code* initialize_stub() { return Isolate::Current()->builtins()->builtin( Builtins::kKeyedLoadIC_Initialize); } Code* megamorphic_stub() { return isolate()->builtins()->builtin( Builtins::kKeyedLoadIC_Generic); } Code* generic_stub() { return isolate()->builtins()->builtin( Builtins::kKeyedLoadIC_Generic); } Code* pre_monomorphic_stub() { return isolate()->builtins()->builtin( Builtins::kKeyedLoadIC_PreMonomorphic); } Code* string_stub() { return isolate()->builtins()->builtin( Builtins::kKeyedLoadIC_String); } Code* indexed_interceptor_stub() { return isolate()->builtins()->builtin( Builtins::kKeyedLoadIC_IndexedInterceptor); } static void Clear(Address address, Code* target); friend class IC; }; class StoreIC: public IC { public: explicit StoreIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { ASSERT(target()->is_store_stub()); } MUST_USE_RESULT MaybeObject* Store(State state, StrictModeFlag strict_mode, Handle<Object> object, Handle<String> name, Handle<Object> value); // Code generators for stub routines. Only called once at startup. static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } static void GenerateMiss(MacroAssembler* masm); static void GenerateMegamorphic(MacroAssembler* masm, StrictModeFlag strict_mode); static void GenerateArrayLength(MacroAssembler* masm); static void GenerateNormal(MacroAssembler* masm); static void GenerateGlobalProxy(MacroAssembler* masm, StrictModeFlag strict_mode); private: // Update the inline cache and the global stub cache based on the // lookup result. void UpdateCaches(LookupResult* lookup, State state, StrictModeFlag strict_mode, Handle<JSObject> receiver, Handle<String> name, Handle<Object> value); void set_target(Code* code) { // Strict mode must be preserved across IC patching. ASSERT((code->extra_ic_state() & kStrictMode) == (target()->extra_ic_state() & kStrictMode)); IC::set_target(code); } // Stub accessors. Code* megamorphic_stub() { return isolate()->builtins()->builtin( Builtins::kStoreIC_Megamorphic); } Code* megamorphic_stub_strict() { return isolate()->builtins()->builtin( Builtins::kStoreIC_Megamorphic_Strict); } static Code* initialize_stub() { return Isolate::Current()->builtins()->builtin( Builtins::kStoreIC_Initialize); } static Code* initialize_stub_strict() { return Isolate::Current()->builtins()->builtin( Builtins::kStoreIC_Initialize_Strict); } Code* global_proxy_stub() { return isolate()->builtins()->builtin( Builtins::kStoreIC_GlobalProxy); } Code* global_proxy_stub_strict() { return isolate()->builtins()->builtin( Builtins::kStoreIC_GlobalProxy_Strict); } static void Clear(Address address, Code* target); friend class IC; }; class KeyedStoreIC: public IC { public: explicit KeyedStoreIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { } MUST_USE_RESULT MaybeObject* Store(State state, StrictModeFlag strict_mode, Handle<Object> object, Handle<Object> name, Handle<Object> value); // Code generators for stub routines. Only called once at startup. static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } static void GenerateMiss(MacroAssembler* masm); static void GenerateRuntimeSetProperty(MacroAssembler* masm, StrictModeFlag strict_mode); static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode); private: // Update the inline cache. void UpdateCaches(LookupResult* lookup, State state, StrictModeFlag strict_mode, Handle<JSObject> receiver, Handle<String> name, Handle<Object> value); void set_target(Code* code) { // Strict mode must be preserved across IC patching. ASSERT((code->extra_ic_state() & kStrictMode) == (target()->extra_ic_state() & kStrictMode)); IC::set_target(code); } // Stub accessors. static Code* initialize_stub() { return Isolate::Current()->builtins()->builtin( Builtins::kKeyedStoreIC_Initialize); } Code* megamorphic_stub() { return isolate()->builtins()->builtin( Builtins::kKeyedStoreIC_Generic); } static Code* initialize_stub_strict() { return Isolate::Current()->builtins()->builtin( Builtins::kKeyedStoreIC_Initialize_Strict); } Code* megamorphic_stub_strict() { return isolate()->builtins()->builtin( Builtins::kKeyedStoreIC_Generic_Strict); } Code* generic_stub() { return isolate()->builtins()->builtin( Builtins::kKeyedStoreIC_Generic); } Code* generic_stub_strict() { return isolate()->builtins()->builtin( Builtins::kKeyedStoreIC_Generic_Strict); } static void Clear(Address address, Code* target); friend class IC; }; class TRUnaryOpIC: public IC { public: // sorted: increasingly more unspecific (ignoring UNINITIALIZED) // TODO(svenpanne) Using enums+switch is an antipattern, use a class instead. enum TypeInfo { UNINITIALIZED, SMI, HEAP_NUMBER, GENERIC }; explicit TRUnaryOpIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { } void patch(Code* code); static const char* GetName(TypeInfo type_info); static State ToState(TypeInfo type_info); static TypeInfo GetTypeInfo(Handle<Object> operand); static TypeInfo JoinTypes(TypeInfo x, TypeInfo y); }; // Type Recording BinaryOpIC, that records the types of the inputs and outputs. class TRBinaryOpIC: public IC { public: enum TypeInfo { UNINITIALIZED, SMI, INT32, HEAP_NUMBER, ODDBALL, BOTH_STRING, // Only used for addition operation. STRING, // Only used for addition operation. At least one string operand. GENERIC }; explicit TRBinaryOpIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { } void patch(Code* code); static const char* GetName(TypeInfo type_info); static State ToState(TypeInfo type_info); static TypeInfo GetTypeInfo(Handle<Object> left, Handle<Object> right); static TypeInfo JoinTypes(TypeInfo x, TypeInfo y); }; class CompareIC: public IC { public: enum State { UNINITIALIZED, SMIS, HEAP_NUMBERS, OBJECTS, GENERIC }; CompareIC(Isolate* isolate, Token::Value op) : IC(EXTRA_CALL_FRAME, isolate), op_(op) { } // Update the inline cache for the given operands. void UpdateCaches(Handle<Object> x, Handle<Object> y); // Factory method for getting an uninitialized compare stub. static Handle<Code> GetUninitialized(Token::Value op); // Helper function for computing the condition for a compare operation. static Condition ComputeCondition(Token::Value op); // Helper function for determining the state of a compare IC. static State ComputeState(Code* target); static const char* GetStateName(State state); private: State TargetState(State state, bool has_inlined_smi_code, Handle<Object> x, Handle<Object> y); bool strict() const { return op_ == Token::EQ_STRICT; } Condition GetCondition() const { return ComputeCondition(op_); } State GetState() { return ComputeState(target()); } Token::Value op_; }; // Helper for TRBinaryOpIC and CompareIC. void PatchInlinedSmiCode(Address address); } } // namespace v8::internal #endif // V8_IC_H_
[ [ [ 1, 632 ] ] ]
c42ac234d8dd81486e677501bf0670eec4820e39
74c8da5b29163992a08a376c7819785998afb588
/NetAnimal/Game/Hunter/NewGame/CCS/src/CCSCollidableOrbitalCameraMode.cpp
ec20e47bcdbc25239f2b1a2c43ad2e71b0289e6e
[]
no_license
dbabox/aomi
dbfb46c1c9417a8078ec9a516cc9c90fe3773b78
4cffc8e59368e82aed997fe0f4dcbd7df626d1d0
refs/heads/master
2021-01-13T14:05:10.813348
2011-06-07T09:36:41
2011-06-07T09:36:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,653
cpp
/* ------------------------------------------------------- Copyright (c) 2009 Alberto G. Salguero ([email protected]) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------- */ #include "CCSPrerequisites.h" //#include "CCSCollidableOrbitalCameraMode.h" // //bool CCS::CollidableOrbitalCameraMode::init() //{ // OrbitalCameraMode::init(); // // this->collisionDelegate = newCollisionDelegate(this // , &CollidableOrbitalCameraMode::DefaultCollisionDetectionFunction); // // return true; //} // //void CCS::CollidableOrbitalCameraMode::update(const Ogre::Real &timeSinceLastFrame) //{ // OrbitalCameraMode::update(timeSinceLastFrame); // // mCameraPosition = collisionDelegate(mCameraCS->getCameraTargetPosition(), mCameraPosition); //} // //Ogre::Vector3 CCS::CollidableOrbitalCameraMode::DefaultCollisionDetectionFunction(Ogre::Vector3 cameraTargetPosition, Ogre::Vector3 cameraPosition) //{ // Ogre::Vector3 finalCameraPosition (cameraPosition.x, cameraPosition.y, cameraPosition.z); // // Ogre::RaySceneQuery *raySceneQuery = mCameraCS->getSceneManager()->createRayQuery(Ogre::Ray(cameraTargetPosition, cameraPosition)); // // // Perform the scene query // Ogre::RaySceneQueryResult &result = raySceneQuery->execute(); // Ogre::RaySceneQueryResult::iterator itr = result.begin(); // // // Get the results, set the camera height // if (itr != result.end() && itr->worldFragment) // { // finalCameraPosition = itr->worldFragment->singleIntersection; // } // // mCameraCS->getSceneManager()->destroyQuery(raySceneQuery); // // return finalCameraPosition; //}
[ [ [ 1, 66 ] ] ]
f8f06f93ba68a87cd5102f0e4bbabe51f91855b2
de24ee2f04bf6d69bc093db4b3091da8c9e44a90
/TutorialApplication.h
66dfe3e9ca5490907d1ca78b8c74cded7dbf3ef4
[]
no_license
martinvium/sidescroller
713361432d5d3e3235766bf9a14b1394dc83085a
00e9a51fc9f6d8a5b765a469c4560ea9f33cb9b6
refs/heads/master
2020-12-24T15:49:37.627554
2011-04-25T17:00:00
2011-04-25T17:00:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,385
h
/* ----------------------------------------------------------------------------- Filename: TutorialApplication.h ----------------------------------------------------------------------------- This source file is part of the ___ __ __ _ _ _ /___\__ _ _ __ ___ / / /\ \ (_) | _(_) // // _` | '__/ _ \ \ \/ \/ / | |/ / | / \_// (_| | | | __/ \ /\ /| | <| | \___/ \__, |_| \___| \/ \/ |_|_|\_\_| |___/ Tutorial Framework http://www.ogre3d.org/tikiwiki/ ----------------------------------------------------------------------------- */ #ifndef __TutorialApplication_h_ #define __TutorialApplication_h_ #include "BaseApplication.h" #include <deque> class TutorialApplication : public BaseApplication { public: TutorialApplication(void); virtual ~TutorialApplication(void); protected: virtual void createScene(void); virtual void createFrameListener(void); virtual bool nextLocation(void); virtual bool frameRenderingQueued(const Ogre::FrameEvent &evt); virtual bool keyPressed( const OIS::KeyEvent &arg ); void createBox(const Ogre::String &name, const Ogre::Vector3 &pos); void createPlayer(void); void createTerrain(void); void createBackground(void); void movePlayer(const Ogre::FrameEvent &evt); void createLava(void); void createLavaLight(void); void jumpPlayer(void); void movePlayerLeft(void); Ogre::Real mDistance; // The distance the object has left to travel Ogre::Vector3 mDirection; // The direction the object is moving Ogre::Vector3 mDestination; // The destination the object is moving towards Ogre::AnimationState *mAnimationState; // The current animation state of the object Ogre::Entity *mPlayerEntity; // The Entity we are animating Ogre::SceneNode *mPlayerNode; // The SceneNode that the Entity is attached to std::deque<Ogre::Vector3> mWalkList; // The list of points we are walking to bool mCameraLocked; Ogre::Real mWalkSpeed; // The speed at which the object is moving static const float CAMERA_Y = 200.0f; static const float CAMERA_Z = 535.0f; }; #endif // #ifndef __TutorialApplication_h_
[ [ [ 1, 42 ], [ 45, 63 ] ], [ [ 43, 44 ] ] ]
60184ad7d8f41144dbe83beaf73c63be869607db
a9cf0c2a8904e42a206c3575b244f8b0850dd7af
/gui/console/line.h
dd6f0290b63c6eba7ba160ebe961c40a49edddc1
[]
no_license
jayrulez/ourlib
3a38751ccb6a38785d4df6f508daeff35ccfd09f
e4727d638f2d69ea29114dc82b9687ea1fd17a2d
refs/heads/master
2020-04-22T15:42:00.891099
2010-01-06T20:00:17
2010-01-06T20:00:17
40,554,487
0
0
null
null
null
null
UTF-8
C++
false
false
1,075
h
/* @Group: BSC2D @Group Members: <ul> <li>Robert Campbell: 0701334</li> <li>Audley Gordon: 0802218</li> <li>Dale McFarlane: 0801042</li> <li>Dyonne Duberry: 0802189</li> <li>Xavier Lowe: 0802488</li> </ul> @ */ #ifndef LINE_H #define LINE_H #include "console.h" class line { private: int x1; int x2; int xy; int y1; int y2; int yx; const int xDChar; const int yDChar; const int xSChar; const int ySChar; console console_line; public: line(); line(int,int,int,int,int,int); ~line(); bool setHCoord(int,int,int); bool setVCoord(int,int,int); /*will be used to draw a horizontal double line*/ void hDLine(); /*will be used to draw a veritcal double line*/ void vDLine(); /*will be used to draw a horizontal single line*/ void hSLine(); /*will be used to draw a vertical single line*/ void vSLine(); }; #endif // LINE_H
[ [ [ 1, 46 ] ] ]
761cd808996a8694726640087baa031f38d05ba2
bd7c64b284e87f9d661bf20d867d90c47dbdc3ad
/include/vise/MechanicsState.h
077883aa2c05522a5fe36e8d769b7c1e8585cebf
[ "MIT" ]
permissive
gasproni/vise_cpp
5fe16405d9b37afdfc8d4f9b6f934fd3c4333c58
f48780e3e177655136d2922a4a9260a9c7ba560d
refs/heads/master
2021-01-01T17:28:37.618664
2010-12-05T15:33:20
2010-12-05T15:33:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
814
h
#ifndef VISE_MECHANICSSTATE_H #define VISE_MECHANICSSTATE_H #include "vise/Platform.h" #include <string> #include <map> #include <boost/shared_ptr.hpp> #include "vise/Serializable.h" #include "vise/SerializableList.h" namespace vise { class VISE_API MechanicsState { public: virtual ~MechanicsState( ) { } virtual bool isRecording( ) const = 0; virtual void openSection( const std::string& sectionName ) = 0; virtual void grip( const SerializablePtr& object, const std::string& label ) = 0; virtual void closeSection( ) = 0; void inspect( ); protected: virtual void getGrippedValues( SerializableList& result ) = 0; }; typedef boost::shared_ptr< MechanicsState > MechanicsStatePtr; } #endif
[ [ [ 1, 49 ] ] ]
a1304a31198535e9aaac867c5b9f5ed9c79a5b32
9fb229975cc6bd01eb38c3e96849d0c36985fa1e
/src/Common/Keypad.h
3c990b3cf729ed5546f418ae87eae07c46486d57
[]
no_license
Danewalker/ahr
3758bf3219f407ed813c2bbed5d1d86291b9237d
2af9fd5a866c98ef1f95f4d1c3d9b192fee785a6
refs/heads/master
2016-09-13T08:03:43.040624
2010-07-21T15:44:41
2010-07-21T15:44:41
56,323,321
0
0
null
null
null
null
UTF-8
C++
false
false
3,770
h
#ifndef __KEYPAD__ #define __KEYPAD__ // Generic Keypad Engine For Cellphone Games // Highly Responsive, Multiple-Input Compatible, Mostly Foolproof // By Alexandre David // (C)2003 Gameloft Canada // ............................................................................ // ............................................................................ // Constants // ............................................................................ // ............................................................................ #define kKeypad_EventType_Released 0 #define kKeypad_EventType_Pressed 1 #define kKeypad_Update_Smart false #define kKeypad_Update_Flush true #define kKeypad_NULL 0 #define kKeypad_0 1 #define kKeypad_1 2 #define kKeypad_2 3 #define kKeypad_3 4 #define kKeypad_4 5 #define kKeypad_5 6 #define kKeypad_6 7 #define kKeypad_7 8 #define kKeypad_8 9 #define kKeypad_9 10 #define kKeypad_Pound 11 #define kKeypad_Star 12 #define kKeypad_Gaming_Key_A 13 #define kKeypad_Gaming_Key_B 14 #define kKeypad_DPad_Up 15 #define kKeypad_DPad_Left 16 #define kKeypad_DPad_Right 17 #define kKeypad_DPad_Down 18 #define kKeypad_DPad_Click 19 #define kKeypad_C 20 #define kKeypad_Pen 21 #define kKeypad_SoftKey_Left 22 #define kKeypad_SoftKey_Right 23 #define kKeypad_Phone_Green 24 #define kKeypad_Phone_Red 25 #define kKeypad_Menu 26 #define kKeypad_Volume_Up 28 #define kKeypad_Volume_Down 29 #define kKeypad_OUTOFBOUNDS 30 #define kKeypad_EventQueue_MaxSize 16 #define kKeypad_Bits_KeyID 6 #define kKeypad_Bits_EventType 1 #define kKeypad_Mask_KeyID ((1 << kKeypad_Bits_KeyID ) - 1) #define kKeypad_Mask_EventType ((1 << kKeypad_Bits_EventType) - 1) #define kKeypad_Get_Key_Mask( key ) (1<<key) #define kKeypad_Last_Key_Code kKeypad_Gaming_Key_B class CKeypad { public: CKeypad (); bool Keypad_IsKeyPressed (unsigned int Param_Key); bool Keypad_HasKeyChanged (unsigned int Param_Key); bool Keypad_HasKeyBeenPressed (unsigned int Param_Key); bool Keypad_IsAnyKeyPressed (); bool Keypad_HasAnyKeyChanged (); bool Keypad_HasAnyKeyBeenPressed (); int Keypad_GetLastPressedKeyCode(); bool Keypad_IsActionKeyBeenPressed( unsigned int action_key, bool permanently = false ); bool Keypad_HasActionKeyBeenDoublePressed (unsigned int action_key); bool Keypad_IsKeyPressed_MenuUp(); bool Keypad_IsKeyPressed_MenuDown(); bool Keypad_IsKeyPressed_MenuLeft(); bool Keypad_IsKeyPressed_MenuRight(); bool Keypad_HasKeyBeenPressed_MenuUp(); bool Keypad_HasKeyBeenPressed_MenuDown(); bool Keypad_HasKeyBeenPressed_MenuLeft(); bool Keypad_HasKeyBeenPressed_MenuRight(); void Keypad_RemoveActionKey ( unsigned int action_key ); bool Keypad_AddEvent (unsigned int Param_Key, unsigned int Param_EventType); void Keypad_UpdateState (bool Param_EntireQueue); void Keypad_ResetQueue (); void Keypad_ResetStates (); void Keypad_Reset (); private: unsigned int Keypad_State_Old; unsigned int Keypad_State_Current; unsigned char Keypad_EventQueue_Start; unsigned char Keypad_EventQueue_End; unsigned char Keypad_Repeated_Key_ID; unsigned char Keypad_Repeated_Key_Time; unsigned char Keypad_Repeated_Key_Count; unsigned char Keypad_EventQueue[kKeypad_EventQueue_MaxSize]; }; #endif
[ "jakesoul@c957e3ca-5ece-11de-8832-3f4c773c73ae" ]
[ [ [ 1, 108 ] ] ]
cee418a5bf4dad20c0eb93fa6cd7bd678ea8c275
1c9f99b2b2e3835038aba7ec0abc3a228e24a558
/Projects/elastix/elastix_sources_v4/src/Common/CostFunctions/itkSingleValuedPointSetToPointSetMetric.h
926fdf39c0f05f0406fa7619905d5edd867e7eed
[]
no_license
mijc/Diploma
95fa1b04801ba9afb6493b24b53383d0fbd00b33
bae131ed74f1b344b219c0ffe0fffcd90306aeb8
refs/heads/master
2021-01-18T13:57:42.223466
2011-02-15T14:19:49
2011-02-15T14:19:49
1,369,569
0
0
null
null
null
null
UTF-8
C++
false
false
7,240
h
/*========================================================================= Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkSingleValuedPointSetToPointSetMetric.h,v $ Language: C++ Date: $Date: 2009-01-26 21:45:56 $ Version: $Revision: 1.2 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef __itkSingleValuedPointSetToPointSetMetric_h #define __itkSingleValuedPointSetToPointSetMetric_h #include "itkImageBase.h" #include "itkAdvancedTransform.h" #include "itkSingleValuedCostFunction.h" #include "itkExceptionObject.h" #include "itkSpatialObject.h" #include "itkPointSet.h" namespace itk { /** \class SingleValuedPointSetToPointSetMetric * \brief Computes similarity between two point sets. * * This Class is templated over the type of the two point-sets. It * expects a Transform to be plugged in. This particular * class is the base class for a hierarchy of point-set to point-set metrics. * * This class computes a value that measures the similarity between the fixed point-set * and the transformed moving point-set. * * \ingroup RegistrationMetrics * */ template <class TFixedPointSet, class TMovingPointSet> class ITK_EXPORT SingleValuedPointSetToPointSetMetric : public SingleValuedCostFunction { public: /** Standard class typedefs. */ typedef SingleValuedPointSetToPointSetMetric Self; typedef SingleValuedCostFunction Superclass; typedef SmartPointer<Self> Pointer; typedef SmartPointer<const Self> ConstPointer; /** Type used for representing point components */ typedef Superclass::ParametersValueType CoordinateRepresentationType; /** Run-time type information (and related methods). */ itkTypeMacro( SingleValuedPointSetToPointSetMetric, SingleValuedCostFunction ); /** Typedefs. */ typedef TFixedPointSet FixedPointSetType; typedef typename FixedPointSetType::PixelType FixedPointSetPixelType; typedef typename FixedPointSetType::ConstPointer FixedPointSetConstPointer; typedef TMovingPointSet MovingPointSetType; typedef typename MovingPointSetType::PixelType MovingPointSetPixelType; typedef typename MovingPointSetType::ConstPointer MovingPointSetConstPointer; typedef typename FixedPointSetType::PointsContainer::ConstIterator PointIterator; typedef typename FixedPointSetType::PointDataContainer::ConstIterator PointDataIterator; /** Constants for the pointset dimensions. */ itkStaticConstMacro( FixedPointSetDimension, unsigned int, TFixedPointSet::PointDimension ); itkStaticConstMacro( MovingPointSetDimension, unsigned int, TMovingPointSet::PointDimension ); /** More typedefs. */ typedef AdvancedTransform< CoordinateRepresentationType, itkGetStaticConstMacro( FixedPointSetDimension ), itkGetStaticConstMacro( MovingPointSetDimension ) > TransformType; typedef typename TransformType::Pointer TransformPointer; typedef typename TransformType::InputPointType InputPointType; typedef typename TransformType::OutputPointType OutputPointType; typedef typename TransformType::ParametersType TransformParametersType; typedef typename TransformType::JacobianType TransformJacobianType; typedef SpatialObject< itkGetStaticConstMacro( FixedPointSetDimension )> FixedImageMaskType; typedef typename FixedImageMaskType::Pointer FixedImageMaskPointer; typedef typename FixedImageMaskType::ConstPointer FixedImageMaskConstPointer; typedef SpatialObject< itkGetStaticConstMacro( MovingPointSetDimension )> MovingImageMaskType; typedef typename MovingImageMaskType::Pointer MovingImageMaskPointer; typedef typename MovingImageMaskType::ConstPointer MovingImageMaskConstPointer; /** Type of the measure. */ typedef Superclass::MeasureType MeasureType; typedef Superclass::DerivativeType DerivativeType; typedef typename DerivativeType::ValueType DerivativeValueType; typedef Superclass::ParametersType ParametersType; /** Typedefs for support of sparse Jacobians and compact support of transformations. */ typedef typename TransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType; /** Connect the fixed pointset. */ itkSetConstObjectMacro( FixedPointSet, FixedPointSetType ); /** Get the fixed pointset. */ itkGetConstObjectMacro( FixedPointSet, FixedPointSetType ); /** Connect the moving pointset. */ itkSetConstObjectMacro( MovingPointSet, MovingPointSetType ); /** Get the moving pointset. */ itkGetConstObjectMacro( MovingPointSet, MovingPointSetType ); /** Connect the Transform. */ itkSetObjectMacro( Transform, TransformType ); /** Get a pointer to the Transform. */ itkGetConstObjectMacro( Transform, TransformType ); /** Set the parameters defining the Transform. */ void SetTransformParameters( const ParametersType & parameters ) const; /** Return the number of parameters required by the transform. */ unsigned int GetNumberOfParameters( void ) const { return this->m_Transform->GetNumberOfParameters(); } /** Initialize the Metric by making sure that all the components are * present and plugged together correctly. */ virtual void Initialize( void ) throw ( ExceptionObject ); /** Set the fixed mask. */ // \todo: currently not used itkSetConstObjectMacro( FixedImageMask, FixedImageMaskType ); /** Get the fixed mask. */ itkGetConstObjectMacro( FixedImageMask, FixedImageMaskType ); /** Set the moving mask. */ itkSetConstObjectMacro( MovingImageMask, MovingImageMaskType ); /** Get the moving mask. */ itkGetConstObjectMacro( MovingImageMask, MovingImageMaskType ); protected: SingleValuedPointSetToPointSetMetric(); virtual ~SingleValuedPointSetToPointSetMetric() {}; /** PrintSelf. */ void PrintSelf( std::ostream & os, Indent indent ) const; /** Member variables. */ FixedPointSetConstPointer m_FixedPointSet; MovingPointSetConstPointer m_MovingPointSet; FixedImageMaskConstPointer m_FixedImageMask; MovingImageMaskConstPointer m_MovingImageMask; mutable TransformPointer m_Transform; mutable unsigned int m_NumberOfPointsCounted; private: SingleValuedPointSetToPointSetMetric(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented }; // end class SingleValuedPointSetToPointSetMetric } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION #include "itkSingleValuedPointSetToPointSetMetric.txx" #endif #endif
[ [ [ 1, 178 ] ] ]
11eea561ccff1df36265af65f4b09c6f047c46c9
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/_Interface/WndQuizEvent.cpp
f77d3a7d1852a8d61cb50fd3b0333dcd6485fbbd
[]
no_license
willrebuild/flyffsf
e5911fb412221e00a20a6867fd00c55afca593c7
d38cc11790480d617b38bb5fc50729d676aef80d
refs/heads/master
2021-01-19T20:27:35.200154
2011-02-10T12:34:43
2011-02-10T12:34:43
32,710,780
3
0
null
null
null
null
UHC
C++
false
false
12,089
cpp
// WndQuizEvent.cpp: implementation of the CWndQuizEvent class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "WndQuizEvent.h" #ifdef __QUIZ #include "Quiz.h" #include "ResData.h" #include "defineText.h" #include "DPClient.h" extern CDPClient g_DPlay; ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CWndQuizEventConfirm::CWndQuizEventConfirm( BOOL bEnter ) :m_bEnter( bEnter ) { } CWndQuizEventConfirm::~CWndQuizEventConfirm() { } void CWndQuizEventConfirm::OnDraw( C2DRender* p2DRender ) { } BOOL CWndQuizEventConfirm::Initialize( CWndBase* pWndParent, DWORD nType ) { return CWndNeuz::InitDialog( g_Neuz.GetSafeHwnd(), APP_QUIZ_CONFIRM, 0, CPoint( 0, 0 ), pWndParent ); } void CWndQuizEventConfirm::OnInitialUpdate( void ) { CWndNeuz::OnInitialUpdate(); MoveParentCenter(); } BOOL CWndQuizEventConfirm::OnChildNotify( UINT message, UINT nID, LRESULT* pLResult ) { switch( nID ) { case WIDC_YES: { if( m_bEnter ) g_DPlay.SendQuizEventEntrance(); else g_DPlay.SendQuizEventTeleport( CQuiz::ZONE_EXIT ); Destroy(); break; } case WIDC_NO: { Destroy(); break; } } return CWndNeuz::OnChildNotify( message, nID, pLResult ); } void CWndQuizEventConfirm::SetString( const char* lpszMessage ) { CWndText* pWndText = (CWndText*)GetDlgItem( WIDC_TEXT1 ); pWndText->m_string.AddParsingString( lpszMessage ); pWndText->ResetString(); } ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CWndQuizEventQuestionOX::CWndQuizEventQuestionOX() { } CWndQuizEventQuestionOX::~CWndQuizEventQuestionOX() { } BOOL CWndQuizEventQuestionOX::Initialize( CWndBase* pWndParent, DWORD nType ) { return CWndNeuz::InitDialog( g_Neuz.GetSafeHwnd(), APP_QUIZ_QUESTION_OX, 0, CPoint( 0, 0 ), pWndParent ); } void CWndQuizEventQuestionOX::OnInitialUpdate( void ) { CWndNeuz::OnInitialUpdate(); CWndBase* pWndBase = (CWndBase*)g_WndMng.GetApplet( APP_INVENTORY ); if( pWndBase ) pWndBase->Destroy(); m_texChar.DeleteDeviceObjects(); m_texChar.LoadTexture( g_Neuz.m_pd3dDevice, MakePath( "char\\", "char_Juria_JAP.tga" ), 0xffff00ff, TRUE ); MoveParentCenter(); } BOOL CWndQuizEventQuestionOX::OnChildNotify( UINT message, UINT nID, LRESULT* pLResult ) { switch( nID ) { case WIDC_O: { if( CQuiz::GetInstance()->GetState() != CQuiz::QE_CORRECT_ANSWER && CQuiz::GetInstance()->GetState() != CQuiz::QE_DROP_OUT && CQuiz::GetInstance()->GetZoneType( g_pPlayer ) == CQuiz::ZONE_QUIZ ) g_DPlay.SendQuizEventTeleport( CQuiz::ZONE_1 ); else g_WndMng.PutString( prj.GetText( TID_GAME_QUIZ_DO_NOT_TELEPORT ), NULL, prj.GetTextColor( TID_GAME_QUIZ_DO_NOT_TELEPORT ) ); Destroy(); break; } case WIDC_X: { if( CQuiz::GetInstance()->GetState() != CQuiz::QE_CORRECT_ANSWER && CQuiz::GetInstance()->GetState() != CQuiz::QE_DROP_OUT && CQuiz::GetInstance()->GetZoneType( g_pPlayer ) == CQuiz::ZONE_QUIZ ) g_DPlay.SendQuizEventTeleport( CQuiz::ZONE_2 ); else g_WndMng.PutString( prj.GetText( TID_GAME_QUIZ_DO_NOT_TELEPORT ), NULL, prj.GetTextColor( TID_GAME_QUIZ_DO_NOT_TELEPORT ) ); Destroy(); break; } case WIDC_CLOSE: { Destroy(); break; } } return CWndNeuz::OnChildNotify( message, nID, pLResult ); } void CWndQuizEventQuestionOX::OnDraw( C2DRender* p2DRender ) { LPWNDCTRL lpWndCtrl = GetWndCtrl( WIDC_CUSTOM1 ); m_texChar.Render( p2DRender, lpWndCtrl->rect.TopLeft(), lpWndCtrl->rect.BottomRight() ); } void CWndQuizEventQuestionOX::UpdateQuestion( const char* lpszQuestion ) { CWndText* pText = (CWndText*)GetDlgItem( WIDC_TEXT1 ); if( lpszQuestion != NULL ) pText->SetString( lpszQuestion, 0xff000000 ); else pText->SetString( CQuiz::GetInstance()->m_strQuestion.c_str(), 0xff000000 ); } ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CWndQuizEventQuestion4C::CWndQuizEventQuestion4C() { } CWndQuizEventQuestion4C::~CWndQuizEventQuestion4C() { } BOOL CWndQuizEventQuestion4C::Initialize( CWndBase* pWndParent, DWORD nType ) { return CWndNeuz::InitDialog( g_Neuz.GetSafeHwnd(), APP_QUIZ_QUESTION_4C, 0, CPoint( 0, 0 ), pWndParent ); } void CWndQuizEventQuestion4C::OnInitialUpdate( void ) { CWndNeuz::OnInitialUpdate(); CWndBase* pWndBase = (CWndBase*)g_WndMng.GetApplet( APP_INVENTORY ); if( pWndBase ) pWndBase->Destroy(); m_texChar.DeleteDeviceObjects(); m_texChar.LoadTexture( g_Neuz.m_pd3dDevice, MakePath( "char\\", "char_Juria_JAP.tga" ), 0xffff00ff, TRUE ); MoveParentCenter(); } BOOL CWndQuizEventQuestion4C::OnChildNotify( UINT message, UINT nID, LRESULT* pLResult ) { switch( nID ) { case WIDC_NO1: { if( CQuiz::GetInstance()->GetState() != CQuiz::QE_CORRECT_ANSWER && CQuiz::GetInstance()->GetState() != CQuiz::QE_DROP_OUT && CQuiz::GetInstance()->GetZoneType( g_pPlayer ) == CQuiz::ZONE_QUIZ ) g_DPlay.SendQuizEventTeleport( CQuiz::ZONE_1 ); else g_WndMng.PutString( prj.GetText( TID_GAME_QUIZ_DO_NOT_TELEPORT ), NULL, prj.GetTextColor( TID_GAME_QUIZ_DO_NOT_TELEPORT ) ); Destroy(); break; } case WIDC_NO2: { if( CQuiz::GetInstance()->GetState() != CQuiz::QE_CORRECT_ANSWER && CQuiz::GetInstance()->GetState() != CQuiz::QE_DROP_OUT && CQuiz::GetInstance()->GetZoneType( g_pPlayer ) == CQuiz::ZONE_QUIZ ) g_DPlay.SendQuizEventTeleport( CQuiz::ZONE_2 ); else g_WndMng.PutString( prj.GetText( TID_GAME_QUIZ_DO_NOT_TELEPORT ), NULL, prj.GetTextColor( TID_GAME_QUIZ_DO_NOT_TELEPORT ) ); Destroy(); break; } case WIDC_NO3: { if( CQuiz::GetInstance()->GetState() != CQuiz::QE_CORRECT_ANSWER && CQuiz::GetInstance()->GetState() != CQuiz::QE_DROP_OUT && CQuiz::GetInstance()->GetZoneType( g_pPlayer ) == CQuiz::ZONE_QUIZ ) g_DPlay.SendQuizEventTeleport( CQuiz::ZONE_3 ); else g_WndMng.PutString( prj.GetText( TID_GAME_QUIZ_DO_NOT_TELEPORT ), NULL, prj.GetTextColor( TID_GAME_QUIZ_DO_NOT_TELEPORT ) ); Destroy(); break; } case WIDC_NO4: { if( CQuiz::GetInstance()->GetState() != CQuiz::QE_CORRECT_ANSWER && CQuiz::GetInstance()->GetState() != CQuiz::QE_DROP_OUT && CQuiz::GetInstance()->GetZoneType( g_pPlayer ) == CQuiz::ZONE_QUIZ ) g_DPlay.SendQuizEventTeleport( CQuiz::ZONE_4 ); else g_WndMng.PutString( prj.GetText( TID_GAME_QUIZ_DO_NOT_TELEPORT ), NULL, prj.GetTextColor( TID_GAME_QUIZ_DO_NOT_TELEPORT ) ); Destroy(); break; } case WIDC_CLOSE: { Destroy(); break; } } return CWndNeuz::OnChildNotify( message, nID, pLResult ); } void CWndQuizEventQuestion4C::OnDraw( C2DRender* p2DRender ) { LPWNDCTRL lpWndCtrl = GetWndCtrl( WIDC_CUSTOM1 ); m_texChar.Render( p2DRender, lpWndCtrl->rect.TopLeft(), lpWndCtrl->rect.BottomRight() ); } void CWndQuizEventQuestion4C::UpdateQuestion( const char* lpszQuestion ) { CWndText* pText = (CWndText*)GetDlgItem( WIDC_TEXT1 ); if( lpszQuestion != NULL ) pText->SetString( lpszQuestion, 0xff000000 ); else pText->SetString( CQuiz::GetInstance()->m_strQuestion.c_str(), 0xff000000 ); } ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CWndQuizEventButton::CWndQuizEventButton() { m_bLoadTexMap = FALSE; m_bFocus = FALSE; m_bPush = FALSE; m_ptPush.x = -1; m_ptPush.y = -1; m_nAlpha = 255; m_bReverse = TRUE; } CWndQuizEventButton::~CWndQuizEventButton() { } HRESULT CWndQuizEventButton::DeleteDeviceObjects() { m_BtnTexture.DeleteDeviceObjects(); return CWndNeuz::DeleteDeviceObjects(); } HRESULT CWndQuizEventButton::RestoreDeviceObjects() { m_BtnTexture.RestoreDeviceObjects(g_Neuz.m_pd3dDevice); return CWndNeuz::RestoreDeviceObjects(); } HRESULT CWndQuizEventButton::InvalidateDeviceObjects() { m_BtnTexture.InvalidateDeviceObjects(); return CWndNeuz::InvalidateDeviceObjects(); } void CWndQuizEventButton::OnInitialUpdate() { CWndNeuz::OnInitialUpdate(); // 여기에 코딩하세요 this->DelWndStyle(WBS_CAPTION); m_wndTitleBar.SetVisible( FALSE ); CRect rectRoot = m_pWndRoot->GetLayoutRect(); CRect rectWindow = GetWindowRect(); CPoint point; //point.x = rectRoot.right - rectWindow.Width() - 5; point.x = rectRoot.left + 10; point.y = rectRoot.top + rectWindow.Height() + 100; Move( point ); m_bLoadTexMap = m_BtnTexture.LoadScript( g_Neuz.m_pd3dDevice, MakePath( DIR_THEME, _T( "texMapQuizEventButton.inc" ) ) ); } void CWndQuizEventButton::PaintFrame( C2DRender* p2DRender ) { } void CWndQuizEventButton::OnLButtonDown( UINT nFlags, CPoint point ) { CRect rectWindow = GetWindowRect(); if(rectWindow.PtInRect(point)) { m_bPush = TRUE; ClientToScreen( &point ); m_ptPush = point; } else m_bPush = FALSE; } void CWndQuizEventButton::OnLButtonUp( UINT nFlags, CPoint point ) { CPoint ptScreen = point; ClientToScreen( &ptScreen ); if( m_ptPush == ptScreen ) { CRect rectWindow = GetWindowRect(); if( rectWindow.PtInRect( point ) ) { if( CQuiz::GetInstance()->GetType() == TYPE_OX ) { if( g_WndMng.m_pWndQuizEventQuestionOX ) { SAFE_DELETE( g_WndMng.m_pWndQuizEventQuestionOX ); } else { g_WndMng.m_pWndQuizEventQuestionOX = new CWndQuizEventQuestionOX; if( g_WndMng.m_pWndQuizEventQuestionOX ) { g_WndMng.m_pWndQuizEventQuestionOX->Initialize(); g_WndMng.m_pWndQuizEventQuestionOX->UpdateQuestion(); } } } else { if( g_WndMng.m_pWndQuizEventQuestion4C ) { SAFE_DELETE( g_WndMng.m_pWndQuizEventQuestion4C ); } else { g_WndMng.m_pWndQuizEventQuestion4C = new CWndQuizEventQuestion4C; if( g_WndMng.m_pWndQuizEventQuestion4C ) { g_WndMng.m_pWndQuizEventQuestion4C->Initialize(); g_WndMng.m_pWndQuizEventQuestion4C->UpdateQuestion(); } } } } } else { m_ptPush.x = -1; m_ptPush.y = -1; } m_bPush = FALSE; } BOOL CWndQuizEventButton::Process() { CPoint ptMouse = GetMousePoint(); CRect rectWindow = GetWindowRect(); if( rectWindow.PtInRect( ptMouse ) ) m_bFocus = TRUE; else m_bFocus = FALSE; if( m_bReverse ) m_nAlpha -= 5; else m_nAlpha += 5; if( m_nAlpha < 100 ) { m_bReverse = FALSE; m_nAlpha = 100; } else if( m_nAlpha > 255 ) { m_bReverse = TRUE; m_nAlpha = 255; } return TRUE; } BOOL CWndQuizEventButton::Initialize( CWndBase* pWndParent, DWORD /*dwWndId*/ ) { // Daisy에서 설정한 리소스로 윈도를 연다. return CWndNeuz::InitDialog( g_Neuz.GetSafeHwnd(), APP_QUIZ_BUTTON, WBS_NOFOCUS, CPoint( 0, 0 ), pWndParent ); } void CWndQuizEventButton::OnDraw( C2DRender* p2DRender ) { if( m_bLoadTexMap ) { int nTexNum = -1; BOOL bNormal = FALSE; CTexture* pTexture = NULL; if( CQuiz::GetInstance()->GetState() == CQuiz::QE_QUESTION ) { if( !m_bFocus && !m_bPush ) { nTexNum = 0; bNormal = TRUE; } else if( m_bFocus && !m_bPush ) nTexNum = 0; else if( m_bFocus && m_bPush ) nTexNum = 2; } else nTexNum = 2; if( nTexNum != -1 ) pTexture = m_BtnTexture.GetAt( nTexNum ); if( pTexture ) { if( bNormal ) pTexture->Render( &g_Neuz.m_2DRender, CPoint(0, 0), m_nAlpha ); else if( nTexNum == 0 || nTexNum == 2 ) pTexture->Render( &g_Neuz.m_2DRender, CPoint(0, 0) ); } } } #endif // __QUIZ
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 457 ] ] ]
fca50dfe0fd19cfa2f8958cdc753656de533536b
59166d9d1eea9b034ac331d9c5590362ab942a8f
/FrustumTerrain/GeometryPatch.h
e27ebbf5a041838ef0a6a60c36422a8b61d08146
[]
no_license
seafengl/osgtraining
5915f7b3a3c78334b9029ee58e6c1cb54de5c220
fbfb29e5ae8cab6fa13900e417b6cba3a8c559df
refs/heads/master
2020-04-09T07:32:31.981473
2010-09-03T15:10:30
2010-09-03T15:10:30
40,032,354
0
3
null
null
null
null
MacCyrillic
C++
false
false
823
h
#ifndef _GEOMETRY_PATCH_H_ #define _GEOMETRY_PATCH_H_ #include <osg/Geometry> #include <vector> class GeometryPatch { public: //x,y - смещение €чейки, sizeC - количество сегментов, scaleC - размер €чейки GeometryPatch( int x , int y , int sizeC , int scaleC ); ~GeometryPatch(); osg::ref_ptr< osg::Geometry > GetGeometry(){ return m_patchGeom.get(); }; private: //создать массив вершин osg::ref_ptr<osg::Vec3Array> CreateVertexArray( int x , int y , int sizeC , int scaleC ); //заполнить вектор индексами void FillIndexVector( std::vector< unsigned int > &_vIndex , int sizeC ); //геометри€ €чейки osg::ref_ptr< osg::Geometry > m_patchGeom; }; #endif //_GEOMETRY_PATCH_H_
[ "asmzx79@3290fc28-3049-11de-8daa-cfecb5f7ff5b" ]
[ [ [ 1, 28 ] ] ]
7d7b0fa614a863bfbbcf213a0eb6d1e481e9adec
e7c45d18fa1e4285e5227e5984e07c47f8867d1d
/Tests/TestMarshal/StdAfx.cpp
de9608dc6ee9b246ee62d392b0e1ddf77a396c29
[]
no_license
abcweizhuo/Test3
0f3379e528a543c0d43aad09489b2444a2e0f86d
128a4edcf9a93d36a45e5585b70dee75e4502db4
refs/heads/master
2021-01-17T01:59:39.357645
2008-08-20T00:00:29
2008-08-20T00:00:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
234
cpp
// stdafx.cpp : source file that includes just the standard includes // TestMarshal.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" CComModule _Module;
[ [ [ 1, 9 ] ] ]
9984db3c99569bc7b4b8ab2f886aa4c264a8220f
26fb9504d098f53b0bf9e0df714956dfba40add6
/trunk/SpellCheckerPlugin.cpp
45f77eef92a5afc5316f046b63f262de06eeb22a
[]
no_license
BackupTheBerlios/spellchecker-svn
13945c1bc9d6f205346502179d322450a62f2a39
878de58a49267e4fa953815ed561d3c8faf5ee01
refs/heads/master
2021-01-25T09:00:23.677616
2011-02-17T20:44:15
2011-02-17T20:44:15
40,772,632
0
0
null
null
null
null
UTF-8
C++
false
false
18,516
cpp
/* * This file is part of SpellChecker plugin for Code::Blocks Studio * Copyright (C) 2009 Daniel Anselmi * * SpellChecker plugin is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * SpellChecker plugin is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with SpellChecker. If not, see <http://www.gnu.org/licenses/>. * */ #include <sdk.h> // Code::Blocks SDK #ifndef CB_PRECOMP #include <configmanager.h> #include <cbeditor.h> #include <editormanager.h> #endif #include <configurationpanel.h> #include <editor_hooks.h> #include <cbstyledtextctrl.h> #ifdef wxUSE_STATUSBAR #include <cbstatusbar.h> #endif #include <wx/dir.h> #include "SpellCheckerPlugin.h" #include "SpellCheckSettingsPanel.h" #include "SpellCheckerConfig.h" #include "OnlineSpellChecker.h" #include "Thesaurus.h" #include "HunspellInterface.h" #include "SpellCheckHelper.h" #include "MySpellingDialog.h" #include "StatusField.h" #include "DictionariesNeededDialog.h" // Register the plugin with Code::Blocks. // We are using an anonymous namespace so we don't litter the global one. namespace { PluginRegistrant<SpellCheckerPlugin> reg(_T("SpellChecker")); const int idSpellCheck = wxNewId(); const int idThesaurus = wxNewId(); const unsigned int MaxSuggestEntries = 5; const int idSuggest[MaxSuggestEntries] = {wxNewId(), wxNewId(), wxNewId(), wxNewId(), wxNewId()}; const int idAddToDictionary = wxNewId(); const int idMoreSuggestions = wxNewId(); } // events handling BEGIN_EVENT_TABLE(SpellCheckerPlugin, cbPlugin) // add any events you want to handle here END_EVENT_TABLE() SpellCheckerPlugin::SpellCheckerPlugin(): m_pSpellChecker(NULL), m_pSpellingDialog(NULL), m_pSpellHelper(NULL), m_pOnlineChecker(NULL), m_pThesaurus(NULL), m_sccfg(NULL) #ifdef wxUSE_STATUSBAR ,m_fld(NULL) #endif { // Make sure our resources are available. // In the generated boilerplate code we have no resources but when // we add some, it will be nice that this code is in place already ;) if(!Manager::LoadResource(_T("SpellChecker.zip"))) { NotifyMissingFile(_T("SpellChecker.zip")); } } SpellCheckerPlugin::~SpellCheckerPlugin() { } void SpellCheckerPlugin::OnAttach() { // do whatever initialization you need for your plugin // NOTE: after this function, the inherited member variable // m_IsAttached will be TRUE... // You should check for it in other functions, because if it // is FALSE, it means that the application did *not* "load" // (see: does not need) this plugin... // load configuration m_sccfg = new SpellCheckerConfig(this); DictionariesNeededDialog dlg; if (m_sccfg->GetPossibleDictionaries().empty()) dlg.ShowModal(); //initialize spell checker if ( !m_pSpellingDialog ) m_pSpellingDialog = new MySpellingDialog( Manager::Get()->GetAppFrame() ); m_pSpellChecker = new HunspellInterface(m_pSpellingDialog); ConfigureHunspellSpellCheckEngine(); m_pSpellChecker->InitializeSpellCheckEngine(); // initialze Helper and online checker m_pSpellHelper = new SpellCheckHelper(); m_pOnlineChecker = new OnlineSpellChecker(m_pSpellChecker, m_pSpellHelper); m_FunctorId = EditorHooks::RegisterHook( m_pOnlineChecker ); m_pOnlineChecker->EnableOnlineChecks( m_sccfg->GetEnableOnlineChecker() ); // initialize thesaurus m_pThesaurus = new Thesaurus(Manager::Get()->GetAppFrame()); ConfigureThesaurus(); // connect events Connect(idSpellCheck, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SpellCheckerPlugin::OnSpelling)); Connect(idSpellCheck, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(SpellCheckerPlugin::OnUpdateSpelling)); for ( unsigned int i = 0 ; i < MaxSuggestEntries ; i++ ) Connect(idSuggest[i], wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SpellCheckerPlugin::OnReplaceBySuggestion), NULL, this); Connect(idMoreSuggestions, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SpellCheckerPlugin::OnMoreSuggestions)); Connect(idAddToDictionary, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SpellCheckerPlugin::OnAddToPersonalDictionary), NULL, this); Connect(idThesaurus, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SpellCheckerPlugin::OnThesaurus)); Connect(idThesaurus, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(SpellCheckerPlugin::OnUpdateThesaurus)); } #ifdef wxUSE_STATUSBAR void SpellCheckerPlugin::CreateStatusField(cbStatusBar *bar) { m_fld = new SpellCheckerStatusField(bar, m_sccfg); bar->AddField(this, m_fld, 60); } #endif void SpellCheckerPlugin::ConfigureThesaurus() { m_pThesaurus->SetFiles( m_sccfg->GetThesaurusPath() + wxFILE_SEP_PATH + _T("th_") + m_sccfg->GetDictionaryName() + _T(".idx"), m_sccfg->GetThesaurusPath() + wxFILE_SEP_PATH + _T("th_") + m_sccfg->GetDictionaryName() + _T(".dat") ); } wxString SpellCheckerPlugin::GetOnlineCheckerConfigPath() { return ConfigManager::GetDataFolder() + wxFileName::GetPathSeparator() + _T("SpellChecker") ; } void SpellCheckerPlugin::ConfigureHunspellSpellCheckEngine() { SpellCheckEngineOption DictionaryFileOption( _T("dict-file"), _T("Dictionary File"), m_sccfg->GetDictionaryPath() + wxFILE_SEP_PATH + m_sccfg->GetDictionaryName() + _T(".dic"), SpellCheckEngineOption::FILE ); m_pSpellChecker->AddOptionToMap(DictionaryFileOption); SpellCheckEngineOption AffixFileOption( _T("affix-file"), _T("Affix File"), m_sccfg->GetDictionaryPath() + wxFILE_SEP_PATH + m_sccfg->GetDictionaryName() + _T(".aff"), SpellCheckEngineOption::FILE ); m_pSpellChecker->AddOptionToMap(AffixFileOption); m_pSpellChecker->ApplyOptions(); ConfigurePersonalDictionary(); } void SpellCheckerPlugin::ConfigurePersonalDictionary() { // Set the personal dictionary file HunspellInterface *hsi = dynamic_cast<HunspellInterface *>(m_pSpellChecker); if (hsi) { wxString dfile = ConfigManager::LocateDataFile(m_sccfg->GetDictionaryName() + _T("_personaldictionary.dic"), sdConfig ); if (dfile == _T("")) dfile = ConfigManager::GetFolder(sdConfig) + wxFILE_SEP_PATH + m_sccfg->GetDictionaryName() + _T("_personaldictionary.dic"); hsi->OpenPersonalDictionary(dfile); } } void SpellCheckerPlugin::OnRelease(bool appShutDown) { // do de-initialization for your plugin // if appShutDown is true, the plugin is unloaded because Code::Blocks is being shut down, // which means you must not use any of the SDK Managers // NOTE: after this function, the inherited member variable // m_IsAttached will be FALSE... EditorHooks::UnregisterHook(m_FunctorId); SavePersonalDictionary(); m_pSpellChecker->UninitializeSpellCheckEngine(); delete m_pSpellChecker; m_pSpellChecker = NULL; delete m_pSpellHelper; m_pSpellHelper = NULL; //delete m_pOnlineChecker; m_pOnlineChecker = NULL; if ( m_pThesaurus ) delete m_pThesaurus; m_pThesaurus = NULL; if ( m_sccfg ) delete m_sccfg; m_sccfg = NULL; Disconnect(idSpellCheck, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SpellCheckerPlugin::OnSpelling)); Disconnect(idSpellCheck, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(SpellCheckerPlugin::OnUpdateSpelling) ); for ( unsigned int i = 0 ; i < MaxSuggestEntries ; i++ ) Disconnect(idSuggest[i], wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SpellCheckerPlugin::OnReplaceBySuggestion), NULL, this); Disconnect(idMoreSuggestions, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SpellCheckerPlugin::OnMoreSuggestions)); Disconnect(idAddToDictionary, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SpellCheckerPlugin::OnAddToPersonalDictionary), NULL, this); Disconnect(idThesaurus, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SpellCheckerPlugin::OnThesaurus)); Disconnect(idThesaurus, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(SpellCheckerPlugin::OnUpdateThesaurus)); } void SpellCheckerPlugin::SavePersonalDictionary() { HunspellInterface *hsi = dynamic_cast<HunspellInterface *>(m_pSpellChecker); if (hsi) hsi->GetPersonalDictionary()->SavePersonalDictionary(); } int SpellCheckerPlugin::Configure() { //create and display the configuration dialog for your plugin cbConfigurationDialog dlg(Manager::Get()->GetAppWindow(), wxID_ANY, _("Your dialog title")); cbConfigurationPanel* panel = GetConfigurationPanel(&dlg); if (panel) { dlg.AttachConfigurationPanel(panel); PlaceWindow(&dlg); return dlg.ShowModal() == wxID_OK ? 0 : -1; } return -1; } void SpellCheckerPlugin::BuildMenu(wxMenuBar* menuBar) { //NOTE: Be careful in here... The application's menubar is at your disposal. // if not attached, exit if (!IsAttached()) return; // insert entry in the View menu int EditPos = menuBar->FindMenu(_("&Edit")); if (EditPos != wxNOT_FOUND) { // just append wxMenu* EditMenu = menuBar->GetMenu(EditPos); EditMenu->AppendSeparator(); EditMenu->Append(idSpellCheck, _T("Spelling..."), _T("Spell check the selected text")); EditMenu->Append(idThesaurus, _T("Thesaurus..."), _T("")); } } void SpellCheckerPlugin::BuildModuleMenu(const ModuleType type, wxMenu* menu, const FileTreeData* data) { //Some library module is ready to display a pop-up menu. //Check the parameter \"type\" and see which module it is //and append any items you need in the menu... //TIP: for consistency, add a separator as the first item... if ( !IsAttached() ) return; if(type != mtEditorManager || !menu ) return; cbEditor *ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor(); if ( !ed ) return; cbStyledTextCtrl *stc = ed->GetControl(); if ( !stc ) return; int pos = stc->GetCurrentPos(); stc->GetIndicatorValue(); m_wordstart= -1; m_wordend = -1; m_suggestions.Empty(); //Manager::Get()->GetLogManager()->Log( wxString::Format(_T("SpellChecker indicator: %d"), indic) ); if ( !stc->GetSelectedText().IsEmpty() ) { menu->AppendSeparator(); menu->Append(idSpellCheck, _T("Spelling...")); } else if ( stc->IndicatorValueAt( m_pOnlineChecker->GetIndicator(), pos) ) { // indicator is on -> check if we can find a suggestion or show that there are no suggestions menu->AppendSeparator(); wxString misspelledWord; int wordstart = pos, wordend = pos; while ( wordstart ) { if ( m_pSpellHelper->IsWhiteSpace( stc->GetCharAt(wordstart-1) ) ) break; wordstart--; } while ( wordend < stc->GetLength() ) { if ( m_pSpellHelper->IsWhiteSpace( stc->GetCharAt(++wordend) ) ) break; } misspelledWord = stc->GetTextRange(wordstart, wordend); m_wordstart = wordstart; m_wordend = wordend; m_suggestions = m_pSpellChecker->GetSuggestions( misspelledWord ); if ( m_suggestions.size() ) { wxMenu *SuggestionsMenu = new wxMenu(); for ( unsigned int i = 0 ; i < MaxSuggestEntries && i < m_suggestions.size() ; i++ ) SuggestionsMenu->Append(idSuggest[i], m_suggestions[i] ); SuggestionsMenu->AppendSeparator(); if ( m_suggestions.size() > MaxSuggestEntries ) SuggestionsMenu->Append(idMoreSuggestions, _("more...")); SuggestionsMenu->Append(idAddToDictionary, _T("Add '") + misspelledWord + _T("' to dictionary")); menu->AppendSubMenu(SuggestionsMenu, _("Spelling suggestions for '") + misspelledWord + _T("'") ); } else { //menu->Append(idMoreSuggestions, _T("No spelling suggestions for '") + misspelledWord + _T("'"))->Enable(false); menu->Append(idAddToDictionary, _T("Add '") + misspelledWord + _T("' to dictionary")); } } } bool SpellCheckerPlugin::BuildToolBar(wxToolBar* toolBar) { //The application is offering its toolbar for your plugin, //to add any toolbar items you want... //Append any items you need on the toolbar... //NotImplemented(_T("SpellChecker::BuildToolBar()")); // return true if you add toolbar items return false; } void SpellCheckerPlugin::OnSpelling(wxCommandEvent &event) { cbEditor *ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor(); if ( !ed ) return; cbStyledTextCtrl *stc = ed->GetControl(); if ( !stc ) return; PlaceWindow(m_pSpellingDialog, pdlBest, true); stc->ReplaceSelection(m_pSpellChecker->CheckSpelling(stc->GetSelectedText())); } void SpellCheckerPlugin::OnUpdateSpelling(wxUpdateUIEvent &event) { cbEditor *ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor(); if ( ed ) { cbStyledTextCtrl *stc = ed->GetControl(); if ( stc ) { wxString str = stc->GetSelectedText(); if ( !str.IsEmpty() ) { event.Enable(true); return; } } } event.Enable(false); } void SpellCheckerPlugin::OnThesaurus(wxCommandEvent &event) { cbEditor *ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor(); if ( !ed ) return; cbStyledTextCtrl *stc = ed->GetControl(); if ( !stc ) return; // take only the first word from the selection int selstart = stc->GetSelectionStart(); while ( selstart < stc->GetLength() ) { if ( !m_pSpellHelper->IsWhiteSpace( stc->GetCharAt(selstart) )) break; selstart++; } int selend = selstart; while ( selend < stc->GetLength() ) { if ( m_pSpellHelper->IsWhiteSpace( stc->GetCharAt(++selend) ) ) break; } wxString word = stc->GetTextRange(selstart, selend); if ( word.IsEmpty() ) return; wxString Synonym; bool hasEntry = m_pThesaurus->GetSynonym(word, Synonym); if ( hasEntry ) { if ( !Synonym.IsEmpty() ) { stc->SetSelectionVoid(selstart, selend); stc->ReplaceSelection(Synonym); } } else { AnnoyingDialog dlg(_T("Thesaurus"), _T("No entry found!"), wxART_INFORMATION, AnnoyingDialog::OK); dlg.ShowModal(); } } void SpellCheckerPlugin::OnUpdateThesaurus(wxUpdateUIEvent &event) { cbEditor *ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor(); if ( ed && m_pThesaurus->IsOk() ) { cbStyledTextCtrl *stc = ed->GetControl(); if ( stc ) { wxString str = stc->GetSelectedText(); if ( !str.IsEmpty() ) { event.Enable(true); return; } } } event.Enable(false); } void SpellCheckerPlugin::OnReplaceBySuggestion(wxCommandEvent &event) { if ( m_wordstart == -1 || m_wordend == -1 ) return; cbEditor *ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor(); if ( ed ) { cbStyledTextCtrl *stc = ed->GetControl(); if ( stc ) { for ( unsigned int i = 0 ; i < MaxSuggestEntries ; i++) { if ( idSuggest[i] == event.GetId() ) { stc->SetAnchor(m_wordstart); stc->SetCurrentPos(m_wordend); stc->ReplaceSelection(m_suggestions[i]); break; } } } } m_wordend = -1; m_wordstart = -1; m_suggestions.Empty(); } void SpellCheckerPlugin::OnMoreSuggestions(wxCommandEvent &event) { if ( m_wordstart == -1 || m_wordend == -1 ) return; cbEditor *ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor(); if ( ed ) { cbStyledTextCtrl *stc = ed->GetControl(); if ( stc ) { stc->SetAnchor(m_wordstart); stc->SetCurrentPos(m_wordend); PlaceWindow(m_pSpellingDialog, pdlBest, true); stc->ReplaceSelection(m_pSpellChecker->CheckSpelling(stc->GetSelectedText())); } } m_wordend = -1; m_wordstart = -1; m_suggestions.Empty(); } void SpellCheckerPlugin::ReloadSettings() { SavePersonalDictionary(); ConfigureHunspellSpellCheckEngine(); m_pOnlineChecker->EnableOnlineChecks(m_sccfg->GetEnableOnlineChecker()); ConfigureThesaurus(); #ifdef wxUSE_STATUSBAR if (m_fld) m_fld->Update(); #endif } cbConfigurationPanel *SpellCheckerPlugin::GetConfigurationPanel(wxWindow* parent) { return new SpellCheckSettingsPanel(parent, m_sccfg); } void SpellCheckerPlugin::OnAddToPersonalDictionary(wxCommandEvent &event) { if ( m_wordstart == -1 || m_wordend == -1 ) return; cbEditor *ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor(); if ( ed ) { cbStyledTextCtrl *stc = ed->GetControl(); if ( stc ) { stc->SetAnchor(m_wordstart); stc->SetCurrentPos(m_wordend); m_pSpellChecker->AddWordToDictionary(stc->GetSelectedText()); } } m_wordend = -1; m_wordstart = -1; m_suggestions.Empty(); if ( ed ) { m_pOnlineChecker->OnEditorChange(ed); m_pOnlineChecker->DoSetIndications(ed); } }
[ "danselmi@28f1e1e6-8c73-0410-a366-f7722952968d" ]
[ [ [ 1, 515 ] ] ]
6eb2757da9cbd19d3f5ee69ad74cc4a6d3e68db5
97f1be9ac088e1c9d3fd73d76c63fc2c4e28749a
/3dc/avp/win95/MouseCentreing.cpp
bcd52cdb50c191482faa150a11ad3cd04da244c7
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
SR-dude/AvP-Wine
2875f7fd6b7914d03d7f58e8f0ec4793f971ad23
41a9c69a45aacc2c345570ba0e37ec3dc89f4efa
refs/heads/master
2021-01-23T02:54:33.593334
2011-09-17T11:10:07
2011-09-17T11:10:07
2,375,686
1
0
null
null
null
null
UTF-8
C++
false
false
712
cpp
#include <windows.h> #include <process.h> #include <math.h> extern "C" { extern BOOL bActive; extern int WinLeftX, WinRightX, WinTopY, WinBotY; } static volatile int EndMouseThread=0; //thread continually moves the mouse cursor to the centre of the window //so you don't accidently click outside it. void MouseThread(void* ) { while(!EndMouseThread) { Sleep(10); if(!bActive) continue; SetCursorPos((WinLeftX+WinRightX)>>1,(WinTopY+WinBotY)>>1); } EndMouseThread=0; } extern "C" { void InitCentreMouseThread() { _beginthread(MouseThread,10000,0); } void FinishCentreMouseThread() { EndMouseThread=1; } };
[ "a_jagers@ANTHONYJ.(none)" ]
[ [ [ 1, 57 ] ] ]
9a05e9963d05db3f83649891354e432d668b3885
de75637338706776f8770c9cd169761cec128579
/Out-Of-Date/Source/game.h
45cddba0cdbfd4f5beaa0e22df72a34407ac1d40
[]
no_license
huytd/fosengine
e018957abb7b2ea2c4908167ec83cb459c3de716
1cebb1bec49720a8e9ecae1c3d0c92e8d16c27c5
refs/heads/master
2021-01-18T23:47:32.402023
2008-07-12T07:20:10
2008-07-12T07:20:10
38,933,821
0
0
null
null
null
null
UTF-8
C++
false
false
4,739
h
/** * \Summary: Game manager content * \Filename: game.h * \Encoding: UTF-8 * \Tabsize: 8 * \Indentation: 4 * \CreatedDate: 18:33 2008/05/26 * \InitializedBy: Irrlicht Forum - randomMesh * \CreatedBy: FOSP Team * \Copyright: FOS Project */ #ifndef GAME_H_ #define GAME_H_ #include "Irrlicht.h" #include <IrrlichtDevice.h> #include "CGUITexturedSkin.h" #ifdef _SOUND #include <irrKlang.h> #endif #include "StateManager.h" #include "Configuration.h" #include "shadermaterial.h" #include "shadergroup.h" class GameObject; //! these macros will return the scaled value based on current screen size //! (i assume 1024x768 is the normal res) to provide a resolution independent gui. #define SX(val) ( (irr::s32)(game->getVideoDriver()->getScreenSize().Width*(irr::f32)(val)/1024.0f) ) #define SY(val) ( (irr::s32)(game->getVideoDriver()->getScreenSize().Height*(irr::f32)(val)/768.0f) ) class Game : public irr::IEventReceiver, public StateManager<Game, irr::SEvent> { private: //! A reference to the configuration object created in the Application object. Configuration& configuration; //! A pointer to the Irrlicht device. irr::IrrlichtDevice* device; //! A pointer to the Irrlicht scene manager. irr::scene::ISceneManager* sceneManager; //! A pointer to the Irrlicht video driver. irr::video::IVideoDriver* videoDriver; //! A pointer to the Irrlicht gui environment. irr::gui::IGUIEnvironment* guiEnvironment; #ifdef _SOUND //! A pointer to the irrKlang sound engine. irrklang::ISoundEngine* soundEngine; #endif //! Default font. irr::gui::IGUIFont* font; //! Timer irr::ITimer* timer; irr::u32 then; irr::u32 now; irr::f32 elapsed; //! Defines a state for the state machine. struct SState { SState(const irr::c8* name = 0, State<Game, irr::SEvent>* state = 0) : name(name), State(state) { } bool operator<(const SState& other) const { return strcmp(name, other.name) < 0; } const irr::c8* name; State<Game, irr::SEvent>* State; }; //! Holds all game states. irr::core::array<SState> gameStates; //! The irrlicht camera. All states use this one. You can call it 'the global camera'. irr::scene::ICameraSceneNode* camera; //! TODO : Delele this unuse variable irr::u32 playerHealth; irr::f32 playerRotation; public: Game(Configuration& configuration, irr::IrrlichtDevice* device #ifdef _SOUND , irrklang::ISoundEngine* soundEngine #endif ); ~Game(); //! Adapt irrlicht event handling to ours. bool OnEvent(const irr::SEvent& event) { return onEvent(event); } const void addGameState(const char* name, State<Game, irr::SEvent>* state); /** * Finds a game state by its name. * \return The game state. 0 if no such game state exits. */ State<Game, irr::SEvent>* findGameState(const char* name); //! \return The Configuration object. inline Configuration& getConfiguration() const { return this->configuration; } //! \return The Irrlicht device. inline irr::IrrlichtDevice* getDevice() const { return this->device; } //! \return The Irrlicht scene manager. inline irr::scene::ISceneManager* getSceneManager() const { return this->sceneManager; } //! \return The Irrlicht gui environment. inline irr::gui::IGUIEnvironment* getGuiEnvironment() const { return this->guiEnvironment; } //! \return The Irrlicht video driver. inline irr::video::IVideoDriver* getVideoDriver() const { return this->videoDriver; } #ifdef _SOUND //! \return A pointer to the irrKlang engine. inline irrklang::ISoundEngine* getSoundEngine() const { return this->soundEngine; } #endif inline irr::scene::ICameraSceneNode* getCamera() const { return this->camera; } inline irr::u32 getPlayerHealth() const { return this->playerHealth; } inline irr::f32 getPlayerRotation() const { return this->playerRotation; } inline void setPlayerRotation(const irr::f32 newRotation) { if (newRotation <= 0) { //! die return; } this->playerRotation = newRotation; } inline void setPlayerHealth(const irr::u32 newHealth) { if (newHealth <= 0) { //! die return; } this->playerHealth = newHealth; } inline const bool isRunning() const { return this->device->run(); } const void tick(); inline const irr::f32 getElapsed() const { return this->elapsed; } const void makeScreenshot() const; const void setFont(const irr::c8* filename); //! Does what the name says. irr::video::ITexture* scaleTexture(irr::video::ITexture* SrcTexture, const irr::core::dimension2di& destSize); }; #endif /*GAME_H_*/
[ "doqkhanh@52f955dd-904d-0410-b1ed-9fe3d3cbfe06" ]
[ [ [ 1, 188 ] ] ]
d2f5ed6d5431ecbb0fe6bdd55c315f8cdb7c1062
fcdddf0f27e52ece3f594c14fd47d1123f4ac863
/terralib/src/qwt/qwt_scale_div.cpp
5967ee53e62448c4993384bb27a035d5c7038965
[]
no_license
radtek/terra-printer
32a2568b1e92cb5a0495c651d7048db6b2bbc8e5
959241e52562128d196ccb806b51fda17d7342ae
refs/heads/master
2020-06-11T01:49:15.043478
2011-12-12T13:31:19
2011-12-12T13:31:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,356
cpp
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** * Qwt Widget Library * Copyright (C) 1997 Josef Wilgen * Copyright (C) 2002 Uwe Rathmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the Qwt License, Version 1.0 *****************************************************************************/ #include "qwt_scale_div.h" #include "qwt_math.h" #include "qwt_double_interval.h" //! Construct an invalid QwtScaleDiv instance. QwtScaleDiv::QwtScaleDiv(): d_lBound(0.0), d_hBound(0.0), d_isValid(false) { } /*! Construct QwtScaleDiv instance. \param interval Interval \param ticks List of major, medium and minor ticks */ QwtScaleDiv::QwtScaleDiv( const QwtDoubleInterval &interval, QwtTickList ticks[NTickTypes]): d_lBound(interval.minValue()), d_hBound(interval.maxValue()), d_isValid(true) { for ( int i = 0; i < NTickTypes; i++ ) d_ticks[i] = ticks[i]; } /*! Construct QwtScaleDiv instance. \param lBound First interval limit \param hBound Second interval limit \param ticks List of major, medium and minor ticks */ QwtScaleDiv::QwtScaleDiv( double lBound, double hBound, QwtTickList ticks[NTickTypes]): d_lBound(lBound), d_hBound(hBound), d_isValid(true) { for ( int i = 0; i < NTickTypes; i++ ) d_ticks[i] = ticks[i]; } /*! \brief Equality operator \return true if this instance is equal to other */ int QwtScaleDiv::operator==(const QwtScaleDiv &other) const { if ( d_lBound != other.d_lBound || d_hBound != other.d_hBound || d_isValid != other.d_isValid ) { return false; } for ( int i = 0; i < NTickTypes; i++ ) { if ( d_ticks[i] != other.d_ticks[i] ) return false; } return true; } /*! \brief Inequality \return true if this instance is not equal to s */ int QwtScaleDiv::operator!=(const QwtScaleDiv &s) const { return (!(*this == s)); } //! Invalidate the scale division void QwtScaleDiv::invalidate() { d_isValid = false; // detach arrays for ( int i = 0; i < NTickTypes; i++ ) d_ticks[i].clear(); d_lBound = d_hBound = 0; } //! Check if the scale division is valid bool QwtScaleDiv::isValid() const { return d_isValid; } bool QwtScaleDiv::contains(double v) const { if ( !d_isValid ) return false; const double min = qwtMin(d_lBound, d_hBound); const double max = qwtMax(d_lBound, d_hBound); return v >= min && v <= max; } //! Invert the scale divison void QwtScaleDiv::invert() { qSwap(d_lBound, d_hBound); for ( int i = 0; i < NTickTypes; i++ ) { QwtTickList& ticks = d_ticks[i]; const int size = ticks.count(); const int size2 = size / 2; for (int i=0; i < size2; i++) qSwap(ticks[i], ticks[size - 1 - i]); } } /*! Return a list of ticks \param type MinorTick, MediumTick or MajorTick */ const QwtTickList &QwtScaleDiv::ticks(int type) const { if ( type >= 0 || type < NTickTypes ) return d_ticks[type]; static QwtTickList noTicks; return noTicks; }
[ "[email protected]@58180da6-ba8b-8960-36a5-00cc02a3ddec" ]
[ [ [ 1, 146 ] ] ]
14a32cd7a8d27f2d3c2fd3e29e856e6d352a4a35
10c14a95421b63a71c7c99adf73e305608c391bf
/gui/core/qrect.h
9416d56f82ae889614fdfce5c443d7787fa64b60
[]
no_license
eaglezzb/wtlcontrols
73fccea541c6ef1f6db5600f5f7349f5c5236daa
61b7fce28df1efe4a1d90c0678ec863b1fd7c81c
refs/heads/master
2021-01-22T13:47:19.456110
2009-05-19T10:58:42
2009-05-19T10:58:42
33,811,815
0
0
null
null
null
null
UTF-8
C++
false
false
23,162
h
/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information ([email protected]) ** ** This file is part of the QtCore module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Commercial License Agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at [email protected]. ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QRECT_H #define QRECT_H // #include <QtCore/qsize.h> // #include <QtCore/qpoint.h> #include "core/qsize.h" #include "core/qpoint.h" #ifdef topLeft #error qrect.h must be included before any header file that defines topLeft #endif QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Gui) class Q_GUI_EXPORT QRect { public: QRect() { x1 = y1 = 0; x2 = y2 = -1; } QRect(const QPoint &topleft, const QPoint &bottomright); QRect(const QPoint &topleft, const QSize &size); QRect(int left, int top, int width, int height); bool isNull() const; bool isEmpty() const; bool isValid() const; int left() const; int top() const; int right() const; int bottom() const; QRect normalized() const; #ifdef QT3_SUPPORT QT3_SUPPORT int &rLeft() { return x1; } QT3_SUPPORT int &rTop() { return y1; } QT3_SUPPORT int &rRight() { return x2; } QT3_SUPPORT int &rBottom() { return y2; } QT3_SUPPORT QRect normalize() const { return normalized(); } #endif int x() const; int y() const; void setLeft(int pos); void setTop(int pos); void setRight(int pos); void setBottom(int pos); void setX(int x); void setY(int y); void setTopLeft(const QPoint &p); void setBottomRight(const QPoint &p); void setTopRight(const QPoint &p); void setBottomLeft(const QPoint &p); QPoint topLeft() const; QPoint bottomRight() const; QPoint topRight() const; QPoint bottomLeft() const; QPoint center() const; void moveLeft(int pos); void moveTop(int pos); void moveRight(int pos); void moveBottom(int pos); void moveTopLeft(const QPoint &p); void moveBottomRight(const QPoint &p); void moveTopRight(const QPoint &p); void moveBottomLeft(const QPoint &p); void moveCenter(const QPoint &p); inline void translate(int dx, int dy); inline void translate(const QPoint &p); inline QRect translated(int dx, int dy) const; inline QRect translated(const QPoint &p) const; void moveTo(int x, int t); void moveTo(const QPoint &p); #ifdef QT3_SUPPORT QT3_SUPPORT void moveBy(int dx, int dy) { translate(dx, dy); } QT3_SUPPORT void moveBy(const QPoint &p) { translate(p); } #endif void setRect(int x, int y, int w, int h); inline void getRect(int *x, int *y, int *w, int *h) const; void setCoords(int x1, int y1, int x2, int y2); #ifdef QT3_SUPPORT QT3_SUPPORT void addCoords(int x1, int y1, int x2, int y2); #endif inline void getCoords(int *x1, int *y1, int *x2, int *y2) const; inline void adjust(int x1, int y1, int x2, int y2); inline QRect adjusted(int x1, int y1, int x2, int y2) const; QSize size() const; int width() const; int height() const; void setWidth(int w); void setHeight(int h); void setSize(const QSize &s); QRect operator|(const QRect &r) const; QRect operator&(const QRect &r) const; QRect& operator|=(const QRect &r); QRect& operator&=(const QRect &r); bool contains(const QPoint &p, bool proper=false) const; bool contains(int x, int y) const; // inline methods, _don't_ merge these bool contains(int x, int y, bool proper) const; bool contains(const QRect &r, bool proper = false) const; QRect unite(const QRect &r) const; // ### Qt 5: make QT4_SUPPORT QRect united(const QRect &other) const; QRect intersect(const QRect &r) const; // ### Qt 5: make QT4_SUPPORT QRect intersected(const QRect &other) const; bool intersects(const QRect &r) const; friend Q_GUI_EXPORT_INLINE bool operator==(const QRect &, const QRect &); friend Q_GUI_EXPORT_INLINE bool operator!=(const QRect &, const QRect &); #ifdef QT3_SUPPORT inline QT3_SUPPORT void rect(int *x, int *y, int *w, int *h) const { getRect(x, y, w, h); } inline QT3_SUPPORT void coords(int *ax1, int *ay1, int *ax2, int *ay2) const { getCoords(ax1, ay1, ax2, ay2); } #endif private: #if defined(Q_WS_X11) friend void qt_setCoords(QRect *r, int xp1, int yp1, int xp2, int yp2); #endif // ### Qt 5; remove the ifdef and just have the same order on all platforms. #if defined(Q_OS_MAC) int y1; int x1; int y2; int x2; #else int x1; int y1; int x2; int y2; #endif }; Q_DECLARE_TYPEINFO(QRect, Q_MOVABLE_TYPE); Q_GUI_EXPORT_INLINE bool operator==(const QRect &, const QRect &); Q_GUI_EXPORT_INLINE bool operator!=(const QRect &, const QRect &); /***************************************************************************** QRect stream functions *****************************************************************************/ // #ifndef QT_NO_DATASTREAM // Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QRect &); // Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QRect &); // #endif /***************************************************************************** QRect inline member functions *****************************************************************************/ inline QRect::QRect(int aleft, int atop, int awidth, int aheight) { x1 = aleft; y1 = atop; x2 = (aleft + awidth - 1); y2 = (atop + aheight - 1); } inline QRect::QRect(const QPoint &atopLeft, const QPoint &abottomRight) { x1 = atopLeft.x(); y1 = atopLeft.y(); x2 = abottomRight.x(); y2 = abottomRight.y(); } inline QRect::QRect(const QPoint &atopLeft, const QSize &asize) { x1 = atopLeft.x(); y1 = atopLeft.y(); x2 = (x1+asize.width() - 1); y2 = (y1+asize.height() - 1); } inline bool QRect::isNull() const { return x2 == x1 - 1 && y2 == y1 - 1; } inline bool QRect::isEmpty() const { return x1 > x2 || y1 > y2; } inline bool QRect::isValid() const { return x1 <= x2 && y1 <= y2; } inline int QRect::left() const { return x1; } inline int QRect::top() const { return y1; } inline int QRect::right() const { return x2; } inline int QRect::bottom() const { return y2; } inline int QRect::x() const { return x1; } inline int QRect::y() const { return y1; } inline void QRect::setLeft(int pos) { x1 = pos; } inline void QRect::setTop(int pos) { y1 = pos; } inline void QRect::setRight(int pos) { x2 = pos; } inline void QRect::setBottom(int pos) { y2 = pos; } inline void QRect::setTopLeft(const QPoint &p) { x1 = p.x(); y1 = p.y(); } inline void QRect::setBottomRight(const QPoint &p) { x2 = p.x(); y2 = p.y(); } inline void QRect::setTopRight(const QPoint &p) { x2 = p.x(); y1 = p.y(); } inline void QRect::setBottomLeft(const QPoint &p) { x1 = p.x(); y2 = p.y(); } inline void QRect::setX(int ax) { x1 = ax; } inline void QRect::setY(int ay) { y1 = ay; } inline QPoint QRect::topLeft() const { return QPoint(x1, y1); } inline QPoint QRect::bottomRight() const { return QPoint(x2, y2); } inline QPoint QRect::topRight() const { return QPoint(x2, y1); } inline QPoint QRect::bottomLeft() const { return QPoint(x1, y2); } inline QPoint QRect::center() const { return QPoint((x1+x2)/2, (y1+y2)/2); } inline int QRect::width() const { return x2 - x1 + 1; } inline int QRect::height() const { return y2 - y1 + 1; } inline QSize QRect::size() const { return QSize(width(), height()); } inline void QRect::translate(int dx, int dy) { x1 += dx; y1 += dy; x2 += dx; y2 += dy; } inline void QRect::translate(const QPoint &p) { x1 += p.x(); y1 += p.y(); x2 += p.x(); y2 += p.y(); } inline QRect QRect::translated(int dx, int dy) const { return QRect(QPoint(x1 + dx, y1 + dy), QPoint(x2 + dx, y2 + dy)); } inline QRect QRect::translated(const QPoint &p) const { return QRect(QPoint(x1 + p.x(), y1 + p.y()), QPoint(x2 + p.x(), y2 + p.y())); } inline void QRect::moveTo(int ax, int ay) { x2 += ax - x1; y2 += ay - y1; x1 = ax; y1 = ay; } inline void QRect::moveTo(const QPoint &p) { x2 += p.x() - x1; y2 += p.y() - y1; x1 = p.x(); y1 = p.y(); } inline void QRect::moveLeft(int pos) { x2 += (pos - x1); x1 = pos; } inline void QRect::moveTop(int pos) { y2 += (pos - y1); y1 = pos; } inline void QRect::moveRight(int pos) { x1 += (pos - x2); x2 = pos; } inline void QRect::moveBottom(int pos) { y1 += (pos - y2); y2 = pos; } inline void QRect::moveTopLeft(const QPoint &p) { moveLeft(p.x()); moveTop(p.y()); } inline void QRect::moveBottomRight(const QPoint &p) { moveRight(p.x()); moveBottom(p.y()); } inline void QRect::moveTopRight(const QPoint &p) { moveRight(p.x()); moveTop(p.y()); } inline void QRect::moveBottomLeft(const QPoint &p) { moveLeft(p.x()); moveBottom(p.y()); } inline void QRect::getRect(int *ax, int *ay, int *aw, int *ah) const { *ax = x1; *ay = y1; *aw = x2 - x1 + 1; *ah = y2 - y1 + 1; } inline void QRect::setRect(int ax, int ay, int aw, int ah) { x1 = ax; y1 = ay; x2 = (ax + aw - 1); y2 = (ay + ah - 1); } inline void QRect::getCoords(int *xp1, int *yp1, int *xp2, int *yp2) const { *xp1 = x1; *yp1 = y1; *xp2 = x2; *yp2 = y2; } inline void QRect::setCoords(int xp1, int yp1, int xp2, int yp2) { x1 = xp1; y1 = yp1; x2 = xp2; y2 = yp2; } #ifdef QT3_SUPPORT inline void QRect::addCoords(int dx1, int dy1, int dx2, int dy2) { adjust(dx1, dy1, dx2, dy2); } #endif inline QRect QRect::adjusted(int xp1, int yp1, int xp2, int yp2) const { return QRect(QPoint(x1 + xp1, y1 + yp1), QPoint(x2 + xp2, y2 + yp2)); } inline void QRect::adjust(int dx1, int dy1, int dx2, int dy2) { x1 += dx1; y1 += dy1; x2 += dx2; y2 += dy2; } inline void QRect::setWidth(int w) { x2 = (x1 + w - 1); } inline void QRect::setHeight(int h) { y2 = (y1 + h - 1); } inline void QRect::setSize(const QSize &s) { x2 = (s.width() + x1 - 1); y2 = (s.height() + y1 - 1); } inline bool QRect::contains(int ax, int ay, bool aproper) const { return contains(QPoint(ax, ay), aproper); } inline bool QRect::contains(int ax, int ay) const { return contains(QPoint(ax, ay), false); } inline QRect& QRect::operator|=(const QRect &r) { *this = *this | r; return *this; } inline QRect& QRect::operator&=(const QRect &r) { *this = *this & r; return *this; } inline QRect QRect::intersect(const QRect &r) const { return *this & r; } inline QRect QRect::intersected(const QRect &other) const { return intersect(other); } inline QRect QRect::unite(const QRect &r) const { return *this | r; } inline QRect QRect::united(const QRect &r) const { return unite(r); } inline bool operator==(const QRect &r1, const QRect &r2) { return r1.x1==r2.x1 && r1.x2==r2.x2 && r1.y1==r2.y1 && r1.y2==r2.y2; } inline bool operator!=(const QRect &r1, const QRect &r2) { return r1.x1!=r2.x1 || r1.x2!=r2.x2 || r1.y1!=r2.y1 || r1.y2!=r2.y2; } #ifndef QT_NO_DEBUG_STREAM Q_GUI_EXPORT QDebug operator<<(QDebug, const QRect &); #endif class Q_GUI_EXPORT QRectF { public: QRectF() { xp = yp = 0.; w = h = 0.; } QRectF(const QPointF &topleft, const QSizeF &size); QRectF(const QPointF &topleft, const QPointF &bottomRight); QRectF(qreal left, qreal top, qreal width, qreal height); QRectF(const QRect &rect); bool isNull() const; bool isEmpty() const; bool isValid() const; QRectF normalized() const; inline qreal left() const { return xp; } inline qreal top() const { return yp; } inline qreal right() const { return xp + w; } inline qreal bottom() const { return yp + h; } inline qreal x() const; inline qreal y() const; inline void setLeft(qreal pos); inline void setTop(qreal pos); inline void setRight(qreal pos); inline void setBottom(qreal pos); inline void setX(qreal pos) { setLeft(pos); } inline void setY(qreal pos) { setTop(pos); } inline QPointF topLeft() const { return QPointF(xp, yp); } inline QPointF bottomRight() const { return QPointF(xp+w, yp+h); } inline QPointF topRight() const { return QPointF(xp+w, yp); } inline QPointF bottomLeft() const { return QPointF(xp, yp+h); } inline QPointF center() const; void setTopLeft(const QPointF &p); void setBottomRight(const QPointF &p); void setTopRight(const QPointF &p); void setBottomLeft(const QPointF &p); void moveLeft(qreal pos); void moveTop(qreal pos); void moveRight(qreal pos); void moveBottom(qreal pos); void moveTopLeft(const QPointF &p); void moveBottomRight(const QPointF &p); void moveTopRight(const QPointF &p); void moveBottomLeft(const QPointF &p); void moveCenter(const QPointF &p); void translate(qreal dx, qreal dy); void translate(const QPointF &p); QRectF translated(qreal dx, qreal dy) const; QRectF translated(const QPointF &p) const; void moveTo(qreal x, qreal t); void moveTo(const QPointF &p); void setRect(qreal x, qreal y, qreal w, qreal h); void getRect(qreal *x, qreal *y, qreal *w, qreal *h) const; void setCoords(qreal x1, qreal y1, qreal x2, qreal y2); void getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const; inline void adjust(qreal x1, qreal y1, qreal x2, qreal y2); inline QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const; QSizeF size() const; qreal width() const; qreal height() const; void setWidth(qreal w); void setHeight(qreal h); void setSize(const QSizeF &s); QRectF operator|(const QRectF &r) const; QRectF operator&(const QRectF &r) const; QRectF& operator|=(const QRectF &r); QRectF& operator&=(const QRectF &r); bool contains(const QPointF &p) const; bool contains(qreal x, qreal y) const; bool contains(const QRectF &r) const; QRectF unite(const QRectF &r) const; // ### Qt 5: make QT4_SUPPORT QRectF united(const QRectF &other) const; QRectF intersect(const QRectF &r) const; // ### Qt 5: make QT4_SUPPORT QRectF intersected(const QRectF &other) const; bool intersects(const QRectF &r) const; friend Q_GUI_EXPORT_INLINE bool operator==(const QRectF &, const QRectF &); friend Q_GUI_EXPORT_INLINE bool operator!=(const QRectF &, const QRectF &); QRect toRect() const; QRect toAlignedRect() const; private: qreal xp; qreal yp; qreal w; qreal h; }; Q_DECLARE_TYPEINFO(QRectF, Q_MOVABLE_TYPE); Q_GUI_EXPORT_INLINE bool operator==(const QRectF &, const QRectF &); Q_GUI_EXPORT_INLINE bool operator!=(const QRectF &, const QRectF &); /***************************************************************************** QRectF stream functions *****************************************************************************/ // #ifndef QT_NO_DATASTREAM // Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QRectF &); // Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QRectF &); // #endif /***************************************************************************** QRectF inline member functions *****************************************************************************/ inline QRectF::QRectF(qreal aleft, qreal atop, qreal awidth, qreal aheight) : xp(aleft), yp(atop), w(awidth), h(aheight) { } inline QRectF::QRectF(const QPointF &atopLeft, const QSizeF &asize) { xp = atopLeft.x(); yp = atopLeft.y(); w = asize.width(); h = asize.height(); } inline QRectF::QRectF(const QPointF &atopLeft, const QPointF &abottomRight) { xp = atopLeft.x(); yp = atopLeft.y(); w = abottomRight.x() - xp; h = abottomRight.y() - yp; } inline QRectF::QRectF(const QRect &r) : xp(r.x()), yp(r.y()), w(r.width()), h(r.height()) { } inline bool QRectF::isNull() const { return qIsNull(w) && qIsNull(h); } inline bool QRectF::isEmpty() const { return w <= 0. || h <= 0.; } inline bool QRectF::isValid() const { return w > 0. && h > 0.; } inline qreal QRectF::x() const { return xp; } inline qreal QRectF::y() const { return yp; } inline void QRectF::setLeft(qreal pos) { qreal diff = pos - xp; xp += diff; w -= diff; } inline void QRectF::setRight(qreal pos) { w = pos - xp; } inline void QRectF::setTop(qreal pos) { qreal diff = pos - yp; yp += diff; h -= diff; } inline void QRectF::setBottom(qreal pos) { h = pos - yp; } inline void QRectF::setTopLeft(const QPointF &p) { setLeft(p.x()); setTop(p.y()); } inline void QRectF::setTopRight(const QPointF &p) { setRight(p.x()); setTop(p.y()); } inline void QRectF::setBottomLeft(const QPointF &p) { setLeft(p.x()); setBottom(p.y()); } inline void QRectF::setBottomRight(const QPointF &p) { setRight(p.x()); setBottom(p.y()); } inline QPointF QRectF::center() const { return QPointF(xp + w/2, yp + h/2); } inline void QRectF::moveLeft(qreal pos) { xp = pos; } inline void QRectF::moveTop(qreal pos) { yp = pos; } inline void QRectF::moveRight(qreal pos) { xp = pos - w; } inline void QRectF::moveBottom(qreal pos) { yp = pos - h; } inline void QRectF::moveTopLeft(const QPointF &p) { moveLeft(p.x()); moveTop(p.y()); } inline void QRectF::moveTopRight(const QPointF &p) { moveRight(p.x()); moveTop(p.y()); } inline void QRectF::moveBottomLeft(const QPointF &p) { moveLeft(p.x()); moveBottom(p.y()); } inline void QRectF::moveBottomRight(const QPointF &p) { moveRight(p.x()); moveBottom(p.y()); } inline void QRectF::moveCenter(const QPointF &p) { xp = p.x() - w/2; yp = p.y() - h/2; } inline qreal QRectF::width() const { return w; } inline qreal QRectF::height() const { return h; } inline QSizeF QRectF::size() const { return QSizeF(w, h); } inline void QRectF::translate(qreal dx, qreal dy) { xp += dx; yp += dy; } inline void QRectF::translate(const QPointF &p) { xp += p.x(); yp += p.y(); } inline void QRectF::moveTo(qreal ax, qreal ay) { xp = ax; yp = ay; } inline void QRectF::moveTo(const QPointF &p) { xp = p.x(); yp = p.y(); } inline QRectF QRectF::translated(qreal dx, qreal dy) const { return QRectF(xp + dx, yp + dy, w, h); } inline QRectF QRectF::translated(const QPointF &p) const { return QRectF(xp + p.x(), yp + p.y(), w, h); } inline void QRectF::getRect(qreal *ax, qreal *ay, qreal *aaw, qreal *aah) const { *ax = this->xp; *ay = this->yp; *aaw = this->w; *aah = this->h; } inline void QRectF::setRect(qreal ax, qreal ay, qreal aaw, qreal aah) { this->xp = ax; this->yp = ay; this->w = aaw; this->h = aah; } inline void QRectF::getCoords(qreal *xp1, qreal *yp1, qreal *xp2, qreal *yp2) const { *xp1 = xp; *yp1 = yp; *xp2 = xp + w; *yp2 = yp + h; } inline void QRectF::setCoords(qreal xp1, qreal yp1, qreal xp2, qreal yp2) { xp = xp1; yp = yp1; w = xp2 - xp1; h = yp2 - yp1; } inline void QRectF::adjust(qreal xp1, qreal yp1, qreal xp2, qreal yp2) { xp += xp1; yp += yp1; w += xp2 - xp1; h += yp2 - yp1; } inline QRectF QRectF::adjusted(qreal xp1, qreal yp1, qreal xp2, qreal yp2) const { return QRectF(xp + xp1, yp + yp1, w + xp2 - xp1, h + yp2 - yp1); } inline void QRectF::setWidth(qreal aw) { this->w = aw; } inline void QRectF::setHeight(qreal ah) { this->h = ah; } inline void QRectF::setSize(const QSizeF &s) { w = s.width(); h = s.height(); } inline bool QRectF::contains(qreal ax, qreal ay) const { return contains(QPointF(ax, ay)); } inline QRectF& QRectF::operator|=(const QRectF &r) { *this = *this | r; return *this; } inline QRectF& QRectF::operator&=(const QRectF &r) { *this = *this & r; return *this; } inline QRectF QRectF::intersect(const QRectF &r) const { return *this & r; } inline QRectF QRectF::intersected(const QRectF &r) const { return intersect(r); } inline QRectF QRectF::unite(const QRectF &r) const { return *this | r; } inline QRectF QRectF::united(const QRectF &r) const { return unite(r); } inline bool operator==(const QRectF &r1, const QRectF &r2) { return qFuzzyCompare(r1.xp, r2.xp) && qFuzzyCompare(r1.yp, r2.yp) && qFuzzyCompare(r1.w, r2.w) && qFuzzyCompare(r1.h, r2.h); } inline bool operator!=(const QRectF &r1, const QRectF &r2) { return !qFuzzyCompare(r1.xp, r2.xp) || !qFuzzyCompare(r1.yp, r2.yp) || !qFuzzyCompare(r1.w, r2.w) || !qFuzzyCompare(r1.h, r2.h); } inline QRect QRectF::toRect() const { return QRect(qRound(xp), qRound(yp), qRound(w), qRound(h)); } #ifndef QT_NO_DEBUG_STREAM Q_GUI_EXPORT QDebug operator<<(QDebug, const QRectF &); #endif QT_END_NAMESPACE QT_END_HEADER #endif // QRECT_H
[ "zhangyinquan@0feb242a-2539-11de-a0d7-251e5865a1c7" ]
[ [ [ 1, 860 ] ] ]
ac889be99bd69e09124312ff3a2d0e350ba20c18
7b32ec66568e9afc4bea9ffec8f54b9646958890
/ mariogame/source code/win 32 api/MarioGame/BonnusObject.cpp
dad2a64f2bed755f8f9abd24b7a43a9438de0aa0
[]
no_license
Dr-Hydrolics/mariogame
47056e4247bcad6da75d0ab8954cda144ee4e499
8611287742690dd1dd51a865202a73535cefbec4
refs/heads/master
2016-08-13T00:17:40.387527
2010-05-13T13:02:24
2010-05-13T13:02:24
43,435,945
0
0
null
null
null
null
UTF-8
C++
false
false
5,539
cpp
#include "StdAfx.h" #include "BonnusObject.h" #include "ObjectManager.h" CCoin::CCoin() { mFamily = FANIMATEMOVELESS; mType = TCOIN; mFrameCount = 0; mFirstFrame = 0; mCurFrame = 0; mDelayCount = 0; mCurDelay = 0; } CCoin::CCoin(int x, int y, int w, int h, LPCTSTR bmSpriteName) { mFamily = FANIMATEMOVELESS; mType = TCOIN; mFrameCount = 4; mFirstFrame = 0; mCurFrame = 0; mDelayCount = 15; mCurDelay = 0; mXPos = x; mYPos = y; mWidth = w; mHeight = h; mAnimation = new Sprite(mXPos, mYPos, mWidth, mHeight, 1, mFrameCount, mDelayCount, bmSpriteName); mAnimation->SetCurrentFrame(mFirstFrame); } CCoin::~CCoin() { if (mAnimation != NULL) { delete mAnimation; mAnimation = NULL; } } void CCoin::NextFrame() { if(mCurDelay>=mDelayCount) { mCurFrame = (mCurFrame + 1)%mFrameCount; mAnimation->SetCurrentFrame(mCurFrame + mFirstFrame); mCurDelay = 0; } else mCurDelay++; } int CCoin::DoAction(/*CScreen* scr, */CObjectManager* objMan) { NextFrame(); return 1; } CTrunk::CTrunk(int x, int y, int w, int h, LPCTSTR bmSpriteName, int innerObjTileIdx, int tileIdx /*= IFLOWER*/) { mOpened = 0; mFamily = FNOANIMATEMOVELESS; mType = TTRUNK; mXPos = x; mYPos = y; mWidth = w; mHeight = h; mTileIndex = tileIdx; bmSprite = new MyBitmap(bmSpriteName); mInnerObjTileIdx = innerObjTileIdx; } CTrunk::~CTrunk(void) { } void CTrunk::Open(CObjectManager* objMan) { if(mOpened == 1) return; mOpened = 1; mTileIndex = 0; CGameObject* obj = NULL; CMap* map = objMan->GameMap(); switch(mInnerObjTileIdx) { case ICOIN: obj = new CCoin(mXPos, mYPos - map->TileHeight(), map->TileWidth(), map->TileHeight(), _T("coin.bmp")); objMan->AddBonnus(obj); break; case IFLOWER: obj = new CFlower(mXPos, mYPos - 24, 24, 24, _T("flower.bmp")); objMan->AddBonnus(obj); break; case IMUSHROOM: obj = new CMushroom(mXPos, mYPos - 24, 24, 24, _T("smallmushroom.bmp")); objMan->AddBonnus(obj); break; case ISTAR: obj = new CStar(mXPos, mYPos - map->TileHeight(), map->TileWidth(), map->TileHeight(), _T("star.bmp")); objMan->AddBonnus(obj); break; default: obj = new CCoin(mXPos, mYPos - map->TileHeight(), map->TileWidth(), map->TileHeight(), _T("coin.bmp")); objMan->AddBonnus(obj); break; } } CMushroom::CMushroom(void) { } CMushroom::CMushroom(int x, int y, int w, int h, LPCTSTR bmSpriteName, int tileIdx/* = IMUSHROOM*/) { mXMove = 3; mYMove = 8; mJumpDirect=0; mJump=1; mFamily = FNOANIMATEMOVABLE; mType = TMUSHROOM; mDirection = DIRRIGHT; mXPos = x; mYPos = y; mWidth = w; mHeight = h; mTileIndex = IMUSHROOM; bmSprite = new MyBitmap(bmSpriteName); } CMushroom::~CMushroom(void) { } int CMushroom::DoAction(/*CScreen* scr, */CObjectManager* objMan) { int moveX=0; if(abs(mXPos - objMan->GetMarioPos().x) < 500 ) { int i = CheckCollision(objMan); if(i == -1) return -1; // Roi xuong vuc sau if (GetBit(i,3)!=1 ) { mYPos=mYPos+mYMove; moveX=0; } else moveX=mXMove; if(mDirection==DIRRIGHT) { if(GetBit(i,0)==1) { mDirection = DIRLEFT; mXPos=mXPos-moveX; } else { mXPos=mXPos+moveX; } } if(mDirection==DIRLEFT) { if (GetBit(i,1)==1) // bi can ben trai { mDirection = DIRRIGHT; mXPos=mXPos+moveX; } else { mXPos=mXPos-moveX; if(mXPos<0) { mXPos=0; mDirection=DIRRIGHT; } } } } return 1; } CFlower::CFlower(int x, int y, int w, int h, LPCTSTR bmSpriteName) { mFamily = FANIMATEMOVELESS; mType = TFLOWER; mFrameCount = 1; mFirstFrame = 0; mCurFrame = 0; mDelayCount = 0; mCurDelay = 0; mXPos = x; mYPos = y; mWidth = w; mHeight = h; mAnimation = new Sprite(mXPos, mYPos, mWidth, mHeight, 1, mFrameCount, mDelayCount, bmSpriteName); mAnimation->SetCurrentFrame(mFirstFrame); } CStar::CStar(int x, int y, int w, int h, LPCTSTR bmSpriteName) { mType = TSTAR; mFamily = FANIMATEMOVABLE; mXPos = x; mYPos = y; mWidth = w; mHeight = h; mCurFrame = 0; mCurDelay = 0; mFirstFrame = 0; mDelayCount = 0; mFrameCount = 1; mDirection = DIRRIGHT; mAnimation = new Sprite(mXPos, mYPos, mWidth, mHeight, 1, mFrameCount, mDelayCount, bmSpriteName); mAnimation->SetCurrentFrame(mCurFrame); mXMove = 3; mYMove = 3; mJumpDirect=1; mJump=1; mYpos1 = mYPos; } int CStar::DoAction(/*CScreen* scr, */CObjectManager* objMan)// di dung chuong ngai vat trai ,phai quay lai , khi gap ho hay bac thang thi quay lai(phai xd chinh xac vi tri dung)//duoi theo mario { int moveX=mXMove; int moveY; int flag=0; int i= CheckCollision(objMan); if(i == -1) return -1; // Roi xuong vuc sau if(mJumpDirect==1 ) { if(mYpos1-mYPos>=150||GetBit(i,2)==1) { mJumpDirect=0; } else mYPos=mYPos -mYMove; } else { if( GetBit(i,3)==1) { flag=1; mJumpDirect=1; mYpos1 = mYPos; } else mYPos=mYPos + mYMove; } if(mDirection==DIRRIGHT) { if(GetBit(i,0)==1) { mDirection = DIRLEFT; mXPos=mXPos-moveX; } else { mXPos=mXPos+moveX; } } if(mDirection==DIRLEFT) { if (GetBit(i,1)==1) // bi can ben trai { mDirection = DIRRIGHT; mXPos=mXPos+moveX; } else { mXPos=mXPos-moveX; if(mXPos<0) { mXPos=0; mDirection=DIRRIGHT; } } } return 1; }
[ "moonlight2708@0b8e3906-489a-11de-8001-7f2440edb24e" ]
[ [ [ 1, 274 ] ] ]
ca3b50cb662aeaf4b80ffcfe20d656431e9da51b
bc3073755ed70dd63a7c947fec63ccce408e5710
/src/Qt/UserInterface/Connect.cpp
11d287d263d4c620806ef2f02316fae99ba5286c
[]
no_license
ptrefall/ste6274gamedesign
9e659f7a8a4801c5eaa060ebe2d7edba9c31e310
7d5517aa68910877fe9aa98243f6bb2444d533c7
refs/heads/master
2016-09-07T18:42:48.012493
2011-10-13T23:41:40
2011-10-13T23:41:40
32,448,466
1
0
null
null
null
null
UTF-8
C++
false
false
4,971
cpp
#include "Connect.h" #include "Join.h" #include "ConnectionFailed.h" #include "Lobby.h" #include "MainMenu.h" #include <Game/game.h> #include <Game/GameOptions.h> #include <Qt/Client/Client.h> #include <Qt/Client/ClientThread.h> #include <Qt/Client/SocketParseTask.h> #include <QTimer.h> using namespace Ui; Connect::Connect(Join *join, Game &game, QWidget *parent, Qt::WFlags flags) : QDialog(parent, flags), join(join), game(game), tryingToConnect(false) { setupUi(this); connectionFailed = new ConnectionFailed(join, game); connectionFailed->hide(); //connect(this, SIGNAL(close()), SLOT(onClose())); connect(connectCancelButton, SIGNAL(clicked()), SLOT(onClose())); //connect(this, SIGNAL(connectToServer()), SLOT(onServerConnectionAttempt())); } Connect::~Connect() { } void Connect::connectToServerAttempt() { GameOptions &opt = game.getOptions(); if(opt.ip_addr == T_String()) return; if(opt.port < 1000) return; connect(this, SIGNAL(signConnectToHost(const QHostAddress &, const quint16 &)), &game.getClient(), SLOT(connectToHost(const QHostAddress &, const quint16 &))); connect(&game.getClient().getClientThread(), SIGNAL(signHostFound()), SLOT(onHostFound())); connect(&game.getClient().getClientThread(), SIGNAL(signHandshakeSucceeded()), SLOT(onHandshakeSucceeded())); connect(&game.getClient().getClientThread(), SIGNAL(signHandshakeFailed(const QString &)), SLOT(onHandshakeFailed(const QString &))); connect(&game.getClient().getClientThread(), SIGNAL(signConnectSucceeded()), SLOT(onConnectionSucceeded())); connect(&game.getClient().getClientThread(), SIGNAL(signConnectFailed(const QString &)), SLOT(onConnectionFailed(const QString &))); connect(&game.getClient().getClientThread(), SIGNAL(signMoveToLobby(const gp_default_server_query_answer &)), SLOT(onMoveToLobby(const gp_default_server_query_answer &))); timer.start(); state = E_INITIATE_CONNECTION; //game.getClient().connectToHost(QHostAddress(opt.ip_addr.c_str()), opt.port); emit signConnectToHost(QHostAddress(opt.ip_addr.c_str()), opt.port); tryingToConnect = true; onUpdateProgress(); } void Connect::onClose() { /*if(state == E_CONNECTION_SUCCEEDED) game.getClient().sendDisconnectRequest();*/ state = E_CONNECTION_ABORTED; tryingToConnect = false; progressBarConnection->setValue(0); this->hide(); join->show(); } void Connect::onHostFound() { state = E_HOST_FOUND; } void Connect::onHandshakeSucceeded() { state = E_HANDSHAKE_SUCCEEDED; //game.getClient().sendConnectRequest(); } void Connect::onHandshakeFailed(const QString &why) { state = E_HANDSHAKE_FAILED; tryingToConnect = false; progressBarConnection->setValue(0); connectionFailed->labelConnectionFailed->setText(why); this->hide(); connectionFailed->show(); } void Connect::onConnectionSucceeded() { state = E_CONNECTION_SUCCEEDED; tryingToConnect = false; progressBarConnection->setValue(100); //From here, attempt to join and enter lobby //game.getClient().sendJoinRequest(); } void Connect::onConnectionFailed(const QString &why) { state = E_CONNECTION_FAILED; tryingToConnect = false; progressBarConnection->setValue(0); connectionFailed->labelConnectionFailed->setText(why); this->hide(); connectionFailed->show(); } void Connect::onMoveToLobby(const gp_default_server_query_answer &answer) { state = E_FINISHED; tryingToConnect = false; progressBarConnection->setValue(100); this->hide(); join->getMainMenu().getLobby().setData(answer); join->getMainMenu().getLobby().show(); } void Connect::onUpdateProgress() { switch(state) { case E_INITIATE_CONNECTION: this->setWindowTitle("Initializing connection..."); break; case E_HOST_FOUND: this->setWindowTitle("Host found, trying to connect..."); break; case E_HANDSHAKE_SUCCEEDED: this->setWindowTitle("Handshake successful, requesting server connection..."); break; case E_HANDSHAKE_FAILED: this->setWindowTitle("Handshake failed!"); break; case E_CONNECTION_SUCCEEDED: this->setWindowTitle("Connection successful, requesting server information..."); break; case E_CONNECTION_FAILED: this->setWindowTitle("Connection failed!"); break; case E_CONNECTION_ABORTED: this->setWindowTitle("Connection aborted!"); break; case E_SERVER_INFO_RECEIVED: this->setWindowTitle("Server information received, processing..."); break; case E_SERVER_INFO_PROCESSED: this->setWindowTitle("Server information processed, finalizing connection..."); break; case E_FINISHED: this->setWindowTitle("Connection established, entering lobby!"); break; default: this->setWindowTitle("Unknown connection state!"); break; }; if(!tryingToConnect) return; progressBarConnection->setValue(progressBarConnection->value() + 1); QTimer::singleShot(1000, this, SLOT(onUpdateProgress())); }
[ "[email protected]@2c5777c1-dd38-1616-73a3-7306c0addc79" ]
[ [ [ 1, 168 ] ] ]
ecbf9f3b9803afe8b291d18f6eb3b46a5195e781
3a577d02f876776b22e2bf1c0db12a083f49086d
/vba2/vba2/settings/presskeydialog.h
c4c0ad6ba4921fc9edfabc0c2f8834e0f8eed3d2
[]
no_license
xiaoluoyuan/VisualBoyAdvance-2
d19565617b26e1771f437842dba5f0131d774e73
cadd2193ba48e1846b45f87ff7c36246cd61b6ee
refs/heads/master
2021-01-10T01:19:23.884491
2010-05-12T09:59:37
2010-05-12T09:59:37
46,539,728
0
0
null
null
null
null
UTF-8
C++
false
false
1,343
h
/* VisualBoyAdvance 2 Copyright (C) 2009-2010 VBA development team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef PRESSKEYDIALOG_H #define PRESSKEYDIALOG_H #include <QDialog> #include <QLabel> #include <QKeyEvent> #include <QString> class PressKeyDialog : public QDialog { Q_OBJECT public: PressKeyDialog( QString message, QWidget *parent = 0 ) : QDialog( parent ) { this->setWindowTitle( tr("Assign Key") ); QLabel *label = new QLabel( message, this ); label->setAlignment( Qt::AlignCenter ); label->setWordWrap( true ); } protected: void keyPressEvent( QKeyEvent *e ) { done( e->key() ); } }; #endif // PRESSKEYDIALOG_H
[ "spacy51@5a53c671-dd2d-0410-9261-3f5c817b7aa0" ]
[ [ [ 1, 51 ] ] ]
8497a539ad3bc85057a546fc7aeee0717af8a1ca
00b979f12f13ace4e98e75a9528033636dab021d
/Logger/src/Logger.cpp
5f34de094f7ac2652eb1af63e8f710dfad081228
[]
no_license
BackupTheBerlios/ziahttpd-svn
812e4278555fdd346b643534d175546bef32afd5
8c0b930d3f4a86f0622987776b5220564e89b7c8
refs/heads/master
2016-09-09T20:39:16.760554
2006-04-13T08:44:28
2006-04-13T08:44:28
40,819,288
0
0
null
null
null
null
UTF-8
C++
false
false
403
cpp
// // Logger.cpp for in // // Made by Bigand Xavier // Login <@epita.fr> // // Started on Mon Dec 26 12:43:59 2005 Bigand Xavier // Last update Tue Dec 27 16:27:30 2005 Bigand Xavier // #include "Logger.hh" Logger::Logger() { int i; _tStrSize = STR_SIZE; _bError = false; for (i = 0; i < NB_TYPE; i++) { _bFlow[i] = false; _Flow[i] = NULL; } }
[ "ringo@754ce95b-6e01-0410-81d0-8774ba66fe44" ]
[ [ [ 1, 24 ] ] ]
7daad56ea59b08a4735fc928abeb010c9ec50195
ea12fed4c32e9c7992956419eb3e2bace91f063a
/zombie/code/zombie/npythonserver/src/python/nsignalbindingpython.cc
37a0bb73afc503102338ac265c61fc544b968cb4
[]
no_license
ugozapad/TheZombieEngine
832492930df28c28cd349673f79f3609b1fe7190
8e8c3e6225c2ed93e07287356def9fbdeacf3d6a
refs/heads/master
2020-04-30T11:35:36.258363
2011-02-24T14:18:43
2011-02-24T14:18:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,002
cc
//------------------------------------------------------------------------------ // nsignalbindingpython.cc // (C) 2005 Conjurer Services, S.A. //------------------------------------------------------------------------------ #include "precompiled/pchnpythonserver.h" #include "python/nsignalbindingpython.h" #include "python/ncmdprotopython.h" //------------------------------------------------------------------------------ extern "C" PyObject* _putOutSingleArg(nArg *arg); //------------------------------------------------------------------------------ nArray<nSignalBindingPython*> nSignalBindingPython::pythonBindings; //------------------------------------------------------------------------------ /** @param obj python object @param str method name in the object @param priority priority of the binding */ nSignalBindingPython::nSignalBindingPython( PyObject * obj, const nString & str, int priority, const nString & proto ): nSignalBinding(priority), pyRefObject(0), method(str) { // check the python object n_assert( obj ); if( obj ) { // get params from proto def string nString params = proto; int index = -1; do { index = params.FindChar( '_', 0 ); if( index != -1 ) { params = params.ExtractRange( index + 1, params.Length() - ( index + 1 ) ); } }while( index != -1 ); // create the Proto Definition of the method this->protoDef.Format( "v_%s_%s", this->method.Get(), params.Get() ); // create a weak reference to object this->pyRefObject = PyWeakref_NewRef( obj, 0 ); } pythonBindings.Append( this ); } //------------------------------------------------------------------------------ /** */ nSignalBindingPython::~nSignalBindingPython() { pythonBindings.EraseQuick( pythonBindings.FindIndex( this ) ); } //------------------------------------------------------------------------------ /** */ bool nSignalBindingPython::Invoke( nCmd * cmd ) { // get info about parameters expected ProtoDefInfo info( this->protoDef.Get() ); if( ! info.valid ) { return false; } if( cmd->GetNumInArgs() != info.numInArgs ) { return false; } this->CallPythonMethod( cmd ); return false; } //------------------------------------------------------------------------------ /** */ bool nSignalBindingPython::Invoke( va_list args ) { nCmdProtoPython cmdProto( this->protoDef.Get() ); nCmd * cmd = cmdProto.NewCmd(); n_assert(cmd); // set input command arguments cmd->CopyInArgsFrom( args ); cmd->Rewind(); this->CallPythonMethod( cmd ); cmdProto.RelCmd( cmd ); return true; } //------------------------------------------------------------------------------ /** */ void nSignalBindingPython::CallPythonMethod( nCmd * const cmd ) { ProtoDefInfo info( this->protoDef.Get() ); // create a tuple for put the args in PyObject * arglist = PyTuple_New( cmd->GetNumInArgs() ); if( ! arglist ) { if( PyErr_Occurred() ) { PyErr_Print(); } return; } // copy the args in the tuple for( int i = 0; i < cmd->GetNumInArgs() ; ++i ) { PyTuple_SetItem( arglist, i, _putOutSingleArg( cmd->In() ) ); } if( this->pyRefObject ) { PyObject * object = PyWeakref_GetObject( this->pyRefObject ); // create the callable object using object + method PyObject * pyStr = PyString_FromFormat( this->method.Get() ); n_assert( pyStr ); if( pyStr ) { // when callobject(pyMethod) is created a Ref to the object is addded PyObject * pyMethod = PyObject_GetAttr( object, pyStr ); if( pyMethod ) { PyObject * retval; retval = PyObject_CallObject( pyMethod, arglist ); if( PyErr_Occurred() ) { PyErr_Print(); } if( retval != 0 ) { Py_DECREF( retval ); } Py_DECREF( pyMethod ); } else { if( PyErr_Occurred() ) { PyErr_Print(); } } Py_DECREF( pyStr ); } } Py_DECREF( arglist ); } //------------------------------------------------------------------------------ /** @returns the proto definition of binding */ const char * nSignalBindingPython::GetProtoDef() const { return this->protoDef.Get(); } //------------------------------------------------------------------------------ /** @returns true if binding is valid */ bool nSignalBindingPython::IsValid() const { if( this->pyRefObject ) { if( PyWeakref_GetObject( this->pyRefObject ) != Py_None ) { return true; } } return false; } //------------------------------------------------------------------------------ /** @param obj the PyObject to found @returns the founded binding or 0 */ nSignalBindingPython * nSignalBindingPython::FindBinding( const PyObject * const obj ) { nSignalBindingPython * founded = 0; for( int i = 0 ; i < pythonBindings.Size() && ! founded ; ++i ) { PyObject * object = PyWeakref_GetObject( pythonBindings[ i ]->pyRefObject ); if( object != Py_None ) { if( object == obj ) { founded = pythonBindings[ i ]; } } } return founded; } //------------------------------------------------------------------------------
[ "magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91" ]
[ [ [ 1, 232 ] ] ]
14276ba25f4fb144dcaeb61fb5e47bfa664d461f
478570cde911b8e8e39046de62d3b5966b850384
/apicompatanamdw/bcdrivers/mw/classicui/uifw/apps/S60_SDK3.0/bctestnote/inc/bctestwaitdialogcase.h
f703d246378faa954947fa75e93d9fbb9d49397e
[]
no_license
SymbianSource/oss.FCL.sftools.ana.compatanamdw
a6a8abf9ef7ad71021d43b7f2b2076b504d4445e
1169475bbf82ebb763de36686d144336fcf9d93b
refs/heads/master
2020-12-24T12:29:44.646072
2010-11-11T14:03:20
2010-11-11T14:03:20
72,994,432
0
0
null
null
null
null
UTF-8
C++
false
false
2,221
h
/* * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: Declares test bc for wait dialog testcase. * */ #ifndef C_CBCTESTWAITDIALOGCASE_H #define C_CBCTESTWAITDIALOGCASE_H #include "bctestcase.h" class CBCTestNoteContainer; class CCoeControl; class CEikDialog; class CEikProgressInfo; /** * test case for various note classes */ class CBCTestWaitDialogCase: public CBCTestCase { public: // constructor and destructor /** * Symbian 2nd static constructor */ static CBCTestWaitDialogCase* NewL( CBCTestNoteContainer* aContainer ); /** * Destructor */ virtual ~CBCTestWaitDialogCase(); // from CBCTestCase /** * Execute corresponding test functions for UI command * @param aCmd, UI command */ void RunL( TInt aCmd ); protected: // new functions /** * Build autotest script */ void BuildScriptL(); /** * TestWaitDialogL function */ void TestWaitDialogL(); /** * TestProgressDialogL function */ void TestProgressDialogL(); /** * TestProgressOtherFunctionsL function */ void TestProgressOtherFunctionsL(); private: // constructor /** * C++ default constructor */ CBCTestWaitDialogCase( CBCTestNoteContainer* aContainer ); /** * Symbian 2nd constructor */ void ConstructL(); private: // data /** * Pointer to container. * not own */ CBCTestNoteContainer* iContainer; /** * Pointer to eikdialog. * own */ CEikDialog* iEikDialog; /** * Pointer to eikprogressinfo. * own */ CEikProgressInfo* iEikProgressInfo; }; #endif // C_CBCTESTWAITDIALOGCASE_H
[ "none@none" ]
[ [ [ 1, 110 ] ] ]
c4f7df91b25ceb3148eb990377d79081dd9647d4
b2155efef00dbb04ae7a23e749955f5ec47afb5a
/source/OEUI/OEUIRenderSystem_Impl.h
567955138fcd4a1c9abdcfae920b73fd45c64895
[]
no_license
zjhlogo/originengine
00c0bd3c38a634b4c96394e3f8eece86f2fe8351
a35a83ed3f49f6aeeab5c3651ce12b5c5a43058f
refs/heads/master
2021-01-20T13:48:48.015940
2011-04-21T04:10:54
2011-04-21T04:10:54
32,371,356
1
0
null
null
null
null
UTF-8
C++
false
false
1,686
h
/*! * \file OEUIRenderSystem_Impl.h * \date 19-2-2010 19:52:06 * * * \author zjhlogo ([email protected]) */ #ifndef __OEUIRENDERSYSTEM_IMPL_H__ #define __OEUIRENDERSYSTEM_IMPL_H__ #include <OEUI/IOEUIRenderSystem.h> #include <libOEMsg/OEMsgCommand.h> #include "OEUIVertexCache.h" class COEUIRenderSystem_Impl : public IOEUIRenderSystem { public: enum CONST_DEFINE { SOLID_VERTEX_CACHE = 4096*32, SOLID_INDEX_CACHE = (4096*3)/2+2, NUM_SOLID_CACHE = 5, TRANSPARENT_VERTEX_CACHE = 4096*32, TRANSPARENT_INDEX_CACHE = (4096*3)/2+2, NUM_TRANSPARENT_CACHE = 5, }; public: RTTI_DEF(COEUIRenderSystem_Impl, IOEUIRenderSystem); COEUIRenderSystem_Impl(); virtual ~COEUIRenderSystem_Impl(); virtual bool Initialize(); virtual void Terminate(); virtual COEUIScreen* GetScreen(); virtual void SetTexture(IOETexture* pTexture); virtual IOETexture* GetTexture() const; virtual void DrawSolidTriList(const void* pVerts, uint nVerts, const ushort* pIndis, uint nIndis); virtual void DrawTransparentTriList(const void* pVerts, uint nVerts, const ushort* pIndis, uint nIndis); virtual float NextDepth(); private: bool Init(); void Destroy(); void FlushSolid(); void FlushTransparent(); void FlushAll(); bool OnUpdate(COEMsgCommand& msg); bool OnRender(COEMsgCommand& msg); bool OnPostRender(COEMsgCommand& msg); private: IOETexture* m_pTexture; IOEShader* m_pShader; COEUIVertexCache* m_pSolidVertsCache[NUM_SOLID_CACHE]; COEUIVertexCache* m_pTransparentVertsCache[NUM_TRANSPARENT_CACHE]; COEUIScreen* m_pScreen; float m_fCurrDepth; }; #endif // __OEUIRENDERSYSTEM_IMPL_H__
[ "zjhlogo@fdcc8808-487c-11de-a4f5-9d9bc3506571" ]
[ [ [ 1, 70 ] ] ]
4a4e6913d061c260b56ea086d705562d3e792f1b
85c91b680d74357b379204ecf7643ae1423f8d1e
/branches/pre_mico_2_3-12/examples/streams/simple/SimpleStream_SinkCompo/SimpleStream_SinkCompo.h
f7b02c7b9978fe403b1f6548aac10db3175c7f48
[]
no_license
BackupTheBerlios/qedo-svn
6fdec4ca613d24b99a20b138fb1488f1ae9a80a2
3679ffe8ac7c781483b012dbef70176e28fea174
refs/heads/master
2020-11-26T09:42:37.603285
2010-07-02T10:00:26
2010-07-02T10:00:26
40,806,890
0
0
null
null
null
null
UTF-8
C++
false
false
5,167
h
// // generated by Qedo // #ifndef _SimpleStream_SinkCompo_H_ #define _SimpleStream_SinkCompo_H_ // BEGIN USER INSERT SECTION file_pre // END USER INSERT SECTION file_pre #include <CORBA.h> #include "SimpleStream_SinkCompo_BUSINESS.h" #include "component_valuetypes.h" #include "RefCountBase.h" #include <string> // BEGIN USER INSERT SECTION file_post // END USER INSERT SECTION file_post namespace SimpleStream { // // executor // class SinkImpl : public virtual CORBA::LocalObject , public virtual ::SimpleStream::CCM_SinkImpl #ifndef MICO_ORB , public virtual Qedo::RefCountLocalObject #endif // BEGIN USER INSERT SECTION INHERITANCE_SinkImpl // END USER INSERT SECTION INHERITANCE_SinkImpl { private: ::SimpleStream::CCM_StreamSink_ContextImpl_var context_; public: SinkImpl(); virtual ~SinkImpl(); void set_context(::SimpleStream::CCM_StreamSink_ContextImpl_ptr context) throw (CORBA::SystemException, Components::CCMException); void configuration_complete() throw (CORBA::SystemException, Components::InvalidConfiguration); void remove() throw (CORBA::SystemException); // // IDL:SimpleStream/StreamSink/input:1.0 // void begin_stream_input (const char*, const ::Components::ConfigValues&); void end_stream_input(); void failed_stream_input(); void receive_stream_input (StreamComponents::StreamingBuffer_ptr); // BEGIN USER INSERT SECTION SinkImpl // END USER INSERT SECTION SinkImpl }; // // executor locator // class SinkCompo : public virtual CORBA::LocalObject , public virtual Components::SessionExecutorLocator #ifndef MICO_ORB , public virtual Qedo::RefCountLocalObject #endif // BEGIN USER INSERT SECTION INHERITANCE_SinkCompo // END USER INSERT SECTION INHERITANCE_SinkCompo { private: ::SimpleStream::CCM_StreamSink_ContextImpl_var context_; SinkImpl* component_; public: SinkCompo(); virtual ~SinkCompo(); // // IDL:Components/ExecutorLocator/obtain_executor:1.0 // virtual CORBA::Object_ptr obtain_executor(const char* name) throw(CORBA::SystemException); // // IDL:Components/ExecutorLocator/release_executor:1.0 // virtual void release_executor(CORBA::Object_ptr exc) throw(CORBA::SystemException); // // IDL:Components/ExecutorLocator/configuration_complete:1.0 // virtual void configuration_complete() throw(CORBA::SystemException, ::Components::InvalidConfiguration); // // IDL:Components/SessionComponent/set_session_context:1.0 // virtual void set_session_context(Components::SessionContext_ptr ctx) throw(CORBA::SystemException, ::Components::CCMException); // // IDL:Components/SessionComponent/ccm_activate:1.0 // virtual void ccm_activate() throw(CORBA::SystemException, ::Components::CCMException); // // IDL:Components/SessionComponent/ccm_passivate:1.0 // virtual void ccm_passivate() throw(CORBA::SystemException, ::Components::CCMException); // // IDL:Components/SessionComponent/ccm_remove:1.0 // virtual void ccm_remove() throw(CORBA::SystemException, ::Components::CCMException); // BEGIN USER INSERT SECTION SinkCompo // END USER INSERT SECTION SinkCompo }; // // home executor // class SinkHomeImpl : public virtual CORBA::LocalObject , public virtual ::SimpleStream::CCM_StreamSinkHome #ifndef MICO_ORB , public virtual Qedo::RefCountLocalObject #endif // BEGIN USER INSERT SECTION INHERITANCE_SinkHomeImpl // END USER INSERT SECTION INHERITANCE_SinkHomeImpl { private: Components::HomeContext_var context_; public: SinkHomeImpl(); virtual ~SinkHomeImpl(); // // IDL:Components/HomeExecutorBase/set_context:1.0 // virtual void set_context (Components::HomeContext_ptr ctx) throw (CORBA::SystemException, Components::CCMException); // // IDL:.../create:1.0 // virtual ::Components::EnterpriseComponent_ptr create() throw (CORBA::SystemException, Components::CreateFailure); // BEGIN USER INSERT SECTION SinkHomeImpl // END USER INSERT SECTION SinkHomeImpl }; }; // // entry point // extern "C" { #ifdef _WIN32 __declspec(dllexport) #else #endif ::Components::HomeExecutorBase_ptr create_StreamSinkHomeE(void); } #endif
[ "tom@798282e8-cfd4-0310-a90d-ae7fb11434eb" ]
[ [ [ 1, 198 ] ] ]
4f852ec641e55c2255e798f76d0fceba33368647
710981ad55d08ec46a9ffa06df2f07aa54ae5dcd
/player/src/sprites/Faceset.cpp
bcf4cd94a6a85a49b3387ac5de3eb7503a779bd9
[]
no_license
weimingtom/easyrpg
b2ee6acf5a97a4744554b26feede7367b7c16233
8877364261e4d4f52cd36cbb43929ed1351f06e1
refs/heads/master
2021-01-10T02:14:36.939339
2009-02-15T03:45:32
2009-02-15T03:45:32
44,462,893
1
0
null
null
null
null
UTF-8
C++
false
false
1,489
cpp
/*Faceset.cpp, sprite routines. Copyright (C) 2007 EasyRPG Project <http://easyrpg.sourceforge.net/>. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "Faceset.h" void Faceset::init_Faceset(int posx,int posy,int theframe) { x = posx; y = posy; frame = theframe; cols=4;//redefinir rows=4;//redefinir int w = 48; int h = 48; SDL_Surface * Eximg; Eximg = SDL_CreateRGBSurface(SDL_SWSURFACE,w, h, 16,0, 0,0, 0); SDL_Rect fuente = {(frame%cols)* w,(frame/cols) * h, w, h}; SDL_Rect rect = {0,0, 0, 0}; SDL_BlitSurface (img, & fuente, Eximg, &rect); dispose(); set_surface(Eximg); } void Faceset::drawf (SDL_Surface * screen) { int w = getw(); int h = geth(); SDL_Rect fuente = {(frame%cols)* w,(frame/cols) * h, w, h}; SDL_Rect rect = {x,y, 0, 0}; SDL_BlitSurface (img, & fuente, screen, &rect); }
[ "fdelapena@2452c464-c253-f492-884b-b99f1bb2d923" ]
[ [ [ 1, 49 ] ] ]
6291acdb2735575cd8cc6eb03d541b4f9d97af8b
a3de460e3b893849fb01b4c31bd30a908160a1f8
/nil/ini.cpp
7a44aa2cb70532ed1adb55f8b2ad18732a1174b7
[]
no_license
encratite/nil
32b3d0d31124dd43469c07df2552f1c3510df36d
b441aba562d87f9c14bfce9291015b7622a064c6
refs/heads/master
2022-06-19T18:59:06.212567
2008-12-23T05:58:00
2008-12-23T05:58:00
262,275,950
0
0
null
null
null
null
UTF-8
C++
false
false
2,116
cpp
#include <nil/ini.hpp> //debugging #include <iostream> namespace nil { ini::ini() { } ini::ini(std::string const & file_name) { load(file_name); } bool ini::load(std::string const & new_file_name) { file_name = new_file_name; values.clear(); std::string input; bool success = read_file(file_name, input); if(success == false) { return false; } std::vector<std::string> lines = string::tokenise(input, '\n'); for(std::vector<std::string>::iterator i = lines.begin(), end = lines.end(); i != end; ++i) { std::string line = string::trim(*i); bool is_empty = line.empty(); if( (is_empty == true) || ( (is_empty == false) && (line[0] == '#') ) ) { continue; } std::size_t offset = line.find('='); if(offset == std::string::npos) { continue; } std::string variable = string::right_trim(line.substr(0, offset)), value = string::left_trim(line.substr(offset + 1)); if( (value.length() >= 2) && (value[0] == '"') && (*(value.end() - 1) == '"') ) { value.erase(value.begin()); value.erase(value.end() - 1); } values[variable] = value; } return true; } bool ini::read_string(std::string const & variable_name, std::string & output) { std::map<std::string, std::string>::iterator search = values.find(variable_name); if(search == values.end()) return false; output = search->second; return true; } std::string ini::string(std::string const & variable_name) { std::string output; bool success = read_string(variable_name, output); if(success == false) throw exception("Unable to find string value \"" + variable_name + "\" in \"" + file_name + "\""); return output; } std::string ini::string(std::string const & variable_name, std::string const & default_value) { std::string output; bool success = read_string(variable_name, output); if(success == false) return default_value; return output; } }
[ [ [ 1, 106 ] ] ]