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
11514055b86115190c0ce5f8a46bbc64e427a6fd
3472e587cd1dff88c7a75ae2d5e1b1a353962d78
/test/TestBoost/src/common.h
5ae940d6f6450fe6e503b413e2023e786ac6cd41
[]
no_license
yewberry/yewtic
9624d05d65e71c78ddfb7bd586845e107b9a1126
2468669485b9f049d7498470c33a096e6accc540
refs/heads/master
2021-01-01T05:40:57.757112
2011-09-14T12:32:15
2011-09-14T12:32:15
32,363,059
0
0
null
null
null
null
UTF-8
C++
false
false
157
h
#include <string> #include <iostream> #include <iomanip> #include <numeric> #include <assert.h> #include <boost/foreach.hpp> using namespace std;
[ "yew1998@5ddc4e96-dffd-11de-b4b3-6d349e4f6f86" ]
[ [ [ 1, 9 ] ] ]
279c739faf21a301891ea2c72914f76187ab5925
c4001da8f012dfbc46fef0d9c11f8412f4ad9c6f
/allegro/examples/ex_pixelformat.cpp
fbaf600ce632f9e689cd1066f9c2238a24b2c487
[ "Zlib", "BSD-3-Clause" ]
permissive
sesc4mt/mvcdecoder
4602fdfe42ab39706cfa3c749282782ca9da73c9
742a5c0d9cad43f0b01aa6e9169d96a286458e72
refs/heads/master
2021-01-01T17:56:47.666505
2010-11-02T12:36:52
2010-11-02T12:36:52
40,896,775
1
0
null
null
null
null
UTF-8
C++
false
false
6,835
cpp
/* * Simple (incomplete) test of pixel format conversions. * * This should be made comprehensive. */ #include <stdio.h> #include "allegro5/allegro5.h" #include "allegro5/allegro_font.h" #include "allegro5/allegro_image.h" #include "allegro5/allegro_primitives.h" #include "nihgui.hpp" #include "common.c" typedef struct FORMAT { int format; char const *name; } FORMAT; const FORMAT formats[ALLEGRO_NUM_PIXEL_FORMATS] = { {ALLEGRO_PIXEL_FORMAT_ANY, "any"}, {ALLEGRO_PIXEL_FORMAT_ANY_NO_ALPHA, "no alpha"}, {ALLEGRO_PIXEL_FORMAT_ANY_WITH_ALPHA, "alpha"}, {ALLEGRO_PIXEL_FORMAT_ANY_15_NO_ALPHA, "15"}, {ALLEGRO_PIXEL_FORMAT_ANY_16_NO_ALPHA, "16"}, {ALLEGRO_PIXEL_FORMAT_ANY_16_WITH_ALPHA, "16 alpha"}, {ALLEGRO_PIXEL_FORMAT_ANY_24_NO_ALPHA, "24"}, {ALLEGRO_PIXEL_FORMAT_ANY_32_NO_ALPHA, "32"}, {ALLEGRO_PIXEL_FORMAT_ANY_32_WITH_ALPHA, "32 alpha"}, {ALLEGRO_PIXEL_FORMAT_ARGB_8888, "ARGB8888"}, {ALLEGRO_PIXEL_FORMAT_RGBA_8888, "RGBA8888"}, {ALLEGRO_PIXEL_FORMAT_ARGB_4444, "ARGB4444"}, {ALLEGRO_PIXEL_FORMAT_RGB_888, "RGB888"}, {ALLEGRO_PIXEL_FORMAT_RGB_565, "RGB565"}, {ALLEGRO_PIXEL_FORMAT_RGB_555, "RGB555"}, {ALLEGRO_PIXEL_FORMAT_RGBA_5551, "RGBA5551"}, {ALLEGRO_PIXEL_FORMAT_ARGB_1555, "ARGB1555"}, {ALLEGRO_PIXEL_FORMAT_ABGR_8888, "ABGR8888"}, {ALLEGRO_PIXEL_FORMAT_XBGR_8888, "XBGR8888"}, {ALLEGRO_PIXEL_FORMAT_BGR_888, "BGR888"}, {ALLEGRO_PIXEL_FORMAT_BGR_565, "BGR565"}, {ALLEGRO_PIXEL_FORMAT_BGR_555, "BGR555"}, {ALLEGRO_PIXEL_FORMAT_RGBX_8888, "RGBX8888"}, {ALLEGRO_PIXEL_FORMAT_XRGB_8888, "XRGB8888"}, {ALLEGRO_PIXEL_FORMAT_ABGR_F32, "ABGR32F"}, {ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE, "ABGR(LE)"}, {ALLEGRO_PIXEL_FORMAT_RGBA_4444, "RGBA4444"} }; #define NUM_FORMATS ALLEGRO_NUM_PIXEL_FORMATS const char *get_format_name(ALLEGRO_BITMAP *bmp) { if (!bmp) return "none"; int format = al_get_bitmap_format(bmp); for (unsigned i = 0; i < NUM_FORMATS; i++) { if (formats[i].format == format) return formats[i].name; } return "unknown"; } class Prog { private: Dialog d; Label source_label; Label dest_label; List source_list; List dest_list; Label true_formats; ToggleButton use_memory_button; ToggleButton enable_timing_button; Label time_label; public: Prog(const Theme & theme, ALLEGRO_DISPLAY *display); void run(); private: void draw_sample(); }; Prog::Prog(const Theme & theme, ALLEGRO_DISPLAY *display) : d(Dialog(theme, display, 20, 30)), source_label(Label("Source")), dest_label(Label("Destination")), source_list(List()), dest_list(List()), true_formats(Label("")), use_memory_button(ToggleButton("Use memory bitmaps")), enable_timing_button(ToggleButton("Enable timing")), time_label(Label("")) { d.add(source_label, 11, 0, 4, 1); d.add(source_list, 11, 1, 4, 27); d.add(dest_label, 15, 0, 4, 1); d.add(dest_list, 15, 1, 4, 27); d.add(true_formats, 0, 15, 10, 1); d.add(use_memory_button, 0, 17, 10, 2); d.add(enable_timing_button, 0, 19, 10, 2); d.add(time_label, 0, 21, 10, 1); for (unsigned i = 0; i < NUM_FORMATS; i++) { source_list.append_item(formats[i].name); dest_list.append_item(formats[i].name); } } void Prog::run() { d.prepare(); while (!d.is_quit_requested()) { if (d.is_draw_requested()) { al_clear_to_color(al_map_rgb(128, 128, 128)); draw_sample(); d.draw(); al_flip_display(); } d.run_step(true); } } void Prog::draw_sample() { const int i = source_list.get_cur_value(); const int j = dest_list.get_cur_value(); ALLEGRO_BITMAP *bitmap1; ALLEGRO_BITMAP *bitmap2; bool use_memory = use_memory_button.get_pushed(); bool enable_timing = enable_timing_button.get_pushed(); if (use_memory) al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); else al_set_new_bitmap_flags(0); al_set_new_bitmap_format(formats[i].format); bitmap1 = al_load_bitmap("data/allegro.pcx"); if (!bitmap1) { abort_example("Could not load image, bitmap format = %d\n", formats[i].format); printf("Could not load image, bitmap format = %d\n", formats[i].format); } al_set_new_bitmap_format(formats[j].format); bitmap2 = al_create_bitmap(320, 200); if (!bitmap2) { abort_example("Could not create bitmap, format = %d\n", formats[j].format); printf("Could not create bitmap, format = %d\n", formats[j].format); } al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO, al_map_rgb(255, 255, 255)); if (bitmap1 && bitmap2) { al_set_target_bitmap(bitmap2); if (enable_timing) { double t0, t1; char str[256]; int frames = 0; t0 = al_current_time(); printf("Timing...\n"); do { al_draw_bitmap(bitmap1, 0, 0, 0); frames++; t1 = al_current_time(); } while (t1 - t0 < 0.25); printf(" ...done.\n"); sprintf(str, "%.0f FPS", (double)frames / (t1 - t0)); time_label.set_text(str); } else { al_draw_bitmap(bitmap1, 0, 0, 0); time_label.set_text(""); } al_set_target_bitmap(al_get_backbuffer()); al_draw_bitmap(bitmap2, 0, 0, 0); } else { al_draw_line(0, 0, 320, 200, al_map_rgb_f(1, 0, 0), 0); al_draw_line(0, 200, 320, 0, al_map_rgb_f(1, 0, 0), 0); } std::string s = get_format_name(bitmap1); s += " -> "; s += get_format_name(bitmap2); true_formats.set_text(s); al_destroy_bitmap(bitmap1); al_destroy_bitmap(bitmap2); } int main(int argc, char *argv[]) { ALLEGRO_DISPLAY *display; ALLEGRO_FONT *font; (void)argc; (void)argv; if (!al_init()) { abort_example("Could not init Allegro.\n"); return 1; } al_init_image_addon(); al_init_font_addon(); al_install_keyboard(); al_install_mouse(); al_set_new_display_flags(ALLEGRO_GENERATE_EXPOSE_EVENTS); display = al_create_display(640, 480); if (!display) { abort_example("Error creating display\n"); return 1; } //printf("Display format = %d\n", al_get_display_format()); font = al_load_font("data/fixed_font.tga", 0, 0); if (!font) { abort_example("Failed to load data/fixed_font.tga\n"); return 1; } /* Don't remove these braces. */ { Theme theme(font); Prog prog(theme, display); prog.run(); } al_destroy_font(font); return 0; } /* vim: set sts=3 sw=3 et: */
[ "edwardtoday@34199c9c-95aa-5eba-f35a-9ba8a8a04cd7" ]
[ [ [ 1, 253 ] ] ]
ea39e93827468f6105b21a1308131f553c34a94a
38d9a3374e52b67ca01ed8bbf11cd0b878cce2a5
/trunk/tbeta/OSX/addons/ofxNCore/src/Communication/TUIO.cpp
b6db6ffe2465753a6d91f136f8b6cd259b36ec47
[]
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
5,630
cpp
/* * TUIO.h * * * Created on 2/2/09. * Copyright 2009 NUI Group\Inc.. All rights reserved. * */ #include "TUIO.h" TUIO::TUIO() { } TUIO::~TUIO() { // this could be useful for whenever we get rid of an object } void TUIO::setup(const char* host, int port, int flashport) { localHost = host; TUIOPort = port; TUIOFlashPort = flashport; frameseq = 0; //FOR TCP bIsConnected = m_tcpServer.setup(TUIOFlashPort); //FOR OSC TUIOSocket.setup(localHost, TUIOPort); } void TUIO::sendTUIO(std::map<int, Blob> * blobs) { frameseq += 1; //if sending OSC (not TCP) if(bOSCMode){ ofxOscBundle b; if(blobs->size() == 0) { //Sends alive message - saying 'Hey, there's no alive blobs' ofxOscMessage alive; alive.setAddress("/tuio/2Dcur"); alive.addStringArg("alive"); //Send fseq message ofxOscMessage fseq; fseq.setAddress( "/tuio/2Dcur" ); fseq.addStringArg( "fseq" ); fseq.addIntArg(frameseq); b.addMessage( alive ); //add message to bundle b.addMessage( fseq ); //add message to bundle TUIOSocket.sendBundle( b ); //send bundle } else //actually send the blobs { map<int, Blob>::iterator this_blob; for(this_blob = blobs->begin(); this_blob != blobs->end(); this_blob++) { //Set Message ofxOscMessage set; set.setAddress("/tuio/2Dcur"); set.addStringArg("set"); set.addIntArg(this_blob->second.id); //id set.addFloatArg(this_blob->second.centroid.x); // x set.addFloatArg(this_blob->second.centroid.y); // y set.addFloatArg(this_blob->second.D.x); //dX set.addFloatArg(this_blob->second.D.y); //dY set.addFloatArg(this_blob->second.maccel); //m if(bHeightWidth){ set.addFloatArg(this_blob->second.boundingRect.width); // wd set.addFloatArg(this_blob->second.boundingRect.height);// ht } b.addMessage( set ); //add message to bundle } //Send alive message of all alive IDs ofxOscMessage alive; alive.setAddress("/tuio/2Dcur"); alive.addStringArg("alive"); std::map<int, Blob>::iterator this_blobID; for(this_blobID = blobs->begin(); this_blobID != blobs->end(); this_blobID++) { alive.addIntArg(this_blobID->second.id); //Get list of ALL active IDs } //Send fseq message ofxOscMessage fseq; fseq.setAddress( "/tuio/2Dcur" ); fseq.addStringArg( "fseq" ); fseq.addIntArg(frameseq); b.addMessage( alive ); //add message to bundle b.addMessage( fseq ); //add message to bundle TUIOSocket.sendBundle( b ); //send bundle } }else if(bTCPMode) //else, if TCP (flash) mode { if(blobs->size() == 0){ m_tcpServer.sendToAll("<OSCPACKET ADDRESS=\"127.0.0.1\" PORT=\""+ofToString(TUIOPort)+"\" TIME=\""+ofToString(ofGetElapsedTimef())+"\">" + "<MESSAGE NAME=\"/tuio/2Dcur\">"+ "<ARGUMENT TYPE=\"s\" VALUE=\"alive\"/>"+ "</MESSAGE>"+ "<MESSAGE NAME=\"/tuio/2Dcur\">"+ "<ARGUMENT TYPE=\"s\" VALUE=\"fseq\"/>"+ "<ARGUMENT TYPE=\"i\" VALUE=\""+ofToString(frameseq)+"\"/>" + "</MESSAGE>"+ "</OSCPACKET>"); } else { string setBlobsMsg; map<int, Blob>::iterator this_blob; for(this_blob = blobs->begin(); this_blob != blobs->end(); this_blob++) { //if sending height and width if(bHeightWidth){ setBlobsMsg += "<MESSAGE NAME=\"/tuio/2Dcur\"><ARGUMENT TYPE=\"s\" VALUE=\"set\"/><ARGUMENT TYPE=\"i\" VALUE=\""+ofToString(this_blob->second.id)+"\"/>"+ "<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.centroid.x)+"\"/>"+ "<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.centroid.y)+"\"/>"+ "<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.D.x)+"\"/>"+ "<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.D.y)+"\"/>"+ "<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.maccel)+"\"/>"+ "<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.boundingRect.width)+"\"/>"+ "<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.boundingRect.height)+"\"/>"+ "</MESSAGE>"; } else{ setBlobsMsg += "<MESSAGE NAME=\"/tuio/2Dcur\"><ARGUMENT TYPE=\"s\" VALUE=\"set\"/><ARGUMENT TYPE=\"i\" VALUE=\""+ofToString(this_blob->second.id)+"\"/>"+ "<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.centroid.x)+"\"/>"+ "<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.centroid.y)+"\"/>"+ "<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.D.x)+"\"/>"+ "<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.D.y)+"\"/>"+ "<ARGUMENT TYPE=\"f\" VALUE=\""+ofToString(this_blob->second.maccel)+"\"/>"+ "</MESSAGE>"; } } string aliveBeginMsg = "<MESSAGE NAME=\"/tuio/2Dcur\"><ARGUMENT TYPE=\"s\" VALUE=\"alive\"/>"; string aliveBlobsMsg; std::map<int, Blob>::iterator this_blobID; for(this_blobID = blobs->begin(); this_blobID != blobs->end(); this_blobID++) { aliveBlobsMsg += "<ARGUMENT TYPE=\"i\" VALUE=\""+ofToString(this_blobID->second.id)+"\"/>"; } string aliveEndMsg = "</MESSAGE>"; string fseq = "<MESSAGE NAME=\"/tuio/2Dcur\"><ARGUMENT TYPE=\"s\" VALUE=\"fseq\"/><ARGUMENT TYPE=\"i\" VALUE=\""+ofToString(frameseq)+"\"/></MESSAGE>"; m_tcpServer.sendToAll("<OSCPACKET ADDRESS=\"127.0.0.1\" PORT=\""+ofToString(TUIOPort)+"\" TIME=\""+ofToString(ofGetElapsedTimef())+"\">" + setBlobsMsg + aliveBeginMsg + aliveBlobsMsg + aliveEndMsg + fseq + "</OSCPACKET>"); } } }
[ "ss@463ed9da-a5aa-4e33-a7e2-2d3b412cff85" ]
[ [ [ 1, 165 ] ] ]
e69ee3b7b54f40a2ff6943eadfa4c55f154dea75
d93e3b7dd398e3aef0588fad27eafb23585bec6b
/Server/ServerDlg.h
2de3791da0765d2d18e764a3eabd49b40a5adf8c
[]
no_license
uwitec/ihcs
9c7168efff68922372272b1627dd7118cafcc675
8418d36a4a072f7a26d81f0c3939b9b214a6d7cc
refs/heads/master
2020-07-07T22:25:24.245803
2011-10-07T08:28:09
2011-10-07T08:28:09
41,098,207
0
0
null
null
null
null
GB18030
C++
false
false
1,739
h
// ServerDlg.h : header file // #if !defined(AFX_SERVERDLG_H__96531D59_ED78_42A4_811A_C40982E2B13B__INCLUDED_) #define AFX_SERVERDLG_H__96531D59_ED78_42A4_811A_C40982E2B13B__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #define WM_RECVDATA WM_USER+1 ///////////////////////////////////////////////////////////////////////////// // CServerDlg dialog class CServerDlg : public CDialog { // Construction public: // void OnRecvData(WPARAM wParam,LPARAM lParam); static DWORD WINAPI RecvProc(LPVOID lpParameter); BOOL InitSocket(); CServerDlg(CWnd* pParent = NULL); // standard constructor // Dialog Data //{{AFX_DATA(CServerDlg) enum { IDD = IDD_SERVER_DIALOG }; CListCtrl m_list; CString m_txtSendMsg; CString m_txtServerPort; //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CServerDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: HICON m_hIcon; // Generated message map functions //{{AFX_MSG(CServerDlg) virtual BOOL OnInitDialog(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); afx_msg void OnButtonSend(); //}}AFX_MSG afx_msg void OnRecvData(WPARAM wParam,LPARAM lParam); DECLARE_MESSAGE_MAP() private: SOCKET m_socket; }; struct RECVPARAM { SOCKET sock; //已创建的套接字 HWND hwnd; //对话窗句柄 }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_SERVERDLG_H__96531D59_ED78_42A4_811A_C40982E2B13B__INCLUDED_)
[ [ [ 1, 66 ] ] ]
9b5d5b4a2886dc2c8bacce592a86cb5a611df64b
5bd189ea897b10ece778fbf9c7a0891bf76ef371
/BasicEngine/BasicEngine/Input/KeyBoard.cpp
2b6de5041fda6480a026dcdb537e8a4f26eb0c38
[]
no_license
boriel/masterullgrupo
c323bdf91f5e1e62c4c44a739daaedf095029710
81b3d81e831eb4d55ede181f875f57c715aa18e3
refs/heads/master
2021-01-02T08:19:54.413488
2011-12-14T22:42:23
2011-12-14T22:42:23
32,330,054
0
0
null
null
null
null
ISO-8859-1
C++
false
false
1,497
cpp
#include <assert.h> #include "KeyBoard.h" #include "InputManager.h" //Inicialicación //Lo primero que se hace es inicializar el array de booleanos a false. Después se crea el objeto teclado y por último se registran los callbacks void cKeyboard::Init() { // Clear the input buffer memset(mabInputBuffer, 0, kuiInputChanelSize); assert(cInputManager::Get().mpOISInputManager); OIS::InputManager* lpOISInputManager = cInputManager::Get().mpOISInputManager; mpOISKeyboard = (OIS::Keyboard*)lpOISInputManager->createInputObject(OIS::OISKeyboard, true); mpOISKeyboard->setEventCallback( this ); mbIsValid = true; } //Destrucción //Simplemente se destruye el objeto y resetean los valores de las variables void cKeyboard::Deinit(void) { assert(cInputManager::Get().mpOISInputManager); cInputManager::Get().mpOISInputManager->destroyInputObject(mpOISKeyboard); mpOISKeyboard = 0; mbIsValid = false; } //Funciones de callbak bool cKeyboard::keyPressed( const OIS::KeyEvent &lArg ) { mabInputBuffer[lArg.key] = true; return true; } //Funciones de callbak bool cKeyboard::keyReleased( const OIS::KeyEvent &lArg ) { mabInputBuffer[lArg.key] = false; return true; } float cKeyboard::Check(unsigned luiEntry) { if (mabInputBuffer[luiEntry]) return 1.0f; return 0.0f; } void cKeyboard::Update(void) { //This fires off buffered events for keyboards assert(mpOISKeyboard); mpOISKeyboard->capture(); }
[ "yormanh@f2da8aa9-0175-0678-5dcd-d323193514b7" ]
[ [ [ 1, 66 ] ] ]
d24ee4dc41deba8a77338e2d05faa517adef9dba
8fcf3f01e46f8933b356f763c61938ab11061a38
/Interface/sources/main.cpp
25b8a1c7f8ed35bb22dff56037e73c55d4ff6561
[]
no_license
jonesbusy/parser-effex
9facab7e0ff865d226460a729f6cb1584e8798da
c8c00e7f9cf360c0f70d86d1929ad5b44c5521be
refs/heads/master
2021-01-01T16:50:16.254785
2011-02-26T22:27:05
2011-02-26T22:27:05
33,957,768
0
0
null
null
null
null
UTF-8
C++
false
false
332
cpp
#include <QApplication> #include "Windows/MainWindow.h" int main(int argc, char* argv[]) { QApplication application(argc, argv); application.setApplicationName("Effex"); application.setOrganizationName("HEIG-VD"); MainWindow mainWindow; mainWindow.show(); return application.exec(); }
[ "jonesbusy@fa255007-c97c-c9ae-ff28-e9f0558300b6" ]
[ [ [ 1, 17 ] ] ]
7947d6cfd48bf0a30fb9a3b5083323a826f3c3d8
1736474d707f5c6c3622f1cd370ce31ac8217c12
/Pseudo/Stream.hpp
cb839418af4ea99927ee72da5a0dceff3d6b6ee6
[]
no_license
arlm/pseudo
6d7450696672b167dd1aceec6446b8ce137591c0
27153e50003faff31a3212452b1aec88831d8103
refs/heads/master
2022-11-05T23:38:08.214807
2011-02-18T23:18:36
2011-02-18T23:18:36
275,132,368
0
0
null
null
null
null
UTF-8
C++
false
false
460
hpp
// Copyright (c) John Lyon-Smith. All rights reserved. #pragma once #pragma warning(push) #include <Pseudo\Compiler.hpp> #include <Pseudo\ValueType.hpp> namespace Pseudo { class Stream { public: Stream() { } public: virtual ~Stream() { } public: virtual void Read(Byte* pBuffer, Int offset, Int count) = 0; public: virtual void Write(Byte* pBuffer, Int offset, Int count) = 0; }; } #pragma warning(pop)
[ [ [ 1, 27 ] ] ]
47aa4ba1a4448a928456895fe05e91b768627888
ea12fed4c32e9c7992956419eb3e2bace91f063a
/zombie/code/zombie/tutorials/src/signals_tutorial/emitter_main.cc
ba0e5f566ac97e396631fa5a2d07ab46b1576fe2
[]
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
115
cc
#include "signals_tutorial/emitter.h" #include "kernel/nkernelserver.h" nNebulaScriptClass( Emitter, "nroot" );
[ "magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91" ]
[ [ [ 1, 4 ] ] ]
08008dedd6830741bde7887cffb9225a4538e07d
6fff0baf3ce6fe5f83b064a92c9aae42a7a0f570
/vetor.h
53ea44dc7d9492d5c4d1a317ade870259127bb3d
[]
no_license
fernandolins/3projetopg
d7bb33db8a768a2ff3b925f8a713ee7243a258b6
ac5f59fdef119c1b20f7431dcb74517192bbcac3
refs/heads/master
2016-09-06T10:48:49.763027
2010-12-16T14:49:50
2010-12-16T14:49:50
32,118,561
0
0
null
null
null
null
UTF-8
C++
false
false
319
h
#ifndef VETOR_H_INCLUDED #define VETOR_H_INCLUDED #define GLUT_DISABLE_ATEXIT_HACK #include <windows.h> #include <GL/glut.h> class vetor { public: GLdouble x; GLdouble y; GLdouble z; vetor(){}; vetor(GLdouble x, GLdouble y, GLdouble z); }; #endif // VETOR_H_INCLUDED
[ "[email protected]@ef6f675b-d43c-f87a-2b51-aa3ec2201cfb" ]
[ [ [ 1, 21 ] ] ]
8facff91adfd49ebc7087eabae5b61b5a6747ec8
8be41f8425a39f7edc92efb3b73b6a8ca91150f3
/MFCOpenGLTest/MyPolygon.cpp
b99b9bd262c00dfef00a7ced97a874b148886457
[]
no_license
SysMa/msq-summer-project
b497a061feef25cac1c892fe4dd19ebb30ae9a56
0ef171aa62ad584259913377eabded14f9f09e4b
refs/heads/master
2021-01-23T09:28:34.696908
2011-09-16T06:39:52
2011-09-16T06:39:52
34,208,886
0
1
null
null
null
null
UTF-8
C++
false
false
4,714
cpp
// MyPolygon.cpp: implementation of the CMyPolygon class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "MFCOpenGLTest.h" #include "MyPolygon.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CMyPolygon::CMyPolygon() { m_count=0; m_first=0; Flag=false; rectMinX=10000; rectMaxX=-1; rectMinY=10000; rectMaxY=-1; } CMyPolygon::~CMyPolygon() { } void CMyPolygon::Draw() { glLogicOp(GL_COPY); glColor3f(this->color.r,this->color.g,this->color.b); glLineWidth(this->Width); glBegin(GL_LINE_LOOP); for(int i=0; i<m_count; i++) glVertex2f(m_points[i].m_x,m_points[i].m_y); glEnd(); } void CMyPolygon::DrawCurrentOperation() { glLogicOp(GL_COPY); glColor3f(this->color.r,this->color.g,this->color.b); glLineWidth(this->Width); glBegin(GL_LINE_STRIP); for(int i=0; i<m_count; i++) glVertex2f(m_points[i].m_x,m_points[i].m_y); glEnd(); glEnable(GL_COLOR_LOGIC_OP); glLineWidth(this->Width); glLogicOp(GL_XOR); glColor3f(0,1,0); if (m_first == 1) { glBegin(GL_LINES); glVertex2f(m_points[m_count-1].m_x, m_points[m_count-1].m_y); glVertex2f(m_x1, m_y1); glEnd(); m_lastx = m_x1, m_lasty = m_y1; m_first = 2; } else if (m_first == 2) { glBegin(GL_LINES); glVertex2f(m_points[m_count-1].m_x, m_points[m_count-1].m_y); glVertex2f(m_lastx,m_lasty); glEnd(); glBegin(GL_LINES); glVertex2f(m_points[m_count-1].m_x, m_points[m_count-1].m_y); glVertex2f(m_x1,m_y1); glEnd(); } glDisable(GL_COLOR_LOGIC_OP); } void CMyPolygon::OnRButtonUp(float x, float y) { Flag=true; } bool CMyPolygon::OnLButtonUp(float x, float y) { if (Flag) return true; if (x<rectMinX) rectMinX=x; if (x>rectMaxX) rectMaxX=x; if (y<rectMinY) rectMinY=y; if (y>rectMaxY) rectMaxY=y; m_points[m_count].m_x=x; m_points[m_count++].m_y=y; m_first = 1; m_x1 = x; m_y1 = y; return false; } void CMyPolygon::OnMouseMove(float x, float y) { if (m_first==2) { m_x1 = x, m_y1 = y; } } bool CMyPolygon::Pick(float x,float y) { if ((x>Field.TopLeft().x&&x<Field.BottomRight().x)&&(y>Field.TopLeft().y&&y<Field.BottomRight().y)) return true; return false; } bool CMyPolygon::GetTheFeildCrect() { Field.SetRect(rectMinX,rectMinY,rectMaxX,rectMaxY); return true; } void CMyPolygon::OnKeyMove(UINT nChar) { int i=0; glEnable(GL_COLOR_LOGIC_OP); glLogicOp(GL_XOR); glColor3f(this->color.r,this->color.g,this->color.b); //glColor3f(0,1,0); glLineWidth(this->Width); glBegin(GL_LINE_LOOP); for(i=0; i<m_count; i++) glVertex2f(m_points[i].m_x,m_points[i].m_y); glEnd(); switch(nChar) { case 'W': for( i=0;i<m_count;i++) m_points[i].m_y=m_points[i].m_y-1; break; case 'S': for( i=0;i<m_count;i++) m_points[i].m_y=m_points[i].m_y+1; break; case 'A': for(i=0;i<m_count;i++) m_points[i].m_x=m_points[i].m_x-1; break; case 'D': for( i=0;i<m_count;i++) m_points[i].m_x=m_points[i].m_x+1; break; default: break; } } bool CMyPolygon:: Read(CString str) { int pos=0; float para[10]; int i=0; pos=str.Find(' '); para[i]=atoi(str.Left(pos)); str=str.Mid(pos+1,str.GetLength()); i++; m_count=para[0]; while (i<5) { pos=str.Find(' '); para[i]=atof(str.Left(pos)); str=str.Mid(pos+1,str.GetLength()); i++; } this->color.r=para[1]; this->color.g=para[2]; this->color.b=para[3]; this->Width=para[4]; i=0; while (i<m_count*2) { pos=str.Find(' '); if (i%2==0) m_points[i/2].m_x=atof(str.Left(pos)); else m_points[i/2].m_y=atof(str.Left(pos)); str=str.Mid(pos+1,str.GetLength()); i++; } return true; } CString CMyPolygon::Save() { CString test=""; // CString str; // str.Format(" %f %f %f %f %f %f ",this->color.r,this->color.g,this->color.b,this->Width,this->m_x,this->m_y); CString temp; temp.Format(" %d",m_count); test=test+temp; temp.Format(" %f %f %f %f",this->color.r,this->color.g,this->color.b,this->Width); test=test+temp; for (int i=0;i<m_count;i++) { temp.Format(" %f %f",m_points[i].m_x,m_points[i].m_y); test=test+temp; } test=test+" "; return test; }
[ "[email protected]@551f4f89-5e81-c284-84fc-d916aa359411" ]
[ [ [ 1, 261 ] ] ]
7242d3af087972e60d8d9133b5eee1aa9a4f30c0
5ac13fa1746046451f1989b5b8734f40d6445322
/minimangalore/Nebula2/code/tutorials/mtutorial06/mtestapp.cc
8757d09effc6ad04c30242e62ec56e731af82c8b
[]
no_license
moltenguy1/minimangalore
9f2edf7901e7392490cc22486a7cf13c1790008d
4d849672a6f25d8e441245d374b6bde4b59cbd48
refs/heads/master
2020-04-23T08:57:16.492734
2009-08-01T09:13:33
2009-08-01T09:13:33
35,933,330
0
0
null
null
null
null
UTF-8
C++
false
false
11,943
cc
//------------------------------------------------------------------------------ // mTutorial06/mTestapp.cc // (C) 2007 [email protected] for nebula2 //------------------------------------------------------------------------------ #include "mtutorial06/mtestapp.h" #include "scene/nsceneserver.h" #include "managers/entitymanager.h" #include "managers/factorymanager.h" #include "managers/focusmanager.h" #include "application/gamestatehandler.h" #include "gui/nguiserver.h" #include "gui/nguiwindow.h" #include "gui/nguilabel.h" #include "gui/nguitextlabel.h" #include "game/property.h" #include "game/entity.h" #include "properties/lightproperty.h" #include "properties/graphicsproperty.h" #include "mtutorial06/state/mtestgamestatehandler.h" #include "mtutorial06/property/polarcameraproperty.h" namespace mTutorial { mTestApp* mTestApp::Singleton = 0; //------------------------------------------------------------------------------ /** Constructor */ mTestApp::mTestApp() { n_assert(0 == Singleton); Singleton = this; } //------------------------------------------------------------------------------ /** Destructor */ mTestApp::~mTestApp() { n_assert(0 != Singleton); Singleton = 0; } //------------------------------------------------------------------------------ /** Override this method in subclasses to return a different application name. */ nString mTestApp::GetAppName() const { return "Tutorial 06 : Applying Damage levels with texture replacement"; } //------------------------------------------------------------------------------ /** Override this method in subclasses to return a different version string. */ nString mTestApp::GetAppVersion() const { return "1.0"; } //------------------------------------------------------------------------------ /** Get the application vendor. This is usually the publishers company name. */ nString mTestApp::GetVendorName() const { return "Radon Labs GmbH"; } //------------------------------------------------------------------------------ /** Sets up default state which may be modified by command line args and user profile. */ void mTestApp::SetupFromDefaults() { App::SetupFromDefaults(); } //------------------------------------------------------------------------------ /** setup the app's input mapping (called in SetupSubsystems()) */ void mTestApp::SetupDefaultInputMapping() { App::SetupDefaultInputMapping(); } //------------------------------------------------------------------------------ /** This initializes some objects owned by DsaApp. */ bool mTestApp::Open() { if (App::Open()) { // FIXME: turn off clip plane fencing and occlusion query (FOR NOW) // because of compatibility problems on Radeon cards nSceneServer::Instance()->SetClipPlaneFencing(false); nSceneServer::Instance()->SetOcclusionQuery(false); // then setup all parts of the application : input, camera, world, etc... this->SetupGui(); // add some object to lock at... this->CreateViewedEntity(); // add at least one light this->SetupLightsInScene(); // add a came where we can look from this->SetupCameraAndInput(); return true; } return false; } //------------------------------------------------------------------------------ /** Clean up objects created by Open(). */ void mTestApp::Close() { App::Close(); } //------------------------------------------------------------------------------ /** This method is called once per-frame by App::Run(). It is used here to check if reset is requested and that case to evoke it. */ void mTestApp::OnFrame() { static char buf[512]; float phi = 0.0f; float theta = 0.0f; float dist = 0.0f; // read informations from camera. EVERYTHING is done throught manager and properties. // PS : a faster way would be to save the entity ref inside a var but this describe // how manager and properties could be used. (This is the name of the camera we gave it) Ptr<Game::Entity> CameraEntity = Managers::EntityManager::Instance()->GetEntityByName( "MainGameCamera", true ); // only if exist if( CameraEntity != null ) { if( CameraEntity.isvalid() ) { // Var (attr) are saved inside the entity (ps : sometime inside a specific property instead) dist = CameraEntity->GetFloat( Attr::PolarCameraDistance ); phi = CameraEntity->GetFloat( Attr::PolarCameraPhi ); theta = CameraEntity->GetFloat( Attr::PolarCameraTheta ); // useless here but a sample to how getting a specific property ref from entity // Ptr<Properties::PolarCameraProperty> camprop = (Properties::PolarCameraProperty *)(CameraEntity->FindProperty( PolarCameraProperty::RTTI )); } } //Update the label with the current frame displayed sprintf( buf, "Current frame : %d\n Camera Phi : %.2f - Theta : %.2f - Dist : %.2f\n(Mouse wheel for zoom)\n\ 0 : no damage\n\1 : level 1\n2 : level 2\ny : fast yellow painting !\nr : fast red painting !\n", Graphics::Server::Instance()->GetFrameId(), phi, theta, dist ); textLabel->SetText( buf ); } //------------------------------------------------------------------------------ /** // setup the state of our application, directly start in "game" state */ void mTestApp::SetupStateHandlers() { // initialize application state handlers // NOTA : nothing new, just replace default state handle by our... Ptr<Application::GameStateHandler> mtestgameStateHandler = n_new(Application::mTestGameStateHandler); mtestgameStateHandler->SetName("Game"); mtestgameStateHandler->SetExitState("Exit"); mtestgameStateHandler->SetSetupMode(Application::mTestGameStateHandler::EmptyWorld); this->AddStateHandler(mtestgameStateHandler); this->SetState("Game"); } //------------------------------------------------------------------------------ /** This does not setup the dragbox object. The purpose is to display usefull information as frame rate, debug info, etc... */ void mTestApp::SetupGui() { // initialize Nebula2 Gui server // NOTA : this is already init at default val by SetupSubsystems // (so, yes, this not really usefull ....) the purpose is to show // how to set your own gui values nGuiServer* guiServer = nGuiServer::Instance(); nKernelServer* kernelServer = nKernelServer::Instance(); guiServer->SetRootPath("/res/gui"); guiServer->SetDisplaySize(vector2(float(this->displayMode.GetWidth()), float(this->displayMode.GetHeight()))); //will work on the default gui window kernelServer->PushCwd(nGuiServer::Instance()->GetRootWindowPointer()); // create a new label which will be modified into the onFrame callback textLabel = (nGuiTextLabel*) nKernelServer::Instance()->New("nguitextlabel", "HelpLabel"); textLabel->SetFont("GuiSmall"); textLabel->SetAlignment(nGuiTextLabel::Left); textLabel->SetColor(vector4(1.0f, 1.0f, 1.0f, 1.0f)); textLabel->SetClipping(false); textLabel->SetText( "\n\n\n\n\n\n\n\n" ); // only set to allow GetTextPolarent to return something... vector2 textPolarent = textLabel->GetTextExtent(); rectangle textRect(vector2(0.0f, 0.0f), textPolarent ); textLabel->SetRect(textRect); textLabel->OnShow(); kernelServer->PopCwd(); } //------------------------------------------------------------------------------ /** // statically load some object, here the opelblitz */ void mTestApp::CreateViewedEntity() { // name of the object, relative to export:gfxlib nString objectName = "examples/opelblitz"; Ptr<Game::Entity> entity; Ptr<Game::Property> graphicProperty; Ptr<Game::Property> damageProperty; //------------------------------------ // The object, every thing is done though property : here add the graphic property // to our object in order to get it... on screen ! entity = Managers::FactoryManager::Instance()->CreateEntityByClassName("Entity"); graphicProperty = Managers::FactoryManager::Instance()->CreateProperty("GraphicsProperty"); entity->SetString( Attr::Name, "Opelblitz" ); // attach properties entity->AttachProperty( graphicProperty ); entity->SetString( Attr::Graphics, objectName ); // attach the "damage" property damageProperty = Managers::FactoryManager::Instance()->CreateProperty("OpelDamageProperty"); entity->AttachProperty( damageProperty ); // a transformation matrix is mandatory, even if just init matrix44 entityTransform; entity->SetMatrix44(Attr::Transform, entityTransform); // attach to world Managers::EntityManager::Instance()->AttachEntity(entity); } //------------------------------------------------------------------------------ /** // no light, no display !! */ void mTestApp::SetupLightsInScene() { Ptr<Game::Entity> entity; Ptr<Game::Property> lightProperty; // create an object in the same wat as the opelblitz one, but this time // attach a light property instead of graphics. // there must be at least one light //create new Entity for light in scene, create lightProperty and attach it to the entity entity = Managers::FactoryManager::Instance()->CreateEntityByClassName("Entity"); lightProperty = Managers::FactoryManager::Instance()->CreateProperty("LightProperty"); entity->AttachProperty(lightProperty); //set position of lightsource matrix44 lightTransform; lightTransform.translate(vector3(0.0, 100.0f, 0.0)); entity->SetMatrix44(Attr::Transform, lightTransform); //set Attributes of the lightsource entity->SetString(Attr::LightType, "Point"); entity->SetVector4(Attr::LightColor, vector4(1.0f, 1.0f, 1.0f, 1.0f)); entity->SetFloat(Attr::LightRange, 1000.0f); entity->SetVector4(Attr::LightAmbient, vector4(1.0f, 0.0f, 0.0f, 0.0f)); entity->SetBool(Attr::LightCastShadows, false); //attach lightproperty to entity Managers::EntityManager::Instance()->AttachEntity(entity); } //------------------------------------------------------------------------------ /** */ void mTestApp::SetupCameraAndInput() { Ptr<Game::Entity> entity; Ptr<Game::Property> cameraProperty; Ptr<Game::Property> inputProperty; // create new Entity as a camera, // attach our more flexible camera with polar coordinate system property entity = Managers::FactoryManager::Instance()->CreateEntityByClassName("Entity"); cameraProperty = Managers::FactoryManager::Instance()->CreateProperty("PolarCameraProperty"); entity->AttachProperty(cameraProperty); // It's important to name the entity since we use this name inside the OnFrame loop in order // to display camera value entity->SetString( Attr::Name, "MainGameCamera" ); // set some default values from where the camera will look at the "opelblitz" entity->SetVector3( Attr::PolarCameraLookAt, vector3.zero ); // look at origine entity->SetFloat( Attr::PolarCameraPhi, -45.0f ); // -45, that's not a mistake... do our math ! entity->SetFloat( Attr::PolarCameraTheta, 45.0f ); entity->SetFloat( Attr::PolarCameraDistance, 10.0f ); // attach the new polarinputcameraproperty inputProperty = Managers::FactoryManager::Instance()->CreateProperty("PolarCameraInputProperty"); entity->AttachProperty(inputProperty); //attach camera to world (entity pool), and tell mangalore we use it for display !!! Managers::EntityManager::Instance()->AttachEntity(entity); Managers::FocusManager::Instance()->SetCameraFocusEntity(entity); // and switch input to our entity Managers::FocusManager::Instance()->SetInputFocusEntity(entity); } }; // namespace
[ "[email protected]@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c" ]
[ [ [ 1, 323 ] ] ]
16d068d68b87660c8d8d3108c943227f346dfc05
899e3440cda769c6a4b7649065dee47bc0516b6c
/topcoder/topcoder/two.cpp
cc0622a6fbe0e10d1b206a2b017c5eced2d43ce9
[]
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
ISO-8859-1
C++
false
false
3,070
cpp
/* Problem Statement      Consider 26 different substances, labeled 'A' through 'Z' (quotes for clarity only). Some of these substances can be created from the others by an alchemical reaction. Each alchemical reaction takes at least two different substances. Exactly 1 gram of each input substance is combined, causing an explosion. After the dust settles, we are left with just 1 gram of the resulting substance. Alchemists don't like extra work, thus, for any given substance, there's at most one known reaction that results in that substance. You are given a String initial describing the substances that you have initially. Each occurrence of a letter indicates 1 gram, so if a letter appears k times in initial, it means you have k grams of that substance. You are also given a String[] reactions describing all the possible alchemical reactions. Each element of reactions describes a single reaction and is formatted as "ingredients->result" (quotes for clarity only), where ingredients is the list of substances consumed and result is the substance produced. Return the minimal number of reactions required to obtain at least 1 gram of the substance 'X', or -1 if it is impossible. Definition      Class: QuantumAlchemy Method: minSteps Parameters: string, vector <string> Returns: int Method signature: int minSteps(string initial, vector <string> reactions) (be sure your method is public)      Constraints - initial will contain between 1 and 50 characters, inclusive. - initial will contain only uppercase letters ('A'-'Z'). - reactions will contain between 1 and 26 elements, inclusive. - Each element of reactions will contain between 5 and 28 characters, inclusive. - Each element of reactions will be formatted as "ingredients->result" (quotes for clarity only). - Each ingredients will be a string of distinct uppercase letters ('A'-'Z'). - Each result will be an uppercase letter ('A'-'Z'). - Each result will be distinct. - Each ingredients will not contain the corresponding result. Examples 0)      "ABCDE" {"ABC->F", "FE->X"} Returns: 2 Some substances may be left unused. 1)      "AABBB" {"BZ->Y", "ZY->X", "AB->Z"} Returns: 4 First, we make two grams of 'Z' by applying the last reaction twice. Second, we make 'Y' via the first reaction, and we still have 1 gram of 'Z' left, so that we can finally make 'X'. 2)      "AAABB" {"BZ->Y", "ZY->X", "AB->Z"} Returns: -1 Not enough. 3)      "AAXB" {"BZ->Y", "ZY->X", "AB->Z"} Returns: 0 No need to bother if we're already there. 4)      "ABCDEFGHIJKLMNOPQRSTUVWYZABCDEFGHIJKLMNOPQRSTUVWYZ" {"ABCE->Z", "RTYUIO->P", "QWER->T", "MN->B"} Returns: -1 We have a lot of stuff and some reactions, but none of them results in 'X'. This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved. */
[ "karan.jude@737fc9ef-4d2d-0410-97ed-4d0c502f76d2" ]
[ [ [ 1, 78 ] ] ]
2953ae4aae5054ee10817734c9100191e69ff197
99c9bf812e25e951f043ebded998a9118051c5e4
/box2d-read-only/Box2D/Box2D/Collision/.svn/text-base/b2BroadPhase.cpp.svn-base
b9e155d2886fa9f73b9926c3324c57d09ec79d9b
[ "Zlib" ]
permissive
BigBadOwl/iPhone-Physics
b20cb1991394de0e19c52f314d92cabda50a23ec
ff7f5e98ea5828f0f5388ac5306ea4099a3f0d1d
refs/heads/master
2016-09-03T07:13:16.938271
2011-03-11T13:30:35
2011-03-11T13:30:35
1,467,940
0
0
null
null
null
null
UTF-8
C++
false
false
3,261
/* * Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com * * 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 <Box2D/Collision/b2BroadPhase.h> #include <cstring> using namespace std; b2BroadPhase::b2BroadPhase() { m_proxyCount = 0; m_pairCapacity = 16; m_pairCount = 0; m_pairBuffer = (b2Pair*)b2Alloc(m_pairCapacity * sizeof(b2Pair)); m_moveCapacity = 16; m_moveCount = 0; m_moveBuffer = (int32*)b2Alloc(m_moveCapacity * sizeof(int32)); } b2BroadPhase::~b2BroadPhase() { b2Free(m_moveBuffer); b2Free(m_pairBuffer); } int32 b2BroadPhase::CreateProxy(const b2AABB& aabb, void* userData) { int32 proxyId = m_tree.CreateProxy(aabb, userData); ++m_proxyCount; BufferMove(proxyId); return proxyId; } void b2BroadPhase::DestroyProxy(int32 proxyId) { UnBufferMove(proxyId); --m_proxyCount; m_tree.DestroyProxy(proxyId); } void b2BroadPhase::MoveProxy(int32 proxyId, const b2AABB& aabb, const b2Vec2& displacement) { bool buffer = m_tree.MoveProxy(proxyId, aabb, displacement); if (buffer) { BufferMove(proxyId); } } void b2BroadPhase::TouchProxy(int32 proxyId) { BufferMove(proxyId); } void b2BroadPhase::BufferMove(int32 proxyId) { if (m_moveCount == m_moveCapacity) { int32* oldBuffer = m_moveBuffer; m_moveCapacity *= 2; m_moveBuffer = (int32*)b2Alloc(m_moveCapacity * sizeof(int32)); memcpy(m_moveBuffer, oldBuffer, m_moveCount * sizeof(int32)); b2Free(oldBuffer); } m_moveBuffer[m_moveCount] = proxyId; ++m_moveCount; } void b2BroadPhase::UnBufferMove(int32 proxyId) { for (int32 i = 0; i < m_moveCount; ++i) { if (m_moveBuffer[i] == proxyId) { m_moveBuffer[i] = e_nullProxy; return; } } } // This is called from b2DynamicTree::Query when we are gathering pairs. bool b2BroadPhase::QueryCallback(int32 proxyId) { // A proxy cannot form a pair with itself. if (proxyId == m_queryProxyId) { return true; } // Grow the pair buffer as needed. if (m_pairCount == m_pairCapacity) { b2Pair* oldBuffer = m_pairBuffer; m_pairCapacity *= 2; m_pairBuffer = (b2Pair*)b2Alloc(m_pairCapacity * sizeof(b2Pair)); memcpy(m_pairBuffer, oldBuffer, m_pairCount * sizeof(b2Pair)); b2Free(oldBuffer); } m_pairBuffer[m_pairCount].proxyIdA = b2Min(proxyId, m_queryProxyId); m_pairBuffer[m_pairCount].proxyIdB = b2Max(proxyId, m_queryProxyId); ++m_pairCount; return true; }
[ [ [ 1, 122 ] ] ]
93cf8ba2ab0d279a62470a82dfac5cbca8693dbe
55196303f36aa20da255031a8f115b6af83e7d11
/private/external/gameswf/gameswf/gameswf_environment.cpp
660118be6d2818875800da87d7dea43d0d032a19
[]
no_license
Heartbroken/bikini
3f5447647d39587ffe15a7ae5badab3300d2a2ff
fe74f51a3a5d281c671d303632ff38be84d23dd7
refs/heads/master
2021-01-10T19:48:40.851837
2010-05-25T19:58:52
2010-05-25T19:58:52
37,190,932
0
0
null
null
null
null
UTF-8
C++
false
false
15,948
cpp
// gameswf_value.cpp -- Thatcher Ulrich <[email protected]> 2003 // This source code has been donated to the Public Domain. Do // whatever you want with it. #include "gameswf/gameswf.h" #include "gameswf/gameswf_value.h" #include "gameswf/gameswf_character.h" #include "gameswf/gameswf_sprite.h" #include "gameswf/gameswf_log.h" #include "gameswf/gameswf_function.h" #include "gameswf/gameswf_render.h" #if TU_CONFIG_LINK_TO_LIB3DS == 1 #include "extensions/lib3ds/gameswf_3ds_inst.h" #endif namespace gameswf { // misc enum file_type { UNKNOWN, SWF, JPG, X3DS }; // static file_type get_file_type(const char* url) { tu_string fn = url; if (fn.size() < 5) // At least 5 symbols { return UNKNOWN; } tu_stringi fn_ext = fn.utf8_substring(fn.size() - 4, fn.size()); if (fn_ext == ".swf") { return SWF; } else if (fn_ext == ".jpg") { return JPG; } else if (fn_ext == ".3ds") { return X3DS; } return UNKNOWN; } // static tu_string get_full_url(const tu_string& workdir, const char* url) { tu_string fn; // is path relative ? if (url[1] == ':' || url[0] == '/') // like c:\my.swf or /home/my.swf { fn = ""; } else { fn = workdir; } fn += url; return fn; } // static const char* next_slash_or_dot(const char* word) // Search for next '.' or '/' character in this word. Return // a pointer to it, or to NULL if it wasn't found. { for (const char* p = word; *p; p++) { if (*p == '.' && p[1] == '.') { p++; } else if (*p == '.' || *p == '/') { return p; } } return NULL; } // url=="" means that the load_file() works as unloadMovie(target) character* as_environment::load_file(const char* url, const as_value& target_value) { character* target = cast_to<character>(find_target(target_value)); if (target == NULL) { IF_VERBOSE_ACTION(log_msg("load_file: target %s is't found\n", target_value.to_string())); return NULL; } // is unloadMovie() ? if (strlen(url) == 0) { character* parent = target->get_parent(); if (parent) { parent->remove_display_object(target); } else // target is _root, unloadMovie(_root) { target->clear_display_objects(); } return NULL; } // is path relative ? tu_string fn = get_full_url(get_player()->get_workdir(), url); switch (get_file_type(fn.c_str())) { default: break; case SWF: { movie_definition* md = get_player()->create_movie(fn.c_str()); if (md) { return target->replace_me(md); } break; } case X3DS: { #if TU_CONFIG_LINK_TO_LIB3DS == 0 log_error("gameswf is not linked to lib3ds -- can't load 3DS file\n"); #else x3ds_definition* x3ds = create_3ds_definition(get_player(), fn.c_str()); if (x3ds) { if (x3ds->is_loaded()) { rect bound; target->get_bound(&bound); x3ds->set_bound(bound); return target->replace_me(x3ds); } } #endif break; } case JPG: { #if TU_CONFIG_LINK_TO_JPEGLIB == 0 log_error("gameswf is not linked to jpeglib -- can't load jpeg image data!\n"); #else image::rgb* im = image::read_jpeg(fn.c_str()); if (im) { bitmap_info* bi = render::create_bitmap_info_rgb(im); delete im; bitmap_character* jpeg = new bitmap_character(get_player(), bi); return target->replace_me(jpeg); } #endif break; } } return NULL; } as_value as_environment::get_variable(const tu_string& varname, const array<with_stack_entry>& with_stack) const // Return the value of the given var, if it's defined. { // Path lookup rigamarole. as_object* target = get_target(); tu_string path; tu_string var; if (parse_path(varname, &path, &var)) { // @@ Use with_stack here too??? Need to test. target = find_target(path.c_str()); if (target) { as_value val; target->get_member(var, &val); return val; } else if(target=get_player()->get_global()->find_target(path.c_str())) { as_value val; target->get_member(var, &val); return val; } else { IF_VERBOSE_ACTION(log_msg("find_target(\"%s\") failed\n", path.c_str())); return as_value(); } } else { return get_variable_raw(varname, with_stack); } } as_value as_environment::get_variable_raw( const tu_string& varname, const array<with_stack_entry>& with_stack) const // varname must be a plain variable name; no path parsing. { as_value val; // First check the with-stack. for (int i = with_stack.size() - 1; i >= 0; i--) { as_object* obj = with_stack[i].m_object.get_ptr(); if (obj && obj->get_member(varname, &val)) { // Found the var in this context. return val; } } // Then check locals. int local_index = find_local(varname, true); if (local_index >= 0) { return m_local_frames[local_index].m_value; } // Check movie members. if (m_target != NULL && m_target->get_member(varname, &val)) { return val; } // Check this, _global, _root as_standard_member varname_id = get_standard_member(varname); switch (varname_id) { default: break; case M_GLOBAL: val.set_as_object(get_player()->get_global()); return val; case MTHIS: val.set_as_object(get_target()); return val; case M_ROOT: case M_LEVEL0: val.set_as_object(get_root()->get_root_movie()); return val; } // check _global.member if (get_player()->get_global()->get_member(varname, &val)) { return val; } // Fallback. IF_VERBOSE_ACTION(log_msg("get_variable_raw(\"%s\") failed, returning UNDEFINED.\n", varname.c_str())); return val; } character* as_environment::get_target() const { return cast_to<character>(m_target.get_ptr()); } void as_environment::set_target(character* target) { m_target = target; } void as_environment::set_target(as_value& target, character* original_target) { if (target.is_string()) { tu_string path = target.to_tu_string(); IF_VERBOSE_ACTION(log_msg("-------------- ActionSetTarget2: %s", path.c_str())); if (path.size() > 0) { character* tar = cast_to<character>(find_target(path.c_str())); if (tar) { set_target(tar); return; } } else { set_target(original_target); return; } } else if (target.is_object()) { IF_VERBOSE_ACTION(log_msg("-------------- ActionSetTarget2: %s", target.to_string())); character* tar = cast_to<character>(find_target(target)); if (tar) { set_target(tar); return; } } IF_VERBOSE_ACTION(log_msg("can't set target %s\n", target.to_string())); } void as_environment::set_variable( const tu_string& varname, const as_value& val, const array<with_stack_entry>& with_stack) // Given a path to variable, set its value. { IF_VERBOSE_ACTION(log_msg("-------------- %s = %s\n", varname.c_str(), val.to_string()));//xxxxxxxxxx // Path lookup rigamarole. character* target = get_target(); tu_string path; tu_string var; if (parse_path(varname, &path, &var)) { target = cast_to<character>(find_target(path.c_str())); if (target) { target->set_member(var, val); } } else { set_variable_raw(varname, val, with_stack); } } void as_environment::set_variable_raw( const tu_string& varname, const as_value& val, const array<with_stack_entry>& with_stack) // No path rigamarole. { // Check the with-stack. for (int i = with_stack.size() - 1; i >= 0; i--) { as_object* obj = with_stack[i].m_object.get_ptr(); as_value unused; if (obj && obj->get_member(varname, &unused)) { // This object has the member; so set it here. obj->set_member(varname, val); return; } } // Check locals. int local_index = find_local(varname, true); if (local_index >= 0) { // Set local var. m_local_frames[local_index].m_value = val; return; } if (m_target != NULL) { m_target->set_member(varname, val); } else { // assume local var // This case happens for example so // class myclass // { // function myfunc() // { // for (i=0;...) should be for (var i=0; ...) // { // } // } // } add_local(varname, val); IF_VERBOSE_ACTION(log_error("can't set_variable_raw %s=%s, target is NULL, it's assumed as local\n", varname.c_str(), val.to_string())); IF_VERBOSE_ACTION(log_error("probably you forgot to declare variable '%s'\n", varname.c_str())); } } void as_environment::set_local(const tu_string& varname, const as_value& val) // Set/initialize the value of the local variable. { // Is it in the current frame already? int index = find_local(varname, false); if (index < 0) { // Not in frame; create a new local var. add_local(varname, val); } else { // In frame already; modify existing var. m_local_frames[index].m_value = val; } } void as_environment::add_local(const tu_string& varname, const as_value& val) // Add a local var with the given name and value to our // current local frame. Use this when you know the var // doesn't exist yet, since it's faster than set_local(); // e.g. when setting up args for a function. { assert(varname.length() > 0); m_local_frames.push_back(frame_slot(varname, val)); } void as_environment::declare_local(const tu_string& varname) // Create the specified local var if it doesn't exist already. { // Is it in the current frame already? int index = find_local(varname, false); if (index < 0) { // Not in frame; create a new local var. add_local(varname, as_value()); } else { // In frame already; don't mess with it. } } as_value* as_environment::get_register(int reg) { as_value* val = local_register_ptr(reg); IF_VERBOSE_ACTION(log_msg("-------------- get_register(%d): %s at 0x%X\n", reg, val->to_string(), val->to_object())); return val; } void as_environment::set_register(int reg, const as_value& val) { IF_VERBOSE_ACTION(log_msg("-------------- set_register(%d): %s at 0x%X\n", reg, val.to_string(), val.to_object())); *local_register_ptr(reg) = val; } as_value* as_environment::local_register_ptr(int reg) // Return a pointer to the specified local register. // Local registers are numbered starting with 1. // // Return value will never be NULL. If reg is out of bounds, // we log an error, but still return a valid pointer (to // global reg[0]). So the behavior is a bit undefined, but // not dangerous. { // We index the registers from the end of the register // array, so we don't have to keep base/frame // pointers. assert(reg >=0 && reg <= m_local_register.size()); // Flash 8 can have zero register (-1 for zero) return &m_local_register[m_local_register.size() - reg - 1]; } int as_environment::find_local(const tu_string& varname, bool ignore_barrier) const // Search the active frame for the named var; return its index // in the m_local_frames stack if found. // // Otherwise return -1. // set_local should use "ignore_barrier=false" // get_variable should use "ignore_barrier=true" { // Linear search sucks, but is probably fine for // typical use of local vars in script. There could // be pathological breakdowns if a function has tons // of locals though. The ActionScript bytecode does // not help us much by using strings to index locals. for (int i = m_local_frames.size() - 1; i >= 0; i--) { const frame_slot& slot = m_local_frames[i]; if (slot.m_name.length() == 0 && ignore_barrier == false) { // End of local frame; stop looking. return -1; } else if (slot.m_name == varname) { // Found it. return i; } } return -1; } // Should be highly optimized !!! bool as_environment::parse_path(const tu_string& var_path, tu_string* path, tu_string* var) // See if the given variable name is actually a sprite path // followed by a variable name. These come in the format: // // /path/to/some/sprite/:varname // // (or same thing, without the last '/') // // or // path.to.some.var // // If that's the format, puts the path part (no colon or // trailing slash) in *path, and the varname part (no color) // in *var and returns true. // // If no colon, returns false and leaves *path & *var alone. { // Search for colon. const char* colon = strrchr(var_path.c_str(), ':'); if (colon) { // Make the subparts. *var = colon + 1; // delete prev '/' if it is not first character if (colon > var_path.c_str() + 1 && *(colon - 1) == '/') { colon--; } *path = var_path; path->resize(int(colon - var_path.c_str())); return true; } else { // Is there a dot? Find the last one, if any. colon = strrchr(var_path.c_str(), '.'); if (colon) { // Make the subparts. *var = colon + 1; *path = var_path; path->resize(int(colon - var_path.c_str())); return true; } } return false; } as_object* as_environment::find_target(const as_value& target) const { if (m_target != NULL) { return m_target->find_target(target); } return NULL; } bool as_environment::set_member(const tu_stringi& name, const as_value& val) { if (m_target != NULL) { return m_target->set_member(name, val); } return false; } bool as_environment::get_member(const tu_stringi& name, as_value* val) { if (m_target != NULL) { return m_target->get_member(name, val); } return false; } void as_environment::clear_refs(hash<as_object*, bool>* visited_objects, as_object* this_ptr) { // target if (m_target == this_ptr) { m_target = NULL; } // local vars for (int i = 0, n = m_local_frames.size(); i < n; i++) { as_object* obj = m_local_frames[i].m_value.to_object(); if (obj) { if (obj == this_ptr) { m_local_frames[i].m_value.set_undefined(); } else { obj->clear_refs(visited_objects, this_ptr); } } } // stack for (int i = 0, n = m_stack.size(); i < n; i++) { as_object* obj = m_stack[i].to_object(); if (obj) { if (obj == this_ptr) { m_stack[i].set_undefined(); } else { obj->clear_refs(visited_objects, this_ptr); } } } // global register for (int i = 0, n = GLOBAL_REGISTER_COUNT; i < n; i++) { as_object* obj = m_global_register[i].to_object(); if (obj) { if (obj == this_ptr) { m_global_register[i].set_undefined(); } else { obj->clear_refs(visited_objects, this_ptr); } } } // local register for (int i = 0, n = m_local_register.size(); i < n; i++) { as_object* obj = m_local_register[i].to_object(); if (obj) { if (obj == this_ptr) { m_local_register[i].set_undefined(); } else { obj->clear_refs(visited_objects, this_ptr); } } } } player* as_environment::get_player() const { return m_player.get_ptr(); } root* as_environment::get_root() const { return m_player->get_root(); } // fn_call player* fn_call::get_player() const { assert(env); return env->get_player(); } root* fn_call::get_root() const { assert(env); return env->get_player()->get_root(); } }
[ "viktor.reutskyy@68c2588f-494f-0410-aecb-65da31d84587" ]
[ [ [ 1, 700 ] ] ]
b4aa789ba3cf4abdfbe04c8a264fe138df1c517e
f4b649f3f48ad288550762f4439fcfffddc08d0e
/eRacer/Source/Graphics/MeshNode.cpp
4015452e77683224690735490bdbc6c5ced93d8f
[]
no_license
Knio/eRacer
0fa27c8f7d1430952a98ac2896ab8b8ee87116e7
65941230b8bed458548a920a6eac84ad23c561b8
refs/heads/master
2023-09-01T16:02:58.232341
2010-04-26T23:58:20
2010-04-26T23:58:20
506,897
1
0
null
null
null
null
UTF-8
C++
false
false
2,381
cpp
/** * @file MeshNode.cpp * @brief Implementation of the MeshNode class * * @date 12.01.2010 * @author: Ole Rehmsen */ #include "MeshNode.h" #include "GraphicsLayer.h" #include "d3d9types.h" #include <iostream> using namespace std; namespace Graphics { MeshNode::MeshNode(const string& name, const Matrix& tx) : RenderableNode(name,tx), initialized(false), mesh_(NULL), boundsMesh_(NULL) { m_colorMtrlTint = D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ); m_texOffset.u = 0; m_texOffset.v = 0; } void MeshNode::setTint(Vector4 tint) { m_colorMtrlTint = D3DXCOLOR( tint.x, tint.y, tint.z, tint.w ); } MeshNode::~MeshNode(){ if(initialized) delete mesh_; if(NULL != boundsMesh_) delete boundsMesh_; } void MeshNode::Draw(IDirect3DDevice9* device) const{ if(!initialized) return; assert(NULL != device); // set the transform device->SetTransform(D3DTS_WORLDMATRIX(0), &transform_); //FIXME Should not be accessed directly ID3DXEffect* effect = GraphicsLayer::GetInstance().m_pEffect; effect->SetMatrix( "g_WorldMatrix", &transform_); effect->SetValue( "g_ColorTint", &m_colorMtrlTint, sizeof( D3DXCOLOR ) ); effect->SetValue( "g_TexOffset", &m_texOffset, sizeof( Vector2 ) ); assert(SUCCEEDED(effect->SetTechnique( "RenderSceneWithTextureDefault" ))); UINT cPasses = 1; assert(SUCCEEDED(effect->Begin( &cPasses, 0 ))); for(UINT iPass = 0; iPass < cPasses; iPass++ ) { effect->BeginPass( iPass ) ; mesh_->Draw(device); assert(SUCCEEDED(effect->EndPass())); } assert(SUCCEEDED(effect->End())); if(NULL != boundsMesh_){ Matrix t = CreateMatrix(worldBounds_.center); device->SetTransform(D3DTS_WORLDMATRIX(0), &t); boundsMesh_->DrawSubset(0); } } void MeshNode::Init(Mesh* mesh){ //this method can only be called once assert(!initialized); assert(NULL != mesh); mesh_ = mesh; //D3DXCreateSphere(GraphicsLayer::GetInstance()->GetDevice(), mesh_->localBounds.radius, 10,10, &boundsMesh_,NULL); initialized = true; UpdateWorldBounds(); } void MeshNode::UpdateWorldBounds(){ if(!initialized) return; worldBounds_.center = mul1(transform_, mesh_->localBounds.center); float x, y, z; ExtractScaling(transform_,x,y,z); worldBounds_.radius = mesh_->localBounds.radius * max(max(x,y),z); } }
[ [ [ 1, 18 ], [ 20, 29 ], [ 34, 48 ], [ 50, 50 ], [ 52, 53 ], [ 55, 58 ], [ 60, 60 ], [ 62, 63 ], [ 65, 67 ], [ 69, 86 ], [ 88, 89 ], [ 92, 102 ] ], [ [ 19, 19 ], [ 49, 49 ], [ 87, 87 ], [ 90, 91 ] ], [ [ 30, 33 ], [ 51, 51 ], [ 54, 54 ], [ 59, 59 ], [ 61, 61 ], [ 64, 64 ], [ 68, 68 ] ] ]
31d718c5f92c27678cbf5c910f29e973d5068d11
0a69372d2ad5a8c3236097d182e50f13a4bd2f66
/tlibc/isctype.cpp
a2d29e73b6488181cd343c8787912ee8bbb52a6b
[]
no_license
Tobbe/tvol
4f13d587fa016e95ba17fc08fd33559092b4bcd7
9f46410acd903d829371e3b4b6d417b2e74159a7
refs/heads/master
2021-04-26T06:31:52.992034
2009-03-02T22:20:21
2009-03-02T22:20:21
139,994
2
0
null
null
null
null
UTF-8
C++
false
false
1,576
cpp
// isctype.cpp // based on: // LIBCTINY - Matt Pietrek 2001 // MSDN Magazine, January 2001 // 08/12/06 (mv) #include <windows.h> #include <ctype.h> #include "libct.h" BEGIN_EXTERN_C int iswctype(wint_t c, wctype_t type) { WORD ret; GetStringTypeW(CT_CTYPE1, (LPCWSTR)&c, 1, &ret); if ((ret & type) != 0) return 1; return 0; } //int _ismbcspace(int c) {return isspace(c);} int isspace(int c) {return ((c >= 0x09 && c <= 0x0D) || (c == 0x20));} int iswspace(wint_t c) {return iswctype(c, _BLANK);} //int _ismbcupper(int c) {return isupper(c);} int isupper(int c) {return (c >= 'A' && c <= 'Z');} int iswupper(wint_t c) {return iswctype(c, _UPPER);} //int ismbcalpha(int c) {return isalpha(c);} int isalpha(int c) {return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');} int iswalpha(wint_t c) {return iswctype(c, _ALPHA);} //int ismbcdigit(int c) {return isdigit(c);} int isdigit(int c) {return (c >= '0' && c <= '9');} int iswdigit(wint_t c) {return iswctype(c, _DIGIT);} //int ismbcxdigit(int c) {return isxdigit(c);} int isxdigit(int c) {return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f');} int iswxdigit(wint_t c) {return iswctype(c, _HEX);} //int ismbcalnum(int c) {return isalnum(c);} int isalnum(int c) {return isalpha(c) || isdigit(c);} int iswalnum(wint_t c) {return iswctype(c, _ALPHA|_DIGIT);} //int ismbcprint(int c) {return isprint(c);} int isprint(int c) {return c >= ' ';} int iswprint(wint_t c) {return iswctype(c, (wctype_t)(~_CONTROL));} END_EXTERN_C
[ [ [ 1, 52 ] ] ]
32c3925b51b86c2feb58144e8a016bf03a0e60aa
c5534a6df16a89e0ae8f53bcd49a6417e8d44409
/trunk/Dependencies/Xerces/include/xercesc/validators/schema/XercesAttGroupInfo.hpp
f46e1531782937cf92c4067dc970094222443362
[]
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
7,970
hpp
/* * Copyright 2001-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: XercesAttGroupInfo.hpp 176026 2004-09-08 13:57:07Z peiyongz $ */ #if !defined(XERCESATTGROUPINFO_HPP) #define XERCESATTGROUPINFO_HPP /** * The class act as a place holder to store attributeGroup information. * * The class is intended for internal use. */ // --------------------------------------------------------------------------- // Includes // --------------------------------------------------------------------------- #include <xercesc/util/RefVectorOf.hpp> #include <xercesc/validators/schema/SchemaAttDef.hpp> #include <xercesc/internal/XSerializable.hpp> XERCES_CPP_NAMESPACE_BEGIN class VALIDATORS_EXPORT XercesAttGroupInfo : public XSerializable, public XMemory { public: // ----------------------------------------------------------------------- // Public Constructors/Destructor // ----------------------------------------------------------------------- XercesAttGroupInfo ( unsigned int attGroupNameId , unsigned int attGroupNamespaceId , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); ~XercesAttGroupInfo(); // ----------------------------------------------------------------------- // Getter methods // ----------------------------------------------------------------------- bool containsTypeWithId() const; unsigned int attributeCount() const; unsigned int anyAttributeCount() const; unsigned int getNameId() const; unsigned int getNamespaceId() const; SchemaAttDef* attributeAt(const unsigned int index); const SchemaAttDef* attributeAt(const unsigned int index) const; SchemaAttDef* anyAttributeAt(const unsigned int index); const SchemaAttDef* anyAttributeAt(const unsigned int index) const; SchemaAttDef* getCompleteWildCard() const; const SchemaAttDef* getAttDef(const XMLCh* const baseName, const int uriId) const; // ----------------------------------------------------------------------- // Setter methods // ----------------------------------------------------------------------- void setTypeWithId(const bool other); void addAttDef(SchemaAttDef* const toAdd, const bool toClone = false); void addAnyAttDef(SchemaAttDef* const toAdd, const bool toClone = false); void setCompleteWildCard(SchemaAttDef* const toSet); // ----------------------------------------------------------------------- // Query methods // ----------------------------------------------------------------------- bool containsAttribute(const XMLCh* const name, const unsigned int uri); /*** * Support for Serialization/De-serialization ***/ DECL_XSERIALIZABLE(XercesAttGroupInfo) XercesAttGroupInfo(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); private: // ----------------------------------------------------------------------- // Unimplemented contstructors and operators // ----------------------------------------------------------------------- XercesAttGroupInfo(const XercesAttGroupInfo& elemInfo); XercesAttGroupInfo& operator= (const XercesAttGroupInfo& other); // ----------------------------------------------------------------------- // Private data members // ----------------------------------------------------------------------- bool fTypeWithId; unsigned int fNameId; unsigned int fNamespaceId; RefVectorOf<SchemaAttDef>* fAttributes; RefVectorOf<SchemaAttDef>* fAnyAttributes; SchemaAttDef* fCompleteWildCard; MemoryManager* fMemoryManager; }; // --------------------------------------------------------------------------- // XercesAttGroupInfo: Getter methods // --------------------------------------------------------------------------- inline bool XercesAttGroupInfo::containsTypeWithId() const { return fTypeWithId; } inline unsigned int XercesAttGroupInfo::attributeCount() const { if (fAttributes) { return fAttributes->size(); } return 0; } inline unsigned int XercesAttGroupInfo::anyAttributeCount() const { if (fAnyAttributes) { return fAnyAttributes->size(); } return 0; } inline unsigned int XercesAttGroupInfo::getNameId() const { return fNameId; } inline unsigned int XercesAttGroupInfo::getNamespaceId() const { return fNamespaceId; } inline SchemaAttDef* XercesAttGroupInfo::attributeAt(const unsigned int index) { if (fAttributes) { return fAttributes->elementAt(index); } return 0; } inline const SchemaAttDef* XercesAttGroupInfo::attributeAt(const unsigned int index) const { if (fAttributes) { return fAttributes->elementAt(index); } return 0; } inline SchemaAttDef* XercesAttGroupInfo::anyAttributeAt(const unsigned int index) { if (fAnyAttributes) { return fAnyAttributes->elementAt(index); } return 0; } inline const SchemaAttDef* XercesAttGroupInfo::anyAttributeAt(const unsigned int index) const { if (fAnyAttributes) { return fAnyAttributes->elementAt(index); } return 0; } inline SchemaAttDef* XercesAttGroupInfo::getCompleteWildCard() const { return fCompleteWildCard; } // --------------------------------------------------------------------------- // XercesAttGroupInfo: Setter methods // --------------------------------------------------------------------------- inline void XercesAttGroupInfo::setTypeWithId(const bool other) { fTypeWithId = other; } inline void XercesAttGroupInfo::addAttDef(SchemaAttDef* const toAdd, const bool toClone) { if (!fAttributes) { fAttributes = new (fMemoryManager) RefVectorOf<SchemaAttDef>(4, true, fMemoryManager); } if (toClone) { SchemaAttDef* clonedAttDef = new (fMemoryManager) SchemaAttDef(toAdd); if (!clonedAttDef->getBaseAttDecl()) clonedAttDef->setBaseAttDecl(toAdd); fAttributes->addElement(clonedAttDef); } else { fAttributes->addElement(toAdd); } } inline void XercesAttGroupInfo::addAnyAttDef(SchemaAttDef* const toAdd, const bool toClone) { if (!fAnyAttributes) { fAnyAttributes = new (fMemoryManager) RefVectorOf<SchemaAttDef>(2, true, fMemoryManager); } if (toClone) { SchemaAttDef* clonedAttDef = new (fMemoryManager) SchemaAttDef(toAdd); if (!clonedAttDef->getBaseAttDecl()) clonedAttDef->setBaseAttDecl(toAdd); fAnyAttributes->addElement(clonedAttDef); } else { fAnyAttributes->addElement(toAdd); } } inline void XercesAttGroupInfo::setCompleteWildCard(SchemaAttDef* const toSet) { if (fCompleteWildCard) { delete fCompleteWildCard; } fCompleteWildCard = toSet; } XERCES_CPP_NAMESPACE_END #endif /** * End of file XercesAttGroupInfo.hpp */
[ "Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57" ]
[ [ [ 1, 256 ] ] ]
6d61faff33c97b04ba1cc59ab3236ae4f8dfc42a
5da9d428805218901d7c039049d7e13a1a2b1c4c
/Vivian/libFade/GDISurface.h
ee8d29d172a143f489b9f19c6fd27a4ec1bf25c9
[]
no_license
SakuraSinojun/vivianmage
840be972f14e17bb76241ba833318c13cf2b00a4
7a82ee5c5f37d98b86e8d917d9bb20c96a2d6c7f
refs/heads/master
2021-01-22T20:44:33.191391
2010-12-11T15:26:15
2010-12-11T15:26:15
32,322,907
0
0
null
null
null
null
GB18030
C++
false
false
3,279
h
////////////////////////////////////////////////////////////////// // // FileName : GDISurface.h // Author : SakuraSinojun // Description : this is the cavans on which we draw use GDI. // // Version : 1.0.0.1 // Date : 2009.9.6 // // Copyright(c): 2009-2010 Sakura // ////////////////////////////////////////////////////////////////// #pragma once #include "..\stdafx.h" #include "Surface.h" class CGDIDraw; class CGDISurface : public CSurface { public: CGDISurface(void); ~CGDISurface(void); HRESULT Create(int width,int height); virtual HRESULT Draw(HDC hdc,HWND hWnd); HRESULT Load(const char * name); HRESULT SetColorKey(bool bColorKey); void CGDISurface::ColorKeyFade(HDC hdc,CSize size); void * Add(); int Width() const; int Height() const; int Depth() const; void GetRect(CRect *r) const; CSize GetSize() const; void SetDrawPos(int x,int y); void SetDrawPos(CPoint point); CPoint GetDrawPos() const; void SetSrcPos(int x,int y); CPoint GetSrcPos()const; void SetSrcRect(CRect& rect); void Show(bool _show=true); CPoint GetDrawPos() { return this->draw_pos; } void SetFadeLevel(int level=255); COLORREF GetPTColor(){return ptcolor;} HDC Get(){return m_hdc;} //LPDIRECTDRAWSURFACE operator->(){return surface;} void SetPaintWnd(CPaintWnd * _paintwnd); protected: HDC m_hdc; //背景加载位图用DC HBITMAP m_hbitmap; //关联位图,也可能是内存兼容位图。 BITMAP bitmap; // char path[MAX_PATH]; //BMP路径 CPoint src_pos; //来源坐标 CPoint draw_pos; //目标坐标 CSize size; //显示大小 CSize draw_size; //绘图大小 bool show; //当前surface显示时为true; bool colorkey; //使用colorkey时此值为true COLORREF ptcolor; //(1,1)点颜色; int iFadeLevel; //0~255交叉透明度。 char * dst_bits; char * bmp_bits; CPaintWnd * painter; }; //取得宽度 inline int CGDISurface::Width() const { return size.cx; } //取得高度 inline int CGDISurface::Height () const { return size.cy ; } //取得色深 inline int CGDISurface::Depth () const { return bitmap.bmBitsPixel ; } //取得绘图坐标 inline void CGDISurface::GetRect(CRect *r) const { r->left =draw_pos.x; r->top =draw_pos.y; r->right=draw_pos.x+size.cx; r->bottom =draw_pos.y+size.cy; } //取得尺寸 inline CSize CGDISurface::GetSize() const { return size; } //设定绘图起点(左上角) inline void CGDISurface::SetDrawPos(int x, int y) { draw_pos.x=x; draw_pos.y=y; } //重载 inline void CGDISurface::SetDrawPos(CPoint point) { draw_pos=point; } //取得绘图起点(左上角) inline CPoint CGDISurface::GetDrawPos () const { return draw_pos; } //设定来源起点 inline void CGDISurface::SetSrcPos (int x,int y) { src_pos.x=x; src_pos.y=y; } //取得来源起点 inline CPoint CGDISurface::GetSrcPos() const { return src_pos; } //显示绘图页 inline void CGDISurface::Show(bool _show) { show=_show; } //设置绘图源区域 inline void CGDISurface::SetSrcRect (CRect& rect) { SetSrcPos(rect.left,rect.top); draw_size=rect.Size(); }
[ "SakuraSinojun@c9cc3ed0-94a9-11de-b6d4-8762f465f3f9" ]
[ [ [ 1, 168 ] ] ]
d70b44ac7345ace7c19303ac3e00ad921a36c9bc
1e8b8f8441f9bc7847415f0a01a7d285198b0526
/BCB6_Heap/Prueba/PruebaHeapObject.cpp
f61bceb7feed9a175c8a05075dddccbdd82237ff
[]
no_license
jmnavarro/BCB_LosRinconesDelAPIWin32
8d5ecde4c2b60795b0cd7f69840bae48612c1fce
e3f03ccf706caf1a99c53eae2994d051b6513c17
refs/heads/master
2020-05-18T11:43:03.637385
2011-06-30T23:24:23
2011-06-30T23:24:23
1,980,854
0
0
null
null
null
null
UTF-8
C++
false
false
974
cpp
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop //--------------------------------------------------------------------------- USEFORM("main.cpp", MainForm); //--------------------------------------------------------------------------- WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { try { Application->Initialize(); Application->Title = "Pruebas CHeapObject"; Application->CreateForm(__classid(TMainForm), &MainForm); Application->Run(); } catch (Exception &exception) { Application->ShowException(&exception); } catch (...) { try { throw Exception(""); } catch (Exception &exception) { Application->ShowException(&exception); } } return 0; } //---------------------------------------------------------------------------
[ [ [ 1, 34 ] ] ]
68a8903b845a83431256d128f90ded2beb49ed2f
2d22825193eacf3669ac8bd7a857791745a9ead4
/HairSimulation/HairSimulation/src/World.cpp
07ef5ae4b893fe8ff96e49e1875159dbc9cc83f6
[]
no_license
dtbinh/com-animation-classprojects
557ba550b575c3d4efc248f7984a3faac8f052fd
37dc800a6f2bac13f5aa4fc7e0e96aa8e9cec29e
refs/heads/master
2021-01-06T20:45:42.613604
2009-01-20T00:23:11
2009-01-20T00:23:11
41,496,905
0
0
null
null
null
null
UTF-8
C++
false
false
12,029
cpp
#include "World.h" #include "AppUtilities.h" using namespace std; float World::TRI_AREA_THRESHOLD = 9999.0; float World::TIME_STEP = 0.001; //----------------------------------------------------------- World::World(SceneManager* sceneMgr) : mSceneMgr(sceneMgr) { mProcessState = PS_INITIAL; mAllHairs = 0; // Create a CollisionContext //mCollisionContext = CollisionManager::getSingletonPtr()->createContext("mCollisionContext"); } //----------------------------------------------------------- World::~World() { clear(); } //----------------------------------------------------------- SceneManager* World::getSceneManager(void) { return mSceneMgr; } //----------------------------------------------------------- void World::clear(void) { ObjectMap::iterator i; for (i = mObjects.begin(); i != mObjects.end(); ++i) { delete i->second; } mObjects.clear(); delete mD_Mesh; } //------------------------------------------------------------------------- template<> World* Ogre::Singleton<World>::ms_Singleton = 0; World* World::getSingletonPtr(void) { return ms_Singleton; } World& World::getSingleton(void) { assert( ms_Singleton ); return ( *ms_Singleton ); } //------------------------------------------------------------------------- Ball* World::createBall(const Ogre::String &name, Ogre::Real radius, const Ogre::Vector3 &pos) { Ball* ball = new Ball(name, radius); ball->setPosition(pos); mObjects[name] = ball; //addCollisionEntity(ball->getEntity()); return ball; } //------------------------------------------------------------------------- OgreHead* World::createOgreHead(const String& name, const Vector3& pos) { OgreHead* head = new OgreHead(name); head->setPosition(pos); mObjects[name] = head; //addCollisionEntity(head->getEntity()); return head; } //------------------------------------------------------------------------- ManHead* World::createManHead(const String& name, const Vector3& pos) { ManHead* head = new ManHead(name); head->setPosition(pos); mObjects[name] = head; //addCollisionEntity(head->getEntity()); return head; } //------------------------------------------------------------------------- World::ProcessState World::getProcessState(void) { return mProcessState; } //------------------------------------------------------------------------- void World::setProcessState(World::ProcessState ps) { mProcessState = ps; } //------------------------------------------------------------------------- void World::addCollisionEntity( Entity* pEntity ) { EntityCollisionShape* pCollisionShape = CollisionManager::getSingletonPtr()->createEntityCollisionShape( pEntity->getName() ); pCollisionShape->load( pEntity ); CollisionObject* pCollisionObject = mCollisionContext->createObject( pEntity->getName() ); pCollisionObject->setCollClass( "mCollClass" ); pCollisionObject->setShape( pCollisionShape ); mCollisionContext->addObject( pCollisionObject ); } //------------------------------------------------------------------------- void World::removeCollisionEntity( Ogre::Entity* pEntity ) { ICollisionShape* pShape = CollisionManager::getSingletonPtr()->getShape( pEntity->getName() ); if( NULL != pShape ) { CollisionManager::getSingletonPtr()->destroyShape( pShape ); } CollisionObject* pObject = NULL; try { pObject = mCollisionContext->getAttachedObject( pEntity->getName() ); } catch( ... ) { return; } mCollisionContext->destroyObject( pObject ); } //------------------------------------------------------------------------- void World::doRayTest(const Ogre::Ray &ray, const Ogre::Real MaxDistance) { int ContactCount = 0; CollisionPair** ppCollisionPair = NULL; mCollisionContext->reset(); if ((ContactCount = mCollisionContext->rayCheck(ray, MaxDistance, COLLTYPE_EXACT, COLLTYPE_ALWAYS_EXACT, ppCollisionPair)) > 0) { mContactVector.clear(); for (int i = 0; i < ContactCount; i++) { mContactVector.push_back(ppCollisionPair[i]->contact); } } } //------------------------------------------------------------------------- Vector3* World::getContactPoint(void) { if (mContactVector.size() > 0) return &mContactVector[0]; else return NULL; } //------------------------------------------------------------------------- void World::generateHairs(CMesh *mesh) { int fIndex, vIndex; int fCount; int* triFlags; unsigned long* indices; Vector3* vertices; Vector3 *p1, *p2, *p3; map<Vector3*, Vector3*> vertexMap; vector<Vector3> inTriVertexList; typedef pair<Vector3*, Vector3*> VertexPair; int rootCount = 0; Vector3* normals; Vector3 fNormal; float curArea, maxArea = -1, minArea = 99999; // Retrieve the mesh data fCount = (int)mesh->getTriCount(); triFlags = mesh->getTriFlags(); indices = mesh->getIndices(); vertices = mesh->getVertices(); normals = mesh->getNormals(); // Calculate the number of hair roots for (fIndex = 0; fIndex < fCount; fIndex++) { if ((triFlags[fIndex] & CMesh::TF_SELECTED) && !(triFlags[fIndex] & CMesh::TF_BACKFACING)) { vIndex = fIndex*3; p1 = &vertices[indices[vIndex]]; p2 = &vertices[indices[vIndex+1]]; p3 = &vertices[indices[vIndex+2]]; vertexMap.insert(VertexPair(p1, p1)); vertexMap.insert(VertexPair(p2, p2)); vertexMap.insert(VertexPair(p3, p3)); } } Hair::cNumHairs = (int)vertexMap.size(); // Set the hair material //Hair::createHairMaterial(); // Allocate mAllHairs mAllHairs = new Hair[Hair::cNumHairs]; // Setup hair information and insert new roots if too sparse int hIndex = 0; vertexMap.clear(); for (fIndex = 0; fIndex < fCount; fIndex++) { if ((triFlags[fIndex] & CMesh::TF_SELECTED) && !(triFlags[fIndex] & CMesh::TF_BACKFACING)) { vIndex = fIndex*3; p1 = &vertices[indices[vIndex]]; p2 = &vertices[indices[vIndex+1]]; p3 = &vertices[indices[vIndex+2]]; fNormal = normals[fIndex]; // Set root position if (vertexMap.insert(VertexPair(p1, p1)).second) { mAllHairs[hIndex].setRootPos(*p1); mAllHairs[hIndex].initParticlePoses(fNormal); hIndex++; } if (vertexMap.insert(VertexPair(p2, p2)).second) { mAllHairs[hIndex].setRootPos(*p2); mAllHairs[hIndex].initParticlePoses(fNormal); hIndex++; } if (vertexMap.insert(VertexPair(p3, p3)).second) { mAllHairs[hIndex].setRootPos(*p3); mAllHairs[hIndex].initParticlePoses(fNormal); hIndex++; } // If face area is larger than the threshold, create new roots curArea = Utilities::getArea(*p1, *p2, *p3); if (curArea > TRI_AREA_THRESHOLD) generateHairsInsideTri(*p1, *p2, *p3, inTriVertexList, curArea, fNormal); // Statistics of triangle area if (curArea > maxArea) maxArea = curArea; if (curArea < minArea) minArea = curArea; } } cout << "minArea = " << minArea << ", maxArea = " << maxArea << endl; // Render hair roots ManualObject* rootPoints = mSceneMgr->createManualObject("HairRoots"); rootPoints->begin("BaseWhiteNoLighting", RenderOperation::OT_POINT_LIST); for (int i=0; i<Hair::cNumHairs; i++) { rootPoints->position(mAllHairs[i].getRootPos()); } rootPoints->end(); mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(rootPoints); } //---------------------------------------------------------------------------------------------------------------------------------------------- void World::generateHairsInsideTri(Ogre::Vector3 &p1, Ogre::Vector3 &p2, Ogre::Vector3 &p3, vector<Vector3>& vertexList, float area, Vector3& normal) { Vector3 midP1, midP2, midP3; Hair *tempHairs; int newVertexCount = 0; Vector3 newVertices[3]; // Get midpoints midP1 = p1.midPoint(p2); midP2 = p2.midPoint(p3); midP3 = p3.midPoint(p1); // Check if each midpoint is repeated if (!Utilities::isInList(midP1, vertexList)) { vertexList.push_back(midP1); newVertices[newVertexCount] = midP1; newVertexCount++; } if (!Utilities::isInList(midP2, vertexList)) { vertexList.push_back(midP2); newVertices[newVertexCount] = midP2; newVertexCount++; } if (!Utilities::isInList(midP3, vertexList)) { vertexList.push_back(midP3); newVertices[newVertexCount] = midP3; newVertexCount++; } //cout << "newVertexCount=" << newVertexCount << endl; if (newVertexCount != 0) { // Extend the size of mAllHairs tempHairs = new Hair[Hair::cNumHairs + newVertexCount]; for (int i = 0; i < Hair::cNumHairs; i++) { tempHairs[i] = mAllHairs[i]; } delete[] mAllHairs; mAllHairs = tempHairs; // Set 3 new roots for (int i = 0; i <newVertexCount; i++) { mAllHairs[Hair::cNumHairs+i].setRootPos(newVertices[i]); mAllHairs[Hair::cNumHairs+i].initParticlePoses(normal); } Hair::cNumHairs += newVertexCount; } float oneQuarterArea = area/4.0; // Recursively call self if the area is big enough if (oneQuarterArea > TRI_AREA_THRESHOLD) { generateHairsInsideTri(p1, midP1, midP3, vertexList, oneQuarterArea, normal); generateHairsInsideTri(midP1, p2, midP2, vertexList, oneQuarterArea, normal); generateHairsInsideTri(midP3, midP2, p3, vertexList, oneQuarterArea, normal); generateHairsInsideTri(midP1, midP2, midP3, vertexList, oneQuarterArea, normal); } } //------------------------------------------------------------------------- // Setup CollisionManager void World::setupCollisionManager() { // Create a CollisionManager and choose a SceneManager mCollisionMgr = new CollisionManager(mSceneMgr); CollisionManager::getSingletonPtr()->setSceneManager(mSceneMgr); // Add collision class and collision type CollisionManager::getSingletonPtr()->addCollClass("mCollClass"); CollisionManager::getSingletonPtr()->addCollType("mCollClass", "mCollClass", COLLTYPE_EXACT); } //------------------------------------------------------------------------- void World::handleProcessState() { switch(mProcessState) { case PS_INITIAL: break; case PS_SELECT_SCALP: break; case PS_GENERATION: break; case PS_SIMULATION: break; } } //------------------------------------------------------------------------- void World::updateHairs() { for (int i = 0; i < Hair::cNumHairs; i++) { mAllHairs[i].updateHairEdges(); } } void World::updateHairsSucks() { int i, j; std::vector<Strand>::const_iterator sPtr; std::vector<AppParticle>::const_iterator pPtr; for (i = 0, sPtr = mD_StrandSys.m_strandList.begin(); i < Hair::cNumHairs; i++, sPtr++) { for (j = 0, pPtr = sPtr->pList.begin(); j < Hair::cNumParticles; j++, pPtr++) mAllHairs[i].mParticlePoses[j] = pPtr->x; mAllHairs[i].updateHairEdges(); } } void World::updateHairsImproved() { int i; //std::vector<Strand>::const_iterator sPtr; //std::vector<AppParticle>::const_iterator pPtr; for (i = 0/*, sPtr = mD_StrandSys.m_strandList.begin()*/; i < Hair::cNumHairs; i++/*, sPtr++*/) { mAllHairs[i].updateHairEdgesImproved(); } } void World::checkAll() { for (int i = 0; i < Hair::cNumHairs; i++) { if (mAllHairs[i].getNumParticles() != Hair::cNumParticles) { cout << "Error of Num particles : mAllHairs[" << i << "].getNumParticles()=" << mAllHairs[i].getNumParticles() << endl; system("PAUSE"); exit(1); } } cout << "checkAll() passed" << endl; } //------------------------------------------------------------------------- void World::setupStrandSystem(CMesh* srcMesh) { mD_Mesh = new mesh(srcMesh); mD_StrandSys.setup(mAllHairs, mD_Mesh); cout << "strand system is set" << endl; } //------------------------------------------------------------------------- void World::stepStrandSystem() { for (int i = 0; i < 10; i++) mD_StrandSys.step(TIME_STEP); }
[ "grahamhuang@73147322-a748-11dd-a8c6-677c70d10fe4" ]
[ [ [ 1, 429 ] ] ]
6fae7be200ab2c6b26c80bbef44318f9e38049b8
d8a93d1a0152abf719b6d614a1871f7a65a940ba
/MovieVis/src/include/Movie.hpp
4c36131ac0082dd312368b9342e65bd5ff4885c2
[]
no_license
awshepard/movievis
be0d732e2e54d60ed1a31cd7c67e4ea6d26b0f5a
079432ec45baa98d67d976b28c14cd96116760c6
refs/heads/master
2021-01-18T22:35:58.479908
2010-07-09T04:48:33
2010-07-09T04:48:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,528
hpp
/** * \file Movie.hpp * \author Douglas W. Paul and Adam Shepard * * Declares the Movie class */ #pragma once #include "Person_pre.hpp" #include <vector> #include <string> #include <boost\smart_ptr\shared_ptr.hpp> #include <boost\smart_ptr\weak_ptr.hpp> #include <boost\date_time\gregorian\gregorian_types.hpp> #include <boost\functional\hash.hpp> using std::string; using std::vector; using boost::shared_ptr; using boost::weak_ptr; using boost::gregorian::date; using boost::hash; /** * A movie */ class Movie { public: /** Constructor */ Movie(string title, date releaseDate, double boxOfficeReceipts); /** Gets the movie's title */ string getTitle() const { return this->title; } /** Gets the movie's release date */ date getReleaseDate() const { return this->releaseDate; } /** Gets the directors for the movie */ const weak_ptr<Person> &getDirector() const { return this->director; } /** Gets the cast members for the movie */ const vector<weak_ptr<Person>> &getCastMembers() const { return this->castMembers; } /** Gets the USD total of box office receipts */ double getBoxOfficeReceipts() const { return this->boxOfficeReceipts; } /** Sets the director of the movie */ void setDirector(const shared_ptr<Person> &director); /** Adds a cast member to the movie */ void addCastMember(const shared_ptr<Person> &castMember); /** Sets the release date of the movie */ void setReleaseDate(const boost::gregorian::date d); /** Sets the box office results for the movie */ void setBoxOfficeReceipts(const double boxOffice); /** A sort predicate for sorting movies by release date */ static bool releaseDateSortPredicate(const Movie &m1, const Movie &m2) { return m1.getReleaseDate() < m2.getReleaseDate(); } /** A sort predicate for sorting weak movie pointers by release date */ static bool sharedPtrReleaseDateSortPredicate(const shared_ptr<Movie> &m1, const shared_ptr<Movie> &m2) { return m1->getReleaseDate() < m2->getReleaseDate(); } /** A sort predicate for sorting weak movie pointers by release date */ static bool weakPtrReleaseDateSortPredicate(const weak_ptr<Movie> &m1, const weak_ptr<Movie> &m2) { return m1.lock()->getReleaseDate() < m2.lock()->getReleaseDate(); } /** Determines whether two people are the same */ bool operator==(const Movie &otherMovie) const; struct hashConf { enum { bucket_size = 4, // 0 < bucket_size min_buckets = 8}; // min_buckets = 2 ^^ N, 0 < N size_t operator()(const Movie &movie) const { boost::hash<string> hasher; return hasher(movie.getTitle()); } size_t operator()(const shared_ptr<Movie> &movie) const { boost::hash<string> hasher; return hasher(movie->getTitle()); } bool operator()(const Movie &left, const Movie &right) const { return Movie::releaseDateSortPredicate(left, right); } bool operator()(const shared_ptr<Movie> &left, const shared_ptr<Movie> &right) const { return Movie::sharedPtrReleaseDateSortPredicate(left, right); } }; protected: /** The movie's title */ string title; /** The movie's release date */ date releaseDate; /** The USD total of box office receipts */ double boxOfficeReceipts; /** The movie's director */ weak_ptr<Person> director; /** The movie's cast members */ vector<weak_ptr<Person>> castMembers; /** The movie's year of release, used for identification */ double year; };
[ "douglyuckling@483a7388-aa76-4cae-9b69-882d6fd7d2f9" ]
[ [ [ 1, 123 ] ] ]
2b4b746261ba02893e3134d086a28365f3101de3
8902879a2619a8278c4dd064f62d8e0e8ffb4e3b
/dui2/UIElem.cpp
3d6ef51896148cd30cf5e3925464b66e62de5495
[ "BSD-2-Clause" ]
permissive
ArnCarveris/directui
4d9911143db125dfb114ca97a70f426dbd89dd79
da531f8bc7737f932c960906cc5f4481a0e162b8
refs/heads/master
2023-03-17T00:59:28.853973
2011-05-19T02:38:42
2011-05-19T02:38:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,414
cpp
#include "UIElem.h" #include "WinUtf8.h" namespace dui { static Graphics *SetupGraphics(Graphics *g) { g->SetPageUnit(UnitPixel); g->SetCompositingMode(CompositingModeSourceOver); g->SetInterpolationMode(InterpolationModeHighQualityBicubic); g->SetSmoothingMode(SmoothingModeHighQuality); g->SetTextRenderingHint(TextRenderingHintAntiAlias); g->SetPixelOffsetMode(PixelOffsetModeHighQuality); return g; } void UIPainter::PaintBegin(HWND hwnd, ARGB bgColor) { this->hwnd = hwnd; BeginPaint(hwnd,&ps); RECT rc; GetClientRect(hwnd, &rc); if (!bmp || (RectDx(rc) > (int)bmp->GetWidth()) || (RectDy(rc) > (int)bmp->GetHeight())) { // TODO: use CachedBitmap() ? delete bmp; delete gfx; bmp = new Bitmap(RectDx(rc), RectDy(rc), PixelFormat32bppARGB); gfx = new Graphics(bmp); SetupGraphics(gfx); } if (bgColor != Color::Transparent) { gfx->FillRectangle(&SolidBrush(Color(bgColor)), RectFromRECT(rc)); } } void UIPainter::PaintUIElem(UIElem* el) { if (gfx && el && el->IsVisible()) { el->Draw(gfx); } } void UIPainter::PaintEnd() { // TODO: clip child hwnd windows // TODO: only blit the part in ps.rcPaint Graphics g(ps.hdc); g.DrawImage(bmp, 0, 0); EndPaint(hwnd, &ps); hwnd = 0; } #define WIN_HWND_CLS_NAME "WinHwndCls" void WinHwnd::OnPaint() { MillisecondTimer t; t.Start(); painter.PaintBegin(hwnd, Color::Blue); painter.PaintUIElem(uiRoot); painter.PaintEnd(); double ms = t.GetCurrTimeInMs(); str::d("OnPaint(): %.2f ms\n", ms); } void WinHwnd::OnSize(int dx, int dy) { RECT r = {0, 0, dx, dy}; InflateRect(&r, -20, -20); uiRoot->SetPosition(r); } void WinHwnd::OnSettingsChanged() { ULONG scrollLines; SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, 0); // scrollLines usually equals 3 or 0 (for no scrolling) // WHEEL_DELTA equals 120, so deltaPerLine will be 40 deltaPerLine = 0; if (scrollLines) deltaPerLine = WHEEL_DELTA / scrollLines; } void WinHwnd::OnFinalMessage(HWND hwnd) { PostQuitMessage(0); } LRESULT CALLBACK WinHwnd::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { WinHwnd* win = NULL; if (WM_ERASEBKGND == uMsg) return TRUE; if (WM_NCCREATE == uMsg) { CREATESTRUCT *lpcs = (CREATESTRUCT*)lParam; win = (WinHwnd*)lpcs->lpCreateParams; win->hwnd = hWnd; ::SetWindowLongPtr(hWnd, GWLP_USERDATA, (LPARAM)win); win->OnSettingsChanged(); goto Exit; } win = (WinHwnd*)::GetWindowLongPtr(hWnd, GWLP_USERDATA); if (!win) goto Exit; if (WM_NCDESTROY == uMsg) { LRESULT res = ::CallWindowProc(win->oldWndProc, hWnd, uMsg, wParam, lParam); ::SetWindowLongPtr(win->hwnd, GWLP_USERDATA, 0L); //if (win->m_subclassed) win->Unsubclass(); win->hwnd = NULL; win->OnFinalMessage(hWnd); return res; } if (WM_PAINT == uMsg) { win->OnPaint(); return 0; } if (WM_SIZE == uMsg) { if (SIZE_MINIMIZED != wParam) { win->OnSize(LOWORD(lParam), HIWORD(lParam)); } goto Exit; } if (WM_SETTINGCHANGE == uMsg) { win->OnSettingsChanged(); return 0; } Exit: if (win) { return win->HandleMessage(uMsg, wParam, lParam); } else { return ::DefWindowProc(hWnd, uMsg, wParam, lParam); } } LRESULT WinHwnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { return ::CallWindowProc(oldWndProc, hwnd, uMsg, wParam, lParam); } void WinHwnd::Show(bool show, bool takeFocus) { ::ShowWindow(hwnd, show ? (takeFocus ? SW_SHOWNORMAL : SW_SHOWNOACTIVATE) : SW_HIDE); if (show) ::UpdateWindow(hwnd); } WinHwnd::~WinHwnd() { delete uiRoot; } void WinHwnd::SetUIRoot(UIElem *root) { delete uiRoot; uiRoot = root; uiRoot->SetHwndParent(hwnd); } static void RegisterWinHwndClass(HINSTANCE hinst) { WNDCLASSA wc = { 0 }; // TODO: don't set CS_*REDRAW and instead schedule repaint in WM_SIZE // to improve fluidity during resize? wc.style = CS_HREDRAW | CS_VREDRAW; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hIcon = NULL; wc.lpfnWndProc = WinHwnd::WndProc; wc.hInstance = hinst; wc.hCursor = ::LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = NULL; wc.lpszMenuName = NULL; wc.lpszClassName = WIN_HWND_CLS_NAME; // it's safe to register a class twice (it'll return an error // and GetLastError()will be ERROR_CLASS_ALREADY_EXISTS) ::RegisterClassA(&wc); } void WinHwnd::Create(UIElem *root, const char* name, DWORD dwStyle, DWORD dwExStyle, int x, int y, int dx, int dy, HMENU hMenu) { RegisterWinHwndClass(hinst); hwnd = ::CreateWindowExUtf8(dwExStyle, WIN_HWND_CLS_NAME, name, dwStyle, x, y, dx, dy, NULL, hMenu, hinst, this); if (root) SetUIRoot(root); } void WinHwnd::Create(UIElem *root, const char* name, DWORD dwStyle, DWORD dwExStyle, const RECT rc, HMENU hMenu) { Create(root, name, dwStyle, dwExStyle, rc.left, rc.top, RectDx(rc), RectDy(rc), hMenu); } UIElem *UIElem::ChildFromPoint(int x, int y) { if (!children) return NULL; for (size_t i=0; i<children->Count(); i++) { UIElem *el = children->At(i); if (!el->IsVisible()) continue; if (PointIn(el->pos, x, y)) { UIElem *el2 = el->ChildFromPoint(el->pos.left + x, el->pos.top + y); if (el2) return el2; return el; } } return NULL; } void UIElem::DrawChildren(Graphics *g) { if (!children) return; for (size_t i=0; i<children->Count(); i++) { UIElem *el = children->At(i); if (el->IsVisible()) { el->Draw(g); } } } void UIRectangle::Draw(Graphics *g) { Rect r(RectFromRECT(pos)); ARGB c = Color::MakeARGB(75,255,255,255); g->FillRectangle(&SolidBrush(c), r); DrawChildren(g); } static bool PreTranslateMessage(const MSG* pMsg) { #if 0 // Pretranslate Message takes care of system-wide messages, such as // tabbing and shortcut key-combos. We'll look for all messages for // each window and any child control attached. HWND hwndParent = ::GetParent(pMsg->hwnd); UINT uStyle = GetWindowStyle(pMsg->hwnd); LRESULT lRes = 0; for (int i = 0; i < m_preMessages.GetSize(); i++) { PaintManagerUI* pT = static_cast<PaintManagerUI*>(m_preMessages[i]); if (pMsg->hwnd == pT->GetPaintWindow() || (hwndParent == pT->GetPaintWindow() && ((uStyle & WS_CHILD) != 0))) { if (pT->PreMessageHandler(pMsg->message, pMsg->wParam, pMsg->lParam, lRes)) return true; } } #endif return false; } void MessageLoop() { MSG msg = { 0 }; while (::GetMessage(&msg, NULL, 0, 0)) { if (!PreTranslateMessage(&msg)) { ::TranslateMessage(&msg); ::DispatchMessage(&msg); } } } }
[ [ [ 1, 280 ] ] ]
006ca5418bb264256b1455cf43680f9b954c59bb
8f816734df7cb71af9c009fa53eeb80a24687e63
/RenderSystem/src/Texture.cpp
37001dd0e378fc5ad02c390ce94a3ce2714f8625
[]
no_license
terepe/rpgskyengine
46a3a09a1f4d07acf1a04a1bcefff2a9aabebf56
fbe0ddc86440025d9670fc39fb7ca72afa223953
refs/heads/master
2021-01-23T13:18:32.028357
2011-06-01T13:35:16
2011-06-01T13:35:16
35,915,383
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
8,834
cpp
#include "Texture.h" #include "IORead.h" #include "Color.h" #include "ddslib.h" #include "RenderSystem.h" void DecompressDXTC(int formatDXT, int w, int h, size_t size, unsigned char *src, unsigned char *dest) { // sort of copied from linghuye int bsx = (w<4) ? w : 4; int bsy = (h<4) ? h : 4; /* if (format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) { DDSDecompressDXT1(src, w, h, dest); return; } */ if (formatDXT == 3)//D3DFMT_DXT3 { DDSDecompressDXT3(src, w, h, dest); for(int y=0; y<h; y ++) { for(int x=0; x<w; x ++) { unsigned int* pixel = (unsigned int*) (dest + (x + y * w)*4); *pixel = (*pixel&0xFF000000) | ((*pixel&0x00FF0000)>>16) | ((*pixel&0x0000FF00)) | ((*pixel& 0x000000FF)<<16); } } return; } /* if (format == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT) { DXT5UnpackAlphaValues(src, w, h, dest); return; } */ for(int y=0; y<h; y += bsy) { for(int x=0; x<w; x += bsx) { //unsigned long alpha = 0; //unsigned int a0 = 0, a1 = 0; unsigned int c0 = *(unsigned short*)(src + 0); unsigned int c1 = *(unsigned short*)(src + 2); src += 4; Color32 color[4]; color[0].b = (unsigned char) ((c0 >> 11) & 0x1f) << 3; color[0].g = (unsigned char) ((c0 >> 5) & 0x3f) << 2; color[0].r = (unsigned char) ((c0) & 0x1f) << 3; color[1].b = (unsigned char) ((c1 >> 11) & 0x1f) << 3; color[1].g = (unsigned char) ((c1 >> 5) & 0x3f) << 2; color[1].r = (unsigned char) ((c1) & 0x1f) << 3; if(c0 > c1 || formatDXT == 3) { color[2].r = (color[0].r * 2 + color[1].r) / 3; color[2].g = (color[0].g * 2 + color[1].g) / 3; color[2].b = (color[0].b * 2 + color[1].b) / 3; color[3].r = (color[0].r + color[1].r * 2) / 3; color[3].g = (color[0].g + color[1].g * 2) / 3; color[3].b = (color[0].b + color[1].b * 2) / 3; } else { color[2].r = (color[0].r + color[1].r) / 2; color[2].g = (color[0].g + color[1].g) / 2; color[2].b = (color[0].b + color[1].b) / 2; color[3].r = 0; color[3].g = 0; color[3].b = 0; } for (int j=0; j<bsy; j++) { unsigned int index = *src++; unsigned char* dd = dest + (w*(y+j)+x)*4; for (int i=0; i<bsx; i++) { *dd++ = color[index & 0x03].r; *dd++ = color[index & 0x03].g; *dd++ = color[index & 0x03].b; //if (format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) { *dd++ = ((index & 0x03) == 3 && c0 <= c1) ? 0 : 255; //} index >>= 2; } } } } } void Decompress256Palette(int w, int h, size_t alphaBits, void* src, void* pal, void* dest) { int cnt = 0; int alpha = 0; unsigned int* p = static_cast<unsigned int*>(dest); unsigned char *c = static_cast<unsigned char*>(src); unsigned char *a = c + w*h; for (int y=0; y<h; y++) { for (int x=0; x<w; x++) { unsigned int k = static_cast<unsigned int*>(pal)[*c++]; k = ((k&0x00FF0000)>>16) | ((k&0x0000FF00)) | ((k& 0x000000FF)<<16); if (alphaBits!=0) { if (alphaBits == 8) { alpha = (*a++); } else if (alphaBits == 1) { alpha = (*a & (1 << cnt++)) ? 0xff : 0; if (cnt == 8) { cnt = 0; a++; } } } else { alpha = 0xff; } k |= alpha << 24; *p++ = k; } } } bool CTexture::createFromBLP(void* pBuf, int nSize, int nLevels) { // BLP int offsets[16], sizes[16], w, h; int format; char attr[4]; unsigned int* pointer = static_cast<unsigned int*>(pBuf); pointer+=2; memcpy(attr,pointer,4); pointer++; memcpy(&w,pointer,4); pointer++; memcpy(&h,pointer,4); pointer++; memcpy(offsets,pointer,4*16); pointer+=16; memcpy(sizes,pointer,4*16); pointer+=16; bool hasmipmaps = attr[3]>0; int mipmax = hasmipmaps ? 16 : 1; createTexture(w, h, mipmax, true); if (attr[0] == 2) // compressed { bool supportCompression = false; unsigned char *ucbuf = NULL; if (!supportCompression) { ucbuf = new unsigned char[w*h*4]; } format = 1;//D3DFMT_DXT1;///GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; int blocksize = 8; // guesswork here :( if (attr[1]==8) { format = 3;//D3DFMT_DXT3;//GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; blocksize = 16; } else { if (!attr[3]) format = 1;//D3DFMT_DXT1;//GL_COMPRESSED_RGB_S3TC_DXT1_EXT; } // do every mipmap level for (int i=0; i<mipmax; i++) { if (w==0) w = 1; if (h==0) h = 1; if (offsets[i] && sizes[i]) { unsigned char* buf = static_cast<unsigned char*>(pBuf)+offsets[i]; int nSize = ((w+3)/4) * ((h+3)/4) * blocksize; if (supportCompression) { //D3DXCreateTextureFromFileInMemoryEx(DXUTGetD3DDevice(),buf,nSize,w, h,0,0, // format, // D3DPOOL_MANAGED,D3DX_FILTER_BOX, D3DX_DEFAULT,0, NULL, NULL, &m_pd3dTexture); //D3DXCreateTextureFromFile(DXUTGetD3DDevice(), buf, nSize, &m_pd3dTexture); //glCompressedTexImage2DARB(GL_TEXTURE_2D, i, format, w, h, 0, nSize, buf); } else { DecompressDXTC(format, w, h, nSize, buf, ucbuf); FillLevel(ucbuf, nSize, w, h, i); } } else { break; } w >>= 1; h >>= 1; } if (!supportCompression) { delete[] ucbuf; } } else if (attr[0]==1) // uncompressed { unsigned int* pal = pointer; unsigned int *buf2 = new unsigned int[w*h]; int nSize = w*h*4; for (int i=0; i<mipmax; i++) { if (w==0) w = 1; if (h==0) h = 1; if (offsets[i] && sizes[i]) { unsigned char* buf = static_cast<unsigned char*>(pBuf)+offsets[i]; Decompress256Palette(w,h,attr[1],buf, pal,buf2); FillLevel(buf2, nSize, w, h, i); } else break; w >>= 1; h >>= 1; } delete[] buf2; } // ´¢´æ //{ // std::string strTempTex("TempTex\\"); // strTempTex.append(m_strName); // strTempTex.append(".bmp"); // for (int i = 9; i<strTempTex.length(); i++) // { // if (strTempTex[i]=='\\') // { // strTempTex[i]='_'; // } // } // SaveToFile(strTempTex); //} return true; } CTexture::CTexture(): m_bPoolManaged(true), m_bLoaded(false), m_nLevels(0), m_nWidth(0), m_nHeight(0), m_eTexType(TEX_TYPE_UNKNOWN), m_pTextureMgr(NULL) { } CTexture::~CTexture(void) { if (m_pTextureMgr) { m_pTextureMgr->remove(this); } } void CTexture::load() { if (m_strFilename.length()>0) { createTextureFromFile(m_strFilename,m_nLevels); m_bLoaded = true; } } void CTexture::setTextureMgr(CTextureMgr* pTextureMgr) { m_pTextureMgr = pTextureMgr; } #include "FileSystem.h" bool CTexture::createTextureFromFile(const std::string& strFilename, int nLevels) { IOReadBase* pRead = IOReadBase::autoOpen(strFilename); if (pRead) { char* pBuf = new char[pRead->GetSize()]; if (pBuf) { pRead->Read(pBuf, pRead->GetSize()); std::string strExtension = GetExtension(strFilename); if (".blp"==strExtension) createFromBLP(pBuf, pRead->GetSize(), nLevels); else if (".ozj"==strExtension) createTextureFromFileInMemory(pBuf+24, pRead->GetSize()-24, nLevels); else if (".ozt"==strExtension) createTextureFromFileInMemory(pBuf+4, pRead->GetSize()-4, nLevels); else if (".ozb"==strExtension) createTextureFromFileInMemory(pBuf+4, pRead->GetSize()-4, nLevels); else createTextureFromFileInMemory(pBuf, pRead->GetSize(), nLevels); delete[] pBuf; } IOReadBase::autoClose(pRead); return true; } return false; } void CTexture::createTextureFromMemory(void* pBuf, int nSize, int nWidth, int nHeight, int nLevels) { createTexture(nWidth, nHeight, nLevels, true); FillLevel(pBuf, nSize, nWidth, nHeight, 0); Filter(0, m_nLevels); } void CTexture::Filter(int nSrcLevel, int nFilter) { //int w = nWidth; //int n = nHeight; //unsigned long* buffer = new unsigned long[w*n]; //for (int i=1; i<16; i++) //{ // unsigned long* p = buffer; // w >>= 1; // h >>= 1; // if (w==0) w = 1; // if (h==0) h = 1; // for(int y=0; y<h; y++) // { // for(int x=0; x<w; x++) // { // p=p[x] // } // } //} } void CTexture::reset() { releaseBuffer(); switch(m_eTexType) { case TEX_TYPE_FORM_FILE: createTextureFromFile(m_strFilename, m_nLevels); break; case TEX_TYPE_NORMAL: createTexture(m_nWidth, m_nHeight, m_nLevels, m_bPoolManaged); break; case TEX_TYPE_DYNAMIC: createDynamicTexture(m_nWidth, m_nHeight); break; case TEX_TYPE_CUBETEXTURE: createTexture(m_nWidth, m_nHeight, m_nLevels, m_bPoolManaged); break; case TEX_TYPE_RENDERTARGET: createRenderTarget(m_nWidth, m_nHeight); break; case TEX_TYPE_DEPTHSTENCIL: createDepthStencil(m_nWidth, m_nHeight); break; default: break; } }
[ "rpgsky.com@97dd8ffa-095c-11df-8772-5d79768f539e" ]
[ [ [ 1, 373 ] ] ]
6b5a532e4ea9a1c001b42c773c1ba5140383b017
59166d9d1eea9b034ac331d9c5590362ab942a8f
/osgViewerSL/main.cpp
faf8a483e846ad1843a711c24834942c29c97d5a
[]
no_license
seafengl/osgtraining
5915f7b3a3c78334b9029ee58e6c1cb54de5c220
fbfb29e5ae8cab6fa13900e417b6cba3a8c559df
refs/heads/master
2020-04-09T07:32:31.981473
2010-09-03T15:10:30
2010-09-03T15:10:30
40,032,354
0
3
null
null
null
null
UTF-8
C++
false
false
10,147
cpp
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield * * This application is open source and may be redistributed and/or modified * freely and without restriction, both in commericial and non commericial applications, * as long as this copyright notice is maintained. * * This application 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. */ #include <osgDB/ReadFile> #include <osgUtil/Optimizer> #include <osg/CoordinateSystemNode> #include <osg/Switch> #include <osgText/Text> #include <osgViewer/Viewer> #include <osgViewer/ViewerEventHandlers> #include <osgGA/TrackballManipulator> #include <osgGA/FlightManipulator> #include <osgGA/DriveManipulator> #include <osgGA/KeySwitchMatrixManipulator> #include <osgGA/StateSetManipulator> #include <osgGA/AnimationPathManipulator> #include <osgGA/TerrainManipulator> #include "SilverLining.h" #include "SkyDrawable.h" #include "CloudsDrawable.h" #include "AtmosphereReference.h" #include "SilverLiningProjectionMatrixCallback.h" #include <iostream> void integrateSilverLining(osg::ref_ptr<osg::Node> sceneGraphRoot, osgViewer::Viewer& viewer) { // No need for OSG to clear the color buffer, the sky will fill it for you. viewer.getCamera()->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Instantiate an Atmosphere and associate it with this camera. If you have multiple cameras // in multiple contexts, be sure to instantiate seperate Atmosphere objects for each. SilverLining::Atmosphere *atm = new SilverLining::Atmosphere( "SilverLining Demo" , "031b0d15111b2f0802492f1454360a0300" ); // Add the sky (calls Atmosphere::BeginFrame and handles initialization once you're in // the rendering thread) osg::Geode *skyGeode = new osg::Geode; SkyDrawable *skyDrawable = new SkyDrawable(&viewer); // ***IMPORTANT!**** Check that the path to the resources folder for SilverLining in SkyDrawable.cpp // SkyDrawable::initializeSilverLining matches with where you installed SilverLining. skyGeode->addDrawable(skyDrawable); skyGeode->setCullingActive(false); /* If you let OSG auto-calculate the near and far clip planes; it'll exclude the sky box and clouds. One solution is to set the near and far clip planes explicitly like this: */ viewer.getCamera()->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); double fovy, aspect, zNear, zFar; viewer.getCamera()->getProjectionMatrixAsPerspective(fovy, aspect, zNear, zFar); viewer.getCamera()->setProjectionMatrixAsPerspective(45.0 , 1050.0 / 1680.0 , 1.0 , 30000.0); /* or, you can use the included projection matrix callback to intercept how OSG computes the near and far clip planes and take SilverLining's objects into account, like this: */ //SilverLiningProjectionMatrixCallback *cb = new SilverLiningProjectionMatrixCallback( // atm, viewer.getCamera()); // viewer.getCamera()->setClampProjectionMatrixCallback(cb); // cb->setSkyDrawable(skyDrawable); AtmosphereReference *ar = new AtmosphereReference; ar->atmosphere = atm; viewer.getCamera()->setUserData(ar); // Use a RenderBin to enforce that the sky gets drawn first, then the scene, then the clouds skyGeode->getOrCreateStateSet()->setRenderBinDetails(-1, "RenderBin"); // Add the models sceneGraphRoot.get()->getOrCreateStateSet()->setRenderBinDetails(1, "RenderBin"); // Add the clouds (note, you need this even if you don't want clouds - it calls // Atmosphere::EndFrame() ) osg::Geode *cloudsGeode = new osg::Geode; cloudsGeode->addDrawable(new CloudsDrawable(&viewer)); cloudsGeode->getOrCreateStateSet()->setRenderBinDetails(99, "RenderBin"); cloudsGeode->setCullingActive(false); viewer.getSceneData()->asGroup()->addChild(skyGeode); viewer.getSceneData()->asGroup()->addChild(cloudsGeode); } int main(int argc, char** argv) { // Our code doesn't handle multiple displays; you need to associate an Atmosphere with each context in // that case. So, we'll force a single window / context. putenv("OSG_WINDOW=20 30 1024 768"); // use an ArgumentParser object to manage the program arguments. osg::ArgumentParser arguments(&argc,argv); arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName()); arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the standard OpenSceneGraph example which loads and visualises 3d models."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); arguments.getApplicationUsage()->addCommandLineOption("--image <filename>","Load an image and render it on a quad"); arguments.getApplicationUsage()->addCommandLineOption("--dem <filename>","Load an image/DEM and render it on a HeightField"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display command line parameters"); arguments.getApplicationUsage()->addCommandLineOption("--help-env","Display environmental variables available"); arguments.getApplicationUsage()->addCommandLineOption("--help-keys","Display keyboard & mouse bindings available"); arguments.getApplicationUsage()->addCommandLineOption("--help-all","Display all command line, env vars and keyboard & mouse bindings."); arguments.getApplicationUsage()->addCommandLineOption("--SingleThreaded","Select SingleThreaded threading model for viewer."); arguments.getApplicationUsage()->addCommandLineOption("--CullDrawThreadPerContext","Select CullDrawThreadPerContext threading model for viewer."); arguments.getApplicationUsage()->addCommandLineOption("--DrawThreadPerContext","Select DrawThreadPerContext threading model for viewer."); arguments.getApplicationUsage()->addCommandLineOption("--CullThreadPerCameraDrawThreadPerContext","Select CullThreadPerCameraDrawThreadPerContext threading model for viewer."); // if user request help write it out to cout. bool helpAll = arguments.read("--help-all"); unsigned int helpType = ((helpAll || arguments.read("-h") || arguments.read("--help"))? osg::ApplicationUsage::COMMAND_LINE_OPTION : 0 ) | ((helpAll || arguments.read("--help-env"))? osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE : 0 ) | ((helpAll || arguments.read("--help-keys"))? osg::ApplicationUsage::KEYBOARD_MOUSE_BINDING : 0 ); if (helpType) { arguments.getApplicationUsage()->write(std::cout, helpType); return 1; } osgViewer::Viewer viewer(arguments); // report any errors if they have occurred when parsing the program arguments. if (arguments.errors()) { arguments.writeErrorMessages(std::cout); return 1; } if (arguments.argc()<=1) { arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); return 1; } // set up the camera manipulators. { osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator; keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() ); keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() ); keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() ); keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() ); std::string pathfile; char keyForAnimationPath = '5'; while (arguments.read("-p",pathfile)) { osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile); if (apm || !apm->valid()) { unsigned int num = keyswitchManipulator->getNumMatrixManipulators(); keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm ); keyswitchManipulator->selectMatrixManipulator(num); ++keyForAnimationPath; } } viewer.setCameraManipulator( keyswitchManipulator.get() ); } // add the state manipulator viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) ); // add the thread model handler viewer.addEventHandler(new osgViewer::ThreadingHandler); // add the window size toggle handler viewer.addEventHandler(new osgViewer::WindowSizeHandler); // add the stats handler viewer.addEventHandler(new osgViewer::StatsHandler); // add the help handler viewer.addEventHandler(new osgViewer::HelpHandler(arguments.getApplicationUsage())); // add the record camera path handler viewer.addEventHandler(new osgViewer::RecordCameraPathHandler); // add the LOD Scale handler viewer.addEventHandler(new osgViewer::LODScaleHandler); // load the data osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments); if (!loadedModel) { std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl; return 1; } // any option left unread are converted into errors to write out later. arguments.reportRemainingOptionsAsUnrecognized(); // report any errors if they have occurred when parsing the program arguments. if (arguments.errors()) { arguments.writeErrorMessages(std::cout); return 1; } // optimize the scene graph, remove redundant nodes and state etc. osgUtil::Optimizer optimizer; optimizer.optimize(loadedModel.get()); viewer.setSceneData( loadedModel.get() ); integrateSilverLining(loadedModel, viewer); viewer.realize(); return viewer.run(); }
[ "asmzx79@3290fc28-3049-11de-8daa-cfecb5f7ff5b" ]
[ [ [ 1, 225 ] ] ]
80555588bf97f0f2783b435cfcf4aae103e365c9
be7df324d5509c7ebb368c884b53ea9445d32e4f
/GUI/dicomConvert/ui_dcmDlg.h
6e9bee7552a7b24497048d6dc91a425aea45c685
[]
no_license
shadimsaleh/thesis.code
b75281001aa0358282e9cceefa0d5d0ecfffdef1
085931bee5b07eec9e276ed0041d494c4a86f6a5
refs/heads/master
2021-01-11T12:20:13.655912
2011-10-19T13:34:01
2011-10-19T13:34:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,353
h
/******************************************************************************** ** Form generated from reading ui file 'dcmDlg.ui' ** ** Created: Mon Nov 24 15:37:26 2008 ** by: Qt User Interface Compiler version 4.4.0 ** ** WARNING! All changes made in this file will be lost when recompiling ui file! ********************************************************************************/ #ifndef UI_DCMDLG_H #define UI_DCMDLG_H #include <QtCore/QVariant> #include <QtGui/QAction> #include <QtGui/QApplication> #include <QtGui/QButtonGroup> #include <QtGui/QComboBox> #include <QtGui/QDialog> #include <QtGui/QGridLayout> #include <QtGui/QHBoxLayout> #include <QtGui/QLabel> #include <QtGui/QPushButton> #include <QtGui/QSpacerItem> #include <QtGui/QTreeWidget> #include <QtGui/QVBoxLayout> QT_BEGIN_NAMESPACE class Ui_dcmDlg { public: QGridLayout *gridLayout; QVBoxLayout *vboxLayout; QPushButton *m_pScanBut; QPushButton *m_pSave3dBut; QPushButton *m_pSave4dBut; QSpacerItem *spacerItem; QLabel *m_lblPreview; QPushButton *m_pDirBrowseBut; QHBoxLayout *hboxLayout; QLabel *label; QComboBox *m_pDcmDir; QTreeWidget *m_pPreview; void setupUi(QDialog *dcmDlg) { if (dcmDlg->objectName().isEmpty()) dcmDlg->setObjectName(QString::fromUtf8("dcmDlg")); dcmDlg->resize(694, 513); gridLayout = new QGridLayout(dcmDlg); #ifndef Q_OS_MAC gridLayout->setSpacing(6); #endif #ifndef Q_OS_MAC gridLayout->setMargin(9); #endif gridLayout->setObjectName(QString::fromUtf8("gridLayout")); vboxLayout = new QVBoxLayout(); #ifndef Q_OS_MAC vboxLayout->setSpacing(6); #endif #ifndef Q_OS_MAC vboxLayout->setMargin(0); #endif vboxLayout->setObjectName(QString::fromUtf8("vboxLayout")); m_pScanBut = new QPushButton(dcmDlg); m_pScanBut->setObjectName(QString::fromUtf8("m_pScanBut")); vboxLayout->addWidget(m_pScanBut); m_pSave3dBut = new QPushButton(dcmDlg); m_pSave3dBut->setObjectName(QString::fromUtf8("m_pSave3dBut")); vboxLayout->addWidget(m_pSave3dBut); m_pSave4dBut = new QPushButton(dcmDlg); m_pSave4dBut->setObjectName(QString::fromUtf8("m_pSave4dBut")); vboxLayout->addWidget(m_pSave4dBut); spacerItem = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); vboxLayout->addItem(spacerItem); m_lblPreview = new QLabel(dcmDlg); m_lblPreview->setObjectName(QString::fromUtf8("m_lblPreview")); QSizePolicy sizePolicy(static_cast<QSizePolicy::Policy>(0), static_cast<QSizePolicy::Policy>(0)); sizePolicy.setHorizontalStretch(0); sizePolicy.setVerticalStretch(0); sizePolicy.setHeightForWidth(m_lblPreview->sizePolicy().hasHeightForWidth()); m_lblPreview->setSizePolicy(sizePolicy); m_lblPreview->setMinimumSize(QSize(128, 128)); m_lblPreview->setMaximumSize(QSize(128, 128)); m_lblPreview->setFrameShape(QFrame::StyledPanel); m_lblPreview->setScaledContents(true); m_lblPreview->setAlignment(Qt::AlignCenter); vboxLayout->addWidget(m_lblPreview); gridLayout->addLayout(vboxLayout, 1, 1, 1, 1); m_pDirBrowseBut = new QPushButton(dcmDlg); m_pDirBrowseBut->setObjectName(QString::fromUtf8("m_pDirBrowseBut")); gridLayout->addWidget(m_pDirBrowseBut, 0, 1, 1, 1); hboxLayout = new QHBoxLayout(); #ifndef Q_OS_MAC hboxLayout->setSpacing(6); #endif hboxLayout->setMargin(0); hboxLayout->setObjectName(QString::fromUtf8("hboxLayout")); label = new QLabel(dcmDlg); label->setObjectName(QString::fromUtf8("label")); QSizePolicy sizePolicy1(static_cast<QSizePolicy::Policy>(5), static_cast<QSizePolicy::Policy>(5)); sizePolicy1.setHorizontalStretch(0); sizePolicy1.setVerticalStretch(0); sizePolicy1.setHeightForWidth(label->sizePolicy().hasHeightForWidth()); label->setSizePolicy(sizePolicy1); hboxLayout->addWidget(label); m_pDcmDir = new QComboBox(dcmDlg); m_pDcmDir->setObjectName(QString::fromUtf8("m_pDcmDir")); QSizePolicy sizePolicy2(static_cast<QSizePolicy::Policy>(7), static_cast<QSizePolicy::Policy>(0)); sizePolicy2.setHorizontalStretch(0); sizePolicy2.setVerticalStretch(0); sizePolicy2.setHeightForWidth(m_pDcmDir->sizePolicy().hasHeightForWidth()); m_pDcmDir->setSizePolicy(sizePolicy2); m_pDcmDir->setEditable(true); hboxLayout->addWidget(m_pDcmDir); gridLayout->addLayout(hboxLayout, 0, 0, 1, 1); m_pPreview = new QTreeWidget(dcmDlg); m_pPreview->setObjectName(QString::fromUtf8("m_pPreview")); gridLayout->addWidget(m_pPreview, 1, 0, 1, 1); retranslateUi(dcmDlg); QMetaObject::connectSlotsByName(dcmDlg); } // setupUi void retranslateUi(QDialog *dcmDlg) { dcmDlg->setWindowTitle(QApplication::translate("dcmDlg", "Dicom Import Dialog", 0, QApplication::UnicodeUTF8)); m_pScanBut->setText(QApplication::translate("dcmDlg", "&Scan", 0, QApplication::UnicodeUTF8)); m_pSave3dBut->setText(QApplication::translate("dcmDlg", "Save 3D", 0, QApplication::UnicodeUTF8)); m_pSave4dBut->setText(QApplication::translate("dcmDlg", "Save 4D", 0, QApplication::UnicodeUTF8)); m_lblPreview->setText(QApplication::translate("dcmDlg", "Preview", 0, QApplication::UnicodeUTF8)); m_pDirBrowseBut->setText(QApplication::translate("dcmDlg", "&Browse ...", 0, QApplication::UnicodeUTF8)); label->setText(QApplication::translate("dcmDlg", "<html><head><meta name=\"qrichtext\" content=\"1\" /></head><body style=\" white-space: pre-wrap; font-family:Sans Serif; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;\"><p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Choose <span style=\" font-weight:600;\">Directory</span>:</p></body></html>", 0, QApplication::UnicodeUTF8)); #ifndef QT_NO_TOOLTIP m_pDcmDir->setToolTip(QApplication::translate("dcmDlg", "The Dicom Directory", 0, QApplication::UnicodeUTF8)); #endif // QT_NO_TOOLTIP Q_UNUSED(dcmDlg); } // retranslateUi }; namespace Ui { class dcmDlg: public Ui_dcmDlg {}; } // namespace Ui QT_END_NAMESPACE #endif // UI_DCMDLG_H
[ [ [ 1, 174 ] ] ]
169c5b9eddae42199a6520ce28bbb36450cb1023
299a1b0fca9e1de3858a5ebeaf63be6dc3a02b48
/tags/051101/dingus/dingus/renderer/RenderableSkin.cpp
43f08316bcb0b0659d0df028d3844b0bc1225a77
[]
no_license
BackupTheBerlios/dingus-svn
331d7546a6e7a5a3cb38ffb106e57b224efbf5df
1223efcf4c2079f58860d7fa685fa5ded8f24f32
refs/heads/master
2016-09-05T22:15:57.658243
2006-09-02T10:10:47
2006-09-02T10:10:47
40,673,143
0
0
null
null
null
null
UTF-8
C++
false
false
3,169
cpp
// -------------------------------------------------------------------------- // Dingus project - a collection of subsystems for game/graphics applications // -------------------------------------------------------------------------- #include "stdafx.h" #include "RenderableSkin.h" #include "RenderContext.h" #include "../utils/Errors.h" #include "../kernel/D3DDevice.h" using namespace dingus; DEFINE_POOLED_ALLOC(dingus::CRenderableSkin,128,false); CRenderableSkin::TVec3Vector CRenderableSkin::mPaletteSkinMatrices; CRenderableSkin::CRenderableSkin( CSkinMesh& mesh, int group, const SVector3* skinMatrices, CEffectParams::TParamName matsParamName, CEffectParams::TParamName bonesParamName, const SVector3* origin, int priority ) : CRenderable( origin, priority ), mMesh( &mesh ), mGroup( group ), mSkinMatrices( skinMatrices ), mMatsParamName( matsParamName ) { assert( group >= 0 && group < mesh.getMesh().getGroupCount() ); assert( mesh.isCreated() ); assert( skinMatrices ); getParams().addInt( bonesParamName, mesh.getBonesPerVertex()-1 ); int vec3sPerPal = mesh.getPaletteSize() * 4; if( mPaletteSkinMatrices.size() < vec3sPerPal ) mPaletteSkinMatrices.resize( vec3sPerPal ); } void CRenderableSkin::render( CRenderContext const& ctx ) { assert( mMesh ); HRESULT hr; CD3DDevice& device = CD3DDevice::getInstance(); IDirect3DDevice9& dx = device.getDevice(); CRenderStats& stats = device.getStats(); CMesh& mesh = mMesh->getMesh(); device.setIndexBuffer( &mesh.getIB() ); device.setVertexBuffer( 0, &mesh.getVB(), 0, mesh.getVertexStride() ); device.setDeclaration( mesh.getVertexDecl() ); // go through palettes and render each that is of needed group // TBD: suboptimal! should have a ID->palettes[] mapping int n = mMesh->getPaletteCount(); for( int i = 0; i < n; ++i ) { const CSkinBonePalette& bpal = mMesh->getPalette(i); if( bpal.getGroupID() != mGroup ) continue; // copy skin matrices into palette's space int palSize = bpal.getBoneCount(); // may be smaller than max. palette size SVector3* dst = &mPaletteSkinMatrices[0]; for( int b = 0; b < palSize; ++b ) { int boneIdx = bpal.getBoneIdx( b ); assert( boneIdx >= 0 && boneIdx < mMesh->getSkeleton().getBoneCount() ); dst[0] = mSkinMatrices[boneIdx*4+0]; dst[1] = mSkinMatrices[boneIdx*4+1]; dst[2] = mSkinMatrices[boneIdx*4+2]; dst[3] = mSkinMatrices[boneIdx*4+3]; dst += 4; } // set palette on effect // TBD: kind of hack! getParams().getEffect()->getObject()->SetFloatArray( mMatsParamName, &mPaletteSkinMatrices[0].x, palSize*4*3 ); getParams().getEffect()->commitParams(); // render const CMesh::CGroup& group = mesh.getGroup( i ); hr = dx.DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, group.getFirstVertex(), group.getVertexCount(), group.getFirstPrim() * 3, group.getPrimCount() ); stats.incVerticesRendered( group.getVertexCount() ); stats.incPrimsRendered( group.getPrimCount() ); if( FAILED( hr ) ) { THROW_DXERROR( hr, "failed to DIP" ); } // stats stats.incDrawCalls(); } }
[ "nearaz@73827abb-88f4-0310-91e6-a2b8c1a3e93d" ]
[ [ [ 1, 93 ] ] ]
7c32ac277513adb2e82ab8c53a73f89f1b389b6a
74ab29ea3cd50efbbedda148d1e575756c624699
/passageiro.h
c24c055c4aafb2ce9c71814ed4c6fc473c39c22b
[]
no_license
Highvolt/AEDA-Projecto-Parte2
04db8301222989e316ad740ef3bba2c1d1514986
0f6f10ecf329c286bdf01281599574c5354e32f9
refs/heads/master
2021-01-18T14:28:43.210862
2010-12-21T22:06:52
2010-12-21T22:06:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,410
h
#ifndef PASSAGEIRO_H_ #define PASSAGEIRO_H_ #include <iostream> #include <vector> #include "Plano_de_voo.h" #include <list> #include <hash_set.h> using namespace std; class passageiro { string name; unsigned long int n_BI; vector<Plano_de_voo> viagens_realizadas; public: /** * creates a new passenger * @name passageiro * @param string nome="" * @param unsigned long int n_BI=0 */ passageiro(string nome="", unsigned long int n_BI=0); /** * creates a new passenger * @name passageiro * @param string nome * @param unsigned long int n_BI * @param vector<Plano_de_voo> via */ passageiro(string nome, unsigned long int n_BI, vector<Plano_de_voo> via); /** * adds the airplanes to the vector * @name adicionar_voo * @param Plano_de_voo a */ void adicionar_voo(Plano_de_voo a); /** * class destructor of passengers * @name ~passageiro */ virtual ~passageiro(); unsigned long int getBI() const { return n_BI; } string getName() const { return name; } vector<Plano_de_voo> getViagens_realizadas() const { return viagens_realizadas; } void setBI(unsigned long int n_BI) { this->n_BI = n_BI; } void setName(string name) { this->name = name; } void setViagens_realizadas(vector<Plano_de_voo> viagens_realizadas) { this->viagens_realizadas = viagens_realizadas; } /** * allows the user to watch the name of the passenger * @name << * @param ostream & out * @param passageiro a * @return the display resulted from the function */ friend ostream & operator<<(ostream & out, passageiro a){ out<<a.name<<'|'<<a.n_BI; vector<Plano_de_voo> planos=a.getViagens_realizadas(); for(vector<Plano_de_voo>::iterator it=planos.begin();it!=planos.end(); it++){ out<<'|'<<*it; } out<<endl; return out; } }; struct hpass { int operator() (passageiro p) const { int v = 0; string s1=p.getName(); for ( unsigned int i=0; i< s1.size(); i++) v = 37*v + s1[i]; return v; } }; struct eqpass { bool operator() (passageiro p1, passageiro p2) const { return p1.getBI()==p2.getBI(); } }; /** * creating a hash_table * @name tableap * @return a hash_table */ typedef hash_set<passageiro,hpass,eqpass> tabelap; class Passageiro_tb{ tabelap tabela; public: /** * creates a passengers hash table * @name Passageiro_tb */ Passageiro_tb(); /** * creates a passengers hash table * @name Passageiro_tb * @param string nome * @param unsigned long BI * @param vector<Plano_de_voo> & viagens_realizadas */ Passageiro_tb(string nome, unsigned long BI, vector<Plano_de_voo> & viagens_realizadas); /** * inserts a new passenger in the hash table * @name insert * @param passageiro & a */ void insert(passageiro & a); /** * inserts a new passenger in the hash table with the given caracteristics * @name insert * @param string nome * @param unsigned long BI * @param vector<Plano_de_voo> & viagens_realizadas * */ void insert(string nome, unsigned long BI, vector<Plano_de_voo> & viagens_realizadas); /** * returns a vector of passengers in the hash table * @name getPassageiros * @return a vector of passengers */ vector<passageiro> getPassageiros(){ vector<passageiro> temp; for(tabelap::iterator it=tabela.begin();it!=tabela.end();it++){ temp.push_back(*it); } return temp; } /** * finds a given passenger in the hash table of passengers * @name find * @param passageiro & a * @return the found passenger */ passageiro find(passageiro & a); /** * deletes a passenger from the hash table of passengers * @name deletep * @param passageiro & a */ void deletep(passageiro & a ); /** * returns the hash table of passengers * @name getTAB * @return the hash table */ tabelap getTAB(){ return tabela; } /** *allows the user to see the hash table of passengers *@name << *@param ostream & out *@param Passageiro_tb & a *@return the hash table */ friend ostream & operator<<(ostream & out, Passageiro_tb & a){ tabelap copia=a.getTAB(); for(tabelap::iterator it=copia.begin();it!=copia.end();it++){ out<<*it; } return out; } }; #endif /** PASSAGEIRO_H_ */
[ [ [ 1, 207 ] ] ]
382a34fba5fe7727965c8d4f4a4b1f75bd760f56
6581dacb25182f7f5d7afb39975dc622914defc7
/CodeProject/ExcelAddinInEasyIF/ColPList.h
fbb30f2ff3b89dd7db70644eba3c60b77cea0fec
[]
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,371
h
#if !defined(AFX_COLPLIST_H__58C88277_A5AA_4ABA_ABA6_EAAD94427918__INCLUDED_) #define AFX_COLPLIST_H__58C88277_A5AA_4ABA_ABA6_EAAD94427918__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // ColPList.h : header file // #include "matrix.h" ///////////////////////////////////////////////////////////////////////////// // ColPickList dialog class ColPickList : public CPropertyPage { DECLARE_DYNCREATE(ColPickList) // Construction public: ColPickList(); ColPickList(Matrix *pMatrix, int iColIndex); ~ColPickList(); // Dialog Data //{{AFX_DATA(ColPickList) enum { IDD = IDD_COLEDIT_PICKLIST }; CString m_cChoices; BOOL m_bRestrictToList; BOOL m_bUsePickList; //}}AFX_DATA // Overrides // ClassWizard generate virtual function overrides //{{AFX_VIRTUAL(ColPickList) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: // Generated message map functions //{{AFX_MSG(ColPickList) virtual BOOL OnInitDialog(); afx_msg void OnPicklistUsepicklist(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_COLPLIST_H__58C88277_A5AA_4ABA_ABA6_EAAD94427918__INCLUDED_)
[ "damoguyan8844@3a4e9f68-f5c2-36dc-e45a-441593085838" ]
[ [ [ 1, 54 ] ] ]
b614b9aa0f75e52f271e135116fd8a7ca9127ecd
9176b0fd29516d34cfd0b143e1c5c0f9e665c0ed
/CS_153_Data_Structures/assignment5/btn.h
c809265308eef4b0bb3f74a4f0b913e5eb5742db
[]
no_license
Mr-Anderson/james_mst_hw
70dbde80838e299f9fa9c5fcc16f4a41eec8263a
83db5f100c56e5bb72fe34d994c83a669218c962
refs/heads/master
2020-05-04T13:15:25.694979
2011-11-30T20:10:15
2011-11-30T20:10:15
2,639,602
2
0
null
null
null
null
UTF-8
C++
false
false
995
h
#ifndef BTN_H #define BTN_H ////////////////////////////////////////////////////////////////////// /// @file btn.h /// @author James Anderson CS 153 Section A /// @brief Heder file for node class for assignment 6 ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// @class btn /// @brief creats a struct containing data and two pointers ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// @fn btn<generic>::btn /// @brief creates a new node /// @post node contains a variable and three pointers /// @param generic holds the type of variable the node will hold ////////////////////////////////////////////////////////////////////// template <class generic> struct Btn { Btn * parent; Btn * left; Btn * right; generic * data; int * instance; }; #endif
[ [ [ 1, 31 ] ] ]
dfd8914afa8df18fdfb877ee952ace6a8e00889b
c1eae8224c4d3d380cc83ff6b218ba2a9df8d687
/Source Codes/MeshUI/MeshLib/MeshModelAdvancedOp.h
c3eb318e29798bd44c85923738d5bdbeeda78d0d
[]
no_license
pizibing/noise-removal
15bad5c0fe1b3b5fb3f8b775040fc3dfeb48e49b
c087356bfa07305ce7ac6cce8745b1e676d6dc42
refs/heads/master
2016-09-06T17:40:15.754799
2010-03-05T06:47:59
2010-03-05T06:47:59
34,849,474
1
0
null
null
null
null
UTF-8
C++
false
false
1,974
h
/* ================== Library Information ================== */ // [Name] // MeshLib Library // // [Developer] // Xu Dong // State Key Lab of CAD&CG, Zhejiang University // // [Date] // 2005-08-05 // // [Goal] // A general, flexible, versatile and easy-to-use mesh library for research purpose. // Supporting arbitrary polygonal meshes as input, but with a // primary focus on triangle meshes. /* ================== File Information ================== */ // [Name] // MeshModelAdvancedOp.h // // [Developer] // Xu Dong // State Key Lab of CAD&CG, Zhejiang University // // [Date] // 2005-08-09 // // [Goal] // Defining the basic operations of the kernel components of the mesh model // Including predictions, queries, Euler operations, etc // // This class is responsible for the manipulations of the kernel components and states // Those change the topology of the mesh model #include "MeshModelKernel.h" #include "MeshModelAuxData.h" #include "MeshModelBasicOp.h" #include "Utility.h" #pragma once /* ================== Advanced Operation ================== */ class MeshModelAdvancedOp { private: MeshModelKernel* kernel; MeshModelAuxData* auxdata; MeshModelBasicOp* basicop; Utility util; public: // Constructor MeshModelAdvancedOp(); // Destructor ~MeshModelAdvancedOp(); // Initializer void ClearData(); void AttachKernel(MeshModelKernel* pKernel); void AttachAuxData(MeshModelAuxData* pAuxData); void AttachBasicOp(MeshModelBasicOp* pBasicOp); // Compact model void CompactModel(); // Euler operator void EdgeCollapse(VertexID vID1, VertexID vID2); void VertexSplit(VertexID vID); void EdgeSplit(VertexID vID1, VertexID vID2); // Model transformation void Translate(Coord delta); void Rotate(Coord center, Coord axis, double angle); void Scale(Coord center, Coord ratio); };
[ "weihongyu1987@f7207f0a-2814-11df-8e46-3928208ddfa0" ]
[ [ [ 1, 82 ] ] ]
6077274751079606de3ee70991e000e9d2678d00
12732dc8a5dd518f35c8af3f2a805806f5e91e28
/trunk/CodeLite/variable.cpp
48563ff2c110f43c9411294a6d27e5fc8d25877a
[]
no_license
BackupTheBerlios/codelite-svn
5acd9ac51fdd0663742f69084fc91a213b24ae5c
c9efd7873960706a8ce23cde31a701520bad8861
refs/heads/master
2020-05-20T13:22:34.635394
2007-08-02T21:35:35
2007-08-02T21:35:35
40,669,327
0
0
null
null
null
null
UTF-8
C++
false
false
1,065
cpp
#include "variable.h" Variable::Variable() { Reset(); } Variable::~Variable() { } Variable::Variable(const Variable &src) { *this = src; } Variable & Variable::operator =(const Variable &src) { m_type = src.m_type; m_templateDecl = src.m_templateDecl; m_name = src.m_name; m_isTemplate = src.m_isTemplate; m_isPtr = src.m_isPtr; m_typeScope = src.m_typeScope; m_pattern = src.m_pattern; m_starAmp = src.m_starAmp; return *this; } void Variable::Reset() { m_type = ""; m_templateDecl = ""; m_name = ""; m_isTemplate = false; m_isPtr = false; m_typeScope = ""; m_pattern = ""; m_starAmp = ""; } void Variable::Print() { fprintf( stdout, "{m_name=%s, m_starAmp=%s, m_type=%s, m_typeScope=%s, m_templateDecl=%s, m_isPtr=%s, m_isTemplate=%s}\n", m_name.c_str(), m_starAmp.c_str(), m_type.c_str(), m_typeScope.c_str(), m_templateDecl.c_str(), m_isPtr ? "true" : "false", m_isTemplate ? "true" : "false"); fprintf( stdout, "Pattern: %s\n", m_pattern.c_str()); fflush(stdout); }
[ "eranif@b1f272c1-3a1e-0410-8d64-bdc0ffbdec4b" ]
[ [ [ 1, 51 ] ] ]
b251dbe70457b53a67f308a77bd232f898ccdac8
45c0d7927220c0607531d6a0d7ce49e6399c8785
/GlobeFactory/src/game/menu.cc
44c3494f192ff4f7161521d42efc19a44fd38694
[]
no_license
wavs/pfe-2011-scia
74e0fc04e30764ffd34ee7cee3866a26d1beb7e2
a4e1843239d9a65ecaa50bafe3c0c66b9c05d86a
refs/heads/master
2021-01-25T07:08:36.552423
2011-01-17T20:23:43
2011-01-17T20:23:43
39,025,134
0
0
null
null
null
null
UTF-8
C++
false
false
4,892
cc
#include "menu.hh" /* FIXME (TEST) */ #include "../gfx/vertex_writer.hh" #include "../gfx/vertex.hh" #include "../gfx/gfx_engine.hh" #include "../gfx/renderer_2D.hh" #include "../gfx/texture_mng.hh" #include "../gfx/render_string.hh" #include "../ui/interface_mng.hh" #include "../ui/ui_button.hh" #include "../ui/ui_window.hh" #include "../ui/ui_check_box.hh" #include "../ui/ui_combo_box.hh" //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ /* FIXME (TEST) */ unsigned material_id = 0; RenderString* render_str = NULL; unsigned MInterface = 0; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ Menu::Menu() { } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ Menu::~Menu() { } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void Menu::Update() { VertexWriter<Vertex::TV3F>& vertexWriter = GfxEngine::get()->GetPreRender2D()->GetVertexWriter<Vertex::TV3F>(material_id, 3, 1); Vertex::TV3F* vertex = NULL; vertex = &vertexWriter.GetVertex(0); vertex->position = Vector3(160.0f ,120.0f, 0.0f); vertex = &vertexWriter.GetVertex(1); vertex->position = Vector3(320.0f, 360.0f, 0.0f); vertex = &vertexWriter.GetVertex(2); vertex->position = Vector3(480.0f, 120.0f, 0.0f); vertexWriter.AddTriangle(0, 1, 2); vertexWriter.Finish(); render_str->SetAligments(AligmentEnum::RIGHT, AligmentEnum::TOP); render_str->Draw(Vector2f(0.0f, 0.0f)); render_str->SetAligments(AligmentEnum::RIGHT, AligmentEnum::BOTTOM); render_str->Draw(Vector2f(0.0f, 600.0f)); render_str->SetAligments(AligmentEnum::LEFT, AligmentEnum::TOP); render_str->Draw(Vector2f(800.0f, 0.0f)); Vector2f a(0.0f, 0.0f); Vector2f b(400.0f, 300.0f); Vector2f c(800.0f, 0.0f); Vector2f min(50.0f, 50.0f); Vector2f max(300.0f, 250.0f); GfxEngine::get()->GetPreRender2D()->DrawLine(a, b, BaseColor::GOLD); GfxEngine::get()->GetPreRender2D()->DrawLine(b, c, BaseColor::ORANGERED); GfxEngine::get()->GetPostRender2D()->DrawQuad(BB2f(Vector2f(400, 400), Vector2f(440, 440)), BaseColor::YELLOWGREEN); GfxEngine::get()->GetPostRender2D()->DrawQuad(BB2f(Vector2f(405, 405), Vector2f(445, 445)), BaseColor::FIREBRICK); GfxEngine::get()->GetPostRender2D()->DrawQuad(BB2f(Vector2f(410, 410), Vector2f(450, 450)), BaseColor::GOLDENROD); GfxEngine::get()->GetPostRender2D()->DrawQuad(BB2f(Vector2f(415, 415), Vector2f(455, 455)), BaseColor::VIOLET); GfxEngine::get()->GetPostRender2D()->DrawQuad(BB2f(Vector2f(420, 420), Vector2f(460, 460)), BaseColor::VIOLETRED); GfxEngine::get()->GetPostRender2D()->DrawQuad(BB2f(Vector2f(425, 425), Vector2f(465, 465)), BaseColor::IVORY); GfxEngine::get()->GetPostRender2D()->DrawQuad(BB2f(Vector2f(430, 430), Vector2f(470, 470)), BaseColor::TAN); GfxEngine::get()->GetPostRender2D()->DrawQuad(BB2f(Vector2f(435, 435), Vector2f(475, 475)), BaseColor::THISTLE); GfxEngine::get()->GetPostRender2D()->DrawQuad(BB2f(Vector2f(440, 440), Vector2f(480, 480)), BaseColor::TOMATO); GfxEngine::get()->GetPostRender2D()->DrawQuad(BB2f(Vector2f(445, 445), Vector2f(485, 485)), material_id); GfxEngine::get()->GetPostRender2D()->DrawQuad(BB2f(Vector2f(450, 450), Vector2f(490, 490)), BaseColor::PAPAYAWHIP); GfxEngine::get()->GetPostRender2D()->DrawQuad(BB2f(Vector2f(455, 455), Vector2f(495, 495)), BaseColor::PERU); GfxEngine::get()->GetPostRender2D()->DrawQuad(BB2f(Vector2f(460, 460), Vector2f(500, 500)), BaseColor::TURQUOISE); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void Menu::OnLaunchMenu() { material_id = MaterialMng::get()->LoadMaterial("anim.txt"); render_str = new RenderString("arial.ttf", 32); render_str->Set("Test String TEST"); render_str->SetColor(BaseColor::BROWN); MInterface = InterfaceMng::get()->LoadFromXML("menu.xml"); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void Menu::OnLeaveMenu() { MaterialMng::get()->UnloadMaterial(material_id); delete render_str; InterfaceMng::get()->DeleteInterface(MInterface); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
[ "creteur.c@8e971d8e-9cf3-0c36-aa0f-a7c54ab41ffc" ]
[ [ [ 1, 114 ] ] ]
da154576593e6ae32838ba456c4bd998e105a767
a36d7a42310a8351aa0d427fe38b4c6eece305ea
/core_billiard/CameraMatrix.h
9dcbd0c8b3a4398c194e832fb828ff3f8f05eed8
[]
no_license
newpolaris/mybilliard01
ca92888373c97606033c16c84a423de54146386a
dc3b21c63b5bfc762d6b1741b550021b347432e8
refs/heads/master
2020-04-21T06:08:04.412207
2009-09-21T15:18:27
2009-09-21T15:18:27
39,947,400
0
0
null
null
null
null
UTF-8
C++
false
false
1,133
h
#pragma once namespace my_render { MY_INTERFACE CameraMatrix { virtual ~CameraMatrix() {} virtual NxVec3 getPosition() PURE; virtual void setPosition( const NxVec3 & newPosition ) PURE; virtual NxVec3 getRightVector () PURE; virtual NxVec3 getUpVector () PURE; virtual NxVec3 getDirectionVector () PURE; virtual void setRightVector( const NxVec3 & ) PURE; virtual void setUpVector( const NxVec3 & ) PURE; virtual void setDirectionVector( const NxVec3 & ) PURE; virtual NxMat33 getRotationMatrix() PURE; virtual void setRotationMatrix( const NxMat33 & ) PURE; virtual RowMajorMatrix44f getProjectionMatrix() PURE; virtual RowMajorMatrix44f getViewMatrix() PURE; virtual RowMajorMatrix44f getProjectionViewMatrix() PURE; virtual void rotateCounterClockWiseByZ( float angle ) PURE; virtual void rotateClockWiseByZ( float angle ) PURE; virtual void pitchUp( float angle ) PURE; virtual void pitchDown( float angle ) PURE; virtual void lookAt( const NxVec3 & whereToLookAt, const NxVec3 & requestedUp ) PURE; }; }
[ "wrice127@af801a76-7f76-11de-8b9f-9be6f49bd635" ]
[ [ [ 1, 36 ] ] ]
31ec858863f8972839a7a01591a77eaceecfcefb
6e4f9952ef7a3a47330a707aa993247afde65597
/PROJECTS_ROOT/SmartWires/SystemUtils/Pop3.h
76861b9628458f78a6138e5cc19af1faf8f135da
[]
no_license
meiercn/wiredplane-wintools
b35422570e2c4b486c3aa6e73200ea7035e9b232
134db644e4271079d631776cffcedc51b5456442
refs/heads/master
2021-01-19T07:50:42.622687
2009-07-07T03:34:11
2009-07-07T03:34:11
34,017,037
2
1
null
null
null
null
UTF-8
C++
false
false
11,863
h
/* Module : POP3.H Purpose: Defines the interface for a MFC class encapsulation of the POP3 protocol Created: PJN / 04-05-1998 Copyright (c) 1998 - 2001 by PJ Naughter. (Web: www.naughter.com, Email: [email protected]) All rights reserved. Copyright / Usage Details: You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise) when your product is released in binary form. You are allowed to modify the source code in any way you want except you cannot modify the copyright details at the top of each module. If you want to distribute source code with your application, then you are only allowed to distribute versions released by the author. This is to maintain a single distribution point for the source code. */ /////////////////////////////// Defines /////////////////////////////////////// #ifndef __POP3_H__ #define __POP3_H__ #ifndef __AFXTEMPL_H__ #pragma message("POP3 classes require afxtempl.h in your PCH") #endif #ifndef _WINSOCKAPI_ #pragma message("POP3 classes require afxsock.h or winsock.h in your PCH") #endif #include <MAPI.H> //#include "imapi.h" /////////////////////////////// Classes /////////////////////////////////////// ////// forward declaration class CPop3Connection; //Encapsulation of a POP3 message class CPop3Message { public: //Constructors / Destructors CPop3Message(); ~CPop3Message(); //Methods LPCSTR GetMessageText() const { return m_pszMessage; }; CString GetHeader() const; CString GetHeaderItem(const CString& sName, int nItem = 0) const; CString GetBody() const; LPCSTR GetRawBody() const; CString GetSubject() const { return GetHeaderItem(_T("Subject")); } CString GetFrom() const { return GetHeaderItem(_T("From")); } CString GetDate() const { return GetHeaderItem(_T("Date")); } CString GetTo() const { return GetHeaderItem(_T("To")); } CString GetCC() const { return GetHeaderItem(_T("CC")); } CString GetReplyTo() const; CString GetContentType() const; CString GetBoundary() const; //protected: char* m_pszMessage; friend class CPop3Connection; }; //Simple Socket wrapper class class CPop3Socket { public: //Constructors / Destructors CPop3Socket(); ~CPop3Socket(); //methods BOOL Create(); BOOL Connect(LPCTSTR pszHostAddress, int nPort = 110); BOOL Send(LPCSTR pszBuf, int nBuf); void Close(); int Receive(LPSTR pszBuf, int nBuf); BOOL IsReadible(BOOL& bReadible); protected: BOOL Connect(const SOCKADDR* lpSockAddr, int nSockAddrLen); SOCKET m_hSocket; friend class CPop3Connection; }; //The main class which encapsulates the POP3 connection class CPop3Connection { public: //Constructors / Destructors CPop3Connection(); ~CPop3Connection(); //Methods BOOL Connect(LPCTSTR pszHostName, LPCTSTR pszUser, LPCTSTR pszPassword, int nPort = 110, CString* sError=NULL); BOOL Disconnect(); BOOL Statistics(int& nNumberOfMails, int& nTotalMailSize); BOOL Delete(int nMsg); BOOL GetMessageSize(int nMsg, DWORD& dwSize); BOOL GetMessageID(int nMsg, CString& sID); BOOL Retrieve(int nMsg, CPop3Message& message); BOOL GetMessageHeader(int nMsg, CPop3Message& message, int iLines=0, DWORD* pdwMsgSize=NULL); BOOL Reset(); BOOL UIDL(); BOOL Noop(); CString GetLastCommandResponse() const { return m_sLastCommandResponse; }; DWORD GetTimeout() const { return m_dwTimeout; }; void SetTimeout(DWORD dwTimeout) { m_dwTimeout = dwTimeout; }; BOOL m_bConnected; protected: virtual BOOL ReadStatResponse(int& nNumberOfMails, int& nTotalMailSize); virtual BOOL ReadCommandResponse(); virtual BOOL ReadListResponse(int nNumberOfMails); virtual BOOL ReadUIDLResponse(int nNumberOfMails); virtual BOOL ReadReturnResponse(CPop3Message& message, DWORD dwSize); virtual BOOL ReadResponse(LPSTR pszBuffer, int nInitialBufSize, LPSTR pszTerminator, LPSTR* ppszOverFlowBuffer, int nGrowBy=4096); BOOL List(); LPSTR GetFirstCharInResponse(LPSTR pszData) const; CPop3Socket m_Pop; int m_nNumberOfMails; BOOL m_bListRetrieved; BOOL m_bStatRetrieved; BOOL m_bUIDLRetrieved; CDWordArray m_msgSizes; CStringArray m_msgIDs; CString m_sLastCommandResponse; DWORD m_dwTimeout; }; class CMIMECode { public: CMIMECode(); virtual ~CMIMECode(); virtual CString Decode( LPCTSTR szDecoding, int nSize = -1) = 0; virtual CString Encode( LPCTSTR szEncoding, int nSize = -1) = 0; }; class CQuoted : public CMIMECode { public: int m_linelength; CQuoted(int linelength=76); virtual ~CQuoted(); virtual CString Decode( LPCTSTR szDecoding, int nSize = -1); virtual CString Encode( LPCTSTR szEncoding, int nSize = -1); protected: static const CString code; static const CString extended_code; }; class CBase64 : public CMIMECode { public: CBase64(); virtual ~CBase64(); // Override the base class mandatory functions virtual CString Decode( LPCTSTR szDecoding, int nSize = -1); virtual CString Encode( LPCTSTR szEncoding, int nSize = -1); protected: void write_bits( UINT nBits, int nNumBts, LPTSTR szOutput, int& lp ); UINT read_bits( int nNumBits, int* pBitsRead, int& lp ); int m_nInputSize; int m_nBitsRemaining; ULONG m_lBitStorage; LPCTSTR m_szInput; static int m_nMask[]; static CString m_sBase64Alphabet; private: }; #include <mlang.h> #include <atlbase.h> class CCharsetDecoder { public: CString m_sCharSetName; CCharsetDecoder(CString sCharSetName): m_sCharSetName(sCharSetName) {}; CCharsetDecoder(UINT CodePage); ~CCharsetDecoder(){}; CString Encode(CString sString); // Encodes the string in default charset (e.g. 1251 for Russian) to the given codepage CString Decode(CString sString); // Decodes the string in the given charset (e.g. koi8-r/*=20866)*/ to the default charset BOOL isKnown(); private: CString Recode(CString sString, bool bEncode, bool* bRes=NULL); }; CString DecodeHeaderValue(CString Encoded, CString *pCharset); //------------------------------------------------------------- //------------------------------------------------------------- //------------------------------------------------------------- //------------------------------------------------------------- const int DEFAULT_PROTOCOL = 0; const int NO_FLAGS = 0; class CFastSmtp { public: CFastSmtp(); virtual ~CFastSmtp(); bool AddRecipient(const char email[], const char name[]=""); bool AddBCCRecipient(const char email[], const char name[]=""); bool AddCCRecipient(const char email[], const char name[]=""); bool ConnectServer(const char server[], const unsigned short port=NULL); bool Disconnect(); bool GetConnectStatus(); const unsigned int GetBCCRecipientCount(); const unsigned int GetCCRecipientCount(); const unsigned int GetRecipientCount(); const unsigned int GetSocket(); const char* const GetLocalHostIp(); const char* const GetLocalHostname(); const char* const GetMessageBody(); const char* const GetReplyTo(); const char* const GetSenderEmail(); const char* const GetSenderName(); const char* const GetSubject(); const char* const GetXMailer(); bool Send(CString& sErr); void SetMessageBody(const char body[]); void SetSubject(const char subject[]); void SetSenderName(const char name[]); void SetSenderEmail(const char email[]); void SetReplyTo(const char replyto[]); void SetXMailer(const char xmailer[]); CString username; CString password; void SetUserName( CString un ){ username = un; }; CString GetUserName() { return username; }; void SetPassward( CString psw ) { password = psw; }; CString GetPassward() { return password; }; CString sFormat; void SetOutFormat(CString sf){sFormat=sf;}; private: class CRecipient { public: CRecipient() { m_pcEmail = NULL; }; CRecipient& operator=(const CRecipient& src) { if (&src != this) { if (m_pcEmail) delete [] m_pcEmail; int s = strlen(src.m_pcEmail); m_pcEmail = new char[s+1]; strcpy(m_pcEmail, src.m_pcEmail); } return (*this); }; virtual ~CRecipient() { if (m_pcEmail) delete [] m_pcEmail; }; char* GetEmail() { return m_pcEmail; }; void SetEmail(const char email[]) { int s=strlen(email); if (s > 0) { m_pcEmail = new char[s+1]; strcpy(m_pcEmail, email); } }; private: char *m_pcEmail; }; bool bCon; char m_cHostName[MAX_PATH]; char* m_pcFromEmail; char* m_pcFromName; char* m_pcSubject; char* m_pcMsgBody; char* m_pcXMailer; char* m_pcReplyTo; char* m_pcIPAddr; WSADATA wsaData; SOCKET hSocket; CArray<CRecipient*, CRecipient*> Recipients; CArray<CRecipient*, CRecipient*> CCRecipients; CArray<CRecipient*, CRecipient*> BCCRecipients; CString _formatHeader(); bool _formatMessage(); SOCKET _connectServerSocket(const char* server, const unsigned short port=NULL); }; int b64decode(char *from,char *to,int from_length); int b64get_encode_buffer_size(int from_length,int output_quads_per_line); int b64strip_encoded_buffer(char *buf,int length); int b64encode(const char *from,char *to,int length,int quads); /* * $Header: /common/IMapi.h 1 28/03/01 8:42p Admin $ * * $History: IMapi.h $ * * ***************** Version 1 ***************** * User: Admin Date: 28/03/01 Time: 8:42p * Created in $/common */ class CIMapi { public: CIMapi(); ~CIMapi(); enum errorCodes { IMAPI_SUCCESS = 0, IMAPI_LOADFAILED, IMAPI_INVALIDDLL, IMAPI_FAILTO, IMAPI_FAILCC, IMAPI_FAILATTACH }; // Attributes void Subject(LPCTSTR subject); void Text(LPCTSTR text) { m_text = text; } UINT Error(); void From(LPCTSTR from) { m_from.lpszName = (LPTSTR) from; } static BOOL HasEmail(); // Operations BOOL To(LPCTSTR recip); BOOL Attach(LPCTSTR path, LPCTSTR name = NULL); BOOL Send(ULONG flags = 0); BOOL SetHTML(){/*m_message.lpszMessageType="text/html";*/return 1;}; private: BOOL AllocNewTo(); MapiMessage m_message; MapiRecipDesc m_from; UINT m_error; CString m_text; LHANDLE m_sessionHandle; ULONG (PASCAL *m_lpfnSendMail)(ULONG, ULONG, MapiMessage*, FLAGS, ULONG); ULONG (PASCAL *m_lpfnMAPILogon)(ULONG, LPTSTR, LPTSTR, FLAGS, ULONG, LPLHANDLE); static HINSTANCE m_hInstMail; static BOOL m_isMailAvail; }; CString Str2UTF8(const WCHAR* input); CString UTF82Str(const char* input); CString urlEscapeString(const char* szString,CString sAddChars="+\\/:?&%='\""); CString GetURLForMailByWWW(CString sFrom,CString sTo,CString sSubject,CString sBody); char ntc(unsigned char n); unsigned char ctn(char c); int b64encode(const char *from,char *to,int length,int quads); int b64decode(char *from,char *to,int length); int b64get_encode_buffer_size(int l,int q); int b64strip_encoded_buffer(const char *buf,int length); #endif //__POP3_H__
[ "wplabs@3fb49600-69e0-11de-a8c1-9da277d31688" ]
[ [ [ 1, 385 ] ] ]
4017b243ae1134b9c0473384261d062554913092
899e3440cda769c6a4b7649065dee47bc0516b6c
/topcoder/topcoder/BomberMan.cpp
7d3c6088ecb1d07ae253bc302c2b3dd3b643461c
[]
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
5,974
cpp
#include "stdafx.h" #include <iostream> #include <sstream> #include <string> #include <vector> #include <queue> #include <string> #include <stack> #include <map> #include <algorithm> #include <utility.cpp> using namespace std; int bomber_man_dx[4] = {0 ,1,0,-1}; int bomber_man_dy[4] = {-1,0,1,0}; int bomber_man_maze[50][50]; struct Node{ Node(int x,int y,int time_taken,int bombs_left){ this->x = x; this->y = y; this->time_taken = time_taken; this->bombs_left = bombs_left; } int x; int y; int time_taken; int bombs_left; }; bool operator < (const Node &left , const Node &right){ return left.time_taken > right.time_taken; } class BombMan{ private: int start_x , start_y , end_x , end_y; int max_x,max_y; int number_of_bombs; map<pair<int,int>,int> visited; map<pair<int,int>,int>::iterator item; void initialize(){ memset(bomber_man_maze,0,sizeof(bomber_man_maze)); visited.clear(); } void pupulate_maze(vector<string> maze){ for(int i = 0; i < maze.size() ; i++){ max_y = maze.size(); for(int j = 0;j < maze[i].length();j++){ max_x = maze[i].length(); switch(maze[i][j]){ case '.' : bomber_man_maze[i][j] = 1; break; case '#' : bomber_man_maze[i][j] = 0; break; case 'B' : bomber_man_maze[i][j] = 3; start_x = j; start_y = i; break; case 'E' : bomber_man_maze[i][j] = 1; end_x = j; end_y = i; break; } } } } bool is_valid(int x,int y){ return !(x < 0 || y < 0 || x > max_x || y > max_y); } public: int shortestPath(vector<string> maze, int bombs){ initialize(); pupulate_maze(maze); number_of_bombs = bombs; priority_queue<Node> q; q.push(Node(start_x,start_y,0,number_of_bombs)); while(!q.empty()){ Node current = q.top();q.pop(); if(current.x == end_x && current.y == end_y){ return current.time_taken; } if(visited.find(make_pair(current.x,current.y)) != visited.end() ) continue; visited.insert(make_pair(make_pair(current.x,current.y),current.time_taken)); for(int i = 0;i < 4;i++){ int x = current.x + bomber_man_dx[i]; int y = current.y + bomber_man_dy[i]; if(is_valid(x,y)) if(bomber_man_maze[y][x] == 1) q.push(Node(x,y,current.time_taken + 1,current.bombs_left)); else if(bomber_man_maze[y][x] == 0 && current.bombs_left > 0) q.push(Node(x,y,current.time_taken + 3,current.bombs_left - 1)); } } return -1; } }; int _tmain(int argc, _TCHAR* argv[]){ string maze[] = {".....B.", ".#####.", ".#...#.", ".#E#.#.", ".###.#.", "......."}; BombMan b; are_equal_with_print<int>(8, b.shortestPath(to_vector<string,6>(maze),1)); string maze1[] = {"..#####", "B.#####", "..#####", "#######", "####...", "####.E."}; are_equal_with_print<int>(17, b.shortestPath(to_vector<string,6>(maze1),4)); string maze2[] = {"B.#.#.#...E"}; are_equal_with_print<int>(-1, b.shortestPath(to_vector<string,1>(maze2),2)); string maze3[] = {".#.#.#.#B#...#.#...#.#...#.#...#.#...#.#.#.......", ".#.#.#.#.#.###.###.#.###.#.#.###.###.#.#.#.###.##", ".#.#.#...#.#.#.#.#.#...#.....#.#.#...#...#.#.#...", ".#.#.###.#.#.#.#.#.###.#.#####.#.###.###.#.#.###.", ".............#.#...#...#.....#.#.#...#.#.#.....#.", "##.#######.###.#.#####.#.#####.#.###.#.#.#.#.####", ".#.#.....#...#...#.#...#...#.#.#...#...#...#.....", ".#######.#.#####.#.#.#.#.###.#.###.#.#####.#.####", ".#.#.#.#...#.#.#.#.#.#.......#...#.#...#.#.#.....", ".#.#.#.###.#.#.#.#.#####.#####.###.###.#.#.######", ".....#...#.#...#...#...#...#...#...#.#.#.........", "####.###.#.###.###.#.###.#.#.###.###.#.#.########", ".......#.........#.#.#.#.#.#.#.#.........#...#...", ".#.###.#########.#.#.#.#.###.#.#####.#.#.#.###.##", ".#.#.........#.#.#.#.#.....#.#.#.....#.#.........", "############.#.#.#.#.#.#####.#.#.################", ".#...........#...#.#.#.#...#.#.#...#.#.#.....#...", ".#####.#####.###.#.#.#.#.###.#.#.###.#.#.#####.##", ".......#...#.#.#.....#...#...#.#.#.#.#...........", "##########.#.#.#####.#.###.###.#.#.#.#.##########", ".....#...#.....#.#...#.......#.#...#.......#.....", "##.#.###.#.###.#.#.#.#.#####.#.#.###.#######.####", "...#...#...#.......#.....#.#...#...#.......#.....", "####.#.#.#########.#.###.#.#####.###.#.#######.##", ".#...#...#.........#.#.....#.........#.#.#.#.....", ".#####.#.#.###.#######.#.###.#.#########.#.#.####", ".......#.#.#...#.......#.....#.#.#.......#.#.#.#.", "########.#.#.#.#####.#.###.#.###.#.#######.#.#.#.", ".........#.#.#.#.....#...#.#.........#.#.........", "################.#.#.#.#.#.#.#.#######.#.########", ".................#.#.#.#.#.#.#...........#.......", "########.#####.#.###.#.#.#####.###.#.#####.###.##", ".........#...#.#...#.#.#...#.....#.#.........#...", ".#####.#####.#.###.#.###.#.#.#.#.#.#####.#.###.#.", ".#.....#.........#.#.#...#.#.#.#.#.#.....#...#.#.", "####.#####.###.#.#.#.#.#.#.###.###.#.#.#.#.#####.", ".....#.....#.#.#.#.#.#.#.#.#...#...#.#.#.#...#...", "####.#.#.###.#.#.###.#.###.#.#.#####.#.#.#.######", ".....#.#.#.#...#...#.#...#.#.#...#...#.#.#.......", "##########.#.#.#.#####.###.#.#.###.#.###.#####.##", "...#.#...#...#.#.....#.#...#.#...#.#.#.......#...", ".#.#.#.#.#.#.#.#.#.#.###.#.#########.###.#.#.#.#.", ".#.#...#...#.#.#.#.#...#.#...#.......#...#.#.#.#.", "##.###.#.#.###.#.#.#.#.#####.#.#.#.###.#.########", ".......#.#...#.#.#.#.#.#.....#.#.#...#.#.........", "####.#######.#.#####.#.###.#.#.###.#.#.#.########", "E..#.......#.#.....#.#.#.#.#.#.#...#.#.#.........", "##.#.#.#.###.###.###.###.#.#.###.#.#.#.#.#######.", ".....#.#...#.#.....#.#.....#...#.#.#.#.#.....#..."}; are_equal_with_print<int>(76, b.shortestPath(to_vector<string,49>(maze3),3)); int i; cin >> i; return 0; }
[ "karan.jude@737fc9ef-4d2d-0410-97ed-4d0c502f76d2" ]
[ [ [ 1, 194 ] ] ]
36bd2cdd5430d7431c099ae800743bfd6f65ea2f
e87cea8c829923b1adedb7e9b28e13988ea848a7
/oberon/Scanner.cpp
aa1070f04c0a20867bc5a761a730d993f8c948a7
[]
no_license
joycode/oberon-0
cd2bedf0aa835061aaf11fc8e7685f97374a6d5f
92c4806d8eaf3c294dd6a8c3b5be93026836ccf6
refs/heads/master
2021-01-25T08:48:15.103032
2011-06-02T09:47:59
2011-06-02T09:47:59
1,970,532
0
0
null
null
null
null
UTF-8
C++
false
false
4,705
cpp
#include <cstdio> #include <cassert> #include <string> #include "scanner.h" #include "KeywordTable.h" using namespace std; Scanner::Scanner(FILE *fp) : m_sourceLocation() { m_fp = fp; m_currentSymbolKind = SymbolKind::ERROR; m_peekChar = '\0'; m_number = 0; m_ident = ""; m_sourceLocation.m_x = 1; m_sourceLocation.m_y = 1; } Scanner::~Scanner() { } void Scanner::mark(string errMsg) { fprintf(stderr, "Line %d, Column %d: %s\n", m_sourceLocation.m_x, m_sourceLocation.m_y, errMsg.c_str()); } SymbolKind::T_SymbolKind Scanner::get() { m_currentSymbolKind = this->getInternal(); return m_currentSymbolKind; } SymbolKind::T_SymbolKind Scanner::getInternal() { for (;;) { while (this->isWhiteSpace(m_peekChar)) { m_peekChar = this->peekChar(); } switch (m_peekChar) { case '*': m_peekChar = this->peekChar(); return SymbolKind::TIMES; case '&': m_peekChar = this->peekChar(); return SymbolKind::AND; case '+': m_peekChar = this->peekChar(); return SymbolKind::PLUS; case '-': m_peekChar = this->peekChar(); return SymbolKind::MINUS; case '=': m_peekChar = this->peekChar(); return SymbolKind::EQL; case '#': m_peekChar = this->peekChar(); return SymbolKind::NEQ; case '<': m_peekChar = this->peekChar(); if (m_peekChar == '=') { m_peekChar = this->peekChar(); return SymbolKind::LEQ; } else { return SymbolKind::LSS; } case '>': m_peekChar = this->peekChar(); if (m_peekChar == '=') { m_peekChar = this->peekChar(); return SymbolKind::GEQ; } else { return SymbolKind::GTR; } case '.': m_peekChar = this->peekChar(); return SymbolKind::PERIOD; case ',': m_peekChar = this->peekChar(); return SymbolKind::COMMA; case ':': m_peekChar = this->peekChar(); if (m_peekChar == '=') { m_peekChar = this->peekChar(); return SymbolKind::BECOMES; } else { return SymbolKind::COLON; } case ')': m_peekChar = this->peekChar(); return SymbolKind::RPAREN; case ']': m_peekChar = this->peekChar(); return SymbolKind::RBRAK; case '(': m_peekChar = this->peekChar(); if (m_peekChar == '*') { if (!this->skipComment()) { return SymbolKind::ERROR; } else { return this->get(); } } else { return SymbolKind::LPREN; } case '[': m_peekChar = this->peekChar(); return SymbolKind::LBRAK; case '~': m_peekChar = this->peekChar(); return SymbolKind::NOT; case ';': m_peekChar = this->peekChar(); return SymbolKind::SEMICOLON; case EOF: return SymbolKind::END_OF_FILE; default: if (isalpha(m_peekChar)) { return this->getIdent(); } else if (isdigit(m_peekChar)) { this->getNumber(); return SymbolKind::NUMBER; } else { this->mark("illegal character"); return SymbolKind::ERROR; } }; } } bool Scanner::init() { m_peekChar = this->peekChar(); return true; } char Scanner::peekChar() { // maybe a problem? char ch = (char)getc(m_fp); if (ch == '\n') { m_sourceLocation.m_x++; m_sourceLocation.m_y = 1; } else if (ch == '\r') { // nothing to do in case of "\n\r" } else { // TODO. how about handling '\t'? m_sourceLocation.m_y++; } return ch; } bool Scanner::isWhiteSpace(char ch) { if ((ch == ' ') || (ch == '\t') || (ch == '\n') || (ch == '\r')) { return true; } else { return false; } } bool Scanner::skipComment() { bool triggering = false; while ((m_peekChar = this->peekChar()) != EOF) { if (triggering) { if (m_peekChar == ')') { m_peekChar = this->peekChar(); return true; } else { triggering = false; } } else if (m_peekChar == '*') { triggering = true; } } this->mark("comment not terminated"); return false; } SymbolKind::T_SymbolKind Scanner::getIdent() { string ident = ""; ident += m_peekChar; while ((m_peekChar = this->peekChar()) != EOF) { if (isalpha(m_peekChar) || isdigit(m_peekChar)) { ident += m_peekChar; } else { break; } } SymbolKind::T_SymbolKind sym = SymbolKind::ERROR; if (KeywordTable::isKeyword(ident, &sym)) { return sym; } else { sym = SymbolKind::IDENT; m_ident = ident; return sym; } } void Scanner::getNumber() { string number = ""; number += m_peekChar; while ((m_peekChar = this->peekChar()) != EOF) { if (isdigit(m_peekChar)) { number += m_peekChar; } else { break; } } m_number = atoi(number.c_str()); }
[ [ [ 1, 242 ] ] ]
98e9ccdf7eefb03d1ebdb465260527badc1d76fd
9a33169387ec29286d82e6e0d5eb2a388734c969
/TreeHierarchy/ServerSocket.cpp
5f72092ae56c64ac1770036c53d9802f4037d64b
[]
no_license
cecilerap/3dbipedrobot
a62773a6db583d66c80f9b8ab78d932b163c8dd9
83c8f972e09ca8f16c89fc9064c55212d197d06a
refs/heads/master
2021-01-10T13:28:09.532652
2009-04-24T03:03:13
2009-04-24T03:03:13
53,042,363
0
0
null
null
null
null
UTF-8
C++
false
false
1,493
cpp
////////////////////////////////////////////////////////////////////////// // ServerSocket.cpp ////////////////////////////////////////////////////////////////////////// #include <winsock2.h> #include <assert.h> #include "ServerSocket.h" CServerSocket::CServerSocket(void) : m_sock(INVALID_SOCKET) { } CServerSocket::~CServerSocket(void) { if(m_sock != INVALID_SOCKET) Close(); } BOOL CServerSocket::Create(unsigned short port) { assert(m_sock == INVALID_SOCKET); if((m_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) return FALSE; sockaddr_in addr = {0}; addr.sin_family = AF_INET; addr.sin_port = htons(port); addr.sin_addr.s_addr = INADDR_ANY; int ret; if((ret = bind(m_sock, (sockaddr*)&addr, sizeof(addr))) == SOCKET_ERROR || (ret = listen(m_sock, SOMAXCONN)) == SOCKET_ERROR ) { Close(); return FALSE; } return TRUE; } SOCKET CServerSocket::Accept(sockaddr_in* addr) { int len = sizeof(sockaddr_in); return accept(m_sock, (sockaddr*)addr, &len); } void CServerSocket::Close() { assert(m_sock != INVALID_SOCKET); closesocket(m_sock); m_sock = INVALID_SOCKET; } int CServerSocket::Send(const char* data, unsigned int len) { assert(m_sock != INVALID_SOCKET); return ::send( m_sock, data, len, 0 ); } int CServerSocket::Recv(char* data, unsigned int bufSize) { assert(m_sock != INVALID_SOCKET); return ::recv(m_sock, data, bufSize, 0); }
[ "t2wish@463fb1f2-0299-11de-9d1d-173cc1d06e3c" ]
[ [ [ 1, 66 ] ] ]
fabb518410ff2694073ec00bbfe47178bf5f2f7c
b1cc5fbe3a6ee5ff0e7536e5725e7cc5f8ab392e
/HW3/main.cpp
d9fdd1c73e33fb6105bfc27ddafbde0c96872b19
[]
no_license
adirzim/HW3
f234fcf951021663f2f22bce2c799b3e94b5516f
412400b01e0e9034a95e3c40938aad3962087499
refs/heads/master
2020-08-06T16:08:04.204842
2011-04-13T09:34:41
2011-04-13T09:34:41
1,575,957
1
0
null
null
null
null
UTF-8
C++
false
false
6,099
cpp
/* * main.cpp * */ #include "memPool_t.h" #include <iostream> using namespace std; //********** Class Person**********/ class Person { public: Person (); Person (int age, double height); int age; double height; }; Person::Person(int age, double height) { this->age = age; this->height = height; } Person::Person() : age(0), height(0){ } //********** variable decleration**********/ int i,j,k,l,m; //********** Method decleration **********/ void write( memPool_t &pool ); //********** other stored type **********/ ostream &operator<<(ostream &os, Person &p){ return os << "Age: " << p.age << '\n' << "Height: " << p.height << endl; } void read( memPool_t &pool ); void GetInformation( memPool_t &pool ); void DoOtherActions( memPool_t &pool ); int main (int argc, int **argv){ memPool_t pool; while (1) { cout << "Choose action:" << endl << "*************" << endl << "1- read/write 2 - information" << endl << "3- other action 4 - exit" <<endl; cin >> k; cout << endl; switch(k){ case 1: cout << "Choose type:" << endl << "***********" << endl << "1 - Person 2 - int" << endl << "3 - double 4 - char" << endl; cin >> i; cout << endl; cout << "Choose action:" <<endl << "**************" << endl << "1- read 2 - write" <<endl; cin >> j; switch(j){ case 1: read(pool); break; case 2: write(pool); break; } continue; case 2: GetInformation(pool); continue; case 3: DoOtherActions(pool); continue; default: case 4: exit(1); } cout << endl; } return 1; } void write( memPool_t &pool ) { int intValue; int position; Person p; if ((i > 0)&&(5 > i)){ switch(i){ case 1: int age; double height; cout << "enter age:"; cin >> age; cout << endl; cout << "enter height:"; cin >> height; cout << endl; p.age = age; p.height = height; position = pool.GetCurrentPosition(); pool.write<Person> (p, sizeof(p)); cout << "new Person with the age of " << p.age << " and height of " << p.height << " was written to position: " << position << endl; break; case 2: cout << "enter value of int:"; cin >> intValue; cout << endl; position = pool.GetCurrentPosition(); pool.write<int> (intValue,sizeof(intValue)); cout << "int with the value of: " << intValue << " was written to position: " << position << endl; break; case 3: double doubleValue; cout << "enter value of double:"; cin >> doubleValue; cout << endl; position = pool.GetCurrentPosition(); pool.write<double> (doubleValue,sizeof(doubleValue)); cout << "double with the value of: " << doubleValue << " was written to position: " << position << endl; break; case 4: char charValue; cout << "enter value of char:"; cin >> charValue; cout << endl; position = pool.GetCurrentPosition(); pool.write<char> (charValue,sizeof(charValue)); cout << "char with the value of: " << charValue << " was written to position: " << position << endl; break; default: break; } } cout << endl; } void read( memPool_t &pool ) { int position; Person p; cout << "enter position: "; cin >> position; cout <<endl; switch (i){ case 1: pool.read<Person> (p, sizeof(p),position); cout << "Person with age: " << p.age << " and height: " << p.height << " was read from position: " << position << endl; break; case 2: int intValue; pool.read(intValue,sizeof(intValue),position); cout << "int with value of " << intValue << " was read from position: " << position << endl; break; case 3: double doubleValue; pool.read(doubleValue,sizeof(doubleValue),position); cout << "double with value of " << doubleValue << " was read from position: " << position << endl; break; case 4: char charValue; pool.read(charValue,sizeof(charValue),position); cout << "char with value of " << charValue << " was read from position: " << position << endl; break; default: break; } cout << endl; } void GetInformation( memPool_t &pool ) { cout << "Choose action:" << endl <<"***************"<< endl << "1- Is Empty? 2- actual size of poll" << endl << "3- capacity 4- number of pages" << endl << "5- get 1st page 6- get last page" << endl << "7- get current page 8- get current position" << endl << "9- get default page size" << endl; cin >> l; switch (l) { case 1: cout << (pool.IsEmpty() ? "yes" : "no") << endl; break; case 2: cout << pool.GetActualSize() << endl; break; case 3: cout << pool.GetCapacity()<< endl; break; case 4: cout << pool.GetNumberOfPages()<< endl; break; case 5: cout << pool.GetFirstMemPage()<< endl; break; case 6: cout << pool.GetLastMemPage()<< endl; break; case 7: cout << pool.GetCurrentMemPage()<< endl; break; case 8: cout << pool.GetCurrentPosition()<<endl; break; case 9: cout << pool.GetDefaultPageSize()<<endl; break; default: break; } } void DoOtherActions( memPool_t &pool ) { cout << "Choose action:" <<"***************" <<endl <<"1- set default page size" << endl <<"2- set current position" << endl <<"3- create new page" << endl; cin >> m; switch (m) { case 1: int size; cout << "enter size:"; cin >> size; cout << endl; pool.SetDefaultPageSize(size); break; case 2: int pos; cout << "enter position:"; cin >> pos; cout << endl; pool.SetCurrentPosition(pos); break; case 3: pool.createNewMemPage(); cout << " new page has been created" << endl; break; default: break; } }
[ [ [ 1, 9 ], [ 11, 30 ], [ 32, 32 ], [ 34, 34 ], [ 36, 36 ], [ 38, 38 ], [ 40, 40 ], [ 42, 42 ], [ 45, 45 ], [ 47, 47 ], [ 49, 49 ], [ 54, 54 ], [ 56, 57 ], [ 97, 97 ], [ 106, 107 ], [ 112, 112 ], [ 119, 120 ], [ 127, 127 ], [ 165, 166 ], [ 171, 171 ], [ 175, 175 ], [ 183, 183 ], [ 202, 203 ], [ 247, 248 ], [ 280, 282 ] ], [ [ 10, 10 ], [ 31, 31 ], [ 33, 33 ], [ 35, 35 ], [ 37, 37 ], [ 39, 39 ], [ 41, 41 ], [ 43, 44 ], [ 46, 46 ], [ 48, 48 ], [ 50, 53 ], [ 55, 55 ], [ 58, 96 ], [ 98, 105 ], [ 108, 111 ], [ 113, 118 ], [ 121, 126 ], [ 128, 164 ], [ 167, 170 ], [ 172, 174 ], [ 176, 182 ], [ 184, 201 ], [ 204, 246 ], [ 249, 279 ], [ 283, 284 ] ] ]
17f564d68e7865fd9e4437dbae429aa36821b968
e02fa80eef98834bf8a042a09d7cb7fe6bf768ba
/TEST_MyGUI_Source/MyGUIEngine/src/MyGUI_VScrollFactory.cpp
f15e7493434892a6b58011e33bcedba9addd94df
[]
no_license
MyGUI/mygui-historical
fcd3edede9f6cb694c544b402149abb68c538673
4886073fd4813de80c22eded0b2033a5ba7f425f
refs/heads/master
2021-01-23T16:40:19.477150
2008-03-06T22:19:12
2008-03-06T22:19:12
22,805,225
2
0
null
null
null
null
WINDOWS-1251
C++
false
false
2,427
cpp
/*! @file @author Albert Semenov @date 11/2007 @module */ #include "MyGUI_VScrollFactory.h" #include "MyGUI_VScroll.h" #include "MyGUI_SkinManager.h" #include "MyGUI_WidgetManager.h" namespace MyGUI { namespace factory { VScrollFactory::VScrollFactory() { // регестрируем себя MyGUI::WidgetManager & manager = MyGUI::WidgetManager::getInstance(); manager.registerFactory(this); // регестрируем все парсеры manager.registerDelegate("Scroll_Range") = newDelegate(this, &VScrollFactory::Scroll_Range); manager.registerDelegate("Scroll_Position") = newDelegate(this, &VScrollFactory::Scroll_Position); manager.registerDelegate("Scroll_Page") = newDelegate(this, &VScrollFactory::Scroll_Page); } VScrollFactory::~VScrollFactory() { // удаляем себя MyGUI::WidgetManager & manager = MyGUI::WidgetManager::getInstance(); manager.unregisterFactory(this); // удаляем все парсеры manager.unregisterDelegate("Scroll_Range"); manager.unregisterDelegate("Scroll_Position"); manager.unregisterDelegate("Scroll_Page"); } const Ogre::String& VScrollFactory::getType() { return VScroll::_getType(); } WidgetPtr VScrollFactory::createWidget(const Ogre::String& _skin, const IntCoord& _coord, Align _align, CroppedRectanglePtr _parent, WidgetCreator * _creator, const Ogre::String& _name) { return new VScroll(_coord, _align, SkinManager::getInstance().getSkin(_skin), _parent, _creator, _name); } void VScrollFactory::Scroll_Range(WidgetPtr _widget, const Ogre::String &_key, const Ogre::String &_value) { MYGUI_RETURN_IS_FALSE_TYPE(VScrollPtr, _widget, _key); static_cast<VScrollPtr>(_widget)->setScrollRange(utility::parseSizeT(_value)); } void VScrollFactory::Scroll_Position(WidgetPtr _widget, const Ogre::String &_key, const Ogre::String &_value) { MYGUI_RETURN_IS_FALSE_TYPE(VScrollPtr, _widget, _key); static_cast<VScrollPtr>(_widget)->setScrollPosition(utility::parseSizeT(_value)); } void VScrollFactory::Scroll_Page(WidgetPtr _widget, const Ogre::String &_key, const Ogre::String &_value) { MYGUI_RETURN_IS_FALSE_TYPE(VScrollPtr, _widget, _key); static_cast<VScrollPtr>(_widget)->setScrollPage(utility::parseSizeT(_value)); } } // namespace factory } // namespace MyGUI
[ [ [ 1, 71 ] ] ]
e9dc82c72d96866cdad6d29c94a6ad51ef33745e
92c233548950eb0d8474151a1e9c4b4f7bddd450
/src/Tests/testRoundTrip1.cpp
83b3c0a8ed8d9b19aff6b11ef6619c4081e001f6
[]
no_license
alepharchives/quickfast
f989e431d1faaacc4404d26bb1c28f8380dc2e70
53c1834b6a8552fa491d139a41ecf2c91ce44ca6
refs/heads/master
2020-04-11T03:00:09.627113
2011-04-01T13:57:07
2011-04-01T13:57:07
6,812,133
0
1
null
null
null
null
UTF-8
C++
false
false
32,455
cpp
// Copyright (c) 2009, Object Computing, Inc. // All rights reserved. // See the file license.txt for licensing information. #include <Common/QuickFASTPch.h> #define BOOST_TEST_NO_MAIN QuickFASTTest #include <boost/test/unit_test.hpp> #include <boost/filesystem.hpp> #include <Codecs/XMLTemplateParser.h> #include <Codecs/TemplateRegistry.h> #include <Codecs/Encoder.h> #include <Codecs/Decoder.h> #include <Codecs/DataDestination.h> #include <Codecs/DataSourceString.h> #include <Codecs/SingleMessageConsumer.h> #include <Codecs/GenericMessageBuilder.h> #include <Messages/Message.h> #include <Messages/FieldIdentity.h> #include <Messages/FieldInt32.h> #include <Messages/FieldUInt32.h> #include <Messages/FieldInt64.h> #include <Messages/FieldUInt64.h> #include <Messages/FieldAscii.h> #include <Messages/FieldByteVector.h> #include <Messages/FieldDecimal.h> #include <Messages/FieldGroup.h> #include <Messages/FieldSequence.h> #include <Messages/FieldUtf8.h> #include <Messages/Sequence.h> #include <Common/Exceptions.h> #include <fstream> #include <cstdlib> using namespace QuickFAST; // test with various combinations: (8*5 + 4 + 3) * 2 = 94 //8 primitive field types: // int32, int64, uint32, uint64, decimal, ascii string, utf8 string, //byte vector //5 general purpose operators // nop, constant, default, copy, delta, //2 special purpose operators: // increment (applies only to 4 integer types), tail (applies only //to 3 types: ascii, utf8, and byte vector) //2 presence values // mandatory, required namespace{ void validateMessage1(Messages::Message & message) { BOOST_CHECK_EQUAL(message.getApplicationType(), "unittestdata"); Messages::FieldCPtr value; //<int32 name="int32_nop" id="1"> //msg.addField(identity_int32_nop, Messages::FieldInt32::create(-1)); BOOST_CHECK(message.getField("int32_nop", value)); BOOST_CHECK_EQUAL(value->toInt32(), -1); //<uInt32 name="uint32_nop" id="2"> //msg.addField(identity_uint32_nop, Messages::FieldUInt32::create(1)); BOOST_CHECK(message.getField("uint32_nop", value)); BOOST_CHECK_EQUAL(value->toUInt32(), 1); //<int64 name="int64_nop" id="3"> //msg.addField(identity_int64_nop, Messages::FieldInt64::create(-500000000)); BOOST_CHECK(message.getField("int64_nop", value)); BOOST_CHECK_EQUAL(value->toInt64(), -500000000); //<uInt64 name="uint64_nop" id="4"> //msg.addField(identity_uint64_nop, Messages::FieldUInt64::create(500000000)); BOOST_CHECK(message.getField("uint64_nop", value)); BOOST_CHECK_EQUAL(value->toUInt64(), 500000000); //<decimal name="decimal_nop" id="5"> //msg.addField(identity_decimal_nop, Messages::FieldDecimal::create(Decimal(12345, -4))); BOOST_CHECK(message.getField("decimal_nop", value)); BOOST_CHECK_EQUAL(value->toDecimal(), Decimal (12345, -4)); //<string name="asciistring_nop" charset="ascii" id="6"> //msg.addField(identity_asciistring_nop, Messages::FieldAscii::create("asciistringblabla")); BOOST_CHECK(message.getField("asciistring_nop", value)); BOOST_CHECK_EQUAL(value->toAscii(), "asciistringblabla"); //<string name="utf8string_nop" charset="unicode" id="7"> //msg.addField(identity_utf8string_nop, Messages::FieldAscii::create("utf8stringblabla")); BOOST_CHECK(message.getField("utf8string_nop", value)); BOOST_CHECK_EQUAL(value->toUtf8(), "utf8stringblabla"); //<byteVector name="bytevector_nop" id="8"> //msg.addField(identity_bytevector_nop, Messages::FieldByteVector::create("bytevectorblabla")); BOOST_CHECK(message.getField("bytevector_nop", value)); BOOST_CHECK_EQUAL(value->toByteVector(), "bytevectorblabla"); // <int32 name="int32_const" id="9"><constant value="-90"/> //msg.addField(identity_int32_const, Messages::FieldInt32::create(-90)); BOOST_CHECK(message.getField("int32_const", value)); BOOST_CHECK_EQUAL(value->toInt32(), -90); // <uInt32 name="uint32_const" id="10"><constant value="100"/> //msg.addField(identity_uint32_const, Messages::FieldUInt32::create(100)); BOOST_CHECK(message.getField("uint32_const", value)); BOOST_CHECK_EQUAL(value->toUInt32(), 100); // <int64 name="int64_const" id="11"><constant value="-5000000000"/> //msg.addField(identity_int64_const, Messages::FieldInt64::create(-5000000000)); BOOST_CHECK(message.getField("int64_const", value)); BOOST_CHECK_EQUAL(value->toInt64(), -5000000000LL); // <uInt64 name="uint64_const" id="12"><constant value="5000000000"/> //msg.addField(identity_uint64_const, Messages::FieldUInt64::create(5000000000)); BOOST_CHECK(message.getField("uint64_const", value)); BOOST_CHECK_EQUAL(value->toUInt64(), 5000000000ULL); // <decimal name="decimal_const" id="13"><constant value="1.2345"/> //msg.addField(identity_decimal_const, Messages::FieldDecimal::create(Decimal(12345, -4))); BOOST_CHECK(message.getField("decimal_const", value)); BOOST_CHECK_EQUAL(value->toDecimal(), Decimal(12345, -4)); // <string name="asciistring_const" charset="ascii" id="14"><constant value="constant asciistring"/> //msg.addField(identity_asciistring_const, Messages::FieldAscii::create("constant asciistring")); BOOST_CHECK(message.getField("asciistring_const", value)); BOOST_CHECK_EQUAL(value->toAscii(), "constant asciistring"); // <string name="utf8string_const" charset="unicode" id="15"><constant value="constant utf8string"/> //msg.addField(identity_utf8string_const, Messages::FieldAscii::create("constant utf8string")); BOOST_CHECK(message.getField("utf8string_const", value)); BOOST_CHECK_EQUAL(value->toUtf8(), "constant utf8string"); // <byteVector name="bytevector_const" id="16"><constant value="constant bytevector"/> //msg.addField(identity_bytevector_const, Messages::FieldByteVector::create("constant bytevector")); BOOST_CHECK(message.getField("bytevector_const", value)); BOOST_CHECK_EQUAL(value->toByteVector(), "constant bytevector"); // <int32 name="int32_default" id="17"><default value="-190"/> //msg.addField(identity_int32_default, Messages::FieldInt32::create(-190)); BOOST_CHECK(message.getField("int32_default", value)); BOOST_CHECK_EQUAL(value->toInt32(), -190); // <uInt32 name="uint32_default" id="18"><default value="200"/> //msg.addField(identity_uint32_default, Messages::FieldUInt32::create(200)); BOOST_CHECK(message.getField("uint32_default", value)); BOOST_CHECK_EQUAL(value->toUInt32(), 200); // <int64 name="int64_default" id="19"><default value="-6000000000"/> //msg.addField(identity_int64_default, Messages::FieldInt64::create(-6000000000)); BOOST_CHECK(message.getField("int64_default", value)); BOOST_CHECK_EQUAL(value->toInt64(), -6000000000LL); // <uInt64 name="uint64_default" id="20"><default value="6000000000"/> //msg.addField(identity_uint64_default, Messages::FieldUInt64::create(6000000000)); BOOST_CHECK(message.getField("uint64_default", value)); BOOST_CHECK_EQUAL(value->toUInt64(), 6000000000ULL); // <decimal name="decimal_default" id="21"><default value="5.4321"/> //msg.addField(identity_decimal_default, Messages::FieldDecimal::create(Decimal(54321, -4))); BOOST_CHECK(message.getField("decimal_default", value)); BOOST_CHECK_EQUAL(value->toDecimal(), Decimal(54321, -4)); // <string name="asciistring_default" charset="ascii" id="22"><default value="default asciistring"/> //msg.addField(identity_asciistring_default, Messages::FieldAscii::create("default asciistring")); BOOST_CHECK(message.getField("asciistring_default", value)); BOOST_CHECK_EQUAL(value->toAscii(), "default asciistring"); // <string name="utf8string_default" charset="unicode" id="23"><default value="default utf8string"/> //msg.addField(identity_utf8string_default, Messages::FieldAscii::create("default utf8string")); BOOST_CHECK(message.getField("utf8string_default", value)); BOOST_CHECK_EQUAL(value->toUtf8(), "default utf8string"); // <byteVector name="bytevector_default" id="24"><default value="default bytevectorblabla"/> //msg.addField(identity_bytevector_default, Messages::FieldByteVector::create("default bytevectorblabla")); BOOST_CHECK(message.getField("bytevector_default", value)); BOOST_CHECK_EQUAL(value->toByteVector(), "default bytevectorblabla"); // <int32 name="int32_copy" id="25"><copy/> //msg.addField(identity_int32_copy, Messages::FieldInt32::create(-1)); BOOST_CHECK(message.getField("int32_copy", value)); BOOST_CHECK_EQUAL(value->toInt32(), -1); // <uInt32 name="uint32_copy" id="26"><copy/> //msg.addField(identity_uint32_copy, Messages::FieldUInt32::create(1)); BOOST_CHECK(message.getField("uint32_copy", value)); BOOST_CHECK_EQUAL(value->toUInt32(), 1); // <int64 name="int64_copy" id="27"><copy/> //msg.addField(identity_int64_copy, Messages::FieldInt64::create(-5000000000)); BOOST_CHECK(message.getField("int64_copy", value)); BOOST_CHECK_EQUAL(value->toInt64(), -5000000000LL); // <uInt64 name="uint64_copy" id="28"><copy/> // msg.addField(identity_uint64_copy, Messages::FieldUInt64::create(5000000000)); BOOST_CHECK(message.getField("uint64_copy", value)); BOOST_CHECK_EQUAL(value->toUInt64(), 5000000000ULL); // <decimal name="decimal_copy" id="29"><copy value="1.2345"/> //msg.addField(identity_decimal_copy, Messages::FieldDecimal::create(Decimal(12345, -4))); BOOST_CHECK(message.getField("decimal_copy", value)); BOOST_CHECK_EQUAL(value->toDecimal(), Decimal(12345, -4)); // <string name="asciistring_copy" charset="ascii" id="30"><copy/> //msg.addField(identity_asciistring_copy, Messages::FieldAscii::create("asciistringblabla")); BOOST_CHECK(message.getField("asciistring_copy", value)); BOOST_CHECK_EQUAL(value->toAscii(), "asciistringblabla"); // <string name="utf8string_copy" charset="unicode" id="31"><copy/> //msg.addField(identity_utf8string_copy, Messages::FieldAscii::create("utf8stringblabla")); BOOST_CHECK(message.getField("utf8string_copy", value)); BOOST_CHECK_EQUAL(value->toUtf8(), "utf8stringblabla"); // <byteVector name="bytevector_copy" id="32"><copy/> //msg.addField(identity_bytevector_copy, Messages::FieldByteVector::create("bytevectorblabla")); BOOST_CHECK(message.getField("bytevector_copy", value)); BOOST_CHECK_EQUAL(value->toByteVector(), "bytevectorblabla"); // <int32 name="int32_delta" id="33"><copy/> //msg.addField(identity_int32_delta, Messages::FieldInt32::create(-1)); BOOST_CHECK(message.getField("int32_delta", value)); BOOST_CHECK_EQUAL(value->toInt32(), -1); // <uInt32 name="uint32_delta" id="34"><delta/> //msg.addField(identity_uint32_delta, Messages::FieldUInt32::create(1)); BOOST_CHECK(message.getField("uint32_delta", value)); BOOST_CHECK_EQUAL(value->toUInt32(), 1); // <int64 name="int64_delta" id="35"><delta/> //msg.addField(identity_int64_delta, Messages::FieldInt64::create(-1)); BOOST_CHECK(message.getField("int64_delta", value)); BOOST_CHECK_EQUAL(value->toInt64(), -1); // <uInt64 name="uint64_delta" id="36"><delta/> //msg.addField(identity_uint64_delta, Messages::FieldUInt64::create(1)); BOOST_CHECK(message.getField("uint64_delta", value)); BOOST_CHECK_EQUAL(value->toUInt64(), 1); // <decimal name="decimal_delta" id="37"><delta/> //msg.addField(identity_decimal_delta, Messages::FieldDecimal::create(Decimal(12345, -4))); BOOST_CHECK(message.getField("decimal_delta", value)); BOOST_CHECK_EQUAL(value->toDecimal(), Decimal(12345, -4)); // <string name="asciistring_delta" charset="ascii" id="38"><delta/> //msg.addField(identity_asciistring_delta, Messages::FieldAscii::create("blabla")); BOOST_CHECK(message.getField("asciistring_delta", value)); BOOST_CHECK_EQUAL(value->toAscii(), "blabla"); // <string name="utf8string_delta" charset="unicode" id="39"><delta/> //msg.addField(identity_utf8string_delta, Messages::FieldAscii::create("blabla")); BOOST_CHECK(message.getField("utf8string_delta", value)); BOOST_CHECK_EQUAL(value->toUtf8(), "blabla"); // <byteVector name="bytevector_delta" id="40"><delta/> //msg.addField(identity_bytevector_delta, Messages::FieldByteVector::create("blabla")); BOOST_CHECK(message.getField("bytevector_delta", value)); BOOST_CHECK_EQUAL(value->toByteVector(), "blabla"); // <int32 name="int32_incre" id="41"><increment value="1"/> //msg.addField(identity_int32_incre, Messages::FieldInt32::create(1)); BOOST_CHECK(message.getField("int32_incre", value)); BOOST_CHECK_EQUAL(value->toInt32(), 1); // <uInt32 name="uint32_incre" id="42"><increment value="1"/> //msg.addField(identity_uint32_incre, Messages::FieldUInt32::create(1)); BOOST_CHECK(message.getField("uint32_incre", value)); BOOST_CHECK_EQUAL(value->toUInt32(), 1); // <int64 name="int64_incre" id="43"><increment value="1"/> //msg.addField(identity_int64_incre, Messages::FieldInt64::create(1)); BOOST_CHECK(message.getField("int64_incre", value)); BOOST_CHECK_EQUAL(value->toInt64(), 1); // <uInt64 name="uint64_incre" id="44"><increment value="1"/> //msg.addField(identity_uint64_incre, Messages::FieldUInt64::create(1)); BOOST_CHECK(message.getField("uint64_incre", value)); BOOST_CHECK_EQUAL(value->toUInt64(), 1); // <string name="asciistring_tail" charset="ascii" id="45"><tail/> //msg.addField(identity_asciistring_tail, Messages::FieldAscii::create("blabla")); BOOST_CHECK(message.getField("asciistring_tail", value)); BOOST_CHECK_EQUAL(value->toAscii(), "blabla"); // <string name="utf8string_tail" charset="unicode" id="46"><tail/> //msg.addField(identity_utf8string_tail, Messages::FieldAscii::create("blabla")); BOOST_CHECK(message.getField("utf8string_tail", value)); BOOST_CHECK_EQUAL(value->toUtf8(), "blabla"); // <byteVector name="bytevector_tail" id="47"><tail/> //msg.addField(identity_bytevector_tail, Messages::FieldByteVector::create("blabla")); BOOST_CHECK(message.getField("bytevector_tail", value)); BOOST_CHECK_EQUAL(value->toByteVector(), "blabla"); } void test (const std::string& xml) { std::ifstream templateStream(xml.c_str(), std::ifstream::binary); BOOST_CHECK(templateStream.good()); Codecs::XMLTemplateParser parser; Codecs::TemplateRegistryPtr templateRegistry = parser.parse(templateStream); BOOST_CHECK(templateRegistry); Messages::Message msg(templateRegistry->maxFieldCount()); //<int32 name="int32_nop" id="1"> Messages::FieldIdentityCPtr identity_int32_nop = new Messages::FieldIdentity("int32_nop"); //<uInt32 name="uint32_nop" id="2"> Messages::FieldIdentityCPtr identity_uint32_nop = new Messages::FieldIdentity("uint32_nop"); //<int64 name="int64_nop" id="3"> Messages::FieldIdentityCPtr identity_int64_nop = new Messages::FieldIdentity("int64_nop"); //<uInt64 name="uint64_nop" id="4"> Messages::FieldIdentityCPtr identity_uint64_nop = new Messages::FieldIdentity("uint64_nop"); //<decimal name="decimal_nop" id="5"> Messages::FieldIdentityCPtr identity_decimal_nop = new Messages::FieldIdentity("decimal_nop"); //<string name="asciistring_nop" charset="ascii" id="6"> Messages::FieldIdentityCPtr identity_asciistring_nop = new Messages::FieldIdentity("asciistring_nop"); //<string name="utf8string_nop" charset="unicode" id="7"> Messages::FieldIdentityCPtr identity_utf8string_nop = new Messages::FieldIdentity("utf8string_nop"); //<byteVector name="bytevector_nop" id="8"> Messages::FieldIdentityCPtr identity_bytevector_nop = new Messages::FieldIdentity("bytevector_nop"); // <int32 name="int32_const" id="9"><constant value="-90"/> Messages::FieldIdentityCPtr identity_int32_const = new Messages::FieldIdentity("int32_const"); // <uInt32 name="uint32_const" id="10"><constant value="100"/> Messages::FieldIdentityCPtr identity_uint32_const = new Messages::FieldIdentity("uint32_const"); // <int64 name="int64_const" id="11"><constant value="-5000000000"/> Messages::FieldIdentityCPtr identity_int64_const = new Messages::FieldIdentity("int64_const"); // <uInt64 name="uint64_const" id="12"><constant value="5000000000"/> Messages::FieldIdentityCPtr identity_uint64_const = new Messages::FieldIdentity("uint64_const"); //<decimal name="decimal_const" id="13"><constant value="1.2345"/> Messages::FieldIdentityCPtr identity_decimal_const = new Messages::FieldIdentity("decimal_const"); // <string name="asciistring_const" charset="ascii" id="14"><constant value="constant asciistring"/> Messages::FieldIdentityCPtr identity_asciistring_const = new Messages::FieldIdentity("asciistring_const"); // <string name="utf8string_const" charset="unicode" id="15"><constant value="constant utf8string"/> Messages::FieldIdentityCPtr identity_utf8string_const = new Messages::FieldIdentity("utf8string_const"); // <byteVector name="bytevector_const" id="16"><constant value="constant bytevector"/> Messages::FieldIdentityCPtr identity_bytevector_const = new Messages::FieldIdentity("bytevector_const"); // <int32 name="int32_default" id="17"><default value="-190"/> Messages::FieldIdentityCPtr identity_int32_default = new Messages::FieldIdentity("int32_default"); // <uInt32 name="uint32_default" id="18"><default value="200"/> Messages::FieldIdentityCPtr identity_uint32_default = new Messages::FieldIdentity("uint32_default"); // <uInt64 name="int64_default" id="19"><default value="-6000000000"/> Messages::FieldIdentityCPtr identity_int64_default = new Messages::FieldIdentity("int64_default"); // <uInt64 name="uint64_default" id="20"><default value="6000000000"/> Messages::FieldIdentityCPtr identity_uint64_default = new Messages::FieldIdentity("uint64_default"); // <decimal name="decimal_default" id="21"><default value="5.4321"/> Messages::FieldIdentityCPtr identity_decimal_default = new Messages::FieldIdentity("decimal_default"); // <string name="asciistring_default" charset="ascii" id="22"><default value="default asciistring"/> Messages::FieldIdentityCPtr identity_asciistring_default = new Messages::FieldIdentity("asciistring_default"); // <string name="utf8string_default" charset="unicode" id="23"><default value="default utf8string"/> Messages::FieldIdentityCPtr identity_utf8string_default = new Messages::FieldIdentity("utf8string_default"); // <byteVector name="bytevector_default" id="24"><default value="default bytevectorblabla"/> Messages::FieldIdentityCPtr identity_bytevector_default = new Messages::FieldIdentity("bytevector_default"); // <int32 name="int32_copy" id="25"><copy/> Messages::FieldIdentityCPtr identity_int32_copy = new Messages::FieldIdentity("int32_copy"); // <uInt32 name="uint32_copy" id="26"><copy/> Messages::FieldIdentityCPtr identity_uint32_copy = new Messages::FieldIdentity("uint32_copy"); // <int64 name="int64_copy" id="27"><copy/> Messages::FieldIdentityCPtr identity_int64_copy = new Messages::FieldIdentity("int64_copy"); // <uInt64 name="uint64_copy" id="28"><copy/> Messages::FieldIdentityCPtr identity_uint64_copy = new Messages::FieldIdentity("uint64_copy"); // <decimal name="decimal_copy" id="29"><copy value="1.2345"/> Messages::FieldIdentityCPtr identity_decimal_copy = new Messages::FieldIdentity("decimal_copy"); // <string name="asciistring_copy" charset="ascii" id="30"><copy/> Messages::FieldIdentityCPtr identity_asciistring_copy = new Messages::FieldIdentity("asciistring_copy"); // <string name="utf8string_copy" charset="unicode" id="31"><copy/> Messages::FieldIdentityCPtr identity_utf8string_copy = new Messages::FieldIdentity("utf8string_copy"); // <byteVector name="bytevector_copy" id="32"><copy/> Messages::FieldIdentityCPtr identity_bytevector_copy = new Messages::FieldIdentity("bytevector_copy"); // <int32 name="int32_delta" id="33"><copy/> Messages::FieldIdentityCPtr identity_int32_delta = new Messages::FieldIdentity("int32_delta"); // <uInt32 name="uint32_delta" id="34"><delta/> Messages::FieldIdentityCPtr identity_uint32_delta = new Messages::FieldIdentity("uint32_delta"); // <int64 name="int64_delta" id="35"><delta/> Messages::FieldIdentityCPtr identity_int64_delta = new Messages::FieldIdentity("int64_delta"); // <uInt64 name="uint64_delta" id="36"><delta/> Messages::FieldIdentityCPtr identity_uint64_delta = new Messages::FieldIdentity("uint64_delta"); // <decimal name="decimal_delta" id="37"><delta/> Messages::FieldIdentityCPtr identity_decimal_delta = new Messages::FieldIdentity("decimal_delta"); // <string name="asciistring_delta" charset="ascii" id="38"><delta/> Messages::FieldIdentityCPtr identity_asciistring_delta = new Messages::FieldIdentity("asciistring_delta"); // <string name="utf8string_delta" charset="unicode" id="39"><delta/> Messages::FieldIdentityCPtr identity_utf8string_delta = new Messages::FieldIdentity("utf8string_delta"); // <byteVector name="bytevector_delta" id="40"><delta/> Messages::FieldIdentityCPtr identity_bytevector_delta = new Messages::FieldIdentity("bytevector_delta"); // <int32 name="int32_incre" id="41"><increment value="1"/> Messages::FieldIdentityCPtr identity_int32_incre = new Messages::FieldIdentity("int32_incre"); // <uInt32 name="uint32_incre" id="42"><increment value="1"/> Messages::FieldIdentityCPtr identity_uint32_incre = new Messages::FieldIdentity("uint32_incre"); // <int64 name="int64_incre" id="43"><increment value="1"/> Messages::FieldIdentityCPtr identity_int64_incre = new Messages::FieldIdentity("int64_incre"); // <uInt64 name="uint64_incre" id="44"><increment value="1"/> Messages::FieldIdentityCPtr identity_uint64_incre = new Messages::FieldIdentity("uint64_incre"); // <string name="asciistring_tail" charset="ascii" id="45"><tail/> Messages::FieldIdentityCPtr identity_asciistring_tail = new Messages::FieldIdentity("asciistring_tail"); // <string name="utf8string_tail" charset="unicode" id="46"><tail/> Messages::FieldIdentityCPtr identity_utf8string_tail = new Messages::FieldIdentity("utf8string_tail"); // <byteVector name="bytevector_tail" id="47"><tail/> Messages::FieldIdentityCPtr identity_bytevector_tail = new Messages::FieldIdentity("bytevector_tail"); //<int32 name="int32_nop" id="1"> msg.addField(identity_int32_nop, Messages::FieldInt32::create(-1)); //<uInt32 name="uint32_nop" id="2"> msg.addField(identity_uint32_nop, Messages::FieldUInt32::create(1)); //<int64 name="int64_nop" id="3"> msg.addField(identity_int64_nop, Messages::FieldInt64::create(-500000000)); //<uInt64 name="uint64_nop" id="4"> msg.addField(identity_uint64_nop, Messages::FieldUInt64::create(500000000)); //<decimal name="decimal_nop" id="5"> msg.addField(identity_decimal_nop, Messages::FieldDecimal::create(Decimal(12345, -4))); //<string name="asciistring_nop" charset="ascii" id="6"> msg.addField(identity_asciistring_nop, Messages::FieldAscii::create("asciistringblabla")); //<string name="utf8string_nop" charset="unicode" id="7"> msg.addField(identity_utf8string_nop, Messages::FieldAscii::create("utf8stringblabla")); //<byteVector name="bytevector_nop" id="8"> msg.addField(identity_bytevector_nop, Messages::FieldByteVector::create("bytevectorblabla")); // <int32 name="int32_const" id="9"><constant value="-90"/> msg.addField(identity_int32_const, Messages::FieldInt32::create(-90)); // <uInt32 name="uint32_const" id="10"><constant value="100"/> msg.addField(identity_uint32_const, Messages::FieldUInt32::create(100)); // <int64 name="int64_const" id="11"><constant value="-5000000000"/> msg.addField(identity_int64_const, Messages::FieldInt64::create(-5000000000LL)); // <uInt64 name="uint64_const" id="12"><constant value="5000000000"/> msg.addField(identity_uint64_const, Messages::FieldUInt64::create(5000000000ULL)); // <decimal name="decimal_const" id="13"><constant value="1.2345"/> msg.addField(identity_decimal_const, Messages::FieldDecimal::create(Decimal(12345, -4))); // <string name="asciistring_const" charset="ascii" id="14"><constant value="constant asciistring"/> msg.addField(identity_asciistring_const, Messages::FieldAscii::create("constant asciistring")); // <string name="utf8string_const" charset="unicode" id="15"><constant value="constant utf8string"/> msg.addField(identity_utf8string_const, Messages::FieldAscii::create("constant utf8string")); // <byteVector name="bytevector_const" id="16"><constant value="constant bytevector"/> msg.addField(identity_bytevector_const, Messages::FieldByteVector::create("constant bytevector")); // <int32 name="int32_default" id="17"><default value="-190"/> msg.addField(identity_int32_default, Messages::FieldInt32::create(-190)); // <uInt32 name="uint32_default" id="18"><default value="200"/> msg.addField(identity_uint32_default, Messages::FieldUInt32::create(200)); // <int64 name="int64_default" id="19"><default value="-6000000000"/> msg.addField(identity_int64_default, Messages::FieldInt64::create(-6000000000LL)); // <uInt64 name="uint64_default" id="20"><default value="6000000000"/> msg.addField(identity_uint64_default, Messages::FieldUInt64::create(6000000000ULL)); // <decimal name="decimal_default" id="21"><default value="5.4321"/> msg.addField(identity_decimal_default, Messages::FieldDecimal::create(Decimal(54321, -4))); // <string name="asciistring_default" charset="ascii" id="22"><default value="default asciistring"/> msg.addField(identity_asciistring_default, Messages::FieldAscii::create("default asciistring")); // <string name="utf8string_default" charset="unicode" id="23"><default value="default utf8string"/> msg.addField(identity_utf8string_default, Messages::FieldAscii::create("default utf8string")); // <byteVector name="bytevector_default" id="24"><default value="default bytevectorblabla"/> msg.addField(identity_bytevector_default, Messages::FieldByteVector::create("default bytevectorblabla")); // <int32 name="int32_copy" id="25"><copy/> msg.addField(identity_int32_copy, Messages::FieldInt32::create(-1)); // <uInt32 name="uint32_copy" id="26"><copy/> msg.addField(identity_uint32_copy, Messages::FieldUInt32::create(1)); // <int64 name="int64_copy" id="27"><copy/> msg.addField(identity_int64_copy, Messages::FieldInt64::create(-5000000000LL)); // <uInt64 name="uint64_copy" id="28"><copy/> msg.addField(identity_uint64_copy, Messages::FieldUInt64::create(5000000000ULL)); // <decimal name="decimal_copy" id="29"><copy value="1.2345"/> msg.addField(identity_decimal_copy, Messages::FieldDecimal::create(Decimal(12345, -4))); // <string name="asciistring_copy" charset="ascii" id="30"><copy/> msg.addField(identity_asciistring_copy, Messages::FieldAscii::create("asciistringblabla")); // <string name="utf8string_copy" charset="unicode" id="31"><copy/> msg.addField(identity_utf8string_copy, Messages::FieldAscii::create("utf8stringblabla")); // <byteVector name="bytevector_copy" id="32"><copy/> msg.addField(identity_bytevector_copy, Messages::FieldByteVector::create("bytevectorblabla")); // <int32 name="int32_delta" id="33"><copy/> msg.addField(identity_int32_delta, Messages::FieldInt32::create(-1)); // <uInt32 name="uint32_delta" id="34"><delta/> msg.addField(identity_uint32_delta, Messages::FieldUInt32::create(1)); // <int64 name="int64_delta" id="35"><delta/> msg.addField(identity_int64_delta, Messages::FieldInt64::create(-1)); // <uInt64 name="uint64_delta" id="36"><delta/> msg.addField(identity_uint64_delta, Messages::FieldUInt64::create(1)); // <decimal name="decimal_delta" id="37"><delta/> msg.addField(identity_decimal_delta, Messages::FieldDecimal::create(Decimal(12345, -4))); // <string name="asciistring_delta" charset="ascii" id="38"><delta/> msg.addField(identity_asciistring_delta, Messages::FieldAscii::create("blabla")); // <string name="utf8string_delta" charset="unicode" id="39"><delta/> msg.addField(identity_utf8string_delta, Messages::FieldAscii::create("blabla")); // <byteVector name="bytevector_delta" id="40"><delta/> msg.addField(identity_bytevector_delta, Messages::FieldByteVector::create("blabla")); // <int32 name="int32_incre" id="41"><increment value="1"/> msg.addField(identity_int32_incre, Messages::FieldInt32::create(1)); // <uInt32 name="uint32_incre" id="42"><increment value="1"/> msg.addField(identity_uint32_incre, Messages::FieldUInt32::create(1)); // <int64 name="int64_incre" id="43"><increment value="1"/> msg.addField(identity_int64_incre, Messages::FieldInt64::create(1)); // <uInt64 name="uint64_incre" id="44"><increment value="1"/> msg.addField(identity_uint64_incre, Messages::FieldUInt64::create(1)); // <string name="asciistring_tail" charset="ascii" id="45"><tail/> msg.addField(identity_asciistring_tail, Messages::FieldAscii::create("blabla")); // <string name="utf8string_tail" charset="unicode" id="46"><tail/> msg.addField(identity_utf8string_tail, Messages::FieldAscii::create("blabla")); // <byteVector name="bytevector_tail" id="47"><tail/> msg.addField(identity_bytevector_tail, Messages::FieldByteVector::create("blabla")); Codecs::Encoder encoder(templateRegistry); // encoder.setVerboseOutput (std::cout); Codecs::DataDestination destination; template_id_t templId = 3; // from the XML file encoder.encodeMessage(destination, templId, msg); std::string fastString; destination.toString(fastString); destination.clear(); #if 0 for(size_t nb = 0; nb < fastString.length(); ++ nb) { if(nb %16 == 0) std::cout << std::endl; else std::cout << ' '; std::cout << std::hex << std::setw(2) << std::setfill('0') << (0xFF & (unsigned short) fastString[nb]) << std::dec << std::setfill(' '); } std::cout << std::endl; #endif Codecs::Decoder decoder(templateRegistry); //decoder.setVerboseOutput (std::cout); Codecs::DataSourceString source(fastString); // source.setEcho(std::cout, Codecs::DataSource::HEX, true, true); Codecs::SingleMessageConsumer consumer; Codecs::GenericMessageBuilder builder(consumer); decoder.decodeMessage(source, builder); Messages::Message & msgOut(consumer.message()); validateMessage1(msgOut); // wanna see it again? encoder.reset(); encoder.encodeMessage(destination, templId, msgOut); std::string reencoded; destination.toString(reencoded); destination.clear(); #if 0 for(size_t nb = 0; nb < reencoded.length(); ++ nb) { if(nb %16 == 0) std::cout << std::endl; else std::cout << ' '; std::cout << std::hex << std::setw(2) << std::setfill('0') << (0xFF & (unsigned short) reencoded[nb]) << std::dec << std::setfill(' '); } std::cout << std::endl; #endif BOOST_CHECK(fastString == reencoded); } } BOOST_AUTO_TEST_CASE(TestRoundTripMandatory) { std::string xml (std::getenv ("QUICKFAST_ROOT")); xml += "/src/Tests/resources/unittest_mandatory.xml"; test (xml); } BOOST_AUTO_TEST_CASE(TestRoundTripOptional) { std::string xml (std::getenv ("QUICKFAST_ROOT")); xml += "/src/Tests/resources/unittest_optional.xml"; test (xml); }
[ "[email protected]@d6d8e96c-ed78-11dd-ab07-b19b4dad1b3d", "dale.wilson@d6d8e96c-ed78-11dd-ab07-b19b4dad1b3d" ]
[ [ [ 1, 13 ], [ 15, 15 ], [ 18, 38 ], [ 41, 111 ], [ 113, 116 ], [ 118, 151 ], [ 153, 156 ], [ 158, 191 ], [ 193, 196 ], [ 198, 299 ], [ 301, 304 ], [ 306, 423 ], [ 425, 425 ], [ 427, 439 ], [ 441, 441 ], [ 443, 455 ], [ 457, 457 ], [ 459, 498 ], [ 501, 502 ], [ 515, 515 ], [ 517, 518 ], [ 520, 520 ], [ 526, 528 ], [ 530, 530 ], [ 543, 561 ] ], [ [ 14, 14 ], [ 16, 17 ], [ 39, 40 ], [ 112, 112 ], [ 117, 117 ], [ 152, 152 ], [ 157, 157 ], [ 192, 192 ], [ 197, 197 ], [ 300, 300 ], [ 305, 305 ], [ 424, 424 ], [ 426, 426 ], [ 440, 440 ], [ 442, 442 ], [ 456, 456 ], [ 458, 458 ], [ 499, 500 ], [ 503, 514 ], [ 516, 516 ], [ 519, 519 ], [ 521, 525 ], [ 529, 529 ], [ 531, 542 ] ] ]
ec02cc9d60782791429d58e9c14edafe973e1fd4
b14d5833a79518a40d302e5eb40ed5da193cf1b2
/cpp/extern/xercesc++/2.6.0/src/xercesc/util/XMLMsgLoader.hpp
4dbaea93a81a3b56f78c3e28bba8d0de079b4bff
[ "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
8,576
hpp
/* * 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. */ /* * $Log: XMLMsgLoader.hpp,v $ * Revision 1.9 2004/09/08 13:56:24 peiyongz * Apache License Version 2.0 * * Revision 1.8 2003/12/24 15:24:13 cargilld * More updates to memory management so that the static memory manager. * * Revision 1.7 2003/12/17 00:18:35 cargilld * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. * * Revision 1.6 2003/05/15 19:07:46 knoaman * Partial implementation of the configurable memory manager. * * Revision 1.5 2003/03/07 18:11:55 tng * Return a reference instead of void for operator= * * Revision 1.4 2003/02/17 19:54:47 peiyongz * Allow set user specified error message file location in PlatformUtils::Initialize(). * * Revision 1.3 2002/11/04 22:24:21 peiyongz * Locale setting for message loader * * Revision 1.2 2002/11/04 15:22:05 tng * C++ Namespace Support. * * Revision 1.1.1.1 2002/02/01 22:22:15 peiyongz * sane_include * * Revision 1.5 2000/03/28 19:43:20 roddey * Fixes for signed/unsigned warnings. New work for two way transcoding * stuff. * * Revision 1.4 2000/03/02 19:54:49 roddey * This checkin includes many changes done while waiting for the * 1.1.0 code to be finished. I can't list them all here, but a list is * available elsewhere. * * Revision 1.3 2000/02/24 20:05:26 abagchi * Swat for removing Log from API docs * * Revision 1.2 2000/02/06 07:48:05 rahulj * Year 2K copyright swat. * * Revision 1.1.1.1 1999/11/09 01:05:47 twl * Initial checkin * * Revision 1.2 1999/11/08 20:45:20 rahul * Swat for adding in Product name and CVS comment log variable. * */ #if !defined(XMLMSGLOADER_HPP) #define XMLMSGLOADER_HPP #include <xercesc/util/XMemory.hpp> #include <xercesc/util/PlatformUtils.hpp> XERCES_CPP_NAMESPACE_BEGIN // // This header defines an abstract message loading API. This is the API via // which the parser system loads translatable text, and there can be multiple // actual implementations of this mechanism. The API is very simple because // there can be many kinds of underlying systems on which implementations are // based and we don't want to get into portability trouble by being overly // smart. // // Each instance of the message loader loads a file of messages, which are // accessed by key and which are associated with a particular language. The // actual source information may be in many forms, but by the time it is // extracted for use it will be in Unicode format. The language is always // the default language for the local machine. // // Msg loader derivatives are not required to be thread safe. The parser will // never use a single instance in more than one thread. // class XMLUTIL_EXPORT XMLMsgLoader : public XMemory { public : // ----------------------------------------------------------------------- // Class specific types // // XMLMsgId // A simple typedef to give us flexibility about the representation // of a message id. // ----------------------------------------------------------------------- typedef unsigned int XMLMsgId; // ----------------------------------------------------------------------- // Public Constructors and Destructor // ----------------------------------------------------------------------- virtual ~XMLMsgLoader(); // ----------------------------------------------------------------------- // The virtual message loader API // ----------------------------------------------------------------------- virtual bool loadMsg ( const XMLMsgId msgToLoad , XMLCh* const toFill , const unsigned int maxChars ) = 0; virtual bool loadMsg ( const XMLMsgId msgToLoad , XMLCh* const toFill , const unsigned int maxChars , const XMLCh* const repText1 , const XMLCh* const repText2 = 0 , const XMLCh* const repText3 = 0 , const XMLCh* const repText4 = 0 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ) = 0; virtual bool loadMsg ( const XMLMsgId msgToLoad , XMLCh* const toFill , const unsigned int maxChars , const char* const repText1 , const char* const repText2 = 0 , const char* const repText3 = 0 , const char* const repText4 = 0 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ) = 0; /** @name Locale Handling */ //@{ /** * This function enables set the locale information which * all concrete message loaders shall refer to during instantiation. * * Note: for detailed discussion, refer to PlatformUtils::initalize() */ static void setLocale(const char* const localeToAdopt); /** * For the derived to retrieve locale info during construction */ static const char* getLocale(); //@} /** @name NLSHome Handling */ //@{ /** * This function enables set the NLSHome information which * all concrete message loaders shall refer to during instantiation. * * Note: for detailed discussion, refer to PlatformUtils::initalize() */ static void setNLSHome(const char* const nlsHomeToAdopt); /** * For the derived to retrieve NLSHome info during construction */ static const char* getNLSHome(); //@} // ----------------------------------------------------------------------- // Deprecated: Getter methods // ----------------------------------------------------------------------- virtual const XMLCh* getLanguageName() const; protected : // ----------------------------------------------------------------------- // Hidden Constructors // ----------------------------------------------------------------------- XMLMsgLoader(); // ----------------------------------------------------------------------- // Deprecated: Protected helper methods // ----------------------------------------------------------------------- void setLanguageName(XMLCh* const nameToAdopt); private : // ----------------------------------------------------------------------- // Unimplemented constructors and operators // ----------------------------------------------------------------------- XMLMsgLoader(const XMLMsgLoader&); XMLMsgLoader& operator=(const XMLMsgLoader&); // ----------------------------------------------------------------------- // Private data members // // fLocale // Locale info set through PlatformUtils::init(). // The derived class may refer to this for locale information. // // fPath // NLSHome info set through PlatformUtils::init(). // The derived class may refer to this for NLSHome information. // // ----------------------------------------------------------------------- static char* fLocale; static char* fPath; static XMLCh fLanguage[]; }; // --------------------------------------------------------------------------- // XMLMsgLoader: Public Constructors and Destructor // --------------------------------------------------------------------------- inline XMLMsgLoader::~XMLMsgLoader() { } // --------------------------------------------------------------------------- // XMLMsgLoader: Hidden Constructors // --------------------------------------------------------------------------- inline XMLMsgLoader::XMLMsgLoader() { } XERCES_CPP_NAMESPACE_END #endif
[ [ [ 1, 242 ] ] ]
46e9446a60ef5a02169126206ed3e7ae3cbeb983
0b66a94448cb545504692eafa3a32f435cdf92fa
/tags/0.7/cbear.berlios.de/windows/com/static/iclassfactory.hpp
8ed640a20e6a6ddeaa637706bde806468594afc2
[ "MIT" ]
permissive
BackupTheBerlios/cbear-svn
e6629dfa5175776fbc41510e2f46ff4ff4280f08
0109296039b505d71dc215a0b256f73b1a60b3af
refs/heads/master
2021-03-12T22:51:43.491728
2007-09-28T01:13:48
2007-09-28T01:13:48
40,608,034
0
0
null
null
null
null
UTF-8
C++
false
false
1,067
hpp
#ifndef CBEAR_BERLIOS_DE_WINDOWS_COM_STATIC_ICLASSFACTORY_HPP_INCLUDED #define CBEAR_BERLIOS_DE_WINDOWS_COM_STATIC_ICLASSFACTORY_HPP_INCLUDED #include <cbear.berlios.de/c/in.hpp> #include <cbear.berlios.de/c/cpp_in.hpp> #include <cbear.berlios.de/c/out.hpp> #include <cbear.berlios.de/c/cpp_out.hpp> #include <cbear.berlios.de/windows/com/static/interface_content.hpp> namespace cbear_berlios_de { namespace windows { namespace com { namespace static_ { template<class T, class B> class interface_content<T, B, ::IClassFactory>: public interface_<T, B, ::IUnknown> { public: hresult::internal_type __stdcall CreateInstance( internal_result<in, iunknown>::type Outer, const uuid::c_t &Uuid, void **ppObject) { // Cannot aggregate. if(Outer) return hresult::class_e_noaggregation; return this->QueryInterface(Uuid, ppObject); } hresult::internal_type __stdcall LockServer(bool_t::value_t fLock) { if(fLock) this->AddRef(); else this->Release(); return hresult::s_ok; } }; } } } } #endif
[ "sergey_shandar@e6e9985e-9100-0410-869a-e199dc1b6838" ]
[ [ [ 1, 48 ] ] ]
2622531db3c0281aa1832a006bd3fe1643dbca5f
73bba167d83aec20fc0664b5df15d2b8c6f20003
/factorial/src/factorial/timer.cpp
e7bb6f1ea72a35d3eaa58b12a4908ba91c8c169d
[]
no_license
rnarozniak/fastfactorial
a473603fa4a91a96fcef5ef4b80787c19901819a
dd23732068a17e283c697afe2553579201bf28ae
refs/heads/master
2020-04-01T18:38:55.854345
2010-01-13T18:05:56
2010-01-13T18:05:56
35,261,166
0
0
null
null
null
null
UTF-8
C++
false
false
616
cpp
////////////////////////////////////////////////////////////////////////// #ifndef _TIMER_H_ #include "timer.h" #endif ////////////////////////////////////////////////////////////////////////// #include <boost/date_time/posix_time/posix_time.hpp> ////////////////////////////////////////////////////////////////////////// size_t Timer::GetCurrTime() { boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time(); return static_cast<size_t>( now.time_of_day().total_milliseconds() ); } //////////////////////////////////////////////////////////////////////////
[ "beemasterz@065cf898-fc4d-11de-be56-c15834921611" ]
[ [ [ 1, 21 ] ] ]
7d490b54737ee6f308c84ea539c537dd7fb0816b
110f8081090ba9591d295d617a55a674467d127e
/tests/RegexTest.cpp
37528c4168b6c8559979c5effbb7c7769aa3c162
[]
no_license
rayfill/cpplib
617bcf04368a2db70aea8b9418a45d7fd187d8c2
bc37fbf0732141d0107dd93bcf5e0b31f0d078ca
refs/heads/master
2021-01-25T03:49:26.965162
2011-07-17T15:19:11
2011-07-17T15:19:11
783,979
1
0
null
null
null
null
UTF-8
C++
false
false
29,417
cpp
#include <cppunit/extensions/HelperMacros.h> #include <text/regex/RegexCompile.hpp> #include <typeinfo> #include <iostream> #include <fstream> #include <iterator> #include <typeinfo> #include <limits> class RegexScannerTest : public CppUnit::TestFixture { private: CPPUNIT_TEST_SUITE(RegexScannerTest); CPPUNIT_TEST(scanTest); CPPUNIT_TEST_SUITE_END(); public: void scanTest() { typedef RegexScanner<char> scanner_t; std::string test("[ab]c*(de)?|abcdef"); RegexScanner<char> scanner(test.begin(), test.end()); CPPUNIT_ASSERT(scanner.scan() == scanner_t::char_trait_t::to_int_type('[')); CPPUNIT_ASSERT(scanner.scan() == scanner_t::char_trait_t::to_int_type('a')); CPPUNIT_ASSERT(scanner.scan() == scanner_t::char_trait_t::to_int_type('b')); CPPUNIT_ASSERT(scanner.scan() == scanner_t::char_trait_t::to_int_type(']')); CPPUNIT_ASSERT(scanner.scan() == scanner_t::char_trait_t::to_int_type('c')); CPPUNIT_ASSERT(scanner.scan() == scanner_t::char_trait_t::to_int_type('*')); CPPUNIT_ASSERT(scanner.scan() == scanner_t::char_trait_t::to_int_type('(')); CPPUNIT_ASSERT(scanner.scan() == scanner_t::char_trait_t::to_int_type('d')); CPPUNIT_ASSERT(scanner.scan() == scanner_t::char_trait_t::to_int_type('e')); CPPUNIT_ASSERT(scanner.scan() == scanner_t::char_trait_t::to_int_type(')')); CPPUNIT_ASSERT(scanner.scan() == scanner_t::char_trait_t::to_int_type('?')); CPPUNIT_ASSERT(scanner.scan() == scanner_t::char_trait_t::to_int_type('|')); scanner.backTrack(); CPPUNIT_ASSERT(scanner.scan() == scanner_t::char_trait_t::to_int_type('|')); CPPUNIT_ASSERT(scanner.scan() == scanner_t::char_trait_t::to_int_type('a')); CPPUNIT_ASSERT(scanner.scan() == scanner_t::char_trait_t::to_int_type('b')); CPPUNIT_ASSERT(scanner.scan() == scanner_t::char_trait_t::to_int_type('c')); CPPUNIT_ASSERT(scanner.scan() == scanner_t::char_trait_t::to_int_type('d')); CPPUNIT_ASSERT(scanner.scan() == scanner_t::char_trait_t::to_int_type('e')); CPPUNIT_ASSERT(scanner.scan() == scanner_t::char_trait_t::to_int_type('f')); CPPUNIT_ASSERT(scanner.scan() == -1); int count = 0; scanner.reset(); while (scanner.scan() != -1) ++count; CPPUNIT_ASSERT(count == 18); } }; class RegexTokenTest : public CppUnit::TestFixture { private: CPPUNIT_TEST_SUITE(RegexTokenTest); CPPUNIT_TEST(regexTokenTest); CPPUNIT_TEST(caseTest); CPPUNIT_TEST(characterTokenTest); CPPUNIT_TEST(anyTokenTest); CPPUNIT_TEST(rangeTokenTest); CPPUNIT_TEST(setTokenTest); CPPUNIT_TEST(notSetTokenTest); CPPUNIT_TEST_SUITE_END(); public: void caseTest() { RegexToken<char> token; CPPUNIT_ASSERT(token.lowerCase('A') == 'a'); CPPUNIT_ASSERT(token.lowerCase('B') == 'b'); CPPUNIT_ASSERT(token.lowerCase('C') == 'c'); CPPUNIT_ASSERT(token.lowerCase('D') == 'd'); CPPUNIT_ASSERT(token.lowerCase('E') == 'e'); CPPUNIT_ASSERT(token.lowerCase('F') == 'f'); CPPUNIT_ASSERT(token.lowerCase('G') == 'g'); CPPUNIT_ASSERT(token.lowerCase('H') == 'h'); CPPUNIT_ASSERT(token.lowerCase('I') == 'i'); CPPUNIT_ASSERT(token.lowerCase('J') == 'j'); CPPUNIT_ASSERT(token.lowerCase('K') == 'k'); CPPUNIT_ASSERT(token.lowerCase('L') == 'l'); CPPUNIT_ASSERT(token.lowerCase('M') == 'm'); CPPUNIT_ASSERT(token.lowerCase('N') == 'n'); CPPUNIT_ASSERT(token.lowerCase('O') == 'o'); CPPUNIT_ASSERT(token.lowerCase('P') == 'p'); CPPUNIT_ASSERT(token.lowerCase('Q') == 'q'); CPPUNIT_ASSERT(token.lowerCase('R') == 'r'); CPPUNIT_ASSERT(token.lowerCase('S') == 's'); CPPUNIT_ASSERT(token.lowerCase('T') == 't'); CPPUNIT_ASSERT(token.lowerCase('U') == 'u'); CPPUNIT_ASSERT(token.lowerCase('V') == 'v'); CPPUNIT_ASSERT(token.lowerCase('W') == 'w'); CPPUNIT_ASSERT(token.lowerCase('X') == 'x'); CPPUNIT_ASSERT(token.lowerCase('Y') == 'y'); CPPUNIT_ASSERT(token.lowerCase('Z') == 'z'); CPPUNIT_ASSERT(token.lowerCase('[') == '['); CPPUNIT_ASSERT(token.upperCase('a') == 'A'); CPPUNIT_ASSERT(token.upperCase('b') == 'B'); CPPUNIT_ASSERT(token.upperCase('c') == 'C'); CPPUNIT_ASSERT(token.upperCase('d') == 'D'); CPPUNIT_ASSERT(token.upperCase('e') == 'E'); CPPUNIT_ASSERT(token.upperCase('f') == 'F'); CPPUNIT_ASSERT(token.upperCase('g') == 'G'); CPPUNIT_ASSERT(token.upperCase('h') == 'H'); CPPUNIT_ASSERT(token.upperCase('i') == 'I'); CPPUNIT_ASSERT(token.upperCase('j') == 'J'); CPPUNIT_ASSERT(token.upperCase('k') == 'K'); CPPUNIT_ASSERT(token.upperCase('l') == 'L'); CPPUNIT_ASSERT(token.upperCase('m') == 'M'); CPPUNIT_ASSERT(token.upperCase('n') == 'N'); CPPUNIT_ASSERT(token.upperCase('o') == 'O'); CPPUNIT_ASSERT(token.upperCase('p') == 'P'); CPPUNIT_ASSERT(token.upperCase('q') == 'Q'); CPPUNIT_ASSERT(token.upperCase('r') == 'R'); CPPUNIT_ASSERT(token.upperCase('s') == 'S'); CPPUNIT_ASSERT(token.upperCase('t') == 'T'); CPPUNIT_ASSERT(token.upperCase('u') == 'U'); CPPUNIT_ASSERT(token.upperCase('v') == 'V'); CPPUNIT_ASSERT(token.upperCase('w') == 'W'); CPPUNIT_ASSERT(token.upperCase('x') == 'X'); CPPUNIT_ASSERT(token.upperCase('y') == 'Y'); CPPUNIT_ASSERT(token.upperCase('z') == 'Z'); CPPUNIT_ASSERT(token.upperCase('[') == '['); } void regexTokenTest() { typedef RegexToken<char> regex_t; regex_t r_token((regex_t*)2); std::vector<regex_t*> lists = r_token.epsilonTransit(); CPPUNIT_ASSERT(lists.size() == 0); for (int character = std::numeric_limits<char>::min(); character <= std::numeric_limits<char>::max(); ++character) { CPPUNIT_ASSERT( r_token.transit( std::char_traits<char>::to_char_type(character), false) == 0); } r_token.addEpsilon((regex_t*)3); r_token.addEpsilon((regex_t*)4); lists = r_token.epsilonTransit(); CPPUNIT_ASSERT(lists.size() == 2); CPPUNIT_ASSERT(*lists.begin() == (regex_t*)3); std::vector<regex_t*>::iterator itor = lists.begin(); CPPUNIT_ASSERT(*++itor == (regex_t*)4); } void anyTokenTest() { typedef RegexToken<char> token_t; typedef AnyMatchToken<char> any_t; any_t a_token((token_t*)2); for (int character = std::numeric_limits<char>::min(); character <= std::numeric_limits<char>::max(); ++character) { CPPUNIT_ASSERT(a_token.transit(std::char_traits<char>:: to_char_type(character), false) == (token_t*)2); } std::vector<token_t*> lists = a_token.epsilonTransit(); CPPUNIT_ASSERT(lists.size() == 0); } void characterTokenTest() { typedef RegexToken<char> token_t; typedef CharacterToken<char> character_t; character_t c_token('a', (token_t*)2); for (int character = std::numeric_limits<char>::min(); character <= std::numeric_limits<char>::max(); ++character) { if (std::char_traits<char>::to_char_type(character) == 'a') { CPPUNIT_ASSERT(c_token.transit( std::char_traits<char>:: to_char_type(character), false) == (token_t*)2); } else { CPPUNIT_ASSERT(c_token.transit( std::char_traits<char>:: to_char_type(character), false) == NULL); } } std::vector<token_t*> lists = c_token.epsilonTransit(); CPPUNIT_ASSERT(lists.size() == 0); } void rangeTokenTest() { typedef RegexToken<char> token_t; typedef RangeToken<char> range_t; range_t r_token('a', 'z', (token_t*)10); for (int character = std::numeric_limits<char>::min(); character <= std::numeric_limits<char>::max(); ++character) { if (std::char_traits<char>::to_char_type(character) >= 'a' && std::char_traits<char>::to_char_type(character) <= 'z') { CPPUNIT_ASSERT( r_token.transit(std::char_traits<char>:: to_char_type(character), false) == (token_t*)10); } else { CPPUNIT_ASSERT( r_token.transit(std::char_traits<char>:: to_char_type(character), false) == NULL); } } } void setTokenTest() { typedef RegexToken<char> token_t; typedef SetToken<char> set_t; set_t s_token; s_token.addAccept('a'); s_token.addAccept('c'); s_token.addAccept('d'); s_token.addAccept('z'); s_token.setNext((token_t*)10); for (int character = std::numeric_limits<char>::min(); character <= std::numeric_limits<char>::max(); ++character) { if (std::char_traits<char>::to_char_type(character) == 'a' || std::char_traits<char>::to_char_type(character) == 'c' || std::char_traits<char>::to_char_type(character) == 'd' || std::char_traits<char>::to_char_type(character) == 'z') { CPPUNIT_ASSERT( s_token.transit(std::char_traits<char>:: to_char_type(character), false) == (token_t*)10); } else { CPPUNIT_ASSERT( s_token.transit(std::char_traits<char>:: to_char_type(character), false) == NULL); } } } void notSetTokenTest() { typedef RegexToken<char> token_t; typedef NotSetToken<char> set_t; set_t s_token; s_token.addReject('a'); s_token.addReject('c'); s_token.addReject('d'); s_token.addReject('z'); s_token.setNext((token_t*)10); for (int character = std::numeric_limits<char>::min(); character <= std::numeric_limits<char>::max(); ++character) { if (std::char_traits<char>::to_char_type(character) != 'a' && std::char_traits<char>::to_char_type(character) != 'c' && std::char_traits<char>::to_char_type(character) != 'd' && std::char_traits<char>::to_char_type(character) != 'z') { CPPUNIT_ASSERT( s_token.transit(std::char_traits<char>:: to_char_type(character), false) == (token_t*)10); } else { CPPUNIT_ASSERT( s_token.transit(std::char_traits<char>:: to_char_type(character), false) == NULL); } } } }; class RegexAutomatonManagerTest : public CppUnit::TestFixture { private: CPPUNIT_TEST_SUITE(RegexAutomatonManagerTest); CPPUNIT_TEST(concatinateTest); CPPUNIT_TEST(groupTest); CPPUNIT_TEST(kleeneTest); CPPUNIT_TEST(kleenePlusTest); CPPUNIT_TEST(selectTest); CPPUNIT_TEST_SUITE_END(); typedef RegexAutomatonManager<char> manager_t; typedef RegexToken<char> regex_token_t; typedef GroupHeadToken<char> group_head_t; typedef GroupTailToken<char> group_tail_t; typedef RegexToken<char> token_t; typedef EpsilonToken<char> epsilon_token_t; typedef CharacterToken<char> char_token_t; typedef RangeToken<char> range_token_t; typedef SetToken<char> set_token_t; typedef std::char_traits<char> char_traits_t; public: void concatinateTest() { manager_t manager; char_token_t* token_a = new char_token_t('a'); char_token_t* token_b = new char_token_t('b'); manager_t::token_pair_t pair = manager.concatenate(token_a, token_b); CPPUNIT_ASSERT(pair.first == token_a); CPPUNIT_ASSERT(pair.second == token_b); CPPUNIT_ASSERT(((char_token_t*)token_a)->transit('a', false) == token_b); } void groupTest() { manager_t manager; char_token_t* token = new char_token_t('A'); manager_t::token_pair_t pair = manager.group(token, token, 1); group_head_t* head = dynamic_cast<group_head_t*>(pair.first); group_tail_t* last = dynamic_cast<group_tail_t*>(pair.second); CPPUNIT_ASSERT(head->getGroupNumber() == 1); CPPUNIT_ASSERT(last->getGroupNumber() == 1); std::vector<token_t*> epsilons = ((group_head_t*)head)->epsilonTransit(); CPPUNIT_ASSERT(epsilons.size() == 1); CPPUNIT_ASSERT(epsilons.front() == token); CPPUNIT_ASSERT(token->transit('A', false) == last); } void kleeneTest() { char_token_t* token = new char_token_t('A'); manager_t::token_pair_t pair = manager_t::kleene(std::make_pair(token, token)); regex_token_t* head = pair.first; regex_token_t* last = pair.second; std::vector<token_t*> epsilons = head->epsilonTransit(); CPPUNIT_ASSERT(epsilons.size() == 2); CPPUNIT_ASSERT(epsilons.front() == token); std::vector<token_t*>::iterator itor = epsilons.begin(); CPPUNIT_ASSERT(*++itor == last); CPPUNIT_ASSERT(token->transit('A', false) != NULL); regex_token_t* loop = token->transit('A', false); epsilons = loop->epsilonTransit(); CPPUNIT_ASSERT(epsilons.size() == 2); CPPUNIT_ASSERT(epsilons.front() == head); itor = epsilons.begin(); CPPUNIT_ASSERT(*++itor == last); } void kleenePlusTest() { manager_t manager; char_token_t* token = new char_token_t('A'); manager_t::token_pair_t pair = manager.kleenePlus(token, token); regex_token_t* head = pair.first; regex_token_t* last = pair.second; std::vector<token_t*> epsilons = head->epsilonTransit(); CPPUNIT_ASSERT(epsilons.size() == 1); CPPUNIT_ASSERT(epsilons.front() == token); CPPUNIT_ASSERT(token->transit('A', false) == last); epsilons = last->epsilonTransit(); CPPUNIT_ASSERT(epsilons.size() == 1); CPPUNIT_ASSERT(epsilons.front() == head); } void selectTest() { typedef char char_type; typedef RegexToken<char> token_t; manager_t manager; char_token_t* token_a = new char_token_t('A'); char_token_t* token_b = new char_token_t('B'); manager_t::token_pair_t pair = manager.select(token_a, token_b); regex_token_t* head = pair.first; regex_token_t* tail = pair.second; CPPUNIT_ASSERT(std::string(typeid(*head).name()) == typeid(epsilon_token_t).name()); CPPUNIT_ASSERT(std::string(typeid(*tail).name()) == typeid(epsilon_token_t).name()); std::vector<token_t*> epsilons = head->epsilonTransit(); CPPUNIT_ASSERT(epsilons.size() == 2); // upside test. route as 'A'. regex_token_t* up = epsilons.front(); CPPUNIT_ASSERT(up == token_a); // downside test. route as 'B'. std::vector<token_t*>::iterator itor = epsilons.begin(); regex_token_t* down = *++itor; CPPUNIT_ASSERT(down == token_b); CPPUNIT_ASSERT(((char_token_t*)up)->transit('A', false) == tail); CPPUNIT_ASSERT(((char_token_t*)down)->transit('B', false) == tail); // terminater test. epsilons = tail->epsilonTransit(); CPPUNIT_ASSERT(epsilons.size() == 0); } }; class RegexResultTest : public CppUnit::TestFixture { private: CPPUNIT_TEST_SUITE(RegexResultTest); CPPUNIT_TEST(OffsetPairTest); CPPUNIT_TEST(CaptureTest); CPPUNIT_TEST_SUITE_END(); public: void CaptureTest() { typedef RegexResult<char> result_t; result_t result; result.setCaptureHead(0, 4); CPPUNIT_ASSERT(result.captures[0].getHead() == 4); result.setCaptureTail(0, 5); CPPUNIT_ASSERT(result.captures[0].getLast() == 5); std::string base = "abcdefg"; CPPUNIT_ASSERT_MESSAGE(result.getString(0, base), result.getString(0, base) == "e"); } void OffsetPairTest() { typedef RegexResult<char>::OffsetPair offset_pair_t; offset_pair_t pair(1, 2); std::string str = "abcdefg"; CPPUNIT_ASSERT_MESSAGE(pair.getString(str), pair.getString(str) == "b"); offset_pair_t null_pair(1, 1); CPPUNIT_ASSERT(null_pair.getString(str) == ""); CPPUNIT_ASSERT_THROW(pair.getString("a"), std::out_of_range); CPPUNIT_ASSERT_THROW(offset_pair_t(1, 0), std::invalid_argument); } }; template <typename CharType> class DummyToken : public RegexToken<CharType> { private: int& counter; public: DummyToken(int& counter_): counter(counter_) {} virtual ~DummyToken() { ++counter; } typedef CharType char_t; typedef RegexScanner<char_t> scanner_t; typedef RegexResult<char_t> result_t; virtual bool isAccept(AcceptArgument<char_t>& argument) { return RegexToken<char_t>::getNext()->isAccept(argument); } }; class RegexMatchTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(RegexMatchTest); CPPUNIT_TEST(eraseTest); CPPUNIT_TEST(matchTest); CPPUNIT_TEST(replaceTest); CPPUNIT_TEST_SUITE_END(); private: void replaceTest() { std::string file("<Meta Name=\"wwwc\" " "Content=\"2006/07/30 00:00:04 piano Power\">\r\n" "<META NAME=\"WWWC\" " "CONTENT=\"2006/07/30 00:00:04 Piano Power\">"); RegexCompiler<char> compiler; // <META NAME="WWWC" CONTENT="2006/07/30 00:00:04 Piano Power"> RegexMatch<char> matcher = compiler.compile("<M.TA[ ]+NAME=\"WWWC\"[ ]" "+CONTENT=\"([^\"]+)\"[ ]*>"); CPPUNIT_ASSERT(matcher.match(file)); CPPUNIT_ASSERT_MESSAGE(matcher.matchedReplace(file, "Electone Power", 1), matcher.matchedReplace(file, "Electone Power", 1) == "<Meta Name=\"wwwc\" " "Content=\"2006/07/30 00:00:04 " "piano Power\">\r\n" "<META NAME=\"WWWC\" " "CONTENT=\"Electone Power\">"); } void matchTest() { std::string file("<Meta Name=\"wwwc\" " "Content=\"2006/07/30 00:00:04 piano Power\">\r\n" "<META NAME=\"WWWC\" " "CONTENT=\"2006/07/30 00:00:04 Piano Power\">"); RegexCompiler<char> compiler; // <META NAME="WWWC" CONTENT="2006/07/30 00:00:04 Piano Power"> RegexMatch<char> matcher = compiler.compile("<M.TA[ ]+NAME=\"WWWC\"[ ]" "+CONTENT=\"([^\"]+)\"[ ]*>"); CPPUNIT_ASSERT(matcher.match(file)); CPPUNIT_ASSERT_MESSAGE(matcher.matchedString(file, 1), matcher.matchedString(file, 1) == "2006/07/30 00:00:04 Piano Power"); CPPUNIT_ASSERT(matcher.match(file, true)); CPPUNIT_ASSERT_MESSAGE(matcher.matchedString(file, 1), matcher.matchedString(file, 1) == "2006/07/30 00:00:04 piano Power"); CPPUNIT_ASSERT(matcher.nextMatch(file, true)); CPPUNIT_ASSERT_MESSAGE(matcher.matchedString(file, 1), matcher.matchedString(file, 1) == "2006/07/30 00:00:04 Piano Power"); } void eraseTest() { typedef RegexToken<char> token_t; typedef DummyToken<char> dummy_t; int eraseCount = 0; RegexHead<char>* head = new RegexHead<char>(); RegexTail<char>* tail = new RegexTail<char>(); dummy_t* dummy = new dummy_t(eraseCount); head->setNext(dummy); dummy->setNext(tail); { RegexMatch<char> match1(head); CPPUNIT_ASSERT(eraseCount == 0); { RegexMatch<char> match2 = match1; CPPUNIT_ASSERT(eraseCount == 0); } CPPUNIT_ASSERT(eraseCount == 0); } CPPUNIT_ASSERT(eraseCount == 1); } }; class RegexCompilerTest : public CppUnit::TestFixture { private: CPPUNIT_TEST_SUITE(RegexCompilerTest); CPPUNIT_TEST(compileGroupTest); CPPUNIT_TEST(literalTest); CPPUNIT_TEST(kleeneTest); CPPUNIT_TEST(selectTest); CPPUNIT_TEST(groupTest); CPPUNIT_TEST(traverseTest); CPPUNIT_TEST(parenTest); CPPUNIT_TEST(acceptTest); CPPUNIT_TEST(setTest); CPPUNIT_TEST_SUITE_END(); typedef RegexCompiler<char> compiler_t; typedef RegexScanner<char> scanner_t; typedef RegexToken<char> token_t; typedef CharacterToken<char> char_token_t; typedef std::pair<token_t*, token_t*> token_pair_t; public: void setTest() { typedef RegexResult<char> result_t; std::string input = "[abcde]"; compiler_t compiler; token_pair_t pair = compiler.compileInternal(input); token_t* head = pair.first; std::string source = "abcde"; scanner_t test_scanner(source.begin(), source.end()); result_t result; AcceptArgument<char> argument(test_scanner, result, false); CPPUNIT_ASSERT(head->isAccept(argument)); test_scanner.reset(); result.clear(); std::set<token_t*> objects; head->traverse(objects); input = "[^abcde]"; pair = compiler.compileInternal(input); head = pair.first; source = "abcde"; scanner_t test_scanner2(source.begin(), source.end()); AcceptArgument<char> argument2(test_scanner2, result, false); CPPUNIT_ASSERT(!head->isAccept(argument2)); head->traverse(objects); for (std::set<token_t*>::iterator itor = objects.begin(); itor != objects.end(); ++itor) delete *itor; } void acceptTest() { compiler_t compiler; token_pair_t tokens = compiler.compileInternal("ab*"); std::string example = "bbbabbbb"; RegexScanner<char> scanner(example.begin(), example.end()); RegexResult<char> result; AcceptArgument<char> argument(scanner, result, false); CPPUNIT_ASSERT(tokens.first->isAccept(argument)); CPPUNIT_ASSERT_MESSAGE(result.getString(0, example), result.getString(0, example) == "abbbb"); std::set<RegexToken<char>*> objects; tokens.first->traverse(objects); for (std::set<RegexToken<char>*>::iterator itor = objects.begin(); itor != objects.end(); ++itor) delete *itor; } void compileGroupTest() { std::string patternBigAlpha = "A-Z"; std::string patternMinAlpha = "a-z"; std::string patternNum = "0-9"; std::string patternError = "a-Z"; RegexCompiler<char> compiler; std::set<char> compiled = compiler.compileGroups(patternBigAlpha.begin(), patternBigAlpha.end()); for (char itor = 'A'; itor <= 'Z'; ++itor) CPPUNIT_ASSERT(compiled.find(itor) != compiled.end()); CPPUNIT_ASSERT(compiled.size() == 26); compiled = compiler.compileGroups(patternMinAlpha.begin(), patternMinAlpha.end()); for (char itor = 'a'; itor <= 'z'; ++itor) CPPUNIT_ASSERT(compiled.find(itor) != compiled.end()); CPPUNIT_ASSERT(compiled.size() == 26); compiled = compiler.compileGroups(patternNum.begin(), patternNum.end()); for (char itor = '0'; itor <= '9'; ++itor) CPPUNIT_ASSERT(compiled.find(itor) != compiled.end()); CPPUNIT_ASSERT(compiled.size() == 10); } void parenTest() { std::string input = "(aaa)"; compiler_t compiler; compiler.compile(input); std::string error_input = "(aaa"; CPPUNIT_ASSERT_THROW(compiler.compile(error_input), CompileError); std::string error_input2 = "aaa)"; CPPUNIT_ASSERT_THROW(compiler.compile(error_input2), CompileError); } void groupTest() { std::string input = "(aaa)"; compiler_t compiler; scanner_t scanner(input.begin(), input.end()); token_pair_t tokens = compiler.subCompile(scanner); token_t* head = tokens.first; token_t* last = tokens.second; std::vector<token_t*> epsilon = head->epsilonTransit(); CPPUNIT_ASSERT(epsilon.size() == 1); char_token_t* current = dynamic_cast<char_token_t*>(epsilon.front()); CPPUNIT_ASSERT(((char_token_t*)current)->transit('a', false) != NULL); current = dynamic_cast<char_token_t*>(current->transit('a', false)); CPPUNIT_ASSERT(((char_token_t*)current)->transit('a', false) != NULL); current = dynamic_cast<char_token_t*>(current->transit('a', false)); CPPUNIT_ASSERT(((char_token_t*)current)->transit('a', false) != NULL); token_t* last2 = current->transit('a', false); CPPUNIT_ASSERT(last2 == last); } void selectTest() { std::string input ="aaa|bbb"; compiler_t compiler; scanner_t scanner(input.begin(), input.end()); token_pair_t token = compiler.subCompile(scanner); token_t* head = token.first; token_t* last = token.second; std::vector<token_t*> epsilons = head->epsilonTransit(); CPPUNIT_ASSERT(epsilons.size() == 2); token_t* upper = epsilons.front(); token_t* downer = epsilons.back(); // upper half. CPPUNIT_ASSERT(((char_token_t*)upper)->transit('a', false) != NULL); upper = ((char_token_t*)upper)->transit('a', false); CPPUNIT_ASSERT(((char_token_t*)upper)->transit('a', false) != NULL); upper = ((char_token_t*)upper)->transit('a', false); CPPUNIT_ASSERT(((char_token_t*)upper)->transit('a', false) != NULL); upper = ((char_token_t*)upper)->transit('a', false); // downer half. CPPUNIT_ASSERT(((char_token_t*)downer)->transit('b', false) != NULL); downer = ((char_token_t*)downer)->transit('b', false); CPPUNIT_ASSERT(((char_token_t*)downer)->transit('b', false) != NULL); downer = ((char_token_t*)downer)->transit('b', false); CPPUNIT_ASSERT(((char_token_t*)downer)->transit('b', false) != NULL); downer = ((char_token_t*)downer)->transit('b', false); CPPUNIT_ASSERT(upper == last); CPPUNIT_ASSERT(downer == last); } void kleeneTest() { std::string input = "aab*cde"; compiler_t compiler; scanner_t scanner(input.begin(), input.end()); token_pair_t token = compiler.subCompile(scanner); token_t* current = token.first; current = ((char_token_t*)current)->transit('a', false); CPPUNIT_ASSERT(current != NULL); current = ((char_token_t*)current)->transit('a', false); CPPUNIT_ASSERT(current != NULL); token_t* kleeneHead = current; std::vector<token_t*> epsilons = current->epsilonTransit(); CPPUNIT_ASSERT(epsilons.size() == 2); current = epsilons.front(); std::vector<token_t*>::iterator itor = epsilons.begin(); token_t* shortcut = *++itor; current = ((char_token_t*)current)->transit('b', false); CPPUNIT_ASSERT(current != NULL); std::vector<token_t*> epsilons2 = current->epsilonTransit(); CPPUNIT_ASSERT(epsilons2.size() == 2); CPPUNIT_ASSERT(epsilons2.front() == kleeneHead); itor = epsilons2.begin(); CPPUNIT_ASSERT(*++itor == shortcut); current = shortcut; CPPUNIT_ASSERT(current->epsilonTransit().size() == 1); current = current->epsilonTransit().front(); current = ((char_token_t*)current)->transit('c', false); CPPUNIT_ASSERT(current != NULL); current = ((char_token_t*)current)->transit('d', false); CPPUNIT_ASSERT(current != NULL); CPPUNIT_ASSERT(current == token.second); current = ((char_token_t*)current)->transit('e', false); CPPUNIT_ASSERT(current == NULL); } void literalTest() { std::string input = "aabcdeedf"; compiler_t compiler; scanner_t scanner(input.begin(), input.end()); token_pair_t token = compiler.subCompile(scanner); token_t* current = token.first; current = ((char_token_t*)current)->transit('a', false); CPPUNIT_ASSERT(current != NULL); current = ((char_token_t*)current)->transit('a', false); CPPUNIT_ASSERT(current != NULL); current = ((char_token_t*)current)->transit('b', false); CPPUNIT_ASSERT(current != NULL); current = ((char_token_t*)current)->transit('c', false); CPPUNIT_ASSERT(current != NULL); current = ((char_token_t*)current)->transit('d', false); CPPUNIT_ASSERT(current != NULL); current = ((char_token_t*)current)->transit('e', false); CPPUNIT_ASSERT(current != NULL); current = ((char_token_t*)current)->transit('e', false); CPPUNIT_ASSERT(current != NULL); current = ((char_token_t*)current)->transit('d', false); CPPUNIT_ASSERT(current != NULL); CPPUNIT_ASSERT(current == token.second); current = ((char_token_t*)current)->transit('f', false); CPPUNIT_ASSERT(current == NULL); } void traverseTest() { std::string input = "aabcdeedf"; compiler_t compiler; scanner_t scanner(input.begin(), input.end()); token_pair_t token = compiler.subCompile(scanner); std::set<token_t*> pointers; token.first->traverse(pointers); CPPUNIT_ASSERT(pointers.size() == 9); token_t* current = token.first; CPPUNIT_ASSERT(pointers.find(current) != pointers.end()); current = ((char_token_t*)current)->transit('a', false); CPPUNIT_ASSERT(current != NULL); CPPUNIT_ASSERT(pointers.find(current) != pointers.end()); current = ((char_token_t*)current)->transit('a', false); CPPUNIT_ASSERT(current != NULL); CPPUNIT_ASSERT(pointers.find(current) != pointers.end()); current = ((char_token_t*)current)->transit('b', false); CPPUNIT_ASSERT(current != NULL); CPPUNIT_ASSERT(pointers.find(current) != pointers.end()); current = ((char_token_t*)current)->transit('c', false); CPPUNIT_ASSERT(current != NULL); CPPUNIT_ASSERT(pointers.find(current) != pointers.end()); current = ((char_token_t*)current)->transit('d', false); CPPUNIT_ASSERT(current != NULL); CPPUNIT_ASSERT(pointers.find(current) != pointers.end()); current = ((char_token_t*)current)->transit('e', false); CPPUNIT_ASSERT(current != NULL); CPPUNIT_ASSERT(pointers.find(current) != pointers.end()); current = ((char_token_t*)current)->transit('e', false); CPPUNIT_ASSERT(current != NULL); CPPUNIT_ASSERT(pointers.find(current) != pointers.end()); current = ((char_token_t*)current)->transit('d', false); CPPUNIT_ASSERT(current != NULL); CPPUNIT_ASSERT(pointers.find(current) != pointers.end()); CPPUNIT_ASSERT(current == token.second); current = ((char_token_t*)current)->transit('f', false); CPPUNIT_ASSERT(current == NULL); } }; CPPUNIT_TEST_SUITE_REGISTRATION( RegexScannerTest ); CPPUNIT_TEST_SUITE_REGISTRATION( RegexTokenTest ); CPPUNIT_TEST_SUITE_REGISTRATION( RegexAutomatonManagerTest ); CPPUNIT_TEST_SUITE_REGISTRATION( RegexResultTest ); CPPUNIT_TEST_SUITE_REGISTRATION( RegexCompilerTest ); CPPUNIT_TEST_SUITE_REGISTRATION( RegexMatchTest );
[ "alfeim@287b3242-7fab-264f-8401-8509467ab285", "bpokazakijr@287b3242-7fab-264f-8401-8509467ab285" ]
[ [ [ 1, 1 ], [ 5, 8 ], [ 79, 79 ], [ 81, 81 ], [ 84, 84 ], [ 88, 149 ], [ 155, 155 ], [ 164, 164 ], [ 173, 174 ], [ 177, 196 ], [ 211, 211 ], [ 217, 217 ], [ 221, 221 ], [ 241, 241 ], [ 247, 247 ], [ 274, 274 ], [ 280, 314 ], [ 333, 334 ], [ 352, 352 ], [ 357, 358 ], [ 367, 367 ], [ 369, 372 ], [ 374, 375 ], [ 379, 379 ], [ 392, 392 ], [ 395, 396 ], [ 398, 399 ], [ 404, 405 ], [ 420, 420 ], [ 424, 424 ], [ 452, 452 ], [ 460, 461 ], [ 464, 465 ], [ 483, 483 ], [ 494, 494 ], [ 499, 500 ], [ 520, 642 ], [ 647, 647 ], [ 654, 655 ], [ 661, 661 ], [ 665, 752 ], [ 760, 761 ], [ 764, 765 ], [ 779, 779 ], [ 782, 782 ], [ 784, 789 ], [ 791, 791 ], [ 805, 805 ], [ 812, 817 ], [ 820, 825 ], [ 840, 840 ], [ 842, 842 ], [ 846, 846 ], [ 849, 850 ], [ 852, 852 ], [ 855, 855 ], [ 858, 859 ], [ 865, 865 ], [ 867, 867 ], [ 871, 871 ], [ 884, 884 ], [ 886, 886 ], [ 888, 888 ], [ 890, 890 ], [ 892, 892 ], [ 894, 894 ], [ 896, 896 ], [ 898, 898 ], [ 902, 902 ], [ 920, 920 ], [ 924, 924 ], [ 928, 928 ], [ 932, 932 ], [ 936, 936 ], [ 940, 940 ], [ 944, 944 ], [ 948, 948 ], [ 954, 954 ], [ 959, 960 ], [ 966, 966 ] ], [ [ 2, 4 ], [ 9, 78 ], [ 80, 80 ], [ 82, 83 ], [ 85, 87 ], [ 150, 154 ], [ 156, 163 ], [ 165, 172 ], [ 175, 176 ], [ 197, 210 ], [ 212, 216 ], [ 218, 220 ], [ 222, 240 ], [ 242, 246 ], [ 248, 273 ], [ 275, 279 ], [ 315, 332 ], [ 335, 351 ], [ 353, 356 ], [ 359, 366 ], [ 368, 368 ], [ 373, 373 ], [ 376, 378 ], [ 380, 391 ], [ 393, 394 ], [ 397, 397 ], [ 400, 403 ], [ 406, 419 ], [ 421, 423 ], [ 425, 451 ], [ 453, 459 ], [ 462, 463 ], [ 466, 482 ], [ 484, 493 ], [ 495, 498 ], [ 501, 519 ], [ 643, 646 ], [ 648, 653 ], [ 656, 660 ], [ 662, 664 ], [ 753, 759 ], [ 762, 763 ], [ 766, 778 ], [ 780, 781 ], [ 783, 783 ], [ 790, 790 ], [ 792, 804 ], [ 806, 811 ], [ 818, 819 ], [ 826, 839 ], [ 841, 841 ], [ 843, 845 ], [ 847, 848 ], [ 851, 851 ], [ 853, 854 ], [ 856, 857 ], [ 860, 864 ], [ 866, 866 ], [ 868, 870 ], [ 872, 883 ], [ 885, 885 ], [ 887, 887 ], [ 889, 889 ], [ 891, 891 ], [ 893, 893 ], [ 895, 895 ], [ 897, 897 ], [ 899, 901 ], [ 903, 919 ], [ 921, 923 ], [ 925, 927 ], [ 929, 931 ], [ 933, 935 ], [ 937, 939 ], [ 941, 943 ], [ 945, 947 ], [ 949, 953 ], [ 955, 958 ], [ 961, 965 ] ] ]
4e8f6611e39b84932f68f3f46305e926893abba0
b2d46af9c6152323ce240374afc998c1574db71f
/cursovideojuegos/theflostiproject/3rdParty/boost/libs/numeric/ublas/test7/test7.hpp
07fd8ba0e69b022849c7f2ddf057f81701a62fa8
[]
no_license
bugbit/cipsaoscar
601b4da0f0a647e71717ed35ee5c2f2d63c8a0f4
52aa8b4b67d48f59e46cb43527480f8b3552e96d
refs/heads/master
2021-01-10T21:31:18.653163
2011-09-28T16:39:12
2011-09-28T16:39:12
33,032,640
0
0
null
null
null
null
UTF-8
C++
false
false
1,275
hpp
// // 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. // #ifndef TEST7_H #define TEST7_H namespace ublas = boost::numeric::ublas; template<class V> void initialize_vector (V &v) { int size = v.size (); for (int i = 0; i < size; ++ i) v [i] = typename V::value_type (i + 1.f); } template<class M> void initialize_matrix (M &m) { int size1 = m.size1 (); int size2 = m.size2 (); for (int i = 0; i < size1; ++ i) for (int j = 0; j < size2; ++ j) m (i, j) = typename M::value_type (i * size1 + j + 1.f); } void test_vector (); void test_matrix_vector (); void test_matrix (); #endif
[ "ohernandezba@71d53fa2-cca5-e1f2-4b5e-677cbd06613a" ]
[ [ [ 1, 45 ] ] ]
64317ab9cf8e71893edd46668b2fd5e9346e6c1a
f55665c5faa3d79d0d6fe91fcfeb8daa5adf84d0
/Depend/MyGUI/UnitTests/UnitTest_Canvas/GraphNodeSimple.h
c4aab88cef237356fce3e5cee616edab6fba14ca
[]
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,155
h
/*! @file @author Albert Semenov @date 01/2009 @module */ #ifndef __GRAPH_NODE_SIMPLE_H__ #define __GRAPH_NODE_SIMPLE_H__ #include <MyGUI.h> #include "BaseGraphNode.h" namespace demo { class GraphNodeSimple : public wraps::BaseGraphNode { public: GraphNodeSimple(const std::string& _name) : BaseGraphNode("NodeSimple.layout"), mName(_name), mConnectionIn1(nullptr), mConnectionOut1(nullptr), mConnectionIn2(nullptr), mConnectionOut2(nullptr) { } private: virtual void initialise() { mMainWidget->castType<MyGUI::Window>()->setCaption(mName); assignBase(mConnectionIn1, "ConnectionIn1"); assignBase(mConnectionOut1, "ConnectionOut1"); assignBase(mConnectionIn2, "ConnectionIn2"); assignBase(mConnectionOut2, "ConnectionOut2"); } virtual void shutdown() { } private: std::string mName; wraps::BaseGraphConnection* mConnectionIn1; wraps::BaseGraphConnection* mConnectionOut1; wraps::BaseGraphConnection* mConnectionIn2; wraps::BaseGraphConnection* mConnectionOut2; }; } // namespace demo #endif // __GRAPH_NODE_SIMPLE_H__
[ "albertclass@a94d7126-06ea-11de-b17c-0f1ef23b492c" ]
[ [ [ 1, 54 ] ] ]
cec490355133287fb77cda1c42cd7e02a20a9378
610c7fab24418c124efa4f224f61fee1076c851b
/opensurf/integral.h
8b9541d72131e400707612b6cd43ad24203943dc
[]
no_license
julapy/ofxOpenSurf
3c2478729ad05d5fa3612620a8fd78ab8dfd3f27
9875b6189360983c6a770bc8a91ed00b0e5c1938
refs/heads/master
2016-08-04T04:35:06.588986
2011-10-11T09:50:06
2011-10-11T09:50:06
2,131,676
13
3
null
2015-02-01T14:42:29
2011-07-31T08:17:22
C++
UTF-8
C++
false
false
1,836
h
/*********************************************************** * --- OpenSURF --- * * This library is distributed under the GNU GPL. Please * * contact [email protected] for more information. * * * * C. Evans, Research Into Robust Visual Features, * * MSc University of Bristol, 2008. * * * ************************************************************/ #ifndef INTEGRAL_H #define INTEGRAL_H #include <algorithm> // req'd for std::min/max // undefine VS macros #ifdef min #undef min #endif #ifdef max #undef max #endif #include "cv.h" //! Computes the integral image of image img. Assumes source image to be a //! 32-bit floating point. Returns IplImage in 32-bit float form. IplImage *Integral(IplImage *img); //! Computes the sum of pixels within the rectangle specified by the top-left start //! co-ordinate and size inline float BoxIntegral(IplImage *img, int row, int col, int rows, int cols) { float *data = (float *) img->imageData; int step = img->widthStep/sizeof(float); // The subtraction by one for row/col is because row/col is inclusive. int r1 = std::min(row, img->height) - 1; int c1 = std::min(col, img->width) - 1; int r2 = std::min(row + rows, img->height) - 1; int c2 = std::min(col + cols, img->width) - 1; float A(0.0f), B(0.0f), C(0.0f), D(0.0f); if (r1 >= 0 && c1 >= 0) A = data[r1 * step + c1]; if (r1 >= 0 && c2 >= 0) B = data[r1 * step + c2]; if (r2 >= 0 && c1 >= 0) C = data[r2 * step + c1]; if (r2 >= 0 && c2 >= 0) D = data[r2 * step + c2]; return std::max(0.f, A - B - C + D); } #endif
[ [ [ 1, 54 ] ] ]
56e4ae3e96ce94bb273501d3185f651dcc26924e
65f587a75567b51375bde5793b4ec44e4b79bc7d
/stepEditSysex.h
ade3dd15e6b1a4452f59e240bc369413f19200c0
[]
no_license
discordance/sklepseq
ce4082074afbdb7e4f7185f042ce9e34d42087ef
8d4fa5a2710ba947e51f5572238eececba4fef74
refs/heads/master
2021-01-13T00:15:23.218795
2008-07-20T20:48:44
2008-07-20T20:48:44
49,079,555
0
0
null
null
null
null
UTF-8
C++
false
false
2,707
h
/* ============================================================================== This is an automatically generated file created by the Jucer! Creation date: 2 Jul 2008 4:05:42 pm Be careful when adding custom code to these files, as only the code within the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded and re-saved. Jucer version: 1.11 ------------------------------------------------------------------------------ The Jucer is part of the JUCE library - "Jules' Utility Class Extensions" Copyright 2004-6 by Raw Material Software ltd. ============================================================================== */ #ifndef __JUCER_HEADER_STEPEDITSYSEX_STEPEDITSYSEX_4791C31A__ #define __JUCER_HEADER_STEPEDITSYSEX_STEPEDITSYSEX_4791C31A__ //[Headers] -- You can add your own extra header files here -- #include "juce.h" #include "myMidiMessage.h" //[/Headers] //============================================================================== /** //[Comments] An auto-generated component, created by the Jucer. Describe your class and how it works here! //[/Comments] */ class stepEditSysex : public Component, public ButtonListener { public: //============================================================================== stepEditSysex (myMidiMessage *msg); ~stepEditSysex(); //============================================================================== //[UserMethods] -- You can add your own custom methods in this section. void setMidiRawData (String t); //[/UserMethods] void paint (Graphics& g); void resized(); void buttonClicked (Button* buttonThatWasClicked); //============================================================================== juce_UseDebuggingNewOperator private: //[UserVariables] -- You can add your own custom variables in this section. uint8 *midiRawData; int midiRawDataLen; myMidiMessage *midiMessage; //[/UserVariables] //============================================================================== TextEditor* midiData; TextButton* saveButton; //============================================================================== // (prevent copy constructor and operator= being generated..) stepEditSysex (const stepEditSysex&); const stepEditSysex& operator= (const stepEditSysex&); }; #endif // __JUCER_HEADER_STEPEDITSYSEX_STEPEDITSYSEX_4791C31A__
[ "kubiak.roman@0c9c7eae-764f-0410-aff0-6774c5161e44" ]
[ [ [ 1, 79 ] ] ]
4f92ab8a4dd523cc501bb04c0a4f418141cb1fa0
9a5db9951432056bb5cd4cf3c32362a4e17008b7
/CamController/trunk/Src/CamControl/stdafx.cpp
153f12dcc1eba876a4ac9446d47d6231c56731db
[]
no_license
miaozhendaoren/appcollection
65b0ede264e74e60b68ca74cf70fb24222543278
f8b85af93f787fa897af90e8361569a36ff65d35
refs/heads/master
2021-05-30T19:27:21.142158
2011-06-27T03:49:22
2011-06-27T03:49:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
210
cpp
// stdafx.cpp : source file that includes just the standard includes // CamControl.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h"
[ "shenbinsc@cbf8b9f2-3a65-11de-be05-5f7a86268029" ]
[ [ [ 1, 7 ] ] ]
a88c3cbf1e58e56d8eabb512be3ae9f45c559ce0
a2904986c09bd07e8c89359632e849534970c1be
/topcoder/completed/StairClimb.cpp
39403fa95367c111e84f542304665c42f1b12312
[]
no_license
naturalself/topcoder_srms
20bf84ac1fd959e9fbbf8b82a93113c858bf6134
7b42d11ac2cc1fe5933c5bc5bc97ee61b6ec55e5
refs/heads/master
2021-01-22T04:36:40.592620
2010-11-29T17:30:40
2010-11-29T17:30:40
444,669
1
0
null
null
null
null
UTF-8
C++
false
false
1,973
cpp
// BEGIN CUT HERE // END CUT HERE #line 5 "StairClimb.cpp" #include <iostream> #include <string> #include <vector> #include <sstream> using namespace std; class StairClimb { public: int stridesTaken(vector <int> flights, int stairsPerStride) { if(flights.size()==0) return 0; int steps = 0; int i=0; for(i=0;i<(int)flights.size();i++){ steps += flights[i]/stairsPerStride; if(flights[i]%stairsPerStride) steps++; if(i!=0) steps += 2; } return steps; } // BEGIN CUT HERE public: void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); } private: template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); } void verify_case(int Case, const int &Expected, const int &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } } void test_case_0() { int Arr0[] = {15}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 2; int Arg2 = 8; verify_case(0, Arg2, stridesTaken(Arg0, Arg1)); } void test_case_1() { int Arr0[] = {15,15}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 2; int Arg2 = 18; verify_case(1, Arg2, stridesTaken(Arg0, Arg1)); } void test_case_2() { int Arr0[] = {5,11,9,13,8,30,14}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 3; int Arg2 = 44; verify_case(2, Arg2, stridesTaken(Arg0, Arg1)); } // END CUT HERE }; // BEGIN CUT HERE int main() { StairClimb ___test; ___test.run_test(-1); } // END CUT HERE
[ "shin@CF-7AUJ41TT52JO.(none)" ]
[ [ [ 1, 50 ] ] ]
9c5f2d641d8fd0865e0249d8e5d30e654c0fd12a
41154e2ebb7d5e67fb3666bab82e4a0795b185ba
/block.h
1891400ce8ed825f1650d36b5039b0fafa2e4937
[]
no_license
webstorage119/collapsible
2e76923a05f8117a94abb19ba65288fc6969ad88
c9f27c84cc50105d9fa558c9bfa9566a08842819
refs/heads/master
2021-05-27T09:39:22.100569
2011-05-03T21:14:55
2011-05-03T21:14:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
337
h
#pragma once class Block { public: Block(int *structure, int w, int h); ~Block(); Block *clone(); void rotate(); int getWidth() { return m_width; } int getHeight() { return m_height; } int *getStructure() { return m_structure; } private: int m_width, m_height; int *m_structure; };
[ "emil@b768d8da-b7b4-46c8-b9a4-691b94f9d7b2" ]
[ [ [ 1, 29 ] ] ]
22c98640d22c8598e7d5ba65a21660fd3c2f5e37
f95341dd85222aa39eaa225262234353f38f6f97
/Dreams/Dreams/CrystalMorph/fractalobject.cpp
eee49a8d0acf04b6fb6707d9dae9b081599ab2e8
[]
no_license
Templier/threeoaks
367b1a0a45596b8fe3607be747b0d0e475fa1df2
5091c0f54bd0a1b160ddca65a5e88286981c8794
refs/heads/master
2020-06-03T11:08:23.458450
2011-10-31T04:33:20
2011-10-31T04:33:20
32,111,618
0
0
null
null
null
null
UTF-8
C++
false
false
9,161
cpp
////////////////////////////////////////////////////////////////// // FRACTAL.CPP // ////////////////////////////////////////////////////////////////// #include "fractalobject.h" // also includes glu and gl correctly //#include "materials.h" extern LPDIRECT3DDEVICE9 g_pd3dDevice; // stuff for the environment cube struct FracVertex { D3DXVECTOR3 position; D3DXVECTOR3 normal; // DWORD color; // The vertex colour. }; //#define FVF_FRACVERTEX ( D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE ) #define FVF_FRACVERTEX ( D3DFVF_XYZ | D3DFVF_NORMAL ) // man, how many times have you typed (or pasted) this data for a cube's // vertices and normals, eh? FracVertex g_cubeVertices[] = { {D3DXVECTOR3(-0.5f, 0.5f,-0.5f), D3DXVECTOR3(0.0f, 0.0f,-1.0f)},// D3DCOLOR_RGBA(0,255,0,255)}, {D3DXVECTOR3( 0.5f, 0.5f,-0.5f), D3DXVECTOR3(0.0f, 0.0f,-1.0f)},// D3DCOLOR_RGBA(255,255,0,255)}, {D3DXVECTOR3(-0.5f,-0.5f,-0.5f), D3DXVECTOR3(0.0f, 0.0f,-1.0f)},// D3DCOLOR_RGBA(0,0,0,255)}, {D3DXVECTOR3( 0.5f,-0.5f,-0.5f), D3DXVECTOR3(0.0f, 0.0f,-1.0f)},// D3DCOLOR_RGBA(255,0,0,255)}, {D3DXVECTOR3(-0.5f, 0.5f, 0.5f), D3DXVECTOR3(0.0f, 0.0f, 1.0f)},// D3DCOLOR_RGBA(0,255,255,255)}, {D3DXVECTOR3(-0.5f,-0.5f, 0.5f), D3DXVECTOR3(0.0f, 0.0f, 1.0f)},// D3DCOLOR_RGBA(0,255,255,255)}, {D3DXVECTOR3( 0.5f, 0.5f, 0.5f), D3DXVECTOR3(0.0f, 0.0f, 1.0f)},// D3DCOLOR_RGBA(255,255,255,255)}, {D3DXVECTOR3( 0.5f,-0.5f, 0.5f), D3DXVECTOR3(0.0f, 0.0f, 1.0f)},// D3DCOLOR_RGBA(255,0,255,255)}, {D3DXVECTOR3(-0.5f, 0.5f, 0.5f), D3DXVECTOR3(0.0f, 1.0f, 0.0f)},// D3DCOLOR_RGBA(0,255,255,255)}, {D3DXVECTOR3( 0.5f, 0.5f, 0.5f), D3DXVECTOR3(0.0f, 1.0f, 0.0f)},// D3DCOLOR_RGBA(255,255,255,255)}, {D3DXVECTOR3(-0.5f, 0.5f,-0.5f), D3DXVECTOR3(0.0f, 1.0f, 0.0f)},// D3DCOLOR_RGBA(0,255,0,255)}, {D3DXVECTOR3( 0.5f, 0.5f,-0.5f), D3DXVECTOR3(0.0f, 1.0f, 0.0f)},// D3DCOLOR_RGBA(255,255,0,255)}, {D3DXVECTOR3(-0.5f,-0.5f, 0.5f), D3DXVECTOR3(0.0f,-1.0f, 0.0f)},// D3DCOLOR_RGBA(0,0,255,255)}, {D3DXVECTOR3(-0.5f,-0.5f,-0.5f), D3DXVECTOR3(0.0f,-1.0f, 0.0f)},// D3DCOLOR_RGBA(0,0,0,255)}, {D3DXVECTOR3( 0.5f,-0.5f, 0.5f), D3DXVECTOR3(0.0f,-1.0f, 0.0f)},// D3DCOLOR_RGBA(255,0,255,255)}, {D3DXVECTOR3( 0.5f,-0.5f,-0.5f), D3DXVECTOR3(0.0f,-1.0f, 0.0f)},// D3DCOLOR_RGBA(255,0,0,255)}, {D3DXVECTOR3( 0.5f, 0.5f,-0.5f), D3DXVECTOR3(1.0f, 0.0f, 0.0f)},// D3DCOLOR_RGBA(255,255,0,255)}, {D3DXVECTOR3( 0.5f, 0.5f, 0.5f), D3DXVECTOR3(1.0f, 0.0f, 0.0f)},// D3DCOLOR_RGBA(255,255,255,255)}, {D3DXVECTOR3( 0.5f,-0.5f,-0.5f), D3DXVECTOR3(1.0f, 0.0f, 0.0f)},// D3DCOLOR_RGBA(255,0,0,255)}, {D3DXVECTOR3( 0.5f,-0.5f, 0.5f), D3DXVECTOR3(1.0f, 0.0f, 0.0f)},// D3DCOLOR_RGBA(255,0,255,255)}, {D3DXVECTOR3(-0.5f, 0.5f,-0.5f), D3DXVECTOR3(-1.0f, 0.0f, 0.0f)},// D3DCOLOR_RGBA(0,255,0,255)}, {D3DXVECTOR3(-0.5f,-0.5f,-0.5f), D3DXVECTOR3(-1.0f, 0.0f, 0.0f)},// D3DCOLOR_RGBA(0,0,0,255)}, {D3DXVECTOR3(-0.5f, 0.5f, 0.5f), D3DXVECTOR3(-1.0f, 0.0f, 0.0f)},// D3DCOLOR_RGBA(0,255,255,255)}, {D3DXVECTOR3(-0.5f,-0.5f, 0.5f), D3DXVECTOR3(-1.0f, 0.0f, 0.0f)},// D3DCOLOR_RGBA(0,0,255,255)} }; FracVertex g_pyramidVertices[] = { {D3DXVECTOR3( 0.5f, 0.5f, 0.5f), D3DXVECTOR3( 0.5f, 0.5f, 0.5f)}, //0xFFFF0000}, {D3DXVECTOR3( 0.5f,-0.5f,-0.5f), D3DXVECTOR3( 0.5f,-0.5f,-0.5f)}, //0xFF00FF00}, {D3DXVECTOR3(-0.5f, 0.5f,-0.5f), D3DXVECTOR3(-0.5f, 0.5f,-0.5f)}, //0xFF0000FF}, {D3DXVECTOR3(-0.5f,-0.5f, 0.5f), D3DXVECTOR3(-0.5f,-0.5f, 0.5f)}, //0xFFFFFF00}, {D3DXVECTOR3( 0.5f, 0.5f, 0.5f), D3DXVECTOR3( 0.5f, 0.5f, 0.5f)}, //0xFFFF0000}, {D3DXVECTOR3( 0.5f,-0.5f,-0.5f), D3DXVECTOR3( 0.5f,-0.5f,-0.5f)}//, 0xFF00FF00} }; LPDIRECT3DVERTEXBUFFER9 g_pCubeVertexBuffer = NULL; LPDIRECT3DVERTEXBUFFER9 g_pPyramidVertexBuffer = NULL; Fractal::Fractal() { Init(4); } Fractal::Fractal(int numTransforms) { Init(numTransforms); } Fractal::~Fractal() { g_pCubeVertexBuffer->Release(); g_pPyramidVertexBuffer->Release(); delete mySphere; } void FractalTransform::Init() { translation.x = translation.y = translation.z = 0.0; scaling.x = scaling.y = scaling.z = 1.0; rotation.x = rotation.y = rotation.z = 0.0; } void FractalData::Init() { numTransforms = 1; for (int i = 0; i < MAX_TRANSFORMS; i++) { transforms[i].Init(); } base = FRACTAL_BASE_PYRAMID; } void initBuffer(LPDIRECT3DVERTEXBUFFER9* buffer, FracVertex * vertices, int numVertices) { g_pd3dDevice->CreateVertexBuffer( numVertices*sizeof(FracVertex), D3DUSAGE_WRITEONLY, FVF_FRACVERTEX, D3DPOOL_DEFAULT, buffer, NULL ); void *pVertices = NULL; (*buffer)->Lock( 0, numVertices*sizeof(FracVertex), (void**)&pVertices, 0 ); memcpy( pVertices, vertices, numVertices*sizeof(FracVertex) ); (*buffer)->Unlock(); } //Inits the Transforms void Fractal::Init(int numTransforms) { myData.Init(); myData.numTransforms = numTransforms; myCutoffDepth = 5; selectionOn = false; mySelectedTransform = 0; myColorLerpAmount = 0.7f; redBlueRender = false; mySphere = new C_Sphere(); glInit(); initBuffer(&g_pCubeVertexBuffer, g_cubeVertices, 24); initBuffer(&g_pPyramidVertexBuffer, g_pyramidVertices, 6); } //Renders the fractal void Fractal::Render() { /* if(selectionOn) RenderSelection(0); if(!redBlueRender) { if(myData.base == FRACTAL_BASE_CUBE) SetMaterial(GREEN_PLASTIC); else SetMaterial(BLUE_WATER); } else { SetMaterial(PURPLE_METAL); }*/ for(int i = 0; i < myData.numTransforms; i++) myData.transforms[i].color.incrementColor(); for(int i = 0; i < myData.numTransforms; i++) { ApplyTransform(i); /* if(selectionOn) { if(i == mySelectedTransform) RenderSelection(1); else RenderSelection(2); }*/ RenderChild(0, i, myData.transforms[i].color.getColor()); InvertTransform(i); } } //The Recursively called render function void Fractal::RenderChild(int depth, int parentTransform, ColorRGB childColor) { depth++; if(depth >= myCutoffDepth) { RenderBase(childColor); return; } for(int i = 0; i < myData.numTransforms; i++) { ApplyTransform(i); RenderChild(depth, parentTransform, LerpColor(myData.transforms[i].color.getColor(), childColor, myColorLerpAmount)); InvertTransform(i); } } /* //Draws the wireframe selection boxes void Fractal::RenderSelection(int depth) { if(!redBlueRender) if(depth == 0) { SetMaterial(DULL_PINK); glColor3f(1.0,1.0,1.0); } else if (depth == 1) { SetMaterial(BRASS); glColor3f(0.0,1.0,1.0); } else if (depth == 2) { SetMaterial(RED_METAL); glColor3f(0.8,.8,0.3); } glutWireCube(1.0); }*/ //applys the transform to the matrix void Fractal::ApplyTransform(int i) { glPushMatrix(); glScalef(myData.transforms[i].scaling.x, myData.transforms[i].scaling.y, myData.transforms[i].scaling.z); glTranslatef(myData.transforms[i].translation.x, myData.transforms[i].translation.y, myData.transforms[i].translation.z); glRotatef(myData.transforms[i].rotation.x, myData.transforms[i].rotation.y, myData.transforms[i].rotation.z); } //Inverts the transform.. just pops the matrix off the stack. void Fractal::InvertTransform(int iTransform) { glPopMatrix(); } //Sets whether selection is on and which transform is selected void Fractal::SetSelection(bool drawSelection, int numSelected) { selectionOn = drawSelection; mySelectedTransform = numSelected % myData.numTransforms; } FractalData *Fractal::GetDataHandle() { return & myData; } //Increments cutoff void Fractal::IncrementCutoff(bool up) { myCutoffDepth += up ? 1 : -1; if (myCutoffDepth == 0) myCutoffDepth = 1; } void Fractal::SetCutoff(int cutoff) { myCutoffDepth = cutoff; myColorLerpAmount = pow(0.4f,1.0f/((float)cutoff)); } void Fractal::setRedBlueRender(bool red) { redBlueRender = red; } // draws the base shape be it cube, pyramid or whatever void Fractal::RenderBase(ColorRGB color) { glApply(); D3DMATERIAL9 mat; memset(&mat,0,sizeof(D3DMATERIAL9)); mat.Diffuse.a = 1.0f; mat.Diffuse.r = ((float)((color&0xFF0000)>>16))/255.0f; mat.Diffuse.g = ((float)((color&0xFF00)>>8))/255.0f; mat.Diffuse.b = ((float)((color&0xFF)))/255.0f; g_pd3dDevice->SetMaterial(&mat); if(myData.base == FRACTAL_BASE_SPHERE) { // mySphere->SetColor(color); mySphere->Render3D(); } else if(myData.base == FRACTAL_BASE_PYRAMID) { g_pd3dDevice->SetFVF( FVF_FRACVERTEX ); g_pd3dDevice->SetStreamSource( 0, g_pPyramidVertexBuffer, 0, sizeof(FracVertex) ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 4 ); } else { g_pd3dDevice->SetFVF( FVF_FRACVERTEX ); g_pd3dDevice->SetStreamSource( 0, g_pCubeVertexBuffer, 0, sizeof(FracVertex) ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 4, 2 ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 8, 2 ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 12, 2 ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 16, 2 ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 20, 2 ); } }
[ "julien.templier@ab80709b-eb45-0410-bb3a-633ce738720d" ]
[ [ [ 1, 299 ] ] ]
3501a3d63e136fb6546ad98ee2ebdccc91904397
ea12fed4c32e9c7992956419eb3e2bace91f063a
/zombie/code/renaissance/rnsgameplay/src/ncagentmemory/ncagentmemory_cmds.cc
7154485d5d24dca8aea859f45e09e29995e2435e
[]
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
1,037
cc
#include "precompiled/pchrnsgameplay.h" //------------------------------------------------------------------------------ // ncagentmemory_cmds.cc // (C) 2005 Conjurer Services, S.A. //------------------------------------------------------------------------------ #include "ncagentmemory/ncagentmemory.h" //----------------------------------------------------------------------------- NSCRIPT_INITCMDS_BEGIN(ncAgentMemory) NSCRIPT_ADDCMD_COMPOBJECT('RSRT', void, SetRecallTime, 1, (int), 0, ()); NSCRIPT_ADDCMD_COMPOBJECT('RSLT', void, UpdateRecallTime, 0, (), 0, ()); NSCRIPT_INITCMDS_END() //------------------------------------------------------------------------------ /** SaveCmds */ bool ncAgentMemory::SaveCmds (nPersistServer* ps) { if ( nComponentObject::SaveCmds(ps) ) { // -- recall time if (!ps->Put (this->entityObject, 'RSRT', this->recallTime)) { return false; } return true; } return false; }
[ "magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91" ]
[ [ [ 1, 34 ] ] ]
0552ae0858092dca68e42f52cc500fd146504d4f
eb8a27a2cc7307f0bc9596faa4aa4a716676c5c5
/WinEdition/browser-lcc/jscc/src/v8/v8/test/cctest/test-unbound-queue.cc
f4c6d44491d74658cb1d9babccf548e37bdf6cec
[ "BSD-3-Clause", "bzip2-1.0.6", "LicenseRef-scancode-public-domain", "Artistic-2.0", "Artistic-1.0" ]
permissive
baxtree/OKBuzzer
c46c7f271a26be13adcf874d77a7a6762a8dc6be
a16e2baad145f5c65052cdc7c767e78cdfee1181
refs/heads/master
2021-01-02T22:17:34.168564
2011-06-15T02:29:56
2011-06-15T02:29:56
1,790,181
0
0
null
null
null
null
UTF-8
C++
false
false
1,054
cc
// Copyright 2010 the V8 project authors. All rights reserved. // // Tests of the unbound queue. #include "v8.h" #include "unbound-queue-inl.h" #include "cctest.h" namespace i = v8::internal; using i::UnboundQueue; TEST(SingleRecord) { typedef int Record; UnboundQueue<Record> cq; CHECK(cq.IsEmpty()); cq.Enqueue(1); CHECK(!cq.IsEmpty()); Record rec = 0; cq.Dequeue(&rec); CHECK_EQ(1, rec); CHECK(cq.IsEmpty()); } TEST(MultipleRecords) { typedef int Record; UnboundQueue<Record> cq; CHECK(cq.IsEmpty()); cq.Enqueue(1); CHECK(!cq.IsEmpty()); for (int i = 2; i <= 5; ++i) { cq.Enqueue(i); CHECK(!cq.IsEmpty()); } Record rec = 0; for (int i = 1; i <= 4; ++i) { CHECK(!cq.IsEmpty()); cq.Dequeue(&rec); CHECK_EQ(i, rec); } for (int i = 6; i <= 12; ++i) { cq.Enqueue(i); CHECK(!cq.IsEmpty()); } for (int i = 5; i <= 12; ++i) { CHECK(!cq.IsEmpty()); cq.Dequeue(&rec); CHECK_EQ(i, rec); } CHECK(cq.IsEmpty()); }
[ [ [ 1, 54 ] ] ]
4801d338ccb8358df44a6a8b35db473d93430b13
de1e5905af557c6155ee50f509758a549e458ef3
/src/code/taps_featurelibrary.cpp
58ece149184e12f3180d9374d9f24ebda5b36617
[]
no_license
alltom/taps
f15f0a5b234db92447a581f3777dbe143d78da6c
a3c399d932314436f055f147106d41a90ba2fd02
refs/heads/master
2021-01-13T01:46:24.766584
2011-09-03T23:20:12
2011-09-03T23:20:12
2,486,969
1
0
null
null
null
null
UTF-8
C++
false
false
5,058
cpp
/*---------------------------------------------------------------------------- TAPESTREA: Techniques And Paradigms for Expressive Synthesis, Transformation, and Rendering of Environmental Audio Engine and User Interface Copyright (c) 2006 Ananya Misra, Perry R. Cook, and Ge Wang. http://taps.cs.princeton.edu/ http://soundlab.cs.princeton.edu/ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U.S.A. -----------------------------------------------------------------------------*/ //----------------------------------------------------------------------------- // file: taps_featurelibrary.cpp // desc: taps feature library // // author: Matt Hoffman ([email protected]) // Ananya Misra ([email protected]) // Ge Wang ([email protected]) // Perry R. Cook ([email protected]) // date: Spring 2006 //----------------------------------------------------------------------------- #include "taps_featurelibrary.h" #include <stdio.h> #include <math.h> #include <string.h> #include <algorithm> FeatureLibrary::FeatureLibrary(char *libName) { int i; //char cbuff[4096]; //sprintf(cbuff, "%s/library.fli", dirName); //FILE *libfile = fopen(cbuff, "r"); FILE *libfile = fopen(libName, "r"); fscanf(libfile, "%d\n", &numFeats); for(i = 0; i < numFeats; i++){ char *featName = new char[128]; fscanf(libfile, "%s", featName); featureNames.push_back(featName); } while(!feof(libfile)){ char *filename = new char[256]; if( fscanf(libfile, "%s", filename) != EOF ) { fileNames.push_back(filename); bool hasTapsFile; fscanf(libfile, "%d", &hasTapsFile); tapsFile.push_back(hasTapsFile); float *fvec = new float[numFeats]; for(i = 0; i < numFeats; i++) fscanf(libfile, "%f", &fvec[i]); featureVals.push_back(fvec); } } weights = new float[numFeats]; for(i = 0; i < numFeats; i++) weights[i] = 1; fclose(libfile); } FeatureLibrary::~FeatureLibrary() { int i; for(i = 0; i < featureNames.size(); i++) delete[] featureNames[i]; for(i = 0; i < featureVals.size(); i++){ delete[] featureVals[i]; delete[] fileNames[i]; } delete[] weights; } void FeatureLibrary::addFile(const char *filename, const float *features, bool isTemplate) { float *addVals = new float[numFeats]; char *addFName = new char[strlen(filename) + 1]; int i; for(i = 0; i < numFeats; i++) addVals[i] = features[i]; strcpy(addFName, filename); featureVals.push_back(addVals); fileNames.push_back(addFName); tapsFile.push_back(isTemplate); } void FeatureLibrary::setWeights(float *newWeights) { for(int i = 0; i < numFeats; i++) weights[i] = newWeights[i]; } float FeatureLibrary::distance(const float *v1, const float *v2) { float dist = 0; for(int i = 0; i < numFeats; i++){ float diff = weights[i] * (v1[i] - v2[i]); dist += diff * diff; } return sqrt(dist); } struct DistIndex { float dist; int index; }; bool operator<(const DistIndex &di1, const DistIndex &di2) { return di1.dist < di2.dist; } void FeatureLibrary::rankClosestFiles(const float *targetVals, int *indices, float *distances) { int i; DistIndex * sortedDistIndices = new DistIndex[featureVals.size()]; for(i = 0; i < featureVals.size(); i++){ DistIndex di; di.dist = distance(targetVals, featureVals[i]); di.index = i; sortedDistIndices[i] = (di); } std::sort(sortedDistIndices, &sortedDistIndices[featureVals.size()]); for(i = 0; i < featureVals.size(); i++) indices[i] = sortedDistIndices[i].index; if(distances) for(i = 0; i < featureVals.size(); i++) distances[i] = sortedDistIndices[i].dist; delete [] sortedDistIndices; } void FeatureLibrary::writeFLIFile(const char *filename) { int i, j; FILE *libfile = fopen(filename, "w"); fprintf(libfile, "%d\n", numFeats); for(i = 0; i < numFeats; i++){ if(i > 0) fprintf(libfile, " "); fprintf(libfile, "%s", featureNames[i]); } fprintf(libfile, "\n"); for(i = 0; i < fileNames.size(); i++){ fprintf(libfile, "%s %d", fileNames[i], (int)tapsFile[i]); for(j = 0; j < numFeats; j++) fprintf(libfile, " %f", featureVals[i][j]); fprintf(libfile, "\n"); } fclose(libfile); }
[ [ [ 1, 181 ] ] ]
0ba7c910687b76355311270378558095a96286bc
c440e6c62e060ee70b82fc07dfb9a93e4cc13370
/src/gui2/guis/gfeedbackdelay.cpp
14cd45ac929da039d72f5aa5f062b46c782b74a8
[]
no_license
BackupTheBerlios/pgrtsound-svn
2a3f2ae2afa4482f9eba906f932c30853c6fe771
d7cefe2129d20ec50a9e18943a850d0bb26852e1
refs/heads/master
2020-05-21T01:01:41.354611
2005-10-02T13:09:13
2005-10-02T13:09:13
40,748,578
0
0
null
null
null
null
WINDOWS-1250
C++
false
false
1,212
cpp
#include "gfeedbackdelay.h" GFeedbackDelay::GFeedbackDelay( Module* mod ) : Gui( mod ) { delayEntry.AttachFloatParameter( (ParameterFloat*)module->GetParameter( 0 ) ); slFeedback.SetParameter( (ParameterFloat*)module->GetParameter( 1 ), 0, 0.99, 0.01 ); delayButton.signal_clicked().connect( sigc::mem_fun( this, &GFeedbackDelay::OnDelayChanged ) ); slFeedback.signal_slider_moved().connect( sigc::mem_fun( (MFeedbackDelay*)module, &MFeedbackDelay::SomethingChanged ) ); delayLabel.set_label( Glib::locale_to_utf8( "Opóźnienie [ms]" ) ); delayButton.set_label( Glib::locale_to_utf8( "Zmień" ) ); delayBox.set_spacing( 2 ); delayBox.add( delayLabel ); delayBox.add( delayEntry ); delayBox.add( delayButton ); box.set_spacing( 2 ); box.add( delayBox ); box.add( slFeedback ); } GFeedbackDelay::~GFeedbackDelay() { } Gtk::Widget* GFeedbackDelay::GetGui() { return &box; } void GFeedbackDelay::OnDelayChanged() { ( (ParameterFloat*)module->GetParameter( 0 ) )->SetValue( delayEntry.GetValue() ); delayEntry.SetValue( ( (ParameterFloat*)module->GetParameter( 0 ) )->GetValue() ); ( (MFeedbackDelay*)module )->SomethingChanged(); }
[ "ad4m@fa088095-53e8-0310-8a07-f9518708c3e6" ]
[ [ [ 1, 43 ] ] ]
f5f6ab8596123bc831734fb0e6bb95d42b0ef5d3
14a00dfaf0619eb57f1f04bb784edd3126e10658
/Lab3/main.cpp
b713300d1df9f6ef474765f34fbaa679b8ddb069
[]
no_license
SHINOTECH/modanimation
89f842262b1f552f1044d4aafb3d5a2ce4b587bd
43d0fde55cf75df9d9a28a7681eddeb77460f97c
refs/heads/master
2021-01-21T09:34:18.032922
2010-04-07T12:23:13
2010-04-07T12:23:13
null
0
0
null
null
null
null
ISO-8859-1
C++
false
false
3,008
cpp
/************************************************************************************************* * * Modeling and animation (TNM079) 2007 * Code base for lab assignments. Copyright: * Gunnar Johansson ([email protected]) * Ken Museth ([email protected]) * Michael Bang Nielsen ([email protected]) * Ola Nilsson ([email protected]) * Andreas Söderström ([email protected]) * *************************************************************************************************/ #include <cstdlib> #include <iostream> #include <string> #include <exception> #include "GUI.h" using namespace std; static const int defaultScreenWidth = 800; static const int defaultScreenHeight = 600; GUI mainGUI; //----------------------------------------------------------------------------- void displayFunc() { mainGUI.displayFunc(); } //----------------------------------------------------------------------------- void winReshapeFunc(int newWidth, int newHeight) { mainGUI.winReshapeFunc(newWidth, newHeight); } //----------------------------------------------------------------------------- void mouseFunc(int button, int action, int mouseX, int mouseY) { mainGUI.mouseFunc(button, action, mouseX, mouseY); } //----------------------------------------------------------------------------- void mouseActiveMotionFunc(int mouseX, int mouseY) { mainGUI.mouseActiveMotionFunc(mouseX, mouseY); } //----------------------------------------------------------------------------- void mousePassiveMotionFunc(int mouseX, int mouseY) { mainGUI.mousePassiveMotionFunc(mouseX, mouseY); } //----------------------------------------------------------------------------- void keyboardUpFunc(unsigned char keycode, int mouseX, int mouseY) { mainGUI.keyboardUpFunc(keycode, mouseX, mouseY); } //----------------------------------------------------------------------------- void keyboardFunc(unsigned char keycode, int mouseX, int mouseY) { mainGUI.keyboardFunc(keycode, mouseX, mouseY); } //----------------------------------------------------------------------------- void specialFunc(int keycode, int mouseX, int mouseY) { mainGUI.specialFunc(keycode, mouseX, mouseY); } //----------------------------------------------------------------------------- void idleFunc() { mainGUI.update(); } //----------------------------------------------------------------------------- int main(int argc, char** argv) { glutInit (&argc, argv); mainGUI.init(); // glut callback functions glutDisplayFunc(displayFunc); glutReshapeFunc(winReshapeFunc); glutMouseFunc(mouseFunc); glutMotionFunc(mouseActiveMotionFunc); glutPassiveMotionFunc(mousePassiveMotionFunc); glutKeyboardUpFunc(keyboardUpFunc); glutKeyboardFunc(keyboardFunc); glutSpecialFunc(specialFunc); glutIdleFunc(idleFunc); // Start main loop glutMainLoop(); return 0; }
[ "jpjorge@da195381-492e-0410-b4d9-ef7979db4686" ]
[ [ [ 1, 101 ] ] ]
d84b7a966b14e3b085ea3f885c2cf7d21e2ba954
1ad310fc8abf44dbcb99add43f6c6b4c97a3767c
/samples_c++/cpp/ConstDevice/ConstDevice.h
eedb500098dcb73e5e162cf372dcc6816375888d
[]
no_license
Jazzinghen/spamOSEK
fed44979b86149809f0fe70355f2117e9cb954f3
7223a2fb78401e1d9fa96ecaa2323564c765c970
refs/heads/master
2020-06-01T03:55:48.113095
2010-05-19T14:37:30
2010-05-19T14:37:30
580,640
1
2
null
null
null
null
UTF-8
C++
false
false
583
h
// // ConstDevice.h // #ifndef CONSTDEVICE_H_ #define CONSTDEVICE_H_ // ECRobot++ API #include "LightSensor.h" #include "SonarSensor.h" #include "SoundSensor.h" #include "TouchSensor.h" #include "Motor.h" using namespace ecrobot; // Constant(read-only) devices extern const LightSensor& crLight; // Lamp on/off is restricted extern const SonarSensor& crSonar; // no difference extern const SoundSensor& crMic; // DBA on/off is restricted extern const TouchSensor& crTouch; // no difference extern const Motor& crMotorA; // only getCount #endif
[ "jazzinghen@Jehuty.(none)" ]
[ [ [ 1, 23 ] ] ]
16065dbffa522cd95f403944e02e8c6819208d55
b73f27ba54ad98fa4314a79f2afbaee638cf13f0
/projects/FilterSetting/stdafx.cpp
50dafb4d6a6a594c081f8e04c124015bd3ef9565
[]
no_license
weimingtom/httpcontentparser
4d5ed678f2b38812e05328b01bc6b0c161690991
54554f163b16a7c56e8350a148b1bd29461300a0
refs/heads/master
2021-01-09T21:58:30.326476
2009-09-23T08:05:31
2009-09-23T08:05:31
48,733,304
3
0
null
null
null
null
GB18030
C++
false
false
170
cpp
// stdafx.cpp : 只包括标准包含文件的源文件 // FilterSetting.pch 将成为预编译头 // stdafx.obj 将包含预编译类型信息 #include "stdafx.h"
[ "ynkhpp@1a8edc88-4151-0410-b40c-1915dda2b29b" ]
[ [ [ 1, 5 ] ] ]
5b34b52b7fac88a71f38033b81154bec2a75d766
fdf457fb3f4e68b4a9631e19540e4de2ea5dd4c2
/brollyflock_centipede/Centipede.cpp
1ea5300b0e318dcc9938a89910cbc6d529c8fc58
[]
no_license
poe/brollyflock
29dae03b834f8e926316b6d2bf4b6748ed1815f3
1442771f93a9e3a7587f25798eef1562af05aab3
refs/heads/master
2021-01-23T11:09:05.457344
2011-08-12T01:48:34
2011-08-12T01:48:34
1,868,090
2
0
null
null
null
null
UTF-8
C++
false
false
3,163
cpp
// Centipede Shield Library // Controls MCP23017 16-bit digital I/O chips #include "WProgram.h" #include "Centipede.h" #include <Wire.h> uint8_t CSDataArray[2] = {0}; #define CSAddress 0b0100000 Centipede::Centipede() { // no constructor tasks yet } // Set device to default values void Centipede::initialize() { for (int j = 0; j < 4; j++) { CSDataArray[0] = 255; CSDataArray[1] = 255; WriteRegisters(0, 0x00, 2); CSDataArray[0] = 0; CSDataArray[1] = 0; for (int k = 2; k < 0x15; k+=2) { WriteRegisters(j, k, 2); } } } void Centipede::WriteRegisters(int port, int startregister, int quantity) { Wire.beginTransmission(CSAddress + port); Wire.send(startregister); for (int i = 0; i < quantity; i++) { Wire.send(CSDataArray[i]); } Wire.endTransmission(); } void Centipede::ReadRegisters(int port, int startregister, int quantity) { Wire.beginTransmission(CSAddress + port); Wire.send(startregister); Wire.endTransmission(); Wire.requestFrom(CSAddress + port, quantity); for (int i = 0; i < quantity; i++) { CSDataArray[i] = Wire.receive(); } } void Centipede::WriteRegisterPin(int port, int regpin, int subregister, int level) { ReadRegisters(port, subregister, 1); if (level == 0) { CSDataArray[0] &= ~(1 << regpin); } else { CSDataArray[0] |= (1 << regpin); } WriteRegisters(port, subregister, 1); } void Centipede::pinMode(int pin, int mode) { int port = pin >> 4; int subregister = (pin & 8) >> 3; int regpin = pin - ((port << 1) + subregister)*8; WriteRegisterPin(port, regpin, subregister, mode ^ 1); } void Centipede::pinPullup(int pin, int mode) { int port = pin >> 4; int subregister = (pin & 8) >> 3; int regpin = pin - ((port << 1) + subregister)*8; WriteRegisterPin(port, regpin, 0x0C + subregister, mode); } void Centipede::digitalWrite(int pin, int level) { int port = pin >> 4; int subregister = (pin & 8) >> 3; int regpin = pin - ((port << 1) + subregister)*8; WriteRegisterPin(port, regpin, 0x12 + subregister, level); } int Centipede::digitalRead(int pin) { int port = pin >> 4; int subregister = (pin & 8) >> 3; ReadRegisters(port, 0x12 + subregister, 1); int returnval = (CSDataArray[0] >> (pin - ((port << 1) + subregister)*8)) & 1; return returnval; } void Centipede::portMode(int port, int value) { CSDataArray[0] = value; CSDataArray[1] = value>>8; WriteRegisters(port, 0x00, 2); } void Centipede::portWrite(int port, int value) { CSDataArray[0] = value; CSDataArray[1] = value>>8; WriteRegisters(port, 0x12, 2); } void Centipede::portPullup(int port, int value) { CSDataArray[0] = value; CSDataArray[1] = value>>8; WriteRegisters(port, 0x0C, 2); } int Centipede::portRead(int port) { ReadRegisters(port, 0x12, 2); int receivedval = CSDataArray[0]; receivedval |= CSDataArray[1] << 8; return receivedval; }
[ [ [ 1, 166 ] ] ]
c957bffe69d4a760281698f365802e8eb5f705c0
dc4b6ab7b120262779e29d8b2d96109517f35551
/Dialog/SizeListCtrl.h
df50851cbfe95fc83a13e6555cb8488fca2f3822
[]
no_license
cnsuhao/wtlhelper9
92daef29b61f95f44a10e3277d8835c2dd620616
681df3a014fc71597e9380b0a60bd3cd23e22efe
refs/heads/master
2021-07-17T19:59:07.143192
2009-05-18T14:24:48
2009-05-18T14:24:48
108,361,858
0
1
null
null
null
null
UTF-8
C++
false
false
3,700
h
//////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2004 Sergey Solozhentsev // Author: Sergey Solozhentsev e-mail: [email protected] // Product: WTL Helper // File: SizeListCtrl.h // Created: 13.01.2005 14:32 // // Using this software in commercial applications requires an author // permission. The permission will be granted to everyone excluding the cases // when someone simply tries to resell the code. // This file may be redistributed by any means PROVIDING it is not sold for // profit without the authors written consent, and providing that this notice // and the authors name is included. // This file is provided "as is" with no expressed or implied warranty. The // author accepts no liability if it causes any damage to you or your computer // whatsoever. // //////////////////////////////////////////////////////////////////////////////// // This file was generated by WTL subclass control wizard // SizeListCtrl.h : Declaration of the CSizeListCtrl #pragma once #include <atlframe.h> // CSizeListCtrl #define MCDS_TEXTCOLOR 1 #define MCDS_BACKCOLOR 2 #define MCDS_STYLE 4 #define SLC_STYLE_ITALIC 1 #define SLC_STYLE_BOLD 2 #define SLC_STYLE_STRIKEOUT 4 #define SLC_STYLE_UNDERLINE 8 struct MyCustomDrawStruct { DWORD dwMask; COLORREF TextColor; COLORREF BackColor; DWORD dwStyle; }; struct LPARAMSTRUCT { LPARAM lOldParam; MyCustomDrawStruct DrawStruct; }; #define SLC_POSTSIZE (WM_USER + 200) typedef CWinTraitsOR<LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | WS_TABSTOP, WS_EX_CLIENTEDGE> CSizeListTraits; class CSizeListCtrl : public CWindowImpl<CSizeListCtrl, CListViewCtrl, CSizeListTraits>, public CCustomDraw<CSizeListCtrl> { CFont m_NewFont; CFontHandle m_OldFont; protected: LPARAM _GetItemData(int nItem); int m_PrevWidth; public: CSizeListCtrl(); ~CSizeListCtrl(); DECLARE_WND_SUPERCLASS(_T("CSizeListCtrl"), CListViewCtrl::GetWndClassName()) BEGIN_MSG_MAP(CSizeListCtrl) MESSAGE_HANDLER(WM_SIZE, OnSize) MESSAGE_HANDLER(LVM_SETITEMA, OnSetItem) MESSAGE_HANDLER(LVM_SETITEMW, OnSetItem) MESSAGE_HANDLER(LVM_INSERTITEMA, OnInsertItem) MESSAGE_HANDLER(LVM_INSERTITEMW, OnInsertItem) MESSAGE_HANDLER(LVM_GETITEMA, OnGetItem) MESSAGE_HANDLER(LVM_GETITEMW, OnGetItem) MESSAGE_HANDLER(SLC_POSTSIZE, OnPostSize) REFLECTED_NOTIFY_CODE_HANDLER(LVN_DELETEITEM, OnDeleteItem) CHAIN_MSG_MAP_ALT(CCustomDraw<CSizeListCtrl>, 1) END_MSG_MAP() DWORD OnPrePaint(int idCtrl, LPNMCUSTOMDRAW lpNMCustomDraw); DWORD OnItemPrePaint(int idCtrl, LPNMCUSTOMDRAW lpNMCustomDraw); DWORD OnSubItemPrePaint(int idCtrl, LPNMCUSTOMDRAW lpNMCustomDraw); void DeleteHelperItemData(LPARAM lParam); BOOL SetDrawStruct(int nItem, const MyCustomDrawStruct* pDrawStruct); BOOL GetDrawStruct(int nItem, MyCustomDrawStruct* pDrawStruct); // Handler prototypes: // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnSetItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnInsertItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnGetItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnDeleteItem(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); LRESULT OnPostSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); };
[ "free2000fly@eea8f18a-16fd-41b0-b60a-c1204a6b73d1" ]
[ [ [ 1, 106 ] ] ]
c4619b457eb1a3fd318a4ecaa5f9a4669165f161
c95a83e1a741b8c0eb810dd018d91060e5872dd8
/Game/ObjectDLL/ObjectShared/Fire.h
a02660d17bd648591cb75ebb080d656023d44fbc
[]
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
1,364
h
// ----------------------------------------------------------------------- // // // MODULE : Fire.h // // PURPOSE : Fire - Definition // // CREATED : 5/6/99 // // (c) 1999 Monolith Productions, Inc. All Rights Reserved // // ----------------------------------------------------------------------- // #ifndef __FIRE_H__ #define __FIRE_H__ #include "ClientSFX.h" #include "SFXMsgIds.h" LINKTO_MODULE( Fire ); class Fire : public CClientSFX { public : Fire(); ~Fire(); protected : uint32 EngineMessageFn(uint32 messageID, void *pData, LTFLOAT fData); bool OnTrigger(HOBJECT hSender, const CParsedMsg &cMsg); private : LTBOOL m_bOn; LTBOOL m_bSmoke; LTBOOL m_bLight; LTBOOL m_bSparks; LTBOOL m_bSound; LTBOOL m_bBlackSmoke; LTBOOL m_bSmokeOnly; LTFLOAT m_fRadius; LTFLOAT m_fSoundRadius; LTFLOAT m_fLightRadius; LTFLOAT m_fLightPhase; LTFLOAT m_fLightFreq; LTVector m_vLightColor; LTVector m_vLightOffset; void Save(ILTMessage_Write *pMsg, uint32 dwSaveFlags); void Load(ILTMessage_Read *pMsg, uint32 dwLoadFlags); LTBOOL ReadProp(ObjectCreateStruct *pStruct); void InitialUpdate(int nInfo); }; #endif // __FIRE_H__
[ [ [ 1, 57 ] ] ]
6d560c0ade1c0af3cc696228ab8ae353934c8d1b
b2d46af9c6152323ce240374afc998c1574db71f
/cursovideojuegos/theflostiproject/3rdParty/boost/libs/config/test/has_sgi_type_traits_fail.cpp
0900b6d3547c1d904a58101f9f76d16661ae3905
[]
no_license
bugbit/cipsaoscar
601b4da0f0a647e71717ed35ee5c2f2d63c8a0f4
52aa8b4b67d48f59e46cb43527480f8b3552e96d
refs/heads/master
2021-01-10T21:31:18.653163
2011-09-28T16:39:12
2011-09-28T16:39:12
33,032,640
0
0
null
null
null
null
UTF-8
C++
false
false
1,208
cpp
// This file was automatically generated on Sun Jul 25 11:47:49 GMTDT 2004, // by libs/config/tools/generate // Copyright John Maddock 2002-4. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org/libs/config for the most recent version. // Test file for macro BOOST_HAS_SGI_TYPE_TRAITS // This file should not compile, if it does then // BOOST_HAS_SGI_TYPE_TRAITS may be defined. // see boost_has_sgi_type_traits.ipp for more details // Do not edit this file, it was generated automatically by // ../tools/generate from boost_has_sgi_type_traits.ipp on // Sun Jul 25 11:47:49 GMTDT 2004 // Must not have BOOST_ASSERT_CONFIG set; it defeats // the objective of this file: #ifdef BOOST_ASSERT_CONFIG # undef BOOST_ASSERT_CONFIG #endif #include <boost/config.hpp> #include "test.hpp" #ifndef BOOST_HAS_SGI_TYPE_TRAITS #include "boost_has_sgi_type_traits.ipp" #else #error "this file should not compile" #endif int main( int, char *[] ) { return boost_has_sgi_type_traits::test(); }
[ "ohernandezba@71d53fa2-cca5-e1f2-4b5e-677cbd06613a" ]
[ [ [ 1, 39 ] ] ]
b03136abc0ff1e39f01e199be92f31b2ebf8521d
d37848c528fe70a9ed6ede4737b93196c855d04e
/ParallelMergeSort/Randomizer.cpp
e8ab7f9782ce44413fa0b60535930365c4b927a9
[]
no_license
chuanran/parallel-merge-sort
74991cae0ad398f7d7d021a4bd62b5c16b2bb52e
9c88ef5507aa800fc31d52b1bcd09058f742488c
refs/heads/master
2021-01-10T13:38:33.531256
2011-03-21T13:57:03
2011-03-21T13:57:03
48,393,723
0
0
null
null
null
null
UTF-8
C++
false
false
709
cpp
#include "Randomizer.h" #include <stdlib.h> #include <time.h> int* Randomizer::GenerateArray(int N, int min /* = 0 */, int max /* = 10 */) { srand((unsigned int)time(NULL)); int* A = new int[N]; for (int i = 0; i < N; i++) { A[i] = (rand() % (max - min)) + min; } return A; } int* Randomizer::CreatePermutation(int N) { srand((unsigned int)time(NULL)); int* A = new int[N]; int* Skip = new int[N]; for (int i = 0; i < N; i++) { Skip[i] = i; } for (int i =0; i < N; i++) { int r = rand() % N; int p = r; while (Skip[r] != r) { r = Skip[r]; } A[r] = i; Skip[r] = (r + 1) % N; Skip[p] = Skip[r]; } delete[] Skip; return A; }
[ "shay.markanty@018be4eb-6b87-c2f0-6375-72b8ba19d606" ]
[ [ [ 1, 42 ] ] ]
0b81dc764c674cc79028a5479c9be022896d16fa
33f59b1ba6b12c2dd3080b24830331c37bba9fe2
/Depend/Foundation/Distance/Wm4DistLine3Rectangle3.h
f785db5ce57a05b54b33db7407b1df06679c9aaa
[]
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
2,067
h
// 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. #ifndef WM4DISTLINE3RECTANGLE3_H #define WM4DISTLINE3RECTANGLE3_H #include "Wm4FoundationLIB.h" #include "Wm4Distance.h" #include "Wm4Line3.h" #include "Wm4Rectangle3.h" namespace Wm4 { template <class Real> class WM4_FOUNDATION_ITEM DistLine3Rectangle3 : public Distance<Real,Vector3<Real> > { public: DistLine3Rectangle3 (const Line3<Real>& rkLine, const Rectangle3<Real>& rkRectangle); // object access const Line3<Real>& GetLine () const; const Rectangle3<Real>& GetRectangle () const; // static distance queries virtual Real Get (); virtual Real GetSquared (); // function calculations for dynamic distance queries virtual Real Get (Real fT, const Vector3<Real>& rkVelocity0, const Vector3<Real>& rkVelocity1); virtual Real GetSquared (Real fT, const Vector3<Real>& rkVelocity0, const Vector3<Real>& rkVelocity1); // Information about the closest points. Real GetLineParameter () const; Real GetRectangleCoordinate (int i) const; private: using Distance<Real,Vector3<Real> >::m_kClosestPoint0; using Distance<Real,Vector3<Real> >::m_kClosestPoint1; const Line3<Real>& m_rkLine; const Rectangle3<Real>& m_rkRectangle; // Information about the closest points. Real m_fLineParameter; // closest0 = line.origin+param*line.direction Real m_afRectCoord[2]; // closest1 = rect.center+param0*rect.dir0+ // param1*rect.dir1 }; typedef DistLine3Rectangle3<float> DistLine3Rectangle3f; typedef DistLine3Rectangle3<double> DistLine3Rectangle3d; } #endif
[ "yf.flagship@e79fdf7c-a9d8-11de-b950-3d5b5f4ea0aa" ]
[ [ [ 1, 66 ] ] ]
a1f4ef34bae97a569380397fef2c8b63425cdd19
2dbbca065b62a24f47aeb7ec5cd7a4fd82083dd4
/OUAN/OUAN/Src/Graphics/RenderComponent/RenderComponentLight.h
b4db8aba59f9d92c8870162faf357cc5be027948
[]
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
931
h
#ifndef RenderComponentLightH_H #define RenderComponentLightH_H #include "RenderComponent.h" namespace OUAN { class RenderComponentLight : public RenderComponent { private: Ogre::Light * mLight; public: RenderComponentLight(const std::string& type=""); ~RenderComponentLight(); Ogre::Light * getLight() const; void setLight(Ogre::Light *); void setVisible(bool visible); void setDiffuseColor(ColourValue colour); void setSpecularColor(ColourValue colour); void setDirection(Vector3 direction); }; class TRenderComponentLightParameters: public TRenderComponentParameters { public: TRenderComponentLightParameters(); ~TRenderComponentLightParameters(); Ogre::Light::LightTypes lighttype; ColourValue diffuse; ColourValue specular; Vector3 direction; bool castshadows; Vector3 lightrange; Vector4 attenuation; Real power; }; } #endif
[ "juanj.mostazo@1610d384-d83c-11de-a027-019ae363d039", "wyern1@1610d384-d83c-11de-a027-019ae363d039", "ithiliel@1610d384-d83c-11de-a027-019ae363d039" ]
[ [ [ 1, 18 ], [ 26, 45 ] ], [ [ 19, 22 ], [ 24, 25 ] ], [ [ 23, 23 ] ] ]
316dbf1ccf591955118f7f7c708053979bcbdfcc
3d9e738c19a8796aad3195fd229cdacf00c80f90
/src/geometries/power_crust_3/Classified_vertex_base_3.h
c696423d07560c4fd90339b89ff2b2718126be42
[]
no_license
mrG7/mesecina
0cd16eb5340c72b3e8db5feda362b6353b5cefda
d34135836d686a60b6f59fa0849015fb99164ab4
refs/heads/master
2021-01-17T10:02:04.124541
2011-03-05T17:29:40
2011-03-05T17:29:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,340
h
/* This source file is part of Mesecina, a software for visualization and studying of * the medial axis and related computational geometry structures. * More info: http://www.agg.ethz.ch/~miklosb/mesecina * Copyright Balint Miklos, Applied Geometry Group, ETH Zurich * * $Id: Classified_vertex_base_3.h 365 2008-06-14 15:07:42Z miklosb $ */ #ifndef MESECINA_CLASSIFIED_VERTEX_BASE_3_H #define MESECINA_CLASSIFIED_VERTEX_BASE_3_H #include <CGAL/Triangulation_vertex_base_3.h> template < class Gt, class Vb = CGAL::Triangulation_vertex_base_3<Gt> > class Classified_vertex_base_3 : public Vb { typedef Vb Base; public: typedef typename Vb::Vertex_handle Vertex_handle; typedef typename Vb::Cell_handle Cell_handle; typedef typename Vb::Point Point_3; typedef typename Gt::Vector_3 Vector_3; template < typename TDS2 > struct Rebind_TDS { typedef typename Vb::template Rebind_TDS<TDS2>::Other Vb2; typedef Classified_vertex_base_3<Gt,Vb2> Other; }; private: Cell_handle pole_plus; Cell_handle pole_minus; float poles_confidence; Vector_3 plus_pole_direction; bool convex_hull; public: Classified_vertex_base_3() : Base(), pole_minus(0), pole_plus(0), poles_confidence(0), convex_hull(false), plus_pole_direction(CGAL::NULL_VECTOR) {} Classified_vertex_base_3(const Point_3 & p) : Base(p), pole_minus(0), pole_plus(0), poles_confidence(0), convex_hull(false), plus_pole_direction(CGAL::NULL_VECTOR) {} Classified_vertex_base_3(const Point_3 & p, Cell_handle f) : Base(f,p), pole_minus(0), pole_plus(0), poles_confidence(0), convex_hull(false), plus_pole_direction(CGAL::NULL_VECTOR) {} // Classified_vertex_base_3(Face_handle f) : Base(f), inner_pole(0), outer_pole(0), convex_hull(false) {} void set_pole_plus(const Cell_handle f) { assert(f!=0); pole_plus = f;} Cell_handle get_pole_plus() {return pole_plus; } void set_pole_minus(const Cell_handle f) {assert(f!=0); pole_minus = f;} Cell_handle get_pole_minus() {return pole_minus; } Cell_handle get_opposite_pole(Cell_handle c) { if (c==pole_plus) return pole_minus; if (c==pole_minus) return pole_plus; bool we_try_to_get_opposite_pole_with_invalid_cell = false; assert(we_try_to_get_opposite_pole_with_invalid_cell); return 0; } Cell_handle get_opposite_pole(Classified_vertex_base_3* c) { if (c==&(*pole_plus)) return pole_minus; if (c==&(*pole_minus)) return pole_plus; bool we_try_to_get_opposite_pole_with_invalid_cell = false; assert(we_try_to_get_opposite_pole_with_invalid_cell); return 0; } Cell_handle get_pole(Voronoi_classification c) { if (pole_plus!=0 && pole_plus->get_classification()==c) return pole_plus; if (pole_minus!=0 && pole_minus->get_classification()==c) return pole_minus; return 0; } void set_plus_pole_direction(const Vector_3 &v) { plus_pole_direction = v; } Vector_3 get_plus_pole_direction() { return plus_pole_direction; } void set_poles_confidence(const float &v) { poles_confidence = v; } float get_poles_confidence() { return poles_confidence; } bool is_on_convex_hull() { return convex_hull; } void set_on_convex_hull(bool f) { convex_hull = f; } }; #endif //MESECINA_CLASSIFIED_VERTEX_BASE_3_H
[ "balint.miklos@localhost" ]
[ [ [ 1, 82 ] ] ]
461e7cf5e66973304ec9cd57d1b44cf80f5b6eab
e1d76663bb020dc27abb53c8f8bb979b4738373f
/source/support/library/stdlib.cc
b1e44b69484066ba7313823b23ee9d739eef79e4
[]
no_license
fanopi/autoFloderSync
97e29f9aa24bc8bf78aa8325996e176572f46f8a
5232e01f43c9cc31df349a8b474c5d35a1e92ac5
refs/heads/master
2020-06-03T15:28:13.583695
2011-09-19T13:52:25
2011-09-19T13:52:25
2,338,869
0
0
null
null
null
null
GB18030
C++
false
false
7,504
cc
/* * stdlib.cc * 增强的内存分配器 * 1)当开启__MEMORY_DEBUG__时,可以自动记录内存分配的对象和文件,判断其是否成功的释放了所分配的内存。 * 2)采用类似于SGI STL 的内存分配方式来对内存进行管理,当分配的内存较小时,可以有效的避免内存碎片。 * Created on: 2011-4-11 * Author: FanOpi */ #include <stdlib.h> #include "stdlib.h" #include <assert.h> #define __MEMORY_DEBUG__ #ifdef __MEMORY_DEBUG__ #include "../support/memoryleak/memoryleaktrace.h" #endif namespace YF{ #if 0 #ifndef THROW_BAD_ALLOC #define THROW_BAD_ALLOC #endif void* malloc(size_t size, const YFCHAR* file, int line){ #ifdef __MEMORY_DEBUG__ void* p_address = DefaultAlloc::Allocate(size); MemoryLeakTrace* p_memoryLeakTrace = MemoryLeakTrace::GetMemoryLeakTrace(); p_memoryLeakTrace->Trace(MEMORY_MALLOC, p_address, size, file, line); return p_address; #else return ::malloc(size); #endif } void free(void* memory){ #ifdef __MEMORY_DEBUG__ MemoryLeakTrace* p_memoryLeakTrace = MemoryLeakTrace::GetMemoryLeakTrace(); size_t size = p_memoryLeakTrace->Detrace(MEMORY_FREE, memory); DefaultAlloc::Deallocate(memory, size); #else ::free(memory); #endif } void* operator new(size_t size, const YFCHAR* file, int line){ #ifdef __MEMORY_DEBUG__ void* p_address = DefaultAlloc::Allocate(size); MemoryLeakTrace* p_memoryLeakTrace = MemoryLeakTrace::GetMemoryLeakTrace(); p_memoryLeakTrace->Trace(MEMORY_NEW, p_address, size, file, line); return p_address; #else #endif } void* operator new[](size_t size, const YFCHAR* file, int line){ #ifdef __MEMORY_DEBUG__ void* p_address = DefaultAlloc::Allocate(size); MemoryLeakTrace* p_memoryLeakTrace = MemoryLeakTrace::GetMemoryLeakTrace(); p_memoryLeakTrace->Trace(MEMORY_NEW, p_address, size, file, line); return p_address; #else #endif } void operator delete(void *memory){ #ifdef __MEMORY_DEBUG__ MemoryLeakTrace* p_memoryLeakTrace = MemoryLeakTrace::GetMemoryLeakTrace(); size_t size = p_memoryLeakTrace->Detrace(MEMORY_DELETE, memory); DefaultAlloc::Deallocate(memory, size); #else #endif } void operator delete[](void *memory){ #ifdef __MEMORY_DEBUG__ MemoryLeakTrace* p_memoryLeakTrace = MemoryLeakTrace::GetMemoryLeakTrace(); size_t size = p_memoryLeakTrace->Detrace(MEMORY_DELETE, memory); DefaultAlloc::Deallocate(memory, size); #else #endif } //////////////////////////////////////////////////////////////////////////////// /// class ChunkMalloc /// void* (*ChunkAlloc::ChunkAllocOomHandle_)(); void* ChunkAlloc::OomAlloc(size_t n){ void* (*myMallocHandle)(); void* result; for( ; ; ){ myMallocHandle = ChunkAllocOomHandle_; if (static_cast<void* (*)()>(NULL) == myMallocHandle){ THROW_BAD_ALLOC; } (* myMallocHandle)(); result = ::malloc(n); if(NULL != result) return result; } } void* ChunkAlloc::OomRealloc(void* p, size_t newSize){ void* (*myMallocHandle)(); void* result; for( ; ; ){ myMallocHandle = ChunkAllocOomHandle_; if (static_cast<void* (*)()>(NULL) == myMallocHandle){ THROW_BAD_ALLOC; // TODO(fpj): } (* myMallocHandle)(); result = ::realloc(p, newSize); if(NULL != result) return result; } }/// class ChunkMalloc /// /// class MemoryPoolMalloc /// char* DefaultAlloc::s_start_free_ = NULL; char* DefaultAlloc::s_end_free_ = NULL; size_t DefaultAlloc::s_heap_size_ = NULL; DefaultAlloc::FreeListEntry* DefaultAlloc::free_list_[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; void* DefaultAlloc::Allocate(size_t alloc_size){ FreeListEntry** pp_my_free_list; FreeListEntry* p_result; if (alloc_size > (size_t)_MAX_BYTES) return (ChunkAlloc::Allocate(alloc_size)); pp_my_free_list = free_list_ + FREELIST_INDEX(alloc_size); p_result = *pp_my_free_list; if (NULL == p_result){ void *p_rtn = DefaultAlloc::Refill(ROUND_UP(alloc_size)); return p_rtn; }else{ *pp_my_free_list = p_result->p_next_entry; return static_cast<void*>(p_result); } } void DefaultAlloc::Deallocate(void* p_dealloc, size_t dealloc_size){ FreeListEntry** pp_my_free_list; FreeListEntry* p_deallocate = static_cast<FreeListEntry*>(p_dealloc); if (dealloc_size > (size_t)_MAX_BYTES) return ChunkAlloc::Deallocate(p_dealloc, dealloc_size); pp_my_free_list = free_list_ + FREELIST_INDEX(dealloc_size); p_deallocate->p_next_entry = *pp_my_free_list; (*pp_my_free_list)->p_next_entry = p_deallocate; } void* DefaultAlloc::Reallocate(void* p, size_t /*old size*/, size_t newSize){ // TODO(fpj): return NULL; } void* DefaultAlloc::Refill(size_t refill_list_entry_size){ int r_list_entry_number = 20; char* p_chunk = ChunkAlloc(refill_list_entry_size, r_list_entry_number); if (0 == r_list_entry_number) return NULL; if (1 == r_list_entry_number) return p_chunk; FreeListEntry* p_current_entry; FreeListEntry* p_next_entry; FreeListEntry* volatile* pp_my_free_list = free_list_ + FREELIST_INDEX(refill_list_entry_size); *pp_my_free_list = p_next_entry = (FreeListEntry*)(p_chunk + refill_list_entry_size); for(int entryIndex = 1; ; entryIndex++){ p_current_entry = p_next_entry; p_next_entry = (FreeListEntry*)((char*)(p_next_entry) + refill_list_entry_size); if (r_list_entry_number - 1 == entryIndex){ p_current_entry->p_next_entry = NULL; break; }else{ p_current_entry->p_next_entry = p_next_entry; }//~ if (r_list_.... }//~ for(int entryIndex.... return (FreeListEntry*)(p_chunk); } char* DefaultAlloc::ChunkAlloc(size_t refill_list_entry_size, int& r_list_entry_number){ char* p_result; size_t total_bytes = refill_list_entry_size * r_list_entry_number; size_t left_bytes = s_end_free_ - s_start_free_; if (left_bytes > total_bytes){ p_result = s_start_free_; s_start_free_ += total_bytes; return p_result; }else if (left_bytes >= refill_list_entry_size){ r_list_entry_number = left_bytes / refill_list_entry_size; p_result = s_start_free_; s_start_free_ += total_bytes; return p_result; }else{ size_t bytes_to_get = 2 * total_bytes + ROUND_UP(s_heap_size_>>4); if (left_bytes > 0){ FreeListEntry** pp_my_free_list = free_list_ + FREELIST_INDEX(left_bytes); ((FreeListEntry*)s_start_free_)->p_next_entry = *pp_my_free_list; *pp_my_free_list = (FreeListEntry*)s_start_free_; } s_start_free_ = (char*)malloc(bytes_to_get); if (NULL == s_start_free_){ FreeListEntry** pp_m_free_list; FreeListEntry* p_list_entry; for(int list_entry_size = refill_list_entry_size; list_entry_size <= _MAX_BYTES; list_entry_size+=_ALIGN){ pp_m_free_list = free_list_ + FREELIST_INDEX(list_entry_size); p_list_entry = *pp_m_free_list; if (NULL != p_list_entry){ *pp_m_free_list = p_list_entry->p_next_entry; s_start_free_ = (char*)p_list_entry; s_end_free_ = s_start_free_ + list_entry_size; return ChunkAlloc(refill_list_entry_size, r_list_entry_number); } }//~ for(i = size; i.... s_end_free_ = 0; s_start_free_ = (char*)ChunkAlloc::Allocate(bytes_to_get); }//~ if (NULL == st.... s_heap_size_ += bytes_to_get; s_end_free_ = s_start_free_ + bytes_to_get; return ChunkAlloc(refill_list_entry_size, r_list_entry_number); }//~else }/// class MemoryPoolMalloc /// #endif } /// namespace YF
[ [ [ 1, 234 ] ] ]
2447eaa9fdb916e9410cbd7845de1525eb2e52f5
4a2b2d6d07714e82ecf94397ea6227edbd7893ad
/Curl/TMOC/TestLogonDlg.cpp
1deb28362b1bdf0a337d1d0cc02284476849eaf1
[]
no_license
intere/tmee
8b0a6dd4651987a580e3194377cfb999e9615758
327fed841df6351dc302071614a9600e2fa67f5f
refs/heads/master
2021-01-25T07:28:47.788280
2011-07-21T04:24:31
2011-07-21T04:24:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,427
cpp
// TestLogonDlg.cpp : implementation file // #include "stdafx.h" #include "TalkMasterConsole.h" #include "TalkMasterConsoleDlg.h" #include "TestLogonDlg.h" #include ".\testlogondlg.h" // CTestLogonDlg dialog IMPLEMENT_DYNAMIC(CTestLogonDlg, CDialog) CTestLogonDlg::CTestLogonDlg(CWnd* pParent /*=NULL*/) : CDialog(CTestLogonDlg::IDD, pParent) , m_csTestLogonName(_T("")) , m_csTestLogonPassword(_T("")) , bRunning(FALSE) , testState(NULL) { } CTestLogonDlg::~CTestLogonDlg() { } void CTestLogonDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_EDIT_TEST_LOGON_NAME, m_editTestLogonName); DDX_Text(pDX, IDC_EDIT_TEST_LOGON_NAME, m_csTestLogonName); DDX_Control(pDX, IDC_EDIT_TEST_LOGON_PASSWORD, m_editTestLogonPassword); DDX_Text(pDX, IDC_EDIT_TEST_LOGON_PASSWORD, m_csTestLogonPassword); DDX_Control(pDX, IDC_BUTTON_TEST, m_btnLogonTest); } BEGIN_MESSAGE_MAP(CTestLogonDlg, CDialog) ON_WM_TIMER() ON_BN_CLICKED(IDC_BUTTON_TEST, OnBnClickedButtonTest) END_MESSAGE_MAP() // CTestLogonDlg message handlers BOOL CTestLogonDlg::OnInitDialog() { // loadAlternateResourceDLL(); CDialog::OnInitDialog(); m_editTestLogonName.SetFocus(); return FALSE; // return TRUE unless you set the focus to a control } void CTestLogonDlg::OnBnClickedButtonTest() { CTalkMasterConsoleDlg *dlg = (CTalkMasterConsoleDlg*)theApp.m_pMainWnd; if( !bRunning ) { testState = TEST_LOGON_STATE_IDLE; m_btnLogonTest.SetWindowText("Stop"); SetTimer( TIMER_LOGON_TEST, 100, NULL ); bRunning = TRUE; } else { bRunning = FALSE; m_btnLogonTest.SetWindowText("Test"); SetTimer( TIMER_LOGON_TEST, 100, NULL ); // Speed it up so we don't have to wait 5 seconds for it to stop } } void CTestLogonDlg::OnTimer(UINT nIDEvent) { CString csTitle; static int guard=0; if( ++guard > 1 ) { --guard; return; } if (nIDEvent == TIMER_LOGON_TEST ) { doLogonTest(); } CDialog::OnTimer(nIDEvent); --guard; } void CTestLogonDlg::doLogonTest() { int error; CTalkMasterConsoleDlg *dlg = (CTalkMasterConsoleDlg*)theApp.m_pMainWnd; UpdateData(); switch(testState) { case TEST_LOGON_STATE_IDLE: m_uFlags = 0; // We want cdecl calls to our callback error = dlg->m_DAOpen( &m_hDA, &m_uFlags, &CallBackTest, NULL ); if( error == ERROR_SUCCESS ) { m_sockaddr_in.sin_family = AF_INET; m_sockaddr_in.sin_port = htons(theApp.UserOptions.IPPort); m_sockaddr_in.sin_addr.S_un.S_addr = inet_addr(theApp.UserOptions.IPAddress); error = dlg->m_DAStart( m_hDA, &m_sockaddr_in, THREAD_BASE_PRIORITY_MAX, m_csTestLogonName.GetBuffer(), m_csTestLogonPassword.GetBuffer(), m_szUserName, &m_uRights ); if( error == ERROR_SUCCESS ) { testState = TEST_LOGON_STATE_STARTED; SetTimer( TIMER_LOGON_TEST, 5000, NULL ); } else { dlg->m_DAClose( m_hDA ); m_btnLogonTest.SetWindowText("Test"); KillTimer(TIMER_LOGON_TEST); bRunning = FALSE; MessageBox("Logon ID or Password Invalid", "Shutting down test"); } } else { m_btnLogonTest.SetWindowText("Test"); KillTimer(TIMER_LOGON_TEST); bRunning = FALSE; MessageBox("DAOpen Failed to Open", "Major Issue Found"); } break; case TEST_LOGON_STATE_STARTED: dlg->m_DAStop( m_hDA ); dlg->m_DAClose( m_hDA ); m_hDA = NULL; if( !bRunning ) { KillTimer(TIMER_LOGON_TEST); m_btnLogonTest.SetWindowText("Test"); } testState = TEST_LOGON_STATE_IDLE; break; } } void CallBackTest( int event, int socket, struct _iComStructure *pIcom, void *eventData, void *myData ) { CTalkMasterConsoleDlg *dlg = (CTalkMasterConsoleDlg*)theApp.m_pMainWnd; switch( event ) { case EVENT_PRINT_STRING: dlg->outputDebug((char *)eventData); break; } } void CTestLogonDlg::OnCancel() { if( bRunning ) { bRunning = FALSE; m_btnLogonTest.SetWindowText("Test"); SetTimer( TIMER_LOGON_TEST, 100, NULL ); // Speed it up so we don't have to wait 5 seconds for it to stop while( testState ) { DoEvents(); Sleep(100); } } CDialog::OnCancel(); } void CTestLogonDlg::DoEvents() { MSG msg; while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { TranslateMessage(&msg); DispatchMessage(&msg); } }
[ "intere@8c6822e2-464b-4b1f-8ae9-3c1f0a8e8225" ]
[ [ [ 1, 207 ] ] ]
244e9ef728910b67b9c52c284d1796160073409c
b2d46af9c6152323ce240374afc998c1574db71f
/cursovideojuegos/theflostiproject/3rdParty/boost/libs/regex/performance/time_pcre.cpp
22139e668c4cb99fd55cb85f47952b9b3673f18d
[ "BSL-1.0" ]
permissive
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
4,220
cpp
/* * * Copyright (c) 2002 * Dr 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) * */ #include <cassert> #include <cfloat> #include "regex_comparison.hpp" #ifdef BOOST_HAS_PCRE #include "pcre.h" #include <boost/timer.hpp> namespace pcr{ double time_match(const std::string& re, const std::string& text, bool icase) { pcre *ppcre; const char *error; int erroffset; int what[50]; boost::timer tim; int iter = 1; int counter, repeats; double result = 0; double run; if(0 == (ppcre = pcre_compile(re.c_str(), (icase ? PCRE_CASELESS | PCRE_ANCHORED | PCRE_DOTALL | PCRE_MULTILINE : PCRE_ANCHORED | PCRE_DOTALL | PCRE_MULTILINE), &error, &erroffset, NULL))) { free(ppcre); return -1; } pcre_extra *pe; pe = pcre_study(ppcre, 0, &error); if(error) { free(ppcre); free(pe); return -1; } do { tim.restart(); for(counter = 0; counter < iter; ++counter) { erroffset = pcre_exec(ppcre, pe, text.c_str(), text.size(), 0, 0, what, sizeof(what)/sizeof(int)); } result = tim.elapsed(); iter *= 2; }while(result < 0.5); iter /= 2; // repeat test and report least value for consistency: for(repeats = 0; repeats < REPEAT_COUNT; ++repeats) { tim.restart(); for(counter = 0; counter < iter; ++counter) { erroffset = pcre_exec(ppcre, pe, text.c_str(), text.size(), 0, 0, what, sizeof(what)/sizeof(int)); } run = tim.elapsed(); result = (std::min)(run, result); } free(ppcre); free(pe); return result / iter; } double time_find_all(const std::string& re, const std::string& text, bool icase) { pcre *ppcre; const char *error; int erroffset; int what[50]; boost::timer tim; int iter = 1; int counter, repeats; double result = 0; double run; int exec_result; int matches; if(0 == (ppcre = pcre_compile(re.c_str(), (icase ? PCRE_CASELESS | PCRE_DOTALL | PCRE_MULTILINE : PCRE_DOTALL | PCRE_MULTILINE), &error, &erroffset, NULL))) { free(ppcre); return -1; } pcre_extra *pe; pe = pcre_study(ppcre, 0, &error); if(error) { free(ppcre); free(pe); return -1; } do { int startoff; tim.restart(); for(counter = 0; counter < iter; ++counter) { matches = 0; startoff = 0; exec_result = pcre_exec(ppcre, pe, text.c_str(), text.size(), startoff, 0, what, sizeof(what)/sizeof(int)); while(exec_result >= 0) { ++matches; startoff = what[1]; exec_result = pcre_exec(ppcre, pe, text.c_str(), text.size(), startoff, 0, what, sizeof(what)/sizeof(int)); } } result = tim.elapsed(); iter *= 2; }while(result < 0.5); iter /= 2; if(result >10) return result / iter; result = DBL_MAX; // repeat test and report least value for consistency: for(repeats = 0; repeats < REPEAT_COUNT; ++repeats) { int startoff; matches = 0; tim.restart(); for(counter = 0; counter < iter; ++counter) { matches = 0; startoff = 0; exec_result = pcre_exec(ppcre, pe, text.c_str(), text.size(), startoff, 0, what, sizeof(what)/sizeof(int)); while(exec_result >= 0) { ++matches; startoff = what[1]; exec_result = pcre_exec(ppcre, pe, text.c_str(), text.size(), startoff, 0, what, sizeof(what)/sizeof(int)); } } run = tim.elapsed(); result = (std::min)(run, result); } return result / iter; } } #else namespace pcr{ double time_match(const std::string& re, const std::string& text, bool icase) { return -1; } double time_find_all(const std::string& re, const std::string& text, bool icase) { return -1; } } #endif
[ "ohernandezba@71d53fa2-cca5-e1f2-4b5e-677cbd06613a" ]
[ [ [ 1, 176 ] ] ]
662dde3e3450af118f487ddd3920747a0e6d212c
d4ba9775ead602c9f41e7859b956c0ac1efa2cfb
/src/framework-ActiveX/Js2nPropPage.h
a7c10da0eae144f602a72f4e64fbc6dc43908f18
[]
no_license
xgc820313/js2n
2460938a47e00a225e5c9a810285950b2d808756
77cec2ea39d465f98added96b61eab1ee30fd53a
refs/heads/master
2016-09-06T07:05:03.475054
2007-09-04T21:08:49
2007-09-04T21:08:49
38,345,093
0
0
null
null
null
null
UTF-8
C++
false
false
548
h
#pragma once // Js2nPropPage.h : Declaration of the CJs2nPropPage property page class. // CJs2nPropPage : See Js2nPropPage.cpp for implementation. class CJs2nPropPage : public COlePropertyPage { DECLARE_DYNCREATE(CJs2nPropPage) DECLARE_OLECREATE_EX(CJs2nPropPage) // Constructor public: CJs2nPropPage(); // Dialog Data enum { IDD = IDD_PROPPAGE_Js2n }; // Implementation protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support // Message maps protected: DECLARE_MESSAGE_MAP() };
[ "amnon.david@a65ff7ae-d338-0410-b7a2-59eabbc4e8c3" ]
[ [ [ 1, 28 ] ] ]
558fc85eb9ccfc13dc4fa88cf6a5c61945ee0a9c
57787ed92809cc6327f9e5d702d8e7a7d78060ee
/Image.h
41729066f8331fb54171f879823e987001078482
[]
no_license
oneamtu/CG1
beda02fad6549ec59d5998dbf0ded9345ee96305
3939f3129872174c29b858b714eea06f4dcc7db5
refs/heads/master
2021-01-02T08:10:15.985793
2010-11-10T13:48:30
2010-11-10T13:48:30
946,008
2
0
null
null
null
null
UTF-8
C++
false
false
1,610
h
/* * Image.h * * where all the projection magic happens * * Created on: Sep 30, 2010 * Author: oneamtu */ #ifndef IMAGE_H_ #define IMAGE_H_ #include "Common.h" #include <vector> #include <fstream> class Image; #include "Color.h" #include "Geometry.h" #include "Vector.h" #include "TriangleMesh.h" #include "Camera.h" using namespace MyMath; class Image { public: const static int height = 400; const static int width = 400; const static float Z_BUFFER_MAX = 10000.0f; private: Color _image[height * width]; float _zBuffer[height * width]; const Camera* _camera; public: Image(const Camera* c) { this->_camera = c; resetZBuffer(); } Vector3f projectVertexIntoViewVolume(const Vector3f* v); Vector2i projectVertexIntoPixel(const Vector3f* v); vector<Vector2i> projectTriangleIntoPixels( const Triangle* t, Shading shading); Vector2i convertFromViewVolumeToImage(const Vector3f* v); void projectVertices(const vector<Vertex> * vertices); void projectTriangleMesh(const TriangleMesh* trig); bool containsPoint(Vector2i p); void addPixel(Vector2i p, Color c); void output(const char * filename); void resetZBuffer() { for (int i = 0; i < width * height; i++) _zBuffer[i] = Z_BUFFER_MAX; } //getters const Color* getImageArray() const { return _image; } void clear() { for (int i = 0; i < height*width; i++) _image[i] = Color(); resetZBuffer(); } }; #endif /* IMAGE_H_ */
[ [ [ 1, 2 ], [ 6, 61 ], [ 63, 66 ], [ 73, 75 ] ], [ [ 3, 5 ], [ 62, 62 ] ], [ [ 67, 72 ] ] ]
c89809ab5de8083f591eb0fed0e97918483cc273
bad6dfe35e27195461f9a9606de4d9979d7ba000
/ocelot/ocelot/ir/test/SamplePTX.cpp
7dbc3c4a02a2c6eb7590ebe9fe08173610569b40
[]
no_license
antmanler/Benchmarking-CUDA
96e069151e9c87afedae806957e96d18fcf29a06
640232ac26e7610569cf3287831719310b8e05d1
refs/heads/master
2020-03-09T23:07:56.672057
2011-03-16T19:47:22
2011-03-16T19:47:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,456
cpp
/*! \file SamplePTX.cpp \author Andrew Kerr <[email protected]> \brief defines PTX programs useful for testing \date 24 Jan 2009 */ #include <string> #include <ocelot/ir/test/SamplePTX.h> using namespace std; using namespace ir; ////////////////////////////////////////////////////////////////////////////////////////////////// static ir::PTXStatement i_add(string d, string a, string b, ir::PTXOperand::DataType type = PTXOperand::f32) { PTXStatement state; state.directive = PTXStatement::Instr; state.instruction.opcode = PTXInstruction::Add; state.instruction.d.addressMode = PTXOperand::Register; state.instruction.d.identifier = d; state.instruction.d.type = type; state.instruction.a.addressMode = PTXOperand::Register; state.instruction.a.identifier = a; state.instruction.a.type = type; state.instruction.b.addressMode = PTXOperand::Register; state.instruction.b.identifier = b; state.instruction.b.type = type; return state; } static ir::PTXStatement i_mul(string d, string a, string b, ir::PTXOperand::DataType type = PTXOperand::f32) { PTXStatement state; state.directive = PTXStatement::Instr; state.instruction.opcode = PTXInstruction::Mul; state.instruction.d.addressMode = PTXOperand::Register; state.instruction.d.identifier = d; state.instruction.d.type = type; state.instruction.a.addressMode = PTXOperand::Register; state.instruction.a.identifier = a; state.instruction.a.type = type; state.instruction.b.addressMode = PTXOperand::Register; state.instruction.b.identifier = b; state.instruction.b.type = type; return state; } static ir::PTXStatement i_sub(string d, string a, string b, ir::PTXOperand::DataType type = PTXOperand::f32) { PTXStatement state; state.directive = PTXStatement::Instr; state.instruction.opcode = PTXInstruction::Sub; state.instruction.d.addressMode = PTXOperand::Register; state.instruction.d.identifier = d; state.instruction.d.type = type; state.instruction.a.addressMode = PTXOperand::Register; state.instruction.a.identifier = a; state.instruction.a.type = type; state.instruction.b.addressMode = PTXOperand::Register; state.instruction.b.identifier = b; state.instruction.b.type = type; return state; } static ir::PTXStatement i_bra(string target) { PTXStatement state; state.directive = PTXStatement::Instr; state.instruction.opcode = PTXInstruction::Bra; //state.instruction.target.identifier = target; return state; } static ir::PTXStatement label(string name) { PTXStatement state; state.directive = PTXStatement::Label; state.name = name; return state; } ////////////////////////////////////////////////////////////////////////////////////////////////// /*! */ ir::Kernel::PTXStatementVector test::Sample_cfg() { ir::Kernel::PTXStatementVector ptx; ptx.push_back( i_add("$r2", "$r0", "$r1") ); ptx.push_back( i_sub("$r2", "$r0", "$r1") ); ptx.push_back( i_bra("$L_01") ); ptx.push_back( i_add("$r3", "$r2", "$r1") ); ptx.push_back( label("$L_01") ); ptx.push_back( i_sub("$r2", "$r3", "$r1") ); ptx.push_back( label("$L_02") ); ptx.push_back( i_add("$r7", "$r2", "$r2") ); ptx.push_back( i_bra("$L_01") ); ptx.push_back( i_add("$r2", "$r7", "$r7") ); return ptx; } ////////////////////////////////////////////////////////////////////////////////////////////////// /*! Constructs a kernel with divergent control flow */ ir::Kernel::PTXStatementVector test::Sample_Divergence() { ir::Kernel::PTXStatementVector ptx; ptx.push_back( label("L01") ); ptx.push_back( i_add("r1", "r2", "r3")); ptx.push_back( i_sub("r1", "r1", "r1")); ptx.push_back(i_bra("L02")); ptx.push_back( label("L03") ); ptx.push_back( i_add("r3", "r2", "r1")); ptx.push_back( i_bra("L07")); ptx.push_back( label("L02")); ptx.push_back( i_add("r2", "r2", "r2")); ptx.push_back( i_add("r2", "r3", "r3")); ptx.push_back( i_bra("L05")); ptx.push_back( label("L04") ); ptx.push_back( i_sub("r4", "r2", "r1")); ptx.push_back( i_bra("L06")); ptx.push_back(label("L05")); ptx.push_back(i_sub("r5", "r5", "r5")); ptx.push_back(i_mul("r5", "r5", "r6")); ptx.push_back(label("L06")); ptx.push_back(i_mul("r6", "r6", "r6")); ptx.push_back( label("L07") ); ptx.push_back(i_add("r7", "r7", "r7")); ptx.push_back(i_bra("L01")); return ptx; } //////////////////////////////////////////////////////////////////////////////////////////////////
[ "fccoelho@tiamat.(none)" ]
[ [ [ 1, 165 ] ] ]
bafb1ec85de104cd0744e1d3c712bd31d8c42c38
7c4e18dc769ebc3b87d6f45d82812984b7eb6608
/source/convert.h
1dc5c942ac2574027897aa39b807e18a0f4d80e7
[]
no_license
ishahid/smartmap
5bce0ca5690efb5b8e28c561d86321c8c5dcc794
195b1ebb03cd786d38167d622e7a46c7603e9094
refs/heads/master
2020-03-27T05:43:49.428923
2010-07-06T08:24:59
2010-07-06T08:24:59
10,093,280
0
0
null
null
null
null
UTF-8
C++
false
false
850
h
#ifndef CONVERT_H #define CONVERT_H #include "point.h" #include <qpainter.h> #include <qcolor.h> #include <qmessagebox.h> class Convert { protected: static int screenx; static int screeny; static int xmax; static int xmin; static int ymax; static int ymin; static int dx; static int dy; static double centerx; static double centery; static double diffx; static double diffy; Convert(); public: static void init( int width=1024, int height=768 ); static void reinit( int width, int height ); static void setCenter( double x, double y ); static int degreeToPixelX( double degree, double sf ); static int degreeToPixelY( double degree, double sf ); static double pixelToDegreeX( int pixel, double sf ); // Longitude static double pixelToDegreeY( int pixel, double sf ); // Latitude }; #endif
[ "none@none" ]
[ [ [ 1, 36 ] ] ]
92f4862d308702f13d15ad1316c9960200a81134
63d8291850783397b2149b4f38d0b1919bf87e5c
/PobotKey/Projects/Processing/libraries/rainbowduino/firmware/rainbowduino/Rainbowduino.h
640aabf6743fd8a697f22c42aafd83ece1a62795
[]
no_license
JulienHoltzer/Pobot-Playground
8d0cb50edc5846d7fe717f467d5a9f07ad7e7979
a4a9c6af9c8b2fec8e5782be86427620843f38df
refs/heads/master
2021-05-28T04:54:03.737479
2011-11-11T10:32:43
2011-11-11T10:32:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,371
h
/* * Rainbowduino.h version 2.0 - A driver to run Seeedstudio 8x8 RBG LED Matrix * Based on Rainbow.h by Seedstudio.com -> http://www.seeedstudio.com/depot/rainbowduino-led-driver-platform-plug-and-shine-p-371.html * Copyright (c) 2009 Tobias Bielohlawek -> http://www.rngtng.com * */ #ifndef RAINBOWDUINO_h #define RAINBOWDUINO_h // include types & constants of Wiring core API #include <WProgram.h> //============================================= //MBI5168 #define SH_DIR DDRC #define SH_PORT PORTC #define SH_BIT_SDI 0x01 #define SH_BIT_CLK 0x02 #define SH_BIT_LE 0x04 #define SH_BIT_OE 0x08 //============================================ #define clk_rising {SH_PORT &= ~SH_BIT_CLK; SH_PORT |= SH_BIT_CLK; } #define le_high {SH_PORT |= SH_BIT_LE; } #define le_low {SH_PORT &= ~SH_BIT_LE; } #define enable_oe {SH_PORT &= ~SH_BIT_OE; } #define disable_oe {SH_PORT |= SH_BIT_OE; } #define shift_data_1 {SH_PORT |= SH_BIT_SDI;} #define shift_data_0 {SH_PORT &= ~SH_BIT_SDI;} #define NUM_LINES 8 #define NUM_ROWS 24 // 3 BYTES per ROW x 8 Lines = 24Bytes #define MAX_NUM_FRAMES 10 // = 240Bytes #define NUM_LEVEL 16 class Rainbowduino { public: byte frame_buffer[NUM_ROWS*MAX_NUM_FRAMES]; // [FRAME_BUFFER_SIZE]; //size of EEPROM -> to read faster?? Rainbowduino(); ///////////////////////// void reset(); byte get_num_frames(); void set_current_frame_nr(byte frame_nr); byte get_current_frame_nr(); void next_frame(); ///////////////////////// void set_frame(byte frame_nr, byte* data); void set_frame_row(byte frame_nr, byte row, byte data); byte get_frame_row(byte frame_nr, byte row); //to set all 3 colors of each line void set_frame_line(byte frame_nr, byte x, byte red, byte green, byte blue); //to set all 3 colors of each pixel void set_frame_pixel(byte frame_nr, byte x, byte y, byte red, byte green, byte blue); ///////////////////////// void draw(byte level = 8); private: byte num_frames; byte current_frame_nr; word current_frame_offset; word off; //buffer offset volatile byte current_row; volatile byte current_level; void draw_row(byte row, byte level, byte r, byte b, byte g); void draw_color(byte c); void enable_row(byte row); }; #endif //RAINBOWDUINO.h
[ "julien.holtzer@c631b436-7905-11de-aab9-69570e6b7754" ]
[ [ [ 1, 85 ] ] ]
f0d3fe4cee6ba4b044251321e9307cd619098a04
cd0987589d3815de1dea8529a7705caac479e7e9
/webkit/WebKitTools/QtTestBrowser/webinspector.h
cecdb32bc8aec0669b3f488a047252dd830db3c4
[]
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,001
h
/* * Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies) * * 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 COMPUTER, INC. ``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 COMPUTER, INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef webinspector_h #define webinspector_h #include <QtGui> #include "qwebinspector.h" class WebInspector : public QWebInspector { Q_OBJECT public: WebInspector(QWidget* parent) : QWebInspector(parent) {} signals: void visibleChanged(bool nowVisible); protected: void showEvent(QShowEvent* event) { QWebInspector::showEvent(event); emit visibleChanged(true); } void hideEvent(QHideEvent* event) { QWebInspector::hideEvent(event); emit visibleChanged(false); } }; #endif
[ [ [ 1, 56 ] ] ]
97adcb0df260ec40890065e81542713bfe202ed4
a0bc9908be9d42d58af7a1a8f8398c2f7dcfa561
/SlonEngine/src/Log/Detail/Stream.cpp
e59de2ac29eb9581298ddf76af35a64ba4958199
[]
no_license
BackupTheBerlios/slon
e0ca1137a84e8415798b5323bc7fd8f71fe1a9c6
dc10b00c8499b5b3966492e3d2260fa658fee2f3
refs/heads/master
2016-08-05T09:45:23.467442
2011-10-28T16:19:31
2011-10-28T16:19:31
39,895,039
0
0
null
null
null
null
UTF-8
C++
false
false
1,172
cpp
#include "stdafx.h" #include "Log/Detail/Stream.h" namespace slon { namespace log { log::ostream& operator << (log::ostream& os, const indent& it) { os.flush(); (*os).set_indent(it); return os; } std::ostream& operator << (std::ostream& os, const indent& it) { if ( log::ostream* fos = dynamic_cast<log::ostream*>(&os) ) { *fos << it; } return os; } log::ostream& operator << (log::ostream& os, const unindent&) { os.flush(); (*os).unindent(); return os; } std::ostream& operator << (std::ostream& os, const unindent& uit) { if ( log::ostream* fos = dynamic_cast<log::ostream*>(&os) ) { *fos << uit; } return os; } log::ostream& operator << (log::ostream& os, const skip_info& si) { os.flush(); if (si.skip) { os->set_flags(os->get_flags() | logger_sink::SKIP_INFO); } else { os->set_flags(os->get_flags() & ~logger_sink::SKIP_INFO); } return os; } std::ostream& operator << (std::ostream& os, const skip_info& si) { if ( log::ostream* fos = dynamic_cast<log::ostream*>(&os) ) { *fos << si; } return os; } } // namespace log } // namespace slon
[ "devnull@localhost" ]
[ [ [ 1, 61 ] ] ]
336238f9f3621fe67f6851f7f38cf7787d31aff3
bdb1e38df8bf74ac0df4209a77ddea841045349e
/CapsuleSortor/Version 1.0 -2.0/CapsuleSortor-10-11-14-1/ImageCard/GenieCard.h
c5f04d0560574d07b5fd6a9de128176ac4cf91d3
[]
no_license
Strongc/my001project
e0754f23c7818df964289dc07890e29144393432
07d6e31b9d4708d2ef691d9bedccbb818ea6b121
refs/heads/master
2021-01-19T07:02:29.673281
2010-12-17T03:10:52
2010-12-17T03:10:52
49,062,858
0
1
null
2016-01-05T11:53:07
2016-01-05T11:53:07
null
GB18030
C++
false
false
2,445
h
// GenieCard.h : Interface of the ProciliCard class // // Copyright (c) 2007 zhao_fsh Zibo Creative Computor CO.,LTD ////////////////////////////////////////////////////////////////////////// // // Module :ImageCard // Create Date : 2008.01.24 // //////////////////////////////////////////////////////////////////// // Example begin // // // GenieCard card; // card.Open(); // card.Live(); // { 线程自动调用 OnAcquistion(), 把图像处理的函数放于此成员函数中 } // card.UnLive(); // card.Close(); // // Example end ///////////////////////////////////////////////////////////////////// // A simple tool for Genie Camera(rgb image card) #ifndef GENIECARD_H #define GENIECARD_H #include "TImageCard.h" #include "TAllocTmpl.h" #include "Genie/Include/SapClassBasic.h" #include "TEvent.h" class GenieCard : public TImageCard { public: GenieCard(); virtual ~GenieCard(); public: bool Open (); //open the card bool Open (const char * camTag); //open the card bool Close (); //close the card bool StartLive (); //start acquistion bool StopLive (); //stop acquistion size_t FrameInterval ( ); //get frame interval bool GrabTimeout (size_t ms); //set grab timeout; bool SetROI (size_t startX, size_t startY, size_t width, size_t height); bool SetExpTime (size_t expTime); bool SetGain (size_t gain); bool GetROI (size_t &startX, size_t &startY, size_t &width, size_t &height); bool GetExpTime (size_t &expTime); bool GetGain (size_t &gain); bool SetGrabMode(EnumGrabMode eMode); bool SaveSetting(); TAlloc<PixelMem> GetPixelMem(); //Get Pixels memery void * GetPixelMemBase () const; bool RegisterProcFunc (REGCallbackFunc* func, void *param); private: GenieCard(const GenieCard& src); GenieCard& operator= (const GenieCard& src); bool CreateObjects(); bool DeleteObjects(); static void XferCallback(SapXferCallbackInfo *pInfo); private: enum { CAMBUFFCOUNT = 3 }; SapAcqDevice *m_acqDevice; SapBuffer *m_buffers; SapTransfer *m_xfer; unsigned int m_grabTimeout; //ms(单位:毫秒) unsigned int m_linePeriod; //us(单位:微秒) TEvent m_grabedEvent; private: void* m_pixelMemBase; REGCallbackFunc* RegisteredFunc; void* m_regFuncParam; double m_stampInterval; }; #endif //GENIECARD_H
[ "vincen.cn@66f52ff4-a261-11de-b161-9f508301ba8e" ]
[ [ [ 1, 98 ] ] ]
c3b252541c3deca776378bc15df49c7231db372a
4108f81fe388a13f5b17db9210a0477db30162e7
/capixx/capimsg.hxx
64d6d667158ee2aee9d15cab60a445af6fbf54bd
[]
no_license
BackupTheBerlios/capircvd
e8edb52809131ffcc8d755f7ad85b9f6b66ffdd7
6cdc97f3b87811116127276a4a6ba3aac1f178d5
refs/heads/master
2016-09-05T12:50:28.804944
2001-04-03T18:44:12
2001-04-03T18:44:12
40,044,021
0
0
null
null
null
null
UTF-8
C++
false
false
12,226
hxx
#ifndef CAPIMSG_H #define CAPIMSG_H #define UNUSED__ALERT_CONF 0x0181 #define UNUSED__ALERT_REQ 0x0180 #define UNUSED__CONNECT_ACTIVE_IND 0x0382 #define UNUSED__CONNECT_ACTIVE_RESP 0x0383 #define UNUSED__CONNECT_B3_ACTIVE_IND 0x8382 #define UNUSED__CONNECT_B3_ACTIVE_RESP 0x8383 #define UNUSED__CONNECT_B3_CONF 0x8281 #define UNUSED__CONNECT_B3_IND 0x8282 #define UNUSED__CONNECT_B3_REQ 0x8280 #define UNUSED__CONNECT_B3_RESP 0x8283 #define UNUSED__CONNECT_B3_T90_ACTIVE_IND 0x8882 #define UNUSED__CONNECT_B3_T90_ACTIVE_RESP 0x8883 #define UNUSED__CONNECT_CONF 0x0281 #define UNUSED__CONNECT_IND 0x0282 #define UNUSED__CONNECT_REQ 0x0280 #define UNUSED__CONNECT_RESP 0x0283 #define UNUSED__DATA_B3_CONF 0x8681 #define UNUSED__DATA_B3_IND 0x8682 #define UNUSED__DATA_B3_REQ 0x8680 #define UNUSED__DATA_B3_RESP 0x8683 #define UNUSED__DISCONNECT_B3_CONF 0x8481 #define UNUSED__DISCONNECT_B3_IND 0x8482 #define UNUSED__DISCONNECT_B3_REQ 0x8480 #define UNUSED__DISCONNECT_B3_RESP 0x8483 #define UNUSED__DISCONNECT_CONF 0x0481 #define UNUSED__DISCONNECT_IND 0x0482 #define UNUSED__DISCONNECT_REQ 0x0480 #define UNUSED__DISCONNECT_RESP 0x0483 #define UNUSED__FACILITY_CONF 0x8081 #define UNUSED__FACILITY_IND 0x8082 #define UNUSED__FACILITY_REQ 0x8080 #define UNUSED__FACILITY_RESP 0x8083 #define UNUSED__INFO_CONF 0x0881 #define UNUSED__INFO_IND 0x0882 #define UNUSED__INFO_REQ 0x0880 #define UNUSED__INFO_RESP 0x0883 #define UNUSED__LISTEN_CONF 0x0581 #define UNUSED__LISTEN_REQ 0x0580 #define UNUSED__MANUFACTURER_CONF 0xff81 #define UNUSED__MANUFACTURER_IND 0xff82 #define UNUSED__MANUFACTURER_REQ 0xff80 #define UNUSED__MANUFACTURER_RESP 0xff83 #define UNUSED__RESET_B3_CONF 0x8781 #define UNUSED__RESET_B3_IND 0x8782 #define UNUSED__RESET_B3_REQ 0x8780 #define UNUSED__RESET_B3_RESP 0x8783 #define UNUSED__SELECT_B_PROTOCOL_CONF 0x4181 #define UNUSED__SELECT_B_PROTOCOL_REQ 0x4180 /*----- CAPI commands -----*/ #define CAPI_ALERT 0x01 #define CAPI_CONNECT 0x02 #define CAPI_CONNECT_ACTIVE 0x03 #define CAPI_CONNECT_B3_ACTIVE 0x83 #define CAPI_CONNECT_B3 0x82 #define CAPI_CONNECT_B3_T90_ACTIVE 0x88 #define CAPI_DATA_B3 0x86 #define CAPI_DISCONNECT_B3 0x84 #define CAPI_DISCONNECT 0x04 #define CAPI_FACILITY 0x80 #define CAPI_INFO 0x08 #define CAPI_LISTEN 0x05 #define CAPI_MANUFACTURER 0xff #define CAPI_RESET_B3 0x87 #define CAPI_SELECT_B_PROTOCOL 0x41 /*----- CAPI subcommands -----*/ #define CAPI_REQ 0x80 #define CAPI_CONF 0x81 #define CAPI_IND 0x82 #define CAPI_RESP 0x83 #define CAPI_REGISTER_ERROR unsigned #define MESSAGE_EXCHANGE_ERROR unsigned typedef unsigned char *CAPI_MESSAGE; #if defined(__GLIBC__) && defined(__GLIBC_MINOR__) #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || __GLIBC__ > 2 #define HAS_UINT8_T #endif #endif #ifdef HAS_UINT8_t typedef uint8_t _cbyte; typedef uint16_t _cword; typedef uint32_t _cdword; typedef uint64_t _cqword; #else typedef unsigned char _cbyte; typedef unsigned short _cword; typedef unsigned long _cdword; #ifdef WIN32 #include<windows.h> typedef LONGLONG _cqword; #else typedef unsigned long long _cqword; #endif #endif typedef CAPI_MESSAGE _cstruct; typedef enum { CAPI_COMPOSE = 0, CAPI_DEFAULT = 1 } _cmstruct; typedef struct { /* Header */ _cword ApplId; _cbyte Command; _cbyte Subcommand; _cword Messagenumber; /* Parameter */ union { _cdword adrController; _cdword adrPLCI; _cdword adrNCCI; } adr; _cmstruct AdditionalInfo; _cstruct B1configuration; _cword B1protocol; _cstruct B2configuration; _cword B2protocol; _cstruct B3configuration; _cword B3protocol; _cstruct BC; _cstruct BChannelinformation; _cmstruct BProtocol; _cstruct CalledPartyNumber; _cstruct CalledPartySubaddress; _cstruct CallingPartyNumber; _cstruct CallingPartySubaddress; _cdword CIPmask; _cdword CIPmask2; _cword CIPValue; _cdword Class; _cstruct ConnectedNumber; _cstruct ConnectedSubaddress; _cdword Data32; _cqword Data64; _cword DataHandle; _cword DataLength; _cstruct FacilityConfirmationParameter; _cstruct Facilitydataarray; _cstruct FacilityIndicationParameter; _cstruct FacilityRequestParameter; _cstruct FacilityResponseParameters; _cword FacilitySelector; _cword Flags; _cdword Function; _cstruct HLC; _cword Info; _cstruct InfoElement; _cdword InfoMask; _cword InfoNumber; _cstruct Keypadfacility; _cstruct LLC; _cstruct ManuData; _cdword ManuID; _cstruct NCPI; _cword Reason; _cword Reason_B3; _cword Reject; _cstruct Useruserdata; unsigned char *Data; /* intern */ unsigned l, p; unsigned char *par; _cbyte *m; /* buffer to construct message */ _cbyte buf[180]; } _cmsg; typedef struct capi_profile { _cword ncontroller; /* number of installed controller */ _cword nbchannel; /* number of B-Channels */ _cdword goptions; /* global options */ _cdword support1; /* B1 protocols support */ _cdword support2; /* B2 protocols support */ _cdword support3; /* B3 protocols support */ _cdword reserved[6]; /* reserved */ _cdword manu[5]; /* manufacturer specific information */ } capi_profile; class CAPImsg { // private: public: _cbyte *msg,*msgtmp; _cmsg *cmsg; unsigned int capi_cmsg_header(unsigned int, unsigned char, unsigned char, short unsigned int, long unsigned int); unsigned CAPImsg::CAPI_MESSAGE_2_CMSG(); unsigned CAPImsg::CAPI_CMSG_2_MESSAGE(); CAPImsg(); ~CAPImsg(); CAPImsg(_cword applid, _cword msgtype,_cword msgnumber); CAPImsg(_cword applid, _cbyte cmd,_cbyte scmd,_cword msgnumber); void CONNECT_B3_REQ(_cword ApplId, _cword Messagenumber, _cdword adr, _cstruct NCPI); void FACILITY_REQ(_cword ApplId, _cword Messagenumber, _cdword adr, _cword FacilitySelector, _cstruct FacilityRequestParameter); void INFO_REQ(_cword ApplId, _cword Messagenumber, _cdword adr, _cstruct CalledPartyNumber, _cstruct BChannelinformation, _cstruct Keypadfacility, _cstruct Useruserdata, _cstruct Facilitydataarray); void LISTEN_REQ(_cword ApplId, _cword Messagenumber, _cdword adr, _cdword InfoMask, _cdword CIPmask, _cdword CIPmask2, _cstruct CallingPartyNumber, _cstruct CallingPartySubaddress); void ALERT_REQ(_cword ApplId, _cword Messagenumber, _cdword adr, _cstruct BChannelinformation, _cstruct Keypadfacility, _cstruct Useruserdata, _cstruct Facilitydataarray); void CONNECT_REQ(_cword ApplId, _cword Messagenumber, _cdword adr, _cword CIPValue, _cstruct CalledPartyNumber, _cstruct CallingPartyNumber, _cstruct CalledPartySubaddress, _cstruct CallingPartySubaddress, _cword B1protocol, _cword B2protocol, _cword B3protocol, _cstruct B1configuration, _cstruct B2configuration, _cstruct B3configuration, _cstruct BC, _cstruct LLC, _cstruct HLC, _cstruct BChannelinformation, _cstruct Keypadfacility, _cstruct Useruserdata, _cstruct Facilitydataarray); void DATA_B3_REQ(_cword ApplId, _cword Messagenumber, _cdword adr, unsigned char *Data, _cword DataLength, _cword DataHandle, _cword Flags); void DISCONNECT_REQ(_cword ApplId, _cword Messagenumber, _cdword adr, _cstruct BChannelinformation, _cstruct Keypadfacility, _cstruct Useruserdata, _cstruct Facilitydataarray); void DISCONNECT_B3_REQ(_cword ApplId, _cword Messagenumber, _cdword adr, _cstruct NCPI); void MANUFACTURER_REQ(_cword ApplId, _cword Messagenumber, _cdword adr, _cdword ManuID, _cdword Class, _cdword Function, _cstruct ManuData); void RESET_B3_REQ(_cword ApplId, _cword Messagenumber, _cdword adr, _cstruct NCPI); void SELECT_B_PROTOCOL_REQ(_cword ApplId, _cword Messagenumber, _cdword adr, _cword B1protocol, _cword B2protocol, _cword B3protocol, _cstruct B1configuration, _cstruct B2configuration, _cstruct B3configuration); void CONNECT_RESP(_cword ApplId, _cword Messagenumber, _cdword adr, _cword Reject, _cword B1protocol, _cword B2protocol, _cword B3protocol, _cstruct B1configuration, _cstruct B2configuration, _cstruct B3configuration, _cstruct ConnectedNumber, _cstruct ConnectedSubaddress, _cstruct LLC, _cstruct BChannelinformation, _cstruct Keypadfacility, _cstruct Useruserdata, _cstruct Facilitydataarray); void CONNECT_ACTIVE_RESP(_cword ApplId, _cword Messagenumber, _cdword adr); void CONNECT_B3_ACTIVE_RESP(_cword ApplId, _cword Messagenumber, _cdword adr); void CONNECT_B3_RESP(_cword ApplId, _cword Messagenumber, _cdword adr, _cword Reject, _cstruct NCPI); void CONNECT_B3_T90_ACTIVE_RESP(_cword ApplId, _cword Messagenumber, _cdword adr); void DATA_B3_RESP(_cword ApplId, _cword Messagenumber, _cdword adr, _cword DataHandle); void DISCONNECT_B3_RESP(_cword ApplId, _cword Messagenumber, _cdword adr); void DISCONNECT_RESP(_cword ApplId, _cword Messagenumber, _cdword adr); void FACILITY_RESP(_cword ApplId, _cword Messagenumber, _cdword adr, _cword FacilitySelector); void INFO_RESP(_cword ApplId, _cword Messagenumber, _cdword adr); void MANUFACTURER_RESP(_cword ApplId, _cword Messagenumber, _cdword adr, _cdword ManuID, _cdword Class, _cdword Function, _cstruct ManuData); void RESET_B3_RESP(_cword ApplId, _cword Messagenumber, _cdword adr); }; #endif
[ "alexbrickwedde" ]
[ [ [ 1, 367 ] ] ]
3a5cf7837b241a87a7ad078ef7825a7a22ad1232
36bf908bb8423598bda91bd63c4bcbc02db67a9d
/WallPaper/WallPaperDoNotAskMore.cpp
d4ced8d173e91e0d00b8c6bb4584fe32602b73ad
[]
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
WINDOWS-1252
C++
false
false
5,052
cpp
/* WallPaperDoNotAskMore.cpp Luca Piergentili, 13/03/04 [email protected] WallPaper (alias crawlpaper) - the hardcore of Windows desktop http://www.crawlpaper.com/ copyright © 1998-2004 Luca Piergentili, all rights reserved crawlpaper is a registered name, all rights reserved This is a free software, released under the terms of the BSD license. Do not attempt to use it in any form which violates the license or you will be persecuted and charged for this. 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 "crawlpaper" 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 "env.h" #include "pragma.h" #include "macro.h" #include "window.h" #include "win32api.h" #include "MessageBoxExt.h" #include "WallPaperConfig.h" #include "WallPaperDoNotAskMore.h" #include "traceexpr.h" //#define _TRACE_FLAG _TRFLAG_TRACEOUTPUT //#define _TRACE_FLAG _TRFLAG_NOTRACE #define _TRACE_FLAG _TRFLAG_NOTRACE #define _TRACE_FLAG_INFO _TRFLAG_NOTRACE #define _TRACE_FLAG_WARN _TRFLAG_NOTRACE #define _TRACE_FLAG_ERR _TRFLAG_NOTRACE #if (defined(_DEBUG) && defined(_WINDOWS)) && (defined(_AFX) || defined(_AFXDLL)) #ifdef PRAGMA_MESSAGE_VERBOSE #pragma message("\t\t\t"__FILE__"("STR(__LINE__)"): using DEBUG_NEW macro") #endif #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif /* DoNotAskMoreMessageBox() */ int DoNotAskMoreMessageBox(HWND hWnd,UINT nResourceID,int nTimeout,CWallPaperConfig* pConfig,LPCSTR lpcszDoNotAskMoreKey,LPCSTR lpcszDoNotAskMoreValue,int nForcedValue/* = -1*/,UINT nStyle/* = MB_YESNO*/) { return(DoNotAskMoreMessageBox(hWnd,MAKEINTRESOURCE(nResourceID),nTimeout,pConfig,lpcszDoNotAskMoreKey,lpcszDoNotAskMoreValue,nForcedValue,nStyle)); } /* DoNotAskMoreMessageBox() */ int DoNotAskMoreMessageBox(HWND hWnd,LPCSTR lpcszText,int nTimeout,CWallPaperConfig* pConfig,LPCSTR lpcszDoNotAskMoreKey,LPCSTR lpcszDoNotAskMoreValue,int nForcedValue/* = -1*/,UINT nStyle/* = MB_YESNO*/) { int nRet = IDNO; // il valore relativo alla chiave (utilizzato sotto per impostare il bottone di default) deve essere 1 (=yes) o 0 (=no) // se non viene forzato viene caricato dalla configurazione int nDefaultValue = (nForcedValue!=-1) ? nForcedValue : pConfig->GetNumber(WALLPAPER_DONOTASKMORE_KEY,lpcszDoNotAskMoreValue); if(pConfig->GetNumber(WALLPAPER_DONOTASKMORE_KEY,lpcszDoNotAskMoreKey)) nRet = pConfig->GetNumber(WALLPAPER_DONOTASKMORE_KEY,lpcszDoNotAskMoreValue) ? IDYES : IDNO; else { if(nStyle==MB_YESNO) nStyle = MB_DONOTASKAGAIN|MB_YESNO|(nDefaultValue==1 ? MB_DEFBUTTON1 : MB_DEFBUTTON2)|MB_ICONQUESTION|MB_TASKMODAL|MB_SETFOREGROUND|MB_TOPMOST; else if(nStyle==MB_ICONINFORMATION) nStyle = MB_DONOTSHOWAGAIN|MB_OK|MB_ICONINFORMATION|MB_TASKMODAL|MB_SETFOREGROUND|MB_TOPMOST; XMSGBOXPARAMS xmb; if(nTimeout > 0) xmb.nTimeoutSeconds = nTimeout; // bug: la MessageBoxExt(), se chiamata da una finestra minimizzata, non mette in primo piano il dialogo, inchiodando il chiamante if(hWnd) ::SetForegroundWindowEx(hWnd); nRet = ::MessageBoxExt(hWnd,lpcszText,WALLPAPER_PROGRAM_NAME,nStyle,&xmb); if(nRet & MB_TIMEOUT) nRet = nRet & ~MB_TIMEOUT; if((nRet & MB_DONOTASKAGAIN) || (nRet & MB_DONOTSHOWAGAIN)) { nRet = nRet & ~MB_DONOTASKAGAIN; pConfig->UpdateNumber(WALLPAPER_DONOTASKMORE_KEY,lpcszDoNotAskMoreKey,1); pConfig->SaveKey(WALLPAPER_DONOTASKMORE_KEY,lpcszDoNotAskMoreKey); } pConfig->UpdateNumber(WALLPAPER_DONOTASKMORE_KEY,lpcszDoNotAskMoreValue,nRet==IDYES ? 1 : 0); pConfig->SaveKey(WALLPAPER_DONOTASKMORE_KEY,lpcszDoNotAskMoreValue); } return(nRet); }
[ [ [ 1, 117 ] ] ]
03f8fee1b2e373fb377b235996c8ebd7ae4798ac
e1d76663bb020dc27abb53c8f8bb979b4738373f
/source/support/datastruct/tree.hpp
6f0b5f893d688a1b9907811234c6d744f62f20fd
[]
no_license
fanopi/autoFloderSync
97e29f9aa24bc8bf78aa8325996e176572f46f8a
5232e01f43c9cc31df349a8b474c5d35a1e92ac5
refs/heads/master
2020-06-03T15:28:13.583695
2011-09-19T13:52:25
2011-09-19T13:52:25
2,338,869
0
0
null
null
null
null
GB18030
C++
false
false
13,251
hpp
/* * tree.h * 为系统提供树形结构的抽象 * Created on: 2011-5-4 * Author: 代码基于 TinyXML项目 重构 原作者Lee Thomason */ #ifndef TREE_HPP_ #define TREE_HPP_ #include <assert.h> #include "../../typedef.h" namespace YF{ /* Nodes have siblings, a parent, and children. A node can be in a document, or stand on its own. * The type of a TreeNode can be queried, and it can be cast to its more defined type. */ template<typename NODE_T, typename VALUE_T> class TreeNode { public: virtual ~TreeNode(); /* Delete all the children of this node. Does not affect 'this'. */ void Clear(); /* One step up the DOM. */ NODE_T* Parent(){ return parent; } const NODE_T* Parent() const { return parent; } /* The first child of this node. Will be null if there are no children. */ const NODE_T* FirstChild() const { return firstChild; } NODE_T* FirstChild(){ return firstChild; } /* The first child of this node with the matching 'value'. Will be null if none found. */ const NODE_T* FirstChild(const VALUE_T* value) const; NODE_T* FirstChild(const VALUE_T* _value){ return const_cast<NODE_T*>((const_cast<const NODE_T*>(this))->FirstChild(_value)); } /* The last child of this node. Will be null if there are no children. */ const NODE_T* LastChild() const{ return lastChild; } NODE_T* LastChild(){ return lastChild; } /* The last child of this node matching 'value'. Will be null if there are no children. */ const NODE_T* LastChild(const VALUE_T* value) const; NODE_T* LastChild(const VALUE_T* _value){ return const_cast<NODE_T*>((const_cast<const NODE_T*>(this))->LastChild(_value)); } /* An alternate way to walk the children of a node. One way to iterate over nodes is: for( child = parent->FirstChild(); child; child = child->NextSibling() ) IterateChildren does the same thing with the syntax: child = 0; while( child = parent->IterateChildren( child ) ) * IterateChildren takes the previous child as input and finds the next one. * If the previous child is null, it returns the first. * IterateChildren will return null when done.*/ const NODE_T* IterateChildren(const NODE_T* previous) const; NODE_T* IterateChildren(const NODE_T* previous){ return const_cast<NODE_T*>((const_cast<const NODE_T*>(this))->IterateChildren(previous)); } /* This flavor of IterateChildren searches for children with a particular 'value' */ const NODE_T* IterateChildren(const VALUE_T* value, const NODE_T* previous) const; NODE_T* IterateChildren(const VALUE_T* _value, const NODE_T* previous){ return const_cast<NODE_T*>((const_cast<const NODE_T*>(this))->IterateChildren(_value, previous)); } /* Add a new node related to this. Adds a child past the LastChild. * Returns a pointer to the new object or NULL if an error occured.*/ NODE_T* InsertEndChild(const NODE_T& addThis); /* Add a new node related to this. Adds a child past the LastChild. * [NOTE] the node to be added is passed by pointer, and will be * henceforth owned (and deleted) by tinyXml. This method is efficient * and avoids an extra copy, but should be used with care as it * uses a different memory model than the other insert functions. * @sa InsertEndChild */ NODE_T* LinkEndChild(NODE_T* addThis); /* Add a new node related to this. Adds a child before the specified child. * Returns a pointer to the new object or NULL if an error occured. */ NODE_T* InsertBeforeChild(NODE_T* beforeThis, const NODE_T& addThis); /* Add a new node related to this. Adds a child after the specified child. * Returns a pointer to the new object or NULL if an error occured. */ NODE_T* InsertAfterChild(NODE_T* afterThis, const NODE_T& addThis); /* Replace a child of this node. * Returns a pointer to the new object or NULL if an error occured. */ NODE_T* ReplaceChild(NODE_T* replaceThis, const NODE_T& withThis); /* Delete a child of this node. */ bool RemoveChild(NODE_T* removeThis); /* Navigate to a sibling node. */ const NODE_T* PreviousSibling() const{ return prev; } NODE_T* PreviousSibling(){ return prev; } /* Navigate to a sibling node. */ const NODE_T* PreviousSibling(const VALUE_T*) const; NODE_T* PreviousSibling(const VALUE_T*_prev){ return const_cast<NODE_T*>((const_cast<const NODE_T*>(this))->PreviousSibling(_prev)); } /* Navigate to a sibling node. */ const NODE_T* NextSibling() const{ return next; } NODE_T* NextSibling(){ return next; } /* Navigate to a sibling node with the given 'value'. */ const NODE_T* NextSibling(const VALUE_T*) const; NODE_T* NextSibling(const VALUE_T* _next){ return const_cast<NODE_T*>((const_cast<const NODE_T*>(this))->NextSibling(_next)); } /* Returns true if this node has no children. */ bool NoChildren() const{ return !firstChild; } /* Create an exact duplicate of this node and return it. * The memory must be deleted by the caller. */ virtual NODE_T* Clone() const = 0; protected: TreeNode(NODE_T* parent_); NODE_T* parent; NODE_T* firstChild; NODE_T* lastChild; NODE_T* prev; NODE_T* next; private: NODE_T* initNode; TreeNode(const NODE_T&); // not implemented. void operator=(const NODE_T& base); // not allowed. }; template<typename NODE_T, typename VALUE_T> TreeNode<NODE_T, VALUE_T>::TreeNode(NODE_T* init_node){ parent = NULL; firstChild = NULL; lastChild = NULL; prev = NULL; next = NULL; initNode = init_node; } template<typename NODE_T, typename VALUE_T> TreeNode<NODE_T, VALUE_T>::~TreeNode(){ NODE_T* node = firstChild; NODE_T* temp = NULL; while (node){ temp = node; node = node->next; delete temp; } } template<typename NODE_T, typename VALUE_T> void TreeNode<NODE_T, VALUE_T>::Clear(){ NODE_T* node = firstChild; NODE_T* temp = NULL; while (node){ temp = node; node = node->next; delete temp; } firstChild = NULL; lastChild = NULL; } template<typename NODE_T, typename VALUE_T> NODE_T* TreeNode<NODE_T, VALUE_T>::LinkEndChild(NODE_T* node){ assert(node->parent == NULL || node->parent == initNode); node->parent = initNode; node->prev = lastChild; node->next = NULL; if (lastChild) lastChild->next = node; else // it was an empty list. firstChild = node; lastChild = node; return node; } template<typename NODE_T, typename VALUE_T> NODE_T* TreeNode<NODE_T, VALUE_T>::InsertEndChild(const NODE_T& addThis){ NODE_T* node = addThis.Clone( ); if ( !node) return NULL; return LinkEndChild(node); } template<typename NODE_T, typename VALUE_T> NODE_T* TreeNode<NODE_T, VALUE_T>::InsertBeforeChild(NODE_T* beforeThis, const NODE_T& addThis){ if ( !beforeThis || beforeThis->parent != this) return NULL; NODE_T* node = addThis.Clone( ); if ( !node) return NULL; node->parent = this; node->next = beforeThis; node->prev = beforeThis->prev; if (beforeThis->prev){ beforeThis->prev->next = node; }else{ assert(firstChild == beforeThis); firstChild = node; } beforeThis->prev = node; return node; } template<typename NODE_T, typename VALUE_T> NODE_T* TreeNode<NODE_T, VALUE_T>::InsertAfterChild(NODE_T* afterThis, const NODE_T& addThis){ if ( !afterThis || afterThis->parent != this) return NULL; NODE_T* node = addThis.Clone( ); if (!node) return NULL; node->parent = this; node->prev = afterThis; node->next = afterThis->next; if (afterThis->next){ afterThis->next->prev = node; }else{ assert(lastChild == afterThis); lastChild = node; } afterThis->next = node; return node; } template<typename NODE_T, typename VALUE_T> NODE_T* TreeNode<NODE_T, VALUE_T>::ReplaceChild(NODE_T* replaceThis, const NODE_T& withThis){ if( ( !replaceThis) || (replaceThis->parent != this) ) return NULL; NODE_T* node = withThis.Clone( ); if ( !node) return NULL; node->next = replaceThis->next; node->prev = replaceThis->prev; if (replaceThis->next) replaceThis->next->prev = node; else lastChild = node; if (replaceThis->prev) replaceThis->prev->next = node; else firstChild = node; delete replaceThis; node->parent = this; return node; } template<typename NODE_T, typename VALUE_T> bool TreeNode<NODE_T, VALUE_T>::RemoveChild(NODE_T* removeThis){ if( ( !removeThis) || (removeThis->parent != this)){ assert(0); return false; } if (removeThis->next) removeThis->next->prev = removeThis->prev; else lastChild = removeThis->prev; if (removeThis->prev) removeThis->prev->next = removeThis->next; else firstChild = removeThis->next; delete removeThis; return true; } template<typename NODE_T, typename VALUE_T> const NODE_T* TreeNode<NODE_T, VALUE_T>::FirstChild(const VALUE_T* _value) const{ const NODE_T* node; for (node = firstChild; node; node = node->next){ if( ( node->Value( ) == _value) == 0) return node; } return NULL; } template<typename NODE_T, typename VALUE_T> const NODE_T* TreeNode<NODE_T, VALUE_T>::LastChild(const VALUE_T* _value) const{ const NODE_T* node; for (node = lastChild; node; node = node->prev){ if ((node->Value( )== _value) == 0) return node; } return NULL; } template<typename NODE_T, typename VALUE_T> const NODE_T* TreeNode<NODE_T, VALUE_T>::IterateChildren(const NODE_T* previous) const{ if ( !previous){ return FirstChild( ); }else{ assert(previous->parent == this); return previous->NextSibling( ); } } template<typename NODE_T, typename VALUE_T> const NODE_T* TreeNode<NODE_T, VALUE_T>::IterateChildren(const VALUE_T* val, const NODE_T* previous) const{ if ( !previous){ return FirstChild(val); }else{ assert(previous->parent == this); return previous->NextSibling(val); } } template<typename NODE_T, typename VALUE_T> const NODE_T* TreeNode<NODE_T, VALUE_T>::NextSibling(const VALUE_T* _value) const { const NODE_T* node; for (node = next; node; node = node->next){ if ((node->Value( )== _value) == 0) return node; } return NULL; } template<typename NODE_T, typename VALUE_T> const NODE_T* TreeNode<NODE_T, VALUE_T>::PreviousSibling(const VALUE_T* _value) const{ const NODE_T* node; for (node = prev; node; node = node->prev){ if ((node->Value( )== _value) == 0) return node; } return NULL; } #if 0 /* A TreeNodeHandle is a class that wraps a node pointer with null checks */ template<typename VALUE_T> class TreeNodeHandle { public: /* Create a handle from any node (at any depth of the tree.) This can be a null pointer.*/ TreeNodeHandle(TreeNode<VALUE_T>* _node){ this->node = _node; } TreeNodeHandle(const TreeNodeHandle& ref){ this->node = ref.node; } TreeNodeHandle operator=(const TreeNodeHandle& ref){ this->node = ref.node; return *this; } /* Return a handle to the first child node. */ TreeNodeHandle FirstChild() const; /* Return a handle to the first child node with the given name. */ TreeNodeHandle FirstChild(const VALUE_T* value) const; /* Return a handle to the "index" child with the given name. * The first child is 0, the second 1, etc.*/ TreeNodeHandle Child(const VALUE_T* value, int index) const; /* Return a handle to the "index" child. * The first child is 0, the second 1, etc.*/ TreeNodeHandle Child(int index) const; /* Return the handle as a TreeNode. This may return null. */ TreeNode<VALUE_T>* ToTreeNode() const{ return node; } private: TreeNode<VALUE_T>* node; }; #endif #if 0 ///////////////////// calss TreeNodeHandle ////////////////////////////////// template<typename NODE_T> TreeNodeHandle<NODE_T> TreeNodeHandle<NODE_T>::FirstChild() const{ if (node){ NODE_T* child = node->FirstChild( ); if (child) return TreeNodeHandle<NODE_T>(child); } return TreeNodeHandle<NODE_T>(NULL); } template<typename NODE_T> TreeNodeHandle<NODE_T> TreeNodeHandle<NODE_T>::FirstChild(const NODE_T* value) const{ if (node){ NODE_T* child = node->FirstChild(value); if (child) return TreeNodeHandle<NODE_T>(child); } return TreeNodeHandle<NODE_T>(NULL); } template<typename NODE_T> TreeNodeHandle<NODE_T> TreeNodeHandle<NODE_T>::Child(int count) const{ if (node){ NODE_T* child = node->FirstChild( ); for (int i = 0; child && i < count; child = child->NextSibling( ), ++i){ // nothing } if (child) return TreeNodeHandle<NODE_T>(child); } return TreeNodeHandle<NODE_T>(NULL); } template<typename NODE_T> TreeNodeHandle<NODE_T> TreeNodeHandle<NODE_T>::Child(const NODE_T* value, int count) const{ if (node){ NODE_T* child = node->FirstChild(value); for (int i = 0; child && i < count; child = child->NextSibling(value), ++i){ // nothing } if (child) return TreeNodeHandle<NODE_T>(child); } return TreeNodeHandle<NODE_T>(NULL); } #endif } /// namespace YF #endif /* TREE_HPP_ */
[ [ [ 1, 465 ] ] ]
14a73065b8022469648d692b812204265ccae76c
28aa23d9cb8f5f4e8c2239c70ef0f8f6ec6d17bc
/mytesgnikrow --username hotga2801/Experiment/Source/Apllication/LedsCtrlApp/LedsCtrlApp/LedsCtrlApp.h
128e3a4c25373722743338e099ac5a6f1e6761c8
[]
no_license
taicent/mytesgnikrow
09aed8836e1297a24bef0f18dadd9e9a78ec8e8b
9264faa662454484ade7137ee8a0794e00bf762f
refs/heads/master
2020-04-06T04:25:30.075548
2011-02-17T13:37:16
2011-02-17T13:37:16
34,991,750
0
0
null
null
null
null
UTF-8
C++
false
false
534
h
// LedsCtrlApp.h : main header file for the PROJECT_NAME application // #pragma once #ifndef __AFXWIN_H__ #error "include 'stdafx.h' before including this file for PCH" #endif #include "resource.h" // main symbols // CLedsCtrlAppApp: // See LedsCtrlApp.cpp for the implementation of this class // class CLedsCtrlAppApp : public CWinApp { public: CLedsCtrlAppApp(); // Overrides public: virtual BOOL InitInstance(); // Implementation DECLARE_MESSAGE_MAP() }; extern CLedsCtrlAppApp theApp;
[ "hotga2801@ecd9aaca-b8df-3bf4-dfa7-576663c5f076" ]
[ [ [ 1, 31 ] ] ]
e6c39b563577993e3ecb861cd48504374eb9c07f
cfcd2a448c91b249ea61d0d0d747129900e9e97f
/thirdparty/OpenCOLLADA/COLLADAFramework/include/COLLADAFWPass.h
dc2b9758e1ee0d19289be1285c8098e8f04876f6
[]
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
3,745
h
/* 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 */ #ifndef __COLLADAFW_PASS_H__ #define __COLLADAFW_PASS_H__ #include "COLLADAFWPrerequisites.h" #include "COLLADAFWPassTarget.h" #include "COLLADAFWPassClear.h" #include "COLLADAFWRenderDraw.h" #include "COLLADAFWRenderState.h" #include "COLLADAFWShader.h" namespace COLLADAFW { /** Provides a static declaration of all the render states, shaders, and settings for one rendering pipeline. <pass> describes all the render states and shaders for a rendering pipeline, and is the element that the FX Runtime is asked to "apply" to the current graphics state before the program can submit geometry. A static declaration is one that requires no evaluation by a scripting engine or runtime system in order to be applied to the graphics state. At the time that a <pass> is applied, all render state settings and uniform parameters are precalculated and known. */ class Pass { private: /** The optional label for this pass, allowing passes to be specified by name and, if desired, reordered by the application as the technique is evaluated. Optional. */ String mSid; /** Adds a strongly typed annotation remark to the parent object. No or one occurance. */ Annotate mAnnotate; /** Specifies which <surface> will receive the color information from the output of this pass. No or one occurance. */ PassTarget mColorTarget; /** Specifies which <surface> will receive the depth information from the output of this pass. No or one occurence. */ PassTarget mDepthTarget; /** Specifies which <surface> will receive the stencil information from the output of this pass. No or one occurence. */ PassTarget mStencilTarget; /** Specifies whether a render target surface is to be cleared, and which value to use. No or one occurence. */ PassColorClear mColorClear; /** Specifies whether a render target surface is to be cleared, and which value to use. No or one occurence. */ PassDepthClear mDepthClear; /** Specifies whether a render target surface is to be cleared, and which value to use. No or one occurence. */ PassStencilClear mStencilClear; /** Instructs the FX Runtime what kind of geometry to submit. No or one occurence. */ RenderDraw mDraw; /** Different FX profiles have different sets of render states available for use within the <pass> element. */ RenderState mRenderStates; /** Declares and prepares a shader for execution in the rendering pipeline of a <pass>. */ Array<Shader> mShaderArray; /** Provides arbitrary additional information about or related to its parent element. */ // Array<Extra> mExtraArray; public: /** Constructor. */ Pass() : mColorTarget ( PassOutput::OUTPUT_TYPE_COLOR ) , mDepthTarget ( PassOutput::OUTPUT_TYPE_DEPTH ) , mStencilTarget ( PassOutput::OUTPUT_TYPE_STENCIL ) {} /** Destructor. */ virtual ~Pass(); private: /** Disable default copy ctor. */ Pass( const Pass& pre ); /** Disable default assignment operator. */ const Pass& operator= ( const Pass& pre ); }; } // namespace COLLADAFW #endif // __COLLADAFW_PASS_H__
[ [ [ 1, 107 ] ] ]
040ec2d69d99df81e3a2a9f4091f3c9477be4ffa
36d0ddb69764f39c440089ecebd10d7df14f75f3
/プログラム/Ngllib/include/Ngl/EffectParameter.h
cc24785006ef162a6b6ca38502f8e5f90fb87c70
[]
no_license
weimingtom/tanuki-mo-issyo
3f57518b4e59f684db642bf064a30fc5cc4715b3
ab57362f3228354179927f58b14fa76b3d334472
refs/heads/master
2021-01-10T01:36:32.162752
2009-04-19T10:37:37
2009-04-19T10:37:37
48,733,344
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
7,958
h
/*******************************************************************************/ /** * @file EffectParameter.h. * * @brief エフェクトパラメータクラスヘッダファイル. * * @date 2008/07/10. * * @version 1.00. * * @author Kentarou Nishimura. */ /******************************************************************************/ #ifndef _NGL_EFFECTPARAMETER_H_ #define _NGL_EFFECTPARAMETER_H_ #include "Ngl/IEffectParameter.h" #include "Ngl/IEffect.h" namespace Ngl{ /** * @class EffectParameter. * @brief エフェクトパラメータクラス. */ class EffectParameter : public IEffectParameter, public IEffectScalarParameter, public IEffectVectorParameter, public IEffectMatrixParameter, public IEffectTextureParameter { public: /*=========================================================================*/ /** * @brief コンストラクタ * * @param[in] effect エフェクトクラスのポインタ. * @param[in] parameterName パラメータ名. */ EffectParameter( IEffect* effect, const std::string parameterName ); /*=========================================================================*/ /** * @brief デストラクタ * * @param[in] なし. */ ~EffectParameter(); /*=========================================================================*/ /** * @brief パラメータ名を取得 * * @param[in] なし. * @return パラメータ名. */ virtual const std::string& name() const; /*=========================================================================*/ /** * @brief スカラーパラメータインターフェースを取得 * * @param[in] なし. * @return スカラーパラメータインターフェースのポインタ. */ virtual IEffectScalarParameter* asScalar(); /*=========================================================================*/ /** * @brief ベクトルパラメータインターフェースを取得 * * @param[in] なし. * @return ベクトルパラメータインターフェースのポインタ. */ virtual IEffectVectorParameter* asVector(); /*=========================================================================*/ /** * @brief 行列パラメータインターフェースを取得 * * @param[in] なし. * @return 行列パラメータインターフェースのポインタ. */ virtual IEffectMatrixParameter* asMatrix(); /*=========================================================================*/ /** * @brief テクスチャパラメータインターフェースを取得 * * @param[in] なし. * @return テクスチャパラメータインターフェースのポインタ. */ virtual IEffectTextureParameter* asTexture(); private: /*=========================================================================*/ /** * @brief int型のパラメータを設定 * * @param[in] v 設定するパラメータ. * @return なし. */ virtual void setInt( int v ); /*=========================================================================*/ /** * @brief int型配列のパラメータを設定 * * @param[in] v 設定する配列パラメータの先頭ポインタ. * @param[in] count 要素数. * @return なし. */ virtual void setIntArray( const int* v, unsigned int count ); /*=========================================================================*/ /** * @brief float型のパラメータを設定 * * @param[in] v 設定するパラメータ. * @return なし. */ virtual void setFloat( float v ); /*=========================================================================*/ /** * @brief float型配列のパラメータを設定 * * @param[in] v 設定する配列パラメータの先頭ポインタ. * @param[in] count 要素数. * @return なし. */ virtual void setFloatArray( const float* v, unsigned int count ); /*=========================================================================*/ /** * @brief RGBAカラー構造体のパラメータを設定 * * @param[in] color 設定するRGBAカラー構造体パラメータ. * @return なし. */ virtual void setColor( const Color4& color ); /*=========================================================================*/ /** * @brief RGBAカラー構造体配列のパラメータを設定 * * @param[in] color 設定するRGBAカラー配列パラメータの先頭ポインタ. * @param[in] count 要素数. * @return なし. */ virtual void setColorArray( const Color4* color, unsigned int count ); /*=========================================================================*/ /** * @brief 2次元ベクトルを設定する * * @param[in] v2 設定する2次元ベクトル構造体. * @return なし. */ virtual void setVector2( const Vector2& v2 ); /*=========================================================================*/ /** * @brief 2次元ベクトルの配列を設定する * * @param[in] v2 設定する2次元ベクトル構造体配列の先頭ポインタ. * @param[in] count 配列の要素数 * @return なし. */ virtual void setVector2Array( const Vector2& v2, unsigned int count ); /*=========================================================================*/ /** * @brief 3次元ベクトルを設定する * * @param[in] v3 設定する3次元ベクトル構造体. * @return なし. */ virtual void setVector3( const Vector3& v3 ); /*=========================================================================*/ /** * @brief 3次元ベクトルの配列を設定する * * @param[in] v3 設定する3次元ベクトル構造体配列の先頭ポインタ. * @param[in] count 配列の要素数 * @return なし. */ virtual void setVector3Array( const Vector3& v3, unsigned int count ); /*=========================================================================*/ /** * @brief 4次元ベクトルを設定する * * @param[in] v4 設定する4次元ベクトル構造体. * @return なし. */ virtual void setVector4( const Vector4& v4 ); /*=========================================================================*/ /** * @brief 4次元ベクトルの配列を設定する * * @param[in] v4 設定する4次元ベクトル構造体配列の先頭ポインタ. * @param[in] count 配列の要素数 * @return なし. */ virtual void setVector4Array( const Vector4& v4, unsigned int count ); /*=========================================================================*/ /** * @brief 4x4行列を設定する * * @param[in] matrix 設定する4x4行列構造体. * @return なし. */ virtual void setMatrix( const Matrix4& matrix ); /*=========================================================================*/ /** * @brief 4x4行列の配列を設定する * * @param[in] matrix 設定する4x4行列構造体配列の先頭ポインタ. * @param[in] count 要素数 * @return なし. */ virtual void setMatrixArray( const Matrix4* matrix, unsigned int count ); /*=========================================================================*/ /** * @brief テクスチャパラメータを設定 * * @param[in] texture 設定するテクスチャインターフェースのポインタ. * @return なし. */ virtual void setTexture( ITexture* texture ); private: /** エフェクトクラスのポインタ */ IEffect* effect_; /** パラメータ名 */ std::string parameterName_; }; } // namespace Ngl #endif /*===== EOF ==================================================================*/
[ "rs.drip@aa49b5b2-a402-11dd-98aa-2b35b7097d33" ]
[ [ [ 1, 276 ] ] ]
e0a3805cf23fcccde0ed59f06811db903d45fea7
25f79693b806edb9041e3786fa3cf331d6fd4b97
/include/core/cal/Buffer.h
0b32780e11c927b7a5f2c7cf61c97d14bcb7289c
[]
no_license
ouj/amd-spl
ff3c9faf89d20b5d6267b7f862c277d16aae9eee
54b38e80088855f5e118f0992558ab88a7dea5b9
refs/heads/master
2016-09-06T03:13:23.993426
2009-08-29T08:55:02
2009-08-29T08:55:02
32,124,284
0
0
null
null
null
null
UTF-8
C++
false
false
5,794
h
#ifndef AMDSPL_BUFFER_H #define AMDSPL_BUFFER_H ////////////////////////////////////////////////////////////////////////// //! //! \file Buffer.h //! \date 27:2:2009 15:51 //! \author Jiawei Ou //! //! \brief Contain declaration of Buffer class. //! ////////////////////////////////////////////////////////////////////////// #include "cal.h" #include "cal_ext.h" #include "SplDefs.h" #include "IBuffer.h" namespace amdspl { namespace core { namespace cal { class Event; ////////////////////////////////////////////////////////////////////////// //! //! \brief Buffer class is an abstract representation of CAL buffer. //! Buffer class is the base class of LocalBuffer and RemoteBuffer, //! it provides functionalities required for Buffer creation and //! data transfer. It maintains the CAL handles, buffer type, //! format and dimensional information of a buffer. //! \warning Not thread safe. //! ////////////////////////////////////////////////////////////////////////// class SPL_EXPORT Buffer : public IBuffer { friend class BufferManager; public: virtual ~Buffer(); virtual bool readData(void *ptr, unsigned long size); virtual bool writeData(void *ptr, unsigned long size); inline CALresource getResHandle(); inline CALformat getFormat(); inline unsigned int getWidth(); inline unsigned int getHeight(); unsigned int getPitch(); bool setInputEvent(Event* e); bool setOutputEvent(Event* e); void waitInputEvent(); void waitOutputEvent(); inline bool isGlobal(); protected: Buffer(CALformat format, unsigned int width, unsigned int height = 0, unsigned int flag = 0); virtual bool initialize(); void* getPointerCPU(CALuint &pitch); void releasePointerCPU(); //! \brief Store the CALformat of the buffer. CALformat _dataFormat; //! \brief Store the CALresource handle of the buffer. CALresource _res; //! \brief Store the width of the 1D or 2D buffer. unsigned int _width; //! \brief Store the height of 2D buffer. In the case of 1D buffer, //! height value is set to zero. unsigned int _height; //! \brief Store the pitch of buffer. Pitch value is acquired by calling // Buffer::getPointerCPU. CALuint _pitch; //! \brief Store the input event of the buffer. Event* _inputEvent; //! \brief Store the output event of the buffer. Event* _outputEvent; //! \brief Buffer initialization flag unsigned int _flag; }; ////////////////////////////////////////////////////////////////////////// //! //! \return CALresource //! //! \brief Get the CAL resouce handle of the buffer. //! ////////////////////////////////////////////////////////////////////////// CALresource Buffer::getResHandle() { return _res; } ////////////////////////////////////////////////////////////////////////// //! //! \return CALformat //! //! \brief Get the CAL format of the buffer. //! ////////////////////////////////////////////////////////////////////////// CALformat Buffer::getFormat() { return _dataFormat; } ////////////////////////////////////////////////////////////////////////// //! //! \return unsigned int //! //! \brief Get the width of the buffer. //! ////////////////////////////////////////////////////////////////////////// unsigned int Buffer::getWidth() { return _width; } ////////////////////////////////////////////////////////////////////////// //! //! \return unsigned int //! //! \brief Get the height of the buffer, return 0 if it is a 1D buffer. //! ////////////////////////////////////////////////////////////////////////// unsigned int Buffer::getHeight() { return _height; } ////////////////////////////////////////////////////////////////////////// //! //! \return bool boolean value indicate whether this buffer is a global //! buffer. //! //! \brief Check if the buffer is a global buffer. //! ////////////////////////////////////////////////////////////////////////// bool Buffer::isGlobal() { return _flag || CAL_RESALLOC_GLOBAL_BUFFER; } } } } #endif //AMDSPL_BUFFER_H
[ "jiawei.ou@1960d7c4-c739-11dd-8829-37334faa441c", "probing@1960d7c4-c739-11dd-8829-37334faa441c" ]
[ [ [ 1, 14 ], [ 16, 146 ] ], [ [ 15, 15 ] ] ]
d2ccd7af7efa794a8a7930e998f49cb440af2c6d
c5534a6df16a89e0ae8f53bcd49a6417e8d44409
/trunk/Dependencies/Xerces/include/xercesc/util/Platforms/OS390/FileHandleImpl.cpp
ed84cdb7ca0d5b47e0f88d7d4ecce537adf639e3
[]
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
2,340
cpp
/* * Copyright 2002,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: FileHandleImpl.cpp 176026 2004-09-08 13:57:07Z peiyongz $ */ #include <fstream.h> #include <stdio.h> #include <ctype.h> #include <typeinfo> #define _XOPEN_SOURCE_EXTENDED 1 #include <stdlib.h> #include <xercesc/util/XMLUniDefs.hpp> #include "FileHandleImpl.hpp" #include <xercesc/framework/MemoryManager.hpp> XERCES_CPP_NAMESPACE_BEGIN //Constructor: FileHandleImpl::FileHandleImpl(FILE* open_handle, int o_type, bool r_type, int fileLrecl, MemoryManager* const manager): Handle(open_handle), openType(o_type), recordType(r_type), lrecl(fileLrecl), fMemoryManager(manager) { stgBufferPtr = 0; nextByte = 0; if ((openType == _FHI_WRITE) && (recordType == _FHI_TYPE_RECORD) && (lrecl != 0)) { //stgBufferPtr = new XMLByte [lrecl]; stgBufferPtr = (XMLByte*) manager->allocate(lrecl * sizeof(XMLByte)); } // printf("FileHandleImpl constructor called\n"); // printf("stgBufferPtr is: x%8.8X\n", stgBufferPtr); // printf("Handle is: x%8.8X\n", Handle); // printf("openType is : %d\n",openType); // printf("recordType is : %d\n",recordType); // printf("lrecl is : %d\n",lrecl); } //Destructor: FileHandleImpl::~FileHandleImpl() { // printf("FileHandleImpl destructor called\n"); // printf("stgBufferPtr is: x%8.8X\n", stgBufferPtr); // printf("Handle is: x%8.8X\n", Handle); // printf("openType is : %d\n",openType); // printf("recordType is : %d\n",recordType); if (stgBufferPtr != 0) { // printf("stgBufferPtr is being freed at: x%8.8X\n", stgBufferPtr); //delete [] stgBufferPtr; fMemoryManager->deallocate(stgBufferPtr); } } XERCES_CPP_NAMESPACE_END
[ "Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57" ]
[ [ [ 1, 75 ] ] ]
3a351bc7f6c7b4fbadcf35f062454b69e9c4340b
3f6ce98c5baf86e2b8518143bfcbeab2c8f5d712
/final/src/drawengine.h
e193ae72a036d408ef8e92c10e1a778c91a50fcd
[]
no_license
mprice1/cs123_final
4d8cdb6ddf8c0a89ff75823b4d4218f3823b316e
b23b571336364de335bb7097e03463eee013b716
refs/heads/master
2020-04-01T18:04:21.262870
2010-12-11T06:54:11
2010-12-11T06:54:11
1,139,252
0
0
null
null
null
null
UTF-8
C++
false
false
2,903
h
#ifndef DRAWENGINE_H #define DRAWENGINE_H #include <QHash> #include <QList> #include <QString> #include <qgl.h> #include "glm.h" #include "common.h" #include "glwidget.h" /* Common shader and texture names are defined as constants For all shots to use! */ #define ROPE_SHADER "ropetest" #define ROPE_OCC "rope_occlusion" #define ROPE_NORM "rope_normal" #define NAIL_SHADER "reflect" #define NAIL_MODEL "nailgeom" #define BRAD_MODEL "bradgeom" #define CRACK_SHADER "crackshader" #define CRACK_COLOR "crackcolor" #define CRACK_NORM "cracknormal" #define SPRITE_ONE "sprite_one" #define SPRITE_TWO "sprite_two" #define PERLIN_TEXTURE "perlin" #define SPRITE_SHADER "spriteshade" class QGLContext; class QGLShaderProgram; class QFile; class QGLFramebufferObject; class QKeyEvent; class Shot; class NMSphere; class DrawEngine { public: //ctor and dtor DrawEngine(const QGLContext *context, int w, int h, GLWidget* widget); ~DrawEngine(); //methods void draw_frame(float time, int w, int h); void resize_frame(int w, int h); void mouse_wheel_event(int dx); void mouse_drag_event(float2 p0, float2 p1); void key_press_event(QKeyEvent *event); //getters and setters float fps() { return fps_; } void perspective_camera(); void orthogonal_camera(); void endShot(); void prevShot(); void fadeShots(int frames); void text(double x, double y, QString s); //member variables Camera camera_; ///a simple camera struct NMSphere* nm_sphere; protected: //methods void perspective_camera(int w, int h); void orthogonal_camera(int w, int h); void textured_quad(int w, int h, bool flip); void realloc_framebuffers(int w, int h); void load_models(); void load_textures(); void load_shaders(); GLuint load_cube_map(QList<QFile *> files); GLuint load_texture(QFile * tex); void create_fbos(int w, int h); int m_w, m_h; GLWidget* m_widget; int frameNumber; int m_fadetimer; int m_fade; //member variables QHash<QString, QGLShaderProgram *> shader_programs_; ///hash map of all shader programs QHash<QString, QGLFramebufferObject *> framebuffer_objects_; ///hash map of all framebuffer objects QHash<QString, Model> models_; ///hashmap of all models QHash<QString, GLuint> textures_; ///hashmap of all textures const QGLContext *context_; ///the current OpenGL context to render to float previous_time_, fps_; ///the previous time and the fps counter int m_curShot;//current shot QList<Shot*>* m_shots; //list of shots }; #endif // DRAWENGINE_H
[ [ [ 1, 9 ], [ 11, 19 ], [ 21, 48 ], [ 50, 61 ], [ 63, 65 ], [ 68, 87 ], [ 90, 90 ], [ 93, 110 ] ], [ [ 10, 10 ], [ 20, 20 ], [ 49, 49 ], [ 62, 62 ], [ 66, 67 ], [ 88, 89 ], [ 91, 92 ] ] ]
562d9909d43577917e2ae9c953d9e0c2747d4836
fd518ed0226c6a044d5e168ab50a0e4a37f8efa9
/iAuthor/Author/SlideListWnd.h
38bdd24e4edf69cbe71248dff26451c50dc5acdb
[]
no_license
shilinxu/iprojects
e2e2394df9882afaacfb9852332f83cbef6a8c93
79bc8e45596577948c45cf2afcff331bc71ab026
refs/heads/master
2020-05-17T19:15:43.197685
2010-04-02T15:58:11
2010-04-02T15:58:11
41,959,151
0
0
null
null
null
null
UTF-8
C++
false
false
1,597
h
#if !defined(AFX_SLIDELISTWND_H__EB404B07_8AC7_4FC8_9729_0EF01D4C2D10__INCLUDED_) #define AFX_SLIDELISTWND_H__EB404B07_8AC7_4FC8_9729_0EF01D4C2D10__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // SlideListWnd.h : header file // #include "ListWnd.h" ///////////////////////////////////////////////////////////////////////////// // CSlideListWnd window class CSlideListWnd : public CWnd { // Construction public: CSlideListWnd(); // Attributes public: CListWnd m_CLipListWnd; int m_nIndex; CString m_strSelectItemPath; // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CSlideListWnd) public: virtual BOOL Create(const RECT& rect, CWnd* pParentWnd, UINT nID); //}}AFX_VIRTUAL // Implementation public: void ReplaceSildeThumbnail(CString strPath); CString GetSelteditemPath(); int GetCount(); void Init(); void AddItem(CString strPath); virtual ~CSlideListWnd(); // Generated message map functions protected: //{{AFX_MSG(CSlideListWnd) afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnPaint(); afx_msg void OnSize(UINT nType, int cx, int cy); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_SLIDELISTWND_H__EB404B07_8AC7_4FC8_9729_0EF01D4C2D10__INCLUDED_)
[ [ [ 1, 62 ] ] ]
b96af63bf835b9b2fe0492637cad01ee6a937f09
737638e4d2496de8656a23e093f40ef74eca6ca8
/palette.cpp
130da13bd25b8d7a8caeeb83957a2129b9c173cf
[]
no_license
ianperez/x-com-reloaded
edbd06f3d78b833a21b0b0effed5a887d93f071f
e581b56479233943ae8c7c572eca2a51abb36f2d
refs/heads/master
2021-01-21T23:16:50.031442
2010-12-18T05:52:45
2010-12-18T05:52:45
32,757,272
0
0
null
null
null
null
UTF-8
C++
false
false
2,010
cpp
#include "palette.h" #include "util.h" #include <fstream> namespace ufo { void Palette::load(string filename, Uint8 index, Uint16 paletteSize) { ifstream infile(filename.c_str(), ios::binary); if (!infile) throw runtime_error("error opening " + filename); Uint8 bufferSize = paletteSize == 256 ? 6 : 0; m_offset = paletteSize == 16 ? 224 : 0; infile.seekg((paletteSize * 3 + bufferSize) * index, ios::beg); for (Uint16 i = 0; i < paletteSize; ++i) { Uint8 r, g, b; infile.read((char*)&r, sizeof(r)); infile.read((char*)&g, sizeof(g)); infile.read((char*)&b, sizeof(b)); if (infile.eof()) break; SDL_Color c; //c.r = (r + 1) * 4 - 1; //c.g = (g + 1) * 4 - 1; //c.b = (b + 1) * 4 - 1; c.r = round<Uint8>(r * 255.0 / 63); c.g = round<Uint8>(g * 255.0 / 63); c.b = round<Uint8>(b * 255.0 / 63); c.unused = 0; m_colors.push_back(c); } } Palette::Palette() : m_offset(0) { } Palette::Palette(string filename, Uint8 index, Uint16 paletteSize) : m_offset(0) { load(filename, index, paletteSize); } Palette::Palette(Surface& surface) : m_offset(0) { for (int i = 0; i < surface.get()->format->palette->ncolors; ++i) m_colors.push_back(surface.get()->format->palette->colors[i]); } Uint32 Palette::getRGBA(Uint8 index) const { SDL_Color c(operator[] (index)); return ((Uint32)c.r << 24) | (Uint32)(c.g << 16) | ((Uint16)c.b << 8) | (Uint8)255; } SDL_Color Palette::operator[] (Uint8 index) const { return m_colors[index - m_offset]; } void Palette::apply(Surface& surface) { surface.setColors(&m_colors[0], m_offset, m_colors.size()); } void Palette::apply(Surface& surface, Uint8 offset) { surface.setColors(&m_colors[0], offset, m_colors.size()); } void Palette::draw(Surface& surface, Sint16 x, Sint16 y) { for (size_t i = 0; i < m_colors.size(); ++i) surface.fillRect(&Rect(x + i, y, 1, 20), i); } }
[ "ianrobertperez@687bc148-feef-c4d9-3bcb-ab45cd3def04", "[email protected]@687bc148-feef-c4d9-3bcb-ab45cd3def04" ]
[ [ [ 1, 67 ], [ 69, 69 ], [ 71, 71 ], [ 73, 84 ] ], [ [ 68, 68 ], [ 70, 70 ], [ 72, 72 ] ] ]
89322d0c6ccc61293133ba1704df8cbf83ab05de
12a0adc508dd5a2589339986047defcc6a850bef
/trunk/TCam - Recorder/TCam - Recorder/DatReader.cpp
cd35246ef95c6f5a4ce93e3ac77a286f998f74b9
[]
no_license
3dElf/tcam
d16880399afab78e941fa23e3dc558ddc4798aee
92771d884d17db4736140080a74323e7790c53e8
refs/heads/master
2023-03-24T10:38:35.279756
2008-09-13T19:59:33
2008-09-13T19:59:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,877
cpp
#include "DatReader.h" #include <string> /************************************************************************************************* Constructor *************************************************************************************************/ CDatReader::CDatReader(string fileName) { byteOffset = 0; // Initialize variables fileSize = 0; minId = 100; maxId = 0; TibiaDat = fopen(fileName.c_str(),"rb"); // Set file handle fseek(TibiaDat,0,SEEK_END); // Set pointer to end of file fileSize = ftell(TibiaDat); // Read the byte offset at to get file length in bytes fseek(TibiaDat,0,SEEK_SET); // Go back to beginning of file data = (char*) malloc (sizeof(char)*fileSize); // Allocate size to store the file in fread(data,1,fileSize,TibiaDat); // Read contents of DAT file to buffer fclose(TibiaDat); // close file Advance(4); // Advance 4 bytes to get maxId GetShort(maxId); // Get the number of items + 100 (since first item is ID:100) Advance(6); while(maxId >= minId) // Loop through all items { Object *newObject = new Object; // Create new object newObject->id = minId; // Object ID (TileID) // Reset all variables newObject->GroundTile = false; newObject->Container = false; newObject->Stackable = false; newObject->Ladder = false; newObject->Useable = false; newObject->Rune = false; newObject->Fluid = false; // Can contain fluids newObject->Splash = false; newObject->Blocking = false; newObject->Movable = true; newObject->ProjBlock = false; // Blocks projectiles such as Magicwalls or Walls newObject->CBlock = false; // blocks creatures from moving (parcels, ect...) newObject->Equipable = false; // Can pick it up newObject->Light = false; // Gives off light int flag; // flag do { flag = 0; GetByte(flag); switch(flag) { case 0x00: //is groundtile newObject->GroundTile = true; Advance(2); break; case 0x01: //Walkable break; case 0x02: //Walkable break; case 0x03: //Walkable break; case 0x04: //Container newObject->Container = true; break; case 0x05: //Stackable newObject->Stackable = true; break; case 0x06: //Ladder newObject->Ladder = true; break; case 0x07: //Useable newObject->Useable = true; break; case 0x08: //Rune newObject->Rune = true; break; case 0x09: //Writeable Advance(2); // 2 bytes for max length break; case 0x0A: //Writeable no edit Advance(2); break; case 0x0B: //Fluid newObject->Fluid = true; break; case 0x0C: //Fluid with state newObject->Splash = true; break; case 0x0D: //Blocking newObject->Blocking = true; break; case 0x0E: //Not Moveable newObject->Movable = false; break; case 0x0F: //Block Missiles newObject->ProjBlock = true; break; case 0x10: //Block Monsters newObject->CBlock = true; break; case 0x11: //Equipable newObject->Equipable = true; break; case 0x12: //Wall item break; case 0x13: // No idea... break; case 0x14: // No idea... break; case 0x15: //Rotateable break; case 0x16: //Light newObject->Light = true; Advance(4); // 2 bytes for color 2 for intensity break; case 0x17: // No object has this... break; case 0x18: //Floor Change break; case 0x19: //Draw Offset Advance(4); break; case 0x1A: // No idea... Advance(2); break; case 0x1B:// No idea... break; case 0x1C: // No idea... break; case 0x1D: // Minimap color Advance(2); // Color break; case 0x1E: // Floor change? Advance(2); break; case 0x1F: break; case 0xFF: break; default: break; } //Advance(1); }while(flag != 0xFF); int width = 0,height = 0,numFrames = 0,xDiv = 0,yDiv = 0,zDiv = 0,animLen = 0,numSprites = 0; GetByte(width); // Needed to calculate numSprites GetByte(height); if((width > 1) || (height > 1)) { Advance(1); // No idea... } GetByte(numFrames); // Number of frames GetByte(xDiv); GetByte(yDiv); GetByte(zDiv); GetByte(animLen); // Length of animation numSprites = width * height * numFrames * xDiv * yDiv * zDiv * animLen; // Get advance number Advance(numSprites * 2); // Advance (*2 because they're all shorts instead of bytes) objectList.push_back(*newObject); // Append new object ot list delete newObject; // Delete object to avoid memory leaks minId++; // Next... } } /************************************************************************************************* Destructor *************************************************************************************************/ CDatReader::~CDatReader() { } /************************************************************************************************* Function name: Advance Purpose: Advances the offset count Comments: Return: Void *************************************************************************************************/ void CDatReader::Advance(int numBytes) { if(byteOffset + numBytes > fileSize) { byteOffset = fileSize; return; } byteOffset += numBytes; // Increment bufferOffset } /************************************************************************************************* Function name: GetByte Purpose: Reads a byte from the buffer Comments: Return: Void *************************************************************************************************/ void CDatReader::GetByte(int &myByte) { //Error check!!! memcpy(&myByte,&data[byteOffset],1); byteOffset++; } /************************************************************************************************* Function name: GetShort Purpose: Reads a short from the buffer Comments: Return: Void *************************************************************************************************/ void CDatReader::GetShort(int &myByte) { //Error check!!! memcpy(&myByte,&data[byteOffset],2); byteOffset+=2; } /************************************************************************************************* Function name: GetObject Purpose: Gets an Objects flag Comments: Return: True if flag is there, false otherwise *************************************************************************************************/ bool CDatReader::GetObject(int objectId, int flag) { list<Object>::iterator i = objectList.begin(); // Beginning of list while (i != objectList.end()) // Loop { if (i->id == objectId) // If correct Id { switch(flag) { case 0: if(i->GroundTile == true) return true; break; case 1: if(i->Container == true) return true; break; case 2: if(i->Stackable == true) return true; break; case 3: if(i->Ladder == true) return true; break; case 4: if(i->Useable == true) return true; break; case 5: if(i->Rune == true) return true; break; case 6: if(i->Fluid == true) return true; break; case 7: if(i->Splash == true) return true; break; case 8: if(i->Blocking == true) return true; break; case 9: if(i->Movable == true) return true; break; case 10: if(i->ProjBlock == true) return true; break; case 11: if(i->CBlock == true) return true; break; case 12: if(i->Equipable == true) return true; break; case 13: if(i->Light == true) return true; break; default: return false; break; } return false; } ++i; } return false; }
[ "oskari.virtanen@8ce3f949-4e55-0410-954e-bd4972fa1158", "jeremic.dd@8ce3f949-4e55-0410-954e-bd4972fa1158" ]
[ [ [ 1, 3 ], [ 7, 28 ], [ 30, 177 ], [ 181, 184 ], [ 191, 200 ], [ 207, 213 ], [ 220, 226 ], [ 233, 309 ] ], [ [ 4, 6 ], [ 29, 29 ], [ 178, 180 ], [ 185, 190 ], [ 201, 206 ], [ 214, 219 ], [ 227, 232 ] ] ]
54bc10f0e32278587470835fd61a9b63dda824d7
9c62af23e0a1faea5aaa8dd328ba1d82688823a5
/rl/branches/newton20/engine/common/include/WriteableDataStreamFormatTarget.h
aad9f51341ed21960870d5817ec4fee3a1541e48
[ "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,217
h
/* This source file is part of Rastullahs Lockenpracht. * Copyright (C) 2003-2008 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. */ #include <xercesc/framework/XMLFormatter.hpp> #include "WriteableDataStream.h" namespace rl { class WriteableDataStreamFormatTarget : public XERCES_CPP_NAMESPACE::XMLFormatTarget { public: WriteableDataStreamFormatTarget(WriteableDataStreamPtr stream); void writeChars (const XMLByte *const toWrite, const unsigned int count, XERCES_CPP_NAMESPACE::XMLFormatter *const formatter); void flush (); protected: WriteableDataStreamPtr mStream; }; }
[ "melven@4c79e8ff-cfd4-0310-af45-a38c79f83013" ]
[ [ [ 1, 33 ] ] ]
0020c2c3d66712a5cd070a225dc92b6f2ea74e08
9420f67e448d4990326fd19841dd3266a96601c3
/ mcvr/mcvr/Put.h
1a556d494b05320ab22542a43b9ffe375ed713c0
[]
no_license
xrr/mcvr
4d8d7880c2fd50e41352fae1b9ede0231cf970a2
b8d3b3c46cfddee281e099945cee8d844cea4e23
refs/heads/master
2020-06-05T11:59:27.857504
2010-02-24T19:32:21
2010-02-24T19:32:21
32,275,830
0
0
null
null
null
null
UTF-8
C++
false
false
248
h
#pragma once #include "PathIndependantPayoff.h" #include "DegeneratedTrajectory.h" class Put : public PathIndependantPayoff { public: double K; //Strike Put(double=90); ~Put(void); double operator()(DegeneratedTrajectory*); };
[ "romain.rousseau@fa0ec5f0-0fe6-11df-8179-3f26cfb4ba5f" ]
[ [ [ 1, 14 ] ] ]
6ac591dd841dcf0d21a0b16fb7c0f753bc066d64
335783c9e5837a1b626073d1288b492f9f6b057f
/source/fbxcmd/daolib/Model/PHY/PIPJ.cpp
38fcaae72655e8b6b5346700b56ae721a60de2cb
[ "BSD-3-Clause", "LicenseRef-scancode-warranty-disclaimer", "BSD-2-Clause" ]
permissive
code-google-com/fbx4eclipse
110766ee9760029d5017536847e9f3dc09e6ebd2
cc494db4261d7d636f8c4d0313db3953b781e295
refs/heads/master
2016-09-08T01:55:57.195874
2009-12-03T20:35:48
2009-12-03T20:35:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
689
cpp
/********************************************************************** *< FILE: PIPJ.h DESCRIPTION: PHY File Format HISTORY: *> Copyright (c) 2009, All Rights Reserved. **********************************************************************/ #include <stdafx.h> #include "GFF/GFFCommon.h" #include "GFF/GFFField.h" #include "GFF/GFFList.h" #include "GFF/GFFStruct.h" #include "PHY/PHYCommon.h" #include "PHY/PIPJ.h" using namespace std; using namespace DAO; using namespace DAO::GFF; using namespace DAO::PHY; /////////////////////////////////////////////////////////////////// ShortString PIPJ::type("PIPJ");PIPJ::PIPJ(GFFStructRef owner) : impl(owner) { }
[ "tazpn314@ccf8930c-dfc1-11de-9043-17b7bd24f792" ]
[ [ [ 1, 26 ] ] ]
40c67b5debb8355c16738fd55166caa90198f76e
fac8de123987842827a68da1b580f1361926ab67
/inc/physics/Physics/Dynamics/Constraint/Chain/BallSocket/hkpBallSocketChainData.h
477bd00356006570a9514402d55ddb38e9ae7fc2
[]
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
5,041
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_DYNAMICS2_BALL_SOCKET_CHAIN_H #define HK_DYNAMICS2_BALL_SOCKET_CHAIN_H #include <Physics/ConstraintSolver/Solve/hkpSolverResults.h> #include <Physics/ConstraintSolver/Constraint/Atom/hkpConstraintAtom.h> #include <Physics/Dynamics/Constraint/Chain/hkpConstraintChainData.h> #include <Physics/Dynamics/Action/hkpArrayAction.h> /// A chain of ball-and-socket constraints. Useful for creating ropes or hanging bridges. class hkpBallSocketChainData : public hkpConstraintChainData { public: HK_DECLARE_REFLECTION(); HK_DECLARE_CLASS_ALLOCATOR( HK_MEMORY_CLASS_CONSTRAINT); // and action too hkpBallSocketChainData(); ~hkpBallSocketChainData(); /// Not implemented. Returns always true. hkBool isValid() const { return true; } /// Get type from this constraint virtual int getType() const; /// Returns the number of stored constraint infos. virtual int getNumConstraintInfos() { return m_infos.getSize(); } /// Adds a constraint info to the chain. /// Pivot points are specified in the local space of the bodies. void addConstraintInfoInBodySpace(const hkVector4& pivotInA, const hkVector4& pivotInB ); public: struct Runtime { /// Runtime only stores solver results. The number of solver results is (hkpBallAndSocketConstraintData::SOLVER_RESULT_MAX * getNumConstraintInfos() /// == 3 * getNumConstraintInfos()). /// Note: when the instance uses less constraints than there are constraintInfos, then the hkpSolverResults at the end of the array are uninitialized. inline const hkpSolverResults* getSolverResults() { return reinterpret_cast<hkpSolverResults*>(this); } }; inline const Runtime* getRuntime( hkpConstraintRuntime* runtime ) { return reinterpret_cast<Runtime*>(runtime); } public: // // Internal functions // /// Interface implementation. virtual void buildJacobian( const hkpConstraintQueryIn &in, hkpConstraintQueryOut &out ); /// Interface implementation. virtual void getConstraintInfo( hkpConstraintData::ConstraintInfo& info ) const; /// Interface implementation. virtual void getRuntimeInfo( hkBool wantRuntime, hkpConstraintData::RuntimeInfo& infoOut ) const; public: /// Serialization ctor. hkpBallSocketChainData(hkFinishLoadedObjectFlag f); public: struct hkpBridgeAtoms m_atoms; /// This structure holds information needed for an individual constraint in the chain. struct ConstraintInfo { HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_DYNAMICS, hkpBallSocketChainData::ConstraintInfo ); HK_DECLARE_REFLECTION(); /// Constraint's pivot point in bodyA's space. hkVector4 m_pivotInA; /// Constraint's pivot point in bodyB's space. hkVector4 m_pivotInB; }; /// Constraint infos for the chain's constraints. hkArray<struct ConstraintInfo> m_infos; /// Solver tau, this overrides the global value from hkpSolverInfo when processing the chained constraints. hkReal m_tau; /// Solver damping, this overrides the global value from hkpSolverInfo when processing the chained constraints. hkReal m_damping; /// Constraint force mixing parameter. Value added to the diagonal of the constraint matrix. /// Should be zero or tiny, e.g. a fraction of HK_REAL_EPSILON. When this value is zero, then some chain configurations /// may result in a division by zero when solving. hkReal m_cfm; /// Specifies the maximum distance error in constraints allowed before the stabilization algorithm kicks in. /// The algorithm eliminates explosions in may cases, but due to its nature it yields incorrect results in certain use cases. /// It is disabled by default. hkReal m_maxErrorDistance; }; #endif // HK_DYNAMICS2_BALL_SOCKET_CHAIN_H /* * 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, 133 ] ] ]
02b3a17f010eafcb327596b9eddb710d6166e396
0c1f669f3dfdab47085bf537348b0354f836abea
/ qtremotedroid/QTNavigator_oldcode/QTNavigator/Server/moc_UDPClient.cpp
52965ddb1e87ec8fe4ccdbc294165fa5781d738a
[]
no_license
harlentan/qtremotedroid
fc5fc96d4374c39561aea73470a88d1f0a68b637
d07dd045213711538b38c7ced2fd6d5a8edcf241
refs/heads/master
2021-01-10T11:37:59.331004
2010-12-12T09:55:39
2010-12-12T09:55:39
54,114,402
0
0
null
null
null
null
UTF-8
C++
false
false
2,532
cpp
/**************************************************************************** ** Meta object code from reading C++ file 'UDPClient.h' ** ** Created: Fri Jul 2 18:37:30 2010 ** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "src/UDPClient.h" #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'UDPClient.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 62 #error "This file was generated using the moc from 4.6.2. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE static const uint qt_meta_data_UDPClient[] = { // content: 4, // revision 0, // classname 0, 0, // classinfo 2, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount // slots: signature, parameters, type, tag, flags 13, 11, 10, 10, 0x0a, 37, 10, 10, 10, 0x0a, 0 // eod }; static const char qt_meta_stringdata_UDPClient[] = { "UDPClient\0\0e\0send_slot(QMouseEvent*)\0" "recv_slot()\0" }; const QMetaObject UDPClient::staticMetaObject = { { &QObject::staticMetaObject, qt_meta_stringdata_UDPClient, qt_meta_data_UDPClient, 0 } }; #ifdef Q_NO_DATA_RELOCATION const QMetaObject &UDPClient::getStaticMetaObject() { return staticMetaObject; } #endif //Q_NO_DATA_RELOCATION const QMetaObject *UDPClient::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; } void *UDPClient::qt_metacast(const char *_clname) { if (!_clname) return 0; if (!strcmp(_clname, qt_meta_stringdata_UDPClient)) return static_cast<void*>(const_cast< UDPClient*>(this)); return QObject::qt_metacast(_clname); } int UDPClient::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: send_slot((*reinterpret_cast< QMouseEvent*(*)>(_a[1]))); break; case 1: recv_slot(); break; default: ; } _id -= 2; } return _id; } QT_END_MOC_NAMESPACE
[ [ [ 1, 82 ] ] ]
1ca8eb18916f88745ff3f28930818de18aae9026
77d0b0ac21a9afdf667099c3cad0f9bbb483dc25
/src/tscroll.cpp
4fce00bd98c36ea8e86d49b9b84c0ff907d46fa5
[]
no_license
martinribelotta/oneshot
21e218bbdfc310bad4a531dcd401ad28625ead75
81bde2718b6dac147282cce8a1c945187b0b2ccf
refs/heads/master
2021-05-27T23:29:43.732068
2010-05-24T04:36:10
2010-05-24T04:36:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,549
cpp
/* * IGLU Iterfaz Grafica Libre del Usuario. (libre de usuarios) (Graphics user interface "free of users") * Copyright (C) 2005 Martin Alejandro Ribelotta * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <iglu/tscroll.h> #include <iglu/screen.h> #include <iglu/tshape.h> TScroll::TScroll (TPoint p, int len, int _hv): TView (Rect(p.x, p.y, 0,0)), max(0), min(0), pos(0), inc(1), hv(_hv) { State &=~stFocusheable; if (_hv==HScroll) { // Horizontal Bounds.b.x = len; Bounds.b.y = Bounds.a.y + SizeBar; Align = vaPreservH; } else { // Vertical Bounds.b.x = Bounds.a.x + SizeBar; Bounds.b.y = len; Align = vaPreservW; } } // Reftur 1 if change ocurrence, 0 is not change int TScroll::setPosForPoint (TPoint& p) { int i; TRect r; if (hv==HScroll) p.y = Bounds.a.y + (Bounds.deltay()>>1); else p.x = Bounds.a.x + (Bounds.deltax()>>1); for (i=min; i<=max; i+=inc) { getCursorGeomOf (r, i); if (r.contain(p)) return i; } return min-1; } void TScroll::getCursorGeom (TRect& r) { getCursorGeomOf (r, pos); } void TScroll::getCursorGeomOf (TRect& r, int p) { /* int cx, cy, cw, ch; int deltav, vp; r = Bounds; r.Grow(1,1); if (inc) vp = p/inc, deltav = (max-min+1) / inc; else vp = 0, deltav=0; if (max==min) vp = 0, deltav=0; if (hv==HScroll) { // Orizontal if (deltav) cw = r.deltax ()/deltav; else cw = r.deltax(); ch = r.deltay (); cx = r.a.x + cw*vp; cy = r.a.y; } else { // Vertical cw = r.deltax (); if (deltav) ch = r.deltay ()/deltav; else ch = r.deltay(); cw = r.deltax (); cx = r.a.x; cy = r.a.y + ch*vp; } r = TRect(cx, cy, cx+cw, cy+ch);*/ r = Bounds; r.Grow( 1, 1 ); p -= min; if ( hv==HScroll ) { double delta = (max-min)/(double)inc+1; double stepSize = Bounds.deltax()/delta; double zp = ((double)p)/((double)inc); r.b.x = r.a.x+(int)stepSize; r.moverel( (int)( stepSize*zp ), 0 ); } else { double delta = (max-min)/(double)inc+1; double stepSize = Bounds.deltay()/delta; double zp = ((double)p)/((double)inc); r.b.y = r.a.y+(int)stepSize; r.moverel( 0, (int)( stepSize*zp ) ); } } void TScroll::GotFocus () { if (State&stFocus) return; TView::GotFocus (); doDraw (); } void TScroll::LostFocus () { if (State&stFocus) { TView::LostFocus (); doDraw (); } } void TScroll::Draw () { TRect r; TShape shp (Bounds, shpPlane, 1, EGA_BLACK, EGA_BLACK, EGA_LIGHTGRAY); shp.Draw (); // r2.Grow (2,2); // gui_drawrectfill (r2, EGA_LIGHTGRAY); getCursorGeom (r); shp = TShape (r, shpUpBox, 1, EGA_DARKGRAY, EGA_WHITE, EGA_LIGHTGRAY);//-1); shp.Draw (); // r2.Grow (-1,-1); // gui_drawrect (r2, EGA_BLACK); } void TScroll::MouseEvent (TEvent& e) { // if (State&stFocus) { if (e.type&evMouseDown) { TRect r; getCursorGeom (r); if (Bounds.contain(e.pos)) { SetState (stSelect, 1); if (!r.contain (e.pos)) SetPos (setPosForPoint (e.pos)); } } if (State&stSelect) { if (e.type&evMouseUp) SetState (stSelect, 0); if (e.type&evMouseMove) SetPos (setPosForPoint (e.pos)); } // } } void TScroll::TimerEvent (TEvent&) { } void TScroll::SetPos (int p) { if ((pos!=p) && (p<=max) && (p>=min)) { long ud = (p>pos)? 0x80000000L: 0L; pos = p; doDraw (); TMessage m (cmChangeScroll, this, (pos&0x7FFFFFFFl)|ud); EventManager.SendMessage (m); } } void TScroll::resize( int w, int h ) { TView::resize( w, h ); SetPos( pos ); } void TScroll::RecuestAlign( TRect& a, TRect& b ) { TView::RecuestAlign( a, b ); SetPos( pos ); }
[ [ [ 1, 182 ] ] ]
0decaea1f65ee71e4b6ee192afee48ab0053cddf
fad6f9883d4ad2686c196dc532a9ecb9199500ee
/NXP-LPC/CommTest/CommTest/SvrListView.cpp
e4d69224154eb2e972f56beba0db32609cecca8b
[]
no_license
aquarius20th/nxp-lpc
fe83d6a140d361a1737d950ff728c6ea9a16a1dd
4abfb804daf0ac9c59bd90d879256e7a3c1b2f30
refs/heads/master
2021-01-10T13:54:40.237682
2009-12-22T14:54:59
2009-12-22T14:54:59
48,420,260
0
0
null
null
null
null
GB18030
C++
false
false
7,712
cpp
// SvrListView.cpp : 实现文件 // #include "stdafx.h" #include "CommTest.h" #include "SvrListView.h" #include "SvrCommDoc.h" #include <algorithm> typedef enum SVR_GRID_COL { SVR_GRID_COLUMN_IDX, // 序号 SVR_GRID_COLUMN_IP, // SVR_GRID_COLUMN_PORT , // SVR_GRID_COLUMN_STATUS , //在线状态 SVR_GRID_COLUMN_RECV, //收发次数 SVR_GRID_COLUMN_SEND // }; BEGIN_MESSAGE_MAP(CSvrListGridCtrl, CBCGPGridCtrl) ON_WM_LBUTTONDBLCLK() END_MESSAGE_MAP() void CSvrListGridCtrl::OnLButtonDblClk(UINT nFlags, CPoint point) { // TODO: 在此添加消息处理程序代码和/或调用默认值 CBCGPGridCtrl::OnLButtonDblClk(nFlags, point); if (GetParent() && GetParent()->IsKindOf(RUNTIME_CLASS(CSvrListView))) { CBCGPGridRow* pSel = GetCurSel (); if (pSel) { DWORD_PTR pData = pSel->GetData(); ((CSvrListView*)GetParent())->OnDblclkGrid(pData); } } } // CSvrListView IMPLEMENT_DYNCREATE(CSvrListView, CView) CSvrListView::CSvrListView() { } CSvrListView::~CSvrListView() { } BEGIN_MESSAGE_MAP(CSvrListView, CView) ON_WM_CREATE() ON_WM_SIZE() ON_WM_ERASEBKGND() ON_WM_DESTROY() ON_WM_SETFOCUS() ON_WM_TIMER() END_MESSAGE_MAP() // CSvrListView 绘图 void CSvrListView::OnDraw(CDC* pDC) { CDocument* pDoc = GetDocument(); // TODO: 在此添加绘制代码 } // CSvrListView 诊断 #ifdef _DEBUG void CSvrListView::AssertValid() const { CView::AssertValid(); } #ifndef _WIN32_WCE void CSvrListView::Dump(CDumpContext& dc) const { CView::Dump(dc); } #endif #endif //_DEBUG // CSvrListView 消息处理程序 int CSvrListView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) return -1; // TODO: 在此添加您专用的创建代码 CRect rectGrid; rectGrid.SetRectEmpty(); m_wndGrid.Create (WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, rectGrid, this, ID_SEVER_LIST); m_wndGrid.SetSingleSel(TRUE); m_wndGrid.SetWholeRowSel (TRUE); m_wndGrid.EnableMarkSortedColumn (FALSE); m_wndGrid.EnableMultipleSort(FALSE); m_wndGrid.EnableHeader (TRUE,BCGP_GRID_HEADER_MOVE_ITEMS); m_wndGrid.EnableLineNumbers(TRUE); m_wndGrid.InsertColumn (SVR_GRID_COLUMN_IDX, _T("序号"), 70); m_wndGrid.InsertColumn (SVR_GRID_COLUMN_IP, _T("客户端IP"), 140); m_wndGrid.InsertColumn (SVR_GRID_COLUMN_PORT, _T("端口号"), 70); m_wndGrid.InsertColumn (SVR_GRID_COLUMN_STATUS, _T("状态"), 70); m_wndGrid.InsertColumn (SVR_GRID_COLUMN_RECV, _T("接收数据包"),80); m_wndGrid.InsertColumn (SVR_GRID_COLUMN_SEND, _T("发送数据包"),80); return 0; } void CSvrListView::OnSize(UINT nType, int cx, int cy) { CView::OnSize(nType, cx, cy); if ( m_wndGrid.GetSafeHwnd()) { m_wndGrid.SetWindowPos (NULL, -1, -1, cx, cy,SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); } // TODO: 在此处添加消息处理程序代码 } void CSvrListView::OnDblclkGrid(DWORD_PTR pClient ) { CSvrCommDoc *pDoc = (CSvrCommDoc *)GetDocument(); ASSERT(pDoc); if (pDoc == NULL) return; //TEST pDoc->OpenSvrCommFrm((CClientNode *)pClient); } void CSvrListView::OnUpdate(CView* /*pSender*/, LPARAM /*lHint*/, CObject* /*pHint*/) { // TODO: 在此添加专用代码和/或调用基类 } BOOL CSvrListView::OnEraseBkgnd(CDC* pDC) { // TODO: 在此添加消息处理程序代码和/或调用默认值 return TRUE; return CView::OnEraseBkgnd(pDC); } void CSvrListView::OnSetFocus(CWnd* pOldWnd) { CView::OnSetFocus(pOldWnd); if (m_wndGrid.GetSafeHwnd() != NULL) { m_wndGrid.SetFocus(); } // TODO: 在此处添加消息处理程序代码 } void CSvrListView::CreateRow(int nIdx, CBCGPGridRow *pRow, CClientNode *pInfo ) { ASSERT(pRow && pInfo); if (pInfo == NULL || pRow == NULL) return; CString szTxt; szTxt.Format( _T("%d"),nIdx); CBCGPGridItem *pItem = pRow->GetItem(SVR_GRID_COLUMN_IDX); ASSERT(pItem); pItem->SetValue(_variant_t (szTxt),FALSE); szTxt.Format(_T("%d.%d.%d.%d"),pInfo->m_addr.sin_addr.s_net ,pInfo->m_addr.sin_addr.s_host , pInfo->m_addr.sin_addr.s_lh ,pInfo->m_addr.sin_addr.s_impno); pItem = pRow->GetItem(SVR_GRID_COLUMN_IP); ASSERT(pItem); pItem->SetValue(_variant_t (szTxt),FALSE); // szTxt.Format(_T("%d"),pInfo->m_addr.sin_port ); pItem = pRow->GetItem(SVR_GRID_COLUMN_PORT); ASSERT(pItem); pItem->SetValue(_variant_t ( htons(pInfo->m_addr.sin_port) ),FALSE); if (pInfo->m_bOnline) { szTxt = _T("在线"); } else { szTxt = _T("离线"); } pItem = pRow->GetItem(SVR_GRID_COLUMN_STATUS); ASSERT(pItem); pItem->SetValue(_variant_t (szTxt),FALSE); pRow->SetData((DWORD_PTR)pInfo); } void CSvrListView::UpdateRowInfo( CBCGPGridRow *pRow, CClientNode *pInfo ) { ASSERT(pRow && pInfo); if (pInfo == NULL || pRow == NULL) return; CString szTxt; CBCGPGridItem *pItem = NULL; if (pInfo->m_bOnline) { szTxt = _T("在线"); } else { szTxt = _T("离线"); } pItem = pRow->GetItem(SVR_GRID_COLUMN_STATUS); ASSERT(pItem); pItem->SetValue(_variant_t (szTxt),FALSE); // szTxt.Format(_T("%d"), pInfo->m_nRecvCnt); pItem = pRow->GetItem(SVR_GRID_COLUMN_RECV); ASSERT(pItem); pItem->SetValue(_variant_t (pInfo->m_nRecvCnt),FALSE); pItem = pRow->GetItem(SVR_GRID_COLUMN_SEND); ASSERT(pItem); pItem->SetValue(_variant_t (pInfo->m_nSendCnt),FALSE); } void CSvrListView::UpdateClientInfo( ) { CSvrCommDoc *pDoc = (CSvrCommDoc *)GetDocument(); ASSERT(pDoc); if (pDoc == NULL) return; if (m_wndGrid.GetSafeHwnd() == NULL) return; int nRowCnt = m_wndGrid.GetRowCount(); int i = 0; CBCGPGridRow *pRow = NULL; CClientNode *pClient = NULL; std::vector <CClientNode *> arrTmp ; std::vector <CClientNode *> arrClientNode = pDoc->m_SvrComm.GetClientNodeArr() ; std::vector <CClientNode *>::iterator iter ,iter_tmp; for (i = 0 ; i < nRowCnt;i++) { pRow = m_wndGrid.GetRow(i); ASSERT(pRow); if (pRow) { pClient = (CClientNode *)pRow->GetData(); ASSERT(pClient); if (pClient) { //刷新界面 UpdateRowInfo(pRow,pClient); arrTmp.push_back(pClient); } } } if (!arrClientNode.empty() && arrTmp != arrClientNode) {//添加新的节点 for (iter_tmp = arrTmp.begin(); iter_tmp != arrTmp.end(); ++iter_tmp) { iter = std::find(arrClientNode.begin(),arrClientNode.end(),(*iter_tmp)); if (iter != arrClientNode.end()) { arrClientNode.erase(iter); } } int nIdx = m_wndGrid.GetRowCount(); for (iter = arrClientNode.begin();iter != arrClientNode.end();++iter) { pRow = m_wndGrid.CreateNewRow (); ASSERT(pRow); if (pRow) { CreateRow(++nIdx,pRow,(*iter)); m_wndGrid.AddRow(pRow,FALSE); } } } m_wndGrid.AdjustLayout(); } const UINT_PTR ID_CLIENT_NODE_EVENT = 200804; void CSvrListView::StartUpdateClientInfo( ) { SetTimer(ID_CLIENT_NODE_EVENT,1000,NULL); } void CSvrListView::StopUpdateClientInfo( ) { KillTimer(ID_CLIENT_NODE_EVENT); //删除界面所有信息 if (m_wndGrid.GetSafeHwnd()) { m_wndGrid.RemoveAll(); } } void CSvrListView::OnTimer(UINT_PTR nIDEvent) { // TODO: 在此添加消息处理程序代码和/或调用默认值 if (nIDEvent == ID_CLIENT_NODE_EVENT) { KillTimer(ID_CLIENT_NODE_EVENT); UpdateClientInfo( ); SetTimer(ID_CLIENT_NODE_EVENT,1000,NULL); } CView::OnTimer(nIDEvent); } void CSvrListView::OnDestroy() { KillTimer(ID_CLIENT_NODE_EVENT); m_wndGrid.DestroyWindow(); CView::OnDestroy(); // TODO: 在此处添加消息处理程序代码 }
[ "lijin.unix@13de9a6c-71d3-11de-b374-81e7cb8b6ca2" ]
[ [ [ 1, 329 ] ] ]
13bcc032c6bfca0ffa7c35a3b4ac10ca77e347b5
22b6d8a368ecfa96cb182437b7b391e408ba8730
/engine/include/qvGameLogic.h
a2d05762454a56731e6d2fe9fb94bdf006eb8e86
[ "MIT" ]
permissive
drr00t/quanticvortex
2d69a3e62d1850b8d3074ec97232e08c349e23c2
b780b0f547cf19bd48198dc43329588d023a9ad9
refs/heads/master
2021-01-22T22:16:50.370688
2010-12-18T12:06:33
2010-12-18T12:06:33
85,525,059
0
0
null
null
null
null
UTF-8
C++
false
false
4,226
h
/************************************************************************************************** //This code is part of QuanticVortex for latest information, see http://www.quanticvortex.org // //Copyright (c) 2009-2010 QuanticMinds Software Ltda. // //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 __GAME_LOGIC_H_ #define __GAME_LOGIC_H_ //engine headers #include "qvActor.h" namespace qv { class CommandManager; class Game; struct SGameParams; namespace physics { class PhysicsManager; } } namespace qv { namespace gaming { class _QUANTICVORTEX_API_ GameLogic { public: GameLogic(qv::Game* game); /// create GameLogic core object to manage the game and set event manager /// and game parameters ~GameLogic(); void addActor( const qv::gaming::AI_ACTOR_ID& actorId); /// add new actor to the game Actor* getActor( const qv::gaming::AI_ACTOR_ID& actorId) /// query a registred actor from game { // ActorsMap::Node* actorNode = mActors.find(actorHashId); Actor* actor(0); // if (actorNode) // actor = actorNode->getValue(); return actor; } void removeActor(const qv::gaming::AI_ACTOR_ID& actorId) /// remove actor from the game, like when actor die or destroyed { Actor* actor = getActor(actorId); // if (actor) // mActors.delink(actorHashId); } bool loadGame(const std::string& gameName); /// load game data, and raise event to inform all subsystems void update( u32 currentTimeMs, u32 elapsedTimeMs); /// update game data, and game tick // void changeState( const qv::gaming::GS_GAME_STATE& newState); /// change the state of game, like: from menu to running void setPause(bool pause); /// pause game logic update physics::PhysicsManager* getPhysicsManager(); /// get physics subsystem access //void attachProcess(IProcess* process) //{ // if(mProcessManager)mProcessManager->attach(process); //} //void detachProcess(IProcess* process){} private: GameLogic(const GameLogic&); // to avoid copy of game logic GameLogic& operator = (const GameLogic&); // to avoid copy of game logic bool initialize(); /// initialize game logic data, like: physics susbsystem, /// raise initial game state event telling all other subsystem /// that game is ready to go bool finalize(); /// finish game logic and all subsystems u32 mCurrentGameStateHashId; u32 mHumanPlayerAttached; bool mPaused; qv::gaming::ActorsMap mActors; physics::PhysicsManager* mPhysicsManager; // game physics qv::CommandManager* mCommandManager; // command manager // IProcessManager* mProcessManager; //game logic AI //event args //qv::events::GameTickEventArgs* mGameTickEventArgs; //SPlayerScore mPlayerScore; //list<ActorID*> mAIPlayersAttached; }; // inlines inline qv::physics::PhysicsManager* GameLogic::getPhysicsManager() { return mPhysicsManager; } inline void qv::gaming::GameLogic::setPause(bool pause) { mPaused = pause; } } } #endif
[ [ [ 1, 157 ] ] ]
44bfab10c466e0c39a2066fcc4fd38a7ba87ea58
2fdbf2ba994ba3ed64f0e2dc75cd2dfce4936583
/spectre/nodepropertiesdialog.h
0f07bdd6d974707359f9895ce0477eed1702bb9e
[]
no_license
TERRANZ/terragraph
36219a4e512e15a925769512a6b60637d39830bf
ea8c36070f532ad0a4af08e46b19f4ee1b85f279
refs/heads/master
2020-05-25T10:31:26.994233
2011-01-29T21:23:04
2011-01-29T21:23:04
1,047,237
0
0
null
null
null
null
UTF-8
C++
false
false
391
h
#ifndef NODEPROPERTIESDIALOG_H #define NODEPROPERTIESDIALOG_H #include <QDialog> namespace Ui { class NodePropertiesDialog; } class NodePropertiesDialog : public QDialog { Q_OBJECT public: explicit NodePropertiesDialog(QWidget *parent = 0); ~NodePropertiesDialog(); private: Ui::NodePropertiesDialog *ui; }; #endif // NODEPROPERTIESDIALOG_H
[ [ [ 1, 23 ] ] ]
6235b23d975a93abea9d1f2369e00ef90b2f3b3f
36bf908bb8423598bda91bd63c4bcbc02db67a9d
/WallPaperUni/WallPaperUni.cpp
2f49bf6dac67a07050f46e4ac7a1fd37915e710e
[]
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
WINDOWS-1252
C++
false
false
4,321
cpp
/* WallPaperUni.cpp Eseguibile per la disinstallazione di WallPaper (SDK). Usato durante la disinstallazione per eliminare la directory base del programma. Luca Piergentili, 29/05/01 [email protected] http://www.geocities.com/crawlpaper/ WallPaper (alias crawlpaper) - the hardcore of Windows desktop http://www.crawlpaper.com/ copyright © 1998-2004 Luca Piergentili, all rights reserved crawlpaper is a registered name, all rights reserved This is a free software, released under the terms of the BSD license. Do not attempt to use it in any form which violates the license or you will be persecuted and charged for this. 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 "crawlpaper" 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 "env.h" #include "pragma.h" #include <stdio.h> #include <stdlib.h> #include "strings.h" #define STRICT 1 #include <windows.h> #include <windowsx.h> #include "win32api.h" #include "WallPaperVersion.h" #include "WallPaperUniVersion.h" #include "traceexpr.h" //#define _TRACE_FLAG _TRFLAG_TRACEOUTPUT #define _TRACE_FLAG _TRFLAG_NOTRACE #define _TRACE_FLAG_INFO _TRFLAG_NOTRACE #define _TRACE_FLAG_WARN _TRFLAG_NOTRACE #define _TRACE_FLAG_ERR _TRFLAG_NOTRACE #if (defined(_DEBUG) && defined(_WINDOWS)) && (defined(_AFX) || defined(_AFXDLL)) #ifdef PRAGMA_MESSAGE_VERBOSE #pragma message("\t\t\t"__FILE__"("STR(__LINE__)"): using DEBUG_NEW macro") #endif #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif /* WinMain() */ int WINAPI WinMain(HINSTANCE /*hInstance*/,HINSTANCE /*hPrevInstance*/,LPSTR lpszCmdLine,int /*nCmdShow*/) { // si assicura che venga passata la directory d'installazione come parametro if(!lpszCmdLine || !*lpszCmdLine) return(0); char szCmd[_MAX_PATH+1]; strcpyn(szCmd,lpszCmdLine,sizeof(szCmd)); ::RemoveBackslash(szCmd); char szBuffer[512]; _snprintf(szBuffer, sizeof(szBuffer)-1, "%s has been unregistered from your system. To complete the uninstall process the %s directory must be removed.\n\nAre you sure you want to delete %s and all its content ?", WALLPAPER_PROGRAM_NAME, WALLPAPER_PROGRAM_NAME, szCmd); // elimina la directory base del programma if(::MessageBox((HWND)NULL,szBuffer,WALLPAPERUNI_PROGRAM_TITLE,MB_TASKMODAL|MB_SETFOREGROUND|MB_TOPMOST|MB_ICONQUESTION|MB_YESNO)==IDYES) { ::DeleteFileToRecycleBin(NULL,szCmd,FALSE); _snprintf(szBuffer,sizeof(szBuffer)-1,"Uninstall complete, thank you for using %s.",WALLPAPER_PROGRAM_NAME); } else { _snprintf(szBuffer,sizeof(szBuffer)-1,"%s has been uninstalled from your system, but some elements (%s) must be removed manually.\nThank you for using %s.",WALLPAPER_PROGRAM_NAME,szCmd,WALLPAPER_PROGRAM_NAME); } ::MessageBox((HWND)NULL,szBuffer,WALLPAPERUNI_PROGRAM_TITLE,MB_TASKMODAL|MB_SETFOREGROUND|MB_TOPMOST|MB_OK|MB_ICONINFORMATION); return(0); }
[ [ [ 1, 106 ] ] ]