blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
5
146
content_id
stringlengths
40
40
detected_licenses
listlengths
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
listlengths
1
16
author_lines
listlengths
1
16
6cb73a938fe0ce8d054133d44320ecc771633802
bef7d0477a5cac485b4b3921a718394d5c2cf700
/testShadows/src/system/main.cpp
cf94927c8c9e52918e72c94e34221ade90b62631
[ "MIT" ]
permissive
TomLeeLive/aras-p-dingus
ed91127790a604e0813cd4704acba742d3485400
22ef90c2bf01afd53c0b5b045f4dd0b59fe83009
refs/heads/master
2023-04-19T20:45:14.410448
2011-10-04T10:51:13
2011-10-04T10:51:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
566
cpp
#include "stdafx.h" #include "../demo/Demo.h" #include <dingus/app/DingusSystem.h> INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR lpCmdLine, INT ) { try { CDemo* demo = new CDemo(); CDingusSystem* system = new CDingusSystem( *demo ); if( SUCCEEDED( system->create( hInst, false ) ) ) system->run(); delete demo; delete system; } catch( std::exception& e ) { std::string willExit = "\n\nThe application will now exit."; MessageBox( 0, (e.what()+willExit).c_str(), "Fatal error", MB_OK ); return 0; } return 0; }
[ [ [ 1, 22 ] ] ]
124777380bbe689c56780d865e389c1e925902b8
2dbbca065b62a24f47aeb7ec5cd7a4fd82083dd4
/OUAN/OUAN/Src/GUI/GUIStoryBook.cpp
b23bc56e1dda6b16bcd6675df43a237db4359999
[]
no_license
juanjmostazo/once-upon-a-night
9651dc4dcebef80f0475e2e61865193ad61edaaa
f8d5d3a62952c45093a94c8b073cbb70f8146a53
refs/heads/master
2020-05-28T05:45:17.386664
2010-10-06T12:49:50
2010-10-06T12:49:50
38,101,059
1
1
null
null
null
null
UTF-8
C++
false
false
1,547
cpp
#include "OUAN_Precompiled.h" #include "GUIStorybook.h" #include "GUISubsystem.h" #include "../Core/GameRunningState.h" #include "../Application.h" using namespace OUAN; void GUIStoryBook::initGUI(GameStatePtr parentGameState) { GUIWindow::initGUI(parentGameState); setStrings(); } void GUIStoryBook::update(double elapsedSeconds) { } void GUIStoryBook::hideBook() { setBookVisibility(false); } void GUIStoryBook::showBook() { setBookVisibility(true); } void GUIStoryBook::setBookVisibility(bool visible) { CEGUI::Window* book= CEGUI::WindowManager::getSingletonPtr()->getWindow((CEGUI::utf8*)"OUANStory/Background"); if (book) book->setVisible(visible); } bool GUIStoryBook::isVisible() { if (CEGUI::WindowManager::getSingletonPtr()->isWindowPresent((CEGUI::utf8*)"OUANStory/Background")) { CEGUI::Window* book= CEGUI::WindowManager::getSingletonPtr()->getWindow((CEGUI::utf8*)"OUANStory/Background"); return book && book->isVisible(); } return false; } void GUIStoryBook::setPageText(int pageNumber,const std::string& text, bool readable) { std::stringstream winNameStr; winNameStr<<CEGUIWIN_ID_PAGE_PREFIX<<pageNumber; CEGUI::Window* win=CEGUI::WindowManager::getSingletonPtr()->getWindow(winNameStr.str()); if (win) { if (!readable) win->setFont(STORY_ENCRYPTED_FONT); win->setText(text); } } void GUIStoryBook::setStrings() { std::string windowNames[] = {CEGUIWIN_ID_STORY_EXIT}; int windowNamesLen=1; setGUIStrings(windowNames,windowNamesLen); }
[ "ithiliel@1610d384-d83c-11de-a027-019ae363d039" ]
[ [ [ 1, 60 ] ] ]
324be542480d5b89675a14830302ffa175dc7efc
eda410906c2ec64689d8c0b84f3c2862f469144b
/DropSendCore/dropsendservice.cpp
0ff97fec7fef0370b8b12cb96bdfd145f2fde37e
[]
no_license
redbox/Dropsend
640ea157a2caec88aa145f5bdc7fa85db95203a5
8fe4b4478616b9850b55011a506653026a28f7da
refs/heads/master
2020-06-02T20:54:18.301786
2010-09-06T16:16:05
2010-09-06T16:16:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,997
cpp
#include "dropsendservice.h" #include "./data/entities/user.h" using namespace dropsend; using namespace dropsend::data; DropSendService::DropSendService() : client_model_(NULL) { entity_factory_ = AbstractEntityFactory::getDAOFactory( AbstractEntityFactory::REMOTE_SERVER_FACTORY); entity_factory_->getDAOFactory(1); } bool DropSendService::login(const QString& login, const QString& password) { User* user = entity_factory_->getUserDAO()->getByLoginAndPassword(login, password); if (user == NULL) { return false; } Account* account = entity_factory_->getAccountDAO()->getById(user->getAccountId()); Plan* plan = entity_factory_->getPlanDAO()->getById(account->getPlanId()); QList<ReceivedFile*> received_files = entity_factory_->getReceivedFileDAO()->getByUserId(user->getId()); QList<SentFile*> sent_files = entity_factory_->getSentFileDAO()->getByUserId(user->getId()); client_model_ = new Client(); client_model_->update(user, account, plan, sent_files, received_files); return true; } Client* DropSendService::getCurrentClientModel() const{ return client_model_; } Account* DropSendService::getAccountByUser(int user_id) const { User* user = entity_factory_->getUserDAO()->getById(user_id); int account_id = user->getAccountId(); delete user; return entity_factory_->getAccountDAO()->getById(account_id); } Plan* DropSendService::getPlanByUser(int user_id) const { Account* account = getAccountByUser(user_id); int plan_id = account->getPlanId(); delete account; return entity_factory_->getPlanDAO()->getById(plan_id); } QList<ReceivedFile*> DropSendService::getReceivedFilesByUser(int user_id) const { return entity_factory_->getReceivedFileDAO()->getByUserId(user_id); } QList<SentFile*> DropSendService::getSentFilesByUser(int user_id) const { return entity_factory_->getSentFileDAO()->getByUserId(user_id); }
[ [ [ 1, 55 ] ] ]
25f3e9e766e509edda559d949fbdab30319f8eb9
3eae1d8c99d08bca129aceb7c2269bd70e106ff0
/trunk/Codes/Solutions/Windows/MiniCLR/VirtualKey.cpp
538bcdb6d89c8824eba8f22993f72c810b2ddece
[]
no_license
yuaom/miniclr
9bfd263e96b0d418f6f6ba08cfe4c7e2a8854082
4d41d3d5fb0feb572f28cf71e0ba02acb9b95dc1
refs/heads/master
2023-06-07T09:10:33.703929
2010-12-27T14:41:18
2010-12-27T14:41:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
638
cpp
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Copyright (c) Microsoft Corporation. All rights reserved. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include "stdafx.h" GPIO_PIN VirtualKey_GetPins(UINT32 virtualKey) { return 0; //return EmulatorNative::GetIGpioDriver()->GetVirtualKeyPin(virtualKey); }
[ [ [ 1, 12 ] ] ]
459b0895683bf20cb4e7472632aaf2f13c8f5f49
5dc6c87a7e6459ef8e832774faa4b5ae4363da99
/vis_avs/r_grain.cpp
c4bd72ea10027b2af5fa9ddccbc260c1dc5f0344
[]
no_license
aidinabedi/avs4unity
407603d2fc44bc8b075b54cd0a808250582ee077
9b6327db1d092218e96d8907bd14d68b741dcc4d
refs/heads/master
2021-01-20T15:27:32.449282
2010-12-24T03:28:09
2010-12-24T03:28:09
90,773,183
5
2
null
null
null
null
UTF-8
C++
false
false
11,075
cpp
/* LICENSE ------- Copyright 2005 Nullsoft, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Nullsoft 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 "config.h" #include <windows.h> #include <stdlib.h> #include <vfw.h> #include <commctrl.h> #include "resource.h" #include "r_defs.h" #ifndef LASER #define MOD_NAME "Trans / Grain" #define C_THISCLASS C_GrainClass class C_THISCLASS : public C_RBASE { protected: public: C_THISCLASS(); virtual ~C_THISCLASS(); virtual int render(char visdata[2][2][SAMPLES], int isBeat, int *framebuffer, int *fbout, int w, int h); virtual char *get_desc() { return MOD_NAME; } virtual HWND conf(HINSTANCE hInstance, HWND hwndParent); virtual void load_config(unsigned char *data, int len); virtual int save_config(unsigned char *data); unsigned char __inline fastrandbyte(void); void reinit(int w, int h); int enabled; int blend, blendavg, smax; unsigned char *depthBuffer; int oldx, oldy; int staticgrain; unsigned char randtab[491]; int randtab_pos; }; static C_THISCLASS *g_ConfigThis; // global configuration dialog pointer static HINSTANCE g_hDllInstance; // global DLL instance pointer (not needed in this example, but could be useful) C_THISCLASS::~C_THISCLASS() // set up default configuration { if (depthBuffer) GlobalFree(depthBuffer); } // configuration read/write C_THISCLASS::C_THISCLASS() // set up default configuration { blend=0; blendavg=0; smax=100; enabled=1; oldx=0; oldy=0; staticgrain=0; depthBuffer=NULL; int x; for (x = 0 ;x < sizeof(randtab); x ++) randtab[x]=rand()&255; randtab_pos=rand()%sizeof(randtab); } unsigned char __inline C_THISCLASS::fastrandbyte(void) { unsigned char r=randtab[randtab_pos]; randtab_pos++; if (!(randtab_pos&15)) { randtab_pos+=rand()%73; } if (randtab_pos >= 491) randtab_pos-=491; return r; } #define GET_INT() (data[pos]|(data[pos+1]<<8)|(data[pos+2]<<16)|(data[pos+3]<<24)) void C_THISCLASS::load_config(unsigned char *data, int len) // read configuration of max length "len" from data. { int pos=0; if (len-pos >= 4) { enabled=GET_INT(); pos+=4; } if (len-pos >= 4) { blend=GET_INT(); pos+=4; } if (len-pos >= 4) { blendavg=GET_INT(); pos+=4; } if (len-pos >= 4) { smax=GET_INT(); pos+=4; } if (len-pos >= 4) { staticgrain=GET_INT(); pos+=4; } } #define PUT_INT(y) data[pos]=(y)&255; data[pos+1]=(y>>8)&255; data[pos+2]=(y>>16)&255; data[pos+3]=(y>>24)&255 int C_THISCLASS::save_config(unsigned char *data) // write configuration to data, return length. config data should not exceed 64k. { int pos=0; PUT_INT(enabled); pos+=4; PUT_INT(blend); pos+=4; PUT_INT(blendavg); pos+=4; PUT_INT(smax); pos+=4; PUT_INT(staticgrain); pos+=4; return pos; } void C_THISCLASS::reinit(int w, int h) { int x,y; unsigned char *p; if (depthBuffer) GlobalFree(depthBuffer); depthBuffer = (unsigned char *)GlobalAlloc(GMEM_FIXED,w*h*2); p = depthBuffer; if (p) for (y=0;y<h;y++) for (x=0;x<w;x++) { *p++ = (rand()%255); *p++ = (rand()%100); } } // render function // render should return 0 if it only used framebuffer, or 1 if the new output data is in fbout. this is // used when you want to do something that you'd otherwise need to make a copy of the framebuffer. // w and h are the width and height of the screen, in pixels. // isBeat is 1 if a beat has been detected. // visdata is in the format of [spectrum:0,wave:1][channel][band]. int C_THISCLASS::render(char visdata[2][2][SAMPLES], int isBeat, int *framebuffer, int *fbout, int w, int h) { if (isBeat&0x80000000) return 0; if (!enabled) return 0; int smax_sc = (smax*255)/100; int *p; unsigned char *q; int l=w*h; if (w != oldx || h != oldy) { reinit(w, h); oldx = w; oldy = h; } randtab_pos+=rand()%300; if (randtab_pos >= 491) randtab_pos-=491; p = framebuffer; q = depthBuffer; if (staticgrain) { if (blend) { while (l--) { if (*p) { int c=0; if (q[1] < smax_sc) { int s = q[0]; int r=(((p[0]&0xff0000)*s)>>8); if (r > 0xff0000) r=0xff0000; c|=r&0xff0000; r=(((p[0]&0xff00)*s)>>8); if (r > 0xff00) r=0xff00; c|=r&0xff00; r=(((p[0]&0xff)*s)>>8); if (r > 0xff) r=0xff; c|=r; } *p = BLEND(*p, c); } p++; q+=2; } } else if (blendavg) { while (l--) { if (*p) { int c=0; if (q[1] < smax_sc) { int s = q[0]; int r=(((p[0]&0xff0000)*s)>>8); if (r > 0xff0000) r=0xff0000; c|=r&0xff0000; r=(((p[0]&0xff00)*s)>>8); if (r > 0xff00) r=0xff00; c|=r&0xff00; r=(((p[0]&0xff)*s)>>8); if (r > 0xff) r=0xff; c|=r; } *p = BLEND_AVG(*p, c); } p++; q+=2; } } else { while (l--) { if (*p) { int c=0; if (q[1] < smax_sc) { int s = q[0]; int r=(((p[0]&0xff0000)*s)>>8); if (r > 0xff0000) r=0xff0000; c|=r&0xff0000; r=(((p[0]&0xff00)*s)>>8); if (r > 0xff00) r=0xff00; c|=r&0xff00; r=(((p[0]&0xff)*s)>>8); if (r > 0xff) r=0xff; c|=r; } *p = c; } p++; q+=2; } } } else { if (blend) { while (l--) { if (*p) { int c=0; if (fastrandbyte() < smax_sc) { int s = fastrandbyte(); int r=(((p[0]&0xff0000)*s)>>8); if (r > 0xff0000) r=0xff0000; c|=r&0xff0000; r=(((p[0]&0xff00)*s)>>8); if (r > 0xff00) r=0xff00; c|=r&0xff00; r=(((p[0]&0xff)*s)>>8); if (r > 0xff) r=0xff; c|=r; } *p = BLEND(*p, c); } p++; q+=2; } } else if (blendavg) { while (l--) { if (*p) { int c=0; if (fastrandbyte() < smax_sc) { int s = fastrandbyte(); int r=(((p[0]&0xff0000)*s)>>8); if (r > 0xff0000) r=0xff0000; c|=r&0xff0000; r=(((p[0]&0xff00)*s)>>8); if (r > 0xff00) r=0xff00; c|=r&0xff00; r=(((p[0]&0xff)*s)>>8); if (r > 0xff) r=0xff; c|=r; } *p = BLEND_AVG(*p, c); } p++; q+=2; } } else { while (l--) { if (*p) { int c=0; if (fastrandbyte() < smax_sc) { int s = fastrandbyte(); int r=(((p[0]&0xff0000)*s)>>8); if (r > 0xff0000) r=0xff0000; c|=r&0xff0000; r=(((p[0]&0xff00)*s)>>8); if (r > 0xff00) r=0xff00; c|=r&0xff00; r=(((p[0]&0xff)*s)>>8); if (r > 0xff) r=0xff; c|=r; } *p = c; } p++; q+=2; } } } return 0; } // configuration dialog stuff static BOOL CALLBACK g_DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: SendDlgItemMessage(hwndDlg, IDC_MAX, TBM_SETTICFREQ, 10, 0); SendDlgItemMessage(hwndDlg, IDC_MAX, TBM_SETRANGE, TRUE, MAKELONG(0, 100)); SendDlgItemMessage(hwndDlg, IDC_MAX, TBM_SETPOS, TRUE, g_ConfigThis->smax); if (g_ConfigThis->enabled) CheckDlgButton(hwndDlg,IDC_CHECK1,BST_CHECKED); if (g_ConfigThis->staticgrain) CheckDlgButton(hwndDlg,IDC_STATGRAIN,BST_CHECKED); if (g_ConfigThis->blend) CheckDlgButton(hwndDlg,IDC_ADDITIVE,BST_CHECKED); if (g_ConfigThis->blendavg) CheckDlgButton(hwndDlg,IDC_5050,BST_CHECKED); if (!g_ConfigThis->blend && !g_ConfigThis->blendavg) CheckDlgButton(hwndDlg,IDC_REPLACE,BST_CHECKED); return 1; case WM_NOTIFY: { if (LOWORD(wParam) == IDC_MAX) g_ConfigThis->smax = SendDlgItemMessage(hwndDlg, IDC_MAX, TBM_GETPOS, 0, 0); return 0; } case WM_COMMAND: if ((LOWORD(wParam) == IDC_CHECK1) || (LOWORD(wParam) == IDC_STATGRAIN) || (LOWORD(wParam) == IDC_ADDITIVE) || (LOWORD(wParam) == IDC_REPLACE) || (LOWORD(wParam) == IDC_5050) ) { g_ConfigThis->enabled=IsDlgButtonChecked(hwndDlg,IDC_CHECK1)?1:0; g_ConfigThis->blend=IsDlgButtonChecked(hwndDlg,IDC_ADDITIVE)?1:0; g_ConfigThis->blendavg=IsDlgButtonChecked(hwndDlg,IDC_5050)?1:0; g_ConfigThis->staticgrain=IsDlgButtonChecked(hwndDlg,IDC_STATGRAIN)?1:0; } return 0; } return 0; } HWND C_THISCLASS::conf(HINSTANCE hInstance, HWND hwndParent) // return NULL if no config dialog possible { g_ConfigThis = this; return CreateDialog(hInstance,MAKEINTRESOURCE(IDD_CFG_GRAIN),hwndParent,g_DlgProc); } // export stuff C_RBASE *R_Grain(char *desc) // creates a new effect object if desc is NULL, otherwise fills in desc with description { if (desc) { strcpy(desc,MOD_NAME); return NULL; } return (C_RBASE *) new C_THISCLASS(); } #else C_RBASE *R_Grain(char *desc) // creates a new effect object if desc is NULL, otherwise fills in desc with description { return NULL; } #endif
[ [ [ 1, 403 ] ] ]
f1c590332b36522e400bcb99b7138e1cdf5a64c3
580738f96494d426d6e5973c5b3493026caf8b6a
/Source/vcl/vclhlpr2.cpp
96f64f3613e4dc7200ffb3bdd7f979817796a96b
[]
no_license
bravesoftdz/cbuilder-vcl
6b460b4d535d17c309560352479b437d99383d4b
7b91ef1602681e094a6a7769ebb65ffd6f291c59
refs/heads/master
2021-01-10T14:21:03.726693
2010-01-11T11:23:45
2010-01-11T11:23:45
48,485,606
2
1
null
null
null
null
UTF-8
C++
false
false
5,942
cpp
#include <vcl.h> #include "vclhlpr2.h" // // This file contains the implementations of the static members of // Vclhlpr. There are three parts to this header: // // 1) dummy definitions. when VCLHLPR_GENSYMS is defined, there are // "no-op" definitions for the static members that will be mapped // directly into the pascal rtl. after compiling, "tdump -m -oicomdef: vclhlpr2.obj" // will dump out the mangled versions of each of these functions. // // 2) alias records that map the members of Vclhlpr to routines in the // pascal rtl. the pascal manglings are maintained by hand. this // section is the "#else" part of the above "#ifdef VCLHLPR_GENSYMS" // // 3) methods that are implemented in C++. // #ifdef VCLHLPR_GENSYMS void __fastcall Vclhlpr::VarCopy(System::Variant& dst, const System::Variant& src) {} void __fastcall Vclhlpr::VarAdd(System::Variant& dst, const System::Variant& src) {} void __fastcall Vclhlpr::VarSub(System::Variant& dst, const System::Variant& src) {} void __fastcall Vclhlpr::VarMul(System::Variant& dst, const System::Variant& src) {} void __fastcall Vclhlpr::VarDiv(System::Variant& dst, System::Variant src) {} void __fastcall Vclhlpr::VarMod(System::Variant& dst, const System::Variant& src) {} void __fastcall Vclhlpr::VarShl(System::Variant& dst, const System::Variant& src) {} void __fastcall Vclhlpr::VarShr(System::Variant& dst, const System::Variant& src) {} void __fastcall Vclhlpr::VarAnd(System::Variant& dst, const System::Variant& src) {} void __fastcall Vclhlpr::VarOr(System::Variant& dst, const System::Variant& src) {} void __fastcall Vclhlpr::VarXor(System::Variant& dst, const System::Variant& src) {} void __fastcall VarCmpSysEQ(const System::Variant&, const System::Variant &) { } void __fastcall VarCmpSysLT(const System::Variant&, const System::Variant &) { } void __fastcall VarCmpSysGT(const System::Variant&, const System::Variant &) { } void __fastcall Vclhlpr::VarNot(System::Variant&) {} void __fastcall Vclhlpr::VarNeg(System::Variant&) {} System::Variant __cdecl Vclhlpr::VarArrayGet(const System::Variant&, int IndexCount, ...) {} void __cdecl Vclhlpr::VarArrayPut(System::Variant&, const System::Variant &, int IndexCount, ...) {} void __fastcall Vclhlpr::VarClear(System::Variant&) {} void __fastcall Vclhlpr::VarCast(System::Variant&, const System::Variant&, int) {} void __fastcall Vclhlpr::VarArrayRedim(System::Variant&, int) {} #else #pragma alias "@Vclhlpr@VarCopy$qqrr14System@Variantrx14System@Variant" \ = "@System@@VarCopy$qqrr14System@Variantrx14System@Variant" #pragma alias "@Vclhlpr@VarAdd$qqrr14System@Variantrx14System@Variant" \ = "@System@@VarAdd$qqrr14System@Variantrx14System@Variant" #pragma alias "@Vclhlpr@VarSub$qqrr14System@Variantrx14System@Variant" \ = "@System@@VarSub$qqrr14System@Variantrx14System@Variant" #pragma alias "@Vclhlpr@VarMul$qqrr14System@Variantrx14System@Variant" \ = "@System@@VarMul$qqrr14System@Variantrx14System@Variant" #pragma alias "@Vclhlpr@VarDiv$qqrr14System@Variantrx14System@Variant" \ = "@System@@VarDiv$qqrr14System@Variantrx14System@Variant" #pragma alias "@Vclhlpr@VarMod$qqrr14System@Variantrx14System@Variant" \ = "@System@@VarMod$qqrr14System@Variantrx14System@Variant" #pragma alias "@Vclhlpr@VarShl$qqrr14System@Variantrx14System@Variant" \ = "@System@@VarShl$qqrr14System@Variantrx14System@Variant" #pragma alias "@Vclhlpr@VarShr$qqrr14System@Variantrx14System@Variant" \ = "@System@@VarShr$qqrr14System@Variantrx14System@Variant" #pragma alias "@Vclhlpr@VarAnd$qqrr14System@Variantrx14System@Variant" \ = "@System@@VarAnd$qqrr14System@Variantrx14System@Variant" #pragma alias "@Vclhlpr@VarOr$qqrr14System@Variantrx14System@Variant" \ = "@System@@VarOr$qqrr14System@Variantrx14System@Variant" #pragma alias "@Vclhlpr@VarXor$qqrr14System@Variantrx14System@Variant" \ = "@System@@VarXor$qqrr14System@Variantrx14System@Variant" #pragma alias "@Vclhlpr@VarCmpSysEQ$qqrrx14System@Variantt1" \ = "@System@@VarCmpEQ$qqrrx14System@Variantt1" #pragma alias "@Vclhlpr@VarCmpSysLT$qqrrx14System@Variantt1" \ = "@System@@VarCmpLT$qqrrx14System@Variantt1" #pragma alias "@Vclhlpr@VarCmpSysGT$qqrrx14System@Variantt1" \ = "@System@@VarCmpGT$qqrrx14System@Variantt1" #pragma alias "@Vclhlpr@VarNot$qqrr14System@Variant" \ = "@System@@VarNot$qqrr14System@Variant" #pragma alias "@Vclhlpr@VarNeg$qqrr14System@Variant" \ = "@System@@VarNeg$qqrr14System@Variant" #pragma alias "@Vclhlpr@VarArrayGet$qrx14System@Variantie" \ = "@System@@VarArrayGet$qr14System@Variantii" #pragma alias "@Vclhlpr@VarArrayPut$qr14System@Variantrx14System@Variantie" \ = "@System@@VarArrayPut$qr14System@Variantrx14System@Variantii" #pragma alias "@System@VarClear$qqrr14System@Variant" \ = "@System@@VarClear$qqrr14System@Variant" #pragma alias "@Variants@VarCast$qqrr14System@Variantrx14System@Varianti" \ = "@System@@VarCast$qqrr14System@Variantrx14System@Varianti" #pragma alias "@System@VarArrayRedim$qqrr14System@Varianti" \ = "@System@@VarArrayRedim$qqrr14System@Varianti" #pragma alias "@Variants@VarArrayRedim$qqrr14System@Varianti" \ = "@System@@VarArrayRedim$qqrr14System@Varianti" #endif // VCLHLPR_GENSYMS int __fastcall Vclhlpr::VarCmp(const System::Variant &x, const System::Variant &y, int Op) { // VarCmpSysnn sets EFLAGS after the compare, so we'll convert things to // the more normal [-1, 0, 1] if (Op == 0) VarCmpSysEQ(x, y); else if (Op > 0) VarCmpSysGT(x, y); else VarCmpSysLT(x, y); const EFL_CARRY = 1UL << 0; const EFL_ZERO = 1UL << 6; if (_FLAGS & EFL_ZERO) return 0; else if (_FLAGS & EFL_CARRY) return -1; else return 1; }
[ "bitscode@7bd08ab0-fa70-11de-930f-d36749347e7b" ]
[ [ [ 1, 136 ] ] ]
7581bc35bdf0e6d56fc97ae6527e831e4b0cce35
33f59b1ba6b12c2dd3080b24830331c37bba9fe2
/Depend/Foundation/ComputationalGeometry/Wm4Query2.inl
23942b1ac0948da812d6555e1d893f1d4d7decae
[]
no_license
daleaddink/flagship3d
4835c223fe1b6429c12e325770c14679c42ae3c6
6cce5b1ff7e7a2d5d0df7aa0594a70d795c7979a
refs/heads/master
2021-01-15T16:29:12.196094
2009-11-01T10:18:11
2009-11-01T10:18:11
37,734,654
1
0
null
null
null
null
UTF-8
C++
false
false
5,031
inl
// Geometric Tools, Inc. // http://www.geometrictools.com // Copyright (c) 1998-2006. All Rights Reserved // // The Wild Magic Version 4 Foundation Library source code is supplied // under the terms of the license agreement // http://www.geometrictools.com/License/Wm4FoundationLicense.pdf // and may not be copied or disclosed except in accordance with the terms // of that agreement. //---------------------------------------------------------------------------- template <class Real> Query2<Real>::Query2 (int iVQuantity, const Vector2<Real>* akVertex) { assert(iVQuantity > 0 && akVertex); m_iVQuantity = iVQuantity; m_akVertex = akVertex; } //---------------------------------------------------------------------------- template <class Real> Query2<Real>::~Query2 () { } //---------------------------------------------------------------------------- template <class Real> Query::Type Query2<Real>::GetType () const { return Query::QT_REAL; } //---------------------------------------------------------------------------- template <class Real> int Query2<Real>::GetQuantity () const { return m_iVQuantity; } //---------------------------------------------------------------------------- template <class Real> const Vector2<Real>* Query2<Real>::GetVertices () const { return m_akVertex; } //---------------------------------------------------------------------------- template <class Real> int Query2<Real>::ToLine (int i, int iV0, int iV1) const { return ToLine(m_akVertex[i],iV0,iV1); } //---------------------------------------------------------------------------- template <class Real> int Query2<Real>::ToLine (const Vector2<Real>& rkP, int iV0, int iV1) const { const Vector2<Real>& rkV0 = m_akVertex[iV0]; const Vector2<Real>& rkV1 = m_akVertex[iV1]; Real fX0 = rkP[0] - rkV0[0]; Real fY0 = rkP[1] - rkV0[1]; Real fX1 = rkV1[0] - rkV0[0]; Real fY1 = rkV1[1] - rkV0[1]; Real fDet2 = Det2(fX0,fY0,fX1,fY1); return (fDet2 > (Real)0.0 ? +1 : (fDet2 < (Real)0.0 ? -1 : 0)); } //---------------------------------------------------------------------------- template <class Real> int Query2<Real>::ToTriangle (int i, int iV0, int iV1, int iV2) const { return ToTriangle(m_akVertex[i],iV0,iV1,iV2); } //---------------------------------------------------------------------------- template <class Real> int Query2<Real>::ToTriangle (const Vector2<Real>& rkP, int iV0, int iV1, int iV2) const { int iSign0 = ToLine(rkP,iV1,iV2); if (iSign0 > 0) { return +1; } int iSign1 = ToLine(rkP,iV0,iV2); if (iSign1 < 0) { return +1; } int iSign2 = ToLine(rkP,iV0,iV1); if (iSign2 > 0) { return +1; } return ((iSign0 && iSign1 && iSign2) ? -1 : 0); } //---------------------------------------------------------------------------- template <class Real> int Query2<Real>::ToCircumcircle (int i, int iV0, int iV1, int iV2) const { return ToCircumcircle(m_akVertex[i],iV0,iV1,iV2); } //---------------------------------------------------------------------------- template <class Real> int Query2<Real>::ToCircumcircle (const Vector2<Real>& rkP, int iV0, int iV1, int iV2) const { const Vector2<Real>& rkV0 = m_akVertex[iV0]; const Vector2<Real>& rkV1 = m_akVertex[iV1]; const Vector2<Real>& rkV2 = m_akVertex[iV2]; Real fS0x = rkV0[0] + rkP[0]; Real fD0x = rkV0[0] - rkP[0]; Real fS0y = rkV0[1] + rkP[1]; Real fD0y = rkV0[1] - rkP[1]; Real fS1x = rkV1[0] + rkP[0]; Real fD1x = rkV1[0] - rkP[0]; Real fS1y = rkV1[1] + rkP[1]; Real fD1y = rkV1[1] - rkP[1]; Real fS2x = rkV2[0] + rkP[0]; Real fD2x = rkV2[0] - rkP[0]; Real fS2y = rkV2[1] + rkP[1]; Real fD2y = rkV2[1] - rkP[1]; Real fZ0 = fS0x*fD0x + fS0y*fD0y; Real fZ1 = fS1x*fD1x + fS1y*fD1y; Real fZ2 = fS2x*fD2x + fS2y*fD2y; Real fDet3 = Det3(fD0x,fD0y,fZ0,fD1x,fD1y,fZ1,fD2x,fD2y,fZ2); return (fDet3 < (Real)0.0 ? 1 : (fDet3 > (Real)0.0 ? -1 : 0)); } //---------------------------------------------------------------------------- template <class Real> Real Query2<Real>::Dot (Real fX0, Real fY0, Real fX1, Real fY1) { return fX0*fX1 + fY0*fY1; } //---------------------------------------------------------------------------- template <class Real> Real Query2<Real>::Det2 (Real fX0, Real fY0, Real fX1, Real fY1) { return fX0*fY1 - fX1*fY0; } //---------------------------------------------------------------------------- template <class Real> Real Query2<Real>::Det3 (Real fX0, Real fY0, Real fZ0, Real fX1, Real fY1, Real fZ1, Real fX2, Real fY2, Real fZ2) { Real fC00 = fY1*fZ2 - fY2*fZ1; Real fC01 = fY2*fZ0 - fY0*fZ2; Real fC02 = fY0*fZ1 - fY1*fZ0; return fX0*fC00 + fX1*fC01 + fX2*fC02; } //----------------------------------------------------------------------------
[ "yf.flagship@e79fdf7c-a9d8-11de-b950-3d5b5f4ea0aa" ]
[ [ [ 1, 149 ] ] ]
8382430c16127815dcdf4fb004558f624829c6f1
d8f64a24453c6f077426ea58aaa7313aafafc75c
/GUI/DKInput.cpp
1a998dfd63abc6f0fa66c752cc6071d1255766a3
[]
no_license
dotted/wfto
5b98591645f3ddd72cad33736da5def09484a339
6eebb66384e6eb519401bdd649ae986d94bcaf27
refs/heads/master
2021-01-20T06:25:20.468978
2010-11-04T21:01:51
2010-11-04T21:01:51
32,183,921
1
0
null
null
null
null
UTF-8
C++
false
false
3,447
cpp
#include "../commons.h" #include <windows.h> #include <gl\gl.h> #include "DKInput.h" #include <math.h> using namespace game_utils; CDKInput::CDKInput() { for (GLuint i=0; i<256; i++) keys[i]=false; z_depth=wsw=w_2=h_2=0.0f; cos_45=0.70710678118f; lmouse_down=rmouse_down=false; } CDKInput::~CDKInput() { } GLint CDKInput::get_screen_x() { POINT p; GetCursorPos(&p); ScreenToClient(CV_WINDOW_HANDLE,&p); return p.x; } GLint CDKInput::get_screen_y() { POINT p; GetCursorPos(&p); ScreenToClient(CV_WINDOW_HANDLE,&p); return p.y; } GLvoid CDKInput::set_z_depth(GLfloat z_depth) { this->z_depth=z_depth; wsw=fabs(1.1044f*z_depth); wsh=fabs(0.8283f*z_depth); w_2=1024/2; h_2=768/2; } GLfloat CDKInput::get_world_x() { GLfloat mx=(GLfloat)get_screen_x(); if (mx<=w_2) { return -(wsw/2-((wsw/2)*mx)/w_2); } else { return ((wsw/2)*(mx-w_2))/w_2; } } GLfloat CDKInput::get_world_y() { GLfloat my=(GLfloat)get_screen_y(); if (my<=h_2) { return wsh/2-((wsh/2)*my)/h_2; } else { return -((wsh/2)*(my-h_2))/h_2; } } GLvoid CDKInput::update(UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_KEYDOWN: { keys[wParam]=true; break; // Jump Back } case WM_KEYUP: { keys[wParam]=false; break; } case WM_LBUTTONDOWN: { lmouse_down=true; break; } case WM_LBUTTONUP: { lmouse_down=false; break; } case WM_RBUTTONDOWN: { rmouse_down=true; break; } case WM_RBUTTONUP: { rmouse_down=false; break; } } } bool CDKInput::is_left_down() { return keys[VK_LEFT]; } bool CDKInput::is_right_down() { return keys[VK_RIGHT]; } bool CDKInput::is_up_down() { return keys[VK_UP]; } bool CDKInput::is_down_down() { return keys[VK_DOWN]; } bool CDKInput::is_esc_down() { return keys[VK_ESCAPE]; } bool CDKInput::is_space_down() { return keys[VK_SPACE]; } bool CDKInput::is_enter_down() { return keys[VK_RETURN]; } bool CDKInput::is_shift_down() { return keys[VK_SHIFT]; } bool CDKInput::is_tab_down() { return keys[VK_TAB]; } bool CDKInput::is_control_down() { return keys[VK_CONTROL]; } bool CDKInput::is_key_down(char key) { return keys[key]; } bool CDKInput::is_plus_down() { return keys[VK_ADD]; } bool CDKInput::is_minus_down() { return keys[VK_SUBTRACT]; } bool CDKInput::is_F1_down() { return keys[VK_F1]; } bool CDKInput::is_F2_down() { return keys[VK_F2]; } bool CDKInput::is_F3_down() { return keys[VK_F3]; } bool CDKInput::is_F4_down() { return keys[VK_F4]; } bool CDKInput::is_F5_down() { return keys[VK_F5]; } bool CDKInput::is_F6_down() { return keys[VK_F6]; } bool CDKInput::is_F7_down() { return keys[VK_F7]; } bool CDKInput::is_F8_down() { return keys[VK_F8]; } bool CDKInput::is_F9_down() { return keys[VK_F9]; } bool CDKInput::is_F10_down() { return keys[VK_F10]; } bool CDKInput::is_F11_down() { return keys[VK_F11]; } bool CDKInput::is_F12_down() { return keys[VK_F12]; } GLvoid CDKInput::set_mouse_pos(GLint xpos, GLint ypos) { SetCursorPos(xpos,ypos); } bool CDKInput::is_lmouse_down() { return lmouse_down; } bool CDKInput::is_rmouse_down() { return rmouse_down; }
[ [ [ 1, 259 ] ] ]
126e37cbd19403987f6e7a81f948c4e98c870546
c70941413b8f7bf90173533115c148411c868bad
/plugins/CairoPlugin/include/vtxcai.h
a18ecb0ef1dddc6e239c48f7e82331d6b3706581
[]
no_license
cnsuhao/vektrix
ac6e028dca066aad4f942b8d9eb73665853fbbbe
9b8c5fa7119ff7f3dc80fb05b7cdba335cf02c1a
refs/heads/master
2021-06-23T11:28:34.907098
2011-03-27T17:39:37
2011-03-27T17:39:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,650
h
/* ----------------------------------------------------------------------------- This source file is part of "vektrix" (the rich media and vector graphics rendering library) For the latest info, see http://www.fuse-software.com/ Copyright (c) 2009-2010 Fuse-Software (tm) 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. ----------------------------------------------------------------------------- */ #ifndef __vtxcai_H__ #define __vtxcai_H__ #include "vtxPrerequisites.h" #define vtxcaiExport namespace vtx { /** The namespace for all classes of the Cairo plugin */ namespace cai { class CairoRasterizer; } } #endif
[ "stonecold_@9773a11d-1121-4470-82d2-da89bd4a628a", "fixxxeruk@9773a11d-1121-4470-82d2-da89bd4a628a" ]
[ [ [ 1, 31 ], [ 33, 45 ] ], [ [ 32, 32 ] ] ]
c1ac6ced27f60ee4a9115654fdc99f0f9347f741
8aa65aef3daa1a52966b287ffa33a3155e48cc84
/Source/World/Entity.h
e5aa90ceaad4d52554b9457f51b6d5e2fd6c8cbe
[]
no_license
jitrc/p3d
da2e63ef4c52ccb70023d64316cbd473f3bd77d9
b9943c5ee533ddc3a5afa6b92bad15a864e40e1e
refs/heads/master
2020-04-15T09:09:16.192788
2009-06-29T04:45:02
2009-06-29T04:45:02
37,063,569
1
0
null
null
null
null
UTF-8
C++
false
false
10,528
h
#pragma once #include "CollisionModel.h" namespace P3D { namespace World { using namespace P3D::Graphics; class CompoundEntity; class World; class RendererContext; class EntityController; /* Something in the world that has position and orientation and can render itself. */ class Entity : public Object, public ObjectWithTags { friend class CompoundEntity; friend class World; friend class Camera; friend class Controller; public: // Available entity classes enum EntityClass { Entity_World, Entity_Compound, Entity_Simple, Entity_Camera }; Entity(World* parent); virtual ~Entity(); /* Return entity class. */ virtual EntityClass GetClass() const { return Entity_Simple; } /* Push current matrix. Load transform matrix. call DoRender Pop matrix. */ void Render(const RendererContext& params); /* Called after world has been build before first update. */ virtual void Prepare(); /* Simulate physics, do thinking etc. Return true in case update happend i.e. tick counter changed since last update. */ virtual bool Update(); /* Return entity that contains this entity. */ inline CompoundEntity* GetParentEntity() const { return _parent; } /* Return world the entity is in. */ inline World* GetWorld() { return _parentWorld; } /* Returns transform from objects space to world space. */ inline const QTransform& GetTransformToWorldSpace() const { return _toWorldSpace(); } /* Changes object transform matrix so that transform to world space == transform. */ void SetTransformToWorldSpace(const QTransform& transform); /* Return bounding box in the object space. */ inline const AABB& GetBoundingBox() const { return _bbox(); } /* Return bounding box in the parent's object space. */ inline const AABB& GetBoundingBoxInParentSpace() const { return _bboxInPS(); } /* Return QTransform from object space to parent space. */ inline const QTransform& GetTransform() const { return _objectTransform; } /* Set QTransform from object space to parent space. */ inline void SetTransform(const QTransform& transform) { _objectTransform = transform; InvalidateObjectTransform(); } /* Return matrix based transform from objects space to parent space. */ inline const Transform& GetMatrixTransform() const { return _transform(); } /* Return matrix based transform from parent space to object space. */ inline const Transform& GetInvMatrixTransform() const { return _invTransform(); } /* Says that entity should recalculate bounding box next time its required. */ inline void InvalidateBoundingBox() { _bbox.Invalidate(); _bboxInPS.Invalidate(); if (_parent) ((Entity*)_parent)->InvalidateBoundingBox(); } /* Return entities random color (for debug purposes). */ inline uint32 GetColor() { return _color; } /* Controls the visibility of the entity. */ virtual void SetVisible(bool visible) { _visible = visible; InvalidateBoundingBox(); } /* Is entity visible? */ inline bool IsVisible() const { return _visible; } /* Sets entities controller. AddRefs the controller. By default each entity use controller provided by PhysicalWorld. */ virtual void SetController(EntityController* controller); /* Get current active controller. */ inline EntityController* GetController() const { return _controller; } /* Set the collision model of the entity. */ inline void SetCollisionModel(Physics::CollisionModel* model) { _collisionModel = model; } /* Return entities collision model if any. */ inline Physics::CollisionModel* GetCollisionModel() const { return _collisionModel; } /* Return entity mass. */ inline Scalar GetMass() const { return _mass; } /* Set entity mass. 0 means infinity. */ inline void SetMass(Scalar mass) { _mass = mass; } protected: /* Set's opaque pointer to some controller specific stuff. Should be called by EntityController only. */ void SetControllerData(void* controllerData) { _controllerData = controllerData; } /* Return stored controller data. Should be called by EntityController only. */ void* GetControllerData() { return _controllerData; } /* Multiply current OpenGL matrix by ObjectTransform matrix. */ inline void ApplyTransform() const { GLfloat transformMatrix[4][4]; GetMatrixTransform().ToOpenGLMatrix(transformMatrix); glMultMatrixf(&transformMatrix[0][0]); } /* Multiply current OpenGL matrix by ObjectTransform^-1 matrix. */ inline void ApplyInvTransform() const { GLfloat invTransformMatrix[4][4]; GetInvMatrixTransform().ToOpenGLMatrix(invTransformMatrix); glMultMatrixf(&invTransformMatrix[0][0]); } /* Render object in the object space. To render child objects call Render RendererContext in objects space. */ virtual void DoRender(const RendererContext& params); /* Recalculate bounding box. */ virtual void RecalculateBoundingBox(AABB& box) { if (!IsVisible()) box.SetImpossible(); else box.SetZero(); } /* Was Update called during this tick? */ bool NeedUpdate(); /* Says that entity should recalculate transform to world space. */ virtual void InvalidateTransformToWorldSpace() { _toWorldSpace.Invalidate(); } /* Call this when you change ObjectTransform to update OpenGL transformation matrix and other important stuff. */ inline void InvalidateObjectTransform() { _transform.Invalidate(); _invTransform.Invalidate(); InvalidateTransformToWorldSpace(); _bboxInPS.Invalidate(); if (_parent) ((Entity*)_parent)->InvalidateBoundingBox(); } private: struct OpenGLMatrix { GLfloat Matrix[4][4]; }; /* Recalculate OpenGL transform matrix from ObjectTransform. */ inline void RecalculateTransform(Transform& t) { t = Transform(GetTransform()); } /* Recalculate OpenGL invert transform matrix from ObjectTransform. Reset dirty flag. */ inline void RecalculateInvTransform(Transform& t) { t = GetMatrixTransform(); t.Invert(); } /* Recalculate QTransform from object space to world space. */ void RecalculateTransformToWorld(QTransform& transform); /* Recalculates bounding box in parent space. */ inline void RecalculateBoundingBoxInPS(AABB& bbox) { if (!IsVisible()) bbox.SetImpossible(); else { bbox = GetBoundingBox(); bbox.Transform(GetMatrixTransform()); } } private: Lazy<Entity, Transform> _transform; // ObjectTransform in matrix form Lazy<Entity, Transform> _invTransform; // _transform ^ -1 Lazy<Entity, QTransform> _toWorldSpace; // transform from object space to world space Lazy<Entity, AABB> _bbox; // bounding box in object space Lazy<Entity, AABB> _bboxInPS; // bounding box in parent space QTransform _objectTransform; CompoundEntity* _parent; // parent entity World* _parentWorld; // the world this entity is in uint _lastUpdateTick; // last tick count of the timer bool _prepareCalled; uint32 _color; // random color of the entity bool _visible; // visibility status bool _solid; SmartPointer<EntityController> _controller; // object that controls entity position void* _controllerData; SmartPointer<Physics::CollisionModel> _collisionModel; Scalar _mass; }; } } #include "CompoundEntity.h" #include "RendererContext.h"
[ "vadun87@6320d0be-1f75-11de-b650-e715bd6d7cf1" ]
[ [ [ 1, 326 ] ] ]
9648dd07c86058a6461af721ad9c05e35e21b542
2199870f3077e1005a36cd1cb2382368aeb977de
/faceapistreamer/Socket/utils.h
40334f68c450d74708c0dd7af0e500fb4eb254a2
[]
no_license
caomw/CVTrack
89f39cd579f6a419258f74baebb10470f0c02058
a384d63a1831beb724e8b11463f9b00f3015b1f8
refs/heads/master
2020-12-31T02:22:20.345394
2011-06-04T15:45:09
2011-06-04T15:45:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,805
h
#ifndef TEST_APP_UTILS_H #define TEST_APP_UTILS_H #define THROW_ON_ERROR(x) \ { \ smReturnCode result = (x); \ if (result < 0) \ { \ std::stringstream s; \ s << "API error code: " << result; \ throw std::runtime_error(s.str()); \ } \ } unsigned short g_overlay_flags(SM_API_VIDEO_DISPLAY_HEAD_MESH); void toggleFlag(unsigned short &val, unsigned short flag) { if (val & flag) { val = val & ~flag; } else { val = val | flag; } } float rad2deg(float rad) { return rad*57.2957795f; } // Handles messages generated by API routines void STDCALL receiveLogMessage(void *, const char *buf, int buf_len) { std::cerr << std::string(buf); } bool processKeyPress(smEngineHandle engine, smVideoDisplayHandle video_display_handle) { if (!_kbhit()) { return true; } int key = _getch(); switch (key) { case 'r': { // Manually restart the tracking THROW_ON_ERROR(smEngineStart(engine)); } return true; case 'a': { // Toggle auto-restart mode int on; THROW_ON_ERROR(smHTGetAutoRestartMode(engine,&on)); THROW_ON_ERROR(smHTSetAutoRestartMode(engine,!on)); } return true; case '2': printf("WHAAAAT?\n"); toggleFlag(g_overlay_flags,SM_API_VIDEO_DISPLAY_PERFORMANCE); THROW_ON_ERROR(smVideoDisplaySetFlags(video_display_handle,g_overlay_flags)); return true; default: return false; } } #endif
[ [ [ 1, 75 ] ] ]
a7558f4a888d0771b1db705832079f94838a8c21
d9a78f212155bb978f5ac27d30eb0489bca87c3f
/PB/src/PbRpc/rpcchannel.cpp
732aa663db508810de71fbb66fc1dbd49cf24e4d
[]
no_license
marchon/pokerbridge
1ed4a6a521f8644dcd0b6ec66a1ac46879b8473c
97d42ef318bf08f3bc0c0cb1d95bd31eb2a3a8a9
refs/heads/master
2021-01-10T07:15:26.496252
2010-05-17T20:01:29
2010-05-17T20:01:29
36,398,892
0
0
null
null
null
null
UTF-8
C++
false
false
4,167
cpp
#include "StdAfx.h" #include "rpcconnection.h" #include "json.h" #include "rpcadaptor.h" #include "rpclistener.h" #include "rpcchannel.h" RpcChannel::RpcChannel(QTcpSocket *socket, RpcConnection *conn) : QObject(conn) { _socket = socket; _remoteHost = _socket->peerAddress().toString(); _remotePort = _socket->peerPort(); _localHost = _socket->localAddress().toString(); _localPort = _socket->localPort(); init(); } RpcChannel::RpcChannel(RpcConnection *conn) : QObject(conn) { _socket = 0; _remoteHost = ""; _remotePort = -1; } RpcChannel::~RpcChannel() { } QString RpcChannel::remoteHost() { return QString().append(_remoteHost).append(":%1").arg(_remotePort); } QString RpcChannel::localHost() { return QString().append(_localHost).append(":%1").arg(_localPort); } RpcConnection *RpcChannel::connection() { return static_cast<RpcConnection*>(parent()); } void RpcChannel::init() { _socket->setParent(this); _reader = new JsonReader(this); _reader->setInput(_socket); connect(_socket, SIGNAL(disconnected()), SLOT(socketDisconnected())); connect(_socket, SIGNAL(readyRead()), SLOT(readyRead())); connect(_socket, SIGNAL(connected()), SLOT(connected())); connect(_reader, SIGNAL(parsed(QVariantMap)),this, SLOT(newMessage(QVariantMap))); } void RpcChannel::socketDisconnected() { connection()->chanelDisconnected(this); } bool RpcChannel::connectToServer(QString url, uint port) { qLog(Debug)<<"connect rpc to "<<url<<":"<<port; Q_ASSERT(_socket==0); _socket = new QTcpSocket(this); _socket->connectToHost(url, port); init(); if(!_socket->waitForConnected()) { qLog(Debug)<<"timeout while connecting to server "<<url<<":"<<port; return false; } return true; } void RpcChannel::connected() { _localHost = _socket->localAddress().toString(); _localPort = _socket->localPort(); _remoteHost = _socket->peerAddress().toString(); _remotePort = _socket->peerPort(); qLog(Debug) << "socket connected ("<<_localHost<<"("<<_localPort<<")->"<<_remoteHost<<"("<<_remotePort<<")"; connection()->channelConnected(this); } void RpcChannel::readyRead() { if(_socket->bytesAvailable()>0) _reader->parse(); } bool getMethod(const QVariantMap &msg, RpcUrl &target, QString &method, RpcUrl &sender) { method = msg.value("method").toString(); target.parse(msg.value("target").toString()); sender.parse(msg.value("sender").toString()); return true; } void RpcChannel::newMessage(QVariantMap msg) { RpcUrl target; RpcUrl sender; QString method; QVariantList args; getMethod(msg, target, method, sender ); args = msg.value("params").toList(); bool isCall = !target.isEmpty(); if(isCall) { if(target.host==localHost()) connection()->channelCall(target, method.toLatin1(), args, sender); else qLog(Debug)<<"call to host "<<target.host<<"!=localhost="<<localHost(); } else connection()->channelSignal(method.toLatin1(), args, sender); } void putMethod(QVariantMap &msg, const RpcUrl &target, const QString &method, const RpcUrl &senderUrl) { msg["sender"]=senderUrl.toString(); msg["target"]=target.toString(); msg["method"]=method; } bool RpcChannel::remoteCall(const RpcUrl &path, const QByteArray &method, const QList<QVariant> &args, const RpcUrl &senderUrl) { QVariantMap msg; msg["params"]=args; putMethod(msg,path,method,senderUrl); sendMessage(msg); qLog(Debug)<<"SendCall: "<<method<<" to "<<path.toString()<<" from "<<senderUrl.toString(); return true; } bool RpcChannel::remoteSignal(const QByteArray &signal, const QList<QVariant> &args, const RpcUrl &senderUrl) { QVariantMap msg; msg["params"]=args; RpcUrl target; putMethod(msg,target,signal,senderUrl); sendMessage(msg); qLog(Debug)<<"SendSignal: "<<signal<<" from "<<senderUrl.toString(); return true; } void RpcChannel::sendMessage(QVariantMap msg) { QString data = VariantToJson::toJson(msg); qLog(Debug)<<"write: "<<data; _socket->write(data.toAscii()); //qLog(Debug)<<"RpcChannel::sendMessage "<<msg<<endl<<"data:"<<data; }
[ "[email protected]", "mikhail.mitkevich@a5377438-2eb2-11df-b28a-19025b8c0740" ]
[ [ [ 1, 5 ], [ 7, 13 ], [ 16, 30 ], [ 32, 35 ], [ 41, 61 ], [ 63, 64 ], [ 66, 70 ], [ 72, 75 ], [ 77, 86 ], [ 94, 101 ], [ 110, 111 ], [ 122, 122 ], [ 127, 127 ], [ 162, 166 ], [ 168, 171 ] ], [ [ 6, 6 ], [ 14, 15 ], [ 31, 31 ], [ 36, 40 ], [ 62, 62 ], [ 65, 65 ], [ 71, 71 ], [ 76, 76 ], [ 87, 93 ], [ 102, 109 ], [ 112, 121 ], [ 123, 126 ], [ 128, 161 ], [ 167, 167 ] ] ]
14b4836ca403e7baaefc0ec556584bc89284a0e3
1e4daaa1f0846720f608094479aadb58759e1021
/p2p-simulation/coupled/Network70/demux.h
d5b375cbab8f7afe6eb0de563693d83f8603cd11
[]
no_license
DDionne/SpiderWeb
d7d69091a08aaf6b2ae7f50ad7a8bd40406cc693
0d3e78a0a053e4c0e826cf9b9eae332930929fc0
refs/heads/master
2021-01-16T19:56:44.257854
2011-06-07T19:33:40
2011-06-07T19:33:40
1,860,449
0
0
null
null
null
null
UTF-8
C++
false
false
4,642
h
/******************************************************************* * * DESCRIPTION: Atomic Model : Demultiplexer : gets a message on its single input and * forwards it to one of its numerous outputs according to a routing table. * * AUTHOR: Alan * * *******************************************************************/ /*handle duplicate inclusion of this header*/ #ifndef __DEMUX_H #define __DEMUX_H #define VERBOSE false /** include files **/ #include "atomic.h" // class Atomic #include "..\complexmessages.h" // functions to manage "coded" messages between components //#include "NetGraph.h" //#include "IntSet.h" #include <map> #include <set> //#include "EventQueue.h" //#include <queue> //STL for queue template class //#include <set> /** declarations **/ class Demux: public Atomic { public: Demux( const string &name = "Demux" ) ; // Default constructor ~Demux(); // Destructor virtual string className() const {return "Demux";}; protected: Model &initFunction() { return *this; }; Model &externalFunction( const ExternalMessage & ); Model &internalFunction( const InternalMessage & ); Model &outputFunction( const InternalMessage & ); private: const Port &msg_in ; // for getting messages const Port &table_in; // for updating the routing table const Port &connect_in; // for connection / disconnection messages Port &out_0 ; Port &out_c0 ; Port &out_1 ; Port &out_c1 ; Port &out_2 ; Port &out_c2 ; Port &out_3 ; Port &out_c3 ; Port &out_4 ; Port &out_c4 ; Port &out_5 ; Port &out_c5 ; Port &out_6 ; Port &out_c6 ; Port &out_7 ; Port &out_c7 ; Port &out_8 ; Port &out_c8 ; Port &out_9 ; Port &out_c9 ; Port &out_10 ; Port &out_c10 ; Port &out_11 ; Port &out_c11 ; Port &out_12 ; Port &out_c12 ; Port &out_13 ; Port &out_c13 ; Port &out_14 ; Port &out_c14 ; Port &out_15 ; Port &out_c15 ; Port &out_16 ; Port &out_c16 ; Port &out_17 ; Port &out_c17 ; Port &out_18 ; Port &out_c18 ; Port &out_19 ; Port &out_c19 ; Port &out_20 ; Port &out_c20 ; Port &out_21 ; Port &out_c21 ; Port &out_22 ; Port &out_c22 ; Port &out_23 ; Port &out_c23 ; Port &out_24 ; Port &out_c24 ; Port &out_25 ; Port &out_c25 ; Port &out_26 ; Port &out_c26 ; Port &out_27 ; Port &out_c27 ; Port &out_28 ; Port &out_c28 ; Port &out_29 ; Port &out_c29 ; Port &out_30 ; Port &out_c30 ; Port &out_31 ; Port &out_c31 ; Port &out_32 ; Port &out_c32 ; Port &out_33 ; Port &out_c33 ; Port &out_34 ; Port &out_c34 ; Port &out_35 ; Port &out_c35 ; Port &out_36 ; Port &out_c36 ; Port &out_37 ; Port &out_c37 ; Port &out_38 ; Port &out_c38 ; Port &out_39 ; Port &out_c39 ; Port &out_40 ; Port &out_c40 ; Port &out_41 ; Port &out_c41 ; Port &out_42 ; Port &out_c42 ; Port &out_43 ; Port &out_c43 ; Port &out_44 ; Port &out_c44 ; Port &out_45 ; Port &out_c45 ; Port &out_46 ; Port &out_c46 ; Port &out_47 ; Port &out_c47 ; Port &out_48 ; Port &out_c48 ; Port &out_49 ; Port &out_c49 ; Port &out_50 ; Port &out_c50 ; Port &out_51 ; Port &out_c51 ; Port &out_52 ; Port &out_c52 ; Port &out_53 ; Port &out_c53 ; Port &out_54 ; Port &out_c54 ; Port &out_55 ; Port &out_c55 ; Port &out_56 ; Port &out_c56 ; Port &out_57 ; Port &out_c57 ; Port &out_58 ; Port &out_c58 ; Port &out_59 ; Port &out_c59 ; Port &out_60 ; Port &out_c60 ; Port &out_61 ; Port &out_c61 ; Port &out_62 ; Port &out_c62 ; Port &out_63 ; Port &out_c63 ; Port &out_64 ; Port &out_c64 ; Port &out_65 ; Port &out_c65 ; Port &out_66 ; Port &out_c66 ; Port &out_67 ; Port &out_c67 ; Port &out_68 ; Port &out_c68 ; Port &out_69 ; Port &out_c69 ; // table to associate message Ids to peers (conceptually for routing responses back to the peer that originated the query). map<int,int > routingTable; bool routing; // if we're routing a queryhit bool connecting; // if we're routing a connect/ disconnect set<int> to_peers; //the set of peers that the next output is meant for int nextOutput; // next output //map<float, Time> a time stamp for the last seen message for a given id : the idea is that after a while we're not routing the message anymore and can forget about which nodes the message has visited. //Time lastpurge // stores the time of the last purge. If this occured more than <purgeinterval> ago we should re-purge the routingtable of old messages }; // class Demux #endif //__DEMUX_H
[ [ [ 1, 215 ] ] ]
53594b94c911270d2b8ccbcced9fb21597a18fbc
c5534a6df16a89e0ae8f53bcd49a6417e8d44409
/trunk/nGENE Proj/NodeParticleSystem.cpp
414697e3234c1210018eb3e7b0923f9cafc49d1c
[]
no_license
svn2github/ngene
b2cddacf7ec035aa681d5b8989feab3383dac012
61850134a354816161859fe86c2907c8e73dc113
refs/heads/master
2023-09-03T12:34:18.944872
2011-07-27T19:26:04
2011-07-27T19:26:04
78,163,390
2
0
null
null
null
null
UTF-8
C++
false
false
3,563
cpp
/* --------------------------------------------------------------------------- This source file is part of nGENE Tech. Copyright (c) 2006- Wojciech Toman This program is free software. File: NodeParticleSystem.cpp Version: 0.09 --------------------------------------------------------------------------- */ #include "PrecompiledHeaders.h" #include "DeviceRender.h" #include "NodeParticleSystem.h" #include "AABB.h" #include "OBB.h" namespace nGENE { // Initialize static members TypeInfo NodeParticleSystem::Type(L"NodeParticleSystem", &NodeVisible::Type); NodeParticleSystem::NodeParticleSystem(): m_bValid(true) { m_dwLastTime = Engine::getSingleton().getTimer().getMilliseconds(); ListenerRegistry <DeviceEvent>::addListener(this); } //---------------------------------------------------------------------- NodeParticleSystem::~NodeParticleSystem() { if(!m_vParticleEmitters.empty()) m_vParticleEmitters.clear(); ListenerRegistry <DeviceEvent>::removeListener(this); } //---------------------------------------------------------------------- void NodeParticleSystem::onUpdate() { // If node is invalid, return if(!m_bValid) return; Timer& timer = Engine::getSingleton().getTimer(); float delta = static_cast<float>(timer.getMilliseconds() - m_dwLastTime); // First update particles for(uint i = 0; i < m_vParticleEmitters.size(); ++i) m_vParticleEmitters[i].update(delta); NodeVisible::onUpdate(); m_dwLastTime = timer.getMilliseconds(); } //---------------------------------------------------------------------- void NodeParticleSystem::addParticleEmitter(ParticleEmitter& _emitter, const wstring& _name) { Surface surface; addSurface(_name, surface); _emitter.setSurface(&m_Surfaces[_name]); _emitter.setParticleSystem(this); _emitter.setName(_name); m_vParticleEmitters.push_back(_emitter); } //---------------------------------------------------------------------- ParticleEmitter* NodeParticleSystem::getParticleEmitter(uint _index) { if(_index < m_vParticleEmitters.size()) return &m_vParticleEmitters[_index]; else return NULL; } //---------------------------------------------------------------------- uint NodeParticleSystem::getParticleEmittersNum() const { return m_vParticleEmitters.size(); } //---------------------------------------------------------------------- void NodeParticleSystem::handleEvent(const DeviceEvent& _evt) { if(_evt.type == DET_DESTROYED || _evt.type == DET_LOST) { m_bValid = false; } else if(_evt.type == DET_RESET || _evt.type == DET_CREATED) { m_bValid = true; } } //---------------------------------------------------------------------- void NodeParticleSystem::serialize(ISerializer* _serializer, bool _serializeType, bool _serializeChildren) { if(!m_bIsSerializable) return; if(_serializeType) _serializer->addObject(this->Type); NodeVisible::serialize(_serializer, false, _serializeChildren); /// Serialize particle emitters for(uint i = 0; i < m_vParticleEmitters.size(); ++i) m_vParticleEmitters[i].serialize(_serializer, true, true); if(_serializeType) _serializer->endObject(this->Type); } //---------------------------------------------------------------------- void NodeParticleSystem::deserialize(ISerializer* _serializer) { NodeVisible::deserialize(_serializer); } //---------------------------------------------------------------------- }
[ "Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57" ]
[ [ [ 1, 120 ] ] ]
6d6c57f946566bc370cdc87cf87025a013376642
3c582e3e95dc0c4a9613477e7ae1c5307a93ace0
/cpp/Game/GameSprite.h
19291386fdefceaf3ff074bdc26fa97230aa64a9
[]
no_license
anat/b429befdb28b97946c1f5f34cf64110f
b4483d718773525009a58dc53c10a00e2c7d00fd
eff1032dbaaa10a486bdf1ac3bccbb7f1001fe87
refs/heads/master
2016-09-06T18:06:46.750071
2010-12-18T02:08:39
2010-12-18T02:08:39
32,614,798
0
0
null
null
null
null
UTF-8
C++
false
false
121
h
#pragma once #include <SFML/Graphics.hpp> class GameSprite : public sf::Sprite { sf::Sprite Sprite; int N; };
[ [ [ 1, 8 ] ] ]
126c56bc238fdc3d2b75f8220cac0245ce2393e8
ea12fed4c32e9c7992956419eb3e2bace91f063a
/zombie/code/nebula2/src/kernel/nfile.cc
e69b537729ad1e72610ac48e8da26e511ee7d9e9
[]
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
14,304
cc
//------------------------------------------------------------------------------ // nfile.cc // (C) 2002 RadonLabs GmbH //------------------------------------------------------------------------------ #include "precompiled/pchnkernel.h" #include "kernel/nfile.h" #include "kernel/nfileserver2.h" #include "kernel/nlogclass.h" #if defined(__LINUX__) || defined(__MACOSX__) #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #endif NCREATELOGLEVEL(file, "File Operation", false, 0); //------------------------------------------------------------------------------ /** history: - 30-Jan-2002 peter created - 11-Feb-2002 floh Linux stuff */ nFile::nFile() : lineNumber(0), isOpen(false) { #ifdef __WIN32__ this->handle = 0; #else this->fp = 0; #endif } //------------------------------------------------------------------------------ /** history: - 30-Jan-2002 peter created */ nFile::~nFile() { if(this->IsOpen()) { this->Close(); } } //------------------------------------------------------------------------------ /** Check if file exists physically on disk by opening it in read-only mode. Close file if it was opened. - 05-Jan-05 floh Bugfix: missing GENERIC_READ access mode didn't work in Win98 */ bool nFile::Exists(const nString& fileName) const { n_assert_return( !fileName.IsEmpty(), false ); nString fullName = nFileServer2::Instance()->ManglePath( fileName ); #ifdef __WIN32__ HANDLE fh = CreateFile(fullName.Get(), // filename GENERIC_READ, // access mode FILE_SHARE_READ, // share mode 0, // security flags OPEN_EXISTING, // what to do if file doesn't exist FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, // flags'n'attributes 0); // template file if (fh != INVALID_HANDLE_VALUE) { CloseHandle(fh); return true; } else { return false; } #else FILE* fp = fopen(fullName.Get(), "r"); if (fp != 0) { fclose(fp); return true; } else { return false; } #endif //return false; } //------------------------------------------------------------------------------ /** opens the specified file @param fileName the name of the file to open @param accessMode the access mode ("(r|w|a)[+]") @return success history: - 30-Jan-2002 peter created - 11-Feb-2002 floh Linux stuff */ bool nFile::Open(const nString& fileName, const char* accessMode) { n_assert_return(!this->IsOpen(), false); n_assert_return(!fileName.IsEmpty(), false); n_assert_return(accessMode, false); nString mangledPath; if (strchr(accessMode,'w') || strchr(accessMode,'W') || strchr(accessMode,'a') || strchr(accessMode,'A')) { NLOG(file, (NLOGUSER | 0, "Opening for writing %s", fileName.Get() )); mangledPath = nFileServer2::Instance()->ManglePath(fileName, false); } else { NLOG(file, (NLOGUSER | 0, "Opening for reading %s", fileName.Get() )); mangledPath = nFileServer2::Instance()->ManglePath(fileName); } this->lineNumber = 0; #ifdef __WIN32__ DWORD access = 0; DWORD disposition = 0; DWORD shareMode = 0; const char* ptr = accessMode; char c; while( 0 != (c = *ptr++)) { if ((c == 'r') || (c == 'R')) { access |= GENERIC_READ; } else if ((c == 'w') || (c == 'W')) { access |= GENERIC_WRITE; } } if (access & GENERIC_WRITE) { disposition = CREATE_ALWAYS; } else { disposition = OPEN_EXISTING; shareMode = FILE_SHARE_READ; } this->handle = CreateFile(mangledPath.Get(), // filename access, // access mode shareMode, // share mode 0, // security flags disposition, // what to do if file doesn't exist FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, // flags'n'attributes 0); // template file if (this->handle == INVALID_HANDLE_VALUE) { this->handle = 0; NLOG(file, (NLOGUSER | 0, "Could not open %s, error %s", fileName.Get(),n_getlastsystemerror().Get() )); return false; } #else this->fp = fopen(mangledPath.Get(), accessMode); if (!this->fp) { return false; } #endif this->isOpen = true; this->fname = fileName; this->accessMode = accessMode; return true; } //------------------------------------------------------------------------------ /** closes the file history: - 30-Jan-2002 peter created - 11-Feb-2002 floh Linux stuff */ void nFile::Close() { n_assert(this->IsOpen()); #ifdef __WIN32__ if (this->handle) { CloseHandle(this->handle); this->handle = 0; } #else if (this->fp) { fclose(this->fp); this->fp = 0; } #endif this->isOpen = false; this->fname.Clear(); } //------------------------------------------------------------------------------ /** writes a number of bytes to the file @param buffer buffer with data @param numBytes number of bytes to write @return number of bytes written history: - 30-Jan-2002 peter created - 11-Feb-2002 floh Linux stuff */ int nFile::Write(const void* buffer, int numBytes) { n_assert(this->IsOpen()); // statistics nFileServer2::Instance()->AddBytesWritten(numBytes); #ifdef __WIN32__ DWORD written; WriteFile(this->handle, buffer, numBytes, &written, NULL); return written; #else return fwrite(buffer, 1, numBytes, this->fp); #endif } //------------------------------------------------------------------------------ /** reads a number of bytes from the file @param buffer buffer for data @param numBytes number of bytes to read @return number of bytes read history: - 30-Jan-2002 peter created */ int nFile::Read(void* buffer, int numBytes) { n_assert(this->IsOpen()); // statistics nFileServer2::Instance()->AddBytesRead(numBytes); #ifdef __WIN32__ DWORD read; ReadFile(this->handle, buffer, numBytes, &read, NULL); return read; #else return fread(buffer, 1, numBytes, this->fp); #endif } //------------------------------------------------------------------------------ /** gets current position of file pointer @return position of pointer history: - 30-Jan-2002 peter created */ int nFile::Tell() const { n_assert(this->IsOpen()); #ifdef __WIN32__ return SetFilePointer(this->handle, 0, NULL, FILE_CURRENT); #else return ftell(this->fp); #endif } //------------------------------------------------------------------------------ /** sets the file pointer to given absolute or relative position @param byteOffset the offset @param origin position from which to count @return success history: - 30-Jan-2002 peter created */ bool nFile::Seek(int byteOffset, nSeekType origin) { n_assert(this->IsOpen()); nFileServer2::Instance()->AddSeek(); #ifdef __WIN32__ DWORD method = FILE_BEGIN; switch (origin) { case CURRENT: method = FILE_CURRENT; break; case START: method = FILE_BEGIN; break; case END: method = FILE_END; break; } DWORD ret = SetFilePointer(this->handle, (LONG)byteOffset, NULL, method); return (ret != 0xffffffff); #else int whence = SEEK_SET; switch (origin) { case CURRENT: whence = SEEK_CUR; break; case START: whence = SEEK_SET; break; case END: whence = SEEK_END; break; } return (0 == fseek(this->fp, byteOffset, whence)) ? true : false; #endif } //------------------------------------------------------------------------------ /** */ bool nFile::Eof() const { n_assert(this->IsOpen()); #ifdef __WIN32__ DWORD fpos = SetFilePointer(this->handle,0,NULL,FILE_CURRENT); DWORD size = GetFileSize(this->handle,NULL); return (fpos == size)? true:false; #else return (!feof(this->fp))? false:true; #endif } //------------------------------------------------------------------------------ /** Returns size of file in bytes. @return byte-size of file */ int nFile::GetSize() const { n_assert(this->IsOpen()); #ifdef __WIN32__ return GetFileSize(this->handle, NULL); #elif defined(__LINUX__) || defined(__MACOSX__) struct stat s; fstat(fileno(this->fp), &s); return s.st_size; #else #error "nFile::GetSize(): NOT IMPLEMENTED!" #endif } //------------------------------------------------------------------------------ /** Returns time of last write access. The file must be opened in "read" mode before this function can be called! */ nFileTime nFile::GetLastWriteTime() const { n_assert(this->IsOpen()); #ifdef __WIN32__ nFileTime fileTime; GetFileTime(this->handle, NULL, NULL, &(fileTime.time)); return fileTime; #elif defined(__LINUX__) || defined(__MACOSX__) nFileTime fileTime; struct stat s; fstat(fileno(this->fp), &s); fileTime.time = s.st_mtime; return fileTime; #else #error "nFile::GetLastWriteTime(): NOT IMPLEMENTED!" #endif } //------------------------------------------------------------------------------ /** writes a string to the file @param buffer the string to write @return success history: - 30-Jan-02 peter created - 29-Jan-03 floh the method suddenly wrote a newLine. WRONG! */ bool nFile::PutS(const char* buffer) { n_assert(this->IsOpen()); if (buffer) { int len = static_cast<int>( strlen(buffer) ); int written = this->Write(buffer, len); if (written != len) { return false; } else { this->lineNumber++; return true; } } return true; } //------------------------------------------------------------------------------ /** reads a string from the file up to and including the first newline character or up to the end of the buffer @param buffer buffer for string @param numChars maximum number of chars to read @return success (false if eof is reached) history: - 30-Jan-2002 peter created */ bool nFile::GetS(char* buffer, int numChars) { n_assert(this->IsOpen()); n_assert(buffer); n_assert(numChars > 0); // store start filepointer position int seekPos = this->Tell(); // read 64 bytes at once, and scan for newlines const int chunkSize = 64; int readSize = chunkSize; char* readPos = buffer; bool retval = false; int bytesRead = 0; int curIndex = 0; for (curIndex = 0; curIndex < (numChars - 1); curIndex++) { // read next chunk of data? if (0 == (curIndex % chunkSize)) { readSize = chunkSize; if ((curIndex + readSize) >= numChars) { readSize = numChars - curIndex; } bytesRead = this->Read(readPos, readSize); readPos[bytesRead] = 0; readPos += readSize; } // end of line reached? if (0 == bytesRead) { retval = false; break; } // newline? if ((buffer[curIndex] == '\n') || (buffer[curIndex] == 0)) { retval = true; this->Seek(seekPos + curIndex + 1, START); break; } } // terminate buffer buffer[curIndex] = 0; this->lineNumber++; return retval; } //------------------------------------------------------------------------------ /** Append the contents of another file to this file. This and the 'other' file must both be open! Returns number of bytes copied. Warning: current implementation reads the complete source file into a ram buffer. @return number of bytes appended */ int nFile::AppendFile(nFile* other, int inputNumBytes) { n_assert(other); int numBytes(inputNumBytes >= 0 ? inputNumBytes : other->GetSize() ); if (numBytes == 0) { // nothing to do return 0; } // allocate temp buffer and read bytes void* buffer = n_malloc(numBytes); n_assert(buffer); n_verify( other->Read(buffer, numBytes) == numBytes); // write to this file n_verify( this->Write(buffer, numBytes) == numBytes); // cleanup n_free(buffer); return numBytes; } //------------------------------------------------------------------------------ /** Return the filename of currently opened file @return filename string */ const nString & nFile::GetFilename() const { return this->fname; } //------------------------------------------------------------------------------ /** Return the access mode in which the file was opened @return access mode string */ const nString & nFile::GetAccessMode() const { return this->accessMode; }
[ "magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91" ]
[ [ [ 1, 560 ] ] ]
cbba142cc9c527d1d248a70261ad6df21f4cff2f
57cbe90b0ad9e7442a835e6f5d746baebc35eb54
/cob_powercube_chain/common/include/cob_powercube_chain/TimeStamp.h
792874c0e42d4104b92950646ee1ba16686002fd
[]
no_license
ipa-aub-cb/cob_driver
1101931f1b931f8f31f4dfc3367105ab12c71d64
4947db439bb889f1f417649f9f321711dfee30a1
refs/heads/master
2021-01-18T05:53:47.683305
2011-12-23T12:19:03
2011-12-23T12:19:03
2,136,697
0
0
null
null
null
null
UTF-8
C++
false
false
4,518
h
/**************************************************************** * * Copyright (c) 2010 * * Fraunhofer Institute for Manufacturing Engineering * and Automation (IPA) * * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * Project name: care-o-bot * ROS stack name: cob_driver * ROS package name: cob_powercube_chain * Description: * * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * Author: Felix Geibel, email:[email protected] * Supervised by: Alexander Bubeck, email:[email protected] * * Date of creation: Aug 2007 * ToDo: * * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * 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 Fraunhofer Institute for Manufacturing * Engineering and Automation (IPA) nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License LGPL 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 Lesser General Public License LGPL for more details. * * You should have received a copy of the GNU Lesser General Public * License LGPL along with this program. * If not, see <http://www.gnu.org/licenses/>. * ****************************************************************/ #ifndef _TimeStamp_H #define _TimeStamp_H #ifdef __LINUX__ #include <time.h> #else #include <windows.h> #ifdef _DEBUG //#define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif namespace RTB { #endif //------------------------------------------------------------------- /** Measure system time with very high accuracy. * Use this class for measure system time accurately. Under Windows, it uses * QueryPerformanceCounter(), which has a resolution of approx. one micro-second. * The difference between two time stamps can be calculated. */ class TimeStamp { public: /// Constructor. TimeStamp(); /// Destructor. virtual ~TimeStamp() {}; /// Makes time measurement. void SetNow(); /// Retrieves time difference in seconds. double operator-(const TimeStamp& EarlierTime) const; /// Increase the timestamp by TimeS seconds. /** @param TimeS must be >0!. */ void operator+=(double TimeS); /// Reduces the timestamp by TimeS seconds. /** @param TimeS must be >0!. */ void operator-=(double TimeS); /// Checks if this time is after time "Time". bool operator>(const TimeStamp& Time); /// Checks if this time is before time "Time". bool operator<(const TimeStamp& Time); /** * Gets seconds and nanoseconds of the timestamp. */ void getTimeStamp(long& lSeconds, long& lNanoSeconds); /** * Sets timestamp from seconds and nanoseconds. */ void setTimeStamp(const long& lSeconds, const long& lNanoSeconds); protected: /// Internal time stamp data. #ifdef __LINUX__ timespec m_TimeStamp; #else LARGE_INTEGER m_TimeStamp; #endif private: /// Conversion timespec -> double #ifdef __LINUX__ static double TimespecToDouble(const ::timespec& LargeInt); /// Conversion double -> timespec static ::timespec DoubleToTimespec(double TimeS); #else static double LargeIntToDouble(const LARGE_INTEGER& LargeInt); /// Conversion double -> LARGE_INTEGER. static LARGE_INTEGER DoubleToLargeInt(double TimeS); /// Size of a Dword field. static double m_DwordSize; /// Seconds per counts. static double m_SecPerCount; #endif }; #ifdef __LINUX__ #else }//namespace #endif #endif
[ [ [ 1, 52 ] ], [ [ 53, 157 ] ] ]
d37fb08c6488db945aeba646947e7afa4ced62b7
668dc83d4bc041d522e35b0c783c3e073fcc0bd2
/fbide-vs/Sdk/Variant.cpp
76edbbf213a155e1a470e19fb0edef08872e06d6
[]
no_license
albeva/fbide-old-svn
4add934982ce1ce95960c9b3859aeaf22477f10b
bde1e72e7e182fabc89452738f7655e3307296f4
refs/heads/master
2021-01-13T10:22:25.921182
2009-11-19T16:50:48
2009-11-19T16:50:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,877
cpp
/* * This file is part of FBIde project * * FBIde 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. * * FBIde 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 FBIde. If not, see <http://www.gnu.org/licenses/>. * * Author: Albert Varaksin <[email protected]> * Copyright (C) The FBIde development team */ #include "sdk_pch.h" using namespace fbi; namespace { wxRegEx reSizePoint("^\\{([0-9]+)[ ]*,[ ]*([0-9]+)\\}$"); } //------------------------------------------------------------------------------ // Variant //------------------------------------------------------------------------------ Variant::Variant (const Variant & value) : m_value(value.m_value) {} void Variant::operator = (const Variant & rhs) { m_value = rhs.m_value; } bool Variant::operator == (const Variant & rhs) const { return m_value == rhs.m_value; } bool Variant::operator != (const Variant & rhs) const { return m_value != rhs.m_value; } //------------------------------------------------------------------------------ // wxString //------------------------------------------------------------------------------ Variant::Variant (const wxString & value) : m_value(value) {} void Variant::operator = (const wxString & rhs) { m_value = rhs; } bool Variant::operator == (const wxString & rhs) const { return m_value == rhs; } bool Variant::operator != (const wxString & rhs) const { return m_value != rhs; } wxString Variant::AsString (const wxString & def) const { return m_value.Len() ? m_value : def; } //------------------------------------------------------------------------------ // const char * //------------------------------------------------------------------------------ Variant::Variant (const char * value) : m_value(value) {} void Variant::operator = (const char * rhs) { m_value = rhs; } bool Variant::operator == (const char * rhs) const { return m_value == rhs; } bool Variant::operator != (const char * rhs) const { return m_value != rhs; } //------------------------------------------------------------------------------ // const wxChar * //------------------------------------------------------------------------------ Variant::Variant (const wxChar * value) : m_value(value) {} void Variant::operator = (const wxChar * rhs) { m_value = rhs; } bool Variant::operator == (const wxChar * rhs) const { return m_value == rhs; } bool Variant::operator != (const wxChar * rhs) const { return m_value != rhs; } //------------------------------------------------------------------------------ // int //------------------------------------------------------------------------------ Variant::Variant (int value) { *this = value; } void Variant::operator = (int rhs) { m_value.Empty(); m_value << rhs; } bool Variant::operator == (int rhs) const { return AsInt() == rhs; } bool Variant::operator != (int rhs) const { return AsInt() != rhs; } int Variant::AsInt (int def) const { if (!m_value.Len()) return def; long v; if (m_value.ToLong(&v)) return v; if (m_value == "true" || m_value == "yes" || m_value== "on") return (int)true; return def; } //------------------------------------------------------------------------------ // bool //------------------------------------------------------------------------------ bool Variant::AsBool (bool def) const { if (!m_value.Len()) return def; if (m_value == "0") return false; if (m_value == "true" || m_value == "yes" || m_value== "on") return true; long v; if (m_value.ToLong(&v)) return v == 0.0 ? false : true; return def; } //------------------------------------------------------------------------------ // double //------------------------------------------------------------------------------ Variant::Variant (double value) { *this = value; } void Variant::operator = (double rhs) { m_value.Empty(); m_value << rhs; } bool Variant::operator == (double rhs) const { return AsDouble() == rhs; } bool Variant::operator != (double rhs) const { return AsDouble() != rhs; } double Variant::AsDouble (double def) const { if (!m_value.Len()) return def; double v; if (m_value.ToDouble(&v)) return v; return def; } //------------------------------------------------------------------------------ // wxSize {w, h} //------------------------------------------------------------------------------ Variant::Variant (const wxSize & value) { *this = value; } void Variant::operator = (const wxSize & rhs) { m_value.Empty(); m_value = MakeString(rhs); } bool Variant::operator == (const wxSize & rhs) const { return m_value == MakeString(rhs); } bool Variant::operator != (const wxSize & rhs) const { return m_value != MakeString(rhs); } wxSize Variant::AsSize (const wxSize & def) const { if (!m_value.Len()) return def; if (reSizePoint.Matches(m_value)) { auto w_str = reSizePoint.GetMatch(m_value, 1); auto h_str = reSizePoint.GetMatch(m_value, 2); long w = 0, h = 0; w_str.ToLong(&w); h_str.ToLong(&h); return wxSize(w, h); } return def; } wxString Variant::MakeString (const wxSize & size) { wxString tmp; tmp << "{" << size.GetWidth() << ", " << size.GetHeight() << "}" ; return tmp; } //------------------------------------------------------------------------------ // wxPoint {w, h} //------------------------------------------------------------------------------ Variant::Variant (const wxPoint & value) { *this = value; } void Variant::operator = (const wxPoint & rhs) { m_value.Empty(); m_value = MakeString(rhs); } bool Variant::operator == (const wxPoint & rhs) const { return m_value == MakeString(rhs); } bool Variant::operator != (const wxPoint & rhs) const { return m_value != MakeString(rhs); } wxPoint Variant::AsPoint (const wxPoint & def) const { if (!m_value.Len()) return def; if (reSizePoint.Matches(m_value)) { auto x_str = reSizePoint.GetMatch(m_value, 1); auto y_str = reSizePoint.GetMatch(m_value, 2); long x = 0, y = 0; x_str.ToLong(&x); y_str.ToLong(&y); return wxPoint(x, y); } return def; } wxString Variant::MakeString (const wxPoint & point) { wxString tmp; tmp << "{" << point.x << ", " << point.y << "}" ; return tmp; } //------------------------------------------------------------------------------ // wxColour css notation //------------------------------------------------------------------------------ Variant::Variant (const wxColour & value) { *this = value; } void Variant::operator = (const wxColour & rhs) { m_value.Empty(); m_value = MakeString(rhs); } bool Variant::operator == (const wxColour & rhs) const { return m_value == MakeString(rhs); } bool Variant::operator != (const wxColour & rhs) const { return m_value != MakeString(rhs); } wxColour Variant::AsColour (const wxColour & def) const { if (!m_value.Len()) return def; auto c = wxColour(m_value); if (c.IsOk ()) return c; return def; } wxString Variant::MakeString (const wxColour & colour) { return colour.GetAsString(wxC2S_HTML_SYNTAX); }
[ "vongodric@957c6b5c-1c3a-0410-895f-c76cfc11fbc7" ]
[ [ [ 1, 280 ] ] ]
a17d396593552658cfd7a38bd99a9e6780ffa4cf
1c84fe02ecde4a78fb03d3c28dce6fef38ebaeff
/FSMEnemyMachine.h
5544d4501ffcb5349ce28bbe4028e744b2c535af
[]
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
499
h
#ifndef FSMENEMYMACHINE_H #define FSMENEMYMACHINE_H #include "FSMMachine.h" using namespace std; class FSMEnemyMachine: public FSMMachine { public: FSMEnemyMachine(int type = FSM_MACH_ENEMY) { m_type = type; } void UpdateMachine(int i); void SetDefaultState(FSMState* state) { m_defaultState = state; } void SetGoalID(FSMState* state) { m_goalState = state; } bool TransitionState(FSMState* state); }; NiSmartPointer(FSMEnemyMachine); #endif
[ "[email protected]", "ruhisinha27@8db35e17-053d-0410-88b8-2990f35e824c" ]
[ [ [ 1, 22 ], [ 24, 32 ] ], [ [ 23, 23 ] ] ]
a5db924d07f9f139a3e395f3c03c84508c49b2ca
9ad9345e116ead00be7b3bd147a0f43144a2e402
/Integration_WAH_&_Extraction/SMDataExtraction/Algorithm/NominalAttribute.h
b37b21995b0e9d358f7877e936468da9470851fd
[]
no_license
asankaf/scalable-data-mining-framework
e46999670a2317ee8d7814a4bd21f62d8f9f5c8f
811fddd97f52a203fdacd14c5753c3923d3a6498
refs/heads/master
2020-04-02T08:14:39.589079
2010-07-18T16:44:56
2010-07-18T16:44:56
33,870,353
0
0
null
null
null
null
UTF-8
C++
false
false
1,342
h
#pragma once #include <vector> #include "distinctvalue.h" #include <xstring> #include "bayesdistinct.h" #include "abstractatt.h" class NominalAttribute : public AbstractAtt { public: NominalAttribute(void); ~NominalAttribute(void); NominalAttribute(double _weight, vector<BayesDistinct *> & _values); double Weight() const { return m_weight; } void Weight(double val) { m_weight = val; } int numValues() const { return m_uniqueValNo; } void numValues(int val) { m_uniqueValNo = val; } BitStreamInfo * bitStreamAt(size_t position); BayesDistinct * distinctValueAt(size_t post); vector<BayesDistinct *> UniqueValues() const { return m_uniqueValues; } void UniqueValues(vector<BayesDistinct *> & val) { m_uniqueValues = val; } void Print(); std::string name() const { return m_name; } void name(std::string val) { m_name = val; } /** * Returns a value of a nominal or string attribute. Returns an * empty string if the attribute is neither a string nor a nominal * attribute. */ string value(int valIndex); private : /* No of unique bitmaps */ int m_uniqueValNo; /* Vector holding all the unique values */ vector<BayesDistinct *> m_uniqueValues; /*weight of each attribute */ double m_weight; /*Name of the attribute */ string m_name; };
[ "jaadds@c7f6ba40-6498-11de-987a-95e5a5a5d5f1" ]
[ [ [ 1, 58 ] ] ]
2763ae26fc3278da57142d17be27294bc58df815
6581dacb25182f7f5d7afb39975dc622914defc7
/CodeProject/ExcelAddinInEasyIF/MtxEdit.h
3b3b9219dfc0b95cc8b5b4cda9339fa5ceebc88c
[]
no_license
dice2019/alexlabonline
caeccad28bf803afb9f30b9e3cc663bb2909cc4f
4c433839965ed0cff99dad82f0ba1757366be671
refs/heads/master
2021-01-16T19:37:24.002905
2011-09-21T15:20:16
2011-09-21T15:20:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,646
h
#if !defined(AFX_MTXEDIT_H__56FF7F8B_2525_442C_8275_5F07575A2ACB__INCLUDED_) #define AFX_MTXEDIT_H__56FF7F8B_2525_442C_8275_5F07575A2ACB__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // MtxEdit.h : header file // #include "mtxedgen.h" #include "mtxedcol.h" #include "mtxeddat.h" ///////////////////////////////////////////////////////////////////////////// // MatrixEdit class MatrixEdit : public CPropertySheet { DECLARE_DYNAMIC(MatrixEdit) public: Matrix *m_pMatrix; MtxEditGen *m_pGeneralTab; MatrixEditCol *m_pColumnTab; MatrixEditData *m_pDataTab; // Construction public: MatrixEdit(Matrix *pMatrix, UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0); MatrixEdit(Matrix *pMatrix, LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0); // Attributes public: // Operations public: BOOL CheckColumnsDefined(); void EnableOKButton(); // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(MatrixEdit) public: virtual int DoModal(); //}}AFX_VIRTUAL // Implementation public: virtual ~MatrixEdit(); // Generated message map functions protected: //{{AFX_MSG(MatrixEdit) // NOTE - the ClassWizard will add and remove member functions here. //}}AFX_MSG DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_MTXEDIT_H__56FF7F8B_2525_442C_8275_5F07575A2ACB__INCLUDED_)
[ "damoguyan8844@3a4e9f68-f5c2-36dc-e45a-441593085838" ]
[ [ [ 1, 66 ] ] ]
6adbaf693ff2484889c0462172ece5f7d8b1f49a
fac8de123987842827a68da1b580f1361926ab67
/inc/physics/Physics/Utilities/CharacterControl/StateMachine/Flying/hkpCharacterStateFlying.h
9da845f52d027bd0a67958b084a249a7cfa95564
[]
no_license
blockspacer/transporter-game
23496e1651b3c19f6727712a5652f8e49c45c076
083ae2ee48fcab2c7d8a68670a71be4d09954428
refs/heads/master
2021-05-31T04:06:07.101459
2009-02-19T20:59:59
2009-02-19T20:59:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,006
h
/* * * Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's * prior written consent.This software contains code, techniques and know-how which is confidential and proprietary to Havok. * Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2008 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement. * */ #ifndef HK_CHARACTER_STATE_FLYING #define HK_CHARACTER_STATE_FLYING #include <Physics/Utilities/CharacterControl/StateMachine/hkpCharacterState.h> /// A state to represent flying. /// This state is currently unused - no other states transition to it. class hkpCharacterStateFlying : public hkpCharacterState { public: hkpCharacterStateFlying() {} /// Return the state type virtual hkpCharacterStateType getType() const; /// Process the user input - causes state actions. virtual void update(hkpCharacterContext& context, const hkpCharacterInput& input, hkpCharacterOutput& output); /// Process the user input - causes state transitions. virtual void change(hkpCharacterContext& context, const hkpCharacterInput& input, hkpCharacterOutput& output); }; #endif // HK_CHARACTER_STATE_FLYING /* * Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20080529) * * Confidential Information of Havok. (C) Copyright 1999-2008 * Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok * Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership * rights, and intellectual property rights in the Havok software remain in * Havok and/or its suppliers. * * Use of this software for evaluation purposes is subject to and indicates * acceptance of the End User licence Agreement for this product. A copy of * the license is included with this software and is also available at * www.havok.com/tryhavok * */
[ "uraymeiviar@bb790a93-564d-0410-8b31-212e73dc95e4" ]
[ [ [ 1, 47 ] ] ]
2331016c92194ed97bdfaa3519f45446db2c71e4
c5ecda551cefa7aaa54b787850b55a2d8fd12387
/src/WorkLayer/GlobalVariable.h
803b4201cb145bafdbbf9545076eca4bb4e2cd6c
[]
no_license
firespeed79/easymule
b2520bfc44977c4e0643064bbc7211c0ce30cf66
3f890fa7ed2526c782cfcfabb5aac08c1e70e033
refs/heads/master
2021-05-28T20:52:15.983758
2007-12-05T09:41:56
2007-12-05T09:41:56
null
0
0
null
null
null
null
IBM852
C++
false
false
4,314
h
#pragma once #include "ServerList.h" #include "ListenSocket.h" #include "ClientList.h" #include "KnownFileList.h" #include "UploadQueue.h" #include "DownloadQueue.h" #include "ClientUDPSocket.h" #include "NatTraversal/NatThread.h" #include "sockets.h" #include "SharedFileList.h" #include "SearchList.h" #include "ip2country.h" #include "PeerCacheFinder.h" #include "WebServer.h" #include "IPFilter.h" #include "Internal/InternalSocket.h" #include "MMServer.h" #include "ClientCredits.h" #include "FileMgr.h" #include "LastCommonRouteFinder.h" #include "SeeFileManager.h" #include "DLP.h" enum AppState { APP_STATE_RUNNING = 0, APP_STATE_SHUTTINGDOWN, APP_STATE_DONE }; class CPeerCacheFinder; class CInternalSocket; class CDNSManager; struct SLogItem; class CGlobalVariable { public: CGlobalVariable(void); ~CGlobalVariable(void); static CClientList* clientlist; static CKnownFileList* knownfiles; static CUploadQueue* uploadqueue; static CDownloadQueue* downloadqueue; static CServerConnect* serverconnect; static CSharedFileList* sharedfiles; static CServerList* serverlist; static CSearchList* searchlist; static CClientCreditsList* clientcredits; static CDNSManager* m_DNSManager; static HWND m_hListenWnd; static AppState m_app_state; // defines application state for shutdown static CListenSocket* listensocket; static CClientUDPSocket* clientudp; static CNatThread* natthread; static CIP2Country* ip2country; //EastShare - added by AndCycle, IP to Country static CPeerCacheFinder* m_pPeerCache; static CWebServer* webserver; static CIPFilter* ipfilter; static CInternalSocket* internalsocket; // VC-kernel[2007-01-11]: static CMMServer* mmserver; static CFileMgr filemgr; static CMutex hashing_mut; static CSeeFileManager m_SeeFileManager; // VC-SearchDream[2007-07-12]: static UploadBandwidthThrottler* uploadBandwidthThrottler; static LastCommonRouteFinder* lastCommonRouteFinder; static CTypedPtrList<CPtrList, SLogItem*> m_QueueDebugLog; static CTypedPtrList<CPtrList, SLogItem*> m_QueueLog; static const UINT m_nVersionMjr; static const UINT m_nVersionMin; static const UINT m_nVersionUpd; static const UINT m_nVersionBld; static const UINT m_nVCVersionBld; //Added by thilon on 2006.01.10, for VeryCD░ŠBuild║┼ static UINT m_uCurVersionShort; static const UINT m_nEasyMuleMjr; static const UINT m_nEasyMuleMin; static const UINT m_nEasyMuleUpd; static const UINT m_nMaxDownloadingSeeFiles; //Xman DLP static CDLP * dlp; public: static bool IsRunning() { return (CGlobalVariable::m_app_state == APP_STATE_RUNNING); } static bool CreateGlobalObject(); static bool Initialize(HWND hWnd); static void Clearup(); // global functions static void SetPublicIP(const uint32 dwIP); static uint32 GetPublicIP(bool bIgnoreKadIP = false); static CString GetCurVersionLong() { return m_strCurVersionLong; } static DWORD GetTCPIPVaule(void) { return m_dwTCPIPValue; } static void SetTCPIPValue(DWORD dwValue) { m_dwTCPIPValue = dwValue; } static void SetCurVersionLong(const CString & strNew); static void QueueDebugLogLine(bool bAddToStatusBar, LPCTSTR line,...); static void QueueDebugLogLineEx(UINT uFlags, LPCTSTR line,...); static void QueueLogLine(bool bAddToStatusBar, LPCTSTR line,...); static void QueueLogLineEx(UINT uFlags, LPCTSTR line,...); static void ClearLogQueue(bool bDebugPendingMsgs = false); static void ClearDebugLogQueue(bool bDebugPendingMsgs = false); static void HandleDebugLogQueue(); static void HandleLogQueue(); static bool DoCallback( CUpDownClient *client ); static bool IsFirewalled(); static bool IsConnected(); static uint32 GetID(); static void ShowNotifier(LPCTSTR pszText, int iMsgType, LPCTSTR pszLink = NULL, bool bForceSoundOFF = false); private: static uint32 m_dwPublicIP; static CString m_strCurVersionLong; static CCriticalSection m_queueLock; static int m_dwTCPIPValue; //Added by thilon on 2006.08.07 }; extern void UINotify(UINT msg, WPARAM wParam, LPARAM lParam, void * pTag = NULL, bool bCredible=false); extern void RemoveMessageTag(void * pTag);
[ "LanceFong@4a627187-453b-0410-a94d-992500ef832d" ]
[ [ [ 1, 142 ] ] ]
4ba43577709a17f3e513a3b8efd8bf99f1cfe132
6d25f0b33ccaadd65b35f77c442b80097a2fce8e
/gbt/tree.h
0081269c47a93c29256bb2016cb7210178e9aed5
[]
no_license
zhongyunuestc/felix-academic-project
8b282d3a783aa48a6b56ff6ca73dc967f13fd6cf
cc71c44fba50a5936b79f7d75b5112d247af17fe
refs/heads/master
2021-01-24T10:28:38.604955
2010-03-20T08:33:59
2010-03-20T08:33:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,486
h
#ifndef __GBTREE__TREE #define __GBTREE__TREE #include <cstdlib> #include <iostream> #include <vector> #include <vectors.h> #include <common.h> struct Node { int attribute; int size; double value; double ymeans; double improve; Node *left, *right; double var; Node() : attribute(-1), value(0), left(NULL), right(NULL) {} Node& getLeft() { return *left; } Node& getRight() { return *right; } virtual ~Node() { if(left!=NULL) delete left; if(right!=NULL) delete right; } }; template <typename T> static double apply_cart(int dim_num, const T& data, const Node* root) { const Node* temp = root; assert(temp!=NULL); while(temp!=NULL) { // printf("temp->att %d value %lf\n", temp->attribute, temp->value); if(temp->left==NULL||temp->right==NULL) return temp->ymeans; if(dcmp(data[temp->attribute]-temp->value)<0) { temp = temp->left; } else { temp = temp->right; } } assert(false); return -1.0; } //void apply_cart(int data_num, int dim_num, const double* data, const Node* root, double* y); void apply_cart(const DataSet& dataset, const Node* root, double* y); void save_tree(FILE* fp, const Node* const root); Node* load_tree(FILE* fp); //void free_tree(Node* root); void save_tree(std::ostream& f, const Node* const root); Node* load_tree(std::istream& f); double apply_cart(const FVector& x, const Node* root); double cal_dependent(const Node* root, int featureid); #endif
[ "Felix.Guozq@fe1a0076-fbb2-11de-b7cb-b1160b2c2156" ]
[ [ [ 1, 57 ] ] ]
202e350a5cca6fae76c1d8c594f429404d73b431
fd4a071ba9d8f0abf82e7a4d2cb41f48b9339b51
/outmod/TextToHtmlModifier.h
d816a340221627aacee2368b679ce7275e97ca5f
[]
no_license
rafalka/rs232testng
c4a6e4c1777ee92b2d67056739b2524569f5be5d
634d38cf8745841cf0509fb10c1faf6943516cbc
refs/heads/master
2020-05-18T17:14:51.166302
2011-01-12T22:00:01
2011-01-12T22:00:01
37,258,102
0
0
null
null
null
null
UTF-8
C++
false
false
1,138
h
/****************************************************************************** * @file TextToHtmlModifier.h * * @brief * * @date 04-12-2010 * @author Rafal Kukla ****************************************************************************** * Copyright (C) 2010 Rafal Kukla ( [email protected] ) * This file is a part of rs232testng project and is released * under the terms of the license contained in the file LICENSE ****************************************************************************** */ #ifndef TEXTTOHTMLMODIFIER_H_ #define TEXTTOHTMLMODIFIER_H_ /* * */ #include "DataProvider.h" #include "StreamItem.h" class TextToHtmlModStreamItem: public StreamItem { public: void In(DataChunk* data); }; class TextToHtmlModifier: public DataProvider { private: TextToHtmlModStreamItem stream; public: static const QString myDisplayName ; StreamItem* getDefaultStream() {return &stream; }; void SetupUI(QWidget *parent) {}; TextToHtmlModifier(); }; #endif /* TEXTTOHTMLMODIFIER_H_ */
[ "rkdevel@ef62a7f8-4c9b-1a64-55d9-32abd1026911" ]
[ [ [ 1, 48 ] ] ]
647890b70068104d941891c936e326d3f0117c5e
ef0162b1f0fc9c0a9b2e13427d0957933ecf8d96
/MStream/Player.h
f82df0b45a842aba80adfd5f18bf0ddec82ff0c4
[]
no_license
ittennull/MStream
1fc432e54354e12cef78a0d40189a0771c93f505
065158e840d0fa86206f396047379adbe97d246f
refs/heads/master
2021-01-01T19:29:52.907776
2011-02-08T06:50:03
2011-02-08T06:50:03
1,319,574
1
1
null
null
null
null
UTF-8
C++
false
false
982
h
#ifndef PLAYER_H #define PLAYER_H #include "IPlayer.h" #include "IDecoder.h" #include "Downloader.h" class Player : public IPlayer { IDecoder* _decoder; Downloader* _downloader; PlayerState _playerState; const size_t _downloaderBufferSize; boost::thread _openThread; CRITICAL_SECTION cs; FILE* _currentFile; boost::function<void()> onOpened; public: Player(size_t downloaderBufferSizeKB); ~Player(); virtual void play(const char* uri, boost::function<void()> onOpened); virtual void stop(); virtual size_t getData(byte* buffer, size_t bufferSize); virtual PlayerState getState(); virtual int getBufferingPercentComplete(); virtual int getNumberOfChannels(); virtual int getNumberOfBitsPerSample(); virtual int getNumberOfSamplesPerSecond(); virtual int getInstantBitRate(); virtual void getComments(std::vector<std::string>& out); private: void onBufferingComplete(); void openStream(); }; #endif
[ "[email protected]", "dima@.(none)" ]
[ [ [ 1, 22 ], [ 25, 28 ], [ 30, 44 ], [ 46, 48 ] ], [ [ 23, 24 ], [ 29, 29 ], [ 45, 45 ] ] ]
210686267e65a8fe76eb9e0b76eee98e7b0ec15c
0429e2b2a1a09254b5182e15835da188f7d44a3d
/tags/v06_STABLE_VERSION/tests/room/troom.cpp
bac7d5e1696ab871a8f66f2665712d98742488e6
[]
no_license
TheolZacharopoulos/tl2hotel
0b5af731aa022b04fc7b894b4fad6ce0b1121744
87ff9c75250d702c49d62f43e494cf549ea700b7
refs/heads/master
2020-03-30T05:41:55.498410
2011-04-25T22:24:44
2011-04-25T22:24:44
42,362,513
0
0
null
null
null
null
UTF-8
C++
false
false
1,616
cpp
/** @file troom.cpp * @brief Room Unit Test Implementation * @author Efstathios Xatzikiriakidis * * This is the unit test for the "Room" class. */ #include "troom.h" int gRoomNumber = 1; /**< Room number value (test data). */ int gRoomFloor = 1; /**< Room floor value (test data). */ int gCapacity = 2; /**< Room capacity value (test data). */ /** Room Constructor Test Method * @brief This method tests the constructor of the "Room" class. * @author Efstathios Xatzikiriakidis */ void TRoom::testConstructor () { Room r (gRoomNumber, gRoomFloor, gCapacity); QVERIFY (r.getRoomNumber () == gRoomNumber && r.getRoomFloor () == gRoomFloor && r.getCapacity () == gCapacity); } /** Room Number Test Method * @brief This method tests the Number set/get methods of the "Room" class. * @author Efstathios Xatzikiriakidis */ void TRoom::testRoomNumber () { Room r; r.setRoomNumber (gRoomNumber); QVERIFY (r.getRoomNumber () == gRoomNumber); } /** Room Floor Test Method * @brief This method tests the Floor set/get methods of the "Room" class. * @author Efstathios Xatzikiriakidis */ void TRoom::testRoomFloor () { Room r; r.setRoomFloor (gRoomFloor); QVERIFY (r.getRoomFloor () == gRoomFloor); } /** Room Capacity Test Method * @brief This method tests the Capacity set/get methods of the "Room" class. * @author Efstathios Xatzikiriakidis */ void TRoom::testCapacity () { Room r; r.setCapacity (gCapacity); QVERIFY (r.getCapacity () == gCapacity); } QTEST_MAIN (TRoom)
[ "delis89@fb7cbe1a-da42-76e9-2caa-fedf319af631" ]
[ [ [ 1, 63 ] ] ]
73abc7befad01d85a5f4eabde82d5abefb4fbda8
a0155e192c9dc2029b231829e3db9ba90861f956
/MFConfig/ListCtrlEx.cpp
4cde1a99844814712a41f7f3bee922f59f13cbfe
[]
no_license
zeha/mailfilter
d2de4aaa79bed2073cec76c93768a42068cfab17
898dd4d4cba226edec566f4b15c6bb97e79f8001
refs/heads/master
2021-01-22T02:03:31.470739
2010-08-12T23:51:35
2010-08-12T23:51:35
81,022,257
0
0
null
null
null
null
UTF-8
C++
false
false
1,872
cpp
// ListCtrlEx.cpp : implementation file // #include "stdafx.h" #include "MFConfig.h" #include "ListCtrlEx.h" #include "mf_c.h" #undef _MAILFILTER_MFCONFIG_STORAGE #include "../MailFilter/Config/MFConfig.h" // CListCtrlEx IMPLEMENT_DYNAMIC(CListCtrlEx, CListCtrl) CListCtrlEx::CListCtrlEx() { } CListCtrlEx::~CListCtrlEx() { } BEGIN_MESSAGE_MAP(CListCtrlEx, CListCtrl) END_MESSAGE_MAP() // Fills in values from MFConfig int CListCtrlEx::UpdateValue(MF_C_Storage* mfcs) { if (mfcs == NULL) return FALSE; CString tmp; switch(mfcs->type) { case None: break; case Integer: tmp.Format("%d",mfcs->data); this->SetItemText(mfcs->displayid, 1, tmp); break; case String: this->SetItemText(mfcs->displayid, 1, (char*)mfcs->data); break; case Bool: this->SetItemText(mfcs->displayid, 1, (bool)(mfcs->data) == TRUE ? "Yes" : "No"); break; default: break; } this->RedrawItems(mfcs->displayid-2,mfcs->displayid+2); return TRUE; } // Fills in values from MFConfig int CListCtrlEx::FillIn(void) { this->InsertColumn(0,"Name"); this->InsertColumn(1,"Value"); this->SetColumnWidth(0,200); this->SetColumnWidth(1,320); CMF_C mfc = theApp.m_CMFC; MF_C_Storage* mfcs = mfc.GetFirst(); int ci = 0; CString tmp; while (mfcs->next != NULL) { this->InsertItem( LVIF_TEXT, ci, mfcs->name, 0, LVIS_SELECTED, 0, 0); this->SetItemData(ci,mfcs->displayid); switch(mfcs->type) { case None: break; case Integer: tmp.Format("%d",mfcs->data); this->SetItemText(ci, 1, tmp); break; case String: this->SetItemText(ci, 1, (char*)mfcs->data); break; case Bool: this->SetItemText(ci, 1, (int)mfcs->data == TRUE ? "Yes" : "No"); break; default: break; } ci++; mfcs = mfcs->next; } return TRUE; }
[ [ [ 1, 100 ] ] ]
76a26069da4cad4fba749bdc51cbe5586b64ea5f
38d9a3374e52b67ca01ed8bbf11cd0b878cce2a5
/branches/tbeta/CCV-fid/addons/ofx3DModelLoader/example/src/testApp.cpp
34f7a372d033bcc235d5922997ffa2f8bd04bdae
[]
no_license
hugodu/ccv-tbeta
8869736cbdf29685a62d046f4820e7a26dcd05a7
246c84989eea0b5c759944466db7c591beb3c2e4
refs/heads/master
2021-04-01T10:39:18.368714
2011-03-09T23:05:24
2011-03-09T23:05:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,510
cpp
#include "testApp.h" GLfloat lightOnePosition[] = {40.0, 40, 100.0, 0.0}; GLfloat lightOneColor[] = {0.99, 0.99, 0.99, 1.0}; GLfloat lightTwoPosition[] = {-40.0, 40, 100.0, 0.0}; GLfloat lightTwoColor[] = {0.99, 0.99, 0.99, 1.0}; //-------------------------------------------------------------- void testApp::setup(){ ofBackground(255,255,255); ofSetVerticalSync(true); //some model / light stuff glEnable (GL_DEPTH_TEST); glShadeModel (GL_SMOOTH); /* initialize lighting */ glLightfv (GL_LIGHT0, GL_POSITION, lightOnePosition); glLightfv (GL_LIGHT0, GL_DIFFUSE, lightOneColor); glEnable (GL_LIGHT0); glLightfv (GL_LIGHT1, GL_POSITION, lightTwoPosition); glLightfv (GL_LIGHT1, GL_DIFFUSE, lightTwoColor); glEnable (GL_LIGHT1); glEnable (GL_LIGHTING); glColorMaterial (GL_FRONT_AND_BACK, GL_DIFFUSE); glEnable (GL_COLOR_MATERIAL); //load the squirrel model - the 3ds and the texture file need to be in the same folder squirrelModel.loadModel("squirrel/NewSquirrel.3ds", 20); //you can create as many rotations as you want //choose which axis you want it to effect //you can update these rotations later on squirrelModel.setRotation(0, 90, 1, 0, 0); squirrelModel.setRotation(1, 270, 0, 0, 1); squirrelModel.setScale(0.9, 0.9, 0.9); squirrelModel.setPosition(ofGetWidth()/2, ofGetHeight()/2, 0); } //-------------------------------------------------------------- void testApp::update(){ squirrelModel.setRotation(1, 270 + ofGetElapsedTimef() * 60, 0, 0, 1); } //-------------------------------------------------------------- void testApp::draw(){ //fake back wall ofSetColor(20, 20, 20); glBegin(GL_QUADS); glVertex3f(0.0, ofGetHeight(), -600); glVertex3f(ofGetWidth(), ofGetHeight(), -600); glVertex3f(ofGetWidth(), 0, -600); glVertex3f(0, 0, -600); glEnd(); //fake wall ofSetColor(50, 50, 50); glBegin(GL_QUADS); glVertex3f(0.0, ofGetHeight(), 0); glVertex3f(ofGetWidth(), ofGetHeight(), 0); glVertex3f(ofGetWidth(), ofGetHeight(), -600); glVertex3f(0, ofGetHeight(), -600); glEnd(); //lets tumble the world with the mouse glPushMatrix(); //draw in middle of the screen glTranslatef(ofGetWidth()/2,ofGetHeight()/2,0); //tumble according to mouse glRotatef(-mouseY,1,0,0); glRotatef(mouseX,0,1,0); glTranslatef(-ofGetWidth()/2,-ofGetHeight()/2,0); ofSetColor(255, 255, 255, 255); squirrelModel.draw(); glPopMatrix(); ofSetColor(0x000000); ofDrawBitmapString("fps: "+ofToString(ofGetFrameRate(), 2), 10, 15); } //-------------------------------------------------------------- void testApp::keyPressed (int key){ } //-------------------------------------------------------------- void testApp::keyReleased (int key){ } //-------------------------------------------------------------- void testApp::mouseMoved(int x, int y ){ } //-------------------------------------------------------------- void testApp::mouseDragged(int x, int y, int button){ } //-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button){ } //-------------------------------------------------------------- void testApp::mouseReleased(int x, int y, int button){ }
[ "schlupek@463ed9da-a5aa-4e33-a7e2-2d3b412cff85" ]
[ [ [ 1, 114 ] ] ]
1f3b823f783b7715509a49e7091cd28bb1e471c4
f177993b13e97f9fecfc0e751602153824dfef7e
/ImProSln/MyLib/MuxSourceFilter.h
d1b57eb8f922136f12b6a13906f81320ab59c763
[]
no_license
svn2github/imtophooksln
7bd7412947d6368ce394810f479ebab1557ef356
bacd7f29002135806d0f5047ae47cbad4c03f90e
refs/heads/master
2020-05-20T04:00:56.564124
2010-09-24T09:10:51
2010-09-24T09:10:51
11,787,598
1
0
null
null
null
null
UTF-8
C++
false
false
2,109
h
#pragma once #include "dshow.h" #include "Streams.h" #include <initguid.h> #include "combase.h" using namespace std; class CMuxSourceOutputPin; class CMuxSourceFilter : public CSource { friend class CMuxSourceOutputPin; protected: //PURE function have to be implemented by Derived class virtual HRESULT CreatePins() = 0; virtual HRESULT FillBuffer(IMediaSample *pSamp, IPin* pPin) = 0; virtual HRESULT GetMediaType(int iPosition, __inout CMediaType *pMediaType, IPin* pPin) = 0; // Called as the thread is created/destroyed - use to perform // jobs such as start/stop streaming mode // If OnThreadCreate returns an error the thread will exit. virtual HRESULT OnThreadCreate(IPin* pPin){return NOERROR;}; virtual HRESULT OnThreadDestroy(IPin* pPin){return NOERROR;}; virtual HRESULT OnThreadStartPlay(IPin* pPin){return NOERROR;}; public: CMuxSourceFilter(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid, __inout HRESULT *phr); CMuxSourceFilter(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid); #ifdef UNICODE CMuxSourceFilter(__in_opt LPCSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid, __inout HRESULT *phr); CMuxSourceFilter(__in_opt LPCSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid); #endif virtual ~CMuxSourceFilter(void); }; class CMuxSourceOutputPin : public CSourceStream { friend class CMuxSourceFilter; public: CMuxSourceOutputPin(__in_opt LPCSTR pObjectName, __inout HRESULT *phr,__inout CMuxSourceFilter *pms,__in_opt LPCWSTR pName); virtual ~CMuxSourceOutputPin(); virtual HRESULT FillBuffer(IMediaSample *pSamp); // Called as the thread is created/destroyed - use to perform // jobs such as start/stop streaming mode // If OnThreadCreate returns an error the thread will exit. virtual HRESULT OnThreadCreate(void); virtual HRESULT OnThreadDestroy(void); virtual HRESULT OnThreadStartPlay(void); // * // * AM_MEDIA_TYPE support // * virtual HRESULT GetMediaType(int iPosition, __inout CMediaType *pMediaType); // List pos. 0-n };
[ "ndhumuscle@fa729b96-8d43-11de-b54f-137c5e29c83a" ]
[ [ [ 1, 67 ] ] ]
4ef9cab8abd112441b58336685c58222d6a43b49
34e71d4557824bf1438579e420701484b27d28d6
/D4.cpp
ac787be0f92db8d0bdf1c9b6fa30c225046dd751
[]
no_license
Maciej-Poleski/athina-submits
afe4b9bcbbcf970ae2e2561e8ba890adfc66b15a
a37bccf16488e79ceb6f40513ec98efb453a3b93
refs/heads/master
2023-06-30T11:53:08.550666
2011-01-16T19:30:27
2011-01-16T19:30:27
392,817,455
0
0
null
null
null
null
UTF-8
C++
false
false
2,768
cpp
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; char a[30005]; char b[30005]; int *LCSP; int *LCSS; int n; int m; int LCS(const int PA,const int KA,const int PB,const int KB) { //printf("\t%d %d %d %d:\n",PA,KA,PB,KB); if(KB-PB==1) { for(int i=PA;i<KA;++i) if(a[i]==b[PB]) { printf("%c",b[PB]); return 1; } return 0; } int l=KA-PA; // Długość części prefixu słowa a if(l==0) // Nie zajmuje się słowem którego nie ma. return 0; LCSP=new int[l]; // Tablica O(n) dla prefixów LCSS=new int[l]; // Dla sufiksów int x,q; // Dodatkowy element /* PREFIXY */ LCSP[0]=(a[PA]==b[PB])?1:0; for(int i=1;i<l;++i) // Wypełniam LCS prefixów pierwszy rząd LCSP[i]=max(LCSP[i-1],(a[PA+i]==b[PB])?1:0); /*printf("int:"); for(int i=0;i<l;++i) printf(" %d",LCSP[i]); puts("");*/ for(int i=PB+1;i<(PB+KB)/2;++i) // Wyznaczam LCS prefixów (rozwiązanie w LCSP[l-1]) { x=LCSP[0]; LCSP[0]=max(LCSP[0],(b[i]==a[PA])?1:0); for(int j=1;j<l;++j) { q=LCSP[j]; LCSP[j]=(b[i]==a[j+PA])?1+x:max(LCSP[j],LCSP[j-1]); x=q; } } /* SUFIXY */ LCSS[l-1]=(a[KA-1]==b[KB-1])?1:0; for(int i=l-2;i>=0;--i) // Wypełniam LCS sufiksów pierwszy rząd LCSS[i]=max(LCSS[i+1],a[PA+i]==b[KB-1]?1:0); for(int i=KB-2;i>=(PB+KB)/2;--i) // Wyznaczam LCS sufixów (rozwiązanie w LCSS[l-1]) { x=LCSS[l-1]; LCSS[l-1]=max(LCSS[l-1],(b[i]==a[KA-1])?1:0); for(int j=l-2;j>=0;--j) { q=LCSS[j]; LCSS[j]=(b[i]==a[PA+j])?1+x:max(LCSS[j],LCSS[j+1]); x=q; } } /*for(int i=0;i<l;++i) printf("%d ",LCSP[i]); puts(""); for(int i=0;i<l;++i) printf("%d ",LCSS[i]); puts("");*/ x=-1; q=LCSS[0]; for(int i=0;i<l-1;++i) { if(LCSP[i]+LCSS[i+1]>q) { x=i; q=LCSP[i]+LCSS[i+1]; } } if(LCSP[l-1]>q) { q=LCSP[l-1]; x=l-1; } int t1=(x>=0)?LCSP[x]:0; int t2=(x+1<l)?LCSS[x+1]:0; delete [] LCSP; delete [] LCSS; if(int e=LCS(PA,PA+x+1,PB,(PB+KB)/2)!=t1) printf("|To rozwiązanie jest błędne!, oczekiwano %d a otrzymano %d|",t1,e); if(int e=LCS(PA+x+1,KA,(PB+KB)/2,KB)!=t2) printf("|To rozwiązanie jest błędne!, oczekiwano %d a otrzymano %d|",t2,e); return q; } int main() { int z; scanf("%d\n",&z); while(z--) { scanf("%s %s\n",a,b); // Słowa a i b n=strlen(a); // Długości m=strlen(b); if(LCS(0,n,0,m)==0) printf("-"); printf("\n"); } return 0; }
[ [ [ 1, 133 ] ] ]
52b0736ecc286de969c8c3032cee73848ded780f
b0252ba622183d115d160eb28953189930ebf9c0
/Source/CSGD_DirectSound.h
93676842d82f604dda597ed93ba005088ec4e84e
[]
no_license
slewicki/khanquest
6c0ced33bffd3c9ee8a60c1ef936139a594fe2fc
f2d68072a1d207f683c099372454add951da903a
refs/heads/master
2020-04-06T03:40:18.180208
2008-08-28T03:43:26
2008-08-28T03:43:26
34,305,386
2
0
null
null
null
null
UTF-8
C++
false
false
3,519
h
//////////////////////////////////////////////////////// // File : "CSGD_DirectSound.h" // // Author : Jensen Rivera (JR) // // Creation Date : 4/05/2004 // // Purpose : Wrapper class for DirectSound. //////////////////////////////////////////////////////// /* Disclaimer: This source code was developed for and is the property of Full Sail Real World Education Game Design Curriculum 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Full Sail students may not redistribute this code, but may use it in any project for educational purposes. */ #pragma once #include <dsound.h> #pragma comment (lib, "dsound.lib") #pragma comment (lib, "dxguid.lib") // Macro to safely Release COM Objects. #ifndef SAFE_RELEASE #define SAFE_RELEASE(p) if (p) { p->Release(); p = NULL; } #endif #ifndef DSERRBOX #define DSERRBOX(a) { MessageBox(m_hWnd, a, "CSGD_DirectSound Error", MB_OK | MB_ICONEXCLAMATION); return false; } #endif // Primary Buffer quality constants enum { PB_LOQUAL = 1, PB_MEDQUAL, PB_HIQUAL, }; class CSGD_DirectSound { private: LPDIRECTSOUND8 m_dsObject; // The Main DirectSound Object. LPDIRECTSOUNDBUFFER m_dsPrimaryBuffer; // The Primary Buffer (if Necessary). HWND m_hWnd; // The Main Window Handle. static CSGD_DirectSound m_Instance; // The Instance of this class. // CSGD_DirectSound : Constructor for DS setup CSGD_DirectSound(); // Copy Constructor. CSGD_DirectSound(const CSGD_DirectSound&); // Assignment Operator. CSGD_DirectSound &operator = (const CSGD_DirectSound&); // ~CSGD_DirectSound: Destructor virtual ~CSGD_DirectSound(); public: /////////////////////////////////////////////////////////////////// // Function: "GetInstance" // // Last Modified: 8/04/2006 // // Input: void // // Return: An instance to this class. // // Purpose: Gets an instance to this class. /////////////////////////////////////////////////////////////////// static CSGD_DirectSound *GetInstance(void); /////////////////////////////////////////////////////////////////////////////// // Function : "GetDSObject" // // Last Modified : 4/05/2004 // // Input : void // // Return : The Main DirectSound Object. // // Purpose : To retrieve the main DirectSound Object. /////////////////////////////////////////////////////////////////////////////// inline LPDIRECTSOUND8 GetDSObject(void) { return m_dsObject; } /////////////////////////////////////////////////////////////////////////////// // Function : "InitDirectSound" // // Last Modified : 4/05/2004 // // Input : hWnd - Main Window Handle. // nPrimaryBufferFormat - PB_LOQUAL for Normal, 11khz (default) // PB_MEDQUAL for 22khz // PB_HIQUAL for 44khz // // Return : true, if successful. // // Purpose : Initialize DirectSound and create a Primar Buffer, if needed. /////////////////////////////////////////////////////////////////////////////// bool InitDirectSound(HWND hWnd, int nPrimaryBufferFormat = PB_LOQUAL); /////////////////////////////////////////////////////////////////////////////// // Function : "ShutdownDirectSound" // // Last Modified : 4/05/2004 // // Input : void // // Return : true, if successful. // // Purpose : Release all DirectSound pointers /////////////////////////////////////////////////////////////////////////////// bool ShutdownDirectSound(void); };
[ "[email protected]@631b4192-2952-0410-9426-c5ed74a7d3ec" ]
[ [ [ 1, 117 ] ] ]
b02141be81d83193d4c39997c9fae8c746695f0c
0f8559dad8e89d112362f9770a4551149d4e738f
/Wall_Destruction/Havok/Source/Common/Visualize/hkVersionReporter.h
e012132fa2847cc8e33879a76e7fb273152e282f
[]
no_license
TheProjecter/olafurabertaymsc
9360ad4c988d921e55b8cef9b8dcf1959e92d814
456d4d87699342c5459534a7992f04669e75d2e1
refs/heads/master
2021-01-10T15:15:49.289873
2010-09-20T12:58:48
2010-09-20T12:58:48
45,933,002
0
0
null
null
null
null
UTF-8
C++
false
false
2,110
h
/* * * Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's * prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok. * Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2009 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement. * */ #ifndef HK_VISUALIZE_VERSION_REPORTER #define HK_VISUALIZE_VERSION_REPORTER class hkStreamWriter; /// This class manages version information between the server and client. /// Currently the proto call version is the same as the build number and /// for a client to work with a server they must have the same version /// number. Please always use the visual debugger client that shipped /// with the packages you received. class hkVersionReporter { public: enum Command // for serialization { HK_VERSION_INFORMATION = 0x90 }; /// Sends a data 'chunk' which contains the version information /// of the Havok libs that the senders process/executable is /// linked with. static hkResult HK_CALL sendVersionInformation( hkStreamWriter* connection ); public: static int m_protocolVersion; static int m_protocolMinimumCompatible; }; #endif // HK_VISUALIZE_VERSION_REPORTER /* * Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20091222) * * Confidential Information of Havok. (C) Copyright 1999-2009 * Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok * Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership * rights, and intellectual property rights in the Havok software remain in * Havok and/or its suppliers. * * Use of this software for evaluation purposes is subject to and indicates * acceptance of the End User licence Agreement for this product. A copy of * the license is included with this software and is also available at www.havok.com/tryhavok. * */
[ [ [ 1, 57 ] ] ]
5897cd386c60df2824e6e9642879d11fb4962a20
718dc2ad71e8b39471b5bf0c6d60cbe5f5c183e1
/soft micros/Codigo/codigo portable/Aparatos/Comunicacion/comunicacionSensorTermoPT.cpp
b1bbf359137e27fa40edf87030995d72225d8330
[]
no_license
jonyMarino/microsdhacel
affb7a6b0ea1f4fd96d79a04d1a3ec3eaa917bca
66d03c6a9d3a2d22b4d7104e2a38a2c9bb4061d3
refs/heads/master
2020-05-18T19:53:51.301695
2011-05-30T20:40:24
2011-05-30T20:40:24
34,532,512
0
0
null
null
null
null
UTF-8
C++
false
false
877
cpp
#include "comunicacionSensorTermoPT.hpp" #include "propiedadesSensorTermoPT.hpp" const void * costructoresGettersSensorTermoPT[] = { &cGetterValSen, &cGetterEstado }; const void * costructoresPropiedadesSensorTermoPT[] = { &cPropiedadTipoSensor, &cPropiedadFiltro, &cPropiedadOffset, &cPropiedadGanancia, &cPropiedadAjCeroT, &cPropiedadAjGanT, &cPropiedadAjCeroPT, &cPropiedadAjGanPT, &cPropiedadAjTempAmb }; const NEW_ARRAY( arrayCostructoresPropiedadesSensorTermoPT,costructoresPropiedadesSensorTermoPT) ; const GetsProps getPropiedadesSensorTermoPT={ &arrayCostructoresPropiedadesSensorTermoPT, TRUE }; const NEW_ARRAY( arrayCostructoresGettersSensorTermoPT,costructoresGettersSensorTermoPT) ; const GetsProps getGettersSensorTermoPT={ &arrayCostructoresGettersSensorTermoPT, FALSE };
[ "jonymarino@9fc3b3b2-dce3-11dd-9b7c-b771bf68b549" ]
[ [ [ 1, 33 ] ] ]
74e079c3d0335eaa3e0e257c6cf5ef41d1d17ed9
b6a6fa4324540b94fb84ee68de3021a66f5efe43
/Duplo/include/Dup_Base.h
8b6068bd183783974192636c22db505ed1f4beca
[]
no_license
southor/duplo-scs
dbb54061704f8a2ec0514ad7d204178bfb5a290e
403cc209039484b469d602b6752f66b9e7c811de
refs/heads/master
2021-01-20T10:41:22.702098
2010-02-25T16:44:39
2010-02-25T16:44:39
34,623,992
0
0
null
null
null
null
UTF-8
C++
false
false
2,097
h
#ifndef _DUP_BASE_H #define _DUP_BASE_H #include "Dup_Declares.h" #include "math.h" namespace Dup { const double PI = 3.141592654; dup_pos timePos; dup_pos beatPos; //double frequency(double Fre,int Oct,int Note); double frequency(double fre, int oct, double note); dup_pos loop(dup_pos A, dup_pos Min, dup_pos Max); dup_pos loop(dup_pos A); double frequency(double fre, int oct, double note) { return fre*pow(2.0, note/12.0 + oct); } /* double frequency(double Fre,int Oct,int Note) { while(Note <= -7 || Note >= 7) { if (Note > 6) { Oct = Oct+1; Note = Note-12; } if (Note < -6) { Oct = Oct-1; Note = Note+12; } } // Oct = Oct+int((double)(Note+5)/12.0); // Note = Note-int((double)Note/7.0)*12; Fre = Fre * pow(2.0,(double)Oct); switch(Note) { case 1: Fre = Fre*1.059463094; break; case 2: Fre = Fre*1.122462048; break; case 3: Fre = Fre*1.189207115; break; case 4: Fre = Fre*1.25992105; break; case 5: Fre = Fre*1.334839854; break; case 6: Fre = Fre*1.414213562; break; case -1: Fre = Fre/1.059463094; break; case -2: Fre = Fre/1.122462048; break; case -3: Fre = Fre/1.189207115; break; case -4: Fre = Fre/1.25992105; break; case -5: Fre = Fre/1.334839854; break; case -6: Fre = Fre/1.414213562; break; } return Fre; } */ dup_pos loop(dup_pos A, dup_pos Min, dup_pos Max) { dup_pos Value, B, C; Value = A-Min; Max = Max-Min; if (Value/Max >= 0.0) { B = int(Value/Max); } else { C = int((-1.0)*Value/Max); B = int(Value/Max+C+3.0)-(C+3.0); } Value = Value-B*Max; return Value+Min; } dup_pos loop(dup_pos A) { dup_pos Value, B, C; Value = A; if (Value/1.0 >= 0.0) { B = int(Value); } else { C = int((-1.0)*Value); B = int(Value+C+3.0)-(C+3.0); } return Value-B; } }; #endif
[ "t.soderberg8@2b3d9118-3c8b-11de-9b50-8bb2048eb44c" ]
[ [ [ 1, 138 ] ] ]
a7d0bc9b021b45592240b24027f4ce9b03cc1d58
90aa2eebb1ab60a2ac2be93215a988e3c51321d7
/castor/branches/boost/libs/castor/test/test_get_value_cont.cpp
d15be40488c194dfe9b870d40d4ea9c90a9c159a
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
roshannaik/castor
b9f4ea138a041fe8bccf2d8fc0dceeb13bcca5a6
e86e2bf893719bf3164f9da9590217c107cbd913
refs/heads/master
2021-04-18T19:24:38.612073
2010-08-18T05:10:39
2010-08-18T05:10:39
126,150,539
0
0
null
null
null
null
UTF-8
C++
false
false
813
cpp
#include <boost/castor.h> #include <boost/test/minimal.hpp> using namespace castor; int test_main(int, char * []) { { // going from from std::list<lref<int> > to std::vector<int> std::list<lref<int> > lri; lri.push_back(1); lri.push_back(2); lri.push_back(3); std::vector<int> vi = getValueCont<std::vector<int> >(lri); BOOST_CHECK(vi[0] == 1 || vi[1] == 2 || vi[2] == 3); } { // going from from std::list<int*> to std::vector<int> int i[] = {1, 2, 3}; std::list<int*>lri; lri.push_back(i + 0); lri.push_back(i + 1); lri.push_back(i + 2); std::vector<int> vi = getValueCont<std::vector<int> >(lri); BOOST_CHECK(vi[0] == 1 || vi[1] == 2 || vi[2] == 3); } return 0; }
[ [ [ 1, 30 ] ] ]
21da38cc45943081b9d5a4a2c443881f4a7f12c6
6f7850c90ed97967998033df615d06eacfabd5fa
/common/my_inet.h
77070cdec1381c6a2d7d19e821663a93eb4b7d2e
[]
no_license
vi-k/whoisalive
1145b0af6a2a18e951533b00a2103b000abd570a
ae86c1982c1e97eeebc50ba54bf53b9b694078b6
refs/heads/master
2021-01-10T02:00:28.585126
2010-08-23T01:58:45
2010-08-23T01:58:45
44,526,120
0
0
null
null
null
null
UTF-8
C++
false
false
835
h
#ifndef MY_INET_H #define MY_INET_H #undef _WIN32_WINNT #define _WIN32_WINNT 0x0501 #define BOOST_ASIO_NO_WIN32_LEAN_AND_MEAN #include <boost/asio.hpp> namespace asio=boost::asio; namespace ip=boost::asio::ip; using boost::asio::ip::icmp; using boost::asio::ip::tcp; namespace my { namespace ip { std::string to_string(const ::ip::address_v4 &address); std::wstring to_wstring(const ::ip::address_v4 &address); std::string punycode_encode(const wchar_t *str, int len = -1); inline std::string punycode_encode(const std::wstring &str) { return my::ip::punycode_encode(str.c_str(), (int)str.size()); } std::wstring punycode_decode(const char *str, int len = -1); inline std::wstring punycode_decode(const std::string &str) { return my::ip::punycode_decode(str.c_str(), (int)str.size()); } } } #endif
[ "victor dunaev ([email protected])" ]
[ [ [ 1, 34 ] ] ]
f318a0efa708b97b9194d67466e1a9c69b2533b8
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/config/test/has_tr1_unordered_map_pass.cpp
8ceea7f6cf4bca3a082bd251bcd0aa393e0fc1ac
[ "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
1,073
cpp
// This file was automatically generated on Sat Feb 19 12:29:55 2005 // by libs/config/tools/generate.cpp // 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_TR1_UNORDERED_MAP // This file should compile, if it does not then // BOOST_HAS_TR1_UNORDERED_MAP should not be defined. // See file boost_has_tr1_unordered_map.ipp for details // 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_TR1_UNORDERED_MAP #include "boost_has_tr1_unordered_map.ipp" #else namespace boost_has_tr1_unordered_map = empty_boost; #endif int main( int, char *[] ) { return boost_has_tr1_unordered_map::test(); }
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 34 ] ] ]
373539a92f8d158ad49d9b080702e84828a2b317
291355fd4592e4060bca01383e2c3a2eff55bd58
/src/stack.h
2b5f03087a394d31fed87167f62e2ec2a83d3bf2
[]
no_license
rrader/cprompt
6d7c9aac25d134971bbf99d4e84848252a626bf3
dfb7d55111b6e8d3c3a0a0a1c703c04a58d5e808
refs/heads/master
2020-05-16T22:06:16.127336
2010-01-23T21:33:04
2010-01-23T21:33:04
1,659,726
1
1
null
null
null
null
UTF-8
C++
false
false
413
h
#ifndef STACK_H #define STACK_H #include "lists.h" #include <stdlib.h> namespace ag { template<typename T> class stack : public list<T> { public: stack() {}; ~stack() {}; listmember<T>* push(T data) { return add_tail(data); }; T& pop() { return del(this->tail); } private: }; } #endif // STACK_H
[ [ [ 1, 32 ] ] ]
89adf0547a07a64e0ba136ed55d49aa1b2e21858
b4f709ac9299fe7a1d3fa538eb0714ba4461c027
/trunk/powertabdocument.cpp
ae07c308cb10c16d9120b703c9086673aa1acf65
[]
no_license
BackupTheBerlios/ptparser-svn
d953f916eba2ae398cc124e6e83f42e5bc4558f0
a18af9c39ed31ef5fd4c5e7b69c3768c5ebb7f0c
refs/heads/master
2020-05-27T12:26:21.811820
2005-11-06T14:23:18
2005-11-06T14:23:18
40,801,514
0
0
null
null
null
null
UTF-8
C++
false
false
27,637
cpp
///////////////////////////////////////////////////////////////////////////// // Name: powertabdocument.cpp // Purpose: Loads and saves Power Tab files (.ptb) // Author: Brad Larsen // Modified by: // Created: Dec 29, 2004 // RCS-ID: // Copyright: (c) Brad Larsen // License: wxWindows license ///////////////////////////////////////////////////////////////////////////// #include "stdwx.h" #include "powertabdocument.h" #include "powertabinputstream.h" #include "powertabstream.h" #include <math.h> // Needed for pow #ifdef _DEBUG #define new DEBUG_NEW #endif IMPLEMENT_DYNAMIC_CLASS(PowerTabDocument, wxDocument) // Default Constants const wxInt32 PowerTabDocument::DEFAULT_TABLATURE_STAFF_LINE_SPACING = 9; const wxUint32 PowerTabDocument::DEFAULT_FADE_IN = 0; const wxUint32 PowerTabDocument::DEFAULT_FADE_OUT = 0; // Tablature Staff Line Spacing Constants const wxInt32 PowerTabDocument::MIN_TABLATURE_STAFF_LINE_SPACING = 6; const wxInt32 PowerTabDocument::MAX_TABLATURE_STAFF_LINE_SPACING = 14; // Score Constants const wxByte PowerTabDocument::NUM_SCORES = 2; const wxByte PowerTabDocument::GUITAR_SCORE = 0; const wxByte PowerTabDocument::BASS_SCORE = 1; // Guitar Constants const wxByte PowerTabDocument::MAX_GUITARS = 7; // Constructor/Destructor /// Default Constructor PowerTabDocument::PowerTabDocument() : m_tablatureStaffLineSpacing(DEFAULT_TABLATURE_STAFF_LINE_SPACING), m_fadeIn(DEFAULT_FADE_IN), m_fadeOut(DEFAULT_FADE_OUT) { //------Last Checked------// // - Jan 26, 2005 } /// Destructor PowerTabDocument::~PowerTabDocument() { //------Last Checked------// // - Jan 26, 2005 DeleteContents(); } // Save Functions /// Serializes the document to an output stream (in v1.7 format) /// @param stream Output stream to save to /// @return The output stream wxOutputStream& PowerTabDocument::SaveObject(wxOutputStream& stream) { //------Last Checked------// // - Jan 26, 2005 // Create our special Power Tab stream PowerTabOutputStream data_stream(stream); // Write the header m_header.Serialize(data_stream); if (!data_stream.CheckState()) { DisplaySerializationError(GetFilename(), stream.TellO(), data_stream.GetLastErrorMessage()); return (stream); } // Write the scores size_t i = 0; size_t count = m_scoreArray.GetCount(); for (; i < count; i++) { m_scoreArray[i]->Serialize(data_stream); if (!data_stream.CheckState()) { DisplaySerializationError(GetFilename(), stream.TellO(), data_stream.GetLastErrorMessage()); return (stream); } } // Write the document font settings wxUint32 fontSettingIndex = 0; for (; fontSettingIndex < NUM_DOCUMENT_FONT_SETTINGS; fontSettingIndex++) { m_fontSettingArray[fontSettingIndex].Serialize(data_stream); if (!data_stream.CheckState()) { DisplaySerializationError(GetFilename(), stream.TellO(), data_stream.GetLastErrorMessage()); return (stream); } } // Write the line spacing and fade values data_stream << m_tablatureStaffLineSpacing << m_fadeIn << m_fadeOut; if (!data_stream.CheckState()) { DisplaySerializationError(GetFilename(), stream.TellO(), data_stream.GetLastErrorMessage()); return (stream); } return (stream); } // Load Functions /// Deserializes the document from an input stream /// @param stream Input stream to load from /// @return Input stream wxInputStream& PowerTabDocument::LoadObject(wxInputStream& stream) { //------Last Checked------// // - Jan 26, 2005 // Create our special Power Tab stream PowerTabInputStream data_stream(stream); // Read the header m_header.Deserialize(data_stream); if (!data_stream.CheckState()) { DeleteContents(); DisplayDeserializationError(GetFilename(), stream.TellI(), data_stream.GetLastErrorMessage()); return (stream); } // Get the file version const wxWord version = m_header.GetVersion(); // v1.0 or v1.0.2 if ((version == PowerTabFileHeader::FILEVERSION_1_0) || (version == PowerTabFileHeader::FILEVERSION_1_0_2)) DeserializeFormat1_0(data_stream, version); // v1.5 else if (version == PowerTabFileHeader::FILEVERSION_1_5) DeserializeFormat1_5(data_stream); // v1.7 else DeserializeFormat1_7(data_stream); if (!data_stream.CheckState()) { DeleteContents(); DisplayDeserializationError(GetFilename(), stream.TellI(), data_stream.GetLastErrorMessage()); return (stream); } return (stream); } /// Loads a power tab file /// @param fileName Full path of the file to load /// @return True if the file was loaded, false if not bool PowerTabDocument::Load(const wxChar* fileName) { //------Last Checked------// // - Jan 27, 2005 wxCHECK(fileName != NULL, false); // Create a stream wxFileInputStream stream(fileName); if (!stream.IsOk()) return (false); // Create our special Power Tab stream, then call the sibling function PowerTabInputStream data_stream(stream); return (Load(data_stream)); } /// Loads a power tab file from an input stream /// @param stream Input stream to load from /// @return True if the file was loaded, false if not bool PowerTabDocument::Load(PowerTabInputStream& stream) { //------Last Checked------// // - Jan 27, 2005 wxCHECK(stream.CheckState(), false); DeleteContents(); // Read the header m_header.Deserialize(stream); wxCHECK(stream.CheckState(), false); const wxWord version = m_header.GetVersion(); // v1.0 or v1.0.2 if (version == PowerTabFileHeader::FILEVERSION_1_0 || version == PowerTabFileHeader::FILEVERSION_1_0_2) DeserializeFormat1_0(stream, version); // v1.5 else if (version == PowerTabFileHeader::FILEVERSION_1_5) DeserializeFormat1_5(stream); // v1.7 else DeserializeFormat1_7(stream); return (stream.CheckState()); } /// Deserializes Version 1.7 Files from an input stream /// @param stream Input stream to read from /// @return True if the document was deserialized, false if not bool PowerTabDocument::DeserializeFormat1_7(PowerTabInputStream& stream) { //------Last Checked------// // - Jan 27, 2005 // Set the version const wxWord version = PowerTabFileHeader::FILEVERSION_1_7; // Read the guitar score Score* guitarScore = new Score; guitarScore->Deserialize(stream, version); if (!stream.CheckState()) { delete guitarScore; return (false); } m_scoreArray.Add(guitarScore); // Read the bass score Score* bassScore = new Score; bassScore->Deserialize(stream, version); if (!stream.CheckState()) { delete bassScore; return (false); } m_scoreArray.Add(bassScore); // Read the document font settings wxUint32 fontSettingIndex = 0; for (; fontSettingIndex < NUM_DOCUMENT_FONT_SETTINGS; fontSettingIndex++) { FontSetting fontSetting; fontSetting.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); m_fontSettingArray[fontSettingIndex] = fontSetting; } // Read the line spacing and fade values stream >> m_tablatureStaffLineSpacing >> m_fadeIn >> m_fadeOut; wxCHECK(stream.CheckState(), false); return (true); } /// Deserializes Version 1.5 Files from an input stream /// @param stream Input stream to read from /// @return True if the document was deserialized, false if not bool PowerTabDocument::DeserializeFormat1_5(PowerTabInputStream& stream) { //------Last Checked------// // - Jan 26, 2005 // Set the version const wxWord version = PowerTabFileHeader::FILEVERSION_1_5; // Deserialize both scores size_t scoreIndex = 0; for (; scoreIndex < 2; scoreIndex++) { // Don't create the score on the heap, the checks will cause memory leaks Score score; // Read the transcriber for the score (stored in the header in v1.7) wxString transcriber = wxT(""); stream.ReadMFCString(transcriber); wxCHECK(stream.CheckState(), false); if (!transcriber.IsEmpty()) { if (scoreIndex == 0) m_header.SetSongGuitarScoreTranscriber(transcriber); else if (scoreIndex == 1) m_header.SetSongBassScoreTranscriber(transcriber); } // Read the notes for the score (stored in the header in v1.7) wxString notes = wxT(""); stream.ReadMFCString(notes); wxCHECK(stream.CheckState(), false); if (!notes.IsEmpty()) { if (scoreIndex == 0) m_header.SetSongGuitarScoreNotes(notes); else if (scoreIndex == 1) m_header.SetSongBassScoreNotes(notes); } score.m_guitarArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); score.m_chordDiagramArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); score.m_floatingTextArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); score.m_guitarInArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); score.m_tempoMarkerArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); score.m_dynamicArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); score.m_alternateEndingArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); score.m_systemArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); // Add the score to the document m_scoreArray.Add((Score*)score.CloneObject()); } // Read the document font settings wxUint32 fontSettingIndex = 0; for (; fontSettingIndex < NUM_DOCUMENT_FONT_SETTINGS; fontSettingIndex++) { FontSetting fontSetting; fontSetting.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); m_fontSettingArray[fontSettingIndex] = fontSetting; } // Read the line spacing and fade values stream >> m_tablatureStaffLineSpacing >> m_fadeIn >> m_fadeOut; wxCHECK(stream.CheckState(), false); return (true); } /// Deserializes Version 1.0 and 1.0.2 files from an input stream /// @param stream Input stream to read from /// @param version File version /// @return True if the document was deserialized, false if not bool PowerTabDocument::DeserializeFormat1_0(PowerTabInputStream& stream, wxWord version) { //------Last Checked------// // - Jan 26, 2005 // Read the line spacing value stream >> m_tablatureStaffLineSpacing; wxCHECK(stream.CheckState(), false); // Read the document font settings wxUint32 fontSettingIndex = 0; for (; fontSettingIndex < NUM_DOCUMENT_FONT_SETTINGS; fontSettingIndex++) { FontSetting fontSetting; fontSetting.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); m_fontSettingArray[fontSettingIndex] = fontSetting; } wxUint32 scoreIndex = 0; for (; scoreIndex < 2; scoreIndex++) { // Don't create the score on the heap, the checks will cause memory leaks Score score; score.m_guitarArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); score.m_chordDiagramArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); score.m_floatingTextArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); score.m_guitarInArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); score.m_tempoMarkerArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); OldTimeSignatureArray oldTimeSignatureArray; oldTimeSignatureArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); score.m_dynamicArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); score.m_alternateEndingArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); OldRehearsalSignArray oldRehearsalSignArray; oldRehearsalSignArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); score.m_systemArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); // Move all time signatures to the appropriate barlines while (!oldTimeSignatureArray.IsEmpty()) { // Get the first element in the array OldTimeSignature* oldTimeSignature = oldTimeSignatureArray[0]; oldTimeSignatureArray.RemoveAt(0); wxCHECK(oldTimeSignature != NULL, false); // Update the data to the new format wxUint32 data = oldTimeSignature->m_data; wxByte temp = HIBYTE(HIWORD(data)); wxByte beatsPerMeasure = (wxByte)(((temp >> 3) & 0x1f) + 1); // Top 5 bits = bpm, where 0 = 1, 1 = 2, etc. wxByte beatAmount = (wxByte)pow(2, (temp & 0x07)); // Bottom 3 bits = ba in power of 2, TimeSignature doesn't use pow bool commonTime = ((data & 0x400000) == 0x400000); bool cutTime = ((data & 0x800000) == 0x800000); // Get the beaming information (all beam values are zero-based and 5 bits each) wxByte beat1 = (wxByte)((data & 0xf8000) >> 15); wxByte beat2 = (wxByte)((data & 0x7c00) >> 10); wxByte beat3 = (wxByte)((data & 0x3e0) >> 5); wxByte beat4 = (wxByte)(data & 0x1f); if (beat1 > 0) beat1++; if (beat2 > 0) beat2++; if (beat3 > 0) beat3++; if (beat4 > 0) beat4++; // Get the location of the object wxWord systemIndex = oldTimeSignature->m_system; wxByte positionIndex = oldTimeSignature->m_position; // Get the system the sign belongs to System* system = score.GetSystem(systemIndex); wxCHECK(system != NULL, false); TimeSignature* timeSignature = NULL; // First position in system if (positionIndex == 0) timeSignature = system->GetStartBarRef().GetTimeSignaturePtr(); else { // Get barline where time sign is located Barline* barline = system->GetBarlineAtPosition(positionIndex); // Exists if (barline != NULL) timeSignature = barline->GetTimeSignaturePtr(); // Doesn't exist - bug } // Update the time signature if (timeSignature != NULL) { // Set the meter timeSignature->SetMeter(beatsPerMeasure, beatAmount); // All time signatures are shown timeSignature->Show(); // Cut time if (cutTime) timeSignature->SetCutTime(); // Common time else if (commonTime) timeSignature->SetCommonTime(); timeSignature->SetBeamingPattern(beat1, beat2, beat3, beat4); } // Free memory delete oldTimeSignature; } // We must update all bars in between v1.0 time signs, because unlike v1.0 // the time is stored with each bar in the score // Setup the default values for 4/4 time wxByte beatsPerMeasure = 4; wxByte beatAmount = 4; wxByte beat1 = 4; wxByte beat2 = 0; wxByte beat3 = 0; wxByte beat4 = 0; bool cutTime = false; bool commonTime = false; bool processedFirst = false; size_t systemIndex = 0; size_t systemCount = score.GetSystemCount(); for (; systemIndex < systemCount; systemIndex++) { // Get the system System* system = score.GetSystem(systemIndex); wxCHECK2(system != NULL, continue); // Update the time signature for all non-shown time signatures // Check each barline in the system // We don't check the end bar, because the key/time data is not maintained in that barline size_t barlineIndex = 0; size_t barlineCount = system->GetBarlineCount(); for (; barlineIndex <= barlineCount; barlineIndex++) { Barline* barline = NULL; // For the first index, use the starting barline // That's why we iterate for <= barlineCount and not < barlineCount if (barlineIndex == 0) barline = &system->GetStartBarRef(); else barline = system->GetBarline(barlineIndex - 1); wxCHECK2(barline != NULL, continue); // Process the time signature at the start of the system TimeSignature& timeSignature = barline->GetTimeSignatureRef(); // Starting time signature is shown, update the time signature data if (timeSignature.IsShown()) { timeSignature.GetMeter(beatsPerMeasure, beatAmount); cutTime = timeSignature.IsCutTime(); commonTime = timeSignature.IsCommonTime(); timeSignature.GetBeamingPattern(beat1, beat2, beat3, beat4); processedFirst = true; } // Starting time signature is not shown; update using the previous time signature data else if (processedFirst) { if (cutTime) timeSignature.SetCutTime(); else if (commonTime) timeSignature.SetCommonTime(); else timeSignature.SetMeter(beatsPerMeasure, beatAmount); timeSignature.SetBeamingPattern(beat1, beat2, beat3, beat4); } } } // Move all rehearsal signs to the appropriate barlines while (!oldRehearsalSignArray.IsEmpty()) { // Get the first element in the array OldRehearsalSign* oldRehearsalSign = oldRehearsalSignArray[0]; oldRehearsalSignArray.RemoveAt(0); wxCHECK(oldRehearsalSign != NULL, false); // Get the location of the object wxWord systemIndex = oldRehearsalSign->m_system; wxByte positionIndex = oldRehearsalSign->m_position; // Get the system the sign belongs to System* system = score.GetSystem(systemIndex); wxCHECK(system != NULL, false); RehearsalSign* rehearsalSign = NULL; // First position in system if (positionIndex == 0) rehearsalSign = system->GetStartBarRef().GetRehearsalSignPtr(); else { // Get the barline where the rehearsal sign is anchored Barline* barline = system->GetBarlineAtPosition(positionIndex); // Exists if (barline != NULL) rehearsalSign = barline->GetRehearsalSignPtr(); // Doesn't exist - bug } // Update the rehearsal sign if (rehearsalSign != NULL) { rehearsalSign->SetLetter(oldRehearsalSign->m_letter); rehearsalSign->SetDescription(oldRehearsalSign->m_description); } // Free memory delete oldRehearsalSign; } // Add the score to the document m_scoreArray.Add((Score*)score.CloneObject()); } wxByte fadeIn = 0; wxByte fadeOut = 0; stream >> fadeIn >> fadeOut; wxCHECK(stream.CheckState(), false); // Fades were stored as measures in v1.0 // We can just fudge this and assume it's 4/4 time, since there will be // very few v1.0 files on the Web m_fadeIn = fadeIn * MIDI_PPQN * 4; m_fadeOut = fadeOut * MIDI_PPQN * 4; // Must refresh note beaming due to redesign to beaming strategy // Note: Beaming algorithm is not included; manually running the score polisher // should rebeam the score; There are very few 1.0 files on the Web anyways /* for (int w = 0; w < 2; w++) { RefreshBeaming((BYTE)w); ToolScorePolisher(SP_FULL, FALSE, (BYTE)w); }*/ return (true); } // Overrides bool PowerTabDocument::DeleteContents() { //------Last Checked------// // - Jan 26, 2005 m_header.LoadDefaults(); DeleteScoreArrayContents(); m_tablatureStaffLineSpacing = DEFAULT_TABLATURE_STAFF_LINE_SPACING; wxUint32 i = 0; for (; i < NUM_DOCUMENT_FONT_SETTINGS; i++) m_fontSettingArray[i] = FontSetting(); m_fadeIn = DEFAULT_FADE_IN; m_fadeOut = DEFAULT_FADE_OUT; return (true); } // Score Functions /// Determines if the guitar score in another document can be merged into the current document /// @param document Document who's guitar score we want to merge with /// @return True if the guitar score can be merged, false if not bool PowerTabDocument::CanMergeGuitarScore(PowerTabDocument& document) const { //------Last Checked------// // - Jan 9, 2005 // In order to merge, we must meet three requirements: // 1) Line spacing on the tablature staff must be the same // 2) All document font settings must be the same // 3) We must not have more than seven guitars total after the merge // 1) if (m_tablatureStaffLineSpacing != document.m_tablatureStaffLineSpacing) return (false); // 2) wxUint32 fontSettingIndex = 0; for (; fontSettingIndex < NUM_DOCUMENT_FONT_SETTINGS; fontSettingIndex++) { if (m_fontSettingArray[fontSettingIndex] != document.m_fontSettingArray[fontSettingIndex]) return (false); } // 3) Score* guitarScore = GetGuitarScore(); wxCHECK(guitarScore != NULL, false); Score* bassScore = document.GetBassScore(); wxCHECK(bassScore != NULL, false); if ((guitarScore->GetGuitarCount() + bassScore->GetGuitarCount()) > MAX_GUITARS) return (false); return (true); } /// Merges the guitar score of another document into the current document /// @param document The document who's guitar score will be merged /// @return True if the document's guitar score was merged, false if not bool PowerTabDocument::MergeGuitarScore(PowerTabDocument& document) { //------Last Checked------// // - Jan 26, 2005 // If we can't merge, bail out if (!CanMergeGuitarScore(document)) return (false); // Get a pointer to the score we're merging Score* fromGuitarScore = document.GetGuitarScore(); wxCHECK(fromGuitarScore != NULL, false); // Get the current guitar score Score* oldGuitarScore = GetGuitarScore(); wxCHECK(oldGuitarScore != NULL, false); // Make a copy of the score Score* mergeGuitarScore = (Score*)fromGuitarScore->CloneObject(); wxCHECK(mergeGuitarScore != NULL, false); // Update the guitar score m_scoreArray[0] = mergeGuitarScore; // Delete the old guitar score delete oldGuitarScore; return (true); } /// Determines if the bass score in another document can be merged into the current document /// @param document Document who's bass score we want to merge with /// @return True if the bass score can be merged, false if not bool PowerTabDocument::CanMergeBassScore(PowerTabDocument& document) const { //------Last Checked------// // - Jan 9, 2005 // In order to merge, we must meet three requirements: // 1) Line spacing on the tablature staff must be the same // 2) All document font settings must be the same // 3) We must not have more than seven guitars total after the merge // 1) if (m_tablatureStaffLineSpacing != document.m_tablatureStaffLineSpacing) return (false); // 2) wxUint32 i = 0; for (; i < NUM_DOCUMENT_FONT_SETTINGS; i++) { if (m_fontSettingArray[i] != document.m_fontSettingArray[i]) return (false); } // 3) Score* guitarScore = GetGuitarScore(); wxCHECK(guitarScore != NULL, false); Score* bassScore = document.GetBassScore(); wxCHECK(bassScore != NULL, false); if ((guitarScore->GetGuitarCount() + bassScore->GetGuitarCount()) > MAX_GUITARS) return (false); return (true); } /// Merges the bass score of another document into the current document /// @param document The document who's bass score will be merged /// @return True if the document's bass score was merged, false if not bool PowerTabDocument::MergeBassScore(PowerTabDocument& document) { //------Last Checked------// // - Jan 26, 2005 // If we can't merge, bail out if (!CanMergeBassScore(document)) return (false); // Get a pointer to the score we're merging Score* fromBassScore = document.GetBassScore(); wxCHECK(fromBassScore != NULL, false); // Get the current bass score Score* oldBassScore = GetBassScore(); wxCHECK(oldBassScore != NULL, false); // Make a copy of the score Score* mergeBassScore = (Score*)fromBassScore->CloneObject(); wxCHECK(mergeBassScore != NULL, false); // Update the bass score m_scoreArray[1] = mergeBassScore; // Delete the old bass score delete oldBassScore; return (true); } /// Deletes the contents (and frees the memory) of the score array void PowerTabDocument::DeleteScoreArrayContents() { //------Last Checked------// // - Dec 16, 2004 size_t i = 0; size_t count = m_scoreArray.GetCount(); for (i = 0; i < count; i++) delete m_scoreArray[i]; m_scoreArray.Clear(); } // Error Functions /// Displays an error message during serialiation /// @param fileName Name of the file that was loading during the error /// @param offset The offset within the file where the error occurred /// @param errorMessage Error message to display void PowerTabDocument::DisplaySerializationError(const wxString& fileName, off_t offset, const wxString& errorMessage) { //------Last Checked------// // - Jan 27, 2005 wxMessageBox(wxString::Format(wxT("An error occurred at offset %lld while loading the file '%s'.\n\n%s"), offset, fileName.c_str(), errorMessage.c_str()), wxT("Serialize Error"), wxICON_ERROR); } /// Displays an error message during deserialiation /// @param fileName Name of the file that was loading during the error /// @param offset The offset within the file where the error occurred /// @param errorMessage Error message to display void PowerTabDocument::DisplayDeserializationError(const wxString& fileName, off_t offset, const wxString& errorMessage) { //------Last Checked------// // - Jan 27, 2005 wxMessageBox(wxString::Format(wxT("An error occurred at offset %lld while saving the file '%s'.\n\n%s"), offset, fileName.c_str(), errorMessage.c_str()), wxT("Deserialize Error"), wxICON_ERROR); }
[ "blarsen@8c24db97-d402-0410-b267-f151a046c31a" ]
[ [ [ 1, 814 ] ] ]
048c29047db6a2d9bf0f7795455d72517dd1154f
12203ea9fe0801d613bbb2159d4f69cab3c84816
/Export/cpp/windows/obj/include/nme/display/Sprite.h
858832db13d3d6e90b1f1668ccb1c655fb8bc363
[]
no_license
alecmce/haxe_game_of_life
91b5557132043c6e9526254d17fdd9bcea9c5086
35ceb1565e06d12c89481451a7bedbbce20fa871
refs/heads/master
2016-09-16T00:47:24.032302
2011-10-10T12:38:14
2011-10-10T12:38:14
2,547,793
0
0
null
null
null
null
UTF-8
C++
false
false
1,463
h
#ifndef INCLUDED_nme_display_Sprite #define INCLUDED_nme_display_Sprite #ifndef HXCPP_H #include <hxcpp.h> #endif #include <nme/display/DisplayObjectContainer.h> HX_DECLARE_CLASS2(nme,display,DisplayObject) HX_DECLARE_CLASS2(nme,display,DisplayObjectContainer) HX_DECLARE_CLASS2(nme,display,IBitmapDrawable) HX_DECLARE_CLASS2(nme,display,InteractiveObject) HX_DECLARE_CLASS2(nme,display,Sprite) HX_DECLARE_CLASS2(nme,events,EventDispatcher) HX_DECLARE_CLASS2(nme,events,IEventDispatcher) HX_DECLARE_CLASS2(nme,geom,Rectangle) namespace nme{ namespace display{ class Sprite_obj : public ::nme::display::DisplayObjectContainer_obj{ public: typedef ::nme::display::DisplayObjectContainer_obj super; typedef Sprite_obj OBJ_; Sprite_obj(); Void __construct(); public: static hx::ObjectPtr< Sprite_obj > __new(); static Dynamic __CreateEmpty(); static Dynamic __Create(hx::DynamicArray inArgs); ~Sprite_obj(); HX_DO_RTTI; static void __boot(); static void __register(); void __Mark(HX_MARK_PARAMS); ::String __ToString() const { return HX_CSTRING("Sprite"); } virtual Void startDrag( Dynamic lockCenter,::nme::geom::Rectangle bounds); Dynamic startDrag_dyn(); virtual Void stopDrag( ); Dynamic stopDrag_dyn(); virtual ::String nmeGetType( ); Dynamic nmeGetType_dyn(); }; } // end namespace nme } // end namespace display #endif /* INCLUDED_nme_display_Sprite */
[ [ [ 1, 54 ] ] ]
9ddae67444f8cbf884dd71db07b6e5668de0d3d2
6477cf9ac119fe17d2c410ff3d8da60656179e3b
/Projects/openredalert/src/misc/StringTableFile.cpp
08a216a193e514e27f82411285956026d50662a9
[]
no_license
crutchwalkfactory/motocakerteam
1cce9f850d2c84faebfc87d0adbfdd23472d9f08
0747624a575fb41db53506379692973e5998f8fe
refs/heads/master
2021-01-10T12:41:59.321840
2010-12-13T18:19:27
2010-12-13T18:19:27
46,494,539
0
0
null
null
null
null
UTF-8
C++
false
false
3,349
cpp
// StringTableFile.cpp // 1.0 // This file is part of OpenRedAlert. // // OpenRedAlert 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, version 2 of the License. // // OpenRedAlert 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 OpenRedAlert. If not, see <http://www.gnu.org/licenses/>. #include "StringTableFile.h" #include <stdexcept> #include <string> #include <vector> #include "SDL/SDL_types.h" #include "include/Logger.h" #include "vfs/vfs.h" #include "vfs/VFile.h" using std::string; using std::vector; using std::runtime_error; extern Logger * logger; /** * @param filename File name to load */ StringTableFile::StringTableFile(string filename) { // Load strings in the file "filename" this->loadStringFile(filename.c_str()); } /** * @param filename File name to load */ StringTableFile::StringTableFile(const char* filename) { // Load strings in the file "filename" this->loadStringFile(filename); } /** * Load all strings in the file specified and stroe it in a std::vector * * @param filename File name to load */ void StringTableFile::loadStringFile(const char* filename) { VFile* stringFile; // Ref to the file in the mix (YEAH!) Uint16 headerLenght; // size of the header Uint16 numString; // Number of string in the file // Open the File stringFile = VFSUtils::VFS_Open(filename); if (stringFile == 0) { string s = "Unable to open "; s += filename; throw runtime_error(s); } // Read the first byte (Uint16) to discover the size of the header stringFile->readWord(&headerLenght, 1); // Calculate the number of strings numString = headerLenght / 2; // Read offsets for (int i = 0; i < numString-1; i++) { Uint16 bufStart; Uint16 bufEnd; // Seek to header stringFile->seekSet(i*2); // Read the offset of Start in the header stringFile->readWord(&bufStart, 1); // Read the offset of End in the header stringFile->readWord(&bufEnd, 1); Uint16 lenght = bufEnd - bufStart; Uint8* tabChar = new Uint8[lenght]; // Seek to the str stringFile->seekSet(bufStart); // read the str stringFile->readByte(tabChar, lenght); string toto = string(((char*)tabChar)); // Add the decoded string in the vector data.push_back(toto); delete tabChar; } // Close the file VFSUtils::VFS_Close(stringFile); } /** * Free only data by calling vector::clear() function. */ StringTableFile::~StringTableFile() { // delete all entries in inidata this->data.clear(); } /** * Return string by id * * @param id Number (id) of the string * @return The string with the id specified */ string StringTableFile::getString(Uint32 id) { string ret; // String to return // Copy the string from the internal data ret = this->data[id]; // Return the string return ret; }
[ [ [ 1, 141 ] ] ]
e61dec32679b4ba6b27eab230d687bcde3e49207
b2d46af9c6152323ce240374afc998c1574db71f
/cursovideojuegos/theflostiproject/3rdParty/boost/libs/numeric/ublas/test5/test53.cpp
de1896f82ab8a5377c2c1a15b4f4bcfc7764d73a
[]
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
10,962
cpp
// // Copyright (c) 2000-2002 // Joerg Walter, Mathias Koch // // Permission to use, copy, modify, distribute and sell this software // and its documentation for any purpose is hereby granted without fee, // provided that the above copyright notice appear in all copies and // that both that copyright notice and this permission notice appear // in supporting documentation. The authors make no representations // about the suitability of this software for any purpose. // It is provided "as is" without express or implied warranty. // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. // #include "test5.hpp" // Test matrix expression templates template<class M, int N> struct test_my_matrix { typedef typename M::value_type value_type; template<class MP> void test_with (MP &m1, MP &m2, MP &m3) const { { value_type t; // Default Construct MP default_constuct; initialize_matrix (default_constuct); std::cout << "default construct = " << default_constuct << std::endl; // Copy and swap initialize_matrix (m1, ublas::lower_tag ()); initialize_matrix (m2, ublas::lower_tag ()); m1 = m2; std::cout << "m1 = m2 = " << m1 << std::endl; m1.assign_temporary (m2); std::cout << "m1.assign_temporary (m2) = " << m1 << std::endl; m1.swap (m2); std::cout << "m1.swap (m2) = " << m1 << " " << m2 << std::endl; // Unary matrix operations resulting in a matrix initialize_matrix (m1, ublas::lower_tag ()); m2 = - m1; std::cout << "- m1 = " << m2 << std::endl; m2 = ublas::conj (m1); std::cout << "conj (m1) = " << m2 << std::endl; // Binary matrix operations resulting in a matrix initialize_matrix (m1, ublas::lower_tag ()); initialize_matrix (m2, ublas::lower_tag ()); m3 = m1 + m2; std::cout << "m1 + m2 = " << m3 << std::endl; m3 = m1 - m2; std::cout << "m1 - m2 = " << m3 << std::endl; // Scaling a matrix t = N; initialize_matrix (m1, ublas::lower_tag ()); m2 = value_type (1.) * m1; std::cout << "1. * m1 = " << m2 << std::endl; m2 = t * m1; std::cout << "N * m1 = " << m2 << std::endl; initialize_matrix (m1, ublas::lower_tag ()); m2 = m1 * value_type (1.); std::cout << "m1 * 1. = " << m2 << std::endl; m2 = m1 * t; std::cout << "m1 * N = " << m2 << std::endl; // Some assignments initialize_matrix (m1, ublas::lower_tag ()); initialize_matrix (m2, ublas::lower_tag ()); m2 += m1; std::cout << "m2 += m1 = " << m2 << std::endl; m2 -= m1; std::cout << "m2 -= m1 = " << m2 << std::endl; m2 = m2 + m1; std::cout << "m2 = m2 + m1 = " << m2 << std::endl; m2 = m2 - m1; std::cout << "m2 = m2 - m1 = " << m2 << std::endl; m1 *= value_type (1.); std::cout << "m1 *= 1. = " << m1 << std::endl; m1 *= t; std::cout << "m1 *= N = " << m1 << std::endl; // Transpose initialize_matrix (m1, ublas::lower_tag ()); // Transpose of a triangular isn't triangular of the same kind std::cout << "trans (m1) = " << ublas::trans (m1) << std::endl; // Hermitian initialize_matrix (m1, ublas::lower_tag ()); // Hermitian of a triangular isn't hermitian of the same kind std::cout << "herm (m1) = " << ublas::herm (m1) << std::endl; // Matrix multiplication initialize_matrix (m1, ublas::lower_tag ()); initialize_matrix (m2, ublas::lower_tag ()); m3 = ublas::prod (m1, m2); std::cout << "prod (m1, m2) = " << m3 << std::endl; } } void operator () () const { { M m1 (N, N), m2 (N, N), m3 (N, N); test_with (m1, m2, m3); #ifdef USE_RANGE ublas::matrix_range<M> mr1 (m1, ublas::range (0, N), ublas::range (0, N)), mr2 (m2, ublas::range (0, N), ublas::range (0, N)), mr3 (m3, ublas::range (0, N), ublas::range (0, N)); test_with (mr1, mr2, mr3); #endif #ifdef USE_SLICE ublas::matrix_slice<M> ms1 (m1, ublas::slice (0, 1, N), ublas::slice (0, 1, N)), ms2 (m2, ublas::slice (0, 1, N), ublas::slice (0, 1, N)), ms3 (m3, ublas::slice (0, 1, N), ublas::slice (0, 1, N)); test_with (ms1, ms2, ms3); #endif } } void operator () (int) const { #ifdef USE_ADAPTOR { M m1 (N, N), m2 (N, N), m3 (N, N); ublas::triangular_adaptor<M> tam1 (m1), tam2 (m2), tam3 (m3); test_with (tam1, tam2, tam3); #ifdef USE_RANGE ublas::matrix_range<ublas::triangular_adaptor<M> > mr1 (tam1, ublas::range (0, N), ublas::range (0, N)), mr2 (tam2, ublas::range (0, N), ublas::range (0, N)), mr3 (tam3, ublas::range (0, N), ublas::range (0, N)); test_with (mr1, mr2, mr3); #endif #ifdef USE_SLICE ublas::matrix_slice<ublas::triangular_adaptor<M> > ms1 (tam1, ublas::slice (0, 1, N), ublas::slice (0, 1, N)), ms2 (tam2, ublas::slice (0, 1, N), ublas::slice (0, 1, N)), ms3 (tam3, ublas::slice (0, 1, N), ublas::slice (0, 1, N)); test_with (ms1, ms2, ms3); #endif } #endif } }; // Test matrix void test_matrix () { std::cout << "test_matrix" << std::endl; #ifdef USE_BOUNDED_ARRAY #ifdef USE_FLOAT std::cout << "float, bounded_array" << std::endl; test_my_matrix<ublas::triangular_matrix<float, ublas::lower, ublas::row_major, ublas::bounded_array<float, 3 * 3> >, 3 > () (); test_my_matrix<ublas::triangular_matrix<float, ublas::lower, ublas::row_major, ublas::bounded_array<float, 3 * 3> >, 3 > () (0); #endif #ifdef USE_DOUBLE std::cout << "double, bounded_array" << std::endl; test_my_matrix<ublas::triangular_matrix<double, ublas::lower, ublas::row_major, ublas::bounded_array<double, 3 * 3> >, 3 > () (); test_my_matrix<ublas::triangular_matrix<double, ublas::lower, ublas::row_major, ublas::bounded_array<double, 3 * 3> >, 3 > () (0); #endif #ifdef USE_STD_COMPLEX #ifdef USE_FLOAT std::cout << "std::complex<float>, bounded_array" << std::endl; test_my_matrix<ublas::triangular_matrix<std::complex<float>, ublas::lower, ublas::row_major, ublas::bounded_array<std::complex<float>, 3 * 3> >, 3 > () (); test_my_matrix<ublas::triangular_matrix<std::complex<float>, ublas::lower, ublas::row_major, ublas::bounded_array<std::complex<float>, 3 * 3> >, 3 > () (0); #endif #ifdef USE_DOUBLE std::cout << "std::complex<double>, bounded_array" << std::endl; test_my_matrix<ublas::triangular_matrix<std::complex<double>, ublas::lower, ublas::row_major, ublas::bounded_array<std::complex<double>, 3 * 3> >, 3 > () (); test_my_matrix<ublas::triangular_matrix<std::complex<double>, ublas::lower, ublas::row_major, ublas::bounded_array<std::complex<double>, 3 * 3> >, 3 > () (0); #endif #endif #endif #ifdef USE_UNBOUNDED_ARRAY #ifdef USE_FLOAT std::cout << "float, unbounded_array" << std::endl; test_my_matrix<ublas::triangular_matrix<float, ublas::lower, ublas::row_major, ublas::unbounded_array<float> >, 3 > () (); test_my_matrix<ublas::triangular_matrix<float, ublas::lower, ublas::row_major, ublas::unbounded_array<float> >, 3 > () (0); #endif #ifdef USE_DOUBLE std::cout << "double, unbounded_array" << std::endl; test_my_matrix<ublas::triangular_matrix<double, ublas::lower, ublas::row_major, ublas::unbounded_array<double> >, 3 > () (); test_my_matrix<ublas::triangular_matrix<double, ublas::lower, ublas::row_major, ublas::unbounded_array<double> >, 3 > () (0); #endif #ifdef USE_STD_COMPLEX #ifdef USE_FLOAT std::cout << "std::complex<float>, unbounded_array" << std::endl; test_my_matrix<ublas::triangular_matrix<std::complex<float>, ublas::lower, ublas::row_major, ublas::unbounded_array<std::complex<float> > >, 3 > () (); test_my_matrix<ublas::triangular_matrix<std::complex<float>, ublas::lower, ublas::row_major, ublas::unbounded_array<std::complex<float> > >, 3 > () (0); #endif #ifdef USE_DOUBLE std::cout << "std::complex<double>, unbounded_array" << std::endl; test_my_matrix<ublas::triangular_matrix<std::complex<double>, ublas::lower, ublas::row_major, ublas::unbounded_array<std::complex<double> > >, 3 > () (); test_my_matrix<ublas::triangular_matrix<std::complex<double>, ublas::lower, ublas::row_major, ublas::unbounded_array<std::complex<double> > >, 3 > () (0); #endif #endif #endif #ifdef USE_STD_VECTOR #ifdef USE_FLOAT std::cout << "float, std::vector" << std::endl; test_my_matrix<ublas::triangular_matrix<float, ublas::lower, ublas::row_major, std::vector<float> >, 3 > () (); test_my_matrix<ublas::triangular_matrix<float, ublas::lower, ublas::row_major, std::vector<float> >, 3 > () (0); #endif #ifdef USE_DOUBLE std::cout << "double, std::vector" << std::endl; test_my_matrix<ublas::triangular_matrix<double, ublas::lower, ublas::row_major, std::vector<double> >, 3 > () (); test_my_matrix<ublas::triangular_matrix<double, ublas::lower, ublas::row_major, std::vector<double> >, 3 > () (0); #endif #ifdef USE_STD_COMPLEX #ifdef USE_FLOAT std::cout << "std::complex<float>, std::vector" << std::endl; test_my_matrix<ublas::triangular_matrix<std::complex<float>, ublas::lower, ublas::row_major, std::vector<std::complex<float> > >, 3 > () (); test_my_matrix<ublas::triangular_matrix<std::complex<float>, ublas::lower, ublas::row_major, std::vector<std::complex<float> > >, 3 > () (0); #endif #ifdef USE_DOUBLE std::cout << "std::complex<double>, std::vector" << std::endl; test_my_matrix<ublas::triangular_matrix<std::complex<double>, ublas::lower, ublas::row_major, std::vector<std::complex<double> > >, 3 > () (); test_my_matrix<ublas::triangular_matrix<std::complex<double>, ublas::lower, ublas::row_major, std::vector<std::complex<double> > >, 3 > () (0); #endif #endif #endif }
[ "ohernandezba@71d53fa2-cca5-e1f2-4b5e-677cbd06613a" ]
[ [ [ 1, 237 ] ] ]
2dab6a342f5d4ddd3df0b3577ca665e176b8a47a
f8b364974573f652d7916c3a830e1d8773751277
/emulator/allegrex/disassembler/XOR.h
fbca9b66afd01170570ce1894635733947b60417
[]
no_license
lemmore22/pspe4all
7a234aece25340c99f49eac280780e08e4f8ef49
77ad0acf0fcb7eda137fdfcb1e93a36428badfd0
refs/heads/master
2021-01-10T08:39:45.222505
2009-08-02T11:58:07
2009-08-02T11:58:07
55,047,469
0
0
null
null
null
null
UTF-8
C++
false
false
359
h
/* XOR */ void AllegrexInstructionTemplate< 0x00000026, 0xfc0007ff >::disassemble(u32 address, u32 opcode, char *opcode_name, char *operands, char *comment) { using namespace Allegrex; ::strcpy(opcode_name, "xor"); ::sprintf(operands, "%s, %s, %s", gpr_name[rd(opcode)], gpr_name[rs(opcode)], gpr_name[rt(opcode)]); ::strcpy(comment, ""); }
[ [ [ 1, 9 ] ] ]
c6423acd4d8c414a3dfcaf8e2d12c3b0f3a42435
c1a2953285f2a6ac7d903059b7ea6480a7e2228e
/deitel/ch21/Fig21_31/fig22_31.cpp
c47241bb2c16fca0ad1b5bd2eb8b42dd23c6fadd
[]
no_license
tecmilenio/computacion2
728ac47299c1a4066b6140cebc9668bf1121053a
a1387e0f7f11c767574fcba608d94e5d61b7f36c
refs/heads/master
2016-09-06T19:17:29.842053
2008-09-28T04:27:56
2008-09-28T04:27:56
50,540
4
3
null
null
null
null
UTF-8
C++
false
false
1,567
cpp
// Fig. 21.31: fig21_31.cpp // Using strpbrk. #include <iostream> using std::cout; using std::endl; #include <cstring> // strpbrk prototype using std::strpbrk; int main() { const char *string1 = "This is a test"; const char *string2 = "beware"; cout << "Of the characters in \"" << string2 << "\"\n'" << *strpbrk( string1, string2 ) << "\' is the first character " << "to appear in\n\"" << string1 << '\"' << endl; return 0; } // end main /************************************************************************** * (C) Copyright 1992-2008 by Deitel & Associates, Inc. and * * Pearson Education, Inc. All Rights Reserved. * * * * DISCLAIMER: The authors and publisher of this book have used their * * best efforts in preparing the book. These efforts include the * * development, research, and testing of the theories and programs * * to determine their effectiveness. The authors and publisher make * * no warranty of any kind, expressed or implied, with regard to these * * programs or to the documentation contained in these books. The authors * * and publisher shall not be liable in any event for incidental or * * consequential damages in connection with, or arising out of, the * * furnishing, performance, or use of these programs. * **************************************************************************/
[ [ [ 1, 34 ] ] ]
b7535fa9d9698c43b2177d58c67a03fe6f585895
899e3440cda769c6a4b7649065dee47bc0516b6c
/topcoder/topcoder/Crossroads.cpp
2e9e517ac48b8b41381424b4ee6f2bb8f1868f8c
[]
no_license
karanjude/snippets
6bf1492cb751a206e4b403ea7f03eda2a37c6892
a1c7e85b8999214f03b30469222cb64b5ad80146
refs/heads/master
2021-01-06T20:38:17.017406
2011-06-06T23:37:53
2011-06-06T23:37:53
32,311,843
0
0
null
null
null
null
UTF-8
C++
false
false
1,987
cpp
#include "stdafx.h" #include <map> #include <algorithm> #include <vector> #include <queue> #include <sstream> #include <list> #include <string> #include <cctype> #include <string> #include <utility.cpp> #include <cmath> using namespace std; class Crossroads{ public: vector<int> getOut(vector<int> angles){ int n = angles.size(); vector<bool> pass(angles.size(),true); for(int i = 0;i < n-1;i++){ for(int j = i+1;j < n;j++){ if(angles[i] < angles[j]){ if(abs(angles[i]-90) < abs(angles[j]-90)) pass[j] = false; else if(abs(angles[i]-90) > abs(angles[j]-90)) pass[i] = false; else pass[j] = false; } } } vector<int> result; for(int i = 0;i < n;i++) if(pass[i]) result.push_back(i); return result; } }; int _tmain(int argc, _TCHAR* argv[]){ int i[] ={105, 75, 25, 120, 35, 75}; int r[] = { 0, 1, 5 }; Crossroads c; are_equal(to_vector<int,3>(r),c.getOut(to_vector<int,6>(i))); int i1[] = {1, 1, 1, 1, 1, 1}; int r1[] = { 0, 1, 2, 3, 4, 5 }; are_equal(to_vector<int,6>(r1),c.getOut(to_vector<int,6>(i1))); int i2[] = {13}; int r2[] = { 0 }; are_equal(to_vector<int,1>(r2),c.getOut(to_vector<int,1>(i2))); int i3[] = {90, 123, 1, 23, 132, 11, 28, 179, 179, 77, 113, 91}; int r3[] = {0}; are_equal(to_vector<int,1>(r3),c.getOut(to_vector<int,12>(i3))); int i4[] = {179, 89, 90, 91, 1}; int r4[] = { 0, 2, 4 }; are_equal(to_vector<int,3>(r4),c.getOut(to_vector<int,5>(i4))); int i5[] = {89 , 91}; int r5[] = {0}; are_equal(to_vector<int,1>(r5),c.getOut(to_vector<int,2>(i5))); int i6[] = {140, 118, 54, 166, 151, 44, 90, 5, 14, 6, 64, 129, 74, 33, 134, 25, 11, 95, 65, 145, 29, 162, 24, 147, 45, 103, 63, 97, 120, 156, 167, 170, 19, 28, 100, 144, 161, 13, 157, 148}; int r6[] = { 0, 1, 6 }; are_equal(to_vector<int,3>(r6),c.getOut(to_vector<int,40>(i6))); int ii; cin >> ii; return 0; }
[ "karan.jude@737fc9ef-4d2d-0410-97ed-4d0c502f76d2" ]
[ [ [ 1, 79 ] ] ]
07096a3fa392caf34354475d2f7b5ff2b99b35ff
ef23e388061a637f82b815d32f7af8cb60c5bb1f
/src/emu/machine/mb3773.h
e8adcb69c8d62f11c0b36cde852cbb2b2c4230b1
[]
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
2,197
h
/*************************************************************************** Fujistu MB3773 Power Supply Monitor with Watch Dog Timer (i.e. Reset IC) ***************************************************************************/ #pragma once #ifndef __MB3773_H__ #define __MB3773_H__ //************************************************************************** // INTERFACE CONFIGURATION MACROS //************************************************************************** #define MCFG_MB3773_ADD(_tag) \ MCFG_DEVICE_ADD(_tag, MB3773, 0) // ======================> mb3773_device_config class mb3773_device_config : public device_config { friend class mb3773_device; // construction/destruction mb3773_device_config( const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock ); public: // allocators static device_config *static_alloc_device_config( const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock ); virtual device_t *alloc_device( running_machine &machine ) const; protected: // device_config overrides virtual void device_config_complete(); virtual bool device_validity_check( emu_options &options, const game_driver &driver ) const; }; // ======================> mb3773_device class mb3773_device : public device_t { friend class mb3773_device_config; // construction/destruction mb3773_device( running_machine &_machine, const mb3773_device_config &config ); public: // I/O operations void set_ck( int state ); protected: // device-level overrides virtual void device_start(); virtual void device_reset(); // internal helpers static TIMER_CALLBACK( watchdog_timeout ); void reset_timer(); // internal state const mb3773_device_config &m_config; emu_timer *m_watchdog_timer; int m_ck; }; // device type definition extern const device_type MB3773; //************************************************************************** // READ/WRITE HANDLERS //************************************************************************** WRITE_LINE_DEVICE_HANDLER( mb3773_set_ck ); #endif
[ "Mike@localhost" ]
[ [ [ 1, 85 ] ] ]
8842c5a2e807ba86ce1f4931699c732f6248a227
c95a83e1a741b8c0eb810dd018d91060e5872dd8
/Game/Shared/TrackedNode.h
98ba1270f19e61895f32dfa83c368cd733864557
[]
no_license
rickyharis39/nolf2
ba0b56e2abb076e60d97fc7a2a8ee7be4394266c
0da0603dc961e73ac734ff365bfbfb8abb9b9b04
refs/heads/master
2021-01-01T17:21:00.678517
2011-07-23T12:11:19
2011-07-23T12:11:19
38,495,312
1
0
null
null
null
null
UTF-8
C++
false
false
3,836
h
#ifndef __TRACKEDNODE_H__ #define __TRACKEDNODE_H__ #include <time.h> #include "LTObjRef.h" //CTrackedNode : // holds all information for a tracked node. This is a behind the scenes class // that is not intended for use outside of the interface provided by the TrackedNodeMgr. // It holds all data necessary to manipulate a tracked node from the NodeController // callback function. //forward declaration of the manager class class CTrackedNodeMgr; class CTrackedNode { public: //constructor CTrackedNode(); //different tracking modes enum ETrackMode { TRACK_OBJECT, TRACK_NODE, TRACK_WORLDPOS, TRACK_LOCALPOS, TRACK_OBJSPACEPOS, TRACK_ANIMATION }; //the type of tracking mode we are in ETrackMode m_eTrackMode; //the model that this node belongs to LTObjRef m_hModel; //the node that it is attached to HMODELNODE m_hNode; //the object that is being tracked NULL if none, in which case //the origin is always used LTObjRef m_hTrackObject; //If HOBJECT is supposed to be treated as a model and not just an object, //this will refer to the node that is supposed to be tracked on the model HMODELNODE m_hTrackNode; //the offset from the object's position to track LTVector m_vTrackOffset; //this is the transform to convert from a space where the desired pointing vector is Z to //the aligned space where Z is always forward LTMatrix m_mInvTargetTransform; //the space we were in at the end of the last update LTVector m_vActualUp; LTVector m_vActualRight; LTVector m_vActualForward; LTVector m_vActualPos; //vector for aligning the target vector to prevent roll LTVector m_vAlignUp; //flags indicating what state we were in during the last update //determine if we were looking at the target bool m_bLookingAtTarget; //determine if we were in the discomfort zone bool m_bInDiscomfort; //determine if the max threshold was hit bool m_bAtMaxThreshold; //flag indicating whether or not this is even enabled bool m_bEnabled; //flag indicating that when this node reaches the target look at state, it should disable itself bool m_bAutoDisable; //this flag indicates that the parent's animation transform should be competely disregarded so //that the constraints will never be altered by it. This is commonly done for higher up nodes //to give complete control over how they move bool m_bIgnoreParentAnimation; //flag indicating if this node alignment should be relative to the animation orienation with //respect to the model orienation. This is used for things such as aiming guns sideways, in which //the node that should be aligned is constantly changing with how the gun is oriented towards //the forward of the model. bool m_bOrientFromAnim; //flag indicating that this update will be the first after a deactivation period. This indicates //that the current orientation should be grabbed from the animation to prevent popping and //will be cleared after the orientation is grabbed bool m_bSyncOrientation; //the child node, can be NULL CTrackedNode* m_pChild; //the object that we are cloning for orientation CTrackedNode* m_pMimicNode; //cosine of the above angles float m_fTanXDiscomfort; float m_fTanYDiscomfort; float m_fTanXThreshold; float m_fTanYThreshold; //maxiumum angular velocity float m_fMaxAngVel; //the last time that this node was updated clock_t m_LastUpdate; //the node holds a pointer back to its manager, this normally isn't //a good thing since it results in cyclic dependencies, but it is //an opaque pointer and is needed due to the callback nature of the //node control CTrackedNodeMgr *m_pNodeMgr; }; #endif
[ [ [ 1, 125 ] ] ]
7145e0f64934a9d1c0f9816c750a658314a01590
914791f0d412fdcd67f9bc5e0a757899b7a48ecb
/src/re330/VertexDeclaration.h
887b83a1679c8a36f8368c672f14ea1cc23e5924
[]
no_license
hchapman/graphics-projects
39af28a5daf426cd2b3a050d3faa8aed935a32da
ede6ad4f44f2002d66fa7f6be5cbfde9829c655c
refs/heads/master
2021-03-12T22:49:37.126498
2010-03-30T03:08:43
2010-03-30T03:08:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,390
h
#ifndef __VertexDeclaration_h__ #define __VertexDeclaration_h__ #include "RE330_global.h" #include <list> #include <map> namespace RE330 { enum VertexElementSemantic { VES_POSITION = 1, VES_NORMAL = 2, VES_DIFFUSE = 3, VES_SPECULAR = 4, VES_TEXTURE_COORDINATES = 5 }; /** This class specificies a vertex element, and how it is stored in a buffer. It should NOT be used directly from applications. */ class RE330_EXPORT VertexElement { public: VertexElement(int bufferIndex, int offset, int size, int stride, VertexElementSemantic veSemantic) : mBufferIndex(bufferIndex), mOffset(offset), mSize(size), mStride(stride), mSemantic(veSemantic) {} int getBufferIndex() const { return mBufferIndex; } int getOffset() const { return mOffset; } int getSize() const { return mSize; } int getStride() const { return mStride; } VertexElementSemantic getSemantic() const { return mSemantic; } private: int mBufferIndex; int mOffset; int mSize; int mStride; VertexElementSemantic mSemantic; }; /** The application program uses this class to specify the format of vertex data. Vertex data is stored in a list of buffers, and each buffer has a certain format. Each buffer may contain one or several vertex elements, such as position, color, etc. @remarks Vertex buffers store items of type float exclusively. */ class RE330_EXPORT VertexDeclaration { public: typedef std::list<VertexElement> VertexElementList; /** Specify a vertex element and how it is stored in a given buffer. @param bufferIndex is the index of the buffer where the element is stored. @param offset is the offset into the buffer (in bytes) where the first data item is stored. @param size is the number of items stored for each vertex. For example, for normal vectors with 3 components, size=3. @param stride is the offset, in bytes, between data for consecutive vertices. @param veSemantic is the semantic of the vertex element, i.e., position, color, etc. Make sure that each vertex declaration has no more than one element of each type! */ void addElement(int bufferIndex, int offset, int size, int stride, VertexElementSemantic veSemantic); int getElementCount() const; const VertexElement* getElement(int index) const; protected: VertexElementList mElementList; }; /** This class stores vertex data. It should NOT be accessed directly from applications. In an advanced implementation of the rendering engine, this could be implemented as OpenGL vertex buffer objects. */ class RE330_EXPORT VertexBuffer { public: VertexBuffer() : mBuffer(0) {} ~VertexBuffer(); void loadBuffer(int bufferSize, unsigned char *data); unsigned char *getBuffer() const { return mBuffer; } private: unsigned char *mBuffer; }; /** This class maps vertex buffer indices to pointers to vertex buffers. It should NOT be accessed directly from applications. */ class RE330_EXPORT VertexBufferBinding { public: typedef std::map<unsigned short, VertexBuffer> VertexBufferBindingMap; protected: VertexBufferBindingMap mBindingMap; public: void setBinding(unsigned short index, const VertexBuffer& buffer); const VertexBuffer& getBuffer(unsigned short index) const; }; } #endif
[ [ [ 1, 110 ] ] ]
fd0ba6fa80aee0c8c3215a7651f5fb264b627400
a353edf4c927a4b7e3abb197dd825d5a16b1397b
/trunk/new/src/audiostate.cc
93fad4b28db248574e6fae50a43d1615afe8b2b6
[]
no_license
BackupTheBerlios/bbplusplus-svn
e84421e7cdbedfd038ff12120ec2bbe344017f61
15ddd62124f0fbe505d458e8b417b750b6621d37
refs/heads/master
2016-09-06T10:38:56.414292
2007-02-05T20:42:44
2007-02-05T20:42:44
40,669,362
0
0
null
null
null
null
UTF-8
C++
false
false
539
cc
#include "../includes/audiostate.h" AudioState::AudioState(Commands &cmd, MenuDisplayer &md, InputHandler & ih) : mCommands(&cmd), mDisplayer(&md), mHandler(&ih) { mMenu = new Menu("Audio Menu"); mMenu->addEntry(MenuItem(AUDIOBURNING, "Burn Audio-CD")); mMenu->addEntry(MenuItem(MAIN, "Back to Main Menu")); } AudioState::~AudioState() { delete mMenu; } Menu* AudioState::getMenu() { return mMenu; } int AudioState::run() { mCommands->clearScreen(); mDisplayer->show(); return mHandler->getInput(); }
[ "aelinden@8b881f40-4f0d-0410-bf13-8b5a6dda1b3d" ]
[ [ [ 1, 24 ] ] ]
075c64d6de13728c7b85e973ed22fd0808d24dbf
f177993b13e97f9fecfc0e751602153824dfef7e
/ImPro/ImProFilters/TouchLibFilter/Touchlib/include/IBlobTracker.h
400c1285d801f511de894e72db6d1492a1a5637e
[]
no_license
svn2github/imtophooksln
7bd7412947d6368ce394810f479ebab1557ef356
bacd7f29002135806d0f5047ae47cbad4c03f90e
refs/heads/master
2020-05-20T04:00:56.564124
2010-09-24T09:10:51
2010-09-24T09:10:51
11,787,598
1
0
null
null
null
null
UTF-8
C++
false
false
1,559
h
#ifndef __TOUCHLIB_IBLOBTRACKER__ #define __TOUCHLIB_IBLOBTRACKER__ #include <vector> #include "touchlib_platform.h" #include "ITouchListener.h" #include "TouchData.h" #include "Image.h" namespace touchlib { class IBlobTracker { public: IBlobTracker(); // ---- pure virtual functions ----------------------------------------- virtual bool getUseKalmanFilter() = 0; virtual bool setUseKalmanFilter(bool bUse) = 0; virtual int getNumFrameFix() = 0; virtual bool setNumFrameFix(int nFrame) = 0; virtual BOOL GetMeasureNoiseCov(float& fNoiseCov) = 0; virtual BOOL SetMeasureNoiseCov(float fNoiseCov) = 0; virtual bool findBlobs(BwImage& frame) = 0; virtual void trackBlobs() = 0; virtual void gatherEvents() = 0; virtual std::vector<CvRect>* GetForeground() = 0; // ---- public members ------------------------------------------------- void registerListener(ITouchListener *listener); void setup(int r_dist, int r_min_dim, int r_max_dim, int g_frames, float minimumDisplacementThreshold); virtual bool drawFingers(IplImage* img) = 0; public: static const float DEFAULT_MINIMUM_DISPLACEMENT_THRESHOLD; protected: void doTouchEvent(const TouchData& data); void doUpdateEvent(const TouchData& data); void doUntouchEvent(const TouchData& data); int reject_distance_threshold; int reject_min_dimension; int reject_max_dimension; int ghost_frames; float minimumDisplacementThreshold; std::vector<ITouchListener *> listenerList; }; } #endif // __TOUCHLIB_IBLOBTRACKER__
[ "ndhumuscle@fa729b96-8d43-11de-b54f-137c5e29c83a" ]
[ [ [ 1, 55 ] ] ]
00d5d7d7c9665e5dad16a7d13fcbaea66c167382
c5534a6df16a89e0ae8f53bcd49a6417e8d44409
/trunk/nGENE Proj/CameraThirdPerson.h
0b908c8d9b731504e435dc4320c9b8504c5730c6
[]
no_license
svn2github/ngene
b2cddacf7ec035aa681d5b8989feab3383dac012
61850134a354816161859fe86c2907c8e73dc113
refs/heads/master
2023-09-03T12:34:18.944872
2011-07-27T19:26:04
2011-07-27T19:26:04
78,163,390
2
0
null
null
null
null
UTF-8
C++
false
false
3,101
h
/* --------------------------------------------------------------------------- This source file is part of nGENE Tech. Copyright (c) 2006- Wojciech Toman This program is free software. File: CameraThirdPerson.h Version: 0.02 --------------------------------------------------------------------------- */ #pragma once #ifndef __INC_CAMERATHIRDPERSON_H_ #define __INC_CAMERATHIRDPERSON_H_ #include "Camera3D.h" #include "TypeInfo.h" #include "Vector3.h" namespace nGENE { /** Presents view from the third person perspective. @par It is especially useful in TPS/RPG and racing games. @par Although position of the camera is influenced by the position of parental node, rotation is not. It is due to the fact TPS camera is quite independent and rarely fixed, so there is no such need. */ class nGENEDLL CameraThirdPerson: public Camera3D { EXPOSE_TYPE private: Real m_fDistanceFromTarget; ///< Preferred distance from target point Vector3 m_vecTarget; ///< Target protected: virtual void updateAxes(); public: CameraThirdPerson(); virtual ~CameraThirdPerson(); virtual void init(); virtual void cleanup(); /** Moves the camera in the z-direction. @param _direction pass 1 to make camera go forward and -1, to go backwards. */ virtual void move(Real _direction); /** Moves the camera in the x-direction. @param _direction pass 1 to make camera go right and -1, to go left. */ virtual void strafe(Real _direction); /// Sets target point for the camera. virtual void setTarget(Vector3& _target); virtual Vector3& getTarget(); /// Sets distance between camera and the target point. virtual void setDistanceFromTarget(Real _distance); virtual Real getDistanceFromTarget() const; virtual void serialize(ISerializer* _serializer, bool _serializeType, bool _serializeChildren); virtual void deserialize(ISerializer* _serializer); }; /** Camera factory to be used for creating CameraThirdPerson type objects. */ class nGENEDLL TPPCameraFactory: public CameraFactory { public: TPPCameraFactory(); ~TPPCameraFactory(); Camera* createCamera() {return new CameraThirdPerson();} }; inline void CameraThirdPerson::setTarget(Vector3& _target) { m_vecTarget = _target; m_bChanged = true; m_bHasChanged = true; } //---------------------------------------------------------------------- inline Vector3& CameraThirdPerson::getTarget() { return m_vecTarget; } //---------------------------------------------------------------------- inline void CameraThirdPerson::setDistanceFromTarget(Real _distance) { m_fDistanceFromTarget = _distance; m_bChanged = true; m_bHasChanged = true; } //---------------------------------------------------------------------- inline Real CameraThirdPerson::getDistanceFromTarget() const { return m_fDistanceFromTarget; } //---------------------------------------------------------------------- } #endif
[ "Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57" ]
[ [ [ 1, 123 ] ] ]
1ddae848d07b0286212bd0f4b69ca25aa6cdfe01
59957e5aa42be6037a8539d299ca741086b81761
/Credentials.cpp
503453145a702086ba1cc77cbd034897bc572733
[]
no_license
thiagomg/twithiago
4a1144ab904ba26b53a09e454f7d9c709984aefe
60b5f8da1a3bcc426916949a7e50944163874a28
refs/heads/master
2020-04-16T07:15:46.909318
2010-04-12T13:06:02
2010-04-12T13:06:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
805
cpp
#include "Credentials.h" #include "Config.h" Credentials::Credentials() { } Credentials::Credentials(const QString &username, const QString &password) { _username = username; _password = password; } Credentials::~Credentials() { } void Credentials::setUsername(const QString &username) { _username = username; } void Credentials::setPassword(const QString &password) { _password = password; } const QString & Credentials::getUsername() const { return _username; } const QString & Credentials::getPassword() const { return _password; } bool Credentials::hasUserSet() const { if( _username.size() > 0 ) return true; return false; } void Credentials::loadConfig() { _username = CONFIG.getUsername(); _password = CONFIG.getPassword(); }
[ "thiedri@8854fccc-d45e-11de-bff8-d51c198f79d0" ]
[ [ [ 1, 50 ] ] ]
bf05fc2668220d227d06adc1b05cc0cbd318c63d
4eb798236579b3a57c9960e0d4acfe825cac5e4a
/MyQGraphicsView.h
4f1e453510d1affccdebe42ba535f44326f29b67
[]
no_license
gclaret/kmeans-cw
1a985e19ee20c9cd1e2310bfeea950e54a4993ca
6e2a765e230b36df602a97f6f0f788bc2c1081b2
refs/heads/master
2021-01-01T15:44:45.026218
2011-12-20T23:22:09
2011-12-20T23:22:09
39,042,975
0
0
null
null
null
null
UTF-8
C++
false
false
865
h
#ifndef MYQGRAPHICSVIEW_H #define MYQGRAPHICSVIEW_H #include <QGraphicsView> #include <QGraphicsScene> #include <QGraphicsEllipseItem> #include <QMouseEvent> #include <QTimer> #include "PointList.h" #include "Cluster.h" class MyQGraphicsView : public QGraphicsView { Q_OBJECT public: explicit MyQGraphicsView(QWidget *parent = 0); void drawPoint(Point *p, QColor color = QColor("black"), bool clear= false, int size = 4); void drawCluster(Cluster *c, bool clear = false); void colourCluster(Cluster *c); QGraphicsScene *getScene(); void delayedColourClusters(std::vector<Cluster *> &clusters); signals: public slots: void mousePressEvent(QMouseEvent *e); void colourClusters(); private: QGraphicsScene *scene; std::vector<Cluster *> cluster_state; }; #endif // MYQGRAPHICSVIEW_H
[ [ [ 1, 35 ] ] ]
1b6d88688634b8ca2958da0fb5add554258bf704
f8b364974573f652d7916c3a830e1d8773751277
/emulator/allegrex/instructions/VEXP2.h
2ae61e230cd695b09785dbe61a2a20c89c9708d1
[]
no_license
lemmore22/pspe4all
7a234aece25340c99f49eac280780e08e4f8ef49
77ad0acf0fcb7eda137fdfcb1e93a36428badfd0
refs/heads/master
2021-01-10T08:39:45.222505
2009-08-02T11:58:07
2009-08-02T11:58:07
55,047,469
0
0
null
null
null
null
UTF-8
C++
false
false
1,042
h
template< > struct AllegrexInstructionTemplate< 0xd0140000, 0xffff0000 > : AllegrexInstructionUnknown { static AllegrexInstructionTemplate &self() { static AllegrexInstructionTemplate insn; return insn; } static AllegrexInstruction *get_instance() { return &AllegrexInstructionTemplate::self(); } virtual AllegrexInstruction *instruction(u32 opcode) { return this; } virtual char const *opcode_name() { return "VEXP2"; } virtual void interpret(Processor &processor, u32 opcode); virtual void disassemble(u32 address, u32 opcode, char *opcode_name, char *operands, char *comment); protected: AllegrexInstructionTemplate() {} }; typedef AllegrexInstructionTemplate< 0xd0140000, 0xffff0000 > AllegrexInstruction_VEXP2; namespace Allegrex { extern AllegrexInstruction_VEXP2 &VEXP2; } #ifdef IMPLEMENT_INSTRUCTION AllegrexInstruction_VEXP2 &Allegrex::VEXP2 = AllegrexInstruction_VEXP2::self(); #endif
[ [ [ 1, 41 ] ] ]
9b0ea0f20749efaaa56b494a6791871c1ba902ee
24c456d31966a458a32eb61bc9425a5b66caeaaa
/autoexport.h
7e356a98f92299f67123b32d4898258624044c5d
[]
no_license
tjssmy/Cuviewer-2.0
577852960a58addb3cd38bbd0f7101334b83f0d2
bc11760c2010e9b2cbe59697e9ed6e0d43d3fbd2
refs/heads/master
2021-01-10T18:27:34.483338
2011-11-28T14:22:58
2011-11-28T14:22:58
2,772,012
0
1
null
null
null
null
UTF-8
C++
false
false
435
h
#ifndef AUTOEXPORT_H #define AUTOEXPORT_H #include <qvariant.h> #include "ui_autoexport.h" namespace Ui { class AutoExport; } // namespace Ui class AutoExport : public QDialog, public Ui::AutoExport { Q_OBJECT public: AutoExport(QWidget* parent = 0, bool modal = false, Qt::WindowFlags fl = 0); ~AutoExport(); protected slots: virtual void languageChange(); }; #endif // AUTOEXPORT_H
[ [ [ 1, 24 ] ] ]
8fc48c5937f8c67a1dd1a806da01cd678cd8bbd2
9566086d262936000a914c5dc31cb4e8aa8c461c
/EnigmaCommon/Entities/SpawnLocation.hpp
0af0cb767db53da39f152fe2b67a1abdf512b1bf
[]
no_license
pazuzu156/Enigma
9a0aaf0cd426607bb981eb46f5baa7f05b66c21f
b8a4dfbd0df206e48072259dbbfcc85845caad76
refs/heads/master
2020-06-06T07:33:46.385396
2011-12-19T03:14:15
2011-12-19T03:14:15
3,023,618
1
0
null
null
null
null
WINDOWS-1252
C++
false
false
1,244
hpp
#ifndef SPAWNLOCATION_HPP_INCLUDED #define SPAWNLOCATION_HPP_INCLUDED /* Copyright © 2009 Christopher Joseph Dean Schaefer (disks86) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "Monster.hpp" namespace Enigma { class DllExport SpawnLocation : public Entity { private: protected: public: SpawnLocation(); ~SpawnLocation(); }; }; #endif // SPAWNLOCATION_HPP_INCLUDED
[ [ [ 1, 34 ] ] ]
cf7db96da47d1cbd3ce3178325a075d7ddb29370
c9026525ec43c9807c9980a93e64a780a7821836
/TuioServerModule/oscpack/tests/OscSendTests.cpp
82d96a4f8e37a46b702a7ed57a01fecc167af3a7
[ "LicenseRef-scancode-warranty-disclaimer", "MIT" ]
permissive
aperron/surface-multitouch
51cf727cd3e1c98dd7016a4e1e3a6da661821d7a
99c103b5419cf7430875f503a2975c40c26b2636
refs/heads/master
2016-09-05T09:44:08.806612
2010-01-22T22:05:42
2010-01-22T22:05:42
32,813,312
0
0
null
null
null
null
UTF-8
C++
false
false
6,791
cpp
/* oscpack -- Open Sound Control packet manipulation library http://www.audiomulch.com/~rossb/oscpack Copyright (c) 2004-2005 Ross Bencina <[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. Any person wishing to distribute modifications to the Software is requested to send the modifications to the original developer so that they can be incorporated into the canonical version. 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 "OscSendTests.h" #include <iostream> #include <string.h> #include "osc/OscOutboundPacketStream.h" #include "ip/UdpSocket.h" #include "ip/IpEndpointName.h" #include <cstdlib> #define IP_MTU_SIZE 1536 namespace osc{ void RunSendTests( const IpEndpointName& host ) { char buffer[IP_MTU_SIZE]; osc::OutboundPacketStream p( buffer, IP_MTU_SIZE ); UdpTransmitSocket socket( host ); p.Clear(); p << osc::BeginMessage( "/test1" ) << true << 23 << (float)3.1415 << "hello" << osc::EndMessage; socket.Send( p.Data(), p.Size() ); // test1 message with too few arguments p.Clear(); p << osc::BeginMessage( "/test1" ) << true << osc::EndMessage; socket.Send( p.Data(), p.Size() ); // test1 message with too many arguments p.Clear(); p << osc::BeginMessage( "/test1" ) << true << 23 << (float)3.1415 << "hello" << 42 << osc::EndMessage; socket.Send( p.Data(), p.Size() ); // test1 message with wrong argument type p.Clear(); p << osc::BeginMessage( "/test1" ) << true << 1.0 << (float)3.1415 << "hello" << osc::EndMessage; socket.Send( p.Data(), p.Size() ); p.Clear(); p << osc::BeginMessage( "/test2" ) << true << 23 << (float)3.1415 << "hello" << osc::EndMessage; socket.Send( p.Data(), p.Size() ); // send four /test3 messages, each with a different type of argument p.Clear(); p << osc::BeginMessage( "/test3" ) << true << osc::EndMessage; socket.Send( p.Data(), p.Size() ); p.Clear(); p << osc::BeginMessage( "/test3" ) << 23 << osc::EndMessage; socket.Send( p.Data(), p.Size() ); p.Clear(); p << osc::BeginMessage( "/test3" ) << (float)3.1415 << osc::EndMessage; socket.Send( p.Data(), p.Size() ); p.Clear(); p << osc::BeginMessage( "/test3" ) << "hello" << osc::EndMessage; socket.Send( p.Data(), p.Size() ); // send a bundle p.Clear(); p << osc::BeginBundle(); p << osc::BeginMessage( "/no_arguments" ) << osc::EndMessage; p << osc::BeginMessage( "/a_bool" ) << true << osc::EndMessage; p << osc::BeginMessage( "/a_bool" ) << false << osc::EndMessage; p << osc::BeginMessage( "/a_bool" ) << (bool)1234 << osc::EndMessage; p << osc::BeginMessage( "/nil" ) << osc::Nil << osc::EndMessage; p << osc::BeginMessage( "/inf" ) << osc::Infinitum << osc::EndMessage; p << osc::BeginMessage( "/an_int" ) << 1234 << osc::EndMessage; p << osc::BeginMessage( "/a_float" ) << 3.1415926f << osc::EndMessage; p << osc::BeginMessage( "/a_char" ) << 'c' << osc::EndMessage; p << osc::BeginMessage( "/an_rgba_color" ) << osc::RgbaColor(0x22334455) << osc::EndMessage; p << osc::BeginMessage( "/a_midi_message" ) << MidiMessage(0x7F) << osc::EndMessage; p << osc::BeginMessage( "/an_int64" ) << (int64)(0xFFFFFFF) << osc::EndMessage; p << osc::BeginMessage( "/a_time_tag" ) << osc::TimeTag(0xFFFFFFFUL) << osc::EndMessage; p << osc::BeginMessage( "/a_double" ) << (double)3.1415926 << osc::EndMessage; p << osc::BeginMessage( "/a_string" ) << "hello world" << osc::EndMessage; p << osc::BeginMessage( "/a_symbol" ) << osc::Symbol("foobar") << osc::EndMessage; // blob { char blobData[] = "abcd"; p << osc::BeginMessage( "/a_blob" ) << osc::Blob( blobData, 4 ) << osc::EndMessage; } p << osc::EndBundle; socket.Send( p.Data(), p.Size() ); // nested bundles, and multiple messages in bundles... p.Clear(); p << osc::BeginBundle( 1234 ) << osc::BeginMessage( "/an_int" ) << 1 << osc::EndMessage << osc::BeginMessage( "/an_int" ) << 2 << osc::EndMessage << osc::BeginMessage( "/an_int" ) << 3 << osc::EndMessage << osc::BeginMessage( "/an_int" ) << 4 << osc::EndMessage << osc::BeginBundle( 12345 ) << osc::BeginMessage( "/an_int" ) << 5 << osc::EndMessage << osc::BeginMessage( "/an_int" ) << 6 << osc::EndMessage << osc::EndBundle << osc::EndBundle; socket.Send( p.Data(), p.Size() ); } } // namespace osc #ifndef NO_OSC_TEST_MAIN int main(int argc, char* argv[]) { if( argc >= 2 && strcmp( argv[1], "-h" ) == 0 ){ std::cout << "usage: OscSendTests [hostname [port]]\n"; return 0; } char *hostName = "localhost"; int port = 7000; if( argc >= 2 ) hostName = argv[1]; if( argc >= 3 ) port = atoi( argv[2] ); IpEndpointName host( hostName, port ); char hostIpAddress[ IpEndpointName::ADDRESS_STRING_LENGTH ]; host.AddressAsString( hostIpAddress ); std::cout << "sending test messages to " << hostName << " (" << hostIpAddress << ") on port " << port << "...\n"; osc::RunSendTests( host ); } #endif /* NO_OSC_TEST_MAIN */
[ "perron.anthony@729dd85e-0118-11df-9748-a16e6a44286a" ]
[ [ [ 1, 215 ] ] ]
cbe9d4b3a854da00ddc6641d6fd57160b6b83996
c0a577ec612a721b324bb615c08882852b433949
/englishplayer/EnTranscription/Mfcc.h
52e9a2343fc1965cc90ffd4873f641539a2f1661
[]
no_license
guojerry/cppxml
ca87ca2e3e62cbe2a132d376ca784f148561a4cc
a4f8b7439e37b6f1f421445694c5a735f8beda71
refs/heads/master
2021-01-10T10:57:40.195940
2010-04-21T13:25:29
2010-04-21T13:25:29
52,403,012
0
0
null
null
null
null
UTF-8
C++
false
false
1,446
h
#pragma once /* * Assume P64 or LP64. If you need to port this to a DSP, let us know. */ typedef int int32; typedef short int16; typedef signed char int8; typedef unsigned int uint32; typedef unsigned short uint16; typedef unsigned char uint8; typedef float float32; typedef double float64; #if defined(_MSC_VER) typedef __int64 int64; typedef unsigned __int64 uint64; #elif defined(HAVE_LONG_LONG) && (SIZEOF_LONG_LONG == 8) typedef long long int64; typedef unsigned long long uint64; #else /* !HAVE_LONG_LONG && SIZEOF_LONG_LONG == 8 */ typedef double int64; typedef double uint64; #endif /* !HAVE_LONG_LONG && SIZEOF_LONG_LONG == 8 */ #include "fe_internal.h" /** * Error codes returned by stuff. */ enum fe_error_e { FE_SUCCESS = 0, FE_OUTPUT_FILE_SUCCESS = 0, FE_CONTROL_FILE_ERROR = -1, FE_START_ERROR = -2, FE_UNKNOWN_SINGLE_OR_BATCH = -3, FE_INPUT_FILE_OPEN_ERROR = -4, FE_INPUT_FILE_READ_ERROR = -5, FE_MEM_ALLOC_ERROR = -6, FE_OUTPUT_FILE_WRITE_ERROR = -7, FE_OUTPUT_FILE_OPEN_ERROR = -8, FE_ZERO_ENERGY_ERROR = -9, FE_INVALID_PARAM_ERROR = -10 }; #define E_ERROR TRACE #define E_FATAL TRACE #define E_INFO TRACE #define E_WARN TRACE class CMfcc { public: CMfcc(void); ~CMfcc(void); public: int32 fe_process_frame(int16 const *spch, int32 nsamps, mfcc_t * fr_cep); private: int fe_free(fe_t * fe); fe_t* m_fe; };
[ "oeichenwei@0e9f5f58-6d57-11de-950b-9fccee66d0d9" ]
[ [ [ 1, 62 ] ] ]
b47f37b5dbf90f271be0e3f40de7efd0de31c2c9
2d4221efb0beb3d28118d065261791d431f4518a
/OIDE源代码/OLIDE/DlgProjectProperty.h
c8cee94ef5a6a016b01c3173e6ff95a4661d12a1
[]
no_license
ophyos/olanguage
3ea9304da44f54110297a5abe31b051a13330db3
38d89352e48c2e687fd9410ffc59636f2431f006
refs/heads/master
2021-01-10T05:54:10.604301
2010-03-23T11:38:51
2010-03-23T11:38:51
48,682,489
1
0
null
null
null
null
GB18030
C++
false
false
1,028
h
#pragma once #include "./Controls/TreePropSheet/ResizableDialog.h" #include "./Controls/TreePropSheet/TreePropSheetEx.h" #include "./Controls/TreePropSheet/TreePropSheetSplitter.h" #include "./Controls/TreePropSheet/TreePropSheetBordered.h" #include "./Data/SolutionProperty.h" #include "DlgLinkProperty.h" // CDlgProjectProperty 对话框 class CDlgProjectProperty : public CResizableDialog { DECLARE_DYNAMIC(CDlgProjectProperty) public: CDlgProjectProperty(CWnd* pParent = NULL); // 标准构造函数 virtual ~CDlgProjectProperty(); // 对话框数据 enum { IDD = IDD_DLG_SYSTEM_OPTION }; private: TreePropSheet::CTreePropSheetEx m_sheetItem; public: CDlgLinkProperty m_dlgLinkProperty; private: bool RegisterSheet(UINT nID, CPropertySheet& rSheet); protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 DECLARE_MESSAGE_MAP() public: virtual BOOL OnInitDialog(); virtual INT_PTR DoModal(); afx_msg void OnBnClickedOk(); };
[ [ [ 1, 44 ] ] ]
a0a184ee2010a497586a2c0b4af1fdbb4b0bc032
f8b364974573f652d7916c3a830e1d8773751277
/emulator/allegrex/disassembler/LUI.h
1bedcb84b30841c4997ff488d639893d21fb019d
[]
no_license
lemmore22/pspe4all
7a234aece25340c99f49eac280780e08e4f8ef49
77ad0acf0fcb7eda137fdfcb1e93a36428badfd0
refs/heads/master
2021-01-10T08:39:45.222505
2009-08-02T11:58:07
2009-08-02T11:58:07
55,047,469
0
0
null
null
null
null
UTF-8
C++
false
false
368
h
/* LUI */ void AllegrexInstructionTemplate< 0x3c000000, 0xffe00000 >::disassemble(u32 address, u32 opcode, char *opcode_name, char *operands, char *comment) { using namespace Allegrex; u32 imm = uimm16(opcode); ::strcpy(opcode_name, "lui"); ::sprintf(operands, "%s, 0x%04X", gpr_name[rt(opcode)], imm&0xFFFF); ::sprintf(comment, "%u", imm<<16); }
[ [ [ 1, 10 ] ] ]
f8668812f142114720decb82bf8e3f6751981c53
5ed707de9f3de6044543886ea91bde39879bfae6
/ASBaseball/Shared/Source/ASBaseballObjectBuilder.h
9c5eeda0e16135561a965f3f5ff784721887009e
[]
no_license
grtvd/asifantasysports
9e472632bedeec0f2d734aa798b7ff00148e7f19
76df32c77c76a76078152c77e582faa097f127a8
refs/heads/master
2020-03-19T02:25:23.901618
1999-12-31T16:00:00
2018-05-31T19:48:19
135,627,290
0
0
null
null
null
null
UTF-8
C++
false
false
1,491
h
/* ASBaseballObjectBuilder */ /******************************************************************************/ #ifndef ASBaseballObjectBuilderH #define ASBaseballObjectBuilderH #include "ASFantasyObjectBuilder.h" #include "ASBaseballType.h" using namespace asfantasy; namespace asbaseball { /******************************************************************************/ /* ASBaseballObjectBuilder Types */ //BOB const CStr31 fobt_TBaseballProfTeamSchedule("TBaseballProfTeamSchedule"); /******************************************************************************/ class ASBaseballObjectBuilder : public ASFantasyObjectBuilder { protected: ASBaseballObjectBuilder() {} public: static ASBaseballObjectBuilder& getThe() { return(dynamic_cast<ASBaseballObjectBuilder&>(ASFantasyObjectBuilder::getThe())); } virtual void* newInstance(const char* type); //BOB TBaseballProfTeamSchedulePtr newBaseballProfTeamSchedule() //BOB { return(TBaseballProfTeamSchedulePtr( //BOB static_cast<TBaseballProfTeamSchedule*>(newInstance(fobt_TBaseballProfTeamSchedule)))); } friend ObjectBuilder& tag::getTheObjectBuilder(); }; /******************************************************************************/ }; //namespace asbaseball #endif //ASBaseballObjectBuilderH /******************************************************************************/ /******************************************************************************/
[ [ [ 1, 46 ] ] ]
5f8431e2efca58c16c613541c1ff6e85405c94c9
5a05acb4caae7d8eb6ab4731dcda528e2696b093
/GameEngine/Gfx/GUI/GuiCheckBoxFwd.hpp
2cad25523ac2050a808790ffb40b66f81104d830
[]
no_license
andreparker/spiralengine
aea8b22491aaae4c14f1cdb20f5407a4fb725922
36a4942045f49a7255004ec968b188f8088758f4
refs/heads/master
2021-01-22T12:12:39.066832
2010-05-07T00:02:31
2010-05-07T00:02:31
33,547,546
0
0
null
null
null
null
UTF-8
C++
false
false
140
hpp
#ifndef GUI_CHECK_BOX_FWD_HPP #define GUI_CHECK_BOX_FWD_HPP namespace Spiral { namespace GUI { class GuiCheckBox; } } #endif
[ "DreLnBrown@e933ee44-1dc6-11de-9e56-bf19dc6c588e" ]
[ [ [ 1, 13 ] ] ]
88b5eaa7ccd3ffe07b88e39c9f6fa8b20fca4eca
1bbd5854d4a2efff9ee040e3febe3f846ed3ecef
/src/scrview/sspacket.cpp
69c0aec2bf045c9fbdd08c3aa531fd09eac4cebe
[]
no_license
amanuelg3/screenviewer
2b896452a05cb135eb7b9eb919424fe6c1ce8dd7
7fc4bb61060e785aa65922551f0e3ff8423eccb6
refs/heads/master
2021-01-01T18:54:06.167154
2011-12-21T02:19:10
2011-12-21T02:19:10
37,343,569
0
0
null
null
null
null
UTF-8
C++
false
false
887
cpp
#include "sspacket.h" SsPacket::SsPacket() { ss = NULL; type = 0; } void SsPacket::makePacket() { if (ss == NULL) { currentPacket = NULL; return; } currentPacket = new QByteArray(); QDataStream out(currentPacket, QIODevice::WriteOnly); out.setVersion(QDataStream::Qt_4_2); blockSize = ss->getScreen()->size() + sizeof(quint16); out << (quint16) blockSize; out << (quint16) type; currentPacket->append(*ss->getScreen()); } void SsPacket::setNewContent(Screenshot *ss) { delete this->ss; this->ss = ss; } Screenshot* SsPacket::analyzePacket(QTcpSocket *socket, quint16 size) { QByteArray* screen = new QByteArray(); *screen = socket->read(size); Screenshot* tmp = new Screenshot(screen); return tmp; } Screenshot* SsPacket::getContent() { return ss; }
[ "JuliusR@localhost", "j.salkevicius@localhost" ]
[ [ [ 1, 29 ], [ 31, 42 ] ], [ [ 30, 30 ] ] ]
3bd05676b51b96b5093cfe6bacbf6a47f0ff5010
478570cde911b8e8e39046de62d3b5966b850384
/apicompatanamdw/bcdrivers/app/contacts/phonebook_data_management_api/MTPbkIconId/inc/MTPbkIconId.h
9ee4e93fa8555eb5801bf3abb299a35cf944e0c3
[]
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
4,536
h
/* * Copyright (c) 2002 - 2007 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: ?Description * */ #ifndef MTPBKICONID_H #define MTPBKICONID_H // INCLUDES #include <StifLogger.h> #include <TestScripterInternal.h> #include <StifTestModule.h> #include <TestclassAssert.h> class CPbkFieldIdArray; #include <e32def.h> // CONSTANTS //const ?type ?constant_var = ?constant; // MACROS //#define ?macro ?macro_def #define TEST_CLASS_VERSION_MAJOR 30 #define TEST_CLASS_VERSION_MINOR 9 #define TEST_CLASS_VERSION_BUILD 38 // Logging path _LIT( KMTPbkIconIdLogPath, "\\logs\\testframework\\MTPbkIconId\\" ); // Log file _LIT( KMTPbkIconIdLogFile, "MTPbkIconId.txt" ); _LIT( KMTPbkIconIdLogFileWithTitle, "MTPbkIconId_[%S].txt" ); // FUNCTION PROTOTYPES //?type ?function_name(?arg_list); // FORWARD DECLARATIONS //class ?FORWARD_CLASSNAME; class CMTPbkIconId; // DATA TYPES //enum ?declaration //typedef ?declaration //extern ?data_type; // CLASS DECLARATION /** * CMTPbkIconId test class for STIF Test Framework TestScripter. * ?other_description_lines * * @lib ?library * @since ?Series60_version */ NONSHARABLE_CLASS(CMTPbkIconId) : public CScriptBase { public: // Constructors and destructor /** * Two-phased constructor. */ static CMTPbkIconId* NewL( CTestModuleIf& aTestModuleIf ); /** * Destructor. */ virtual ~CMTPbkIconId(); public: // New functions /** * ?member_description. * @since ?Series60_version * @param ?arg1 ?description * @return ?description */ //?type ?member_function( ?type ?arg1 ); public: // Functions from base classes /** * From CScriptBase Runs a script line. * @since ?Series60_version * @param aItem Script line containing method name and parameters * @return Symbian OS error code */ virtual TInt RunMethodL( CStifItemParser& aItem ); protected: // New functions /** * ?member_description. * @since ?Series60_version * @param ?arg1 ?description * @return ?description */ //?type ?member_function( ?type ?arg1 ); protected: // Functions from base classes /** * From ?base_class ?member_description */ //?type ?member_function(); private: /** * C++ default constructor. */ CMTPbkIconId( CTestModuleIf& aTestModuleIf ); /** * By default Symbian 2nd phase constructor is private. */ void ConstructL(); // Prohibit copy constructor if not deriving from CBase. // ?classname( const ?classname& ); // Prohibit assigment operator if not deriving from CBase. // ?classname& operator=( const ?classname& ); /** * Frees all resources allocated from test methods. * @since ?Series60_version */ void Delete(); /** * Test methods are listed below. */ void SetupL(); void Teardown(); TInt CheckEnumValuesL(); /** * Method used to log version of test class */ void SendTestClassVersion(); //ADD NEW METHOD DEC HERE //[TestMethods] - Do not remove public: // Data // ?one_line_short_description_of_data //?data_declaration; protected: // Data // ?one_line_short_description_of_data //?data_declaration; private: // Data // ?one_line_short_description_of_data //?data_declaration; // Reserved pointer for future extension //TAny* iReserved; public: // Friend classes //?friend_class_declaration; protected: // Friend classes //?friend_class_declaration; private: // Friend classes //?friend_class_declaration; }; #endif // MTPBKICONID_H // End of File
[ "none@none" ]
[ [ [ 1, 186 ] ] ]
089db61bc659154783ad82c4b5853af6260fc973
2b80036db6f86012afcc7bc55431355fc3234058
/src/contrib/mp3decoder/Layer3Decoder.cpp
f6f3a281736b895bb6a5e8bb3cb9f442753bd750
[ "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
UTF-8
C++
false
false
74,189
cpp
#include <math.h> #include "Layer3Decoder.h" static unsigned long g_huffman_table_1[7] = { 0x00020001, 0x00000000, 0x00020001, 0x00000010, 0x00020001, 0x00000001, 0x00000011, }; static unsigned long g_huffman_table_2[17] = { 0x00020001, 0x00000000, 0x00040001, 0x00020001, 0x00000010, 0x00000001, 0x00020001, 0x00000011, 0x00040001, 0x00020001, 0x00000020, 0x00000021, 0x00020001, 0x00000012, 0x00020001, 0x00000002, 0x00000022, }; static unsigned long g_huffman_table_3[17] = { 0x00040001, 0x00020001, 0x00000000, 0x00000001, 0x00020001, 0x00000011, 0x00020001, 0x00000010, 0x00040001, 0x00020001, 0x00000020, 0x00000021, 0x00020001, 0x00000012, 0x00020001, 0x00000002, 0x00000022, }; static unsigned long g_huffman_table_5[31] = { 0x00020001, 0x00000000, 0x00040001, 0x00020001, 0x00000010, 0x00000001, 0x00020001, 0x00000011, 0x00080001, 0x00040001, 0x00020001, 0x00000020, 0x00000002, 0x00020001, 0x00000021, 0x00000012, 0x00080001, 0x00040001, 0x00020001, 0x00000022, 0x00000030, 0x00020001, 0x00000003, 0x00000013, 0x00020001, 0x00000031, 0x00020001, 0x00000032, 0x00020001, 0x00000023, 0x00000033, }; static unsigned long g_huffman_table_6[31] = { 0x00060001, 0x00040001, 0x00020001, 0x00000000, 0x00000010, 0x00000011, 0x00060001, 0x00020001, 0x00000001, 0x00020001, 0x00000020, 0x00000021, 0x00060001, 0x00020001, 0x00000012, 0x00020001, 0x00000002, 0x00000022, 0x00040001, 0x00020001, 0x00000031, 0x00000013, 0x00040001, 0x00020001, 0x00000030, 0x00000032, 0x00020001, 0x00000023, 0x00020001, 0x00000003, 0x00000033, }; static unsigned long g_huffman_table_7[71] = { 0x00020001, 0x00000000, 0x00040001, 0x00020001, 0x00000010, 0x00000001, 0x00080001, 0x00020001, 0x00000011, 0x00040001, 0x00020001, 0x00000020, 0x00000002, 0x00000021, 0x00120001, 0x00060001, 0x00020001, 0x00000012, 0x00020001, 0x00000022, 0x00000030, 0x00040001, 0x00020001, 0x00000031, 0x00000013, 0x00040001, 0x00020001, 0x00000003, 0x00000032, 0x00020001, 0x00000023, 0x00000004, 0x000a0001, 0x00040001, 0x00020001, 0x00000040, 0x00000041, 0x00020001, 0x00000014, 0x00020001, 0x00000042, 0x00000024, 0x000c0001, 0x00060001, 0x00040001, 0x00020001, 0x00000033, 0x00000043, 0x00000050, 0x00040001, 0x00020001, 0x00000034, 0x00000005, 0x00000051, 0x00060001, 0x00020001, 0x00000015, 0x00020001, 0x00000052, 0x00000025, 0x00040001, 0x00020001, 0x00000044, 0x00000035, 0x00040001, 0x00020001, 0x00000053, 0x00000054, 0x00020001, 0x00000045, 0x00000055, }; static unsigned long g_huffman_table_8[71] = { 0x00060001, 0x00020001, 0x00000000, 0x00020001, 0x00000010, 0x00000001, 0x00020001, 0x00000011, 0x00040001, 0x00020001, 0x00000021, 0x00000012, 0x000e0001, 0x00040001, 0x00020001, 0x00000020, 0x00000002, 0x00020001, 0x00000022, 0x00040001, 0x00020001, 0x00000030, 0x00000003, 0x00020001, 0x00000031, 0x00000013, 0x000e0001, 0x00080001, 0x00040001, 0x00020001, 0x00000032, 0x00000023, 0x00020001, 0x00000040, 0x00000004, 0x00020001, 0x00000041, 0x00020001, 0x00000014, 0x00000042, 0x000c0001, 0x00060001, 0x00020001, 0x00000024, 0x00020001, 0x00000033, 0x00000050, 0x00040001, 0x00020001, 0x00000043, 0x00000034, 0x00000051, 0x00060001, 0x00020001, 0x00000015, 0x00020001, 0x00000005, 0x00000052, 0x00060001, 0x00020001, 0x00000025, 0x00020001, 0x00000044, 0x00000035, 0x00020001, 0x00000053, 0x00020001, 0x00000045, 0x00020001, 0x00000054, 0x00000055, }; static unsigned long g_huffman_table_9[71] = { 0x00080001, 0x00040001, 0x00020001, 0x00000000, 0x00000010, 0x00020001, 0x00000001, 0x00000011, 0x000a0001, 0x00040001, 0x00020001, 0x00000020, 0x00000021, 0x00020001, 0x00000012, 0x00020001, 0x00000002, 0x00000022, 0x000c0001, 0x00060001, 0x00040001, 0x00020001, 0x00000030, 0x00000003, 0x00000031, 0x00020001, 0x00000013, 0x00020001, 0x00000032, 0x00000023, 0x000c0001, 0x00040001, 0x00020001, 0x00000041, 0x00000014, 0x00040001, 0x00020001, 0x00000040, 0x00000033, 0x00020001, 0x00000042, 0x00000024, 0x000a0001, 0x00060001, 0x00040001, 0x00020001, 0x00000004, 0x00000050, 0x00000043, 0x00020001, 0x00000034, 0x00000051, 0x00080001, 0x00040001, 0x00020001, 0x00000015, 0x00000052, 0x00020001, 0x00000025, 0x00000044, 0x00060001, 0x00040001, 0x00020001, 0x00000005, 0x00000054, 0x00000053, 0x00020001, 0x00000035, 0x00020001, 0x00000045, 0x00000055, }; static unsigned long g_huffman_table_10[127] = { 0x00020001, 0x00000000, 0x00040001, 0x00020001, 0x00000010, 0x00000001, 0x000a0001, 0x00020001, 0x00000011, 0x00040001, 0x00020001, 0x00000020, 0x00000002, 0x00020001, 0x00000021, 0x00000012, 0x001c0001, 0x00080001, 0x00040001, 0x00020001, 0x00000022, 0x00000030, 0x00020001, 0x00000031, 0x00000013, 0x00080001, 0x00040001, 0x00020001, 0x00000003, 0x00000032, 0x00020001, 0x00000023, 0x00000040, 0x00040001, 0x00020001, 0x00000041, 0x00000014, 0x00040001, 0x00020001, 0x00000004, 0x00000033, 0x00020001, 0x00000042, 0x00000024, 0x001c0001, 0x000a0001, 0x00060001, 0x00040001, 0x00020001, 0x00000050, 0x00000005, 0x00000060, 0x00020001, 0x00000061, 0x00000016, 0x000c0001, 0x00060001, 0x00040001, 0x00020001, 0x00000043, 0x00000034, 0x00000051, 0x00020001, 0x00000015, 0x00020001, 0x00000052, 0x00000025, 0x00040001, 0x00020001, 0x00000026, 0x00000036, 0x00000071, 0x00140001, 0x00080001, 0x00020001, 0x00000017, 0x00040001, 0x00020001, 0x00000044, 0x00000053, 0x00000006, 0x00060001, 0x00040001, 0x00020001, 0x00000035, 0x00000045, 0x00000062, 0x00020001, 0x00000070, 0x00020001, 0x00000007, 0x00000064, 0x000e0001, 0x00040001, 0x00020001, 0x00000072, 0x00000027, 0x00060001, 0x00020001, 0x00000063, 0x00020001, 0x00000054, 0x00000055, 0x00020001, 0x00000046, 0x00000073, 0x00080001, 0x00040001, 0x00020001, 0x00000037, 0x00000065, 0x00020001, 0x00000056, 0x00000074, 0x00060001, 0x00020001, 0x00000047, 0x00020001, 0x00000066, 0x00000075, 0x00040001, 0x00020001, 0x00000057, 0x00000076, 0x00020001, 0x00000067, 0x00000077, }; static unsigned long g_huffman_table_11[127] = { 0x00060001, 0x00020001, 0x00000000, 0x00020001, 0x00000010, 0x00000001, 0x00080001, 0x00020001, 0x00000011, 0x00040001, 0x00020001, 0x00000020, 0x00000002, 0x00000012, 0x00180001, 0x00080001, 0x00020001, 0x00000021, 0x00020001, 0x00000022, 0x00020001, 0x00000030, 0x00000003, 0x00040001, 0x00020001, 0x00000031, 0x00000013, 0x00040001, 0x00020001, 0x00000032, 0x00000023, 0x00040001, 0x00020001, 0x00000040, 0x00000004, 0x00020001, 0x00000041, 0x00000014, 0x001e0001, 0x00100001, 0x000a0001, 0x00040001, 0x00020001, 0x00000042, 0x00000024, 0x00040001, 0x00020001, 0x00000033, 0x00000043, 0x00000050, 0x00040001, 0x00020001, 0x00000034, 0x00000051, 0x00000061, 0x00060001, 0x00020001, 0x00000016, 0x00020001, 0x00000006, 0x00000026, 0x00020001, 0x00000062, 0x00020001, 0x00000015, 0x00020001, 0x00000005, 0x00000052, 0x00100001, 0x000a0001, 0x00060001, 0x00040001, 0x00020001, 0x00000025, 0x00000044, 0x00000060, 0x00020001, 0x00000063, 0x00000036, 0x00040001, 0x00020001, 0x00000070, 0x00000017, 0x00000071, 0x00100001, 0x00060001, 0x00040001, 0x00020001, 0x00000007, 0x00000064, 0x00000072, 0x00020001, 0x00000027, 0x00040001, 0x00020001, 0x00000053, 0x00000035, 0x00020001, 0x00000054, 0x00000045, 0x000a0001, 0x00040001, 0x00020001, 0x00000046, 0x00000073, 0x00020001, 0x00000037, 0x00020001, 0x00000065, 0x00000056, 0x000a0001, 0x00060001, 0x00040001, 0x00020001, 0x00000055, 0x00000057, 0x00000074, 0x00020001, 0x00000047, 0x00000066, 0x00040001, 0x00020001, 0x00000075, 0x00000076, 0x00020001, 0x00000067, 0x00000077, }; static unsigned long g_huffman_table_12[127] = { 0x000c0001, 0x00040001, 0x00020001, 0x00000010, 0x00000001, 0x00020001, 0x00000011, 0x00020001, 0x00000000, 0x00020001, 0x00000020, 0x00000002, 0x00100001, 0x00040001, 0x00020001, 0x00000021, 0x00000012, 0x00040001, 0x00020001, 0x00000022, 0x00000031, 0x00020001, 0x00000013, 0x00020001, 0x00000030, 0x00020001, 0x00000003, 0x00000040, 0x001a0001, 0x00080001, 0x00040001, 0x00020001, 0x00000032, 0x00000023, 0x00020001, 0x00000041, 0x00000033, 0x000a0001, 0x00040001, 0x00020001, 0x00000014, 0x00000042, 0x00020001, 0x00000024, 0x00020001, 0x00000004, 0x00000050, 0x00040001, 0x00020001, 0x00000043, 0x00000034, 0x00020001, 0x00000051, 0x00000015, 0x001c0001, 0x000e0001, 0x00080001, 0x00040001, 0x00020001, 0x00000052, 0x00000025, 0x00020001, 0x00000053, 0x00000035, 0x00040001, 0x00020001, 0x00000060, 0x00000016, 0x00000061, 0x00040001, 0x00020001, 0x00000062, 0x00000026, 0x00060001, 0x00040001, 0x00020001, 0x00000005, 0x00000006, 0x00000044, 0x00020001, 0x00000054, 0x00000045, 0x00120001, 0x000a0001, 0x00040001, 0x00020001, 0x00000063, 0x00000036, 0x00040001, 0x00020001, 0x00000070, 0x00000007, 0x00000071, 0x00040001, 0x00020001, 0x00000017, 0x00000064, 0x00020001, 0x00000046, 0x00000072, 0x000a0001, 0x00060001, 0x00020001, 0x00000027, 0x00020001, 0x00000055, 0x00000073, 0x00020001, 0x00000037, 0x00000056, 0x00080001, 0x00040001, 0x00020001, 0x00000065, 0x00000074, 0x00020001, 0x00000047, 0x00000066, 0x00040001, 0x00020001, 0x00000075, 0x00000057, 0x00020001, 0x00000076, 0x00020001, 0x00000067, 0x00000077, }; static unsigned long g_huffman_table_13[511] = { 0x00020001, 0x00000000, 0x00060001, 0x00020001, 0x00000010, 0x00020001, 0x00000001, 0x00000011, 0x001c0001, 0x00080001, 0x00040001, 0x00020001, 0x00000020, 0x00000002, 0x00020001, 0x00000021, 0x00000012, 0x00080001, 0x00040001, 0x00020001, 0x00000022, 0x00000030, 0x00020001, 0x00000003, 0x00000031, 0x00060001, 0x00020001, 0x00000013, 0x00020001, 0x00000032, 0x00000023, 0x00040001, 0x00020001, 0x00000040, 0x00000004, 0x00000041, 0x00460001, 0x001c0001, 0x000e0001, 0x00060001, 0x00020001, 0x00000014, 0x00020001, 0x00000033, 0x00000042, 0x00040001, 0x00020001, 0x00000024, 0x00000050, 0x00020001, 0x00000043, 0x00000034, 0x00040001, 0x00020001, 0x00000051, 0x00000015, 0x00040001, 0x00020001, 0x00000005, 0x00000052, 0x00020001, 0x00000025, 0x00020001, 0x00000044, 0x00000053, 0x000e0001, 0x00080001, 0x00040001, 0x00020001, 0x00000060, 0x00000006, 0x00020001, 0x00000061, 0x00000016, 0x00040001, 0x00020001, 0x00000080, 0x00000008, 0x00000081, 0x00100001, 0x00080001, 0x00040001, 0x00020001, 0x00000035, 0x00000062, 0x00020001, 0x00000026, 0x00000054, 0x00040001, 0x00020001, 0x00000045, 0x00000063, 0x00020001, 0x00000036, 0x00000070, 0x00060001, 0x00040001, 0x00020001, 0x00000007, 0x00000055, 0x00000071, 0x00020001, 0x00000017, 0x00020001, 0x00000027, 0x00000037, 0x00480001, 0x00180001, 0x000c0001, 0x00040001, 0x00020001, 0x00000018, 0x00000082, 0x00020001, 0x00000028, 0x00040001, 0x00020001, 0x00000064, 0x00000046, 0x00000072, 0x00080001, 0x00040001, 0x00020001, 0x00000084, 0x00000048, 0x00020001, 0x00000090, 0x00000009, 0x00020001, 0x00000091, 0x00000019, 0x00180001, 0x000e0001, 0x00080001, 0x00040001, 0x00020001, 0x00000073, 0x00000065, 0x00020001, 0x00000056, 0x00000074, 0x00040001, 0x00020001, 0x00000047, 0x00000066, 0x00000083, 0x00060001, 0x00020001, 0x00000038, 0x00020001, 0x00000075, 0x00000057, 0x00020001, 0x00000092, 0x00000029, 0x000e0001, 0x00080001, 0x00040001, 0x00020001, 0x00000067, 0x00000085, 0x00020001, 0x00000058, 0x00000039, 0x00020001, 0x00000093, 0x00020001, 0x00000049, 0x00000086, 0x00060001, 0x00020001, 0x000000a0, 0x00020001, 0x00000068, 0x0000000a, 0x00020001, 0x000000a1, 0x0000001a, 0x00440001, 0x00180001, 0x000c0001, 0x00040001, 0x00020001, 0x000000a2, 0x0000002a, 0x00040001, 0x00020001, 0x00000095, 0x00000059, 0x00020001, 0x000000a3, 0x0000003a, 0x00080001, 0x00040001, 0x00020001, 0x0000004a, 0x00000096, 0x00020001, 0x000000b0, 0x0000000b, 0x00020001, 0x000000b1, 0x0000001b, 0x00140001, 0x00080001, 0x00020001, 0x000000b2, 0x00040001, 0x00020001, 0x00000076, 0x00000077, 0x00000094, 0x00060001, 0x00040001, 0x00020001, 0x00000087, 0x00000078, 0x000000a4, 0x00040001, 0x00020001, 0x00000069, 0x000000a5, 0x0000002b, 0x000c0001, 0x00060001, 0x00040001, 0x00020001, 0x0000005a, 0x00000088, 0x000000b3, 0x00020001, 0x0000003b, 0x00020001, 0x00000079, 0x000000a6, 0x00060001, 0x00040001, 0x00020001, 0x0000006a, 0x000000b4, 0x000000c0, 0x00040001, 0x00020001, 0x0000000c, 0x00000098, 0x000000c1, 0x003c0001, 0x00160001, 0x000a0001, 0x00060001, 0x00020001, 0x0000001c, 0x00020001, 0x00000089, 0x000000b5, 0x00020001, 0x0000005b, 0x000000c2, 0x00040001, 0x00020001, 0x0000002c, 0x0000003c, 0x00040001, 0x00020001, 0x000000b6, 0x0000006b, 0x00020001, 0x000000c4, 0x0000004c, 0x00100001, 0x00080001, 0x00040001, 0x00020001, 0x000000a8, 0x0000008a, 0x00020001, 0x000000d0, 0x0000000d, 0x00020001, 0x000000d1, 0x00020001, 0x0000004b, 0x00020001, 0x00000097, 0x000000a7, 0x000c0001, 0x00060001, 0x00020001, 0x000000c3, 0x00020001, 0x0000007a, 0x00000099, 0x00040001, 0x00020001, 0x000000c5, 0x0000005c, 0x000000b7, 0x00040001, 0x00020001, 0x0000001d, 0x000000d2, 0x00020001, 0x0000002d, 0x00020001, 0x0000007b, 0x000000d3, 0x00340001, 0x001c0001, 0x000c0001, 0x00040001, 0x00020001, 0x0000003d, 0x000000c6, 0x00040001, 0x00020001, 0x0000006c, 0x000000a9, 0x00020001, 0x0000009a, 0x000000d4, 0x00080001, 0x00040001, 0x00020001, 0x000000b8, 0x0000008b, 0x00020001, 0x0000004d, 0x000000c7, 0x00040001, 0x00020001, 0x0000007c, 0x000000d5, 0x00020001, 0x0000005d, 0x000000e0, 0x000a0001, 0x00040001, 0x00020001, 0x000000e1, 0x0000001e, 0x00040001, 0x00020001, 0x0000000e, 0x0000002e, 0x000000e2, 0x00080001, 0x00040001, 0x00020001, 0x000000e3, 0x0000006d, 0x00020001, 0x0000008c, 0x000000e4, 0x00040001, 0x00020001, 0x000000e5, 0x000000ba, 0x000000f0, 0x00260001, 0x00100001, 0x00040001, 0x00020001, 0x000000f1, 0x0000001f, 0x00060001, 0x00040001, 0x00020001, 0x000000aa, 0x0000009b, 0x000000b9, 0x00020001, 0x0000003e, 0x00020001, 0x000000d6, 0x000000c8, 0x000c0001, 0x00060001, 0x00020001, 0x0000004e, 0x00020001, 0x000000d7, 0x0000007d, 0x00020001, 0x000000ab, 0x00020001, 0x0000005e, 0x000000c9, 0x00060001, 0x00020001, 0x0000000f, 0x00020001, 0x0000009c, 0x0000006e, 0x00020001, 0x000000f2, 0x0000002f, 0x00200001, 0x00100001, 0x00060001, 0x00040001, 0x00020001, 0x000000d8, 0x0000008d, 0x0000003f, 0x00060001, 0x00020001, 0x000000f3, 0x00020001, 0x000000e6, 0x000000ca, 0x00020001, 0x000000f4, 0x0000004f, 0x00080001, 0x00040001, 0x00020001, 0x000000bb, 0x000000ac, 0x00020001, 0x000000e7, 0x000000f5, 0x00040001, 0x00020001, 0x000000d9, 0x0000009d, 0x00020001, 0x0000005f, 0x000000e8, 0x001e0001, 0x000c0001, 0x00060001, 0x00020001, 0x0000006f, 0x00020001, 0x000000f6, 0x000000cb, 0x00040001, 0x00020001, 0x000000bc, 0x000000ad, 0x000000da, 0x00080001, 0x00020001, 0x000000f7, 0x00040001, 0x00020001, 0x0000007e, 0x0000007f, 0x0000008e, 0x00060001, 0x00040001, 0x00020001, 0x0000009e, 0x000000ae, 0x000000cc, 0x00020001, 0x000000f8, 0x0000008f, 0x00120001, 0x00080001, 0x00040001, 0x00020001, 0x000000db, 0x000000bd, 0x00020001, 0x000000ea, 0x000000f9, 0x00040001, 0x00020001, 0x0000009f, 0x000000eb, 0x00020001, 0x000000be, 0x00020001, 0x000000cd, 0x000000fa, 0x000e0001, 0x00040001, 0x00020001, 0x000000dd, 0x000000ec, 0x00060001, 0x00040001, 0x00020001, 0x000000e9, 0x000000af, 0x000000dc, 0x00020001, 0x000000ce, 0x000000fb, 0x00080001, 0x00040001, 0x00020001, 0x000000bf, 0x000000de, 0x00020001, 0x000000cf, 0x000000ee, 0x00040001, 0x00020001, 0x000000df, 0x000000ef, 0x00020001, 0x000000ff, 0x00020001, 0x000000ed, 0x00020001, 0x000000fd, 0x00020001, 0x000000fc, 0x000000fe, }; static unsigned long g_huffman_table_15[511] = { 0x00100001, 0x00060001, 0x00020001, 0x00000000, 0x00020001, 0x00000010, 0x00000001, 0x00020001, 0x00000011, 0x00040001, 0x00020001, 0x00000020, 0x00000002, 0x00020001, 0x00000021, 0x00000012, 0x00320001, 0x00100001, 0x00060001, 0x00020001, 0x00000022, 0x00020001, 0x00000030, 0x00000031, 0x00060001, 0x00020001, 0x00000013, 0x00020001, 0x00000003, 0x00000040, 0x00020001, 0x00000032, 0x00000023, 0x000e0001, 0x00060001, 0x00040001, 0x00020001, 0x00000004, 0x00000014, 0x00000041, 0x00040001, 0x00020001, 0x00000033, 0x00000042, 0x00020001, 0x00000024, 0x00000043, 0x000a0001, 0x00060001, 0x00020001, 0x00000034, 0x00020001, 0x00000050, 0x00000005, 0x00020001, 0x00000051, 0x00000015, 0x00040001, 0x00020001, 0x00000052, 0x00000025, 0x00040001, 0x00020001, 0x00000044, 0x00000053, 0x00000061, 0x005a0001, 0x00240001, 0x00120001, 0x000a0001, 0x00060001, 0x00020001, 0x00000035, 0x00020001, 0x00000060, 0x00000006, 0x00020001, 0x00000016, 0x00000062, 0x00040001, 0x00020001, 0x00000026, 0x00000054, 0x00020001, 0x00000045, 0x00000063, 0x000a0001, 0x00060001, 0x00020001, 0x00000036, 0x00020001, 0x00000070, 0x00000007, 0x00020001, 0x00000071, 0x00000055, 0x00040001, 0x00020001, 0x00000017, 0x00000064, 0x00020001, 0x00000072, 0x00000027, 0x00180001, 0x00100001, 0x00080001, 0x00040001, 0x00020001, 0x00000046, 0x00000073, 0x00020001, 0x00000037, 0x00000065, 0x00040001, 0x00020001, 0x00000056, 0x00000080, 0x00020001, 0x00000008, 0x00000074, 0x00040001, 0x00020001, 0x00000081, 0x00000018, 0x00020001, 0x00000082, 0x00000028, 0x00100001, 0x00080001, 0x00040001, 0x00020001, 0x00000047, 0x00000066, 0x00020001, 0x00000083, 0x00000038, 0x00040001, 0x00020001, 0x00000075, 0x00000057, 0x00020001, 0x00000084, 0x00000048, 0x00060001, 0x00040001, 0x00020001, 0x00000090, 0x00000019, 0x00000091, 0x00040001, 0x00020001, 0x00000092, 0x00000076, 0x00020001, 0x00000067, 0x00000029, 0x005c0001, 0x00240001, 0x00120001, 0x000a0001, 0x00040001, 0x00020001, 0x00000085, 0x00000058, 0x00040001, 0x00020001, 0x00000009, 0x00000077, 0x00000093, 0x00040001, 0x00020001, 0x00000039, 0x00000094, 0x00020001, 0x00000049, 0x00000086, 0x000a0001, 0x00060001, 0x00020001, 0x00000068, 0x00020001, 0x000000a0, 0x0000000a, 0x00020001, 0x000000a1, 0x0000001a, 0x00040001, 0x00020001, 0x000000a2, 0x0000002a, 0x00020001, 0x00000095, 0x00000059, 0x001a0001, 0x000e0001, 0x00060001, 0x00020001, 0x000000a3, 0x00020001, 0x0000003a, 0x00000087, 0x00040001, 0x00020001, 0x00000078, 0x000000a4, 0x00020001, 0x0000004a, 0x00000096, 0x00060001, 0x00040001, 0x00020001, 0x00000069, 0x000000b0, 0x000000b1, 0x00040001, 0x00020001, 0x0000001b, 0x000000a5, 0x000000b2, 0x000e0001, 0x00080001, 0x00040001, 0x00020001, 0x0000005a, 0x0000002b, 0x00020001, 0x00000088, 0x00000097, 0x00020001, 0x000000b3, 0x00020001, 0x00000079, 0x0000003b, 0x00080001, 0x00040001, 0x00020001, 0x0000006a, 0x000000b4, 0x00020001, 0x0000004b, 0x000000c1, 0x00040001, 0x00020001, 0x00000098, 0x00000089, 0x00020001, 0x0000001c, 0x000000b5, 0x00500001, 0x00220001, 0x00100001, 0x00060001, 0x00040001, 0x00020001, 0x0000005b, 0x0000002c, 0x000000c2, 0x00060001, 0x00040001, 0x00020001, 0x0000000b, 0x000000c0, 0x000000a6, 0x00020001, 0x000000a7, 0x0000007a, 0x000a0001, 0x00040001, 0x00020001, 0x000000c3, 0x0000003c, 0x00040001, 0x00020001, 0x0000000c, 0x00000099, 0x000000b6, 0x00040001, 0x00020001, 0x0000006b, 0x000000c4, 0x00020001, 0x0000004c, 0x000000a8, 0x00140001, 0x000a0001, 0x00040001, 0x00020001, 0x0000008a, 0x000000c5, 0x00040001, 0x00020001, 0x000000d0, 0x0000005c, 0x000000d1, 0x00040001, 0x00020001, 0x000000b7, 0x0000007b, 0x00020001, 0x0000001d, 0x00020001, 0x0000000d, 0x0000002d, 0x000c0001, 0x00040001, 0x00020001, 0x000000d2, 0x000000d3, 0x00040001, 0x00020001, 0x0000003d, 0x000000c6, 0x00020001, 0x0000006c, 0x000000a9, 0x00060001, 0x00040001, 0x00020001, 0x0000009a, 0x000000b8, 0x000000d4, 0x00040001, 0x00020001, 0x0000008b, 0x0000004d, 0x00020001, 0x000000c7, 0x0000007c, 0x00440001, 0x00220001, 0x00120001, 0x000a0001, 0x00040001, 0x00020001, 0x000000d5, 0x0000005d, 0x00040001, 0x00020001, 0x000000e0, 0x0000000e, 0x000000e1, 0x00040001, 0x00020001, 0x0000001e, 0x000000e2, 0x00020001, 0x000000aa, 0x0000002e, 0x00080001, 0x00040001, 0x00020001, 0x000000b9, 0x0000009b, 0x00020001, 0x000000e3, 0x000000d6, 0x00040001, 0x00020001, 0x0000006d, 0x0000003e, 0x00020001, 0x000000c8, 0x0000008c, 0x00100001, 0x00080001, 0x00040001, 0x00020001, 0x000000e4, 0x0000004e, 0x00020001, 0x000000d7, 0x0000007d, 0x00040001, 0x00020001, 0x000000e5, 0x000000ba, 0x00020001, 0x000000ab, 0x0000005e, 0x00080001, 0x00040001, 0x00020001, 0x000000c9, 0x0000009c, 0x00020001, 0x000000f1, 0x0000001f, 0x00060001, 0x00040001, 0x00020001, 0x000000f0, 0x0000006e, 0x000000f2, 0x00020001, 0x0000002f, 0x000000e6, 0x00260001, 0x00120001, 0x00080001, 0x00040001, 0x00020001, 0x000000d8, 0x000000f3, 0x00020001, 0x0000003f, 0x000000f4, 0x00060001, 0x00020001, 0x0000004f, 0x00020001, 0x0000008d, 0x000000d9, 0x00020001, 0x000000bb, 0x000000ca, 0x00080001, 0x00040001, 0x00020001, 0x000000ac, 0x000000e7, 0x00020001, 0x0000007e, 0x000000f5, 0x00080001, 0x00040001, 0x00020001, 0x0000009d, 0x0000005f, 0x00020001, 0x000000e8, 0x0000008e, 0x00020001, 0x000000f6, 0x000000cb, 0x00220001, 0x00120001, 0x000a0001, 0x00060001, 0x00040001, 0x00020001, 0x0000000f, 0x000000ae, 0x0000006f, 0x00020001, 0x000000bc, 0x000000da, 0x00040001, 0x00020001, 0x000000ad, 0x000000f7, 0x00020001, 0x0000007f, 0x000000e9, 0x00080001, 0x00040001, 0x00020001, 0x0000009e, 0x000000cc, 0x00020001, 0x000000f8, 0x0000008f, 0x00040001, 0x00020001, 0x000000db, 0x000000bd, 0x00020001, 0x000000ea, 0x000000f9, 0x00100001, 0x00080001, 0x00040001, 0x00020001, 0x0000009f, 0x000000dc, 0x00020001, 0x000000cd, 0x000000eb, 0x00040001, 0x00020001, 0x000000be, 0x000000fa, 0x00020001, 0x000000af, 0x000000dd, 0x000e0001, 0x00060001, 0x00040001, 0x00020001, 0x000000ec, 0x000000ce, 0x000000fb, 0x00040001, 0x00020001, 0x000000bf, 0x000000ed, 0x00020001, 0x000000de, 0x000000fc, 0x00060001, 0x00040001, 0x00020001, 0x000000cf, 0x000000fd, 0x000000ee, 0x00040001, 0x00020001, 0x000000df, 0x000000fe, 0x00020001, 0x000000ef, 0x000000ff, }; static unsigned long g_huffman_table_16[511] = { 0x00020001, 0x00000000, 0x00060001, 0x00020001, 0x00000010, 0x00020001, 0x00000001, 0x00000011, 0x002a0001, 0x00080001, 0x00040001, 0x00020001, 0x00000020, 0x00000002, 0x00020001, 0x00000021, 0x00000012, 0x000a0001, 0x00060001, 0x00020001, 0x00000022, 0x00020001, 0x00000030, 0x00000003, 0x00020001, 0x00000031, 0x00000013, 0x000a0001, 0x00040001, 0x00020001, 0x00000032, 0x00000023, 0x00040001, 0x00020001, 0x00000040, 0x00000004, 0x00000041, 0x00060001, 0x00020001, 0x00000014, 0x00020001, 0x00000033, 0x00000042, 0x00040001, 0x00020001, 0x00000024, 0x00000050, 0x00020001, 0x00000043, 0x00000034, 0x008a0001, 0x00280001, 0x00100001, 0x00060001, 0x00040001, 0x00020001, 0x00000005, 0x00000015, 0x00000051, 0x00040001, 0x00020001, 0x00000052, 0x00000025, 0x00040001, 0x00020001, 0x00000044, 0x00000035, 0x00000053, 0x000a0001, 0x00060001, 0x00040001, 0x00020001, 0x00000060, 0x00000006, 0x00000061, 0x00020001, 0x00000016, 0x00000062, 0x00080001, 0x00040001, 0x00020001, 0x00000026, 0x00000054, 0x00020001, 0x00000045, 0x00000063, 0x00040001, 0x00020001, 0x00000036, 0x00000070, 0x00000071, 0x00280001, 0x00120001, 0x00080001, 0x00020001, 0x00000017, 0x00020001, 0x00000007, 0x00020001, 0x00000055, 0x00000064, 0x00040001, 0x00020001, 0x00000072, 0x00000027, 0x00040001, 0x00020001, 0x00000046, 0x00000065, 0x00000073, 0x000a0001, 0x00060001, 0x00020001, 0x00000037, 0x00020001, 0x00000056, 0x00000008, 0x00020001, 0x00000080, 0x00000081, 0x00060001, 0x00020001, 0x00000018, 0x00020001, 0x00000074, 0x00000047, 0x00020001, 0x00000082, 0x00020001, 0x00000028, 0x00000066, 0x00180001, 0x000e0001, 0x00080001, 0x00040001, 0x00020001, 0x00000083, 0x00000038, 0x00020001, 0x00000075, 0x00000084, 0x00040001, 0x00020001, 0x00000048, 0x00000090, 0x00000091, 0x00060001, 0x00020001, 0x00000019, 0x00020001, 0x00000009, 0x00000076, 0x00020001, 0x00000092, 0x00000029, 0x000e0001, 0x00080001, 0x00040001, 0x00020001, 0x00000085, 0x00000058, 0x00020001, 0x00000093, 0x00000039, 0x00040001, 0x00020001, 0x000000a0, 0x0000000a, 0x0000001a, 0x00080001, 0x00020001, 0x000000a2, 0x00020001, 0x00000067, 0x00020001, 0x00000057, 0x00000049, 0x00060001, 0x00020001, 0x00000094, 0x00020001, 0x00000077, 0x00000086, 0x00020001, 0x000000a1, 0x00020001, 0x00000068, 0x00000095, 0x00dc0001, 0x007e0001, 0x00320001, 0x001a0001, 0x000c0001, 0x00060001, 0x00020001, 0x0000002a, 0x00020001, 0x00000059, 0x0000003a, 0x00020001, 0x000000a3, 0x00020001, 0x00000087, 0x00000078, 0x00080001, 0x00040001, 0x00020001, 0x000000a4, 0x0000004a, 0x00020001, 0x00000096, 0x00000069, 0x00040001, 0x00020001, 0x000000b0, 0x0000000b, 0x000000b1, 0x000a0001, 0x00040001, 0x00020001, 0x0000001b, 0x000000b2, 0x00020001, 0x0000002b, 0x00020001, 0x000000a5, 0x0000005a, 0x00060001, 0x00020001, 0x000000b3, 0x00020001, 0x000000a6, 0x0000006a, 0x00040001, 0x00020001, 0x000000b4, 0x0000004b, 0x00020001, 0x0000000c, 0x000000c1, 0x001e0001, 0x000e0001, 0x00060001, 0x00040001, 0x00020001, 0x000000b5, 0x000000c2, 0x0000002c, 0x00040001, 0x00020001, 0x000000a7, 0x000000c3, 0x00020001, 0x0000006b, 0x000000c4, 0x00080001, 0x00020001, 0x0000001d, 0x00040001, 0x00020001, 0x00000088, 0x00000097, 0x0000003b, 0x00040001, 0x00020001, 0x000000d1, 0x000000d2, 0x00020001, 0x0000002d, 0x000000d3, 0x00120001, 0x00060001, 0x00040001, 0x00020001, 0x0000001e, 0x0000002e, 0x000000e2, 0x00060001, 0x00040001, 0x00020001, 0x00000079, 0x00000098, 0x000000c0, 0x00020001, 0x0000001c, 0x00020001, 0x00000089, 0x0000005b, 0x000e0001, 0x00060001, 0x00020001, 0x0000003c, 0x00020001, 0x0000007a, 0x000000b6, 0x00040001, 0x00020001, 0x0000004c, 0x00000099, 0x00020001, 0x000000a8, 0x0000008a, 0x00060001, 0x00020001, 0x0000000d, 0x00020001, 0x000000c5, 0x0000005c, 0x00040001, 0x00020001, 0x0000003d, 0x000000c6, 0x00020001, 0x0000006c, 0x0000009a, 0x00580001, 0x00560001, 0x00240001, 0x00100001, 0x00080001, 0x00040001, 0x00020001, 0x0000008b, 0x0000004d, 0x00020001, 0x000000c7, 0x0000007c, 0x00040001, 0x00020001, 0x000000d5, 0x0000005d, 0x00020001, 0x000000e0, 0x0000000e, 0x00080001, 0x00020001, 0x000000e3, 0x00040001, 0x00020001, 0x000000d0, 0x000000b7, 0x0000007b, 0x00060001, 0x00040001, 0x00020001, 0x000000a9, 0x000000b8, 0x000000d4, 0x00020001, 0x000000e1, 0x00020001, 0x000000aa, 0x000000b9, 0x00180001, 0x000a0001, 0x00060001, 0x00040001, 0x00020001, 0x0000009b, 0x000000d6, 0x0000006d, 0x00020001, 0x0000003e, 0x000000c8, 0x00060001, 0x00040001, 0x00020001, 0x0000008c, 0x000000e4, 0x0000004e, 0x00040001, 0x00020001, 0x000000d7, 0x000000e5, 0x00020001, 0x000000ba, 0x000000ab, 0x000c0001, 0x00040001, 0x00020001, 0x0000009c, 0x000000e6, 0x00040001, 0x00020001, 0x0000006e, 0x000000d8, 0x00020001, 0x0000008d, 0x000000bb, 0x00080001, 0x00040001, 0x00020001, 0x000000e7, 0x0000009d, 0x00020001, 0x000000e8, 0x0000008e, 0x00040001, 0x00020001, 0x000000cb, 0x000000bc, 0x0000009e, 0x000000f1, 0x00020001, 0x0000001f, 0x00020001, 0x0000000f, 0x0000002f, 0x00420001, 0x00380001, 0x00020001, 0x000000f2, 0x00340001, 0x00320001, 0x00140001, 0x00080001, 0x00020001, 0x000000bd, 0x00020001, 0x0000005e, 0x00020001, 0x0000007d, 0x000000c9, 0x00060001, 0x00020001, 0x000000ca, 0x00020001, 0x000000ac, 0x0000007e, 0x00040001, 0x00020001, 0x000000da, 0x000000ad, 0x000000cc, 0x000a0001, 0x00060001, 0x00020001, 0x000000ae, 0x00020001, 0x000000db, 0x000000dc, 0x00020001, 0x000000cd, 0x000000be, 0x00060001, 0x00040001, 0x00020001, 0x000000eb, 0x000000ed, 0x000000ee, 0x00060001, 0x00040001, 0x00020001, 0x000000d9, 0x000000ea, 0x000000e9, 0x00020001, 0x000000de, 0x00040001, 0x00020001, 0x000000dd, 0x000000ec, 0x000000ce, 0x0000003f, 0x000000f0, 0x00040001, 0x00020001, 0x000000f3, 0x000000f4, 0x00020001, 0x0000004f, 0x00020001, 0x000000f5, 0x0000005f, 0x000a0001, 0x00020001, 0x000000ff, 0x00040001, 0x00020001, 0x000000f6, 0x0000006f, 0x00020001, 0x000000f7, 0x0000007f, 0x000c0001, 0x00060001, 0x00020001, 0x0000008f, 0x00020001, 0x000000f8, 0x000000f9, 0x00040001, 0x00020001, 0x0000009f, 0x000000fa, 0x000000af, 0x00080001, 0x00040001, 0x00020001, 0x000000fb, 0x000000bf, 0x00020001, 0x000000fc, 0x000000cf, 0x00040001, 0x00020001, 0x000000fd, 0x000000df, 0x00020001, 0x000000fe, 0x000000ef, }; static unsigned long g_huffman_table_24[512] = { 0x003c0001, 0x00080001, 0x00040001, 0x00020001, 0x00000000, 0x00000010, 0x00020001, 0x00000001, 0x00000011, 0x000e0001, 0x00060001, 0x00040001, 0x00020001, 0x00000020, 0x00000002, 0x00000021, 0x00020001, 0x00000012, 0x00020001, 0x00000022, 0x00020001, 0x00000030, 0x00000003, 0x000e0001, 0x00040001, 0x00020001, 0x00000031, 0x00000013, 0x00040001, 0x00020001, 0x00000032, 0x00000023, 0x00040001, 0x00020001, 0x00000040, 0x00000004, 0x00000041, 0x00080001, 0x00040001, 0x00020001, 0x00000014, 0x00000033, 0x00020001, 0x00000042, 0x00000024, 0x00060001, 0x00040001, 0x00020001, 0x00000043, 0x00000034, 0x00000051, 0x00060001, 0x00040001, 0x00020001, 0x00000050, 0x00000005, 0x00000015, 0x00020001, 0x00000052, 0x00000025, 0x00fa0001, 0x00620001, 0x00220001, 0x00120001, 0x000a0001, 0x00040001, 0x00020001, 0x00000044, 0x00000053, 0x00020001, 0x00000035, 0x00020001, 0x00000060, 0x00000006, 0x00040001, 0x00020001, 0x00000061, 0x00000016, 0x00020001, 0x00000062, 0x00000026, 0x00080001, 0x00040001, 0x00020001, 0x00000054, 0x00000045, 0x00020001, 0x00000063, 0x00000036, 0x00040001, 0x00020001, 0x00000071, 0x00000055, 0x00020001, 0x00000064, 0x00000046, 0x00200001, 0x000e0001, 0x00060001, 0x00020001, 0x00000072, 0x00020001, 0x00000027, 0x00000037, 0x00020001, 0x00000073, 0x00040001, 0x00020001, 0x00000070, 0x00000007, 0x00000017, 0x000a0001, 0x00040001, 0x00020001, 0x00000065, 0x00000056, 0x00040001, 0x00020001, 0x00000080, 0x00000008, 0x00000081, 0x00040001, 0x00020001, 0x00000074, 0x00000047, 0x00020001, 0x00000018, 0x00000082, 0x00100001, 0x00080001, 0x00040001, 0x00020001, 0x00000028, 0x00000066, 0x00020001, 0x00000083, 0x00000038, 0x00040001, 0x00020001, 0x00000075, 0x00000057, 0x00020001, 0x00000084, 0x00000048, 0x00080001, 0x00040001, 0x00020001, 0x00000091, 0x00000019, 0x00020001, 0x00000092, 0x00000076, 0x00040001, 0x00020001, 0x00000067, 0x00000029, 0x00020001, 0x00000085, 0x00000058, 0x005c0001, 0x00220001, 0x00100001, 0x00080001, 0x00040001, 0x00020001, 0x00000093, 0x00000039, 0x00020001, 0x00000094, 0x00000049, 0x00040001, 0x00020001, 0x00000077, 0x00000086, 0x00020001, 0x00000068, 0x000000a1, 0x00080001, 0x00040001, 0x00020001, 0x000000a2, 0x0000002a, 0x00020001, 0x00000095, 0x00000059, 0x00040001, 0x00020001, 0x000000a3, 0x0000003a, 0x00020001, 0x00000087, 0x00020001, 0x00000078, 0x0000004a, 0x00160001, 0x000c0001, 0x00040001, 0x00020001, 0x000000a4, 0x00000096, 0x00040001, 0x00020001, 0x00000069, 0x000000b1, 0x00020001, 0x0000001b, 0x000000a5, 0x00060001, 0x00020001, 0x000000b2, 0x00020001, 0x0000005a, 0x0000002b, 0x00020001, 0x00000088, 0x000000b3, 0x00100001, 0x000a0001, 0x00060001, 0x00020001, 0x00000090, 0x00020001, 0x00000009, 0x000000a0, 0x00020001, 0x00000097, 0x00000079, 0x00040001, 0x00020001, 0x000000a6, 0x0000006a, 0x000000b4, 0x000c0001, 0x00060001, 0x00020001, 0x0000001a, 0x00020001, 0x0000000a, 0x000000b0, 0x00020001, 0x0000003b, 0x00020001, 0x0000000b, 0x000000c0, 0x00040001, 0x00020001, 0x0000004b, 0x000000c1, 0x00020001, 0x00000098, 0x00000089, 0x00430001, 0x00220001, 0x00100001, 0x00080001, 0x00040001, 0x00020001, 0x0000001c, 0x000000b5, 0x00020001, 0x0000005b, 0x000000c2, 0x00040001, 0x00020001, 0x0000002c, 0x000000a7, 0x00020001, 0x0000007a, 0x000000c3, 0x000a0001, 0x00060001, 0x00020001, 0x0000003c, 0x00020001, 0x0000000c, 0x000000d0, 0x00020001, 0x000000b6, 0x0000006b, 0x00040001, 0x00020001, 0x000000c4, 0x0000004c, 0x00020001, 0x00000099, 0x000000a8, 0x00100001, 0x00080001, 0x00040001, 0x00020001, 0x0000008a, 0x000000c5, 0x00020001, 0x0000005c, 0x000000d1, 0x00040001, 0x00020001, 0x000000b7, 0x0000007b, 0x00020001, 0x0000001d, 0x000000d2, 0x00090001, 0x00040001, 0x00020001, 0x0000002d, 0x000000d3, 0x00020001, 0x0000003d, 0x000000c6, 0x005500fa, 0x00040001, 0x00020001, 0x0000006c, 0x000000a9, 0x00020001, 0x0000009a, 0x000000d4, 0x00200001, 0x00100001, 0x00080001, 0x00040001, 0x00020001, 0x000000b8, 0x0000008b, 0x00020001, 0x0000004d, 0x000000c7, 0x00040001, 0x00020001, 0x0000007c, 0x000000d5, 0x00020001, 0x0000005d, 0x000000e1, 0x00080001, 0x00040001, 0x00020001, 0x0000001e, 0x000000e2, 0x00020001, 0x000000aa, 0x000000b9, 0x00040001, 0x00020001, 0x0000009b, 0x000000e3, 0x00020001, 0x000000d6, 0x0000006d, 0x00140001, 0x000a0001, 0x00060001, 0x00020001, 0x0000003e, 0x00020001, 0x0000002e, 0x0000004e, 0x00020001, 0x000000c8, 0x0000008c, 0x00040001, 0x00020001, 0x000000e4, 0x000000d7, 0x00040001, 0x00020001, 0x0000007d, 0x000000ab, 0x000000e5, 0x000a0001, 0x00040001, 0x00020001, 0x000000ba, 0x0000005e, 0x00020001, 0x000000c9, 0x00020001, 0x0000009c, 0x0000006e, 0x00080001, 0x00020001, 0x000000e6, 0x00020001, 0x0000000d, 0x00020001, 0x000000e0, 0x0000000e, 0x00040001, 0x00020001, 0x000000d8, 0x0000008d, 0x00020001, 0x000000bb, 0x000000ca, 0x004a0001, 0x00020001, 0x000000ff, 0x00400001, 0x003a0001, 0x00200001, 0x00100001, 0x00080001, 0x00040001, 0x00020001, 0x000000ac, 0x000000e7, 0x00020001, 0x0000007e, 0x000000d9, 0x00040001, 0x00020001, 0x0000009d, 0x000000e8, 0x00020001, 0x0000008e, 0x000000cb, 0x00080001, 0x00040001, 0x00020001, 0x000000bc, 0x000000da, 0x00020001, 0x000000ad, 0x000000e9, 0x00040001, 0x00020001, 0x0000009e, 0x000000cc, 0x00020001, 0x000000db, 0x000000bd, 0x00100001, 0x00080001, 0x00040001, 0x00020001, 0x000000ea, 0x000000ae, 0x00020001, 0x000000dc, 0x000000cd, 0x00040001, 0x00020001, 0x000000eb, 0x000000be, 0x00020001, 0x000000dd, 0x000000ec, 0x00080001, 0x00040001, 0x00020001, 0x000000ce, 0x000000ed, 0x00020001, 0x000000de, 0x000000ee, 0x0000000f, 0x00040001, 0x00020001, 0x000000f0, 0x0000001f, 0x000000f1, 0x00040001, 0x00020001, 0x000000f2, 0x0000002f, 0x00020001, 0x000000f3, 0x0000003f, 0x00120001, 0x00080001, 0x00040001, 0x00020001, 0x000000f4, 0x0000004f, 0x00020001, 0x000000f5, 0x0000005f, 0x00040001, 0x00020001, 0x000000f6, 0x0000006f, 0x00020001, 0x000000f7, 0x00020001, 0x0000007f, 0x0000008f, 0x000a0001, 0x00040001, 0x00020001, 0x000000f8, 0x000000f9, 0x00040001, 0x00020001, 0x0000009f, 0x000000af, 0x000000fa, 0x00080001, 0x00040001, 0x00020001, 0x000000fb, 0x000000bf, 0x00020001, 0x000000fc, 0x000000cf, 0x00040001, 0x00020001, 0x000000fd, 0x000000df, 0x00020001, 0x000000fe, 0x000000ef, }; static unsigned long g_huffman_table_32[31] = { 0x00020001, 0x00000000, 0x00080001, 0x00040001, 0x00020001, 0x00000008, 0x00000004, 0x00020001, 0x00000001, 0x00000002, 0x00080001, 0x00040001, 0x00020001, 0x0000000c, 0x0000000a, 0x00020001, 0x00000003, 0x00000006, 0x00060001, 0x00020001, 0x00000009, 0x00020001, 0x00000005, 0x00000007, 0x00040001, 0x00020001, 0x0000000e, 0x0000000d, 0x00020001, 0x0000000f, 0x0000000b, }; static unsigned long g_huffman_table_33[31] = { 0x00100001, 0x00080001, 0x00040001, 0x00020001, 0x00000000, 0x00000001, 0x00020001, 0x00000002, 0x00000003, 0x00040001, 0x00020001, 0x00000004, 0x00000005, 0x00020001, 0x00000006, 0x00000007, 0x00080001, 0x00040001, 0x00020001, 0x00000008, 0x00000009, 0x00020001, 0x0000000a, 0x0000000b, 0x00040001, 0x00020001, 0x0000000c, 0x0000000d, 0x00020001, 0x0000000e, 0x0000000f, }; typedef struct _HUFFMAN_ { unsigned long * TableData; unsigned long TreeLen; unsigned long linbits; } HuffmanData; static HuffmanData g_huffman_main [34] = { { 0 , 0, 0 }, /* Table 0 */ { g_huffman_table_1 , 7, 0 }, /* Table 1 */ { g_huffman_table_2 , 17, 0 }, /* Table 2 */ { g_huffman_table_3 , 17, 0 }, /* Table 3 */ { 0 , 0, 0 }, /* Table 4 */ { g_huffman_table_5 , 31, 0 }, /* Table 5 */ { g_huffman_table_6 , 31, 0 }, /* Table 6 */ { g_huffman_table_7 , 71, 0 }, /* Table 7 */ { g_huffman_table_8 , 71, 0 }, /* Table 8 */ { g_huffman_table_9 , 71, 0 }, /* Table 9 */ { g_huffman_table_10, 127, 0 }, /* Table 10 */ { g_huffman_table_11, 127, 0 }, /* Table 11 */ { g_huffman_table_12, 127, 0 }, /* Table 12 */ { g_huffman_table_13, 511, 0 }, /* Table 13 */ { 0 , 0, 0 }, /* Table 14 */ { g_huffman_table_15, 511, 0 }, /* Table 15 */ { g_huffman_table_16, 511, 1 }, /* Table 16 */ { g_huffman_table_16, 511, 2 }, /* Table 17 */ { g_huffman_table_16, 511, 3 }, /* Table 18 */ { g_huffman_table_16, 511, 4 }, /* Table 19 */ { g_huffman_table_16, 511, 6 }, /* Table 20 */ { g_huffman_table_16, 511, 8 }, /* Table 21 */ { g_huffman_table_16, 511, 10 }, /* Table 22 */ { g_huffman_table_16, 511, 13 }, /* Table 23 */ { g_huffman_table_24, 512, 4 }, /* Table 24 */ { g_huffman_table_24, 512, 5 }, /* Table 25 */ { g_huffman_table_24, 512, 6 }, /* Table 26 */ { g_huffman_table_24, 512, 7 }, /* Table 27 */ { g_huffman_table_24, 512, 8 }, /* Table 28 */ { g_huffman_table_24, 512, 9 }, /* Table 29 */ { g_huffman_table_24, 512, 11 }, /* Table 30 */ { g_huffman_table_24, 512, 13 }, /* Table 31 */ { g_huffman_table_32, 31, 0 }, /* Table 32 */ { g_huffman_table_33, 31, 0 }, /* Table 33 */ }; const CLayer3Decoder::SBI CLayer3Decoder::sfBandIndex[3][3] = { { // MPEG1 { // 44.4 Khz {0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 52, 62, 74, 90, 110, 134, 162, 196, 238, 288, 342, 418, 576}, {0, 4, 8, 12, 16, 22, 30, 40, 52, 66, 84, 106, 136, 192 } }, { // 48 Khz {0, 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 60, 72, 88, 106, 128, 156, 190, 230, 276, 330, 384, 576 }, {0, 4, 8, 12, 16, 22, 28, 38, 50, 64, 80, 100, 126, 192 } }, { // 32Khz {0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 54, 66, 82, 102, 126, 156, 194, 240, 296, 364, 448, 550, 576 }, {0, 4, 8, 12, 16, 22, 30, 42, 58, 78, 104, 138, 180, 192} } }, { // MPEG2 { // 22.5khz {0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576}, {0, 4, 8, 12, 18, 24, 32, 42, 56, 74, 100, 132, 174, 192} }, { // 24Khz {0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 114, 136, 162, 194, 232, 278, 332, 394, 464, 540, 576}, {0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 136, 180, 192} }, { // 16khz {0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576}, {0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192} }, }, { // MPEG2.5 { // 11.25Khz {0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576}, {0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192}, }, { // 12Khz {0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576}, {0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192}, }, { // 8Khz {0, 12, 24, 36, 48, 60, 72, 88, 108, 132, 160, 192, 232, 280, 336, 400, 476, 566, 568, 570, 572, 574, 576}, {0, 8, 16, 24, 36, 52, 72, 96, 124, 160, 162, 164, 166, 192}, }, } }; const float CLayer3Decoder::ShortTwiddles[] = { 0.866025403f, 0.500000000f, 1.931851653f, 0.707106781f, 0.517638090f, 0.504314480f, 0.541196100f, 0.630236207f, 0.821339815f, 1.306562965f, 3.830648788f, 0.793353340f, 0.608761429f, 0.923879532f, 0.382683432f, 0.991444861f, 0.130526192f, 0.382683432f, 0.608761429f, 0.793353340f, 0.923879532f, 0.991444861f, 0.130526192f }; const float CLayer3Decoder::NormalTwiddles[] = { 5.736856623f, 1.931851653f, 1.183100792f, 0.871723397f, 0.707106781f, 0.610387294f, 0.551688959f, 0.517638090f, 0.501909918f, -0.500476342f, -0.504314480f, -0.512139757f, -0.524264562f, -0.541196100f, -0.563690973f, -0.592844523f, -0.630236207f, -0.678170852f, -0.740093616f, -0.821339815f, -0.930579498f, -1.082840285f, -1.306562965f, -1.662754762f, -2.310113158f, -3.830648788f, -11.46279281f }; CLayer3Decoder::CLayer3Decoder() { int i; float ci[8] = { -0.6f, -0.535f, -0.33f, -0.185f, -0.095f, -0.041f, -0.0142f, -0.0037f }; for (i = 0; i < 8; i++) { Cs[i] = 1.0f / (float)sqrt(1.0 + ci[i]*ci[i]); Ca[i] = ci[i] / (float)sqrt(1.0 + ci[i]*ci[i]); } for(i = 0; i < 64; i++) { PowerTableMinus2[i] = (float)pow(2.0, -2.0 * i); PowerTableMinus05[i] = (float)pow(2.0, -0.5 * i); } for(i = 0; i < 256; i++) GainTable[i] = (float)pow(2.0 , (0.25 * (i - 210.0))); // table for the MPEG1 intensity stereo position // 7 == INVALID_POS so.... for(i=0; i<16; i++) { TanPi12Table[i] = (float)tan(i * PI/12); } // magic for the IMDCT stuff int odd_i, two_odd_i, four_odd_i, eight_odd_i; int j = 0; for(i = 0; i < 9; i++) { odd_i = (i << 1) + 1; two_odd_i = odd_i << 1; four_odd_i = odd_i << 2; IMDCT9x8Table[j++] = (float)cos(PI18 * odd_i); IMDCT9x8Table[j++] = (float)cos(PI18 * two_odd_i); eight_odd_i = two_odd_i << 2; IMDCT9x8Table[j++] = (float)cos(PI18 * (four_odd_i - odd_i)); IMDCT9x8Table[j++] = (float)cos(PI18 * four_odd_i); IMDCT9x8Table[j++] = (float)cos(PI18 * (four_odd_i + odd_i)); IMDCT9x8Table[j++] = (float)cos(PI18 * (four_odd_i + two_odd_i)); IMDCT9x8Table[j++] = (float)cos(PI18 * (eight_odd_i - odd_i)); IMDCT9x8Table[j++] = (float)cos(PI18 * eight_odd_i); } for(int ch=0;ch<2;ch++) for(int j=0; j<576; j++) prevblck[ch][j] = 0.0f; /* block_type 0 (normal window) */ for(i = 0; i < 36; i++) IMDCTwin[0][i] = (float)sin(PI36 * (i + 0.5)); /* block_type 1 (start block) */ for(i = 0; i < 18; i++) IMDCTwin[1][i] = (float)sin(PI36 * (i + 0.5)); for(i = 18; i < 24; i++) IMDCTwin[1][i] = 1.0f; for(i = 24; i < 30; i++) IMDCTwin[1][i] = (float)sin(PI12 * (i - 18 + 0.5)); for(i = 30; i < 36; i++) IMDCTwin[1][i] = 0.0f; /* block_type 2 (short block) */ for(i = 0; i < 12; i++) IMDCTwin[2][i] = (float)sin(PI12 * (i + 0.5)); for(i = 12; i < 36; i++) IMDCTwin[2][i] = 0.0f; /* block_type 3 (stop block) */ for(i = 0; i < 6; i++) IMDCTwin[3][i] = 0.0f; for(i = 6; i < 12; i++) IMDCTwin[3][i] = (float)sin(PI12 * (i - 6 + 0.5)); for(i = 12; i < 18; i++) IMDCTwin[3][i] = 1.0f; for(i = 18; i < 36; i++) IMDCTwin[3][i] = (float)sin(PI36 * (i + 0.5)); } CLayer3Decoder::~CLayer3Decoder() { } void CLayer3Decoder::DecodeScalefactors(unsigned long ch, unsigned long gr) { const unsigned int slentab1[16] = {0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4}; const unsigned int slentab2[16] = {0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3}; int sfb, window; for(sfb=0; sfb<21; sfb++) { m_fr->m_SI.grinf[gr][ch].Scalefac_Long[sfb] = 0; } for(sfb=0; sfb<13; sfb++) { m_fr->m_SI.grinf[gr][ch].Scalefac_Short[sfb][0] = 0; m_fr->m_SI.grinf[gr][ch].Scalefac_Short[sfb][1] = 0; m_fr->m_SI.grinf[gr][ch].Scalefac_Short[sfb][2] = 0; } if(m_MpegVer == MPEG1) { unsigned int slen1 = slentab1[m_fr->m_SI.grinf[gr][ch].ScalefacCompress]; unsigned int slen2 = slentab2[m_fr->m_SI.grinf[gr][ch].ScalefacCompress]; if( (m_fr->m_SI.grinf[gr][ch].WindowSwitchingFlag == 1) && (m_fr->m_SI.grinf[gr][ch].BlockType == 2)) { if(m_fr->m_SI.grinf[gr][ch].MixedBlockFlag) { // this is the long block for (sfb = 0; sfb < 8; sfb++) m_fr->m_SI.grinf[gr][ch].Scalefac_Long[sfb] = br.GetBits(slen1); for (sfb = 3; sfb < 6; sfb++) for (window=0; window<3; window++) m_fr->m_SI.grinf[gr][ch].Scalefac_Short[sfb][window] = br.GetBits(slen1); for (sfb = 6; sfb < 12; sfb++) for (window=0; window<3; window++) m_fr->m_SI.grinf[gr][ch].Scalefac_Short[sfb][window] = br.GetBits(slen2); for (sfb=12,window=0; window<3; window++) m_fr->m_SI.grinf[gr][ch].Scalefac_Short[12][window] = 0; } else { // SHORT // this is a short block... for(sfb=0; sfb<6; sfb++) { for(window=0; window<3; window++) { m_fr->m_SI.grinf[gr][ch].Scalefac_Short[sfb][window] = br.GetBits(slen1); } } for(sfb=6; sfb<12; sfb++) { for(window=0; window<3; window++) { m_fr->m_SI.grinf[gr][ch].Scalefac_Short[sfb][window] = br.GetBits(slen2); } } for(window=0; window<3; window++) m_fr->m_SI.grinf[gr][ch].Scalefac_Short[12][window] = 0; } } else { for(sfb=0; sfb<6; sfb++) { if((m_fr->m_SI.ScfSi[ch][0] == 0) || (gr == 0)) { m_fr->m_SI.grinf[gr][ch].Scalefac_Long[sfb] = br.GetBits(slen1); } else m_fr->m_SI.grinf[1][ch].Scalefac_Long[sfb] = m_fr->m_SI.grinf[0][ch].Scalefac_Long[sfb]; } for(sfb=6; sfb<11; sfb++) { if((m_fr->m_SI.ScfSi[ch][1] == 0) || (gr == 0)) { m_fr->m_SI.grinf[gr][ch].Scalefac_Long[sfb] = br.GetBits(slen1); } else m_fr->m_SI.grinf[1][ch].Scalefac_Long[sfb] = m_fr->m_SI.grinf[0][ch].Scalefac_Long[sfb]; } for(sfb=11; sfb<16; sfb++) { if((m_fr->m_SI.ScfSi[ch][2] == 0) || (gr == 0)) { m_fr->m_SI.grinf[gr][ch].Scalefac_Long[sfb] = br.GetBits(slen2); } else m_fr->m_SI.grinf[1][ch].Scalefac_Long[sfb] = m_fr->m_SI.grinf[0][ch].Scalefac_Long[sfb]; } for(sfb=16; sfb<21; sfb++) { if((m_fr->m_SI.ScfSi[ch][3] == 0) || (gr == 0)) { m_fr->m_SI.grinf[gr][ch].Scalefac_Long[sfb] = br.GetBits(slen2); } else m_fr->m_SI.grinf[1][ch].Scalefac_Long[sfb] = m_fr->m_SI.grinf[0][ch].Scalefac_Long[sfb]; } m_fr->m_SI.grinf[gr][ch].Scalefac_Long[21] = 0; } } else // MPEG 2 { int nfsbtable [2][3][3][4] = { { { {6, 5, 5, 5}, {9, 9, 9, 9}, {6, 9, 9, 9} }, { {6, 5, 7, 3}, {9, 9, 12, 6}, {6, 9, 12, 6} }, { {11, 10, 0, 0}, {18, 18, 0, 0}, {15, 18, 0, 0} }, }, { { { 7, 7, 7, 0}, {12, 12, 12, 0}, { 6, 15, 12, 0} }, { { 6, 6, 6, 3}, {12, 9, 9, 6}, { 6, 12, 9, 6} }, { { 8, 8, 5, 0}, {15, 12, 9, 0}, { 6, 18, 9, 0} }, }, }; unsigned int scalefac_comp; unsigned int slen[4] = {0,0,0,0}; unsigned long index1, index2, index3; if( (m_fr->m_SI.grinf[gr][ch].WindowSwitchingFlag == 1) && (m_fr->m_SI.grinf[gr][ch].BlockType == 2)) { if(m_fr->m_SI.grinf[gr][ch].MixedBlockFlag) { index3 = 2; } else { index3 = 1; } } else { index3 = 0; } scalefac_comp = m_fr->m_SI.grinf[gr][ch].ScalefacCompress; if(!( ((m_ModeExt == 1) || (m_ModeExt==3)) && (ch == 1))) { index1 = 0; m_fr->m_SI.grinf[gr][ch].PreFlag = 0; if (scalefac_comp>=500) { slen[0] = ((scalefac_comp-500)/ 3)%4; slen[1] = ((scalefac_comp-500)/ 1)%3; slen[2] = ((scalefac_comp-500)/ 1)%1; slen[3] = ((scalefac_comp-500)/ 1)%1; index2 = 2; m_fr->m_SI.grinf[gr][ch].PreFlag = 1; } else if (scalefac_comp>=400) { slen[0] = ((scalefac_comp-400)/20)%5; slen[1] = ((scalefac_comp-400)/ 4)%5; slen[2] = ((scalefac_comp-400)/ 1)%4; slen[3] = ((scalefac_comp-400)/ 1)%1; index2 = 1; } else { slen[0] = ((scalefac_comp- 0)/80)%5; slen[1] = ((scalefac_comp- 0)/16)%5; slen[2] = ((scalefac_comp- 0)/ 4)%4; slen[3] = ((scalefac_comp- 0)/ 1)%4; index2 = 0; } } else { index1 = 1; m_fr->m_SI.grinf[gr][ch].PreFlag = 0; scalefac_comp>>=1; if (scalefac_comp>=244) { slen[0] = ((scalefac_comp-244)/ 3)%4; slen[1] = ((scalefac_comp-244)/ 1)%3; slen[2] = ((scalefac_comp-244)/ 1)%1; slen[3] = ((scalefac_comp-244)/ 1)%1; index2 = 2; } else if (scalefac_comp>=180) { slen[0] = ((scalefac_comp-180)/16)%4; slen[1] = ((scalefac_comp-180)/ 4)%4; slen[2] = ((scalefac_comp-180)/ 1)%4; slen[3] = ((scalefac_comp-180)/ 1)%1; index2 = 1; } else { slen[0] = ((scalefac_comp- 0)/36)%5; slen[1] = ((scalefac_comp- 0)/ 6)%6; slen[2] = ((scalefac_comp- 0)/ 1)%6; slen[3] = ((scalefac_comp- 0)/ 1)%1; index2 = 0; } } if( (m_fr->m_SI.grinf[gr][ch].WindowSwitchingFlag == 1) && (m_fr->m_SI.grinf[gr][ch].BlockType == 2)) { if(m_fr->m_SI.grinf[gr][ch].MixedBlockFlag) { } else { int sfb = 0; int window = 0; for(int j=0; j<4; j++) { for(int i=0; i<nfsbtable[index1][index2][index3][j]; i++) { if(slen[j] > 0) m_fr->m_SI.grinf[gr][ch].Scalefac_Short[sfb][window] = br.GetBits(slen[j]); else m_fr->m_SI.grinf[gr][ch].Scalefac_Short[sfb][window] = 0; window++; if(window > 2) { if( (m_MpegVer != MPEG1) && ((m_ModeExt == 1) || (m_ModeExt==3)) ) m_fr->m_SI.grinf[gr][ch].is_max[sfb] = (1<<slen[j])-1; window = 0; sfb++; } } } for(window=0; window<3; window++) m_fr->m_SI.grinf[gr][ch].Scalefac_Short[12][window] = 0; } } else { int sfb = 0; for(int j=0; j<4; j++) { for(int i=0; i<nfsbtable[index1][index2][index3][j]; i++) { if(slen[j] > 0) m_fr->m_SI.grinf[gr][ch].Scalefac_Long[sfb] = br.GetBits(slen[j]); else m_fr->m_SI.grinf[gr][ch].Scalefac_Long[sfb] = 0; if( (m_MpegVer != MPEG1) && ((m_ModeExt == 1) || (m_ModeExt==3)) ) m_fr->m_SI.grinf[gr][ch].is_max[sfb] = (1<<slen[j])-1; sfb++; } } m_fr->m_SI.grinf[gr][ch].Scalefac_Long[21] = 0; m_fr->m_SI.grinf[gr][ch].Scalefac_Long[22] = 0; } } } bool __forceinline CLayer3Decoder::HuffmanDecode(unsigned long TableNum, int * x, int * y, int * v, int * w) { unsigned long point, error, bitsleft, treelen, linbits; unsigned long *htptr; point = 0; bitsleft = 32; /* Check for empty tables */ if(g_huffman_main[TableNum].TreeLen == 0) { *x = *y = *v = *w = 0; return true; } treelen = g_huffman_main[TableNum].TreeLen; linbits = g_huffman_main[TableNum].linbits; htptr = g_huffman_main[TableNum].TableData; /* Start reading the Huffman code word, bit by bit */ error = 1; do { /* Check if we've matched a code word */ if((htptr[point] & 0xffff0000) == 0x00000000) { error = 0; *x = (htptr[point] >> 4) & 0xf; *y = htptr[point] & 0xf; break; } if(br.GetBits(1)) { /* Go right in tree */ while((htptr[point] & 0xff) >= 250) { point += htptr[point] & 0xff; } point += htptr[point] & 0xff; } else { /* Go left in tree */ while((htptr[point] >> 16) >= 250) { point += htptr[point] >> 16; } point += htptr[point] >> 16; } } while((--bitsleft > 0) && (point < treelen)); /* Check for error. */ if(error) { *x = *y = *v = *w = 0; return false; } /* Process sign encodings for quadruples tables. */ if(TableNum > 31) { *v = (*y >> 3) & 1; *w = (*y >> 2) & 1; *x = (*y >> 1) & 1; *y = *y & 1; if(*v > 0) if(br.GetBits(1)) *v = -*v; if(*w > 0) if(br.GetBits(1)) *w = -*w; if(*x > 0) if(br.GetBits(1)) *x = -*x; if(*y > 0) if(br.GetBits(1)) *y = -*y; } else { /* Get linbits */ if((linbits > 0) && (*x == 15)) { *x += br.GetBits(linbits); } /* Get sign bit */ if(*x > 0) { if(br.GetBits(1)) *x = -*x; } /* Get linbits */ if((linbits > 0) && (*y == 15)) { *y += br.GetBits(linbits); } /* Get sign bit */ if(*y > 0) { if(br.GetBits(1)) *y = -*y; } } return true; } bool CLayer3Decoder::ReadHuffman(unsigned long ch, unsigned long gr) { unsigned long index = 0; unsigned long Part23End; unsigned long Region1; unsigned long Region2; unsigned long TableNumber; int x, y, v, w; Part23End = m_Part2Start[ch] + m_fr->m_SI.grinf[gr][ch].Part23Length; if(m_MpegVer == MPEG1) { m_MixedBandLimit[ch] = sfBandIndex[m_MpegVer][m_SampleFrequency].Long[8]; } else { m_MixedBandLimit[ch] = sfBandIndex[m_MpegVer][m_SampleFrequency].Long[6]; } if( (m_fr->m_SI.grinf[gr][ch].WindowSwitchingFlag) && (m_fr->m_SI.grinf[gr][ch].BlockType == BLOCKTYPE_3WIN) ) { Region1 = m_MixedBandLimit[ch]; Region2 = 576; } else { Region1 = sfBandIndex[m_MpegVer][m_SampleFrequency].Long[m_fr->m_SI.grinf[gr][ch].Region0Count + 1]; Region2 = sfBandIndex[m_MpegVer][m_SampleFrequency].Long[m_fr->m_SI.grinf[gr][ch].Region0Count + m_fr->m_SI.grinf[gr][ch].Region1Count + 2]; } if(m_fr->m_SI.grinf[gr][ch].Part23Length == 0) { for(index = 0; index < 576; index++) { is[ch][index] = 0; } m_NonZero[ch] = 0; return true; } while(index < (m_fr->m_SI.grinf[gr][ch].BigValues << 1)) { if(index < Region1) { TableNumber = m_fr->m_SI.grinf[gr][ch].TableSelect[0]; } else if(index < Region2) { TableNumber = m_fr->m_SI.grinf[gr][ch].TableSelect[1]; } else { TableNumber = m_fr->m_SI.grinf[gr][ch].TableSelect[2]; } if(!HuffmanDecode(TableNumber, &x, &y, &v, &w)) return false; is[ch][index++] = x; is[ch][index++] = y; } unsigned long pos = br.GetPos(); TableNumber = m_fr->m_SI.grinf[gr][ch].Count1Table_Select + 32; while((index < 576) && (pos < Part23End)) { if(!HuffmanDecode(TableNumber, &x, &y, &v, &w)) return false; is[ch][index++] = v; is[ch][index++] = w; is[ch][index++] = x; is[ch][index++] = y; pos = br.GetPos(); } pos = br.GetPos(); if(pos > Part23End) { index -= 4; if(index < 0) index = 0; } m_NonZero[ch] = index; br.SetPos(Part23End); for(; index < 576; index++) { is[ch][index] = 0; } return true; } void CLayer3Decoder::DequantizeSample(int ch, int gr) { static const int pretab[22] = { 0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,2,0 }; unsigned long index = 0; int window = 0; int windowsize = 0; int sfb = 0; int startband = 0; float txr = 0.0f; float globscale = GainTable[ m_fr->m_SI.grinf[gr][ch].GlobalGain ]; if(m_fr->m_SI.grinf[gr][ch].WindowSwitchingFlag && m_fr->m_SI.grinf[gr][ch].BlockType == BLOCKTYPE_3WIN) { if(m_fr->m_SI.grinf[gr][ch].MixedBlockFlag) { int endblock = 0; // Mixed Block if(m_MpegVer == MPEG1) { endblock = 8; } else { endblock = 6; } for(sfb=0; sfb<endblock; sfb++) { windowsize = sfBandIndex[m_MpegVer][m_SampleFrequency].Long[sfb+1] - sfBandIndex[m_MpegVer][m_SampleFrequency].Long[sfb]; for(int i=0; i<windowsize; i++) { txr = globscale * PowerTableMinus05[(1 + m_fr->m_SI.grinf[gr][ch].ScalefacScale) * (m_fr->m_SI.grinf[gr][ch].Scalefac_Long[sfb] + (m_fr->m_SI.grinf[gr][ch].PreFlag * pretab[sfb]) )]; xr[ch][index] = txr * ( pow( (float)abs(is[ch][index]), (float)1.333333333333333) * ( is[ch][index] > 0 ? 1 : -1 ) ); index ++; // should be 36 at the end of all this! } } startband = 3; } // Short Block // xr[i] = sign(is[i]) * |is[i]|^(4/3) * 2 ^ 0.25 * (global_gain - 210 - 8 * subblock_gain[window]) * 2 ^ -(scalefac_multiplier * scalefac_s[band][window]) // short blocks are arranged as 3 windowsize windows per scalefactorband // like this: 111 111 111 22 22 22 3 3 3 // SFB1 SFB2 SFB3 ... etc for(sfb=startband; sfb < 13; sfb++) { windowsize = sfBandIndex[m_MpegVer][m_SampleFrequency].Short[sfb+1] - sfBandIndex[m_MpegVer][m_SampleFrequency].Short[sfb]; for(window = 0; window<3; window++) { for(int i=0; i<windowsize; i++) { txr = globscale * PowerTableMinus2[m_fr->m_SI.grinf[gr][ch].SubblockGain[window]] * PowerTableMinus05[(1 + m_fr->m_SI.grinf[gr][ch].ScalefacScale) * m_fr->m_SI.grinf[gr][ch].Scalefac_Short[sfb][window]]; /* apply the sign(is[i]) * |is[i]| ^ (4/3) formula */ xr[ch][index] = txr * ( pow( (float)abs(is[ch][index]), (float)1.333333333333333) * ( is[ch][index] > 0 ? 1 : -1 ) ); index ++; if(index >= m_NonZero[ch]) break; } } } } else { // Long Block // xr[i] = sign(is[i]) * | is[i] |^(4/3) * 2 ^ 0.25 * (global_gain - 210) * 2 ^ -(scalefac_multiplier * (scalefac_l[band] + preflag * pretab[band])) for(sfb=0; sfb<22; sfb++) { windowsize = sfBandIndex[m_MpegVer][m_SampleFrequency].Long[sfb+1] - sfBandIndex[m_MpegVer][m_SampleFrequency].Long[sfb]; for(int i=0; i<windowsize; i++) { txr = globscale * PowerTableMinus05[(1 + m_fr->m_SI.grinf[gr][ch].ScalefacScale) * (m_fr->m_SI.grinf[gr][ch].Scalefac_Long[sfb] + (m_fr->m_SI.grinf[gr][ch].PreFlag * pretab[sfb]) )]; xr[ch][index] = txr * ( pow( (float)abs(is[ch][index]), (float)1.333333333333333) * ( is[ch][index] > 0 ? 1 : -1 ) ); index ++; if(index >= m_NonZero[ch]) break; } } } for(; index<576; index++) { xr[ch][index] = 0.0; } } void CLayer3Decoder::Reorder(unsigned int ch, unsigned int gr) { if(m_fr->m_SI.grinf[gr][ch].WindowSwitchingFlag && m_fr->m_SI.grinf[gr][ch].BlockType == BLOCKTYPE_3WIN) { int ScaleFactorBand = 0; int BandStart; int BandSize; int Window, src, dst; int i; if(m_fr->m_SI.grinf[gr][ch].MixedBlockFlag) { for(unsigned long index=0; index < m_MixedBandLimit[ch]; index++) { xrr[ch][index] = xr[ch][index]; } ScaleFactorBand = 4; } /* short block, reorder everything */ // this is a 3window block, we need to reorder it.... in something like this // 111 222 333 444 555 666 777 888 999 101010 111111 121212 // to // 123123123 456456456 789789789 101112101112101112 do { BandStart = sfBandIndex[m_MpegVer][m_SampleFrequency].Short[ScaleFactorBand]; BandSize = sfBandIndex[m_MpegVer][m_SampleFrequency].Short[ScaleFactorBand+1] - BandStart; src = BandStart * 3; for(Window = 0; Window < 3; Window++) { dst = (BandStart * 3) + Window; for(i = 0; i < BandSize; i++) { xrr[ch][dst] = xr[ch][src]; src++; dst += 3; } } ScaleFactorBand++; } while(ScaleFactorBand < 13); } else { // long blocks for(int index=0; index < 576; index++) { xrr[ch][index] = xr[ch][index]; } } } void CLayer3Decoder::CalculateK(int index, int is_pos, int intensity_scale) { // MPEG2/2.5 if(is_pos == 0) { kl[index] = 1.0; kr[index] = 1.0; } else { if(intensity_scale == 1) { if(is_pos%2==1) { kl[index] = (float)pow(2.0f, -( (is_pos+1) / (4)) ); kr[index] = 1.0; } else { kl[index] = 1.0; kr[index] = (float)pow(2.0f, -(is_pos/(4)) ); } } else { if(is_pos%2==1) { kl[index] = (float)pow(2.0f, -( (is_pos+1) / (8)) ); kr[index] = 1.0; } else { kl[index] = 1.0; kr[index] = (float)pow(2.0f, -(is_pos/(8)) ); } } } } void CLayer3Decoder::Stereo(unsigned int gr) { int index; if(m_Channels == 2) // dont bother with stereo processing unless its STEREO duuh { int MS_Stereo = (m_Mode == MODE_JOINT_STEREO) && (m_ModeExt & MODE_EXT_MS); int I_Stereo = (m_Mode == MODE_JOINT_STEREO) && (m_ModeExt & MODE_EXT_IS); int is_pos; // intensity stereo positions int is_valid[576]; float is_ratio[576]; // intensity stereo left / right ratio int intensity_scale = (m_fr->m_SI.grinf[gr][0].ScalefacCompress % 2); if(I_Stereo) { for(index=0; index<576; index++) is_valid[index] = 0; if(m_fr->m_SI.grinf[gr][0].WindowSwitchingFlag && (m_fr->m_SI.grinf[gr][0].BlockType == BLOCKTYPE_3WIN)) { if(m_fr->m_SI.grinf[gr][0].MixedBlockFlag) { // printf("Mixed Block - Arrgh"); } else { unsigned long startband = 0; while((unsigned long)(sfBandIndex[m_MpegVer][m_SampleFrequency].Short[startband]*3) < m_NonZero[1]) startband ++; for(int sfb=startband; sfb<13; sfb++) { int windowsize = sfBandIndex[m_MpegVer][m_SampleFrequency].Short[sfb+1] - sfBandIndex[m_MpegVer][m_SampleFrequency].Short[sfb]; for(int window=0; window<3; window++) { int sfb_start = sfBandIndex[m_MpegVer][m_SampleFrequency].Short[sfb]*3 + windowsize*window; int sfb_stop = sfb_start + windowsize; for(int i = sfb_start; i < sfb_stop; i++) { is_pos = m_fr->m_SI.grinf[gr][1].Scalefac_Short[ sfb ][window]; if(m_MpegVer == MPEG1) { if (is_pos != 7) { is_ratio[ i ] = TanPi12Table[ is_pos ]; is_valid[ i ] = 1; } } else { if(is_pos != m_fr->m_SI.grinf[gr][1].is_max[ sfb ] ) { CalculateK(i, is_pos, intensity_scale); is_valid[ i ] = 1; } } } } } } } else { int i; int startband = 0; while(sfBandIndex[m_MpegVer][m_SampleFrequency].Long[startband] < m_NonZero[1]) startband ++; for(int sfb = startband; sfb<22; sfb++) { i = sfBandIndex[m_MpegVer][m_SampleFrequency].Long[sfb]; int windowsize = sfBandIndex[m_MpegVer][m_SampleFrequency].Long[sfb+1] - sfBandIndex[m_MpegVer][m_SampleFrequency].Long[sfb]; for(int w=0; w<windowsize; w++) { is_pos = m_fr->m_SI.grinf[gr][1].Scalefac_Long[ sfb ]; if(m_MpegVer == MPEG1) { if (is_pos != 7) { is_ratio[ i ] = TanPi12Table[ is_pos ]; is_valid[ i ] = 1; } } else { if(is_pos != m_fr->m_SI.grinf[gr][1].is_max[ sfb ] ) { CalculateK(i, is_pos, intensity_scale); is_valid[ i ] = 1; } } i++; } } } // process the intensity stere stuff for(index=0; index<576; index++) { float temp = xrr[0][index]; if( is_valid[index] == 0 ) { // NOT intensity Stereo Mode if(MS_Stereo) { // MSStereo mode. we have to undo it... xrr[0][index] = (temp + xrr[1][index]) / SQRT2; xrr[1][index] = (temp - xrr[1][index]) / SQRT2; } } else { // this IS an intensity stereo value if(m_MpegVer == MPEG1) { xrr[0][index] = temp * (is_ratio[index] / (1.0f + is_ratio[index])); xrr[1][index] = temp * (1.0f / (1.0f + is_ratio[index])); } else { xrr[0][index] = temp * kl[index]; xrr[1][index] = temp * kr[index]; } } } } else if(MS_Stereo) { // MSStereo mode. we have to undo it... for(index=0; index<576; index++) { float temp = xrr[0][index]; xrr[0][index] = (temp + xrr[1][index]) / SQRT2; xrr[1][index] = (temp - xrr[1][index]) / SQRT2; } } } } void CLayer3Decoder::AntiAlias(unsigned int ch, unsigned int gr) { int sb_amount; int index =0; if(m_fr->m_SI.grinf[gr][ch].BlockType != BLOCKTYPE_3WIN) { sb_amount = 558; // antialias the full stectrum } else { if(m_fr->m_SI.grinf[gr][ch].MixedBlockFlag) { // this is a long block, then a short block sb_amount = m_MixedBandLimit[ch]; } else // No antialiasing for short blocks { return; } } int src_idx1; int src_idx2; register float temp; for(int sb = 18; sb < sb_amount; sb+=18) { for(int i=0; i<8; i++) { src_idx1 = sb - 1 - i; src_idx2 = sb + i; temp = xrr[ch][src_idx1]; xrr[ch][src_idx1] = (temp * Cs[i]) - (xrr[ch][src_idx2] * Ca[i]); xrr[ch][src_idx2] = (xrr[ch][src_idx2] * Cs[i]) + (temp * Ca[i]); } } } void CLayer3Decoder::FreqencyInverse(int gr, int ch) { int sb, ss; int offset; for(sb = 1; sb < 32; sb+=2) { offset = 32; for(ss=1; ss<18; ss+=2) { xir[ch][offset+sb] = -xir[ch][offset+sb]; offset += 64; } } } void CLayer3Decoder::IMDCT(float *in, float *out, int block_type) { if(block_type == 2) { float tmp[18]; register float sum; register float save; register float pp1; int six_i = 6; int window; for(int i=0; i<36; i++) { out[i] = 0.0; } for(window=0; window<3; window++) { in[15+window] += in[12+window]; in[12+window] += in[9+window]; in[9+window] += in[6+window]; in[6+window] += in[3+window]; in[3+window] += in[window]; in[15+window] += in[9+window]; in[9+window] += in[3+window]; pp1 = in[6+window] * ShortTwiddles[0]; sum = in[window] + in[12+window] * ShortTwiddles[1]; tmp[1] = in[window] - in[12+window]; tmp[0] = sum + pp1; tmp[2] = sum - pp1; pp1 = in[9+window] * ShortTwiddles[0]; sum = in[3+window] + in[15+window] * ShortTwiddles[1]; tmp[4] = in[3+window] - in[15+window]; tmp[5] = sum + pp1; tmp[3] = sum - pp1; tmp[3] *= ShortTwiddles[2]; tmp[4] *= ShortTwiddles[3]; tmp[5] *= ShortTwiddles[4]; save = tmp[0]; tmp[0] += tmp[5]; tmp[5] = save - tmp[5]; save = tmp[1]; tmp[1] += tmp[4]; tmp[4] = save - tmp[4]; save = tmp[2]; tmp[2] += tmp[3]; tmp[3] = save - tmp[3]; tmp[0] *= ShortTwiddles[5]; tmp[1] *= ShortTwiddles[6]; tmp[2] *= ShortTwiddles[7]; tmp[3] *= ShortTwiddles[8]; tmp[4] *= ShortTwiddles[9]; tmp[5] *= ShortTwiddles[10]; tmp[6] = -tmp[2] * ShortTwiddles[15]; tmp[7] = -tmp[1] * ShortTwiddles[13]; tmp[8] = -tmp[0] * ShortTwiddles[11]; tmp[9] = -tmp[0] * ShortTwiddles[12]; tmp[10] = -tmp[1] * ShortTwiddles[14]; tmp[11] = -tmp[2] * ShortTwiddles[16]; tmp[0] = tmp[3]; tmp[1] = tmp[4] * ShortTwiddles[17]; tmp[2] = tmp[5] * ShortTwiddles[18]; tmp[3] = -tmp[5] * ShortTwiddles[19]; tmp[4] = -tmp[4] * ShortTwiddles[20]; tmp[5] = -tmp[0] * ShortTwiddles[21]; tmp[0] *= ShortTwiddles[22]; out[six_i] += tmp[0]; out[six_i + 1] += tmp[1]; out[six_i + 2] += tmp[2]; out[six_i + 3] += tmp[3]; out[six_i + 4] += tmp[4]; out[six_i + 5] += tmp[5]; out[six_i + 6] += tmp[6]; out[six_i + 7] += tmp[7]; out[six_i + 8] += tmp[8]; out[six_i + 9] += tmp[9]; out[six_i + 10] += tmp[10]; out[six_i + 11] += tmp[11]; six_i += 6; } } else { float tmp[18]; int i, j; register float sum; register float sum2; register float save; in[17] += in[16]; in[16] += in[15]; in[15] += in[14]; in[14] += in[13]; in[13] += in[12]; in[12] += in[11]; in[11] += in[10]; in[10] += in[9]; in[9] += in[8]; in[8] += in[7]; in[7] += in[6]; in[6] += in[5]; in[5] += in[4]; in[4] += in[3]; in[3] += in[2]; in[2] += in[1]; in[1] += in[0]; in[17] += in[15]; in[15] += in[13]; in[13] += in[11]; in[11] += in[9]; in[9] += in[7]; in[7] += in[5]; in[5] += in[3]; in[3] += in[1]; j = 0; i = 0; int b = 9; do { sum = in[0]; sum2 = in[1]; sum += in[2] * IMDCT9x8Table[j]; sum2 += in[3] * IMDCT9x8Table[j]; sum += in[4] * IMDCT9x8Table[j+1]; sum2 += in[5] * IMDCT9x8Table[j+1]; sum += in[6] * IMDCT9x8Table[j+2]; sum2 += in[7] * IMDCT9x8Table[j+2]; sum += in[8] * IMDCT9x8Table[j+3]; sum2 += in[9] * IMDCT9x8Table[j+3]; sum += in[10] * IMDCT9x8Table[j+4]; sum2 += in[11] * IMDCT9x8Table[j+4]; sum += in[12] * IMDCT9x8Table[j+5]; sum2 += in[13] * IMDCT9x8Table[j+5]; sum += in[14] * IMDCT9x8Table[j+6]; sum2 += in[15] * IMDCT9x8Table[j+6]; sum += in[16] * IMDCT9x8Table[j+7]; sum2 += in[17] * IMDCT9x8Table[j+7]; tmp[i] = sum; tmp[17-i] = sum2; j += 8; i++; } while(--b); tmp[9] *= NormalTwiddles[0]; tmp[10] *= NormalTwiddles[1]; tmp[11] *= NormalTwiddles[2]; tmp[12] *= NormalTwiddles[3]; tmp[13] *= NormalTwiddles[4]; tmp[14] *= NormalTwiddles[5]; tmp[15] *= NormalTwiddles[6]; tmp[16] *= NormalTwiddles[7]; tmp[17] *= NormalTwiddles[8]; for(i = 0; i < 9; i++) { save = tmp[i]; tmp[i] += tmp[17-i]; tmp[17-i] = save - tmp[17-i]; } tmp[0] *= NormalTwiddles[9]; tmp[1] *= NormalTwiddles[10]; tmp[2] *= NormalTwiddles[11]; tmp[3] *= NormalTwiddles[12]; tmp[4] *= NormalTwiddles[13]; tmp[5] *= NormalTwiddles[14]; tmp[6] *= NormalTwiddles[15]; tmp[7] *= NormalTwiddles[16]; tmp[8] *= NormalTwiddles[17]; tmp[9] *= NormalTwiddles[18]; tmp[10] *= NormalTwiddles[19]; tmp[11] *= NormalTwiddles[20]; tmp[12] *= NormalTwiddles[21]; tmp[13] *= NormalTwiddles[22]; tmp[14] *= NormalTwiddles[23]; tmp[15] *= NormalTwiddles[24]; tmp[16] *= NormalTwiddles[25]; tmp[17] *= NormalTwiddles[26]; for(i = 0; i < 9; i++) { out[i] = -tmp[i+9] * IMDCTwin[block_type][i]; out[i+9] = tmp[17-i] * IMDCTwin[block_type][i+9]; out[i+18] = tmp[8-i] * IMDCTwin[block_type][i+18]; out[i+27] = tmp[i] * IMDCTwin[block_type][i+27]; } } } void CLayer3Decoder::Hybrid(int ch, float *xfrom, float *xto, int blocktype, int windowswitching, int mixedblock) { float rawout[36]; unsigned int bt; int sb18 = 0; int sb = 0; int x = 32; do { bt = (windowswitching && mixedblock && (sb18 < 36)) ? 0 : blocktype; IMDCT(&xfrom[sb18], rawout, bt); xto[sb] = rawout[ 0] + prevblck[ch][sb18+0]; xto[sb+32] = rawout[ 1] + prevblck[ch][sb18+1]; xto[sb+64] = rawout[ 2] + prevblck[ch][sb18+2]; xto[sb+96] = rawout[ 3] + prevblck[ch][sb18+3]; xto[sb+128] = rawout[ 4] + prevblck[ch][sb18+4]; xto[sb+160] = rawout[ 5] + prevblck[ch][sb18+5]; xto[sb+192] = rawout[ 6] + prevblck[ch][sb18+6]; xto[sb+224] = rawout[ 7] + prevblck[ch][sb18+7]; xto[sb+256] = rawout[ 8] + prevblck[ch][sb18+8]; xto[sb+288] = rawout[ 9] + prevblck[ch][sb18+9]; xto[sb+320] = rawout[10] + prevblck[ch][sb18+10]; xto[sb+352] = rawout[11] + prevblck[ch][sb18+11]; xto[sb+384] = rawout[12] + prevblck[ch][sb18+12]; xto[sb+416] = rawout[13] + prevblck[ch][sb18+13]; xto[sb+448] = rawout[14] + prevblck[ch][sb18+14]; xto[sb+480] = rawout[15] + prevblck[ch][sb18+15]; xto[sb+512] = rawout[16] + prevblck[ch][sb18+16]; xto[sb+544] = rawout[17] + prevblck[ch][sb18+17]; prevblck[ch][sb18+0] = rawout[18]; prevblck[ch][sb18+1] = rawout[19]; prevblck[ch][sb18+2] = rawout[20]; prevblck[ch][sb18+3] = rawout[21]; prevblck[ch][sb18+4] = rawout[22]; prevblck[ch][sb18+5] = rawout[23]; prevblck[ch][sb18+6] = rawout[24]; prevblck[ch][sb18+7] = rawout[25]; prevblck[ch][sb18+8] = rawout[26]; prevblck[ch][sb18+9] = rawout[27]; prevblck[ch][sb18+10] = rawout[28]; prevblck[ch][sb18+11] = rawout[29]; prevblck[ch][sb18+12] = rawout[30]; prevblck[ch][sb18+13] = rawout[31]; prevblck[ch][sb18+14] = rawout[32]; prevblck[ch][sb18+15] = rawout[33]; prevblck[ch][sb18+16] = rawout[34]; prevblck[ch][sb18+17] = rawout[35]; sb++; sb18+=18; } while(--x); } bool CLayer3Decoder::ProcessFrame(Frame * fr, float * PCMSamples, unsigned long * NumSamples) { unsigned long ch, gr; m_fr = fr; if(NumSamples) *NumSamples = 0; m_MpegVer = fr->m_Header.GetMpegVersion(); m_Mode = fr->m_Header.GetMode(); m_ModeExt = fr->m_Header.GetModeExtension(); m_Channels = fr->m_Header.GetChannels(); m_SampleFrequency = fr->m_Header.GetSampleFrequencyIndex(); m_Granules = (m_MpegVer) == MPEG1 ? 2 : 1; br.FillBitReserve(m_fr->m_Data, m_fr->m_Header.GetDataSize()); if(!br.BackStep(m_fr->m_SI.MainDataBegin)) { return(false); } if(!PCMSamples) { return(true); } for(gr=0; gr<m_Granules; gr++) { for(ch = 0; ch<m_Channels; ch++) { m_Part2Start[ch] = br.GetPos(); DecodeScalefactors(ch, gr); ReadHuffman(ch, gr); DequantizeSample(ch, gr); Reorder(ch, gr); } Stereo(gr); for(ch = 0; ch<m_Channels; ch++) { AntiAlias(ch, gr); Hybrid(ch, xrr[ch], xir[ch], m_fr->m_SI.grinf[gr][ch].BlockType, m_fr->m_SI.grinf[gr][ch].WindowSwitchingFlag, m_fr->m_SI.grinf[gr][ch].MixedBlockFlag); FreqencyInverse(gr, ch); } if(m_Channels == 1) { for(int ss=0; ss<576; ss+=32) { PerformSynthesis(&xir[0][ss], ((float*)PCMSamples)+*NumSamples, 0, 1); *NumSamples += 32; } } else { for(int ss=0; ss<576; ss+=32) { PerformSynthesis(&xir[0][ss], ((float*)PCMSamples)+*NumSamples, 0, 2); PerformSynthesis(&xir[1][ss], ((float*)PCMSamples)+*NumSamples, 1, 2); *NumSamples += 64; } } } return(true); }
[ "onnerby@6a861d04-ae47-0410-a6da-2d49beace72e" ]
[ [ [ 1, 2104 ] ] ]
9bafac94acd46b9648b8fbe86390f38a899551ff
5eb582292aeef7c56b13bc05accf71592d15931f
/include/raknet/RakPeer.h
4bac85dea22f9b5524c9af40d63ebad68392f65b
[]
no_license
goebish/WiiBlob
9316a56f2a60a506ecbd856ab7c521f906b961a1
bef78fc2fdbe2d52749ed3bc965632dd699c2fea
refs/heads/master
2020-05-26T12:19:40.164479
2010-09-05T18:09:07
2010-09-05T18:09:07
188,229,195
0
0
null
null
null
null
UTF-8
C++
false
false
47,911
h
/* -*- mode: c++; c-file-style: raknet; tab-always-indent: nil; -*- */ /** * @file * @brief A RakPeer is the lower level Communication End Point. * * This file is part of RakNet Copyright 2003 Rakkarsoft LLC and Kevin Jenkins. * * Usage of Raknet is subject to the appropriate licence agreement. * "Shareware" Licensees with Rakkarsoft LLC are subject to the * shareware license found at * http://www.rakkarsoft.com/shareWareLicense.html which you agreed to * upon purchase of a "Shareware license" "Commercial" Licensees with * Rakkarsoft LLC are subject to the commercial license found at * http://www.rakkarsoft.com/sourceCodeLicense.html which you agreed * to upon purchase of a "Commercial license" * Custom license users are subject to the terms therein. * All other users are * subject to 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. * * Refer to the appropriate license agreement for distribution, * modification, and warranty rights. */ #ifndef __RAK_PEER_H #define __RAK_PEER_H #include "ReliabilityLayer.h" #include "RakPeerInterface.h" #include "RPCNode.h" #include "RSACrypt.h" #include "BitStream.h" #include "SingleProducerConsumer.h" #include "RPCMap.h" #include "PacketPool.h" class HuffmanEncodingTree; class MessageHandlerInterface; #ifdef _WIN32 // unsigned __stdcall RecvFromNetworkLoop(LPVOID arguments); void __stdcall ProcessPortUnreachable( unsigned int binaryAddress, unsigned short port, RakPeer *rakPeer ); void __stdcall ProcessNetworkPacket( unsigned int binaryAddress, unsigned short port, const char *data, int length, RakPeer *rakPeer ); unsigned __stdcall UpdateNetworkLoop( LPVOID arguments ); #else // void* RecvFromNetworkLoop( void* arguments ); void ProcessPortUnreachable( unsigned int binaryAddress, unsigned short port, RakPeer *rakPeer ); void ProcessNetworkPacket( unsigned int binaryAddress, unsigned short port, const char *data, int length, RakPeer *rakPeer ); void* UpdateNetworkLoop( void* arguments ); #endif /** * @brief The lowest communication end point in RakNet. * * This class provide the lowest communication end point in RakNet. * It is recommended that you use it if you are going to be at the * same time client and server. */ class RakPeer : public RakPeerInterface { public: /** * Constructor */ RakPeer(); /** * Destructor */ virtual ~RakPeer(); /* * -------------------------------------------------------------------------------------------- * Major Low Level Functions - Functions needed by most users * -------------------------------------------------------------------------------------------- */ /** * Starts the network threads, opens the listen port * You must call this before calling SetMaximumIncomingConnections or Connect * Multiple calls while already active are ignored. To call this function again with different settings, you must first call Disconnect() * To accept incoming connections, use SetMaximumIncomingConnections * * Parameters: * @param MaximumNumberOfPeers Required so the network can preallocate and for thread safety. * - A pure client would set this to 1. A pure server would set it to the number of allowed clients. * - A hybrid would set it to the sum of both types of connections * @param localPort The port to listen for connections on. * @param _threadSleepTimer >=0 for how many ms to Sleep each internal update cycle (recommended 30 for low performance, 0 for regular) * @param forceHostAddress Can force RakNet to use a particular IP to host on. Pass 0 to automatically pick an IP * * @return False on failure (can't create socket or thread), true on success. */ bool Initialize( unsigned short MaximumNumberOfPeers, unsigned short localPort, int _threadSleepTimer, const char *forceHostAddress=0 ); /** * Must be called while offline * Secures connections though a combination of SHA1, AES128, SYN Cookies, and RSA to prevent * connection spoofing, replay attacks, data eavesdropping, packet tampering, and MitM attacks. * There is a significant amount of processing and a slight amount of bandwidth * overhead for this feature. * * If you accept connections, you must call this or else secure connections will not be enabled * for incoming connections. * If you are connecting to another system, you can call this with values for the * (e and p,q) public keys before connecting to prevent MitM * * @param pubKeyE A pointer to the public keys from the RSACrypt class. * @param pubKeyN A pointer to the public keys from the RSACrypt class. * @param privKeyP Public key generated from the RSACrypt class. * @param privKeyQ Public key generated from the RSACrypt class. * If the private keys are 0, then a new key will be generated when this function is called * * @see the Encryption sample */ void InitializeSecurity(const char *pubKeyE, const char *pubKeyN, const char *privKeyP, const char *privKeyQ ); /** * Disables all security. * @note Must be called while offline * */ virtual void DisableSecurity( void ); /** * Sets how many incoming connections are allowed. If this is less than the number of players currently connected, no * more players will be allowed to connect. If this is greater than the maximum number of peers allowed, it will be reduced * to the maximum number of peers allowed. Defaults to 0. * * @param numberAllowed Maximum number of incoming connections allowed. */ void SetMaximumIncomingConnections( unsigned short numberAllowed ); /** * Get the number of maximum incoming connection. * @return the maximum number of incoming connections, which is always <= MaximumNumberOfPeers */ unsigned short GetMaximumIncomingConnections( void ) const; /** * Sets the password incoming connections must match in the call to Connect (defaults to none) * Pass 0 to passwordData to specify no password * * @param passwordData A data block that incoming connections must match. This can be just a password, or can be a stream of data. * Specify 0 for no password data * @param passwordDataLength The length in bytes of passwordData */ void SetIncomingPassword( const char* passwordData, int passwordDataLength ); /** * Get the password set by SetIncomingPassword in a BitStream * @return The password in a BitStream. */ RakNet::BitStream *GetIncomingPassword( void ); /** * Call this to connect to the specified host (ip or domain name) and server port. * Calling Connect and not calling SetMaximumIncomingConnections acts as a dedicated client. Calling both acts as a true peer. * This is a non-blocking connection. You know the connection is successful when IsConnected() returns true * or receive gets a packet with the type identifier ID_CONNECTION_ACCEPTED. If the connection is not * successful, such as rejected connection or no response then neither of these things will happen. * Requires that you first call Initialize * * @param host Either a dotted IP address or a domain name * @param remotePort Which port to connect to on the remote machine. * @param passwordData A data block that must match the data block on the server. This can be just a password, or can be a stream of data * @param passwordDataLength The length in bytes of passwordData * * @return True on successful initiation. False on incorrect parameters, internal error, or too many existing peers */ bool Connect( const char* host, unsigned short remotePort, char* passwordData, int passwordDataLength ); /** * Stops the network threads and close all connections. Multiple calls are ok. * * * @param blockDuration How long you should wait for all remaining packets to go out, per connected system * If you set it to 0 then the disconnection notification probably won't arrive */ virtual void Disconnect( unsigned int blockDuration ); /** * Returns true if the network threads are running */ bool IsActive( void ) const; /** * Fills the array remoteSystems with the playerID of all the systems we are connected to * * @param[out] remoteSystems An array of PlayerID structures to be filled with the PlayerIDs of the systems we are connected to * - pass 0 to remoteSystems to only get the number of systems we are connected to * @param numberOfSystems As input, the size of remoteSystems array. As output, the number of elements put into the array */ bool GetConnectionList( PlayerID *remoteSystems, unsigned short *numberOfSystems ) const; /** * Sends a block of data to the specified system that you are connected to. * This function only works while the client is connected (Use the Connect function). * * @param data The block of data to send * @param length The size in bytes of the data to send * @param priority What priority level to send on. * @param reliability How reliability to send this data * @param orderingChannel When using ordered or sequenced packets, what channel to order these on. * - Packets are only ordered relative to other packets on the same stream * @param playerId Who to send this packet to, or in the case of broadcasting who not to send it to. Use UNASSIGNED_PLAYER_ID to specify none * @param broadcast True to send this packet to all connected systems. If true, then playerId specifies who not to send the packet to. * @return * False if we are not connected to the specified recipient. True otherwise */ bool Send( const char *data, const long length, PacketPriority priority, PacketReliability reliability, char orderingChannel, PlayerID playerId, bool broadcast ); /** * Sends a block of data to the specified system that you are connected to. * This function only works while the client is connected (Use the Connect function). * * @param bitStream The bitstream to send * @param priority What priority level to send on. * @param reliability How reliability to send this data * @param orderingChannel When using ordered or sequenced packets, what channel to order these on. * - Packets are only ordered relative to other packets on the same stream * @param playerId Who to send this packet to, or in the case of broadcasting who not to send it to. Use UNASSIGNED_PLAYER_ID to specify none * @param broadcast True to send this packet to all connected systems. If true, then playerId specifies who not to send the packet to. * @return * False if we are not connected to the specified recipient. True otherwise */ bool Send( RakNet::BitStream * bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, PlayerID playerId, bool broadcast ); /** * Gets a packet from the incoming packet queue. Use DeallocatePacket to deallocate the packet after you are done with it. * Check the Packet struct at the top of CoreNetworkStructures.h for the format of the struct * * @return * 0 if no packets are waiting to be handled, otherwise an allocated packet * If the client is not active this will also return 0, as all waiting packets are flushed when the client is Disconnected * This also updates all memory blocks associated with synchronized memory and distributed objects */ Packet* Receive( void ); /** * Call this to deallocate a packet returned by Receive when you are done handling it. * @param packet A packet to free */ void DeallocatePacket( Packet *packet ); /** * Return the total number of connections we are allowed */ unsigned short GetMaximumNumberOfPeers( void ) const; /* * -------------------------------------------------------------------------------------------- * Remote Procedure Call Functions - Functions to initialize and perform RPC * -------------------------------------------------------------------------------------------- */ /** * @ingroup RAKNET_RPC * Register a C or static member function as available for calling as a remote procedure call. * * @param uniqueID: A null terminated non-case sensitive string of only letters to identify this procedure * @param functionPointer(...): The name of the function to be used as a function pointer * This can be called whether the client is active or not, and registered functions stay registered unless unregistered with * UnregisterAsRemoteProcedureCall * @note This is part of the Remote Procedure Call Subsystem * */ void RegisterAsRemoteProcedureCall( char* uniqueID, void ( *functionPointer ) ( RPCParameters *rpcParms ) ); /** * @ingroup RAKNET_RPC * Register a C++ member function as available for calling as a remote procedure call. * * @param uniqueID: A null terminated string to identify this procedure. * Recommended you use the macro REGISTER_CLASS_MEMBER_RPC * @param functionPointer: The name of the function to be used as a function pointer * This can be called whether the client is active or not, and registered functions stay registered unless unregistered with * UnregisterAsRemoteProcedureCall * See the ObjectMemberRPC sample for notes on how to call this and setup the member function * @note This is part of the Remote Procedure Call Subsystem * */ void RegisterClassMemberRPC( char* uniqueID, void *functionPointer ); /** * @ingroup RAKNET_RPC * Unregisters a C function as available for calling as a remote procedure call that was formerly registered * with RegisterAsRemoteProcedureCall * Only call offline * * @param uniqueID A string of only letters to identify this procedure. Recommended you use the macro CLASS_MEMBER_ID for class member functions. Must match the parameter * passed to RegisterAsRemoteProcedureCall * * @note This is part of the Remote Procedure Call Subsystem * */ void UnregisterAsRemoteProcedureCall( char* uniqueID ); /** * @ingroup RAKNET_RPC * Calls a C function on the server that the server already registered using RegisterAsRemoteProcedureCall * If you want that function to return data you should call RPC from that system in the same way * Returns true on a successful packet send (this does not indicate the recipient performed the call), false on failure * * @param uniqueID A string of only letters to identify this procedure. Recommended you use the macro CLASS_MEMBER_ID for class member functions. Must match the parameter * @param data The block of data to send * @param bitLength The size in BITS of the data to send * @param priority What priority level to send on. * @param reliability How reliability to send this data * @param orderingChannel When using ordered or sequenced packets, what channel to order these on. * @param playerId Who to send this packet to, or in the case of broadcasting who not to send it to. Use UNASSIGNED_PLAYER_ID to specify none * @param broadcast True to send this packet to all connected systems. If true, then playerId specifies who not to send the packet to. * @param shiftTimestamp True to treat the first 4 bytes as a timestamp and make it system relative on arrival (Same as ID_TIMESTAMP for a packet enumeration type) * @param objectID For static functions, pass UNASSIGNED_OBJECT_ID. For member functions, you must derive from NetworkIDGenerator and pass the value returned by NetworkIDGenerator::GetNetworkID for that object. * @return True on a successful packet send (this does not indicate the recipient performed the call), false on failure * @note This is part of the Remote Procedure Call Subsystem */ bool RPC( char* uniqueID, const char *data, unsigned int bitLength, PacketPriority priority, PacketReliability reliability, char orderingChannel, PlayerID playerId, bool broadcast, bool shiftTimestamp, ObjectID objectID ); /** * @ingroup RAKNET_RPC * Calls a C function on the server that the server already registered using RegisterAsRemoteProcedureCall * If you want that function to return data you should call RPC from that system in the same way * Returns true on a successful packet send (this does not indicate the recipient performed the call), false on failure * * @param uniqueID A string of only letters to identify this procedure. Recommended you use the macro CLASS_MEMBER_ID for class member functions. Must match the parameter * @param bitStream The bitstream to send * @param priority What priority level to send on. * @param reliability How reliability to send this data * @param orderingChannel When using ordered or sequenced packets, what channel to order these on. * @param playerId Who to send this packet to, or in the case of broadcasting who not to send it to. Use UNASSIGNED_PLAYER_ID to specify none * @param broadcast True to send this packet to all connected systems. If true, then playerId specifies who not to send the packet to. * @param shiftTimestamp True to treat the first 4 bytes as a timestamp and make it system relative on arrival (Same as ID_TIMESTAMP for a packet enumeration type) * @param objectID For static functions, pass UNASSIGNED_OBJECT_ID. For member functions, you must derive from NetworkIDGenerator and pass the value returned by NetworkIDGenerator::GetNetworkID for that object. * @return True on a successful packet send (this does not indicate the recipient performed the call), false on failure * @note This is part of the Remote Procedure Call Subsystem */ bool RPC( char* uniqueID, RakNet::BitStream *bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, PlayerID playerId, bool broadcast, bool shiftTimestamp, ObjectID objectID ); /* * -------------------------------------------------------------------------------------------- * Player Management Functions * -------------------------------------------------------------------------------------------- */ /** * Close the connection to another host (if we initiated the connection it will disconnect, if they did it will kick them out). * * @param target Which connection to close * @param sendDisconnectionNotification True to send ID_DISCONNECTION_NOTIFICATION to the recipient. False to close it silently. */ void CloseConnection( PlayerID target, bool sendDisconnectionNotification, int depreciated=0 ); /** * Given a playerID, returns an index from 0 to the maximum number of players allowed - 1. * * @param playerId The playerID to search for * * @return An integer from 0 to the maximum number of peers -1, or -1 if that player is not found */ int GetIndexFromPlayerID( PlayerID playerId ); /** * This function is only useful for looping through all players. * * @param index an integer between 0 and the maximum number of players allowed - 1. * * @return A valid playerID or UNASSIGNED_PLAYER_ID if no such player at that index */ PlayerID GetPlayerIDFromIndex( int index ); /** * Bans an IP from connecting. Banned IPs persist between connections. * * @param IP Dotted IP address. Can use * as a wildcard, such as 128.0.0.* will ban * All IP addresses starting with 128.0.0 * @param milliseconds - how many ms for a temporary ban. Use 0 for a permanent ban */ void AddToBanList( const char *IP, unsigned int milliseconds=0 ); /** * Allows a previously banned IP to connect. * * @param IP Dotted IP address. Can use * as a wildcard, such as 128.0.0.* will unban * All IP addresses starting with 128.0.0 */ void RemoveFromBanList( const char *IP ); /** * Allows all previously banned IPs to connect. */ void ClearBanList( void ); /** * Determines if a particular IP is banned. * * @param IP Complete dotted IP address * * @return * - True if IP matches any IPs in the ban list, accounting for any wildcards. * - False otherwise. */ bool IsBanned( const char *IP ); /* * -------------------------------------------------------------------------------------------- * Pinging Functions - Functions dealing with the automatic ping mechanism * -------------------------------------------------------------------------------------------- */ /** * Send a ping to the specified connected system. * * Requires: * The sender and recipient must already be started via a successful call to Initialize * * @param target who to ping */ void Ping( PlayerID target ); /** * Send a ping to the specified unconnected system. * The remote system, if it is Initialized, will respond with ID_PONG. * The final ping time will be encoded in the following 4 bytes (2-5) as an unsigned int * * Requires: * The sender and recipient must already be started via a successful call to Initialize * * * @param host Either a dotted IP address or a domain name. Can be 255.255.255.255 for LAN broadcast. * @param remotePort Which port to connect to on the remote machine. * @param onlyReplyOnAcceptingConnections Only request a reply if the remote system is accepting connections */ void Ping( const char* host, unsigned short remotePort, bool onlyReplyOnAcceptingConnections ); /** * Gets the average of all ping times read for a specified target * * @param target whose time to read * @return The average of all ping times read for a specified target. */ int GetAveragePing( PlayerID playerId ); /** * Gets the last ping time read for the specific player or -1 if none read yet * * @param target whose time to read * @return Just the last ping */ int GetLastPing( PlayerID playerId ) const; /** * Gets the lowest ping time read or -1 if none read yet * * @param target whose time to read * @return the lowest ping time */ int GetLowestPing( PlayerID playerId ) const; /** * Ping the remote systems every so often. This is off by default * This will work anytime * * @param doPing True to start occasional pings. False to stop them. */ void SetOccasionalPing( bool doPing ); /* * -------------------------------------------------------------------------------------------- * Static Data Functions - Functions dealing with API defined synchronized memory * -------------------------------------------------------------------------------------------- */ /** * All systems have a block of data associated with them, for user use. This block of data can be used to easily * specify typical system data that you want to know on connection, such as the player's name. * * @param playerId Which system you are referring to. Pass the value returned by GetInternalID to refer to yourself * * @return The data passed to SetRemoteStaticData stored as a bitstream */ RakNet::BitStream * GetRemoteStaticData( PlayerID playerId ); /** * All systems have a block of data associated with them, for user use. This block of data can be used to easily * specify typical system data that you want to know on connection, such as the player's name. * * @param playerId Whose static data to change. Use your own playerId to change your own static data * @param data a block of data to store * @param length The length of data in bytes */ void SetRemoteStaticData( PlayerID playerId, const char *data, const long length ); /** * Sends your static data to the specified system. This is automatically done on connection. * You should call this when you change your static data. * To send the static data of another system (such as relaying their data) you should do this normally with Send * * @param target Who to send your static data to. Specify UNASSIGNED_PLAYER_ID to broadcast to all */ void SendStaticData( PlayerID target ); /** * Sets the data to send with an (LAN server discovery) /(offline ping) response * Length should be under 400 bytes, as a security measure against flood attacks * See the Ping sample project for how this is used. * @param data a block of data to store, or 0 for none * @param length The length of data in bytes, or 0 for none */ void SetOfflinePingResponse( const char *data, const unsigned int length ); /* * -------------------------------------------------------------------------------------------- * Network Functions - Functions dealing with the network in general * -------------------------------------------------------------------------------------------- */ /** * Return the unique address identifier that represents you on the the network and is based on your local IP / port * Note that unlike in previous versions, this is a struct and is not sequential */ PlayerID GetInternalID( void ) const; /** * Return the unique address identifier that represents you on the the network and is based on your external * IP / port (the IP / port the specified player uses to communicate with you) * @note that unlike in previous versions, this is a struct and is not sequential * * @param target Which remote system you are referring to for your external ID */ PlayerID GetExternalID( PlayerID target ) const; /** * Change the MTU size in order to improve performance when sending large packets * This can only be called when not connected. * A too high of value will cause packets not to arrive at worst and be fragmented at best. * A too low of value will split packets unnecessarily. * * Parameters: * @param size: Set according to the following table: * - 1500. The largest Ethernet packet size; it is also the default value. * This is the typical setting for non-PPPoE, non-VPN connections. The default value for NETGEAR routers, adapters and switches. * - 1492. The size PPPoE prefers. * - 1472. Maximum size to use for pinging. (Bigger packets are fragmented.) * - 1468. The size DHCP prefers. * - 1460. Usable by AOL if you don't have large email attachments, etc. * - 1430. The size VPN and PPTP prefer. * - 1400. Maximum size for AOL DSL. * - 576. Typical value to connect to dial-up ISPs. (Default) * * @return False on failure (we are connected). True on success. Maximum allowed size is MAXIMUM_MTU_SIZE */ bool SetMTUSize( int size ); /** * Returns the current MTU size * * @return The MTU sized specified in SetMTUSize */ int GetMTUSize( void ) const; /** * Returns the number of IP addresses we have */ unsigned GetNumberOfAddresses( void ); /** * Returns the dotted IP address for the specified playerId * * @param playerId Any player ID other than UNASSIGNED_PLAYER_ID, even if that player is not currently connected */ const char* PlayerIDToDottedIP( PlayerID playerId ) const; /** * Converts a dotted IP to a playerId * * @param[in] host Either a dotted IP address or a domain name * @param[in] remotePort Which port to connect to on the remote machine. * @param[out] playerId The result of this operation */ void IPToPlayerID( const char* host, unsigned short remotePort, PlayerID *playerId ); /** * Returns an IP address at index 0 to GetNumberOfAddresses-1 */ const char* GetLocalIP( unsigned int index ); /** * Allow or disallow connection responses from any IP. Normally this should be false, but may be necessary * when connection to servers with multiple IP addresses. * * @param allow - True to allow this behavior, false to not allow. Defaults to false. Value persists between connections */ void AllowConnectionResponseIPMigration( bool allow ); /** * Sends a one byte message ID_ADVERTISE_SYSTEM to the remote unconnected system. * This will tell the remote system our external IP outside the LAN, and can be used for NAT punch through * * Requires: * The sender and recipient must already be started via a successful call to Initialize * * @param host Either a dotted IP address or a domain name * @param remotePort Which port to connect to on the remote machine. * @param data Optional data to append to the packet. * @param dataLength length of data in bytes. Use 0 if no data. */ void AdvertiseSystem( char *host, unsigned short remotePort, const char *data, int dataLength ); /* * -------------------------------------------------------------------------------------------- * Compression Functions - Functions related to the compression layer * -------------------------------------------------------------------------------------------- */ /** * Enables or disables our tracking of bytes input to and output from the network. * This is required to get a frequency table, which is used to generate a new compression layer. * You can call this at any time - however you SHOULD only call it when disconnected. Otherwise you will only track * part of the values sent over the network. * This value persists between connect calls and defaults to false (no frequency tracking) * * @param doCompile - true to track bytes. Defaults to false */ void SetCompileFrequencyTable( bool doCompile ); /** * Returns the frequency of outgoing bytes into outputFrequencyTable * The purpose is to save to file as either a master frequency table from a sample game session for passing to * GenerateCompressionLayer(false); * You should only call this when disconnected. * Requires that you first enable data frequency tracking by calling SetCompileFrequencyTable(true) * * @param[out] outputFrequencyTable The frequency of each corresponding byte * * @return False (failure) if connected or if frequency table tracking is not enabled. Otherwise true (success) */ bool GetOutgoingFrequencyTable( unsigned int outputFrequencyTable[ 256 ] ); /** * Generates the compression layer from the input frequency table. * You should call this twice - once with inputLayer as true and once as false. * The frequency table passed here with inputLayer=true should match the frequency table on the recipient with inputLayer=false. * Likewise, the frequency table passed here with inputLayer=false should match the frequency table on the recipient with inputLayer=true * Calling this function when there is an existing layer will overwrite the old layer * You should only call this when disconnected * * @param inputFrequencyTable The frequency table returned from GetSendFrequencyTable(...); * @param inputLayer Whether inputFrequencyTable represents incoming data from other systems (true) or outgoing data from this system (false) * * @return False on failure (we are connected). True otherwise */ bool GenerateCompressionLayer( unsigned int inputFrequencyTable[ 256 ], bool inputLayer ); /** * Deletes the output or input layer as specified. This is not necessary to call and is only valuable for freeing memory * You should only call this when disconnected * * @param inputLayer Specifies the corresponding compression layer generated by GenerateCompressionLayer. * * @return False on failure (we are connected). True otherwise */ bool DeleteCompressionLayer( bool inputLayer ); /** * Get the compression ratio. A low compression ratio is good. Compression is for outgoing data * @return The compression ratio. */ float GetCompressionRatio( void ) const; /** * Get the decompression ratio. A high decompression ratio is good. Decompression is for incoming data * @return The decompression ratio. */ float GetDecompressionRatio( void ) const; /* * -------------------------------------------------------------------------------------------- * Message Handler Functions * -------------------------------------------------------------------------------------------- */ /** * Attatches a message handler interface to run code automatically on message receipt in the Receive call * * @param messageHandler Pointer to a message handler to attach */ void AttachMessageHandler( MessageHandlerInterface *messageHandler ); /** * Detatches a message handler interface to run code automatically on message receipt * * @param messageHandler Pointer to a message handler to detatch */ void DetachMessageHandler( MessageHandlerInterface *messageHandler ); /* * -------------------------------------------------------------------------------------------- * Micellaneous Functions * -------------------------------------------------------------------------------------------- */ /** * Retrieves the data you passed to the passwordData parameter in Connect * * @param[out] passwordData Should point to a block large enough to hold the password data you passed to Connect * @param passwordDataLength Maximum size of the array passwordData. Modified to hold the number of bytes actually written */ void GetPasswordData( char *passwordData, int *passwordDataLength ); /** * Put a packet back at the end of the receive queue in case you don't want to deal with it immediately * * @param packet The packet you want to push back. */ void PushBackPacket( Packet *packet ); /* * -------------------------------------------------------------------------------------------- * Statistical Functions - Functions dealing with API performance * -------------------------------------------------------------------------------------------- */ /** * Returns a structure containing a large set of network statistics for the specified system * You can map this data to a string using the C style StatisticsToString function * * @param playerId Which connected system to get statistics for * * @return 0 on can't find the specified system. A pointer to a set of data otherwise. */ RakNetStatisticsStruct * const GetStatistics( PlayerID playerId ); /** * @brief Used to unify time * * * This structure agregate the ping time and the clock differential. * both are used to synchronized time between peers */ struct PingAndClockDifferential { /** * ping time */ short pingTime; /** * clock differential */ unsigned int clockDifferential; }; /** * @brief Store Remote System Description. * * RakPeer need to maintain a set of information concerning all remote peer * This is the goal of this structure. */ struct RemoteSystemStruct { PlayerID playerId; /**< The remote system associated with this reliability layer*/ PlayerID myExternalPlayerId; /**< Your own IP, as reported by the remote system*/ ReliabilityLayer reliabilityLayer; /**< The reliability layer associated with this player*/ bool weInitiatedTheConnection; /**< True if we started this connection via Connect. False if someone else connected to us.*/ PingAndClockDifferential pingAndClockDifferential[ PING_TIMES_ARRAY_SIZE ]; /**< last x ping times and calculated clock differentials with it*/ int pingAndClockDifferentialWriteIndex; /**< The index we are writing into the pingAndClockDifferential circular buffer*/ int lowestPing; /**<The lowest ping value encounter */ unsigned int nextPingTime; /**< When to next ping this player */ unsigned int lastReliableSend; /**< When did the last reliable send occur. Reliable sends must occur at least once every TIMEOUT_TIME/2 units to notice disconnects */ RakNet::BitStream staticData; /**< static data */ unsigned int connectionTime; /**< connection time, if active. */ unsigned char AESKey[ 16 ]; /**< Security key. */ bool setAESKey; /**< true if security is enabled. */ RPCMap rpcMap; /**< Mapping of RPC calls to single byte integers to save transmission bandwidth. */ enum ConnectMode {NO_ACTION, DISCONNECT_ASAP, REQUESTED_CONNECTION, HANDLING_CONNECTION_REQUEST, UNVERIFIED_SENDER, SET_ENCRYPTION_ON_MULTIPLE_16_BYTE_PACKET, CONNECTED} connectMode; }; protected: #ifdef _WIN32 // friend unsigned __stdcall RecvFromNetworkLoop(LPVOID arguments); friend void __stdcall ProcessPortUnreachable( unsigned int binaryAddress, unsigned short port, RakPeer *rakPeer ); friend void __stdcall ProcessNetworkPacket( unsigned int binaryAddress, unsigned short port, const char *data, int length, RakPeer *rakPeer ); friend unsigned __stdcall UpdateNetworkLoop( LPVOID arguments ); #else // friend void* RecvFromNetworkLoop( void* arguments ); friend void ProcessPortUnreachable( unsigned int binaryAddress, unsigned short port, RakPeer *rakPeer ); friend void ProcessNetworkPacket( unsigned int binaryAddress, unsigned short port, const char *data, int length, RakPeer *rakPeer ); friend void* UpdateNetworkLoop( void* arguments ); #endif //void RemoveFromRequestedConnectionsList( PlayerID playerId ); bool SendConnectionRequest( const char* host, unsigned short remotePort ); /** * Get the reliability layer associated with a playerID. * @param playerID The player identifier * @return 0 if none */ RemoteSystemStruct *GetRemoteSystemFromPlayerID( PlayerID playerID ) const; /** * Parse out a connection request packet */ void ParseConnectionRequestPacket( RakPeer::RemoteSystemStruct *remoteSystem, PlayerID playerId, const char *data, int byteSize); /** * When we get a connection request from an ip / port, accept it unless full */ void OnConnectionRequest( RakPeer::RemoteSystemStruct *remoteSystem, unsigned char *AESKey, bool setAESKey ); /** * Send a reliable disconnect packet to this player and disconnect them when it is delivered */ void NotifyAndFlagForDisconnect( PlayerID playerId, bool performImmediate ); /** * Returns how many remote systems initiated a connection to us */ unsigned short GetNumberOfRemoteInitiatedConnections( void ) const; /** * Get a free remote system from the list and assign our playerID to it. Should only be called from the update thread - not the user thread */ RemoteSystemStruct * AssignPlayerIDToRemoteSystemList( PlayerID playerId, RemoteSystemStruct::ConnectMode connectionMode ); /** * An incoming packet has a timestamp, so adjust it to be relative to this system */ void ShiftIncomingTimestamp( char *data, PlayerID playerId ) const; /** * Get the most probably accurate clock differential for a certain player */ unsigned int GetBestClockDifferential( PlayerID playerId ) const; /** * @todo Document this * */ void PushPortRefused( PlayerID target ); /** * Handles an RPC packet. If you get a packet with the ID ID_RPC you should pass it to this function * This is already done in Multiplayer.cpp, so if you use the Multiplayer class it is handled for you. * * @param data A packet returned from Receive with the ID ID_RPC * @param length The size of the packet data * @param playerId The sender of the packet * * @return true on success, false on a bad packet or an unregistered function */ bool HandleRPCPacket( const char *data, int length, PlayerID playerId ); #ifdef __USE_IO_COMPLETION_PORTS bool SetupIOCompletionPortSocket( int index ); #endif /** * Set this to true to terminate the Peer thread execution */ bool endThreads; /** * true if the peer thread is active. */ bool isMainLoopThreadActive; // bool isRecvfromThreadActive; /**< Tracks thread states */ bool occasionalPing; /**< Do we occasionally ping the other systems?*/ /** * Store the maximum number of peers allowed to connect */ unsigned short maximumNumberOfPeers; /** * Store the maximum number of peers able to connect, including reserved connection slots for pings, etc. */ unsigned short remoteSystemListSize; /** * Store the maximum incoming connection allowed */ unsigned short maximumIncomingConnections; /** * localStaticData necessary because we may not have a RemoteSystemStruct representing ourselves in the list */ RakNet::BitStream incomingPasswordBitStream, outgoingPasswordBitStream, localStaticData, offlinePingResponse; /** * Local Player ID */ PlayerID myPlayerId; /** * This is an array of pointers to RemoteSystemStruct * This allows us to preallocate the list when starting, so we don't have to allocate or delete at runtime. * Another benefit is that is lets us add and remove active players simply by setting playerId * and moving elements in the list by copying pointers variables without affecting running threads, even if they are in the * reliability layer */ RemoteSystemStruct* remoteSystemList; enum { // requestedConnections_MUTEX, incomingPasswordBitStream_Mutex, outgoingPasswordBitStream_Mutex, // remoteSystemList_Mutex, /**< This mutex is to lock remoteSystemList::PlayerID and only used for critical cases */ // updateCycleIsRunning_Mutex, offlinePingResponse_Mutex, //bufferedCommandQueue_Mutex, /**< This mutex is to buffer all send calls to run from the update thread. This is to get around the problem of the update thread changing playerIDs in the remoteSystemList while in the send call and thus having the sends go to the wrong player */ //bufferedCommandPool_Mutex, /**< This mutex is to buffer all send calls to run from the update thread. This is to get around the problem of the update thread changing playerIDs in the remoteSystemList while in the send call and thus having the sends go to the wrong player */ NUMBER_OF_RAKPEER_MUTEXES }; SimpleMutex rakPeerMutexes[ NUMBER_OF_RAKPEER_MUTEXES ]; /** * RunUpdateCycle is not thread safe but we don't need to mutex calls. Just skip calls if it is running already */ bool updateCycleIsRunning; /** * The list of people we have tried to connect to recently */ //BasicDataStructures::Queue<RequestedConnectionStruct*> requestedConnectionsList; /** * Data that both the client and the server needs */ unsigned int bytesSentPerSecond, bytesReceivedPerSecond; // bool isSocketLayerBlocking; // bool continualPing,isRecvfromThreadActive,isMainLoopThreadActive, endThreads, isSocketLayerBlocking; unsigned int validationInteger; #ifdef _WIN32 HANDLE #else pthread_t #endif processPacketsThreadHandle, recvfromThreadHandle; SimpleMutex incomingQueueMutex, banListMutex; //,synchronizedMemoryQueueMutex, automaticVariableSynchronizationMutex; BasicDataStructures::Queue<Packet *> incomingPacketQueue; //, synchronizedMemoryPacketQueue; // BitStream enumerationData; /** * @brief Automatic Variable Synchronization Mechanism * * automatic variable synchronization takes a primary and secondary identifier * The unique primary identifier is the index into the automaticVariableSynchronizationList * The unique secondary identifier (UNASSIGNED_OBJECT_ID for none) is in an unsorted list of memory blocks */ struct MemoryBlock { char *original, *copy; unsigned short size; ObjectID secondaryID; bool isAuthority; bool ( *synchronizationRules ) ( char*, char* ); }; struct BanStruct { char *IP; unsigned int timeout; // 0 for none }; struct RequestedConnectionStruct { PlayerID playerId; unsigned int nextRequestTime; unsigned char requestsMade; char *data; unsigned short dataLength; enum {CONNECT=1, PING=2, PING_OPEN_CONNECTIONS=4, ADVERTISE_SYSTEM=8} actionToTake; }; //BasicDataStructures::List<BasicDataStructures::List<MemoryBlock>* > automaticVariableSynchronizationList; BasicDataStructures::List<BanStruct*> banList; BasicDataStructures::List<MessageHandlerInterface*> messageHandlerList; BasicDataStructures::SingleProducerConsumer<RequestedConnectionStruct> requestedConnectionList; /* * Compression stuff */ unsigned int frequencyTable[ 256 ]; HuffmanEncodingTree *inputTree, *outputTree; unsigned int rawBytesSent, rawBytesReceived, compressedBytesSent, compressedBytesReceived; // void DecompressInput(RakNet::BitStream *bitStream); // void UpdateOutgoingFrequencyTable(RakNet::BitStream * bitStream); void GenerateSYNCookieRandomNumber( void ); void SecuredConnectionResponse( PlayerID playerId ); void SecuredConnectionConfirmation( RakPeer::RemoteSystemStruct * remoteSystem, char* data ); bool RunUpdateCycle( void ); // void RunMutexedUpdateCycle(void); struct BufferedCommandStruct { char *data; int numberOfBitsToSend; PacketPriority priority; PacketReliability reliability; char orderingChannel; PlayerID playerId; bool broadcast; RemoteSystemStruct::ConnectMode connectionMode; ObjectID objectID; enum {BCS_SEND, BCS_CLOSE_CONNECTION, BCS_RPC, BCS_RPC_SHIFT, BCS_DO_NOTHING} command; }; // Single producer single consumer queue using a linked list //BufferedCommandStruct* bufferedCommandReadIndex, bufferedCommandWriteIndex; BasicDataStructures::SingleProducerConsumer<BufferedCommandStruct> bufferedCommands; //BasicDataStructures::Queue<BufferedCommandStruct *> bufferedCommandQueue; //BasicDataStructures::Queue<BufferedCommandStruct *> bufferedCommandPool; //RakPeer::BufferedCommandStruct *LockWriteBufferedCommandStruct(bool *outParam_wasInserted); // Get the next BCS to write //void UnlockWriteBufferedCommandStruct(RakPeer::BufferedCommandStruct *bcs, bool *outParam_wasInserted); // Done with the next BCS to write //RakPeer::BufferedCommandStruct *LockReadBufferedCommandStruct(void); // Get the next BCS to read //RakPeer::BufferedCommandStruct *UnlockReadBufferedCommandStruct(void); // Done with the next BCS to read //void FreeBufferedCommandStruct(RakPeer::BufferedCommandStruct *bcs); bool AllowIncomingConnections(void) const; // Sends static data using immediate send mode or not (if called from user thread, put false for performImmediate. If called from update thread, put true). // This is done for efficiency, so we don't buffer send calls that are from the network thread anyway void SendStaticDataInternal( PlayerID target, bool performImmediate ); void PingInternal( PlayerID target, bool performImmediate ); bool ValidSendTarget(PlayerID playerId, bool broadcast); // This stores the user send calls to be handled by the update thread. This way we don't have thread contention over playerIDs void CloseConnectionInternal( PlayerID target, bool sendDisconnectionNotification, bool performImmediate ); void SendBuffered( RakNet::BitStream * bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, PlayerID playerId, bool broadcast, RemoteSystemStruct::ConnectMode connectionMode ); bool SendImmediate( char *data, int numberOfBitsToSend, PacketPriority priority, PacketReliability reliability, char orderingChannel, PlayerID playerId, bool broadcast, bool useCallerDataAllocation, unsigned int currentTime ); bool HandleBufferedRPC(BufferedCommandStruct *bcs, unsigned time); void ClearBufferedCommands(void); void ClearRequestedConnectionList(void); //BasicDataStructures::AVLBalancedBinarySearchTree<RPCNode> rpcTree; RPCMap rpcMap; // Can't use StrPtrHash because runtime insertions will screw up the indices int MTUSize; bool trackFrequencyTable; int threadSleepTimer; SOCKET connectionSocket; // Histogram statistics //unsigned int nextReadBytesTime; //int lastSentBytes,lastReceivedBytes; /* * Encryption and security */ big::RSACrypt<RSA_BIT_SIZE> rsacrypt; big::u32 publicKeyE; RSA_BIT_SIZE publicKeyN; bool keysLocallyGenerated, usingSecurity; unsigned int randomNumberExpirationTime; unsigned char newRandomNumber[ 20 ], oldRandomNumber[ 20 ]; /** * How long it has been since things were updated by a call to receive * Update thread uses this to determine how long to sleep for */ unsigned int lastUserUpdateCycle; /* * True to allow connection accepted packets from anyone. False to only allow these packets from servers * we requested a connection to. */ bool allowConnectionResponseIPMigration; PacketPool packetPool; }; #endif
[ [ [ 1, 1035 ] ] ]
5f1eaa23a5b1f6adda333cfd5776f9d4f71a21b4
9c62af23e0a1faea5aaa8dd328ba1d82688823a5
/rl/tags/v0-1/engine/dialog/include/AimlParser.h
43c0fe73e11fa9decd2f2a64e53a92ac0d7f83dc
[ "ClArtistic", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
jacmoe/dsa-hl-svn
55b05b6f28b0b8b216eac7b0f9eedf650d116f85
97798e1f54df9d5785fb206c7165cd011c611560
refs/heads/master
2021-04-22T12:07:43.389214
2009-11-27T22:01:03
2009-11-27T22:01:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,453
h
/* This source file is part of Rastullahs Lockenpracht. * Copyright (C) 2003-2005 Team Pantheon. http://www.team-pantheon.de * * This program is free software; you can redistribute it and/or modify * it under the terms of the Clarified Artistic License. * * 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 * Clarified Artistic License for more details. * * You should have received a copy of the Clarified Artistic License * along with this program; if not you can get it here * http://www.jpaulmorrison.com/fbp/artistic2.htm. */ #ifndef __Rl_AimlParser_H__ #define __Rl_AimlParser_H__ #include "DialogPrerequisites.h" #include <string> namespace rl { class NaturalLanguageProcessor; class AimlCoreComponent; /** Handler class used to parse the startup xml file and aiml files using SAX2 * @author Philipp Walser */ class _RlDialogExport AimlParser { public: //! Constructor AimlParser(NaturalLanguageProcessor* nlp); AimlParser(AimlCoreComponent* aimlCore); //! Destructor virtual ~AimlParser(void){ } virtual bool parse(const std::string& fileName); protected: std::string mFileName; NaturalLanguageProcessor* mNlp; AimlCoreComponent* mAimlCore; }; } // End of rl namespace section #endif
[ "blakharaz@4c79e8ff-cfd4-0310-af45-a38c79f83013" ]
[ [ [ 1, 50 ] ] ]
4375f08009ffa3ab15213c0521b3e7d2f74cc905
c4e8cb1539bc0cf5cb119af4a6b6212230f937aa
/Babel/IOStreamData.hpp
96aa60093591d4412ab09ef3f09313212493f8b1
[]
no_license
RemiGuillard/Babel-save-03
56e93fd7beda23be5faad102b43090a2d756f0d2
25893350dc14c6434dcc053302440bdca710c59e
refs/heads/master
2021-01-13T02:14:46.982890
2010-11-29T17:40:53
2010-11-29T17:40:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
689
hpp
#ifndef IOSTREAMDATA # define IOSTREAMDATA #define FRAMES_PER_BUFFER (160) #include "UdpNetwork.h" //#include <QMutex> template <typename T> struct IOStreamData { T IBuf[FRAMES_PER_BUFFER]; //QMutex mutex; bool IAvailable; // a transformer en mutex //int IFrameIndex; /* Index into sample array. */ int IMaxFrameIndex; T OBuf[FRAMES_PER_BUFFER]; bool OAvailable; // mutex //int OFrameIndex; /* Index into sample array. */ int OMaxFrameIndex; char encoded[FRAMES_PER_BUFFER]; bool ThreadEnd; UdpNetwork *Net; }; #endif // !IOSTREAMDATA
[ [ [ 1, 26 ] ] ]
b3b09aca23d53618f506c7395883a6f48166dc04
6581dacb25182f7f5d7afb39975dc622914defc7
/EDStock/EDStockDoc.cpp
92136f384fc1104c3c178e7fd3b9a8fddb6e1f8c
[]
no_license
dice2019/alexlabonline
caeccad28bf803afb9f30b9e3cc663bb2909cc4f
4c433839965ed0cff99dad82f0ba1757366be671
refs/heads/master
2021-01-16T19:37:24.002905
2011-09-21T15:20:16
2011-09-21T15:20:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,762
cpp
// EDStockDoc.cpp : implementation of the CEDStockDoc class // #include "stdafx.h" #include "EDStock.h" #include "EDStockDoc.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CEDStockDoc IMPLEMENT_DYNCREATE(CEDStockDoc, CDocument) BEGIN_MESSAGE_MAP(CEDStockDoc, CDocument) //{{AFX_MSG_MAP(CEDStockDoc) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CEDStockDoc construction/destruction CEDStockDoc::CEDStockDoc() { // TODO: add one-time construction code here } CEDStockDoc::~CEDStockDoc() { } BOOL CEDStockDoc::OnNewDocument() { if (!CDocument::OnNewDocument()) return FALSE; // TODO: add reinitialization code here // (SDI documents will reuse this document) return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CEDStockDoc serialization void CEDStockDoc::Serialize(CArchive& ar) { if (ar.IsStoring()) { // TODO: add storing code here } else { // TODO: add loading code here } } ///////////////////////////////////////////////////////////////////////////// // CEDStockDoc diagnostics #ifdef _DEBUG void CEDStockDoc::AssertValid() const { CDocument::AssertValid(); } void CEDStockDoc::Dump(CDumpContext& dc) const { CDocument::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CEDStockDoc commands
[ "damoguyan8844@3a4e9f68-f5c2-36dc-e45a-441593085838" ]
[ [ [ 1, 84 ] ] ]
f8c8022e19edc585991f9cf368457c16a65cab7a
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/_Common/lordskill.cpp
c659d852b793c76d10eef731e404c6900d500b9f
[]
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
5,995
cpp
#include "stdafx.h" #if __VER >= 12 // __LORD #include "lordskill.h" #include "definelordskill.h" #ifdef __WORLDSERVER #include "definetext.h" #include "slord.h" #include "user.h" extern CUserMng g_UserMng; #include "dpsrvr.h" extern CDPSrvr g_DPSrvr; #endif // __WORLDSERVER CLordSkillComponent::CLordSkillComponent() : m_nId( 0 ), m_nCooltime( 0 ), m_nTick( 0 ), m_nItem( 0 ), m_bPassive( 0 ), m_nTargetType( LTT_NA ) #ifdef __CLIENT , m_pTexture( NULL ) , m_dwSrcSfx( NULL_ID ) , m_dwDstSfx( NULL_ID ) #endif // __CLIENT { *m_szName = '\0'; *m_szDesc = '\0'; *m_szIcon = '\0'; } CLordSkillComponent::~CLordSkillComponent() { } void CLordSkillComponent::Initialize( int nId, int nCooltime, int nItem, const char* szName, const char* szDesc, const char* szIcon, BOOL bPassive, int nTargetType, DWORD dwSrcSfx, DWORD dwDstSfx, FLOAT fRange ) { m_nId = nId; m_nCooltime = nCooltime; m_nItem = nItem; lstrcpy( m_szName, szName ); lstrcpy( m_szDesc, szDesc ); lstrcpy( m_szIcon, szIcon ); m_bPassive = bPassive; m_nTargetType = nTargetType; #ifdef __CLIENT m_dwSrcSfx = dwSrcSfx; m_dwDstSfx = dwDstSfx; #endif // __CLIENT #ifndef __DBSERVER m_fRange = fRange; #endif // __DBSERVER } #ifdef __CLIENT CTexture* CLordSkillComponent::GetTexture( void ) { if( !m_pTexture ) m_pTexture = CWndBase::m_textureMng.AddTexture( g_Neuz.m_pd3dDevice, MakePath( DIR_ICON, m_szIcon ), 0xffff00ff ); return m_pTexture; } #endif // __CLIENT int CLordSkillComponent::Tick( void ) { return 0; } //////////////////////////////////////////////////////////////////////////////// CLordSkill::CLordSkill( CLord* pLord ) : m_pLord( pLord ) { } CLordSkill::~CLordSkill() { Clear(); } void CLordSkill::Clear( void ) { for( VLSC::iterator i = m_vComponents.begin(); i != m_vComponents.end(); ++i ) safe_delete( *i ); m_vComponents.clear(); } void CLordSkill::AddSkillComponent( CLordSkillComponentExecutable* pComponent ) { m_vComponents.push_back( pComponent ); } CLordSkillComponentExecutable* CLordSkill::GetSkill( int nId ) { for( VLSC::iterator i = m_vComponents.begin(); i != m_vComponents.end(); ++i ) { if( ( *i )->GetId() == nId ) return ( *i ); } return NULL; } CLordSkillComponentExecutable* CLordSkill::CreateSkillComponent( int nType ) { return new CLordSkillComponentExecutable; } void CLordSkill::Reset( void ) { for( VLSC::iterator i = m_vComponents.begin(); i != m_vComponents.end(); ++i ) ( *i )->SetTick( 0 ); } BOOL CLordSkill::Initialize( const char* szFile ) { CScript s; if( !s.Load( szFile, FALSE ) ) return FALSE; int nId = s.GetNumber(); while( s.tok != FINISHED ) { char szName[CLordSkillComponent::eMaxName] = { 0,}; char szDesc[CLordSkillComponent::eMaxDesc] = { 0,}; char szIcon[CLordSkillComponent::eMaxIcon] = { 0,}; int nType = s.GetNumber(); s.GetToken(); strncpy( szName, s.token, CLordSkillComponent::eMaxName ); szName[CLordSkillComponent::eMaxName - 1] = '\0'; s.GetToken(); strncpy( szDesc, s.token, CLordSkillComponent::eMaxDesc ); szDesc[CLordSkillComponent::eMaxDesc - 1] = '\0'; int nTargetType = s.GetNumber(); int nItem = s.GetNumber(); int nCooltime = s.GetNumber(); s.GetToken(); strncpy( szIcon, s.token, CLordSkillComponent::eMaxIcon ); szIcon[CLordSkillComponent::eMaxIcon - 1] = '\0'; BOOL bPassive = static_cast<BOOL>( s.GetNumber() ); DWORD dwSrcSfx = s.GetNumber(); DWORD dwDstSfx = s.GetNumber(); FLOAT fRange = s.GetFloat(); CLordSkillComponentExecutable* pComponent = CreateSkillComponent( nType ); pComponent->Initialize( nId, nCooltime, nItem, szName, szDesc, szIcon, bPassive, nTargetType, dwSrcSfx, dwDstSfx, fRange ); AddSkillComponent( pComponent ); nId = s.GetNumber(); } return TRUE; } void CLordSkill::SerializeTick( CAr & ar ) { if( ar.IsStoring() ) { ar << m_vComponents.size(); for( VLSC::iterator i = m_vComponents.begin(); i != m_vComponents.end(); ++i ) { ar << ( *i )->GetId(); ar << ( *i )->GetTick(); } } else { size_t nSize; ar >> nSize; for( size_t i = 0; i < nSize; i++ ) { int nSkill, nTick; ar >> nSkill >> nTick; CLordSkillComponent* pSkill = GetSkill( nSkill ); if( pSkill ) pSkill->SetTick( nTick ); } } } #ifdef __WORLDSERVER int CLordSkillComponentExecutable::IsExecutable( CUser* pUser, const char* szTarget, u_long & idTarget ) { if( !CSLord::Instance()->IsLord( pUser->m_idPlayer ) ) return TID_GAME_LORD_SKILL_USE_E001; if( IsPassive() ) return TID_GAME_LORD_SKILL_USE_E003; idTarget = pUser->m_idPlayer; if( GetTargetType() != LTT_SELF ) { idTarget = CPlayerDataCenter::GetInstance()->GetPlayerId( const_cast<char*>( szTarget ) ); CUser* pTarget = g_UserMng.GetUserByPlayerID( idTarget ); if( !IsValidObj( pTarget ) || ( GetTargetType() == LTT_OTHER && pTarget == pUser ) ) return TID_GAME_LORD_SKILL_USE_E004; if( GetRange() != 0.0F ) { D3DXVECTOR3 v = pUser->GetPos() - pTarget->GetPos(); FLOAT fLengthSq = D3DXVec3LengthSq( &v ); if( fLengthSq > GetRange() * GetRange() ) return TID_GAME_LORD_SKILL_USE_E008; } // 12-2 康 - 일반화 대상 if( GetId() == LI_RAGE && pTarget->IsAuthHigher( AUTH_GAMEMASTER ) ) return TID_GAME_LORD_SKILL_USE_E004; } return 0; } int CLordSkillComponentExecutable::IsTeleportable( CUser* pUser, CUser* pTarget ) { ASSERT( pTarget ); if( pTarget->IsAuthHigher( AUTH_GAMEMASTER ) ) return TID_GAME_LORD_SKILL_USE_E004; if( !pUser->IsTeleportable() ) return TID_GAME_LORD_SKILL_USE_E009; if( !pTarget->IsTeleportable() ) return TID_GAME_LORD_SKILL_USE_E010; return 0; } void CLordSkillComponentExecutable::PutSkillLog( CUser* pUser ) { g_DPSrvr.PutPenyaLog( pUser, "s", GetName(), 0 ); } #endif // __WORLDSERVER #endif // __LORD
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 228 ] ] ]
07c5851e567e29ba23e000f215d6f8c072c6c5bb
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/regex/example/snippets/regex_token_iterator_eg_1.cpp
c2196dc6a4d4c51538e994c9d0670b148802e8f4
[ "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
1,556
cpp
/* * * Copyright (c) 12003 * John Maddock * * 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) * */ /* * LOCATION: see http://www.boost.org for most recent version. * FILE regex_token_iterator_example_1.cpp * VERSION see <boost/version.hpp> * DESCRIPTION: regex_token_iterator example: split a string into tokens. */ #include <boost/regex.hpp> #include <iostream> using namespace std; #if defined(BOOST_MSVC) || (defined(__BORLANDC__) && (__BORLANDC__ == 0x550)) // // problem with std::getline under MSVC6sp3 istream& getline(istream& is, std::string& s) { s.erase(); char c = is.get(); while(c != '\n') { s.append(1, c); c = is.get(); } return is; } #endif int main(int argc) { string s; do{ if(argc == 1) { cout << "Enter text to split (or \"quit\" to exit): "; getline(cin, s); if(s == "quit") break; } else s = "This is a string of tokens"; boost::regex re("\\s+"); boost::sregex_token_iterator i(s.begin(), s.end(), re, -1); boost::sregex_token_iterator j; unsigned count = 0; while(i != j) { cout << *i++ << endl; count++; } cout << "There were " << count << " tokens found." << endl; }while(argc == 1); return 0; }
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 72 ] ] ]
74cfce8830773253dc19112428e2ef4ca807cdf7
cfcd2a448c91b249ea61d0d0d747129900e9e97f
/thirdparty/OpenCOLLADA/COLLADAFramework/src/COLLADAFWRotate.cpp
a78f766b0e5316b47577cbe96d5082244bc6c4b8
[]
no_license
fire-archive/OgreCollada
b1686b1b84b512ffee65baddb290503fb1ebac9c
49114208f176eb695b525dca4f79fc0cfd40e9de
refs/heads/master
2020-04-10T10:04:15.187350
2009-05-31T15:33:15
2009-05-31T15:33:15
268,046
0
0
null
null
null
null
UTF-8
C++
false
false
1,181
cpp
/* Copyright (c) 2008 NetAllied Systems GmbH This file is part of COLLADAFramework. Licensed under the MIT Open Source License, for details please see LICENSE file or the website http://www.opensource.org/licenses/mit-license.php */ #include "COLLADAFWStableHeaders.h" #include "COLLADAFWRotate.h" namespace COLLADAFW { //-------------------------------------------------------------------- Rotate::Rotate() : Transformation(Transformation::ROTATE), mRotationAxis(COLLADABU::Math::Vector3::ZERO), mRotationAngle(0.0) { } //-------------------------------------------------------------------- Rotate::Rotate( const COLLADABU::Math::Vector3& rotationAxis, double rotationAngle ) : Transformation(Transformation::ROTATE), mRotationAxis(rotationAxis), mRotationAngle(rotationAngle) { } Rotate::Rotate( double x, double y, double z, double rotationAngle ) : Transformation(Transformation::ROTATE), mRotationAxis(COLLADABU::Math::Vector3(x, y, z)), mRotationAngle(rotationAngle) { } //-------------------------------------------------------------------- Rotate::~Rotate() { } } // namespace COLLADAFW
[ [ [ 1, 44 ] ] ]
cdb8ddd9d2582017ffe3a2284cf601eab8d7727f
c95a83e1a741b8c0eb810dd018d91060e5872dd8
/Engine/sdk/inc/cuicheck.h
01520a08ae906f7ca4f2e1d38fd1b80f3bd2a063
[]
no_license
rickyharis39/nolf2
ba0b56e2abb076e60d97fc7a2a8ee7be4394266c
0da0603dc961e73ac734ff365bfbfb8abb9b9b04
refs/heads/master
2021-01-01T17:21:00.678517
2011-07-23T12:11:19
2011-07-23T12:11:19
38,495,312
1
0
null
null
null
null
UTF-8
C++
false
false
2,113
h
//------------------------------------------------------------------- // // MODULE : CUICHECK.H // // PURPOSE : Defines the interface for The CUICheck Widget // // CREATED : 4/01 // // COPYRIGHT : (C) 2001 LithTech Inc // //------------------------------------------------------------------- #ifndef __CUICHECK_H__ #define __CUICHECK_H__ #ifndef __CUIBUTTON_H__ #include "cuibutton.h" #endif /*! CUICheck is one of the CUI widgets. It displays a string of text (using an internal CUIPolyString), a background image and one of the following CUI_ELEMENTTYPEs based on its state: CUIE_BG, CUIE_CHECK_ON, CUIE_CHECK_OFF, CUIE_CHECK_DISABLED. \see ILTWidgetManager \see CUI_ELEMENTTYPE \see SetState() Used for: Text and UI. */ class CUICheck : public CUIButton { public: #ifndef DOXYGEN_SHOULD_SKIP_THIS // CUIWidgets should not be created with new and delete, but should instead // be created via the ILTWindowManager's CreateWidget() and DestroyWidget() // management functions. CUICheck(); CUICheck(CUIGUID guid); virtual ~CUICheck(); #endif /* DOXYGEN_SHOULD_SKIP_THIS */ /*! \param value true or false \return the previous value Use this function to set a CUICheck widget's state. If \e value is \b true, this function is equivalent to calling CUIBase::SetState(CUIS_PRESSED). if \e value is \b false, this function is equivalent to calling CUIBase::UnsetState(CUIS_PRESSED). */ virtual bool SetValue(bool value); /*! \return the current value Use this function to query a CUICheck widget's state. The return is \b true if the widget has the state CUIS_PRESSED set, or \b false otherwise. */ virtual bool GetValue(); /*! \return the previous value Use this function to toggle a CUICheck widget's state. If the widget currently has the state CUIS_PRESSED set, the return will be \b true and the state will be unset. If CUIS_PRESSED is not currently set, \b false will be returned and the state will be set. */ virtual bool Toggle(); }; #endif //__CUICHECK_H__
[ [ [ 1, 86 ] ] ]
b6c3bd6cc0a449030415634bfd373e4e0e9418a4
37ade55537ef49661ed568a0824c42a68cdceade
/LOG.h
eaf8bae8d106e8cfa9e15f14427fe9651bf69213
[]
no_license
ranzoken/gsm
f4e787b987795deb47fa69ed1d65df8d99954a1f
e331af7fd194ebc680f291df311227876c622fe4
refs/heads/master
2021-01-18T03:57:07.134247
2011-10-14T12:24:44
2011-10-14T12:24:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
576
h
/* LOG.h - Library for standard logging convention. Created by Meir Michanie, June 9, 2010. Released into the public domain. Version 0.1 */ #ifndef LOG_h #define LOG_h #include "WProgram.h" class LOG { public: LOG(int level); void DEBUG(const char* string); void INFO(const char* string); void WARNING(const char* string); void CRITICAL(const char* string); void DATA(const char* string); void DATA(int number); inline int getLevel(void) { return _level; } inline void setLevel(int level) { _level = level; } private: int _level; }; #endif
[ [ [ 1, 30 ] ] ]
66f2d7849e27a02b5a027c4547c3d7578d4da7a1
cd387cba6088f351af4869c02b2cabbb678be6ae
/src/experimental/petesimulator/Dispensor.cpp
f095d784b1d7779fce48be2e2efab5066a505481
[]
no_license
pedromartins/mew-dev
e8a9cd10f73fbc9c0c7b5bacddd0e7453edd097e
e6384775b00f76ab13eb046509da21d7f395909b
refs/heads/master
2016-09-06T14:57:00.937033
2009-04-13T15:16:15
2009-04-13T15:16:15
32,332,332
0
0
null
null
null
null
UTF-8
C++
false
false
217
cpp
#include "Dispensor.h" Dispensor::Dispensor(bool col, int cyl) { //Initialise with number of cylinders cylinders = cyl; color = col; realSize = new Point(80,80); } Dispensor::~Dispensor(void) { }
[ "fushunpoon@1fd432d8-e285-11dd-b2d9-215335d0b316" ]
[ [ [ 1, 14 ] ] ]
1dd9b0ca390758100e197a7d2fb7a786ba69bd5c
aca65a1eb785ebe6d6e0e862f3b49931923da90b
/DTI Visualization/Hypergraph.cpp
ea557d1bb4f31e6fef6655063ed36d8b2bbb05d1
[]
no_license
vcpudding/DTI-Visualization-Hypergraph
d5126a0123707a2b1399a73751aa9bec88c1e25c
23da494ba4291450cdece4bda421853ec2beedfc
refs/heads/master
2020-06-05T09:47:30.924373
2011-12-29T13:13:44
2011-12-29T13:13:44
3,026,931
0
0
null
null
null
null
UTF-8
C++
false
false
47,220
cpp
#include "Hypergraph.h" #include <fstream> #include <string> #include <sstream> #include <GL/glut.h> #include <time.h> #include <Windows.h> #include <QProgressDialog> Hypergraph::Hypergraph(void) { _layoutDim = 2; _nVertices = 0; _edges = vector<HyperEdge> (0); _layout = vector<fvec> (0); //_colorTable = new ColorTable(); } Hypergraph::~Hypergraph(void) { } void Hypergraph::setNumOfVertices(int nVertices) { _nVertices = nVertices; _selectedBuf.resize(nVertices); _selectedBuf.assign(nVertices, false); _clusters.resize(_nVertices); } void Hypergraph::saveHypergraph(const QString &fileName) { ofstream graphFile (fileName.toStdString().c_str()); graphFile <<_nVertices<<"\n"; for (int i=0; i<_edges.size(); ++i) { for (int j=0; j<_edges[i].size(); ++j) { graphFile <<_edges[i][j] <<"\t"; } graphFile <<"\n"; } graphFile.close(); } void Hypergraph::loadHypergraph(const QString &fileName) { ifstream graphFile (fileName.toStdString().c_str()); graphFile >>_nVertices; setNumOfVertices(_nVertices); string line; _edges.clear(); while(getline(graphFile,line)) { stringstream strLine(line); HyperEdge e(0); int fibIdx; while (strLine >>fibIdx) { e.push_back(fibIdx); } if (!e.empty()) { _edges.push_back(e); } } graphFile.close(); } void Hypergraph::layoutGraph( int boundary [], int dim/*=2*/, float c/*=1.0*/ ) { _layoutDim = dim; int nIteration = 500; float temperature = 10; srand(time(NULL)); int area = 1; for (int i=0; i<dim; ++i) { area *= boundary[2*i+1]-boundary[2*i]; } float k = c*sqrt(area*1.0f/_nVertices); /*initialize vertex layout*/ int nEdges = _edges.size(); int nTotal = _nVertices+nEdges; _layout.resize(nTotal); vector<fvec> dispBuf (nTotal); for (int i=0; i<nTotal; ++i) { _layout[i] = fvec(dim); for (int j=0; j<dim; ++j) { _layout[i](j) = boundary[2*j]+rand()%(boundary[2*j+1]-boundary[2*j]); } dispBuf[i] = fvec(dim); } int i,j; QProgressDialog prog ("Performing graph layout ...", "", 0, nIteration-1); prog.setCancelButton(NULL); for (int it=0; it<nIteration; ++it) { DWORD t1 = GetTickCount(); bool bChanged = false; for (i=0; i<nTotal; ++i) { dispBuf[i].fill(0); } DWORD t2 = GetTickCount(); /*calculate repulsive force*/ for (i=0; i<nTotal; ++i) { for (j=0; j<i; ++j) { if (j==i) { continue; } fvec disp = getRepulsiveForce(_layout[i], _layout[j], k); dispBuf[j] += disp; dispBuf[i] -= disp; } } DWORD tRepForce = GetTickCount()-t2; /*calculate attractive force*/ for (i=0; i<_edges.size(); ++i) { int edgeIdx = i+_nVertices; for (j=0; j<_edges[i].size(); ++j) { float c2 = 300.0; fvec disp1 = c2*getAttractiveForce(_layout[_edges[i][j]], _layout[edgeIdx], k); dispBuf[edgeIdx] -= disp1; dispBuf[_edges[i][j]] += disp1; } } DWORD tRepAttrForces = GetTickCount()-t2; /*restrict the points from being pushed towards the boundary*/ for (i=0; i<nTotal; ++i) { for (j=0; j<dim; ++j) { float c1=1.0e6; float x = _layout[i](j); if (x==boundary[j*2] || x==boundary[j*2+1]) { int stop = 1; } float d = c1*(1/(x-boundary[j*2]+1.0e-3)-1/(boundary[j*2+1]-x+1.0e-3)); dispBuf[i](j) += d; } } /*limit the maximum displacement, boundary check*/ for (i=0; i<nTotal; ++i) { float n = norm(dispBuf[i],2); fvec newLayout = _layout[i]+dispBuf[i]*min(n, temperature)/n; for (j=0; j<dim; ++j) { int minBoundary = boundary[2*j]; int maxBoundary = boundary[2*j+1]; newLayout(j) = newLayout(j) < minBoundary?minBoundary:(newLayout(j)>maxBoundary?maxBoundary:newLayout(j)); } if (norm(newLayout-_layout[i], 2)>1.0e-3) { _layout[i] = newLayout; bChanged = true; } } if (!bChanged) { break; } DWORD perItTime = GetTickCount() - t1; t1 = GetTickCount(); prog.setValue(it); } } void Hypergraph::saveLayout(const QString &fileName) { ofstream layoutFile (fileName.toStdString().c_str(), ios::binary); layoutFile.write((char*)&_layoutDim, sizeof(int)); layoutFile.write((char*)&_nVertices, sizeof(int)); int nEdges = _edges.size(); layoutFile.write((char*)&nEdges, sizeof(int)); for (int i=0; i<nEdges; ++i) { int edgeSize = _edges[i].size(); layoutFile.write((char*)&edgeSize, sizeof(int)); for (int j=0; j<edgeSize; ++j) { layoutFile.write((char*)&(_edges[i][j]), sizeof(int)); } } for(int i=0; i<_nVertices+nEdges; ++i) { layoutFile.write((char*)_layout[i].memptr(), _layoutDim*sizeof(float)); } layoutFile.close(); } void Hypergraph::loadLayout(const QString &fileName) { ifstream layoutFile (fileName.toStdString().c_str(), ios::binary); layoutFile.read((char*)&_layoutDim, sizeof(int)); layoutFile.read((char*)&_nVertices, sizeof(int)); setNumOfVertices(_nVertices); int nEdges; layoutFile.read((char*)&nEdges, sizeof(int)); _edges.clear(); for (int i=0; i<nEdges; ++i) { int edgeSize; layoutFile.read((char*)&edgeSize, sizeof(int)); HyperEdge e (edgeSize); for (int j=0; j<edgeSize; ++j) { layoutFile.read((char*)&(e[j]), sizeof(int)); } _edges.push_back(e); } _layout.resize(_nVertices+nEdges); for(int i=0; i<_nVertices+nEdges; ++i) { _layout[i] = fvec(_layoutDim); layoutFile.read((char*)_layout[i].memptr(), _layoutDim*sizeof(float)); } layoutFile.close(); } void Hypergraph::drawHypergraph() { if (_layout.empty()) { return; } for (int i=0; i<_edges.size(); ++i) { int edgeIdx = i+_nVertices; for (int j=0; j<_edges[i].size(); ++j) { glBegin(GL_LINES); float alpha = _selectedBuf[_edges[i][j]]?1:0.3; glColor4f(1,1,1,alpha); glVertex2fv(_layout[_edges[i][j]].memptr()); const uchar *col = _clusterColorer->getColor(i); glColor4ub(col[0], col[1], col[2], alpha*255); glVertex2fv(_layout[edgeIdx].memptr()); glEnd(); } } for (int i=0; i<_nVertices; ++i) { int clusterIdx = _clusters[i]; float alpha = _selectedBuf[i]?1:0.3; const uchar *col = _clusterColorer->getColor(clusterIdx); glColor4ub(col[0], col[1], col[2], alpha*255); glPushMatrix(); /*label the vertex*/ glPushName(i); glTranslatef(_layout[i](0), _layout[i](1), 0); glutSolidSphere(5, 10, 10); glPopName(); glPopMatrix(); if (_layout[i](0)<0 || _layout[i](1)<0 || _layout[i](0)>1000 || _layout[i](1)>700) { int stop = 1; } } GLfloat oldLineWidth; glGetFloatv(GL_LINE_WIDTH, &oldLineWidth); glLineWidth(1); for (int i=0; i<_edges.size(); ++i) { if (_edges[i].empty()) { continue; } //glColor3ubv(_colorTable->getColor(i*1.0/(_edges.size()-1))); glPushMatrix(); /*label the edge*/ glPushName(i+_nVertices); glTranslatef(_layout[_nVertices+i](0), _layout[_nVertices+i](1), 0); glColor3ubv(_clusterColorer->getColor(i)); glutSolidCube(15); glColor4f(1,1,1, 0.3); glutWireCube(16); glPopName(); glPopMatrix(); } for (int i=0; i<_linkageBuf.size(); ++i) { int edgeIdx = _linkageBuf[i]; glPushMatrix(); glTranslatef(_layout[edgeIdx](0), _layout[edgeIdx](1), 0); /*glLineWidth(7); glColor3f(1,1,1); glutWireCube(22);*/ glLineWidth(3); glColor3ubv(_clusterColorer->getColor(edgeIdx-_nVertices)); glutWireCube(22); glPopMatrix(); } glLineWidth(oldLineWidth); } bool * Hypergraph::selectVertices( const vector<int> &selectedIdx, int mode ) { bool *selectionBuf = new bool [_nVertices]; memset(selectionBuf, false, sizeof(bool)*_nVertices); for (int i=0; i<selectedIdx.size(); ++i) { int idx = selectedIdx[i]; if (idx<_nVertices) { selectionBuf[idx] = true; } else if (mode == 0) /*click mode*/ { int edgeIdx = idx-_nVertices; for (int j=0; j<_edges[edgeIdx].size(); ++j) { selectionBuf[_edges[edgeIdx][j]] = true; } } } return selectionBuf; } void Hypergraph::setSelectionBuf(const vector<bool> selectionBuf) { //memcpy(_selectedBuf, selectionBuf, _nVertices*sizeof(bool)); copy(selectionBuf.begin(), selectionBuf.end(), _selectedBuf.begin()); } void Hypergraph::addLinkageEdge( const vector<int> idxBuf ) { for (int i=0; i<idxBuf.size(); ++i) { if (idxBuf[i]>=_nVertices) { _linkageBuf.push_back(idxBuf[i]); } } } void Hypergraph::setLinkageEdge( const vector<int> idxBuf ) { _linkageBuf.clear(); for (int i=0; i<idxBuf.size(); ++i) { if (idxBuf[i]>=_nVertices) { _linkageBuf.push_back(idxBuf[i]); } } } bool * Hypergraph::selectLinkage() { vector<int> result (_nVertices); vector<int>::iterator resultPos = result.begin(); for (int i=0; i<_linkageBuf.size(); ++i) { const HyperEdge & e = _edges[_linkageBuf[i]-_nVertices]; if (i==0) { copy(e.begin(), e.end(), result.begin()); advance(resultPos, e.size()); } else { resultPos = set_intersection(e.begin(), e.end(), result.begin(), resultPos, result.begin()); } } bool *selectionBuf = new bool [_nVertices]; memset(selectionBuf, false, _nVertices*sizeof(bool)); for (vector<int>::iterator it=result.begin(); it!=resultPos; ++it) { selectionBuf[*it] = true; } _linkageBuf.clear(); return selectionBuf; } /* void Hypergraph::resetLinkageBuf() { _linkageBuf.clear(); }*/ void Hypergraph::renewSelection(const bool *selectionBuf, SelectionMode mode) { for (int i=0; i<_nVertices; ++i) { switch (mode) { case SEL_NEW: _selectedBuf[i] = selectionBuf[i]; break; case SEL_INTERSECT: _selectedBuf[i] = selectionBuf[i] & _selectedBuf[i]; break; case SEL_UNION: _selectedBuf[i] = selectionBuf[i] | _selectedBuf[i]; break; case SEL_DIFF: _selectedBuf[i] = selectionBuf[i] ^ _selectedBuf[i]; break; case SEL_REMOVE: _selectedBuf[i] = (~selectionBuf[i]) & _selectedBuf[i]; break; } } } bool Hypergraph::assignSelectedToCluster() { if (_linkageBuf.empty()) { return false; } bool bChanged = false; int edgeIdx = _linkageBuf[0]; int clusterIdx = edgeIdx-_nVertices; for (int i=0; i<_nVertices; ++i) { if (_selectedBuf[i] && _clusters[i]!=clusterIdx) { _clusters[i] = clusterIdx; bChanged = true; } } _linkageBuf.clear(); return bChanged; } void Hypergraph::setClusters(const vector<int> &clusters) { _clusters.resize(clusters.size()); copy(clusters.begin(), clusters.end(), _clusters.begin()); } void Hypergraph::findSampleSets(int vertexIdx, int nTotal, float &maxDist, const vector<float> &distMat, vector<int> &VBuf, vector<int> &SBuf, int Vmax, int Smax) { srand(time(NULL)); SBuf.clear(); if (vertexIdx == 10) { int stop = 1; } /*vector<bool> picked (nTotal); picked.assign(nTotal, false); for (int i=0; i<VBuf.size(); i+=2) { picked[VBuf[i]] = true; }*/ for (int i=0; i<nTotal; ++i) { if (i==vertexIdx /*|| picked[i]*/) { continue; } float p = (Smax-SBuf.size()/2)*1.0f/(nTotal-i); if ((time(NULL)%1000)/1000.0f <= p) { /*point picked*/ float d = i<vertexIdx?distMat[vertexIdx*(vertexIdx-1)/2+i]:distMat[i*(i-1)/2+vertexIdx]; if (d<maxDist) { int j=0; while(j<VBuf.size() && (VBuf[j+1] <d || (VBuf[j+1]==d && VBuf[j]<i))) { j+=2; } if (j==VBuf.size() || VBuf[j+1]>d || VBuf[j] != i) { vector<int>::iterator it = VBuf.insert(VBuf.begin()+j, d); VBuf.insert(it, i); } if (VBuf.size()>=Vmax*2) { VBuf.resize(Vmax*2); maxDist = VBuf[Vmax*2-1]; } } else { SBuf.push_back(i); SBuf.push_back(d); if (SBuf.size()>=Smax*2) { break; } } } } if (VBuf.size()>Vmax*2) { VBuf.resize(Vmax*2); } } void Hypergraph::findSampleSets(int vertexIdx, float &maxDist, const vector<float> &distMat, list<int> &sampleBuf, int &Vsize, int Vmax, int Smax) { //srand(time(NULL)); int nTotal = _nVertices + _edges.size(); int bufMax = Vmax+Smax; list<int>::iterator Vpos = sampleBuf.begin(); advance(Vpos, Vsize*2); sampleBuf.erase(Vpos, sampleBuf.end()); for (int i=0; i<vertexIdx; ++i) { float p = (bufMax-sampleBuf.size()/2)*1.0f/(vertexIdx-i); if ((time(NULL)%1000)/1000.0f <= p) { float d = distMat[vertexIdx*(vertexIdx-1)/2+i]; list<int>::iterator insertPos = sampleBuf.begin(); list<int>::iterator insertPosNext = insertPos; if (insertPos!=sampleBuf.end()) { advance(insertPosNext, 1); } while(insertPos!=sampleBuf.end() && (*insertPosNext<d || *insertPosNext==d && *insertPos<i)) { advance(insertPos, 2); if (insertPos!=sampleBuf.end()) { advance(insertPosNext, 2); } } if (insertPos==sampleBuf.end() || *insertPosNext>d || *insertPos != i) { list<int>::iterator it = sampleBuf.insert(insertPos, d); sampleBuf.insert(it, i); if (d<maxDist) { ++Vsize; if (Vsize>=Vmax) { Vsize = Vmax; maxDist = *(sampleBuf.rbegin()); } } } if (sampleBuf.size()>=2*bufMax) { break; } } } } void Hypergraph::layoutFast(int boundary [], int dim, float c, int Vmax, int Smax, int nIteration) { _layoutDim = dim; float temperature = 10; srand(time(NULL)); int area = 1; for (int i=0; i<dim; ++i) { area *= boundary[2*i+1]-boundary[2*i]; } float k = c*sqrt(area*1.0f/_nVertices); /*initialize vertex layout*/ int nEdges = _edges.size(); int nTotal = _nVertices+nEdges; _layout.resize(nTotal); vector<fvec> dispBuf (nTotal); for (int i=0; i<nTotal; ++i) { _layout[i] = fvec(dim); for (int j=0; j<dim; ++j) { _layout[i](j) = boundary[2*j]+rand()%(boundary[2*j+1]-boundary[2*j]); } dispBuf[i] = fvec(dim); } int i,j; vector<list<int> > sampleBufs (nTotal); vector<int> Vsizes (nTotal); vector<float> maxDists (nTotal); maxDists.assign(nTotal, 40); /*initialize distance matrix*/ vector<float> distMat (nTotal*(nTotal-1)/2); distMat.assign(nTotal*(nTotal-1)/2, 50); for (int i=0; i<nEdges; ++i) { int edgeIdx = i+_nVertices; for (int j=0; j<_edges[i].size(); ++j) { int n1 = _edges[i][j]; for (int k=0; k<j; ++k) { int n2 = _edges[i][k]; distMat[n1*(n1-1)/2+n2] = 20; } distMat[edgeIdx*(edgeIdx-1)/2+n1] = 10; } } QProgressDialog prog ("Performing graph layout ...", "", 0, nIteration-1); prog.setCancelButton(NULL); for (int it=0; it<nIteration; ++it) { DWORD t1 = GetTickCount(); bool bChanged = false; for (i=0; i<nTotal; ++i) { dispBuf[i].fill(0); } DWORD t2 = GetTickCount(); DWORD tFindSample = 0; for (i=0; i<nTotal; ++i) { DWORD t3 = GetTickCount(); findSampleSets(i, maxDists[i], distMat, sampleBufs[i], Vsizes[i], Vmax, Smax); list<int> &sampleBuf = sampleBufs[i]; tFindSample += GetTickCount()-t3; //for (j=0; j<sampleBuf.size(); ++j) for (list<int>::iterator sampleIt = sampleBuf.begin(); sampleIt!=sampleBuf.end(); ++sampleIt) { int sampleIdx = *sampleIt; ++sampleIt; float dist = *sampleIt; if (sampleIdx==i) { continue; } fvec d = _layout[sampleIdx]-_layout[i]; float normD = norm(d,2); /*calculate repulsive force*/ fvec dispRepulsive; if (normD<1.0e-5) { dispRepulsive = fvec(dim); for (int iDim=0; iDim<dim; ++iDim) { dispRepulsive(iDim) = rand()%100/100.0f; } dispRepulsive *= temperature; } else { dispRepulsive = d*k*k/pow(normD,2); } dispBuf[i] -= dispRepulsive; dispBuf[sampleIdx] += dispRepulsive; /*calculate attractive force*/ //float dist = i>sampleIdx?distMat[i*(i-1)/2+sampleIdx]:distMat[sampleIdx*(sampleIdx-1)/2+i]; /*if (dist<50) { float c3 = dist<15?3.0:1.0; fvec dispAttractive = c3*d*normD/k; dispBuf[i] += dispAttractive; dispBuf[sampleIdx] -= dispAttractive; }*/ } } DWORD tRepAttrForces = GetTickCount()-t2; /*restrict the points from being pushed towards the boundary*/ t2 = GetTickCount(); for (i=0; i<nTotal; ++i) { for (j=0; j<dim; ++j) { float c1=1.0e6; float x = _layout[i](j); if (x==boundary[j*2] || x==boundary[j*2+1]) { int stop = 1; } float d = c1*(1/(x-boundary[j*2]+1.0e-3)-1/(boundary[j*2+1]-x+1.0e-3)); dispBuf[i](j) += d; } } DWORD tBoundaries = GetTickCount()-t2; /*limit the maximum displacement, boundary check*/ t2 = GetTickCount(); for (i=0; i<nTotal; ++i) { float n = norm(dispBuf[i],2); fvec newLayout = _layout[i]+dispBuf[i]*min(n, temperature)/n; for (j=0; j<dim; ++j) { int minBoundary = boundary[2*j]; int maxBoundary = boundary[2*j+1]; newLayout(j) = newLayout(j) < minBoundary?minBoundary:(newLayout(j)>maxBoundary?maxBoundary:newLayout(j)); } } DWORD tLimits = GetTickCount()-t2; DWORD perItTime = GetTickCount() - t1; t1 = GetTickCount(); prog.setValue(it); } } vector<unsigned> Hypergraph::computeGraphDistMat() { int nTotal = _nVertices+_edges.size(); vector<unsigned> pathBuf (nTotal*(nTotal-1)/2); pathBuf.assign(nTotal*(nTotal-1)/2, 100); /*initialization*/ for (int i=0; i<_edges.size(); ++i) { int edgeIdx = _nVertices+i; for (int j=0; j<_edges[i].size(); ++j) { for (int k=0; k<j; ++k) { int idx = _edges[i][j]*(_edges[i][j]-1)/2+_edges[i][k]; pathBuf[idx] = 2; } pathBuf[edgeIdx*(edgeIdx-1)/2+_edges[i][j]] = 1; } } for (int k=0; k<nTotal; ++k) { for (int i=0; i<nTotal; ++i) { if (i==k) { continue; } for (int j=0; j<i; ++j) { if (j==k) { continue; } int idxIJ = i*(i-1)/2+j; int idxIK = i>k?i*(i-1)/2+k:k*(k-1)/2+i; int idxJK = j>k?j*(j-1)/2+k:k*(k-1)/2+j; pathBuf[idxIJ] = min(pathBuf[idxIJ], pathBuf[idxIK]+pathBuf[idxJK]); } } } return pathBuf; } vector<unsigned> Hypergraph::computeEdgeDistMat() { int nEdges = _edges.size(); vector<unsigned> pathBuf (nEdges*(nEdges-1)/2); pathBuf.assign(nEdges*(nEdges-1)/2, UINT_MAX); /*initialization*/ for (int i=0; i<nEdges; ++i) { for (int j=0; j<i; ++j) { HyperEdge v(_edges[i].size()+_edges[j].size()); HyperEdge::iterator vIt = set_intersection(_edges[i].begin(), _edges[i].begin(), _edges[j].begin(), _edges[j].end(), v.begin()); if (vIt!=v.begin()) { pathBuf[i*(i-1)/2+j] = 2; } } } for (int k=0; k<nEdges; ++k) { for (int i=0; i<nEdges; ++i) { if (i==k) { continue; } for (int j=0; j<i; ++j) { if (j==k) { continue; } int idxIJ = i*(i-1)/2+j; int idxIK = i>k?i*(i-1)/2+k:k*(k-1)/2+i; int idxJK = j>k?j*(j-1)/2+k:k*(k-1)/2+j; pathBuf[idxIJ] = min(pathBuf[idxIJ], pathBuf[idxIK]+pathBuf[idxJK]); } } } return pathBuf; } vector<int> Hypergraph::getGraphDifference(const Hypergraph *newGraph) { const vector<HyperEdge> &newEdges = newGraph->_edges; vector<int> diffSet (0); int nEdges = _edges.size(); int nNewEdges = newEdges.size(); int i=0; vector<int>::iterator it = diffSet.begin(); for (; i<min(nEdges, nNewEdges); ++i) { vector<int> v(_edges[i].size()+newEdges[i].size()); vector<int>::iterator vIt = set_symmetric_difference(_edges[i].begin(), _edges[i].end(), newEdges[i].begin(), newEdges[i].end(), v.begin()); int originalSize = diffSet.size(); diffSet.resize(vIt-v.begin()+diffSet.size()); copy(v.begin(), vIt, diffSet.begin()+originalSize); } for (;i<nEdges; ++i) { int originalSize = diffSet.size(); diffSet.resize(diffSet.size()+_edges[i].size()); copy(_edges[i].begin(), _edges[i].end(), diffSet.begin()+originalSize); } for (;i<nNewEdges; ++i) { int originalSize = diffSet.size(); diffSet.resize(diffSet.size()+newEdges[i].size()); copy(_edges[i].begin(), _edges[i].end(), diffSet.begin()+originalSize); } sort(diffSet.begin(), diffSet.end()); it = unique(diffSet.begin(), diffSet.end()); diffSet.resize(it-diffSet.begin()); return diffSet; } void Hypergraph::updateLayout(const vector<int> &changedSet, int boundary [], int dim, float c) { _layoutDim = dim; int nIteration = 500; float temperature = 10; srand(time(NULL)); int area = 1; for (int i=0; i<dim; ++i) { area *= boundary[2*i+1]-boundary[2*i]; } float k = c*sqrt(area*1.0f/_nVertices); int nEdges = _edges.size(); int nTotal = _nVertices+nEdges; vector<fvec> dispBuf (nTotal); for (int i=0; i<nTotal; ++i) { dispBuf[i] = fvec(dim); } int i,j; vector<bool> bMovable (nTotal); for (i=0; i<changedSet.size(); ++i) { bMovable[changedSet[i]] = true; } QProgressDialog prog ("Performing graph layout ...", "", 0, nIteration-1); prog.setCancelButton(NULL); for (int it=0; it<nIteration; ++it) { DWORD t1 = GetTickCount(); bool bChanged = false; for (i=0; i<nTotal; ++i) { dispBuf[i].fill(0); } DWORD t2 = GetTickCount(); /*calculate repulsive force*/ for (i=0; i<changedSet.size(); ++i) { int idx = changedSet[i]; for (j=0; j<nTotal; ++j) { if (j==idx) { continue; } fvec d = _layout[j]-_layout[idx]; fvec disp; float normD = norm(d,2); if (normD<1.0e-5) { disp = fvec(dim); for (int iDim=0; iDim<dim; ++iDim) { disp(iDim) = rand()%100/100.0f; } disp *= temperature; } else { disp = d*k*k/pow(normD,2); } dispBuf[idx] -= disp; } } DWORD tRepForce = GetTickCount()-t2; /*calculate attractive force*/ for (i=0; i<_edges.size(); ++i) { int edgeIdx = i+_nVertices; for (j=0; j<_edges[i].size(); ++j) { if (!bMovable[_edges[i][j]]) { continue; } float c2 = 3.0; fvec d1 = _layout[edgeIdx] - _layout[_edges[i][j]]; fvec disp1 = c2*d1*norm(d1,2)/k; dispBuf[edgeIdx] -= disp1; dispBuf[_edges[i][j]] += disp1; for (int m=0; m<_edges[i].size(); ++m) { if (m==j) { continue; } fvec d = _layout[_edges[i][m]] - _layout[_edges[i][j]]; fvec disp = d*norm(d,2)/k; dispBuf[_edges[i][j]] += disp; } } } DWORD tRepAttrForces = GetTickCount()-t2; /*restrict the points from being pushed towards the boundary*/ for (i=0; i<nTotal; ++i) { if (!bMovable[i]) { continue; } for (j=0; j<dim; ++j) { float c1=1.0e6; float x = _layout[i](j); if (x==boundary[j*2] || x==boundary[j*2+1]) { int stop = 1; } float d = c1*(1/(x-boundary[j*2]+1.0e-3)-1/(boundary[j*2+1]-x+1.0e-3)); dispBuf[i](j) += d; } } /*limit the maximum displacement, boundary check*/ for (i=0; i<nTotal; ++i) { if (!bMovable[i]) { continue; } float n = norm(dispBuf[i],2); fvec newLayout = _layout[i]+dispBuf[i]*min(n, temperature)/n; for (j=0; j<dim; ++j) { int minBoundary = boundary[2*j]; int maxBoundary = boundary[2*j+1]; newLayout(j) = newLayout(j) < minBoundary?minBoundary:(newLayout(j)>maxBoundary?maxBoundary:newLayout(j)); } if (norm(newLayout-_layout[i], 2)>1.0e-3) { _layout[i] = newLayout; bChanged = true; } } if (!bChanged) { break; } DWORD perItTime = GetTickCount() - t1; t1 = GetTickCount(); prog.setValue(it); } } void Hypergraph::setEdges(const Hypergraph *newGraph) { _edges.clear(); _edges = newGraph->_edges; } void Hypergraph::layoutClustered(int boundary [], int nIteration, int dim/* =2 */, float c/* =1.0 */) { _layoutDim = dim; float temperature = 10; int nEdges = _edges.size(); int nTotal = _nVertices+nEdges; srand(time(NULL)); int area = 1; for (int i=0; i<dim; ++i) { area *= boundary[2*i+1]-boundary[2*i]; } float k = c*sqrt(area*1.0f/nTotal); /*initialize vertex layout*/ _layout.resize(nTotal); vector<fvec> dispBuf (nTotal); for (int i=0; i<nTotal; ++i) { _layout[i] = fvec(dim); for (int j=0; j<dim; ++j) { _layout[i](j) = boundary[2*j]+rand()%(boundary[2*j+1]-boundary[2*j]); } dispBuf[i] = fvec(dim); } int i,j; QProgressDialog prog ("Performing graph layout ...", "", 0, nIteration-1); prog.setCancelButton(NULL); for (int it=0; it<nIteration; ++it) { DWORD t1 = GetTickCount(); bool bChanged = false; for (i=0; i<nTotal; ++i) { dispBuf[i].fill(0); } DWORD t2 = GetTickCount(); /*calculate repulsive force*/ for (i=0; i<nTotal; ++i) { int clusterI = i<_nVertices?_clusters[i]:i-_nVertices; for (j=0; j<i; ++j) { int clusterJ = j<_nVertices?_clusters[j]:j-_nVertices; float edgeLengthSqr = 1; if (i<_nVertices) { edgeLengthSqr = clusterI==clusterJ?1.5:4; } else { if (j<_nVertices) { edgeLengthSqr = clusterI==clusterJ?1:4; } else { edgeLengthSqr = 9; } } edgeLengthSqr*=k*k; fvec d = _layout[j]-_layout[i]; fvec disp; float normD = norm(d,2); if (normD<1.0e-5) { disp = fvec(dim); for (int iDim=0; iDim<dim; ++iDim) { disp(iDim) = rand()%100/100.0f; } disp *= temperature; } else { //disp = d*k*k/pow(normD,2); disp = edgeLengthSqr/pow(normD, 2)*d; } dispBuf[j] += disp; dispBuf[i] -= disp; } } DWORD tRepForce = GetTickCount()-t2; /*calculate attractive force*/ for (i=0; i<_edges.size(); ++i) { int edgeIdx = i+_nVertices; for (j=0; j<_edges[i].size(); ++j) { float c2 = 10; float edgeLengthSqr = _clusters[_edges[i][j]]==i?1:9.0; edgeLengthSqr *= k; fvec d = _layout[edgeIdx] - _layout[_edges[i][j]]; fvec disp = c2*d*norm(d,2)/edgeLengthSqr; dispBuf[edgeIdx] -= disp; dispBuf[_edges[i][j]] += disp; /*for (int m=0; m<j; ++m) { if (m==j) { continue; } float edgeLengthSqr = _clusters[_edges[i][j]]==_clusters[_edges[i][m]]?1:16.0; edgeLengthSqr *= k; fvec d = _layout[_edges[i][m]] - _layout[_edges[i][j]]; fvec disp = c2*d*norm(d,2)/edgeLengthSqr; dispBuf[_edges[i][m]] -= disp; dispBuf[_edges[i][j]] += disp; }*/ } } DWORD tRepAttrForces = GetTickCount()-t2; /*restrict the points from being pushed towards the boundary*/ for (i=0; i<nTotal; ++i) { for (j=0; j<dim; ++j) { float c1=1.0e6; float x = _layout[i](j); if (x==boundary[j*2] || x==boundary[j*2+1]) { int stop = 1; } float d = c1*(1/(x-boundary[j*2]+1.0e-3)-1/(boundary[j*2+1]-x+1.0e-3)); dispBuf[i](j) += d; } } /*limit the maximum displacement, boundary check*/ for (i=0; i<nTotal; ++i) { float n = norm(dispBuf[i],2); fvec newLayout = _layout[i]+dispBuf[i]*min(n, temperature)/n; for (j=0; j<dim; ++j) { int minBoundary = boundary[2*j]; int maxBoundary = boundary[2*j+1]; newLayout(j) = newLayout(j) < minBoundary?minBoundary:(newLayout(j)>maxBoundary?maxBoundary:newLayout(j)); } if (norm(newLayout-_layout[i], 2)>1.0e-3) { _layout[i] = newLayout; bChanged = true; } } if (!bChanged) { break; } DWORD perItTime = GetTickCount() - t1; t1 = GetTickCount(); prog.setValue(it); } } void Hypergraph::updateLayoutUnpinned(int boundary [], int dim/* =2 */, float c/* =1.0 */) { _layoutDim = dim; int nIteration = 50; float temperature = 10; srand(time(NULL)); int area = 1; for (int i=0; i<dim; ++i) { area *= boundary[2*i+1]-boundary[2*i]; } float k = c*sqrt(area*1.0f/_nVertices); /*initialize vertex layout*/ int nEdges = _edges.size(); int nTotal = _nVertices+nEdges; //_layout.resize(nTotal); vector<fvec> dispBuf (nTotal); for (int i=0; i<nTotal; ++i) { dispBuf[i] = fvec(dim); } int i,j; QProgressDialog prog ("Performing graph layout ...", "", 0, nIteration-1); prog.setCancelButton(NULL); for (int it=0; it<nIteration; ++it) { DWORD t1 = GetTickCount(); bool bChanged = false; for (i=0; i<nTotal; ++i) { dispBuf[i].fill(0); } DWORD t2 = GetTickCount(); /*calculate repulsive force*/ for (i=0; i<nTotal; ++i) { for (j=0; j<i; ++j) { if (j==i) { continue; } fvec d = _layout[j]-_layout[i]; fvec disp; float normD = norm(d,2); if (normD<1.0e-5) { disp = fvec(dim); for (int iDim=0; iDim<dim; ++iDim) { disp(iDim) = rand()%100/100.0f; } disp *= temperature; } else { disp = d*k*k/pow(normD,2); } dispBuf[j] += disp; dispBuf[i] -= disp; } } DWORD tRepForce = GetTickCount()-t2; /*calculate attractive force*/ for (i=0; i<_edges.size(); ++i) { int edgeIdx = i+_nVertices; for (j=0; j<_edges[i].size(); ++j) { float c2 = 3.0; fvec d1 = _layout[edgeIdx] - _layout[_edges[i][j]]; fvec disp1 = c2*d1*norm(d1,2)/k/k; dispBuf[edgeIdx] -= disp1; dispBuf[_edges[i][j]] += disp1; for (int m=0; m<j; ++m) { if (m==j) { continue; } fvec d = _layout[_edges[i][m]] - _layout[_edges[i][j]]; fvec disp = d*norm(d,2)/k/k; dispBuf[_edges[i][m]] -= disp; dispBuf[_edges[i][j]] += disp; } } } DWORD tRepAttrForces = GetTickCount()-t2; /*restrict the points from being pushed towards the boundary*/ for (i=0; i<nTotal; ++i) { for (j=0; j<dim; ++j) { float c1=2.0e5; float x = _layout[i](j); float d = c1*(1/(x-boundary[j*2]+1.0e-3)-1/(boundary[j*2+1]-x+1.0e-3)); dispBuf[i](j) += d; } } /*limit the maximum displacement, boundary check*/ for (i=0; i<nTotal; ++i) { float n = norm(dispBuf[i],2); fvec newLayout = _layout[i]+dispBuf[i]*min(n, temperature)/n; for (j=0; j<dim; ++j) { int minBoundary = boundary[2*j]; int maxBoundary = boundary[2*j+1]; newLayout(j) = newLayout(j) < minBoundary?minBoundary:(newLayout(j)>maxBoundary?maxBoundary:newLayout(j)); } if (norm(newLayout-_layout[i], 2)>1.0e-3) { _layout[i] = newLayout; bChanged = true; } } if (!bChanged) { break; } DWORD perItTime = GetTickCount() - t1; t1 = GetTickCount(); prog.setValue(it); } } vector<unsigned> Hypergraph::getDistToModification(const vector<int> &modifySet) { int nTotal = _nVertices+_edges.size(); vector<unsigned> distVec (nTotal); distVec.assign(nTotal, 100); for (int i=0; i<modifySet.size(); ++i) { distVec[modifySet[i]] = 0; } int nEdges = _edges.size(); vector<unsigned> pathBuf (nEdges*(nEdges+1)/2); pathBuf.assign(nEdges*(nEdges+1)/2, 100); /*initialization*/ for (int i=0; i<nEdges; ++i) { for (int j=0; j<i; ++j) { HyperEdge v(_edges[i].size()+_edges[j].size()); HyperEdge::iterator vIt = set_intersection(_edges[i].begin(), _edges[i].begin(), _edges[j].begin(), _edges[j].end(), v.begin()); if (vIt!=v.begin()) { pathBuf[i*(i-1)/2+j] = 2; } } for (int j=0; j<modifySet.size(); ++j) { int modifiedIdx = modifySet[j]; HyperEdge::iterator it = find(_edges[i].begin(), _edges[i].end(), modifiedIdx); if (it!=_edges[i].end()) { pathBuf[nEdges*(nEdges-1)/2+i] = 1; break; } } } for (int k=0; k<nEdges+1; ++k) { for (int i=0; i<nEdges+1; ++i) { if (i==k) { continue; } for (int j=0; j<i; ++j) { if (j==k) { continue; } int idxIJ = i*(i-1)/2+j; int idxIK = i>k?i*(i-1)/2+k:k*(k-1)/2+i; int idxJK = j>k?j*(j-1)/2+k:k*(k-1)/2+j; pathBuf[idxIJ] = min(pathBuf[idxIJ], pathBuf[idxIK]+pathBuf[idxJK]); } } } for (int i=0; i<nEdges; ++i) { distVec[i+_nVertices] = pathBuf[nEdges*(nEdges-1)/2+i]; for (int j=0; j<_edges[i].size(); ++j) { distVec[_edges[i][j]] = min(distVec[i+_nVertices]+1, distVec[_edges[i][j]]); } } return distVec; } void Hypergraph::getPinnedWeights(const vector<unsigned> &distToModification) { _pinWeights.resize(distToModification.size()); float k = 0.5; for (int i=0; i<distToModification.size(); ++i) { _pinWeights[i] = exp(-k*distToModification[i]); } } void Hypergraph::updateLayoutPinned(int boundary [], int dim, float c) { _layoutDim = dim; int nIteration = 50; float temperature = 10; srand(time(NULL)); int area = 1; for (int i=0; i<dim; ++i) { area *= boundary[2*i+1]-boundary[2*i]; } float k = c*sqrt(area*1.0f/_nVertices); /*initialize vertex layout*/ int nEdges = _edges.size(); int nTotal = _nVertices+nEdges; //_layout.resize(nTotal); vector<fvec> dispBuf (nTotal); for (int i=0; i<nTotal; ++i) { dispBuf[i] = fvec(dim); } int i,j; const float PIN_THRES = 1.0e-3; QProgressDialog prog ("Performing graph layout ...", "", 0, nIteration-1); prog.setCancelButton(NULL); for (int it=0; it<nIteration; ++it) { DWORD t1 = GetTickCount(); bool bChanged = false; for (i=0; i<nTotal; ++i) { dispBuf[i].fill(0); } DWORD t2 = GetTickCount(); /*calculate repulsive force*/ for (i=0; i<nTotal; ++i) { if (_pinWeights[i]<PIN_THRES) { continue; } for (j=0; j<nTotal; ++j) { if (j==i) { continue; } fvec d = _layout[j]-_layout[i]; fvec disp; float normD = norm(d,2); if (normD<1.0e-5) { disp = fvec(dim); for (int iDim=0; iDim<dim; ++iDim) { disp(iDim) = rand()%100/100.0f; } disp *= temperature; } else { disp = d*k*k/pow(normD,2); } //dispBuf[j] += disp; dispBuf[i] -= disp; } } DWORD tRepForce = GetTickCount()-t2; /*calculate attractive force*/ for (i=0; i<_edges.size(); ++i) { int edgeIdx = i+_nVertices; for (j=0; j<_edges[i].size(); ++j) { if (_pinWeights[_edges[i][j]]<PIN_THRES) { continue; } float c2 = 3.0; fvec d1 = _layout[edgeIdx] - _layout[_edges[i][j]]; fvec disp1 = c2*d1*norm(d1,2)/k/k; dispBuf[edgeIdx] -= disp1; dispBuf[_edges[i][j]] += disp1; for (int m=0; m<_edges[i].size(); ++m) { if (m==j) { continue; } fvec d = _layout[_edges[i][m]] - _layout[_edges[i][j]]; fvec disp = d*norm(d,2)/k/k; //dispBuf[_edges[i][m]] -= disp; dispBuf[_edges[i][j]] += disp; } } } DWORD tRepAttrForces = GetTickCount()-t2; /*restrict the points from being pushed towards the boundary*/ for (i=0; i<nTotal; ++i) { if (_pinWeights[i]<PIN_THRES) { continue; } for (j=0; j<dim; ++j) { float c1=2.0e5; float x = _layout[i](j); float d = c1*(1/(x-boundary[j*2]+1.0e-3)-1/(boundary[j*2+1]-x+1.0e-3)); dispBuf[i](j) += d; } } /*limit the maximum displacement, boundary check*/ for (i=0; i<nTotal; ++i) { if (_pinWeights[i]<PIN_THRES) { continue; } float n = norm(dispBuf[i],2); fvec newLayout = _layout[i]+dispBuf[i]*min(n, temperature*_pinWeights[i])/n; for (j=0; j<dim; ++j) { int minBoundary = boundary[2*j]; int maxBoundary = boundary[2*j+1]; newLayout(j) = newLayout(j) < minBoundary?minBoundary:(newLayout(j)>maxBoundary?maxBoundary:newLayout(j)); } if (norm(newLayout-_layout[i], 2)>1.0e-3) { _layout[i] = newLayout; bChanged = true; } } if (!bChanged) { break; } DWORD perItTime = GetTickCount() - t1; t1 = GetTickCount(); prog.setValue(it); } } void Hypergraph::drawPinWeights() { for (int i=0; i<_nVertices+_edges.size(); ++i) { float w = _pinWeights[i]; glPushMatrix(); /*label the vertex*/ glPushName(i); glTranslatef(_layout[i](0), _layout[i](1), 0); glColor3f(1,1,1); glutSolidSphere(5, 10, 16); glColor3f(w, w, w); glutSolidSphere(5, 10, 10); glPopName(); glPopMatrix(); } } void Hypergraph::layoutPartitioned(int boundary [], bool bUpdate) { int dim = 2; int nIteration = bUpdate?50:500; float temperature = 10; typedef fvec2 LayoutPoint; srand(time(NULL)); int area = 1; for (int i=0; i<dim; ++i) { area *= boundary[2*i+1]-boundary[2*i]; } float k = 1.0*sqrt(area*1.0f/_nVertices); /*initialize vertex layout*/ int nEdges = _edges.size(); int nTotal = _nVertices+nEdges; _layout.resize(nTotal); vector<LayoutPoint> dispBuf (nTotal); if (!bUpdate) { for (int i=0; i<nTotal; ++i) { _layout[i] = fvec(dim); for (int j=0; j<dim; ++j) { _layout[i](j) = boundary[2*j]+rand()%(boundary[2*j+1]-boundary[2*j]); } dispBuf[i] = fvec(dim); } _pinWeights.resize(nTotal); _pinWeights.assign(nTotal, 1); } int nClusters = *max_element(_clusters.begin(), _clusters.end())+1; int nPartitions; vector<int> partitionSizes; getPartitionsByEdge(nPartitions, partitionSizes, _partitions); //getPartitionsByCluster(nPartitions, partitionSizes, _partitions); //getPartitionsByKDTree(nPartitions, partitionSizes, _partitions); vector<LayoutPoint> partCenters (nPartitions); vector<vector<int> > edgeBuf (_nVertices); for (int i=0; i<_edges.size(); ++i) { for (int j=0; j<_edges[i].size(); ++j) { edgeBuf[_edges[i][j]].push_back(i+_nVertices); } } int i,j; DWORD t0 = GetTickCount(); DWORD perItTime = 0; DWORD tReplInt = 0; DWORD tReplExt = 0; DWORD tAttr = 0; QProgressDialog prog ("Performing graph layout ...", "", 0, nIteration-1); prog.setCancelButton(NULL); for (int it=0; it<nIteration; ++it) { DWORD t1 = GetTickCount(); bool bChanged = false; for (int i=0; i<nTotal; ++i) { dispBuf[i].fill(0); } for (int i=0; i<nPartitions; ++i) { partCenters[i].fill(0); for (int j=0; j<nTotal; ++j) { if (i!=_partitions[j]) { continue; } partCenters[i] += _layout[j]; } partCenters[i] /= partitionSizes[i]; } for (int i=0; i<nTotal; ++i) { if (_pinWeights[i]<1.0e-3) { continue; } float edgeLength = (i<_nVertices&&_clusters[i]==-1)?1.5*k:k; /*interior repulsive forces*/ DWORD t2 = GetTickCount(); for (int j=0; j<i; ++j) { if (_partitions[i]!=_partitions[j]) { continue; } int vertexIdx = j; fvec disp = getRepulsiveForce(_layout[i], _layout[j], k); dispBuf[i] -= disp; dispBuf[j] += disp; } tReplInt += GetTickCount() - t2; /*exterior repulsive forces*/ t2 = GetTickCount(); for (int j=0; j<nPartitions; ++j) { if (j==_partitions[i]) { continue; } if (partitionSizes[j]!=0) { fvec disp = partitionSizes[j]*getRepulsiveForce(_layout[i], partCenters[j], k); dispBuf[i] -= disp; } } tReplExt += GetTickCount() - t2; /*attractive forces*/ t2 = GetTickCount(); if (i<_nVertices) { for (int j=0; j<edgeBuf[i].size(); ++j) { int edgeIdx = edgeBuf[i][j]; fvec disp = getAttractiveForce(_layout[i], _layout[edgeIdx], edgeLength); dispBuf[i] += 3.0*disp; dispBuf[edgeIdx] -= 3.0*disp; } } tAttr += GetTickCount() - t2; } /*cooling*/ for (int i=0; i<nTotal; ++i) { /*adjust forces*/ for (int j=0; j<dim; ++j) { float c1=1.0e5; float x = _layout[i](j); float d = c1*(1.0/(x-boundary[j*2]+1.0e-3)-1.0/(boundary[j*2+1]-x+1.0e-3)); dispBuf[i](j) += d; } float n = norm(dispBuf[i],2); fvec newLayout = _layout[i]+dispBuf[i]*min(n, temperature*_pinWeights[i])/n; for (int j=0; j<dim; ++j) { int minBoundary = boundary[2*j]; int maxBoundary = boundary[2*j+1]; newLayout(j) = newLayout(j) < minBoundary?minBoundary:(newLayout(j)>maxBoundary?maxBoundary:newLayout(j)); } _layout[i] = newLayout; } perItTime += GetTickCount() - t1; prog.setValue(it); } DWORD totalTime = GetTickCount()-t0; tReplInt /= nIteration; tReplExt /= nIteration; tAttr /= nIteration; perItTime /= nIteration; return; } fvec Hypergraph::getRepulsiveForce(fvec &pt1, fvec &pt2, float edgeLength) { int dim = pt1.n_elem; fvec d = pt2 - pt1; fvec disp; float normDSqr = dot(d,d); if (normDSqr<1.0e-6) { disp = fvec(dim); for (int iDim=0; iDim<dim; ++iDim) { disp(iDim) = rand()%100/100.0f; } disp *= edgeLength*edgeLength; } else { disp = d*edgeLength*edgeLength/normDSqr; } return disp; } fvec Hypergraph::getAttractiveForce(fvec &pt1, fvec &pt2, float edgeLength) { fvec d = pt2 - pt1; fvec disp = d*dot(d,d)/edgeLength/edgeLength; return disp; } void Hypergraph::getPartitionsByCluster(int &nPartitions, vector<int> &partitionSizes, vector<int> &partitions) { int minPartition = 5; int maxPartition = 15; int nClusters = *max_element(_clusters.begin(), _clusters.end())+1; int partitionIdx = 0; int partitionCnt = 0; _clusters.resize(_nVertices+_edges.size()); for (int i=_nVertices; i<_nVertices+_edges.size(); ++i) { _clusters[i] = i-_nVertices; } _partitions.resize(_clusters.size()); for (int i=0; i<nClusters; ++i) { int clusterSize = count(_clusters.begin(), _clusters.end(), i); int partitionSize = 0; if (clusterSize<=maxPartition) { partitionSize = clusterSize; } else { float n = (ceil(clusterSize*1.0f/maxPartition)+floor(clusterSize*1.0f/minPartition))/2.0; partitionSize = ceil(clusterSize/n); } for (int j=0; j<_clusters.size(); ++j) { if (_clusters[j]!=i) { continue; } /*if (partitionCnt>=partitionSize) { partitionSizes.push_back(partitionCnt); ++partitionIdx; partitionCnt = 0; }*/ _partitions[j] = partitionIdx; ++partitionCnt; } partitionSizes.push_back(partitionCnt); ++partitionIdx; partitionCnt = 0; } nPartitions = partitionIdx; _clusters.resize(_nVertices); } void Hypergraph::drawPartitions() { srand(NULL); int nPartitions = *max_element(_partitions.begin(), _partitions.end())+1; ColorTable * colTable = new ColorTable(); vector<float> colBuf (nPartitions); for (int i=0; i<nPartitions; ++i) { colBuf[i] = i*1.0/(nPartitions-1); } for (int i=0; i<_nVertices+_edges.size(); ++i) { glPushMatrix(); /*label the vertex*/ glPushName(i); glTranslatef(_layout[i](0), _layout[i](1), 0); glColor3f(1,1,1); glutSolidSphere(7, 10, 10); glColor3ubv(colTable->getColor(colBuf[_partitions[i]])); glutSolidSphere(5, 10, 10); glPopName(); glPopMatrix(); } } void Hypergraph::getPartitionsByKDTree(int &nPartitions, vector<int> &partitionSizes, vector<int> &partitions) { int minPartition = 5; int maxPartition = 15; int nClusters = *max_element(_clusters.begin(), _clusters.end())+1; int partitionIdx = 0; int partitionCnt = 0; _clusters.resize(_nVertices+_edges.size()); for (int i=_nVertices; i<_nVertices+_edges.size(); ++i) { _clusters[i] = i-_nVertices; } _partitions.resize(_clusters.size()); for (int i=0; i<nClusters; ++i) { int clusterSize = count(_clusters.begin(), _clusters.end(), i); int partitionSize = 0; int nSubPartitions = (clusterSize*1.0f/maxPartition+clusterSize*1.0f/minPartition)/2; int depth = max(floor(log(1.0f*nSubPartitions)/log(2.0f)),0); nSubPartitions = pow(2.0f, depth); vector<fvec> ptBuf (clusterSize); vector<float> divisions (pow(2.0f, depth+1)-1); int bufIdx = 0; for (int j=0; j<_clusters.size(); ++j) { if (_clusters[j] == i) { ptBuf[bufIdx++] = _layout[j]; } } kdPartition(0, depth, ptBuf.begin(), ptBuf.end(), divisions, 0); for (int j=0; j<_clusters.size(); ++j) { if (_clusters[j] == i) { int subPartitionIdx = kdCoord(_layout[j], depth, divisions); _partitions[j] = partitionIdx+subPartitionIdx; } } partitionIdx += nSubPartitions; } nPartitions = partitionIdx; partitionSizes.resize(nPartitions); for (int i=0; i<nPartitions; ++i) { partitionSizes[i] = count(_partitions.begin(), _partitions.end(), i); } _clusters.resize(_nVertices); } bool compareX (fvec pt1, fvec pt2) {return pt1(0)<=pt2(0);} bool compareY (fvec pt1, fvec pt2) {return pt1(1)<=pt2(1);} void Hypergraph::kdPartition (int depth, int targetDepth, vector<fvec>::iterator &firstPt, vector<fvec>::iterator &lastPt, vector<float> &divisions, int divisionIdx) { if (depth>targetDepth) { return; } int nPoints = lastPt-firstPt; int nMidPoint = nPoints/2; int coord = depth%2; switch (coord) { case 0: nth_element(firstPt, firstPt+nMidPoint, lastPt, compareX); break; case 1: nth_element(firstPt, firstPt+nMidPoint, lastPt, compareY); break; } fvec &midPoint = *(firstPt+nMidPoint); divisions[divisionIdx] = midPoint(coord%2); kdPartition(depth+1, targetDepth, firstPt, firstPt+nMidPoint, divisions, 2*divisionIdx+1); kdPartition(depth+1, targetDepth, firstPt+nMidPoint, lastPt, divisions, 2*divisionIdx+2); } int Hypergraph::kdCoord(const fvec &pt, int depth, vector<float> &divisions) { int coord = 0; int divisionIdx = 0; for (int d=0; d<=depth; ++d) { int c = 0; switch (d%2) { case 0: c = pt(0)>divisions[divisionIdx]; break; case 1: c = pt(1)>divisions[divisionIdx]; break; } coord |= c<<(depth-d); divisionIdx += pow(2.0f, d)+c; } return coord; } void Hypergraph::getPartitionsByEdge(int &nPartitions, vector<int> &partitionSizes, vector<int> &partitions) { int nEdges = _edges.size(); nPartitions = nEdges; partitions.resize(_nVertices+nEdges); partitions.assign(partitions.size(), -1); for (int i=0; i<nEdges; ++i) { for (int j=0; j<_edges[i].size(); ++j) { int idx = _edges[i][j]; if (partitions[idx]==-1) { partitions[idx] = i; } else if (_clusters[idx]==i) { partitions[idx] = i; } } partitions[i+_nVertices] = i; } partitionSizes.resize(nPartitions); for (int i=0; i<nPartitions; ++i) { partitionSizes[i] = count(partitions.begin(), partitions.end(), i); } } vector<int> Hypergraph::getSelectedIdx() { vector<int> selectedIdx; for (int i=0; i<_nVertices; ++i) { if (_selectedBuf[i]) { selectedIdx.push_back(i); } } return selectedIdx; } int Hypergraph::getLinkage() { if (_linkageBuf.empty()) { return -1; } else { return _linkageBuf[0]-_nVertices; } }
[ [ [ 1, 2052 ] ] ]
e0208253c5ec7b406651a54d8d8d6c93ecbff1ec
b2d46af9c6152323ce240374afc998c1574db71f
/cursovideojuegos/theflostiproject/Code/Flosti Engine/Core/Core.cpp
77daa6d7e308e0467c7a5097b2089a548e30e83b
[]
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
13,515
cpp
#include "__PCH_Core.h" #include "FlostiEngine.h" #include "Core.h" #include "Input/InputManager.h" #include "Input/ActionToInput.h" #include "PhysX/PhysicsManager.h" #include "Graphics/RenderManager.h" #include "Graphics/FontManager.h" #include "Script/ScriptManager.h" #include "Logger/Logger.h" #include "Graphics/Materials/EffectManager.h" #include "Graphics/Textures/TextureManager.h" #include "Console.h" #include "GUI/GUIManager.h" #include "Network/NetworkManager.h" #include "Sound/SoundManager.h" #include "Graphics/AviPlayerManager.h" #include "ComputerVision/ComputerVisionManager.h" #include "Process.h" #include "Exceptions/Exception.h" #include "Language/LanguageManager.h" #include "luabind/luabind.hpp" //---------------------------------------------------------------------------- // Finalize data //---------------------------------------------------------------------------- void CCore::Done () { if (IsOk()) { Release(); m_bIsOk = false; } } //---------------------------------------------------------------------------- // Free memory //---------------------------------------------------------------------------- void CCore::Release () { CHECKED_DELETE(m_pInputManager); CHECKED_DELETE(m_pActionToInput); CHECKED_DELETE(m_pRenderManager); CHECKED_DELETE(m_pPhysicsManager); CHECKED_DELETE(m_pScriptManager); CHECKED_DELETE(m_pTextureManager); CHECKED_DELETE(m_pGUIManager); CHECKED_DELETE(m_pNetworkManager); CHECKED_DELETE(m_pSoundManager); CHECKED_DELETE(m_pAviPlayerManager); CHECKED_DELETE(m_pComputerVisionManager); CHECKED_DELETE(m_pLanguageManager); CHECKED_DELETE(m_pFontManager); if (m_pEffectManager) { m_pEffectManager->Destroy(); } CHECKED_DELETE(m_pEffectManager); } bool CCore::Init( HWND hwnd, CFlostiEngine* app, CConsole* console, const SEngineInitParams& params) { m_pApplication = app; m_pConsole = console; assert(m_pConsole); assert(m_pApplication); //----Init Script Manager m_pScriptManager = new CScriptManager(); assert(m_pScriptManager); m_bIsOk = m_pScriptManager->Init(); //----Init Render Manager if (m_bIsOk) { m_pRenderManager = new CRenderManager(); assert(m_pRenderManager); m_pScriptManager->AddNewScriptRegister(m_pRenderManager); m_bIsOk = m_pRenderManager->Init(hwnd, params.m_bFullScreen, params.m_ScreenResolution.x, params.m_ScreenResolution.y); } //----Init Font Manager if (m_bIsOk) { m_pFontManager = new CFontManager(); assert(m_pFontManager); m_pScriptManager->AddNewScriptRegister(m_pFontManager); m_bIsOk = m_pFontManager->Init(m_pRenderManager); m_pFontManager->LoadTTFs(params.m_sInitFontsXML); } //----Init Input Manager if (m_bIsOk) { m_pInputManager = new CInputManager(); assert(m_pInputManager); m_pScriptManager->AddNewScriptRegister(m_pInputManager); Vect2i screenResolution; uint32 w,h; m_pRenderManager->GetWidthAndHeight(w, h); screenResolution.x = w; screenResolution.y = h; m_bIsOk = m_pInputManager->Init(hwnd, screenResolution, params.m_bExclusiveModeinMouse); } //----Init Action To Input if (m_bIsOk) { m_pActionToInput = new CActionToInput(); assert(m_pActionToInput); m_bIsOk = m_pActionToInput->Init(m_pInputManager); if (params.m_sAction2InputXML != "") { m_pActionToInput->LoadXML(params.m_sAction2InputXML); m_pActionToInput->PrintToLogger(); } } //----Init Physics Manager if (m_bIsOk) { m_pPhysicsManager = new CPhysicsManager(); assert(m_pPhysicsManager); m_pScriptManager->AddNewScriptRegister(m_pPhysicsManager); if (params.m_bInitPhysX) { m_bIsOk = m_pPhysicsManager->Init(); } } //----Init Sound Manager if (m_bIsOk) { m_pSoundManager = new CSoundManager(); assert(m_pSoundManager); m_pScriptManager->AddNewScriptRegister(m_pSoundManager); m_bIsOk = m_pSoundManager->Init(); if(m_bIsOk && (params.m_sInitSoundsXML.compare("") != 0) ) { m_pSoundManager->LoadSounds(params.m_sInitSoundsXML); } } //----Init AviPlayer Manager if (m_bIsOk) { m_pAviPlayerManager = new CAviPlayerManager(); assert(m_pAviPlayerManager); m_pScriptManager->AddNewScriptRegister(m_pAviPlayerManager); m_bIsOk = m_pAviPlayerManager->Init(m_pRenderManager); if(m_bIsOk && (params.m_sInitAvisXML.compare("") != 0) ) { m_pAviPlayerManager->LoadAvis(params.m_sInitAvisXML); } } //----Init Network Manager if (m_bIsOk) { m_pNetworkManager = new CNetworkManager(); assert(m_pNetworkManager); m_pScriptManager->AddNewScriptRegister(m_pNetworkManager); m_pNetworkManager->SetWindow(hwnd); } // Init Effects if(m_bIsOk) { m_pEffectManager = new CEffectManager; assert(m_pEffectManager); m_pScriptManager->AddNewScriptRegister(m_pEffectManager); m_pEffectManager->Init(); } // Init Texture Manager if (m_bIsOk) { m_pTextureManager = new CTextureManager(); assert(m_pTextureManager); m_pScriptManager->AddNewScriptRegister(m_pTextureManager); m_pTextureManager->Init(); } // Init Computer Vision Manager if (m_bIsOk) { m_pComputerVisionManager = new CComputerVisionManager(); assert(m_pComputerVisionManager); m_pScriptManager->AddNewScriptRegister(m_pComputerVisionManager); if (params.m_bInitComputerVision) { m_bIsOk = m_pComputerVisionManager->Init(); } } // Init Language Manager if (m_bIsOk) { m_pLanguageManager = new CLanguageManager(); assert(m_pLanguageManager); std::vector<std::string>::const_iterator it = params.m_vLanguageXML.begin(); std::vector<std::string>::const_iterator itEnd = params.m_vLanguageXML.end(); while (it != itEnd) { m_pLanguageManager->SetXmlFile(*it); ++it; } m_pLanguageManager->LoadXMLs(); m_pLanguageManager->SetCurrentLanguage(params.m_sCurrentLanguage); } //Init GUI Manager if (m_bIsOk) { Vect2i screenResolution; uint32 w,h; m_pRenderManager->GetWidthAndHeight(w, h); screenResolution.x = w; screenResolution.y = h; m_pGUIManager = new CGUIManager(screenResolution); m_pScriptManager->AddNewScriptRegister(m_pGUIManager); assert(m_pGUIManager); m_pGUIManager->SetVisiblePointerMouse(params.m_bDrawPointerMouse); if (params.m_sInitGuiXML.compare("") != 0) { m_bIsOk = m_pGUIManager->Init(params.m_sInitGuiXML); } } if (!m_bIsOk) { Release(); std::string msg_error = "CCore::Init-> Error al inicializar los managers" ; LOGGER->AddNewLog(ELL_ERROR, msg_error.c_str()); throw CException(__FILE__, __LINE__, msg_error); } else { m_pScriptManager->AddNewScriptRegister(this); } return m_bIsOk; } void CCore::Render () { if (m_pRenderManager->IsOk()) { if (m_pPhysicsManager->IsOk()) { m_pPhysicsManager->DebugRender(m_pRenderManager); } } } void CCore::RenderAssetErrors () { m_AssetErrors.Render(m_pRenderManager, m_pFontManager); } void CCore::SetAssetError (TypeOfAssetError error) { m_AssetErrors.SetAssetError(error); } void CCore::ResetAssetErrors () { m_AssetErrors.ResetAssetErrors(); } void CCore::Update (float elapsedTime) { if (m_pInputManager->IsOk()) { m_pInputManager->Update(); } if (m_pPhysicsManager->IsOk()) { m_pPhysicsManager->Update(elapsedTime); } if (m_pGUIManager->IsOk()) { m_pGUIManager->Update(elapsedTime); } if (m_pNetworkManager->IsOk()) { m_pNetworkManager->Update(); } if (m_pAviPlayerManager->IsOk()) { m_pAviPlayerManager->Update(elapsedTime); } if (m_pComputerVisionManager->IsOk()) { m_pComputerVisionManager->Update(elapsedTime); } if (m_pSoundManager->IsOk()) { m_pSoundManager->Update(elapsedTime); } UpdateTimers(elapsedTime); m_AssetErrors.Update(elapsedTime); } void CCore::Finished () { m_pProcess->Finished(); } void CCore::ResetCurrentProcess () { m_pApplication->ResetCurrentProcess(); } void CCore::ChangeProcess (const std::string& newProcess) { m_pApplication->ChangeProcess(newProcess); } bool CCore::SaveLogsInFile () { return LOGGER->SaveLogsInFile(); } void CCore::SetAutoComplete (const std::vector<std::string>& vector) { if (m_pConsole) { m_pConsole->SetAutoComplete(vector); } else { //Error message: LOGGER->AddNewLog(ELL_ERROR, "CCore::SetAutoComplete puntero a console nulo!!"); } } bool CCore::IsEndTimer (const std::string& id, float timeOut) { bool isEnd = true; tTimerMap::iterator it = m_Timers.find(id); if (it != m_Timers.end()) { //Existe el timer--> por lo tanto aun no ha finalizado: isEnd = false; } else { //Si no existe lo creamos y retornamos true m_Timers.insert(std::pair<std::string,float>(id,timeOut)); } return isEnd; } void CCore::UpdateTimers(float elapsedTime) { tTimerMap::iterator it = m_Timers.begin(); tTimerMap::iterator itEnd = m_Timers.end(); while (it != itEnd) { it->second -= elapsedTime; if (it->second < 0.f) { //Ya ha pasado el tiempo-> lo eliminamos m_Timers.erase( it ); //Si hubieran dos timers a eliminar no pasa nada, en el siguiente loop ya lo eliminaremos. break; } it++; } } void CCore::SetLinesPerPageInLogger(uint32 lines) { if (m_pApplication!=NULL) { m_pApplication->SetLinesPerPageInLogger(lines); } } void CCore::RegisterFunctions (CScriptManager* scriptManager) { lua_State* l_pLUAState = scriptManager->GetLuaState(); using namespace luabind; // ahora registramos lo que querramos module(l_pLUAState) [ def("getCore", &CCore::GetSingletonPtr), // registramos la clase CCore class_<CCore>(CScriptRegister::SetClassName("CCore")) // registramos su constructor .def(constructor<>()) .def( CScriptRegister::PushFunctionName(AUTO_COMPLETE), &CScriptRegister::AutoComplete) .def( CScriptRegister::PushFunctionName(HELP,"void","void", "Muestra todas las funciones de esta clase"), &CScriptRegister::Help) .def( CScriptRegister::PushFunctionName("getInput","CInputManager*","void", "Obtiene puntero al inputManager"), &CCore::GetInputManager) .def( CScriptRegister::PushFunctionName("getRender", "CRenderManager*", "void", "Obtiene puntero al renderManager"), &CCore::GetRenderManager) .def( CScriptRegister::PushFunctionName("getPhysic", "CPhysicManager*", "void", "Obtiene puntero al physicManager"), &CCore::GetPhysicManager) .def(CScriptRegister::PushFunctionName("getScript", "CScriptManager*", "void", "Obtiene puntero al scriptManager"), &CCore::GetScriptManager) .def( CScriptRegister::PushFunctionName("getTexture" ,"CTextureManager*", "void", "Obtiene puntero al textureManager"), &CCore::GetTextureManager) .def( CScriptRegister::PushFunctionName("getEffect", "CEffectManager*", "void", "Obtiene puntero al effectManager"), &CCore::GetEffectManager) .def( CScriptRegister::PushFunctionName("getGui", "CGUIManager*", "void", "Obtiene puntero al guiManager"), &CCore::GetGUIManager) .def( CScriptRegister::PushFunctionName("getSound", "CSoundManager*", "void", "Obtiene puntero al soundManager"), &CCore::GetSoundManager) .def( CScriptRegister::PushFunctionName("getAviPlayer", "CAviPlayerManager*", "void", "Obtiene puntero al aviPlayerManager"), &CCore::GetAviPlayerManager) .def( CScriptRegister::PushFunctionName("getNetwork", "CNetworkManager*","void", "Obtiene puntero al networkManager"), &CCore::GetNetworkManager) .def( CScriptRegister::PushFunctionName("getComputerVision","CComputerVisionManager*","void", "Obtiene puntero al computerVisionManager"), &CCore::GetComputerVisionManager) .def( CScriptRegister::PushFunctionName("finished", "void", "void", "Nos informa si el proceso ha finalizado"), &CCore::Finished) .def( CScriptRegister::PushFunctionName("isEndTimer", "bool", "const std::string&, float", "Informa si un timer ha finalizado su cuenta atras"), &CCore::IsEndTimer) .def( CScriptRegister::PushFunctionName("saveLogsInFile", "bool", "void", "Guarda si es posible el log en un fichero"), &CCore::SaveLogsInFile) .def( CScriptRegister::PushFunctionName("setAssetError" "void", "TypeOfAssetError", "Advierte por pantalla un error con un asset determinado"), &CCore::SetAssetError) .def( CScriptRegister::PushFunctionName("resetAssetErrors", "void", "void", "Resetea las advertencias de assets que se estaban mostrando por pantalla"), &CCore::ResetAssetErrors) .def( CScriptRegister::PushFunctionName("changeProcess", "void", "const std::string&", "Hace un deinit del proceso actual y un init del proceso a cambiar"), &CCore::ChangeProcess) .def( CScriptRegister::PushFunctionName("resetCurrentProcess", "void", "void", "Hace un deinit y un init del proceso actual"), &CCore::ResetCurrentProcess) .def( CScriptRegister::PushFunctionName("setLinesPerPageInLogger", "void", "void", "Setea la cantidad de lineas en el render del log"), &CCore::SetLinesPerPageInLogger) ]; }
[ "ohernandezba@71d53fa2-cca5-e1f2-4b5e-677cbd06613a" ]
[ [ [ 1, 500 ] ] ]
69060dfb4772dbd61182785b1cd50862361222dd
3187b0dd0d7a7b83b33c62357efa0092b3943110
/src/dlib/test/matrix2.cpp
38cff08422c8222ab933b2a5cac753f1b5b814f1
[ "BSL-1.0" ]
permissive
exi/gravisim
8a4dad954f68960d42f1d7da14ff1ca7a20e92f2
361e70e40f58c9f5e2c2f574c9e7446751629807
refs/heads/master
2021-01-19T17:45:04.106839
2010-10-22T09:11:24
2010-10-22T09:11:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
33,844
cpp
// Copyright (C) 2006 Davis E. King ([email protected]) // License: Boost Software License See LICENSE.txt for the full license. #include <dlib/matrix.h> #include <sstream> #include <string> #include <cstdlib> #include <ctime> #include <vector> #include "../stl_checked.h" #include "../array.h" #include "../rand.h" #include "tester.h" #include <dlib/memory_manager_stateless.h> #include <dlib/array2d.h> namespace { using namespace test; using namespace dlib; using namespace std; logger dlog("test.matrix2"); void matrix_test ( ) /*! ensures - runs tests on the matrix stuff compliance with the specs !*/ { typedef memory_manager_stateless<char>::kernel_2_2a MM; print_spinner(); const double ident[] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; const double uniform3[] = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }; const double uniform1[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; const double uniform0[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; const int array[] = { 42, 58, 9, 1, 9, 5, 8, 2, 98, 28, 4, 77, 9, 2, 44, 88 }; const int array2[] = { 1, 22, 3, 4, 52, 6, 7, 8, 9 }; const int array2_r[] = { 52, 6, 4, 8, 9, 7, 22, 3, 1 }; const double array_f[] = { -0.99, 0.99}; matrix<double,2,1,MM> fm(array_f); DLIB_CASSERT(fm.size() == 2,""); matrix<double> dfm(fm); DLIB_CASSERT(round(fm)(0) == -1,""); DLIB_CASSERT(round(fm)(1) == 1,""); DLIB_CASSERT(round(dfm)(0) == -1,""); DLIB_CASSERT(round(dfm)(1) == 1,""); DLIB_CASSERT(round(dfm).size() == dfm.size(),""); const int array3[] = { 1, 2, 3, 4 }; matrix<double,3,3,MM> m3(array2); matrix<double> dm3; DLIB_CASSERT(dm3.size() == 0,""); DLIB_CASSERT(dm3.nr() == 0,""); DLIB_CASSERT(dm3.nc() == 0,""); dm3.set_size(3,4); DLIB_CASSERT(dm3.nr() == 3,""); DLIB_CASSERT(dm3.nc() == 4,""); DLIB_CASSERT(dm3.size() == 3*4,""); dm3.set_size(3,3); DLIB_CASSERT(dm3.nr() == 3,""); DLIB_CASSERT(dm3.nc() == 3,""); dm3 = m3; dm3(0,0)++; DLIB_CASSERT( dm3 != m3,""); dm3 = m3; DLIB_CASSERT( dm3 == m3,""); DLIB_CASSERT( abs(sum(squared(normalize(dm3))) - 1.0) < 1e-10,""); matrix<double,3,4> mrc; mrc.set_size(3,4); set_all_elements(mrc,1); DLIB_CASSERT(diag(mrc) == uniform_matrix<double>(3,1,1),""); DLIB_CASSERT(diag(matrix<double>(mrc)) == uniform_matrix<double>(3,1,1),""); matrix<double,2,3> mrc2; set_all_elements(mrc2,1); DLIB_CASSERT((removerc<1,1>(mrc) == mrc2),""); DLIB_CASSERT((removerc(mrc,1,1) == mrc2),""); matrix<int,3,3> m4, m5, m6; set_all_elements(m4, 4); set_all_elements(m5, 4); set_all_elements(m6, 1); DLIB_CASSERT(squared(m4) == pointwise_multiply(m4,m4),""); DLIB_CASSERT(cubed(m4) == pointwise_multiply(m4,m4,m4),""); DLIB_CASSERT(pow(matrix_cast<double>(m4),2) == squared(matrix_cast<double>(m4)),""); DLIB_CASSERT(pow(matrix_cast<double>(m4),3) == cubed(matrix_cast<double>(m4)),""); matrix<int> dm4; matrix<int,0,0,memory_manager_stateless<char>::kernel_2_2a> dm5; dm4 = dm4; dm4 = dm5; DLIB_CASSERT(dm4.nr() == 0,""); dm4 = m4; dm5 = m5; DLIB_CASSERT(dm4 == dm5,""); DLIB_CASSERT(m4 == m5,""); DLIB_CASSERT(m6 != m5,""); m4.swap(m6); DLIB_CASSERT(m6 == m5,""); DLIB_CASSERT(m4 != m5,""); DLIB_CASSERT(m3.nr() == 3,""); DLIB_CASSERT(m3.nc() == 3,""); matrix<double,4,1> v(array3), v2; DLIB_CASSERT(v.nr() == 4,""); DLIB_CASSERT(v.nc() == 1,""); std::vector<double> stdv(4); std_vector_c<double> stdv_c(4); dlib::array<double>::expand_1a_c arr; arr.expand(4); for (long i = 0; i < 4; ++i) stdv[i] = stdv_c[i] = arr[i] = i+1; DLIB_CASSERT(vector_to_matrix(stdv)(0) == 1,""); DLIB_CASSERT(vector_to_matrix(stdv)(1) == 2,""); DLIB_CASSERT(vector_to_matrix(stdv)(2) == 3,""); DLIB_CASSERT(vector_to_matrix(stdv)(3) == 4,""); DLIB_CASSERT(vector_to_matrix(stdv).nr() == 4,""); DLIB_CASSERT(vector_to_matrix(stdv).nc() == 1,""); DLIB_CASSERT(vector_to_matrix(stdv).size() == 4,""); DLIB_CASSERT(equal(trans(vector_to_matrix(stdv))*vector_to_matrix(stdv), trans(v)*v), ""); DLIB_CASSERT(equal(trans(vector_to_matrix(stdv))*vector_to_matrix(stdv), tmp(trans(v)*v)), ""); DLIB_CASSERT(vector_to_matrix(stdv_c)(0) == 1,""); DLIB_CASSERT(vector_to_matrix(stdv_c)(1) == 2,""); DLIB_CASSERT(vector_to_matrix(stdv_c)(2) == 3,""); DLIB_CASSERT(vector_to_matrix(stdv_c)(3) == 4,""); DLIB_CASSERT(vector_to_matrix(stdv_c).nr() == 4,""); DLIB_CASSERT(vector_to_matrix(stdv_c).nc() == 1,""); DLIB_CASSERT(vector_to_matrix(stdv_c).size() == 4,""); DLIB_CASSERT(equal(trans(vector_to_matrix(stdv_c))*vector_to_matrix(stdv_c), trans(v)*v), ""); DLIB_CASSERT(vector_to_matrix(arr)(0) == 1,""); DLIB_CASSERT(vector_to_matrix(arr)(1) == 2,""); DLIB_CASSERT(vector_to_matrix(arr)(2) == 3,""); DLIB_CASSERT(vector_to_matrix(arr)(3) == 4,""); DLIB_CASSERT(vector_to_matrix(arr).nr() == 4,""); DLIB_CASSERT(vector_to_matrix(arr).nc() == 1,""); DLIB_CASSERT(vector_to_matrix(arr).size() == 4,""); DLIB_CASSERT(equal(trans(vector_to_matrix(arr))*vector_to_matrix(arr), trans(v)*v), ""); DLIB_CASSERT(v(0) == 1,""); DLIB_CASSERT(v(1) == 2,""); DLIB_CASSERT(v(2) == 3,""); DLIB_CASSERT(v(3) == 4,""); matrix<double> dv = v; DLIB_CASSERT((trans(v)*v).size() == 1,""); DLIB_CASSERT((trans(v)*v).nr() == 1,""); DLIB_CASSERT((trans(v)*dv).nr() == 1,""); DLIB_CASSERT((trans(dv)*dv).nr() == 1,""); DLIB_CASSERT((trans(dv)*v).nr() == 1,""); DLIB_CASSERT((trans(v)*v).nc() == 1,""); DLIB_CASSERT((trans(v)*dv).nc() == 1,""); DLIB_CASSERT((trans(dv)*dv).nc() == 1,""); DLIB_CASSERT((trans(dv)*v).nc() == 1,""); DLIB_CASSERT((trans(v)*v)(0) == 1*1 + 2*2 + 3*3 + 4*4,""); DLIB_CASSERT((trans(dv)*v)(0) == 1*1 + 2*2 + 3*3 + 4*4,""); DLIB_CASSERT((trans(dv)*dv)(0) == 1*1 + 2*2 + 3*3 + 4*4,""); DLIB_CASSERT((trans(v)*dv)(0) == 1*1 + 2*2 + 3*3 + 4*4,""); dv = trans(dv)*v; DLIB_CASSERT(dv.nr() == 1,""); DLIB_CASSERT(dv.nc() == 1,""); dm3 = m3; DLIB_CASSERT(floor(det(m3)+0.01) == -444,""); DLIB_CASSERT(floor(det(dm3)+0.01) == -444,""); DLIB_CASSERT(min(m3) == 1,""); DLIB_CASSERT(min(dm3) == 1,""); DLIB_CASSERT(max(m3) == 52,""); DLIB_CASSERT(max(dm3) == 52,""); DLIB_CASSERT(sum(m3) == 112,""); DLIB_CASSERT(sum(dm3) == 112,""); DLIB_CASSERT(prod(m3) == 41513472,""); DLIB_CASSERT(prod(dm3) == 41513472,""); DLIB_CASSERT(prod(diag(m3)) == 1*52*9,""); DLIB_CASSERT(prod(diag(dm3)) == 1*52*9,""); DLIB_CASSERT(sum(diag(m3)) == 1+52+9,""); DLIB_CASSERT(sum(diag(dm3)) == 1+52+9,""); DLIB_CASSERT(equal(round(10000*m3*inv(m3))/10000 , identity_matrix<double,3>()),""); DLIB_CASSERT(equal(round(10000*dm3*inv(m3))/10000 , identity_matrix<double,3>()),""); DLIB_CASSERT(equal(round(10000*dm3*inv(dm3))/10000 , identity_matrix<double,3>()),""); DLIB_CASSERT(equal(round(10000*m3*inv(dm3))/10000 , identity_matrix<double,3>()),""); DLIB_CASSERT(equal(round(10000*tmp(m3*inv(m3)))/10000 , identity_matrix<double,3>()),""); DLIB_CASSERT(equal(round(10000*tmp(dm3*inv(m3)))/10000 , identity_matrix<double,3>()),""); DLIB_CASSERT(equal(round(10000*tmp(dm3*inv(dm3)))/10000 , identity_matrix<double,3>()),""); DLIB_CASSERT(equal(round(10000*tmp(m3*inv(dm3)))/10000 , identity_matrix<double,3>()),""); DLIB_CASSERT(-1*m3 == -m3,""); DLIB_CASSERT(-1*dm3 == -m3,""); DLIB_CASSERT(-1*m3 == -dm3,""); DLIB_CASSERT(-1*dm3 == -dm3,""); DLIB_CASSERT(m3 == dm3,""); m3(1,1) = 99; DLIB_CASSERT(m3 != dm3,""); m3 = dm3; DLIB_CASSERT(m3 == dm3,""); matrix<double,4,4,MM> mident(ident); matrix<double,4,4> muniform0(uniform0); matrix<double,4,4> muniform1(uniform1); matrix<double,4,4> muniform3(uniform3); matrix<double,4,4> m1(array), m2; DLIB_CASSERT(m1.nr() == 4,""); DLIB_CASSERT(m1.nc() == 4,""); DLIB_CASSERT(muniform1 + muniform1 + muniform1 == muniform3,""); DLIB_CASSERT(muniform1*2 + muniform1 + muniform1 - muniform1 == muniform3,""); DLIB_CASSERT(2*muniform1 + muniform1 + muniform1 - muniform1 == muniform3,""); DLIB_CASSERT(muniform1 + muniform1 + muniform1 - muniform3 == muniform0,""); DLIB_CASSERT(equal(muniform3/3 , muniform1),""); DLIB_CASSERT(v != m1,""); DLIB_CASSERT(v == v,""); DLIB_CASSERT(m1 == m1,""); muniform0.swap(muniform1); DLIB_CASSERT((muniform1 == matrix_cast<double>(uniform_matrix<long,4,4,0>())),""); DLIB_CASSERT((muniform0 == matrix_cast<double>(uniform_matrix<long,4,4,1>())),""); DLIB_CASSERT((muniform1 == matrix_cast<double>(uniform_matrix<long>(4,4,0))),""); DLIB_CASSERT((muniform0 == matrix_cast<double>(uniform_matrix<long>(4,4,1))),""); swap(muniform0,muniform1); DLIB_CASSERT((mident == identity_matrix<double,4>()),""); DLIB_CASSERT((muniform0 == matrix_cast<double>(uniform_matrix<long,4,4,0>())),""); DLIB_CASSERT((muniform1 == matrix_cast<double>(uniform_matrix<long,4,4,1>())),""); DLIB_CASSERT((muniform3 == matrix_cast<double>(uniform_matrix<long,4,4,3>())),""); DLIB_CASSERT((muniform1*8 == matrix_cast<double>(uniform_matrix<long,4,4,8>())),""); set_all_elements(m2,7); DLIB_CASSERT(m2 == muniform1*7,""); m2 = array; DLIB_CASSERT(m2 == m1,""); const double m1inv[] = { -0.00946427624, 0.0593272941, 0.00970564379, -0.00973323731, 0.0249312057, -0.0590122427, -0.00583102756, 0.00616002729, -0.00575431149, 0.110081189, -0.00806792253, 0.00462297692, 0.00327847478, -0.0597669712, 0.00317386196, 0.00990759201 }; m2 = m1inv; DLIB_CASSERT((round(m2*m1) == identity_matrix<double,4>()),""); DLIB_CASSERT((round(tmp(m2*m1)) == identity_matrix<double,4>()),""); DLIB_CASSERT(round(m2*10000) == round(inv(m1)*10000), round(m2*10000) - round(inv(m1)*10000) << "\n\n" << round(m2*10000) << "\n\n" << round(inv(m1)*10000) << "\n\n" << m2 << "\n\n" << inv(m1) ); DLIB_CASSERT(m1 == abs(-1*m1),""); DLIB_CASSERT(abs(m2) == abs(-1*m2),""); DLIB_CASSERT(floor(det(m1)+0.01) == 3297875,"\nm1: \n" << m1 << "\ndet(m1): " << det(m1)); ostringstream sout; m1 = m2; serialize(m1,sout); set_all_elements(m1,0); istringstream sin(sout.str()); deserialize(m1,sin); DLIB_CASSERT(round(100000*m1) == round(100000*m2),"m1: \n" << m1 << endl << "m2: \n" << m2); set_all_elements(v,2); v2 = pointwise_multiply(v, v*2); set_all_elements(v,8); DLIB_CASSERT(v == v2,""); DLIB_CASSERT(v == tmp(v2),""); DLIB_CASSERT((v == rotate<2,0>(v)),""); m4 = array2; m5 = array2_r; DLIB_CASSERT((m5 == rotate<1,1>(m4)),""); m5 = array2; DLIB_CASSERT((m5*2 == pointwise_multiply(m5,uniform_matrix<int,3,3,2>())),""); DLIB_CASSERT((tmp(m5*2) == tmp(pointwise_multiply(m5,uniform_matrix<int,3,3,2>()))),""); v = tmp(v); matrix<double> dm10(10,5); DLIB_CASSERT(dm10.nr() == 10,""); DLIB_CASSERT(dm10.nc() == 5,""); set_all_elements(dm10,4); DLIB_CASSERT(dm10.nr() == 10,""); DLIB_CASSERT(dm10.nc() == 5,""); matrix<double,10,5> m10; DLIB_CASSERT(m10.nr() == 10,""); DLIB_CASSERT(m10.nc() == 5,""); set_all_elements(m10,4); DLIB_CASSERT(dm10 == m10,""); DLIB_CASSERT((clamp<0,3>(dm10) == clamp<0,3>(m10)),""); DLIB_CASSERT((clamp<0,3>(dm10)(0,2) == 3),""); set_all_elements(dm10,1); set_all_elements(m10,4); DLIB_CASSERT(4*dm10 == m10,""); DLIB_CASSERT(5*dm10 - dm10 == m10,""); DLIB_CASSERT((16*dm10)/4 == m10,""); DLIB_CASSERT(dm10+dm10+2*dm10 == m10,""); DLIB_CASSERT(dm10+tmp(dm10+2*dm10) == m10,""); set_all_elements(dm10,4); DLIB_CASSERT(dm10 == m10,""); DLIB_CASSERT(sum(abs(sigmoid(dm10) -sigmoid(m10))) < 1e-10,sum(abs(sigmoid(dm10) -sigmoid(m10))) ); matrix<double, 7, 7,MM,column_major_layout> m7; matrix<double> dm7(7,7); for (long r= 0; r< dm7.nr(); ++r) { for (long c = 0; c < dm7.nc(); ++c) { dm7(r,c) = r*c/3.3; } } m7 = dm7; DLIB_CASSERT(inv(dm7) == inv(m7),""); DLIB_CASSERT(det(dm7) == det(m7),""); DLIB_CASSERT(min(dm7) == min(m7),""); DLIB_CASSERT(max(dm7) == max(m7),""); DLIB_CASSERT(abs(sum(dm7) - sum(m7)) < 1e-14,sum(dm7) - sum(m7)); DLIB_CASSERT(prod(dm7) == prod(m7),""); DLIB_CASSERT(diag(dm7) == diag(m7),""); DLIB_CASSERT(trans(dm7) == trans(m7),""); DLIB_CASSERT(abs(dm7) == abs(m7),""); DLIB_CASSERT(round(dm7) == round(m7),""); DLIB_CASSERT(matrix_cast<int>(dm7) == matrix_cast<int>(m7),""); DLIB_CASSERT((rotate<2,3>(dm7) == rotate<2,3>(m7)),""); DLIB_CASSERT((sum(pointwise_multiply(dm7,dm7) - pointwise_multiply(m7,m7))) < 1e-10,""); DLIB_CASSERT((sum(pointwise_multiply(dm7,dm7,dm7) - pointwise_multiply(m7,m7,m7))) < 1e-10,""); DLIB_CASSERT((sum(pointwise_multiply(dm7,dm7,dm7,dm7) - pointwise_multiply(m7,m7,m7,m7))) < 1e-10, (sum(pointwise_multiply(dm7,dm7,dm7,dm7) - pointwise_multiply(m7,m7,m7,m7))) ); matrix<double> temp(5,5); matrix<double> dsm(5,5); matrix<double,5,5,MM> sm; set_all_elements(dsm,1); set_all_elements(sm,1); set_all_elements(temp,1); dsm += dsm; sm += sm; DLIB_CASSERT(dsm == 2*temp,""); DLIB_CASSERT(sm == 2*temp,""); temp = dsm*sm + dsm; dsm += dsm*sm; DLIB_CASSERT(temp == dsm,temp - dsm); set_all_elements(dsm,1); set_all_elements(sm,1); set_all_elements(temp,1); dsm += dsm; sm += sm; DLIB_CASSERT(dsm == 2*temp,""); DLIB_CASSERT(sm == 2*temp,""); temp = dsm*sm + dsm; sm += dsm*sm; DLIB_CASSERT(temp == sm,temp - sm); set_all_elements(dsm,1); set_all_elements(sm,1); set_all_elements(temp,1); dsm += dsm; sm += sm; DLIB_CASSERT(dsm == 2*temp,""); DLIB_CASSERT(sm == 2*temp,""); temp = sm - dsm*sm ; sm -= dsm*sm; DLIB_CASSERT(temp == sm,temp - sm); set_all_elements(dsm,1); set_all_elements(sm,1); set_all_elements(temp,1); dsm += dsm; sm += sm; DLIB_CASSERT(dsm == 2*temp,""); DLIB_CASSERT(sm == 2*temp,""); temp = dsm - dsm*sm ; dsm -= dsm*sm; DLIB_CASSERT(temp == dsm,temp - dsm); set_all_elements(dsm,1); set_all_elements(sm,1); set_all_elements(temp,2); dsm *= 2; sm *= 2; DLIB_CASSERT(dsm == temp,""); DLIB_CASSERT(sm == temp,""); dsm /= 2; sm /= 2; DLIB_CASSERT(dsm == temp/2,""); DLIB_CASSERT(sm == temp/2,""); dsm += dsm; sm += sm; DLIB_CASSERT(dsm == temp,""); DLIB_CASSERT(sm == temp,""); dsm += sm; sm += dsm; DLIB_CASSERT(dsm == 2*temp,""); DLIB_CASSERT(sm == temp*3,""); dsm -= sm; sm -= dsm; DLIB_CASSERT(dsm == -temp,""); DLIB_CASSERT(sm == 4*temp,""); sm -= sm; dsm -= dsm; DLIB_CASSERT(dsm == 0*temp,""); DLIB_CASSERT(sm == 0*temp,""); set_all_elements(dsm,1); set_all_elements(sm,1); set_all_elements(temp,3); dsm += sm+sm; DLIB_CASSERT(dsm == temp,""); set_all_elements(dsm,1); set_all_elements(sm,1); set_all_elements(temp,-1); dsm -= sm+sm; DLIB_CASSERT(dsm == temp,""); set_all_elements(dsm,1); set_all_elements(sm,1); set_all_elements(temp,-1); sm -= dsm+dsm; DLIB_CASSERT(sm == temp,""); set_all_elements(dsm,1); set_all_elements(sm,1); set_all_elements(temp,3); sm += dsm+dsm; DLIB_CASSERT(sm == temp,""); // test the implicit conversion to bool stuff { matrix<float> bt1(3,1); matrix<float,3,1> bt2; set_all_elements(bt1,2); set_all_elements(bt2,3); DLIB_CASSERT(trans(bt1)*bt2 == 18,""); } { matrix<float,3,1> bt1; matrix<float> bt2(3,1); set_all_elements(bt1,2); set_all_elements(bt2,3); DLIB_CASSERT(trans(bt1)*bt2 == 18,""); } { matrix<float> bt1(3,1); matrix<float> bt2(3,1); set_all_elements(bt1,2); set_all_elements(bt2,3); DLIB_CASSERT(trans(bt1)*bt2 == 18,""); } { matrix<float,3,1> bt1; matrix<float,3,1> bt2; set_all_elements(bt1,2); set_all_elements(bt2,3); DLIB_CASSERT(trans(bt1)*bt2 == 18,""); } { srand(423452); const long M = 50; const long N = 40; matrix<double> a(M,N); for (long r = 0; r < a.nr(); ++r) { for (long c = 0; c < a.nc(); ++c) { a(r,c) = 10*((double)::rand())/RAND_MAX; } } matrix<double> u, u2; matrix<double> q, q2; matrix<double> v, v2; matrix<double> a2; a2 = tmp(a/2); svd2(true,true,a2+a2,u,q,v); double err = sum(round(1e10*(a - subm(u,get_rect(a2+a2))*diagm(q)*trans(v)))); DLIB_CASSERT( err == 0,"err: " << err); DLIB_CASSERT((round(1e10*trans(u)*u) == 1e10*identity_matrix<double,M>()),""); DLIB_CASSERT((round(1e10*trans(v)*v) == 1e10*identity_matrix<double,N>()),""); svd2(false,true,a2+a2,u2,q2,v2); DLIB_CASSERT(equal(q2,q),""); DLIB_CASSERT(equal(v2,v),""); svd2(true,false,a2+a2,u2,q2,v2); DLIB_CASSERT(equal(q2,q),""); DLIB_CASSERT(equal(u2,u),""); svd2(false,false,a2+a2,u2,q2,v2); DLIB_CASSERT(equal(q2,q),""); } { srand(423452); const long M = 3; const long N = 3; matrix<double> a(M,N); for (long r = 0; r < a.nr(); ++r) { for (long c = 0; c < a.nc(); ++c) { a(r,c) = 10*((double)::rand())/RAND_MAX; } } matrix<double,M,M> u, u2; matrix<double> q, q2; matrix<double,N,N> v, v2; matrix<double,M,N,MM> a2; a2 = tmp(a/2); svd2(true,true,a2+a2,u,q,v); double err = sum(round(1e10*(a - subm(u,get_rect(a2+a2))*diagm(q)*trans(v)))); DLIB_CASSERT( err == 0,"err: " << err); DLIB_CASSERT((round(1e10*trans(u)*u) == 1e10*identity_matrix<double,M>()),""); DLIB_CASSERT((round(1e10*trans(v)*v) == 1e10*identity_matrix<double,N>()),""); svd2(false,true,a2+a2,u2,q2,v2); DLIB_CASSERT(equal(q2,q),""); DLIB_CASSERT(equal(v2,v),""); svd2(true,false,a2+a2,u2,q2,v2); DLIB_CASSERT(equal(q2,q),""); DLIB_CASSERT(equal(u2,u),""); svd2(false,false,a2+a2,u2,q2,v2); DLIB_CASSERT(equal(q2,q),""); } { srand(423452); const long M = 10; const long N = 7; matrix<double> a(M,N); for (long r = 0; r < a.nr(); ++r) { for (long c = 0; c < a.nc(); ++c) { a(r,c) = 10*((double)::rand())/RAND_MAX; } } matrix<double,M,M> u; matrix<double> q; matrix<double,N,N> v; matrix<double,M,N,MM> a2; a2 = tmp(a/2); svd2(true,true,a2+a2,u,q,v); double err = sum(round(1e10*(a - subm(u,get_rect(a2+a2))*diagm(q)*trans(v)))); DLIB_CASSERT( err == 0,"err: " << err); DLIB_CASSERT((round(1e10*trans(u)*u) == 1e10*identity_matrix<double,M>()),""); DLIB_CASSERT((round(1e10*trans(v)*v) == 1e10*identity_matrix<double,N>()),""); } { srand(423452); const long M = 10; const long N = 7; matrix<double> a(M,N); for (long r = 0; r < a.nr(); ++r) { for (long c = 0; c < a.nc(); ++c) { a(r,c) = 10*((double)::rand())/RAND_MAX; } } matrix<double,M> u(M,N); matrix<double> w; matrix<double,N,N> v(N,N); matrix<double,M,N,MM> a2; a2 = tmp(a/2); svd(a2+a2,u,w,v); DLIB_CASSERT( sum(round(1e10*(a - u*w*trans(v)))) == 0,""); DLIB_CASSERT((round(1e10*trans(u)*u) == 1e10*identity_matrix<double,N>()),""); DLIB_CASSERT((round(1e10*trans(v)*v) == 1e10*identity_matrix<double,N>()),""); } { srand(423452); const long M = 1; const long N = 1; matrix<double> a(M,N); for (long r = 0; r < a.nr(); ++r) { for (long c = 0; c < a.nc(); ++c) { a(r,c) = 10*((double)::rand())/RAND_MAX; } } matrix<double,M,N> u; matrix<double> w; matrix<double,N,N> v; matrix<double,M,N> a2; a2 = tmp(a/2); svd(a2+a2,u,w,v); DLIB_CASSERT( sum(round(1e10*(a - u*w*trans(v)))) == 0,""); DLIB_CASSERT((round(1e10*trans(u)*u) == 1e10*identity_matrix<double,N>()),""); DLIB_CASSERT((round(1e10*trans(v)*v) == 1e10*identity_matrix<double,N>()),""); } { srand(53434); const long M = 5; const long N = 5; matrix<double> a(M,N); for (long r = 0; r < a.nr(); ++r) { for (long c = 0; c < a.nc(); ++c) { a(r,c) = 10*((double)::rand())/RAND_MAX; } } matrix<double,0,N> u(M,N); matrix<double,N,N> w; matrix<double> v; svd(a,u,w,v); DLIB_CASSERT( sum(round(1e10*(a - u*w*trans(v)))) == 0,""); DLIB_CASSERT((round(1e10*trans(u)*u) == 1e10*identity_matrix<double,N>()),""); DLIB_CASSERT((round(1e10*trans(v)*v) == 1e10*identity_matrix<double,N>()),""); } { srand(11234); const long M = 9; const long N = 4; matrix<double,0,0,MM> a(M,N); for (long r = 0; r < a.nr(); ++r) { for (long c = 0; c < a.nc(); ++c) { a(r,c) = 10*((double)::rand())/RAND_MAX; } } matrix<double> u; matrix<double,0,0,MM> w; matrix<double> v; svd(a,u,w,v); DLIB_CASSERT( sum(round(1e10*(a - u*w*trans(v)))) == 0,""); DLIB_CASSERT((round(1e10*trans(u)*u) == 1e10*identity_matrix<double,N>()),""); DLIB_CASSERT((round(1e10*trans(v)*v) == 1e10*identity_matrix<double,N>()),""); } { srand(53934); const long M = 2; const long N = 4; matrix<double> a(M,N); for (long r = 0; r < a.nr(); ++r) { for (long c = 0; c < a.nc(); ++c) { a(r,c) = 10*((double)::rand())/RAND_MAX; } } matrix<double> u; matrix<double> w; matrix<double> v; svd(a,u,w,v); DLIB_CASSERT( sum(round(1e10*(a - u*w*trans(v)))) == 0,""); } { srand(53234); const long M = 9; const long N = 40; matrix<double> a(M,N); for (long r = 0; r < a.nr(); ++r) { for (long c = 0; c < a.nc(); ++c) { a(r,c) = 10*((double)::rand())/RAND_MAX; } } matrix<double> u; matrix<double> w; matrix<double> v; svd(a,u,w,v); DLIB_CASSERT( sum(round(1e10*(a - u*w*trans(v)))) == 0,""); } { matrix<double> a(3,3); matrix<double,3,3> b; set_all_elements(a,0); a(0,0) = 1; a(1,1) = 2; a(2,2) = 3; b = a; DLIB_CASSERT(diag(a)(0) == 1,""); DLIB_CASSERT(diag(a)(1) == 2,""); DLIB_CASSERT(diag(a)(2) == 3,""); DLIB_CASSERT(diag(a).nr() == 3,""); DLIB_CASSERT(diag(a).nc() == 1,""); DLIB_CASSERT(diag(b)(0) == 1,""); DLIB_CASSERT(diag(b)(1) == 2,""); DLIB_CASSERT(diag(b)(2) == 3,""); DLIB_CASSERT(diag(b).nr() == 3,""); DLIB_CASSERT(diag(b).nc() == 1,""); DLIB_CASSERT(pointwise_multiply(a,b)(0,0) == 1,""); DLIB_CASSERT(pointwise_multiply(a,b)(1,1) == 4,""); DLIB_CASSERT(pointwise_multiply(a,b)(2,2) == 9,""); DLIB_CASSERT(pointwise_multiply(a,b)(1,0) == 0,""); DLIB_CASSERT(pointwise_multiply(a,b,a)(1,0) == 0,""); DLIB_CASSERT(pointwise_multiply(a,b,a,b)(1,0) == 0,""); DLIB_CASSERT(complex_matrix(a,b)(0,0) == std::complex<double>(1,1),""); DLIB_CASSERT(complex_matrix(a,b)(2,2) == std::complex<double>(3,3),""); DLIB_CASSERT(complex_matrix(a,b)(2,1) == std::complex<double>(0,0),""); } { matrix<float,3,1> m1, m2; set_all_elements(m1,2.0); set_all_elements(m2,1.0/2.0); DLIB_CASSERT(reciprocal(m1) == m2,""); DLIB_CASSERT((reciprocal(uniform_matrix<float,3,1>(2.0)) == m2),""); DLIB_CASSERT((round_zeros(uniform_matrix<float,3,1>(1e-8f)) == uniform_matrix<float,3,1>(0)) ,""); set_all_elements(m1,2.0); m2 = m1; m1(1,0) = static_cast<float>(1e-8); m2(1,0) = 0; DLIB_CASSERT(round_zeros(m1) == m2,""); m1 = round_zeros(m1); DLIB_CASSERT(m1 == m2,""); } { matrix<matrix<double,2,2> > m; m.set_size(3,3); set_all_elements(m,uniform_matrix<double,2,2>(1)); DLIB_CASSERT((sum(m) == uniform_matrix<double,2,2>(9)),""); DLIB_CASSERT((round_zeros(sqrt(sum(m)) - uniform_matrix<double,2,2>(3)) == uniform_matrix<double,2,2>(0)),""); } { matrix<int,2,2> m1; matrix<int> m2; m2.set_size(2,2); set_all_elements(m1,2); m2 = uniform_matrix<int,2,2>(2); m1 = m1 + m2; DLIB_CASSERT((m1 == uniform_matrix<int,2,2>(4)),""); set_all_elements(m1,2); set_all_elements(m2,2); m1 = m1*m1; DLIB_CASSERT((m1 == uniform_matrix<int,2,2>(8)),""); m1(1,0) = 1; set_all_elements(m2,8); m2(0,1) = 1; m1 = trans(m1); DLIB_CASSERT(m1 == m2,""); } { matrix<double,2,3> m; matrix<double> m2(2,3); set_all_elements(m,1); DLIB_CASSERT(mean(m) == 1,""); set_all_elements(m,2); DLIB_CASSERT(mean(m) == 2,""); m(0,0) = 1; m(0,1) = 1; m(0,2) = 1; DLIB_CASSERT(abs(mean(m) - 1.5) < 1e-10,""); DLIB_CASSERT(abs(variance(m) - 0.3) < 1e-10,""); set_all_elements(m2,1); DLIB_CASSERT(mean(m2) == 1,""); set_all_elements(m2,2); DLIB_CASSERT(mean(m2) == 2,""); m2(0,0) = 1; m2(0,1) = 1; m2(0,2) = 1; DLIB_CASSERT(abs(mean(m2) - 1.5) < 1e-10,""); DLIB_CASSERT(abs(variance(m2) - 0.3) < 1e-10,""); set_all_elements(m,0); DLIB_CASSERT(abs(variance(m)) < 1e-10,""); set_all_elements(m,1); DLIB_CASSERT(abs(variance(m)) < 1e-10,""); set_all_elements(m,23.4); DLIB_CASSERT(abs(variance(m)) < 1e-10,""); } { matrix<matrix<double,3,1,MM>,2,2,MM> m; set_all_elements(m,uniform_matrix<double,3,1>(1)); DLIB_CASSERT((round_zeros(variance(m)) == uniform_matrix<double,3,1>(0)),""); DLIB_CASSERT((round_zeros(mean(m)) == uniform_matrix<double,3,1>(1)),""); m(0,0) = uniform_matrix<double,3,1>(9); DLIB_CASSERT((round_zeros(variance(m)) == uniform_matrix<double,3,1>(16)),""); DLIB_CASSERT((round_zeros(mean(m)) == uniform_matrix<double,3,1>(3)),""); matrix<matrix<double> > m2(2,2); set_all_elements(m2,uniform_matrix<double,3,1>(1)); DLIB_CASSERT((round_zeros(variance(m2)) == uniform_matrix<double,3,1>(0)),""); DLIB_CASSERT((round_zeros(mean(m2)) == uniform_matrix<double,3,1>(1)),""); m2(0,0) = uniform_matrix<double,3,1>(9); DLIB_CASSERT((round_zeros(variance(m2)) == uniform_matrix<double,3,1>(16)),""); DLIB_CASSERT((round_zeros(mean(m2)) == uniform_matrix<double,3,1>(3)),""); } { matrix<double> m(4,4), m2; m = 1,2,3,4, 1,2,3,4, 4,6,8,10, 4,6,8,10; m2 = m; DLIB_CASSERT(colm(m,range(0,3)) == m,""); DLIB_CASSERT(rowm(m,range(0,3)) == m,""); DLIB_CASSERT(colm(m,range(0,0)) == colm(m,0),""); DLIB_CASSERT(rowm(m,range(0,0)) == rowm(m,0),""); DLIB_CASSERT(colm(m,range(1,1)) == colm(m,1),""); DLIB_CASSERT(rowm(m,range(1,1)) == rowm(m,1),""); DLIB_CASSERT(colm(m,range(2,2)) == colm(m,2),""); DLIB_CASSERT(rowm(m,range(2,2)) == rowm(m,2),""); DLIB_CASSERT(colm(m,range(1,2)) == subm(m,0,1,4,2),""); DLIB_CASSERT(rowm(m,range(1,2)) == subm(m,1,0,2,4),""); set_colm(m,range(1,2)) = 9; set_subm(m2,0,1,4,2) = 9; DLIB_CASSERT(m == m2,""); set_colm(m,range(1,2)) = 11; set_subm(m2,0,1,4,2) = 11; DLIB_CASSERT(m == m2,""); } } class matrix_tester : public tester { public: matrix_tester ( ) : tester ("test_matrix2", "Runs tests on the matrix component.") {} void perform_test ( ) { matrix_test(); } } a; }
[ [ [ 1, 1008 ] ] ]
547374b9eefb427c2d9283f1a7dd56d36d1a6bbe
9566086d262936000a914c5dc31cb4e8aa8c461c
/EnigmaProtocol/Messages/SkillRequestMessage.hpp
be407be7bd97825ce2c71d112ad08015bce62a33
[]
no_license
pazuzu156/Enigma
9a0aaf0cd426607bb981eb46f5baa7f05b66c21f
b8a4dfbd0df206e48072259dbbfcc85845caad76
refs/heads/master
2020-06-06T07:33:46.385396
2011-12-19T03:14:15
2011-12-19T03:14:15
3,023,618
1
0
null
null
null
null
WINDOWS-1252
C++
false
false
2,537
hpp
#ifndef SKILLREQUESTMESSAGE_HPP_INCLUDED #define SKILLREQUESTMESSAGE_HPP_INCLUDED /* Copyright © 2009 Christopher Joseph Dean Schaefer (disks86) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "MessageContainer.hpp" #include "string.hpp" #include "TargetPreferenceTypes.hpp" namespace Enigma { class DllExport SkillRequestMessage : public MessageContainer { private: protected: public: SkillRequestMessage(Message& message) :MessageContainer(message){}; SkillRequestMessage(); ~SkillRequestMessage(); static const int GetMessageType(){return 42;} static const int GetMessageLength(){return 5;} Enigma::s32 GetSkillId(); void SetSkillId(Enigma::s32 value); void SetSkillId(std::string value); Enigma::s32 GetSkillLevel(); void SetSkillLevel(Enigma::s32 value); void SetSkillLevel(std::string value); Enigma::s32 GetTargetNpcId(); void SetTargetNpcId(Enigma::s32 value); void SetTargetNpcId(std::string value); Enigma::s32 GetTargetMonsterId(); void SetTargetMonsterId(Enigma::s32 value); void SetTargetMonsterId(std::string value); Enigma::s32 GetTargetCharacterId(); void SetTargetCharacterId(Enigma::s32 value); void SetTargetCharacterId(std::string value); Enigma::s32 GetTargetPreferenceType(); void SetTargetPreferenceType(Enigma::s32 value); void SetTargetPreferenceType(std::string value); Enigma::vector3d<Enigma::s32> GetTargetLocation(); void SetTargetLocation(Enigma::vector3d<Enigma::s32> value); }; }; #endif // SKILLREQUESTMESSAGE_HPP_INCLUDED
[ [ [ 1, 70 ] ] ]
5b2720fe2170aadaba889e30f5c4ea037b4b98da
283d1a3bae9162d16f7755a1b024a6bf709282bc
/Network_Data_Logger/src/ofxHttpUtils/ofxHttpUtils.h
e5dc2361756305e0ee8ad72d40eb2eeeb389732f
[]
no_license
imclab/SanJoseZero1
aac1ada36a0f21ca43f3d2541c1458600d9ab762
4a99dea9850c056ff1930e6e6deebbf02f82956e
refs/heads/master
2021-01-22T15:22:46.078940
2010-10-28T21:35:44
2010-10-28T21:35:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,558
h
/* ofxHttpUtils v0.3 Chris O'Shea, Arturo, Jesus, CJ Modified: 16th March 2009 openFrameworks 0.06 */ #ifndef _OFX_HTTP_UTILS #define _OFX_HTTP_UTILS #include "ofMain.h" #include "ofxThread.h" #include "Poco/Net/HTTPClientSession.h" #include "Poco/Net/HTTPRequest.h" #include "Poco/Net/HTTPResponse.h" #include "Poco/Net/HTMLForm.h" #include "Poco/StreamCopier.h" #include "Poco/Path.h" #include "Poco/URI.h" #include "Poco/Exception.h" #include "Poco/Mutex.h" #include <iostream> #include <queue> #include <istream> using namespace Poco::Net; using namespace Poco; class ofxHttpListener; class ofxHttpEventManager; #include "ofxHttpTypes.h" struct ofxHttpResponse{ ofxHttpResponse(HTTPResponse& pocoResponse, istream &bodyStream, string turl){ status=pocoResponse.getStatus(); timestamp=pocoResponse.getDate(); reasonForStatus=pocoResponse.getReasonForStatus(pocoResponse.getStatus()); contentType = pocoResponse.getContentType(); StreamCopier::copyToString(bodyStream, responseBody); url = turl; } ofxHttpResponse(){} int status; // return code for the response ie: 200 = OK string reasonForStatus; // text explaining the status string responseBody; // the actual response string contentType; // the mime type of the response Poco::Timestamp timestamp; // time of the response string url; }; class ofxHttpUtils : public ofxThread{ public: ofxHttpUtils(); ~ofxHttpUtils(); //------------------------------- // non blocking functions void addForm(ofxHttpForm form); void addUrl(string url); //------------------------------- // blocking functions void submitForm(ofxHttpForm form); void getUrl(string url); //int getQueueLength(); //void clearQueue(); //------------------------------- // threading stuff void threadedFunction(); //------------------------------ // events ofEvent<ofxHttpResponse> newResponseEvent; // other stuff------------------- void setTimeoutSeconds(int t){ timeoutSeconds = t; } void setVerbose(bool v){ verbose = v; } protected: void start(); void stop(); bool isThreadRunning(); bool verbose; int timeoutSeconds; //-------------------------------- // http utils string generateUrl(ofxHttpForm & form); void doPostForm(ofxHttpForm & form); //queue<ofxHttpForm> forms; ofxHttpForm formToSend; bool thereIsFormToSend; FastMutex threadStartedMutex; }; #endif
[ [ [ 1, 120 ] ] ]
203ca542b42b951c7385f18ddec9fddaf98dbc8a
a51ac532423cf58c35682415c81aee8e8ae706ce
/CameraAPI/Camera.cpp
43efb7aaa155764aa93a17a0eab186fc25b7cdf1
[]
no_license
anderslindmark/PickNPlace
b9a89fb2a6df839b2b010b35a0c873af436a1ab9
00ca4f6ce2ecfeddfea7db5cb7ae8e9d0023a5e1
refs/heads/master
2020-12-24T16:59:20.515351
2008-05-25T01:32:31
2008-05-25T01:32:31
34,914,321
1
0
null
null
null
null
UTF-8
C++
false
false
1,388
cpp
#include "Camera.h" #include "CameraException.h" #include "log.h" namespace camera { Camera::Camera() { LOG_TRACE("Camera::Camera()"); m_listener = NULL; m_lastImage = NULL; } Camera::~Camera() { LOG_TRACE("Camera::~Camera()"); } Image *Camera::getLastImage() { return m_lastImage; } void Camera::addFilter(Filter *filter) { m_filters.push_back(filter); } void Camera::removeFilter(camera::Filter *filter) { for(FilterList::const_iterator iter = m_filters.begin(); iter != m_filters.end(); iter++) { if((*iter) == filter) m_filters.erase(iter); } } void Camera::setListener(CameraListener *listener) { LOG_TRACE("Camera::setCallbackClass()"); m_listener = listener; } void Camera::doNewImageCallback(Image *image) { LOG_TRACE("Camera::doNewImageCallback()"); // Apply all filters for(FilterList::const_iterator iter = m_filters.begin(); iter != m_filters.end(); iter++) { if((*iter)->getEnabled()) { image = (*iter)->apply(image); } } m_lastImage = image; if(m_listener != NULL) { m_listener->cameraNewImage(this, image); } } void Camera::doErrorCallback(int errorCode, const std::string &errorMessage) { LOG_TRACE("Camera::doErrorCallback()"); if(m_listener != NULL) { m_listener->cameraError(this, errorCode, errorMessage); } } } // namespace camera
[ "kers@f672c3ff-8b41-4f22-a4ab-2adcb4f732c7", "js@f672c3ff-8b41-4f22-a4ab-2adcb4f732c7" ]
[ [ [ 1, 4 ], [ 7, 7 ], [ 10, 10 ], [ 12, 15 ], [ 18, 39 ], [ 42, 46 ], [ 48, 60 ], [ 62, 65 ], [ 68, 69 ], [ 71, 75 ] ], [ [ 5, 6 ], [ 8, 9 ], [ 11, 11 ], [ 16, 17 ], [ 40, 41 ], [ 47, 47 ], [ 61, 61 ], [ 66, 67 ], [ 70, 70 ] ] ]
921648e6dcff7b254adb5ebb6d7809f66e96e53f
280e6fff54711b88fa370e38c6e201aedcfedfc9
/3rdparty/json/src/jsonval.cpp
4c7eda0a3084e37889a143d1e40c2b3372c6c6e2
[]
no_license
plus7/Highwind
7cf48022f0b511202b1f6dd42623c07bd1291ac6
4cfe2874c2ab5697963946401bf1d2a769f19832
refs/heads/master
2016-09-02T09:13:35.628726
2009-10-13T16:41:19
2009-10-13T16:41:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
82,568
cpp
///////////////////////////////////////////////////////////////////////////// // Name: jsonval.cpp // Purpose: the wxJSON class that holds a JSON value // Author: Luciano Cattani // Created: 2007/10/01 // RCS-ID: $Id: jsonval.cpp,v 1.12 2008/03/06 10:25:18 luccat Exp $ // Copyright: (c) 2007 Luciano Cattani // Licence: wxWidgets licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ #pragma implementation "jsonval.cpp" #endif // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #include <wx/log.h> #include <wx/debug.h> #include <wx/arrimpl.cpp> #include <wx/jsonval.h> WX_DEFINE_OBJARRAY( wxJSONInternalArray ); // the trace mask used in ::wxLogTrace() function static const wxChar* traceMask = _T("jsonval"); static const wxChar* compareTraceMask = _T("sameas"); static const wxChar* cowTraceMask = _T("traceCOW" ); /******************************************************************* class wxJSONRefData *******************************************************************/ /*! \class wxJSONRefData \brief The reference counted JSON value data (internal use). Starting from version 0.4, the JSON value class use the reference counting tecnique (also know as \e copy-on-write) described in the \b wxWidgets documentation in order to speed up processing. The class is used internally by the wxJSONValue class which does all processing. */ #if defined( WXJSON_USE_VALUE_COUNTER ) // The progressive counter (used for debugging only) int wxJSONRefData::sm_progr = 1; #endif //! Constructor. wxJSONRefData::wxJSONRefData() { m_lineNo = -1; m_refCount = 1; #if defined( WXJSON_USE_VALUE_COUNTER ) m_progr = sm_progr; ++sm_progr; ::wxLogTrace( traceMask, _T("(%s) JSON refData ctor progr=%d"), __PRETTY_FUNCTION__, m_progr); #endif } // Dtor - does nothing wxJSONRefData::~wxJSONRefData() { } int wxJSONRefData::GetRefCount() const { return m_refCount; } /******************************************************************* class wxJSONValue *******************************************************************/ /*! \class wxJSONValue \brief The JSON value class implementation. This class holds a JSON value which may be of variuos types (see the wxJSONType constants for a description of the types). To know more about the internal representation of JSON values see \ref pg_json_internals. Starting from version 0.5 the wxJSON library supports 64-bits integers on platforms that have native support for very large integers. Note that the integer type is still stored as a generic wxJSONTYPE_(U)INT constant regardless the size of the value but the JSON value class defines functions in order to let the user know if an integer value fits in a 32-bit integer or it is so large that it needs a 64-bits integer storage. To know more about 64-bits integer support see \ref json_internals_integer Storing values in a JSON value object of this class is very simple. The following is an example: \code wxJSONValue v( _T( "A string")); // store a string value in the object wxString s = v.AsString(); // get the string value v = 12; // now 'v' contains an integer value int i = v.AsInt(); // get the integer \endcode To know more about using this class see the \ref wxjson_tutorial. */ #if defined( WXJSON_USE_VALUE_COUNTER ) // The progressive counter (used for debugging only) int wxJSONValue::sm_progr = 1; #endif //! Constructors. /*! The overloaded constructors allow the user to construct a JSON value object that holds the specified value and type of value. The default ctor construct a valid JSON object that constains a \b null value. If you want to create an \b empty JSON value object you have to use the \c wxJSONValue( wxJSONTYPE_INVALID ) ctor. Note that this object is not a valid JSON value - to know more about this topic see the SetType() function. \par The C-string JSON value object The wxJSONValue(const wxChar*) ctor allows you to create a JSON value object that contains a string value which is stored as a \e pointer-to-statci-string. In fact, the ctor DOES NOT copy the string: it only stores the pointer in a data member and the pointed-to buffer is not deleted by the dtor. If the string is not static you have to use the wxJSONValue(const wxString&) constructor. Also note that this does NOT mean that the value stored in this JSON object cannot change: you can assign whatever other value you want, an integer, a double or an array of values. What I intended is that the pointed-to string must exist for the lifetime of the wxJSONValue object. The following code is perfectly legal: \code wxJSONvalue aString( "this is a static string" ); aString = 10; \endcode To know more about this topic see \ref json_internals_cstring */ wxJSONValue::wxJSONValue() { m_refData = 0; Init( wxJSONTYPE_NULL ); } //! Initialize the JSON value class. /*! The function is called by the ctors and allocates a new instance of the wxJSONRefData class and sets the type of the JSON value. Note that only the type is set, not the value. Also note that this function may be called from other memberfunctions if the \c m_refData data member is NULL. */ wxJSONRefData* wxJSONValue::Init( wxJSONType type ) { wxJSONRefData* data = GetRefData(); if ( data != 0 ) { UnRef(); } // we allocate a new instance of the referenced data data = new wxJSONRefData(); wxJSON_ASSERT( data ); // in release builds w do not have ASSERT so we check 'data' before // using it if ( data ) { data->m_type = type; data->m_commentPos = wxJSONVALUE_COMMENT_BEFORE; } SetRefData( data ); #if defined( WXJSON_USE_VALUE_COUNTER ) m_progr = sm_progr; ++sm_progr; ::wxLogTrace( cowTraceMask, _T("(%s) Init a new object progr=%d"), __PRETTY_FUNCTION__, m_progr ); #endif return data; } //! \overload wxJSONValue() wxJSONValue::wxJSONValue( wxJSONType type ) { m_refData = 0; Init( type ); } //! \overload wxJSONValue() wxJSONValue::wxJSONValue( int i ) { m_refData = 0; wxJSONRefData* data = Init( wxJSONTYPE_INT ); wxJSON_ASSERT( data ); if ( data != 0 ) { // the 'VAL_INT' macro expands to 'm_valLong' or 'm_valInt64' depending // on 64-bits integer support being enabled on not data->m_value.VAL_INT = i; } } //! \overload wxJSONValue() wxJSONValue::wxJSONValue( unsigned int ui ) { m_refData = 0; wxJSONRefData* data = Init( wxJSONTYPE_UINT ); wxJSON_ASSERT( data ); if ( data != 0 ) { // the 'VAL_UINT' macro expands to 'm_valULong' or 'm_valUInt64' depending // on 64-bits integer support being enabled on not data->m_value.VAL_UINT = ui; } } //! \overload wxJSONValue() wxJSONValue::wxJSONValue( short int i ) { m_refData = 0; wxJSONRefData* data = Init( wxJSONTYPE_INT ); wxJSON_ASSERT( data ); if ( data != 0 ) { // the 'VAL_INT' macro expands to 'm_valLong' or 'm_valInt64' depending // on 64-bits integer support being enabled on not data->m_value.VAL_INT = i; } } //! \overload wxJSONValue() wxJSONValue::wxJSONValue( unsigned short ui ) { m_refData = 0; wxJSONRefData* data = Init( wxJSONTYPE_UINT ); wxJSON_ASSERT( data ); if ( data != 0 ) { // the 'VAL_UINT' macro expands to 'm_valULong' or 'm_valUInt64' depending // on 64-bits integer support being enabled on not data->m_value.VAL_UINT = ui; } } //! \overload wxJSONValue() wxJSONValue::wxJSONValue( bool b ) { m_refData = 0; wxJSONRefData* data = Init( wxJSONTYPE_BOOL ); wxJSON_ASSERT( data ); if ( data != 0 ) { data->m_value.m_valBool = b; } } //! \overload wxJSONValue() wxJSONValue::wxJSONValue( double d ) { m_refData = 0; wxJSONRefData* data = Init( wxJSONTYPE_DOUBLE ); wxJSON_ASSERT( data ); if ( data != 0 ) { data->m_value.m_valDouble = d; } } //! \overload wxJSONValue() wxJSONValue::wxJSONValue( const wxChar* str ) { m_refData = 0; wxJSONRefData* data = Init( wxJSONTYPE_CSTRING ); wxJSON_ASSERT( data ); if ( data != 0 ) { #if !defined( WXJSON_USE_CSTRING ) data->m_type = wxJSONTYPE_STRING; data->m_valString.assign( str ); #else data->m_value.m_valCString = str; #endif } } //! \overload wxJSONValue() wxJSONValue::wxJSONValue( const wxString& str ) { m_refData = 0; wxJSONRefData* data = Init( wxJSONTYPE_STRING ); wxJSON_ASSERT( data ); if ( data != 0 ) { data->m_valString.assign( str ); } } //! \overload wxJSONValue() wxJSONValue::wxJSONValue( long int l ) { m_refData = 0; wxJSONRefData* data = Init( wxJSONTYPE_INT ); wxJSON_ASSERT( data ); if ( data != 0 ) { data->m_value.VAL_INT = l; } } //! \overload wxJSONValue() wxJSONValue::wxJSONValue( unsigned long int ul ) { m_refData = 0; wxJSONRefData* data = Init( wxJSONTYPE_UINT ); wxJSON_ASSERT( data ); if ( data != 0 ) { data->m_value.VAL_UINT = ul; } } //! Copy constructor /*! The function copies the content of \c other in this object. Note that the JSON value object is not really copied; the function calls Ref() in order to increment the reference count of the \c wxJSONRefData structure. */ wxJSONValue::wxJSONValue( const wxJSONValue& other ) { m_refData = 0; Ref( other ); // the progressive counter of the ctor is not copied from // the other wxJSONValue object: only data is shared, the // progressive counter is not shared because this object // is a copy of 'other' and it has its own progressive #if defined( WXJSON_USE_VALUE_COUNTER ) m_progr = sm_progr; ++sm_progr; ::wxLogTrace( cowTraceMask, _T("(%s) Copy ctor - progr=%d other progr=%d"), __PRETTY_FUNCTION__, m_progr, other.m_progr ); #endif } //! Dtor - calls UnRef(). wxJSONValue::~wxJSONValue() { UnRef(); } // functions for retreiving the value type: they are all 'const' //! Return the type of the value stored in the object. /*! This function is the only one that does not ASSERT that the \c m_refData data member is not NULL. In fact, if the JSON value object does not contain a pointer to a wxJSONRefData structure, the function returns the wxJSONTYPE_INVALID constant which represent an invalid JSON value object. Also note that the pointer to the referenced data structure should NEVER be NULL. \par Integer types Integers are stored internally in a \b (unsigned) \b long \b int or, on platforms that support 64-bits integers, in a \b wx(U)Int64 data type. When constructed, it is assigned a generic integer type that only depends on the sign: wxJSON_(U)INT regardless the size of the stored value. This function can be used to know the actual size requirement of the stored value and how it can be retrieved. The value returned by this function is: - for signed integers: - \b wxJSONTYPE_SHORT if the value is between SHORT_MIN and SHORT_MAX - \b wxJSONTYPE_LONG if the value is between LONG_MIN and LONG_MAX and greater than SHORT_MAX and less than SHORT_MIN - \b wxJSONTYPE_INT64 if the value is greater than LONG_MAX and less than LONG_MIN - for unsigned integers: - \b wxJSONTYPE_USHORT if the value is between 0 and USHORT_MAX - \b wxJSONTYPE_ULONG if the value is between 0 and ULONG_MAX and greater than USHORT_MAX - \b wxJSONTYPE_UINT64 if the value is greater than ULONG_MAX Note that this function never returns the wxJSONTYPE_(U)INT constant because the \b int data type may have the same width as SHORT or LONG depending on the platform. This does not mean that you cannot use \b int as the return value: if you use \b wxWidgets to develop application in only one platform, you can use \b int because you know the size of the data type. Otherwise, if is preferable to always use \b long instead of \b int. Also note that the class defines the \c IsInt() memberfunction which works fine regardless the actual width of the \b int data type. This function returns TRUE if the stored value fits in a \b int data type whatever its size is on the current platform (16 or 32-bits). \sa SetType IsInt */ wxJSONType wxJSONValue::GetType() const { wxJSONRefData* data = GetRefData(); wxJSONType type = wxJSONTYPE_INVALID; if ( data ) { type = data->m_type; // for integers and unsigned ints check the storage requirements // note that ints are stored as 'long' or as 'long long' switch ( type ) { case wxJSONTYPE_INT : // check if the integer fits in a SHORT INT if ( data->m_value.VAL_INT >= SHORT_MIN && data->m_value.VAL_INT <= SHORT_MAX ) { type = wxJSONTYPE_SHORT; } // check if the value fits in LONG INT else if ( data->m_value.VAL_INT >= LONG_MIN && data->m_value.VAL_INT <= LONG_MAX ) { type = wxJSONTYPE_LONG; } else { type = wxJSONTYPE_INT64; } break; case wxJSONTYPE_UINT : if ( data->m_value.VAL_UINT <= USHORT_MAX ) { type = wxJSONTYPE_USHORT; } else if ( data->m_value.VAL_UINT <= ULONG_MAX ) { type = wxJSONTYPE_ULONG; } else { type = wxJSONTYPE_UINT64; } break; default : break; } } return type; } //! Return TRUE if the type of the value is wxJSONTYPE_NULL. bool wxJSONValue::IsNull() const { wxJSONType type = GetType(); bool r = false; if ( type == wxJSONTYPE_NULL ) { r = true; } return r; } //! Return TRUE if the value stored is valid /*! The function returns TRUE if the wxJSONValue object was correctly initialized - that is it contains a valid value. A JSON object is valid if its type is not equal to wxJSONTYPE_INVALID. */ bool wxJSONValue::IsValid() const { wxJSONType type = GetType(); bool r = false; if ( type != wxJSONTYPE_INVALID ) { r = true; } return r; } //! Return TRUE if the type of the value stored is integer. /*! This function returns TRUE if the stored value is of type signed integer and the numeric value fits in a \b int data type. In other words, the function returns TRUE if the \c wxJSONRefData::m_type data member is of type \c wxJSONTYPE_INT and: \code INT_MIN <= m_value <= INT_MAX \endcode Note that if you are developing cross-platform applications you should never use \b int as the integer data type but \b long for 32-bits integers and \b short for 16-bits integers. This is because the \b int data type may have different width on different platforms. Regardless the widht of the data type (16 or 32 bits), the function returns the correct result because it relies on the INT_MAX and INT_MIN macros. \sa \ref json_internals_integer */ bool wxJSONValue::IsInt() const { wxJSONType type = GetType(); bool r = false; // if the type is SHORT the value fits into an INT, too if ( type == wxJSONTYPE_SHORT ) { r = true; } else if ( type == wxJSONTYPE_LONG ) { // in case of LONG, check if the bit width is the same if ( INT_MAX == LONG_MAX ) { r = true; } } return r; } //! Return TRUE if the type of the value stored is 16-bit integer. /*! This function returns TRUE if the stored value is of type signed integer and the numeric value fits in a \b short \b int data type (16-bit integer). In other words, the function returns TRUE if the \c wxJSONRefData::m_type data member is of type \c wxJSONTYPE_INT and: \code SHORT_MIN <= m_value <= SHORT_MAX \endcode \sa \ref json_internals_integer */ bool wxJSONValue::IsShort() const { wxJSONType type = GetType(); bool r = false; if ( type == wxJSONTYPE_SHORT ) { r = true; } return r; } //! Return TRUE if the type of the value stored is a unsigned int. /*! This function returns TRUE if the stored value is of type unsigned integer and the numeric value fits int a \b int data type. In other words, the function returns TRUE if the \c wxJSONRefData::m_type data member is of type \c wxJSONTYPE_UINT and: \code 0 <= m_value <= UINT_MAX \endcode Note that if you are developing cross-platform applications you should never use \b unsigned \b int as the integer data type but \b unsigned \b long for 32-bits integers and \b unsigned \b short for 16-bits integers. This is because the \b unsigned \b int data type may have different width on different platforms. Regardless the widht of the data type (16 or 32 bits), the function returns the correct result because it relies on the UINT_MAX macro. \sa \ref json_internals_integer */ bool wxJSONValue::IsUInt() const { wxJSONType type = GetType(); bool r = false; if ( type == wxJSONTYPE_USHORT ) { r = true; } else if ( type == wxJSONTYPE_ULONG ) { if ( INT_MAX == LONG_MAX ) { r = true; } } return r; } //! Return TRUE if the type of the value stored is a unsigned short. /*! This function returns TRUE if the stored value is of type unsigned integer and the numeric value fits in a \b unsigned \b short \b int data type. In other words, the function returns TRUE if the \c wxJSONRefData::m_type data member is of type \c wxJSONTYPE_UINT and: \code 0 <= m_value <= USHORT_MAX \endcode \sa \ref json_internals_integer */ bool wxJSONValue::IsUShort() const { wxJSONType type = GetType(); bool r = false; if ( type == wxJSONTYPE_USHORT ) { r = true; } return r; } //! Return TRUE if the stored value is an integer which fits in a long int /*! This function returns TRUE if the stored value is of type signed LONG integer and the numeric value fits int a \B long \b int data type. In other words, the function returns TRUE if the \c wxJSONRefData::m_type data member is of type \c wxJSONTYPE_INT and: \code LONG_MIN <= m_value <= LONG_MAX \endcode \sa \ref json_internals_integer */ bool wxJSONValue::IsLong() const { wxJSONType type = GetType(); bool r = false; if ( type == wxJSONTYPE_LONG || type == wxJSONTYPE_SHORT ) { r = true; } return r; } //! Return TRUE if the stored value is an integer which fits in a unsigned long int /*! This function returns TRUE if the stored value is of type unsigned LONG integer and the numeric value fits int a \b unsigned \B long \b int data type. In other words, the function returns TRUE if the \c wxJSONRefData::m_type data member is of type \c wxJSONTYPE_UINT and: \code 0 <= m_value <= ULONG_MAX \endcode \sa \ref json_internals_integer */ bool wxJSONValue::IsULong() const { wxJSONType type = GetType(); bool r = false; if ( type == wxJSONTYPE_ULONG || type == wxJSONTYPE_USHORT ) { r = true; } return r; } //! Return TRUE if the type of the value stored is a boolean. bool wxJSONValue::IsBool() const { wxJSONType type = GetType(); bool r = false; if ( type == wxJSONTYPE_BOOL ) { r = true; } return r; } //! Return TRUE if the type of the value stored is a double. bool wxJSONValue::IsDouble() const { wxJSONType type = GetType(); bool r = false; if ( type == wxJSONTYPE_DOUBLE ) { r = true; } return r; } //! Return TRUE if the type of the value stored is a wxString object. bool wxJSONValue::IsString() const { wxJSONType type = GetType(); bool r = false; if ( type == wxJSONTYPE_STRING ) { r = true; } return r; } //! Return TRUE if the type of the value stored is a pointer to a static C string. /*! This function returns TRUE if, and only if the stored value is a pointer to a static C-string and the C-string storage is enabled in the wxJSON library. By default, C-string storage is not enabled in the library so this function always returns FALSE. To know more about C-strings read \ref json_internals_cstring */ bool wxJSONValue::IsCString() const { wxJSONType type = GetType(); bool r = false; if ( type == wxJSONTYPE_CSTRING ) { r = true; } return r; } //! Return TRUE if the type of the value stored is an array type. bool wxJSONValue::IsArray() const { wxJSONType type = GetType(); bool r = false; if ( type == wxJSONTYPE_ARRAY ) { r = true; } return r; } //! Return TRUE if the type of this value is a key/value map. bool wxJSONValue::IsObject() const { wxJSONType type = GetType(); bool r = false; if ( type == wxJSONTYPE_OBJECT ) { r = true; } return r; } // get the stored value; all these functions are 'const' //! Return the stored value as an integer. /*! The function returns the stored value as an integer. Note that the function does not check that the type of the value is actually an integer and it just returns the content of the wxJSONValueHolder union. However, in debug builds, the function ASSERTs that the type of the stored value \c IsInt(). \sa \ref json_internals_integer \sa \ref wxjson_tutorial_get */ int wxJSONValue::AsInt() const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); int i = data->m_value.m_valInt; wxJSON_ASSERT( IsInt()); return i; } //! Return the stored value as a boolean. /*! The function returns the stored value as a boolean. Note that the function does not check that the type of the value is actually a boolean and it just returns the content of the wxJSONValueHolder union. However, in debug builds, the function ASSERTs that the type of the stored value is wxJSONTYPE_BOOL. \sa \ref wxjson_tutorial_get */ bool wxJSONValue::AsBool() const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); wxJSON_ASSERT( data->m_type == wxJSONTYPE_BOOL ); return data->m_value.m_valBool; } //! Return the stored value as a double. /*! The function returns the stored value as a double. Note that the function does not check that the type of the value is actually a double and it just returns the content of the wxJSONValueHolder union as if it was a double. However, in debug builds, the function ASSERTs that the type of the stored value \c IsDouble(). \sa \ref wxjson_tutorial_get */ double wxJSONValue::AsDouble() const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); double d = data->m_value.m_valDouble; wxJSON_ASSERT( IsDouble()); return d; } //! Return the stored value as a wxWidget's string. /*! The function returns a string representation of the value stored in the JSON object. All primitive values can be converted to a string. If the stored value is a boolean, the function returns the literal string \b true or \b false. If the value is a NULL value the \b null literal string is returned. If the value is of type wxJSONTYPE_INVALID, the literal string \b &lt;invalid&gt; is returned. Note that this is NOT a valid JSON text. If the value is an array or map, an empty string is returned. \sa \ref wxjson_tutorial_get */ wxString wxJSONValue::AsString() const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); wxString s; switch ( data->m_type ) { case wxJSONTYPE_STRING : s.assign( data->m_valString); break; case wxJSONTYPE_CSTRING : s.assign( data->m_value.m_valCString); break; case wxJSONTYPE_INT : #if defined( wxJSON_64BIT_INT ) s.Printf( _T("%") wxLongLongFmtSpec _T("i"), data->m_value.m_valInt64 ); #else s.Printf( _T("%ld"), data->m_value.m_valLong ); #endif break; case wxJSONTYPE_UINT : #if defined( wxJSON_64BIT_INT ) s.Printf( _T("%") wxLongLongFmtSpec _T("u"), data->m_value.m_valUInt64 ); #else s.Printf( _T("%lu"), data->m_value.m_valULong ); #endif break; case wxJSONTYPE_DOUBLE : s.Printf( _T("%f"), data->m_value.m_valDouble ); break; case wxJSONTYPE_BOOL : s.assign( ( data->m_value.m_valBool ? _T("true") : _T("false") )); break; case wxJSONTYPE_NULL : s.assign( _T( "null")); break; case wxJSONTYPE_INVALID : s.assign( _T( "<empty>")); break; case wxJSONTYPE_ARRAY : case wxJSONTYPE_OBJECT : break; default : s.assign( _T( "wxJSONValue::AsString(): Unknown JSON type \'")); s.append( TypeToString( data->m_type )); s.append( _T( "\'" )); wxFAIL_MSG( s ); break; } return s; } //! Return the stored value as a pointer to a static C string. /*! If the type of the value is stored as a C-string data type the function just returns that pointer. If the stored value is a wxString object, the function returns the pointer returned by the \b wxString::c_str() function. If the stored value is of all other JSON types, the functions returns a NULL pointer. This changed in version 0.5 and later. In previous versions, the functions returned a NULL pointer also if the value is a wxString object (thanks to Robbie Groenewoudt). \sa \ref json_internals_cstring \sa \ref wxjson_tutorial_get */ const wxChar* wxJSONValue::AsCString() const { const wxChar* s = 0; wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); switch ( data->m_type ) { case wxJSONTYPE_CSTRING : s = data->m_value.m_valCString; break; case wxJSONTYPE_STRING : s = data->m_valString.c_str(); break; default : break; } return s; } //! Return the stored value as a unsigned int. /*! The function returns the stored value as a unsigned integer. Note that the function does not check that the type of the value is actually a unsigned integer and it just returns the content of the wxJSONValueHolder union. However, in debug builds, the function ASSERTs that the type of the stored value is wxJSONTYPE_UINT. \sa \ref json_internals_integer \sa \ref wxjson_tutorial_get */ unsigned int wxJSONValue::AsUInt() const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); unsigned int ui = data->m_value.m_valUInt; wxJSON_ASSERT( IsUInt()); return ui; } //! Returns the value as a long integer /*! The function returns the stored value as a long integer. Note that the function does not check that the type of the value is actually a long integer and it just returns the content of the wxJSONValueHolder union. However, in debug builds, the function ASSERTs that the type of the stored value \c IsLong(). \sa \ref json_internals_integer \sa \ref wxjson_tutorial_get */ long int wxJSONValue::AsLong() const { long int l; wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); l = data->m_value.m_valLong; wxJSON_ASSERT( IsLong()); return l; } //! Returns the value as a unsigned long integer /*! The function returns the stored value as a unsigned long integer. Note that the function does not check that the type of the value is actually a unsigned long integer and it just returns the content of the wxJSONValueHolder union. However, in debug builds, the function ASSERTs that the type of the stored value \c IsLong(). \sa \ref json_internals_integer \sa \ref wxjson_tutorial_get */ unsigned long int wxJSONValue::AsULong() const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); unsigned long int ul = data->m_value.m_valULong; wxJSON_ASSERT( IsULong()); // exapnds only in debug builds return ul; } //! Returns the value as a short integer /*! The function returns the stored value as a short integer. Note that the function does not check that the type of the value is actually a short integer and it just returns the content of the wxJSONValueHolder union. However, in debug builds, the function ASSERTs that the type of the stored value \c IsShort(). \sa \ref json_internals_integer \sa \ref wxjson_tutorial_get */ short int wxJSONValue::AsShort() const { short int i; wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); i = data->m_value.m_valShort; wxJSON_ASSERT( IsShort()); return i; } //! Returns the value as a unsigned short integer /*! The function returns the stored value as a unsigned short integer. Note that the function does not check that the type of the value is actually a unsigned short and it just returns the content of the wxJSONValueHolder union. However, in debug builds, the function ASSERTs that the type of the stored value \c IsUShort(). \sa \ref json_internals_integer \sa \ref wxjson_tutorial_get */ unsigned short wxJSONValue::AsUShort() const { unsigned short ui; wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); ui = data->m_value.m_valUShort; wxJSON_ASSERT( IsUShort()); return ui; } // internal use //! Return the stored value as a map object. /*! This function is for testing and debugging purposes and you shold never use it. To retreive values from an array or map JSON object use the \c Item() or ItemAt() memberfunctions or the subscript operator. If the stored value is not a map type, returns a NULL pointer. */ const wxJSONInternalMap* wxJSONValue::AsMap() const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); const wxJSONInternalMap* v = 0; if ( data->m_type == wxJSONTYPE_OBJECT ) { v = &( data->m_valMap ); } return v; } //! Return the stored value as an array object. /*! This function is for testing and debugging purposes and you shold never use it. To retreive values from an array or map JSON object use the \c Item() or ItemAt() memberfunctions or the subscript operator. If the stored value is not an array type, returns a NULL pointer. */ const wxJSONInternalArray* wxJSONValue::AsArray() const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); const wxJSONInternalArray* v = 0; if ( data->m_type == wxJSONTYPE_ARRAY ) { v = &( data->m_valArray ); } return v; } // retrieve the members and other info //! Return TRUE if the object contains an element at the specified index. /*! If the stoerd value is not an array or a map, the function returns FALSE. */ bool wxJSONValue::HasMember( unsigned index ) const { bool r = false; int size = Size(); if ( index < (unsigned) size ) { r = true; } return r; } //! Return TRUE if the object contains an element at the specified key. /*! If the stored value is not a key/map map, the function returns FALSE. */ bool wxJSONValue::HasMember( const wxString& key ) const { bool r = false; wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); if ( data && data->m_type == wxJSONTYPE_OBJECT ) { wxJSONInternalMap::iterator it = data->m_valMap.find( key ); if ( it != data->m_valMap.end() ) { r = true; } } return r; } //! Return the size of the array or map stored in this value. /*! Note that both the array and the key/value map may have a size of ZERO elements. If the stored value is not an array nor a key/value hashmap, the function returns -1. */ int wxJSONValue::Size() const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); int size = -1; if ( data->m_type == wxJSONTYPE_ARRAY ) { size = (int) data->m_valArray.GetCount(); } if ( data->m_type == wxJSONTYPE_OBJECT ) { size = (int) data->m_valMap.size(); } return size; } //! Return the array of keys of this JSON object. /*! If the stored value is a key/value map, the function returns an array of strings containing the \e key of all elements. Note that the returned array may be empty if the map has ZERO elements. An empty string array is also returned if the stored value is not a key/value map. Also note that in debug builds, the function wxJSON_ASSERTs that the type of the stored object is wxJSONTYPE_OBJECT. */ wxArrayString wxJSONValue::GetMemberNames() const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); wxJSON_ASSERT( data->m_type == wxJSONTYPE_OBJECT ); wxArrayString arr; if ( data->m_type == wxJSONTYPE_OBJECT ) { wxJSONInternalMap::iterator it; for ( it = data->m_valMap.begin(); it != data->m_valMap.end(); it++ ) { arr.Add( it->first ); } } return arr; } // appending items, resizing and deleting items // NOTE: these functions are not 'const' so we have to call // the COW() function before accessing data //! Append the specified value in the array. /*! The function appends the value specified in the parameter to the array contained in this object. If this object does not contain an array type, the actual content is deleted, a new array type is created and the JSON value \c value is appended to the newly created array. Returns a reference to the appended object. */ wxJSONValue& wxJSONValue::Append( const wxJSONValue& value ) { wxJSONRefData* data = COW(); wxJSON_ASSERT( data ); if ( data->m_type != wxJSONTYPE_ARRAY ) { // we have to change the type of the actual object to the array type SetType( wxJSONTYPE_ARRAY ); } // we add the wxJSONValue object to the wxObjArray: note that the // array makes a copy of the JSON-value object by calling its // copy ctor thus using reference count data->m_valArray.Add( value ); wxJSONValue& v = data->m_valArray.Last(); return v; } //! \overload Append( const wxJSONValue& ) wxJSONValue& wxJSONValue::Append( int i ) { wxJSONValue v( i ); wxJSONValue& r = Append( v ); return r; } //! \overload Append( const wxJSONValue& ) wxJSONValue& wxJSONValue::Append( short int i ) { wxJSONValue v( i ); wxJSONValue& r = Append( v ); return r; } //! \overload Append( const wxJSONValue& ) wxJSONValue& wxJSONValue::Append( long int l ) { wxJSONValue v( l ); wxJSONValue& r = Append( v ); return r; } //! \overload Append( const wxJSONValue& ) wxJSONValue& wxJSONValue::Append( bool b ) { wxJSONValue v( b ); wxJSONValue& r = Append( v ); return r; } //! \overload Append( const wxJSONValue& ) wxJSONValue& wxJSONValue::Append( unsigned int ui ) { wxJSONValue v( ui ); wxJSONValue& r = Append( v ); return r; } //! \overload Append( const wxJSONValue& ) wxJSONValue& wxJSONValue::Append( unsigned short ui ) { wxJSONValue v( ui ); wxJSONValue& r = Append( v ); return r; } //! \overload Append( const wxJSONValue& ) wxJSONValue& wxJSONValue::Append( unsigned long ul ) { wxJSONValue v( ul ); wxJSONValue& r = Append( v ); return r; } //! \overload Append( const wxJSONValue& ) wxJSONValue& wxJSONValue::Append( double d ) { wxJSONValue v( d ); wxJSONValue& r = Append( v ); return r; } //! \overload Append( const wxJSONValue& ) wxJSONValue& wxJSONValue::Append( const wxChar* str ) { wxJSONValue v( str ); wxJSONValue& r = Append( v ); return r; } //! \overload Append( const wxJSONValue& ) wxJSONValue& wxJSONValue::Append( const wxString& str ) { wxJSONValue v( str ); wxJSONValue& r = Append( v ); return r; } //! Concatenate a string to this string object. /*! The function concatenates \c str to the string contained in this object and returns TRUE if the operation is succefull. If the value stored in this value is not a string object the function does nothing and returns FALSE. Note that in order to be successfull, the value must contain a \b wxString object and not a pointer to C-string. */ bool wxJSONValue::Cat( const wxString& str ) { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); bool r = false; if ( data->m_type == wxJSONTYPE_STRING ) { wxJSONRefData* data = COW(); wxJSON_ASSERT( data ); data->m_valString.append( str ); r = true; } return r; } //! \overload Cat( const wxString& ) bool wxJSONValue::Cat( const wxChar* str ) { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); bool r = false; if ( data->m_type == wxJSONTYPE_STRING ) { wxJSONRefData* data = COW(); wxJSON_ASSERT( data ); data->m_valString.append( str ); r = true; } return r; } //! Remove the item at the specified index or key. /*! The function removes the item at index \c index or at the specified key in the array or map. If this object does not contain an array (for a index parameter) or a map (for a key parameter), the function does nothing and returns FALSE. If the element does not exist, FALSE is returned. */ bool wxJSONValue::Remove( int index ) { wxJSONRefData* data = COW(); wxJSON_ASSERT( data ); bool r = false; if ( data->m_type == wxJSONTYPE_ARRAY ) { data->m_valArray.RemoveAt( index ); r = true; } return r; } //! \overload Remove( int ) bool wxJSONValue::Remove( const wxString& key ) { wxJSONRefData* data = COW(); wxJSON_ASSERT( data ); bool r = false; if ( data->m_type == wxJSONTYPE_OBJECT ) { wxJSONInternalMap::size_type count = data->m_valMap.erase( key ); if ( count > 0 ) { r = true; } } return r; } //! Clear the object value. /*! This function causes the object to be empty. The function simply calls UnRef() making this object to become invalid and set its type to wxJSONTYPE_INVALID. */ void wxJSONValue::Clear() { UnRef(); SetType( wxJSONTYPE_INVALID ); } // retrieve an item //! Return the item at the specified index. /*! The function returns a reference to the object at the specified index. If the element does not exist, the array is enlarged to \c index + 1 elements and a reference to the last element will be returned. New elements will contain NULL values. If this object does not contain an array, the old value is replaced by an array object which will be enlarged to the needed dimension. */ wxJSONValue& wxJSONValue::Item( unsigned index ) { wxJSONRefData* data = COW(); wxJSON_ASSERT( data ); if ( data->m_type != wxJSONTYPE_ARRAY ) { data = SetType( wxJSONTYPE_ARRAY ); } int size = Size(); wxJSON_ASSERT( size >= 0 ); // if the desired element does not yet exist, we create as many // elements as needed; the new values will be 'null' values if ( index >= (unsigned) size ) { wxJSONValue v( wxJSONTYPE_NULL); int missing = index - size + 1; data->m_valArray.Add( v, missing ); } return data->m_valArray.Item( index ); } //! Return the item at the specified key. /*! The function returns a reference to the object in the map that has the specified key. If \c key does not exist, a new NULL value is created with the provided key and a reference to it is returned. If this object does not contain a map, the old value is replaced by a map object. */ wxJSONValue& wxJSONValue::Item( const wxString& key ) { ::wxLogTrace( traceMask, _T("(%s) searched key=\'%s\'"), __PRETTY_FUNCTION__, key.c_str()); ::wxLogTrace( traceMask, _T("(%s) actual object: %s"), __PRETTY_FUNCTION__, GetInfo().c_str()); wxJSONRefData* data = COW(); wxJSON_ASSERT( data ); if ( data->m_type != wxJSONTYPE_OBJECT ) { // deletes the contained value; data = SetType( wxJSONTYPE_OBJECT ); return data->m_valMap[key]; } ::wxLogTrace( traceMask, _T("(%s) searching key \'%s' in the actual object"), __PRETTY_FUNCTION__, key.c_str() ); return data->m_valMap[key]; } //! Return the item at the specified index. /*! The function returns a copy of the object at the specified index. If the element does not exist, the function returns an 'empty' value. */ wxJSONValue wxJSONValue::ItemAt( unsigned index ) const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); wxJSONValue v( wxJSONTYPE_INVALID ); if ( data->m_type == wxJSONTYPE_ARRAY ) { int size = Size(); wxJSON_ASSERT( size >= 0 ); if ( index < (unsigned) size ) { v = data->m_valArray.Item( index ); } } return v; } //! Return the item at the specified key. /*! The function returns a copy of the object in the map that has the specified key. If \c key does not exist, an 'empty' value is returned. */ wxJSONValue wxJSONValue::ItemAt( const wxString& key ) const { ::wxLogTrace( traceMask, _T("(%s) searched key=\'%s\'"), __PRETTY_FUNCTION__, key.c_str()); ::wxLogTrace( traceMask, _T("(%s) actual object: %s"), __PRETTY_FUNCTION__, GetInfo().c_str()); wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); wxJSONValue v( wxJSONTYPE_INVALID ); if ( data->m_type == wxJSONTYPE_OBJECT ) { wxJSONInternalMap::const_iterator it = data->m_valMap.find( key ); if ( it != data->m_valMap.end() ) { v = it->second; } } return v; } //! Return the item at the specified index. /*! The function returns a reference to the object at the specified index. If the element does not exist, the array is enlarged to \c index + 1 elements and a reference to the last element will be returned. New elements will contain NULL values. If this object does not contain an array, the old value is replaced by an array object. */ wxJSONValue& wxJSONValue::operator [] ( unsigned index ) { wxJSONValue& v = Item( index ); return v; } //! Return the item at the specified key. /*! The function returns a reference to the object in the map that has the specified key. If \c key does not exist, a new NULL value is created with the provided key and a reference to it is returned. If this object does not contain a map, the old value is replaced by a map object. */ wxJSONValue& wxJSONValue::operator [] ( const wxString& key ) { wxJSONValue& v = Item( key ); return v; } // // assignment operators // note that reference counting is only used if the original // value is a wxJSONValue object // in all other cases, the operator= function deletes the old // content and assigns the new one //! Assign the specified value to this object replacing the old value. /*! The assignment operator assigns to this object the value specified in the right operand of the assignment operator. Note that the old value is deleted but not the other data members in the wxJSONRefData structure. This is particularly usefull for the parser class which stores comment lines in a temporary wxJSONvalue object that is of type wxJSONTYPE_INVALID. As comment lines may apear before the value they refer to, comments are stored in a value that is not yet being read. when the value is read, it is assigned to the temporary JSON value object without deleting the comment lines. */ wxJSONValue& wxJSONValue::operator = ( int i ) { wxJSONRefData* data = SetType( wxJSONTYPE_INT ); data->m_value.VAL_INT = i; return *this; } //! \overload operator = (int) wxJSONValue& wxJSONValue::operator = ( bool b ) { wxJSONRefData* data = SetType( wxJSONTYPE_BOOL ); data->m_value.m_valBool = b; return *this; } //! \overload operator = (int) wxJSONValue& wxJSONValue::operator = ( unsigned int ui ) { wxJSONRefData* data = SetType( wxJSONTYPE_UINT ); data->m_value.VAL_UINT = ui; return *this; } //! \overload operator = (int) wxJSONValue& wxJSONValue::operator = ( long l ) { wxJSONRefData* data = SetType( wxJSONTYPE_INT ); data->m_value.VAL_INT = l; return *this; } //! \overload operator = (int) wxJSONValue& wxJSONValue::operator = ( unsigned long ul ) { wxJSONRefData* data = SetType( wxJSONTYPE_UINT ); data->m_value.VAL_UINT = ul; return *this; } //! \overload operator = (int) wxJSONValue& wxJSONValue::operator = ( short i ) { wxJSONRefData* data = SetType( wxJSONTYPE_INT ); data->m_value.VAL_INT = i; return *this; } //! \overload operator = (int) wxJSONValue& wxJSONValue::operator = ( unsigned short ui ) { wxJSONRefData* data = SetType( wxJSONTYPE_UINT ); data->m_value.VAL_UINT = ui; return *this; } //! \overload operator = (int) wxJSONValue& wxJSONValue::operator = ( double d ) { wxJSONRefData* data = SetType( wxJSONTYPE_DOUBLE ); data->m_value.m_valDouble = d; return *this; } //! \overload operator = (int) wxJSONValue& wxJSONValue::operator = ( const wxChar* str ) { wxJSONRefData* data = SetType( wxJSONTYPE_CSTRING ); data->m_value.m_valCString = str; #if !defined( WXJSON_USE_CSTRING ) data->m_type = wxJSONTYPE_STRING; data->m_valString.assign( str ); #endif return *this; } //! \overload operator = (int) wxJSONValue& wxJSONValue::operator = ( const wxString& str ) { wxJSONRefData* data = SetType( wxJSONTYPE_STRING ); data->m_valString.assign( str ); return *this; } //! Assignment operator using reference counting. /*! Unlike all other assignment operators, this one makes a swallow copy of the other JSON value object. The function calls \c Ref() to get a shared referenced data. \sa \ref json_internals_cow */ wxJSONValue& wxJSONValue::operator = ( const wxJSONValue& other ) { Ref( other ); return *this; } // finding elements //! Return a value or a default value. /*! This function returns a copy of the value object for the specified key. If the key is not found, a copy of \c defaultValue is returned. Note that the returned values are not real copy of the \c key or the default values because \e copy-on-write is used by this class. However, you have to treat them as real copies; in other words, if you change the values of the returned object your changes does not reflect in the otiginal value. Example: \code wxJSONValue defaultValue( 0 ); wxJSONvalue v1; v1["key"] = 100; // 'v1["key"]' contains the integer 100 // 'v2' contains 100 but it is a swallow copy of 'v1["key"]' wxJSONValue v2 = v1.Get( "key", defaultValue ); // 'v1["key"]' still contains 100 v2 = 200; // if you want your change to be reflected in the 'v1' object // you have to assign it v1["key"] = v2; \endcode */ wxJSONValue wxJSONValue::Get( const wxString& key, const wxJSONValue& defaultValue ) const { // NOTE: this function does many wxJSONValue copies. // so implementing COW is a good thing // this is the first copy (the default value) wxJSONValue v( defaultValue ); wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); if ( data->m_type == wxJSONTYPE_OBJECT ) { wxJSONInternalMap::iterator it = data->m_valMap.find( key ); if ( it != data->m_valMap.end() ) { v = it->second; } } return v; } // protected functions //! Find an element /*! The function returns a pointer to the element at index \c index or a NULL pointer if \c index does not exist. A NULL pointer is also returned if the object does not contain an array nor a key/value map. */ wxJSONValue* wxJSONValue::Find( unsigned index ) const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); wxJSONValue* vp = 0; if ( data->m_type == wxJSONTYPE_ARRAY ) { size_t size = data->m_valArray.GetCount(); if ( index < size ) { vp = &(data->m_valArray.Item( index )); } } return vp; } //! Find an element /*! The function returns a pointer to the element with key \c key or a NULL pointer if \c key does not exist. A NULL pointer is also returned if the object does not contain a key/value map. */ wxJSONValue* wxJSONValue::Find( const wxString& key ) const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); wxJSONValue* vp = 0; if ( data->m_type == wxJSONTYPE_OBJECT ) { wxJSONInternalMap::iterator it = data->m_valMap.find( key ); if ( it != data->m_valMap.end() ) { vp = &(it->second); } } return vp; } //! Return a string description of the type /*! This static function is only usefull for debugging purposes and should not be used by users of this class. It simply returns a string representation of the JSON value type stored in a object. For example, if \c type is wxJSONTYPE_INT the function returns the string "wxJSONTYPE_INT". If \c type is out of range, an empty string is returned (should never happen). */ wxString wxJSONValue::TypeToString( wxJSONType type ) { static const wxChar* str[] = { _T( "wxJSONTYPE_INVALID" ), // 0 _T( "wxJSONTYPE_NULL" ), // 1 _T( "wxJSONTYPE_INT" ), // 2 _T( "wxJSONTYPE_UINT" ), // 3 _T( "wxJSONTYPE_DOUBLE" ), // 4 _T( "wxJSONTYPE_STRING" ), // 5 _T( "wxJSONTYPE_CSTRING" ), // 6 _T( "wxJSONTYPE_BOOL" ), // 7 _T( "wxJSONTYPE_ARRAY" ), // 8 _T( "wxJSONTYPE_OBJECT" ), // 9 _T( "wxJSONTYPE_LONG" ), // 10 _T( "wxJSONTYPE_INT64" ), // 11 _T( "wxJSONTYPE_ULONG" ), // 12 _T( "wxJSONTYPE_UINT64" ), // 13 _T( "wxJSONTYPE_SHORT" ), // 14 _T( "wxJSONTYPE_USHORT" ), // 15 }; wxString s; int idx = (int) type; if ( idx >= 0 && idx < 16 ) { s = str[idx]; } return s; } //! Returns informations about the object /*! The function is only usefull for debugging purposes and will probably be dropped in future versions. Returns a string that contains info about the object such as: \li the type of the object \li the size \li the progressive counter \li the pointer to referenced data \li the progressive counter of referenced data \li the number of share of referenced data The \c deep parameter is used to specify if the function will be called recursively in order to dump sub-items. If the parameter is TRUE than a deep dump is executed. The \c indent is the initial indentation: it is incremented by 3 every time the Dump() function is called recursively. */ wxString wxJSONValue::Dump( bool deep, int indent ) const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); wxJSONType type = GetType(); wxString s; if ( indent > 0 ) { s.append( indent, ' ' ); } wxString s1; wxString s2; #if defined( WXJSON_USE_VALUE_COUNTER ) s1.Printf( _T("Object: Progr=%d Type=%s Size=%d comments=%d\n"), m_progr, TypeToString( type ).c_str(), Size(), data->m_comments.GetCount() ); s2.Printf(_T(" : RefData=%p Progr=%d Num shares=%d\n"), data, data->m_progr, data->GetRefCount() ); #else s1.Printf( _T("Object: Type=%s Size=%d comments=%d\n"), TypeToString( type ).c_str(), Size(), data->m_comments.GetCount() ); s2.Printf(_T(" : RefData=%p Num shares=%d\n"), data, data->GetRefCount() ); #endif s.append( s1 ); if ( indent > 0 ) { s.append( indent, ' ' ); } s.append( s2 ); wxString sub; // if we have to do a deep dump, we call the Dump() function for // every sub-item if ( deep ) { indent += 3; const wxJSONInternalMap* map; int size;; wxJSONInternalMap::const_iterator it; switch ( type ) { case wxJSONTYPE_OBJECT : map = AsMap(); size = Size(); for ( it = map->begin(); it != map->end(); ++it ) { const wxJSONValue& v = it->second; sub = v.Dump( true, indent ); s.append( sub ); } break; case wxJSONTYPE_ARRAY : size = Size(); for ( int i = 0; i < size; i++ ) { const wxJSONValue* v = Find( i ); wxJSON_ASSERT( v ); sub = v->Dump( true, indent ); s.append( sub ); } break; default : break; } } return s; } //! Returns informations about the object /*! The function is only usefull for debugging purposes and will probably be dropped in future versions. You should not rely on this function to exist in future versions. */ wxString wxJSONValue::GetInfo() const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); wxString s; #if defined( WXJSON_USE_VALUE_CONTER ) s.Printf( _T("Object: Progr=%d Type=%s Size=%d comments=%d\n"), data->m_progr, wxJSONValue::TypeToString( data->m_type ).c_str(), Size(), data->m_comments.GetCount() ); #else s.Printf( _T("Object: Type=%s Size=%d comments=%d\n"), wxJSONValue::TypeToString( data->m_type ).c_str(), Size(), data->m_comments.GetCount() ); #endif if ( data->m_type == wxJSONTYPE_OBJECT ) { wxArrayString arr = GetMemberNames(); for ( unsigned int i = 0; i < arr.size(); i++ ) { s.append( _T(" Member name: ")); s.append( arr[i] ); s.append( _T("\n") ); } } return s; } //! The comparison function /*! This function returns TRUE if this object looks like \c other. Note that this class does not define a comparison operator (the classical \b operator== function) because the notion of \b equal for JSON values objects is not applicable. The comment strings array are not compared: JSON value objects are \b the \b same if they contains the same values, regardless the comment's strings. Note that the function does not return the element that cause the comparison to return FALSE. There is not a good structure to tell this information. If you need it for debugging purposes, you have to turn on the \b sameas tracing feature by setting the WXTRACE environment variable (you need a debug version of the application): \code export WXTRACE=sameas // for unix systems that use bash \endcode Note that if the two JSON value objects share the same referenced data, the function immediatly returns TRUE without doing a deep comparison which is, sure, useless. For further info see \ref json_internals_compare. \bug comparing very large 64-bits integers that differ by a small value may cause the function to return TRUE intead of FALSE */ bool wxJSONValue::IsSameAs( const wxJSONValue& other ) const { // this is a recursive function: it calls itself // for every 'value' object in an array or map bool r = true; // some variables used in the switch statement int size; wxJSONInternalMap::const_iterator it; int* usedElements; // get the referenced data for the two objects wxJSONRefData* data = GetRefData(); wxJSONRefData* otherData = other.GetRefData(); if ( data == otherData ) { ::wxLogTrace( compareTraceMask, _T("(%s) objects share the same referenced data - r=TRUE"), __PRETTY_FUNCTION__ ); return true; } // if the type does not match the function compares the values if // they are of compatible types such as INT, UINT and DOUBLE if ( data->m_type != otherData->m_type ) { // if the types are not compatible, returns false double val, otherVal; switch ( data->m_type ) { case wxJSONTYPE_INT : val = data->m_value.VAL_INT; break; case wxJSONTYPE_UINT : val = data->m_value.VAL_UINT; break; case wxJSONTYPE_DOUBLE : val = data->m_value.m_valDouble; break; default: return false; break; } switch ( otherData->m_type ) { case wxJSONTYPE_INT : otherVal = otherData->m_value.VAL_INT; break; case wxJSONTYPE_UINT : otherVal = otherData->m_value.VAL_UINT; break; case wxJSONTYPE_DOUBLE : otherVal = otherData->m_value.m_valDouble; break; default: return false; break; } bool r = false; if ( val == otherVal ) { r = true; } return r; } // the two objects have the same 'm_type' // for comparing wxJSONTYPE_CSTRING we use two temporary wxString // objects: this is to avoid using strcmp() and wcscmp() which // may not be available on all platforms wxString s1, s2; switch ( data->m_type ) { case wxJSONTYPE_INVALID : case wxJSONTYPE_NULL : // there is no need to compare the values break; case wxJSONTYPE_INT : if ( data->m_value.VAL_INT != otherData->m_value.VAL_INT ) { r = false; } break; case wxJSONTYPE_UINT : if ( data->m_value.VAL_UINT != otherData->m_value.VAL_UINT ) { r = false; } break; case wxJSONTYPE_DOUBLE : if ( data->m_value.m_valDouble != otherData->m_value.m_valDouble ) { r = false; } break; case wxJSONTYPE_CSTRING : s1 = wxString( data->m_value.m_valCString ); s2 = wxString( otherData->m_value.m_valCString ); // i = strcmp( m_value.m_valCString, other.m_value.m_valCString ); // i = wcscmp( m_value.m_valCString, other.m_value.m_valCString ); if ( s1 != s2 ) { r = false; } break; case wxJSONTYPE_BOOL : if ( data->m_value.m_valBool != otherData->m_value.m_valBool ) { r = false; } break; case wxJSONTYPE_STRING : if ( data->m_valString != otherData->m_valString ) { r = false; } break; case wxJSONTYPE_ARRAY : size = Size(); ::wxLogTrace( compareTraceMask, _T("(%s) Comparing an array object - size=%d"), __PRETTY_FUNCTION__, size ); if ( size != other.Size() ) { ::wxLogTrace( compareTraceMask, _T("(%s) Sizes does not match"), __PRETTY_FUNCTION__ ); return false; } // for every element in this object iterates through all // items in the 'other' object searching for a matching // value. if not found, returns FALSE. // note that when an element is found in other it must be marked as // 'already used' (see 'test/testjson4.cpp') usedElements = new int[size]; for ( int y = 0; y < size; y++ ) { usedElements[y] = 0; } for ( int i = 0; i < size; i++ ) { ::wxLogTrace( compareTraceMask, _T("(%s) Comparing array element=%d"), __PRETTY_FUNCTION__, i ); r = false; for ( int y = 0; y < size; y++ ) { if ( ItemAt( i ).IsSameAs( other.ItemAt( y )) && usedElements[y] == 0 ) { r = true; usedElements[y] = 1; break; } } if ( r == false ) { delete [] usedElements; ::wxLogTrace( compareTraceMask, _T("(%s) Comparison failed"), __PRETTY_FUNCTION__ ); return false; } } delete [] usedElements; break; case wxJSONTYPE_OBJECT : size = Size(); ::wxLogTrace( compareTraceMask, _T("(%s) Comparing a map obejct - size=%d"), __PRETTY_FUNCTION__, size ); if ( size != other.Size() ) { ::wxLogTrace( compareTraceMask, _T("(%s) Comparison failed - sizes does not match"), __PRETTY_FUNCTION__ ); return false; } // for every key, calls itself on the value found in // the other object. if 'key' does no exist, returns FALSE // wxJSONInternalMap::const_iterator it; for ( it = data->m_valMap.begin(); it != data->m_valMap.end(); it++ ) { wxString key = it->first; ::wxLogTrace( compareTraceMask, _T("(%s) Comparing map object - key=%s"), __PRETTY_FUNCTION__, key.c_str() ); wxJSONValue otherVal = other.ItemAt( key ); bool isSame = it->second.IsSameAs( otherVal ); if ( !isSame ) { ::wxLogTrace( compareTraceMask, _T("(%s) Comparison failed for the last object"), __PRETTY_FUNCTION__ ); return false; } } break; default : // should never happen wxFAIL_MSG( _T("wxJSONValue::IsSameAs() unexpected wxJSONType")); // wxJSON_ASSERT( 0 ); break; } return r; } //! Add a comment to this JSON value object. /*! The function adds a comment string to this JSON value object and returns the total number of comment strings belonging to this value. Note that the comment string must be a valid C/C++ comment because the wxJSONWriter does not modify it. In other words, a C++ comment string must start with '//' and must end with a new-line character. If the final LF char is missing, the automatically adds it. You can also add C-style comments which must be enclosed in the usual C-comment characters. For C-style comments, the function does not try to append the final comment characters but allows trailing whitespaces and new-line chars. The \c position parameter is one of: \li wxJSONVALUE_COMMENT_BEFORE: the comment will be written before the value \li wxJSONVALUE_COMMENT_INLINE: the comment will be written on the same line \li wxJSONVALUE_COMMENT_AFTER: the comment will be written after the value \li wxJSONVALUE_COMMENT_DEFAULT: the old value of comment's position is not changed; if no comments were added to the value object this is the same as wxJSONVALUE_COMMENT_BEFORE. To know more about comment's storage see \ref json_comment_add */ int wxJSONValue::AddComment( const wxString& str, int position ) { wxJSONRefData* data = COW(); wxJSON_ASSERT( data ); ::wxLogTrace( traceMask, _T("(%s) comment=%s"), __PRETTY_FUNCTION__, str.c_str() ); int r = -1; int len = str.length(); if ( len < 2 ) { ::wxLogTrace( traceMask, _T(" error: len < 2") ); return -1; } if ( str[0] != '/' ) { ::wxLogTrace( traceMask, _T(" error: does not start with\'/\'") ); return -1; } if ( str[1] == '/' ) { // a C++ comment: check that it ends with '\n' ::wxLogTrace( traceMask, _T(" C++ comment" )); if ( str.GetChar(len - 1) != '\n' ) { wxString temp( str ); temp.append( 1, '\n' ); data->m_comments.Add( temp ); ::wxLogTrace( traceMask, _T(" C++ comment: LF added") ); } else { data->m_comments.Add( str ); } r = data->m_comments.size(); } else if ( str[1] == '*' ) { // a C-style comment: check that it ends with '*/' ::wxLogTrace( traceMask, _T(" C-style comment") ); int lastPos = len - 1; wxChar ch = str.GetChar( lastPos ); // skip leading whitespaces while ( ch == ' ' || ch == '\n' || ch == '\t' ) { --lastPos; ch = str.GetChar( lastPos ); } if ( str.GetChar( lastPos ) == '/' && str.GetChar( lastPos - 1 ) == '*' ) { data->m_comments.Add( str ); r = data->m_comments.size(); } } else { ::wxLogTrace( traceMask, _T(" error: is not a valid comment string") ); r = -1; } // if the comment was stored, store the position if ( r >= 0 && position != wxJSONVALUE_COMMENT_DEFAULT ) { data->m_commentPos = position; } return r; } //! Add one or more comments to this JSON value object. /*! The function adds the strings contained in \c comments to the comment's string array of this value object by calling the AddComment( const wxString&,int) function for every string in the \c comment array. Returns the number of strings correctly added. */ int wxJSONValue::AddComment( const wxArrayString& comments, int position ) { int siz = comments.GetCount(); int r = 0; for ( int i = 0; i < siz; i++ ) { int r2 = AddComment( comments[i], position ); if ( r2 >= 0 ) { ++r; } } return r; } //! Return a comment string. /*! The function returns the comment string at index \c idx. If \c idx is out of range, an empty string is returned. If \c idx is equal to -1, then the function returns a string that contains all comment's strings stored in the array. */ wxString wxJSONValue::GetComment( int idx ) const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); wxString s; int size = data->m_comments.GetCount(); if ( idx < 0 ) { for ( int i = 0; i < size; i++ ) { s.append( data->m_comments[i] ); } } else if ( idx < size ) { s = data->m_comments[idx]; } return s; } //! Return the number of comment strings. int wxJSONValue::GetCommentCount() const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); int d = data->m_comments.GetCount(); ::wxLogTrace( traceMask, _T("(%s) comment count=%d"), __PRETTY_FUNCTION__, d ); return d; } //! Return the comment position. int wxJSONValue::GetCommentPos() const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); return data->m_commentPos; } //! Get the comment string's array. const wxArrayString& wxJSONValue::GetCommentArray() const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); return data->m_comments; } //! Clear all comment strings void wxJSONValue::ClearComments() { wxJSONRefData* data = COW(); wxJSON_ASSERT( data ); data->m_comments.clear(); } //! Set the type of the stored value. /*! The function sets the type of the stored value as specified in the provided argument. If the actual type is equal to \c type, nothing happens and this JSON value object retains the original type and value. If the type differs, however, the original type and value are lost. The function just sets the type of the object and not the value itself. If the object does not have a data structure it is allocated using the CreateRefData() function unless the type to be set is wxJSONTYPE_INVALID. In this case and if a data structure is not yet allocated, it is not allocated. If the object already contains a data structure it is not deleted but the type is changed in the original data structure. Complex values in the old structure are cleared. The \c type argument can be one of the following: \li wxJSONTYPE_INVALID: an empty (not initialized) JSON value \li wxJSONTYPE_NULL: a NULL value \li wxJSONTYPE_INT: an integer value \li wxJSONTYPE_UINT: an unsigned integer \li wxJSONTYPE_DOUBLE: a double precision number \li wxJSONTYPE_BOOL: a boolean \li wxJSONTYPE_CSTRING: a C string \li wxJSONTYPE_STRING: a wxString object \li wxJSONTYPE_ARRAY: an array of wxJSONValue objects \li wxJSONTYPE_OBJECT: a hashmap of key/value pairs where \e value is a wxJSONValue object \li wxJSONTYPE_LONG: a 32-bits integer value \li wxJSONTYPE_ULONG: an unsigned 32-bits integer \li wxJSONTYPE_INT64: a 64-bits integer value \li wxJSONTYPE_UINT64: an unsigned 64-bits integer \li wxJSONTYPE_SHORT: a signed short integer \li wxJSONTYPE_USHORT: an unsigned short integer The integer storage depends on the platform: for platforms that support 64-bits integers, integers are always stored as 64-bits integers. On platforms that do not support 64-bits integers, ints are stored as \b long \b int. To know more about the internal representation of integers, read \ref json_internals_integer. Note that there is no need to set a type for the object in order to assign a value to it. In other words, if you want to construct a JSON value which holds an integer value of 10, just use the specific constructor: \code wxJSONValue value( 10 ); \endcode which sets the integer type and also the numeric value. Moreover, there is no need to set the type for none of the handled types, not only for primitive types but for complex types, too. For example, if you want to construct an array of JSON values, just use the default ctor and call the Append() member function which will append the first element to the array and will set the array type: \code wxJSONValue value; value.Append( "a string" ); \endcode \sa GetType */ wxJSONRefData* wxJSONValue::SetType( wxJSONType type ) { wxJSONRefData* data = GetRefData(); wxJSONType oldType = GetType(); // check that type is within the allowed range wxJSON_ASSERT((type >= wxJSONTYPE_INVALID) && (type <= wxJSONTYPE_OBJECT)); if ( (type < wxJSONTYPE_INVALID) || (type > wxJSONTYPE_OBJECT) ) { type = wxJSONTYPE_INVALID; } // the function unshares the referenced data but does not delete the // structure. This is because the wxJSON reader stores comments // that apear before the value in a temporary value of type wxJSONTYPE_INVALID // which is invalid and, next, it stores the JSON value in the same // wxJSONValue object. // If we would delete the structure using 'Unref()' we loose the // comments data = COW(); // do nothing if the actual type is the same as 'type' if ( type == oldType ) { return data; } // change the type of the referened structure // NOTE: integer types are always stored as the generic integer types if ( type == wxJSONTYPE_LONG || type == wxJSONTYPE_INT64 || type == wxJSONTYPE_SHORT ) { type = wxJSONTYPE_INT; } if ( type == wxJSONTYPE_ULONG || type == wxJSONTYPE_UINT64 || type == wxJSONTYPE_USHORT ) { type = wxJSONTYPE_UINT; } wxJSON_ASSERT( data ); data->m_type = type; // clears complex objects of the old type switch ( oldType ) { case wxJSONTYPE_STRING: data->m_valString.clear(); break; case wxJSONTYPE_ARRAY: data->m_valArray.Clear(); break; case wxJSONTYPE_OBJECT: data->m_valMap.clear(); break; default : // there is not need to clear primitive types break; } // if the WXJSON_USE_CSTRING macro is not defined, the class forces // C-string to be stored as wxString objects #if !defined( WXJSON_USE_CSTRING ) if ( data->m_type == wxJSONTYPE_CSTRING ) { data->m_type = wxJSONTYPE_STRING; } #endif return data; } //! Return the line number of this JSON value object /*! The line number of a JSON value object is set to -1 when the object is constructed. The line number is set by the parser class, wxJSONReader, when a JSON text is read from a stream or a string. it is used when reading a comment line: comment lines that apear on the same line as a value are considered \b inline comments of the value. */ int wxJSONValue::GetLineNo() const { // return ZERO if there is not a referenced data structure int n = 0; wxJSONRefData* data = GetRefData(); if ( data != 0 ) { n = data->m_lineNo; } return n; } //! Set the line number of this JSON value object. void wxJSONValue::SetLineNo( int num ) { wxJSONRefData* data = COW(); wxJSON_ASSERT( data ); data->m_lineNo = num; } //! Set the pointer to the referenced data. void wxJSONValue::SetRefData(wxJSONRefData* data) { m_refData = data; } //! Increments the referenced data counter. void wxJSONValue::Ref(const wxJSONValue& clone) { // nothing to be done if (m_refData == clone.m_refData) return; // delete reference to old data UnRef(); // reference new data if ( clone.m_refData ) { m_refData = clone.m_refData; ++(m_refData->m_refCount); } } //! Unreferences the shared data /*! The function decrements the number of shares in wxJSONRefData::m_refCount and if it is ZERO, deletes the referenced data. It is called by the destructor. */ void wxJSONValue::UnRef() { if ( m_refData ) { wxASSERT_MSG( m_refData->m_refCount > 0, _T("invalid ref data count") ); if ( --m_refData->m_refCount == 0 ) delete m_refData; m_refData = NULL; } } //! Makes an exclusive copy of shared data void wxJSONValue::UnShare() { AllocExclusive(); } //! Do a deep copy of the other object. /*! This function allocates a new ref-data structure and copies it from the object \c other. */ void wxJSONValue::DeepCopy( const wxJSONValue& other ) { UnRef(); wxJSONRefData* data = CloneRefData( other.m_refData ); SetRefData( data ); } //! Return the pointer to the referenced data structure. wxJSONRefData* wxJSONValue::GetRefData() const { wxJSONRefData* data = m_refData; return data; } //! Make a copy of the referenced data. /*! The function allocates a new instance of the wxJSONRefData structure, copies the content of \c other and returns the pointer to the newly created structure. This function is called by the wxObject::UnRef() function when a non-const member function is called on multiple referenced data. */ wxJSONRefData* wxJSONValue::CloneRefData( const wxJSONRefData* otherData ) const { wxJSON_ASSERT( otherData ); // make a static cast to pointer-to-wxJSONRefData const wxJSONRefData* other = otherData; // allocate a new instance of wxJSONRefData using the default // ctor; we cannot use the copy ctor of a wxJSONRefData wxJSONRefData* data = new wxJSONRefData(); // wxObjectRefData is private and cannot be accessed by this // wxJSONValue class - but we need to set the reference counter // to 1 so we cannot simply use the default copy ctor of // wxJSONRefData* data = new wxJSONRefData( *other ); // wxJSONRefData structure. //data->m_count = 1; // copy the referenced data structure's data members data->m_type = other->m_type; data->m_value = other->m_value; data->m_commentPos = other->m_commentPos; data->m_comments = other->m_comments; data->m_lineNo = other->m_lineNo; data->m_valString = other->m_valString; data->m_valArray = other->m_valArray; data->m_valMap = other->m_valMap; ::wxLogTrace( cowTraceMask, _T("(%s) CloneRefData() PROGR: other=%d data=%d"), __PRETTY_FUNCTION__, other->GetRefCount(), data->GetRefCount() ); return data; } //! Create a new data structure /*! The function allocates a new instance of the wxJSONRefData structure and returns its pointer. The type of the JSON value is set to wxJSONTYPE_INVALID (= a not initialized value). */ wxJSONRefData* wxJSONValue::CreateRefData() const { wxJSONRefData* data = new wxJSONRefData(); data->m_type = wxJSONTYPE_INVALID; return data; } //! Make sure the referenced data is unique /*! This function is called by all non-const member functions and makes sure that the referenced data is unique by calling \b UnShare() If the referenced data is shared acrosss other wxJSONValue instances, the \c UnShare() function makes a private copy of the shared data. */ wxJSONRefData* wxJSONValue::COW() { wxJSONRefData* data = GetRefData(); ::wxLogTrace( cowTraceMask, _T("(%s) COW() START data=%p data->m_count=%d"), __PRETTY_FUNCTION__, data, data->GetRefCount()); UnShare(); data = GetRefData(); ::wxLogTrace( cowTraceMask, _T("(%s) COW() END data=%p data->m_count=%d"), __PRETTY_FUNCTION__, data, data->GetRefCount()); return GetRefData(); } //! Makes a private copy of the referenced data void wxJSONValue::AllocExclusive() { if ( !m_refData ) { m_refData = CreateRefData(); } else if ( m_refData->GetRefCount() > 1 ) { // note that ref is not going to be destroyed in this case const wxJSONRefData* ref = m_refData; UnRef(); // ... so we can still access it m_refData = CloneRefData(ref); } //else: ref count is 1, we are exclusive owners of m_refData anyhow wxASSERT_MSG( m_refData && m_refData->GetRefCount() == 1, _T("wxObject::AllocExclusive() failed.") ); } /************************************************************************* 64-bits integer support *************************************************************************/ #if defined( wxJSON_64BIT_INT) //! \overload wxJSONValue() wxJSONValue::wxJSONValue( wxInt64 i ) { m_refData = 0; wxJSONRefData* data = Init( wxJSONTYPE_INT ); wxJSON_ASSERT( data ); if ( data != 0 ) { data->m_value.VAL_INT = i; } } //! \overload wxJSONValue() wxJSONValue::wxJSONValue( wxUint64 ui ) { m_refData = 0; wxJSONRefData* data = Init( wxJSONTYPE_UINT ); wxJSON_ASSERT( data ); if ( data != 0 ) { data->m_value.VAL_UINT = ui; } } //! Return TRUE if the stored value is a 32-bits integer /*! This function is only available on 64-bits platforms and returns TRUE if, and only if, the stored value is of type \b wxJSONTYPE_INT and the numeric value fits in a 32-bits signed integer. The function just calls IsLong() and returns the value returned by that function. The use of this function is deprecated: use \c IsLong() instead */ bool wxJSONValue::IsInt32() const { bool r = IsLong(); return r; } //! Return TRUE if the stored value is a unsigned 32-bits integer /*! This function is only available on 64-bits platforms and returns TRUE if, and only if, the stored value is of type \b wxJSONTYPE_UINT and the numeric value fits in a 32-bits unsigned integer. The function just calls IsULong() and returns the value returned by that function. The use of this function is deprecated: use \c IsULong() instead */ bool wxJSONValue::IsUInt32() const { bool r = IsULong(); return r; } //! Return TRUE if the stored value is integer. /*! This function returns TRUE if the stored value is of type signed integer. In other words, the function returns TRUE if the \c wxJSONRefData::m_type data member is of type \c wxJSONTYPE_INT The function is only available if 64-bits integer support is enabled. \sa \ref json_internals_integer */ bool wxJSONValue::IsInt64() const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); bool r = false; if ( data->m_type == wxJSONTYPE_INT ) { r = true; } return r; } //! Return TRUE if the stored value is a unsigned integer /*! This function returns TRUE if the stored value is of type unsigned integer. In other words, the function returns TRUE if the \c wxJSONRefData::m_type data member is of type \c wxJSONTYPE_UINT. The function is only available if 64-bits integer support is enabled. \sa \ref json_internals_integer */ bool wxJSONValue::IsUInt64() const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); bool r = false; if ( data->m_type == wxJSONTYPE_UINT ) { r = true; } return r; } //! Returns the low-order 32 bits of the value as an integer /*! This function is only available on 64-bits platforms and returns the low-order 32-bits of the integer stored in the JSON value. Note that all integer types are stored as \b wx(U)Int64 data types by the JSON value class and that the function does not check that the numeric value fits in a 32-bit integer. The function just calls AsLong() and casts the value in a wxInt32 data type \sa \ref wxjson_tutorial_get */ wxInt32 wxJSONValue::AsInt32() const { wxInt32 i; i = (wxInt32) AsLong(); return i; } //! Returns the low-order 32 bits of the value as an unsigned integer /*! This function is only available on 64-bits platforms and returns the low-order 32-bits of the integer stored in the JSON value. Note that all integer types are stored as \b wx(U)Int64 data types by the JSON value class and that the function does not check that the numeric value fits in a 32-bit integer. The function just calls AsULong() and casts the value in a wxUInt32 data type \sa \ref wxjson_tutorial_get */ wxUint32 wxJSONValue::AsUInt32() const { wxUint32 ui; ui = (wxUint32) AsULong(); return ui; } //! Return the numeric value as a 64-bit integer. /*! This function is only available on 64-bits platforms and returns the numeric value as a 64-bit integer. Note that the function does not check that the type of the value is actually an integer and it just returns the content of the wxJSONValueHolder union. However, in debug builds, the function ASSERTs that the type of the stored value is wxJSONTYPE_INT. \sa \ref json_internals_integer \sa \ref wxjson_tutorial_get */ wxInt64 wxJSONValue::AsInt64() const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); wxInt64 i64 = data->m_value.m_valInt64; wxJSON_ASSERT( IsInt64()); // exapnds only in debug builds return i64; } //! Return the numeric value as a 64-bit unsigned integer. /*! This function is only available on 64-bits platforms and returns the numeric value as a 64-bit unsigned integer. Note that the function does not check that the type of the value is actually an integer and it just returns the content of the wxJSONValueHolder union. However, in debug builds, the function wxJSON_ASSERTs that the type of the stored value is wxJSONTYPE_UINT. \sa \ref json_internals_integer \sa \ref wxjson_tutorial_get */ wxUint64 wxJSONValue::AsUInt64() const { wxJSONRefData* data = GetRefData(); wxJSON_ASSERT( data ); wxUint64 ui64 = data->m_value.m_valUInt64; wxJSON_ASSERT( IsUInt64()); // exapnds only in debug builds return ui64; } //! \overload Append( const wxJSONValue& ) wxJSONValue& wxJSONValue::Append( wxInt64 i ) { wxJSONValue v( i ); wxJSONValue& r = Append( v ); return r; } //! \overload Append( const wxJSONValue& ) wxJSONValue& wxJSONValue::Append( wxUint64 ui ) { wxJSONValue v( ui ); wxJSONValue& r = Append( v ); return r; } //! \overload operator = (int) wxJSONValue& wxJSONValue::operator = ( wxInt64 i ) { wxJSONRefData* data = SetType( wxJSONTYPE_INT ); data->m_value.VAL_INT = i; return *this; } //! \overload operator = (int) wxJSONValue& wxJSONValue::operator = ( wxUint64 ui ) { wxJSONRefData* data = SetType( wxJSONTYPE_UINT ); data->m_value.VAL_UINT = ui; return *this; } #endif // defined( wxJSON_64BIT_INT ) /* { } */
[ "Master@IBM-A89814EDA00.(none)" ]
[ [ [ 1, 2922 ] ] ]
7326f8530fa91a2148bffca668c692dc63de440d
457cfb51e6b1053c852602f57acc9087629e966d
/source/BLUE/Object.cpp
dcdbd570490dd71c8607feb761a1386987345d46
[]
no_license
bluespeck/BLUE
b05eeff4958b2bf30adb0aeb2432f1c2f6c21d96
430d9dc0e64837007f35ce98fbface014be93678
refs/heads/master
2021-01-13T01:50:57.300012
2010-11-15T16:37:10
2010-11-15T16:37:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,459
cpp
#include "stdafx.h" #include <cstring> #include <cassert> #include <fstream> #include <set> #include <algorithm> #include <tchar.h> #include "Object.h" namespace BLUE { unsigned long CObject::m_objCount = 0; CObject::CObject( void ): m_pParent( NULL ), m_pChild( NULL ), m_pNextBrother( NULL ), m_bDirty(false), m_vecScaleFactors( 1.0f, 1.0f, 1.0f ), m_bHighlight( false ) { m_objCount++; m_szName = new TCHAR[16]; _tcprintf_s( m_szName, 15, _T( "obj_%ld" ), m_objCount ); CMatrix4::MatIdentity( m_matGlobal ); CMatrix4::MatIdentity( m_matLocal ); //m_pPhysics = NULL; } CObject::~CObject( void ) { m_pParent = NULL; m_pChild = NULL; m_pNextBrother = NULL; delete[] m_szName; // Free space occupied by controllers for( int i = 0, s = m_pControllers.size(); i < s; i++ ) m_pControllers[i]->DeleteMe(); m_pControllers.clear(); } void CObject::DeleteMe() { delete this; } void CObject::DeleteHierarchy() { for( CObject * pObj = m_pChild; pObj; ) { CObject *pNextObj = pObj->m_pNextBrother; pObj->DeleteHierarchy(); pObj = pNextObj; } DeleteMe(); } const TCHAR *CObject::GetName() { return m_szName; } void CObject::SetName( const TCHAR *szName ) { if( szName != NULL || szName[0] == 0) { if(m_szName != NULL) delete[] m_szName; unsigned int size = _tcslen( szName ) + 1; m_szName = new TCHAR[size]; _tcscpy_s( m_szName, size, szName ); } } void CObject::AddChild(CObject *pObj) { if(m_pChild == NULL) { // This object has no children. Add pObj as its only child m_pChild = pObj; } else { // This object has children. Add pObj at the end of the children list CObject *p = m_pChild; while(p->m_pNextBrother != NULL) { p = p->m_pNextBrother; } p->m_pNextBrother = pObj; } // Link child to its parent pObj->m_pParent = this; } bool CObject::GetDirty() { return m_bDirty; } void CObject::SetDirty(bool bDirty) { m_bDirty = bDirty; } void CObject::SetHighlight(bool bHighlight) { m_bHighlight = bHighlight; } bool CObject::GetHighlight() { return m_bHighlight; } void CObject::GetGlobalPosition( CVector3 &vecPos ) { m_matGlobal.GetRow( vecPos, 3 ); } CObject *CObject::GetRootObj() { CObject *pParent = this; while( pParent->m_pParent != NULL ) { pParent = pParent->m_pParent; } return pParent; } }
[ [ [ 1, 144 ] ] ]
d1d9fa6c4ed91223d936323d5e1d4a93a203be43
1c122be854fde96f345d2c82a87ff3bc1df5f75c
/libs/glui/glui_listbox.cpp
e399cd1eb0ff7516932d987a068944097e37aca9
[]
no_license
varungupta181186/vistool
97c6ad5a83f739f3d821c3e0287d6d093ca595e9
9136985d48ab09abed43961d3815a8cdf3ceb9cf
refs/heads/master
2021-01-21T03:22:28.618673
2011-12-04T11:45:06
2011-12-04T11:45:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,579
cpp
/**************************************************************************** GLUI User Interface Toolkit --------------------------- glui_listbox - GLUI_ListBox control class -------------------------------------------------- Copyright (c) 1998 Paul Rademacher This program is freely distributable without licensing fees and is provided without guarantee or warrantee expressed or implied. This program is -not- in the public domain. *****************************************************************************/ #include "glui.h" #include "stdinc.h" /****************************** GLUI_Listbox::mouse_down_handler() **********/ int GLUI_Listbox::mouse_down_handler( int local_x, int local_y ) { return false; } /****************************** GLUI_Listbox::mouse_up_handler() **********/ int GLUI_Listbox::mouse_up_handler( int local_x, int local_y, int inside ) { return false; } /****************************** GLUI_Listbox::mouse_held_down_handler() ******/ int GLUI_Listbox::mouse_held_down_handler( int local_x, int local_y, int inside) { return false; } /****************************** GLUI_Listbox::key_handler() **********/ int GLUI_Listbox::key_handler( unsigned char key,int modifiers ) { return false; } /****************************** GLUI_Listbox::draw() **********/ void GLUI_Listbox::draw( int x, int y ) { int orig, name_x; if ( NOT can_draw() ) return; orig = set_to_glut_window(); /* draw_active_area(); */ name_x = MAX(text_x_offset - string_width(this->name) - 3,0); draw_name( name_x , 13); draw_box_inwards_outline( text_x_offset, w, 0, h ); if ( NOT active ) { draw_box( text_x_offset+3, w-2, 2, h-2, 1.0, 1.0, 1.0 ); if ( NOT enabled ) glColor3b( 32, 32, 32 ); else glColor3f( 0.0, 0.0, 0.0 ); glRasterPos2i( text_x_offset+5, 13 ); draw_string( curr_text.string ); } else { draw_box( text_x_offset+3, w-2, 2, h-2, .0, .0, .6 ); glColor3f( 1.0, 1.0, 1.0 ); glRasterPos2i( text_x_offset+5, 13 ); draw_string( curr_text.string ); } if ( enabled ) { glui->std_bitmaps. draw(GLUI_STDBITMAP_LISTBOX_UP, w-glui->std_bitmaps.bitmaps[GLUI_STDBITMAP_LISTBOX_UP].w-1, 2 ); } else { glui->std_bitmaps. draw(GLUI_STDBITMAP_LISTBOX_UP_DIS, w-glui->std_bitmaps.bitmaps[GLUI_STDBITMAP_LISTBOX_UP].w-1, 2 ); } restore_window(orig); } /************************************ GLUI_Listbox::update_si() **********/ void GLUI_Listbox::update_size( void ) { int text_size, delta; int item_text_size; if ( NOT glui ) return; text_size = string_width( name ); /*** Find the longest item string ***/ item_text_size = 0; delta = 0; if ( text_x_offset < text_size +2 ) delta = text_size+2-text_x_offset; text_x_offset += delta; if ( w < text_x_offset+MAX(GLUI_EDITTEXT_MIN_TEXT_WIDTH,item_text_size)+20) w = text_x_offset + MAX( GLUI_EDITTEXT_MIN_TEXT_WIDTH,item_text_size)+20; } /********************************* GLUI_Listbox::set_int_val() **************/ void GLUI_Listbox::set_int_val( int new_val ) { /* int_val = new_val; */ do_selection( new_val ); /*** Update the variable we're (possibly) pointing to, and update the main gfx ***/ output_live(true); } /**************************** GLUI_Listbox::draw_active_area() **************/ void GLUI_Listbox::draw_active_area( void ) { int orig; if ( NOT can_draw() ) return; orig = set_to_glut_window(); restore_window(orig); } /**************************************** GLUI_Listbox::add_item() **********/ int GLUI_Listbox::add_item( int id, const char *new_text ) { GLUI_Listbox_Item *new_node = new GLUI_Listbox_Item; GLUI_Listbox_Item *head; strcpy( new_node->text, new_text ); new_node->id = id; head = (GLUI_Listbox_Item*) items_list.first_child(); new_node->link_this_to_parent_last( &items_list ); if ( head == NULL ) { /*** This is first item added ***/ int_val = id+1; /** Different than id **/ do_selection( id ); last_live_int = id; if( glui ) glui->post_update_main_gfx(); } /*** Check if we need to increase control size ***/ if ( w < text_x_offset + MAX( GLUI_EDITTEXT_MIN_TEXT_WIDTH, string_width( new_text ) ) + 20 ) { w = text_x_offset + MAX( GLUI_EDITTEXT_MIN_TEXT_WIDTH, string_width( new_text ) ) + 20; if ( glui ) glui->refresh(); /* printf( "%s\n", new_text ); */ } return true; } /************************************** GLUI_Listbox::delete_item() **********/ int GLUI_Listbox::delete_item(const char *text ) { GLUI_Listbox_Item *node = get_item_ptr( text ); if ( node ) { node->unlink(); delete node; return true; } else { return false; } } /************************************** GLUI_Listbox::delete_item() **********/ int GLUI_Listbox::delete_item( int id ) { GLUI_Listbox_Item *node = get_item_ptr( id ); if ( node ) { node->unlink(); delete node; return true; } else { return false; } } /************************************** GLUI_Listbox::sort_items() **********/ int GLUI_Listbox::sort_items( void ) { return false; } /********************************************* GLUI_Listbox::dump() **********/ void GLUI_Listbox::dump( FILE *output ) { GLUI_Listbox_Item *item; /* printf( "%p\n", (char*) name ); */ fprintf( output, "Listbox: %s\n", (char*) name ); item = (GLUI_Listbox_Item *) items_list.first_child(); while( item ) { fprintf( output, " %3d : %s\n", item->id, (char*) item->text ); item = (GLUI_Listbox_Item *) item->next(); } } /************************************ GLUI_Listbox::get_item_ptr() **********/ GLUI_Listbox_Item *GLUI_Listbox::get_item_ptr( const char *text ) { GLUI_Listbox_Item *item; item = (GLUI_Listbox_Item *) items_list.first_child(); while( item ) { if ( NOT strcmp( item->text, text )) return item; item = (GLUI_Listbox_Item *) item->next(); } return NULL; } /************************************ GLUI_Listbox::get_item_ptr() **********/ GLUI_Listbox_Item *GLUI_Listbox::get_item_ptr( int id ) { GLUI_Listbox_Item *item; item = (GLUI_Listbox_Item *) items_list.first_child(); while( item ) { if ( item->id == id ) return item; item = (GLUI_Listbox_Item *) item->next(); } return NULL; } /************************************ GLUI_Listbox::mouse_over() **********/ static void listbox_callback( int i ) { int old_val; if ( NOT GLUI_Master.curr_left_button_glut_menu OR GLUI_Master.curr_left_button_glut_menu->type != GLUI_CONTROL_LISTBOX ) return; old_val = ((GLUI_Listbox*)GLUI_Master.curr_left_button_glut_menu)->int_val; ((GLUI_Listbox*)GLUI_Master.curr_left_button_glut_menu)->set_int_val(i); /**** If value changed, execute callback ****/ if ( old_val != ((GLUI_Listbox*)GLUI_Master.curr_left_button_glut_menu)->int_val ) { ((GLUI_Listbox*)GLUI_Master.curr_left_button_glut_menu)->execute_callback(); } } /*************************************** GLUI_Listbox::mouse_over() **********/ int GLUI_Listbox::mouse_over( int state, int x, int y ) { GLUI_Listbox_Item *item; /* printf( "x/y: %d/%d\n", x, y ); */ if ( state AND enabled AND x > x_abs + text_x_offset) { /**** Build a GLUT menu for this listbox ***/ /* printf( "%d %d\n", x, y ); */ glut_menu_id = glutCreateMenu(listbox_callback); item = (GLUI_Listbox_Item *) items_list.first_child(); while( item ) { glutAddMenuEntry( item->text, item->id ); item = (GLUI_Listbox_Item *) item->next(); } glutAttachMenu( GLUT_LEFT_BUTTON); GLUI_Master.set_left_button_glut_menu_control( this ); } else if ( glut_menu_id != -1 ) { /* printf( "OUT\n" ); */ glutDetachMenu( GLUT_LEFT_BUTTON ); glutDestroyMenu( glut_menu_id ); glut_menu_id = -1; } return true; } /************************************ GLUI_Listbox::do_selection() **********/ int GLUI_Listbox::do_selection( int item_num ) { GLUI_Listbox_Item *item, *sel_item; /*** Is this item already selected? ***/ if ( item_num == int_val ) return false; sel_item = NULL; item = (GLUI_Listbox_Item *) items_list.first_child(); while( item ) { if ( item->id == item_num ) { sel_item = item; break; } item = (GLUI_Listbox_Item *) item->next(); } if ( NOT sel_item ) return false; /* printf( "-> %s\n", (char*) sel_item->text ); */ int_val = item_num; strcpy( curr_text.string, sel_item->text.string ); translate_and_draw_front(); return true; } /*********************************** GLUI_Listbox::~GLUI_Listbox() **********/ GLUI_Listbox::~GLUI_Listbox( ) { GLUI_Listbox_Item *item, *tmp_item; item = (GLUI_Listbox_Item *) items_list.first_child(); while( item ) { tmp_item = item; delete item; item = (GLUI_Listbox_Item *) tmp_item->next(); } } /****************************** GLUI_Listbox::special_handler() **********/ int GLUI_Listbox::special_handler( int key,int modifiers ) { GLUI_Listbox_Item *node, *new_node; node = get_item_ptr( int_val ); new_node = NULL; if ( key == GLUT_KEY_DOWN ) { new_node = (GLUI_Listbox_Item*) node->next(); } else if ( key == GLUT_KEY_UP ) { new_node = (GLUI_Listbox_Item*) node->prev(); } else if ( key == GLUT_KEY_HOME ) { new_node = (GLUI_Listbox_Item*) items_list.first_child(); } else if ( key == GLUT_KEY_END ) { new_node = (GLUI_Listbox_Item*) items_list.last_child(); } if ( new_node != NULL AND new_node != node ) { node = new_node; set_int_val( node->id ); execute_callback(); return true; } else { return false; } } /************************* GLUI_Listbox::increase_width( void ) ***********/ void GLUI_Listbox::increase_width( void ) { }
[ [ [ 1, 447 ] ] ]
164573f58eea48cdd0e1cfc8d5307d4e9841d18c
bef7d0477a5cac485b4b3921a718394d5c2cf700
/dingus/dingus/resource/TextureBundle.h
0da2aea776e4d49939553a2f26c34d1b21a4d2d4
[ "MIT" ]
permissive
TomLeeLive/aras-p-dingus
ed91127790a604e0813cd4704acba742d3485400
22ef90c2bf01afd53c0b5b045f4dd0b59fe83009
refs/heads/master
2023-04-19T20:45:14.410448
2011-10-04T10:51:13
2011-10-04T10:51:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,369
h
// -------------------------------------------------------------------------- // Dingus project - a collection of subsystems for game/graphics applications // -------------------------------------------------------------------------- #ifndef __TEXTURE_BUNDLE_H #define __TEXTURE_BUNDLE_H #include "StorageResourceBundle.h" #include "../kernel/Proxies.h" #include "DeviceResource.h" #include "../utils/Singleton.h" namespace dingus { class CTextureBundle : public CStorageResourceBundle<CD3DTexture>, public CSingleton<CTextureBundle>, public IDeviceReloadableBundle { public: virtual void createResource(); virtual void activateResource(); virtual void passivateResource(); virtual void deleteResource(); protected: virtual CD3DTexture* loadResourceById( const CResourceId& id, const CResourceId& fullName ); virtual void deleteResource( CD3DTexture& resource ) { if( resource.getObject() ) resource.getObject()->Release(); delete &resource; } private: IMPLEMENT_SIMPLE_SINGLETON(CTextureBundle); CTextureBundle(); virtual ~CTextureBundle() { clear(); }; IDirect3DTexture9* loadTexture( const CResourceId& id, const CResourceId& fullName ) const; }; }; // namespace /// Shortcut macro #define RGET_TEX(rid) dingus::CTextureBundle::getInstance().getResourceById(rid) #endif
[ [ [ 1, 50 ] ] ]
be705ff765494c9ad130c84f720b63487d999c39
82cceba079939c15aa1fc3086c2a6c87e71f96d5
/ACM5/viech.h
a4db3310c3f09788f27d3cdf0eed30ea882fd218
[]
no_license
ahnt/ACM5
7844df3359d9b3bcae63745c465f13f09045264e
0cce2226d70930df0f3186ed53e9d32edafef36b
refs/heads/master
2016-09-01T23:09:01.446157
2011-11-11T15:27:15
2011-11-11T15:27:15
2,606,523
0
0
null
null
null
null
UTF-8
C++
false
false
1,646
h
#ifndef _T_VIECH_H_ #include "chemistry.h" #include <stdint.h> #include <vector> #include <string> using namespace std; struct t_gene{ double n; unsigned char ident; unsigned char direction; int domain[5]; int A,B,wo_A,wo_B,AP,BP; double affinity[5]; signed char delta_e; }; class t_viech{ public: t_viech *ancestor; int nrPointingAtMe; int born; string changeLog; int hmvg[16]; int speed_hits; int32_t age; unsigned char heading; double speed; double energy; double xpos,ypos; double total_n; double n_comp[608]; int n_comp_hits[608]; t_gene *genes; double *activity; int32_t hmg; long nr; vector<vector<unsigned char> > chromosome; t_viech *next,*last; t_viech(); ~t_viech(); void show(t_chemistry *chemistry); void fill_chr_rand(int32_t length_A,int32_t length_B); void inherit(t_viech *from,double mutationRate,double duplicationRate,double deletionRate); void setup_proteom(t_chemistry *chemistry); void setup_total_n(double a); int32_t how_many_genes(void); int32_t how_many_working_genes(void); void step(t_chemistry *chemistry); void calc_nucleotide_needs(void); void save_proteom_network(char *filename, t_chemistry *chemistry); void save_proteom_toDot(char *filename, t_chemistry *chemistry); void showProteomNetwork(t_chemistry *chemistry); void save_genome(int name); void load_genome(char *filename); int ready_to_divide(double level,double *fitness_for_compound); double get_total_n(void); void saveLOD(FILE *lod,FILE *comment,FILE *data); t_viech* getLMRCA(void); }; #define _T_VIECH_H_ #endif
[ [ [ 1, 64 ] ] ]
214488257086a887fd739615d3a46e130a816e37
5506729a4934330023f745c3c5497619bddbae1d
/vst2.x/tuio/gl_tk.cpp
74354015cdbb383af59312b658a7a88f05319c16
[]
no_license
berak/vst2.0
9e6d1d7246567f367d8ba36cf6f76422f010739e
9d8f51ad3233b9375f7768be528525c15a2ba7a1
refs/heads/master
2020-03-27T05:42:19.762167
2011-02-18T13:35:09
2011-02-18T13:35:09
1,918,997
4
3
null
null
null
null
UTF-8
C++
false
false
20,932
cpp
#include "gl_tk.h" #ifdef WIN32 #include <windows.h> // 'double' to 'float' : #pragma warning (disable:4244) // 'size_t' nach 'GLsizei' #pragma warning (disable:4267) #endif #include <GL/gl.h> #include <GL/glu.h> #include <cmath> #include <cstdio> #ifndef M_PI #define M_PI 3.14159265358979323846f // Pi, again. #endif char * RGL::checkError () { static GLenum last_err = 0; GLenum err = glGetError(); if ( err == last_err ) return 0; last_err = err; switch ( err ) { default: case GL_NO_ERROR : break; case GL_INVALID_ENUM : return ( "GL_INVALID_ENUM"); case GL_INVALID_VALUE : return ( "GL_INVALID_VALUE"); case GL_INVALID_OPERATION : return ( "GL_INVALID_OPERATION"); case GL_STACK_OVERFLOW : return ( "GL_STACK_OVERFLOW"); case GL_STACK_UNDERFLOW : return ( "GL_STACK_UNDERFLOW"); case GL_OUT_OF_MEMORY : return ( "GL_OUT_OF_MEMORY"); } return 0; } char * RGL::driverInfo() { static char str[8012] = {0}; str[0] = 0; sprintf( str, "vendor : %s\nrenderer : %s\nversion : %s\n", (char*)glGetString(GL_VENDOR), (char*)glGetString(GL_RENDERER), (char*)glGetString(GL_VERSION) ); char *e = str + strlen(str); const char *supportedExt = NULL; // Try To Use wglGetExtensionStringARB On Current DC, If Possible PROC wglGetExtString = wglGetProcAddress("wglGetExtensionsStringARB"); if (wglGetExtString) { supportedExt = ((char*(__stdcall*)(HDC))wglGetExtString)(wglGetCurrentDC()); strcat( str, supportedExt ); } supportedExt = (char*)glGetString(GL_EXTENSIONS); strcat( str, supportedExt ); for ( char *c=e; *c; c++ ) { if ( *c == ' ' ) *c = '\n'; }; return str; } ////////////////////////////////////////////////////////////////////////////// // drawing: ////////////////////////////////////////////////////////////////////////////// void RGL::drawGrid( float r,float g,float b ) { glColor3f( r,g,b ); int g_siz = 1000, g_step=10; for ( int i=-g_siz; i<g_siz; i+=g_step ) { glBegin( GL_LINES ); glVertex3i( -g_siz, 0, i ); glVertex3i( g_siz, 0, i ); glVertex3i( i, 0, -g_siz ); glVertex3i( i, 0, g_siz ); glEnd(); } } void RGL::drawAABB( float m[3], float M[3]) { glPushMatrix(); glBegin(GL_LINES); glVertex3d(m[0],m[1],m[2]); glVertex3d(M[0],m[1],m[2]); glVertex3d(m[0],m[1],M[2]); glVertex3d(M[0],m[1],M[2]); glVertex3d(m[0],M[1],m[2]); glVertex3d(M[0],M[1],m[2]); glVertex3d(m[0],M[1],M[2]); glVertex3d(M[0],M[1],M[2]); glVertex3d(m[0],m[1],m[2]); glVertex3d(m[0],M[1],m[2]); glVertex3d(m[0],m[1],M[2]); glVertex3d(m[0],M[1],M[2]); glVertex3d(M[0],m[1],m[2]); glVertex3d(M[0],M[1],m[2]); glVertex3d(M[0],m[1],M[2]); glVertex3d(M[0],M[1],M[2]); glVertex3d(m[0],m[1],m[2]); glVertex3d(m[0],m[1],M[2]); glVertex3d(m[0],M[1],m[2]); glVertex3d(m[0],M[1],M[2]); glVertex3d(M[0],m[1],m[2]); glVertex3d(M[0],m[1],M[2]); glVertex3d(M[0],M[1],m[2]); glVertex3d(M[0],M[1],M[2]); glEnd(); glPopMatrix(); } void RGL::drawAxes( float px, float py, float pz, float sx, float sy, float sz ) { static float zero[3] = { 0,0,0 }; static float axes[3][3] = { {1,0,0}, {0,1,0}, {0,0,1} }; glPushAttrib(GL_ALL_ATTRIB_BITS); glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); //glColor3f(1,1,0); glPointSize( 6.0f ); glPushMatrix(); glTranslatef( px,py,pz ); glScalef( sx,sy,sz ); glBegin( GL_POINTS ); glVertex3fv( zero ); glEnd(); for ( int i=0; i<3; i++ ) { glColor3f(axes[i][0],axes[i][1],axes[i][2]); glBegin( GL_LINES ); glVertex3fv( zero ); glVertex3fv( axes[i] ); glEnd(); glBegin( GL_POINTS ); glVertex3fv( axes[i] ); glEnd(); } glColor3f(1,1,1); glPopMatrix(); glPopAttrib(); } void RGL::drawSphere( float radius, int numMajor, int numMinor) { double majorStep = (M_PI / numMajor); double minorStep = (2.0 * M_PI / numMinor); int i, j; for (i = 0; i < numMajor; ++i) { double a = i * majorStep; double b = a + majorStep; double r0 = radius * sin(a); double r1 = radius * sin(b); GLfloat z0 = radius * cos(a); GLfloat z1 = radius * cos(b); glBegin(GL_TRIANGLE_STRIP); for (j = 0; j <= numMinor; ++j) { double c = j * minorStep; GLfloat x = cos(c); GLfloat y = sin(c); glNormal3f((x * r0) / radius, (y * r0) / radius, z0 / radius); glTexCoord2f(j / (GLfloat) numMinor, i / (GLfloat) numMajor); glVertex3f(x * r0, y * r0, z0); glNormal3f((x * r1) / radius, (y * r1) / radius, z1 / radius); glTexCoord2f(j / (GLfloat) numMinor, (i + 1) / (GLfloat) numMajor); glVertex3f(x * r1, y * r1, z1); } glEnd(); } } void RGL::drawCylinder( float radius, int numMajor, int numMinor, float height) { double majorStep = height / numMajor; double minorStep = 2.0 * M_PI / numMinor; int i, j; for (i = 0; i < numMajor; ++i) { GLfloat z0 = 0.5 * height - i * majorStep; GLfloat z1 = z0 - majorStep; glBegin(GL_TRIANGLE_STRIP); for (j = 0; j <= numMinor; ++j) { double a = j * minorStep; GLfloat x = radius * cos(a); GLfloat y = radius * sin(a); glNormal3f(x / radius, y / radius, 0.0); glTexCoord2f(j / (GLfloat) numMinor, i / (GLfloat) numMajor); glVertex3f(x, y, z0); glNormal3f(x / radius, y / radius, 0.0); glTexCoord2f(j / (GLfloat) numMinor, (i + 1) / (GLfloat) numMajor); glVertex3f(x, y, z1); } glEnd(); } } //~ void RGL::drawCone( float radius1, float radius2, int numMinor, float height) //~ { //~ double minorStep = 2.0 * M_PI / numMinor; //~ int i, j; //~ glBegin(GL_TRIANGLE_STRIP); //~ for (j = 0; j <= numMinor; ++j) { //~ double a = j * minorStep; //~ GLfloat x = radius * cos(a); //~ GLfloat y = radius * sin(a); //~ glNormal3f(x / radius, y / radius, 0.0); //~ glTexCoord2f(j / (GLfloat) numMinor, i / (GLfloat) numMajor); //~ glVertex3f(x, y, 0); //~ glNormal3f(x / radius, y / radius, 0.0); //~ glTexCoord2f(j / (GLfloat) numMinor, (i + 1) / (GLfloat) numMajor); //~ glVertex3f(x, y, height); //~ } //~ glEnd(); //~ } void RGL::drawTorus(float majorRadius, float minorRadius, int numMajor, int numMinor) { double majorStep = 2.0 * M_PI / numMajor; double minorStep = 2.0 * M_PI / numMinor; int i, j; for (i = 0; i < numMajor; ++i) { double a0 = i * majorStep; double a1 = a0 + majorStep; GLfloat x0 = cos(a0); GLfloat y0 = sin(a0); GLfloat x1 = cos(a1); GLfloat y1 = sin(a1); glBegin(GL_TRIANGLE_STRIP); for (j = 0; j <= numMinor; ++j) { double b = j * minorStep; GLfloat c = cos(b); GLfloat r = minorRadius * c + majorRadius; GLfloat z = minorRadius * sin(b); glNormal3f(x0 * c, y0 * c, z / minorRadius); glTexCoord2f(i / (GLfloat) numMajor, j / (GLfloat) numMinor); glVertex3f(x0 * r, y0 * r, z); glNormal3f(x1 * c, y1 * c, z / minorRadius); glTexCoord2f((i + 1) / (GLfloat) numMajor, j / (GLfloat) numMinor); glVertex3f(x1 * r, y1 * r, z); } glEnd(); } } // // *--v1 // | | // | | // v0--* // void RGL::drawTexQuad2D( float vx1, float vy1, float vx2, float vy2, float tx1, float ty1, float tx2, float ty2 ) { glBegin(GL_QUADS); glTexCoord2d( tx1, ty1 ); glVertex2d( vx1, vy1 ); glTexCoord2d( tx2, ty1 ); glVertex2d( vx2, vy1 ); glTexCoord2d( tx2, ty2 ); glVertex2d( vx2, vy2 ); glTexCoord2d( tx1, ty2 ); glVertex2d( vx1, vy2 ); glEnd(); } void _renderPoint( int i, int j, float wn, float hn, int DIM) { float px = wn + (float)i * wn; float pz = hn + (float)j * hn; float tx = (float)i /DIM; float ty = (float)j /DIM; glNormal3f( 0,1,0 ); glTexCoord2f( tx,ty ); glVertex3f( px,0,pz ); } void RGL::drawPlane( float w, float h, int DIM ) { float wn = (float)w / (float)(DIM + 1); /* Grid element width */ float hn = (float)h / (float)(DIM + 1); /* Grid element height */ for (int i=0, j=0; j < DIM - 1; j++) { glBegin(GL_TRIANGLE_STRIP); i = 0; _renderPoint( i, j, wn, hn, DIM ); for (i = 0; i < DIM - 1; i++) { _renderPoint( i, j+1, wn, hn, DIM ); _renderPoint( i+1, j, wn, hn, DIM ); } _renderPoint( DIM-1, j+1, wn, hn, DIM ); glEnd(); } } int gl_font_base = -1; void RGL::drawText(int x,int y,char *text) { if ( gl_font_base == -1 ) { #ifdef _WIN32 HDC dc = wglGetCurrentDC(); gl_font_base = glGenLists(256); wglUseFontBitmaps(dc, 0, 255, gl_font_base); #else base = RGL::makeRasterFont(); #endif } glRasterPos2i(x,y); glListBase(gl_font_base); glCallLists(strlen(text), GL_BYTE, text); } void RGL::drawTextFont( char *txt, int x, int y, int font_texture ) { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, font_texture); static int font_listbase = -1; if ( font_listbase == -1 ) { glBindTexture(GL_TEXTURE_2D, font_texture); font_listbase = glGenLists(256); for( int i=0; i<256; i++) { float cx=float(i%16)/16.0f; float cy=float(i/16)/16.0f; glNewList(font_listbase + i, GL_COMPILE); glBegin(GL_QUADS); glTexCoord2f(cx, 1-cy-0.0625f); glVertex2i(0, 0); glTexCoord2f(cx+0.0625f, 1-cy-0.0625f); glVertex2i(16, 0); glTexCoord2f(cx+0.0625f, 1-cy); glVertex2i(16, 16); glTexCoord2f(cx, 1-cy); glVertex2i(0, 16); glEnd(); glTranslatef(16,0,0); glEndList(); } } glPushMatrix(); glLoadIdentity(); glTranslated(x, y, 0); glListBase(font_listbase-32+(128*0)); glCallLists(strlen(txt), GL_BYTE,txt); glPopMatrix(); } void RGL::drawTri() { glPushMatrix(); glBegin( GL_TRIANGLES ); glColor3ub(0xff,0,0); glVertex3f(-5,0,-20); glColor3ub(0,0xff,0); glVertex3f( 5,0,-20); glColor3ub(0,0,0xff); glVertex3f( 0,5,-20); glEnd(); glPopMatrix(); } ////////////////////////////////////////////////////////////////////////////// // projection ////////////////////////////////////////////////////////////////////////////// void RGL::perspective(float fov, float np, float fp, float *res) { float vp[4]; glGetFloatv( GL_VIEWPORT, vp ); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective( fov, float(vp[2])/vp[3], np, fp ); if ( res ) { glGetFloatv( GL_PROJECTION_MATRIX, res ); } glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void RGL::ortho( float siz, float znear, float zfar ) { glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glOrtho( -siz, siz, -siz, siz, znear, zfar ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); } void RGL::enter2D() { static GLint view[4]; glGetIntegerv( GL_VIEWPORT, view ); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluOrtho2D( view[0], view[2], view[1], view[3] ); glPushAttrib( GL_ALL_ATTRIB_BITS ); } void RGL::leave2D() { glPopAttrib(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glColor3f(1,1,1); // glDisable(GL_BLEND); // glEnable(GL_DEPTH_TEST); } ////////////////////////////////////////////////////////////////////////////// // texturing: ////////////////////////////////////////////////////////////////////////////// unsigned int RGL::texCreate( unsigned int width, unsigned int height, unsigned int bpp, void *data, bool mipmap, unsigned int id ) { if ( ! data ) return 0; int type = bpp; int gl_dim = GL_TEXTURE_2D; switch( bpp ) { case 1: type = GL_LUMINANCE; gl_dim = GL_TEXTURE_1D; break; case 3: type = GL_RGB; break; case 4: type = GL_RGBA; break; //~ case 3: type = GL_BGR_EXT; break; //~ case 4: type = GL_RGBA_EXT; break; default: return false; } glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // glEnable( GL_TEXTURE_2D, 1 ); if ( id < 1 ) glGenTextures( 1, &id ); if ( id < 1 ) { printf( "GlEngine could not create texObject !\n" ); return 0; } glBindTexture( gl_dim, id ); if ( mipmap && (type!=GL_LUMINANCE) ) // no mip for cellshading! gluBuild2DMipmaps( gl_dim, bpp, width, height, type, GL_UNSIGNED_BYTE, data ); else glTexImage2D( gl_dim, 0, bpp, width, height, 0, type, GL_UNSIGNED_BYTE, data ); return id; } void RGL::texRelease( unsigned int id ) { if ( glIsTexture( id ) ) { // glBindTexture( GL_TEXTURE_2D, id ); // glTexImage2D( GL_TEXTURE_2D, 0, 3, 0, 0, 0, 3, GL_UNSIGNED_BYTE, 0 ); glDeleteTextures( 1, &id ); } } void RGL::texBind( unsigned int id ) { if ( glIsTexture( id ) ) { glBindTexture( GL_TEXTURE_2D, id ); } } bool RGL::texIsValid( unsigned int id ) { return ( glIsTexture( id ) != 0 ); } void RGL::texParams( int minf, int magf, int wrap, int env ) { glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minf); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magf); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap ); if ( env ) glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, env ); } void RGL::texGenOn( int mode, float *s, float *t ) { // Set up texture coordinate generation glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, mode); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, mode); float fS[4] = { -0.1f, 0.0f, 0.0f, 0.0f }; float fT[4] = { 0.0f, 0.0f, -0.1f, 0.0f }; if ( mode == GL_OBJECT_LINEAR ) { glTexGenfv(GL_S, GL_OBJECT_PLANE, ( s ? s : fS ) ); glTexGenfv(GL_T, GL_OBJECT_PLANE, ( t ? t : fT ) ); } else if ( mode == GL_EYE_LINEAR ) { glTexGenfv(GL_S, GL_EYE_PLANE, ( s ? s : fS ) ); glTexGenfv(GL_T, GL_EYE_PLANE, ( t ? t : fT ) ); } // Turn on the coordinate generation, // DON'T FORGET TO SWITCH THIS OFF AFTER RENDERING !!! glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); } void RGL::texGenOff() { glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); } bool RGL::texIsResident(unsigned int id) { unsigned char res=false; glAreTexturesResident( 1, &id, &res ); return (res!=0); } long RGL::texMaxSize() { int s=0; glGetIntegerv( GL_MAX_TEXTURE_SIZE, &s ); return s; } long RGL::texProxyMem() { int w = 1; int ok = 1; while ( ok ) { glTexImage2D( GL_PROXY_TEXTURE_2D, 0, GL_RGBA, w, w, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0 ); glGetTexLevelParameteriv( GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &ok ); if ( checkError() ) break; w <<= 1; } return w*w*4; } int RGL::texChecker( int size, int tile ) { unsigned char *pix = new unsigned char[ size* size* 3]; unsigned char *d = pix; for ( int i = 0; i < size; i++) { for ( int j = 0; j < size; j++) { unsigned char c = ((((i&tile)==0)^((j&tile)==0)))*255; *d++ = 0xff; *d++ = c; *d++ = c; } } return RGL::texCreate( size,size,3,pix, 1, 1 ); } ////////////////////////////////////////////////////////////////////////////// // font ////////////////////////////////////////////////////////////////////////////// unsigned int RGL::setFont(unsigned int fSize, const char * fName) { #ifdef _WIN32 LOGFONT lf; ZeroMemory(&lf, sizeof(lf)); lstrcpy(lf.lfFaceName, fName ); lf.lfHeight = fSize; lf.lfWeight = 100;//FW_HEAVY; //lf.lfItalic = TRUE; //lf.lfUnderline = TRUE; HFONT font = CreateFontIndirect(&lf); if ( font ) { HDC dc = wglGetCurrentDC(); SelectObject( dc, font ); //SendMessage( GetActiveWindow(), WM_SETFONT, (WPARAM)font, 1 ); gl_font_base = glGenLists(256); wglUseFontBitmaps(dc, 0, 255, gl_font_base); return true; } #endif return gl_font_base; } unsigned int RGL::makeRasterFont() { // private bitmap table (pbm) // only big letterz A-Z ! static unsigned char letters[][13] = { {0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18}, {0x00, 0x00, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe}, {0x00, 0x00, 0x7e, 0xe7, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e}, {0x00, 0x00, 0xfc, 0xce, 0xc7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc7, 0xce, 0xfc}, {0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xff}, {0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xff}, {0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xcf, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e}, {0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3}, {0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e}, {0x00, 0x00, 0x7c, 0xee, 0xc6, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06}, {0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xe0, 0xf0, 0xd8, 0xcc, 0xc6, 0xc3}, {0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0}, {0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xdb, 0xff, 0xff, 0xe7, 0xc3}, {0x00, 0x00, 0xc7, 0xc7, 0xcf, 0xcf, 0xdf, 0xdb, 0xfb, 0xf3, 0xf3, 0xe3, 0xe3}, {0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xe7, 0x7e}, {0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe}, {0x00, 0x00, 0x3f, 0x6e, 0xdf, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c}, {0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe}, {0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0x7e, 0xe0, 0xc0, 0xc0, 0xe7, 0x7e}, {0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff}, {0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3}, {0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3}, {0x00, 0x00, 0xc3, 0xe7, 0xff, 0xff, 0xdb, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3}, {0x00, 0x00, 0xc3, 0x66, 0x66, 0x3c, 0x3c, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3}, {0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3}, {0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30, 0x7e, 0x0c, 0x06, 0x03, 0x03, 0xff}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // space {0x00, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x7c, 0x3c, 0x1c, 0x00}, // 1 {0x00, 0x00, 0x7e, 0x7e, 0x30, 0x18, 0x0e, 0x06, 0x06, 0x4c, 0x38, 0x30, 0x00}, // 2 {0x00, 0x00, 0x78, 0x7c, 0x0c, 0x1c, 0x38, 0x1c, 0x4c, 0x3c, 0x38, 0x00, 0x00} // 3 }; glPixelStorei(GL_UNPACK_ALIGNMENT, 1); GLuint fontOffset = glGenLists (128); GLuint i, j; for (i = 0,j = 'A'; i < 30; i++,j++) { glNewList(fontOffset + j, GL_COMPILE); glColor3f( 1.0f, 1.0f, 1.0f ); glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, letters[i]); glEndList(); } return fontOffset; } int RGL::screenShot (char *fName, int w, int h) { //FIXME! w -= (w%4); //w = 256; //h = 256; unsigned int size = w * h * 3; unsigned char *fBuffer = new unsigned char [ size ]; if (fBuffer == NULL) return 0; // glPixelStorei(GL_UNPACK_ALIGNMENT, 4); glReadPixels (0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, fBuffer); //unsigned char header[] = "\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00"; //unsigned char info[6] = { w, (w >> 8), h, (h >> 8), 24, 0 }; FILE *ppm = fopen (fName, "wb"); fprintf( ppm, "P6\n# SCREENDUMP\n%d %d \n255\n", w, h ); //fwrite (header, sizeof (char), 12, s); //fwrite (info, sizeof (char), 6, s); /* unsigned char *p = fBuffer; for (unsigned int i=0; i<size; i+=3) { unsigned char temp = p[i]; p[i] = p[i + 2]; p[i + 2] = temp; }*/ // dump the image data to the file fwrite (fBuffer, sizeof (char), size, ppm); fclose (ppm); delete [] fBuffer; return size; }
[ [ [ 1, 734 ] ] ]
b97799be0473cc94f86b34cab59f025c11a8f339
4b0f51aeecddecf3f57a29ffa7a184ae48f1dc61
/CleanProject/ParticleUniverse/include/ParticleAffectors/ParticleUniverseColourAffectorFactory.h
f431e65fad84bb60836a230e7dd3ede3a8c9886b
[]
no_license
bahao247/apeengine2
56560dbf6d262364fbc0f9f96ba4231e5e4ed301
f2617b2a42bdf2907c6d56e334c0d027fb62062d
refs/heads/master
2021-01-10T14:04:02.319337
2009-08-26T08:23:33
2009-08-26T08:23:33
45,979,392
0
1
null
null
null
null
UTF-8
C++
false
false
1,806
h
/* ----------------------------------------------------------------------------- This source file is part of the Particle Universe product. Copyright (c) 2006-2008 Henry van Merode Usage of this program is free for non-commercial use and licensed under the the terms of the GNU Lesser General Public License. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt. ----------------------------------------------------------------------------- */ #ifndef __PU_COLOUR_AFFECTOR_FACTORY_H__ #define __PU_COLOUR_AFFECTOR_FACTORY_H__ #include "ParticleUniversePrerequisites.h" #include "ParticleUniverseColourAffectorTokens.h" #include "ParticleUniverseColourAffector.h" #include "ParticleUniverseAffectorFactory.h" namespace ParticleUniverse { /** Factory class responsible for creating the ColourAffector. */ class _ParticleUniverseExport ColourAffectorFactory : public ParticleAffectorFactory { public: ColourAffectorFactory(void) {}; virtual ~ColourAffectorFactory(void) {}; /** See ParticleAffectorFactory */ Ogre::String getAffectorType() const { return "Colour"; } /** See ParticleAffectorFactory */ ParticleAffector* createAffector(void) { return _createAffector<ColourAffector>(); } /** See ParticleAffectorFactory */ virtual void setupTokenDefinitions(ITokenRegister* tokenRegister) { // Delegate to mColourAffectorTokens mColourAffectorTokens.setupTokenDefinitions(tokenRegister); } protected: ColourAffectorTokens mColourAffectorTokens; }; } #endif
[ "pablosn@06488772-1f9a-11de-8b5c-13accb87f508" ]
[ [ [ 1, 59 ] ] ]
80a657484b926e9dc17b5fbb446257dbb97e339d
cd0987589d3815de1dea8529a7705caac479e7e9
/webkit/WebKit2/UIProcess/WebNavigationData.h
f55cd77dc554bd6b13a78e51e7f08047fa7496a4
[]
no_license
azrul2202/WebKit-Smartphone
0aab1ff641d74f15c0623f00c56806dbc9b59fc1
023d6fe819445369134dee793b69de36748e71d7
refs/heads/master
2021-01-15T09:24:31.288774
2011-07-11T11:12:44
2011-07-11T11:12:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,181
h
/* * Copyright (C) 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 WebNavigationData_h #define WebNavigationData_h #include "APIObject.h" #include "WebNavigationDataStore.h" #include <wtf/PassRefPtr.h> namespace WebKit { class WebNavigationData : public APIObject { public: static const Type APIType = TypeNavigationData; static PassRefPtr<WebNavigationData> create(const WebNavigationDataStore& store) { return adoptRef(new WebNavigationData(store)); } ~WebNavigationData(); WTF::String title() const { return m_store.title; } WTF::String url() const { return m_store.url; } private: WebNavigationData(const WebNavigationDataStore&); virtual Type type() const { return APIType; } WebNavigationDataStore m_store; }; } // namespace WebKit #endif // WebNavigationData_h
[ [ [ 1, 58 ] ] ]
8d09c6e1b4b0f6ae9fe0c4532f2d68c5fa22f513
5b61b21b4ee18488e9bc1074ea32ed20c62f9633
/ExploreDirectories/explore.h
36c52002b479fe97397567970d27bfef41e952e5
[]
no_license
mohammadharisbaig/opencv-kinect
ca8905e0c32b65b6410adf2a73e70562f1633fb0
e1dab326d44351da8dec4fa11a8ad1cb65dcfdcb
refs/heads/master
2016-09-06T17:33:51.809798
2011-09-01T21:22:55
2011-09-01T21:22:55
32,089,782
0
1
null
null
null
null
UTF-8
C++
false
false
1,885
h
#ifndef _EXPLORE_H_ #define _EXPLORE_H_ #include <string> #include <vector> #include <fstream> #include <dirent.h> #include <cstring> #include <iostream> #include "simplewriter.h" class Explore { // Class is designed to explore all the subdirectories of any parent directory for files // Is very useful in obtaining list of different files of same type to be used for batch processing a datasets private: // Variables used by the class include // 1- initialPath denotes the root directory whose contents we would like to search // 2- directoryMap is a container of all the directories that are contained in the parent directory and its subdirectories // 3- fileMap is a container for all the files that are contained within this directory and all its subdirectories // 4- numberOfFiles read is a container of the number of Files in the directory and all its sub directories // 5- fileWriter is a writer for simple files used to output details to a file for later reading std::string initialPath; std::vector<std::string> fileMap; std::vector<std::string> directoryMap; int numberOfFilesRead; int numberOfDirectoriesRead; SimpleWriter fileWriter; // Internal functions // Main function for reading void readDirectory(std::string currentDirectoryPath); // Determines if the current entry being read is a directory or not bool isDirectory(std::string directoryPath); public: // Constructor Explore(std::string rootDirectory); // Destructor ~Explore(); // Obtain List Methods std::vector<std::string> getFilesList(std::string extension,std::string writePath = ""); std::vector<std::string> getDirectoriesList(std::string writePath = ""); // Read another Directory void readNewDirectory(std::string newPath); }; #endif
[ "[email protected]@b19eb72c-7a23-c4c4-98cb-0a5561f3c209" ]
[ [ [ 1, 64 ] ] ]
77180308b43a5f43d1135acc37ded318246213f0
f55665c5faa3d79d0d6fe91fcfeb8daa5adf84d0
/Depend/MyGUI/MyGUIEngine/include/MyGUI_DeprecatedTypes.h
fbf2ee47cc49ff14cb8595eb57d0755f1ba0cb6f
[]
no_license
lxinhcn/starworld
79ed06ca49d4064307ae73156574932d6185dbab
86eb0fb8bd268994454b0cfe6419ffef3fc0fc80
refs/heads/master
2021-01-10T07:43:51.858394
2010-09-15T02:38:48
2010-09-15T02:38:48
47,859,019
2
1
null
null
null
null
UTF-8
C++
false
false
1,950
h
/*! @file @author Albert Semenov @date 08/2010 */ /* This file is part of MyGUI. MyGUI 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 3 of the License, or (at your option) any later version. MyGUI 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 MyGUI. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __MYGUI_DEPRECATED_TYPES_H__ #define __MYGUI_DEPRECATED_TYPES_H__ namespace MyGUI { template <typename Type> class MemberObsolete { public: }; #ifndef MYGUI_DONT_USE_OBSOLETE typedef Widget* WidgetPtr; typedef Button* ButtonPtr; typedef Window* WindowPtr; typedef List* ListPtr; typedef HScroll* HScrollPtr; typedef VScroll* VScrollPtr; typedef Edit* EditPtr; typedef ComboBox* ComboBoxPtr; typedef StaticText* StaticTextPtr; typedef Tab* TabPtr; typedef TabItem* TabItemPtr; typedef Progress* ProgressPtr; typedef ItemBox* ItemBoxPtr; typedef MultiList* MultiListPtr; typedef StaticImage* StaticImagePtr; typedef Message* MessagePtr; typedef MenuCtrl* MenuCtrlPtr; typedef MenuItem* MenuItemPtr; typedef PopupMenu* PopupMenuPtr; typedef MenuBar* MenuBarPtr; typedef ScrollView* ScrollViewPtr; typedef DDContainer* DDContainerPtr; typedef Canvas* CanvasPtr; typedef ListCtrl* ListCtrlPtr; typedef ListBox* ListBoxPtr; typedef TabItem Sheet; typedef TabItem* SheetPtr; typedef Canvas RenderBox; typedef Canvas* RenderBoxPtr; #endif // MYGUI_DONT_USE_OBSOLETE } // namespace MyGUI #endif // __MYGUI_DEPRECATED_TYPES_H__
[ "albertclass@a94d7126-06ea-11de-b17c-0f1ef23b492c" ]
[ [ [ 1, 70 ] ] ]
af6cec050a035a2adaa79b10f3f35639f35d7bc1
59abf9cf4595cc3d2663fcb38bacd328ab6618af
/3Party/squirrel/sqstdlib/sqstdsystem.cpp
e959c7eae50803b78de81bd8ea562bd273a7d7b4
[]
no_license
DrDrake/mcore3d
2ce53148ae3b9c07a3d48b15b3f1a0eab7846de6
0bab2c59650a815d6a5b581a2c2551d0659c51c3
refs/heads/master
2021-01-10T17:08:00.014942
2011-03-18T09:16:28
2011-03-18T09:16:28
54,134,775
0
0
null
null
null
null
UTF-8
C++
false
false
3,379
cpp
/* see copyright notice in squirrel.h */ #include "../squirrel.h" #include <time.h> #include <stdlib.h> #include <stdio.h> #include "../sqstdsystem.h" #ifdef SQUNICODE #include <wchar.h> #define scgetenv _wgetenv #define scsystem _wsystem #define scasctime _wasctime #define scremove _wremove #define screname _wrename #else #define scgetenv getenv #define scsystem system #define scasctime asctime #define scremove remove #define screname rename #endif static SQInteger _system_getenv(HSQUIRRELVM v) { const SQChar *s; if(SQ_SUCCEEDED(sq_getstring(v,2,&s))){ sq_pushstring(v,scgetenv(s),-1); return 1; } return 0; } static SQInteger _system_system(HSQUIRRELVM v) { const SQChar *s; if(SQ_SUCCEEDED(sq_getstring(v,2,&s))){ sq_pushinteger(v,scsystem(s)); return 1; } return sq_throwerror(v,_SC("wrong param")); } static SQInteger _system_clock(HSQUIRRELVM v) { sq_pushfloat(v,((SQFloat)clock())/(SQFloat)CLOCKS_PER_SEC); return 1; } static SQInteger _system_time(HSQUIRRELVM v) { time_t t; time(&t); sq_pushinteger(v,*((SQInteger *)&t)); return 1; } static SQInteger _system_remove(HSQUIRRELVM v) { const SQChar *s; sq_getstring(v,2,&s); if(scremove(s)==-1) return sq_throwerror(v,_SC("remove() failed")); return 0; } static SQInteger _system_rename(HSQUIRRELVM v) { const SQChar *oldn,*newn; sq_getstring(v,2,&oldn); sq_getstring(v,3,&newn); if(screname(oldn,newn)==-1) return sq_throwerror(v,_SC("rename() failed")); return 0; } static void _set_integer_slot(HSQUIRRELVM v,const SQChar *name,SQInteger val) { sq_pushstring(v,name,-1); sq_pushinteger(v,val); sq_rawset(v,-3); } static SQInteger _system_date(HSQUIRRELVM v) { time_t t; SQInteger it; SQInteger format = 'l'; if(sq_gettop(v) > 1) { sq_getinteger(v,2,&it); t = it; if(sq_gettop(v) > 2) { sq_getinteger(v,3,(SQInteger*)&format); } } else { time(&t); } tm *date; if(format == 'u') date = gmtime(&t); else date = localtime(&t); if(!date) return sq_throwerror(v,_SC("crt api failure")); sq_newtable(v); _set_integer_slot(v, _SC("sec"), date->tm_sec); _set_integer_slot(v, _SC("min"), date->tm_min); _set_integer_slot(v, _SC("hour"), date->tm_hour); _set_integer_slot(v, _SC("day"), date->tm_mday); _set_integer_slot(v, _SC("month"), date->tm_mon); _set_integer_slot(v, _SC("year"), date->tm_year+1900); _set_integer_slot(v, _SC("wday"), date->tm_wday); _set_integer_slot(v, _SC("yday"), date->tm_yday); return 1; } #define _DECL_FUNC(name,nparams,pmask) {_SC(#name),_system_##name,nparams,pmask} static SQRegFunction systemlib_funcs[]={ _DECL_FUNC(getenv,2,_SC(".s")), _DECL_FUNC(system,2,_SC(".s")), _DECL_FUNC(clock,0,NULL), _DECL_FUNC(time,1,NULL), _DECL_FUNC(date,-1,_SC(".nn")), _DECL_FUNC(remove,2,_SC(".s")), _DECL_FUNC(rename,3,_SC(".ss")), {0,0} }; SQInteger sqstd_register_systemlib(HSQUIRRELVM v) { SQInteger i=0; while(systemlib_funcs[i].name!=0) { sq_pushstring(v,systemlib_funcs[i].name,-1); sq_newclosure(v,systemlib_funcs[i].f,0); sq_setparamscheck(v,systemlib_funcs[i].nparamscheck,systemlib_funcs[i].typemask); sq_setnativeclosurename(v,-1,systemlib_funcs[i].name); sq_createslot(v,-3); i++; } return 1; }
[ "mtlung@080b3119-2d51-0410-af92-4d39592ae298" ]
[ [ [ 1, 147 ] ] ]
e3eb5a3f642a1009f75c3fd235bc490f3e3c7cb8
b822313f0e48cf146b4ebc6e4548b9ad9da9a78e
/Dependencies/PackFileSystem/include/LockedZipDataStream.h
722a57e5a3a85d0bb4d7a2f9206d3bfccda644cd
[]
no_license
dzw/kylin001v
5cca7318301931bbb9ede9a06a24a6adfe5a8d48
6cec2ed2e44cea42957301ec5013d264be03ea3e
refs/heads/master
2021-01-10T12:27:26.074650
2011-05-30T07:11:36
2011-05-30T07:11:36
46,501,473
0
0
null
null
null
null
UTF-8
C++
false
false
1,591
h
#ifndef _LockedZipDataStream_H__ #define _LockedZipDataStream_H__ #include "OgreDataStream.h" //#include "OgreNoMemoryMacros.h" #include "ZipArchive.h" //#include "OgreMemoryMacros.h" // i have to do this otherwise i get conflicts with std::min // probabily due to redefinition in ziparchive or something #undef min #undef max #include <algorithm> using std::min; using std::max; namespace Ogre { /** Specialisation of DataStream to handle streaming data from locked zip archives. */ class LockedZipDataStream : public DataStream { protected: /// ZipArchive memory file CZipMemFile* m_zipFile; /// Temporary zip copy area char mZipTmpArea[OGRE_STREAM_TEMP_SIZE]; public: ///// Unnamed constructor //LockedZipDataStream(FILE* zzipFile, size_t uncompressedSize); /// Constructor for creating named streams LockedZipDataStream::LockedZipDataStream(const String& name, CZipMemFile* zipMemoryFile, size_t uncompressedSize); ~LockedZipDataStream(); /// @copydoc DataStream::read size_t read(void* buf, size_t count); /// @copydoc DataStream::read size_t readLine(char* buf, size_t maxCount, const String& delim = "\n"); /// @copydoc DataStream::skipLine size_t skipLine(const String& delim = "\n"); /// @copydoc DataStream::skip void skip(long count); /// @copydoc DataStream::seek void seek( size_t pos ); /// @copydoc DataStream::tell size_t tell(void) const; /// @copydoc DataStream::eof bool eof(void) const; /// @copydoc DataStream::close void close(void); }; } #endif
[ [ [ 1, 57 ] ] ]
2c480069bc41e2ee316030936a225fbdaa23bf21
97335be47ec517de6739eb4a803d0df2b08f9ee0
/inc/Geocaching_SampleProject.h
3c681001eccf0711e1f3107051555dda31ff908b
[]
no_license
idaohang/Geocaching_SampleProject
40e5015a1ec18aee9f475c6cb7ee6514d4863055
103c96ce471a01ca1b226271b3c47cbb411e1b95
refs/heads/master
2020-03-31T16:27:08.662898
2011-08-16T16:37:38
2011-08-16T16:37:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,570
h
#ifndef _GEOCACHING_SAMPLEPROJECT_H_ #define _GEOCACHING_SAMPLEPROJECT_H_ #include <FApp.h> #include <FBase.h> #include <FSystem.h> #include <FUi.h> /** * [Geocaching_SampleProject] application must inherit from Application class * which provides basic features necessary to define an application. */ class Geocaching_SampleProject : public Osp::App::Application, public Osp::System::IScreenEventListener { public: /** * [Geocaching_SampleProject] application must have a factory method that creates an instance of itself. */ static Osp::App::Application* CreateInstance(void); public: Geocaching_SampleProject(); ~Geocaching_SampleProject(); public: // Called when the application is initializing. bool OnAppInitializing(Osp::App::AppRegistry& appRegistry); // Called when the application is terminating. bool OnAppTerminating(Osp::App::AppRegistry& appRegistry, bool forcedTermination = false); // Called when the application's frame moves to the top of the screen. void OnForeground(void); // Called when this application's frame is moved from top of the screen to the background. void OnBackground(void); // Called when the system memory is not sufficient to run the application any further. void OnLowMemory(void); // Called when the battery level changes. void OnBatteryLevelChanged(Osp::System::BatteryLevel batteryLevel); // Called when the screen turns on. void OnScreenOn (void); // Called when the screen turns off. void OnScreenOff (void); }; #endif
[ [ [ 1, 60 ] ] ]
e4f444a8a2eb54501a91c52a5a9b2cfe4180e4da
cd0987589d3815de1dea8529a7705caac479e7e9
/webkit/WebKit/win/WebKitPrefix.h
ffbbf8afb9a18f8c0042df5d0a1069d4580b719c
[ "BSD-2-Clause" ]
permissive
azrul2202/WebKit-Smartphone
0aab1ff641d74f15c0623f00c56806dbc9b59fc1
023d6fe819445369134dee793b69de36748e71d7
refs/heads/master
2021-01-15T09:24:31.288774
2011-07-11T11:12:44
2011-07-11T11:12:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,060
h
/* * Copyright (C) 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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 _WIN32_WINNT #define _WIN32_WINNT 0x0500 #endif #ifndef WINVER #define WINVER 0x0500 #endif // If we don't define these, they get defined in windef.h. // We want to use std::min and std::max. #ifndef max #define max max #endif #ifndef min #define min min #endif #ifndef _WINSOCKAPI_ #define _WINSOCKAPI_ // Prevent inclusion of winsock.h in windows.h #endif #include <CoreFoundation/CoreFoundation.h> #include <WebKit/WebKit.h>
[ [ [ 1, 51 ] ] ]
0e5b604e0a923325ea3c6b98c8d495f7a88fecbe
2d212a074917aad8c57ed585e6ce8e2073aa06c6
/cgworkshop/src/GUI/TypeDefs.h
cc75ad52775574d3d064a3ada8931f4733a161d4
[]
no_license
morsela/cgworkshop
b31c9ec39419edcedfaed81468c923436528e538
cdf9ef2a9b2d9c389279fe0e38fb9c8bc1d86d89
refs/heads/master
2021-07-29T01:37:24.739450
2007-09-09T13:44:54
2007-09-09T13:44:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
203
h
#ifndef _H_TYPEDEFS_H #define _H_TYPEDEFS_H #include <vector> #include "Scribble.h" #define SCRIBBLE_NUMBER 10 typedef std::vector< CScribble > ScribbleVector; #endif // _H_TYPEDEFS_H
[ "morsela@60b542fb-872c-0410-bfbb-43802cb78f6e", "ikirsh@60b542fb-872c-0410-bfbb-43802cb78f6e" ]
[ [ [ 1, 12 ] ], [ [ 13, 13 ] ] ]
7993938a50027bdb242da7b228ca3ade247a482e
0f3224fcbe7dbfddb1a98f75762a48cd1cfdbf07
/src/ai.cpp
a00053a9c13f8b2e979b77fda117e2f67f74dd8d
[]
no_license
Karethoth/LudumDare20
a534972c3669d7612bbcf60270894156e485e1f4
0b5c3f50a1178f37ac5dee9e185700ba081378d5
refs/heads/master
2020-05-27T17:06:16.673518
2011-05-01T23:37:16
2011-05-01T23:37:16
1,683,324
0
0
null
null
null
null
UTF-8
C++
false
false
2,521
cpp
#include "ai.hpp" void MainCharacterAI( NPC *me ) { map.Draw( window, Coord( 0, 0 ) ); if( gameState == mainGame ) { FollowPlayerAI( me ); } else if( me->location.x == me->goal.x && me->location.y == me->goal.y ) { if( me->waypoint == 0 ) { if( IntroOver() ) me->waypoint++; } else if( me->waypoint == 1 ) { if( StartMainGame() ) me->waypoint++; } else if( me->waypoint == 2 ) { messageBox.message[0] = "King: That's a good son. You'll make a great king someday."; messageBox.message[2] = "->"; messageBox.Draw(); refresh(); wrefresh( messageBox.window ); getch(); EndGame(); } } else { Direction d = NextMove( me->location, me->goal ); me->location = DirectionToCoord( me->location, d ); } map.Draw( window, Coord( 0, 0 ) ); } void StationaryNPCAI( NPC *me ) { } void FollowPlayerAI( NPC *me ) { Coord tgt = player->location; // A hack to make this work. player->location = Coord( 0, 0 ); Direction d = NextMove( me->location, tgt ); Coord next = DirectionToCoord( me->location, d ); player->location = tgt; if( next.x == tgt.x && next.y == tgt.y ) { vector<Coord> neighbours = Neighbours( me->location ); int max = neighbours.size(); if( max ) { int next = rand() % max; me->location = neighbours.at( next ); } } else { me->location = next; } } void MonsterAI( NPC *me ) { if( !me->alive ) { return; } if( me->hostile ) { // Check who's closer, main character or player int deltaMain = Heuristic( me->location, mainCharacter->location ); int deltaPlayer = Heuristic( me->location, player->location ); // Side note: this might lead to some interesting behaviour.. Coord target = deltaPlayer <= deltaMain ? player->location : mainCharacter->location; Entity *targetEntity = deltaPlayer <= deltaMain ? (Entity*)player : mainCharacter; // If we can attack the target.. if( Heuristic( me->location, target ) <= me->stats.attackRange ) { Attack( me, targetEntity ); } // If we can't attack, move closer if we can see the player else { me->goal = target; if( Heuristic( me->location, target ) <= me->stats.sight ) { targetEntity->location = Coord( 0,0 ); Direction d = NextMove( me->location, target ); me->location = DirectionToCoord( me->location, d ); targetEntity->location = target; } } } else { } }
[ [ [ 1, 121 ] ] ]
50ca6e3f28972b2f3a1ed51aab140b3ce486bd82
36bf908bb8423598bda91bd63c4bcbc02db67a9d
/SelfExtractor/include/SelfExtractorDlg.h
59fed9ab8a6888a6a9aa28826d638b4b0b430579
[]
no_license
code4bones/crawlpaper
edbae18a8b099814a1eed5453607a2d66142b496
f218be1947a9791b2438b438362bc66c0a505f99
refs/heads/master
2021-01-10T13:11:23.176481
2011-04-14T11:04:17
2011-04-14T11:04:17
44,686,513
0
1
null
null
null
null
UTF-8
C++
false
false
1,484
h
/* James Spibey, 04/08/1998 [email protected] You are free to use, distribute or modify this code as long as this header is not removed or modified. ------------------------------------------------------- Added support for file compression through the GZW API. More changes. Luca Piergentili, 24/08/00 [email protected] */ #ifndef _SELF_EXTRACTOR_H #define _SELF_EXTRACTOR_H 1 #include "window.h" #include "CSelfExtractor.h" #include "CSEFileInfo.h" #include "CDirDialog.h" #include "CTextProgressCtrl.h" #include "resource.h" class CSelfExtractorDlg : public CDialog { public: CSelfExtractorDlg(CWnd* pParent = NULL); enum { IDD = IDD_SELFEXTRACTOR_DIALOG }; CString GetWorkingDir(BOOL withBackSlash = FALSE); void UpdateList(); static UINT AddCallBack(LPVOID CallbackData,LPVOID UserData); CSelfExtractor m_Extractor; CString m_strWorkingDir; CTextProgressCtrl m_Progress; CListCtrl m_List; CString m_strExePath; CString m_strExtractorPath; CString m_strCurrFile; protected: void DoDataExchange(CDataExchange* pDX); HICON m_hIcon; BOOL OnInitDialog(void); void OnPaint(void); HCURSOR OnQueryDragIcon(void); void OnBrowseExtractor(void); void OnReadExtractor(void); void OnBrowseExe(void); void OnCreateExe(void); void OnAddFile(void); void OnAddScript(void); void OnClearList(void); DECLARE_MESSAGE_MAP() }; #endif // _SELF_EXTRACTOR_H
[ [ [ 1, 64 ] ] ]
a09bbb4d1acd508294148ce7370790be5d9fb1ab
b14d5833a79518a40d302e5eb40ed5da193cf1b2
/cpp/extern/xercesc++/2.6.0/src/xercesc/util/NetAccessors/MacOSURLAccessCF/MacOSURLAccessCF.cpp
856ec3d883bf1335bc6eb528edb04015aadc151e
[ "Apache-2.0" ]
permissive
andyburke/bitflood
dcb3fb62dad7fa5e20cf9f1d58aaa94be30e82bf
fca6c0b635d07da4e6c7fbfa032921c827a981d6
refs/heads/master
2016-09-10T02:14:35.564530
2011-11-17T09:51:49
2011-11-17T09:51:49
2,794,411
1
0
null
null
null
null
UTF-8
C++
false
false
1,832
cpp
/* * Copyright 1999-2000,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * $Id: MacOSURLAccessCF.cpp,v 1.5 2004/09/08 13:56:34 peiyongz Exp $ */ #include <xercesc/util/XMLUni.hpp> #include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/XMLString.hpp> #include <xercesc/util/XMLExceptMsgs.hpp> #include <xercesc/util/NetAccessors/MacOSURLAccessCF/MacOSURLAccessCF.hpp> #include <xercesc/util/NetAccessors/MacOSURLAccessCF/URLAccessCFBinInputStream.hpp> XERCES_CPP_NAMESPACE_BEGIN const XMLCh MacOSURLAccessCF::sMyID[] = { chLatin_M, chLatin_a, chLatin_c, chLatin_O, chLatin_S, chLatin_U, chLatin_R, chLatin_L, chLatin_A, chLatin_c, chLatin_c, chLatin_e, chLatin_s, chLatin_s, chLatin_C, chLatin_F, chNull }; MacOSURLAccessCF::MacOSURLAccessCF() { } MacOSURLAccessCF::~MacOSURLAccessCF() { } BinInputStream* MacOSURLAccessCF::makeNew(const XMLURL& urlSource, const XMLNetHTTPInfo* httpInfo/*=0*/) { if(httpInfo!=0 && httpInfo->fHTTPMethod!=XMLNetHTTPInfo::GET) ThrowXML(NetAccessorException, XMLExcepts::NetAcc_UnsupportedMethod); BinInputStream* result = new (urlSource.getMemoryManager()) URLAccessCFBinInputStream(urlSource); return result; } XERCES_CPP_NAMESPACE_END
[ [ [ 1, 61 ] ] ]