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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
00667cec6f0d0768391c47fc496342a19be04329 | b4f709ac9299fe7a1d3fa538eb0714ba4461c027 | /trunk/directiontestsuite.cpp | 2f2a6ab22b2e0fdc4eedc6cacef374842d8eaacc | []
| no_license | BackupTheBerlios/ptparser-svn | d953f916eba2ae398cc124e6e83f42e5bc4558f0 | a18af9c39ed31ef5fd4c5e7b69c3768c5ebb7f0c | refs/heads/master | 2020-05-27T12:26:21.811820 | 2005-11-06T14:23:18 | 2005-11-06T14:23:18 | 40,801,514 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,091 | cpp | /////////////////////////////////////////////////////////////////////////////
// Name: directiontestsuite.cpp
// Purpose: Performs unit testing on the Direction class
// Author: Brad Larsen
// Modified by:
// Created: Jan 9, 2005
// RCS-ID:
// Copyright: (c) Brad Larsen
// License: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#include "stdwx.h"
#include "directiontestsuite.h"
#include "direction.h"
#include "powertabfileheader.h" // Needed for file version constants
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
IMPLEMENT_DYNAMIC_CLASS(DirectionTestSuite, TestSuite)
/// Default Constructor
DirectionTestSuite::DirectionTestSuite()
{
//------Last Checked------//
// - Jan 11, 2005
}
/// Destructor
DirectionTestSuite::~DirectionTestSuite()
{
//------Last Checked------//
// - Jan 11, 2005
}
/// Gets the total number of tests in the test suite
/// @return The total number of tests in the test suite
size_t DirectionTestSuite::GetTestCount() const
{
//------Last Checked------//
// - Jan 11, 2005
return (602);
}
/// Executes all test cases in the test suite
/// @return True if all tests were executed, false if not
bool DirectionTestSuite::RunTestCases()
{
//------Last Checked------//
// - Jan 11, 2005
if (!TestCaseConstructor())
return (false);
if (!TestCaseCreation())
return (false);
if (!TestCaseOperator())
return (false);
if (!TestCaseSerialize())
return (false);
if (!TestCasePosition())
return (false);
if (!TestCaseSymbolType())
return (false);
if (!TestCaseActiveSymbol())
return (false);
if (!TestCaseRepeatNumber())
return (false);
if (!TestCaseSymbolArray())
return (false);
if (!TestCaseOperations())
return (false);
return (true);
}
/// Tests the Constructors
/// @return True if all tests were executed, false if not
bool DirectionTestSuite::TestCaseConstructor()
{
//------Last Checked------//
// - Jan 11, 2005
// TEST CASE: Default constructor
{
Direction direction;
TEST(wxT("Default Constructor"),
(direction.GetPosition() == Direction::DEFAULT_POSITION) &&
(direction.GetSymbolCount() == 0)
);
}
// TEST CASE: Primary constructor
{
Direction direction(12, Direction::toCoda, Direction::activeDaCapo, 4);
wxByte symbolType = 0;
wxByte activeSymbol = 0;
wxByte repeatNumber = 0;
bool ok = direction.GetSymbol(0, symbolType, activeSymbol, repeatNumber);
TEST(wxT("Primary Constructor"),
(ok) &&
(direction.GetPosition() == 12) &&
(symbolType == Direction::toCoda) &&
(activeSymbol == Direction::activeDaCapo) &&
(repeatNumber == 4)
);
}
// TEST CASE: Copy constructor
{
Direction direction(12, Direction::toCoda, Direction::activeDaCapo, 4);
Direction direction2(direction);
TEST(wxT("Copy Constructor"),
(direction2 == direction)
);
}
return (true);
}
/// Tests the Creation Functions
/// @return True if all tests were executed, false if not
bool DirectionTestSuite::TestCaseCreation()
{
//------Last Checked------//
// - Jan 11, 2005
Direction direction(12, Direction::toCoda, Direction::activeDaCapo, 4);
Direction* clone = (Direction*)direction.CloneObject();
TEST(wxT("CloneObject"),
(*clone == direction)
);
delete clone;
return (true);
}
/// Tests the Operators
/// @return True if all tests were executed, false if not
bool DirectionTestSuite::TestCaseOperator()
{
//------Last Checked------//
// - Jan 11, 2005
// TEST CASE: Operator=
{
Direction direction(12, Direction::toCoda, Direction::activeDaCapo, 4);
Direction direction2 = direction;
TEST(wxT("Operator="),
(direction2 == direction)
);
direction = direction;
TEST(wxT("Operator= (self-assignment)"),
(direction == direction)
);
}
// TEST CASE: Operator==
{
Direction direction(12, Direction::toCoda, Direction::activeDaCapo, 4);
Direction direction2(12, Direction::toCoda, Direction::activeDaCapo, 4);
Direction direction3(13, Direction::toDoubleCoda, Direction::activeDaCapo, 4);
Direction direction4(12, Direction::toCoda, Direction::activeNone, 4);
Direction direction5(12, Direction::toCoda, Direction::activeDaCapo, 5);
Direction direction6(12, Direction::toCoda, Direction::activeDaCapo, 4);
direction6.AddSymbol(Direction::toDoubleCoda, Direction::activeDaCapo, 4);
TEST(wxT("Operator== - direction == direction"), (direction == direction2));
TEST(wxT("Operator== - direction != direction"), !(direction == direction3));
TEST(wxT("Operator== - direction != direction 2"), !(direction == direction4));
TEST(wxT("Operator== - direction != direction 3"), !(direction == direction5));
TEST(wxT("Operator== - direction != direction 4"), !(direction == direction6));
}
// TEST CASE: Operator!=
{
Direction direction(12, Direction::toCoda, Direction::activeDaCapo, 4);
Direction direction2(12, Direction::toCoda, Direction::activeDaCapo, 4);
Direction direction3(13, Direction::toDoubleCoda, Direction::activeDaCapo, 4);
Direction direction4(12, Direction::toCoda, Direction::activeNone, 4);
Direction direction5(12, Direction::toCoda, Direction::activeDaCapo, 5);
Direction direction6(12, Direction::toCoda, Direction::activeDaCapo, 4);
direction6.AddSymbol(Direction::toDoubleCoda, Direction::activeDaCapo, 4);
TEST(wxT("Operator!= - direction == direction"), !(direction != direction2));
TEST(wxT("Operator!= - direction != direction"), (direction != direction3));
TEST(wxT("Operator!= - direction != direction 2"), (direction != direction4));
TEST(wxT("Operator!= - direction != direction 3"), (direction != direction5));
TEST(wxT("Operator!= - direction != direction 4"), (direction != direction6));
}
return (true);
}
/// Tests the Serialization Fucntions
/// @return True if all tests were executed, false if not
bool DirectionTestSuite::TestCaseSerialize()
{
//------Last Checked------//
// - Jan 11, 2005
bool ok = false;
TestStream testStream;
PowerTabOutputStream streamOut(testStream.GetOutputStream());
// Write test data to stream
Direction directionOut(12, Direction::toCoda, Direction::activeDaCapo, 4);
directionOut.Serialize(streamOut);
// Output must be OK before using input
if (testStream.CheckOutputState())
{
PowerTabInputStream streamIn(testStream.GetInputStream());
// Read test data back from stream
Direction directionIn;
directionIn.Deserialize(streamIn, PowerTabFileHeader::FILEVERSION_CURRENT);
// Validate the data
ok = ((directionIn == directionOut)
&& (streamIn.CheckState()));
}
TEST(wxT("Serialize"), ok);
return (true);
}
/// Tests the Position Functions
/// @return True if all tests were executed, false if not
bool DirectionTestSuite::TestCasePosition()
{
//------Last Checked------//
// - Jan 11, 2005
Direction direction;
// TEST CASE: IsValidPosition
{
wxUint32 i = 0;
for (; i <= (Direction::MAX_POSITION + 1); i++)
{
TEST(wxString::Format(wxT("IsValidPosition - %d"), i),
(Direction::IsValidPosition(i) == (i <= Direction::MAX_POSITION))
);
}
}
// TEST CASE: SetPosition
{
wxUint32 i = 0;
for (; i <= (Direction::MAX_POSITION + 1); i++)
{
TEST(wxT("SetPosition - %d"),
(direction.SetPosition(i) == (i <= Direction::MAX_POSITION)) &&
((i > Direction::MAX_POSITION) ? 1 : (direction.GetPosition() == i))
);
}
}
return (true);
}
/// Tests the Symbol Type Functions
/// @return True if all tests were executed, false if not
bool DirectionTestSuite::TestCaseSymbolType()
{
//------Last Checked------//
// - Jan 11, 2005
wxByte i = Direction::coda;
for (; i <= (Direction::dalSegnoSegnoAlFine + 1); i++)
TEST(wxString::Format(wxT("IsValidSymbolType - %d"), i),
(Direction::IsValidSymbolType(i) == (i <= Direction::dalSegnoSegnoAlFine))
);
return (true);
}
/// Tests the Active Symbol Functions
/// @return True if all tests were executed, false if not
bool DirectionTestSuite::TestCaseActiveSymbol()
{
//------Last Checked------//
// - Jan 11, 2005
wxByte i = Direction::activeNone;
for (; i <= (Direction::activeDalSegnoSegno + 1); i++)
TEST(wxString::Format(wxT("IsValidActiveSymbol - %d"), i),
(Direction::IsValidActiveSymbol(i) == (i <= Direction::activeDalSegnoSegno))
);
return (true);
}
/// Tests the Repeat Number Functions
/// @return True if all tests were executed, false if not
bool DirectionTestSuite::TestCaseRepeatNumber()
{
//------Last Checked------//
// - Jan 11, 2005
wxByte i = 0;
for (; i <= (Direction::MAX_REPEAT_NUMBER + 1); i++)
TEST(wxString::Format(wxT("IsValidRepeatNumber - %d"), i),
(Direction::IsValidRepeatNumber(i) == (i <= Direction::MAX_REPEAT_NUMBER))
);
return (true);
}
/// Tests the Symbol Array Functions
bool DirectionTestSuite::TestCaseSymbolArray()
{
//------Last Checked------//
// - Jan 11, 2005
Direction direction(12, Direction::toCoda, Direction::activeDaCapo, 4);
direction.AddSymbol(Direction::toDoubleCoda, Direction::activeDalSegno, 5);
direction.AddSymbol(Direction::coda);
// TEST CASE: IsValidSymbolIndex
{
wxUint32 i = 0;
for (; i <= Direction::MAX_SYMBOLS; i++)
TEST(wxString::Format(wxT("IsValidSymbolIndex - %d"), i),
(direction.IsValidSymbolIndex(i) == (i < Direction::MAX_SYMBOLS))
);
}
// TEST CASE: AddSymbol
{
Direction direction2;
TEST(wxT("AddSymbol"),
(direction2.AddSymbol(Direction::toCoda, Direction::activeDaCapo, 5)) &&
(direction2.GetSymbolCount() == 1)
);
TEST(wxT("AddSymbol - full"), (!direction.AddSymbol(Direction::doubleCoda)));
}
// TEST CASE: GetSymbolCount
{
TEST(wxT("GetSymbolCount"), (direction.GetSymbolCount() == 3));
}
// TEST CASE: SetSymbol
{
Direction direction2(12, Direction::toCoda, Direction::activeDaCapo, 5);
TEST(wxT("SetSymbol - invalid index"),
(!direction2.SetSymbol(Direction::MAX_SYMBOLS, Direction::coda, Direction::activeNone, 0))
);
TEST(wxT("SetSymbol - invalid symbol type"),
(!direction2.SetSymbol(0, 255, Direction::activeNone, 0))
);
TEST(wxT("SetSymbol - invalid active symbol"),
(!direction2.SetSymbol(0, Direction::coda, 255, 0))
);
TEST(wxT("SetSymbol - invalid repeat number"),
(!direction2.SetSymbol(0, Direction::coda, Direction::activeNone, Direction::MAX_REPEAT_NUMBER + 1))
);
direction2.SetSymbol(0, Direction::coda, Direction::activeNone, 0);
wxByte symbolType = 0;
wxByte activeSymbol = 0;
wxByte repeatNumber = 0;
direction2.GetSymbol(0, symbolType, activeSymbol, repeatNumber);
TEST(wxT("SetSymbol"),
(symbolType == Direction::coda) &&
(activeSymbol == Direction::activeNone) &&
(repeatNumber == 0)
);
}
// TEST CASE: IsSymbolType
{
TEST(wxT("IsSymbolType - invalid index"),
(!direction.IsSymbolType(Direction::MAX_SYMBOLS, Direction::toCoda))
);
TEST(wxT("IsSymbolType - invalid symbol type"),
(!direction.IsSymbolType(0, 255))
);
TEST(wxT("IsSymbolType"),
(direction.IsSymbolType(0, Direction::toCoda)) &&
(direction.IsSymbolType(1, Direction::toDoubleCoda)) &&
(direction.IsSymbolType(2, Direction::coda))
);
}
// TEST CASE: RemoveSymbolAtIndex
{
TEST(wxT("RemoveSymbolAtIndex - invalid index"),
(!direction.RemoveSymbolAtIndex(Direction::MAX_SYMBOLS))
);
TEST(wxT("RemoveSymbolAtIndex"),
(direction.RemoveSymbolAtIndex(0)) &&
(direction.GetSymbolCount() == 2)
);
}
// TEST CASE: DeleteSymbolArrayContents
{
direction.DeleteSymbolArrayContents();
TEST(wxT("DeleteSymbolArrayContents"),
(direction.GetSymbolCount() == 0)
);
}
return (true);
}
/// Tests the Operations
/// @return True if all tests were executed, false if not
bool DirectionTestSuite::TestCaseOperations()
{
//------Last Checked------//
// - Jan 11, 2005
Direction direction(12, Direction::toCoda, Direction::activeDaCapo, 4);
TEST(wxT("GetText - invalid symbol index"), (!direction.GetText(1)));
TEST(wxT("GetText"), (direction.GetText(0) == wxT("To Coda")));
return (true);
}
| [
"blarsen@8c24db97-d402-0410-b267-f151a046c31a"
]
| [
[
[
1,
421
]
]
]
|
ddbb6d07adc9dfac8216914be821f353206fc3b4 | 1c84fe02ecde4a78fb03d3c28dce6fef38ebaeff | /ControllerAttr.h | 7389fa353d8b98f846f8928d9ccd06a48a6be092 | []
| no_license | aadarshasubedi/beesiege | c29cb8c3fce910771deec5bb63bcb32e741c1897 | 2128b212c5c5a68e146d3f888bb5a8201c8104f7 | refs/heads/master | 2016-08-12T08:37:10.410041 | 2007-12-16T20:57:33 | 2007-12-16T20:57:33 | 36,995,410 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 396 | h | #ifndef CONTROLLERATTR_H
#define CONTROLLERATTR_H
#include "CharacterAttribute.h"
#include "GameCharacter.h"
class ControllerAttr : public CharacterAttribute
{
NiDeclareRTTI;
public:
// ctor / dtor
ControllerAttr(GameCharacter* owner);
virtual ~ControllerAttr();
// pure virtual update
virtual void Update(float fTime) = 0;
};
NiSmartPointer(ControllerAttr);
#endif | [
"[email protected]"
]
| [
[
[
1,
21
]
]
]
|
0df70332aec68672ac3d7ccec5675d77649bfb44 | b2d46af9c6152323ce240374afc998c1574db71f | /cursovideojuegos/theflostiproject/Code/proyectos/Quake/ItemLife.cpp | 3cd1c8c57c6b780573018e1826e237b4cb3da2ae | []
| 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 | 153 | cpp | #include "__PCH_Quake.h"
#include "ItemLife.h"
CItemLife::CItemLife(void)
:CItem()
,mi_AmountLife(0)
{
}
CItemLife::~CItemLife(void)
{
}
| [
"ohernandezba@71d53fa2-cca5-e1f2-4b5e-677cbd06613a"
]
| [
[
[
1,
13
]
]
]
|
f250f7c5d1b7d9f25619e2ca5a198b28228f1372 | 0468c65f767387da526efe03b37e1d6e8ddd1815 | /source/drivers/sdl/sdl-video.cpp | 427130d319069bdd496861db2cdb43dfd0e674ee | []
| no_license | arntsonl/fc2x | aadc4e1a6c4e1d5bfcc76a3815f1f033b2d7e2fd | 57ffbf6bcdf0c0b1d1e583663e4466adba80081b | refs/heads/master | 2021-01-13T02:22:19.536144 | 2011-01-11T22:48:58 | 2011-01-11T22:48:58 | 32,103,729 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 20,738 | cpp | /* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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 USA
*/
/// \file
/// \brief Handles the graphical game display for the SDL implementation.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "sdl.h"
#include "sdl-opengl.h"
#include "../common/vidblit.h"
#include "../../fceu.h"
#include "../../version.h"
#include "../../utils/memory.h"
#include "sdl-icon.h"
#include "dface.h"
#include "../common/configSys.h"
#include "sdl-video.h"
#ifdef CREATE_AVI
#include "../videolog/nesvideos-piece.h"
#endif
#ifdef _GTK
#include "gui.h"
#endif
// GLOBALS
extern Config *g_config;
// STATIC GLOBALS
extern SDL_Surface *s_screen;
static SDL_Surface *s_BlitBuf; // Buffer when using hardware-accelerated blits.
static SDL_Surface *s_IconSurface = NULL;
static int s_curbpp;
static int s_srendline, s_erendline;
static int s_tlines;
static int s_inited;
#ifdef OPENGL
static int s_useOpenGL;
#endif
static double s_exs, s_eys;
static int s_eefx;
static int s_clipSides;
static int s_fullscreen;
static int noframe;
#define NWIDTH (256 - (s_clipSides ? 16 : 0))
#define NOFFSET (s_clipSides ? 8 : 0)
static int s_paletterefresh;
extern bool MaxSpeed;
/**
* Attempts to destroy the graphical video display. Returns 0 on
* success, -1 on failure.
*/
//draw input aids if we are fullscreen
bool FCEUD_ShouldDrawInputAids()
{
return s_fullscreen!=0;
}
int
KillVideo()
{
// if the IconSurface has been initialized, destroy it
if(s_IconSurface) {
SDL_FreeSurface(s_IconSurface);
s_IconSurface=0;
}
// return failure if the video system was not initialized
if(s_inited == 0)
return -1;
// if the rest of the system has been initialized, shut it down
#ifdef OPENGL
// check for OpenGL and shut it down
if(s_useOpenGL)
KillOpenGL();
else
#endif
// shut down the system that converts from 8 to 16/32 bpp
if(s_curbpp > 8)
KillBlitToHigh();
// shut down the SDL video sub-system
SDL_QuitSubSystem(SDL_INIT_VIDEO);
s_inited = 0;
return 0;
}
// this variable contains information about the special scaling filters
static int s_sponge;
/**
* These functions determine an appropriate scale factor for fullscreen/
*/
inline double GetXScale(int xres)
{
return ((double)xres) / NWIDTH;
}
inline double GetYScale(int yres)
{
return ((double)yres) / s_tlines;
}
void FCEUD_VideoChanged()
{
int buf;
g_config->getOption("SDL.PAL", &buf);
if(buf)
PAL = 1;
else
PAL = 0;
}
/**
* Attempts to initialize the graphical video display. Returns 0 on
* success, -1 on failure.
*/
int
InitVideo(FCEUGI *gi)
{
// XXX soules - const? is this necessary?
const SDL_VideoInfo *vinf;
int error, flags = 0;
int doublebuf, xstretch, ystretch, xres, yres;
FCEUI_printf("Initializing video...");
// load the relevant configuration variables
g_config->getOption("SDL.Fullscreen", &s_fullscreen);
g_config->getOption("SDL.DoubleBuffering", &doublebuf);
#ifdef OPENGL
g_config->getOption("SDL.OpenGL", &s_useOpenGL);
#endif
g_config->getOption("SDL.SpecialFilter", &s_sponge);
g_config->getOption("SDL.XStretch", &xstretch);
g_config->getOption("SDL.YStretch", &ystretch);
g_config->getOption("SDL.XResolution", &xres);
g_config->getOption("SDL.YResolution", &yres);
g_config->getOption("SDL.ClipSides", &s_clipSides);
g_config->getOption("SDL.NoFrame", &noframe);
// check the starting, ending, and total scan lines
FCEUI_GetCurrentVidSystem(&s_srendline, &s_erendline);
s_tlines = s_erendline - s_srendline + 1;
// check for OpenGL and set the global flags
#if OPENGL
if(s_useOpenGL && !s_sponge) {
flags = SDL_OPENGL;
}
#endif
// initialize the SDL video subsystem if it is not already active
if(!SDL_WasInit(SDL_INIT_VIDEO)) {
error = SDL_InitSubSystem(SDL_INIT_VIDEO);
if(error) {
FCEUD_PrintError(SDL_GetError());
return -1;
}
}
s_inited = 1;
// shows the cursor within the display window
SDL_ShowCursor(1);
// determine if we can allocate the display on the video card
vinf = SDL_GetVideoInfo();
if(vinf->hw_available) {
flags |= SDL_HWSURFACE;
}
// check if we are rendering fullscreen
if(s_fullscreen) {
flags |= SDL_FULLSCREEN;
SDL_ShowCursor(0);
}
else {
SDL_ShowCursor(1);
}
if(noframe) {
flags |= SDL_NOFRAME;
}
// gives the SDL exclusive palette control... ensures the requested colors
flags |= SDL_HWPALETTE;
// enable double buffering if requested and we have hardware support
#ifdef OPENGL
if(s_useOpenGL) {
FCEU_printf("Initializing with OpenGL (Disable with '-opengl 0').\n");
if(doublebuf) {
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
}
} else
#endif
if(doublebuf && (flags & SDL_HWSURFACE)) {
flags |= SDL_DOUBLEBUF;
}
if(s_fullscreen) {
int desbpp, autoscale;
g_config->getOption("SDL.BitsPerPixel", &desbpp);
g_config->getOption("SDL.AutoScale", &autoscale);
if (autoscale)
{
double auto_xscale = GetXScale(xres);
double auto_yscale = GetYScale(yres);
double native_ratio = ((double)NWIDTH) / s_tlines;
double screen_ratio = ((double)xres) / yres;
int keep_ratio;
g_config->getOption("SDL.KeepRatio", &keep_ratio);
// Try to choose resolution
if (screen_ratio < native_ratio)
{
// The screen is narrower than the original. Maximizing width will not clip
auto_xscale = auto_yscale = GetXScale(xres);
if (keep_ratio)
auto_yscale = GetYScale(yres);
}
else
{
auto_yscale = auto_xscale = GetYScale(yres);
if (keep_ratio)
auto_xscale = GetXScale(xres);
}
s_exs = auto_xscale;
s_eys = auto_yscale;
}
else
{
g_config->getOption("SDL.XScale", &s_exs);
g_config->getOption("SDL.YScale", &s_eys);
}
g_config->getOption("SDL.SpecialFX", &s_eefx);
#ifdef OPENGL
if(!s_useOpenGL) {
s_exs = (int)s_exs;
s_eys = (int)s_eys;
} else {
desbpp = 0;
}
// -Video Modes Tag-
if(s_sponge) {
if(s_sponge == 4 || s_sponge == 5) {
s_exs = s_eys = 3;
} else {
s_exs = s_eys = 2;
}
s_eefx = 0;
if(s_sponge == 1 || s_sponge == 4) {
desbpp = 32;
}
}
if((s_useOpenGL && !xstretch) || !s_useOpenGL)
#endif
if(xres < (NWIDTH * s_exs) || s_exs <= 0.01) {
FCEUD_PrintError("xscale out of bounds.");
KillVideo();
return -1;
}
#ifdef OPENGL
if((s_useOpenGL && !ystretch) || !s_useOpenGL)
#endif
if(yres < s_tlines * s_eys || s_eys <= 0.01) {
FCEUD_PrintError("yscale out of bounds.");
KillVideo();
return -1;
}
s_screen = SDL_SetVideoMode(xres, yres, desbpp, flags);
if(!s_screen) {
FCEUD_PrintError(SDL_GetError());
return -1;
}
} else {
int desbpp;
g_config->getOption("SDL.BitsPerPixel", &desbpp);
g_config->getOption("SDL.XScale", &s_exs);
g_config->getOption("SDL.YScale", &s_eys);
g_config->getOption("SDL.SpecialFX", &s_eefx);
// -Video Modes Tag-
if(s_sponge) {
if(s_sponge >= 4) {
s_exs = s_eys = 3;
} else {
s_exs = s_eys = 2;
}
s_eefx = 0;
}
#ifdef OPENGL
if(!s_useOpenGL) {
s_exs = (int)s_exs;
s_eys = (int)s_eys;
}
if(s_exs <= 0.01) {
FCEUD_PrintError("xscale out of bounds.");
KillVideo();
return -1;
}
if(s_eys <= 0.01) {
FCEUD_PrintError("yscale out of bounds.");
KillVideo();
return -1;
}
if(s_sponge && s_useOpenGL) {
FCEUD_PrintError("scalers not compatible with openGL mode.");
KillVideo();
return -1;
}
#endif
s_screen = SDL_SetVideoMode((int)(NWIDTH * s_exs),
(int)(s_tlines * s_eys),
desbpp, flags);
if(!s_screen) {
FCEUD_PrintError(SDL_GetError());
return -1;
}
}
s_curbpp = s_screen->format->BitsPerPixel;
if(!s_screen) {
FCEUD_PrintError(SDL_GetError());
KillVideo();
return -1;
}
#if 0
// XXX soules - this would be creating a surface on the video
// card, but was commented out for some reason...
s_BlitBuf = SDL_CreateRGBSurface(SDL_HWSURFACE, 256, 240,
s_screen->format->BitsPerPixel,
s_screen->format->Rmask,
s_screen->format->Gmask,
s_screen->format->Bmask, 0);
#endif
FCEU_printf(" Video Mode: %d x %d x %d bpp %s\n",
s_screen->w, s_screen->h, s_screen->format->BitsPerPixel,
s_fullscreen ? "full screen" : "");
if(s_curbpp != 8 && s_curbpp != 16 && s_curbpp != 24 && s_curbpp != 32) {
FCEU_printf(" Sorry, %dbpp modes are not supported by FCE Ultra. Supported bit depths are 8bpp, 16bpp, and 32bpp.\n", s_curbpp);
KillVideo();
return -1;
}
// if the game being run has a name, set it as the window name
if(gi->name) {
SDL_WM_SetCaption((const char *)gi->name, (const char *)gi->name);
} else {
SDL_WM_SetCaption(FCEU_NAME_AND_VERSION,"FCE Ultra");
}
// create the surface for displaying graphical messages
#ifdef LSB_FIRST
s_IconSurface = SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data,
32, 32, 24, 32 * 3,
0xFF, 0xFF00, 0xFF0000, 0x00);
#else
s_IconSurface = SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data,
32, 32, 24, 32 * 3,
0xFF0000, 0xFF00, 0xFF, 0x00);
#endif
SDL_WM_SetIcon(s_IconSurface,0);
s_paletterefresh = 1;
// XXX soules - can't SDL do this for us?
// if using more than 8bpp, initialize the conversion routines
if(s_curbpp > 8) {
InitBlitToHigh(s_curbpp >> 3,
s_screen->format->Rmask,
s_screen->format->Gmask,
s_screen->format->Bmask,
s_eefx, s_sponge, 0);
#ifdef OPENGL
if(s_useOpenGL)
{
int openGLip;
g_config->getOption("SDL.OpenGLip", &openGLip);
if(!InitOpenGL(NOFFSET, 256 - (s_clipSides ? 8 : 0),
s_srendline, s_erendline + 1,
s_exs, s_eys, s_eefx,
openGLip, xstretch, ystretch, s_screen))
{
FCEUD_PrintError("Error initializing OpenGL.");
KillVideo();
return -1;
}
}
#endif
}
return 0;
}
/**
* Toggles the full-screen display.
*/
void
ToggleFS()
{
int error, fullscreen = s_fullscreen;
// shut down the current video system
KillVideo();
// flip the fullscreen flag
g_config->setOption("SDL.Fullscreen", !fullscreen);
#ifdef _GTK
if(!fullscreen)
showGui(0);
else
showGui(1);
#endif
// try to initialize the video
error = InitVideo(GameInfo);
if(error) {
// if we fail, just continue with what worked before
g_config->setOption("SDL.Fullscreen", fullscreen);
InitVideo(GameInfo);
}
}
static SDL_Color s_psdl[256];
/**
* Sets the color for a particular index in the palette.
*/
void
FCEUD_SetPalette(uint8 index,
uint8 r,
uint8 g,
uint8 b)
{
s_psdl[index].r = r;
s_psdl[index].g = g;
s_psdl[index].b = b;
s_paletterefresh = 1;
}
/**
* Gets the color for a particular index in the palette.
*/
void
FCEUD_GetPalette(uint8 index,
uint8 *r,
uint8 *g,
uint8 *b)
{
*r = s_psdl[index].r;
*g = s_psdl[index].g;
*b = s_psdl[index].b;
}
/**
* Pushes the palette structure into the underlying video subsystem.
*/
static void
RedoPalette()
{
#ifdef OPENGL
if(s_useOpenGL)
SetOpenGLPalette((uint8*)s_psdl);
else
#endif
{
if(s_curbpp > 8) {
SetPaletteBlitToHigh((uint8*)s_psdl);
} else {
SDL_SetPalette(s_screen, SDL_PHYSPAL, s_psdl, 0, 256);
}
}
}
// XXX soules - console lock/unlock unimplemented?
///Currently unimplemented.
void LockConsole(){}
///Currently unimplemented.
void UnlockConsole(){}
/**
* Pushes the given buffer of bits to the screen.
*/
void
BlitScreen(uint8 *XBuf)
{
SDL_Surface *TmpScreen;
uint8 *dest;
int xo = 0, yo = 0;
if(!s_screen) {
return;
}
// refresh the palette if required
if(s_paletterefresh) {
RedoPalette();
s_paletterefresh = 0;
}
#ifdef OPENGL
// OpenGL is handled separately
if(s_useOpenGL) {
BlitOpenGL(XBuf);
return;
}
#endif
// XXX soules - not entirely sure why this is being done yet
XBuf += s_srendline * 256;
if(s_BlitBuf) {
TmpScreen = s_BlitBuf;
} else {
TmpScreen = s_screen;
}
// lock the display, if necessary
if(SDL_MUSTLOCK(TmpScreen)) {
if(SDL_LockSurface(TmpScreen) < 0) {
return;
}
}
dest = (uint8*)TmpScreen->pixels;
if(s_fullscreen) {
xo = (int)(((TmpScreen->w - NWIDTH * s_exs)) / 2);
dest += xo * (s_curbpp >> 3);
if(TmpScreen->h > (s_tlines * s_eys)) {
yo = (int)((TmpScreen->h - s_tlines * s_eys) / 2);
dest += yo * TmpScreen->pitch;
}
}
// XXX soules - again, I'm surprised SDL can't handle this
// perform the blit, converting bpp if necessary
if(s_curbpp > 8) {
if(s_BlitBuf) {
Blit8ToHigh(XBuf + NOFFSET, dest, NWIDTH, s_tlines,
TmpScreen->pitch, 1, 1);
} else {
Blit8ToHigh(XBuf + NOFFSET, dest, NWIDTH, s_tlines,
TmpScreen->pitch, (int)s_exs, (int)s_eys);
}
} else {
if(s_BlitBuf) {
Blit8To8(XBuf + NOFFSET, dest, NWIDTH, s_tlines,
TmpScreen->pitch, 1, 1, 0, s_sponge);
} else {
Blit8To8(XBuf + NOFFSET, dest, NWIDTH, s_tlines,
TmpScreen->pitch, (int)s_exs, (int)s_eys,
s_eefx, s_sponge);
}
}
// unlock the display, if necessary
if(SDL_MUSTLOCK(TmpScreen)) {
SDL_UnlockSurface(TmpScreen);
}
// if we have a hardware video buffer, do a fast video->video copy
if(s_BlitBuf) {
SDL_Rect srect;
SDL_Rect drect;
srect.x = 0;
srect.y = 0;
srect.w = NWIDTH;
srect.h = s_tlines;
drect.x = 0;
drect.y = 0;
drect.w = (Uint16)(s_exs * NWIDTH);
drect.h = (Uint16)(s_eys * s_tlines);
SDL_BlitSurface(s_BlitBuf, &srect, s_screen, &drect);
}
// ensure that the display is updated
SDL_UpdateRect(s_screen, xo, yo,
(Uint32)(NWIDTH * s_exs), (Uint32)(s_tlines * s_eys));
#ifdef CREATE_AVI
#if 0 /* PAL INTO NTSC HACK */
{ int fps = FCEUI_GetDesiredFPS();
if(FCEUI_GetDesiredFPS() == 838977920) fps = 1008307711;
NESVideoLoggingVideo(s_screen->pixels, width,height, fps, s_curbpp);
if(FCEUI_GetDesiredFPS() == 838977920)
{
static unsigned dup=0;
if(++dup==5) { dup=0;
NESVideoLoggingVideo(s_screen->pixels, width,height, fps, s_curbpp); }
} }
#else
{ int fps = FCEUI_GetDesiredFPS();
static unsigned char* result = NULL;
static unsigned resultsize = 0;
int width = NWIDTH, height = s_tlines;
if(!result || resultsize != width*height*3*2)
{
if(result) free(result);
result = (unsigned char*) FCEU_dmalloc(resultsize = width*height*3*2);
}
switch(s_curbpp)
{
#if 0
case 24: case 32: case 15: case 16:
/* Convert to I420 if possible, because our I420 conversion is optimized
* and it'll produce less network traffic, hence faster throughput than
* anything else. And H.264 eats only I420, so it'd be converted sooner
* or later anyway if we didn't do it. Win-win situation.
*/
switch(s_curbpp)
{
case 32: Convert32To_I420Frame(s_screen->pixels, &result[0], width*height, width); break;
case 24: Convert24To_I420Frame(s_screen->pixels, &result[0], width*height, width); break;
case 15: Convert15To_I420Frame(s_screen->pixels, &result[0], width*height, width); break;
case 16: Convert16To_I420Frame(s_screen->pixels, &result[0], width*height, width); break;
}
NESVideoLoggingVideo(&result[0], width,height, fps, 12);
break;
#endif
default:
NESVideoLoggingVideo(s_screen->pixels, width,height, fps, s_curbpp);
}
}
#endif
#if REALTIME_LOGGING
{
static struct timeval last_time;
static int first_time=1;
extern long soundrate;
struct timeval cur_time;
gettimeofday(&cur_time, NULL);
double timediff =
(cur_time.tv_sec *1e6 + cur_time.tv_usec
- (last_time.tv_sec *1e6 + last_time.tv_usec)) / 1e6;
int nframes = timediff * 60 - 1;
if(first_time)
first_time = 0;
else while(nframes > 0)
{
static const unsigned char Buf[800*4] = {0};
NESVideoLoggingVideo(screen->pixels, 256,tlines, FCEUI_GetDesiredFPS(), s_curbpp);
NESVideoLoggingAudio(Buf, soundrate,16,1, soundrate/60.0);
--nframes;
}
memcpy(&last_time, &cur_time, sizeof(last_time));
}
#endif
#endif
// have to flip the displayed buffer in the case of double buffering
if(s_screen->flags & SDL_DOUBLEBUF) {
SDL_Flip(s_screen);
}
}
/**
* Converts an x-y coordinate in the window manager into an x-y
* coordinate on FCEU's screen.
*/
uint32
PtoV(uint16 x,
uint16 y)
{
y = (uint16)((double)y / s_eys);
x = (uint16)((double)x / s_exs);
if(s_clipSides) {
x += 8;
}
y += s_srendline;
return (x | (y << 16));
}
bool disableMovieMessages = false;
bool FCEUI_AviDisableMovieMessages()
{
if (disableMovieMessages)
return true;
return false;
}
void FCEUI_SetAviDisableMovieMessages(bool disable)
{
disableMovieMessages = disable;
}
| [
"Cthulhu32@e9098629-9c10-95be-0fa9-336bad66c20b"
]
| [
[
[
1,
744
]
]
]
|
d4a8ac01e3683b1e1d574c00e581fca3d3cea1f8 | b2ff7f6bdf1d09f1adc4d95e8bfdb64746a3d6a4 | /src/bmpfhdrs.h | cb2c11e3daf86810d2ad6185884e045f6d9a1ccf | []
| no_license | thebruno/dabster | 39a315025b9344b8cca344d2904c084516915353 | f85d7ec99a95542461862b8890b2542ec7a6b28d | refs/heads/master | 2020-05-20T08:48:42.053900 | 2007-08-29T14:29:46 | 2007-08-29T14:29:46 | 32,205,762 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,363 | h | /*********************************************************************
Sigma Dabster 5
Copyright (C) The Dabster Team 2007.
All rights reserved.
http://www.dabster.prv.pl/
http://code.google.com/p/dabster/
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; version 2 dated June, 1991.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
bmpfileheaders
bmpfhdrs.h
*********************************************************************/
#include "bmptypes.h"
#ifndef BMPHDRHEADERFILE
#define BMPHDRHEADERFILE
#pragma pack(push, BMP_DABSTER_PACKING)
namespace bmp {
using namespace bmptypes;
/*!
* \brief
* Naglowek bitmapy.
*
* Zawiera naglowek standardowej bitmapy w wersji 5.
*/
struct BMP_HEADER {
public:
uint16 bfType; /*!< Sygnatura pliku, zawsze przyjmuje wartosc BM. */
uint32 bfSize; /*!< Dlugosc calego pliku w bajtach. */
uint16 bfReserved1; /*!< Pole zarezerwowane, zwykle ma wartosc 0. */
uint16 bfReserved2; /*!< Pole zarezerwowane, zwykle ma wartosc 0. */
uint32 bfOffBits; /*!< Pozycja danych obrazowych w pliku. */
uint32 biSize; /*!< Wielkosc naglowka informacyjnego. Dlugosc stad do konca naglowka - 40, czasem mniej. */
uint32 biWidth; /*!< Szerokosc obrazu w pixelach. */
uint32 biHeight; /*!< Wysokosc obrazu w pixelach. */
uint16 biPlanes; /*!< Liczba platow, zwykle 0. */
uint16 biBitCount; /*!< Liczba bitow na piksel. */
uint32 biCompression; /*!< Algorytm kompresji. */
uint32 biSizeImage; /*!< Rozmiar samego rysunku, z zerami dopelniajacymi. */
uint32 biXPelsPerMeter; /*!< Rozdzielczosc pozioma. */
uint32 biYPelsPerMeter; /*!< Rozdzielczosc pionowa. */
uint32 biClrUsed; /*!< Liczba kolorow w palecie. */
uint8 biClrImportant; /*!< Liczba waznych kolorow w palecie. */
uint8 biCrlRotation; /*!< Flaga sygnalizujaca czy ma nastepowac rotacja palety. */
uint16 biReserved; /*!< Nie uzywane. */
public:
uint32 biUsefulData; /*!< = biWidth * biHeight * 3 B. */
BMP_HEADER();
};
/*!
* \brief
* Naglowek Dabstera.
*
* Naglowek Dabstera zapisywany do plikow bmp. Wielkosc 21 bajtow
*/
class DAB_HEADER { // 4+4+2+1+2+4+4 = 21 bajtow
private:
uint32 Sygn; /*!< sygnatura ustawiana przez program. */
uint32 DabName; /*!< "DAB5" - na dysku 4 bajty. */
uint16 Ver; /*!< wersja modulu bitmap. */
uint8 Compr; /*!< stopien kompresji, czyli ilosc najmlodszych bitow branych pod uwage. */
uint16 FilesCount; /*!< ilosc plikow i folderow. */
uint32 FilesSize; /*!< calkowita zajeta przestrzen. */
uint32 FreeSpc; /*!< szacowane wolne miejsce, ktore pozostalo (max wartosc). */
private: /*!< dodatkowe pola uzywane juz tylko przez klase bmp. */
uint64 DabHeaderStart; /*!< poczatek naglowka dabstera . */
uint64 FirstFileStart; /*!< poczatek naglowka pierwszetgo pliku/folderu. */
uint64 CompressionStart; /*!< pierszy bit kompresji. */
public:
DAB_HEADER();
friend class BMP;
};
/*!
* \brief
* Naglowek kazdego pliku lub folderu w bitmapie.
*
* Naglowek kazdego pliku lub folderu w bitmapie. Zapisywany do plikow bmp. Wielkosc 12B + dlugosc nazwy
*/
class FILE_HEADER { // 4 + 4 + 2 + 2 + x = 12 B + x B
private:
uint32 DataSize; /*!< Ilosc danych (w bajtach) zapisana w pliku. */
uint32 TimeDate; /*!< Data i czas spakowania. */
uint16 Attributes; /*!< aDtrybuty pliku. */
uint16 FileNameLen;
string FileName; /*!< Nazwa pliku o zmiennej dlugosci - max 255 znakow!!. */
private: //dodatkowe pola uzywane juz tylko przez klase bmp
uint64 HeaderStart; /*!< poczatek naglowka pliku. */
uint64 DataStart; /*!< pierwszy bit danych. */
bool PerformAction; /*!< Uzywane glownie przy usuwaniu pliku z bitmapy. */
//pozycje plikow w bitmapie
public:
FILE_HEADER();
friend class BMP;
};
}
#pragma pack(pop)
#endif | [
"konrad.balys@019b6672-ce2e-0410-a4f6-31e0795bab1a"
]
| [
[
[
1,
116
]
]
]
|
2a5af5f5baf1d25bb171fa8da5608f8dad12441a | cd0987589d3815de1dea8529a7705caac479e7e9 | /webkit/WebKit/chromium/public/WebFileSystem.h | cb7b907c59ff6debaa0ad609b816211d51e12ab2 | [
"BSD-2-Clause"
]
| permissive | azrul2202/WebKit-Smartphone | 0aab1ff641d74f15c0623f00c56806dbc9b59fc1 | 023d6fe819445369134dee793b69de36748e71d7 | refs/heads/master | 2021-01-15T09:24:31.288774 | 2011-07-11T11:12:44 | 2011-07-11T11:12:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,087 | h | /*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WebFileSystem_h
#define WebFileSystem_h
#include "WebCommon.h"
#include "WebString.h"
namespace WebKit {
class WebFileSystemCallbacks;
class WebFileWriter;
class WebFileWriterClient;
class WebFileSystem {
public:
enum Type {
TypeTemporary,
TypePersistent,
};
// Moves a file or directory at |srcPath| to |destPath|.
// WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
// WebFileSystemCallbacks::didFail() must be called otherwise.
virtual void move(const WebString& srcPath, const WebString& destPath, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
// Copies a file or directory at |srcPath| to |destPath|.
// WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
// WebFileSystemCallbacks::didFail() must be called otherwise.
virtual void copy(const WebString& srcPath, const WebString& destPath, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
// Deletes a file or directory at a given |path|.
// WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
// WebFileSystemCallbacks::didFail() must be called otherwise.
virtual void remove(const WebString& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
// Retrieves the metadata information of the file or directory at the given |path|.
// WebFileSystemCallbacks::didReadMetadata() must be called with a valid metadata when the retrieval is completed successfully.
// WebFileSystemCallbacks::didFail() must be called otherwise.
virtual void readMetadata(const WebString& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
// Creates a file at given |path|.
// If the |path| doesn't exist, it creates a new file at |path|.
// If |exclusive| is true, it fails if the |path| already exists.
// If |exclusive| is false, it succeeds if the |path| already exists or
// it has successfully created a new file at |path|.
//
// WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
// WebFileSystemCallbacks::didFail() must be called otherwise.
virtual void createFile(const WebString& path, bool exclusive, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
// Creates a directory at a given |path|.
// If the |path| doesn't exist, it creates a new directory at |path|.
// If |exclusive| is true, it fails if the |path| already exists.
// If |exclusive| is false, it succeeds if the |path| already exists or it has successfully created a new directory at |path|.
//
// WebFileSystemCallbacks::didSucceed() must be called when
// the operation is completed successfully.
// WebFileSystemCallbacks::didFail() must be called otherwise.
virtual void createDirectory(const WebString& path, bool exclusive, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
// Checks if a file exists at a given |path|.
// WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
// WebFileSystemCallbacks::didFail() must be called otherwise.
virtual void fileExists(const WebString& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
// Checks if a directory exists at a given |path|.
// WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
// WebFileSystemCallbacks::didFail() must be called otherwise.
virtual void directoryExists(const WebString& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
// Reads directory entries of a given directory at |path|.
// WebFileSystemCallbacks::didReadDirectory() must be called when the operation is completed successfully.
// WebFileSystemCallbacks::didFail() must be called otherwise.
virtual void readDirectory(const WebString& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
// Creates a WebFileWriter that can be used to write to the given file.
// This is a fast, synchronous call, and should not stat the filesystem.
virtual WebFileWriter* createFileWriter(const WebString& path, WebFileWriterClient*) { WEBKIT_ASSERT_NOT_REACHED(); return 0; }
protected:
virtual ~WebFileSystem() { }
};
} // namespace WebKit
#endif
| [
"[email protected]"
]
| [
[
[
1,
115
]
]
]
|
e5fd2ecb11660cc2923977f0a4a7e690df2a8a9e | f2b4a9d938244916aa4377d4d15e0e2a6f65a345 | /Game/sprite.cpp | 049e7b23b5b3fd7b04970d35f1b74ac134f74858 | [
"Apache-2.0"
]
| permissive | notpushkin/palm-heroes | d4523798c813b6d1f872be2c88282161cb9bee0b | 9313ea9a2948526eaed7a4d0c8ed2292a90a4966 | refs/heads/master | 2021-05-31T19:10:39.270939 | 2010-07-25T12:25:00 | 2010-07-25T12:25:00 | 62,046,865 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 19,700 | cpp | /*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
#include "stdafx.h"
/*
#include "sprite2.h"
* 16bit Dib Sprite Class
bool iSprite16::Init(iDynamicBuffer &buff)
{
uint16 sx,sy;
sint16 ax,ay;
uint32 len;
buff.Read(sx);
buff.Read(sy);
buff.Read(ax);
buff.Read(ay);
buff.Read(len);
m_Anchor.x = ax;
m_Anchor.y = ay;
m_Dib.Init(iSize(sx,sy),iDib::RGB);
check(len == sx*sy*sizeof(iDib::pixel));
buff.Read(m_Dib.GetPtr(),len);
m_bInited = true;
return m_bInited;
}
void iSprite16::Cleanup()
{}
void iSprite16::Compose(iDib& srf, const iPoint& pos) const
{
check(m_bInited);
m_Dib.CopyToDibXY(srf,pos);
}
void iSprite16::ComposeRect(iDib& srf, const iRect& srect, const iPoint& pos) const
{
check(m_bInited);
m_Dib.CopyRectToDibXY(srf,srect,pos);
}
void iSprite16::ComposeTranslucent(iDib& srf, const iPoint& pos) const
{
check(m_bInited);
check( 0 );
// *** NOT IMPLEMENTED ***
//m_Dib.CopyToDibXY(srf,pos);
}
void iSprite16::TileRect(iDib& srf, const iRect& src_rect, const iRect& dst_rect) const
{
check(m_bInited);
if (!src_rect.w || !src_rect.h) return;
// Tile Dib
uint32 numx = dst_rect.w / src_rect.w;
uint32 numy = dst_rect.h / src_rect.h;
if ((dst_rect.w % src_rect.w) != 0) numx ++;
if ((dst_rect.h % src_rect.h) != 0) numy ++;
for (uint32 yy=0; yy<numy; ++yy) {
for (uint32 xx=0; xx<numx; ++xx) {
sint32 w = iMIN(src_rect.w,dst_rect.w - (xx*src_rect.w));
sint32 h = iMIN(src_rect.h,dst_rect.h - (yy*src_rect.h));
m_Dib.CopyRectToDibXY(srf,iRect(src_rect.x,src_rect.y,w,h),iPoint(dst_rect.x+xx*src_rect.w,dst_rect.y+yy*src_rect.h));
}
}
}
void iSprite16::H3TileRect(iDib& srf, const iRect& src_rect, const iRect& dst_rect) const
{
check(m_bInited);
uint32 sH = src_rect.h;
uint32 sW = 0;
if (!sH || src_rect.w%3 != 0 || !(sW=src_rect.w/3)){
check(0);
return;
}
m_Dib.CopyRectToDibXY(srf,iRect(src_rect.x,src_rect.y,sW,sH),dst_rect.point());
m_Dib.CopyRectToDibXY(srf,iRect(src_rect.x+sW*2,src_rect.y,sW,sH),iPoint(dst_rect.x+dst_rect.w-sW,dst_rect.y));
TileRect(srf, iRect(src_rect.x+sW,src_rect.y,sW,sH), iRect(dst_rect.x+sW,dst_rect.y,dst_rect.w-sW*2,sH));
}
*/
/*
* 16bit SpanSprite
bool iSpanSprite16::Init(iDynamicBuffer &buff)
{
uint16 sx,sy;
sint16 ax,ay;
uint32 len;
buff.Read(sx);
buff.Read(sy);
buff.Read(ax);
buff.Read(ay);
buff.Read(len);
m_Anchor.x = ax;
m_Anchor.y = ay;
m_Size.w = sx;
m_Size.h = sy;
m_Buff.Allocate(len/2);
buff.Read(m_Buff,len);
m_bInited = true;
return m_bInited;
}
void iSpanSprite16::Cleanup()
{
}
*/
/*
*
inline uint16* WordBlt( uint16*& dst, const uint16* src, size_t count )
{
uint16* _dst = dst;
for( ; count != 0; --count, ++src, ++_dst ) *_dst = *src;
dst = _dst;
return (uint16*)src;
}
inline uint16* WordBltClip( uint16*& dst, const uint16* src, size_t count, const uint16* clipIn, const uint16* clipOut )
{
// empty clip span
check( clipIn != clipOut );
check( clipIn < clipOut );
// WARN:: using local variable is important, because
// compiler could not optimize away reference and produce
// a bunch of load&stores for each operation.
uint16* _dst = dst;
// preclip
// >> for( ; count != 0 && dst < clipIn; --count, ++src, ++dst );
sint32 clipDif = clipIn - _dst;
size_t cinc = min( (size_t)max(clipDif, 0L), count );
check( cinc <= count );
src += cinc;
_dst += cinc;
count -= cinc;
// all span is clipped out
// copy span until clip or end
// >> for( ; count != 0 && dst < clipOut; --count, ++src, ++dst ) *dst = *src;
// >> return src += count;
if ( 0 != count && _dst < clipOut ) {
check( _dst <= clipOut );
size_t ccount = min( (size_t)(clipOut - _dst), count );
check( ccount <= count );
count -= ccount;
for( ; ccount != 0; --ccount, ++src, ++_dst ) *_dst = *src;
}
dst = _dst;
// eat tail
return (uint16*)src + count;
}
uint16* ProcessSpanLine(const uint16* src, uint16* dst)
{
bool bLast = false;
do {
uint16 code = *src;
bLast = (code & (1<<15)) != 0;
uint32 offset = ((code >> 8) & 0x7F);
dst += offset;
uint32 len = code & 0xFF;
src = WordBlt( dst, ++src, len );
} while (!bLast);
return (uint16*)src;
}
inline uint16* SkipSpanLine(const uint16* src)
{
bool bLast = false;
do {
uint16 code = *src;
bLast = (code & (1<<15)) != 0;
uint32 len = code & 0xFF;
src += (len+1);
} while (!bLast);
return (uint16*)src;
}
uint16* ProcessClipSpanLine(const uint16* src, uint16* dst, const uint16* clipIn, const uint16* clipOut )
{
bool bLast = false;
do {
uint code = *src;
bLast = (code & (1<<15)) != 0;
uint32 offset = ((code >> 8) & 0x7F);
dst += offset;
uint32 len = code & 0xFF;
src = WordBltClip( dst, ++src, len, clipIn, clipOut );
} while (!bLast);
return (uint16*)src;
}
//
inline uint16* WordMaskBlt( uint16*& dst, const uint16* src_mask, const uint16*& src_clr, size_t count )
{
src_mask += count;
uint16* _dst = dst;
const uint16* _src = src_clr;
for( ; count != 0; --count, ++_src, ++_dst ) *_dst = *_src;
dst = _dst;
src_clr = _src;
return (uint16*)src_mask;
}
inline uint16* WordMaskBltClip( uint16*& dst, const uint16* src_mask, const uint16*& src_clr, size_t count, const uint16* clipIn, const uint16* clipOut )
{
// empty clip span
check( clipIn != clipOut );
check( clipIn < clipOut );
uint16* _dst = dst;
const uint16* _src = src_clr;
// preclip
sint32 clipDif = clipIn - _dst;
size_t cinc = min( (size_t)max(clipDif, 0L), count );
check( cinc <= count );
src_mask += cinc;
_src += cinc;
_dst += cinc;
count -= cinc;
// all span is clipped out
// copy span until clip or end
if ( 0 != count && dst < clipOut ) {
check( _dst <= clipOut );
size_t ccount = min( (size_t)(clipOut - _dst), count );
check( ccount <= count );
count -= ccount;
src_mask += ccount;
for( ; ccount != 0; --ccount, ++_src, ++_dst ) *_dst = *_src;
}
/// *** WARN *** Here is problem, something is not incremented!
dst = _dst;
src_clr = _src + count;
// eat tail
return (uint16*)src_mask + count;
}
uint16* ProcessMaskSpanLine(const uint16* src_mask, const uint16* src_clr, uint16* dst)
{
bool bLast = false;
do {
uint16 code = *src_mask;
bLast = (code & (1<<15)) != 0;
uint32 offset = ((code >> 8) & 0x7F);
dst += offset;
src_clr += offset;
uint32 len = code & 0xFF;
src_mask = WordMaskBlt( dst, ++src_mask, src_clr, len );
} while (!bLast);
return (uint16*)src_mask;
}
uint16* ProcessClipMaskSpanLine(const uint16* src_mask, const uint16* src_clr, uint16* dst, const uint16* clipIn, const uint16* clipOut )
{
bool bLast = false;
do {
uint16 code = *src_mask;
bLast = (code & (1<<15)) != 0;
uint32 offset = ((code >> 8) & 0x7F);
dst += offset;
src_clr += offset;
uint32 len = code & 0xFF;
src_mask = WordMaskBltClip( dst, ++src_mask, src_clr, len, clipIn, clipOut );
} while (!bLast);
return (uint16*)src_mask;
}
inline uint32
Modulate50( uint32 pixel )
{
return (pixel & 0xf7de) >> 1;
}
inline uint32
Modulate25( uint32 pixel )
{
pixel = (pixel & 0xf7de) >> 1;
pixel += (pixel & 0xf7de) >> 1;
return pixel;
}
//
inline uint16* ShadowWordBlt( uint16*& dst, const uint16* src, size_t count )
{
uint16* _dst = dst;
for( ; count != 0; --count, ++src, ++_dst ) *_dst = (uint16)Modulate50( *_dst ) ;
dst = _dst;
return (uint16*)src;
}
inline uint16* ShadowWordBltClip( uint16*& dst, const uint16* src, size_t count, const uint16* clipIn, const uint16* clipOut )
{
// empty clip span
check( clipIn != clipOut );
check( clipIn < clipOut );
// *const_cast<uint16*>(clipIn) = 0x000f;
// *const_cast<uint16*>(clipOut-1) = 0x00ff;
// preclip
size_t tcount = 0;
size_t ocount = count;
uint16* _dst = dst;
sint32 clipDif = clipIn - _dst;
size_t cinc = min( (size_t)max(clipDif, 0L), count );
check( cinc <= count );
src += cinc;
_dst += cinc;
count -= cinc;
tcount += cinc;
// all span is clipped out
// copy span until clip or end
if ( 0 != count && _dst < clipOut ) {
check( _dst <= clipOut );
size_t ccount = min( (size_t)(clipOut - _dst), count );
check( ccount <= count );
count -= ccount;
tcount += ccount;
for( ; ccount != 0; --ccount, ++src, ++_dst ) *_dst = (uint16)Modulate50( *_dst ) ;
}
tcount += count;
check( tcount == ocount );
dst += count;
dst = _dst;
// eat tail
return (uint16*)src + count;
}
// TODO:: Refactor tons of those blitters!
uint16* ProcessShadowSpanLine(const uint16* src, uint16* dst)
{
bool bLast = false;
do {
uint16 code = *src++;
if ( code == 0x8000 ) break; // skip empty
bLast = (code & (1<<15)) != 0;
uint32 offset = ((code >> 8) & 0x7F);
dst += offset;
uint32 len = code & 0xFF;
check( len != 0 );
src = ShadowWordBlt( dst, src, len );
//src = ShadowWordBltClip( dst, ++src, len, dst, dst + len + 1);
} while (!bLast);
return (uint16*)src;
}
uint16* ProcessShadowClipSpanLine(const uint16* src, uint16* dst, const uint16* clipIn, const uint16* clipOut )
{
bool bLast = false;
do {
uint16 code = *src++;
if ( code == 0x8000 ) break; // skip empty
bLast = (code & (1<<15)) != 0;
uint32 offset = ((code >> 8) & 0x7F);
dst += offset;
uint32 len = code & 0xFF;
src = ShadowWordBltClip( dst, src, len, clipIn, clipOut );
} while (!bLast);
return (uint16*)src;
}
*/
/*
*
void iSpanSprite16::Compose(iDib& srf, const iPoint& pos) const
{
typedef Blitter<CopyOp> Blt;
check(m_bInited);
if ( (pos.x + (sint32)m_Size.w) <= 0 || (pos.y + (sint32)m_Size.h) <= 0) return;
iRect src_rect(GetSize());
iSize siz = iSize(srf.GetWidth() - pos.x, srf.GetHeight() - pos.y);
iRect dst_rect(pos,siz);
if (!iClipper::iClipRectRect(dst_rect,srf.GetSize(),src_rect,GetSize())) return;
uint16* dst_clr = srf.GetPtr(dst_rect);
const uint16* ptr = m_Buff.GetPtr();
const uint16* eptr= ptr + m_Buff.GetSize();
const size_t dstStride = srf.GetWidth();
if (src_rect.size() == m_Size){
while (ptr != eptr) {
//ptr = ProcessSpanLine(ptr, dst_clr);
ptr = Blt::SpanFast( ptr,dst_clr );
dst_clr += dstStride;
}
} else {
dst_clr -= src_rect.x;
sint32 toSkip = src_rect.y;
while (toSkip--) ptr = Blt::SpanSkip( ptr );
const uint16* clipIn = dst_clr + src_rect.x;
for (sint32 yy=0; yy<(sint32)src_rect.h; ++yy){
//ptr = ProcessClipSpanLine(ptr, dst_clr, clipIn, clipOut );
ptr = Blt::Span(ptr, dst_clr, clipIn, clipIn + src_rect.w );
dst_clr += dstStride;
clipIn += dstStride;
}
}
}
void iSpanSprite16::ComposeTranslucent(iDib& srf, const iPoint& pos) const
{
typedef Blitter<Shadow25Op> Blt;
check(m_bInited);
if ( (pos.x + (sint32)m_Size.w) <= 0 || (pos.y + (sint32)m_Size.h) <= 0) return;
iRect src_rect(GetSize());
iSize siz = iSize(srf.GetWidth() - pos.x, srf.GetHeight() - pos.y);
iRect dst_rect(pos,siz);
if (!iClipper::iClipRectRect(dst_rect,srf.GetSize(),src_rect,GetSize())) return;
uint16* dst_clr = srf.GetPtr(dst_rect);
const uint16* ptr = m_Buff.GetPtr();
const uint16* eptr= ptr + m_Buff.GetSize();
const size_t dstStride = srf.GetWidth();
if (src_rect.size() == m_Size){
while (ptr != eptr) {
//ptr = ProcessShadowSpanLine(ptr, dst_clr);
ptr = Blt::SpanFast( ptr,dst_clr );
dst_clr += dstStride;
}
} else {
dst_clr -= src_rect.x;
sint32 toSkip = src_rect.y;
//while (toSkip--) ptr = SkipSpanLine(ptr);
while (toSkip--) ptr = Blt::SpanSkip( ptr );
const uint16* clipIn = dst_clr + src_rect.x;
for (sint32 yy=0; yy<(sint32)src_rect.h; ++yy){
//ptr = ProcessShadowClipSpanLine(ptr, dst_clr, clipIn, clipOut );
ptr = Blt::Span(ptr, dst_clr, clipIn, clipIn + src_rect.w );
dst_clr += dstStride;
clipIn += dstStride;
}
}
}
void iSpanSprite16::ComposeRect(iDib& srf, const iRect& srect, const iPoint& pos) const
{
check(0);
}
void iSpanSprite16::TileRect(iDib& srf, const iRect& src_rect, const iRect& dst_rect) const
{
check(0);
}
void iSpanSprite16::H3TileRect(iDib& srf, const iRect& src_rect, const iRect& dst_rect) const
{
check(0);
}
*/
/*
* Sprite Manager
iSpriteMgr::iSpriteMgr()
{}
iSpriteMgr::~iSpriteMgr()
{ Cleanup(); }
bool iSpriteMgr::InitSpriteMgr()
{
return true;
}
uint32 iSpriteMgr::AddSprite(iDynamicBuffer &buff)
{
uint8 flags;
buff.Read(flags);
uint8 stype = flags & 1;
bool bShadow = (flags & 2)!=0;
iSpriteI* pSprite = NULL;
if (stype == 0) pSprite = new iSprite16();
else if (stype == 1) pSprite = new iSpanSprite16();
else {
check(0);
return 0;
}
if (!pSprite->Init(buff)) {
check(0);
delete(pSprite);
return 0;
}
pSprite->SetShadow(bShadow);
m_Sprites.Add(pSprite);
return m_Sprites.GetSize();
}
void iSpriteMgr::Cleanup()
{
for (uint32 xx=0; xx<m_Sprites.GetSize(); ++xx) {
m_Sprites[xx]->Cleanup();
delete m_Sprites[xx];
}
m_Sprites.RemoveAll();
}
void iSpriteMgr::ComposeSprite(uint32 spr_id, iDib& srf, const iPoint& pos) const
{
check(spr_id < m_Sprites.GetSize());
m_Sprites[spr_id]->Compose(srf,pos+m_Sprites[spr_id]->GetAnchor());
}
void iSpriteMgr::ComposeTranslucent(uint32 spr_id, iDib& srf, const iPoint& pos) const
{
check(spr_id < m_Sprites.GetSize());
m_Sprites[spr_id]->ComposeTranslucent(srf,pos+m_Sprites[spr_id]->GetAnchor());
}
void iSpriteMgr::ComposeSpriteRect(uint32 spr_id, iDib& srf, const iRect& srect, const iPoint& pos) const
{
check(spr_id < m_Sprites.GetSize());
m_Sprites[spr_id]->ComposeRect(srf,srect,pos+m_Sprites[spr_id]->GetAnchor());
}
void iSpriteMgr::ComposeMaskedSprite(uint32 spr_id, uint32 mask_id, iDib& srf, const iPoint& pos) const
{
check(spr_id < m_Sprites.GetSize());
check(mask_id < m_Sprites.GetSize());
check(m_Sprites[spr_id]->GetSize() == m_Sprites[mask_id]->GetSize());
check(m_Sprites[spr_id]->IsInited());
check(m_Sprites[mask_id]->IsInited());
// sprite must be in RAW format, mask nust be Spanned
if ( (pos.x + (sint32)m_Sprites[spr_id]->GetSize().w) <= 0 || (pos.y + (sint32)m_Sprites[spr_id]->GetSize().h) <= 0) return;
iRect src_rect(m_Sprites[spr_id]->GetSize());
iSize siz = iSize(srf.GetWidth() - pos.x, srf.GetHeight() - pos.y);
iRect dst_rect(pos,siz);
if (!iClipper::iClipRectRect(dst_rect,srf.GetSize(),src_rect,m_Sprites[spr_id]->GetSize())) return;
typedef Blitter<CopyOp> Blt;
uint16* dptr = srf.GetPtr(dst_rect);
const uint16* sptr = m_Sprites[spr_id]->GetPtr();
const uint16* mptr = m_Sprites[mask_id]->GetPtr();
const uint16* eptr= mptr + m_Sprites[mask_id]->GetBuffSiz()/2;
const size_t dstStride = srf.GetWidth();
const size_t srcStride = m_Sprites[spr_id]->GetSize().w;
if (src_rect.size() == m_Sprites[spr_id]->GetSize()){
while (mptr != eptr) {
//mptr = ProcessMaskSpanLine(mptr, sptr, dptr);
mptr = Blt::MaskedSpanFast(mptr, sptr, dptr);
dptr += dstStride;
sptr += srcStride;
}
} else {
dptr -= src_rect.x;
sint32 toSkip = src_rect.y;
sptr += m_Sprites[spr_id]->GetSize().w * toSkip;
//while (toSkip--) mptr = SkipSpanLine(mptr);
while (toSkip--) mptr = Blt::SpanSkip(mptr);
const uint16* clipIn = dptr + src_rect.x;
for (sint32 yy=0; yy<(sint32)src_rect.h; ++yy){
//mptr = ProcessClipMaskSpanLine(mptr, sptr, dptr, clipIn, clipOut );
mptr = Blt::MaskedSpan( mptr, sptr, dptr, clipIn, clipIn + src_rect.w );
dptr += dstStride;
clipIn += dstStride;
sptr += srcStride;
}
}
}
void iSpriteMgr::ComposeShadow(uint32 spr_id, iDib& srf, const iPoint& rpos) const
{
check(spr_id < m_Sprites.GetSize());
check(m_Sprites[spr_id]->IsInited());
// sprite must be Spanned
iSpanSprite16& spr = *(iSpanSprite16*)m_Sprites[spr_id];
iPoint pos = spr.GetAnchor() + rpos;
// sprite rect -> sprite shadow rect
iSize sprSz = spr.GetSize();
uint32 hhgt = (spr.GetSize().h + 1) / 2;
check( hhgt > 1 );
pos.x -= hhgt ;
pos.y += sprSz.h - hhgt - 1;
sprSz.w += hhgt - 1;
sprSz.h = hhgt;
if ( (pos.x + (sint32)sprSz.w) <= 0 || (pos.y + (sint32)sprSz.h) <= 0) return;
iRect src_rect(sprSz);
iSize siz = iSize(srf.GetWidth() - pos.x, srf.GetHeight() - pos.y);
iRect dst_rect(pos,siz);
if (!iClipper::iClipRectRect(dst_rect,srf.GetSize(),src_rect,sprSz)) return;
uint16* dst_clr = srf.GetPtr(dst_rect);
const uint16* ptr = spr.GetPtr();
const uint16* eptr= spr.GetEPtr();
const size_t dstStride = srf.GetWidth();
typedef Blitter<Shadow50Op> Blt;
if ( src_rect.size() == sprSz ){
while (ptr != eptr) {
//ptr = ProcessShadowSpanLine(ptr, dst_clr);
ptr = Blt::SpanFast(ptr, dst_clr);
++dst_clr; // shadow skew
dst_clr += dstStride;
//if ( ptr != eptr ) ptr = SkipSpanLine(ptr); // shadow skip
if ( ptr != eptr ) ptr = Blt::SpanSkip(ptr); // shadow skip
}
} else {
dst_clr -= src_rect.x;
sint32 toSkip = src_rect.y;
while (toSkip--) {
//ptr = SkipSpanLine(ptr);
ptr = Blt::SpanSkip(ptr);
check( ptr != eptr ); // skip by factor of two
//ptr = SkipSpanLine(ptr);
ptr = Blt::SpanSkip(ptr);
}
const uint16* clipIn = dst_clr + src_rect.x;
dst_clr += src_rect.y; // pre-skew ( after y-clipping )
for (sint32 yy=0; yy<(sint32)src_rect.h; ++yy) {
//ptr = ProcessShadowClipSpanLine(ptr, dst_clr, clipIn, clipIn + src_rect.w );
ptr = Blt::Span(ptr, dst_clr, clipIn, clipIn + src_rect.w );
clipIn += dstStride;
dst_clr += dstStride;
++dst_clr;
if ( ptr != eptr ) ptr = Blt::SpanSkip(ptr);
else break;
//ptr = SkipSpanLine(ptr); // shadow skip
}
}
}
void iSpriteMgr::TileSpriteRect(uint32 spr_id, iDib& srf, const iRect& src_rect, const iRect& dst_rect) const
{
check(spr_id < m_Sprites.GetSize());
m_Sprites[spr_id]->TileRect(srf,src_rect,dst_rect);
}
void iSpriteMgr::H3TileSpriteRect(uint32 spr_id, iDib& srf, const iRect& src_rect, const iRect& dst_rect) const
{
check(spr_id < m_Sprites.GetSize());
m_Sprites[spr_id]->H3TileRect(srf,src_rect,dst_rect);
}
void iSpriteMgr::H3TileSprite(uint32 spr_id, iDib& srf, const iRect& dst_rect) const
{
check(spr_id < m_Sprites.GetSize());
m_Sprites[spr_id]->H3TileRect(srf,m_Sprites[spr_id]->GetSize(),dst_rect);
}
*/
//
//
/*
struct Span
{
uint8 start;
uint8 end;
const uint16* data;
};
typedef iSimpleArray<Span> SpanList;
iSpanSprite16*
MakeOutlined( iSpanSprite16* src, uint16 outColor )
{
check( src != 0 );
iSize newSize = src->GetSize();
newSize.InflateSize( 2, 2 );
// allocate new spanlist
ScopedArray<SpanList> spans( new SpanList[ newSize.h ] );
const uint16* spanPtr =
}*/
| [
"palmheroesteam@2c21ad19-eed7-4c86-9350-8a7669309276"
]
| [
[
[
1,
731
]
]
]
|
39ca2c7a524ae2379b1cfbf661575db9b3b39115 | 0d32d7cd4fb22b60c4173b970bdf2851808c0d71 | /src/hancock/LogFiles/log.h | 194b9f41f0831c5011024043a759b52836867776 | []
| no_license | kanakb/cs130-hancock | a6eaef9a44955846d486ee2330bec61046cb91bd | d1f77798d90c42074c7a26b03eb9d13925c6e9d7 | refs/heads/master | 2021-01-18T13:04:25.582562 | 2009-06-12T03:49:56 | 2009-06-12T03:49:56 | 32,226,524 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,450 | h | #ifndef LOG_H
#define LOG_H
#include <string>
#include <iostream>
#include <fstream>
#include <Windows.h>
#include <stdio.h>
const char DIR[256] = "";
using namespace std;
class Log{
char* filename;
ofstream fout;
string curLog;
public:
Log();
~Log();
void write(string info);
char* getFileName();
string dispLog(const char* filename);
string dispCurrLog();
};
string timestamp(){
SYSTEMTIME st;
GetSystemTime(&st);
char time[256];
sprintf_s(time,256,"%d.%d.%d %d:%d - ",st.wMonth,st.wDay,st.wYear,st.wHour,st.wMinute);
return time;
}
Log::Log(){
SYSTEMTIME st;
GetSystemTime(&st);
filename = new char[256];
sprintf_s(filename,256,"%s%d.%d.%d.%d.%d.txt",DIR,st.wMonth,st.wDay,st.wYear,st.wHour,st.wMinute);
fout.open(filename);
this->write("Log Created.");
}
Log::~Log()
{
delete filename;
fout.close();
}
char* Log::getFileName(){
return filename;
}
void Log::write(string info){
fout << timestamp() + info + "\n";
curLog = curLog + timestamp() + info + "\n";
}
string Log::dispCurrLog(){
return curLog;
}
string Log::dispLog(const char* filename){
string line;
string content;
ifstream fin (filename);
if (fin.is_open())
{
while (! fin.eof() )
{
getline (fin,line);
content = content + "\n" + line;
}
fin.close();
}
else content = "Unable to open file\n";
return content;
}
#endif | [
"kanakb@1f8f3222-2881-11de-bcab-dfcfbda92187",
"sargis.panosyan@1f8f3222-2881-11de-bcab-dfcfbda92187"
]
| [
[
[
1,
3
],
[
91,
91
]
],
[
[
4,
90
]
]
]
|
ba454d5c93d9963fc507716894783b6d3d64acc1 | 8f828231b15af1203c30cac311dbbd166f9f743f | /hellocairo/myapp.h | d4c2960a824715da0295c08d9f670d3e8ba3a76a | []
| no_license | d3ru/cairo-for-symbian | 07a1e4ceeb433ab7bc3485134903f123884e1939 | 1031d4d020701003161f19e207b32324d89cf8b6 | refs/heads/master | 2016-08-11T14:19:16.881139 | 2009-03-15T14:00:11 | 2009-03-15T14:00:11 | 36,205,677 | 0 | 1 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 1,468 | h | /*
* Copyright © 2009 [email protected]
*
* 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, and
* that the name of the copyright holders not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. The copyright holders make no representations
* about the suitability of this software for any purpose. It is provided "as
* is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
#ifndef __MYAPPLICATION_H__
#define __MYAPPLICATION_H__
#include <aknapp.h>
class CMyApplication: public CAknApplication
{
public:
TUid AppDllUid() const;
protected:
CApaDocument* CreateDocumentL();
};
#endif
| [
"[email protected]@a20834f0-d954-11dd-a2b5-e5f827957e07"
]
| [
[
[
1,
38
]
]
]
|
f174a5565d16bf0541d6c406871caf0ba7dc4be7 | 8c4d8b2646a9c96ec7f1178a7f2716823fb99984 | /hell/Chave.h | c9ab42e9cd2b5db87335b8626b0bf05ca88ac375 | []
| no_license | MiguelCosta/cg-trabalho | c93987ff8c2ec8ac022b936e620594a4f420789d | b293ca8d55d9c4938b66a0561695be0079bd50ac | refs/heads/master | 2020-07-08T13:02:35.644637 | 2011-05-23T13:57:47 | 2011-05-23T13:57:47 | 32,185,313 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 812 | h | #pragma once
#include <GL/glut.h>
#include <math.h>
#include "defines.h"
#include "glm.h"
class Chave
{
public:
/* posicao da chave */
GLdouble posicao[3];
/*variavel para a chave*/
GLMmodel * chave;
/* angulo de rotacao da chave */
GLfloat ang;
/* estado da chave
* 0 nao encontrada
* 1 encontrada
* */
int encontrada;
/** Contrutores **/
/** Cria a chave*/
Chave(void);
/** Cria a chave recebendo a posição onde vai ser colocada*/
Chave(GLdouble posicaoInicialX, GLdouble posicaoInicialZ);
/** Desenha a chave */
void desenha(float posX, float posY, float posZ);
/** girar, actualiza o angulo para depois girar */
void girar(void);
/** quando o agente encontra a chave */
void encontra(void);
/** Destrutor */
~Chave(void);
};
| [
"miguelpintodacosta@db629c75-4b32-85d7-0afe-a27431d4d09a",
"andvieira.16@db629c75-4b32-85d7-0afe-a27431d4d09a",
"emanspace@db629c75-4b32-85d7-0afe-a27431d4d09a"
]
| [
[
[
1,
5
],
[
7,
12
],
[
16,
32
],
[
34,
44
]
],
[
[
6,
6
],
[
13,
15
]
],
[
[
33,
33
]
]
]
|
51896b6e88134c2878dc16a4f2c17291ecc46573 | f8b364974573f652d7916c3a830e1d8773751277 | /emulator/allegrex/instructions/VFIM.h | 091741f55b003e105924cdc3c107c7b17f918f8f | []
| no_license | lemmore22/pspe4all | 7a234aece25340c99f49eac280780e08e4f8ef49 | 77ad0acf0fcb7eda137fdfcb1e93a36428badfd0 | refs/heads/master | 2021-01-10T08:39:45.222505 | 2009-08-02T11:58:07 | 2009-08-02T11:58:07 | 55,047,469 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,035 | h | template< > struct AllegrexInstructionTemplate< 0xdf800000, 0xff800000 > : AllegrexInstructionUnknown
{
static AllegrexInstructionTemplate &self()
{
static AllegrexInstructionTemplate insn;
return insn;
}
static AllegrexInstruction *get_instance()
{
return &AllegrexInstructionTemplate::self();
}
virtual AllegrexInstruction *instruction(u32 opcode)
{
return this;
}
virtual char const *opcode_name()
{
return "VFIM";
}
virtual void interpret(Processor &processor, u32 opcode);
virtual void disassemble(u32 address, u32 opcode, char *opcode_name, char *operands, char *comment);
protected:
AllegrexInstructionTemplate() {}
};
typedef AllegrexInstructionTemplate< 0xdf800000, 0xff800000 >
AllegrexInstruction_VFIM;
namespace Allegrex
{
extern AllegrexInstruction_VFIM &VFIM;
}
#ifdef IMPLEMENT_INSTRUCTION
AllegrexInstruction_VFIM &Allegrex::VFIM =
AllegrexInstruction_VFIM::self();
#endif
| [
"[email protected]"
]
| [
[
[
1,
41
]
]
]
|
549a2bfdf345794c4fa16de3ed13731ccb2f843d | e7c45d18fa1e4285e5227e5984e07c47f8867d1d | /Application/SysCAD/ScdApplication.h | 84e1d607d2e0bbe7439c3b946bb3a10b01451b48 | []
| no_license | abcweizhuo/Test3 | 0f3379e528a543c0d43aad09489b2444a2e0f86d | 128a4edcf9a93d36a45e5585b70dee75e4502db4 | refs/heads/master | 2021-01-17T01:59:39.357645 | 2008-08-20T00:00:29 | 2008-08-20T00:00:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,979 | h |
// ScdApplication.h : Declaration of the CScdApplication
#ifndef __SCDAPPLICATION_H_
#define __SCDAPPLICATION_H_
#include "resource.h" // main symbols
#include "..\..\common\com\scdif\scdif.h" // main symbols
#include "..\..\common\com\scdslv\scdatl.h" // main symbols
#include "ScdAppCP.h"
#include "..\..\common\com\scdif\scdcomevts.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CScdApplicationFactory
#include <map>
typedef std::map<std::string,IUnknown*> CScdAppmapObjects;
class CScdApplicationFactory :
public CComClassFactory,
public IOleItemContainer
//, public ITheObjectsTable
{
public:
CScdApplicationFactory() {};
BEGIN_COM_MAP(CScdApplicationFactory)
COM_INTERFACE_ENTRY(IClassFactory)
COM_INTERFACE_ENTRY2(IParseDisplayName, IOleItemContainer)
COM_INTERFACE_ENTRY(IOleItemContainer)
//COM_INTERFACE_ENTRY(ITheObjectsTable)
END_COM_MAP()
//
// IParseDisplayName
STDMETHOD(ParseDisplayName)(
IBindCtx *pbc, //Pointer to bind context
LPOLESTR pszDisplayName, //Pointer to string containing display name
ULONG *pchEaten, //Pointer to length, in characters, of display name
IMoniker **ppmkOut //Address of output variable that receives the
//resulting IMoniker interface pointer
)
{
HRESULT hr=::CreateItemMoniker(OLESTR("!"),
pszDisplayName+1,
ppmkOut);
if(SUCCEEDED(hr))
{
*pchEaten = wcslen(pszDisplayName);
}else
{
*pchEaten = 0;
}
return hr;
}
//IOleItemContainer
STDMETHOD(EnumObjects)(DWORD grfFlags, IEnumUnknown **ppenum)
{
return E_NOTIMPL;
}
STDMETHOD(LockContainer)(BOOL fLock)
{
return E_NOTIMPL;
}
STDMETHOD(GetObject)(LPOLESTR pszItem, //Pointer to name of the object requested
DWORD dwSpeedNeeded, //Speed requirements on binding
IBindCtx *pbc, //Pointer to bind context object to be used
REFIID riid, //Reference to the identifier of the
// interface pointer desired
void **ppvObject //Address of output variable that receives
// the interface pointer requested in riid
);
STDMETHOD(GetObjectStorage)(LPOLESTR pszItem,IBindCtx *pbc,REFIID riid,void **ppvStorage)
{
return E_NOTIMPL;
}
STDMETHOD(IsRunning)(LPOLESTR pszItem)
{
return E_NOTIMPL;
}
//// ITheObjectsTable
//STDMETHOD(RemoveObject)(BSTR bstrObjectName);
protected:
static CScdAppmapObjects sm_mapObjects;
};
/////////////////////////////////////////////////////////////////////////////
// CScdApplication
//class CScdApplicationClassFactory : public CComClassFactory {};
class ATL_NO_VTABLE CScdApplication :
public CScdCOCmdBase,
public CComObjectRootEx<CComMultiThreadModel>,
public CComCoClass<CScdApplication, &CLSID_ScdApplication>,
public ISupportErrorInfo,
public IConnectionPointContainerImpl<CScdApplication>,
public IDispatchImpl<IScdApplication, &IID_IScdApplication, &LIBID_ScdApp>,
public IDispatchImpl<IScdASyncEvents, &IID_IScdASyncEvents, &LIBID_ScdIF>,
public CProxy_IScdApplicationEvents< CScdApplication >
{
public:
CScdApplication();
DECLARE_REGISTRY_RESOURCEID(IDR_SCDAPPLICATION)
//DECLARE_REGISTRY_RESOURCEID_SCDEXE_AS_SERVER(IDR_SCDAPPLICATION)
DECLARE_GET_CONTROLLING_UNKNOWN()
//DECLARE_CLASSFACTORY_SINGLETON(CScdApplication);
//DECLARE_CLASSFACTORY_EX(CScdApplicationFactory);
DECLARE_PROTECT_FINAL_CONSTRUCT()
// This breaks the registration
//DECLARE_OBJECT_DESCRIPTION("SysCAD Application Class");
BEGIN_COM_MAP(CScdApplication)
COM_INTERFACE_ENTRY(IScdApplication)
//DEL COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY(IConnectionPointContainer)
//COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
COM_INTERFACE_ENTRY2(IDispatch, IScdApplication)
COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
COM_INTERFACE_ENTRY(IScdASyncEvents)
END_COM_MAP()
BEGIN_CONNECTION_POINT_MAP(CScdApplication)
CONNECTION_POINT_ENTRY(DIID__IScdApplicationEvents)
END_CONNECTION_POINT_MAP()
DECLARE_SCD(long)
#ifdef _DEBUG
BEGIN_CATEGORY_MAP(CScdApplication)
IMPLEMENTED_CATEGORY(CATID_SysCADAppObject)
END_CATEGORY_MAP()
#endif
//DECLARE_CLASSFACTORY_EX(CScdApplicationClassFactory)
HRESULT FinalConstruct();
void FinalRelease();
//CComPtr<IUnknown> m_pUnkMarshaler;
CComPtr<IScdSolver > m_pSolver;
CComPtr<IScdProject > m_pProject;
CComPtr<IScdOptions > m_pOptions;
CComPtr<IScdLicenseApp > m_pLicense;
// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
// IScdApplication
public:
STDMETHOD(CloseProject)(/*[in,defaultvalue(FALSE)]*/ VARIANT_BOOL SaveIt);
STDMETHOD(get_Options)(/*[out, retval]*/ IScdOptions ** pOptions);
STDMETHOD(get_License)(/*[out, retval]*/ IScdLicenseApp ** pLicense);
STDMETHOD(CreateProject)(/*[in]*/ BSTR CfgFolder, /*[in]*/ BSTR PrjFolder, VARIANT_BOOL WithVersion, VARIANT_BOOL RemoveOld, /*[out, retval]*/ IScdProject ** pProject);
STDMETHOD(OpenProject)(/*[in]*/ BSTR PrjFolder, /*[out, retval]*/ IScdProject ** pProject);
STDMETHOD(get_Messages)(/*[out, retval]*/ IScdMessages ** pMessages);
STDMETHOD(get_Test)(/*[out, retval]*/ IScdTest ** pTest);
STDMETHOD(get_Debug)(/*[out, retval]*/ IScdDebug ** pDebug);
// IScdASyncEvents
STDMETHOD(DoEventMsg)(LONG Evt, LONG Data)
{
CScdCOCmdBase::DoEventMsg(Evt, Data);
return S_OK;
}
virtual void FireTheEvent(long Evt, long Data);
STDMETHOD(SetWindowState)(eScdWndStateCmds ReqdState);
STDMETHOD(get_Project)(IScdProject** pVal);
public:
};
#endif //__SCDAPPLICATION_H_
| [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
7
],
[
10,
10
],
[
12,
174
],
[
177,
178
]
],
[
[
8,
9
],
[
11,
11
],
[
175,
176
]
]
]
|
0d6fab016779c1c755ab8b8ec645cc5aba1d6e71 | accd6e4daa3fc1103c86d245c784182e31681ea4 | /HappyHunter/Core/safefunction.h | 40252e61a06d9fb7db6f64c62d893431324d26e6 | []
| no_license | linfuqing/zero3d | d87ad6cf97069aea7861332a9ab8fc02b016d286 | cebb12c37fe0c9047fb5b8fd3c50157638764c24 | refs/heads/master | 2016-09-05T19:37:56.213992 | 2011-08-04T01:37:36 | 2011-08-04T01:37:36 | 34,048,942 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 893 | h | #ifndef SAFEFUCTION_H
#define SAFEFUCTION_H
namespace zerO
{
#ifdef _UNICODE
#define STRLEN(pStr) wcslen(pStr)
#define STRCPY(pDest, pSource) wcscpy_s(pDest, pSource)
#define STRTOK(pStr, pDelim, ppContext) wcstok_s(pStr, pDelim, ppContext)
#define VSPRINTF(pBuffer, uCount, pText, pArgList) vswprintf_s(pBuffer, uCount, pText, pArgList)
#define STRSTR(pStr, pSubStr) wcsstr(pStr, pSubStr)
#else
#define STRLEN(pStr) strlen(pStr)
#define STRCPY(pDest, pSource) strcpy_s(pDest, pSource)
#define STRTOK(pStr, pDelim, ppContext) strtok_s(pStr, pDelim, ppContext)
#define VSPRINTF(pBuffer, uCount, pText, pArgList) vsprintf_s(pBuffer, uCount, pText, pArgList)
#define STRSTR(pStr, pSubStr) strstr(pStr, pSubStr)
#endif
#define STRCMP(pStr1, pStr2) _strcmpi(pStr1, pStr2)
#define STRNICMP(pStr1, pStr2, uMaxCount) _strnicmp(pStr1, pStr2, uMaxCount)
}
#endif | [
"[email protected]"
]
| [
[
[
1,
24
]
]
]
|
21c1b32aae8dba90c97886e183476bca397fd436 | 5ff30d64df43c7438bbbcfda528b09bb8fec9e6b | /tests/graphics/step02/Drawable.h | 8bf6a7ae6468891a1d82e1afee143ca88e575346 | []
| no_license | lvtx/gamekernel | c80cdb4655f6d4930a7d035a5448b469ac9ae924 | a84d9c268590a294a298a4c825d2dfe35e6eca21 | refs/heads/master | 2016-09-06T18:11:42.702216 | 2011-09-27T07:22:08 | 2011-09-27T07:22:08 | 38,255,025 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 242 | h | #pragma once
#include <string>
namespace gfx {
class Renderer;
/**
* @class Drawable
*/
class Drawable
{
public:
Drawable();
virtual ~Drawable();
virtual void Draw( Renderer* renderer );
};
} // namespace gfx
| [
"darkface@localhost"
]
| [
[
[
1,
21
]
]
]
|
5b81693a60b5fe0fee7a8ad7ab65505d26e6e47f | ef23e388061a637f82b815d32f7af8cb60c5bb1f | /src/mame/includes/cchasm.h | 3ef7e88302e2735dc2b9815bea84df3d88fb065d | []
| no_license | marcellodash/psmame | 76fd877a210d50d34f23e50d338e65a17deff066 | 09f52313bd3b06311b910ed67a0e7c70c2dd2535 | refs/heads/master | 2021-05-29T23:57:23.333706 | 2011-06-23T20:11:22 | 2011-06-23T20:11:22 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,206 | h | /*************************************************************************
Cinematronics Cosmic Chasm hardware
*************************************************************************/
#include "machine/z80ctc.h"
class cchasm_state : public driver_device
{
public:
cchasm_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
int m_sound_flags;
int m_coin_flag;
device_t *m_ctc;
int m_channel_active[2];
int m_output[2];
UINT16 *m_ram;
int m_xcenter;
int m_ycenter;
};
/*----------- defined in machine/cchasm.c -----------*/
WRITE16_HANDLER( cchasm_led_w );
/*----------- defined in audio/cchasm.c -----------*/
extern const z80ctc_interface cchasm_ctc_intf;
WRITE8_HANDLER( cchasm_reset_coin_flag_w );
INPUT_CHANGED( cchasm_set_coin_flag );
READ8_HANDLER( cchasm_coin_sound_r );
READ8_HANDLER( cchasm_soundlatch2_r );
WRITE8_HANDLER( cchasm_soundlatch4_w );
WRITE16_HANDLER( cchasm_io_w );
READ16_HANDLER( cchasm_io_r );
SOUND_START( cchasm );
/*----------- defined in video/cchasm.c -----------*/
WRITE16_HANDLER( cchasm_refresh_control_w );
VIDEO_START( cchasm );
| [
"Mike@localhost"
]
| [
[
[
1,
50
]
]
]
|
c54c905dd1edd71484036e85e7bb68c7d2c021e4 | b8ac0bb1d1731d074b7a3cbebccc283529b750d4 | /Code/controllers/Tcleaner/protocol/BoardPacketHandler.h | 4c0cbc0eafd29bf3ea359e31436bbebf1acf2d29 | []
| no_license | dh-04/tpf-robotica | 5efbac38d59fda0271ac4639ea7b3b4129c28d82 | 10a7f4113d5a38dc0568996edebba91f672786e9 | refs/heads/master | 2022-12-10T18:19:22.428435 | 2010-11-05T02:42:29 | 2010-11-05T02:42:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 487 | h | // Class automatically generated by Dev-C++ New Class wizard
#ifndef BOARDPACKETHANDLER_H
#define BOARDPACKETHANDLER_H
#include <protocol/Packet.h>
#ifdef LINUX
#include <mutex>
#endif
namespace protocol {
/**
* No description
*/
class BoardPacketHandler
{
public:
// class destructor
virtual ~BoardPacketHandler(){};
virtual void handlePacket(Packet * p) = 0;
bool isBitSet(int val, int index);
};
}
#endif // BOARDPACKETHANDLER_H
| [
"guicamest@d69ea68a-f96b-11de-8cdf-e97ad7d0f28a",
"nachogoni@d69ea68a-f96b-11de-8cdf-e97ad7d0f28a"
]
| [
[
[
1,
23
],
[
27,
31
]
],
[
[
24,
26
]
]
]
|
17d4beafa85a733ee4fd6a6046b0749b7151155b | 864b3c4db459e0b497eab4ec85cce01122c48fad | /kg_static_polymorphism_multi_platform/src/ps2/kg_widget_ps2.h | fadd56bc4bc52b84e3d2f112fd3bb8fcd8131eee | []
| no_license | kgeorge/kgeorge-lib | e1b6334f7e02822886641c5a92956045bfd88349 | c81040deeebb9324845928a65d1d9146fac3d2dd | refs/heads/master | 2021-01-10T08:19:23.124790 | 2009-07-12T23:04:54 | 2009-07-12T23:04:54 | 36,910,482 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 529 | h | #if !defined(KG_WIDGET_PS2_H_)
#define KG_WIDGET_PS2_H_
#include "kg_widget.h"
//ps2 platform specific headers that is usable by kg_widget_ps2.cpp
//goes here
//Please note that this .h file is not publicly shared and is kept in the
//src directory rather than the inc directory
namespace kg_static_polymorphism_multi_platform
{
//definitions of ps2 platform specific static functions and private classes
//goes here
}//namespace kg_static_polymorphism_multi_platform
#endif //KG_WIDGET_PS2_H_ | [
"kgeorge2@553ec044-b8b1-11dd-a067-9b1d96bc3259"
]
| [
[
[
1,
21
]
]
]
|
ca5c8371c4e550b377067e067d544b9b9ca33024 | 9fb229975cc6bd01eb38c3e96849d0c36985fa1e | /src/Lib3D2/Color.h | 157c4773495ae1c790217fe5cb9adc14187be9d2 | []
| no_license | Danewalker/ahr | 3758bf3219f407ed813c2bbed5d1d86291b9237d | 2af9fd5a866c98ef1f95f4d1c3d9b192fee785a6 | refs/heads/master | 2016-09-13T08:03:43.040624 | 2010-07-21T15:44:41 | 2010-07-21T15:44:41 | 56,323,321 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,644 | h | #ifndef _COLOR_H_
#define _COLOR_H_
#include "config.h"
namespace Lib3D
{
// ---------------------------------------------------------------------------
// Colour Manipulation functions
//
//
// Note: The colour Format is:
// 16 bits: gd/a 4 bits, can be alpha (in the texture) or gouraud shading in the screen buffer
// r,g,b 4 bits/chanel. The rgb triplet is located in the lower part of the
// value for compatibility with the Simbian frame buffer
// ---------------------------------------------------------------------------
class CColor
{
public:
typedef unsigned int Type;
enum
{
kMaskA = 0xF000,
kMaskR = 0x0F00,
kMaskG = 0x00F0,
kMaskB = 0x000F
};
enum
{
kMaxintensity = 0x0F
};
enum
{
kNbColourShade = 1<<16,
};
inline static Type ClampIntensity(int i) {if (i >= kMaxintensity) return kMaxintensity;else if(i <= 0)return 0; else return i;}
inline static Type MaxIntensity() {return kMaxintensity;}
inline static void SetIntensity(Type& col,int i) {if(i>=0){if(i>=kMaxintensity) i=kMaxintensity; col = (col&0x0FFF) | (i<<12);}}
inline static void SetMaxIntensity(Type& col) {col = (col&0x0FFF) | (unsigned short)(kMaxintensity<<12);}
// Create a 16 bits colour from a 24bits RGB
inline static Type GetColor(const unsigned char* data) {return GetColor(data,0xFF);}
inline static Type GetColorAlpha(const unsigned char* data) {return GetColor(data,data[3]);}
inline static Type GetColor(const unsigned char* data,unsigned char i)
{
return ((i &0xF0) << 8) |
((data[0]&0xF0) << 4) |
((data[1]&0xF0) ) |
((data[2]&0xF0) >>4 );
}
inline static Type GetRawColour(const Type c) {return c & 0x0FFF;}
inline static Type Mix(Type a,Type b,Type c,Type d)
{
// TODO: Alpha
Type r1 = ((a & kMaskR) +(b & kMaskR) +(c & kMaskR) + (d & kMaskR)) >> 2;
Type g1 = ((a & kMaskG) +(b & kMaskG) +(c & kMaskG) + (d & kMaskG)) >> 2;
Type b1 = ((a & kMaskB) +(b & kMaskB) +(c & kMaskB) + (d & kMaskB)) >> 2;
Type a1 = ((a & kMaskA)>>2) + ((b & kMaskA)>>2) +((c & kMaskA)>>2) + ((d & kMaskA)>>2);
return (a1 & kMaskA)| (r1 & kMaskR) | (g1&kMaskG) | b1;
}
inline static Type Mix(Type a,Type b)
{
// TODO: Alpha
Type r1 = ((a & kMaskR) +(b & kMaskR)) >>1;
Type g1 = ((a & kMaskG) +(b & kMaskG)) >>1;
Type b1 = ((a & kMaskB) +(b & kMaskB)) >>1;
Type a1 = ((a & kMaskA)>>1) + ((b & kMaskA)>>1);
return (a1 & kMaskA)| (r1 & kMaskR) | (g1&kMaskG) | b1;
}
static inline void MaskAlpha(Type& c) {}
};
}//namepsace
#endif // _COLOR_H_
| [
"jakesoul@c957e3ca-5ece-11de-8832-3f4c773c73ae"
]
| [
[
[
1,
87
]
]
]
|
3f2aa21c037d81507d2b3f521b86d82a7dd0dc08 | ef23e388061a637f82b815d32f7af8cb60c5bb1f | /src/mame/includes/mermaid.h | 1b5ac77cbe129c269f750fbb9ce9e4f74243d518 | []
| no_license | marcellodash/psmame | 76fd877a210d50d34f23e50d338e65a17deff066 | 09f52313bd3b06311b910ed67a0e7c70c2dd2535 | refs/heads/master | 2021-05-29T23:57:23.333706 | 2011-06-23T20:11:22 | 2011-06-23T20:11:22 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,766 | h | /*************************************************************************
Mermaid
*************************************************************************/
class mermaid_state : public driver_device
{
public:
mermaid_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
/* memory pointers */
UINT8 * m_videoram;
UINT8 * m_colorram;
UINT8 * m_videoram2;
UINT8 * m_spriteram;
UINT8 * m_bg_scrollram;
UINT8 * m_fg_scrollram;
UINT8 * m_ay8910_enable;
size_t m_spriteram_size;
/* video-related */
tilemap_t *m_bg_tilemap;
tilemap_t *m_fg_tilemap;
bitmap_t* m_helper;
bitmap_t* m_helper2;
int m_coll_bit0;
int m_coll_bit1;
int m_coll_bit2;
int m_coll_bit3;
int m_coll_bit6;
int m_rougien_gfxbank1;
int m_rougien_gfxbank2;
/* sound-related */
UINT32 m_adpcm_pos;
UINT32 m_adpcm_end;
UINT8 m_adpcm_idle;
int m_adpcm_data;
UINT8 m_adpcm_trigger;
UINT8 m_adpcm_rom_sel;
UINT8 m_adpcm_play_reg;
/* devices */
device_t *m_maincpu;
device_t *m_ay1;
device_t *m_ay2;
};
/*----------- defined in video/mermaid.c -----------*/
WRITE8_HANDLER( mermaid_videoram2_w );
WRITE8_HANDLER( mermaid_videoram_w );
WRITE8_HANDLER( mermaid_colorram_w );
WRITE8_HANDLER( mermaid_flip_screen_x_w );
WRITE8_HANDLER( mermaid_flip_screen_y_w );
WRITE8_HANDLER( mermaid_bg_scroll_w );
WRITE8_HANDLER( mermaid_fg_scroll_w );
WRITE8_HANDLER( rougien_gfxbankswitch1_w );
WRITE8_HANDLER( rougien_gfxbankswitch2_w );
READ8_HANDLER( mermaid_collision_r );
PALETTE_INIT( mermaid );
PALETTE_INIT( rougien );
VIDEO_START( mermaid );
SCREEN_UPDATE( mermaid );
SCREEN_EOF( mermaid );
| [
"Mike@localhost"
]
| [
[
[
1,
70
]
]
]
|
2425d6dbda999a69713ce2eb72aaf4982e357919 | fd3f2268460656e395652b11ae1a5b358bfe0a59 | /srchybrid/ReadWriteLock.h | 8c2632de9554708d1ecc261eb72398563003aaef | []
| no_license | mikezhoubill/emule-gifc | e1cc6ff8b1bb63197bcfc7e67c57cfce0538ff60 | 46979cf32a313ad6d58603b275ec0b2150562166 | refs/heads/master | 2021-01-10T20:37:07.581465 | 2011-08-13T13:58:37 | 2011-08-13T13:58:37 | 32,465,033 | 4 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,227 | h | //this file is part of eMule
// added by SLUGFILLER
//
//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., 675 Mass Ave, Cambridge, MA 02139, USA.
// SLUGFILLER: SafeHash
#pragma once
class CReadWriteLock
{
public:
CReadWriteLock();
CReadWriteLock(CReadWriteLock* other);
~CReadWriteLock();
bool ReadLock(DWORD dwMilliseconds = INFINITE);
void ReadUnlock();
bool WriteLock(DWORD dwMilliseconds = INFINITE);
void WriteUnlock();
private:
HANDLE m_hAccessLock;
HANDLE m_hCanRead;
HANDLE m_hCanWrite;
int m_nReadLocks;
int m_nWriteLocks;
int m_sState;
CReadWriteLock* m_other;
};
| [
"Mike.Ken.S@dd569cc8-ff36-11de-bbca-1111db1fd05b"
]
| [
[
[
1,
40
]
]
]
|
4f6e7495a82df6455373ccfe8ed388383aeaa2ad | b22c254d7670522ec2caa61c998f8741b1da9388 | /shared/MapInfo.h | b2ec0dec560b39a7ddf831359d670d07655b57d7 | []
| no_license | ldaehler/lbanet | 341ddc4b62ef2df0a167caff46c2075fdfc85f5c | ecb54fc6fd691f1be3bae03681e355a225f92418 | refs/heads/master | 2021-01-23T13:17:19.963262 | 2011-03-22T21:49:52 | 2011-03-22T21:49:52 | 39,529,945 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,779 | h | /*
------------------------[ Lbanet Source ]-------------------------
Copyright (C) 2009
Author: Vivien Delage [Rincevent_123]
Email : [email protected]
-------------------------------[ GNU License ]-------------------------------
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
*/
#ifndef __LBA_NET_MAP_INFO_H__
#define __LBA_NET_MAP_INFO_H__
#include <map>
#include <string>
#include "ObjectsDescription.h"
/***********************************************************************
contain world description
***********************************************************************/
struct WorldDesc
{
std::string WorldName;
std::string Description;
std::string FileName;
};
/***********************************************************************
contain information about a teleport place
***********************************************************************/
struct TPInfo
{
// name
std::string Name;
// arrival point
std::string NewMap;
std::string Spawning;
};
/***********************************************************************
contain information about a spawning point
***********************************************************************/
struct SpawningInfo
{
// name
std::string Name;
// position
float PosX;
float PosY;
float PosZ;
// rotation at arrival in degree
int Rotation;
};
/***********************************************************************
contains information about maps
***********************************************************************/
class MapInfo
{
public:
// map name
std::string Name;
// map type: e.g interior/exterior
std::string Type;
// map description
std::string Description;
// path to the music file to be played
std::string Music;
// number of time the music should be played
int MusicLoop;
// files to be loaded
std::map<std::string, std::string> Files;
// spawning points
std::map<std::string, SpawningInfo> Spawnings;
// actors
std::map<long, ObjectInfo> Actors;
};
/***********************************************************************
contains information about where the new player should start in the world
***********************************************************************/
class WorldStartingInfo
{
public:
// map used at arrival in the world
std::string FirstMap;
// spawn area used at arrival in the world
std::string FirstSpawning;
};
/***********************************************************************
contains information about an LBA world
***********************************************************************/
class WorldInfo
{
public:
// world name
std::string Name;
//world starting info
WorldStartingInfo StartInfo;
// map description
std::string Description;
// description of the maps constituing the world
std::map<std::string, MapInfo> Maps;
// teleport places
std::map<std::string, TPInfo> Teleports;
// files to be loaded
std::map<std::string, std::string> Files;
};
#endif
| [
"vdelage@3806491c-8dad-11de-9a8c-6d5b7d1e4d13"
]
| [
[
[
1,
151
]
]
]
|
19e645a902dc39c5653e638725463e6740265272 | 79636d9a11c4ac53811d55ef0f432f68ab62944f | /smart-darkgdk/include/Terrain.h | cb0a466f649a0ed3aea73ef9af79bce1117e8b26 | [
"MIT"
]
| permissive | endel/smart-darkgdk | 44d90a1afcd71deebef65f47dc54586df4ae4736 | 6235288b8aab505577223f9544a6e5a7eb6bf6cd | refs/heads/master | 2021-01-19T10:58:29.387767 | 2009-06-26T16:44:15 | 2009-06-26T16:44:15 | 32,123,434 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 739 | h | #pragma once
#include "commonobject.h"
class Image;
class Object;
class Terrain :
public CommonObject
{
public:
Terrain();
~Terrain(void);
void load(char *filename);
void save(char *filename);
void setup();
void build();
void update();
void setScale(float x, float y, float z);
void setSplit(int split);
void setTiling(int tile);
void setHeightmap(char* filename);
void setTexture(Image *texture, int detail=1);
Image *setTexture(char* imagePath, int detail=1);
void setLight( float fXDir, float fYDir, float fZDir, int iRed, int iGreen, int iBlue, float fScale );
float getGroundHeight(float x, float z);
float getGroundHeight(Object *o);
float getXSize();
float getZSize();
};
| [
"endel.dreyer@0995f060-2c81-11de-ae9b-2be1a451ffb1"
]
| [
[
[
1,
34
]
]
]
|
2b0bedbef1d2a55d5b0689b36cc862f89eecd9e0 | 670c614fea64d683cd517bf973559217a4b8d4b6 | / mindmap-search/mindmap-search_2nd/indexer/DBIndexBuilder.cpp | 2f318899ddf8a72cf534c7759972ef8a634dce4a | []
| no_license | mcpanic/mindmap-search | 5ce3e9a75d9a91224c38d7c0faa4089d9ea2487b | 67fd93be5f60c61a33d84f18cbaa1c5dd7ae7166 | refs/heads/master | 2021-01-18T13:33:19.390091 | 2009-04-06T11:42:07 | 2009-04-06T11:42:07 | 32,127,402 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 4,292 | cpp | #include "stdAfx.h"
#include "DBIndexBuilder.h"
#include "CppSQLite3.h"
#include <iostream>
#include <ctime>
#include <string>
#include <vector>
#pragma warning(disable:4996)
using namespace std;
DBIndexBuilder::DBIndexBuilder()
{
}
DBIndexBuilder::~DBIndexBuilder()
{
}
void DBIndexBuilder::Release()
{
delete this;
}
bool DBIndexBuilder::OpenDB()
{
m_dbMindmap.open(m_szDBFilename.c_str()); // DB open
return true;
}
bool DBIndexBuilder::CloseDB() // // DB close
{
m_dbMindmap.close();
return true;
}
// insert DB
bool DBIndexBuilder::insertIndexDB(string s_Word, string szFilename, vector<DBIndexEntity> &a_vNodes)
{
string szCommand;
if (!m_dbMindmap.tableExists("IndexDB"))
{
cout << endl << "IndexDB doesn't exist. Creating IndexDB table" << endl;
AddIndexDBTable();
}
if (a_vNodes.size() < 1)
{
printf("size lacking.");
return false;
}
char szTemp[1024] = {0,};
char sQuery[1024] = {0,};
CppSQLite3Query qry;
std::vector<int> vecIndexID;
std::vector<DBIndexEntity>::iterator it = a_vNodes.begin();
for (; it != a_vNodes.end(); ++it)
{
sprintf(sQuery, _T("select indexID from Dictionary where Word = '%s';"), s_Word.c_str());
try
{
qry = m_dbMindmap.execQuery(sQuery);
}
catch (CppSQLite3Exception &ex)
{
printf("Query문에 문제(%s)가 발생하여 프로그램을 종료합니다.(1)", ex.errorMessage());
abort();
}
if (true == qry.eof())
continue;
else {
sprintf(szTemp, _T("insert into IndexDB(IndexID, FileName, weight) values ((SELECT IndexID FROM Dictionary where word = '%s'), '%s', 0);"), s_Word.c_str(), szFilename.c_str());
try
{
m_dbMindmap.execQuery(szTemp);
}
catch (CppSQLite3Exception &ex)
{
printf("Query문에 문제(%s)가 발생하여 프로그램을 종료합니다.(2)\n", ex.errorMessage());
abort();
}
break;
}
}
return true;
}
bool DBIndexBuilder::insertDictionary(string s_Word, vector<DBIndexEntity> &a_vNodes)
{
string szCommand;
int nField = 0;
if (!m_dbMindmap.tableExists("Dictionary"))
{
cout << endl << "Dictionary doesn't exist. Creating Dictionary table" << endl;
AddDictionaryTable();
}
if (a_vNodes.size() < 1)
{
printf("Size Error!.");
return false;
}
char szTemp[1024] = {0,};
char sQuery[1024] = {0,};
CppSQLite3Query qry;
std::vector<int> vecIndexID;
std::vector<DBIndexEntity>::iterator it = a_vNodes.begin();
for (; it != a_vNodes.end(); ++it)
{
sprintf(sQuery, _T("select indexID from Dictionary where Word = '%s';"), s_Word);
try
{
qry = m_dbMindmap.execQuery(sQuery);
}
catch (CppSQLite3Exception &ex)
{
printf("Query문에 문제(%s)가 발생하여 프로그램을 종료합니다.(1)", ex.errorMessage());
abort();
}
if (true != qry.eof())
continue;
else
{
sprintf(szTemp, _T("insert into Dictionary(indexID, Word) values ((SELECT max(indexID) FROM Dictionary)+1, '%s');"), s_Word.c_str());
try
{
m_dbMindmap.execQuery(szTemp);
}
catch (CppSQLite3Exception &ex)
{
printf("Query문에 문제(%s)가 발생하여 프로그램을 종료합니다.(2)", ex.errorMessage());
abort();
}
break;
}
}
return true;
}
bool DBIndexBuilder::AddIndexDBTable()
{
if (m_dbMindmap.tableExists("IndexDB"))
{
return false;
}
if (ExecCommand("create table IndexDB(IndexID integer PRIMARY KEY, FileName TEXT, weight integer)"))
return true;
else
return false;
}
bool DBIndexBuilder::AddDictionaryTable()
{
if (m_dbMindmap.tableExists("Dictionary"))
{
return false;
}
if (ExecCommand("create table Dictionary(IndexID integer PRIMARY KEY, word TEXT)"))
return true;
else
return false;
}
int DBIndexBuilder::ExecCommand(char* a_szCommand)
{
int nResult = 0;
try
{
nResult = m_dbMindmap.execDML(a_szCommand); //a_szCommand.c_str();
}
catch (CppSQLite3Exception& e)
{
cerr << e.errorCode() << ":" << e.errorMessage() << endl;
return -1;
}
return nResult;
}
void DBIndexBuilder::SetDBName(string a_szDBFilename)
{
m_szDBFilename = a_szDBFilename;
} | [
"dolphhong@ba4b31b2-0743-0410-801d-7d2edeec4cc6"
]
| [
[
[
1,
203
]
]
]
|
488cdf62cfd522021c2c54c66179b04afe83c263 | e7c45d18fa1e4285e5227e5984e07c47f8867d1d | /Common/ModelsC/Petro1/SecReform.H | fcbb5af5b5e11320d9654ff97466676be3d13496 | []
| no_license | abcweizhuo/Test3 | 0f3379e528a543c0d43aad09489b2444a2e0f86d | 128a4edcf9a93d36a45e5585b70dee75e4502db4 | refs/heads/master | 2021-01-17T01:59:39.357645 | 2008-08-20T00:00:29 | 2008-08-20T00:00:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,804 | h | //================== SysCAD - Copyright Kenwalt (Pty) Ltd ===================
// $Nokeywords: $
//===========================================================================
// SysCAD Copyright Kenwalt (Pty) Ltd 1992
#ifndef __TANK_H
#define __TANK_H
#ifndef __SC_DEFS_H
#include "sc_defs.h"
#endif
#ifndef __M_SURGE_H
#include "m_surge.h"
#endif
#ifdef __SECREFORM_CPP
#define DllImportExport DllExport
#elif !defined(Petro1)
#define DllImportExport DllImport
#else
#define DllImportExport
#endif
//===========================================================================
const byte MaxSecRefTPoints=5;
DEFINE_TAGOBJ(SecReformer);
/*Basic Mixed Tank - Multiple Inputs and Outputs*/
class DllImportExport SecReformer: public MN_Surge
{
public:
//double FlashSplit;
//double SS_Lvl;
byte nAbove, nBelow;
struct
{
double m_dTemp;
double m_dMult;
} m_TPoints[MaxSecRefTPoints];
SecReformer(pTagObjClass pClass_, pchar TagIn, pTaggedObject pAttach, TagObjAttachment eAttach);
virtual ~SecReformer(){};
virtual void BuildDataDefn(DataDefnBlk & DDB);
virtual flag DataXchg(DataChangeBlk & DCB);
virtual flag ValidateData(ValidateDataBlk & VDB);
//virtual void StartSolution();
//virtual void EvalSteadyState();
//virtual void EvalJoinPressures(long JoinMask);
//virtual void EvalJoinFlows(int JoinNo);
virtual void EvalProducts(CNodeEvalIndex & NEI);
virtual void EvalDerivs(CNodeEvalIndex & NEI);
virtual void EvalDiscrete();
private:
};
//===========================================================================
#undef DllImportExport
#endif
| [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
50
],
[
53,
64
]
],
[
[
51,
52
]
]
]
|
c57802125b3046a870996a9c2f5f1a8fe9060d7b | cf0bff15c0e295fa1d8141032451301e423b2e0d | /StatModule.cpp | bb01a4d0e58430b3e908e71cacd592a77117c128 | []
| no_license | ershovdz/StatModule | ec902fe969b98dd545b34e68f9f8a423c1b12e89 | 414881c401b2ca4744ec40509e3b5c758dc2cfbe | refs/heads/master | 2016-09-03T06:57:38.835675 | 2011-05-13T09:05:40 | 2011-05-13T09:05:40 | 1,663,774 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,371 | cpp | #include "StatModule.h"
#include <boost/interprocess/sync/scoped_lock.hpp>
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/sync/named_mutex.hpp>
#include <boost/interprocess/sync/named_semaphore.hpp>
#include "boost/date_time/posix_time/posix_time.hpp"
#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/circular_buffer.hpp>
#include <boost/interprocess/exceptions.hpp>
using namespace boost::posix_time;
using namespace boost::interprocess;
/***********************************************
* class StatElement
*
* Stores statistic for period = interval/bufSize
************************************************/
class StatElement
{
friend class StatBlock;
protected:
StatElement()
: _totalDuration(0)
, _minDuration(-1)
, _maxDuration(0)
, _callsCounter(0)
{
};
StatElement(uint64_t totalDuration, uint64_t minDuration, uint64_t maxDuration, uint64_t callsCounter)
: _totalDuration(totalDuration)
, _minDuration(minDuration)
, _maxDuration(maxDuration)
, _callsCounter(callsCounter)
{
};
protected:
uint64_t _totalDuration;
uint64_t _minDuration;
uint64_t _maxDuration;
uint64_t _callsCounter;
};
typedef allocator<StatElement, managed_shared_memory::segment_manager> ShmStatElementAllocator;
typedef boost::circular_buffer<StatElement, ShmStatElementAllocator> ShmStatElementsBuffer;
typedef scoped_lock<interprocess_mutex> ScopedLocker;
typedef scoped_lock<named_mutex> NamedMutexLocker;
/****************************************************
* class StatBlock
*
* Stores StatElement objects for given block
* and provides functionality for API of StatModule
****************************************************/
class StatBlock
{
public:
/*
We must achieve the following precision: interval +- 10%.
So bufSize has to be 100% / 10% = 10 elements
*/
StatBlock(uint64_t interval, const ShmStatElementAllocator& ac, uint64_t bufSize = 10);
void AddCallInfo(uint64_t callDuration);
uint64_t GetCallCount();
uint64_t GetAvgDuration();
uint64_t GetMaxDuration();
uint64_t GetMinDuration();
private:
StatBlock(const StatBlock&);
uint64_t UpdateBuffer();
private:
ShmStatElementsBuffer _statBuf;
ptime _startTime;
interprocess_mutex _blockMutex; //may be spinlock is more suitable here
const uint64_t _interval;
const uint64_t _bufSize;
};
/*********************************************
* class StatBlockStorage
*
* Stores globals StatBlock objects
* and provides wrapper for shared memory
*********************************************/
class StatModule::StatBlockStorage
{
public:
static StatBlockStorage* CreateStorage();
static void RemoveStorage();
StatBlock* AddStat(const char* szName, uint64_t interval);
private:
StatBlockStorage(void);
StatBlockStorage(const StatBlockStorage&) {};
private:
managed_shared_memory _shmSegment;
uint64_t _localRefCounter;
uint64_t volatile* _pInterprocessRefCounter; //pointer to counter, stored in shared memory
static StatBlockStorage* _pStorageInstance;
static const uint64_t SEGMENT_SIZE;
};
/*******************************
class StatBlock
********************************/
StatBlock::StatBlock(uint64_t interval, const ShmStatElementAllocator& ac, uint64_t bufSize)
: _statBuf(bufSize, ac)
, _startTime(boost::posix_time::microsec_clock::local_time())
, _interval(interval*1000000) //interval is in seconds, but we use microseconds
, _bufSize(bufSize)
{
printf("\n CREATE NEW StatBlock\n");
for(uint64_t i = 0; i < bufSize; ++i)
{
_statBuf.push_back(StatElement());
}
};
uint64_t StatBlock::UpdateBuffer()
{
ptime callTime(boost::posix_time::microsec_clock::local_time());
uint64_t cur_interval = (callTime - _startTime).total_microseconds();
uint64_t shift = ((double)cur_interval/_interval)*_bufSize;
/**********************************************
* CASE 1:
* ____ <== _startTime
* |____|
*_statBuf |____|<== cur_interval is here now
* |____|
* |____|<== _startTime + _interval
***********************************************/
if(shift < _bufSize)
return shift;
/**********************************************
* CASE 2:
* _____ <== _startTime
* |stale|
* |stale|
* |_____|
*_statBuf |_____|<== _startTime + _interval
* |_____|
* |_____|<== cur_interval is here now
* |_____|
* |_____|<== _startTime + 2*_interval
***********************************************/
if(cur_interval - _interval < _interval)
{
//printf("\n\n CASE 2 \n\n");
shift -= _bufSize - 1;
for(uint64_t i = 0; i < shift; ++i)
{
_statBuf.push_back(StatElement()); //remove stale StatElement and insert new
}
_startTime += microseconds(shift*(_interval/_bufSize));
return _bufSize;
}
//printf("\n\n CASE 3 \n\n");
/******************************************************************************
* CASE 3:
* _____ <== _startTime ____ <== _startTime,
* |stale| |____|<== cur_interval is here now
* |stale| |____|
* |stale| |____|
*_statBuf |stale|<== _startTime + _interv |____|
* |stale| |____|
* |stale| Clear _statBuf |____|<== _startTime + _interval
* |stale| ==============>
* |stale|<== _startTime + 2*_interval
* |_____|
* |_____|<== cur_interval is here now
* |_____|
* |_____|<== _startTime + 3*_interval
********************************************************************************/
for(uint64_t i = 0; i < _bufSize; ++i)
{
_statBuf[i]._callsCounter = 0;
_statBuf[i]._totalDuration = 0;
_statBuf[i]._minDuration = -1;
_statBuf[i]._maxDuration = 0;
}
_startTime += microseconds(shift*(_interval/_bufSize));
return shift;
}
void StatBlock::AddCallInfo(uint64_t callDuration)
{
ScopedLocker lock(_blockMutex);
uint64_t shift = UpdateBuffer();
if(shift < _bufSize) //case 1
{
_statBuf[shift]._callsCounter++;
_statBuf[shift]._totalDuration += callDuration;
if(_statBuf[shift]._minDuration > callDuration)
_statBuf[shift]._minDuration = callDuration;
else if(_statBuf[shift]._maxDuration < callDuration)
_statBuf[shift]._maxDuration = callDuration;
}
else if(shift == _bufSize) //case 2
{
_statBuf[_bufSize - 1]._callsCounter = 1;
_statBuf[_bufSize - 1]._totalDuration = callDuration;
_statBuf[_bufSize - 1]._minDuration = callDuration;
_statBuf[_bufSize - 1]._maxDuration = callDuration;
}
else if(shift > _bufSize) //case 3, buffer is clear now
{
_statBuf[0]._callsCounter = 1;
_statBuf[0]._totalDuration = callDuration;
_statBuf[0]._minDuration = callDuration;
_statBuf[0]._maxDuration = callDuration;
}
}
uint64_t StatBlock::GetAvgDuration()
{
ScopedLocker lock(_blockMutex);
UpdateBuffer();
uint64_t totalTime = 0;
uint64_t totalCallCount = 0;
for(uint64_t i = 0; i < _bufSize; ++i)
{
totalTime += _statBuf[i]._totalDuration;
totalCallCount += _statBuf[i]._callsCounter;
}
if(totalCallCount)
{
return totalTime/totalCallCount;
}
return 0;
}
uint64_t StatBlock::GetMaxDuration()
{
ScopedLocker lock(_blockMutex);
UpdateBuffer();
uint64_t maxDuration = 0;
for(uint64_t i = 0; i < _bufSize; ++i)
{
if(maxDuration < _statBuf[i]._maxDuration)
maxDuration = _statBuf[i]._maxDuration;
}
return maxDuration;
}
uint64_t StatBlock::GetMinDuration()
{
ScopedLocker lock(_blockMutex);
UpdateBuffer();
uint64_t minDuration = _statBuf[0]._minDuration;
for(uint64_t i = 1; i < _bufSize; ++i)
{
if(minDuration > _statBuf[i]._minDuration)
minDuration = _statBuf[i]._minDuration;
}
if(minDuration == uint64_t(-1))
return 0;
return minDuration;
}
uint64_t StatBlock::GetCallCount()
{
ScopedLocker lock(_blockMutex);
UpdateBuffer();
uint64_t totalCallCounter = 0;
for(uint64_t i = 0; i < _bufSize; i++)
{
totalCallCounter += _statBuf[i]._callsCounter;
}
return totalCallCounter;
}
/*******************************
class StatBlockStorage
********************************/
StatModule::StatBlockStorage* StatModule::StatBlockStorage::_pStorageInstance = 0;
//we are going to store up to 1000 stat block. Size of each one is ~600 bytes
//Let's set segment size to 2 MB, just in case
const uint64_t StatModule::StatBlockStorage::SEGMENT_SIZE = 2091008;
StatModule::StatBlockStorage::StatBlockStorage()
:_shmSegment(open_or_create, "STATBLOCK_STORAGE", SEGMENT_SIZE) // can throw
, _localRefCounter(1)
, _pInterprocessRefCounter(0)
{
}
StatModule::StatBlockStorage* StatModule::StatBlockStorage::CreateStorage()
{
named_mutex storageMutex(open_or_create, "STATBLOCK_STORAGE_MUTEX");
NamedMutexLocker lock(storageMutex);
try
{
if(_pStorageInstance)
{
_pStorageInstance->_localRefCounter++;
printf("\nCurrent thread counter = %llu\n", _pStorageInstance->_localRefCounter);
return _pStorageInstance;
}
_pStorageInstance = new StatBlockStorage();
// increment interprocess ref counter
_pStorageInstance->_pInterprocessRefCounter = _pStorageInstance->_shmSegment.find_or_construct<uint64_t>("STATBLOCK_STORAGE_REF_COUNTER")(0);
(*(_pStorageInstance->_pInterprocessRefCounter))++;
printf("Current proc counter = %llu\n", *(_pStorageInstance->_pInterprocessRefCounter));
}
catch(...) // could not create storage or obtain ref counter
{
if(_pStorageInstance) //we have created a first instance, so we can delete it
{
try
{
delete _pStorageInstance;
}
catch(...) //shit happens
{
}
_pStorageInstance = 0;
}
}
printf("\n STORAGE IS CREATED \n");
return _pStorageInstance;
}
void StatModule::StatBlockStorage::RemoveStorage()
{
named_mutex storageMutex(open_or_create, "STATBLOCK_STORAGE_MUTEX");
NamedMutexLocker lock(storageMutex);
try
{
if(_pStorageInstance)
{
_pStorageInstance->_localRefCounter--;
printf("\nCurrent thread counter = %llu\n\n", _pStorageInstance->_localRefCounter);
if(0 == _pStorageInstance->_localRefCounter) // last thread
{
(*(_pStorageInstance->_pInterprocessRefCounter))--;
printf("\nCurrent proc counter = %llu\n", *(_pStorageInstance->_pInterprocessRefCounter));
if(0 == *(_pStorageInstance->_pInterprocessRefCounter)) // last process
{
shared_memory_object::remove("STATBLOCK_STORAGE");
printf("\n SHARED MEMORY IS REMOVED \n");
}
delete _pStorageInstance;
_pStorageInstance = 0;
printf("\n\n STORAGE IS REMOVED \n\n");
}
}
}
catch(...) //
{
}
}
StatBlock* StatModule::StatBlockStorage::AddStat(const char* szName, uint64_t interval)
{
named_mutex storageMutex(open_or_create, "STATBLOCK_STORAGE_MUTEX");
NamedMutexLocker lock(storageMutex);
const ShmStatElementAllocator allocator(_shmSegment.get_segment_manager());
return _shmSegment.find_or_construct<StatBlock>(szName)(interval, allocator, 10);
};
/*******************************
class StatModule
********************************/
StatModule::StatModule(): _interval(600) // 10 minutes, by default
{
pStorage = StatModule::StatBlockStorage::CreateStorage();
}
StatModule::~StatModule()
{
StatModule::StatBlockStorage::RemoveStorage();
pStorage = 0;
}
void StatModule::SetInterval(uint64_t interval)
{
_interval = interval;
}
STAT_HANDLE StatModule::AddStat(const char* szName)
{
try
{
return pStorage->AddStat(szName, _interval);
}
catch(...)
{
}
return 0;
}
void StatModule::AddCallInfo(STAT_HANDLE h, uint64_t callDuration)
{
h->AddCallInfo(callDuration);
}
uint64_t StatModule::GetCallCount(STAT_HANDLE h)
{
return h->GetCallCount();
}
uint64_t StatModule::GetAvgDuration(STAT_HANDLE h)
{
return h->GetAvgDuration();
}
uint64_t StatModule::GetMaxDuration(STAT_HANDLE h)
{
return h->GetMaxDuration();
}
uint64_t StatModule::GetMinDuration(STAT_HANDLE h)
{
return h->GetMinDuration();
}
| [
"user@bell.(none)",
"[email protected]"
]
| [
[
[
1,
15
],
[
22,
23
],
[
27,
40
],
[
43,
50
],
[
52,
54
],
[
61,
80
],
[
82,
82
],
[
84,
87
],
[
95,
106
],
[
110,
110
],
[
113,
142
],
[
148,
153
],
[
163,
165
],
[
167,
168
],
[
170,
176
],
[
178,
179
],
[
193,
193
],
[
195,
215
],
[
217,
224
],
[
226,
229
],
[
231,
231
],
[
234,
245
],
[
247,
247
],
[
250,
266
],
[
268,
282
],
[
284,
320
],
[
322,
334
],
[
336,
340
],
[
346,
352
],
[
354,
375
],
[
378,
379
],
[
383,
413
],
[
415,
418
],
[
420,
458
]
],
[
[
16,
21
],
[
24,
26
],
[
41,
42
],
[
51,
51
],
[
55,
60
],
[
81,
81
],
[
83,
83
],
[
88,
94
],
[
107,
109
],
[
111,
112
],
[
143,
147
],
[
154,
162
],
[
166,
166
],
[
169,
169
],
[
177,
177
],
[
180,
192
],
[
194,
194
],
[
216,
216
],
[
225,
225
],
[
230,
230
],
[
232,
233
],
[
246,
246
],
[
248,
249
],
[
267,
267
],
[
283,
283
],
[
321,
321
],
[
335,
335
],
[
341,
345
],
[
353,
353
],
[
376,
377
],
[
380,
382
],
[
414,
414
],
[
419,
419
]
]
]
|
83daf67c72289cd1fa165ca97622409898acd7ad | e2e49023f5a82922cb9b134e93ae926ed69675a1 | /tools/aoslcpp/include/aosl/axis_origin_z_forward.hpp | e750032daff39346b608a29ff2e72432121112e8 | []
| no_license | invy/mjklaim-freewindows | c93c867e93f0e2fe1d33f207306c0b9538ac61d6 | 30de8e3dfcde4e81a57e9059dfaf54c98cc1135b | refs/heads/master | 2021-01-10T10:21:51.579762 | 2011-12-12T18:56:43 | 2011-12-12T18:56:43 | 54,794,395 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,552 | hpp | // Copyright (C) 2005-2010 Code Synthesis Tools CC
//
// This program was generated by CodeSynthesis XSD, an XML Schema
// to C++ data binding compiler, in the Proprietary License mode.
// You should have received a proprietary license from Code Synthesis
// Tools CC prior to generating this code. See the license text for
// conditions.
//
#ifndef AOSLCPP_AOSL__AXIS_ORIGIN_Z_FORWARD_HPP
#define AOSLCPP_AOSL__AXIS_ORIGIN_Z_FORWARD_HPP
// Begin prologue.
//
//
// End prologue.
#include <xsd/cxx/version.hxx>
#if (XSD_INT_VERSION != 3030000L)
#error XSD runtime version mismatch
#endif
#include <xsd/cxx/pre.hxx>
#ifndef XSD_USE_CHAR
#define XSD_USE_CHAR
#endif
#ifndef XSD_CXX_TREE_USE_CHAR
#define XSD_CXX_TREE_USE_CHAR
#endif
#include <xsd/cxx/xml/char-utf8.hxx>
#include <xsd/cxx/tree/exceptions.hxx>
#include <xsd/cxx/tree/elements.hxx>
#include <xsd/cxx/tree/types.hxx>
#include <xsd/cxx/xml/error-handler.hxx>
#include <xsd/cxx/xml/dom/auto-ptr.hxx>
#include <xsd/cxx/tree/parsing.hxx>
#include <xsd/cxx/tree/parsing/byte.hxx>
#include <xsd/cxx/tree/parsing/unsigned-byte.hxx>
#include <xsd/cxx/tree/parsing/short.hxx>
#include <xsd/cxx/tree/parsing/unsigned-short.hxx>
#include <xsd/cxx/tree/parsing/int.hxx>
#include <xsd/cxx/tree/parsing/unsigned-int.hxx>
#include <xsd/cxx/tree/parsing/long.hxx>
#include <xsd/cxx/tree/parsing/unsigned-long.hxx>
#include <xsd/cxx/tree/parsing/boolean.hxx>
#include <xsd/cxx/tree/parsing/float.hxx>
#include <xsd/cxx/tree/parsing/double.hxx>
#include <xsd/cxx/tree/parsing/decimal.hxx>
#include <xsd/cxx/xml/dom/serialization-header.hxx>
#include <xsd/cxx/tree/serialization.hxx>
#include <xsd/cxx/tree/serialization/byte.hxx>
#include <xsd/cxx/tree/serialization/unsigned-byte.hxx>
#include <xsd/cxx/tree/serialization/short.hxx>
#include <xsd/cxx/tree/serialization/unsigned-short.hxx>
#include <xsd/cxx/tree/serialization/int.hxx>
#include <xsd/cxx/tree/serialization/unsigned-int.hxx>
#include <xsd/cxx/tree/serialization/long.hxx>
#include <xsd/cxx/tree/serialization/unsigned-long.hxx>
#include <xsd/cxx/tree/serialization/boolean.hxx>
#include <xsd/cxx/tree/serialization/float.hxx>
#include <xsd/cxx/tree/serialization/double.hxx>
#include <xsd/cxx/tree/serialization/decimal.hxx>
#include <xsd/cxx/tree/std-ostream-operators.hxx>
/**
* @brief C++ namespace for the %http://www.w3.org/2001/XMLSchema
* schema namespace.
*/
namespace xml_schema
{
// anyType and anySimpleType.
//
/**
* @brief C++ type corresponding to the anyType XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::type Type;
/**
* @brief C++ type corresponding to the anySimpleType XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::simple_type< Type > SimpleType;
/**
* @brief Alias for the anyType type.
*/
typedef ::xsd::cxx::tree::type Container;
// 8-bit
//
/**
* @brief C++ type corresponding to the byte XML Schema
* built-in type.
*/
typedef signed char Byte;
/**
* @brief C++ type corresponding to the unsignedByte XML Schema
* built-in type.
*/
typedef unsigned char UnsignedByte;
// 16-bit
//
/**
* @brief C++ type corresponding to the short XML Schema
* built-in type.
*/
typedef short Short;
/**
* @brief C++ type corresponding to the unsignedShort XML Schema
* built-in type.
*/
typedef unsigned short UnsignedShort;
// 32-bit
//
/**
* @brief C++ type corresponding to the int XML Schema
* built-in type.
*/
typedef int Int;
/**
* @brief C++ type corresponding to the unsignedInt XML Schema
* built-in type.
*/
typedef unsigned int UnsignedInt;
// 64-bit
//
/**
* @brief C++ type corresponding to the long XML Schema
* built-in type.
*/
typedef long long Long;
/**
* @brief C++ type corresponding to the unsignedLong XML Schema
* built-in type.
*/
typedef unsigned long long UnsignedLong;
// Supposed to be arbitrary-length integral types.
//
/**
* @brief C++ type corresponding to the integer XML Schema
* built-in type.
*/
typedef long long Integer;
/**
* @brief C++ type corresponding to the nonPositiveInteger XML Schema
* built-in type.
*/
typedef long long NonPositiveInteger;
/**
* @brief C++ type corresponding to the nonNegativeInteger XML Schema
* built-in type.
*/
typedef unsigned long long NonNegativeInteger;
/**
* @brief C++ type corresponding to the positiveInteger XML Schema
* built-in type.
*/
typedef unsigned long long PositiveInteger;
/**
* @brief C++ type corresponding to the negativeInteger XML Schema
* built-in type.
*/
typedef long long NegativeInteger;
// Boolean.
//
/**
* @brief C++ type corresponding to the boolean XML Schema
* built-in type.
*/
typedef bool Boolean;
// Floating-point types.
//
/**
* @brief C++ type corresponding to the float XML Schema
* built-in type.
*/
typedef float Float;
/**
* @brief C++ type corresponding to the double XML Schema
* built-in type.
*/
typedef double Double;
/**
* @brief C++ type corresponding to the decimal XML Schema
* built-in type.
*/
typedef double Decimal;
// String types.
//
/**
* @brief C++ type corresponding to the string XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::string< char, SimpleType > String;
/**
* @brief C++ type corresponding to the normalizedString XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::normalized_string< char, String > NormalizedString;
/**
* @brief C++ type corresponding to the token XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::token< char, NormalizedString > Token;
/**
* @brief C++ type corresponding to the Name XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::name< char, Token > Name;
/**
* @brief C++ type corresponding to the NMTOKEN XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::nmtoken< char, Token > Nmtoken;
/**
* @brief C++ type corresponding to the NMTOKENS XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::nmtokens< char, SimpleType, Nmtoken > Nmtokens;
/**
* @brief C++ type corresponding to the NCName XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::ncname< char, Name > Ncname;
/**
* @brief C++ type corresponding to the language XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::language< char, Token > Language;
// ID/IDREF.
//
/**
* @brief C++ type corresponding to the ID XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::id< char, Ncname > Id;
/**
* @brief C++ type corresponding to the IDREF XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::idref< char, Ncname, Type > Idref;
/**
* @brief C++ type corresponding to the IDREFS XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::idrefs< char, SimpleType, Idref > Idrefs;
// URI.
//
/**
* @brief C++ type corresponding to the anyURI XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::uri< char, SimpleType > Uri;
// Qualified name.
//
/**
* @brief C++ type corresponding to the QName XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::qname< char, SimpleType, Uri, Ncname > Qname;
// Binary.
//
/**
* @brief Binary buffer type.
*/
typedef ::xsd::cxx::tree::buffer< char > Buffer;
/**
* @brief C++ type corresponding to the base64Binary XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::base64_binary< char, SimpleType > Base64Binary;
/**
* @brief C++ type corresponding to the hexBinary XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::hex_binary< char, SimpleType > HexBinary;
// Date/time.
//
/**
* @brief Time zone type.
*/
typedef ::xsd::cxx::tree::time_zone TimeZone;
/**
* @brief C++ type corresponding to the date XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::date< char, SimpleType > Date;
/**
* @brief C++ type corresponding to the dateTime XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::date_time< char, SimpleType > DateTime;
/**
* @brief C++ type corresponding to the duration XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::duration< char, SimpleType > Duration;
/**
* @brief C++ type corresponding to the gDay XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::gday< char, SimpleType > Gday;
/**
* @brief C++ type corresponding to the gMonth XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::gmonth< char, SimpleType > Gmonth;
/**
* @brief C++ type corresponding to the gMonthDay XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::gmonth_day< char, SimpleType > GmonthDay;
/**
* @brief C++ type corresponding to the gYear XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::gyear< char, SimpleType > Gyear;
/**
* @brief C++ type corresponding to the gYearMonth XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::gyear_month< char, SimpleType > GyearMonth;
/**
* @brief C++ type corresponding to the time XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::time< char, SimpleType > Time;
// Entity.
//
/**
* @brief C++ type corresponding to the ENTITY XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::entity< char, Ncname > Entity;
/**
* @brief C++ type corresponding to the ENTITIES XML Schema
* built-in type.
*/
typedef ::xsd::cxx::tree::entities< char, SimpleType, Entity > Entities;
// Namespace information and list stream. Used in
// serialization functions.
//
/**
* @brief Namespace serialization information.
*/
typedef ::xsd::cxx::xml::dom::namespace_info< char > NamespaceInfo;
/**
* @brief Namespace serialization information map.
*/
typedef ::xsd::cxx::xml::dom::namespace_infomap< char > NamespaceInfomap;
/**
* @brief List serialization stream.
*/
typedef ::xsd::cxx::tree::list_stream< char > ListStream;
/**
* @brief Serialization wrapper for the %double type.
*/
typedef ::xsd::cxx::tree::as_double< Double > AsDouble;
/**
* @brief Serialization wrapper for the %decimal type.
*/
typedef ::xsd::cxx::tree::as_decimal< Decimal > AsDecimal;
/**
* @brief Simple type facet.
*/
typedef ::xsd::cxx::tree::facet Facet;
// Flags and properties.
//
/**
* @brief Parsing and serialization flags.
*/
typedef ::xsd::cxx::tree::flags Flags;
/**
* @brief Parsing properties.
*/
typedef ::xsd::cxx::tree::properties< char > Properties;
// Parsing/serialization diagnostics.
//
/**
* @brief Error severity.
*/
typedef ::xsd::cxx::tree::severity Severity;
/**
* @brief Error condition.
*/
typedef ::xsd::cxx::tree::error< char > Error;
/**
* @brief List of %error conditions.
*/
typedef ::xsd::cxx::tree::diagnostics< char > Diagnostics;
// Exceptions.
//
/**
* @brief Root of the C++/Tree %exception hierarchy.
*/
typedef ::xsd::cxx::tree::exception< char > Exception;
/**
* @brief Exception indicating that the size argument exceeds
* the capacity argument.
*/
typedef ::xsd::cxx::tree::bounds< char > Bounds;
/**
* @brief Exception indicating that a duplicate ID value
* was encountered in the object model.
*/
typedef ::xsd::cxx::tree::duplicate_id< char > DuplicateId;
/**
* @brief Exception indicating a parsing failure.
*/
typedef ::xsd::cxx::tree::parsing< char > Parsing;
/**
* @brief Exception indicating that an expected element
* was not encountered.
*/
typedef ::xsd::cxx::tree::expected_element< char > ExpectedElement;
/**
* @brief Exception indicating that an unexpected element
* was encountered.
*/
typedef ::xsd::cxx::tree::unexpected_element< char > UnexpectedElement;
/**
* @brief Exception indicating that an expected attribute
* was not encountered.
*/
typedef ::xsd::cxx::tree::expected_attribute< char > ExpectedAttribute;
/**
* @brief Exception indicating that an unexpected enumerator
* was encountered.
*/
typedef ::xsd::cxx::tree::unexpected_enumerator< char > UnexpectedEnumerator;
/**
* @brief Exception indicating that the text content was
* expected for an element.
*/
typedef ::xsd::cxx::tree::expected_text_content< char > ExpectedTextContent;
/**
* @brief Exception indicating that a prefix-namespace
* mapping was not provided.
*/
typedef ::xsd::cxx::tree::no_prefix_mapping< char > NoPrefixMapping;
/**
* @brief Exception indicating that the type information
* is not available for a type.
*/
typedef ::xsd::cxx::tree::no_type_info< char > NoTypeInfo;
/**
* @brief Exception indicating that the types are not
* related by inheritance.
*/
typedef ::xsd::cxx::tree::not_derived< char > NotDerived;
/**
* @brief Exception indicating a serialization failure.
*/
typedef ::xsd::cxx::tree::serialization< char > Serialization;
/**
* @brief Error handler callback interface.
*/
typedef ::xsd::cxx::xml::error_handler< char > ErrorHandler;
/**
* @brief DOM interaction.
*/
namespace dom
{
/**
* @brief Automatic pointer for DOMDocument.
*/
using ::xsd::cxx::xml::dom::auto_ptr;
#ifndef XSD_CXX_TREE_TREE_NODE_KEY__XML_SCHEMA
#define XSD_CXX_TREE_TREE_NODE_KEY__XML_SCHEMA
/**
* @brief DOM user data key for back pointers to tree nodes.
*/
const XMLCh* const tree_node_key = ::xsd::cxx::tree::user_data_keys::node;
#endif
}
}
// Forward declarations.
//
namespace aosl
{
class Axis_origin_z;
}
#include <xsd/cxx/post.hxx>
// Begin epilogue.
//
//
// End epilogue.
#endif // AOSLCPP_AOSL__AXIS_ORIGIN_Z_FORWARD_HPP
| [
"klaim@localhost"
]
| [
[
[
1,
608
]
]
]
|
6d0a4ca3eff1410166db336af826606295cb0b04 | 2b80036db6f86012afcc7bc55431355fc3234058 | /src/contrib/oggdecoder/OggSourceSupplier.h | b4bcf483c52eb6cd9a554838200d746f68a14dc0 | [
"BSD-3-Clause"
]
| permissive | leezhongshan/musikcube | d1e09cf263854bb16acbde707cb6c18b09a0189f | e7ca6a5515a5f5e8e499bbdd158e5cb406fda948 | refs/heads/master | 2021-01-15T11:45:29.512171 | 2011-02-25T14:09:21 | 2011-02-25T14:09:21 | null | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 2,161 | h | //////////////////////////////////////////////////////////////////////////////
// Copyright © 2007, Björn Olievier
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include <core/audio/IDecoderFactory.h>
using namespace musik::core::audio;
class OggSourceSupplier : public IDecoderFactory
{
public: OggSourceSupplier();
public: ~OggSourceSupplier();
public: IDecoder* CreateDecoder();
public: void Destroy();
public: bool CanHandle(const utfchar* type) const;
};
| [
"onnerby@6a861d04-ae47-0410-a6da-2d49beace72e",
"[email protected]@6a861d04-ae47-0410-a6da-2d49beace72e"
]
| [
[
[
1,
35
],
[
37,
39
],
[
41,
44
],
[
46,
46
],
[
48,
48
]
],
[
[
36,
36
],
[
40,
40
],
[
45,
45
],
[
47,
47
]
]
]
|
2111cf185aba8177c3ba9666f9de54e63a111e9a | 823afcea9ac0705f6262ccffdff65d687822fe93 | /RayTracing/Src/Triangle.h | 9021cd656aa17955068f6cbb4b269e7d47ecfc1f | []
| no_license | shourav9884/raytracing99999 | 02b405759edf7eb5021496f87af8fa8157e972be | 19c5e3a236dc1356f6b4ec38efcc05827acb9e04 | refs/heads/master | 2016-09-10T03:30:54.820034 | 2006-10-15T21:49:19 | 2006-10-15T21:49:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 279 | h | #pragma once
#include "Object3D.h"
#include "Vector3D.h"
class Triangle : public Object3D
{
private:
Vector3D pointA;
Vector3D pointB;
Vector3D pointC;
public:
Triangle( void );
void checkIntersection( const Ray &aRay, IntersectionResult &aResult );
};
| [
"saulopessoa@34b68867-b01b-0410-ab61-0f167d00cb52"
]
| [
[
[
1,
17
]
]
]
|
28f74795c957047c9036fc6395490dcd47741d48 | 5e61787e7adba6ed1c2b5e40d38098ebdf9bdee8 | /sans/models/c_models/pearlnecklace.cpp | 5fbedb0f4bda5866f1520767eac58cda773f506d | []
| no_license | mcvine/sansmodels | 4dcba43d18c930488b0e69e8afb04139e89e7b21 | 618928810ee7ae58ec35bbb839eba2a0117c4611 | refs/heads/master | 2021-01-22T13:12:22.721492 | 2011-09-30T14:01:06 | 2011-09-30T14:01:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,488 | cpp |
#include <math.h>
#include "models.hh"
#include "parameters.hh"
#include <stdio.h>
using namespace std;
extern "C" {
#include "pearlnecklace.h"
}
PearlNecklaceModel :: PearlNecklaceModel() {
scale = Parameter(1.0);
radius = Parameter(80.0, true);
radius.set_min(0.0);
edge_separation = Parameter(350.0, true);
edge_separation.set_min(0.0);
thick_string = Parameter(2.5, true);
thick_string.set_min(0.0);
num_pearls = Parameter(3);
num_pearls.set_min(0.0);
sld_pearl = Parameter(1.0e-06);
sld_string = Parameter(1.0e-06);
sld_solv = Parameter(6.3e-06);
background = Parameter(0.0);
}
/**
* Function to evaluate 1D PearlNecklaceModel function
* @param q: q-value
* @return: function value
*/
double PearlNecklaceModel :: operator()(double q) {
double dp[9];
// Fill parameter array for IGOR library
// Add the background after averaging
dp[0] = scale();
dp[1] = radius();
dp[2] = edge_separation();
dp[3] = thick_string();
dp[4] = num_pearls();
dp[5] = sld_pearl();
dp[6] = sld_string();
dp[7] = sld_solv();
dp[8] = 0.0;
double pi = 4.0*atan(1.0);
// No polydispersion supported in this model.
// Get the dispersion points for the radius
vector<WeightPoint> weights_radius;
radius.get_weights(weights_radius);
vector<WeightPoint> weights_edge_separation;
edge_separation.get_weights(weights_edge_separation);
// Perform the computation, with all weight points
double sum = 0.0;
double norm = 0.0;
double vol = 0.0;
double string_vol = 0.0;
double pearl_vol = 0.0;
double tot_vol = 0.0;
// Loop over core weight points
for(int i=0; i<weights_radius.size(); i++) {
dp[1] = weights_radius[i].value;
// Loop over thick_inter0 weight points
for(int j=0; j<weights_edge_separation.size(); j++) {
dp[2] = weights_edge_separation[j].value;
pearl_vol = 4.0 /3.0 * pi * pow(dp[1], 3);
string_vol =dp[2] * pi * pow((dp[3] / 2.0), 2);
tot_vol = (dp[4] - 1.0) * string_vol;
tot_vol += dp[4] * pearl_vol;
//Un-normalize Sphere by volume
sum += weights_radius[i].weight * weights_edge_separation[j].weight
* pearl_necklace_kernel(dp,q) * tot_vol;
//Find average volume
vol += weights_radius[i].weight * weights_edge_separation[j].weight
* tot_vol;
norm += weights_radius[i].weight * weights_edge_separation[j].weight;
}
}
if (vol != 0.0 && norm != 0.0) {
//Re-normalize by avg volume
sum = sum/(vol/norm);}
return sum/norm + background();
}
/**
* Function to evaluate 2D PearlNecklaceModel function
* @param q_x: value of Q along x
* @param q_y: value of Q along y
* @return: function value
*/
double PearlNecklaceModel :: operator()(double qx, double qy) {
double q = sqrt(qx*qx + qy*qy);
return (*this).operator()(q);
}
/**
* Function to evaluate PearlNecklaceModel function
* @param pars: parameters of the PearlNecklaceModel
* @param q: q-value
* @param phi: angle phi
* @return: function value
*/
double PearlNecklaceModel :: evaluate_rphi(double q, double phi) {
return (*this).operator()(q);
}
/**
* Function to calculate TOTAL radius
* Todo: decide whether or not we keep this calculation
* @return: effective radius value
*/
// No polydispersion supported in this model.
// Calculate max radius assumming max_radius = effective radius
// Note that this max radius is not affected by sld of layer, sld of interface, or
// sld of solvent.
double PearlNecklaceModel :: calculate_ER() {
PeralNecklaceParameters dp;
dp.scale = scale();
dp.radius = radius();
dp.edge_separation = edge_separation();
dp.thick_string = thick_string();
dp.num_pearls = num_pearls();
double rad_out = 0.0;
// Perform the computation, with all weight points
double sum = 0.0;
double norm = 0.0;
double pi = 4.0*atan(1.0);
// No polydispersion supported in this model.
// Get the dispersion points for the radius
vector<WeightPoint> weights_radius;
radius.get_weights(weights_radius);
vector<WeightPoint> weights_edge_separation;
edge_separation.get_weights(weights_edge_separation);
// Perform the computation, with all weight points
double string_vol = 0.0;
double pearl_vol = 0.0;
double tot_vol = 0.0;
// Loop over core weight points
for(int i=0; i<weights_radius.size(); i++) {
dp.radius = weights_radius[i].value;
// Loop over thick_inter0 weight points
for(int j=0; j<weights_edge_separation.size(); j++) {
dp.edge_separation = weights_edge_separation[j].value;
pearl_vol = 4.0 /3.0 * pi * pow(dp.radius , 3);
string_vol =dp.edge_separation * pi * pow((dp.thick_string / 2.0), 2);
tot_vol = (dp.num_pearls - 1.0) * string_vol;
tot_vol += dp.num_pearls * pearl_vol;
//Find volume
// This may be a too much approximation
//Todo: decided whether or not we keep this calculation
sum += weights_radius[i].weight * weights_edge_separation[j].weight
* pow(3.0*tot_vol/4.0/pi,0.333333);
norm += weights_radius[i].weight * weights_edge_separation[j].weight;
}
}
if (norm != 0){
//return the averaged value
rad_out = sum/norm;}
else{
//return normal value
pearl_vol = 4.0 /3.0 * pi * pow(dp.radius , 3);
string_vol =dp.edge_separation * pi * pow((dp.thick_string / 2.0), 2);
tot_vol = (dp.num_pearls - 1.0) * string_vol;
tot_vol += dp.num_pearls * pearl_vol;
rad_out = pow((3.0*tot_vol/4.0/pi), 0.33333);
}
return rad_out;
}
| [
"[email protected]"
]
| [
[
[
1,
177
]
]
]
|
645e3fcc751d35107bd1f0ce84844232d902fc30 | 744e9a2bf1d0aee245c42ee145392d1f6a6f65c9 | /tags/0.11.2-alpha/avstream/ttheaderlist.cpp | e30c874dd70644b929b21f53ef4e0eb70c49d3bd | []
| no_license | BackupTheBerlios/ttcut-svn | 2b5d00c3c6d16aa118b4a58c7d0702cfcc0b051a | 958032e74e8bb144a96b6eb7e1d63bc8ae762096 | refs/heads/master | 2020-04-22T12:08:57.640316 | 2009-02-08T16:14:00 | 2009-02-08T16:14:00 | 40,747,642 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,448 | cpp | /*----------------------------------------------------------------------------*/
/* COPYRIGHT: TriTime (c) 2003/2005 / www.tritime.org */
/*----------------------------------------------------------------------------*/
/* PROJEKT : TTCUT 2005 */
/* FILE : ttheaderlist.cpp */
/*----------------------------------------------------------------------------*/
/* AUTHOR : b. altendorf (E-Mail: [email protected]) DATE: 05/12/2005 */
/* MODIFIED: b. altendorf DATE: 08/13/2005 */
/* MODIFIED: DATE: */
/*----------------------------------------------------------------------------*/
// ----------------------------------------------------------------------------
// *** TTHEADERLIST
// ----------------------------------------------------------------------------
/*----------------------------------------------------------------------------*/
/* 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, USA. */
/*----------------------------------------------------------------------------*/
#include "ttheaderlist.h"
//#define TTHEADERLIST_DEBUG
const char c_name[] = "TTHEADERLIST : ";
// construct a header list object
TTHeaderList::TTHeaderList( int size )
{
initial_size = size;
actual_size = size;
}
TTHeaderList::~TTHeaderList()
{
int i;
#if defined(TTHEADERLIST_DEBUG)
qDebug( "%sdelete header list: %d",c_name,size() );
#endif
for ( i = 0; i < size(); i++ )
{
TTAVHeader* av_header = at(i);
//qDebug("delete: %ld",at(i));
delete av_header;
}
clear();
}
// ad an header to the header list
void TTHeaderList::add( TTAVHeader* header )
{
//#if defined(TTHEADERLIST_DEBUG)
//qDebug("%sadd header: %ld",c_name,header);
//#endif
append( header );
}
// remove all items from the header list
void TTHeaderList::deleteAll()
{
int i;
for ( i = 0; i < size(); i++ )
{
TTAVHeader* av_header = at(i);
delete av_header;
}
clear();
}
void TTHeaderList::sort()
{
qSort( begin(), end() );
}
void TTHeaderList::checkIndexRange( int index )
{
//qDebug("check index: %d / %d",index,count() );
if ( index < 0 || index >= size() )
throw TTListIndexException(index);
}
| [
"tritime@7763a927-590e-0410-8f7f-dbc853b76eaa"
]
| [
[
[
1,
97
]
]
]
|
6351e86a5bf349f127c360db025bfb5443688fd0 | 15732b8e4190ae526dcf99e9ffcee5171ed9bd7e | /INC/TopoAnalysis.h | 1bdcc761d88527efc14bae65ac911023fd6ec284 | []
| no_license | clovermwliu/whutnetsim | d95c07f77330af8cefe50a04b19a2d5cca23e0ae | 924f2625898c4f00147e473a05704f7b91dac0c4 | refs/heads/master | 2021-01-10T13:10:00.678815 | 2010-04-14T08:38:01 | 2010-04-14T08:38:01 | 48,568,805 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 250 | h | #pragma once
#ifndef __CTOPOANALYSIS__H__
#define __CTOPOANALYSIS__H__
#include "PlatTopoBase.h"
class CTopoAnalysis
{
public:
CTopoAnalysis(void);
public:
~CTopoAnalysis(void);
void AnalysisDegree(CPlatTopoBase* base);
};
#endif | [
"pengelmer@f37e807c-cba8-11de-937e-2741d7931076"
]
| [
[
[
1,
15
]
]
]
|
a8d20a9a4216c1e892d83f4fed4369fb5c0e1aed | c5534a6df16a89e0ae8f53bcd49a6417e8d44409 | /trunk/Dependencies/Xerces/include/xercesc/util/regx/UnionToken.cpp | f5b36125e17d11e88ca273b7a4a4f977f8e5a826 | []
| 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 | 4,546 | cpp | /*
* 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: UnionToken.cpp 191054 2005-06-17 02:56:35Z jberry $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/util/regx/UnionToken.hpp>
#include <xercesc/framework/XMLBuffer.hpp>
#include <xercesc/util/regx/RegxUtil.hpp>
#include <xercesc/util/regx/TokenFactory.hpp>
#include <xercesc/util/regx/StringToken.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// Static member data initialization
// ---------------------------------------------------------------------------
const unsigned short UnionToken::INITIALSIZE = 8;
// ---------------------------------------------------------------------------
// UnionToken: Constructors and Destructors
// ---------------------------------------------------------------------------
UnionToken::UnionToken(const unsigned short tokType, MemoryManager* const manager)
: Token(tokType, manager)
, fChildren(0)
{
}
UnionToken::~UnionToken() {
delete fChildren;
}
// ---------------------------------------------------------------------------
// UnionToken: Children manipulation methods
// ---------------------------------------------------------------------------
void UnionToken::addChild(Token* const child, TokenFactory* const tokFactory) {
if (child == 0)
return;
if (fChildren == 0)
fChildren = new (tokFactory->getMemoryManager()) RefVectorOf<Token>(INITIALSIZE, false, tokFactory->getMemoryManager());
if (getTokenType() == T_UNION) {
fChildren->addElement(child);
return;
}
unsigned short childType = child->getTokenType();
unsigned int childSize = child->size();
if (childType == T_CONCAT) {
for (unsigned int i = 0; i < childSize; i++) {
addChild(child->getChild(i), tokFactory);
}
return;
}
unsigned int childrenSize = fChildren->size();
if (childrenSize == 0) {
fChildren->addElement(child);
return;
}
Token* previousTok = fChildren->elementAt(childrenSize - 1);
unsigned short previousType = previousTok->getTokenType();
if (!((previousType == T_CHAR || previousType == T_STRING)
&& (childType == T_CHAR || childType == T_STRING))) {
fChildren->addElement(child);
return;
}
// Continue
XMLBuffer stringBuf(1023, tokFactory->getMemoryManager());
if (previousType == T_CHAR) {
XMLInt32 ch = previousTok->getChar();
if (ch >= 0x10000) {
XMLCh* chSurrogate = RegxUtil::decomposeToSurrogates(ch, tokFactory->getMemoryManager());
stringBuf.append(chSurrogate);
tokFactory->getMemoryManager()->deallocate(chSurrogate);//delete [] chSurrogate;
}
else {
stringBuf.append((XMLCh) ch);
}
previousTok = tokFactory->createString(0);
fChildren->setElementAt(previousTok, childrenSize - 1);
}
else {
stringBuf.append(previousTok->getString());
}
if (childType == T_CHAR) {
XMLInt32 ch = child->getChar();
if (ch >= 0x10000) {
XMLCh* chSurrogate = RegxUtil::decomposeToSurrogates(ch, tokFactory->getMemoryManager());
stringBuf.append(chSurrogate);
tokFactory->getMemoryManager()->deallocate(chSurrogate);//delete [] chSurrogate;
}
else {
stringBuf.append((XMLCh) ch);
}
}
else {
stringBuf.append(child->getString());
}
((StringToken*) previousTok)->setString(stringBuf.getRawBuffer());
}
XERCES_CPP_NAMESPACE_END
/**
* End of file UnionToken.cpp
*/
| [
"Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57"
]
| [
[
[
1,
149
]
]
]
|
749a0707d8937619431e9b05eebad9140e698e0f | 0f8559dad8e89d112362f9770a4551149d4e738f | /Wall_Destruction/Havok/Source/Common/Base/Reflection/Rtti/hkCppRttiInfoUtil.h | 2d61e39b2e91434734c46781874df588f73f434e | []
| no_license | TheProjecter/olafurabertaymsc | 9360ad4c988d921e55b8cef9b8dcf1959e92d814 | 456d4d87699342c5459534a7992f04669e75d2e1 | refs/heads/master | 2021-01-10T15:15:49.289873 | 2010-09-20T12:58:48 | 2010-09-20T12:58:48 | 45,933,002 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,045 | h | /*
*
* Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's
* prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok.
* Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2009 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
*
*/
#ifndef HK_CPP_RTTI_INFO_UTIL_H
#define HK_CPP_RTTI_INFO_UTIL_H
// Abstraction to gain access in a platform independent way to C++ Rtti type info
// Use the typeid opertator to get a const hkCppRttiInfo& for a type
//
// For this to work correctly - C++ rtti must be enabled, specifically if typeid is
// going to be used on dynamic types.
// Visual studio
# if defined(_CPPRTTI)
# define HK_HAS_CPP_RTTI
# include <typeinfo.h>
typedef std::type_info hkCppTypeInfo;
# endif
// Gcc
// Make a something available -> will keep other interfaces working
#if !defined(HK_HAS_CPP_RTTI)
typedef int hkCppTypeInfo;
#define HK_GET_TYPE_ID(x) (HK_NULL)
#else
#define HK_GET_TYPE_ID(x) (&typeid(x))
#endif
struct hkCppTypeInfoHash
{
inline static unsigned hash( const hkCppTypeInfoHash& key, unsigned mod )
{
return key.m_hash & mod;
}
inline static void invalidate( hkCppTypeInfoHash& key ) { key.m_type = HK_NULL; }
inline static hkBool32 isValid( const hkCppTypeInfoHash& key ) { return key.m_type != HK_NULL; }
inline static hkBool32 equal( const hkCppTypeInfoHash& key0, const hkCppTypeInfoHash& key1 ) { return key0.m_hash == key1.m_hash && *key0.m_type == *key1.m_type; }
/// Default ctor
hkCppTypeInfoHash():
m_type(HK_NULL),
m_hash(0)
{
}
/// Ctor
hkCppTypeInfoHash(const hkCppTypeInfo& info);
const hkCppTypeInfo* m_type;
unsigned m_hash;
};
class hkCppRttiInfoUtil
{
public:
static const char* HK_CALL getName(const hkCppTypeInfo& info);
static const char* HK_CALL getRawName(const hkCppTypeInfo& info);
/// Returns the type of a virtual object. Only works if dynamic rtti information is switched on the build
/// If cannot determine the type will return HK_NULL
static const hkCppTypeInfo* HK_CALL getVirtualClassType(void* ptr);
};
#endif // HK_CPP_RTTI_INFO_UTIL_H
/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20091222)
*
* Confidential Information of Havok. (C) Copyright 1999-2009
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates
* acceptance of the End User licence Agreement for this product. A copy of
* the license is included with this software and is also available at www.havok.com/tryhavok.
*
*/
| [
"[email protected]"
]
| [
[
[
1,
83
]
]
]
|
3e291f42425284d9ef4648f547ace8489eec9da9 | ea2786bfb29ab1522074aa865524600f719b5d60 | /MultimodalSpaceShooter/src/core/AudioEngine.h | 06ee604efc9b7de7a10a124febd22542a2a37cb9 | []
| no_license | jeremysingy/multimodal-space-shooter | 90ffda254246d0e3a1e25558aae5a15fed39137f | ca6e28944cdda97285a2caf90e635a73c9e4e5cd | refs/heads/master | 2021-01-19T08:52:52.393679 | 2011-04-12T08:37:03 | 2011-04-12T08:37:03 | 1,467,691 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 626 | h | #ifndef AUDIOENGINE_H
#define AUDIOENGINE_H
#include <vector>
#include <string>
#include <SFML/Audio.hpp>
//////////////////////////////////////////////////
/// Manage sound playing in the game
//////////////////////////////////////////////////
class AudioEngine
{
public:
void playSound(const std::string& name, float volume = 100.f);
private:
AudioEngine();
~AudioEngine();
std::vector<sf::Sound> mySounds;
unsigned int myNextSoundId;
static const int MAX_SOUNDS = 64;
friend class Game;
};
#endif // AUDIOENGINE_H | [
"[email protected]"
]
| [
[
[
1,
29
]
]
]
|
450cf54453ea765490f9fe75e107199889dea4b1 | b14d5833a79518a40d302e5eb40ed5da193cf1b2 | /cpp/extern/xercesc++/2.6.0/src/xercesc/internal/XTemplateComparator.cpp | 237bd8f6bf5aa3ee17da81683ccd9fd63151f4c1 | [
"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 | 27,550 | cpp | /*
* Copyright 2003,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: XTemplateComparator.cpp,v $
* Revision 1.4 2004/09/08 13:56:14 peiyongz
* Apache License Version 2.0
*
* Revision 1.3 2003/12/19 23:02:43 cargilld
* Fix compiler messages on OS390.
*
* Revision 1.2 2003/12/17 00:18:34 cargilld
* Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
*
* Revision 1.1 2003/10/29 16:14:15 peiyongz
* XObjectComparator/XTemplateComparator
*
* $Id: XTemplateComparator.cpp,v 1.4 2004/09/08 13:56:14 peiyongz Exp $
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/internal/XTemplateComparator.hpp>
#include <xercesc/internal/XObjectComparator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
/**********************************************************
*
* ValueVectorOf
*
* SchemaElementDecl*
* unsigned int
*
***********************************************************/
bool XTemplateComparator::isEquivalent(ValueVectorOf<SchemaElementDecl*>* const lValue
, ValueVectorOf<SchemaElementDecl*>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
int size1 = lValue->size();
int size2 = rValue->size();
if (size1 != size2)
return false;
for ( int i = 0; i < size1; i++)
{
SchemaElementDecl*& data1 = lValue->elementAt(i);
SchemaElementDecl*& data2 = rValue->elementAt(i);
if (!XObjectComparator::isEquivalent(data1, data2))
return false;
}
return true;
}
bool XTemplateComparator::isEquivalent(ValueVectorOf<unsigned int>* const lValue
, ValueVectorOf<unsigned int>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
int size1 = lValue->size();
int size2 = rValue->size();
if (size1 != size2)
return false;
for ( int i = 0; i < size1; i++)
{
unsigned int& data1 = lValue->elementAt(i);
unsigned int& data2 = rValue->elementAt(i);
if (data1!=data2)
return false;
}
return true;
}
/**********************************************************
*
* RefArrayVectorOf
*
* XMLCh
*
***********************************************************/
bool XTemplateComparator::isEquivalent(RefArrayVectorOf<XMLCh>* const lValue
, RefArrayVectorOf<XMLCh>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
int size1 = lValue->size();
int size2 = rValue->size();
if (size1 != size2)
return false;
for ( int i = 0; i < size1; i++)
{
XMLCh* data1 = lValue->elementAt(i);
XMLCh* data2 = rValue->elementAt(i);
if (!XMLString::equals(data1, data2))
{
return false;
}
}
return true;
}
/**********************************************************
*
* RefVectorOf
*
* SchemaAttDef
* SchemaElementDecl
* ContentSpecNode
* IC_Field
* DatatypeValidator
* IdentityConstraint
* XMLNumber
* XercesLocationPath
* XercesStep
*
***********************************************************/
bool XTemplateComparator::isEquivalent(RefVectorOf<SchemaAttDef>* const lValue
, RefVectorOf<SchemaAttDef>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
int size1 = lValue->size();
int size2 = rValue->size();
if (size1 != size2)
return false;
for ( int i = 0; i < size1; i++)
{
SchemaAttDef* data1 = lValue->elementAt(i);
SchemaAttDef* data2 = rValue->elementAt(i);
if (!XObjectComparator::isEquivalent(data1, data2))
return false;
}
return true;
}
bool XTemplateComparator::isEquivalent(RefVectorOf<SchemaElementDecl>* const lValue
, RefVectorOf<SchemaElementDecl>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
int size1 = lValue->size();
int size2 = rValue->size();
if (size1 != size2)
return false;
for ( int i = 0; i < size1; i++)
{
SchemaElementDecl* data1 = lValue->elementAt(i);
SchemaElementDecl* data2 = rValue->elementAt(i);
if (!XObjectComparator::isEquivalent(data1, data2))
return false;
}
return true;
}
bool XTemplateComparator::isEquivalent(RefVectorOf<ContentSpecNode>* const lValue
, RefVectorOf<ContentSpecNode>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
int size1 = lValue->size();
int size2 = rValue->size();
if (size1 != size2)
return false;
for ( int i = 0; i < size1; i++)
{
ContentSpecNode* data1 = lValue->elementAt(i);
ContentSpecNode* data2 = rValue->elementAt(i);
if (!XObjectComparator::isEquivalent(data1, data2))
return false;
}
return true;
}
bool XTemplateComparator::isEquivalent(RefVectorOf<IC_Field>* const lValue
, RefVectorOf<IC_Field>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
int size1 = lValue->size();
int size2 = rValue->size();
if (size1 != size2)
return false;
for ( int i = 0; i < size1; i++)
{
IC_Field* data1 = lValue->elementAt(i);
IC_Field* data2 = rValue->elementAt(i);
if (!XObjectComparator::isEquivalent(data1, data2))
return false;
}
return true;
}
bool XTemplateComparator::isEquivalent(RefVectorOf<DatatypeValidator>* const lValue
, RefVectorOf<DatatypeValidator>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
int size1 = lValue->size();
int size2 = rValue->size();
if (size1 != size2)
return false;
for ( int i = 0; i < size1; i++)
{
DatatypeValidator* data1 = lValue->elementAt(i);
DatatypeValidator* data2 = rValue->elementAt(i);
if (!XObjectComparator::isEquivalent(data1, data2))
return false;
}
return true;
}
bool XTemplateComparator::isEquivalent(RefVectorOf<IdentityConstraint>* const lValue
, RefVectorOf<IdentityConstraint>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
int size1 = lValue->size();
int size2 = rValue->size();
if (size1 != size2)
return false;
for ( int i = 0; i < size1; i++)
{
IdentityConstraint* data1 = lValue->elementAt(i);
IdentityConstraint* data2 = rValue->elementAt(i);
if (!XObjectComparator::isEquivalent(data1, data2))
return false;
}
return true;
}
bool XTemplateComparator::isEquivalent(RefVectorOf<XMLNumber>* const lValue
, RefVectorOf<XMLNumber>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
int size1 = lValue->size();
int size2 = rValue->size();
if (size1 != size2)
return false;
for ( int i = 0; i < size1; i++)
{
XMLNumber* data1 = lValue->elementAt(i);
XMLNumber* data2 = rValue->elementAt(i);
if (!XObjectComparator::isEquivalent(data1, data2))
return false;
}
return true;
}
bool XTemplateComparator::isEquivalent(RefVectorOf<XercesLocationPath>* const lValue
, RefVectorOf<XercesLocationPath>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
int size1 = lValue->size();
int size2 = rValue->size();
if (size1 != size2)
return false;
for ( int i = 0; i < size1; i++)
{
XercesLocationPath* data1 = lValue->elementAt(i);
XercesLocationPath* data2 = rValue->elementAt(i);
if (!XObjectComparator::isEquivalent(data1, data2))
return false;
}
return true;
}
bool XTemplateComparator::isEquivalent(RefVectorOf<XercesStep>* const lValue
, RefVectorOf<XercesStep>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
int size1 = lValue->size();
int size2 = rValue->size();
if (size1 != size2)
return false;
for ( int i = 0; i < size1; i++)
{
XercesStep* data1 = lValue->elementAt(i);
XercesStep* data2 = rValue->elementAt(i);
if (!XObjectComparator::isEquivalent(data1, data2))
return false;
}
return true;
}
/**********************************************************
*
* RefHashTableOf
*
* KVStringPair
* XMLAttDef
* DTDAttDef
* ComplexTypeInfo
* XercesGroupInfo
* XercesAttGroupInfo
* XMLRefInfo
* DatatypeValidator
* Grammar
*
***********************************************************/
bool XTemplateComparator::isEquivalent(RefHashTableOf<KVStringPair>* const lValue
, RefHashTableOf<KVStringPair>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
RefHashTableOfEnumerator<KVStringPair> lEnum(lValue, false, lValue->getMemoryManager());
int lItemNumber = 0;
while (lEnum.hasMoreElements())
{
lEnum.nextElement();
lItemNumber++;
}
RefHashTableOfEnumerator<KVStringPair> rEnum(rValue, false, rValue->getMemoryManager());
int rItemNumber = 0;
while (rEnum.hasMoreElements())
{
rEnum.nextElement();
rItemNumber++;
}
//both shall have the number of item in it
if (lItemNumber != rItemNumber)
return false;
//Any thing in the lValue shall be found in the rValue
lEnum.Reset();
while (lEnum.hasMoreElements())
{
XMLCh* key = (XMLCh*) lEnum.nextElementKey();
KVStringPair* data1 = lValue->get(key);
KVStringPair* data2 = rValue->get(key);
if (!XObjectComparator::isEquivalent(data1, data2))
return false;
}
return true;
}
bool XTemplateComparator::isEquivalent(RefHashTableOf<XMLAttDef>* const lValue
, RefHashTableOf<XMLAttDef>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
RefHashTableOfEnumerator<XMLAttDef> lEnum(lValue, false, lValue->getMemoryManager());
int lItemNumber = 0;
while (lEnum.hasMoreElements())
{
lEnum.nextElement();
lItemNumber++;
}
RefHashTableOfEnumerator<XMLAttDef> rEnum(rValue, false, rValue->getMemoryManager());
int rItemNumber = 0;
while (rEnum.hasMoreElements())
{
rEnum.nextElement();
rItemNumber++;
}
//both shall have the number of item in it
if (lItemNumber != rItemNumber)
return false;
//Any thing in the lValue shall be found in the rValue
lEnum.Reset();
while (lEnum.hasMoreElements())
{
XMLCh* key = (XMLCh*) lEnum.nextElementKey();
//we know they are SchemaAttDef
SchemaAttDef* data1 = (SchemaAttDef*) lValue->get(key);
SchemaAttDef* data2 = (SchemaAttDef*) rValue->get(key);
if (!XObjectComparator::isEquivalent(data1, data2))
return false;
}
return true;
}
bool XTemplateComparator::isEquivalent(RefHashTableOf<DTDAttDef>* const lValue
, RefHashTableOf<DTDAttDef>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
RefHashTableOfEnumerator<DTDAttDef> lEnum(lValue, false, lValue->getMemoryManager());
int lItemNumber = 0;
while (lEnum.hasMoreElements())
{
lEnum.nextElement();
lItemNumber++;
}
RefHashTableOfEnumerator<DTDAttDef> rEnum(rValue, false, rValue->getMemoryManager());
int rItemNumber = 0;
while (rEnum.hasMoreElements())
{
rEnum.nextElement();
rItemNumber++;
}
//both shall have the number of item in it
if (lItemNumber != rItemNumber)
return false;
//Any thing in the lValue shall be found in the rValue
lEnum.Reset();
while (lEnum.hasMoreElements())
{
XMLCh* key = (XMLCh*) lEnum.nextElementKey();
DTDAttDef* data1 = (DTDAttDef*) lValue->get(key);
DTDAttDef* data2 = (DTDAttDef*) rValue->get(key);
if (!XObjectComparator::isEquivalent(data1, data2))
return false;
}
return true;
}
bool XTemplateComparator::isEquivalent(RefHashTableOf<ComplexTypeInfo>* const lValue
, RefHashTableOf<ComplexTypeInfo>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
RefHashTableOfEnumerator<ComplexTypeInfo> lEnum(lValue, false, lValue->getMemoryManager());
int lItemNumber = 0;
while (lEnum.hasMoreElements())
{
lEnum.nextElement();
lItemNumber++;
}
RefHashTableOfEnumerator<ComplexTypeInfo> rEnum(rValue, false, rValue->getMemoryManager());
int rItemNumber = 0;
while (rEnum.hasMoreElements())
{
rEnum.nextElement();
rItemNumber++;
}
//both shall have the number of item in it
if (lItemNumber != rItemNumber)
return false;
//Any thing in the lValue shall be found in the rValue
lEnum.Reset();
while (lEnum.hasMoreElements())
{
XMLCh* key = (XMLCh*) lEnum.nextElementKey();
ComplexTypeInfo* data1 = (ComplexTypeInfo*) lValue->get(key);
ComplexTypeInfo* data2 = (ComplexTypeInfo*) rValue->get(key);
if (!XObjectComparator::isEquivalent(data1, data2))
return false;
}
return true;
}
bool XTemplateComparator::isEquivalent(RefHashTableOf<XercesGroupInfo>* const lValue
, RefHashTableOf<XercesGroupInfo>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
RefHashTableOfEnumerator<XercesGroupInfo> lEnum(lValue, false, lValue->getMemoryManager());
int lItemNumber = 0;
while (lEnum.hasMoreElements())
{
lEnum.nextElement();
lItemNumber++;
}
RefHashTableOfEnumerator<XercesGroupInfo> rEnum(rValue, false, rValue->getMemoryManager());
int rItemNumber = 0;
while (rEnum.hasMoreElements())
{
rEnum.nextElement();
rItemNumber++;
}
//both shall have the number of item in it
if (lItemNumber != rItemNumber)
return false;
//Any thing in the lValue shall be found in the rValue
lEnum.Reset();
while (lEnum.hasMoreElements())
{
XMLCh* key = (XMLCh*) lEnum.nextElementKey();
XercesGroupInfo* data1 = (XercesGroupInfo*) lValue->get(key);
XercesGroupInfo* data2 = (XercesGroupInfo*) rValue->get(key);
if (!XObjectComparator::isEquivalent(data1, data2))
return false;
}
return true;
}
bool XTemplateComparator::isEquivalent(RefHashTableOf<XercesAttGroupInfo>* const lValue
, RefHashTableOf<XercesAttGroupInfo>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
RefHashTableOfEnumerator<XercesAttGroupInfo> lEnum(lValue, false, lValue->getMemoryManager());
int lItemNumber = 0;
while (lEnum.hasMoreElements())
{
lEnum.nextElement();
lItemNumber++;
}
RefHashTableOfEnumerator<XercesAttGroupInfo> rEnum(rValue, false, rValue->getMemoryManager());
int rItemNumber = 0;
while (rEnum.hasMoreElements())
{
rEnum.nextElement();
rItemNumber++;
}
//both shall have the number of item in it
if (lItemNumber != rItemNumber)
return false;
//Any thing in the lValue shall be found in the rValue
lEnum.Reset();
while (lEnum.hasMoreElements())
{
XMLCh* key = (XMLCh*) lEnum.nextElementKey();
XercesAttGroupInfo* data1 = (XercesAttGroupInfo*) lValue->get(key);
XercesAttGroupInfo* data2 = (XercesAttGroupInfo*) rValue->get(key);
if (!XObjectComparator::isEquivalent(data1, data2))
return false;
}
return true;
}
bool XTemplateComparator::isEquivalent(RefHashTableOf<XMLRefInfo>* const lValue
, RefHashTableOf<XMLRefInfo>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
RefHashTableOfEnumerator<XMLRefInfo> lEnum(lValue, false, lValue->getMemoryManager());
int lItemNumber = 0;
while (lEnum.hasMoreElements())
{
lEnum.nextElement();
lItemNumber++;
}
RefHashTableOfEnumerator<XMLRefInfo> rEnum(rValue, false, rValue->getMemoryManager());
int rItemNumber = 0;
while (rEnum.hasMoreElements())
{
rEnum.nextElement();
rItemNumber++;
}
//both shall have the number of item in it
if (lItemNumber != rItemNumber)
return false;
//Any thing in the lValue shall be found in the rValue
lEnum.Reset();
while (lEnum.hasMoreElements())
{
XMLCh* key = (XMLCh*) lEnum.nextElementKey();
XMLRefInfo* data1 = (XMLRefInfo*) lValue->get(key);
XMLRefInfo* data2 = (XMLRefInfo*) rValue->get(key);
if (!XObjectComparator::isEquivalent(data1, data2))
return false;
}
return true;
}
bool XTemplateComparator::isEquivalent(RefHashTableOf<DatatypeValidator>* const lValue
, RefHashTableOf<DatatypeValidator>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
RefHashTableOfEnumerator<DatatypeValidator> lEnum(lValue, false, lValue->getMemoryManager());
int lItemNumber = 0;
while (lEnum.hasMoreElements())
{
lEnum.nextElement();
lItemNumber++;
}
RefHashTableOfEnumerator<DatatypeValidator> rEnum(rValue, false, rValue->getMemoryManager());
int rItemNumber = 0;
while (rEnum.hasMoreElements())
{
rEnum.nextElement();
rItemNumber++;
}
//both shall have the number of item in it
if (lItemNumber != rItemNumber)
return false;
//Any thing in the lValue shall be found in the rValue
lEnum.Reset();
while (lEnum.hasMoreElements())
{
XMLCh* key = (XMLCh*) lEnum.nextElementKey();
DatatypeValidator* data1 = (DatatypeValidator*) lValue->get(key);
DatatypeValidator* data2 = (DatatypeValidator*) rValue->get(key);
if (!XObjectComparator::isEquivalent(data1, data2))
return false;
}
return true;
}
bool XTemplateComparator::isEquivalent(RefHashTableOf<Grammar>* const lValue
, RefHashTableOf<Grammar>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
RefHashTableOfEnumerator<Grammar> lEnum(lValue, false, lValue->getMemoryManager());
int lItemNumber = 0;
while (lEnum.hasMoreElements())
{
lEnum.nextElement();
lItemNumber++;
}
RefHashTableOfEnumerator<Grammar> rEnum(rValue, false, rValue->getMemoryManager());
int rItemNumber = 0;
while (rEnum.hasMoreElements())
{
rEnum.nextElement();
rItemNumber++;
}
//both shall have the number of item in it
if (lItemNumber != rItemNumber)
return false;
//Any thing in the lValue shall be found in the rValue
lEnum.Reset();
while (lEnum.hasMoreElements())
{
XMLCh* key = (XMLCh*) lEnum.nextElementKey();
Grammar* data1 = (Grammar*) lValue->get(key);
Grammar* data2 = (Grammar*) rValue->get(key);
if (!XObjectComparator::isEquivalent(data1, data2))
return false;
}
return true;
}
/**********************************************************
*
* RefHash2KeysTableOf
*
* SchemaAttDef
* ElemVector
*
***********************************************************/
bool XTemplateComparator::isEquivalent(RefHash2KeysTableOf<SchemaAttDef>* const lValue
, RefHash2KeysTableOf<SchemaAttDef>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
RefHash2KeysTableOfEnumerator<SchemaAttDef> lEnum(lValue, false, lValue->getMemoryManager());
int lItemNumber = 0;
while (lEnum.hasMoreElements())
{
lEnum.nextElement();
lItemNumber++;
}
RefHash2KeysTableOfEnumerator<SchemaAttDef> rEnum(rValue, false, rValue->getMemoryManager());
int rItemNumber = 0;
while (rEnum.hasMoreElements())
{
rEnum.nextElement();
rItemNumber++;
}
//both shall have the number of item in it
if (lItemNumber != rItemNumber)
return false;
//Any thing in the lValue shall be found in the rValue
lEnum.Reset();
while (lEnum.hasMoreElements())
{
XMLCh* key1;
int key2;
lEnum.nextElementKey((void*&)key1, key2);
SchemaAttDef* data1 = (SchemaAttDef*) lValue->get(key1, key2);
SchemaAttDef* data2 = (SchemaAttDef*) rValue->get(key1, key2);
if (!XObjectComparator::isEquivalent(data1, data2))
return false;
}
return true;
}
bool XTemplateComparator::isEquivalent(RefHash2KeysTableOf<ElemVector>* const lValue
, RefHash2KeysTableOf<ElemVector>* const rValue)
{
IS_EQUIVALENT(lValue, rValue);
RefHash2KeysTableOfEnumerator<ElemVector> lEnum(lValue, false, lValue->getMemoryManager());
int lItemNumber = 0;
while (lEnum.hasMoreElements())
{
lEnum.nextElement();
lItemNumber++;
}
RefHash2KeysTableOfEnumerator<ElemVector> rEnum(rValue, false, rValue->getMemoryManager());
int rItemNumber = 0;
while (rEnum.hasMoreElements())
{
rEnum.nextElement();
rItemNumber++;
}
//both shall have the number of item in it
if (lItemNumber != rItemNumber)
return false;
//Any thing in the lValue shall be found in the rValue
lEnum.Reset();
while (lEnum.hasMoreElements())
{
XMLCh* key1;
int key2;
lEnum.nextElementKey((void*&)key1, key2);
ElemVector* data1 = (ElemVector*) lValue->get(key1, key2);
ElemVector* data2 = (ElemVector*) rValue->get(key1, key2);
if (!isEquivalent(data1, data2))
return false;
}
return true;
}
/**********************************************************
*
* RefHash3KeysIdPool
*
* SchemaElementDecl
*
***********************************************************/
bool XTemplateComparator::isEquivalent(RefHash3KeysIdPool<SchemaElementDecl>* const lValue
, RefHash3KeysIdPool<SchemaElementDecl>* const rValue)
{
IS_EQUIVALENT(lValue, rValue)
RefHash3KeysIdPoolEnumerator<SchemaElementDecl> lEnum(lValue, false, lValue->getMemoryManager());
RefHash3KeysIdPoolEnumerator<SchemaElementDecl> rEnum(rValue, false, rValue->getMemoryManager());
if (lEnum.size() != rEnum.size())
return false;
for (int i = 0; i < lEnum.size(); i++)
{
SchemaElementDecl& lData = lEnum.nextElement();
SchemaElementDecl& rData = rEnum.nextElement();
if (!XObjectComparator::isEquivalent(&lData, &rData))
return false;
}
return true;
}
/**********************************************************
*
* NameIdPool
*
* DTDElementDecl
* DTDEntityDecl
* XMLNotationDecl
*
***********************************************************/
bool XTemplateComparator::isEquivalent(NameIdPool<DTDElementDecl>* const lValue
, NameIdPool<DTDElementDecl>* const rValue)
{
IS_EQUIVALENT(lValue, rValue)
NameIdPoolEnumerator<DTDElementDecl> lEnum(lValue, lValue->getMemoryManager());
NameIdPoolEnumerator<DTDElementDecl> rEnum(rValue, rValue->getMemoryManager());
if (lEnum.size() != rEnum.size())
return false;
for (int i = 0; i < lEnum.size(); i++)
{
DTDElementDecl& lData = lEnum.nextElement();
DTDElementDecl& rData = rEnum.nextElement();
if (!XObjectComparator::isEquivalent(&lData, &rData))
return false;
}
return true;
}
bool XTemplateComparator::isEquivalent(NameIdPool<DTDEntityDecl>* const lValue
, NameIdPool<DTDEntityDecl>* const rValue)
{
IS_EQUIVALENT(lValue, rValue)
NameIdPoolEnumerator<DTDEntityDecl> lEnum(lValue, lValue->getMemoryManager());
NameIdPoolEnumerator<DTDEntityDecl> rEnum(rValue, rValue->getMemoryManager());
if (lEnum.size() != rEnum.size())
return false;
for (int i = 0; i < lEnum.size(); i++)
{
DTDEntityDecl& lData = lEnum.nextElement();
DTDEntityDecl& rData = rEnum.nextElement();
if (!XObjectComparator::isEquivalent(&lData, &rData))
return false;
}
return true;
}
bool XTemplateComparator::isEquivalent(NameIdPool<XMLNotationDecl>* const lValue
, NameIdPool<XMLNotationDecl>* const rValue)
{
IS_EQUIVALENT(lValue, rValue)
NameIdPoolEnumerator<XMLNotationDecl> lEnum(lValue, lValue->getMemoryManager());
NameIdPoolEnumerator<XMLNotationDecl> rEnum(rValue, rValue->getMemoryManager());
if (lEnum.size() != rEnum.size())
return false;
for (int i = 0; i < lEnum.size(); i++)
{
XMLNotationDecl& lData = lEnum.nextElement();
XMLNotationDecl& rData = rEnum.nextElement();
if (!XObjectComparator::isEquivalent(&lData, &rData))
return false;
}
return true;
}
XERCES_CPP_NAMESPACE_END
| [
"[email protected]"
]
| [
[
[
1,
957
]
]
]
|
2f0e5e732cdad0bb0f68658c3cef115dc7cc1626 | 718dc2ad71e8b39471b5bf0c6d60cbe5f5c183e1 | /soft micros/Codigo/Librerias/OOC/lang/lib_project/src/CharPointer.cpp | f531353da3484bc02ddd6207a726635e3980c514 | []
| no_license | jonyMarino/microsdhacel | affb7a6b0ea1f4fd96d79a04d1a3ec3eaa917bca | 66d03c6a9d3a2d22b4d7104e2a38a2c9bb4061d3 | refs/heads/master | 2020-05-18T19:53:51.301695 | 2011-05-30T20:40:24 | 2011-05-30T20:40:24 | 34,532,512 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 754 | cpp | #include <stdio.h>
#include <stdlib.h>
#include "CharPointer.hpp"
#include "Math.hpp"
void CharPointer::printFloat(char * str,int integer,byte decimalPosition){
if(decimalPosition){
int a;
a=sprintf(str,"%d.",integer/ Math::pow10(decimalPosition));
str+=a;
sprintf(str,"%0*d",decimalPosition,abs(integer)% Math::pow10(decimalPosition));
}else
sprintf(str,"%d",integer);
}
void CharPointer::printFloatLeft(char * str,int size,int integer,byte decimalPosition){
if(decimalPosition){
int a;
a=sprintf(str,"%i.",integer/ Math::pow10(decimalPosition));
str+=a;
sprintf(str,"%0*i",decimalPosition,abs(integer)% Math::pow10(decimalPosition));
}else
sprintf(str,"%4i",integer);
}
| [
"jonymarino@9fc3b3b2-dce3-11dd-9b7c-b771bf68b549"
]
| [
[
[
1,
25
]
]
]
|
d48db9d2795fae44a9f879991847cedfd69622be | db3bc5e0550abf83819e70e1bc4f554e97da0b41 | /Scene.cpp | 12c99c81a2ecf8660a515442e60fab18bd53bf57 | []
| no_license | jiwonkim/Basic-Ray-Tracer | 019ee02ad59eab8366ece4f552cff8aeed53fcbc | eea6df78c8a6049a264b8af4679c4df84469dc82 | refs/heads/master | 2021-01-15T11:18:30.921793 | 2011-12-30T01:27:15 | 2011-12-30T01:27:15 | 3,072,017 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,833 | cpp | #include "Scene.h"
#include "Triangle.h"
#include "Sphere.h"
#include <fstream>
#include <sstream>
#include <stdlib.h>
#include <time.h>
#define NUM_JITTER 3
Scene::Scene(std::string sceneFilename)
{
srand(time(NULL));
Parse(sceneFilename);
}
/*
* function Render
* ---------------
* Renders the image to an image file described in the file parsed
*/
void Scene::Render() {
// Iterates through each pixel in image, shoots ray through it
for(int y = height-1; y >= 0; y--) {
for(int x = 0; x < width; x++) {
STColor3f sum = STColor3f(0,0,0);
float jitter = 1./(NUM_JITTER+1);
for(int i = 1; i <= NUM_JITTER; i++) {
for(int j = 1; j <= NUM_JITTER; j++) {
float jx = i*jitter;
float jy = j*jitter;
// Create ray through center of pixel (x,y)
STVector3 point;
if(!imageplane.getPointOnImagePlane(x+jx,y+jy,point)) continue;
Ray ray = Ray(camera, point);
// Find the closest intersection of ray and object
Intersection *hit = FindIntersection(ray);
// If ray hit any object, find the color at the pixel (x,y) by
// getting the color of the intersection and recursing through
// all refelctive rays.
if(hit!=NULL && hit->getTValue()>1) {
STColor3f color = FindColorAt(hit);
sum += RecursivelyRayTrace(hit,color,1);
}
}
}
sum /= (float)(NUM_JITTER*NUM_JITTER);
imageplane.setPixel(x,y,sum);
//debug: show progress
if(x%5==0 && y%10==0){
//double val = sqrt(sum.r*sum.r+sum.g*sum.g+sum.b*sum.b);
double val =0.3*sum.r + 0.59*sum.g + 0.11*sum.b;
if(val<0.1){
printf(" ");
} else if(val<0.4){
printf(".");
} else if (val < 0.6){
printf("*");
} else if (val < 0.8){
printf("#");
} else {
printf("@");
}
fflush(stdout);
}
}
if(y%10==0){
printf("\n");
}
}
printf("Iterated over all pixels\n");
int num_ambient_lights = ambient_lights.size();
for(int i=0; i<num_ambient_lights; i++) {
delete ambient_lights[i];
}
int num_lights = lights.size();
for(int i=0; i<num_lights; i++) {
delete lights[i];
}
delete environment_light;
printf("Freed memory\n");
imageplane.writeToFile(); // Generate resulting image file
}
Intersection *Scene::FindIntersection(Ray ray) {
// Total number of objects in scene
int num_objects = objects.size();
// True when the ray hasn't hit any object yet
bool flag = true;
// t value where the ray intersects the closest object to source point
float min_t;
// index of the closest object hit by ray
int object_index;
// Untransformed version of the ray that hit above object - differs from object to object
Ray untransformed_ray;
// Iterate through each object, try intersecting it with ray
for(int i=0; i<num_objects; i++) {
Ray r = objects[i].getUntransformedRay(ray);
float t = objects[i].intersects(r);
if(t>0 && (flag || t<min_t)) {
min_t = t;
flag = false;
object_index = i;
untransformed_ray = r;
}
}
// If no object has hit, return NULL
if(flag) return NULL;
// Get transformation matrix and its inverse in order to get true point and normal
STTransform4 transform = objects[object_index].getTransform();
STTransform4 inverse_transform = objects[object_index].getInverseTransform();
// Given the info we have of the untransformed point, create the actual point in scene
STVector3 untransformed_point = untransformed_ray.getPointAt(min_t);
STVector3 point = STVector3(transform*STPoint3(untransformed_point));
// Given the normal generated with the untransformed ray and object, get the actual normal
STVector3 untransformed_normal = objects[object_index].getNormalAt(untransformed_point,untransformed_ray.getDirection());
STVector3 normal = STVector3(inverse_transform.Transpose()*STPoint3(untransformed_normal));
// Return an Intersection object created with actual point, normal, ray direction, and object
return new Intersection(min_t,point,normal,ray.getDirection(),&objects[object_index]);
}
/*
* Find if the given intersection is shadowed by shooting rays to each light source
*/
void Scene::FindReachableLights(Intersection *hit,std::vector<Light *> &reachable) {
STVector3 point = hit->getIntersectionPoint();
STVector3 normal = hit->getObject()->getNormalAt(point,camera.getEye()-point);
// Loop over each light and shoot a ray to the light
int num_lights = lights.size();
for(int i=0; i<num_lights; i++) {
STVector3 lightSource = lights[i]->getLocation(point);
STVector3 direction = lightSource - point;
Ray ray = Ray(point+shadow_bias*direction,lightSource);
Intersection *obstacle = FindIntersection(ray);
if(obstacle==NULL) reachable.push_back(lights[i]);
if(obstacle!=NULL) {
float t = obstacle->getTValue();
if(t<=0 || t>=1) reachable.push_back(lights[i]);
}
}
}
STColor3f Scene::RecursivelyRayTrace(Intersection *hit, STColor3f &color, int bounce) {
if(bounce>bounce_depth) return color;
// mirror reflectance of material - if less than epsilon, return curr color
STColor3f mirror = (hit->getObject())->getMirrorReflectance();
if(mirror.r*mirror.g*mirror.b < 0.0001) return color;
// source point of ray
STVector3 source = hit->getIntersectionPoint();
// calculates reflection vector using normal and direction of previous ray
STVector3 normal = hit->getNormal();
normal /= normal.Length();
STVector3 prev_dir = hit->getDirection();
prev_dir /= prev_dir.Length();
STVector3 next_dir = prev_dir-2*STVector3::Dot(prev_dir,normal)*normal;
next_dir /= next_dir.Length();
// generates new ray from new source
Ray ray = Ray(source+next_dir*shadow_bias, source+next_dir);
Intersection *next_hit = FindIntersection(ray);
// if ray did not hit anything, return current color - nothing to reflect
if(next_hit==NULL) return color;
// evaluate mirror reflectance and update
color += mirror*FindColorAt(next_hit);
return RecursivelyRayTrace(next_hit,color,bounce+1);
}
STColor3f Scene::FindColorAt(Intersection *hit) {
STVector3 normal = hit->getNormal();
STVector3 point = hit->getIntersectionPoint();
STVector3 view = camera.getEye() - point;
SceneObject *object = hit->getObject();
std::vector<Light *> reachable_lights;
FindReachableLights(hit,reachable_lights);
// Pass in all ambient lights and environment lights for computing color because
// they are always reachable, but pass in only reachable lights for point/directional
// lights because they can generate shadows
return object->getColor(ambient_lights,reachable_lights,environment_light,normal,view,point);
}
void Scene::Parse(std::string sceneFilename)
{
BeganParsing();
std::ifstream sceneFile(sceneFilename.c_str());
char line[1024];
while (!sceneFile.eof())
{
sceneFile.getline(line, 1023);
std::stringstream ss;
ss.str(line);
std::string command;
ss >> command;
if (command == "Fisheye") {
imageplane.setFisheye();
}
else if (command == "Cylinderx") {
imageplane.setCylinder(true);
}
else if (command == "Cylindery") {
imageplane.setCylinder(false);
}
else if (command == "Camera")
{
float ex, ey, ez, ux, uy, uz, lx, ly, lz, f, a;
ss >> ex >> ey >> ez >> ux >> uy >> uz >> lx >> ly >> lz >> f >> a;
STPoint3 eye(ex, ey, ez);
STVector3 up(ux, uy, uz);
STPoint3 lookAt(lx, ly, lz);
ParsedCamera(eye, up, lookAt, f, a);
}
else
if (command == "Output")
{
int w, h;
std::string fname;
ss >> w >> h >> fname;
ParsedOutput(w, h, fname);
}
else
if (command == "BounceDepth")
{
int depth;
ss >> depth;
ParsedBounceDepth(depth);
}
else if (command == "ShadowBias")
{
float bias;
ss >> bias;
ParsedShadowBias(bias);
}
else
if (command == "PushMatrix")
{
ParsedPushMatrix();
}
else
if (command == "PopMatrix")
{
ParsedPopMatrix();
}
else
if (command == "Rotate")
{
float rx, ry, rz;
ss >> rx >> ry >> rz;
ParsedRotate(rx, ry, rz);
}
else
if (command == "Scale")
{
float sx, sy, sz;
ss >> sx >> sy >> sz;
ParsedScale(sx, sy, sz);
}
else
if (command == "Translate")
{
float tx, ty, tz;
ss >> tx >> ty >> tz;
ParsedTranslate(tx, ty, tz);
}
else
if (command == "Sphere")
{
float cx, cy, cz, r;
ss >> cx >> cy >> cz >> r;
STPoint3 center(cx, cy, cz);
ParsedSphere(center, r);
}
else
if (command == "Triangle")
{
float x1, y1, z1, x2, y2, z2, x3, y3, z3;
ss >> x1 >> y1 >> z1 >> x2 >> y2 >> z2 >> x3 >> y3 >> z3;
STPoint3 v[3];
v[0] = STPoint3(x1, y1, z1);
v[1] = STPoint3(x2, y2, z2);
v[2] = STPoint3(x3, y3, z3);
ParsedTriangle(v[0], v[1], v[2]);
}
else
if (command == "EnvironmentLight")
{
std::string filename;
float r,g,b;
ss >> filename >> r >> g >> b;
STColor3f intensity(r,g,b);
ParsedEnvironmentLight(filename, intensity);
}
else
if (command == "AmbientLight")
{
float r, g, b;
ss >> r >> g >> b;
STColor3f col(r, g, b);
ParsedAmbientLight(col);
}
else
if (command == "PointLight")
{
float px, py, pz, r, g, b;
ss >> px >> py >> pz >> r >> g >> b;
STPoint3 pos(px, py, pz);
STColor3f col(r, g, b);
ParsedPointLight(pos, col);
}
else
if (command == "DirectionalLight")
{
float dx, dy, dz, r, g, b;
ss >> dx >> dy >> dz >> r >> g >> b;
STVector3 dir(dx, dy, dz);
STColor3f col(r, g, b);
ParsedDirectionalLight(dir, col);
}
else
if (command == "LineLight") {
float sx, sy, sz, ex, ey, ez, r, g, b;
int n;
ss >> sx >> sy >> sz >> ex >> ey >> ez >> r >> g >> b >> n;
STPoint3 start(sx,sy,sz);
STPoint3 end(ex,ey,ez);
STColor3f intensity(r,g,b);
ParsedLineLight(start,end,intensity,n);
}
else
if (command == "CircleLight") {
float cx,cy,cz,rxx,rxy,rxz,ryx,ryy,ryz,r,g,b;
int n;
ss >> cx >> cy >> cz >> rxx >> rxy >> rxz >> ryx >> ryy >> ryz >> r >> g >> b >> n;
STPoint3 center(cx,cy,cz);
STVector3 radiusVector_x(rxx,rxy,rxz);
STVector3 radiusVector_y(ryx,ryy,ryz);
STColor3f intensity(r,g,b);
ParsedCircleLight(center,radiusVector_x,radiusVector_y,intensity,n);
}
else
if (command == "Material")
{
float ra, ga, ba, rd, gd, bd, rs, gs, bs, rr, gr, br, shine;
ss >> ra >> ga >> ba >> rd >> gd >> bd >> rs >> gs >> bs >> rr >> gr >> br >> shine;
STColor3f amb(ra, ga, ba);
STColor3f diff(rd, gd, bd);
STColor3f spec(rs, gs, bs);
STColor3f mirr(rr, gr, br);
ParsedMaterial(amb, diff, spec, mirr, shine);
}
}
sceneFile.close();
FinishedParsing();
}
void Scene::BeganParsing()
{
environment_light = NULL;
matrix_stack.push_back(STTransform4::Identity());
printf("Transformation stack looks like this: \n");
for(int i=0; i<matrix_stack.size(); i++) {
for(int r=0; r<4; r++) {
float *row = matrix_stack[i][r];
printf(" %f %f %f %f\n",row[0],row[1],row[2],row[3]);
}
printf("\n");
}
}
void Scene::FinishedParsing()
{
matrix_stack.clear();
printf("\nNumber of non-ambient lights in scene: %d\n",(int)lights.size());
printf("Number of objects in scene: %d\n",(int)objects.size());
printf("Finished parsing file\n");
}
void Scene::ParsedCamera(const STPoint3& eye, const STVector3& up, const STPoint3& lookAt, float fovy, float aspect)
{
camera.setCamera(eye,up,lookAt,fovy,aspect);
}
void Scene::ParsedOutput(int imgWidth, int imgHeight, const std::string& outputFilename)
{
width = imgWidth, height = imgHeight;
imageplane.setImagePlane(imgWidth,imgHeight,outputFilename,camera);
}
void Scene::ParsedBounceDepth(int depth)
{
bounce_depth = depth;
}
void Scene::ParsedShadowBias(float bias)
{
shadow_bias = bias;
}
void Scene::ParsedPushMatrix()
{
STTransform4 matrix = STTransform4(matrix_stack.back());
matrix_stack.push_back(matrix);
printf("Pushed top matrix. Transformation stack looks like this: \n");
for(int i=0; i<matrix_stack.size(); i++) {
for(int r=0; r<4; r++) {
float *row = matrix_stack[i][r];
printf(" %f %f %f %f\n",row[0],row[1],row[2],row[3]);
}
printf("\n");
}
}
void Scene::ParsedPopMatrix()
{
matrix_stack.pop_back();
printf("\nPopped matrix. Transformation stack looks like this: \n");
for(int i=0; i<matrix_stack.size(); i++) {
for(int r=0; r<4; r++) {
float *row = matrix_stack[i][r];
printf(" %f %f %f %f\n",row[0],row[1],row[2],row[3]);
}
printf("\n");
}
}
void Scene::ParsedRotate(float rx, float ry, float rz)
{
STTransform4 rotation_matrix = STTransform4::Rotation(DegreesToRadians(rx),DegreesToRadians(ry),DegreesToRadians(rz));
int i = matrix_stack.size() - 1;
matrix_stack[i] = matrix_stack[i]*rotation_matrix;
printf("Rotated top matrix. Transformation stack looks like this: \n");
for(int i=0; i<matrix_stack.size(); i++) {
for(int r=0; r<4; r++) {
float *row = matrix_stack[i][r];
printf(" %f %f %f %f\n",row[0],row[1],row[2],row[3]);
}
printf("\n");
}
}
void Scene::ParsedScale(float sx, float sy, float sz)
{
STTransform4 scaling_matrix = STTransform4::Scaling(sx,sy,sz);
int i = matrix_stack.size() - 1;
matrix_stack[i] = matrix_stack[i]*scaling_matrix;
printf("Scaled top matrix. Transformation stack looks like this: \n");
for(int i=0; i<matrix_stack.size(); i++) {
for(int r=0; r<4; r++) {
float *row = matrix_stack[i][r];
printf(" %f %f %f %f\n",row[0],row[1],row[2],row[3]);
}
printf("\n");
}
}
void Scene::ParsedTranslate(float tx, float ty, float tz)
{
STTransform4 translation_matrix = STTransform4::Translation(tx,ty,tz);
int i = matrix_stack.size() - 1;
matrix_stack[i] = matrix_stack[i]*translation_matrix;
printf("Translated top matrix. Transformation stack looks like this: \n");
for(int i=0; i<matrix_stack.size(); i++) {
for(int r=0; r<4; r++) {
float *row = matrix_stack[i][r];
printf(" %f %f %f %f\n",row[0],row[1],row[2],row[3]);
}
printf("\n");
}
}
void Scene::ParsedSphere(const STPoint3& center, float radius)
{
objects.push_back(SceneObject(new Sphere(center,radius),material,matrix_stack.back()));
}
void Scene::ParsedTriangle(const STPoint3& v1, const STPoint3& v2, const STPoint3& v3)
{
objects.push_back(SceneObject(new Triangle(v1,v2,v3),material,matrix_stack.back()));
}
void Scene::ParsedLineLight(const STPoint3 &start, const STPoint3 &end, const STColor3f &intensity, const int numSamples)
{
LineLight *light = new LineLight(start,end,intensity,numSamples);
std::vector<PointLight *> point_lights;
light->getPointLights(point_lights);
for(int i=0; i<numSamples; i++) {
lights.push_back(point_lights[i]);
}
}
void Scene::ParsedCircleLight(const STPoint3& center, const STVector3& radiusVector_x, const STVector3& radiusVector_y, const STColor3f &intensity, int numLines) {
CircleLight *light_source = new CircleLight(center,radiusVector_x,radiusVector_y,intensity,numLines);
std::vector<PointLight *> point_lights;
light_source->getPointLights(point_lights);
int num_lights = point_lights.size();
for(int i=0; i<num_lights; i++) {
lights.push_back(point_lights[i]);
}
}
void Scene::ParsedEnvironmentLight(const std::string filename, STColor3f &intensity) {
environment_light = new EnvironmentLight(filename, intensity);
}
void Scene::ParsedAmbientLight(const STColor3f& col)
{
ambient_lights.push_back(new AmbientLight(col));
}
void Scene::ParsedPointLight(const STPoint3& loc, const STColor3f& col)
{
lights.push_back(new PointLight(matrix_stack.back()*loc,col));
}
void Scene::ParsedDirectionalLight(const STVector3& dir, const STColor3f& col)
{
lights.push_back(new DirectionalLight(matrix_stack.back()*dir,col));
}
void Scene::ParsedMaterial(const STColor3f& amb, const STColor3f& diff, const STColor3f& spec, const STColor3f& mirr, float shine)
{
material.setMaterial(amb,diff,spec,mirr,shine);
}
| [
"[email protected]"
]
| [
[
[
1,
566
]
]
]
|
611148f2a8fb6ed354ee746a7a10ec2dd0e66793 | 7acbb1c1941bd6edae0a4217eb5d3513929324c0 | /GLibrary-CPP/sources/GLineEdit.h | 6bda2d8cda56e1f85feac43e92bc1edb9ca9f8f8 | []
| no_license | hungconcon/geofreylibrary | a5bfc96e0602298b5a7b53d4afe7395a993498f1 | 3abf3e1c31a245a79fa26b4bcf2e6e86fa258e4d | refs/heads/master | 2021-01-10T10:11:51.535513 | 2009-11-30T15:29:34 | 2009-11-30T15:29:34 | 46,771,895 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 442 | h |
#ifndef __GLINEEDIT_H__
# define __GLINEEDIT_H__
#include "GWidget.h"
#include "GExport.h"
class GEXPORTED GLineEdit : public GWidget
{
public:
GLineEdit(GWidget *Parent);
~GLineEdit(void);
GString GetText(void);
void SetText(const GString &Text);
void Password(void);
void SetPasswordChar(const GChar &Char);
void SetLimitLength(unsigned int Limit);
private:
GWidget *_parent;
};
#endif | [
"[email protected]"
]
| [
[
[
1,
25
]
]
]
|
0d752f601ceb348c6bc5ac9a0964c97cf03ac620 | ca99bc050dbc58be61a92e04f2a80a4b83cb6000 | /Game/src/Entities/Bear.cpp | 99491cd50373b78976873779e792fabe0495bfb8 | []
| no_license | NicolasBeaudrot/angry-tux | e26c619346c63a468ad3711de786e94f5b78a2f1 | 5a8259f57ba59db9071158a775948d06e424a9a8 | refs/heads/master | 2021-01-06T20:41:23.705460 | 2011-04-14T18:28:04 | 2011-04-14T18:28:04 | 32,141,181 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,121 | cpp | #include "Bear.h"
Bear::Bear(sf::RenderWindow* app
,sf::Vector2i& position
,std::string& path
,int size
,int score
,b2World* world) : Entity(app, position, path = "bears/" + path, 0){
_score = score;
_size = size;
//Physics definition
b2BodyDef bd;
bd.position.Set(_position.x, _position.y);
bd.type = b2_dynamicBody;
bd.angularDamping = 0.01f;
b2CircleShape circle;
circle.m_radius = _image->GetWidth() / 2;
b2FixtureDef fixtureDef;
fixtureDef.shape = &circle;
fixtureDef.density = 100;
fixtureDef.friction = 0.3f;
fixtureDef.restitution = 0.3f;
_bearBody = world->CreateBody(&bd);
_bearBody->CreateFixture(&fixtureDef);
_sprite.SetCenter(_image->GetWidth()/2, _image->GetHeight()/2);
}
Bear::~Bear() {
}
void Bear::render() {
sf::Vector2i position_sfml = Conversion::to_sfmlcoord(_bearBody->GetPosition().x, _bearBody->GetPosition().y);
_sprite.SetPosition(position_sfml.x, position_sfml.y);
_sprite.SetRotation(Conversion::to_degres(_bearBody->GetAngle()));
_app->Draw(_sprite);
}
| [
"nicolas.beaudrot@43db0318-7ac6-f280-19a0-2e79116859ad"
]
| [
[
[
1,
44
]
]
]
|
e40b0848b38e626bfbd02ef1c19a5b4c0d742e7b | ee636be1d3c3ab19b23251beb1292d006db0a4df | /Arranger/src/gfxScene.cpp | cb81fa37d8616b0f35844d67a4066c02c2619dba | []
| no_license | arturo182/OOP | 6f5084f515fc34f9b0be95298538f0f4ce0bbb0e | 978aa6f13c62850593ffcca0e314218e297180f9 | refs/heads/master | 2020-06-05T13:27:36.779823 | 2011-02-28T07:36:32 | 2011-02-28T07:36:32 | 1,420,589 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,991 | cpp | #include "gfxScene.h"
#include "itmRoom.h"
#include "itmFurniture.h"
#include <QtCore/QSettings>
#include <QtCore/QDebug>
#include <QtGui/QPainter>
#include <QtGui/QGraphicsRectItem>
#include <QtGui/QGraphicsSceneMouseEvent>
gfxScene::gfxScene(QObject *parent): QGraphicsScene(parent)
{
m_active = 0;
}
void gfxScene::newFile()
{
m_active = 0;
clear();
}
void gfxScene::moveActive(int x, int y)
{
QSettings set;
if(m_active) {
int gridSize = set.value("gridSize", 25).toInt();
m_active->moveBy(x * gridSize, y * gridSize);
if(m_active->type() == itmRoom::Type) {
itmRoom *room = static_cast<itmRoom*>(m_active);
foreach(itmFurniture *furni, room->furniture()) {
furni->moveBy(x * gridSize, y * gridSize);
}
}
}
}
void gfxScene::resizeActive(int w, int h)
{
QSettings set;
if(m_active) {
int gridSize = set.value("gridSize", 25).toInt();
if((m_active->rect().width() + 2 * w * gridSize > 0) && (m_active->rect().height() + 2 * h * gridSize > 0)) {
m_active->setRect(m_active->rect().x() - w * gridSize, m_active->rect().y() - h * gridSize, m_active->rect().width() + 2 * w * gridSize, m_active->rect().height() + 2 * h * gridSize);
}
}
}
void gfxScene::drawBackground(QPainter *painter, const QRectF &rect)
{
QSettings set;
int gridSize = set.value("gridSize", 25).toInt();
int gridDivs = set.value("gridDivs", 4).toInt();
painter->setWorldMatrixEnabled(true);
qreal left = (int)rect.left() - ((int)rect.left() % gridSize);
qreal top = (int)rect.top() - ((int)rect.top() % gridSize);
QVector<QLineF> lines;
QVector<QLineF> linesBold;
for(qreal x = left; x < rect.right(); x += gridSize) {
lines.append(QLineF(x, rect.top(), x, rect.bottom()));
if((int)x % (gridSize * gridDivs) == 0) {
linesBold.append(QLineF(x, rect.top(), x, rect.bottom()));
}
}
for(qreal y = top; y < rect.bottom(); y += gridSize) {
lines.append(QLineF(rect.left(), y, rect.right(), y));
if((int)y % (gridSize * gridDivs) == 0) {
linesBold.append(QLineF(rect.left(), y, rect.right(), y));
}
}
QPen pen = painter->pen();
pen.setColor(QColor(195, 195, 195));
pen.setStyle(Qt::DotLine);
painter->setPen(pen);
painter->drawLines(lines);
QPen penBold = painter->pen();
penBold.setColor(QColor(130, 130, 130));
penBold.setStyle(Qt::SolidLine);
painter->setPen(penBold);
painter->drawLines(linesBold);
}
void gfxScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
QGraphicsScene::mousePressEvent(mouseEvent);
QGraphicsRectItem *item = static_cast<QGraphicsRectItem*>(itemAt(mouseEvent->scenePos()));
if(item) {
if(m_active) {
m_active->setPen(QPen(QColor(m_active->data(0).toInt(), m_active->data(1).toInt(), m_active->data(2).toInt()), 1));
}
item->setPen(QPen(Qt::red, 2));
m_active = item;
}
}
| [
"[email protected]"
]
| [
[
[
1,
109
]
]
]
|
e70fe0f22023f636e0a09896bc84854513a5a007 | 291355fd4592e4060bca01383e2c3a2eff55bd58 | /src/lists.h | b0cd3db4a3036669bdb6d574529f55287e4cf42f | []
| no_license | rrader/cprompt | 6d7c9aac25d134971bbf99d4e84848252a626bf3 | dfb7d55111b6e8d3c3a0a0a1c703c04a58d5e808 | refs/heads/master | 2020-05-16T22:06:16.127336 | 2010-01-23T21:33:04 | 2010-01-23T21:33:04 | 1,659,726 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,047 | h | #ifndef LISTS_H_INCLUDED
#define LISTS_H_INCLUDED
#include <cstdlib>
namespace ag
{
template<typename T>
struct listmember
{
listmember* next;
listmember* prev;
T data;
};
template<typename T>
class list
{
public:
list();
~list();
void delall();
listmember<T>* add_head(T data);
listmember<T>* add_tail(T data);
T& del(listmember<T>* e);
listmember<T>* create_first(T data);
listmember<T>* find(T d);
typedef listmember< T >* member;
listmember< T >* operator[](int i);
member head;
member tail;
int count();
bool empty(){ return this->tail==NULL; }
void copyfrom_ptr(list<T>* i)
{
void* k;
T* w;
for (member m=i->head;m!=NULL;m=m->next)
{
k=m->data;
w=new T;
memcpy(w,k,sizeof(T));
add_tail(*w);
}
};
};
template<typename T>
list<T>::list()
{
head=0;
tail=0;
};
template<typename T>
list<T>::~list()
{
member p=head;
member k;
while (p!=0)
{
k=p->next;
del(p);
p=k;
}
};
template<typename T>
void list<T>::delall()
{
member p=head;
member k;
while (p!=0)
{
k=p->next;
del(p);
p=k;
}
};
template<typename T>
listmember<T>* list<T>::add_head(T data)
{
if (head==0)
return create_first(data);
else
{
listmember<T>* e=new listmember<T>;
e->data=data;
e->prev=0;
e->next=head;
head->prev=e;
head=e;
return e;
}
};
template<typename T>
listmember<T>* list<T>::add_tail(T data)
{
if (tail==0)
return create_first(data);
else
{
listmember<T>* e=new listmember<T>;
e->data=data;
e->next=0;
e->prev=tail;
tail->next=e;
tail=e;
return e;
}
};
template<typename T>
T& list<T>::del(listmember<T>* e)
{
if (!e) throw -1;
T* k=new T;
*k=e->data;
if (e->prev)
e->prev->next=e->next;
else
head=e->next;
if (e->next)
e->next->prev=e->prev;
else
tail=e->prev;
delete e;
return *k;
};
template<typename T>
listmember<T>* list<T>::create_first(T data)
{
listmember<T>* e=0;
if ((head==0)&&(tail==0))
{
e=new listmember<T>;
e->data=data;
e->next=0;
e->prev=0;
head=tail=e;
}
return e;
};
template<typename T>
listmember<T>* list<T>::find(T d)
{
member p=head;
while (p!=NULL)
{
if (p->data==d)
return p;
p=p->next;
}
return 0;
};
template<typename T>
int list<T>::count()
{
member p=head;
int i=0;
while (p!=NULL)
{
i++;
p=p->next;
}
return i;
};
template<typename T>
listmember<T>* list<T>::operator[](int i)
{
member p=head;
int k=0;
while (p!=0)
{
if (k==i)
return p;
p=p->next;
k++;
}
return 0;
}
};
#endif // LISTS_H_INCLUDED
| [
"[email protected]"
]
| [
[
[
1,
195
]
]
]
|
86a7463c2e2f26d538edb9945473a0e93b812327 | 975d45994f670a7f284b0dc88d3a0ebe44458a82 | /Docs/FINAIS/Fonte/cliente/Source/Menu/CMenuLogin.h | 1214d578da1f3b9a492cbb14a77c001447c2a5cd | []
| no_license | phabh/warbugs | 2b616be17a54fbf46c78b576f17e702f6ddda1e6 | bf1def2f8b7d4267fb7af42df104e9cdbe0378f8 | refs/heads/master | 2020-12-25T08:51:02.308060 | 2010-11-15T00:37:38 | 2010-11-15T00:37:38 | 60,636,297 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 380 | h | #pragma once
#include "CMenu.h"
class CMenuLogin : public CMenu
{
private:
IGUIEditBox *Login,
*Password;
char _login[15],
_senha[15];
int _loadingStage;
void graphicsDrawAddOn();
void updateHuds();
void readCommands();
void updateGraphics();
void receivePackages();
public:
CMenuLogin();
bool start(CGameCore *gameCore);
};
| [
"[email protected]"
]
| [
[
[
1,
28
]
]
]
|
7f13acc7de20ee101d8ded7b345936f9cfa2a7c6 | b86d7c8f28a0c243b4c578821e353d5efcaf81d2 | /clearcasehelper/ResizeLib/ResizableSheetEx.cpp | 352cbddcf889683dc9419c3b7f3be6d6e0590e17 | []
| no_license | nk39/mototool | dd4998d38348e0e2d010098919f68cf2c982f26a | 34a0698fd274ae8b159fc8032f3065877ba2114d | refs/heads/master | 2021-01-10T19:26:23.675639 | 2008-01-04T04:47:54 | 2008-01-04T04:47:54 | 34,927,428 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 9,083 | cpp | // ResizableSheetEx.cpp : implementation file
//
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2000-2001 by Paolo Messina
// (http://www.geocities.com/ppescher - [email protected])
//
// The contents of this file are subject to the Artistic License (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.opensource.org/licenses/artistic-license.html
//
// If you find this code useful, credits would be nice!
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ResizableSheetEx.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CResizableSheetEx
IMPLEMENT_DYNAMIC(CResizableSheetEx, CPropertySheetEx)
inline void CResizableSheetEx::Construct()
{
m_bInitDone = FALSE;
m_bEnableSaveRestore = FALSE;
m_bSavePage = FALSE;
}
CResizableSheetEx::CResizableSheetEx()
{
Construct();
}
CResizableSheetEx::CResizableSheetEx(UINT nIDCaption, CWnd* pParentWnd,
UINT iSelectPage, HBITMAP hbmWatermark, HPALETTE hpalWatermark,
HBITMAP hbmHeader)
: CPropertySheetEx(nIDCaption, pParentWnd, iSelectPage,
hbmWatermark, hpalWatermark, hbmHeader)
{
Construct();
}
CResizableSheetEx::CResizableSheetEx(LPCTSTR pszCaption, CWnd* pParentWnd,
UINT iSelectPage, HBITMAP hbmWatermark, HPALETTE hpalWatermark,
HBITMAP hbmHeader)
: CPropertySheetEx(pszCaption, pParentWnd, iSelectPage,
hbmWatermark, hpalWatermark, hbmHeader)
{
Construct();
}
CResizableSheetEx::~CResizableSheetEx()
{
}
BEGIN_MESSAGE_MAP(CResizableSheetEx, CPropertySheetEx)
//{{AFX_MSG_MAP(CResizableSheetEx)
ON_WM_GETMINMAXINFO()
ON_WM_SIZE()
ON_WM_DESTROY()
ON_WM_CREATE()
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
ON_NOTIFY_REFLECT_EX(PSN_SETACTIVE, OnPageChanging)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CResizableSheetEx message handlers
int CResizableSheetEx::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CPropertySheetEx::OnCreate(lpCreateStruct) == -1)
return -1;
// keep client area
CRect rect;
GetClientRect(&rect);
// set resizable style
ModifyStyle(DS_MODALFRAME, WS_POPUP | WS_THICKFRAME);
// adjust size to reflect new style
::AdjustWindowRectEx(&rect, GetStyle(),
::IsMenu(GetMenu()->GetSafeHmenu()), GetExStyle());
SetWindowPos(NULL, 0, 0, rect.Width(), rect.Height(), SWP_FRAMECHANGED|
SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREPOSITION);
if (!InitGrip())
return -1;
return 0;
}
BOOL CResizableSheetEx::OnInitDialog()
{
BOOL bResult = CPropertySheetEx::OnInitDialog();
// set the initial size as the min track size
CRect rc;
GetWindowRect(&rc);
SetMinTrackSize(rc.Size());
// init
UpdateGripPos();
PresetLayout();
// prevent flickering
GetTabControl()->ModifyStyle(0, WS_CLIPSIBLINGS);
m_bInitDone = TRUE;
ArrangeLayout();
return bResult;
}
void CResizableSheetEx::OnDestroy()
{
if (m_bEnableSaveRestore)
{
SaveWindowRect(m_sSection, m_bRectOnly);
SavePage();
}
RemoveAllAnchors();
CPropertySheetEx::OnDestroy();
}
// maps an index to a button ID and vice-versa
static UINT _propButtons[] =
{
IDOK, IDCANCEL, ID_APPLY_NOW, IDHELP,
ID_WIZBACK, ID_WIZNEXT, ID_WIZFINISH
};
// horizontal line in wizard mode
#define ID_WIZLINE ID_WIZFINISH+1
#define ID_WIZLINEHDR ID_WIZFINISH+2
void CResizableSheetEx::PresetLayout()
{
if (IsWizard() || IsWizard97()) // wizard mode
{
// hide tab control
GetTabControl()->ShowWindow(SW_HIDE);
AddAnchor(ID_WIZLINE, BOTTOM_LEFT, BOTTOM_RIGHT);
if (IsWizard97()) // add header line for wizard97 dialogs
AddAnchor(ID_WIZLINEHDR, TOP_LEFT, TOP_RIGHT);
}
else // tab mode
{
AddAnchor(AFX_IDC_TAB_CONTROL, TOP_LEFT, BOTTOM_RIGHT);
}
// add a callback for active page (which can change at run-time)
AddAnchorCallback(1);
// use *total* parent size to have correct margins
CRect rectPage, rectSheet;
GetTotalClientRect(&rectSheet);
GetActivePage()->GetWindowRect(&rectPage);
ScreenToClient(&rectPage);
// pre-calculate margins
m_sizePageTL = rectPage.TopLeft() - rectSheet.TopLeft();
m_sizePageBR = rectPage.BottomRight() - rectSheet.BottomRight();
// add all possible buttons, if they exist
for (int i = 0; i < 7; i++)
{
if (NULL != GetDlgItem(_propButtons[i]))
AddAnchor(_propButtons[i], BOTTOM_RIGHT);
}
}
BOOL CResizableSheetEx::ArrangeLayoutCallback(LayoutInfo &layout)
{
if (layout.nCallbackID != 1) // we only added 1 callback
return CResizableLayout::ArrangeLayoutCallback(layout);
// set layout info for active page
layout.hWnd = GetActivePage()->GetSafeHwnd();
// set margins
if (IsWizard()) // wizard mode
{
// use pre-calculated margins
layout.sizeMarginTL = m_sizePageTL;
layout.sizeMarginBR = m_sizePageBR;
}
else if (IsWizard97()) // wizard 97
{
// use pre-calculated margins
layout.sizeMarginTL = m_sizePageTL;
layout.sizeMarginBR = m_sizePageBR;
if (!(GetActivePage()->m_psp.dwFlags & PSP_HIDEHEADER))
{
// add header vertical offset
CRect rectLine;
GetDlgItem(ID_WIZLINEHDR)->GetWindowRect(&rectLine);
ScreenToClient(&rectLine);
layout.sizeMarginTL.cy = rectLine.bottom;
}
}
else // tab mode
{
CRect rectPage, rectSheet;
GetTotalClientRect(&rectSheet);
CTabCtrl* pTab = GetTabControl();
pTab->GetWindowRect(&rectPage);
pTab->AdjustRect(FALSE, &rectPage);
ScreenToClient(&rectPage);
// use tab control
layout.sizeMarginTL = rectPage.TopLeft() - rectSheet.TopLeft();
layout.sizeMarginBR = rectPage.BottomRight() - rectSheet.BottomRight();
}
// set anchor types
layout.sizeTypeTL = TOP_LEFT;
layout.sizeTypeBR = BOTTOM_RIGHT;
// use this layout info
return TRUE;
}
void CResizableSheetEx::OnSize(UINT nType, int cx, int cy)
{
CWnd::OnSize(nType, cx, cy);
if (nType == SIZE_MAXHIDE || nType == SIZE_MAXSHOW)
return; // arrangement not needed
if (m_bInitDone)
{
// update size-grip
UpdateGripPos();
ArrangeLayout();
}
}
BOOL CResizableSheetEx::OnPageChanging(NMHDR* /*pNotifyStruct*/, LRESULT* /*pResult*/)
{
// update new wizard page
// active page changes after this notification
PostMessage(WM_SIZE);
return FALSE; // continue routing
}
BOOL CResizableSheetEx::OnEraseBkgnd(CDC* pDC)
{
ClipChildren(pDC);
return CPropertySheetEx::OnEraseBkgnd(pDC);
}
void CResizableSheetEx::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
if (!m_bInitDone)
return;
MinMaxInfo(lpMMI);
}
// protected members
int CResizableSheetEx::GetMinWidth()
{
CWnd* pWnd = NULL;
CRect rectWnd, rectSheet;
GetTotalClientRect(&rectSheet);
int max = 0, min = rectSheet.Width();
// search for leftmost and rightmost button margins
for (int i = 0; i < 7; i++)
{
pWnd = GetDlgItem(_propButtons[i]);
// exclude not present or hidden buttons
if (pWnd == NULL || !(pWnd->GetStyle() & WS_VISIBLE))
continue;
// left position is relative to the right border
// of the parent window (negative value)
pWnd->GetWindowRect(&rectWnd);
ScreenToClient(&rectWnd);
int left = rectSheet.right - rectWnd.left;
int right = rectSheet.right - rectWnd.right;
if (left > max)
max = left;
if (right < min)
min = right;
}
// sizing border width
int border = GetSystemMetrics(SM_CXSIZEFRAME);
// compute total width
return max + min + 2*border;
}
// NOTE: this must be called after all the other settings
// to have the window and its controls displayed properly
void CResizableSheetEx::EnableSaveRestore(LPCTSTR pszSection, BOOL bRectOnly, BOOL bWithPage)
{
m_sSection = pszSection;
m_bSavePage = bWithPage;
m_bEnableSaveRestore = TRUE;
m_bRectOnly = bRectOnly;
// restore immediately
LoadWindowRect(pszSection, bRectOnly);
LoadPage();
}
// private memebers
// used to save/restore active page
// either in the registry or a private .INI file
// depending on your application settings
#define ACTIVEPAGE _T("ActivePage")
void CResizableSheetEx::SavePage()
{
if (!m_bSavePage)
return;
// saves active page index, zero (the first) if problems
// cannot use GetActivePage, because it always fails
CTabCtrl *pTab = GetTabControl();
int page = 0;
if (pTab != NULL)
page = pTab->GetCurSel();
if (page < 0)
page = 0;
AfxGetApp()->WriteProfileInt(m_sSection, ACTIVEPAGE, page);
}
void CResizableSheetEx::LoadPage()
{
// restore active page, zero (the first) if not found
int page = AfxGetApp()->GetProfileInt(m_sSection, ACTIVEPAGE, 0);
if (m_bSavePage)
{
SetActivePage(page);
ArrangeLayout(); // needs refresh
}
}
| [
"netnchen@631d5421-cb3f-0410-96e9-8590a48607ad"
]
| [
[
[
1,
375
]
]
]
|
53c2d6476a3a0fd555f6efd23f9e8c9fac7575df | 10bac563fc7e174d8f7c79c8777e4eb8460bc49e | /core/client_base_t.cpp | c443c95a4ce6b720ed235c80765c6f01b10dec15 | []
| no_license | chenbk85/alcordev | 41154355a837ebd15db02ecaeaca6726e722892a | bdb9d0928c80315d24299000ca6d8c492808f1d5 | refs/heads/master | 2021-01-10T13:36:29.338077 | 2008-10-22T15:57:50 | 2008-10-22T15:57:50 | 44,953,286 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 8,058 | cpp | #include "client_base_t.hpp"
namespace all {
namespace core {
client_base_t::client_base_t():
m_io_service(),
m_tcp_socket(m_io_service),
m_resolver(m_io_service),
m_tcp_sender(m_tcp_socket),
m_tcp_receiver(m_tcp_socket)
{
m_server_addr.hostname = "localhost";
m_server_addr.port = 33333;
m_tcp_receiver.set_read_callback(boost::bind(&client_base_t::in_packet_handler, this, _1));
m_tcp_receiver.set_error_callback(boost::bind(&client_base_t::in_packet_error_cb, this, _1));
set_packet_handler(COMMAND_PACKET, boost::bind(&client_base_t::command_packet_handler, this, _1));
set_packet_handler(ANSWER_PACKET, boost::bind(&client_base_t::command_packet_handler, this, _1));
//add_command_handler("shutdown", boost::bind(&client_base_t::shutdown_handler, this, _1));
m_state = STATE_DISCONNECTED;
}
client_base_t::~client_base_t() {
stop();
}
void client_base_t::run() {
try_connect();
m_io_service.run();
}
void client_base_t::run_async() {
try_connect();
m_execution_thread.reset(new boost::thread(boost::bind(&boost::asio::io_service::run, &m_io_service)));
}
void client_base_t::stop() {
m_io_service.post(boost::bind(&client_base_t::handle_stop, this));
m_execution_thread->join();
m_io_service.reset();
printf("all done\n");
}
void client_base_t::set_server_addr(all::core::ip_address_t server_address) {
m_server_addr = server_address;
}
bool client_base_t::is_connected() {
return (m_state == STATE_CONNECTED);
}
void client_base_t::try_connect() {
boost::asio::ip::tcp::resolver::query query(boost::asio::ip::tcp::v4(),
m_server_addr.hostname,
boost::lexical_cast<std::string>(m_server_addr.port));
m_resolver.async_resolve(query,
boost::bind(&client_base_t::handle_resolve,
this,
boost::asio::placeholders::error,
boost::asio::placeholders::iterator));
}
void client_base_t::handle_resolve(const boost::system::error_code& error, boost::asio::ip::tcp::resolver::iterator endpoint_iterator) {
if (!error) {
// Attempt a connection to the first endpoint in the list. Each endpoint
// will be tried until we successfully establish a connection.
boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
m_tcp_socket.async_connect(endpoint,
boost::bind(&client_base_t::handle_connect,
this,
boost::asio::placeholders::error,
++endpoint_iterator));
}
else {
printf("error in client_base_t::handle_resolve \n %s", error.message());
}
}
void client_base_t::handle_stop() {
printf("handle_stop\n");
if (m_state == STATE_CONNECTED) {
m_state = STATE_DISCONNECTED;
printf("stop listening\n");
m_tcp_receiver.stop_listen();
printf("disconnect cb\n");
if (m_disconnect_cb)
m_disconnect_cb();
printf("closing tcp socket\n");
m_tcp_socket.close();
}
m_state = STATE_DISCONNECTED;
printf("stopping io service\n");
m_io_service.stop();
}
void client_base_t::handle_lost_connection() {
printf("handle lost connection\n");
m_tcp_receiver.stop_listen();
if (m_disconnect_cb) {
m_disconnect_cb();
}
m_tcp_socket.close();
try_connect();
}
void client_base_t::handle_connect(const boost::system::error_code& error, boost::asio::ip::tcp::resolver::iterator endpoint_iterator) {
if (!error) {
// The connection was successful.
m_state = STATE_CONNECTED;
printf("Client connected\n");
boost::asio::socket_base::keep_alive keep_alive_opt(true);
m_tcp_socket.set_option(keep_alive_opt);
m_tcp_receiver.start_listen();
if (m_connect_cb)
m_connect_cb();
}
else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
// The connection failed. Try the next endpoint in the list.
m_tcp_socket.close();
boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
m_tcp_socket.async_connect(endpoint,
boost::bind(&client_base_t::handle_connect, this,
boost::asio::placeholders::error,
++endpoint_iterator));
}
else {
printf("Error connecting to the server...trying again\n");
try_connect();
}
}
void client_base_t::send_command(std::string command) {
net_packet_ptr_t packet(new net_packet_t);
send_command(command, packet);
}
void client_base_t::send_command(std::string command, net_packet_ptr_t packet) {
if (m_state == STATE_CONNECTED) {
packet->set_packet_type(COMMAND_PACKET);
packet->set_command(command);
packet->finalize_packet();
m_tcp_sender.send_packet(packet);
}
else
printf("operation aborted: not connected to the server\n");
}
void client_base_t::send_request(std::string request, int req_freq) {
net_packet_ptr_t packet(new net_packet_t);
send_request(request, packet, req_freq);
}
void client_base_t::send_request(std::string request, net_packet_ptr_t packet, int req_freq) {
if (m_state == STATE_CONNECTED) {
packet->set_packet_type(REQUEST_PACKET);
packet->set_command(request);
packet->set_req_freq(req_freq);
packet->finalize_packet();
m_tcp_sender.send_packet(packet);
}
else
printf("operation aborted: not connected to the server\n");
}
void client_base_t::stop_request(std::string request) {
send_request(request, -1);
}
void client_base_t::send_finalized_packet(net_packet_ptr_t packet) {
if (m_state == STATE_CONNECTED) {
m_tcp_sender.send_packet(packet);
}
}
void client_base_t::in_packet_handler (net_packet_ptr_t packet) {
net_packet_type packet_type = packet->get_header().get_packet_type();
std::map <net_packet_type, in_packet_handler_t >::iterator type_it = m_packet_handler_list.find(packet_type);
if (type_it != m_packet_handler_list.end()) {
in_packet_handler_t packet_handler = type_it->second;
packet_handler(packet);
}
else {
printf ("Cannot find an handler for received packet type");
}
}
void client_base_t::in_packet_error_cb(const boost::system::error_code& error) {
if (m_state == STATE_CONNECTED) {
if (error == boost::asio::error::no_data) {
printf("Bad packet received\n");
}
else if (error == boost::asio::error::eof) {
printf("Lost connection with server...reconnecting\n");
m_state = STATE_LOST_CONNECTION;
m_io_service.post(boost::bind(&client_base_t::handle_lost_connection, this));
}
else {
printf("Error with server connection: %s\n Resetting...\n", error.message().c_str());
m_state = STATE_LOST_CONNECTION;
m_io_service.post(boost::bind(&client_base_t::handle_lost_connection, this));
//handle_lost_connection();
}
}
}
void client_base_t::command_packet_handler (net_packet_ptr_t packet) {
std::string command = packet->get_command();
std::map <std::string, in_packet_handler_t>::iterator cmd_it= m_command_handler_list.find(command);
if (cmd_it != m_command_handler_list.end()) {
in_packet_handler_t packet_handler = cmd_it->second;
packet_handler(packet);
}
else {
printf ("Unknown command received by server: %s\n", command.c_str());
}
}
void client_base_t::set_packet_handler (net_packet_type packet_type, boost::function <void (net_packet_ptr_t) > handler) {
m_packet_handler_list[packet_type] = handler;
}
void client_base_t::add_command_handler(std::string command, boost::function <void (net_packet_ptr_t)> handler) {
//m_command_pkt_handler_list.insert(make_pair(command, handler));
m_command_handler_list[command] = handler;
}
//void client_base_t::shutdown_handler(net_packet_ptr_t packet) {
// printf("Server shutting down...disconnecting\n");
// handle_stop();
//}
void client_base_t::set_connect_callback(boost::function <void (void)> connect_cb) {
m_connect_cb = connect_cb;
}
void client_base_t::set_disconnect_callback(boost::function <void (void)> disconnect_cb) {
m_disconnect_cb = disconnect_cb;
}
}} //namespaces | [
"stefano.marra@1c7d64d3-9b28-0410-bae3-039769c3cb81"
]
| [
[
[
1,
276
]
]
]
|
4b963b2f80fe95a0a49df109b4f6de7f15a5f3b9 | 9340e21ef492eec9f19d1e4ef2ef33a19354ca6e | /cing/src/graphics/GraphicsUserAPI.h | 687281ae84da5f6f18f52465a339a9e27c7bd06a | []
| no_license | jamessqr/Cing | e236c38fe729fd9d49ccd1584358eaad475f7686 | c46045d9d0c2b4d9e569466971bbff1662be4e7a | refs/heads/master | 2021-01-17T22:55:17.935520 | 2011-05-14T18:35:30 | 2011-05-14T18:35:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,396 | h | /*
This source file is part of the Cing project
For the latest info, see http://www.cing.cc
Copyright (c) 2006-2009 Julio Obelleiro and Jorge Cano
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 USA
*/
#ifndef _GraphicsUserAPI_h_
#define _GraphicsUserAPI_h_
// Precompiled headers
#include "Cing-Precompiled.h"
#include "GraphicsPrereqs.h"
#include "MovableText.h"
#include "Color.h"
#include "Image.h"
#include "common/eString.h"
#include "common/CommonConstants.h"
#include <sstream>
namespace Cing
{
/**
* @brief Graphics related functions that user can call
*/
//-----------------------------------------------------------------------------------
// Color/Settings
//-----------------------------------------------------------------------------------
/* The background() function sets the color used for the background of the window.
The default background is light gray. In the draw() function, the background color
is used to clear the display window at the beginning of each frame.
*/
void background( float gray );
void background( float gray, float alpha );
void background( float x, float y, float z );
void background( float x, float y, float z, float a );
void background( int rgb );
void background( int rgb, float alpha );
void background( const Color& theColor );
void background( const Image& image ); // TODO: not implemented yet!
void setBackgroundColor( const Color& color );
/* The stroke() function sets the color used to draw lines and borders around shapes. This color is either
specified in terms of the RGB or HSB color depending on the current colorMode()
(the default color space is RGB, with each value in the range from 0 to 255).
*/
void stroke( float gray );
void stroke( float gray, float alpha );
void stroke( float x, float y, float z );
void stroke( float x, float y, float z, float a );
void stroke( int rgb );
void stroke( int rgb, float alpha );
void stroke( const Color& color );
/* Changes the way Cing interprets color data. By default, the
parameters for fill(), stroke(), background(), and color() are defined by values
between 0 and 255 using the RGB color model. The colorMode() function is used to
change the numerical range used for specifying colors and to switch color systems.
For example, calling colorMode(RGB, 1.0) will specify that values are specified
between 0 and 1. The limits for defining colors are altered by setting the
parameters range1, range2, range3, and range 4.
*/
void colorMode(GraphicsType mode);
/* Sets the color used to fill shapes. For example, if you run fill(204, 102, 0),
all subsequent shapes will be filled with orange. This color is either specified
in terms of the RGB or HSB color depending on the current colorMode() (the default
color space is RGB, with each value in the range from 0 to 255).
*/
void fill( float gray );
void fill( float gray, float alpha );
void fill( float value1, float value2, float value3 );
void fill( float value1, float value2, float value3, float alpha );
void fill( const Color& color );
//void fill(hex) NO HEX DATA TYPE
//void fill(hex, alpha) NO HEX DATA TYPE
//-----------------------------------------------------------------------------------
// Shape / 2D Primitives
//-----------------------------------------------------------------------------------
void strokeWeight( int weight );
void noFill ();
void noStroke ();
void smooth ();
void noSmooth ();
void line ( int x1, int y1, int x2, int y2 );
void point ( int x, int y );
void triangle ( int x1, int y1, int x2, int y2, int x3, int y3 );
void rect ( int x1, int y1, int width, int height );
void quad ( int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4 );
void ellipse ( int x, int y, int width, int height);
void arc ( int x, int y, int width, int height, float start, float stop );
void rectMode ( int mode );
void ellipseMode ( int mode );
void pushStyle();
void popStyle ();
//-----------------------------------------------------------------------------------
// Shape / 3D Primitives
//-----------------------------------------------------------------------------------
void line( float x1, float y1, float z1, float x2, float y2, float z2);
void beginShape ();
void beginShape (GraphicsType operation);
void endShape ();
void endShape (GraphicsType operation);
void vertex (float x, float y);
void vertex (float x, float y, float z);
// Render related functions
void setRenderMode( RenderMode mode );
// Camera 3D related functions
void enableDefault3DCameraControl( bool value = true );
void enableMouseCameraControl ( bool value = true );
void enableKeyboardCameraControl ( bool value = true );
// Debugle methods
void showFps ( bool show = true );
// Image Create functions
Image createImage( int width, int height, GraphicsType format );
Image loadImage ( const std::string& name );
// Read and writes to the global pixels variable.( slooooow for now!)
void loadPixels();
void updatePixels();
// To control at a global level the 2D/3D Transforms
void pushMatrix();
void popMatrix();
void resetMatrix();
void printMatrix();
void applyMatrix( float m00, float m01, float m02, float m03,
float m10, float m11, float m12, float m13,
float m20, float m21, float m22, float m23,
float m30, float m31, float m32, float m33 );
void translate( float x, float y );
void translate( float x, float y, float z );
void rotate ( float angleZRad );
void rotateX ( float angleRad );
void rotateY ( float angleRad );
void rotateZ ( float angleRad );
void scale ( float x, float y, float z );
void scale ( float x, float y );
// Coordinate systems
void applyCoordinateSystemTransform( const GraphicsType& coordSystem );
//Save frames
void save( const String& name );
//-----------------------------------------------------------------------------------
// Typography
//-----------------------------------------------------------------------------------
void text( const String& text, float x, float y );
void text( const String& text, float x, float y, float z);
void text( const String& text, float x, float y, float width, float height );
void text( const String& text, float x, float y, float z, float width, float height );
void text( const std::ostringstream& text, float x, float y );
void text( int text, float x, float y );
void text( float text, float x, float y );
//void text(data, x, y, z)
//void text(stringdata, x, y, width, height)
//void text(stringdata, x, y, width, height, z)
void textFont (const Font& font);
void textFont (const Font& font, float size);
void textAlign (int halign, int valign = TOP);
void textMode (TextMode mode);
void textSize (float size);
//-----------------------------------------------------------------------------------
// Shadows
//-----------------------------------------------------------------------------------
void enableShadows( ShadowTechnique technique );
//-----------------------------------------------------------------------------------
// Coordinate System related
//-----------------------------------------------------------------------------------
Vector2d worldToScreen ( const Vector& worldCoordinate );
Vector2d worldToScreenNormalized ( const Vector& worldCoordinate );
Vector screenToWorld ( const Vector2d& screenCoordinate, float distanceToCamera );
Vector screenToWorld ( const Vector& screenCoordinate, float distanceToCamera );
} // namespace Cing
#endif // _GraphicsUserAPI_h_
| [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
30
],
[
33,
47
],
[
49,
49
],
[
54,
54
],
[
70,
70
],
[
81,
81
],
[
89,
89
],
[
98,
102
],
[
105,
105
],
[
107,
107
],
[
109,
109
],
[
118,
124
],
[
126,
127
],
[
131,
131
],
[
133,
133
],
[
135,
136
],
[
147,
154
],
[
159,
159
],
[
176,
176
],
[
178,
183
],
[
189,
233
]
],
[
[
31,
32
],
[
48,
48
],
[
50,
53
],
[
55,
69
],
[
71,
80
],
[
82,
88
],
[
90,
97
],
[
103,
104
],
[
106,
106
],
[
108,
108
],
[
110,
117
],
[
125,
125
],
[
128,
130
],
[
132,
132
],
[
134,
134
],
[
137,
146
],
[
155,
158
],
[
160,
175
],
[
177,
177
],
[
184,
188
],
[
234,
234
]
]
]
|
346c9bf74f37cc8d897de1ebe6ce7f5188f2b8f4 | 74c8da5b29163992a08a376c7819785998afb588 | /NetAnimal/addons/pa/ParticleUniverse/src/ParticleAffectors/ParticleUniverseScaleAffectorTokens.cpp | a875487a30975f5f3a80271a1571b93ab0b7fcf0 | []
| no_license | dbabox/aomi | dbfb46c1c9417a8078ec9a516cc9c90fe3773b78 | 4cffc8e59368e82aed997fe0f4dcbd7df626d1d0 | refs/heads/master | 2021-01-13T14:05:10.813348 | 2011-06-07T09:36:41 | 2011-06-07T09:36:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,920 | cpp | /*
-----------------------------------------------------------------------------------------------
This source file is part of the Particle Universe product.
Copyright (c) 2010 Henry van Merode
Usage of this program is licensed under the terms of the Particle Universe Commercial License.
You can find a copy of the Commercial License in the Particle Universe package.
-----------------------------------------------------------------------------------------------
*/
#include "ParticleUniversePCH.h"
#ifndef PARTICLE_UNIVERSE_EXPORTS
#define PARTICLE_UNIVERSE_EXPORTS
#endif
#include "ParticleAffectors/ParticleUniverseScaleAffector.h"
#include "ParticleAffectors/ParticleUniverseScaleAffectorTokens.h"
namespace ParticleUniverse
{
//-----------------------------------------------------------------------
bool ScaleAffectorTranslator::translateChildProperty(Ogre::ScriptCompiler* compiler, const Ogre::AbstractNodePtr &node)
{
Ogre::PropertyAbstractNode* prop = reinterpret_cast<Ogre::PropertyAbstractNode*>(node.get());
ParticleAffector* af = Ogre::any_cast<ParticleAffector*>(prop->parent->context);
ScaleAffector* affector = static_cast<ScaleAffector*>(af);
if (prop->name == token[TOKEN_SCALE_XYZ_SCALE])
{
// Property: xyz_scale
if (passValidateProperty(compiler, prop, token[TOKEN_SCALE_XYZ_SCALE], VAL_REAL))
{
Ogre::Real val = 0.0f;
if(getReal(prop->values.front(), &val))
{
DynamicAttributeFixed* dynamicAttributeFixed = OGRE_NEW_T(DynamicAttributeFixed, Ogre::MEMCATEGORY_SCENE_OBJECTS)();
dynamicAttributeFixed->setValue(val);
affector->setDynScaleXYZ(dynamicAttributeFixed);
return true;
}
}
}
else if (prop->name == token[TOKEN_SCALE_X_SCALE])
{
// Property: x_scale
if (passValidateProperty(compiler, prop, token[TOKEN_SCALE_X_SCALE], VAL_REAL))
{
Ogre::Real val = 0.0f;
if(getReal(prop->values.front(), &val))
{
DynamicAttributeFixed* dynamicAttributeFixed = OGRE_NEW_T(DynamicAttributeFixed, Ogre::MEMCATEGORY_SCENE_OBJECTS)();
dynamicAttributeFixed->setValue(val);
affector->setDynScaleX(dynamicAttributeFixed);
return true;
}
}
}
else if (prop->name == token[TOKEN_SCALE_Y_SCALE])
{
// Property: y_scale
if (passValidateProperty(compiler, prop, token[TOKEN_SCALE_Y_SCALE], VAL_REAL))
{
Ogre::Real val = 0.0f;
if(getReal(prop->values.front(), &val))
{
DynamicAttributeFixed* dynamicAttributeFixed = OGRE_NEW_T(DynamicAttributeFixed, Ogre::MEMCATEGORY_SCENE_OBJECTS)();
dynamicAttributeFixed->setValue(val);
affector->setDynScaleY(dynamicAttributeFixed);
return true;
}
}
}
else if (prop->name == token[TOKEN_SCALE_Z_SCALE])
{
// Property: z_scale
if (passValidateProperty(compiler, prop, token[TOKEN_SCALE_Z_SCALE], VAL_REAL))
{
Ogre::Real val = 0.0f;
if(getReal(prop->values.front(), &val))
{
DynamicAttributeFixed* dynamicAttributeFixed = OGRE_NEW_T(DynamicAttributeFixed, Ogre::MEMCATEGORY_SCENE_OBJECTS)();
dynamicAttributeFixed->setValue(val);
affector->setDynScaleZ(dynamicAttributeFixed);
return true;
}
}
}
return false;
}
//-----------------------------------------------------------------------
bool ScaleAffectorTranslator::translateChildObject(Ogre::ScriptCompiler* compiler, const Ogre::AbstractNodePtr &node)
{
Ogre::ObjectAbstractNode* child = reinterpret_cast<Ogre::ObjectAbstractNode*>(node.get());
ParticleAffector* af = Ogre::any_cast<ParticleAffector*>(child->parent->context);
ScaleAffector* affector = static_cast<ScaleAffector*>(af);
DynamicAttributeTranslator dynamicAttributeTranslator;
if (child->cls == token[TOKEN_SCALE_XYZ_SCALE])
{
// Property: xyz_scale
dynamicAttributeTranslator.translate(compiler, node);
DynamicAttribute* dynamicAttribute = Ogre::any_cast<DynamicAttribute*>(child->context);
affector->setDynScaleXYZ(dynamicAttribute);
return true;
}
else if (child->cls == token[TOKEN_SCALE_X_SCALE])
{
// Property: x_scale
dynamicAttributeTranslator.translate(compiler, node);
DynamicAttribute* dynamicAttribute = Ogre::any_cast<DynamicAttribute*>(child->context);
affector->setDynScaleX(dynamicAttribute);
return true;
}
else if (child->cls == token[TOKEN_SCALE_Y_SCALE])
{
// Property: y_scale
dynamicAttributeTranslator.translate(compiler, node);
DynamicAttribute* dynamicAttribute = Ogre::any_cast<DynamicAttribute*>(child->context);
affector->setDynScaleY(dynamicAttribute);
return true;
}
else if (child->cls == token[TOKEN_SCALE_Z_SCALE])
{
// Property: z_scale
dynamicAttributeTranslator.translate(compiler, node);
DynamicAttribute* dynamicAttribute = Ogre::any_cast<DynamicAttribute*>(child->context);
affector->setDynScaleZ(dynamicAttribute);
return true;
}
return false;
}
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
void ScaleAffectorWriter::write(ParticleScriptSerializer* serializer, const IElement* element)
{
// Cast the element to a ScaleAffector
const ScaleAffector* affector = static_cast<const ScaleAffector*>(element);
// Write the header of the ScaleAffector
serializer->writeLine(token[TOKEN_AFFECTOR], affector->getAffectorType(), affector->getName(), 8);
serializer->writeLine("{", 8);
// Write base attributes
ParticleAffectorWriter::write(serializer, element);
// Write own attributes
DynamicAttributeFactory dynamicAttributeFactory;
if (dynamicAttributeFactory._getDefaultValue(affector->getDynScaleXYZ()) != ScaleAffector::DEFAULT_XYZ_SCALE)
{
serializer->setKeyword(token[TOKEN_SCALE_XYZ_SCALE]);
serializer->setIndentation(12);
dynamicAttributeFactory.write(serializer, affector->getDynScaleXYZ());
}
if (dynamicAttributeFactory._getDefaultValue(affector->getDynScaleX()) != ScaleAffector::DEFAULT_X_SCALE)
{
serializer->setKeyword(token[TOKEN_SCALE_X_SCALE]);
dynamicAttributeFactory.write(serializer, affector->getDynScaleX());
}
if (dynamicAttributeFactory._getDefaultValue(affector->getDynScaleY()) != ScaleAffector::DEFAULT_Y_SCALE)
{
serializer->setKeyword(token[TOKEN_SCALE_Y_SCALE]);
dynamicAttributeFactory.write(serializer, affector->getDynScaleY());
}
if (dynamicAttributeFactory._getDefaultValue(affector->getDynScaleZ()) != ScaleAffector::DEFAULT_Z_SCALE)
{
serializer->setKeyword(token[TOKEN_SCALE_Z_SCALE]);
dynamicAttributeFactory.write(serializer, affector->getDynScaleZ());
}
// Write the close bracket
serializer->writeLine("}", 8);
}
}
| [
"[email protected]"
]
| [
[
[
1,
179
]
]
]
|
4398f79e2f3ceae43e28ca9f85477c638c4e54bf | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/_Interface/WndTutorial.h | feb6528cb3dd90060b46e1cc95c703780459824a | []
| no_license | willrebuild/flyffsf | e5911fb412221e00a20a6867fd00c55afca593c7 | d38cc11790480d617b38bb5fc50729d676aef80d | refs/heads/master | 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,046 | h | #ifndef __WNDTUTORIAL__H
#define __WNDTUTORIAL__H
#if __VER >= 12 // __MOD_TUTORIAL
struct TUTORIAL_STRING
{
CString strTitle;
CString strContents;
};
// typedef map<int, TUTORIAL_STRING>::value_type mgValType;
// typedef map<int, TUTORIAL_STRING>::iterator mgMapItor;
class CWndTutorial : public CWndNeuz
{
public:
CString m_strKeyword;
map<int, TUTORIAL_STRING> m_mapTutorial;
CWndTutorial();
~CWndTutorial();
virtual BOOL Initialize( CWndBase* pWndParent = NULL, DWORD nType = MB_OK );
virtual BOOL OnChildNotify( UINT message, UINT nID, LRESULT* pLResult );
virtual void OnDraw( C2DRender* p2DRender );
virtual void OnInitialUpdate();
virtual BOOL OnCommand( UINT nID, DWORD dwMessage, CWndBase* pWndBase );
virtual void OnSize( UINT nType, int cx, int cy );
virtual void OnLButtonUp( UINT nFlags, CPoint point );
virtual void OnLButtonDown( UINT nFlags, CPoint point );
BOOL LoadTutorial(LPCTSTR lpszFileName);
BOOL AddToList(int nIndex);
};
#endif
#endif
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
38
]
]
]
|
1494d747a98ab2ef844dddf998acfc824a0e26b5 | 854ee643a4e4d0b7a202fce237ee76b6930315ec | /arcemu_svn/src/arcemu-shared/WoWGuid.h | 61c878759c6572b2cf68adbbde62bac745ce3fc2 | []
| no_license | miklasiak/projekt | df37fa82cf2d4a91c2073f41609bec8b2f23cf66 | 064402da950555bf88609e98b7256d4dc0af248a | refs/heads/master | 2021-01-01T19:29:49.778109 | 2008-11-10T17:14:14 | 2008-11-10T17:14:14 | 34,016,391 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,859 | h | /*
* ArcEmu MMORPG Server
* Copyright (C) 2008 <http://www.ArcEmu.org/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef _WOWGUID_H
#define _WOWGUID_H
#include "Common.h"
#define BitCount1(x) ((x) & 1)
#define BitCount2(x) ( BitCount1(x) + BitCount1((x)>>1) )
#define BitCount4(x) ( BitCount2(x) + BitCount2((x)>>2) )
#define BitCount8(x) ( BitCount4(x) + BitCount4((x)>>4) )
class SERVER_DECL WoWGuid {
public:
WoWGuid()
{
Clear();
}
WoWGuid(uint64 guid)
{
Clear();
Init((uint64)guid);
}
WoWGuid(uint8 mask)
{
Clear();
Init((uint8)mask);
}
WoWGuid(uint8 mask, uint8 *fields)
{
Clear();
Init(mask, fields);
}
~WoWGuid()
{
Clear();
}
void Clear()
{
oldguid = 0;
guidmask = 0;
*((uint32*)guidfields)=0;
*((uint32*)&guidfields[4])=0;
compiled = false;
fieldcount = 0;
}
void Init(uint64 guid)
{
Clear();
oldguid = guid;
_CompileByOld();
}
void Init(uint8 mask)
{
Clear();
guidmask = mask;
if (!guidmask)
_CompileByNew();
}
void Init(uint8 mask, uint8 *fields)
{
Clear();
guidmask = mask;
if (!BitCount8(guidmask))
return;
for(int i = 0; i < BitCount8(guidmask); i++)
guidfields[i] = (fields[i]);
fieldcount = BitCount8(guidmask);
_CompileByNew();
}
const uint64 GetOldGuid() const { return oldguid; }
const uint8* GetNewGuid() const { return guidfields; }
const uint8 GetNewGuidLen() const { return BitCount8(guidmask); }
const uint8 GetNewGuidMask() const { return guidmask; }
void AppendField(uint8 field)
{
ASSERT(!compiled);
ASSERT(fieldcount < BitCount8(guidmask));
guidfields[fieldcount++] = field;
if (fieldcount == BitCount8(guidmask))
_CompileByNew();
}
private:
uint64 oldguid;
uint8 guidmask;
uint8 guidfields[8];
uint8 fieldcount;
bool compiled;
void _CompileByOld()
{
#ifdef USING_BIG_ENDIAN
uint64 t = swap64(oldguid);
#endif
ASSERT(!compiled);
fieldcount = 0;
for(uint32 x=0;x<8;x++)
{
#ifdef USING_BIG_ENDIAN
uint8 p = ((uint8*)&t)[x];
#else
uint8 p =((uint8*)&oldguid)[x];
#endif
if(p)
{
guidfields[fieldcount++]=p;
guidmask|=1<<x;
}
}
compiled = true;
}
void _CompileByNew()
{
ASSERT(!compiled || fieldcount == BitCount8(guidmask));
int j = 0;
if (guidmask & 0x01) //1
{
oldguid |= ((uint64)guidfields[j]);
j++;
}
if (guidmask & 0x02) //2
{
oldguid |= ((uint64)guidfields[j] << 8);
j++;
}
if (guidmask & 0x04)//4
{
oldguid |= ((uint64)guidfields[j] << 16);
j++;
}
if (guidmask & 0x08) //8
{
oldguid |= ((uint64)guidfields[j] << 24);
j++;
}
if (guidmask & 0x10)//16
{
oldguid |= ((uint64)guidfields[j] << 32);
j++;
}
if (guidmask & 0x20)//32
{
oldguid |= ((uint64)guidfields[j] << 40);
j++;
}
if (guidmask & 0x40)//64
{
oldguid |= ((uint64)guidfields[j] << 48);
j++;
}
if (guidmask & 0x80) //128
{
oldguid |= ((uint64)guidfields[j] << 56);
j++;
}
compiled = true;
}
};
#endif
| [
"[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef",
"[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef"
]
| [
[
[
1,
1
],
[
4,
208
]
],
[
[
2,
3
]
]
]
|
176941c50b62fce85031786b1df7fa37da26b13c | 82dd2bf8f3b6755248a7c461acd3664bf85a8ec5 | / zhndocument/网络编程/IOCP/IOCP Framework by rtybase/LikeJavaThreads_src/LikeJavaThreads_src/Threading/INCLUDE/log.h | 94cf486ec4185d15398bba02bdb049021266df43 | []
| no_license | emuikernel/zhndocument | 1343d2d3ca0deeeaf4cc900be3121f4cef853746 | 3d33c302454b159087c28c597f93e609f5752049 | refs/heads/master | 2021-01-10T12:35:27.173949 | 2011-08-07T16:02:15 | 2011-08-07T16:02:15 | 49,942,349 | 0 | 1 | null | null | null | null | GB18030 | C++ | false | false | 1,650 | h | #ifndef ___LOG_H_INCLUDED___
#define ___LOG_H_INCLUDED___
#include "INCLUDE/sync_simple.h"
//---------------------------- CLASS -------------------------------------------------------------
class Log {
private:
static QMutex m_qMutex;
public:
static void LogMessage(const wchar_t *str);
static void LogMessage(const wchar_t *str, long num);
static void LogMessage(const wchar_t *str, long num1, long num2);
static void LogMessage(const wchar_t *str, long num, wchar_t *str1);
static void LogMessage(const wchar_t *str, wchar_t *str1);
static void LogMessage(const wchar_t *str, wchar_t *str1, wchar_t *str2);
};
//---------------------------- IMPLEMENTATION ----------------------------------------------------
//静态成员变量的初始化
QMutex Log::m_qMutex;
void Log::LogMessage(const wchar_t *str, long num1, long num2)
{
m_qMutex.Lock();
fwprintf(stderr, str, num1, num2);
m_qMutex.Unlock();
}
void Log::LogMessage(const wchar_t *str, long num, wchar_t *str1)
{
m_qMutex.Lock();
fwprintf(stderr, str, num, str1);
m_qMutex.Unlock();
}
void Log::LogMessage(const wchar_t *str, wchar_t *str1, wchar_t *str2)
{
m_qMutex.Lock();
fwprintf(stderr, str, str1, str2);
m_qMutex.Unlock();
}
void Log::LogMessage(const wchar_t *str, wchar_t *str1)
{
m_qMutex.Lock();
fwprintf(stderr, str, str1);
m_qMutex.Unlock();
}
void Log::LogMessage(const wchar_t *str, long num)
{
m_qMutex.Lock();
fwprintf(stderr, str, num);
m_qMutex.Unlock();
}
void Log::LogMessage(const wchar_t *str)
{
m_qMutex.Lock();
fwprintf(stderr,str);
m_qMutex.Unlock();
}
#endif | [
"zhangnian88123@4293da22-f94a-ef5d-2b64-63c050326dd1"
]
| [
[
[
1,
66
]
]
]
|
5530bae11b7ff6fd8deb16d54578fa52a7553f6a | 33f59b1ba6b12c2dd3080b24830331c37bba9fe2 | /Depend/Foundation/ImageAnalysis/Wm4ImageConvert.cpp | ca79491ef6bb86fda3277c0f4801e60b68a454e6 | []
| 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 | 8,514 | cpp | // 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.
#include "Wm4FoundationPCH.h"
#include "Wm4Element.h"
#include "Wm4ImageConvert.h"
using namespace Wm4;
//----------------------------------------------------------------------------
#define CONVERTER(SrcType,TrgType) \
static void SrcType##To##TrgType (int iQuantity, void* pvSrc, void* pvTrg) \
{ \
SrcType* ptSrc = (SrcType*)pvSrc; \
TrgType* ptTrg = (TrgType*)pvTrg; \
for (int i = 0; i < iQuantity; i++, ptSrc++, ptTrg++) \
{ \
*ptTrg = (TrgType)(*ptSrc); \
} \
}
//----------------------------------------------------------------------------
CONVERTER(char,uchar)
CONVERTER(char,short)
CONVERTER(char,ushort)
CONVERTER(char,int)
CONVERTER(char,uint)
CONVERTER(char,long)
CONVERTER(char,ulong)
CONVERTER(char,float)
CONVERTER(char,double)
CONVERTER(char,rgb5)
CONVERTER(char,rgb8)
CONVERTER(uchar,char)
CONVERTER(uchar,short)
CONVERTER(uchar,ushort)
CONVERTER(uchar,int)
CONVERTER(uchar,uint)
CONVERTER(uchar,long)
CONVERTER(uchar,ulong)
CONVERTER(uchar,float)
CONVERTER(uchar,double)
CONVERTER(uchar,rgb5)
CONVERTER(uchar,rgb8)
CONVERTER(short,char)
CONVERTER(short,uchar)
CONVERTER(short,ushort)
CONVERTER(short,int)
CONVERTER(short,uint)
CONVERTER(short,long)
CONVERTER(short,ulong)
CONVERTER(short,float)
CONVERTER(short,double)
CONVERTER(short,rgb5)
CONVERTER(short,rgb8)
CONVERTER(ushort,char)
CONVERTER(ushort,uchar)
CONVERTER(ushort,short)
CONVERTER(ushort,int)
CONVERTER(ushort,uint)
CONVERTER(ushort,long)
CONVERTER(ushort,ulong)
CONVERTER(ushort,float)
CONVERTER(ushort,double)
CONVERTER(ushort,rgb5)
CONVERTER(ushort,rgb8)
CONVERTER(int,char)
CONVERTER(int,uchar)
CONVERTER(int,short)
CONVERTER(int,ushort)
CONVERTER(int,uint)
CONVERTER(int,long)
CONVERTER(int,ulong)
CONVERTER(int,float)
CONVERTER(int,double)
CONVERTER(int,rgb5)
CONVERTER(int,rgb8)
CONVERTER(uint,char)
CONVERTER(uint,uchar)
CONVERTER(uint,short)
CONVERTER(uint,ushort)
CONVERTER(uint,int)
CONVERTER(uint,long)
CONVERTER(uint,ulong)
CONVERTER(uint,float)
CONVERTER(uint,double)
CONVERTER(uint,rgb5)
CONVERTER(uint,rgb8)
CONVERTER(long,char)
CONVERTER(long,uchar)
CONVERTER(long,short)
CONVERTER(long,ushort)
CONVERTER(long,int)
CONVERTER(long,uint)
CONVERTER(long,ulong)
CONVERTER(long,float)
CONVERTER(long,double)
CONVERTER(long,rgb5)
CONVERTER(long,rgb8)
CONVERTER(ulong,char)
CONVERTER(ulong,uchar)
CONVERTER(ulong,short)
CONVERTER(ulong,ushort)
CONVERTER(ulong,int)
CONVERTER(ulong,uint)
CONVERTER(ulong,long)
CONVERTER(ulong,float)
CONVERTER(ulong,double)
CONVERTER(ulong,rgb5)
CONVERTER(ulong,rgb8)
CONVERTER(float,char)
CONVERTER(float,uchar)
CONVERTER(float,short)
CONVERTER(float,ushort)
CONVERTER(float,int)
CONVERTER(float,uint)
CONVERTER(float,long)
CONVERTER(float,ulong)
CONVERTER(float,double)
CONVERTER(float,rgb5)
CONVERTER(float,rgb8)
CONVERTER(double,char)
CONVERTER(double,uchar)
CONVERTER(double,short)
CONVERTER(double,ushort)
CONVERTER(double,int)
CONVERTER(double,uint)
CONVERTER(double,long)
CONVERTER(double,ulong)
CONVERTER(double,float)
CONVERTER(double,rgb5)
CONVERTER(double,rgb8)
CONVERTER(rgb5,char)
CONVERTER(rgb5,uchar)
CONVERTER(rgb5,short)
CONVERTER(rgb5,ushort)
CONVERTER(rgb5,int)
CONVERTER(rgb5,uint)
CONVERTER(rgb5,long)
CONVERTER(rgb5,ulong)
CONVERTER(rgb5,float)
CONVERTER(rgb5,double)
CONVERTER(rgb5,rgb8)
CONVERTER(rgb8,char)
CONVERTER(rgb8,uchar)
CONVERTER(rgb8,short)
CONVERTER(rgb8,ushort)
CONVERTER(rgb8,int)
CONVERTER(rgb8,uint)
CONVERTER(rgb8,long)
CONVERTER(rgb8,ulong)
CONVERTER(rgb8,float)
CONVERTER(rgb8,double)
CONVERTER(rgb8,rgb5)
//----------------------------------------------------------------------------
#define ENTRY(SrcType,TrgType) SrcType##To##TrgType
//----------------------------------------------------------------------------
typedef void (*Converter)(int,void*,void*);
static Converter gs_aaoConvert[WM4_ELEMENT_QUANTITY][WM4_ELEMENT_QUANTITY] =
{
{ 0,
ENTRY(char,uchar),
ENTRY(char,short),
ENTRY(char,ushort),
ENTRY(char,int),
ENTRY(char,uint),
ENTRY(char,long),
ENTRY(char,ulong),
ENTRY(char,float),
ENTRY(char,double),
ENTRY(char,rgb5),
ENTRY(char,rgb8) },
{ ENTRY(uchar,char),
0,
ENTRY(uchar,short),
ENTRY(uchar,ushort),
ENTRY(uchar,int),
ENTRY(uchar,uint),
ENTRY(uchar,long),
ENTRY(uchar,ulong),
ENTRY(uchar,float),
ENTRY(uchar,double),
ENTRY(uchar,rgb5),
ENTRY(uchar,rgb8) },
{ ENTRY(short,char),
ENTRY(short,uchar),
0,
ENTRY(short,ushort),
ENTRY(short,int),
ENTRY(short,uint),
ENTRY(short,long),
ENTRY(short,ulong),
ENTRY(short,float),
ENTRY(short,double),
ENTRY(short,rgb5),
ENTRY(short,rgb8) },
{ ENTRY(ushort,char),
ENTRY(ushort,uchar),
ENTRY(ushort,short),
0,
ENTRY(ushort,int),
ENTRY(ushort,uint),
ENTRY(ushort,long),
ENTRY(ushort,ulong),
ENTRY(ushort,float),
ENTRY(ushort,double),
ENTRY(ushort,rgb5),
ENTRY(ushort,rgb8) },
{ ENTRY(int,char),
ENTRY(int,uchar),
ENTRY(int,short),
ENTRY(int,ushort),
0,
ENTRY(int,uint),
ENTRY(int,long),
ENTRY(int,ulong),
ENTRY(int,float),
ENTRY(int,double),
ENTRY(int,rgb5),
ENTRY(int,rgb8) },
{ ENTRY(uint,char),
ENTRY(uint,uchar),
ENTRY(uint,short),
ENTRY(uint,ushort),
ENTRY(uint,int),
0,
ENTRY(uint,long),
ENTRY(uint,ulong),
ENTRY(uint,float),
ENTRY(uint,double),
ENTRY(uint,rgb5),
ENTRY(uint,rgb8) },
{ ENTRY(long,char),
ENTRY(long,uchar),
ENTRY(long,short),
ENTRY(long,ushort),
ENTRY(long,int),
ENTRY(long,uint),
0,
ENTRY(long,ulong),
ENTRY(long,float),
ENTRY(long,double),
ENTRY(long,rgb5),
ENTRY(long,rgb8) },
{ ENTRY(ulong,char),
ENTRY(ulong,uchar),
ENTRY(ulong,short),
ENTRY(ulong,ushort),
ENTRY(ulong,int),
ENTRY(ulong,uint),
ENTRY(ulong,long),
0,
ENTRY(ulong,float),
ENTRY(ulong,double),
ENTRY(ulong,rgb5),
ENTRY(ulong,rgb8) },
{ ENTRY(float,char),
ENTRY(float,uchar),
ENTRY(float,short),
ENTRY(float,ushort),
ENTRY(float,int),
ENTRY(float,uint),
ENTRY(float,long),
ENTRY(float,ulong),
0,
ENTRY(float,double),
ENTRY(float,rgb5),
ENTRY(float,rgb8) },
{ ENTRY(double,char),
ENTRY(double,uchar),
ENTRY(double,short),
ENTRY(double,ushort),
ENTRY(double,int),
ENTRY(double,uint),
ENTRY(double,long),
ENTRY(double,ulong),
ENTRY(double,float),
0,
ENTRY(double,rgb5),
ENTRY(double,rgb8) },
{ ENTRY(rgb5,char),
ENTRY(rgb5,uchar),
ENTRY(rgb5,short),
ENTRY(rgb5,ushort),
ENTRY(rgb5,int),
ENTRY(rgb5,uint),
ENTRY(rgb5,long),
ENTRY(rgb5,ulong),
ENTRY(rgb5,float),
ENTRY(rgb5,double),
0,
ENTRY(rgb5,rgb8) },
{ ENTRY(rgb8,char),
ENTRY(rgb8,uchar),
ENTRY(rgb8,short),
ENTRY(rgb8,ushort),
ENTRY(rgb8,int),
ENTRY(rgb8,uint),
ENTRY(rgb8,long),
ENTRY(rgb8,ulong),
ENTRY(rgb8,float),
ENTRY(rgb8,double),
ENTRY(rgb8,rgb5),
0 }
};
//----------------------------------------------------------------------------
void Wm4::ImageConvert (int iQuantity, int iSrcRTTI, void* pvSrcData,
int iTrgRTTI, void* pvTrgData)
{
assert(iSrcRTTI < WM4_ELEMENT_QUANTITY
&& iTrgRTTI < WM4_ELEMENT_QUANTITY);
Converter oConverter = gs_aaoConvert[iSrcRTTI][iTrgRTTI];
oConverter(iQuantity,pvSrcData,pvTrgData);
}
//----------------------------------------------------------------------------
| [
"yf.flagship@e79fdf7c-a9d8-11de-b950-3d5b5f4ea0aa"
]
| [
[
[
1,
343
]
]
]
|
5e0674b52d91ba093072858a2a9a3d590dec6e19 | 448ef6f020ff51ef3c4266e2504a49e18c032d04 | /CppTest/CppTest/AsClassA.cpp | 53f48f54c624bf1c9d302a8a95154d304c38560a | []
| no_license | weeeBox/oldies-cpp-template | f0990a1832e0f441db8523932a19a6addf16d620 | 00223721d33f95b396dc698a5596199224291e8b | refs/heads/master | 2020-05-20T07:33:33.792823 | 2011-12-09T16:45:10 | 2011-12-09T16:45:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 795 | cpp | #include "AsClassA.h"
#include "AsClassA.h"
#include "AsClassB.h"
AsClassA_ref AsClassA::__createAsClassA()
{
AsClassA_ref __reference(new AsClassA());
return __reference;
}
void AsClassA::__internalInitialiseAsClassA()
{
}
StaticInit AsClassA::__internalStaticInitializerAsClassA(&AsClassA::__internalStaticInit);
BOOL AsClassA::__internalStaticInitializedAsClassA = false;
void AsClassA::__internalStaticInit()
{
if (!__internalStaticInitializedAsClassA)
{
__internalStaticInitializedAsClassA = true;
AsBaseClass::__internalStaticInit();
}
}
AsClassA::AsClassA() :
classB(false)
{
}
void AsClassA::__internalGc()
{
if(__internalGcNeeded())
{
AsBaseClass::__internalGc();
if (classB != __NULL) classB->__internalGc();
}
}
| [
"[email protected]@29e91505-0bf5-f861-a13c-499aeb2b9760"
]
| [
[
[
1,
40
]
]
]
|
9aaa08c224a37b716becaf3e534c5473efb7a5a0 | 4b116281b895732989336f45dc65e95deb69917b | /Documentation/Design Patterns/Factory/Factory/Thief.cpp | bc54ad861d6b092a4c066333730657dea4a9f15a | []
| no_license | Pavani565/gsp410-spaceshooter | 1f192ca16b41e8afdcc25645f950508a6f9a92c6 | c299b03d285e676874f72aa062d76b186918b146 | refs/heads/master | 2021-01-10T00:59:18.499288 | 2011-12-12T16:59:51 | 2011-12-12T16:59:51 | 33,170,205 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 98 | cpp | #include "StdAfx.h"
#include "Thief.h"
Thief::Thief(void)
{
}
Thief::~Thief(void)
{
}
| [
"[email protected]@7eab73fc-b600-5548-9ef9-911d97763ba7"
]
| [
[
[
1,
10
]
]
]
|
24c106844a78a19d74eb86a507a20b44a8f8ded0 | f744f8897adce6654cdfe6466eaf4d0fad4ba661 | /src/loaders/TerrainModelLoader.cpp | 3f9b4f08503d2fd8e27c1730970d8abba9469445 | []
| no_license | pizibing/bones-animation | 37919ab3750683a5da0cc849f80d1e0f5b37c89c | 92ce438e28e3020c0e8987299c11c4b74ff98ed5 | refs/heads/master | 2016-08-03T05:34:19.294712 | 2009-09-16T14:59:32 | 2009-09-16T14:59:32 | 33,969,248 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,741 | cpp | #include "imageloader.h"
#include "TerrainModelLoader.h"
#include "../data/VBOMesh.h"
#include "../data/VBOObject.h"
#include "../data/terrain/TerrainObject.h"
#include "../managers/ObjectManager.h"
#include "../managers/TextureManager.h"
// define the scale from file read height to real display height
const float HEIGHT_SCALE = 0.015;
// define stride
const float STRIDE = 0.5;
// constructor
TerrainModelLoader::TerrainModelLoader(void){
}
// destructor
TerrainModelLoader::~TerrainModelLoader(void){
}
/*
* para: path: load a model with the given path
* kind: specifies the role of the model in the entire world(e.g terrain,character etc.)
* function: load the model with the given path and set it in the ObjectManager
* return: true when model is successfully loaded, vice versa
*/
bool TerrainModelLoader::loadModel(int kind, const char* path){
// load height information from image file
Image* image = loadBMP(path);
float* pHeightMap = new float[image->height * image->width];
for(int i = 0; i < image->height * image->width; i++){
pHeightMap[i] = ((float)((unsigned char)image->pixels[3*i])) * HEIGHT_SCALE;
/*if(pHeightMap[i] < 0)
int S = 4;*/
}
// create a new TerrainObject
TerrainObject* terrain = new TerrainObject(image->width, image->height, STRIDE);
// set texture
GLuint tex = TextureManager::getInstance()->getTextureId("resource/Textures/terrain.bmp");
terrain->setTexId(tex);
// set height map
terrain->setHeightMap(pHeightMap);
// set materail
//terrain->setMaterail(SOIL_TERRAIN);
// get ObjectManager
ObjectManager* om = ObjectManager::getInstance();
// add terrain into ObjectManager
om->addVBOObject(terrain);
return true;
}
| [
"[email protected]"
]
| [
[
[
1,
52
]
]
]
|
1ad65f3c0f549b2a66d36561f8effe31e6962bea | 8fb9ccf49a324a586256bb08c22edc92e23affcf | /src/Engine/LfoHandler.h | 96c4cfc05db2c94dbf52cc49521cfd35927d9754 | []
| no_license | eriser/tal-noisemak3r | 76468c98db61dfa28315284b4a5b1acfeb9c1ff6 | 1043c8f237741ea7beb89b5bd26243f8891cb037 | refs/heads/master | 2021-01-18T18:29:56.446225 | 2010-08-05T20:51:35 | 2010-08-05T20:51:35 | 62,891,642 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,224 | h | /*
==============================================================================
This file is part of Tal-NoiseMaker by Patrick Kunz.
Copyright(c) 2005-2010 Patrick Kunz, TAL
Togu Audio Line, Inc.
http://kunz.corrupt.ch
This file may be licensed under the terms of of the
GNU General Public License Version 2 (the ``GPL'').
Software distributed under the License is distributed
on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
express or implied. See the GPL for the specific language
governing rights and limitations.
You should have received a copy of the GPL along with this
program. If not, go to http://www.gnu.org/licenses/gpl.html
or write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
==============================================================================
*/
#ifndef LfoHandler_H
#define LfoHandler_H
#include "LfoHandler.h"
#include "Lfo.h"
#include "Math.h"
#include "AudioUtils.h"
class LfoHandler
{
public:
enum Waveform
{
SIN,
TRIANGLE,
SAW,
RECTANGE,
RANDOMSTEP,
RANDOM
};
private:
Lfo *lfo;
Waveform waveform;
bool keyTrigger;
float currentRateHz;
float currentPhase;
AudioUtils audioUtils;
public:
float value;
float amount;
float amountPositive;
bool isSync;
LfoHandler(float sampleRate)
{
lfo = new Lfo(sampleRate);
waveform = SIN;
value = 0.0f;
amount = 1.0f;
keyTrigger = false;
isSync = false;
currentRateHz = 1.0f;
currentPhase = 0.0f;
}
~LfoHandler()
{
}
void setWaveform(float waveform)
{
int waveformInt = (int)(waveform * 5.000001f);
switch (waveformInt)
{
case SIN: this->setWaveform(SIN); break;
case TRIANGLE: this->setWaveform(TRIANGLE); break;
case SAW: this->setWaveform(SAW); break;
case RECTANGE: this->setWaveform(RECTANGE); break;
case RANDOMSTEP: this->setWaveform(RANDOMSTEP); break;
case RANDOM: this->setWaveform(RANDOM); break;
}
}
void setWaveform(const Waveform waveform)
{
this->waveform = waveform;
}
// modulator [-1..1]
inline void setRateMultiplier(float modulator)
{
if (modulator < 0.0f)
{
this->lfo->setRate(currentRateHz * (1.0f + modulator * 0.01f));
}
else
{
this->lfo->setRate(currentRateHz * (1.0f + modulator * 100.0f));
}
}
void setRate(float rateIn, const float bpm)
{
if (!isSync)
{
currentRateHz = audioUtils.getLogScaledRate(rateIn);
this->lfo->setRate(currentRateHz);
}
else
{
audioUtils.getSyncedRateAndGetText(&rateIn, bpm);
currentRateHz = rateIn;
this->lfo->setRate(rateIn);
}
}
void setAmount(const float amount)
{
this->amount = amount;
this->amountPositive = fabs(amount);
}
void setPhase(float phase)
{
this->currentPhase = phase;
}
void triggerPhase()
{
if (keyTrigger)
{
this->lfo->resetPhase();
this->lfo->phase = currentPhase * 255.0f;
}
}
// Phase [0..1]
void setHostPhase(const float phase)
{
if (!keyTrigger)
{
this->lfo->phase = 255.0f * (phase + currentPhase);
}
}
void setKeyTrigger(bool value)
{
this->keyTrigger = value;
}
void setSync(bool value, float rateIn, const float bpm)
{
this->isSync = value;
this->setRate(rateIn, bpm);
}
inline float getValue()
{
return value;
}
inline float getAmount()
{
return amount;
}
inline float process()
{
return value = lfo->tick(this->waveform);
}
inline float getLfoInc()
{
return lfo->inc;
}
};
#endif | [
"patrickkunzch@1672e8fc-9579-4a43-9460-95afed9bdb0b"
]
| [
[
[
1,
183
]
]
]
|
cdad69a69845d965db8602c75ad4ed13f27b3b7d | c3efe4021165e718d23ce0f853808e10c7114216 | /Rainman2/inifile.cpp | 48976b6f60c067023539dd108748fdff782dd560 | []
| no_license | lkdd/modstudio2 | 254b47ebd28a51a7d8c8682a86c576dafcc971bf | 287b4782580e37c8ac621046100dc550abd05b1d | refs/heads/master | 2021-01-10T08:14:56.230097 | 2009-03-08T19:14:16 | 2009-03-08T19:14:16 | 52,721,924 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,521 | cpp | /*
Copyright (c) 2008 Peter "Corsix" Cawley
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
#include "inifile.h"
#include "exception.h"
#include "buffering_streams.h"
template <class T, T* T::* pPrev, T* T::* pNext>
struct DLinkList
{
typedef DLinkList<T, pNext, pPrev> reversed;
static T* erase(T* p)
{
if(p->*pPrev)
p->*pPrev->*pNext = p->*pNext;
if(p->*pNext)
p->*pNext->*pPrev = p->*pPrev;
p->*pPrev = 0;
p->*pNext = 0;
return p;
}
static T* append(T* existing, T* p)
{
p->*pPrev = existing;
p->*pNext = 0;
if(existing)
{
if(existing->*pNext)
{
p->*pNext = existing->*pNext;
p->*pNext->*pPrev = p;
}
existing->*pNext = p;
}
return p;
}
static T* append_end(T* list, T* p)
{
return append(last(list), p);
}
static T* prepend(T* existing, T* p)
{
return reversed::append(existing, p);
}
static T* prepend_start(T* existing, T* p)
{
return reversed::append_end(existing, p);
}
static T* last(T* list)
{
if(list)
{
for(T* next; (next = list->*pNext); list = next)
{
}
}
return list;
}
static T* first(T* list)
{
return reversed::first(list);
}
template <class A>
static T* find_forward(T* list, const A& what)
{
for(; list; = list = list->*pNext)
{
if(*list == what)
return list;
}
return 0;
}
template <class A>
static T* find_backward(T* list, const A& what)
{
return reversed::find_forward<A>(list, what);
}
};
#define DLinkList_Section DLinkList<IniFile::Section , &IniFile::Section ::m_pPrev , &IniFile::Section ::m_pNext >
#define DLinkList_SectionTwin DLinkList<IniFile::Section , &IniFile::Section ::m_pPrevTwin, &IniFile::Section ::m_pNextTwin>
#define DLinkList_Value DLinkList<IniFile::Section::Value, &IniFile::Section::Value::m_pPrev , &IniFile::Section::Value::m_pNext >
#define DLinkList_ValueTwin DLinkList<IniFile::Section::Value, &IniFile::Section::Value::m_pPrevTwin, &IniFile::Section::Value::m_pNextTwin>
IniFile::IniFile()
{
m_pFirstSection = 0;
m_pLastSection = 0;
m_cCommentCharacter = ';';
m_cAssignmentCharacter = '=';
m_cSectionStartCharacter = '[';
m_cSectionEndCharacter = ']';
m_oEmptySection.m_pFile = this;
}
IniFile::~IniFile()
{
clear();
}
IniFile::iterator::iterator() throw()
{
m_pSection = 0;
m_pPrev = 0;
m_pNext = 0;
}
IniFile::Section::iterator::iterator() throw()
{
m_pValue = 0;
m_pPrev = 0;
m_pNext = 0;
}
IniFile::iterator::iterator(const IniFile::iterator& other) throw()
{
m_pSection = other.m_pSection;
m_pPrev = other.m_pPrev;
m_pNext = other.m_pNext;
}
IniFile::Section::iterator::iterator(const IniFile::Section::iterator& other) throw()
{
m_pValue = other.m_pValue;
m_pPrev = other.m_pPrev;
m_pNext = other.m_pNext;
}
IniFile::iterator::iterator(IniFile::iterator::value_type* pSection, IniFile::iterator::value_type* IniFile::iterator::value_type::* pPrev, IniFile::iterator::value_type* IniFile::iterator::value_type::* pNext) throw()
{
m_pSection = pSection;
m_pPrev = pPrev;
m_pNext = pNext;
}
IniFile::Section::iterator::iterator(IniFile::Section::iterator::value_type* pValue, IniFile::Section::iterator::value_type* IniFile::Section::iterator::value_type::* pPrev, IniFile::Section::iterator::value_type* IniFile::Section::iterator::value_type::* pNext) throw()
{
m_pValue = pValue;
m_pPrev = pPrev;
m_pNext = pNext;
}
IniFile::iterator& IniFile::iterator::operator =(const IniFile::iterator& other) throw()
{
m_pSection = other.m_pSection;
m_pPrev = other.m_pPrev;
m_pNext = other.m_pNext;
return *this;
}
IniFile::Section::iterator& IniFile::Section::iterator::operator =(const IniFile::Section::iterator& other) throw()
{
m_pValue = other.m_pValue;
m_pPrev = other.m_pPrev;
m_pNext = other.m_pNext;
return *this;
}
IniFile::iterator& IniFile::iterator::operator ++() throw()
{
m_pSection = m_pSection->*m_pNext;
return *this;
}
IniFile::Section::iterator& IniFile::Section::iterator::operator ++() throw()
{
m_pValue = m_pValue->*m_pNext;
return *this;
}
IniFile::iterator& IniFile::iterator::operator --() throw()
{
m_pSection = m_pSection->*m_pPrev;
return *this;
}
IniFile::Section::iterator& IniFile::Section::iterator::operator --() throw()
{
m_pValue = m_pValue->*m_pPrev;
return *this;
}
bool IniFile::iterator::operator ==(const IniFile::iterator& other) const throw()
{
return m_pSection == other.m_pSection;
}
bool IniFile::Section::iterator::operator ==(const IniFile::Section::iterator& other) const throw()
{
return m_pValue == other.m_pValue;
}
bool IniFile::iterator::operator !=(const IniFile::iterator& other) const throw()
{
return m_pSection != other.m_pSection;
}
bool IniFile::Section::iterator::operator !=(const IniFile::Section::iterator& other) const throw()
{
return m_pValue != other.m_pValue;
}
IniFile::iterator::reference IniFile::iterator::operator *() throw()
{
return *m_pSection;
}
IniFile::Section::iterator::reference IniFile::Section::iterator::operator *() throw()
{
return *m_pValue;
}
IniFile::iterator::pointer IniFile::iterator::operator ->() throw()
{
return m_pSection;
}
IniFile::Section::iterator::pointer IniFile::Section::iterator::operator ->() throw()
{
return m_pValue;
}
IniFile::iterator IniFile::begin() throw()
{
return iterator(m_pFirstSection, &Section::m_pPrev, &Section::m_pNext);
}
IniFile::Section::iterator IniFile::Section::begin() throw()
{
return iterator(m_pFirstValue, &Value::m_pPrev, &Value::m_pNext);
}
IniFile::iterator IniFile::begin(RainString sSectionName) throw()
{
map_type::iterator itr = m_mapSections.find(sSectionName);
if(itr == m_mapSections.end())
return end();
else
return iterator(itr->second, &Section::m_pPrevTwin, &Section::m_pNextTwin);
}
IniFile::Section::iterator IniFile::Section::begin(RainString sValueName) throw()
{
map_type::iterator itr = m_mapValues.find(sValueName);
if(itr == m_mapValues.end())
return end();
else
return iterator(itr->second, &Value::m_pPrevTwin, &Value::m_pNextTwin);
}
IniFile::iterator IniFile::end() throw()
{
return iterator(0, 0, 0);
}
IniFile::Section::iterator IniFile::Section::end() throw()
{
return iterator(0, 0, 0);
}
void IniFile::setSpecialCharacters(RainChar cCommentMarker, RainChar cNameValueDelimiter, RainChar cSectionStarter, RainChar cSectionFinisher) throw()
{
m_cCommentCharacter = cCommentMarker;
m_cAssignmentCharacter = cNameValueDelimiter;
m_cSectionStartCharacter = cSectionStarter;
m_cSectionEndCharacter = cSectionFinisher;
}
void IniFile::clear() throw()
{
m_sComment = "";
m_mapSections.clear();
while(m_pFirstSection)
delete m_pFirstSection;
}
IniFile::Section& IniFile::operator[](const RainString& sSection)
{
map_type::iterator itr = m_mapSections.find(sSection);
if(itr == m_mapSections.end())
{
return appendSection(sSection);
}
else
{
return *itr->second;
}
}
const IniFile::Section& IniFile::operator[](const RainString& sSection) const
{
map_type::const_iterator itr = m_mapSections.find(sSection);
if(itr == m_mapSections.end())
{
return m_oEmptySection;
}
else
{
return *itr->second;
}
}
IniFile::Section::Section()
{
m_pFirstValue = 0;
m_pLastValue = 0;
m_pPrev = 0;
m_pNext = 0;
m_pPrevTwin = 0;
m_pNextTwin = 0;
m_pFile = 0;
m_oEmptyValue.m_pSection = this;
}
bool IniFile::Section::empty() const throw()
{
return m_pFirstValue == 0;
}
void IniFile::Section::clear() throw()
{
while(m_pFirstValue)
delete m_pFirstValue;
}
IniFile* IniFile::Section::getFile() const throw()
{
return m_pFile;
}
IniFile::Section::~Section()
{
clear();
if(m_pFile)
{
if(m_pFile->m_pFirstSection == this)
m_pFile->m_pFirstSection = m_pNext;
if(m_pFile->m_pLastSection == this)
m_pFile->m_pLastSection = m_pPrev;
if(m_pFile->m_mapSections[m_sName] == this)
{
if(m_pNextTwin)
m_pFile->m_mapSections[m_sName] = m_pNextTwin;
else
m_pFile->m_mapSections.erase(m_sName);
}
}
DLinkList_Section::erase(this);
DLinkList_SectionTwin::erase(this);
}
IniFile::Section::Value& IniFile::Section::operator[](const RainString& sKey)
{
map_type::iterator itr = m_mapValues.find(sKey);
if(itr == m_mapValues.end())
{
return appendValue(sKey, RainString());
}
else
{
return *itr->second;
}
}
const IniFile::Section::Value& IniFile::Section::operator[](const RainString& sKey) const
{
map_type::const_iterator itr = m_mapValues.find(sKey);
if(itr == m_mapValues.end())
{
return m_oEmptyValue;
}
else
{
return *itr->second;
}
}
bool IniFile::Section::hasValue(const RainString& sKey, bool bReturnValueOnBlank) const
{
map_type::const_iterator itr = m_mapValues.find(sKey);
if(itr == m_mapValues.end())
{
return false;
}
else if(bReturnValueOnBlank)
{
return true;
}
else
{
return !itr->second->value().isEmpty();
}
}
IniFile::Section::Value::Value()
{
m_pPrev = 0;
m_pNext = 0;
m_pPrevTwin = 0;
m_pNextTwin = 0;
m_pSection = 0;
}
IniFile::Section::Value::~Value()
{
if(m_pSection)
{
if(m_pSection->m_pFirstValue == this)
m_pSection->m_pFirstValue = m_pNext;
if(m_pSection->m_pLastValue == this)
m_pSection->m_pLastValue = m_pPrev;
if(m_pSection->m_mapValues[m_sKey] == this)
{
if(m_pNextTwin)
m_pSection->m_mapValues[m_sKey] = m_pNextTwin;
else
m_pSection->m_mapValues.erase(m_sKey);
}
}
DLinkList_Value::erase(this);
DLinkList_ValueTwin::erase(this);
}
static bool iswhite(RainChar c)
{
return c == ' ' || c == '\n' || c == '\t' || c == '\r';
}
void IniFile::load(IFile* pFile) throw(...)
{
clear();
RainString *pLastComment = &m_sComment;
Section *pLastSection = 0;
Section::Value *pLastValue = 0;
BufferingInputTextStream<char> oFile(pFile);
do
{
RainString sLine = oFile.readLine();
RainString sComment;
size_t iCommentBegin = sLine.indexOf(m_cCommentCharacter, 0, sLine.length());
for(; iCommentBegin > 0 && iswhite(sLine.getCharacters()[iCommentBegin - 1]); --iCommentBegin)
{
}
if(iCommentBegin == 0)
{
pLastComment->append(sLine);
}
else
{
sComment = sLine.mid(iCommentBegin, sLine.length() - iCommentBegin);
size_t iPrefixLength = 0;
for(; iswhite(sLine.getCharacters()[iPrefixLength]); ++iPrefixLength)
{
}
if(iPrefixLength != 0)
{
pLastComment->append(sLine.getCharacters(), iPrefixLength);
}
if(iPrefixLength != sLine.length())
{
sLine = sLine.mid(iPrefixLength, iCommentBegin - iPrefixLength);
if(sLine.getCharacters()[0] == m_cSectionStartCharacter && sLine.getCharacters()[sLine.length() - 1] == m_cSectionEndCharacter)
{
pLastSection = &appendSection(sLine.mid(1, sLine.length() - 2));
pLastComment = &pLastSection->m_sComment;
}
else
{
if(pLastSection == 0)
pLastSection = &appendSection(RainString());
if(sLine.indexOf(m_cAssignmentCharacter) == static_cast<size_t>(-1))
{
THROW_SIMPLE_(L"Line is not a section nor a value \'%s\'", sLine.getCharacters());
}
pLastValue = &pLastSection->appendValue(sLine.beforeFirst(m_cAssignmentCharacter).trimWhitespace(), sLine.afterFirst(m_cAssignmentCharacter).trimWhitespace());
pLastComment = &pLastValue->m_sComment;
}
}
pLastComment->append(sComment);
}
} while(!oFile.isEOF());
}
void IniFile::load(const RainString& sFile) throw(...)
{
IFile* pFile = 0;
try
{
pFile = RainOpenFile(sFile, FM_Read);
load(pFile);
}
CATCH_THROW_SIMPLE_(delete pFile, L"Cannot load INI file \'%s\'", sFile.getCharacters());
delete pFile;
}
static char RainCharToChar(RainChar c)
{
return c & ~0xFF ? '?' : static_cast<char>(c);
}
void IniFile::save(IFile* pFile) throw(...)
{
BufferingOutputStream<char> oOutput(pFile);
oOutput.writeConverting(m_sComment, RainCharToChar);
for(iterator itr_s = begin(), end_s = end(); itr_s != end_s; ++itr_s)
{
oOutput.write(RainCharToChar(m_cSectionStartCharacter));
oOutput.writeConverting(itr_s->name(), RainCharToChar);
oOutput.write(RainCharToChar(m_cSectionEndCharacter));
if(itr_s->comment().isEmpty())
oOutput.writeConverting(L"\r\n", 2, RainCharToChar);
else
oOutput.writeConverting(itr_s->comment(), RainCharToChar);
for(Section::iterator itr_v = itr_s->begin(), end_v = itr_s->end(); itr_v != end_v; ++itr_v)
{
oOutput.writeConverting(itr_v->key(), RainCharToChar);
oOutput.write(' ');
oOutput.write(RainCharToChar(m_cAssignmentCharacter));
oOutput.write(' ');
oOutput.writeConverting(itr_v->value(), RainCharToChar);
if(itr_v->comment().isEmpty())
oOutput.writeConverting(L"\r\n", 2, RainCharToChar);
else
oOutput.writeConverting(itr_v->comment(), RainCharToChar);
}
}
}
void IniFile::save(const RainString &sFile) throw(...)
{
IFile* pFile = 0;
try
{
pFile = RainOpenFile(sFile, FM_Write);
save(pFile);
}
CATCH_THROW_SIMPLE_(delete pFile, L"Cannot save INI file \'%s\'", sFile.getCharacters());
delete pFile;
}
IniFile::Section& IniFile::appendSection(const RainString& sSection)
{
Section *pNewSection = new Section;
if(m_pFirstSection == 0)
m_pFirstSection = pNewSection;
DLinkList_Section::append(m_pLastSection, pNewSection);
map_type::iterator itr = m_mapSections.find(sSection);
if(itr == m_mapSections.end())
{
m_mapSections[sSection] = pNewSection;
}
else
{
DLinkList_SectionTwin::append_end(itr->second, pNewSection);
}
m_pLastSection = pNewSection;
pNewSection->m_sName = sSection;
pNewSection->m_pFile = this;
return *pNewSection;
}
IniFile::Section::Value& IniFile::Section::appendValue(const RainString& sKey, const RainString& sValue)
{
Value *pNewValue = new Value;
if(m_pFirstValue == 0)
m_pFirstValue = pNewValue;
DLinkList_Value::append(m_pLastValue, pNewValue);
map_type::iterator itr = m_mapValues.find(sKey);
if(itr == m_mapValues.end())
{
m_mapValues[sKey] = pNewValue;
}
else
{
DLinkList_ValueTwin::append_end(itr->second, pNewValue);
}
m_pLastValue = pNewValue;
pNewValue->m_sKey = sKey;
pNewValue->m_sValue = sValue;
pNewValue->m_pSection = this;
return *pNewValue;
}
IniFile::Section::operator const RainString&() const
{
return m_sName;
}
const RainString& IniFile::Section::name() const
{
return m_sName;
}
const RainString& IniFile::comment() const
{
return m_sComment;
}
const RainString& IniFile::Section::comment() const
{
return m_sComment;
}
const RainString& IniFile::Section::Value::comment() const
{
return m_sComment;
}
bool IniFile::Section::operator ==(const RainString& sName) const
{
return m_sName == sName;
}
bool IniFile::Section::Value::operator ==(const RainString& sValue) const
{
return m_sValue == sValue;
}
IniFile::Section::Value& IniFile::Section::Value::operator =(const RainString& sValue)
{
m_sValue = sValue;
return *this;
}
IniFile::Section::Value::operator RainString&()
{
return m_sValue;
}
IniFile::Section::Value::operator const RainString&() const
{
return m_sValue;
}
RainString& IniFile::Section::Value::value()
{
return m_sValue;
}
const RainString& IniFile::Section::Value::value() const
{
return m_sValue;
}
IniFile::Section::Value& IniFile::Section::Value::setValue(const RainString& sValue)
{
value() = sValue;
return *this;
}
const RainString& IniFile::Section::Value::key() const
{
return m_sKey;
}
| [
"corsix@07142bc5-7355-0410-a98c-5fd2ca6e29ee"
]
| [
[
[
1,
688
]
]
]
|
9bace17116bf712abfddbdc7c71dbcc42976cc54 | 9a93e286fa82271228c7ac3626e268092f81d526 | /jni/process.cpp | 92b580125f3d15920c17616ab0b14560f9567879 | []
| no_license | pashapm/myandroidcats | 969b0a6c7d3a667327e6d867139fffd13488d733 | 76036926cc1c8ae2f7426a24267a2d9800ed030d | refs/heads/master | 2016-09-02T04:53:35.632947 | 2010-11-13T13:40:16 | 2010-11-13T13:40:16 | 33,294,725 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,933 | cpp |
#include <jni.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <android/log.h>
#ifndef _Included_ru_waterdist_ProgressTest
#define _Included_ru_waterdist_ProgressTest
#ifdef __cplusplus
extern "C" {
#endif
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, "native progress!!!!!!!!!", __VA_ARGS__)
JNIEXPORT jint JNICALL Java_ru_waterdist_ProgressTest_mkfifo
(JNIEnv *env, jobject, jstring path) {
const char* cpath = env->GetStringUTFChars(path, NULL);
struct stat buf;
//remove the old pipe
remove(cpath);
if ( mkfifo(cpath, S_IRWXU) < 0 ) {
LOGD("Cannot create a pipe");
return -1;
} else {
LOGD("created fifo!");
return 0;
}
/*
if ( stat(cpath, &buf) < 0) {
if ( mkfifo(cpath, S_IRWXU) < 0 ) {
LOGD("Cannot create a pipe");
return -1;
} else {
LOGD("created fifo!");
}
} else {
LOGD("pipe exists");
}
*/
return 0;
}
void ehook() {
LOGD("EXIT HOOKK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
}
JNIEXPORT jint JNICALL Java_ru_waterdist_ProgressTest_process
(JNIEnv * env, jobject, jstring path) {
const char* cpath = env->GetStringUTFChars(path, NULL);
struct stat buf;
if ( stat(cpath, &buf) < 0 || ! (buf.st_mode | S_IFIFO)) {
LOGD("The file isn't a pipe");
return -1;
}
int fp = open(cpath, O_WRONLY);
if(fp == -1) {
LOGD("Could not open the pipe");
return -1;
}
char progress = 0;
for (int i=0; i<10; ++i) {
sleep(1);
++progress;
write(fp, &progress, 1);
}
atexit(ehook);
//exit(0);
return 0;
}
#ifdef __cplusplus
}
#endif
#endif
| [
"jecklandin@b144376d-b932-3d78-0189-40c2374323a9"
]
| [
[
[
1,
97
]
]
]
|
c9ec7ae35eb73744e038ad70b41c0a6679e9ac04 | 9c62af23e0a1faea5aaa8dd328ba1d82688823a5 | /rl/tags/v0-1/engine/dialog/src/DialogSubsystem.cpp | 623bd2a64ddd57b381780c48cb7aff01f404d077 | [
"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 | 3,670 | cpp | /* This source file is part of Rastullahs Lockenpracht.
* Copyright (C) 2003-2005 Team Pantheon. http://www.team-pantheon.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the Clarified Artistic License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Clarified Artistic License for more details.
*
* You should have received a copy of the Clarified Artistic License
* along with this program; if not you can get it here
* http://www.jpaulmorrison.com/fbp/artistic2.htm.
*/
#include <xercesc/sax2/SAX2XMLReader.hpp>
#include <xercesc/sax2/DefaultHandler.hpp>
#include <xercesc/sax2/XMLReaderFactory.hpp>
#include <xercesc/dom/DOM.hpp>
#include "XmlHelper.h"
#include "XmlResourceManager.h"
#include "Logger.h"
#include "CoreSubsystem.h"
#include "AimlParserImplXerces.h"
#include "AimlProcessorManager.h"
#include "DialogCharacter.h"
#include "BotParser.h"
#include "DialogSubsystem.h"
using namespace Ogre;
template<> rl::DialogSubsystem* Singleton<rl::DialogSubsystem>::ms_Singleton = 0;
namespace rl
{
DialogSubsystem& DialogSubsystem::getSingleton(void)
{
return Singleton<DialogSubsystem>::getSingleton();
}
DialogSubsystem* DialogSubsystem::getSingletonPtr(void)
{
return Singleton<DialogSubsystem>::getSingletonPtr();
}
DialogSubsystem::DialogSubsystem()
: mCurrentBot(NULL)
{
AimlProcessorManager::addStandardProcessors();
// Initialize Xerces if this wasn't done already
try
{
XMLPlatformUtils::Initialize();
XmlHelper::initializeTranscoder();
}
catch (const XMLException& exc)
{
char* excmsg = XMLString::transcode(exc.getMessage());
std::string excs="Exception while initializing Xerces: ";
excs+=excmsg;
Logger::getSingleton().log(Logger::DIALOG, Ogre::LML_TRIVIAL, excs);
XMLString::release(&excmsg);
}
}
DialogSubsystem::~DialogSubsystem()
{
for(BotMap::iterator iter = mBots.begin();
iter != mBots.end();
++iter)
{
delete iter->second;
}
}
DialogCharacter* DialogSubsystem::getCurrentBot()
{
return mCurrentBot;
}
DialogCharacter* DialogSubsystem::loadBot(const CeGuiString& fileName, const CeGuiString& botName)
{
mCurrentBot = new DialogCharacter();
setAimlParser(new AimlParserImplXerces(this));
BotParser parser(botName);
if(parser.parse(fileName, mCurrentBot))
{
BotMap::iterator iter = mBots.find(mCurrentBot->getName());
if(iter == mBots.end())
{
mBots[mCurrentBot->getName()] = mCurrentBot;
}
else
{
delete mCurrentBot;
mCurrentBot = iter->second;
}
}
else
{
delete mCurrentBot;
mCurrentBot = NULL;
}
return mCurrentBot;
}
ResourcePtr DialogSubsystem::getXmlResource(const Ogre::String& filename)
{
ResourcePtr res = XmlResourceManager::getSingleton().getByName(filename);
if (res.isNull())
{
Ogre::String group = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME;
if (ResourceGroupManager::getSingleton().resourceExists(
CoreSubsystem::getSingleton().getActiveAdventureModule(), filename))
{
group = CoreSubsystem::getSingleton().getActiveAdventureModule();
}
res = XmlResourceManager::getSingleton().create(filename, group);
}
return res;
}
}
| [
"blakharaz@4c79e8ff-cfd4-0310-af45-a38c79f83013"
]
| [
[
[
1,
129
]
]
]
|
044247ffef710ab449a731d0ddb9858d9556605e | 71ffdff29137de6bda23f02c9e22a45fe94e7910 | /LevelEditor/src/gui/CLayerControl.cpp | 36ac9201ed04f8ad8f45b0ce8ea2922d79339cd3 | []
| no_license | anhoppe/killakoptuz3000 | f2b6ecca308c1d6ebee9f43a1632a2051f321272 | fbf2e77d16c11abdadf45a88e1c747fa86517c59 | refs/heads/master | 2021-01-02T22:19:10.695739 | 2009-03-15T21:22:31 | 2009-03-15T21:22:31 | 35,839,301 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,306 | cpp | /********************************************************************
created: 2009/03/04
created: 4:3:2009 19:56
filename: c:\hoppe\develop\KK3000\LevelEditor\src\CLayerControl.cpp
file path: c:\hoppe\develop\KK3000\LevelEditor\src
file base: CLayerControl
file ext: cpp
author: anhoppe
purpose:
*********************************************************************/
#include "CLayerControl.h"
#include "../data/CDataStorage.h"
#include "../data/CUpdateContainer.h"
//////////////////////////////////////////////////////////////////////////
// Definitions
//////////////////////////////////////////////////////////////////////////
#define ID_LIST_OBJECTS 1000
#define ID_BUTTON_ADD_OBJECT 1001
#define ID_BUTTON_ADD_ENEMY 1002
#define ID_BUTTON_INSERT_LAYER 1003
#define ID_BUTTON_DELETE_LAYER 1004
#define ID_BUTTON_OBJECT_UP 1005
#define ID_BUTTON_OBJECT_DOWN 1006
#define BUTTON_SIZE wxSize(35, 20)
//////////////////////////////////////////////////////////////////////////
// Event Table
//////////////////////////////////////////////////////////////////////////
BEGIN_EVENT_TABLE(CLayerControl, wxPanel)
EVT_TOGGLEBUTTON(ID_BUTTON_ADD_OBJECT, onButtonAddObject)
EVT_TOGGLEBUTTON(ID_BUTTON_ADD_ENEMY, onButtonAddEnemy)
EVT_BUTTON(ID_BUTTON_INSERT_LAYER, onButtonInsertLayer)
EVT_BUTTON(ID_BUTTON_DELETE_LAYER, onButtonDeleteLayer)
EVT_BUTTON(ID_BUTTON_OBJECT_UP, onButtonObjectUp)
EVT_BUTTON(ID_BUTTON_OBJECT_DOWN, onButtonObjectDown)
EVT_LISTBOX(ID_LIST_OBJECTS, onListObjects)
END_EVENT_TABLE()
//////////////////////////////////////////////////////////////////////////
// Implementation
//////////////////////////////////////////////////////////////////////////
CLayerControl::CLayerControl(wxWindow* t_parentPtr)
: wxPanel(t_parentPtr, wxID_ANY, wxDefaultPosition, wxSize(200, 360))
{
m_listLayersPtr = 0;
createControls();
// register as update listener
CUpdateContainer::getInstance().add((IUpdate*)this);
CUpdateContainer::getInstance().add((ISetObject*)this);
}
CLayerControl::~CLayerControl()
{
}
void CLayerControl::update()
{
if(0 != m_listLayersPtr)
{
std::vector<std::string> a_objectList;
std::vector<std::string>::iterator a_strIt;
std::vector<int>::iterator a_posIt;
int a_count = 0;
char a_str[1024];
int a_index = 0;
a_index = m_listLayersPtr->GetSelection();
m_listLayersPtr->Clear();
// get the object names
CDataStorage::getInstance().getObjectsAsStrings(a_objectList);
// put the object names into the list
for(a_strIt = a_objectList.begin(); a_strIt != a_objectList.end(); a_strIt++)
{
m_listLayersPtr->Append((*a_strIt).c_str());
}
// insert the layer number
for(a_posIt = m_layerPositions.begin(); a_posIt != m_layerPositions.end(); a_posIt++)
{
sprintf(a_str, "---Layer%d", a_count++);
m_listLayersPtr->Insert(a_str, (*a_posIt));
}
m_listLayersPtr->SetSelection(a_index);
// assign the layer position
assignLayerPosition();
}
}
void CLayerControl::setObject(int t_index)
{
int a_rowIndex = getObjectRow(t_index);
m_listLayersPtr->SetSelection(a_rowIndex);
}
//////////////////////////////////////////////////////////////////////////
// Private Methods
//////////////////////////////////////////////////////////////////////////
void CLayerControl::createControls()
{
wxBoxSizer* a_sizerPtr = new wxBoxSizer(wxVERTICAL);
// add the list box to the sizer
m_listLayersPtr = new wxListBox(this, ID_LIST_OBJECTS);
a_sizerPtr->Add(m_listLayersPtr, 1, wxEXPAND|wxGROW|wxLEFT|wxTOP|wxRIGHT|wxBOTTOM|wxALIGN_CENTER, 1);
//////////////////////////////////////////////////////////////////////////
// create a sizer for the buttons
wxBoxSizer* a_buttonSizerPtr = new wxBoxSizer(wxHORIZONTAL);
wxBitmap* a_bitmapPtr = 0;
// create the add object mode button
m_buttonAddObjectPtr = new wxToggleButton(this, ID_BUTTON_ADD_OBJECT, "Obj", wxDefaultPosition, BUTTON_SIZE);
a_buttonSizerPtr->Add(m_buttonAddObjectPtr, 0, wxALIGN_LEFT, 0);
// create the add enemy mode button
m_buttonAddEnemyPtr = new wxToggleButton(this, ID_BUTTON_ADD_ENEMY, "Enemy", wxDefaultPosition, BUTTON_SIZE);
a_buttonSizerPtr->Add(m_buttonAddEnemyPtr, 0, wxALIGN_LEFT, 0);
// create the add layer button
a_buttonSizerPtr->Add(new wxButton(this, ID_BUTTON_INSERT_LAYER, "Layer", wxDefaultPosition, BUTTON_SIZE), 0, wxALIGN_LEFT, 0);
// create the delete button
a_buttonSizerPtr->Add(new wxButton(this, ID_BUTTON_DELETE_LAYER, "Del", wxDefaultPosition, BUTTON_SIZE), 0, wxALIGN_LEFT, 0);
a_buttonSizerPtr->AddStretchSpacer(1);
// create the object up button
a_buttonSizerPtr->Add(new wxButton(this, ID_BUTTON_OBJECT_UP, "Up", wxDefaultPosition, BUTTON_SIZE), 0, wxALIGN_RIGHT, 0);
// create the delete button
a_buttonSizerPtr->Add(new wxButton(this, ID_BUTTON_OBJECT_DOWN, "Down", wxDefaultPosition, BUTTON_SIZE), 0, wxALIGN_RIGHT, 0);
a_sizerPtr->Add(a_buttonSizerPtr, 0, wxALIGN_BOTTOM);
SetSizer(a_sizerPtr);
}
void CLayerControl::assignLayerPosition()
{
unsigned int a_index = 0;
int a_objectIndex = 0;
for(a_index = 0; a_index < m_listLayersPtr->GetCount(); a_index++)
{
a_objectIndex = getObjectPosition((int)a_index);
if(-1 != a_objectIndex)
{
assignLayerPosition(a_objectIndex, (int)a_index);
}
}
}
void CLayerControl::assignLayerPosition(int t_objectIndex, int t_index)
{
if(m_layerPositions.size() > 0)
{
std::vector<int>::iterator a_it;
int a_layerNumber = 0;
bool a_numberAssigned = false;
for(a_it = m_layerPositions.begin(); a_it != m_layerPositions.end(); a_it++)
{
if(t_index < (*a_it))
{
CDataStorage::getInstance().assignLayerNumber(t_objectIndex, a_layerNumber);
a_numberAssigned = true;
break;
}
a_layerNumber++;
}
if(!a_numberAssigned)
{
CDataStorage::getInstance().assignLayerNumber(t_objectIndex, a_layerNumber);
}
}
}
void CLayerControl::insertLayers(std::vector<int>& t_layerPositions)
{
std::vector<int>::iterator a_it;
int a_count = 0;
m_layerPositions.clear();
for(a_it = t_layerPositions.begin(); a_it != t_layerPositions.end(); a_it++)
{
m_layerPositions.push_back((*a_it)+a_count++);
}
}
bool CLayerControl::isObject(int t_index)
{
std::vector<int>::iterator a_it;
bool r_isObject = true;
for(a_it = m_layerPositions.begin(); a_it < m_layerPositions.end(); a_it++)
{
if((*a_it) == t_index)
{
r_isObject = false;
break;
}
}
return r_isObject;
}
int CLayerControl::getObjectPosition(int t_index)
{
int r_position = -1;
if(isObject(t_index))
{
int a_index = 0;
for(a_index = 0; a_index <= t_index; a_index++)
{
if(isObject(a_index))
{
r_position++;
}
}
}
return r_position;
}
int CLayerControl::getObjectRow(int t_index)
{
int r_result = 0;
int a_count = 0;
int a_index = 0;
if(t_index < CDataStorage::getInstance().getNumObjects())
{
for(a_index = 0; a_index < (int)m_listLayersPtr->GetCount(); a_index++)
{
if(isObject(a_index))
{
if(a_count == t_index)
{
r_result = a_index;
break;
}
a_count++;
}
}
}
return r_result;
}
int CLayerControl::getLayerIndex(int t_rowIndex)
{
std::vector<int>::iterator a_it;
int a_count = 0;
int r_index = -1;
for(a_it = m_layerPositions.begin(); a_it != m_layerPositions.end(); a_it++)
{
if((*a_it) == t_rowIndex)
{
r_index = a_count;
break;
}
a_count++;
}
return r_index;
}
bool CLayerControl::canMoveLayerUp(int t_index)
{
int a_index = 0;
bool r_result = false;
if(t_index > 0)
{
if(m_layerPositions[t_index] > m_layerPositions[t_index-1]+1)
{
r_result = true;
}
}
else
{
if(m_layerPositions[t_index] > 0)
{
r_result = true;
}
}
return r_result;
}
bool CLayerControl::canMoveLayerDown(int t_index)
{
size_t a_index = 0;
bool r_result = false;
if(t_index < (int)m_layerPositions.size()-1)
{
if(m_layerPositions[t_index] < m_layerPositions[t_index+1]-1)
{
r_result = true;
}
}
else
{
if(m_layerPositions[t_index] < (int)m_listLayersPtr->GetCount()-1)
{
r_result = true;
}
}
return r_result;
}
void CLayerControl::deleteLayerByIndex(int t_index)
{
if(t_index >= 0 && t_index < (int)m_layerPositions.size())
{
std::vector<int>::iterator a_it;
int a_count = 0;
for(a_it = m_layerPositions.begin(); a_it != m_layerPositions.end(); a_it++)
{
if(a_count == t_index)
{
m_layerPositions.erase(a_it);
break;
}
a_count++;
}
}
}
//////////////////////////////////////////////////////////////////////////
// Events
//////////////////////////////////////////////////////////////////////////
void CLayerControl::onButtonAddObject(wxCommandEvent& t_event)
{
bool a_state = m_buttonAddObjectPtr->GetValue();
CDataStorage::getInstance().setAddObjectMode(a_state);
if(a_state)
{
m_buttonAddEnemyPtr->SetValue(false);
}
}
void CLayerControl::onButtonAddEnemy(wxCommandEvent& t_event)
{
bool a_state = m_buttonAddEnemyPtr->GetValue();
CDataStorage::getInstance().setAddEnemyMode(a_state);
if(a_state)
{
m_buttonAddObjectPtr->SetValue(false);
}
}
void CLayerControl::onButtonInsertLayer(wxCommandEvent& t_event)
{
m_layerPositions.push_back(m_listLayersPtr->GetCount());
update();
}
void CLayerControl::onButtonDeleteLayer(wxCommandEvent& t_event)
{
int a_index = m_listLayersPtr->GetSelection();
if(wxNOT_FOUND != a_index)
{
if(isObject(a_index))
{
CDataStorage::getInstance().deleteObjectByIndex(getObjectPosition(a_index));
}
else
{
deleteLayerByIndex(getLayerIndex(a_index));
}
CUpdateContainer::getInstance().update();
}
}
void CLayerControl::onButtonObjectUp(wxCommandEvent& t_event)
{
int a_sel = m_listLayersPtr->GetSelection();
if(a_sel != -1)
{
bool a_moved = false;
int a_objectPosition = getObjectPosition(a_sel);
// move either object ...
if(-1 != a_objectPosition)
{
a_moved = CDataStorage::getInstance().moveObject(a_objectPosition, a_objectPosition-1);
CUpdateContainer::getInstance().update();
}
// ... or layer
else
{
int a_indexPosition = getLayerIndex(a_sel);
if(canMoveLayerUp(a_indexPosition))
{
m_layerPositions[a_indexPosition] -= 1;
CUpdateContainer::getInstance().update();
a_moved = true;
}
}
if(a_moved)
{
m_listLayersPtr->SetSelection(a_sel-1);
}
}
}
void CLayerControl::onButtonObjectDown(wxCommandEvent& t_event)
{
int a_sel = m_listLayersPtr->GetSelection();
if(a_sel != -1)
{
bool a_moved = false;
int a_objectPosition = getObjectPosition(a_sel);
if(-1 != a_objectPosition)
{
a_moved = CDataStorage::getInstance().moveObject(a_objectPosition, a_objectPosition+1);
CUpdateContainer::getInstance().update();
}
// ... or layer
else
{
int a_indexPosition = getLayerIndex(a_sel);
if(canMoveLayerDown(a_indexPosition))
{
m_layerPositions[a_indexPosition] += 1;
CUpdateContainer::getInstance().update();
a_moved = true;
}
}
if(a_moved)
{
m_listLayersPtr->SetSelection(a_sel+1);
}
}
}
void CLayerControl::onListObjects(wxCommandEvent& t_event)
{
int a_index = m_listLayersPtr->GetSelection();
if(a_index != -1)
{
a_index = getObjectPosition(a_index);
if(-1 != a_index)
{
CUpdateContainer::getInstance().setObject(a_index);
CUpdateContainer::getInstance().update();
}
}
}
| [
"anhoppe@9386d06f-8230-0410-af72-8d16ca8b68df"
]
| [
[
[
1,
492
]
]
]
|
bbab5ea26a1d167813d268c1a538ee1ab99d53e0 | 09c43e037d720e24e769ef9faa148f1377524c2c | /nil/net.hpp | 7a39e67661488379ff0d2fd9575f7f269f4948db | []
| no_license | goal/qqbot | bf63cf06e4976f16e2f0b8ec7c6cce88782bdf29 | 3a4b5920d5554cc55b6df962d27ebbc499c63474 | refs/heads/master | 2020-07-30T13:57:11.135976 | 2009-06-10T00:13:46 | 2009-06-10T00:13:46 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,850 | hpp | #ifndef NIL_NET_HPP
#define NIL_NET_HPP
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <nil/environment.hpp>
#include <nil/thread.hpp>
#include <nil/exception.hpp>
#include <nil/types.hpp>
#ifdef NIL_WINDOWS
#include <nil/windows.hpp>
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#endif
#ifdef NIL_WITH_SSL
#include <openssl/crypto.h>
#include <openssl/x509.h>
#include <openssl/pem.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#endif
namespace nil
{
namespace net
{
enum client_status_type
{
client_status_idle,
client_status_lookup,
client_status_connecting,
client_status_connected
};
enum client_event_type
{
client_event_connect,
client_event_disconnect,
client_event_receive,
client_event_error
};
enum client_error_type
{
client_error_socket,
client_error_blocking_mode,
client_error_dns,
client_error_connect,
client_error_receive,
client_error_send
};
enum tcp_server_event_type
{
tcp_server_event_error,
tcp_server_event_connect,
tcp_server_event_disconnect,
tcp_server_event_receive
};
enum tcp_server_error_type
{
tcp_server_error_socket,
tcp_server_error_bind,
tcp_server_error_listen,
tcp_server_error_accept,
tcp_server_error_receive
};
#ifdef NIL_WINDOWS
class winsock
{
public:
winsock();
~winsock();
void launch();
bool success() const;
private:
bool launched;
bool successful_startup;
nil::mutex mutex;
};
#endif
#ifdef NIL_WITH_SSL
class ssl_launcher_class
{
public:
ssl_launcher_class();
~ssl_launcher_class();
void launch();
private:
bool launched;
nil::mutex mutex;
};
#endif
struct client_event
{
client_event_type type;
client_error_type error;
std::string data;
client_event();
client_event(client_event_type type);
client_event(client_error_type error);
client_event(std::string const & input);
};
#ifdef NIL_WINDOWS
typedef SOCKET socket_type;
#else
typedef int socket_type;
#endif
class tcp_socket
{
public:
tcp_socket();
~tcp_socket();
bool connect(ulong address, ulong port);
bool connect(std::string const & address, ulong port);
void disconnect();
bool send(std::string const & input);
bool send(void const * input, std::size_t input_size);
bool receive(std::string & output);
client_status_type get_status() const;
bool get_ip(ulong & output);
private:
client_status_type status;
socket_type socket_descriptor;
};
class tcp_client
{
public:
tcp_client();
~tcp_client();
void connect(ulong address, ulong port);
void connect(std::string const & address, ulong port);
void disconnect();
void send(std::string const & input);
client_event get_event();
client_status_type get_status() const;
void wtf();
private:
thread client_thread;
mutex client_mutex;
client_status_type status;
std::queue<client_event> event_queue;
bool terminate_thread;
socket_type socket_descriptor;
event tcp_client_event;
ulong address_number;
std::string address_string;
ulong address_port;
void thread_function(void * unused);
void push_event(client_event the_event);
void error_event(client_error_type error);
};
#ifdef NIL_WITH_SSL
class ssl_tcp_socket
{
public:
ssl_tcp_socket();
~ssl_tcp_socket();
bool connect(ulong address, ulong port);
bool connect(std::string const & address, ulong port);
void disconnect();
bool send(std::string const & input);
bool send(void const * input, std::size_t input_size);
bool receive(std::string & output);
client_status_type get_status() const;
bool get_ip(ulong & output);
private:
client_status_type status;
socket_type socket_descriptor;
::SSL_CTX * ctx;
::SSL * ssl;
};
#endif
struct tcp_server_event
{
tcp_server_event_type type;
tcp_server_error_type error;
int client_identifier;
std::string data;
tcp_server_event();
tcp_server_event(tcp_server_event_type type);
tcp_server_event(tcp_server_error_type error);
tcp_server_event(ulong client_identifier, tcp_server_event_type type);
tcp_server_event(ulong client_identifier, std::string data);
tcp_server_event(ulong client_identifier, tcp_server_error_type error);
};
struct tcp_server_client
{
thread client_thread;
socket_type client_socket;
ulong identifier;
std::string send_buffer;
bool to_disconnect;
ulong ip;
tcp_server_client();
};
class tcp_server
{
public:
tcp_server();
~tcp_server();
bool listen(ulong server_port);
void shutdown();
void send(ulong client_identifier, std::string const & data);
void disconnect(ulong client_identifier);
std::string get_ip(ulong client_identifier);
tcp_server_event get_event();
private:
typedef std::vector<tcp_server_event> queue_type;
typedef std::map<ulong, tcp_server_client *> map_type;
typedef std::vector<ulong> dead_client_type;
bool running;
ulong port;
thread server_thread;
mutex server_mutex;
event queue_event;
bool terminate_thread;
queue_type event_queue;
map_type client_map;
dead_client_type dead_clients;
socket_type server_socket;
void check_identifier(ulong identifier);
bool is_valid_identifier(ulong identifier);
void cleanup();
void error_event(tcp_server_error_type error);
void push_event(tcp_server_event server_event);
ulong get_unused_id();
void thread_function(void * unused);
void client_thread(void * client_void_pointer);
};
class udp_client
{
public:
udp_client();
~udp_client();
void set_target(ulong target_address, ulong target_port);
bool set_target(std::string const & target_address, ulong target_port);
void send(std::string const & data);
std::string receive();
private:
bool target_is_set;
sockaddr_in address;
socket_type socket_descriptor;
};
struct udp_server_event
{
std::string data;
ulong ip;
};
class udp_server
{
public:
udp_server();
~udp_server();
bool launch(ulong port);
void shut_down();
udp_server_event receive();
private:
bool is_running;
socket_type socket_descriptor;
};
ulong get_ip();
std::string ip_to_string(ulong address);
#ifdef NIL_WINDOWS
extern winsock winsock_launcher;
#endif
}
}
#endif
| [
"akirarat@ba06997c-553f-11de-8ef9-cf35a3c3eb08"
]
| [
[
[
1,
341
]
]
]
|
a050726eb4d6d7482049a2baee4a8bdef3a79fe2 | 36135d8069401456e92aea4515a9504b6afdc8f4 | /seeautz/source/glutFramework/glutFramework/SG400KGA1.cpp | c2d7975662f105ce17a53f9cf148c7f0bd3ae291 | []
| no_license | CorwinJV/seeautz-projekt1 | 82d03b19d474de61ef58dea475ac4afee11570a5 | bbfb4ce0d341dfba9f4d076eced229bee5c9301c | refs/heads/master | 2020-03-30T23:06:45.280743 | 2009-05-31T23:09:15 | 2009-05-31T23:09:15 | 32,131,398 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,054 | cpp | #include "SG400KGA1.h"
#include <stdlib.h>
bool SG400KGA1::Update()
{
if(myMenu != NULL)
myMenu->Update();
return true;
}
bool SG400KGA1::Draw()
{
// since all fonts are now well, blackish stuff, lets draw a white background
solidWhite->drawImage();
// image
if(imgSG400)
{
imgSG400->drawImageFaded(alpha);
}
// interface
glColor3ub(255, 0, 0);
GameVars->fontArial18.drawText(25, 700, "Enter Command:");
glColor3ub(0, 255, 0);
GameVars->fontArial18.drawText(220, 700, tempString);
// history
glColor3ub(255, 255, 255);
GameVars->fontArial18.drawText(25, 10, "Command History");
int offsetAmt = 0;
int textOffset = 14;
vector<string*>::iterator sitr;
sitr = commandList.begin();
for(;sitr < commandList.end(); sitr++)
{
GameVars->fontArial12.drawText(25, 29 + offsetAmt*textOffset, (*sitr)->c_str());
offsetAmt++;
}
// draw instruction list on top right
offsetAmt = 0;
textOffset = 15;
int xp = 575;
int yp = 25;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "Available Commands");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "Values inside () & [] are");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "used without the () & []");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "() denotes values");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "[] denotes specific words");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "i.e. move up 50");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "move [up/down/left/right] (pixels)");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "resize (width) (height)");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "set [alpha/width/height/x/y] (value)");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "reset");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "load (filename)");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "quit");
offsetAmt++;
return false;
}
void SG400KGA1::processMouse(int x, int y)
{
}
void SG400KGA1::processMouseClick(int button, int state, int x, int y)
{
}
void SG400KGA1::keyboardInput(unsigned char c, int x, int y)
{
switch(c)
{
case 13: // enter key
if(finished == 2)
{
tempString = "";
finished = 0;
}
else
finished = 1;
break;
case 8: // backspace
if(tempString.length() > 0)
tempString.erase(tempString.length() - 1, 1);
break;
case 27: // escape key
tempString = "";
/*GSM->addGameState<MainMenuState>();
this->setStatus(DeleteMe);*/
break;
default:
if(tempString.length() <= 60)
{
tempString += c;
finished = 0;
}
break;
}
if(finished)
{
tString = new string;
*tString = tempString;
interpret(tString);
commandList.push_back(tString);
tempString = "";
}
}
void SG400KGA1::interpret(string *iString)
{
// parse this out into various things first
vector<string*> parseList;
bool done = false;
bool foundCommand = false;
bool foundvar1 = false;
bool foundvar2 = false;
string command;
string var1 = "";
string var2 = "";
int targetSpot = 0;
(*iString) += " ";
for(int x = 0; x < (int)iString->length(); x++)
{
if(iString->substr(x, 1) == " ")
{
// we found a space, lets do something with it
if(!foundCommand)
{
command = iString->substr(0, x);
foundCommand = true;
targetSpot = x+1;
}
else if(!foundvar1)
{
var1 = (iString->substr(targetSpot, x-targetSpot).c_str());
foundvar1 = true;
targetSpot = x+1;
}
else if(!done)
{
var2 = (iString->substr(targetSpot, x-targetSpot).c_str());
done = true;
foundvar2 = true;
}
}
}
if(foundCommand)
{
if(command == "quit")
{
exit(0);
}
else if(command == "move")
{
if(foundvar1)
{
if(var1 == "up")
{
imgSG400->mY = imgSG400->mY - atoi(var2.c_str());
}
else if(var1 == "down")
{
imgSG400->mY = imgSG400->mY + atoi(var2.c_str());
}
else if(var1 == "left")
{
imgSG400->mX = imgSG400->mX - atoi(var2.c_str());
}
else if(var1 == "right")
{
imgSG400->mX = imgSG400->mX + atoi(var2.c_str());
}
else
{
*iString += " <invalid direction>";
}
}
}
else if(command == "resize")
{
if(foundvar1)
{
imgSG400->dX = atoi(var1.c_str());
}
if(foundvar2)
{
imgSG400->dY = atoi(var2.c_str());
}
}
else if(command == "reset")
{
delete imgSG400;
imgSG400 = new oglTexture2D();
imgSG400->loadImage("buttons\\bacardi.png", 256, 256);
imgSG400->dX = 256;
imgSG400->dY = 256;
imgSG400->mX = 300;
imgSG400->mY = 50;
alpha = 1.0;
}
else if(command == "load")
{
if(foundvar1)
{
delete imgSG400;
imgSG400 = new oglTexture2D();
if(!imgSG400->loadImage(var1.c_str(), 256, 256))
{
*iString += " <invalid file>";
}
imgSG400->dX = 256;
imgSG400->dY = 256;
imgSG400->mX = 300;
imgSG400->mY = 50;
}
}
else if(command == "set" && foundvar1 && foundvar2)
{
if(var1 == "alpha")
{
alpha = atof(var2.c_str());
}
else if(var1 == "width")
{
imgSG400->dX = atoi(var2.c_str());
}
else if(var1 == "height")
{
imgSG400->dY = atoi(var2.c_str());
}
else if(var1 == "x")
{
imgSG400->mX = atoi(var2.c_str());
}
else if(var1 == "y")
{
imgSG400->mY = atoi(var2.c_str());
}
}
else // invalid command
{
*iString += " <Invalid Command>";
}
}
} | [
"[email protected]@6d558e22-e0db-11dd-bce9-bf72c0239d3a"
]
| [
[
[
1,
272
]
]
]
|
c8406ac84cb776e18b191f9b166b62b5c008b51a | 76ea17bc9bc52ae653bd203dd6716fd1e965a8c9 | /libwnd/include/Dlg.h | 91de201b3335ca17964e5285833dbd53ad8b3f27 | []
| no_license | eickegao/avgscript | 1e78cc09b8c52e5ee9b3be48b81ef5b128fef269 | 75e75b8c5597b673855b91e6e1bd87c5c60b8c04 | refs/heads/master | 2016-09-08T00:32:29.508547 | 2009-01-12T08:40:08 | 2009-01-12T08:40:08 | 33,953,223 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 782 | h | //********************************************
// project: libwnd
// filename: cdlg.h
// author: [email protected]
// date: 200712
// descript: common dlg class
// history: v1.0
//********************************************
#ifndef _DLG_H
#define _DLG_H
#include "libnge.h"
#include "def.h"
#include "CommonWnd.h"
class CDlg: public CCommonWnd
{
public:
CDlg();
~CDlg();
virtual bool CreateTexture(const char* pszFileName);
virtual void Draw(_RECT rect=_RECT(0,0,0,0));
// virtual void DragStart();
// virtual void DragIng();
virtual void Drag(int x, int y,int nNextDragStatus);
virtual bool IsPtInDragArea(int x, int y) const;
private:
_RECT m_DragArea; //this coordinate is relative this dlg
};
#endif | [
"sgch1982@7305fedb-903f-0410-a37f-9f94d3351015"
]
| [
[
[
1,
40
]
]
]
|
2f4539a6b7b49e1076c938acde3170658aadeda3 | 672d939ad74ccb32afe7ec11b6b99a89c64a6020 | /Graph/Graph3D/SetView.cpp | 4a640cf69ade62c6d18d837be731163c3c78caf1 | []
| no_license | cloudlander/legacy | a073013c69e399744de09d649aaac012e17da325 | 89acf51531165a29b35e36f360220eeca3b0c1f6 | refs/heads/master | 2022-04-22T14:55:37.354762 | 2009-04-11T13:51:56 | 2009-04-11T13:51:56 | 256,939,313 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 5,613 | cpp | // SetView.cpp : implementation file
//
#include "stdafx.h"
#include "Graph3D.h"
#include "SetView.h"
#include "MainFrm.h"
#include "ChildView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSetView
extern int Cx,Cy;
IMPLEMENT_DYNCREATE(CSetView, CFormView)
CSetView::CSetView()
: CFormView(CSetView::IDD)
{
//{{AFX_DATA_INIT(CSetView)
//}}AFX_DATA_INIT
}
CSetView::~CSetView()
{
}
void CSetView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSetView)
DDX_Control(pDX, IDC_SLIDER9, m_ctlVUPz);
DDX_Control(pDX, IDC_SLIDER8, m_ctlVUPy);
DDX_Control(pDX, IDC_SLIDER7, m_ctlVUPx);
DDX_Control(pDX, IDC_SLIDER6, m_ctlVPNz);
DDX_Control(pDX, IDC_SLIDER5, m_ctlVPNy);
DDX_Control(pDX, IDC_SLIDER4, m_ctlVPNx);
DDX_Control(pDX, IDC_SLIDER3, m_ctlCOPz);
DDX_Control(pDX, IDC_SLIDER2, m_ctlCOPy);
DDX_Control(pDX, IDC_SLIDER1, m_ctlCOPx);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSetView, CFormView)
//{{AFX_MSG_MAP(CSetView)
ON_WM_HSCROLL()
ON_WM_SIZE()
ON_COMMAND(ID_RESET, OnReset)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSetView diagnostics
#ifdef _DEBUG
void CSetView::AssertValid() const
{
CFormView::AssertValid();
}
void CSetView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CSetView message handlers
void CSetView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
TRACE("Pos is %d\n",nPos);
CString str;
int ctlID;
CMainFrame* pMain;
CChildView* pChild;
pMain=static_cast<CMainFrame*>(AfxGetApp()->GetMainWnd());
pChild=static_cast<CChildView*>(pMain->m_splitterwnd.GetPane(0,1));
// 这里有不解得问题
if ( pScrollBar->IsKindOf( RUNTIME_CLASS( CScrollBar ) ))
{
CFormView::OnHScroll( nSBCode, nPos, pScrollBar );
}
else if ( pScrollBar->IsKindOf( RUNTIME_CLASS( CSliderCtrl ) ))
{
ctlID=pScrollBar->GetDlgCtrlID();
if(nSBCode == SB_THUMBTRACK)
{
str.Format("%d",nPos);
switch(ctlID)
{
case IDC_SLIDER1:
GetDlgItem(IDC_STATICX)->SetWindowText(str);
// m_ctlCOPx.SetPos(nPos);
pChild->SetCOP(m_ctlCOPx.GetPos(),m_ctlCOPy.GetPos(),m_ctlCOPz.GetPos());
break;
case IDC_SLIDER2:
GetDlgItem(IDC_STATICY)->SetWindowText(str);
pChild->SetCOP(m_ctlCOPx.GetPos(),m_ctlCOPy.GetPos(),m_ctlCOPz.GetPos());
break;
case IDC_SLIDER3:
GetDlgItem(IDC_STATICZ)->SetWindowText(str);
pChild->SetCOP(m_ctlCOPx.GetPos(),m_ctlCOPy.GetPos(),m_ctlCOPz.GetPos());
break;
case IDC_SLIDER4:
GetDlgItem(IDC_STATICX2)->SetWindowText(str);
pChild->SetVPN(m_ctlVPNx.GetPos(),m_ctlVPNy.GetPos(),m_ctlVPNz.GetPos());
break;
case IDC_SLIDER5:
GetDlgItem(IDC_STATICY2)->SetWindowText(str);
pChild->SetVPN(m_ctlVPNx.GetPos(),m_ctlVPNy.GetPos(),m_ctlVPNz.GetPos());
break;
case IDC_SLIDER6:
GetDlgItem(IDC_STATICZ2)->SetWindowText(str);
pChild->SetVPN(m_ctlVPNx.GetPos(),m_ctlVPNy.GetPos(),m_ctlVPNz.GetPos());
break;
case IDC_SLIDER7:
GetDlgItem(IDC_STATICX3)->SetWindowText(str);
pChild->SetVUP(m_ctlVUPx.GetPos(),m_ctlVUPy.GetPos(),m_ctlVUPz.GetPos());
break;
case IDC_SLIDER8:
GetDlgItem(IDC_STATICY3)->SetWindowText(str);
pChild->SetVUP(m_ctlVUPx.GetPos(),m_ctlVUPy.GetPos(),m_ctlVUPz.GetPos());
break;
case IDC_SLIDER9:
GetDlgItem(IDC_STATICZ3)->SetWindowText(str);
pChild->SetVUP(m_ctlVUPx.GetPos(),m_ctlVUPy.GetPos(),m_ctlVUPz.GetPos());
break;
default:
ASSERT(FALSE);
}
pChild->Draw();
}
}
else if ( pScrollBar->IsKindOf( RUNTIME_CLASS( CSpinButtonCtrl ) ))
{
CWnd::OnHScroll( nSBCode, nPos, pScrollBar );
}
// CFormView::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CSetView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// TODO: Add your specialized code here and/or call the base class
m_ctlCOPx.SetRange(-100,100);
m_ctlCOPx.SetPos(0);
m_ctlCOPy.SetRange(-100,100);
m_ctlCOPy.SetPos(0);
m_ctlCOPz.SetRange(-74,74);
m_ctlCOPz.SetPos(-10);
m_ctlVPNx.SetRange(-20,20);
m_ctlVPNx.SetPos(0);
m_ctlVPNy.SetRange(-20,20);
m_ctlVPNy.SetPos(0);
m_ctlVPNz.SetRange(-20,20);
m_ctlVPNz.SetPos(-1);
m_ctlVUPx.SetRange(-20,20);
m_ctlVUPx.SetPos(0);
m_ctlVUPy.SetRange(-20,20);
m_ctlVUPy.SetPos(1);
m_ctlVUPz.SetRange(-20,20);
m_ctlVUPz.SetPos(0);
}
void CSetView::OnSize(UINT nType, int cx, int cy)
{
// CFormView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
}
void CSetView::OnReset()
{
// TODO: Add your command handler code here
m_ctlCOPx.SetPos(0);
m_ctlCOPy.SetPos(0);
m_ctlCOPz.SetPos(-10);
m_ctlVPNx.SetPos(0);
m_ctlVPNy.SetPos(0);
m_ctlVPNz.SetPos(-1);
m_ctlVUPx.SetPos(0);
m_ctlVUPy.SetPos(1);
m_ctlVUPz.SetPos(0);
CMainFrame* pMain;
CChildView* pChild;
pMain=static_cast<CMainFrame*>(AfxGetApp()->GetMainWnd());
pChild=static_cast<CChildView*>(pMain->m_splitterwnd.GetPane(0,1));
pChild->SetCOP(0,0,-10);
pChild->SetVPN(0,0,-1);
pChild->SetVUP(0,1,0);
pChild->SetVRP(0,0,800);
pChild->Draw();
}
| [
"xmzhang@5428276e-be0b-f542-9301-ee418ed919ad"
]
| [
[
[
1,
211
]
]
]
|
0a547d1b2d968f5788996d04a65f752efe3d82de | cfcd2a448c91b249ea61d0d0d747129900e9e97f | /thirdparty/OpenCOLLADA/COLLADASaxFrameworkLoader/include/COLLADASaxFWLInputUnshared.h | e06cea3f388ae0d969795c46535d1e616226c36f | []
| 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 | WINDOWS-1252 | C++ | false | false | 7,221 | h | /*
Copyright (c) 2008 NetAllied Systems GmbH
This file is part of COLLADASaxFrameworkLoader.
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 __COLLADASAXFWL_INPUT_UNSHARED_H__
#define __COLLADASAXFWL_INPUT_UNSHARED_H__
#include "COLLADASaxFWLPrerequisites.h"
// TODO
#include "COLLADAFWConstants.h"
#include "COLLADAFWArray.h"
#include "COLLADABUURI.h"
namespace COLLADASaxFWL
{
namespace InputSemantic
{
/** The geometry source data types. */
enum Semantic
{
BINORMAL=0, /** Geometric binormal (bitangent) vector */
COLOR, /** Color coordinate vector. Color inputs are RGB (float3) */
CONTINUITY, /** Continuity constraint at the control vertex (CV). See also "Curve Interpolation" in Chapter 4: Programming Guide. */
IMAGE, /** Raster or MIP-level input. */
INPUT, /** Sampler input. See also "Curve Interpolation" in Chapter 4: Programming Guide. */
IN_TANGENT, /** Tangent vector for preceding control point. See also "Curve Interpolation" in Chapter 4: Programming Guide. */
INTERPOLATION, /** Sampler interpolation type. See also "Curve Interpolation" in Chapter 4: Programming Guide. */
INV_BIND_MATRIX, /** Inverse of local-to-world matrix. */
JOINT, /** Skin influence identifier */
LINEAR_STEPS, /** Number of piece-wise linear approximation steps to use for the spline segment that follows this CV. See also “Curve Interpolation” in Chapter 4: Programming Guide. */
MORPH_TARGET, /** Morph targets for mesh morphing */
MORPH_WEIGHT, /** Weights for mesh morphing */
NORMAL, /** Normal vector */
OUTPUT, /** Sampler output. See also “Curve Interpolation” in Chapter 4: Programming Guide. */
OUT_TANGENT, /** Tangent vector for succeeding control point. See also "Curve Interpolation" in Chapter 4: Programming Guide. */
POSITION, /** Geometric coordinate vector. See also "Curve Interpolation" in Chapter 4: Programming Guide. */
TANGENT, /** Geometric tangent vector */
TEXBINORMAL, /** Texture binormal (bitangent) vector */
TEXCOORD, /** Texture coordinate vector */
TEXTANGENT, /** Texture tangent vector */
UV, /** Generic parameter vector */
VERTEX, /** Mesh vertex */
WEIGHT, /** Skin influence weighting value */
UNKNOWN = -1 /**< An unknown data source. */
};
}
/**
* Declares the input semantics of a data source and connects a consumer to that source.
* Note: There are two <input> variants; see also "<input> (shared)."
* The <input> element declares the input connections that a consumer requires. A data source
* is a container of raw data that lacks semantic meaning so that the data can be reused within
* the document. To use the data, a consumer declares a connection to it with the desired
* semantic information.
* The <source> and <input> elements are part of the COLLADA dataflow model. This model is also
* known as stream processing, pipe, or producer-consumer. An input connection is the dataflow
* path from a <source> to a sink (the dataflow consumers, which are <input>’s parents, such as
* <vertices>).
* In COLLADA, all inputs are driven by index values. A consumer samples an input by supplying
* an index value to an input. Some consumers have simple inputs that are driven by unique
* index values. These inputs are described in this section as unshared inputs but otherwise
* operate in the same manner as shared inputs.
*/
class InputUnshared
{
private:
/** The user-defined meaning of the input connection. Required. See "Details"
for the list of common <input> semantic attribute values enumerated in
the COLLADA schema (type Common_profile_input). */
InputSemantic::Semantic mSemantic;
/** The location of the data source. Required. */
COLLADABU::URI mSource;
public:
/**
* Default-Constructor.
*/
InputUnshared () : mSemantic ( InputSemantic::UNKNOWN ) {}
/**
* Constructor.
* @param semantic The semantic of the @a \<input\> element.
* @param source The source of the @a \<input\> element.
*/
InputUnshared ( InputSemantic::Semantic semantic, const COLLADABU::URI& source );
/**
* Constructor.
* @param semantic The semantic of the @a \<input\> element.
* @param source The source of the @a \<input\> element.
*/
InputUnshared ( const String& semantic, const String& source );
/**
* Destructor.
*/
virtual ~InputUnshared() {}
/**
* The user-defined meaning of the input connection. Required. See InputSemantic::Semantic
* for the list of common <input> semantic attribute values enumerated in the COLLADA
* schema (type Common_profile_input).
* @return const InputSemantic::Semantic The user-defined meaning of the input connection.
*/
const InputSemantic::Semantic& getSemantic () const { return mSemantic; }
/**
* The user-defined meaning of the input connection. Required. See InputSemantic::Semantic
* for the list of common <input> semantic attribute values enumerated in the COLLADA
* schema (type Common_profile_input).
* @param val The user-defined meaning of the input connection.
*/
void setSemantic ( const InputSemantic::Semantic val ) { mSemantic = val; }
/**
* The location of the data source. Required.
* @return const COLLADABU::URI The location of the data source.
*/
const COLLADABU::URI& getSource () const { return mSource; }
/**
* The location of the data source. Required.
* @param val The location of the data source.
*/
void setSource ( const COLLADABU::URI val ) { mSource = val; }
/**
* Returns the string of the current semantic type.
* @param semantic The input semantic as semantic type.
* @return const String& The input semantic as string.
*/
static const String& getSemanticAsString ( const InputSemantic::Semantic semantic );
/**
* Returns the string of the current semantic type.
* @param semanticStr The input semantic as semantic string.
* @return const String& The input semantic as semantic type.
*/
static const InputSemantic::Semantic getSemanticFromString ( const String& semanticStr );
};
/** Pointer to an array of input elements. */
typedef COLLADAFW::ArrayPrimitiveType<InputUnshared*> InputUnsharedArray;
}
#endif // __COLLADASAXFWL_INPUT_UNSHARED_H__ | [
"[email protected]"
]
| [
[
[
1,
162
]
]
]
|
1939111839cd73d5476ed9be016861fbea506853 | c8ab6c440f0e70e848c5f69ccbbfd9fe2913fbad | /bowling/Vertex.cpp | 694837bda1cadad083c8f3d040d5135898cbf2d9 | []
| no_license | alyshamsy/power-bowling | 2b6426cfd4feb355928de95f1840bd39eb88de0b | dd650b2a8e146f6cdf7b6ce703801b96360a90fe | refs/heads/master | 2020-12-24T16:50:09.092801 | 2011-05-12T14:37:15 | 2011-05-12T14:37:15 | 32,115,585 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,200 | cpp | #include <iostream>
#include "Vertex.h"
using namespace std;
/*
The default constructor of the vertex which initiates the x, y and z components to be 0
*/
Vertex::Vertex() {
this->x = 0.0;
this->y = 0.0;
this->z = 0.0;
}
/*
The parameter constructor which takes in 3 parameters a, b and c and assigns them to x, y and z respectively
*/
Vertex::Vertex(float a, float b, float c) {
this->x = a;
this->y = b;
this->z = c;
}
/*
The copy constructor which copies the contents of the source vertex to the local vertex
*/
Vertex::Vertex(const Vertex& source):
x(source.x),
y(source.y),
z(source.z) {
}
/*
The default constructor
*/
Vertex::~Vertex() {
}
/*
The setter method which takes in 3 parameters a, b and c and assigns them to x, y and z respectively
*/
void Vertex::set_vertex(double a, double b, double c) {
this->x = a;
this->y = b;
this->z = c;
}
/*
The assignment operator is used to equate the local vertex to the value provided by the parameter and returns the local vertex
*/
Vertex& Vertex::operator=(const Vertex& rhs) {
if(this == &rhs)
return (*this);
this->x = rhs.x;
this->y = rhs.y;
this->z = rhs.z;
return (*this);
}
/*
the addition operation adds the 2 vertices provided and returns a vertex with the respective x, y and z variables added
*/
Vertex operator+(Vertex& A, Vertex& B) {
Vertex added_vector;
added_vector.x = A.x + B.x;
added_vector.y = A.y + B.y;
added_vector.z = A.z + B.z;
return added_vector;
}
/*
the subtraction operation subtracts the 2 vertices provided and returns the vertex with the respective x, y and z variablessubtracted
*/
Vertex operator-(Vertex& A, Vertex& B) {
Vertex subtracted_vector;
subtracted_vector.x = A.x - B.x;
subtracted_vector.y = A.y - B.y;
subtracted_vector.z = A.z - B.z;
return subtracted_vector;
}
/*
The equals operation which checks if the values of the parameter vertex is the same as the local vertex and returns true else returns false
*/
bool Vertex::operator==(const Vertex& rhs) {
if(this->x == rhs.x && this->y == rhs.y && this->z == rhs.z) {
return true;
} else {
return false;
}
} | [
"aly.shamsy@71b57f4a-8c0b-a9ba-d1fe-6729e2c2215a"
]
| [
[
[
1,
97
]
]
]
|
b4ed88d84a2d9bf807384b1c805a0a10e2390747 | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/os/ossrv/stdlibs/apps/libc/testpipe/inc/testpipe.h | aeee4787bd3cca2b34c05fbd0d7af408cfe36e4e | []
| no_license | SymbianSource/oss.FCL.sftools.ana.compatanamdw | a6a8abf9ef7ad71021d43b7f2b2076b504d4445e | 1169475bbf82ebb763de36686d144336fcf9d93b | refs/heads/master | 2020-12-24T12:29:44.646072 | 2010-11-11T14:03:20 | 2010-11-11T14:03:20 | 72,994,432 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,627 | h | /*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
/*
* ==============================================================================
* Name : tsetpipe.h
* Part of : testpipe
*
* Description : ?Description
* Version: 0.5
*
*/
#ifndef __TESTPIPE_H__
#define __TESTPIPE_H__
#include <test/TestExecuteStepBase.h>
//#include <TestScripterInternal.h>
enum TErrorCode
{
IN = 0x01,
OUT,
ERROR
};
_LIT(KTestPipe, "TestPipe");
_LIT(KPipeCheckWriteOnReadfd, "PipeCheckWriteOnReadfd");
_LIT(KPipeCheckReadOnWritefd, "PipeCheckReadOnWritefd");
_LIT(KPipeWriteRead, "PipeWriteRead");
_LIT(KPipeCheckWriteFd, "PipeCheckWriteFd");
_LIT(KPipeCheckReadFd, "PipeCheckReadFd");
/*popen tests names*/
_LIT(KPopenPipeCommandRead, "PopenPipeCommandRead");
_LIT(KMultiplePopenPipeCommandRead, "MultiplePopenPipeCommandRead");
_LIT(KPopenPipeOEExeRead, "PopenPipeOEExeRead");
_LIT(KPopenPipeInvalidPathRead, "PopenPipeInvalidPathRead");
_LIT(KPopenPipeInvalidCommand, "PopenPipeInvalidCommand");
_LIT(KPopenPipeInvalidMode, "PopenPipeInvalidMode");
_LIT(KPopenPipeWrite, "PopenPipeWrite");
_LIT(KPopenBlockingRead, "PopenBlockingRead");
/*popen3 tests names*/
_LIT(KPopen3PipeCommandRead, "Popen3PipeCommandRead");
_LIT(KMultiplePopen3PipeCommandRead, "MultiplePopen3PipeCommandRead");
_LIT(KPopen3PipeOEExeRead, "Popen3PipeOEExeRead");
_LIT(KPopen3PipeInvalidPathRead, "Popen3PipeInvalidPathRead");
_LIT(KPopen3PipeInvalidCommand, "Popen3PipeInvalidCommand");
_LIT(KTestProcessPopen3ChitChat, "TestProcessPopen3ChitChat");
_LIT(KPopen3ReadWriteTest, "Popen3ReadWriteTest");
_LIT(KTestSystem, "TestSystem");
/*Negative tests*/
_LIT(KLseekpipetest, "Lseekpipetest");
_LIT(KOpenMaxfdPipetest, "OpenMaxfdPipetest");
_LIT(KSimultaneousOpenfdPipetest, "SimultaneousOpenfdPipetest");
_LIT(KFopenMaxPopenTest, "FopenMaxPopenTest");
_LIT(KFopenMaxPopen3Test, "FopenMaxPopen3Test");
_LIT(KTestEnvPopen3, "TestEnvPopen3");
//*DEF111452*//
_LIT(KTestsystem_LongName, "Testsystem_LongName");
_LIT(KTestwsystem_LongName, "Testwsystem_LongName");
_LIT(KTestpopen_LongName, "Testpopen_LongName");
_LIT(KTestwpopen_LongName, "Testwpopen_LongName");
_LIT(KTestpopen3_LongName, "Testpopen3_LongName");
_LIT(KTestwpopen3_LongName, "Testwpopen3_LongName");
/*DEF1222259*/
_LIT(KTestPipeWaitForData, "TestPipeWaitForData");
typedef struct data
{
int fds[2];
int write_size;
int read_size;
}DATA;
class CTestPipe : public CTestStep
{
public:
~CTestPipe();
CTestPipe(const TDesC& aStepName);
TVerdict doTestStepL();
TVerdict doTestStepPreambleL();
TVerdict doTestStepPostambleL();
private:
TInt TestPipe();
/**
* Pipe Write on Read file desc
* @since MRT 2.0
* @param aItem Script line containing parameters.
* @return Symbian OS error code.
*/
virtual TInt PipeCheckWriteOnReadfd( );
/**
* Pipe Read on Write file desc
* @since MRT 2.0
* @param aItem Script line containing parameters.
* @return Symbian OS error code.
*/
virtual TInt PipeCheckReadOnWritefd( );
/**
* Pipe Write and Read
* @since MRT 2.0
* @param aItem Script line containing parameters.
* @return Symbian OS error code.
*/
virtual TInt PipeWriteRead( );
/**
* Pipe Check Write desc
* @since MRT 2.0
* @param aItem Script line containing parameters.
* @return Symbian OS error code.
*/
virtual TInt PipeCheckWriteFd( );
/**
* Pipe Check Read desc
* @since MRT 2.0
* @param aItem Script line containing parameters.
* @return Symbian OS error code.
*/
virtual TInt PipeCheckReadFd( );
// void* ReadData(void *data);
/*popen() tests*/
virtual TInt PopenPipeCommandRead();
virtual TInt MultiplePopenPipeCommandRead();
virtual TInt PopenPipeOEExeRead();
virtual TInt PopenPipeInvalidPathRead();
virtual TInt PopenPipeInvalidCommand();
virtual TInt PopenPipeInvalidMode();
virtual TInt PopenPipeWrite();
virtual TInt PopenBlockingRead();
// virtual TInt PopenNonBlockingReadWithNoData();
/*popen3() tests*/
virtual TInt Popen3PipeCommandRead();
virtual TInt MultiplePopen3PipeCommandRead();
virtual TInt Popen3PipeOEExeRead();
virtual TInt Popen3PipeInvalidPathRead();
virtual TInt Popen3PipeInvalidCommand();
virtual TInt TestProcessPopen3ChitChat();
virtual TInt Popen3ReadWriteTest();
virtual TInt OpenMaxfdPipetest();
/*system() test*/
virtual TInt TestSystem();
/*Negative tests*/
virtual TInt Lseekpipetest();
virtual TInt SimultaneousOpenfdPipetest();
virtual TInt FopenMaxPopenTest();
virtual TInt FopenMaxPopen3Test();
virtual TInt TestEnvPopen3();
//*DEF111452*//
virtual TInt Testwsystem_LongName();
virtual TInt Testsystem_LongName();
virtual TInt Testpopen_LongName();
virtual TInt Testwpopen_LongName();
virtual TInt Testpopen3_LongName();
virtual TInt Testwpopen3_LongName();
/*122259*/
virtual TInt TestPipeWaitForData();
};
#endif
| [
"none@none"
]
| [
[
[
1,
195
]
]
]
|
dc875c060c3bbe49a5e6c1e20a54aecaedaeca56 | c94135316a6706e7a1131e810222c12910cb8495 | /MarbleMadness/ManejadorTextura.cpp | cc4b738b439f3160a2cafb05e4139cc955d31866 | []
| no_license | lcianelli/compgraf-marble-madness | 05d2e8f23adf034723dd3d1267e7cdf6350cf5e7 | f3e79763b43a31095ffeff49f440c24614db045b | refs/heads/master | 2016-09-06T14:20:10.951974 | 2011-05-28T21:10:48 | 2011-05-28T21:10:48 | 32,283,765 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 853 | cpp | #include "ManejadorTextura.h"
ManejadorTextura* ManejadorTextura::_instancia = 0;
ManejadorTextura::ManejadorTextura() {
}
int ManejadorTextura::cargar(const string &archivoTextura) {
if (texturas.find(archivoTextura) != texturas.end()) {
//la textura ya fue cargada
return texturas.find(archivoTextura)->second;
}
int texId;
texturas[archivoTextura] = (texId = glmLoadTexture(archivoTextura.c_str()));
return texId;
}
int ManejadorTextura::getId(const string &archivoTextura) {
if (texturas.find(archivoTextura) != texturas.end()) {
//la textura ya fue cargada
return texturas.find(archivoTextura)->second;
}
return -1;
}
void ManejadorTextura::limpiar() {
this->texturas.clear();
}
void ManejadorTextura::borrar() {
_instancia->limpiar();
delete _instancia;
_instancia = 0;
} | [
"lucia.cianelli@1aa7beb8-f67a-c4d8-682d-4e0fe4e45017",
"srodriki@1aa7beb8-f67a-c4d8-682d-4e0fe4e45017"
]
| [
[
[
1,
2
],
[
5,
6
],
[
8,
10
],
[
19,
22
],
[
27,
27
],
[
29,
30
],
[
33,
36
],
[
42,
42
]
],
[
[
3,
4
],
[
7,
7
],
[
11,
18
],
[
23,
26
],
[
28,
28
],
[
31,
32
],
[
37,
41
]
]
]
|
9c1447ec2c3fb039b9bdf1962babc8e2d2c1b544 | 9eb49222299e0e92722b38959272c0489d20fab7 | /Option.h | 94195882e2cc9fa019914ce1b00e3d7a661ecd99 | []
| no_license | kerolldev/copypathx | f86a4bc7f89dff294e012a951bcdba0faa52c437 | 8d76ab1704014fe4e800e69da46ca9bb27971270 | refs/heads/master | 2021-01-10T19:58:53.262997 | 2011-10-28T02:35:32 | 2011-10-28T02:35:32 | 2,509,231 | 2 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 406 | h | #pragma once
///////////////////////////////////////////////////////////////////
// 設定クラス
class COption
{
public:
COption(HMODULE hModule);
~COption(void);
private:
HMODULE m_hModule;
_TCHAR m_strFile[MAX_PATH];
public:
void Init(void);
int GetInt(_TCHAR * pKeyName, int idef);
void GetString(_TCHAR * pKeyName, _TCHAR * pDefault, _TCHAR * pRetruned, int nSize);
};
| [
"[email protected]"
]
| [
[
[
1,
18
]
]
]
|
a615893357399d35a8b2c04139866638d9acf07b | fac8de123987842827a68da1b580f1361926ab67 | /inc/physics/Common/Base/Types/Geometry/Sphere/hkSphere.inl | 631cfe3a789a2a7bc28a42e88bd2214988b94c9e | []
| 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 | 1,935 | inl | /*
*
* 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.
*
*/
inline hkSphere::hkSphere()
{
}
inline hkSphere::hkSphere(const hkVector4& pt, hkReal radius)
{
m_pos = pt;
m_pos(3) = radius;
}
inline hkReal hkSphere::getRadius() const
{
return m_pos(3);
}
inline void hkSphere::setRadius(hkReal newRadius)
{
m_pos(3) = newRadius;
}
inline const hkVector4& hkSphere::getPosition() const
{
return m_pos;
}
inline const hkVector4& hkSphere::getPositionAndRadius() const
{
return m_pos;
}
inline hkVector4& hkSphere::getPositionAndRadius()
{
return m_pos;
}
inline void hkSphere::setPosition(const hkVector4& newPos)
{
m_pos.setXYZ( newPos ); // do not override the z component
}
inline void hkSphere::setPositionAndRadius( const hkVector4& newPos )
{
m_pos = newPos;
}
/*
* 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,
68
]
]
]
|
fe23b1b4e5fa0c8aae9d93a31126ed39f32d94f6 | b2c66c8de198d9915dfc63b8c60cb82e57643a6b | /UnitTest/trunk/ScoreRankTest.cpp | 6c5b5e4f5f4a4abb0196c4fcedd450eceda671b4 | []
| no_license | feleio/words-with-friends-exhaustive-cheater | 88d6d401c28ef7bb82099c0cd9d77459828b89ca | bc198ee2677be02fc935fb8bb8e74b580f0540df | refs/heads/master | 2021-01-02T08:54:47.975272 | 2011-05-10T14:51:06 | 2011-05-10T14:51:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,452 | cpp | #include "TestHarness.h"
#include "ScoreRank.h"
#include "PlacedTileInfo.h"
TEST( ScoreRank, Submit )
{
ScoreRank subject;
int score[30];
int placedSize[30];
score[0] = 35; placedSize[0] = 0;
score[1] = 11; placedSize[1] = score[1] %7 + 1;
score[2] = 0 ; placedSize[2] = score[2] %7 + 1;
score[3] = 16; placedSize[3] = score[3] %7 + 1;
score[4] = 12; placedSize[4] = score[4] %7 + 1;
score[5] = 1 ; placedSize[5] = score[5] %7 + 1;
score[6] = 6 ; placedSize[6] = score[6] %7 + 1;
score[7] = 18; placedSize[7] = score[7] %7 + 1;
score[8] = 35; placedSize[8] = 8;
score[9] = 35; placedSize[9] = 9;
score[10] = 35; placedSize[10] = 0;
score[11] = 10; placedSize[11] = score[11] %7 + 1;
score[12] = 9 ; placedSize[12] = score[12] %7 + 1;
score[13] = 5 ; placedSize[13] = score[13] %7 + 1;
score[14] = 14; placedSize[14] = score[14] %7 + 1;
score[15] = 2 ; placedSize[15] = score[15] %7 + 1;
score[16] = 13; placedSize[16] = score[16] %7 + 1;
score[17] = 4 ; placedSize[17] = score[17] %7 + 1;
score[18] = 35; placedSize[18] = 8;
score[19] = 35; placedSize[19] = 9;
score[20] = 35; placedSize[20] = 0;
score[21] = 17; placedSize[21] = score[21] %7 + 1;
score[22] = 0 ; placedSize[22] = score[22] %7 + 1;
score[23] = 3 ; placedSize[23] = score[23] %7 + 1;
score[24] = 7 ; placedSize[24] = score[24] %7 + 1;
score[25] = 8 ; placedSize[25] = score[25] %7 + 1;
score[26] = 0 ; placedSize[26] = score[26] %7 + 1;
score[27] = 15; placedSize[27] = score[27] %7 + 1;
score[28] = 35; placedSize[28] = 8;
score[29] = 35; placedSize[29] = 9;
PlacedTileInfo placedTiles[8];
for(int i = 0; i< 8; ++i )
{
placedTiles[i].m_row = 2*i + i;
placedTiles[i].m_col = 2*i + i;
placedTiles[i].m_placedChar = 'a' + 2*i + i;
}
for(int i =0; i<30; ++i)
subject.Submit( score[i], placedSize[i], placedTiles );
std::vector<ScoreRank::RankEntity>::const_iterator begin;
std::vector<ScoreRank::RankEntity>::const_iterator end;
subject.GetResults( begin, end );
int expScore = 18;
for( std::vector<ScoreRank::RankEntity>::const_iterator itr = begin;
itr != end;
++itr )
{
CHECK( itr->m_score == expScore );
CHECK( itr->m_numPlacedTiles == itr->m_score % 7 + 1);
CHECK( std::memcmp( itr->m_placedTiles, placedTiles, (itr->m_numPlacedTiles) * sizeof(ScoreRank::RankEntity) ) == 0 );
--expScore;
}
}
TEST( ScoreRank, Submit_with_few_results )
{
ScoreRank subject;
int score[30];
int placedSize[30];
score[0] = 35; placedSize[0] = 0;
score[1] = 11; placedSize[1] = score[1] %7 + 1;
score[2] = 0 ; placedSize[2] = 0;
score[3] = 16; placedSize[3] = score[3] %7 + 1;
score[4] = 12; placedSize[4] = score[4] %7 + 1;
score[5] = 1 ; placedSize[5] = 0;
score[6] = 6 ; placedSize[6] = 0;
score[7] = 18; placedSize[7] = score[7] %7 + 1;
score[8] = 35; placedSize[8] = 8;
score[9] = 35; placedSize[9] = 9;
score[10] = 35; placedSize[10] = 0;
score[11] = 10; placedSize[11] = score[11] %7 + 1;
score[12] = 9 ; placedSize[12] = score[12] %7 + 1;
score[13] = 5 ; placedSize[13] = 0;
score[14] = 14; placedSize[14] = score[14] %7 + 1;
score[15] = 2 ; placedSize[15] = 0;
score[16] = 13; placedSize[16] = score[16] %7 + 1;
score[17] = 4 ; placedSize[17] = 0;
score[18] = 35; placedSize[18] = 8;
score[19] = 35; placedSize[19] = 9;
score[20] = 35; placedSize[20] = 0;
score[21] = 17; placedSize[21] = score[21] %7 + 1;
score[22] = 0 ; placedSize[22] = 0;
score[23] = 3 ; placedSize[23] = 0;
score[24] = 7 ; placedSize[24] = 0;
score[25] = 8 ; placedSize[25] = 0;
score[26] = 0 ; placedSize[26] = 0;
score[27] = 15; placedSize[27] = score[27] %7 + 1;
score[28] = 35; placedSize[28] = 8;
score[29] = 35; placedSize[29] = 9;
PlacedTileInfo placedTiles[8];
for(int i = 0; i< 8; ++i )
{
placedTiles[i].m_row = 2*i + i;
placedTiles[i].m_col = 2*i + i;
placedTiles[i].m_placedChar = 'a' + 2*i + i;
}
for(int i =0; i<30; ++i)
subject.Submit( score[i], placedSize[i], placedTiles );
std::vector<ScoreRank::RankEntity>::const_iterator begin;
std::vector<ScoreRank::RankEntity>::const_iterator end;
subject.GetResults( begin, end );
int expScore = 18;
for( std::vector<ScoreRank::RankEntity>::const_iterator itr = begin;
itr != end;
++itr )
{
CHECK( itr->m_score == expScore );
CHECK( itr->m_numPlacedTiles == itr->m_score % 7 + 1);
CHECK( std::memcmp( itr->m_placedTiles, placedTiles, (itr->m_numPlacedTiles) * sizeof(ScoreRank::RankEntity) ) == 0 );
--expScore;
}
}
TEST( ScoreRank, Reset )
{
ScoreRank subject;
int score[30];
int placedSize[30];
score[0] = 35; placedSize[0] = 0;
score[1] = 11; placedSize[1] = score[1] %7 + 1;
score[2] = 0 ; placedSize[2] = score[2] %7 + 1;
score[3] = 16; placedSize[3] = score[3] %7 + 1;
score[4] = 12; placedSize[4] = score[4] %7 + 1;
score[5] = 1 ; placedSize[5] = score[5] %7 + 1;
score[6] = 6 ; placedSize[6] = score[6] %7 + 1;
score[7] = 18; placedSize[7] = score[7] %7 + 1;
score[8] = 35; placedSize[8] = 8;
score[9] = 35; placedSize[9] = 9;
score[10] = 35; placedSize[10] = 0;
score[11] = 10; placedSize[11] = score[11] %7 + 1;
score[12] = 9 ; placedSize[12] = score[12] %7 + 1;
score[13] = 5 ; placedSize[13] = score[13] %7 + 1;
score[14] = 14; placedSize[14] = score[14] %7 + 1;
score[15] = 2 ; placedSize[15] = score[15] %7 + 1;
score[16] = 13; placedSize[16] = score[16] %7 + 1;
score[17] = 4 ; placedSize[17] = score[17] %7 + 1;
score[18] = 35; placedSize[18] = 8;
score[19] = 35; placedSize[19] = 9;
score[20] = 35; placedSize[20] = 0;
score[21] = 17; placedSize[21] = score[21] %7 + 1;
score[22] = 0 ; placedSize[22] = score[22] %7 + 1;
score[23] = 3 ; placedSize[23] = score[23] %7 + 1;
score[24] = 7 ; placedSize[24] = score[24] %7 + 1;
score[25] = 8 ; placedSize[25] = score[25] %7 + 1;
score[26] = 0 ; placedSize[26] = score[26] %7 + 1;
score[27] = 15; placedSize[27] = score[27] %7 + 1;
score[28] = 35; placedSize[28] = 8;
score[29] = 35; placedSize[29] = 9;
PlacedTileInfo placedTiles[8];
for(int i = 0; i< 8; ++i )
{
placedTiles[i].m_row = 2*i + i;
placedTiles[i].m_col = 2*i + i;
placedTiles[i].m_placedChar = 'a' + 2*i + i;
}
for(int i =0; i<30; ++i)
subject.Submit( score[i], placedSize[i], placedTiles );
subject.Reset();
std::vector<ScoreRank::RankEntity>::const_iterator begin;
std::vector<ScoreRank::RankEntity>::const_iterator end;
subject.GetResults( begin, end );
CHECK( begin == end );
} | [
"[email protected]@2165158a-c2d0-8582-d542-857db5896f79"
]
| [
[
[
1,
194
]
]
]
|
d08e0c357af727ebe7f25ea42f813c2b7683a267 | ede4ece661bdf14c10d81d31e2078e74b098bb45 | /libkindi/src/detail/type_info.cpp | 3bf42a516df8596190a61e4e4ca3dacc83427992 | [
"BSL-1.0"
]
| permissive | TheProjecter/kindi | c5a3fd4b0c0203379954caa869779e7f96d7c142 | c90ae632bc5ec391d3c26517a2b2c11d57201840 | refs/heads/master | 2020-04-19T20:45:44.165131 | 2011-08-07T01:49:22 | 2011-08-07T01:49:22 | 42,944,646 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,338 | cpp | // ***************************************************************************
// (C) Copyright Sébastien Débia 2011.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://code.google.com/p/kindi/ for the library home page.
//
// File : $RCSfile$
//
// Version : $Revision: 0 $
// ***************************************************************************
#include "kindi/detail/type_info.hpp"
#include "kindi/detail/demangle.hpp"
#include <ostream>
bool kindi::detail::type_info::operator<( type_info const & rhs ) const
{
return m_info->before( *rhs.m_info ) ? true : false;
}
bool kindi::detail::type_info::operator==( type_info const & rhs ) const
{
return !( *this < rhs ) && !( rhs < *this );
}
bool kindi::detail::type_info::operator!=( type_info const & rhs ) const
{
return !( *this == rhs );
}
std::string kindi::detail::type_info::name() const
{
return m_info->name();
}
kindi::detail::type_info::type_info()
: m_info( &typeid(kindi::type_wrapper<void>::type) )
{
}
std::ostream& kindi::detail::operator<<( std::ostream & os, const type_info & info )
{
return os << detail::demangle( info.name() );
}
| [
"[email protected]"
]
| [
[
[
1,
46
]
]
]
|
adeafa3bcf45b4e90038eb44705838d9eebf4b41 | 7af9fe205f0391d92ae2dad0364f0d2445f136f6 | /pointers/pointers2.cpp | 8e186ee5456b0df23dac768a5ced481fd18b6159 | []
| no_license | yujack12/Cpp | f3ea85baf9a4f64a17743dbba97b82996642e3f6 | 7c0a0197c5df2dc5b985cdc063f49e90fbe56b21 | refs/heads/master | 2021-01-20T23:32:46.830033 | 2011-12-08T11:38:40 | 2011-12-08T11:38:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 290 | cpp | /**
* Studying C++
* Pointers
*
* Fredi Machado
* http://github.com/fredi
*/
#include <cstdio>
int main()
{
int x = 4;
int* pX = &x;
printf("[%p] %d\n", pX, *pX);
int y = 10;
pX = &y;
printf("[%p] %d\n", pX, *pX);
return 0;
}
| [
"[email protected]"
]
| [
[
[
1,
24
]
]
]
|
e42965a97a435d3a549c7b7280130c7e6926fc1f | 27bde5e083cf5a32f75de64421ba541b3a23dd29 | /source/Entity.cpp | 6b15939791521ff9362c1ba3cd0b6062cef2ac23 | []
| no_license | jbsheblak/fatal-inflation | 229fc6111039aff4fd00bb1609964cf37e4303af | 5d6c0a99e8c4791336cf529ed8ce63911a297a23 | refs/heads/master | 2021-03-12T19:22:31.878561 | 2006-10-20T21:48:17 | 2006-10-20T21:48:17 | 32,184,096 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,595 | cpp | //---------------------------------------------------
// Name: Game : Entity
// Desc: a thing on the field
// Author: John Sheblak
// Contact: [email protected]
//---------------------------------------------------
#include "Entity.h"
#include <assert.h>
#include "Algorithms.h"
#include "ResourceCache.h"
#include "FileIO.h"
#include "GameXExt.h"
namespace Game
{
//----------------------------------------------------------------------------
// Name: EntityDescManager
// Desc: manages an entities properties
//----------------------------------------------------------------------------
//-----------------------------------------------------------
// Name: EntityDescManager
// Desc: constructor
//-----------------------------------------------------------
EntityDescManager::EntityDescManager( EntityDesc* desc )
{
mDesc = desc;
}
//-----------------------------------------------------------
// Name: ContainsProperty
// Desc: checks if this arrow's desc contains this prop
//-----------------------------------------------------------
bool EntityDescManager::ContainsProperty( uint32_t flag )
{
EntityDesc::iterator itr;
for( itr = mDesc->begin(); itr != mDesc->end(); ++itr )
{
if( itr->mFlag == flag )
{
return true;
}
}
return false;
}
//-----------------------------------------------------------
// Name: GetProperty
// Desc: attempts to get the property with givne flag
//-----------------------------------------------------------
bool EntityDescManager::GetProperty( uint32_t flag, EntityProperty& out )
{
EntityDesc::iterator itr;
for( itr = mDesc->begin(); itr != mDesc->end(); ++itr )
{
if( itr->mFlag == flag )
{
out.mData = itr->mData;
out.mDataSize = itr->mDataSize;
out.mFlag = itr->mFlag;
return true;
}
}
return false;
}
//-----------------------------------------------------------
// Name: AddProperty
// Desc: adds a property to the description (does not check for existance)
//-----------------------------------------------------------
bool EntityDescManager::AddProperty( const EntityProperty& prop )
{
mDesc->push_back(prop);
return true;
}
//-----------------------------------------------------------
// Name: RemoveProperty
// Desc: removes a property from a description
//-----------------------------------------------------------
bool EntityDescManager::RemoveProperty( uint32_t flag )
{
EntityDesc::iterator itr;
for( itr = mDesc->begin(); itr != mDesc->end(); ++itr )
{
if( itr->mFlag == flag )
{
mDesc->erase(itr);
return true;
}
}
return false;
}
//-----------------------------------------------------------
// Name: SetPropertyFromArrayne
// Desc: sets or adds a property in a description
//-----------------------------------------------------------
template <typename T>
bool SetPropertyFromArray2e( EntityDescManager* man, uint32_t flag, T e1, T e2 )
{
T elem [] = { e1, e2 };
return man->SetProperty( flag, (void*)elem, sizeof(T) * 2 );
}
//-----------------------------------------------------------
// Name: SetPropertyFromArrayne
// Desc: sets or adds a property in a description
//-----------------------------------------------------------
template <typename T>
bool SetPropertyFromArray1e( EntityDescManager* man, uint32_t flag, T e1 )
{
T elem [] = { e1 };
return man->SetProperty( flag, (void*)elem, sizeof(T) * 1 );
}
//-----------------------------------------------------------
// Name: SetProperty
// Desc: sets or adds a property in a description
//-----------------------------------------------------------
bool EntityDescManager::SetProperty( uint32_t flag, void* data, uint32_t dataSize )
{
EntityProperty prop;
prop.mFlag = flag;
prop.mData = (uint8_t*)data;
prop.mDataSize = dataSize;
return SetProperty(prop);
}
//-----------------------------------------------------------
// Name: SetProperty
// Desc: sets or adds a property in a description
//-----------------------------------------------------------
bool EntityDescManager::SetProperty( const EntityProperty& prop )
{
// if prop has a data size of zero, it indicates that we
// are just trying to pass a ptr (ie: passing the base image ptr)
EntityProperty internal;
if( GetProperty( prop.mFlag, internal ) )
{
assert( internal.mData );
if( !internal.mDataSize )
{
internal.mData = prop.mData;
}
else
{
memcpy( internal.mData, prop.mData, internal.mDataSize );
}
}
else
{
EntityProperty newProp;
newProp.mFlag = prop.mFlag;
newProp.mDataSize = prop.mDataSize;
if( newProp.mDataSize )
{
newProp.mData = new uint8_t[prop.mDataSize];
memcpy( newProp.mData, prop.mData, prop.mDataSize );
}
else
{
newProp.mData = prop.mData;
}
AddProperty(newProp);
}
return true;
}
bool EntityDescManager::SetProperty2i( uint32_t flag, int32_t e1, int32_t e2 )
{
return SetPropertyFromArray2e<int32_t>( this, flag, e1, e2 );
}
bool EntityDescManager::SetProperty1f( uint32_t flag, F32 e1 )
{
return SetPropertyFromArray1e<F32>( this, flag, e1 );
}
bool EntityDescManager::SetProperty2f( uint32_t flag, F32 e1, F32 e2 )
{
return SetPropertyFromArray2e<F32>( this, flag, e1, e2 );
}
bool EntityDescManager::SetPropertyPtr( uint32_t flag, void* ptr )
{
return SetProperty( flag, ptr, 0 );
}
bool EntityDescManager::GetProperty2i( uint32_t flag, int32_t& e1, int32_t& e2 )
{
EntityProperty prop;
if( !GetProperty(flag,prop) )
return false;
int32_t* data = (int32_t*)prop.mData;
e1 = data[0];
e2 = data[1];
return true;
}
//----------------------------------------------------------------------------
// Name: Entity
// Desc: A basic unit on the field
//----------------------------------------------------------------------------
//-----------------------------------------------------------
// Name: Entity
// Desc: constructor
//-----------------------------------------------------------
Entity::Entity( EntityDesc* desc ) : mStartTime(-1.0f)
, mBaseImage(NULL)
{
if( desc )
{
EntityDesc::iterator itr;
for( itr = desc->begin(); itr != desc->end(); ++itr )
{
switch( itr->mFlag )
{
case kEntProp_BaseImage:
{
mBaseImage = (ImageX*)itr->mData;
break;
}
}
}
}
}
//-----------------------------------------------------------
// Name: SetStartTime
// Desc: set the start (spawn) time for entity
//-----------------------------------------------------------
void Entity::SetStartTime( F32 time )
{
mStartTime = time;
}
//-----------------------------------------------------------
// Name: DestroyEntityDescMap
// Desc: delete entity property data
//-----------------------------------------------------------
void DestroyEntityDescMap( EntityDescMap* descMap )
{
if( !descMap )
return;
EntityDescMap::iterator itr;
for( itr = descMap->begin(); itr != descMap->end(); ++itr )
{
EntityDesc::iterator propItr;
for( propItr = itr->second.begin(); propItr != itr->second.end(); ++propItr )
{
if( propItr->mData && propItr->mDataSize )
delete [] propItr->mData;
}
}
}
}; //end Game
| [
"jbsheblak@5660b91f-811d-0410-8070-91869aa11e15"
]
| [
[
[
1,
268
]
]
]
|
c42af6b5b60511148065fe2463d7c3d0361ac33e | a2904986c09bd07e8c89359632e849534970c1be | /topcoder/PalindromesCount.cpp | a2ccd237d797eb1d3eae85304960ee7fdbf62c5b | []
| no_license | naturalself/topcoder_srms | 20bf84ac1fd959e9fbbf8b82a93113c858bf6134 | 7b42d11ac2cc1fe5933c5bc5bc97ee61b6ec55e5 | refs/heads/master | 2021-01-22T04:36:40.592620 | 2010-11-29T17:30:40 | 2010-11-29T17:30:40 | 444,669 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,735 | cpp | // BEGIN CUT HERE
// END CUT HERE
#line 5 "PalindromesCount.cpp"
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
#define forv(i, v) for (int i = 0; i < (int)(v.size()); ++i)
#define fors(i, s) for (int i = 0; i < (int)(s.length()); ++i)
#define all(a) a.begin(), a.end()
class PalindromesCount {
public:
int count(string A, string B) {
int ret=0;
for(int i=0;i<=(int)A.size();i++){
string str = A;
str.insert(i,B);
ret += isPal(str);
}
return ret;
}
private:
int isPal(string s){
int mid = 0;
string rev;
int n = (int)s.size();
mid = (n/2);
if(n%2==0){
rev = s.substr(mid);
}else{
rev = s.substr(mid+1);
}
reverse(all(rev));
if(s.substr(0,mid)==rev){
return 1;
}else{
return 0;
}
return 0;
}
// BEGIN CUT HERE
public:
void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); if ((Case == -1) || (Case == 4)) test_case_4(); }
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() { string Arg0 = "aba"; string Arg1 = "b"; int Arg2 = 2; verify_case(0, Arg2, count(Arg0, Arg1)); }
void test_case_1() { string Arg0 = "aa"; string Arg1 = "a"; int Arg2 = 3; verify_case(1, Arg2, count(Arg0, Arg1)); }
void test_case_2() { string Arg0 = "aca"; string Arg1 = "bb"; int Arg2 = 0; verify_case(2, Arg2, count(Arg0, Arg1)); }
void test_case_3() { string Arg0 = "abba"; string Arg1 = "abba"; int Arg2 = 3; verify_case(3, Arg2, count(Arg0, Arg1)); }
void test_case_4() { string Arg0 = "topcoder"; string Arg1 = "coder"; int Arg2 = 0; verify_case(4, Arg2, count(Arg0, Arg1)); }
// END CUT HERE
};
// BEGIN CUT HERE
int main() {
PalindromesCount ___test;
___test.run_test(-1);
}
// END CUT HERE
| [
"shin@CF-7AUJ41TT52JO.(none)"
]
| [
[
[
1,
90
]
]
]
|
1ead5d40f03c1f8b7b483c22acb49f1e815f32a0 | 21ade818b3e3f355a6cb7ba7839bc3e9ceda2abe | /add_dino.cpp | 5538d06ba263adc2c3d9e4f78906a4889a8283f5 | []
| no_license | sajal14/game | b2ebe8037c2ff821147bc399a413b95486d8eb1f | 7a7affda35c88f9d2f1056dc53e9b10ee20249b6 | refs/heads/master | 2021-01-10T20:38:48.484984 | 2011-04-16T20:47:15 | 2011-04-16T20:47:15 | 1,624,173 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,530 | cpp |
/*This source code copyrighted by Lazy Foo' Productions (2004-2011)
and may not be redestributed without written permission.*/
//The headers
SDL_Surface *screen = NULL;
SDL_Surface *image_quit = NULL;
SDL_Surface *image_start = NULL;
SDL_Surface *background = NULL;
SDL_Event event;
//const int SCREEN_WIDTH = 640;
//const int SCREEN_HEIGHT = 480;
//const int SCREEN_BPP = 32;
//Screen attributes
//The frames per second
const int FRAMES_PER_SECOND = 15;
//The dimenstions of the stick figure
const int FOO_WIDTH = 48;
const int FOO_HEIGHT = 50;
//The direction status of the stick figure
const int FOO_RIGHT = 0;
const int FOO_LEFT = 1;
const int FOO_UP = 3;
const int FOO_DOWN = 2;
//The surfaces
SDL_Surface *image = NULL;
//The event structure
//SDL_Event event;
//The areas of the sprite sheet
SDL_Rect clipsRight[ 5];
SDL_Rect clipsLeft[ 4 ];
SDL_Rect clipsUp[ 5 ];
SDL_Rect clipsDown[ 5 ];
//The stick figure
class Foo
{
private:
//The offset
int xoffSet;
int yoffSet;
//Its rate of movement
int xvelocity;
int yvelocity;
//Its current frame
int frame;
//Its animation status
int status;
public:
//Initializes the variables
Foo();
//Handles input
void handle_events();
//Moves the stick figure
void move();
//Shows the stick figure
void show();
};
//The timer
class Timer
{
private:
//The clock time when the timer started
int startTicks;
//The ticks stored when the timer was paused
int pausedTicks;
//The timer status
bool paused;
bool started;
public:
//Initializes variables
Timer();
//The various clock actions
void start();
void stop();
void pause();
void unpause();
//Gets the timer's time
int get_ticks();
//Checks the status of the timer
bool is_started();
bool is_paused();
};
/*SDL_Surface *load_image( std::string filename )
{
//The image that's loaded
SDL_Surface* loadedImage = NULL;
//The optimized surface that will be used
SDL_Surface* optimizedImage = NULL;
//Load the image
loadedImage = IMG_Load( filename.c_str() );
//If the image loaded
if( loadedImage != NULL )
{
//Create an optimized surface
optimizedImage = SDL_DisplayFormat( loadedImage );
//Free the old surface
SDL_FreeSurface( loadedImage );
//If the surface was optimized
if( optimizedImage != NULL )
{
//Color key surface
SDL_SetColorKey( optimizedImage, SDL_SRCCOLORKEY, SDL_MapRGB( optimizedImage->format, 0, 0xFF, 0xFF ) );
}
}
//Return the optimized surface
return optimizedImage;
}
void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip = NULL )
{
//Holds offsets
SDL_Rect offset;
//Get offsets
offset.x = x;
offset.y = y;
//Blit
SDL_BlitSurface( source, clip, destination, &offset );
}
*/
void set_clips()
{
//Clip the sprites
clipsRight[ 0 ].x = 0;
clipsRight[ 0 ].y = 0;
clipsRight[ 0 ].w = 40;
clipsRight[ 0 ].h = 50;
clipsRight[ 1 ].x = 40;
clipsRight[ 1 ].y = 0;
clipsRight[ 1 ].w = 50;
clipsRight[ 1 ].h = 50;
clipsRight[ 2 ].x = 90;
clipsRight[ 2 ].y = 0;
clipsRight[ 2 ].w = 50;
clipsRight[ 2 ].h = 50;
clipsRight[ 3 ].x = 140;
clipsRight[ 3 ].y = 0;
clipsRight[ 3 ].w = 50;
clipsRight[ 3 ].h = 50;
clipsRight[ 4 ].x = 190;
clipsRight[ 4 ].y = 0;
clipsRight[ 4 ].w = 45;
clipsRight[ 4 ].h = 50;
clipsLeft[ 0 ].x = 270;
clipsLeft[ 0 ].y = 220;
clipsLeft[ 0 ].w =40;
clipsLeft[ 0 ].h =40;
clipsLeft[ 1 ].x = 310;
clipsLeft[ 1 ].y = 220;
clipsLeft[ 1 ].w = 40;
clipsLeft[ 1 ].h = 40;
clipsLeft[ 2 ].x = 350;
clipsLeft[ 2 ].y = 220;
clipsLeft[ 2 ].w = 45;
clipsLeft[ 2 ].h = 40;
clipsLeft[ 3 ].x = 395;
clipsLeft[ 3 ].y = 220;
clipsLeft[ 3 ].w = 40;
clipsLeft[ 3 ].h = 40;
clipsUp[ 0 ].x = 0;
clipsUp [ 0 ].y = 100;
clipsUp[ 0 ].w = 50;
clipsUp[ 0 ].h = 50;
clipsUp[ 1 ].x = 50;
clipsUp[ 1 ].y = 100;
clipsUp[ 1 ].w = 50;
clipsUp[ 1 ].h = 50;
clipsUp[ 2 ].x = 100;
clipsUp[ 2 ].y = 100;
clipsUp[ 2 ].w = 40;
clipsUp[ 2 ].h = 50;
clipsUp[ 3 ].x = 140;
clipsUp[ 3 ].y = 100;
clipsUp[ 3 ].w = 45;
clipsUp[ 3 ].h = 50;
clipsUp[ 4].x = 185;
clipsUp[ 4 ].y = 100;
clipsUp[ 4 ].w = 45;
clipsUp[ 4 ].h = 50;
clipsDown[ 0 ].x = 0;
clipsDown [ 0 ].y = 50;
clipsDown[ 0 ].w = 40;
clipsDown[ 0 ].h = 50;
clipsDown[ 1 ].x = 40;
clipsDown[ 1 ].y = 50;
clipsDown[ 1 ].w = 45;
clipsDown[ 1 ].h = 50;
clipsDown[ 2 ].x = 85;
clipsDown[ 2 ].y = 50;
clipsDown[ 2 ].w = 50;
clipsDown[ 2 ].h = 50;
clipsDown[ 3 ].x = 135;
clipsDown[ 3 ].y = 50;
clipsDown[ 3 ].w = 50;
clipsDown[ 3 ].h = 50;
clipsDown[ 4].x = 185;
clipsDown[ 4 ].y = 50;
clipsDown[ 4 ].w = 45;
clipsDown[ 4 ].h = 50;
}
/*bool init()
{
//Initialize all SDL subsystems
if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 )
{
return false;
}
//Set up the screen
screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );
//If there was an error in setting up the screen
if( screen == NULL )
{
return false;
}
//Set the window caption
SDL_WM_SetCaption( "Animation Test", NULL );
//If everything initialized fine
return true;
}
bool load_files()
{
//Load the sprite sheet
image = load_image( "try.gif" );
background = load_image( "back.png" );
image_quit = load_image("quit.png");
image_start = load_image("start.png");
return true;
//If there was a problem in loading the sprite
if( image == NULL )
{
return false;
}
//If everything loaded fine
return true;
}
void clean_up()
{
//Free the surface
SDL_FreeSurface( image );
//Quit SDL
SDL_Quit();
}
*/
Foo::Foo()
{
//Initialize movement variables
xoffSet = 0;
yoffSet = 0;
xvelocity = 0;
yvelocity=0;
//Initialize animation variables
frame = 0;
status = FOO_RIGHT;
}
void Foo::handle_events()
{
//If a key was pressed
if( event.type == SDL_KEYDOWN )
{
//Set the velocity
switch( event.key.keysym.sym )
{
case SDLK_RIGHT: xvelocity += FOO_WIDTH /4; break;
case SDLK_LEFT: xvelocity -= FOO_WIDTH / 4; break;
case SDLK_DOWN: yvelocity += FOO_WIDTH / 4; break;
case SDLK_UP: yvelocity -= FOO_WIDTH / 4; break;
}
}
//If a key was released
else if( event.type == SDL_KEYUP )
{
//Set the velocity
switch( event.key.keysym.sym )
{
case SDLK_RIGHT: xvelocity -= FOO_WIDTH / 4; break;
case SDLK_LEFT: xvelocity += FOO_WIDTH / 4; break;
case SDLK_DOWN: yvelocity -= FOO_WIDTH / 4; break;
case SDLK_UP: yvelocity += FOO_WIDTH / 4; break;
}
}
}
void Foo::move()
{
//Move
xoffSet += xvelocity;
//Keep the stick figure in bounds
if( ( xoffSet < 0 ) || ( xoffSet > SCREEN_WIDTH-40) )
{
xoffSet -= xvelocity;
}
yoffSet+= yvelocity;
if((yoffSet <0)|| (yoffSet > SCREEN_HEIGHT+ FOO_HEIGHT+40))
{
yoffSet-= yvelocity;
}
}
void Foo::show()
{
//If Foo is moving left
if( xvelocity < 0 )
{
//Set the animation to left
status = FOO_LEFT;
//Move to the next frame in the animation
frame++;
}
//If Foo is moving right
else if( xvelocity > 0 )
{
//Set the animation to right
status = FOO_RIGHT;
//Move to the next frame in the animation
frame++;
}
else if( yvelocity < 0 )
{
//Set the animation to right
status = FOO_UP;
//Move to the next frame in the animation
frame++;
}
else if( yvelocity > 0 )
{
//Set the animation to right
status = FOO_DOWN;
//Move to the next frame in the animation
frame++;
}
//If Foo standing
else
{
//Restart the animation
frame = 0;
}
//Loop the animation
if( frame >= 4 )
{
frame = 0;
}
//Show the stick figure
if( status == FOO_RIGHT )
{
apply_surface( xoffSet, yoffSet, image, screen, &clipsRight[frame] );
}
else if( status == FOO_LEFT )
{
apply_surface( xoffSet, yoffSet, image, screen, &clipsLeft[frame] );
}
else if( status == FOO_UP )
{
apply_surface( xoffSet, yoffSet, image, screen, &clipsUp[ frame ] );
}
else if( status == FOO_DOWN )
{
apply_surface( xoffSet, yoffSet, image, screen, &clipsDown[ frame ] );
}
}
Timer::Timer()
{
//Initialize the variables
startTicks = 0;
pausedTicks = 0;
paused = false;
started = false;
}
void Timer::start()
{
//Start the timer
started = true;
//Unpause the timer
paused = false;
//Get the current clock time
startTicks = SDL_GetTicks();
}
void Timer::stop()
{
//Stop the timer
started = false;
//Unpause the timer
paused = false;
}
void Timer::pause()
{
//If the timer is running and isn't already paused
if( ( started == true ) && ( paused == false ) )
{
//Pause the timer
paused = true;
//Calculate the paused ticks
pausedTicks = SDL_GetTicks() - startTicks;
}
}
void Timer::unpause()
{
//If the timer is paused
if( paused == true )
{
//Unpause the timer
paused = false;
//Reset the starting ticks
startTicks = SDL_GetTicks() - pausedTicks;
//Reset the paused ticks
pausedTicks = 0;
}
}
int Timer::get_ticks()
{
//If the timer is running
if( started == true )
{
//If the timer is paused
if( paused == true )
{
//Return the number of ticks when the timer was paused
return pausedTicks;
}
else
{
//Return the current time minus the start time
return SDL_GetTicks() - startTicks;
}
}
//If the timer isn't running
return 0;
}
bool Timer::is_started()
{
return started;
}
bool Timer::is_paused()
{
return paused;
}
void dino_main()
{
//Quit flag
bool quit = false;
//Initialize
if (init()== false)
{
}
//Load the files
if( load_files() == false )
{
}
//Clip the sprite sheet
set_clips();
//The frame rate regulator
Timer fps;
//The stick figure
Foo walk;
//While the user hasn't quit
while( quit == false )
{
//Start the frame timer
fps.start();
//While there's events to handle
while( SDL_PollEvent( &event ) )
{
//Handle events for the stick figure
walk.handle_events();
//If the user has Xed out the window
if( event.type == SDL_QUIT )
{
//Quit the program
quit = true;
}
}
//Move the stick figure
walk.move();
//Fill the screen white
SDL_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0, 0xFF, 0xFF ) );
//Show the stick figure on the screen
walk.show();
//Update the screen
if( SDL_Flip( screen ) == -1 )
{
}
//Cap the frame rate
if( fps.get_ticks() < 1000 / FRAMES_PER_SECOND )
{
SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - fps.get_ticks() );
}
}
//Clean up
// clean_up();
}
| [
"[email protected]"
]
| [
[
[
1,
633
]
]
]
|
2b0ae248409707e48627b6fc0ccd7691dbc71ca0 | 8cf9b251e0f4a23a6ef979c33ee96ff4bdb829ab | /src-ginga-editing/ncl30-generator-cpp/include/LabeledAnchorGenerator.h | 3830eb188b28c9cf6ea27ff23481dbe677388520 | []
| no_license | BrunoSSts/ginga-wac | 7436a9815427a74032c9d58028394ccaac45cbf9 | ea4c5ab349b971bd7f4f2b0940f2f595e6475d6c | refs/heads/master | 2020-05-20T22:21:33.645904 | 2011-10-17T12:34:32 | 2011-10-17T12:34:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,725 | h | /******************************************************************************
Este arquivo eh parte da implementacao do ambiente declarativo do middleware
Ginga (Ginga-NCL).
Copyright (C) 2009 UFSCar/Lince, Todos os Direitos Reservados.
Este programa eh software livre; voce pode redistribui-lo e/ou modificah-lo sob
os termos da Licenca Publica Geral GNU versao 2 conforme publicada pela Free
Software Foundation.
Este programa eh distribuido na expectativa de que seja util, porem, SEM
NENHUMA GARANTIA; nem mesmo a garantia implicita de COMERCIABILIDADE OU
ADEQUACAO A UMA FINALIDADE ESPECIFICA. Consulte a Licenca Publica Geral do
GNU versao 2 para mais detalhes.
Voce deve ter recebido uma copia da Licenca Publica Geral do GNU versao 2 junto
com este programa; se nao, escreva para a Free Software Foundation, Inc., no
endereco 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
Para maiores informacoes:
[email protected]
http://www.ncl.org.br
http://www.ginga.org.br
http://lince.dc.ufscar.br
******************************************************************************
This file is part of the declarative environment of middleware Ginga (Ginga-NCL)
Copyright (C) 2009 UFSCar/Lince, Todos os Direitos Reservados.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License version 2 as published by
the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License version 2 for more
details.
You should have received a copy of the GNU General Public License version 2
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
For further information contact:
[email protected]
http://www.ncl.org.br
http://www.ginga.org.br
http://lince.dc.ufscar.br
*******************************************************************************/
/**
* @file LabeledAnchorGenerator.h
* @author Caio Viel
* @date 29-01-10
*/
#ifndef _LABELEDANCHORGENERATOR_H
#define _LABELEDANCHORGENERATOR_H
#include "ncl/interfaces/LabeledAnchor.h"
using namespace ::br::pucrio::telemidia::ncl::interfaces;
namespace br {
namespace ufscar {
namespace lince {
namespace ncl {
namespace generate {
class LabeledAnchorGenerator : public LabeledAnchor {
public:
/**
* Gera o código XML da entidade NCL LabeledAnchor.
* @return Uma string contendo o código NCL gerado.
*/
string generateCode();
};
}
}
}
}
}
#endif /* _LABELEDANCHORGENERATOR_H */
| [
"[email protected]"
]
| [
[
[
1,
81
]
]
]
|
b48dcadd7bc91a08fda479150a8eb3c89332d41f | d37a1d5e50105d82427e8bf3642ba6f3e56e06b8 | /DVR/HaohanITPlayer/public/Common/SysUtils/SystemException.cpp | 83d6cc5b9e30d06d1e657f22e9110f6a83b24022 | []
| no_license | 080278/dvrmd-filter | 176f4406dbb437fb5e67159b6cdce8c0f48fe0ca | b9461f3bf4a07b4c16e337e9c1d5683193498227 | refs/heads/master | 2016-09-10T21:14:44.669128 | 2011-10-17T09:18:09 | 2011-10-17T09:18:09 | 32,274,136 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,382 | cpp | ///////////////////////////////////////////////////////////////////////////////
// SystemException.cpp
// Copyright (c) 2004, Haohanit. All rights reserved.
///////////////////////////////////////////////////////////////////////////////
//SR FS Needs Review [JAW 20040912] - check unusual use of format strings
//SR FS: Reviewed [JAW 20040913] - All formatting handled by SonicText in safe manner
//SR FS: Reviewed [wwt 20040914]
#ifdef _WIN32
#ifndef STRIP_QUICKTIME
#include "MacTypes.h"
#endif
#include "WinGDIPlusHeaders.h"
#include <dxerr9.h>
#endif
#include "SystemException.h"
#include "SonicTextBase.h"
#include "UnicodeUtilities.h"
#include "sonic_crt.h"
const SonicText SystemException::Errno::text (SonicTextBase::SonicExceptionText - 10, "operating system error: number = %0 - %1");
SystemException::Errno::Errno(
SInt32 error)
: SonicException(text),
m_error(error)
{
SonicText::Args args;
char number[16];
sonic::snprintf_safe(number, sizeof(number), "%d", error);
args.push_back(unicode::to_string8(number));
#if defined(_WIN32) && _MSC_VER >= 1400
char buffer[1024] = {0};
strerror_s(buffer, sizeof(buffer), static_cast<int>(error));
args.push_back(unicode::to_string8(buffer));
#else
args.push_back(unicode::to_string8(strerror(static_cast<int>(error))));
#endif
m_text = text.GetText(args);
}
SystemException::Errno::~Errno() throw()
{
}
SonicException * SystemException::Errno::Copy() const
{
return new SystemException::Errno(*this);
}
SInt32 SystemException::Errno::GetError() const
{
return m_error;
}
const SystemException::Errno & SystemException::Errno::Note(const std::string & note) const
{
SonicException::Note(note);
return *this;
}
void SystemException::Errno::Throw() const
{
throw *this;
}
#if defined(_WIN32)
const SonicText SystemException::Win32::text (SonicTextBase::SonicExceptionText - 11, "operating system error: number = %0 - %1");
SystemException::Win32::Win32(
DWORD error)
: SonicException(text),
m_error(error)
{
SonicText::Args args;
char number[16];
sonic::snprintf_safe(number, sizeof(number), "0x%08lX", (long) error);
args.push_back(unicode::to_string8(number));
wchar_t * buffer = NULL;
FormatMessageW(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
error,
0,
reinterpret_cast<wchar_t *>(&buffer),
0,
NULL);
// get error message and remove trailing CR/LF
unicode::string8 msg = unicode::to_string8(buffer ? buffer : L"n/a");
for (size_t i = msg.size(); i-- && (msg[i] == 0x0a || msg[i] == 0x0d); msg.erase(i));
LocalFree(buffer);
args.push_back(msg);
m_text = text.GetText(args);
}
SystemException::Win32::~Win32() throw()
{
}
SonicException * SystemException::Win32::Copy() const
{
return new SystemException::Win32(*this);
}
DWORD SystemException::Win32::GetError() const
{
return m_error;
}
const SystemException::Win32 & SystemException::Win32::Note(const std::string & note) const
{
SonicException::Note(note);
return *this;
}
void SystemException::Win32::Throw() const
{
throw *this;
}
const SonicText SystemException::Gdiplus::text (SonicTextBase::SonicExceptionText - 12, "operating system error: Gdiplus::Status = %0");
SystemException::Gdiplus::Gdiplus(
::Gdiplus::Status error)
: SonicException(text),
m_error(error)
{
SonicText::Args args;
char number[16];
sonic::snprintf_safe(number, sizeof(number), "0x%08lX", (long) error);
args.push_back(unicode::to_string8(number));
m_text = text.GetText(args);
}
SystemException::Gdiplus::~Gdiplus() throw()
{
}
SonicException * SystemException::Gdiplus::Copy() const
{
return new SystemException::Gdiplus(*this);
}
::Gdiplus::Status SystemException::Gdiplus::GetError() const
{
return m_error;
}
const SystemException::Gdiplus & SystemException::Gdiplus::Note(const std::string & note) const
{
SonicException::Note(note);
return *this;
}
void SystemException::Gdiplus::Throw() const
{
throw *this;
}
const SonicText SystemException::HRESULT::text (SonicTextBase::SonicExceptionText - 13, "operating system error: HRESULT = %0 - %1");
SystemException::HRESULT::HRESULT(
::HRESULT error)
: SonicException(text),
m_error(error)
{
SonicText::Args args;
char number[16];
sonic::snprintf_safe(number, sizeof(number), "0x%08lX", (long) error);
args.push_back(unicode::to_string8(number));
wchar_t * buffer = NULL;
FormatMessageW(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
error,
0,
reinterpret_cast<wchar_t *>(&buffer),
0,
NULL);
// get error message and remove trailing CR/LF
unicode::string8 msg = unicode::to_string8(buffer ? buffer : DXGetErrorDescription9W(error));
for (size_t i = msg.size(); i-- && (msg[i] == 0x0a || msg[i] == 0x0d); msg.erase(i));
LocalFree(buffer);
args.push_back(msg);
m_text = text.GetText(args);
}
SystemException::HRESULT::~HRESULT() throw()
{
}
SonicException * SystemException::HRESULT::Copy() const
{
return new SystemException::HRESULT(*this);
}
::HRESULT SystemException::HRESULT::GetError() const
{
return m_error;
}
const SystemException::HRESULT & SystemException::HRESULT::Note(const std::string & note) const
{
SonicException::Note(note);
return *this;
}
void SystemException::HRESULT::Throw() const
{
throw *this;
}
#if defined _INC_MMSYSTEM
const SonicText SystemException::MMRESULT::text (SonicTextBase::SonicExceptionText - 14, "operating system error: MMRESULT = %0");
SystemException::MMRESULT::MMRESULT(
::MMRESULT error)
: SonicException(text),
m_error(error)
{
SonicText::Args args;
char number[16];
sonic::snprintf_safe(number, sizeof(number), "0x%08lX", (long) error);
args.push_back(unicode::to_string8(number));
m_text = text.GetText(args);
}
SystemException::MMRESULT::~MMRESULT() throw()
{
}
SonicException * SystemException::MMRESULT::Copy() const
{
return new SystemException::MMRESULT(*this);
}
::MMRESULT SystemException::MMRESULT::GetError() const
{
return m_error;
}
const SystemException::MMRESULT & SystemException::MMRESULT::Note(const std::string & note) const
{
SonicException::Note(note);
return *this;
}
void SystemException::MMRESULT::Throw() const
{
throw *this;
}
#endif // _INC_MMSYSTEM
#ifdef __MACTYPES__
const SonicText SystemException::OSErr::text (SonicTextBase::SonicExceptionText - 15, "QuickTime system error: number = %0");
SystemException::OSErr::OSErr(
::OSErr error)
: SonicException(text),
m_error(error)
{
SonicText::Args args;
char number[16];
sonic::snprintf_safe(number, sizeof(number), "%ld", (long) error);
args.push_back(unicode::to_string8(number));
m_text = text.GetText(args);
}
SystemException::OSErr::~OSErr() throw()
{
}
SonicException * SystemException::OSErr::Copy() const
{
return new SystemException::OSErr(*this);
}
::OSErr SystemException::OSErr::GetError() const
{
return m_error;
}
const SystemException::OSErr & SystemException::OSErr::Note(const std::string & note) const
{
SonicException::Note(note);
return *this;
}
void SystemException::OSErr::Throw() const
{
throw *this;
}
#endif // __MACTYPES__
#endif // _WIN32
| [
"[email protected]@27769579-7047-b306-4d6f-d36f87483bb3"
]
| [
[
[
1,
320
]
]
]
|
1fdf5aefb5ed53bc640ea3dc6d0e3c754c3ef463 | 028d6009f3beceba80316daa84b628496a210f8d | /connectivity/com.nokia.tcf/native/TCFNative/Common/Source/ServerClient.cpp | c36fa2bfd17cb36b3665b59167ea2ff7e8e1856d | []
| no_license | JamesLinus/oss.FCL.sftools.dev.ide.carbidecpp | fa50cafa69d3e317abf0db0f4e3e557150fd88b3 | 4420f338bc4e522c563f8899d81201857236a66a | refs/heads/master | 2020-12-30T16:45:28.474973 | 2010-10-20T16:19:31 | 2010-10-20T16:19:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,668 | cpp | /*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
#include "stdafx.h"
#include "ServerClient.h"
#include "TCErrorConstants.h"
#include <time.h>
#ifdef TCF_CLIENT
#include "..\..\TCFClient\ClientManager.h"
extern CClientManager* gManager;
#endif
#ifdef TCF_SERVER
#include "..\..\TCFServer\ServerManager.h"
extern CServerManager* gManager;
#endif
#ifdef _DEBUG
extern BOOL gDoLogging;
#endif
//#define LOG_SERVERCLIENT
#if defined(LOG_SERVERCLIENT) && defined(_DEBUG)
extern BOOL gDoLogging;
extern char TCDebugMsg[];
#define TCDEBUGOPEN() if (gDoLogging) { gManager->m_DebugLog->WaitForAccess(); }
#define TCDEBUGLOGS(s) if (gDoLogging) { sprintf(TCDebugMsg,"%s", s); gManager->m_DebugLog->log(TCDebugMsg); }
#define TCDEBUGLOGA1(s, a1) if (gDoLogging) { sprintf(TCDebugMsg, s, a1); gManager->m_DebugLog->log(TCDebugMsg); }
#define TCDEBUGLOGA2(s, a1, a2) if (gDoLogging) { sprintf(TCDebugMsg, s, a1, a2); gManager->m_DebugLog->log(TCDebugMsg); }
#define TCDEBUGLOGA3(s, a1, a2, a3) if (gDoLogging) { sprintf(TCDebugMsg, s, a1, a2, a3); gManager->m_DebugLog->log(TCDebugMsg); }
#define TCDEBUGCLOSE() if (gDoLogging) { gManager->m_DebugLog->ReleaseAccess(); }
#else
#define TCDEBUGOPEN()
#define TCDEBUGLOGS(s)
#define TCDEBUGLOGA1(s, a1)
#define TCDEBUGLOGA2(s, a1, a2)
#define TCDEBUGLOGA3(s, a1, a2, a3)
#define TCDEBUGCLOSE()
#endif
CServerCommand::CServerCommand()
{
// Server commands/responses
m_ServerCommandMutex.Open(SERVERCOMMANDDATA_MUTEX_NAME, SERVERCOMMANDDATA_MUTEX_TIMEOUT);
m_ServerCommandData.Open(SERVERCOMMANDDATA_MAP_SIZE, SERVERCOMMANDDATA_MAP_NAME);
m_ServerCommandData.Init();
m_ServerMessageData.Open(SERVERMESSAGEDATA_MAP_SIZE, SERVERMESSAGEDATA_MAP_NAME);
m_ServerMessageData.Init();
m_ServerProcessData.Open(SERVERPROCESSDATA_MAP_SIZE, SERVERPROCESSDATA_MAP_NAME);
m_ServerProcessData.Init();
// General server access
m_ServerPipeMutex.Open(SERVERPIPE_MUTEX_NAME, SERVERPIPE_MUTEX_TIMEOUT);
// command/response events
m_hServerCommandReadyEvent = ::CreateEvent(NULL, FALSE, FALSE, SERVER_COMMAND_READY_EVENTNAME);
m_hServerResponseReadyEvent = ::CreateEvent(NULL, FALSE, FALSE, SERVER_RESPONSE_READY_EVENTNAME);
}
CServerCommand::~CServerCommand()
{
m_ServerCommandMutex.Close();
m_ServerCommandData.Close();
m_ServerMessageData.Close();
m_ServerProcessData.Close();
m_ServerPipeMutex.Close();
::CloseHandle(m_hServerCommandReadyEvent);
::CloseHandle(m_hServerResponseReadyEvent);
}
// Client methods
BOOL CServerCommand::SendCommand(pServerCommandData pCmd, DWORD msgLength, BYTE* message)
{
BOOL sent = FALSE;
// if (pCmd == NULL) return sent;
TCDEBUGOPEN();
TCDEBUGLOGS("CServerCommand::SendCommand\n");
TCDEBUGCLOSE();
WaitForServerCommandAccess();
pServerCommandData pData1 = GetDataPtr();
if (pCmd->command != eCmdNone)
{
memcpy(pData1, pCmd, sizeof(ServerCommandData));
if (msgLength > 0 && message != NULL)
{
pServerMessageData pData2 = GetMsgPtr();
pData2->length = msgLength;
if (msgLength > 0)
memcpy(pData2->message, message, msgLength);
}
pData1->response = eRspNone; // setup for response
sent = TRUE;
::SetEvent(m_hServerCommandReadyEvent);
}
ReleaseServerCommandAccess();
TCDEBUGOPEN();
TCDEBUGLOGS("CServerCommand::SendCommand done\n");
TCDEBUGCLOSE();
return sent;
}
BOOL CServerCommand::GetResponse(pServerCommandData pRsp)
{
BOOL found = FALSE;
TCDEBUGOPEN();
TCDEBUGLOGS("CServerCommand::GetResponse\n");
TCDEBUGCLOSE();
if (::WaitForSingleObject(m_hServerResponseReadyEvent, SERVER_CMDRSP_EVENT_TIMEOUT) == WAIT_OBJECT_0)
{
WaitForServerCommandAccess();
pServerCommandData pData = GetDataPtr();
if (pData->response != eRspNone)
{
// response is ready when command is cleared
memcpy(pRsp, pData, sizeof(ServerCommandData));
found = TRUE;
}
ReleaseServerCommandAccess();
}
else
{
TCDEBUGLOGS("CServerCommand::GetResponse timeout\n");
pRsp->response = eRspError;
pRsp->error = TCAPI_ERR_COMM_SERVER_RESPONSE_TIMEOUT;
}
#if (0)
BOOL timeoutoccurred = FALSE;
pServerCommandData pData = GetDataPtr();
time_t ctime = time(NULL);
time_t timeout = ctime + 60; // wait 60 seconds only
// if (pRsp == NULL) return found;
TCDEBUGOPEN();
TCDEBUGLOGA2("CServerCommand::GetResponse time = %d timeout = %d\n", ctime, timeout);
TCDEBUGCLOSE();
while(!found && !timeoutoccurred)
{
WaitForServerCommandAccess();
if (pData->response != eRspNone)
{
// response is ready when command is cleared
memcpy(pRsp, pData, sizeof(ServerCommandData));
found = TRUE;
}
else
{
time_t ctime = time(NULL);
if (ctime >= timeout)
{
TCDEBUGLOGS("CServerCommand::GetResponse timeout\n");
pRsp->response = eRspError;
pRsp->error = TCAPI_ERR_COMM_SERVER_RESPONSE_TIMEOUT;
timeoutoccurred = TRUE;
}
}
ReleaseServerCommandAccess();
Sleep(1);
}
#endif
TCDEBUGOPEN();
TCDEBUGLOGA1("CServerCommand::GetResponse waiting for response found=%d\n", found);
TCDEBUGCLOSE();
return found;
}
// Server methods
BOOL CServerCommand::GetCommand(pServerCommandData pCmd, pServerMessageData pMsg)
{
BOOL found = FALSE;
if (::WaitForSingleObject(m_hServerCommandReadyEvent, SERVER_CMDRSP_EVENT_TIMEOUT) == WAIT_OBJECT_0)
{
pServerCommandData pData1 = GetDataPtr();
WaitForServerCommandAccess();
if (pData1->command != eCmdNone)
{
memcpy(pCmd, pData1, sizeof(ServerCommandData));
if (pMsg)
{
pServerMessageData pData2 = GetMsgPtr();
pMsg->length = pData2->length;
memcpy(pMsg->message, pData2->message, pData2->length);
}
found = TRUE;
}
ReleaseServerCommandAccess();
}
return found;
}
BOOL CServerCommand::SendResponse(pServerCommandData pRsp)
{
BOOL sent = FALSE;
pServerCommandData pData = GetDataPtr();
WaitForServerCommandAccess();
if (pRsp->response != eRspNone)
{
memcpy(pData, pRsp, sizeof(ServerCommandData));
pData->command = eCmdNone; // setup for next command
sent = TRUE;
::SetEvent(m_hServerResponseReadyEvent);
}
ReleaseServerCommandAccess();
return sent;
}
| [
"none@none"
]
| [
[
[
1,
241
]
]
]
|
2086a206bc1292c9f4e1c29602a553ae9d0f75ba | 7acbb1c1941bd6edae0a4217eb5d3513929324c0 | /GLibrary-CPP/sources/GFraction.h | 5f60cd5dd1edbd44504d95cef0c2b7f797393815 | []
| no_license | hungconcon/geofreylibrary | a5bfc96e0602298b5a7b53d4afe7395a993498f1 | 3abf3e1c31a245a79fa26b4bcf2e6e86fa258e4d | refs/heads/master | 2021-01-10T10:11:51.535513 | 2009-11-30T15:29:34 | 2009-11-30T15:29:34 | 46,771,895 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 639 | h |
#ifndef __GFRACTION_H__
# define __GFRACTION_H__
#include "GAlgo.h"
#include "GString.h"
class GFraction
{
public:
GFraction(void);
GFraction(int, int = 1);
~GFraction(void);
bool IsPositive(void) const;
bool IsNegative(void) const;
void Simplify(void);
int GetNumerator(void) const;
int GetDenominator(void) const;
GFraction &operator=(const GFraction &);
GFraction &operator+=(const GFraction &);
GFraction &operator-=(const GFraction &);
GFraction &operator/=(const GFraction &);
GFraction &operator*=(const GFraction &);
private:
int _den;
int _num;
};
#endif
| [
"mvoirgard@34e8d5ee-a372-11de-889f-a79cef5dd62c"
]
| [
[
[
1,
32
]
]
]
|
5350ef4b3a6e757ebc84bbbd36b401c1fab9204f | 12732dc8a5dd518f35c8af3f2a805806f5e91e28 | /trunk/LiteEditor/filedroptarget.cpp | 87eddae275b37d07bcbe5c43491790117b257a04 | []
| 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 | 424 | cpp | #include "filedroptarget.h"
#include "manager.h"
FileDropTarget::FileDropTarget()
: wxFileDropTarget()
{
}
FileDropTarget::~FileDropTarget()
{
}
bool FileDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &filenames)
{
wxUnusedVar(x);
wxUnusedVar(y);
for(size_t i=0; i<filenames.GetCount(); i++){
ManagerST::Get()->OpenFile(filenames.Item(i), wxEmptyString);
}
return true;
}
| [
"eranif@b1f272c1-3a1e-0410-8d64-bdc0ffbdec4b"
]
| [
[
[
1,
22
]
]
]
|
4f25f62a1b23e3fb5d0ae28563c737abd2dfed1f | e7c45d18fa1e4285e5227e5984e07c47f8867d1d | /Application/SysCAD/OLE/Ole_mngr.cpp | 9223704cd805b100d72f8a28c6119e338819fb69 | []
| no_license | abcweizhuo/Test3 | 0f3379e528a543c0d43aad09489b2444a2e0f86d | 128a4edcf9a93d36a45e5585b70dee75e4502db4 | refs/heads/master | 2021-01-17T01:59:39.357645 | 2008-08-20T00:00:29 | 2008-08-20T00:00:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,022 | cpp | //================== SysCAD - Copyright Kenwalt (Pty) Ltd ===================
// $Nokeywords: $
//===========================================================================
#include "stdafx.h"
#include "sc_defs.h"
#include "gpfuncs.h"
#include "ole_base.h"
#include "ole_mngr.h"
#include "..\resource.h"
#include "oledlgs.h"
#include "oleexcel.h"
#include "project.h"
#include "scd_wm.h"
//===========================================================================
COleThread* pOleThread = NULL;
//===========================================================================
COleExec::COleExec()
{
wm_SyscadOleCommand = RegisterWindowMessage("WM_SyscadOleCommand");
EO_Register(pExecName_OLE, /*EOWrite_Msg|EORead_Msg|*/EOExec_Msg, /*Pri*/THREAD_PRIORITY_NORMAL, /*Stack*/10000);
COleThread* pOleThrd = (pCOleThread)AfxBeginThread(RUNTIME_CLASS(COleThread), THREAD_PRIORITY_NORMAL, 65536);
dwThreadId = pOleThrd->m_nThreadID;
}
//---------------------------------------------------------------------------
COleExec::~COleExec()
{
EO_DeRegister();
PostThreadMessage(dwThreadId, wm_SyscadOleCommand, MAKEWPARAM(OLE_QUIT,0), 0);
}
//---------------------------------------------------------------------------
DWORD COleExec::EO_Message(CXMsgLst &XM, CXM_Route &Route)
{
while (XM.MsgAvail())
switch (XM.MsgId())
{
case XM_OleExcelReport:
{
CXM_OleExcelReport* p = XM.OleExcelReport();
CXM_Route* pXRoute = XM.Route();
ASSERT(pXRoute); //did you remember to pack the route into the message ???
COleBaseAuto* pReportMngr = NULL;
switch (p->iOpt)
{
case SUB_REPORT_GETVALUES : pReportMngr = (COleBaseAuto*)new COleReportMngr(this, pXRoute, p->FileName(), p->ReportName(), true); break;
case SUB_REPORT_TREND : pReportMngr = (COleBaseAuto*)new COleReportTrendMngr(this, pXRoute, p->FileName(), p->ReportName()); break;
case SUB_REPORT_SETVALUES : pReportMngr = (COleBaseAuto*)new COleSetTagsMngr(this, pXRoute, p->FileName(), p->ReportName()); break;
case SUB_REPORT_OPEN : pReportMngr = (COleBaseAuto*)new COleStartExcel(this, pXRoute, p->FileName()); break;
case SUB_REPORT_SAVEANDCLOSE: pReportMngr = (COleBaseAuto*)new COleSaveCloseExcel(this, pXRoute, p->FileName()); break;
case SUB_REPORT_MACRO : pReportMngr = (COleBaseAuto*)new COleExcelMacro(this, pXRoute, p->FileName(), p->ReportName()); break;
case SUB_REPORT_GENERALINFO : pReportMngr = (COleBaseAuto*)new COleInfoReportMngr(this, pXRoute, p->FileName()); break;
default: ASSERT(FALSE); //what Excel OLE option is this ???
}
pReportMngr->m_pComCmd=p->ComCmdBlk();
((COleExcelBaseAuto*)pReportMngr)->SetOptions((byte)gs_pPrj->m_bRptExcelLock,
(byte)gs_pPrj->m_bRptExcelCellName,
(byte)gs_pPrj->m_bRptExcelMakeActive,
(byte)gs_pPrj->m_bRptExcelSysCADActive,
(byte)gs_pPrj->m_bRptExcelUpdateLinks,
(byte)gs_pPrj->m_bRptExcelSaveOnComplete);
pOleThread->AddQueueItem(pReportMngr);
PostThreadMessage(dwThreadId, wm_SyscadOleCommand, MAKEWPARAM(OLE_DOAUTOITEM, (WORD)(p->FromExecutive?1:0)), (LPARAM)pReportMngr);
break;
}
case XM_QueryRow:
{
CXM_QueryRow* p = XM.QueryRow();
COleReportTrendMngr* pM = (COleReportTrendMngr*)(p->iSrcID);
pM->Lock();
CRepTrndItem* pNewItm = new CRepTrndItem(p->dTime, p->nPts);
if (pM->pFirst==NULL)
pM->pFirst = pNewItm;
else
{
CRepTrndItem* pItm = pM->pFirst;
while (pItm->pNxt)
pItm = pItm->pNxt;
pItm->pNxt = pNewItm;
}
for (int i=0; i<p->nPts; i++)
pNewItm->Values[i] = p->dValue[i];
pM->Unlock();
break;
}
case XM_QueryRowEx:
{
CXM_QueryRowEx* p = XM.QueryRowEx();
COleReportTrendMngr* pM = (COleReportTrendMngr*)(p->iSrcID);
pM->Lock();
CRepTrndItem* pNewItm = new CRepTrndItem(p->dTime, p->nPts);
if (pM->pFirst==NULL)
pM->pFirst = pNewItm;
else
{
CRepTrndItem* pItm = pM->pFirst;
while (pItm->pNxt)
pItm = pItm->pNxt;
pItm->pNxt = pNewItm;
}
//for (int i=0; i<p->nPts; i++)
// pNewItm->Values[i] = p->dValue[i];
int Pos=0;
byte ValTyp = p->FirstValTyp(Pos);
for (int j=0; j<p->nPts; j++)
{
if (ValTyp==QueryRowExType_Double)
{
pNewItm->Values[j] = p->DValue(Pos);
}
else if (ValTyp==QueryRowExType_Long)
pNewItm->Values[j] = p->LValue(Pos);
else
pNewItm->Values[j] = p->SValue(Pos);
ValTyp = p->NextValTyp(Pos);
}
pM->Unlock();
break;
}
case XM_QueryString:
{
CXM_QueryString* p = XM.QueryString();
if (p->cValue)
{
const int len = strlen(p->cValue);
if (len==6 && _stricmp(p->cValue, "TheEnd")==0)
{
COleReportTrendMngr* pM = (COleReportTrendMngr*)(p->iSrcID);
pM->Lock();
pM->bQueryDone = 1;
pM->Unlock();
}
else if (len>6 && _strnicmp(p->cValue, "TheTags", 7)==0)
{
COleReportTrendMngr* pM = (COleReportTrendMngr*)(p->iSrcID);
pM->Lock();
pM->sTagList = p->cValue;
pM->bQueryTagsDone = 1;
pM->Unlock();
}
}
break;
}
default:
ASSERT(0);
}
return 1;
}
//---------------------------------------------------------------------------
flag COleExec::EO_QueryTime(CXM_TimeControl &CB, CTimeValue &TimeRqd, CTimeValue &dTimeRqd)
{
return True;
}
//---------------------------------------------------------------------------
flag COleExec::EO_Start(CXM_TimeControl &CB)
{
return True;
}
//---------------------------------------------------------------------------
void COleExec::EO_QuerySubsReqd(CXMsgLst &XM)
{
XM.Clear();
}
//---------------------------------------------------------------------------
void COleExec::EO_QuerySubsAvail(CXMsgLst &XM, CXMsgLst &XMRet)
{
//XM.Clear();
}
//---------------------------------------------------------------------------
flag COleExec::EO_ReadSubsData(CXMsgLst &XM)
{
flag DataRead = 0;
return DataRead;
}
//---------------------------------------------------------------------------
flag COleExec::EO_WriteSubsData(CXMsgLst &XM, flag FirstBlock, flag LastBlock)
{
while (XM.MsgAvail())
{
CXM_ObjectData* pX = XM.ObjectData();
CPkDataItem* pPItem = pX->FirstItem();
}
return True;
}
//---------------------------------------------------------------------------
flag COleExec::EO_Execute(CXM_TimeControl &CB, CEOExecReturn &EORet)
{
return False;
}
//---------------------------------------------------------------------------
flag COleExec::EO_Stop(CXM_TimeControl &CB)
{
return True;
}
//---------------------------------------------------------------------------
int COleExec::EO_CanClose(Strng_List & Problems)
{
if (pOleThread->IsBusy())
{
pOleThread->CancelQueueItems();
//should these rather be added to the problems list???
LogWarning("SysCAD", 0, "Extra Automation requests have been canceled.");
LogError("SysCAD", 0, "Automation requests (eg Excel reports) are still being serviced.");
return EO_CanClose_Wait;
}
return EO_CanClose_Yes;
}
//===========================================================================
IMPLEMENT_DYNCREATE(COleThread, CWinThread);
//---------------------------------------------------------------------------
BOOL COleThread::InitInstance()
{
pOleThread = this;
InitializeCriticalSection(&QueueSection);
pQueue = NULL;
bQuitNow = 0;
iQueueCnt = 0;
if (pOleInfoWnd==NULL)
pOleInfoWnd = (CWnd*)(new COleInfoWnd(AfxGetMainWnd()));
DWORD dwThreadId = GetCurrentThreadId();
SCODE sc = ::OleInitialize(NULL);
return TRUE;//Must return TRUE to begin run loop
}
//---------------------------------------------------------------------------
int COleThread::ExitInstance()
{
Lock();
bQuitNow = 1;
Unlock();
DeleteCriticalSection(&QueueSection);
if (pOleInfoWnd)
{
pOleInfoWnd->DestroyWindow();
delete pOleInfoWnd;
pOleInfoWnd = NULL;
}
pOleThread = NULL;
::OleUninitialize();
return 0;
}
//---------------------------------------------------------------------------
void COleThread::AddQueueItem(COleBaseAuto* pNewItem)
{
Lock();
//add to end of queue...
COleAutoQueueItem* pItem = pQueue;
while (pItem && pItem->pNxt)
pItem = pItem->pNxt;
if (pQueue)
pItem->pNxt = new COleAutoQueueItem(pNewItem);
else
pQueue = new COleAutoQueueItem(pNewItem);
iQueueCnt++;
Unlock();
COleInfoMsg* pMsg;
if (iQueueCnt==1)
pMsg = new COleInfoMsg(iQueueCnt, "", "");
else
pMsg = new COleInfoMsg(iQueueCnt);
pOleInfoWnd->SendMessage(WMU_OLEINFOUPDATE, 0, (LPARAM)pMsg);
}
//---------------------------------------------------------------------------
void COleThread::CancelQueueItems()
{
Lock();
bQuitNow = 1;
Unlock();
}
//---------------------------------------------------------------------------
BOOL COleThread::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message==wm_SyscadOleCommand)
{
WORD Cmd = LOWORD(pMsg->wParam);
WORD FromExecutive= HIWORD(pMsg->wParam);
switch (Cmd)
{
case OLE_DOAUTOITEM:
{
if (bQuitNow)
{
Lock();
while (pQueue)
{
iQueueCnt--;
delete pQueue->pAutoItem;
COleAutoQueueItem* DelItem = pQueue;
pQueue = pQueue->pNxt;
delete DelItem;
}
Unlock();
}
Lock();
if (pQueue)
{
Unlock();
pQueue->pAutoItem->DoAutomation();
pQueue->pAutoItem->ActivateSysCAD();
delete pQueue->pAutoItem;
Lock();
iQueueCnt--;
COleAutoQueueItem* DelItem = pQueue;
pQueue = pQueue->pNxt;
delete DelItem;
}
Unlock();
COleInfoMsg* pMsg = new COleInfoMsg(iQueueCnt);
pOleInfoWnd->SendMessage(WMU_OLEINFOUPDATE, 0, (LPARAM)pMsg);
if (FromExecutive)
gs_Exec.OneReportComplete();
if (iQueueCnt==0 && !bQuitNow)
ScdMainWnd()->PostMessage(WMU_OLEINFOUPDATE, 0, 0); //send message after LAST report
break;
}
case OLE_QUIT:
::PostQuitMessage(0); //Do NOT use AfxEndThread for a user interface thread
break;
default:
ASSERT(FALSE); //where did this message come from ???
}
return 1; //message processed here
}
else
return CWinThread::PreTranslateMessage(pMsg);
}
//---------------------------------------------------------------------------
//===========================================================================
| [
"[email protected]",
"[email protected]",
"[email protected]"
]
| [
[
[
1,
62
],
[
69,
69
],
[
71,
132
],
[
134,
139
],
[
141,
158
],
[
160,
165
],
[
167,
206
],
[
208,
213
],
[
215,
311
],
[
313,
345
],
[
348,
348
],
[
350,
365
]
],
[
[
63,
68
],
[
133,
133
],
[
140,
140
],
[
159,
159
],
[
166,
166
],
[
207,
207
],
[
214,
214
],
[
349,
349
]
],
[
[
70,
70
],
[
312,
312
],
[
346,
347
]
]
]
|
2de6f9cefc9b16194e5daffe066769eb5e0502ea | a230afa027a8a672c3d3581df13439127c795a55 | /Rendrer/Physics/Helpers/MyCloth.cpp | 91c1646a17630aa65aa9ab440278673227bcd019 | []
| no_license | ASDen/CGsp | fbecb2463d975412f85fa343e87fda9707b7801a | 2657b72269566c59cc0127239e3827f359197f9e | refs/heads/master | 2021-01-25T12:02:10.331018 | 2010-09-22T12:43:19 | 2010-09-22T12:43:19 | 503,933 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,576 | cpp | #include "stdafx.h"
#include "../../RdInc.h"
#define TEAR_MEMORY_FACTOR 2
// -----------------------------------------------------------------------
MyCloth::MyCloth(NxScene *scene, NxClothDesc &desc)
{
mInitDone = false;
mTexId = 0;
mTexCoords = NULL;
NxClothMeshDesc meshDesc;
if (!generateObjMeshDesc(meshDesc, objFileName, scale))
{
printf("Error loading cloth mesh from file: %s\n", objFileName);
exit(-1);
}
init(scene, desc, meshDesc);
}
// -----------------------------------------------------------------------
MyCloth::MyCloth(NxScene *scene, NxClothDesc &desc, NxReal w, NxReal h, NxReal d, char *texFilename, bool tearLines)
{
mInitDone = false;
mTexId = 0;
mTexCoords = NULL;
NxClothMeshDesc meshDesc;
generateRegularMeshDesc(meshDesc, w, h, d, texFilename != NULL, tearLines);
init(scene, desc, meshDesc);
if (texFilename)
createTexture(texFilename);
}
// -----------------------------------------------------------------------
void MyCloth::init(NxScene *scene, NxClothDesc &desc, NxClothMeshDesc &meshDesc)
{
mScene = scene;
// if we want tearing we must tell the cooker
// this way it will generate some space for particles that will be generated during tearing
if (desc.flags & NX_CLF_TEARABLE)
meshDesc.flags |= NX_CLOTH_MESH_TEARABLE;
NxInitCooking();
cookMesh(meshDesc);
NxCloseCooking();
releaseMeshDescBuffers(meshDesc);
allocateReceiveBuffers(meshDesc.numVertices, meshDesc.numTriangles);
desc.clothMesh = mClothMesh;
desc.meshData = mReceiveBuffers;
mCloth = scene->createCloth(desc);
mInitDone = true;
}
// -----------------------------------------------------------------------
MyCloth::~MyCloth()
{
if (mInitDone) {
mScene->releaseCloth(*mCloth);
mScene->getPhysicsSDK().releaseClothMesh(*mClothMesh);
releaseReceiveBuffers();
if (mTexCoords) free(mTexCoords);
}
}
// -----------------------------------------------------------------------
bool MyCloth::generateObjMeshDesc(NxClothMeshDesc &desc, char *filename, NxReal scale)
{
WavefrontObj wo;
wo.loadObj(filename);
if (wo.mVertexCount == 0) return false;
desc.numVertices = wo.mVertexCount;
desc.numTriangles = wo.mTriCount;
desc.pointStrideBytes = sizeof(NxVec3);
desc.triangleStrideBytes = 3*sizeof(NxU32);
desc.vertexMassStrideBytes = sizeof(NxReal);
desc.vertexFlagStrideBytes = sizeof(NxU32);
desc.points = (NxVec3*)malloc(sizeof(NxVec3)*desc.numVertices);
desc.triangles = (NxU32*)malloc(sizeof(NxU32)*desc.numTriangles*3);
desc.vertexMasses = 0;
desc.vertexFlags = 0;
desc.flags = 0;
// copy positions and indices
NxVec3 *vSrc = (NxVec3*)wo.mVertices;
NxVec3 *vDest = (NxVec3*)desc.points;
for (int i = 0; i < wo.mVertexCount; i++, vDest++, vSrc++)
*vDest = (*vSrc)*scale; // resize
memcpy((NxU32*)desc.triangles, wo.mIndices, sizeof(NxU32)*desc.numTriangles*3);
return true;
}
// -----------------------------------------------------------------------
void MyCloth::generateRegularMeshDesc(NxClothMeshDesc &desc, NxReal w, NxReal h, NxReal d, bool texCoords, bool tearLines)
{
int numX = (int)(w / d) + 1;
int numY = (int)(h / d) + 1;
desc.numVertices = (numX+1) * (numY+1);
desc.numTriangles = numX*numY*2;
desc.pointStrideBytes = sizeof(NxVec3);
desc.triangleStrideBytes = 3*sizeof(NxU32);
desc.vertexMassStrideBytes = sizeof(NxReal);
desc.vertexFlagStrideBytes = sizeof(NxU32);
desc.points = (NxVec3*)malloc(sizeof(NxVec3)*desc.numVertices);
desc.triangles = (NxU32*)malloc(sizeof(NxU32)*desc.numTriangles*3);
desc.vertexMasses = 0;
desc.vertexFlags = 0;
desc.flags = 0;
int i,j;
NxVec3 *p = (NxVec3*)desc.points;
for (i = 0; i <= numY; i++) {
for (j = 0; j <= numX; j++) {
p->set(-d*j, 0.0f, -d*i);
p++;
}
}
if (texCoords) {
mTexCoords = (GLfloat *)malloc(sizeof(GLfloat)*2*TEAR_MEMORY_FACTOR*desc.numVertices);
GLfloat *f = mTexCoords;
GLfloat dx = 1.0f; if (numX > 0) dx /= numX;
GLfloat dy = 1.0f; if (numY > 0) dy /= numY;
for (i = 0; i <= numY; i++) {
for (j = 0; j <= numX; j++) {
*f++ = j*dx;
*f++ = i*dy;
}
}
mNumTexCoords = desc.numVertices;
}
else mNumTexCoords = 0;
NxU32 *id = (NxU32*)desc.triangles;
for (i = 0; i < numY; i++) {
for (j = 0; j < numX; j++) {
NxU32 i0 = i * (numX+1) + j;
NxU32 i1 = i0 + 1;
NxU32 i2 = i0 + (numX+1);
NxU32 i3 = i2 + 1;
if ((j+i)%2) {
*id++ = i0; *id++ = i2; *id++ = i1;
*id++ = i1; *id++ = i2; *id++ = i3;
}
else {
*id++ = i0; *id++ = i2; *id++ = i3;
*id++ = i0; *id++ = i3; *id++ = i1;
}
}
}
// generate tear lines if necessary
if(tearLines)
generateTearLines(desc, numX + 1, numY + 1);
}
// -----------------------------------------------------------------------
void MyCloth::generateTearLines(NxClothMeshDesc& desc, NxU32 w, NxU32 h)
{
// allocate flag buffer
if(desc.vertexFlags == 0)
desc.vertexFlags = malloc(sizeof(NxU32)*desc.numVertices);
// create tear lines
NxU32* flags = (NxU32*)desc.vertexFlags;
NxU32 y;
for(y = 0; y < h; y++)
{
NxU32 x;
for(x = 0; x < w; x++)
{
if(((x + y) % 16 == 0) || ((x - y + 16) % 16 == 0))
flags[y * w + x] = NX_CLOTH_VERTEX_TEARABLE;
else
flags[y * w + x] = 0;
}
}
}
// -----------------------------------------------------------------------
void MyCloth::releaseMeshDescBuffers(const NxClothMeshDesc& desc)
{
NxVec3* p = (NxVec3*)desc.points;
NxU32* t = (NxU32*)desc.triangles;
NxReal* m = (NxReal*)desc.vertexMasses;
NxU32* f = (NxU32*)desc.vertexFlags;
free(p);
free(t);
free(m);
free(f);
}
// -----------------------------------------------------------------------
bool MyCloth::cookMesh(NxClothMeshDesc& desc)
{
// we cook the mesh on the fly through a memory stream
// we could also use a file stream and pre-cook the mesh
MemoryWriteBuffer wb;
if (!NxCookClothMesh(desc, wb))
return false;
MemoryReadBuffer rb(wb.data);
mClothMesh = mScene->getPhysicsSDK().createClothMesh(rb);
return true;
}
// -----------------------------------------------------------------------
void MyCloth::allocateReceiveBuffers(int numVertices, int numTriangles)
{
// here we setup the buffers through which the SDK returns the dynamic cloth data
// we reserve more memory for vertices than the initial mesh takes
// because tearing creates new vertices
// the SDK only tears cloth as long as there is room in these buffers
NxU32 maxVertices = TEAR_MEMORY_FACTOR * numVertices;
mReceiveBuffers.verticesPosBegin = (NxVec3*)malloc(sizeof(NxVec3)*maxVertices);
mReceiveBuffers.verticesNormalBegin = (NxVec3*)malloc(sizeof(NxVec3)*maxVertices);
mReceiveBuffers.verticesPosByteStride = sizeof(NxVec3);
mReceiveBuffers.verticesNormalByteStride = sizeof(NxVec3);
mReceiveBuffers.maxVertices = maxVertices;
mReceiveBuffers.numVerticesPtr = (NxU32*)malloc(sizeof(NxU32));
// the number of triangles is constant, even if the cloth is torn
NxU32 maxIndices = 3*numTriangles;
mReceiveBuffers.indicesBegin = (NxU32*)malloc(sizeof(NxU32)*maxIndices);
mReceiveBuffers.indicesByteStride = sizeof(NxU32);
mReceiveBuffers.maxIndices = maxIndices;
mReceiveBuffers.numIndicesPtr = (NxU32*)malloc(sizeof(NxU32));
// the parent index information would be needed if we used textured cloth
NxU32 maxParentIndices = maxVertices;
mReceiveBuffers.parentIndicesBegin = (NxU32*)malloc(sizeof(NxU32)*maxParentIndices);
mReceiveBuffers.parentIndicesByteStride = sizeof(NxU32);
mReceiveBuffers.maxParentIndices = maxParentIndices;
mReceiveBuffers.numParentIndicesPtr = (NxU32*)malloc(sizeof(NxU32));
// init the buffers in case we want to draw the mesh
// before the SDK as filled in the correct values
*mReceiveBuffers.numVerticesPtr = 0;
*mReceiveBuffers.numIndicesPtr = 0;
}
// -----------------------------------------------------------------------
void MyCloth::releaseReceiveBuffers()
{
NxVec3* vp;
NxU32* up;
vp = (NxVec3*)mReceiveBuffers.verticesPosBegin; free(vp);
vp = (NxVec3*)mReceiveBuffers.verticesNormalBegin; free(vp);
up = (NxU32*)mReceiveBuffers.numVerticesPtr; free(up);
up = (NxU32*)mReceiveBuffers.indicesBegin; free(up);
up = (NxU32*)mReceiveBuffers.numIndicesPtr; free(up);
up = (NxU32*)mReceiveBuffers.parentIndicesBegin; free(up);
up = (NxU32*)mReceiveBuffers.numParentIndicesPtr; free(up);
}
| [
"[email protected]"
]
| [
[
[
1,
263
]
]
]
|
24d30ea8ffa7966ef1d020770e51c15e3dff4d0d | f96efcf47a7b6a617b5b08f83924c7384dcf98eb | /tags/mucc_1_0_5_10/ChatContainer.h | bd878d568136b732d9165c73daed3cc859667d8c | []
| no_license | BackupTheBerlios/mtlen-svn | 0b4e7c53842914416ed3f6b1fa02c3f1623cac44 | f0ea6f0cec85e9ed537b89f7d28f75b1dc108554 | refs/heads/master | 2020-12-03T19:37:37.828462 | 2011-12-07T20:02:16 | 2011-12-07T20:02:16 | 40,800,938 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,536 | h | /*
MUCC Group Chat GUI Plugin for Miranda IM
Copyright (C) 2004 Piotr Piastucki
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, USA.
*/
class ChatContainer;
#ifndef CHATCONTAINER_INCLUDED
#define CHATCONTAINER_INCLUDED
#include "mucc.h"
#include "ChatEvent.h"
#include "ChatUser.h"
#include "AdminWindow.h"
class ChatContainerChild {
public:
ChatWindow *window;
ChatContainerChild *next;
ChatContainerChild *prev;
};
class ChatContainer{
private:
static ChatContainer * list;
static bool released;
static CRITICAL_SECTION mutex;
HWND hWnd;
HANDLE hEvent;
int childCount;
int width, height;
ChatContainer *next, *prev;
ChatWindow * active;
ChatContainer();
protected:
friend BOOL CALLBACK ContainerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
void addChild(ChatWindow *);
void activateChild(ChatWindow *);
void changeChildData(ChatWindow *);
void removeChild(ChatWindow *);
void getChildWindowRect(RECT *rcChild);
ChatWindow * getChildFromTab(int tabId);
int getChildTab(ChatWindow *);
int getChildCount();
void setChildCount(int);
ChatWindow * getActive();
ChatContainerChild *getChildren();
ChatContainer * getNext();
void setNext(ChatContainer *);
ChatContainer * getPrev();
void setPrev(ChatContainer *);
int lastClickTime;
int lastClickTab;
HANDLE getEvent();
void setHWND(HWND);
public:
enum FLAGS {
FLAG_USE_TABS = 0x00000001,
};
~ChatContainer();
static void init();
static void release();
static ChatContainer * getWindow();
static int getDefaultOptions();
void show(bool bShow);
HWND getHWND();
HWND remoteCreateChild(DLGPROC proc, ChatWindow *);
void remoteAddChild(ChatWindow *);
void remoteChangeChildData(ChatWindow *);
void remoteRemoveChild(ChatWindow *);
};
#endif
| [
"the_leech@3f195757-89ef-0310-a553-cc0e5972f89c"
]
| [
[
[
1,
92
]
]
]
|
425717772cdea803e528a2078716e632e4685c7b | 1cc5720e245ca0d8083b0f12806a5c8b13b5cf98 | /archive/ok/3006/c.cpp | 8605cc9142da1b7ae43af4ff96b09ed3fe55e389 | []
| no_license | Emerson21/uva-problems | 399d82d93b563e3018921eaff12ca545415fd782 | 3079bdd1cd17087cf54b08c60e2d52dbd0118556 | refs/heads/master | 2021-01-18T09:12:23.069387 | 2010-12-15T00:38:34 | 2010-12-15T00:38:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,414 | cpp | #include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
char l[300];
char comandos[300];
int lencmd;
int len;
bool exec(char c,int p) {
if(p==-1) return false;
char &ch = l[p];
if(c=='R' || c=='L') {
if(ch=='1') ch='2';
else if(ch=='2') ch='1';
else if(ch=='3') ch='4';
else if(ch=='4') ch='3';
if(c=='R' && (ch=='1' || ch=='4')) return exec(c,p-1);
else if(c=='L' && (ch=='2' || ch=='3')) return exec(c,p-1);
} else if(c=='U' || c=='D') {
if(ch=='1') ch='4';
else if(ch=='2') ch='3';
else if(ch=='3') ch='2';
else if(ch=='4') ch='1';
if(c=='U' && (ch=='4' || ch=='3')) return exec(c,p-1);
else if(c=='D' && (ch=='1' || ch=='2')) return exec(c,p-1);
}
return true;
}
bool cmd() {
for(int i=0;i!=lencmd;i++) {
char c = comandos[i];
if(!exec(c,len-1)) return false;
}
return true;
}
int main() {
while(true) {
cin >> l >> comandos;
if(l[0]=='E') break; len = strlen(l); lencmd = strlen(comandos);
if(cmd()) cout << l << endl;
else cout << "OUT" << endl;
}
return 0;
} | [
"[email protected]"
]
| [
[
[
1,
58
]
]
]
|
99040d1d23da8a2106b298db77a70dfead2ad74b | 1e976ee65d326c2d9ed11c3235a9f4e2693557cf | /CommonSources/ResizingDialog.h | 3726b1119ae7ed50f5b0fdd0271d2bf21b764337 | []
| no_license | outcast1000/Jaangle | 062c7d8d06e058186cb65bdade68a2ad8d5e7e65 | 18feb537068f1f3be6ecaa8a4b663b917c429e3d | refs/heads/master | 2020-04-08T20:04:56.875651 | 2010-12-25T10:44:38 | 2010-12-25T10:44:38 | 19,334,292 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,741 | h | // /*
// *
// * Copyright (C) 2003-2010 Alexandros Economou
// *
// * This file is part of Jaangle (http://www.jaangle.com)
// *
// * This Program is free software; you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation; either version 2, or (at your option)
// * any later version.
// *
// * This Program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with GNU Make; see the file COPYING. If not, write to
// * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
// * http://www.gnu.org/copyleft/gpl.html
// *
// */
#if !defined(AFX_RESIZINGDIALOG_H__6907518B_528A_4FF8_9D41_E87796B543AF__INCLUDED_)
#define AFX_RESIZINGDIALOG_H__6907518B_528A_4FF8_9D41_E87796B543AF__INCLUDED_
#pragma once
// resizing dialog class
class CResizingDialog : public CDialog
{
public:
// possible sizing types
enum eSizeType
{
sizeNone, // do nothing
sizeResize, // proportional expand/contract
sizeRepos, // maintain distance from top/left
sizeRelative // proportional distance from sides
};
protected:
// id for the size icon - change if you get a clash with any of your controls
enum { m_idSizeIcon=0x4545 };
// contained class to hold item state
class CItem
{
public:
UINT m_resID; // resource ID
eSizeType m_xSize; // x sizing option
eSizeType m_ySize; // y sizing option
CRect m_rcControl; // last size
bool m_bFlickerFree; // flicker-free move?
double m_xRatio; // x ratio (for relative)
double m_yRatio; // y ratio (for relative)
protected:
void Assign(const CItem& src);
public:
CItem();
CItem(const CItem& src);
void OnSize(HDWP hdwp,const CRect& rcParentOld,const CRect& rcParentNew,CWnd *pDlg);
CItem& operator=(const CItem& src);
};
// data members
std::vector<CItem> m_Items; // array of controlled items
CRect m_rcDialog; // last dialog size
CPoint m_MinSize; // smallest size allowed
eSizeType m_xAllow; // horizontal sizing allowed
eSizeType m_yAllow; // vertical sizing allowed
CBitmap m_bmSizeIcon; // size icon bitmap
CStatic m_wndSizeIcon; // size icon window
bool m_bInited; // set after initialize
protected:
//{{AFX_MSG(CResizingDialog)
virtual BOOL OnInitDialog();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnGetMinMaxInfo(MINMAXINFO *lpMMI);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
void AddControl(const UINT resID,const eSizeType xsize,const eSizeType ysize,const bool bFlickerFree=true);
void AllowSizing(const eSizeType xsize,const eSizeType ysize);
void HideSizeIcon(void);
public:
CResizingDialog(const UINT resID,CWnd *pParent);
//{{AFX_DATA(CResizingDialog)
//}}AFX_DATA
//{{AFX_VIRTUAL(CResizingDialog)
//}}AFX_VIRTUAL
};
//{{AFX_INSERT_LOCATION}}
#endif // !defined(AFX_RESIZINGDIALOG_H__6907518B_528A_4FF8_9D41_E87796B543AF__INCLUDED_)
| [
"outcast1000@dc1b949e-fa36-4f9e-8e5c-de004ec35678"
]
| [
[
[
1,
113
]
]
]
|
e437f31d8da35cb058b79b167a5f61fac89f1c3e | fab77712e8dfd19aea9716b74314f998093093e2 | /TableDataServer/Section.cpp | 9cfac73284bb07c73c9572d61d53f80848ba1aa8 | []
| no_license | alandigi/tsfriend | 95f98b123ae52f1f515ab4a909de9af3724b138d | b8f246a51f01afde40a352248065a6a42f0bcbf8 | refs/heads/master | 2016-08-12T07:09:23.928793 | 2011-11-13T15:12:54 | 2011-11-13T15:12:54 | 45,849,814 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 8,811 | cpp | #include "StdAfx.h"
#include "include.h"
CSection::CSection(void)
{
SectionData = NULL;
pNext = NULL;
}
/*
CSection::CSection(u16 SectinSize)
{
assert(SectionSize > 0);
SectionData = (u8 *)malloc(SectinSize);
SectionSize = SectinSize;
SectionContent = NULL;
//pNext = NULL;
}
*/
CSection::~CSection(void)
{
if(SectionData)
free(SectionData);
}
u16 * CSection::AnalyseSubTablePID(u16 * PidArray)
{
CommonSection * pCS =(CommonSection * )SectionData;
u16 Found_PID;
u8 * pU8 = SectionData;
if(pCS == NULL)
return PidArray;
if(PidArray == NULL)
{
PidArray = (u16 *)malloc( sizeof(u16));/*first for pid count */
PidArray[0] = 0;
}
switch(pCS->table_id)
{
case PROGRAM_ASSOCIATION_INFORMATION:
{
u16 ProgramCount = (GetSectionLength() -5 - CRC_32_LENGTH)/4;
u16 ProgramNumber;
pU8 += 8;
for(int i = 0; i<ProgramCount; i++)
{
ProgramNumber = pU8[0]*256 + pU8[1];
Found_PID = (pU8[2]&0x1F) * 256 + pU8[3];
if(ProgramNumber)// service -> PMT
{
PidArray[0] ++;
PidArray = (u16 *)realloc(PidArray, (PidArray[0]+1) * sizeof(u16));
assert(PidArray);
PidArray[PidArray[0] ] = Found_PID;
}
else // NIT
{
//pList.AddTable(ACTUAL_NETWORK_INFORMATION, Found_PID);
}
pU8 += 4;
}
}
break;
case CONDITIONAL_ACCESS_INFORMATION:
{
int SectionLength = GetSectionLength();
pU8 += 8;
SectionLength -=5;
while(SectionLength >= 10)
{
Found_PID = (pU8[4]&0x1F) * 256 + pU8[5];
//pList.AddTable(ENTITLE_MANAGE_MESSAGE, Found_PID);
PidArray[0] ++;
PidArray = (u16 *)realloc(PidArray, (PidArray[0]+1) * sizeof(u16));
assert(PidArray);
PidArray[PidArray[0] ] = Found_PID;
SectionLength -= (pU8[1] +2);
pU8 += (pU8[1] +2);
}
}
break;
case PROGRAM_MAP_INFORMATION:
{
PMTSection * pPMTS = (PMTSection *)SectionData;
int LeftLength = pPMTS->program_info_length_hi * 256 + pPMTS->program_info_length_low;
pU8 += 12 ;
while(LeftLength > 5)
{
if((pU8[0])== DESCRIPTOR_CA)
{
Found_PID = (pU8[4]&0x1F) * 256 + pU8[5];
PidArray[0] ++;
PidArray = (u16 *)realloc(PidArray, (PidArray[0]+1) * sizeof(u16));
assert(PidArray);
PidArray[PidArray[0] ] = Found_PID;
//pList.AddTable(ENTITLE_CONTROL_MESSAGE_EVEN, Found_PID);
//pList.AddTable(ENTITLE_CONTROL_MESSAGE_ODD, Found_PID);
}
LeftLength -= (pU8[1]+2);
pU8 += (pU8[1]+2);
}
pU8 += LeftLength;
LeftLength = GetSectionLength() - 9 - ( pPMTS->program_info_length_hi * 256 + pPMTS->program_info_length_low);
while(LeftLength >= (5+6+4))
{
u16 es_info_length = (pU8[3] & 0x0F) * 256 + pU8[4];
LeftLength -= (5+es_info_length);
pU8 += 5;
while(es_info_length >= 6)
{
if((pU8[0])== DESCRIPTOR_CA)
{
Found_PID = (pU8[4]&0x1F) * 256 + pU8[5];
PidArray[0] ++;
PidArray = (u16 *)realloc(PidArray, (PidArray[0]+1) * sizeof(u16));
assert(PidArray);
PidArray[PidArray[0] ] = Found_PID;
//pList.AddTable(ENTITLE_CONTROL_MESSAGE_EVEN, Found_PID);
//pList.AddTable(ENTITLE_CONTROL_MESSAGE_ODD, Found_PID);
}
es_info_length -= (pU8[1]+2);
pU8 += (pU8[1]+2);
}
pU8 += es_info_length;
}
}
break;
default:
assert(0);
break;
}
return PidArray;
}
/*
bool CSection::SectionDataValid()
{
CommonSection * pCS =(CommonSection * )SectionData;
return ((SectionSize -3) == (pCS->section_length_hi*256+pCS->section_length_low));
}
*/
u16 CSection::GetSectionNum()
{
if(SectionData)
{
CommonSection * pCS =(CommonSection * )SectionData;
return (pCS->section_number);
}
else
return INVALID_SECTION_NUMBER;
}
u16 CSection::GetLastSectionNum()
{
if(SectionData)
{
CommonSection * pCS =(CommonSection * )SectionData;
return (pCS->last_section_number);
}
else
return INVALID_SECTION_NUMBER;
}
u16 CSection::GetSectionLength()
{
if(SectionData)
{
CommonSection * pCS =(CommonSection * )SectionData;
return (pCS->section_length_hi*256+pCS->section_length_low);
}
else
return 0;
}
u8 CSection::GetSectionVersion()
{
if(SectionData)
{
CommonSection * pCS =(CommonSection * )SectionData;
return (pCS->version_number);
}
else
return INVALID_VERSION;
}
bool CSection::IsLastSection()
{
CommonSection * pPS =(CommonSection * )SectionData;
return (pPS->section_syntax_indicator ? (pPS->last_section_number <= pPS->section_number):1);
}
u8 CSection::GetSectionSyntaxIndicator(void)
{
CommonSection * pPS =(CommonSection * )SectionData;
return (pPS->section_syntax_indicator);
}
/*
return true:
table finished;
false : table building not finished
bool CSection::Build(CESData * es ,u32 PktIdx)
{
u32 NeedCopyCount , SecBuffLen;
CPacket * pPkt = es->GetPacket(PktIdx);
u8 PktSize = pPkt->GetPktSize();
CommonSection * pPS = pPkt->GetSectionAddress();
SecBuffLen = (pPS->section_length_hi*256+pPS->section_length_low) + 3 ;
// section length only indicat data lenth after this field, so +3
assert(SecBuffLen < MAX_SECTION_LENGTH);
if(SectionData)
free(SectionData);
if((SectionData = (u8 *)malloc(SecBuffLen)) == NULL)
{
TRACE("Malloc(%d) section data fail\r\n",SecBuffLen);
return false;
}
StartPktIdx = PktIdx;
NeedCopyCount = SecBuffLen;
if(pPkt->GetDataStartOffset() + NeedCopyCount < (PktSize))
{// this section in one Packet
memcpy(SectionData , pPS ,NeedCopyCount);
}
else
{// this section transmited in more than one Packet
u8 * BuffAddr = SectionData;
u8 CurCpy;
memcpy(BuffAddr , pPS , (PktSize - pPkt->GetDataStartOffset()));
NeedCopyCount -= (PktSize - pPkt->GetDataStartOffset());
BuffAddr += (PktSize - pPkt->GetDataStartOffset());
PktIdx ++;
while(NeedCopyCount > 0)
{
if((NeedCopyCount + PACKET_HEAD_SIZE) > (PktSize ))
CurCpy = (PktSize - PACKET_HEAD_SIZE);
else
CurCpy = (u8)NeedCopyCount;
memcpy(BuffAddr , ((u8 *)((es->GetPacket(PktIdx))->GetPktData()))+ PACKET_HEAD_SIZE ,CurCpy);
BuffAddr += CurCpy;
NeedCopyCount -= CurCpy;// may be copy more than we want
PktIdx ++;
}
}
return true;
}
*/
/*
bool CSection::WriteBack(CESData * pES,u32 PktIdx)
{
//if(PktIdx == NULL)
// PktIdx = StartPktIdx;//write back to myself by default
bool ret = false ;
CPacket * pPkt = pES->GetPacket(PktIdx);
CommonSection * pPS = pPkt->GetSectionAddress();
s32 NeedCopyCount = GetSectionLength() + 3;
if(NeedCopyCount < (pES->GetPacketSize()- pPkt->GetDataStartOffset()))/* in one packet
{
memcpy((u8 *)pPS, SectionData, NeedCopyCount);
//ret = pES->SavePacketToTS(PktIdx);
assert(0);
}
else
{/* this section in more than one Packet
u8 * BuffAddr = SectionData;
u8 CurCpy;
memcpy(pPS , BuffAddr , (pES->GetPacketSize() - pPkt->GetDataStartOffset()));
ret = pES->SavePacketToTS(PktIdx);
NeedCopyCount -= (pES->GetPacketSize() - pPkt->GetDataStartOffset());
BuffAddr += (pES->GetPacketSize() - pPkt->GetDataStartOffset());
while(NeedCopyCount > 0)
{
PktIdx++;
pPkt = pES->GetPacket(PktIdx);
if(NeedCopyCount > (pES->GetPacketSize() - PACKET_HEAD_SIZE))
CurCpy = (pES->GetPacketSize() - PACKET_HEAD_SIZE);
else
CurCpy = (u8)NeedCopyCount;
memcpy(((u8 *)(pPkt->GetPktData()))+ PACKET_HEAD_SIZE ,BuffAddr , CurCpy);
ret = pES->SavePacketToTS(PktIdx);
BuffAddr += CurCpy;
NeedCopyCount -= CurCpy;/* may be copy more than we want
}
}
return ret;
}
*/
bool CSection::IsSame(u8 * pNewData, u32 DataLen)
{
return (memcmp(SectionData,pNewData,DataLen) == 0);
}
bool CSection::ReplaceData(u8 * pNewData, u32 DataLen)
{
if(IsSame(pNewData,DataLen))
return false;
if(SectionData)
free(SectionData);
assert(DataLen <= 0xFFFF );
SectionData = (u8 *)malloc(DataLen);
memcpy(SectionData, pNewData , DataLen);
{// if updated
CRC myCrc;
u32 NewCrc = myCrc.CalCrc32(SectionData, (u16)(DataLen - 4));
SectionData[DataLen-4] = (u8)(NewCrc >> 24 & 0xFF);
SectionData[DataLen-3] = (u8)(NewCrc >> 16 & 0xFF);
SectionData[DataLen-2] = (u8)(NewCrc >> 8 & 0xFF);
SectionData[DataLen-1] = (u8)(NewCrc & 0xFF);
}
return true;
}
CSection * CSection::Duplicate()
{
CSection * pSecO = new CSection;
pSecO->SectionData = (u8 *)malloc(GetSectionLength()+3);
memcpy(pSecO->SectionData, SectionData, GetSectionLength()+3);
pSecO->StartPktIdx = StartPktIdx;
if(pNext)
pSecO->pNext = pNext->Duplicate();
else
pSecO->pNext = NULL;
return pSecO;
}
| [
"[email protected]"
]
| [
[
[
1,
353
]
]
]
|
4a13620a4ffdaa722fef4fc267b9f6ecd198abd0 | 2eda21938786de13a565903d8b2feab25ac9ccb8 | /Creature.h | a6ab5bafb074d37db67730a3028e358b2df42f73 | []
| no_license | gbougard/NBK | d2ed27fc825a8919c716e7011e1a7631a6bc3be1 | e8155adec2da3f333230b050fccc164e1e3c04fe | refs/heads/master | 2021-01-15T21:39:58.541842 | 2011-11-21T20:36:38 | 2011-11-21T20:36:38 | 3,157,757 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,447 | h | #ifndef CREATURE_H
#define CREATURE_H
#include "BR5Model.h"
#include "Entity.h"
namespace game_objects
{
class CCreature: public CEntity
{
public:
CCreature();
~CCreature();
enum ACTION_ANIMATIONS
{
AA_IDLE = 0,
AA_WALK,
AA_DIG,
AA_CLAIM,
AA_DRAG
// TODO, add the rest
};
GLvoid setName(std::string name);
GLvoid setOwner(GLubyte owner);
GLvoid setLevel(GLint level);
GLvoid setGold(GLint gold);
GLvoid addCurrentXP(GLint CurrentXP);
GLvoid setModel(loaders::CBR5Model *model);
GLvoid setAction(GLint action, GLint startFrame, GLint endFrame);
GLvoid useAction(GLint action);
GLvoid Idle(GLfloat deltaTime);
GLvoid draw(GLfloat deltaTime);
virtual GLvoid update(GLfloat deltaTime);
loaders::CBR5Model *getModel();
std::string getName();
GLubyte getOwner();
GLint getLevel();
GLint getCurrentXP();
GLint getGold();
protected:
std::string name;
loaders::CBR5Model *model;
GLint currentAction;
// mapping for action -> model action
std::map<GLint, GLint> actions;
// creature params, TODO add more
GLfloat moveSpeed;
GLfloat count, change;
cml::vector3f moveVector;
// Creature stats
GLubyte owner;
GLint level;
GLint CurrentXP;
GLint gold;
/* holds the current path */
std::vector<cml::vector2i> path;
};
};
#endif // CREATURE_H | [
"[email protected]",
"[email protected]",
"[email protected]"
]
| [
[
[
1,
16
],
[
22,
25
],
[
30,
32
],
[
34,
38
],
[
43,
56
],
[
58,
58
],
[
68,
72
]
],
[
[
17,
21
],
[
26,
29
],
[
33,
33
],
[
39,
42
],
[
57,
57
],
[
60,
65
]
],
[
[
59,
59
],
[
66,
67
]
]
]
|
daadf82781d71e4909159a3fedd7a51c04af7433 | 41efaed82e413e06f31b65633ed12adce4b7abc2 | /projects/example/src/MyLight.h | 7c00a0fc2b232c5f17d26477ad1eee33a580b9a3 | []
| no_license | ivandro/AVT---project | e0494f2e505f76494feb0272d1f41f5d8f117ac5 | ef6fe6ebfe4d01e4eef704fb9f6a919c9cddd97f | refs/heads/master | 2016-09-06T03:45:35.997569 | 2011-10-27T15:00:14 | 2011-10-27T15:00:14 | 2,642,435 | 0 | 2 | null | 2016-04-08T14:24:40 | 2011-10-25T09:47:13 | C | UTF-8 | C++ | false | false | 1,288 | h | // This file is an example for CGLib.
//
// CGLib 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.
//
// CGLib 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 CGLib; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
// Copyright 2007 Carlos Martinho
#ifndef MY_LIGHT_H
#define MY_LIGHT_H
#include <string>
#include "cg/cg.h"
#include "MyPhysics.h"
namespace example {
class MyLight : public cg::Entity,
public cg::IDrawListener,
public cg::IUpdateListener
{
private:
bool _isDebug;
MyPhysics _physics;
int _lightDL;
void makeLight();
public:
MyLight(std::string id);
~MyLight();
void init();
void update(unsigned long elapsed_millis);
void draw();
void toggleDebugMode();
};
}
#endif | [
"Moreira@Moreira-PC.(none)"
]
| [
[
[
1,
49
]
]
]
|
863f2f4c18419dfb41cbf7c51b9f8e83738fc69b | 7ba7440b6a7b6068c900d561ad03c3ff86439c09 | /GalDemo/GalDemo/Quad.cpp | 8cdcf78ac3b495a64438e1de8a5bd62cca5f16b8 | []
| no_license | weimingtom/gal-demo | 96dc06f8f02b4c767412aac7fcf050e241b40c04 | f2b028591a195516af3ce33d084b7b29cbea84aa | refs/heads/master | 2021-01-20T11:47:07.598476 | 2011-08-10T23:48:43 | 2011-08-10T23:48:43 | 42,379,726 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,789 | cpp | #include "stdafx.h"
#include "Quad.h"
#include "Game.h"
#include <assert.h>
CQuad::CQuad( hgeQuad quad, int id):CRenderableObject(id)
{
memset(&m_quad, 0x0, sizeof(hgeQuad));
memcpy(&m_quad, &quad, sizeof(hgeQuad));
}
CQuad::CQuad(HTEXTURE tex, int id):CRenderableObject(id)
{
assert(tex != 0);
memset(&m_quad, 0x0, sizeof(hgeQuad));
for (int i = 0; i < 4; i++)
{
m_quad.v[i].col = 0xffffffff;
m_quad.v[i].z = 0.5;
}
m_quad.blend = BLEND_DEFAULT;
m_quad.tex = tex;
HGE *hge = hgeCreate(HGE_VERSION);
float width = hge->Texture_GetWidth(tex);
float height = hge->Texture_GetHeight(tex);
hge->Release();
m_quad.v[0].tx = 0;
m_quad.v[0].ty = 0;
m_quad.v[1].tx = 1;
m_quad.v[1].ty = 0;
m_quad.v[2].tx = 1;
m_quad.v[2].ty = 1;
m_quad.v[3].tx = 0;
m_quad.v[3].ty = 1;
m_quad.v[0].x = 0;
m_quad.v[0].y = 0;
m_quad.v[1].x = width;
m_quad.v[1].y = 0;
m_quad.v[2].x = width;
m_quad.v[2].y = height;
m_quad.v[3].x = 0;
m_quad.v[3].y = height;
}
CQuad::~CQuad(void)
{
}
void CQuad::Render()
{
HGE *hge = hgeCreate(HGE_VERSION);
hge->Gfx_RenderQuad(&m_quad);
hge->Release();
}
void CQuad::SetVertex( FPOINT pos[4] )
{
for (int i = 0; i < 4; i++)
{
m_quad.v[i].tx = pos[i].x;
m_quad.v[i].ty = pos[i].y;
}
}
void CQuad::GetVertex(FPOINT pos[4])
{
for (int i = 0; i < 4; i++)
{
pos[i].x = m_quad.v[i].tx;
pos[i].y = m_quad.v[i].ty;
}
}
void CQuad::SetPosition( FPOINT pos[4] )
{
for (int i = 0; i < 4; i++)
{
m_quad.v[i].x = pos[i].x;
m_quad.v[i].y = pos[i].y;
}
}
void CQuad::GetPosition( FPOINT pos[4] )
{
for (int i = 0; i < 4; i++)
{
pos[i].x = m_quad.v[i].x;
pos[i].y = m_quad.v[i].y;
}
}
void CQuad::SetColor( int color[4] )
{
for (int i = 0; i < 4; i++)
{
m_quad.v[i].col = color[i];
}
}
void CQuad::GetColor( int color[4] )
{
for (int i = 0; i < 4; i++)
{
color[i] = m_quad.v[i].col;
}
}
void CQuad::SetZ( float z[4] )
{
for (int i = 0; i < 4; i++)
{
m_quad.v[i].z = z[i];
}
}
void CQuad::GetZ( float z[4] )
{
for (int i = 0; i < 4; i++)
{
z[i] = m_quad.v[i].z;
}
}
FPOINT CQuad::GetTopLeft()
{
return FPOINT(m_quad.v[0].x, m_quad.v[0].y);
}
void CQuad::SetTopLeft( FPOINT point )
{
float width = GetWidth();
float height = GetHeight();
m_quad.v[0].x = point.x; m_quad.v[0].y = point.y;
m_quad.v[1].x = point.x + width; m_quad.v[1].y = point.y;
m_quad.v[2].x = point.x + width; m_quad.v[2].y = point.y + height;
m_quad.v[3].x = point.x; m_quad.v[3].y = point.y + height;
}
float CQuad::GetWidth()
{
return m_quad.v[1].x - m_quad.v[0].x;
}
float CQuad::GetHeight()
{
return m_quad.v[2].y - m_quad.v[1].y;
} | [
"[email protected]"
]
| [
[
[
1,
160
]
]
]
|
c157adca06931af69b99d1a140858f6583f3e6fc | 2dbbca065b62a24f47aeb7ec5cd7a4fd82083dd4 | /OUAN/OUAN/Src/Logic/LogicComponent/WeaponComponent.h | ce6f7cf218fff5d0dda04395710645546bb89d23 | []
| no_license | juanjmostazo/once-upon-a-night | 9651dc4dcebef80f0475e2e61865193ad61edaaa | f8d5d3a62952c45093a94c8b073cbb70f8146a53 | refs/heads/master | 2020-05-28T05:45:17.386664 | 2010-10-06T12:49:50 | 2010-10-06T12:49:50 | 38,101,059 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,866 | h | #ifndef WEAPONCOMPONENTH_H
#define WEAPONCOMPONENTH_H
#include "../../Component/Component.h"
namespace OUAN
{
typedef std::map<std::string,GameObjectPtr> TWeaponCollection;
class WeaponComponent: public Component
{
public:
WeaponComponent(const std::string& type="");
~WeaponComponent();
void initWeapons(std::vector<std::string> weapons, const std::string& activeWeapon);
void cleanUp();
void changeActiveWeapon(const std::string& newWeapon);
GameObjectPtr getActiveWeapon();
void initActiveWeapon();
void setAttackType(const std::string& newAttack);
void updateAttackType();
void update(long elapsedTime);
bool isActiveWeaponInUse() const;
void setActiveWeaponInUse(bool activeWeaponInUse);
void switchOn();
void switchOff();
int getWeaponPower() const;
void setWeaponPower(int weaponPower);
void increaseWeaponPower(int amount=1);
void decreaseWeaponPower(int amount=1);
int getMaxWeaponPower() const;
void setMaxWeaponPower(int maxWeaponPower);
private:
//TWeaponCollection mAvailableWeapons;
GameObjectPtr mActiveWeapon;
bool mActiveWeaponInUse;
std::string mActiveWeaponName;
int mWeaponPower;//Atm, use the same value for both weapons
int mMaxWeaponPower;//set as an attribute to consider 'level-up'
std::string mCurrentWeaponAttack;
// We can't instance the GameObjects during the component initialization,
// since in principle it is possible that they haven't been created yet.
// For that reason, we'll keep their names temporarily until
std::vector<std::string> mWeaponNames;
};
class TWeaponComponentParameters: public TComponentParameters
{
public:
TWeaponComponentParameters();
~TWeaponComponentParameters();
std::vector<std::string> mWeaponNames;
std::string mSelectedWeapon;
};
}
#endif | [
"ithiliel@1610d384-d83c-11de-a027-019ae363d039"
]
| [
[
[
1,
65
]
]
]
|
ce87a04cc949125ef5afde3e61d67be9a47c6207 | e7c45d18fa1e4285e5227e5984e07c47f8867d1d | /SMDK/TransCritical/TTOrifice/TTFT.cpp | 8e29ba4f0cb4afd545e7e673c1fa05fa2c1d353f | []
| no_license | abcweizhuo/Test3 | 0f3379e528a543c0d43aad09489b2444a2e0f86d | 128a4edcf9a93d36a45e5585b70dee75e4502db4 | refs/heads/master | 2021-01-17T01:59:39.357645 | 2008-08-20T00:00:29 | 2008-08-20T00:00:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,335 | cpp | //================== SysCAD - Copyright Kenwalt (Pty) Ltd ===================
// $Nokeywords: $
//===========================================================================
#include "stdafx.h"
#define __TTECHFT_CPP
#include "TTFT.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
#include "scdmacros.h"
#include "md_headers.h"
#pragma LIBCOMMENT("..\\..\\Bin\\", "\\DevLib" )
#pragma LIBCOMMENT("..\\..\\Bin\\", "\\scdlib" )
//===========================================================================
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
//===========================================================================
void ForceLoad_TTechFT()
{
// Dummy Function to allow other libraries to force load this one
}
//===========================================================================
extern "C" __declspec(dllexport) BOOL IsSMDKLibDLL()
{
return TRUE;
}
//===========================================================================
| [
"[email protected]",
"[email protected]",
"[email protected]"
]
| [
[
[
1,
15
],
[
18,
52
]
],
[
[
16,
16
]
],
[
[
17,
17
]
]
]
|
02af1956863dc2d4ccf05ddac17de8ff7635b78c | 28b0332fabba904ac0668630f185e0ecd292d2a1 | /src/Common/HugeInt.cpp | 48da8284cc428b2e476f6377477041192cc94ff8 | []
| no_license | iplayfast/crylib | 57a507ba996d1abe020f93ea4a58f47f62b31434 | dbd435e14abc508c31d1f2f041f8254620e24dc0 | refs/heads/master | 2016-09-05T10:33:02.861605 | 2009-04-19T05:17:55 | 2009-04-19T05:17:55 | 35,353,897 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 27,346 | cpp | #include <stdio.h>
#include <string.h>
#include "HugeInt.h"
#include "ClassString.h"
#include "ClassProperty.h"
#include "ClassException.h"
using namespace Crystal;
//#pragma inline
#define SBS 1024
#ifdef VALIDATING
bool HugeInt::Test(bool Verbose,Object &ThisObject,bool (CallBack)(bool Verbose,const char *Result,bool fail))
{
bool fail = false;
if (!Object::Test(Verbose,ThisObject,CallBack))
return true;
HugeInt m,n;
m.Add(0xffffffff);
m.Inc(1);
m.Inc(1);
m.Dec(2);
n = m;
m.Add(m);
m.Sub(n);
if (m!=0xffffffff)
fail = true;
if (!CallBack(Verbose,"Carry Tests",fail))
return true;
// m.Set
return true;
}
#endif
void HugeInt::SetNumDigits(unsigned int n)
{
if (NumDigits==n) return;
if (NumDigits>n) // we are reducing the size of a number so zero out anything that is above the size
{
for(unsigned int i=0;i<(NumDigits-n);i++)
Number[i] = 0;
return;
}
unsigned *nn = new unsigned [n];
if (!nn)
throw Exception(this,"Out of memory Creating HugeInt");
for (unsigned int i=0;i<n-NumDigits;i++)
nn[i] = 0;
for(unsigned int j=0,i=n-NumDigits;i<n;i++,j++)
{
nn[i] = Number[j];
}
if (NumDigits)
delete []Number;
Number = nn;
NumDigits = n;
SetFlags();
}
void HugeInt::CopyTo(Object &Dest) const //copies contents of this to Dest
{
if (Dest.IsA(CHugeInt))
{
HugeInt *h = (HugeInt *)&Dest;
*h = *this;
return;
}
if (Dest.IsA(CStream))
{
SaveTo(*(Stream *)&Dest);
return;
}
throw Exception(this,"Can't copy HugeInt to %s",Dest.ChildClassName());
}
Object *HugeInt::Dup() const // creates a duplicate of this object
{
HugeInt *h = new HugeInt();
*h = *this;
return h;
}
const char *HugeInt::GetProperty(const PropertyParser &PropertyName,String &Result) const
{
if (PropertyName=="Value")
{
return GetValue(Result);
}
return Object::GetProperty(PropertyName,Result);
}
const char *HugeInt::GetProperty(const char *PropertyName,String &Result) const
{
PropertyParser pp(PropertyName);
return GetProperty(pp,Result);
}
bool HugeInt::HasProperty(const PropertyParser &PropertyName)const
{
return (PropertyName=="Value") || Object::HasProperty(PropertyName);
}
bool HugeInt::HasProperty(const char *PropertyName)const
{
PropertyParser pp(PropertyName);
return HasProperty(pp);
}
PropertyList *HugeInt::PropertyNames() const
{
PropertyList *n = Object::PropertyNames();
n->AddPropertyByName("Value",this);
return n;
}
int HugeInt::GetPropertyCount() const
{
return 1 + Object::GetPropertyCount();
}
bool HugeInt::SetProperty(const PropertyParser &PropertyName,const char *PropertyValue)
{
if (PropertyName=="Value")
{
this->SetValue(PropertyValue);
return true;
}
return Object::SetProperty(PropertyName,PropertyValue);
}
bool HugeInt::SetProperty(const char *PropertyName,const char *PropertyValue)
{
PropertyParser pp(PropertyName);
return SetProperty(pp,PropertyValue);
}
void FindFactor::Step()
{
HugeInt n;
CalcTargetDigits();
LowerNums.PutPool(CurrentResult);
FindMults();
exp++;
}
void FindFactor::CalcTargetDigits()
{
if (TargetDigitsBase!=HIBase)
{
Target.GetDigits(0,Target.GetNumDigits() * 32,HIBase,TargetDigits);
TargetDigitsBase = HIBase;
}
}
void FindFactor::FindMults()
{
HugeInt i,k,*n,*d,t;
HugeInt exp10 = 1;
HugeInt c;
HugeInt AddVal,TopVal;
HugeInt LocalTarget;
for(unsigned int I=0;I<exp;I++)
{
AddVal = exp10;
if (HIBase!=0)
exp10.Mult(HIBase);
else
exp10.Shl32();
}
TopVal = AddVal;
if (HIBase!=0)
TopVal.Mult(HIBase);
else
TopVal.Shl32();
HugeInt *FirstMult,*SecondMult;
n = Scrap.Get();
while(LowerNums.Count())
{
FirstMult = LowerNums.Get();
SecondMult = LowerNums.Get();
i.ZeroOut();
for(unsigned int I=0;HIBase >= I; I++,i.Add(AddVal))
{
*n = i;
n->Add(*FirstMult);
k.ZeroOut();
d = Scrap.Get();
for(HugeInt K=0;HIBase>=K;K.Inc(),k.Add(AddVal))
{
*d = k;
d->Add(*SecondMult);
t = *n;
t.Mult(*d);
if (t>Target)
break;
if (t.GetDigit(exp,HIBase) == TargetDigits[exp-1])//Target.GetDigit(exp,Base))
{
if (t==Target)
{
HugeInt *f = Scrap.Get();
*f = *d;
FinalResults.Put(f);
f = Scrap.Get();
*f = *n;
FinalResults.Put(f);
}
if (!CurrentResult.InPool(*d,*n))
{
HugeInt *Temp = Scrap.Get();
*Temp = *d;
CurrentResult.Put(Temp);
Temp = Scrap.Get();
*Temp = *n;
CurrentResult.Put(Temp);
}
}
}
}
}
Scrap.Put(n);
}
//=======================================================================================================
static char StrBuffer[SBS];
HugeInt *Pool::Get()
{
if (pPool == 0)
{
pPool = new HugeInt();
pPool->SetPointer(0);
_Count=1;
}
HugeInt *r = pPool;
pPool = r->GetPointer();
r->SetPointer(0);
_Count--;
if (_Count==0)
memset(HashArray,0,HASHSIZE);
return r;
}
void Pool::Put(HugeInt *p)
{
if (p)
{
SetHash(p);
p->SetPointer(pPool);
pPool = p;
_Count++;
}
}
bool Pool::CheckHash(HugeInt *p)
{
unsigned int Value = p->GetBottomDigit();
unsigned int HashValue = (Value / 32) % HASHSIZE;
return HashArray[HashValue] & BitArray[Value & 31];
}
void Pool::SetHash(HugeInt *p)
{
unsigned int Value = p->GetBottomDigit();
unsigned int HashValue = (Value / 32) % HASHSIZE;
HashArray[HashValue] |= BitArray[Value & 31];
}
void Pool::PutTail(HugeInt *p)
{
HugeInt *pp = pPool;
if (p)
{
SetHash(p);
p->SetPointer(0L);
while(pp->GetPointer())
pp = pp->GetPointer();
pp->SetPointer(p);
_Count++;
}
}
bool Pool::InPool(HugeInt &Value)
{
HugeInt *p1 = pPool;
if (CheckHash(&Value))
while(p1)
{
if (*p1==Value)
return true;
p1 = p1->GetPointer();
}
return false;
}
bool Pool::InPool(HugeInt &Value1,HugeInt &Value2)
{
HugeInt *p1 = pPool;
if (CheckHash(&Value1))
while(p1 && p1->GetPointer())
{
if ((*p1==Value1) && (*(p1->GetPointer())==Value2))
return true;
p1 = p1->GetPointer();
}
return false;
}
bool Pool::InPool(HugeInt &Value1,HugeInt &Value2,HugeInt &Value3)
{
HugeInt *p1 = pPool;
if (CheckHash(&Value1))
while(p1 && p1->GetPointer() && p1->GetPointer()->GetPointer())
{
if ((*p1==Value1) && (*(p1->GetPointer())==Value2) && *(p1->GetPointer()->GetPointer())==Value3)
return true;
p1 = p1->GetPointer();
}
return false;
}
//================================================================================
String &HugeInt::GetValue(String &Result) const
{
Result.Clear();
HugeInt Divisor,Quotient,Remainder,Temp = *this;
char Buff[2];
Buff[1] = '\0';
Divisor = 10;
if (Temp.IsZero())
Result = "0";
while(!Temp.IsZero())
{
Temp.Div(Divisor,Quotient,Remainder);
int i = Remainder.GetBottomDigit();
Buff[0] = '0'+i;
Result += Buff;
Temp = Remainder;
}
return Result;
}
HugeInt &HugeInt::SetValue(const char *str)
{
char ch;
HugeInt M = 10;
ZeroOut();
const char *Orgstr = str;
while(*str)
{
if (*str<'0' || *str>'9')
throw Exception(this,"Bad format for HugeInt ",Orgstr);
ch = *str - '0';
M = *this;
// Mult by 10 = (M*2*2+M)*2
Shl1(); // *2
Shl1(); // *2
Add(M); // add original value
Shl1(); // *2
Add(ch); // Add new digit
str++;
}
return *this;
}
HugeInt &HugeInt::Mult(const HugeInt &m)
{
HugeInt t = *this;
unsigned int i;
// bool first = false;
if (&m == this)
return Mult(t);
if (m.IsOne() || IsZero())
return *this; // if I'm 0 return me cause 0 * N = 0
if (m.IsZero() || IsOne()) // if I'm 1 return N cause 1 * N = N
{
*this = m;
return *this;
}
if (m.IsTwo())
{
Shl1();
return *this;
}
if (IsTwo())
{
*this = m;
Shl1();
return *this;
}
ZeroOut();
HugeInt nm = m;
while(nm.Number[nm.NumDigits-1]==0)
{
nm.Shr32();
t.Shl32();
}
// for(i=(m.FirstDigit)*32 ;i<NumBits;i++) // the first bit of the the multipliers first digit,
for(i=nm.FirstBit();i<NumBits;i++) // the first bit of the the multipliers first digit,
{
if (nm.IsOdd()) // 1 * N = N
Add(t); // flags are set here as well
if (!nm.Shr1()) // is m == 0
return *this; // yes
t.Shl1();
}
SetFlags(); // should never get here
return *this;
}
// returns true if non-zero
bool HugeInt::Shl1()
{
if (IsZero())
return false;
unsigned int *Digit,*EndDigit;
//bool cy;
if ((FirstDigit==0) && ((Number[FirstDigit] & HighDigitBit)!=0))
{
SetNumDigits(NumDigits+1);
//FirstDigit++;
}
EndDigit = &Number[NumDigits-1];
Digit = &Number[FirstDigit];
// if (Digit==EndDigit)
{
if ((*Digit & HighDigitBit)!=0)
{
FirstDigit--;
Number[FirstDigit] = 1;
}
}
while(Digit < EndDigit)
{
*Digit = (*Digit<<1);
if ((Digit[1] & HighDigitBit)) // if the next one has the high bit set
*Digit|=1; // add 1
Digit++;
}
*Digit = (*Digit<<1);
return SetFlags();
}
// returns true if non zero
bool HugeInt::Shl32()
{
unsigned int *Digit;
unsigned int t = 0;
if ((FirstDigit==0) && (Number[FirstDigit]!=0))
{
SetNumDigits(NumDigits+1);
FirstDigit++;
}
if (FirstDigit)
FirstDigit--; // setup for final result
Digit = &Number[FirstDigit];
while(Digit<&Number[NumDigits-1])
{
t |= *Digit = Digit[1];
Digit++;
}
*Digit = 0L;
if (t==0)
Flags = ISZERO | ISMOSTLYZERO;
else
Flags = 0;
return Flags != ISZERO;
}
HugeInt &HugeInt::Shl(unsigned int n)
{
while(n>32)
{
Shl32();
n-=32;
}
while(n)
{
Shl1();
n--;
}
return *this;
}
// returns true if non-zero
bool HugeInt::Shr1()
{
if (IsZero())
return false;
unsigned int F = Flags;
unsigned int *Digit = &Number[NumDigits-1];
if (F & (ISONE | ISTWO))
{
*Digit = *Digit >> 1;
return SetFlags(*Digit);
}
while(Digit>&Number[FirstDigit])
{
*Digit = *Digit >> 1;
Digit--;
if (*Digit & 0x00000001)
Digit[1] |= HighDigitBit;
}
*Digit = *Digit >> 1;
return SetFlags();
}
// returns true if non-zero
bool HugeInt::Shr32()
{
unsigned int *Digit = &Number[NumDigits-1];
unsigned int *First = &Number[FirstDigit];
unsigned int F = 0L;
if (Flags & (ISZERO | ISMOSTLYZERO)==0)
{
*Digit = 0;
Flags = ISZERO;
return false;
}
while(Digit >First)
{
F |= Digit[0] = Digit[-1];
Digit--;
}
Digit[0] = 0L;
if (FirstDigit<NumDigits-1)
FirstDigit++;
if (F)
{
Flags = 0; // one of the digits had a value reset flags
return true;
}
else
{
Flags = ISZERO | ISMOSTLYZERO;
return false;
}
}
HugeInt &HugeInt::Shr(unsigned int n)
{
while(n>32)
{
Shr32();
n-=32;
}
while(n)
{
Shr1();
n--;
}
return *this;
}
bool HugeInt::Mult10()
{
HugeInt t = *this;
Shl1();
Shl1();
Add(t);
Shl1();
return SetFlags();
}
HugeInt &HugeInt::Inc(unsigned int Amount) // need to test
{
unsigned int cy=Amount,*d1 = &Number[NumDigits-1],temp;
while(d1>=Number)
{
temp = *d1;
*d1 += cy;
if (temp <= *d1)
break;
d1--;
cy = 1;
// *d1 = *d1 + cy;
//asm jc CarryLable:
// SetFlags();
// return *this;
// CarryLable:
// d1--;
}
SetFlags();
return *this;
}
HugeInt &HugeInt::Dec(unsigned int Amount)// Need Testing
{
unsigned int cy=Amount,*d1 = &Number[NumDigits-1],temp;
while(d1>=Number)
{
temp = *d1;
*d1 -= cy;
if (temp >= cy)
break;
d1--;
cy = 1;
// *d1 = *d1 - cy;
//asm jc CarryLable:
//SetFlags();
// return *this;
// CarryLable:
// d1--;
}
SetFlags();
return *this;
}
HugeInt &HugeInt::IncDigit(unsigned int d)
{
d--;
do
{
d++;
Number[NumDigits - d]++;
}
while (Number[NumDigits -d]==0);
SetFlags();
return *this;
}
HugeInt &HugeInt::DecDigit(unsigned int d)
{
if (d>NumDigits)
return *this;
bool cy;
do
{
cy = Number[NumDigits - d]==0;
Number[NumDigits - d]--;
d++;
}
while(cy);
SetFlags();
return *this;
}
HugeInt &HugeInt::Add(const HugeInt &n)
{
#ifdef Verify
HugeInt Org = *this;
#endif
if (&n==this)
{
Shl1();
return *this;
}
// Insure there is space for the result
{
unsigned int MaxDigitNeeded = n.NumDigits;
if (n.Number[0]!=0) MaxDigitNeeded++;
if (NumDigits >= MaxDigitNeeded)
{
MaxDigitNeeded = NumDigits;
if (Number[0]!=0) MaxDigitNeeded++;
}
if (NumDigits<MaxDigitNeeded)
SetNumDigits(MaxDigitNeeded);
}
unsigned int cy=0,
*Stop,
*d1 = &Number[NumDigits-1],*d2 = &n.Number[n.NumDigits-1],temp;
unsigned int FirstDigitM1; // last digit to add (first from the left)
FirstDigitM1 = FirstDigit-1; // first digit must be at least one, (because otherwise it would have been expanded above)
if (n.FirstDigit<FirstDigit)
FirstDigitM1 = n.FirstDigit-1;
Stop = &Number[FirstDigitM1];
while(1)
{
if (cy)
{
temp = *d1;
*d1 += cy;
if (temp > *d1)
cy = 1;
else
cy = 0;
}
temp = *d1;
*d1 += *d2;
if (temp > *d1)
cy = 1;
if (d1==Stop) // at first digit
break;
d1--;
if (d1==Stop)
{
if (cy)
*d1 += cy;
break;
}
d2--;
}
#ifdef Verify
HugeInt v = *this;
v.Sub(n);
if (v!=Org)
throw;
#endif
SetFlags();
return *this;
}
HugeInt &HugeInt::Sub(const HugeInt &n)
{
if (&n==this)
{
ZeroOut();
return *this;
}
if (NumDigits<n.NumDigits)
SetNumDigits(n.NumDigits);
unsigned int cy=0,*d1 = &Number[NumDigits-1],*d2 = &n.Number[n.NumDigits-1],temp;
unsigned int *stop = &n.Number[n.FirstDigit];
while(d1>=Number)
{
temp = *d1;
*d1 -= cy;
if (temp < *d1)
cy = 1;
else
cy = 0;
temp = *d1;
*d1 -= *d2;
if (temp < *d1)
cy = 1;
if (d1>Number) // avoid codeguard pointer underrun warning
{
d1--;
if (d2==stop)
{
if (cy) *d1 -= cy;
break;
}
d2--;
}
else break;
}
SetFlags();
return *this;
}
HugeInt &HugeInt::Add(const unsigned int &n)
{
unsigned int cy=0,*d1 = &Number[NumDigits-1],d2,temp;
d2 = n;
do
{
temp = *d1;
*d1 += cy;
if (temp > *d1)
cy = 1;
else
cy = 0;
temp = *d1;
*d1 += d2;
if (temp > *d1)
cy = 1;
d1--;
d2 = 0L;
}
while(cy!=0);
SetFlags();
return *this;
}
HugeInt &HugeInt::Sub(const unsigned int &n)
{
unsigned int cy=0,*d1 = &Number[NumDigits-1],d2,temp;
d2 = n;
do
{
temp = *d1;
*d1 -= cy;
if (temp < *d1)
cy = 1;
else
cy = 0;
temp = *d1;
*d1 -= d2;
if (temp < *d1)
cy = 1;
d1--;
d2 = 0L;
}
while(cy!=0);
SetFlags();
return *this;
}
bool HugeInt::Div(HugeInt &Divisor,HugeInt &Quotient,HugeInt &Remainder)
{
return Div(*this,Divisor,Quotient,Remainder);
}
unsigned int HugeInt::FirstBit() const
{
unsigned int FirstBit = 0;
const unsigned int *pNumber = &Number[0];
if (IsZero())
return 0;
unsigned int i;
i = FirstDigit;
FirstBit = i * 32;
pNumber = &Number[i];
for(;i<NumDigits;i++)
{
if (*pNumber!=0L)
{
unsigned int ByteMask = 0xff000000;
unsigned int BitMask = 0x80000000;
while(1)
{
if ((*pNumber & ByteMask)!=0)
{
while ((*pNumber & BitMask)==0)
{
FirstBit++;
BitMask >>=1;
}
return FirstBit;
}
FirstBit +=8;
ByteMask >>=8;
BitMask >>=8;
}
}
else // shouldn't ever get here
FirstBit += 32;
pNumber++;
}
return 0; // shouldn't get here
}
bool HugeInt::Div(HugeInt &Dividend, HugeInt &Divisor,HugeInt &Quotient,HugeInt &Remainder) const
{
HugeInt d;
Quotient.ZeroOut();
Remainder.ZeroOut();
if (Divisor.IsZero())
return true; // divide by zero error
if (Divisor > Dividend)
{
Remainder = Dividend;
return false;
}
if (Divisor == Dividend)
{
Quotient = 1L;
return false;
}
if (Divisor.IsOne())
return false;
if (Divisor.IsTwo())
{
if (Dividend.IsOdd())
Remainder = 1;
else
Remainder = 0;
Quotient = Dividend;
Quotient.Shr1();
return false;
}
//-----------------------------------
// #define SLOW_BUT_WORKING
// while(IsEven() && Divisor.IsEven())
// {
// Shr1();
// Divisor.Shr1();
// }
HugeInt OrgDivisor = Divisor;
HugeInt ShiftDivisor = Divisor;
unsigned int DividendFirstBit = Dividend.FirstBit();
unsigned int DivisorFirstBit= Divisor.FirstBit();
if (DivisorFirstBit>DividendFirstBit)
{
ShiftDivisor.Shl(DivisorFirstBit-DividendFirstBit);
DivisorFirstBit = DividendFirstBit;
}
Remainder = Dividend;
while(ShiftDivisor >=OrgDivisor)
{
if (!Quotient.IsZero())
Quotient.Shl1();
if (Remainder >= ShiftDivisor)
{
Remainder.Sub(ShiftDivisor);
Quotient.Number[Quotient.NumDigits-1] |= 1;
if (Quotient.IMZ())
Quotient.SetFlags(Quotient.Number[Quotient.NumDigits-1]);
else
Quotient.Flags = 0;
}
ShiftDivisor.Shr1();
}
return false;
//-----------------------------------
}
const char *HugeInt::GetAsStr(unsigned int Base) const
{
char *s = &StrBuffer[SBS-1];
HugeInt Dividend,Divisor,Remainder,Quotient;
memset(StrBuffer,' ',SBS-1);
Dividend = *this;
*s-- = '\0';
if (Base==10)
{
while(!Dividend.IsZero())
{
Divisor = Base;
Div(Dividend,Divisor,Quotient,Remainder);
*s = Remainder.Number[NumDigits-1] + '0';
s--;
Dividend = Quotient;
}
// Huge2Str(StrBuffer);
s++;
if (*s=='\0')
{
s--;
*s = '0';
}
return s;
}
if (Base==16)
{
int ni = NumDigits-1;
unsigned int mask,shiftcount,v;
while(ni)
{
mask = 0x0f;
shiftcount = 0;
while(mask)
{
v = Number[ni];
v &= mask;
v >>=shiftcount;
*s = '0' + v;
if (*s>'9') *s = *s - '9' + 'A' - 1;
s--;
shiftcount +=4;
mask <<=4;
}
ni--;
}
if (*s=='\0')
{
s--;
*s = '0';
}
return s;
}
char FinalOut[1024];
FinalOut[0] = '\0';
while(!Dividend.IsZero())
{
Divisor = Base;
Div(Dividend,Divisor,Quotient,Remainder);
strcat(FinalOut,Remainder.GetAsStr());
strcat(FinalOut,",");
Dividend = Quotient;
}
{
StrBuffer[0] = '\0';
char *ch = &FinalOut[strlen(FinalOut)-1];
while(ch>FinalOut)
{
*ch = '\0';
while((ch>FinalOut) && (*ch!=','))
ch--;
if (ch==FinalOut)
strcat(StrBuffer,",");
strcat(StrBuffer,ch);
}
}
return StrBuffer+1;
}
void HugeInt::Huge2Str(char *b)
{
char Buffer[20];
bool dd =false;
strcpy(StrBuffer,"0x");
for(unsigned int i=0;i<NumDigits;i++)
{
if (Number[i]!=0L)
{
sprintf(Buffer,"%lX",Number[i]);
strcat(StrBuffer,Buffer);
dd = true;
}
}
if (!dd)
strcat(StrBuffer,"0");
strcpy(b,StrBuffer);
}
unsigned int HugeInt::GetDigit(unsigned int Digit,unsigned int Base) const
{
if (Base==0)
return GetDigit(Digit);
if (IMZ())
{
unsigned int Value = GetBottomDigit();
while(--Digit)
{
Value /= Base;
}
return Value % Base;
}
HugeInt t = *this;
HugeInt q,r,HIBase = Base;
while(Digit--)
{
Div(t,HIBase,q,r);
HIBase = Base;
t = q;
}
return r.GetDigit(1);
}
HugeInt HugeInt::GetDigit(unsigned int Digit,const HugeInt &Base) const
{
if (Base.IsZero())
return *this;
HugeInt t = *this;
HugeInt q,r,HIBase = Base;
while(Digit--)
{
Div(t,HIBase,q,r);
HIBase = Base;
t = q;
}
return r;
}
void HugeInt::GetDigits(unsigned int start,unsigned int end,HugeInt Base,unsigned int *Digits) const
{
while(start)
{
start--;
end--;
Digits++;
}
HugeInt t = *this;
HugeInt q,r,HiBase = Base;
while(end)
{
Div(t,HiBase,q,r);
HiBase = Base;
t = q;
*Digits++=r.GetDigit(1);
end--;
}
}
bool Primes::Div(HugeInt &i)
{
HugeInt Quot,Rem;
HugeInt *pp = _Primes[0];
HugeInt Div2;
Quot =2; // just temporary
i.Div(i,Quot,Div2,Rem);
while(pp)
{
if (*pp<=Div2)
{
i.Div(i,*pp,Quot,Rem);
if (Rem==0)
return true;
}
pp = pp->GetPointer();
}
return false;
}
Primes::Primes(char *Number)
{
HugeInt n;
HugeInt *i = new HugeInt();
HugeInt Test;
Test = 5147;
n.SetValue(Number);
*i = 2;
_Primes.Put(i);
i = new HugeInt();
*i = 3;
HugeInt Add;
Add = 2;
while(*i < n)
{
if (!Div(*i))
{
HugeInt *ii = new HugeInt(*i);
_Primes.PutTail(ii);
}
i->Inc(2);
}
}
//==========================================================
HugeInt Power(HugeInt x,HugeInt n)
{
HugeInt r(1);
HugeInt y(x);
while(n > 1)
{
if (n.IsOdd())
r.Mult(y);
n.Shr1();
y.Mult(x);
x = y;
}
r.Mult(y);
return r;
}
// Return (x*y)%z
HugeInt MulMod(HugeInt x,HugeInt y,HugeInt z)
{
HugeInt d1,d2;
x.Mult(y);
x.Div(z,d1,d2);
return d2;
}
// a^b % m
HugeInt ModExp(HugeInt a ,HugeInt b,HugeInt m)
{
HugeInt n = 1;
HugeInt d1,d2;//dummy
while(!b.IsZero())
{
if (b.IsOdd())
{
n.Mult(a);
n.Div(m,d1,d2);
n = d2;
}
b.Shr1();
{
a.Mult(a);
a.Div(m,d1,d2);
a = d2;
}
}
return n;
}
bool TestForPrime(HugeInt n,HugeInt Base)
{
HugeInt t = n;
t.Dec();
if (t.IsZero())
return false;
HugeInt nMinus1 = t;
unsigned int a = 0;
//Find t and a satisfying: n-1=2^a * t, t odd
while( t.IsEven())
{
t.Shr1();
a++;
}
// We check the congruence class of b^((2^i)t) % n for each i
// from 0 to a - 1. If any one is correct, then n passes.
// Otherwise, n fails.
HugeInt test = ModExp(Base, t, n);
if( test.IsOne() || test == nMinus1 )
return true;
HugeInt d1,d2;
while( --a )
{
test.Mult(test);
test.Div(n,d1,d2);
test = d2;
if( test == nMinus1 )
return true;
}
return false;
}
/*
Thoughts, if we find a prime contained within the target that will reduce the possibilities
to 2 at that point. We can also test various bases (since we are dealing with digits and not
the whole number).
function IsPrime(ByRef pLngNumber)
Dim lLngSquare
Dim lLngIndex
IsPrime = False
if pLngNumber < 2 Then Exit function
if pLngNumber Mod 2 = 0 Then Exit function
lLngSquare = Sqr(pLngNumber)
For lLngIndex = 3 To lLngSquare Step 2
if pLngNumber Mod lLngIndex = 0 Then Exit function
Next
IsPrime = True
End function
Finding square roots of of numbers that aren't perfect squares without a calculator
1. Estimate - first, get as close as you can by finding two perfect square roots your number is between.
2. Divide - divide your number by one of those square roots.
3. Average - take the average of the result of step 2 and the root.
4. Use the result of step 3 to repeat steps 2 and 3 until you have a number that is accurate enough for you.
*/
| [
"cwbruner@f8ea3247-a519-0410-8bc2-439d413616df"
]
| [
[
[
1,
1233
]
]
]
|
28e881984d370f548dc1b83567e67a3f4c3a5905 | 1c80a726376d6134744d82eec3129456b0ab0cbf | /Project/C++/POJ/1204/1204.cpp | 959b6649cd87978d05d7f79187279892d7b1481c | []
| no_license | dabaopku/project_pku | 338a8971586b6c4cdc52bf82cdd301d398ad909f | b97f3f15cdc3f85a9407e6bf35587116b5129334 | refs/heads/master | 2021-01-19T11:35:53.500533 | 2010-09-01T03:42:40 | 2010-09-01T03:42:40 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,060 | cpp | #include"stdio.h"
#include "iostream"
using namespace std;
#define nodenum 1000005
struct TreeNode
{
int id;
TreeNode *next[26];
};
TreeNode *s,*t,root1,treepoint[nodenum];
int pos,n,m,w,sx,sy,foundnum;
char box[1002][1002];
char word[1002];
int dp[1002][3];//状态0是行,1是列,2是方向
int dx[8]={-1,-1,0,1,1,1,0,-1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
void creat(TreeNode & head)
{
int i;
for(i=0;i<26;i++)
head.next[i]=NULL;
head.id=-1;
pos=0;
}
void insert1(TreeNode &head,char *word,int id)
{
s=&head;
int i,j,k,len=strlen(word);
for(i=0;i<len;i++)
{
if(s->next[word[i]-'A']==NULL)
break;
s=s->next[word[i]-'A'];
}
if(i==len)
{
s->id=id;
return ;
}
for(j=i;j<len;j++)
{
t=&treepoint[pos++];
for(k=0;k<26;k++)
{
t->next[k]=NULL;
}
t->id=-1;
s->next[word[j]-'A']=t;
s=t;
}
s->id=id;
}
bool isinbox(int x,int y)
{
if( x>=1 && x<=n && y>=1 && y<=m ) return 1;
return 0;
}
void search1(TreeNode *root11,int x,int y,int k) //搜索单词
{
if(root11==NULL) return ;
if(root11->id>-1)
{
dp[root11->id][0]=sx;
dp[root11->id][1]=sy;
dp[root11->id][2]=k;
root11->id=-1;
foundnum++;
}
if(isinbox(x,y))
{
search1(root11->next[box[x][y]-'A'],x+dx[k],y+dy[k],k);
}
}
int main()
{
int i,j,k;
while(scanf("%d%d%d",&n,&m,&w)!=EOF)
{
for(i=1;i<=n;i++)
scanf("%s",box[i]+1);
creat(root1);
for(i=1;i<=w;i++)
{
scanf("%s",&word);
insert1(root1,word,i);
}
foundnum=0;
for(i=1;i<=n;i++){
for(j=1;j<=m;j++){
for(k=0;k<8;k++){
sx=i;
sy=j;
search1(&root1,i,j,k);//从 i,j开始沿k是方向
if(foundnum==w)goto exitpoint;
}
}
}
exitpoint:
for(i=1;i<=w;i++)
printf("%d %d %c\n",dp[i][0]-1,dp[i][1]-1,dp[i][2]+'A');
}
return 0;
}
| [
"[email protected]@592586dc-1302-11df-8689-7786f20063ad"
]
| [
[
[
1,
109
]
]
]
|
3ecfd01092f74e7d2f4beafe9586a9b358e24587 | 27d5670a7739a866c3ad97a71c0fc9334f6875f2 | /CPP/Targets/MapLib/Shared/include/ParamsNotice.h | 75d059a15a5f313363ce39866cd76e53220cff2e | [
"BSD-3-Clause"
]
| permissive | ravustaja/Wayfinder-S60-Navigator | ef506c418b8c2e6498ece6dcae67e583fb8a4a95 | 14d1b729b2cea52f726874687e78f17492949585 | refs/heads/master | 2021-01-16T20:53:37.630909 | 2010-06-28T09:51:10 | 2010-06-28T09:51:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,034 | h | /*
Copyright (c) 1999 - 2010, Vodafone Group Services Ltd
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the Vodafone Group Services Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef PARAMSNOTICE_H
#define PARAMSNOTICE_H
#include "SharedBuffer.h"
#include "TileMapParams.h"
// ----------------------- ParamsNotice -------------------------
/**
* A notice describing a collection of TileMapParams.
*/
struct ParamsNotice {
/**
* Construct the ParamNotice with bogus members.
*/
ParamsNotice() : m_startLatIdx( MAX_INT32 ),
m_endLatIdx( MAX_INT32 ),
m_startLonIdx( MAX_INT32 ),
m_endLonIdx( MAX_INT32 ),
m_detailLevel( MAX_INT32 ),
m_nbrImportances( MAX_INT32 ),
m_layerID( MAX_INT32 ) {}
/**
* @return If the two notices are equal.
*/
bool operator == ( const ParamsNotice& other ) const {
return m_startLatIdx == other.m_startLatIdx &&
m_endLatIdx == other.m_endLatIdx &&
m_startLonIdx == other.m_startLonIdx &&
m_endLonIdx == other.m_endLonIdx &&
m_detailLevel == other.m_detailLevel &&
m_nbrImportances == other.m_nbrImportances &&
m_layerID == other.m_layerID;
}
/**
* @return If the two notices are not equal.
*/
bool operator != ( const ParamsNotice& other ) const {
return ! (*this == other);
}
/**
* @return True if the param is inside the ParamsNotice.
*/
bool inside( const TileMapParams& param ) const {
return m_detailLevel == (int)param.getDetailLevel() &&
m_layerID == (uint32) param.getLayer() &&
m_startLatIdx <= param.getTileIndexLat() &&
m_endLatIdx >= param.getTileIndexLat() &&
m_startLonIdx <= param.getTileIndexLon() &&
m_endLonIdx >= param.getTileIndexLon();
// XXX importance ignored.
}
/**
* Load from buffer.
*/
void load( SharedBuffer& buf ) {
m_layerID = buf.readNextBALong();
m_detailLevel = (int) buf.readNextBALong();
m_nbrImportances = (int) buf.readNextBALong();
m_startLatIdx = (int) buf.readNextBALong();
m_endLatIdx = (int) buf.readNextBALong();
m_startLonIdx = (int) buf.readNextBALong();
m_endLonIdx = (int) buf.readNextBALong();
}
/**
* Save to buffer.
*/
void save( SharedBuffer& buf ) const {
buf.writeNextBALong( m_layerID );
buf.writeNextBALong( m_detailLevel );
buf.writeNextBALong( m_nbrImportances );
buf.writeNextBALong( m_startLatIdx );
buf.writeNextBALong( m_endLatIdx );
buf.writeNextBALong( m_startLonIdx );
buf.writeNextBALong( m_endLonIdx );
}
void dump( ostream& str ) const {
str << "ParamsNotice: m_layerID = " << m_layerID
<< ", m_detailLevel = " << m_detailLevel
<< ", m_startLatIdx = " << m_startLatIdx
<< ", m_endLatIdx = " << m_endLatIdx
<< ", m_startLonIdx = " << m_startLonIdx
<< ", m_endLonIdx = " << m_endLonIdx << std::endl;
}
/// Start lat index.
int m_startLatIdx;
/// End lat index.
int m_endLatIdx;
/// Start lon index.
int m_startLonIdx;
/// End lon index.
int m_endLonIdx;
/// The detail level.
int m_detailLevel;
/// Number importances.
int m_nbrImportances;
/// The layer id.
uint32 m_layerID;
};
#endif
| [
"[email protected]"
]
| [
[
[
1,
130
]
]
]
|
0759d5330ee04178200fa047e2c8f22e32a0af42 | cc946ca4fb4831693af2c6f252100b9a83cfc7d0 | /uCash.Tech.Lib/uCash.Tech.Candle.cpp | fb635e54ececb973fc6309ead12e6d4e3e6c3116 | []
| no_license | primespace/ucash-cybos | 18b8b324689516e08cf6d0124d8ad19c0f316d68 | 1ccece53844fad0ef8f3abc8bbb51dadafc75ab7 | refs/heads/master | 2021-01-10T04:42:53.966915 | 2011-10-14T07:15:33 | 2011-10-14T07:15:33 | 52,243,596 | 7 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,320 | cpp | /*
* uCash.Cybos Copyright (c) 2011 Taeyoung Park ([email protected])
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "stdafx.h"
#include <cassert>
#include "uCash.Tech.Candle.h"
namespace uCash { namespace Tech {
}} // namespace uCash::Tech | [
"[email protected]"
]
| [
[
[
1,
32
]
]
]
|
bccd3a01dd19b8e47fea16f72dbf32c7f5fb1240 | 3f37de877cbd9a426e0b1dd26a290553bcaab109 | /sources/jeu.hpp | 81ac5fc91f2959342b36893c92dd575c9e716e5b | []
| no_license | Birdimol/GreenPlague | f698ba87a7325fd015da619146cb93057e94fe44 | 1675ec597247be9f09e30a3ceac01a7d7ec1af43 | refs/heads/master | 2016-09-09T18:57:25.414142 | 2011-10-19T06:08:15 | 2011-10-19T06:08:15 | 2,480,187 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 563 | hpp | #ifndef DEF_JEU
#define DEF_JEU
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
#include <iostream>
#include <SFML/Graphics.hpp>
#include <vector>
using namespace std;
class Jeu
{
public:
Jeu(sf::RenderWindow* App);
int lancer();
private:
sf::Image im_interface;
sf::Image im_interface_zombie;
sf::Image im_interface_zombies;
sf::Image im_icone_go;
sf::Image im_icone_look;
sf::Image im_icone_go_selected;
sf::Image im_icone_look_selected;
sf::RenderWindow* App;
};
#endif
| [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
19
],
[
27,
31
]
],
[
[
20,
26
]
]
]
|
71d6923b67a8405d7d3cbfc31b5209d85f61acb2 | 61a1444517cf2b76d273ff90243f8a8d7e627e6a | /util/stabi/interface/queue.h | 7543ba90d1a5f0237ed1cd93241c9bdcdd2cb687 | []
| no_license | DayBreakZhang/stabi | eeea80792a3d2501732d19d5a7c8593e497f43a4 | 0d50868bf384a25840a31af87bebb3989d3b350c | refs/heads/master | 2020-05-20T07:29:06.875021 | 2010-06-22T09:40:45 | 2010-06-22T09:40:45 | 33,292,141 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,601 | h | // Copyright (c) 2010 Yu-Li Lin
//
// 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 __UTIL_STABI_INTERFACE_QUEUE_H
#define __UTIL_STABI_INTERFACE_QUEUE_H
#include "util/stabi/interface/restrictedCollection.h"
namespace util
{
namespace stabi
{
namespace interface
{
template<
typename _DataType
>
class Queue :
public RestrictedCollection
{
public:
typedef _DataType DataType;
};
} // namespace interface
} // namespace stabi
} // namespace util
#endif // __UTIL_STABI_INTERFACE_QUEUE_H
| [
"yuli.lin@c77a587f-fc48-8b61-66aa-f312bb63b7e1"
]
| [
[
[
1,
47
]
]
]
|
36e6bae17b3486bf5bd60babc339ba4998b495ad | 4d48aca5cb1f3605befb9caba48890fcb034f87d | /win_calc_mfc/win_calc_mfc/stdafx.cpp | a5743dfc94cb58fb389b29ded0b41d1f471a5a27 | []
| no_license | Wiles/win_calc | b65fc2391dc74feb95902f03a5578891e6d80117 | fc85c3934b4a0e3a2611fa3d7a78a75437597fe7 | refs/heads/master | 2020-08-12T21:52:10.011916 | 2010-11-02T16:20:31 | 2010-11-02T16:20:31 | 214,848,627 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 212 | cpp | // stdafx.cpp : source file that includes just the standard includes
// win_calc_mfc.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
| [
"[email protected]"
]
| [
[
[
1,
7
]
]
]
|
2d65a654534774f5f602174fc09fdd3e20d08aae | d19003930543ea6f162a308eec675718d4fecd4f | /ShootingGameAlgorithmLibrary/Pos.h | 7c9b76b521ec16868407e2f90cc17c415529e5e2 | []
| no_license | yudixiaok/shooting-game-algorithm-library | 3414668b470fb3aa62bd5eefde2a7e91d26446ea | c114a2e365516f43e1b49df2363dbcf0119cc7bb | refs/heads/master | 2020-04-04T00:36:39.699887 | 2011-07-18T07:08:07 | 2011-07-18T07:08:07 | 34,234,604 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,651 | h | #pragma once
#include <cmath>
#include <cassert>
#include <algorithm>
struct Pos
{
float x, y;
Pos()
{ }
Pos (float _x, float _y)
:
x(_x),
y(_y)
{ }
Pos (const float *v)
:
x(v[0]),
y(v[1])
{ }
/************************************************************************/
inline Pos operator + ( const Pos& pos ) const
{
return Pos(
x + pos.x,
y + pos.y);
}
inline Pos operator - ( const Pos& pos ) const
{
return Pos(
x - pos.x,
y - pos.y);
}
inline Pos operator * ( const float fScalar ) const
{
return Pos(
x * fScalar,
y * fScalar);
}
inline Pos operator * ( const Pos& rhs) const
{
return Pos(
x * rhs.x,
y * rhs.y);
}
inline Pos operator / ( const float fScalar ) const
{
assert( fScalar != 0.0 );
float fInv = 1.0f / fScalar;
return Pos(
x * fInv,
y * fInv);
}
inline Pos operator / ( const Pos& rhs) const
{
return Pos(
x / rhs.x,
y / rhs.y);
}
inline const Pos& operator + () const
{
return *this;
}
inline Pos operator - () const
{
return Pos(-x, -y);
}
// overloaded operators to help Pos
inline friend Pos operator * ( const float fScalar, const Pos& pos )
{
return Pos(
fScalar * pos.x,
fScalar * pos.y);
}
inline friend Pos operator / ( const float fScalar, const Pos& pos )
{
return Pos(
fScalar / pos.x,
fScalar / pos.y);
}
inline friend Pos operator + (const Pos& lhs, const float rhs)
{
return Pos(
lhs.x + rhs,
lhs.y + rhs);
}
inline friend Pos operator + (const float lhs, const Pos& rhs)
{
return Pos(
lhs + rhs.x,
lhs + rhs.y);
}
inline friend Pos operator - (const Pos& lhs, const float rhs)
{
return Pos(
lhs.x - rhs,
lhs.y - rhs);
}
inline friend Pos operator - (const float lhs, const Pos& rhs)
{
return Pos(
lhs - rhs.x,
lhs - rhs.y);
}
// arithmetic updates
inline Pos& operator += ( const Pos& pos )
{
x += pos.x;
y += pos.y;
return *this;
}
inline Pos& operator += ( const float fScaler )
{
x += fScaler;
y += fScaler;
return *this;
}
inline Pos& operator -= ( const Pos& pos )
{
x -= pos.x;
y -= pos.y;
return *this;
}
inline Pos& operator -= ( const float fScaler )
{
x -= fScaler;
y -= fScaler;
return *this;
}
inline Pos& operator *= ( const float fScalar )
{
x *= fScalar;
y *= fScalar;
return *this;
}
inline Pos& operator *= ( const Pos& pos )
{
x *= pos.x;
y *= pos.y;
return *this;
}
inline Pos& operator /= ( const float fScalar )
{
assert( fScalar != 0.0 );
float fInv = 1.0f / fScalar;
x *= fInv;
y *= fInv;
return *this;
}
inline Pos& operator /= ( const Pos& pos )
{
x /= pos.x;
y /= pos.y;
return *this;
}
/************************************************************************/
Pos &operator=(const Pos &pos)
{
x = pos.x;
y = pos.y;
return *this;
};
bool operator==(const Pos &pos) const
{
return (pos.x == x) && (pos.y == y);
};
bool operator!=(const Pos &pos) const
{
return (pos.x != x) || (pos.y != y);
};
/************************************************************************/
Pos Max(const Pos& pos) const
{
return Pos(max(x, pos.x), max(y, pos.y));
}
Pos Min(const Pos& pos) const
{
return Pos(min(x, pos.x), min(y, pos.y));
}
float length() const
{
return sqrt((float) (x * x + y * y));
};
float squaredLength() const
{
return x * x + y * y;
};
float distance(const Pos &pos) const
{
return (*this - pos).length();
}
Pos &inverse()
{
x = -x;
y = -y;
return *this;
}
float normalise()
{
float fLength = length();
if (fLength > 1e-08)
{
float fInvLength = 1.0f / fLength;
x *= fInvLength;
y *= fInvLength;
}
return fLength;
}
Pos midPoint(const Pos &vec) const
{
return Pos((x + vec.x) * 0.5f, (y + vec.y) * 0.5f);
}
float dotProduct(const Pos &vec) const
{
return x * vec.x + y * vec.y;
}
float crossProduct(const Pos &pos) const
{
return x * pos.y - y * pos.x;
}
Pos reflect(const Pos &normal) const
{
return Pos(*this - (2 * this->dotProduct(normal) * normal));
}
/** Function for writing to a stream.
*/
inline friend std::ostream & operator <<(std::ostream & o, const Pos & v)
{
o << "Pos(" << v.x << ", " << v.y << ")";
return o;
}
inline void swap(Pos &other)
{
std::swap(x, other.x);
std::swap(y, other.y);
}
};
| [
"t1238142000@bec1ec1d-4e10-fd0a-0ccf-f7fb723f4b98"
]
| [
[
[
1,
278
]
]
]
|
661cd213c66393a95d9d995bc38459ecd1eb5ae2 | ce262ae496ab3eeebfcbb337da86d34eb689c07b | /SEFoundation/SEContainment/SEContSphere3.cpp | 92a2a86ae43ba20c9216da05766425fc5ec0ef74 | []
| no_license | pizibing/swingengine | d8d9208c00ec2944817e1aab51287a3c38103bea | e7109d7b3e28c4421c173712eaf872771550669e | refs/heads/master | 2021-01-16T18:29:10.689858 | 2011-06-23T04:27:46 | 2011-06-23T04:27:46 | 33,969,301 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 23,446 | cpp | // Swing Engine Version 1 Source Code
// Most of techniques in the engine are mainly based on David Eberly's
// Wild Magic 4 open-source code.The author of Swing Engine learned a lot
// from Eberly's experience of architecture and algorithm.
// Several sub-systems are totally new,and others are re-implimented or
// re-organized based on Wild Magic 4's sub-systems.
// Copyright (c) 2007-2010. All Rights Reserved
//
// Eberly's permission:
// Geometric Tools, Inc.
// http://www.geometrictools.com
// Copyright (c) 1998-2006. All Rights Reserved
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or (at
// your option) any later version. The license is available for reading at
// the location:
// http://www.gnu.org/copyleft/lgpl.html
#include "SEFoundationPCH.h"
#include "SEContSphere3.h"
using namespace Swing;
//----------------------------------------------------------------------------
SESphere3f Swing::ContSphereOfAABBf(int iCount, const SEVector3f* aPoint)
{
SEVector3f vec3fMinPoint, vec3fMaxPoint;
SEVector3f::ComputeExtremes(iCount, aPoint, vec3fMinPoint, vec3fMaxPoint);
SESphere3f tempSphere;
tempSphere.Center = 0.5f * (vec3fMaxPoint + vec3fMinPoint);
SEVector3f vec3fHalfDiagonal = 0.5f * (vec3fMaxPoint - vec3fMinPoint);
tempSphere.Radius = vec3fHalfDiagonal.GetLength();
return tempSphere;
}
//----------------------------------------------------------------------------
SESphere3f Swing::ContSphereAveragef(int iCount, const SEVector3f* aPoint)
{
SESphere3f tempSphere;
tempSphere.Center = aPoint[0];
tempSphere.Radius = 0.0f;
int i;
for( i = 1; i < iCount; i++ )
{
tempSphere.Center += aPoint[i];
}
tempSphere.Center /= (float)iCount;
for( i = 0; i < iCount; i++ )
{
SEVector3f vec3fDiff = aPoint[i] - tempSphere.Center;
float fRadiusSqr = vec3fDiff.GetSquaredLength();
if( fRadiusSqr > tempSphere.Radius )
{
tempSphere.Radius = fRadiusSqr;
}
}
tempSphere.Radius = SEMath<float>::Sqrt(tempSphere.Radius);
return tempSphere;
}
//----------------------------------------------------------------------------
bool Swing::IsInSpheref(const SEVector3f& rPoint, const SESphere3f& rSphere)
{
SEVector3f vec3fDiff = rPoint - rSphere.Center;
return vec3fDiff.GetSquaredLength() <= rSphere.Radius * rSphere.Radius;
}
//----------------------------------------------------------------------------
SESphere3f Swing::MergeSpheresf(const SESphere3f& rSphere0,
const SESphere3f& rSphere1)
{
SEVector3f vec3fCenterDiff = rSphere1.Center - rSphere0.Center;
float fLSqr = vec3fCenterDiff.GetSquaredLength();
float fRadiusDiff = rSphere1.Radius - rSphere0.Radius;
float fRadiusDiffSqr = fRadiusDiff * fRadiusDiff;
if( fRadiusDiffSqr >= fLSqr )
{
return ( fRadiusDiff >= 0.0f ? rSphere1 : rSphere0 );
}
float fLength = SEMath<float>::Sqrt(fLSqr);
SESphere3f tempSphere;
if( fLength > SEMath<float>::ZERO_TOLERANCE )
{
float fCoeff = (fLength + fRadiusDiff) / (2.0f * fLength);
tempSphere.Center = rSphere0.Center + fCoeff*vec3fCenterDiff;
}
else
{
tempSphere.Center = rSphere0.Center;
}
tempSphere.Radius = 0.5f * (fLength + rSphere0.Radius + rSphere1.Radius);
return tempSphere;
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// SEMinSphere3f
//
// 所有最小球的内部计算函数都在SESphere3f对象中暂存平方半径,只有最后输出时才
// 开方.
//----------------------------------------------------------------------------
SEMinSphere3f::SEMinSphere3f(int iCount, const SEVector3f* aPoint,
SESphere3f& rMinimal, float fEpsilon)
{
m_fEpsilon = fEpsilon;
m_aoUpdate[0] = 0;
m_aoUpdate[1] = &SEMinSphere3f::UpdateSupport1;
m_aoUpdate[2] = &SEMinSphere3f::UpdateSupport2;
m_aoUpdate[3] = &SEMinSphere3f::UpdateSupport3;
m_aoUpdate[4] = &SEMinSphere3f::UpdateSupport4;
SESupport tempSupp;
float fDistDiff;
if( iCount >= 1 )
{
// 创建等同于输入顶点的新顶点集指针数组.
SEVector3f** apPermute = new SEVector3f*[iCount];
int i;
for( i = 0; i < iCount; i++ )
{
apPermute[i] = (SEVector3f*)&aPoint[i];
}
// 随机重新排列顶点顺序.
for( i = iCount - 1; i > 0; i-- )
{
int j = rand() % (i + 1);
if( j != i )
{
SEVector3f* pTemp = apPermute[i];
apPermute[i] = apPermute[j];
apPermute[j] = pTemp;
}
}
rMinimal = ExactSphere1(*apPermute[0]);
tempSupp.Count = 1;
tempSupp.Index[0] = 0;
i = 1;
while( i < iCount )
{
if( !tempSupp.Contains(i, apPermute, m_fEpsilon) )
{
// 如果当前support集合不包含当前顶点i.
if( !Contains(*apPermute[i], rMinimal, fDistDiff) )
{
// 如果当前最小球不包含当前顶点i.
UpdateFunction oUpdate = m_aoUpdate[tempSupp.Count];
// 计算新的当前最小球,
// 使其能够同时包含当前support集合和当前顶点i.
SESphere3f tempSphere =(this->*oUpdate)(i, apPermute,
tempSupp);
if( tempSphere.Radius > rMinimal.Radius )
{
rMinimal = tempSphere;
i = 0;
continue;
}
}
}
i++;
}
delete[] apPermute;
}
else
{
SE_ASSERT( false );
}
rMinimal.Radius = SEMath<float>::Sqrt(rMinimal.Radius);
}
//----------------------------------------------------------------------------
bool SEMinSphere3f::Contains(const SEVector3f& rPoint, const SESphere3f&
rSphere, float& rfDistDiff)
{
SEVector3f vec3fDiff = rPoint - rSphere.Center;
float fTest = vec3fDiff.GetSquaredLength();
// 这里的sphere半径是平方半径.
rfDistDiff = fTest - rSphere.Radius;
return rfDistDiff <= 0.0f;
}
//----------------------------------------------------------------------------
SESphere3f SEMinSphere3f::ExactSphere1(const SEVector3f& rPoint)
{
SESphere3f tempMinimal;
tempMinimal.Center = rPoint;
tempMinimal.Radius = 0.0f;
return tempMinimal;
}
//----------------------------------------------------------------------------
SESphere3f SEMinSphere3f::ExactSphere2(const SEVector3f& rPoint0,
const SEVector3f& rPoint1)
{
SESphere3f tempMinimal;
tempMinimal.Center = 0.5f * (rPoint0 + rPoint1);
SEVector3f vec3fDiff = rPoint1 - rPoint0;
tempMinimal.Radius = 0.25f * vec3fDiff.GetSquaredLength();
return tempMinimal;
}
//----------------------------------------------------------------------------
SESphere3f SEMinSphere3f::ExactSphere3(const SEVector3f& rPoint0,
const SEVector3f& rPoint1, const SEVector3f& rPoint2)
{
// 计算经过三个顶点p0,p1,p2的球,球心C是三个顶点的重心,
// 且K = u0*p0 + u1*p1 + u2*p2,其中u0 + u1 + u2 = 1,
// 且|K - p0| = |K - p1| = |K - p2| = 半径r
// 由此得到:
// K - p0 = (u0*A + u1*B) - A
// K - p1 = (u0*A + u1*B) - B
// K - p2 = (u0*A + u1*B)
// 其中 A = p0 - p2, B = p1 - p2,
// 由此得到:
// r^2 = |u0*A + u1*B|^2 - 2*Dot(A, u0*A + u1*B) + |A|^2
// r^2 = |u0*A + u1*B|^2 - 2*Dot(B, u0*A + u1*B) + |B|^2
// r^2 = |u0*A + u1*B|^2
// 把前两式减去最后式,得到线性方程组:
// +- -++ -+ +- -+
// | Dot(A,A) Dot(A,B) || u0 | = 0.5 | Dot(A,A) |
// | Dot(B,A) Dot(B,B) || u1 | | Dot(B,B) |
// +- -++ -+ +- -+
//
// 以下代码解该线性方程组,得到u0,u1,然后得到r,
// 注意线性方程组无解的情况.
SEVector3f vec3fA = rPoint0 - rPoint2;
SEVector3f vec3fB = rPoint1 - rPoint2;
float fAdA = vec3fA.Dot(vec3fA);
float fAdB = vec3fA.Dot(vec3fB);
float fBdB = vec3fB.Dot(vec3fB);
float fDet = fAdA*fBdB - fAdB*fAdB;
SESphere3f tempMinimal;
if( SEMath<float>::FAbs(fDet) > m_fEpsilon )
{
float fHalfInvDet = 0.5f / fDet;
float fU0 = fHalfInvDet * fBdB * (fAdA - fAdB);
float fU1 = fHalfInvDet * fAdA * (fBdB - fAdB);
float fU2 = 1.0f - fU0 - fU1;
tempMinimal.Center = fU0*rPoint0 + fU1*rPoint1 + fU2*rPoint2;
SEVector3f vec3fTemp = fU0*vec3fA + fU1*vec3fB;
tempMinimal.Radius = vec3fTemp.GetSquaredLength();
}
else
{
tempMinimal.Center = SEVector3f::ZERO;
tempMinimal.Radius = SEMath<float>::MAX_REAL;
}
return tempMinimal;
}
//----------------------------------------------------------------------------
SESphere3f SEMinSphere3f::ExactSphere4(const SEVector3f& rPoint0,
const SEVector3f& rPoint1, const SEVector3f& rPoint2, const SEVector3f&
rPoint3)
{
// 计算经过四个顶点p0,p1,p2,p3的球,球心C是四个顶点的重心,
// 且K = u0*p0 + u1*p1 + u2*p2 + u3*p3,其中u0 + u1 + u2 + u3 = 1,
// 且|K - p0| = |K - p1| = |K - p2| = |K - p3| = 半径r
// 由此得到:
// K - p0 = u0*A + u1*B + u2*C - A
// K - p1 = u0*A + u1*B + u2*C - B
// K - p2 = u0*A + u1*B + u2*C - C
// K - p3 = u0*A + u1*B + u2*C
// 其中 A = p0 - p3, B = p1 - p3, C = p2 - p3
// 由此得到:
// r^2 = |u0*A + u1*B+u2*C|^2 - 2*Dot(A, u0*A + u1*B+u2*C) + |A|^2
// r^2 = |u0*A + u1*B+u2*C|^2 - 2*Dot(B, u0*A + u1*B+u2*C) + |B|^2
// r^2 = |u0*A + u1*B+u2*C|^2 - 2*Dot(C, u0*A + u1*B+u2*C) + |C|^2
// r^2 = |u0*A + u1*B+u2*C|^2
// 把前三式减去最后式,得到线性方程组
//
// +- -++ -+ +- -+
// | Dot(A,A) Dot(A,B) Dot(A,C) || u0 | = 0.5 | Dot(A,A) |
// | Dot(B,A) Dot(B,B) Dot(B,C) || u1 | | Dot(B,B) |
// | Dot(C,A) Dot(C,B) Dot(C,C) || u2 | | Dot(C,C) |
// +- -++ -+ +- -+
//
// 以下代码解该线性方程组,得到u0,u1,u2然后得到r,
// 注意线性方程组无解的情况.
SEVector3f vec3fE10 = rPoint0 - rPoint3;
SEVector3f vec3fE20 = rPoint1 - rPoint3;
SEVector3f vec3fE30 = rPoint2 - rPoint3;
float aafA[3][3];
aafA[0][0] = vec3fE10.Dot(vec3fE10);
aafA[0][1] = vec3fE10.Dot(vec3fE20);
aafA[0][2] = vec3fE10.Dot(vec3fE30);
aafA[1][0] = aafA[0][1];
aafA[1][1] = vec3fE20.Dot(vec3fE20);
aafA[1][2] = vec3fE20.Dot(vec3fE30);
aafA[2][0] = aafA[0][2];
aafA[2][1] = aafA[1][2];
aafA[2][2] = vec3fE30.Dot(vec3fE30);
float afB[3];
afB[0] = 0.5f * aafA[0][0];
afB[1] = 0.5f * aafA[1][1];
afB[2] = 0.5f * aafA[2][2];
float aafAInv[3][3];
aafAInv[0][0] = aafA[1][1]*aafA[2][2] - aafA[1][2]*aafA[2][1];
aafAInv[0][1] = aafA[0][2]*aafA[2][1] - aafA[0][1]*aafA[2][2];
aafAInv[0][2] = aafA[0][1]*aafA[1][2] - aafA[0][2]*aafA[1][1];
aafAInv[1][0] = aafA[1][2]*aafA[2][0] - aafA[1][0]*aafA[2][2];
aafAInv[1][1] = aafA[0][0]*aafA[2][2] - aafA[0][2]*aafA[2][0];
aafAInv[1][2] = aafA[0][2]*aafA[1][0] - aafA[0][0]*aafA[1][2];
aafAInv[2][0] = aafA[1][0]*aafA[2][1] - aafA[1][1]*aafA[2][0];
aafAInv[2][1] = aafA[0][1]*aafA[2][0] - aafA[0][0]*aafA[2][1];
aafAInv[2][2] = aafA[0][0]*aafA[1][1] - aafA[0][1]*aafA[1][0];
float fDet = aafA[0][0]*aafAInv[0][0] + aafA[0][1]*aafAInv[1][0] +
aafA[0][2]*aafAInv[2][0];
SESphere3f tempMinimal;
if( SEMath<float>::FAbs(fDet) > m_fEpsilon )
{
float fInvDet = 1.0f / fDet;
int iRow, iCol;
for( iRow = 0; iRow < 3; iRow++ )
{
for( iCol = 0; iCol < 3; iCol++ )
{
aafAInv[iRow][iCol] *= fInvDet;
}
}
float afU[4];
for( iRow = 0; iRow < 3; iRow++ )
{
afU[iRow] = 0.0f;
for( iCol = 0; iCol < 3; iCol++ )
{
afU[iRow] += aafAInv[iRow][iCol] * afB[iCol];
}
}
afU[3] = 1.0f - afU[0] - afU[1] - afU[2];
tempMinimal.Center = afU[0]*rPoint0 + afU[1]*rPoint1 + afU[2]*rPoint2 +
afU[3]*rPoint3;
SEVector3f vec3fTemp = afU[0]*vec3fE10 + afU[1]*vec3fE20 +
afU[2]*vec3fE30;
tempMinimal.Radius = vec3fTemp.GetSquaredLength();
}
else
{
tempMinimal.Center = SEVector3f::ZERO;
tempMinimal.Radius = SEMath<float>::MAX_REAL;
}
return tempMinimal;
}
//----------------------------------------------------------------------------
SESphere3f SEMinSphere3f::UpdateSupport1(int i, SEVector3f** apPermute,
SESupport& rSupport)
{
const SEVector3f& rPoint0 = *apPermute[rSupport.Index[0]];
const SEVector3f& rPoint1 = *apPermute[i];
SESphere3f tempMinimal = ExactSphere2(rPoint0, rPoint1);
rSupport.Count = 2;
rSupport.Index[1] = i;
return tempMinimal;
}
//----------------------------------------------------------------------------
SESphere3f SEMinSphere3f::UpdateSupport2(int i, SEVector3f** apPermute,
SESupport& rSupport)
{
const SEVector3f& rPoint0 = *apPermute[rSupport.Index[0]];
const SEVector3f& rPoint1 = *apPermute[rSupport.Index[1]];
const SEVector3f& rPoint2 = *apPermute[i];
SESphere3f tempSpheres[3];
float fMinRSqr = SEMath<float>::MAX_REAL;
float fDistDiff;
int iIndex = -1;
tempSpheres[0] = ExactSphere2(rPoint0, rPoint2);
if( Contains(rPoint1, tempSpheres[0], fDistDiff) )
{
fMinRSqr = tempSpheres[0].Radius;
iIndex = 0;
}
tempSpheres[1] = ExactSphere2(rPoint1, rPoint2);
if( tempSpheres[1].Radius < fMinRSqr )
{
if( Contains(rPoint0, tempSpheres[1], fDistDiff) )
{
fMinRSqr = tempSpheres[1].Radius;
iIndex = 1;
}
}
SESphere3f tempMinimal;
if( iIndex != -1 )
{
tempMinimal = tempSpheres[iIndex];
rSupport.Index[1 - iIndex] = i;
}
else
{
tempMinimal = ExactSphere3(rPoint0, rPoint1, rPoint2);
SE_ASSERT( tempMinimal.Radius <= fMinRSqr );
rSupport.Count = 3;
rSupport.Index[2] = i;
}
return tempMinimal;
}
//----------------------------------------------------------------------------
SESphere3f SEMinSphere3f::UpdateSupport3(int i, SEVector3f** apPermute,
SESupport& rSupport)
{
const SEVector3f& rPoint0 = *apPermute[rSupport.Index[0]];
const SEVector3f& rPoint1 = *apPermute[rSupport.Index[1]];
const SEVector3f& rPoint2 = *apPermute[rSupport.Index[2]];
const SEVector3f& rPoint3 = *apPermute[i];
SESphere3f tempSpheres[6];
float fMinRSqr = SEMath<float>::MAX_REAL;
float fDistDiff;
int iIndex = -1;
tempSpheres[0] = ExactSphere2(rPoint0, rPoint3);
if( Contains(rPoint1, tempSpheres[0], fDistDiff) &&
Contains(rPoint2, tempSpheres[0], fDistDiff) )
{
fMinRSqr = tempSpheres[0].Radius;
iIndex = 0;
}
tempSpheres[1] = ExactSphere2(rPoint1, rPoint3);
if( tempSpheres[1].Radius < fMinRSqr &&
Contains(rPoint0, tempSpheres[1], fDistDiff) &&
Contains(rPoint2, tempSpheres[1], fDistDiff) )
{
fMinRSqr = tempSpheres[1].Radius;
iIndex = 1;
}
tempSpheres[2] = ExactSphere2(rPoint2, rPoint3);
if( tempSpheres[2].Radius < fMinRSqr &&
Contains(rPoint0, tempSpheres[2], fDistDiff) &&
Contains(rPoint1, tempSpheres[2], fDistDiff) )
{
fMinRSqr = tempSpheres[2].Radius;
iIndex = 2;
}
tempSpheres[3] = ExactSphere3(rPoint0, rPoint1, rPoint3);
if( tempSpheres[3].Radius < fMinRSqr &&
Contains(rPoint2, tempSpheres[3], fDistDiff) )
{
fMinRSqr = tempSpheres[3].Radius;
iIndex = 3;
}
tempSpheres[4] = ExactSphere3(rPoint0, rPoint2, rPoint3);
if( tempSpheres[4].Radius < fMinRSqr &&
Contains(rPoint1, tempSpheres[4], fDistDiff) )
{
fMinRSqr = tempSpheres[4].Radius;
iIndex = 4;
}
tempSpheres[5] = ExactSphere3(rPoint1, rPoint2, rPoint3);
if( tempSpheres[5].Radius < fMinRSqr &&
Contains(rPoint0, tempSpheres[5], fDistDiff) )
{
fMinRSqr = tempSpheres[5].Radius;
iIndex = 5;
}
SESphere3f tempMinimal;
switch( iIndex )
{
case 0:
tempMinimal = tempSpheres[0];
rSupport.Count = 2;
rSupport.Index[1] = i;
break;
case 1:
tempMinimal = tempSpheres[1];
rSupport.Count = 2;
rSupport.Index[0] = i;
break;
case 2:
tempMinimal = tempSpheres[2];
rSupport.Count = 2;
rSupport.Index[0] = rSupport.Index[2];
rSupport.Index[1] = i;
break;
case 3:
tempMinimal = tempSpheres[3];
rSupport.Index[2] = i;
break;
case 4:
tempMinimal = tempSpheres[4];
rSupport.Index[1] = i;
break;
case 5:
tempMinimal = tempSpheres[5];
rSupport.Index[0] = i;
break;
default:
tempMinimal = ExactSphere4(rPoint0, rPoint1, rPoint2, rPoint3);
SE_ASSERT( tempMinimal.Radius <= fMinRSqr );
rSupport.Count = 4;
rSupport.Index[3] = i;
break;
}
return tempMinimal;
}
//----------------------------------------------------------------------------
SESphere3f SEMinSphere3f::UpdateSupport4(int i, SEVector3f** apPermute,
SESupport& rSupport)
{
const SEVector3f* aPoint[4] =
{
apPermute[rSupport.Index[0]],
apPermute[rSupport.Index[1]],
apPermute[rSupport.Index[2]],
apPermute[rSupport.Index[3]]
};
const SEVector3f& rPoint4 = *apPermute[i];
// 排列类型1.
int aiT1[4][4] =
{
{0, /*4*/ 1,2,3},
{1, /*4*/ 0,2,3},
{2, /*4*/ 0,1,3},
{3, /*4*/ 0,1,2}
};
// 排列类型2.
int aiT2[6][4] =
{
{0,1, /*4*/ 2,3},
{0,2, /*4*/ 1,3},
{0,3, /*4*/ 1,2},
{1,2, /*4*/ 0,3},
{1,3, /*4*/ 0,2},
{2,3, /*4*/ 0,1}
};
// 排列类型3.
int aiT3[4][4] =
{
{0,1,2, /*4*/ 3},
{0,1,3, /*4*/ 2},
{0,2,3, /*4*/ 1},
{1,2,3, /*4*/ 0}
};
SESphere3f tempSpheres[14];
float fMinRSqr = SEMath<float>::MAX_REAL;
int iIndex = -1;
float fDistDiff, fMinDistDiff = SEMath<float>::MAX_REAL;
int iMinIndex = -1;
int k = 0; // 球的索引
// 排列类型1.
int j;
for( j = 0; j < 4; j++, k++ )
{
tempSpheres[k] = ExactSphere2(*aPoint[aiT1[j][0]], rPoint4);
if( tempSpheres[k].Radius < fMinRSqr )
{
if( Contains(*aPoint[aiT1[j][1]], tempSpheres[k], fDistDiff) &&
Contains(*aPoint[aiT1[j][2]], tempSpheres[k], fDistDiff) &&
Contains(*aPoint[aiT1[j][3]], tempSpheres[k], fDistDiff) )
{
fMinRSqr = tempSpheres[k].Radius;
iIndex = k;
}
else if( fDistDiff < fMinDistDiff )
{
fMinDistDiff = fDistDiff;
iMinIndex = k;
}
}
}
// 排列类型2.
for( j = 0; j < 6; j++, k++ )
{
tempSpheres[k] = ExactSphere3(*aPoint[aiT2[j][0]], *aPoint[aiT2[j][1]],
rPoint4);
if( tempSpheres[k].Radius < fMinRSqr )
{
if( Contains(*aPoint[aiT2[j][2]], tempSpheres[k], fDistDiff) &&
Contains(*aPoint[aiT2[j][3]], tempSpheres[k], fDistDiff) )
{
fMinRSqr = tempSpheres[k].Radius;
iIndex = k;
}
else if( fDistDiff < fMinDistDiff )
{
fMinDistDiff = fDistDiff;
iMinIndex = k;
}
}
}
// 排列类型3.
for( j = 0; j < 4; j++, k++ )
{
tempSpheres[k] = ExactSphere4(*aPoint[aiT3[j][0]], *aPoint[aiT3[j][1]],
*aPoint[aiT3[j][2]], rPoint4);
if( tempSpheres[k].Radius < fMinRSqr )
{
if( Contains(*aPoint[aiT3[j][3]], tempSpheres[k], fDistDiff) )
{
fMinRSqr = tempSpheres[k].Radius;
iIndex = k;
}
else if( fDistDiff < fMinDistDiff )
{
fMinDistDiff = fDistDiff;
iMinIndex = k;
}
}
}
// 理论上来说,iIndex >= 0应该会发生,但由于浮点运算舍入问题引起误差,
// iIndex == -1也有可能发生,
// 此时选择具备最小外围顶点误差的球.
if( iIndex == -1 )
{
iIndex = iMinIndex;
}
SESphere3f tempMinimal = tempSpheres[iIndex];
switch( iIndex )
{
case 0:
rSupport.Count = 2;
rSupport.Index[1] = i;
break;
case 1:
rSupport.Count = 2;
rSupport.Index[0] = i;
break;
case 2:
rSupport.Count = 2;
rSupport.Index[0] = rSupport.Index[2];
rSupport.Index[1] = i;
break;
case 3:
rSupport.Count = 2;
rSupport.Index[0] = rSupport.Index[3];
rSupport.Index[1] = i;
break;
case 4:
rSupport.Count = 3;
rSupport.Index[2] = i;
break;
case 5:
rSupport.Count = 3;
rSupport.Index[1] = i;
break;
case 6:
rSupport.Count = 3;
rSupport.Index[1] = rSupport.Index[3];
rSupport.Index[2] = i;
break;
case 7:
rSupport.Count = 3;
rSupport.Index[0] = i;
break;
case 8:
rSupport.Count = 3;
rSupport.Index[0] = rSupport.Index[3];
rSupport.Index[2] = i;
break;
case 9:
rSupport.Count = 3;
rSupport.Index[0] = rSupport.Index[3];
rSupport.Index[1] = i;
break;
case 10:
rSupport.Index[3] = i;
break;
case 11:
rSupport.Index[2] = i;
break;
case 12:
rSupport.Index[1] = i;
break;
case 13:
rSupport.Index[0] = i;
break;
}
return tempMinimal;
}
//---------------------------------------------------------------------------- | [
"[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac"
]
| [
[
[
1,
729
]
]
]
|
7ff37a770d35c078d67471b7275dad9cd63bf303 | 1bbd5854d4a2efff9ee040e3febe3f846ed3ecef | /src/scrview/IPdatabase.cpp | 2789aa2887ac7051281c76db6c156c973738d37c | []
| no_license | amanuelg3/screenviewer | 2b896452a05cb135eb7b9eb919424fe6c1ce8dd7 | 7fc4bb61060e785aa65922551f0e3ff8423eccb6 | refs/heads/master | 2021-01-01T18:54:06.167154 | 2011-12-21T02:19:10 | 2011-12-21T02:19:10 | 37,343,569 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,313 | cpp | #include "IPdatabase.h"
#include <QDebug>
#include <QtCore>
#include <QtNetwork>
#define REGISTERIP_URL "http://scrview.albinas.lt/reg.php?user=%1&pass=%2"
#define GETIP_URL "http://scrview.albinas.lt/getip.php?user=%1&pass=%2"
/*
klase, kuri i serva http protokolu kreipiasi ir siuncia
reg.php?ip=[saityno serveris gali suzinot]&user=manokompas&pass=abc123
ir ip, user ir pass iraso i db, ir kita metoda kuris kreipiasi i
getip.php?user=manokompas&pass=abc123 ir gauna ip
*/
IPdatabase::IPdatabase() {
connect(&networkManagerGet, SIGNAL(finished(QNetworkReply *)),
this, SLOT(gotIP(QNetworkReply *)));
connect(&networkManagerSet, SIGNAL(finished(QNetworkReply *)),
this, SLOT(settedIP(QNetworkReply *)));
}
IPdatabase::IPdatabase(Client *&bb) {
b = bb;
connect(&networkManagerGet, SIGNAL(finished(QNetworkReply *)),
this, SLOT(gotIP(QNetworkReply *)));
connect(&networkManagerSet, SIGNAL(finished(QNetworkReply *)),
this, SLOT(settedIP(QNetworkReply *)));
}
void IPdatabase::getIP(QString user, QString pass) {
QString url = QString(GETIP_URL).arg(user, pass);
qDebug() << url;
networkManagerGet.get(QNetworkRequest(QString(url)));// QNetworkReply *reply =
qDebug() << "request sent to get IP request";
}
void IPdatabase::gotIP(QNetworkReply *networkReply)
{
if (!networkReply->error()) {
QString ip(networkReply->readAll());//Response from our server
qDebug() << "Got IP" << ip;
if(!ip.isEmpty()) {
b->setHost(ip);
//b->setHost("88.222.10.7"); test ip
} else {
b->setHost("127.0.0.1");
}
b->connectToHost();
this->ip = ip;
}
networkReply->deleteLater();
}
void IPdatabase::setIP(QString user, QString pass) {
QString url = QString(REGISTERIP_URL).arg(user, pass);
qDebug() << url;
networkManagerSet.get(QNetworkRequest(QString(url)));
qDebug() << "Request sent to save IP into our server database";
}
void IPdatabase::settedIP(QNetworkReply *networkReply)
{
if (!networkReply->error()) {
QString response(networkReply->readAll());
qDebug() << "Setted IP:" << response;
}
networkReply->deleteLater();
}
| [
"JuliusR@localhost",
"[email protected]"
]
| [
[
[
1,
14
],
[
22,
29
],
[
31,
37
],
[
47,
50
],
[
61,
69
]
],
[
[
15,
21
],
[
30,
30
],
[
38,
46
],
[
51,
60
]
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.