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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
43c359b0107b7f01ae4f1de33355ebf714121966 | d397b0d420dffcf45713596f5e3db269b0652dee | /src/Lib/PropertySystem/TypeVisitor.hpp | c2647a2679245405d79008ae87b58b8fadee515f | []
| no_license | irov/Axe | 62cf29def34ee529b79e6dbcf9b2f9bf3709ac4f | d3de329512a4251470cbc11264ed3868d9261d22 | refs/heads/master | 2021-01-22T20:35:54.710866 | 2010-09-15T14:36:43 | 2010-09-15T14:36:43 | 85,337,070 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 499 | hpp | # pragma once
namespace AxeProperty
{
template<class T>
class TypeNumeric;
class TypeVisitor
{
public:
virtual void process( class TypeNumeric<bool> * _type ) = 0;
virtual void process( class TypeNumeric<int> * _type ) = 0;
virtual void process( class TypeNumeric<float> * _type ) = 0;
virtual void process( class TypeNumeric<double> * _type ) = 0;
virtual void process( class TypeString * _type ) = 0;
virtual void process( class TypeArray * _type ) = 0;
};
}
| [
"yuriy_levchenko@b35ac3e7-fb55-4080-a4c2-184bb04a16e0"
]
| [
[
[
1,
18
]
]
]
|
d2c00e0860a14a05baf35c5e93ec2e7a60ee69ca | 51e1cf5dc3b99e8eecffcf5790ada07b2f03f39c | /SMC/src/collision.cpp | 17148b0a3f8939044e3ea0857b0f789b1329ffa1 | []
| no_license | jdek/jim-pspware | c3e043b59a69cf5c28daf62dc9d8dca5daf87589 | fd779e1148caac2da4c590844db7235357b47f7e | refs/heads/master | 2021-05-31T06:45:03.953631 | 2007-06-25T22:45:26 | 2007-06-25T22:45:26 | 56,973,047 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,214 | cpp | /***************************************************************************
collison.cpp - internal collision functions
-------------------
copyright : (C) 2005 FluXy
(C) 2005 Amir Taaki
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#include "include/globals.h"
bool CollideBoundingBox( SDL_Surface *a, int ax, int ay, SDL_Surface *b, int bx, int by )
{
if( bx + b->w <= ax ) return 0; // just checking if their
if( bx >= ax + a->w ) return 0; // bounding boxes even touch
if( by + b->h <= ay ) return 0;
if( by >= ay + a->h ) return 0;
return 1; //bounding boxes intersect
}
bool CollideBoundingBox( SDL_Rect *a , SDL_Rect *b )
{
if( b->x + b->w <= a->x ) return 0; //just checking if their
if( b->x >= a->x + a->w ) return 0; //bounding boxes even touch
if( b->y + b->h <= a->y ) return 0;
if( b->y >= a->y + a->h ) return 0;
return 1; //bounding boxes intersect
}
bool CollideCompleteBoundingBox( SDL_Rect *a, SDL_Rect *b )
{
if( a->x <= b->x )
{
return 0;
}
if( a->x + a->w >= b->x + b->w )
{
return 0;
}
if( a->y <= b->y )
{
return 0;
}
if( a->y + a->h >= b->y + b->h )
{
return 0;
}
return 1;
}
// from SDL_collide ( Copyright (C) 2005 Amir Taaki )
bool CollideBoundingCircle( int x1, int y1, int r1, int x2, int y2, int r2, int offset )
{
int xdiff = x2 - x1; // x plane difference
int ydiff = y2 - y1; // y plane difference
/* distance between the circles centres squared */
int dcentre_sq = ( ydiff * ydiff ) + ( xdiff * xdiff );
/* calculate sum of radiuses squared */
int r_sum_sq = r1 + r2; // square on seperate line, so
r_sum_sq *= r_sum_sq; // dont recompute r1 + r2
return ( dcentre_sq - r_sum_sq <= ( offset * offset ) );
}
bool CollideBoundingCircle( SDL_Surface *surface1, SDL_Rect *a, SDL_Surface *surface2, SDL_Rect *b, int offset )
{
return CollideBoundingCircle( surface1, a->x, a->y, surface2, b->x, b->y, offset );
}
// from SDL_collide ( Copyright (C) 2005 Amir Taaki )
bool CollideBoundingCircle( SDL_Surface *a, int x1, int y1, SDL_Surface *b, int x2, int y2, int offset )
{
/* if radius is not specified
we approximate them using SDL_Surface's
width and height average and divide by 2*/
int r1 = ( a->w + a->h ) / 4; // same as / 2) / 2;
int r2 = ( b->w + b->h ) / 4;
x1 += a->w / 2; // offset x and y
y1 += a->h / 2; // co-ordinates into
// centre of image
x2 += b->w / 2;
y2 += b->h / 2;
return CollideBoundingCircle( x1, y1, r1, x2, y2, r2, offset );
}
| [
"rinco@ff2c0c17-07fa-0310-a4bd-d48831021cb5"
]
| [
[
[
1,
101
]
]
]
|
18eb3b4908e78a796793a007bdc5706ee32429f4 | 02a0f2ff9542df43d95e7dbe54d4bd21e68a0056 | /spepcpp/include/spep/authn/AuthnProcessorData.h | ab567ed74f5ed38fac53be2919159dc50e593834 | [
"Apache-2.0"
]
| permissive | stevehs/esoeproject | a510a12a7f27d25491f0cdfac328c993c396bd6c | 584772580a668c562a1e24e6ff64a74315c57931 | refs/heads/master | 2021-01-16T21:20:18.967631 | 2009-11-19T06:55:23 | 2009-11-19T06:55:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,778 | h | /* Copyright 2006-2007, Queensland University of Technology
* 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.
*
* Author: Shaun Mangelsdorf
* Creation Date: 19/02/2007
*
* Purpose: Contains data for calls to the authentication processor.
*/
#ifndef AUTHNPROCESSORDATA_H_
#define AUTHNPROCESSORDATA_H_
#include <string>
#include "spep/Util.h"
#include "saml2/handlers/SAMLDocument.h"
namespace spep
{
/**
* Contains data used for or returned from calls to the authentication processor.
*/
class SPEPEXPORT AuthnProcessorData
{
public:
AuthnProcessorData();
/**
* Sets the URL originally request by the user agent, before authentication was invoked.
*/
void setRequestURL( const std::string &requestURL );
std::string getRequestURL();
/**
* Sets the base URL for the host the request was made to.
*/
void setBaseRequestURL( const std::string& baseRequestURL );
std::string getBaseRequestURL();
/**
* Sets the local session ID assigned to the session by the authentication processor
*/
void setSessionID( const std::string &sessionID );
std::string getSessionID();
/**
* Sets the SAML request document. The meaning of this document is context dependant, and
* may also be used to return a SAML request document from a method.
*/
void setRequestDocument( const saml2::SAMLDocument& requestDocument );
const saml2::SAMLDocument& getRequestDocument();
/**
* Sets the SAML response document. The meaning of this document is context dependant, and
* may also be used to return a SAML response document from a method.
*/
void setResponseDocument( const saml2::SAMLDocument& responseDocument );
const saml2::SAMLDocument& getResponseDocument();
/**
* Sets whether or not to disable attribute querying for this session
*/
void setDisableAttributeQuery( bool value );
bool getDisableAttributeQuery();
private:
std::string _requestURL;
std::string _baseRequestURL;
std::string _sessionID;
saml2::SAMLDocument _requestDocument;
saml2::SAMLDocument _responseDocument;
bool _disableAttributeQuery;
};
}
#endif /*AUTHNPROCESSORDATA_H_*/
| [
"[email protected]"
]
| [
[
[
1,
91
]
]
]
|
e4fc93995fa77c691abcc9dc38f50326d71d68ab | 222bc22cb0330b694d2c3b0f4b866d726fd29c72 | /src/brookbox/wm2/WmlContSeparatePoints3.h | 8332d4acd740929e6e5fd027104f2fba81cbf658 | [
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | darwin/inferno | 02acd3d05ca4c092aa4006b028a843ac04b551b1 | e87017763abae0cfe09d47987f5f6ac37c4f073d | refs/heads/master | 2021-03-12T22:15:47.889580 | 2009-04-17T13:29:39 | 2009-04-17T13:29:39 | 178,477 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,345 | h | // Magic Software, Inc.
// http://www.magic-software.com
// http://www.wild-magic.com
// Copyright (c) 2003. All Rights Reserved
//
// The Wild Magic Library (WML) source code is supplied under the terms of
// the license agreement http://www.magic-software.com/License/WildMagic.pdf
// and may not be copied or disclosed except in accordance with the terms of
// that agreement.
#ifndef WMLCONTSEPARATEPOINTS3_H
#define WMLCONTSEPARATEPOINTS3_H
// Separate two point sets, if possible, by computing a plane for which the
// point sets lie on opposite sides. The algorithm computes the convex hull
// of the point sets, then uses the method of separating axes to determine if
// the two convex polyhedra are disjoint. The convex hull calculation is
// O(n*log(n)). There is a randomized linear approach that takes O(n), but
// I have not yet implemented it.
//
// The return value of the function is 'true' if and only if there is a
// separation. If 'true', the returned plane is a separating plane.
#include "WmlPlane3.h"
namespace Wml
{
// Assumes that both sets have at least 4 noncoplanar points.
template <class Real>
WML_ITEM bool SeparatePoints3 (int iQuantity0,
const Vector3<Real>* akVertex0, int iQuantity1,
const Vector3<Real>* akVertex1, Plane3<Real>& rkSeprPlane);
}
#endif
| [
"[email protected]"
]
| [
[
[
1,
37
]
]
]
|
30b05a2f71090dfc96d5b09b38b830b4915015df | 3e69b159d352a57a48bc483cb8ca802b49679d65 | /tags/release-2006-01-18/pcbnew/classtrc.cpp | f598c461b9075f01bc1105be1acc1b3ede3f329d | []
| no_license | BackupTheBerlios/kicad-svn | 4b79bc0af39d6e5cb0f07556eb781a83e8a464b9 | 4c97bbde4b1b12ec5616a57c17298c77a9790398 | refs/heads/master | 2021-01-01T19:38:40.000652 | 2006-06-19T20:01:24 | 2006-06-19T20:01:24 | 40,799,911 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,850 | cpp | /******************************************************************/
/* fonctions membres des classes TRACK et derivees (voir struct.h */
/******************************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "pcbnew.h"
#ifdef CVPCB
#include "cvpcb.h"
#endif
/**************************************/
/* Classes pour Pistes, Vias et Zones */
/**************************************/
/* Constructeur des classes type pistes, vias et zones */
TRACK::TRACK(EDA_BaseStruct * StructFather, DrawStructureType idtype):
SEGDRAW_Struct( StructFather, idtype)
{
m_Shape = S_SEGMENT;
start = end = NULL;
m_NetCode = 0;
m_Sous_Netcode = 0;
}
SEGZONE::SEGZONE(EDA_BaseStruct * StructFather):
TRACK( StructFather, TYPEZONE)
{
}
SEGVIA::SEGVIA(EDA_BaseStruct * StructFather):
TRACK( StructFather, TYPEVIA)
{
}
/******************************************/
bool SEGVIA::IsViaOnLayer(int layer_number )
/******************************************/
/* Retoune TRUE si Via sur layer layer_number
*/
{
int via_type = Shape();
if( via_type == VIA_NORMALE )
{
if ( layer_number <= LAYER_CMP_N ) return TRUE;
else return FALSE;
}
// VIA_BORGNE ou VIA_ENTERREE:
int bottom_layer, top_layer;
ReturnLayerPair(& top_layer, & bottom_layer);
if ( (bottom_layer <= layer_number) && (top_layer >= layer_number) )
return TRUE;
else return FALSE;
}
/*********************************************************/
void SEGVIA::SetLayerPair(int top_layer, int bottom_layer)
/*********************************************************/
/* Met a jour .m_Layer pour une via:
m_Layer code les 2 couches limitant la via
*/
{
int via_type = m_Shape & 255;
if( via_type == VIA_NORMALE )
{
top_layer = LAYER_CMP_N; bottom_layer = LAYER_CUIVRE_N;
}
if ( bottom_layer > top_layer ) EXCHG (bottom_layer, top_layer);
m_Layer = (top_layer & 15) + ( (bottom_layer & 15) << 4 );
}
/***************************************************************/
void SEGVIA::ReturnLayerPair(int * top_layer, int * bottom_layer)
/***************************************************************/
/* Retourne les 2 couches limitant la via
les pointeurs top_layer et bottom_layer peuvent etre NULLs
*/
{
int b_layer = (m_Layer >> 4) & 15;
int t_layer = m_Layer & 15;
if ( b_layer > t_layer ) EXCHG (b_layer, t_layer);
if ( top_layer ) * top_layer = t_layer;
if ( bottom_layer ) * bottom_layer = b_layer;
}
/************************/
TRACK * TRACK::Next(void)
/************************/
{
return (TRACK *) Pnext;
}
/* supprime du chainage la structure Struct
les structures arrieres et avant sont chainees directement
*/
void TRACK::UnLink( void )
{
/* Modification du chainage arriere */
if( Pback )
{
if( Pback->m_StructType != TYPEPCB)
{
Pback->Pnext = Pnext;
}
else /* Le chainage arriere pointe sur la structure "Pere" */
{
if ( GetState(DELETED) ) // A REVOIR car Pback = NULL si place en undelete
{
if( g_UnDeleteStack ) g_UnDeleteStack[g_UnDeleteStackPtr-1] = Pnext;
}
else
{
if (m_StructType == TYPEZONE)
{
((BOARD*)Pback)->m_Zone = (TRACK*)Pnext;
}
else
{
((BOARD*)Pback)->m_Track = (TRACK*)Pnext;
}
}
}
}
/* Modification du chainage avant */
if( Pnext) Pnext->Pback = Pback;
Pnext = Pback = NULL;
}
/************************************************************/
void TRACK::Insert(BOARD * Pcb, EDA_BaseStruct * InsertPoint)
/************************************************************/
/* Ajoute un element ou une liste a une liste de base
Si Insertpoint == NULL: insertion en debut de
liste Pcb->Track ou Pcb->Zone
Insertion a la suite de InsertPoint
Si InsertPoint == NULL, insertion en tete de liste
*/
{
TRACK* track, *NextS;
/* Insertion du debut de la chaine a greffer */
if (InsertPoint == NULL)
{
Pback = Pcb;
if (m_StructType == TYPEZONE)
{
NextS = Pcb->m_Zone; Pcb->m_Zone = this;
}
else
{
NextS = Pcb->m_Track; Pcb->m_Track = this;
}
}
else
{
NextS = (TRACK*)InsertPoint->Pnext;
Pback = InsertPoint;
InsertPoint->Pnext = this;
}
/* Chainage de la fin de la liste a greffer */
track = this;
while ( track->Pnext ) track = (TRACK*) track->Pnext;
/* Track pointe la fin de la chaine a greffer */
track->Pnext = NextS;
if ( NextS ) NextS->Pback = track;
}
/***********************************************/
TRACK * TRACK::GetBestInsertPoint( BOARD * Pcb )
/***********************************************/
/* Recherche du meilleur point d'insertion pour le nouveau segment de piste
Retourne
un pointeur sur le segment de piste APRES lequel l'insertion
doit se faire ( dernier segment du net d'apartenance )
NULL si pas de piste ( liste vide );
*/
{
TRACK * track, * NextTrack;
if( m_StructType == TYPEZONE ) track = Pcb->m_Zone;
else track = Pcb->m_Track;
/* Traitement du debut de liste */
if ( track == NULL ) return(NULL); /* pas de piste ! */
if ( m_NetCode < track->m_NetCode ) /* insertion en tete de liste */
return(NULL);
while( (NextTrack = (TRACK*)track->Pnext) != NULL )
{
if ( NextTrack->m_NetCode > this->m_NetCode ) break;
track = NextTrack;
}
return ( track);
}
/* Recherche du debut du net
( les elements sont classes par net_code croissant )
la recherche se fait a partir de this
si net_code == -1 le netcode de this sera utilise
Retourne un pointeur sur le debut du net, ou NULL si net non trouve
*/
TRACK * TRACK::GetStartNetCode(int NetCode )
{
TRACK * Track = this;
int ii = 0;
if( NetCode == -1 ) NetCode = m_NetCode;
while( Track != NULL)
{
if ( Track->m_NetCode > NetCode ) break;
if ( Track->m_NetCode == NetCode )
{
ii++; break;
}
Track = (TRACK*) Track->Pnext;
}
if ( ii ) return(Track);
else return (NULL);
}
/* Recherche de la fin du net
Retourne un pointeur sur la fin du net, ou NULL si net non trouve
*/
TRACK * TRACK::GetEndNetCode(int NetCode)
{
TRACK * NextS, * Track = this;
int ii = 0;
if( Track == NULL ) return(NULL);
if( NetCode == -1 ) NetCode = m_NetCode;
while( Track != NULL)
{
NextS = (TRACK*)Track->Pnext;
if(Track->m_NetCode == NetCode) ii++;
if ( NextS == NULL ) break;
if ( NextS->m_NetCode > NetCode) break;
Track = NextS;
}
if ( ii ) return(Track);
else return (NULL);
}
/**********************************/
TRACK * TRACK:: Copy( int NbSegm )
/**********************************/
/* Copie d'un Element ou d'une chaine de n elements
Retourne un pointeur sur le nouvel element ou le debut de la
nouvelle chaine
*/
{
TRACK * NewTrack, * FirstTrack, *OldTrack, * Source = this;
int ii;
FirstTrack = NewTrack = new TRACK(NULL);
*NewTrack = * Source;
/* correction du chainage */
NewTrack->Pback = NewTrack->Pnext = NULL;
/* reset des pointeurs auxiliaires */
NewTrack->start = NewTrack->end = NULL;
if( NbSegm <=1 ) return (FirstTrack);
for( ii = 1; ii < NbSegm; ii++ )
{
Source = (TRACK*) Source->Pnext;
if( Source == NULL ) break;
OldTrack = NewTrack;
NewTrack = new TRACK(m_Parent);
if ( NewTrack == NULL ) break;
NewTrack->m_StructType = Source->m_StructType;
NewTrack->m_Shape = Source->m_Shape;
NewTrack->m_NetCode = Source->m_NetCode;
NewTrack->m_Flags = Source->m_Flags;
NewTrack->m_TimeStamp = Source->m_TimeStamp;
NewTrack->SetStatus(Source->ReturnStatus() );
NewTrack->m_Layer = Source->m_Layer;
NewTrack->m_Start = Source->m_Start;
NewTrack->m_End = Source->m_End;
NewTrack->m_Width = Source->m_Width;
NewTrack->Insert(NULL, OldTrack);
}
return (FirstTrack);
}
/********************************************/
bool TRACK::WriteTrackDescr(FILE * File)
/********************************************/
{
int type;
type = 0;
if( m_StructType == TYPEVIA ) type = 1;
if( GetState(DELETED) ) return FALSE;
fprintf( File,"Po %d %d %d %d %d %d\n",m_Shape,
m_Start.x, m_Start.y, m_End.x, m_End.y, m_Width );
fprintf( File,"De %d %d %d %lX %X\n",
m_Layer, type ,m_NetCode,
m_TimeStamp, ReturnStatus());
return TRUE;
}
/**********************************************************************/
void TRACK::Draw(WinEDA_DrawPanel * panel, wxDC * DC, int draw_mode)
/*********************************************************************/
/* routine de trace de 1 segment de piste.
Parametres :
draw_mode = mode ( GR_XOR, GR_OR..)
*/
{
int l_piste;
int color;
int zoom;
int rayon;
int curr_layer = ((PCB_SCREEN*)panel->GetScreen())->m_Active_Layer;
if(m_StructType == TYPEZONE && (! DisplayOpt.DisplayZones) )
return;
GRSetDrawMode(DC, draw_mode);
if ( m_StructType == TYPEVIA ) /* VIA rencontree */
color = g_DesignSettings.m_ViaColor[m_Shape];
else color = g_DesignSettings.m_LayerColor[m_Layer];
if( (color & (ITEM_NOT_SHOW | HIGHT_LIGHT_FLAG)) == ITEM_NOT_SHOW) return ;
if ( DisplayOpt.ContrastModeDisplay )
{
if ( m_StructType == TYPEVIA )
{
if ( ! ((SEGVIA*)this)->IsViaOnLayer(curr_layer) )
{
color &= ~MASKCOLOR;
color |= DARKDARKGRAY;
}
}
else if ( m_Layer != curr_layer)
{
color &= ~MASKCOLOR;
color |= DARKDARKGRAY;
}
}
if( draw_mode & GR_SURBRILL)
{
if( draw_mode & GR_AND) color &= ~HIGHT_LIGHT_FLAG;
else color |= HIGHT_LIGHT_FLAG;
}
if ( color & HIGHT_LIGHT_FLAG)
color = ColorRefs[color & MASKCOLOR].m_LightColor;
zoom = panel->GetZoom();
l_piste = m_Width >> 1;
if ( m_StructType == TYPEVIA ) /* VIA rencontree */
{
rayon = l_piste; if( rayon < zoom ) rayon = zoom;
GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon, color) ;
if ( rayon > (4*zoom) )
{
GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y,
rayon-(2*zoom) , color);
if(DisplayOpt.DisplayTrackIsol)
GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y,
rayon + g_DesignSettings.m_TrackClearence, color);
}
return;
}
if(m_Shape == S_CIRCLE)
{
rayon = (int)hypot((double)(m_End.x - m_Start.x),
(double)(m_End.y - m_Start.y) );
if ( (l_piste/zoom) < L_MIN_DESSIN)
{
GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon , color) ;
}
else
{
if(l_piste <= zoom) /* trace simplifie si l_piste/zoom <= 1 */
{
GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon, color);
}
else if( ( ! DisplayOpt.DisplayPcbTrackFill) || GetState(FORCE_SKETCH))
{
GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon-l_piste, color);
GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon+l_piste, color);
}
else
{
GRCircle(&panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon,
m_Width, color);
}
}
return;
}
if ( (l_piste/zoom) < L_MIN_DESSIN)
{
GRLine(&panel->m_ClipBox, DC, m_Start.x, m_Start.y,
m_End.x, m_End.y, color);
return;
}
if( (! DisplayOpt.DisplayPcbTrackFill) || GetState(FORCE_SKETCH) )
{
GRCSegm(&panel->m_ClipBox, DC, m_Start.x, m_Start.y,
m_End.x, m_End.y, m_Width, color) ;
}
else
{
GRFillCSegm(&panel->m_ClipBox, DC, m_Start.x, m_Start.y,
m_End.x, m_End.y, m_Width, color) ;
}
/* Trace de l'isolation (pour segments type CUIVRE et TRACK uniquement */
if( (DisplayOpt.DisplayTrackIsol) && (m_Layer <= CMP_N )
&& ( m_StructType == TYPETRACK) )
{
GRCSegm(&panel->m_ClipBox, DC, m_Start.x, m_Start.y,
m_End.x, m_End.y,
m_Width + (g_DesignSettings.m_TrackClearence*2), color) ;
}
}
| [
"bokeoa@244deca0-f506-0410-ab94-f4f3571dea26"
]
| [
[
[
1,
460
]
]
]
|
e1f0ae0029ad187497e435cd5d9f71f8fa6cd663 | fc3691e5b88f10ce159d61fd198f5742fb2f643c | /src/main.cpp | e3e140d90daa63639d6b004d5fba2ccdea381a10 | []
| no_license | hardyx/openpirates | 6f438ed04ec1c64cb1d35e7da4e56aa919c91750 | 5833ee50474398bc7c364902343d3ff52f5306a6 | refs/heads/master | 2020-03-11T09:40:55.969627 | 2010-07-26T00:47:56 | 2010-07-26T00:47:56 | 129,919,203 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,678 | cpp | /***
* openPirates
* Copyright (C) 2010 Scott Smith
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "main.h"
int main( int argc, char *argv[] )
{
int8_t result = SIG_NONE;
CModeMain ModeMain;
Log( "openPirates Copyright (C) 2010 Scott Smith\n" );
Log( "This program comes with ABSOLUTELY NO WARRANTY\n" );
Log( "This is free software, and you are welcome to redistribute it\n" );
Log( "under certain conditions.\n\n" );
Log( "Starting %s\n", TITLE );
result = ModeMain.Run( argc, argv );
switch ( result )
{
case SIG_NONE:
case SIG_QUIT:
Log( "%s Terminated by normal request\n", TITLE );
result = 0;
break;
case SIG_FAIL:
Log( "%s Terminated by error signal (check stderr)\n", TITLE );
result = -1;
break;
default:
Log( "%s Terminated by unknown signal %d (check stderr)\n", TITLE, result );
result = -2;
break;
}
return result;
}
| [
"pickle136@3faa6364-4847-409f-afa2-7fad3069fade"
]
| [
[
[
1,
53
]
]
]
|
49dcefa18fe0345ebfe0f5185ae95772f7a047bb | 0f19aa6d0ba7b58e5ded3c63bb6846ab84d84c88 | /dependencies/irrlicht/source/Irrlicht/CTRTextureGouraudAddNoZ2.cpp | a7639609270ba750a5771f0d48e642216a0f91bf | [
"LicenseRef-scancode-other-permissive",
"Zlib",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | aep/slay | 200387b28b4dc1d21a9f5931967a85ff610d563a | daa808795fe352135e75a101520f208d4ba90433 | refs/heads/master | 2022-11-11T21:18:55.229691 | 2009-11-07T05:50:28 | 2009-11-07T05:50:28 | 275,114,718 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,582 | cpp | // Copyright (C) 2002-2009 Nikolaus Gebhardt / Thomas Alten
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "IrrCompileConfig.h"
#include "IBurningShader.h"
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
// compile flag for this file
#undef USE_ZBUFFER
#undef IPOL_Z
#undef CMP_Z
#undef WRITE_Z
#undef IPOL_W
#undef CMP_W
#undef WRITE_W
#undef SUBTEXEL
#undef INVERSE_W
#undef IPOL_C0
#undef IPOL_T0
#undef IPOL_T1
// define render case
#define SUBTEXEL
#define INVERSE_W
#define USE_ZBUFFER
#define IPOL_W
#define CMP_W
//#define WRITE_W
//#define IPOL_C0
#define IPOL_T0
//#define IPOL_T1
// apply global override
#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT
#undef INVERSE_W
#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT
#undef IPOL_W
#endif
#endif
#ifndef SOFTWARE_DRIVER_2_SUBTEXEL
#undef SUBTEXEL
#endif
#ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR
#undef IPOL_C0
#endif
#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER )
#define IPOL_Z
#ifdef CMP_W
#undef CMP_W
#define CMP_Z
#endif
#ifdef WRITE_W
#undef WRITE_W
#define WRITE_Z
#endif
#endif
namespace irr
{
namespace video
{
class CTRTextureGouraudAddNoZ2 : public IBurningShader
{
public:
//! constructor
CTRTextureGouraudAddNoZ2(IDepthBuffer* zbuffer);
//! draws an indexed triangle list
virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c );
private:
void scanline_bilinear ();
sScanConvertData scan;
sScanLineData line;
};
//! constructor
CTRTextureGouraudAddNoZ2::CTRTextureGouraudAddNoZ2(IDepthBuffer* zbuffer)
: IBurningShader(zbuffer)
{
#ifdef _DEBUG
setDebugName("CTRTextureGouraudAddNoZ2");
#endif
}
/*!
*/
void CTRTextureGouraudAddNoZ2::scanline_bilinear ()
{
tVideoSample *dst;
#ifdef USE_ZBUFFER
fp24 *z;
#endif
s32 xStart;
s32 xEnd;
s32 dx;
#ifdef SUBTEXEL
f32 subPixel;
#endif
#ifdef IPOL_Z
f32 slopeZ;
#endif
#ifdef IPOL_W
fp24 slopeW;
#endif
#ifdef IPOL_C0
sVec4 slopeC;
#endif
#ifdef IPOL_T0
sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES];
#endif
// apply top-left fill-convention, left
xStart = core::ceil32( line.x[0] );
xEnd = core::ceil32( line.x[1] ) - 1;
dx = xEnd - xStart;
if ( dx < 0 )
return;
// slopes
const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] );
#ifdef IPOL_Z
slopeZ = (line.z[1] - line.z[0]) * invDeltaX;
#endif
#ifdef IPOL_W
slopeW = (line.w[1] - line.w[0]) * invDeltaX;
#endif
#ifdef IPOL_C0
slopeC = (line.c[1] - line.c[0]) * invDeltaX;
#endif
#ifdef IPOL_T0
slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX;
#endif
#ifdef IPOL_T1
slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX;
#endif
#ifdef SUBTEXEL
subPixel = ( (f32) xStart ) - line.x[0];
#ifdef IPOL_Z
line.z[0] += slopeZ * subPixel;
#endif
#ifdef IPOL_W
line.w[0] += slopeW * subPixel;
#endif
#ifdef IPOL_C0
line.c[0] += slopeC * subPixel;
#endif
#ifdef IPOL_T0
line.t[0][0] += slopeT[0] * subPixel;
#endif
#ifdef IPOL_T1
line.t[1][0] += slopeT[1] * subPixel;
#endif
#endif
dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
#ifdef USE_ZBUFFER
z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
#endif
#ifdef IPOL_W
f32 inversew;
#endif
tFixPoint tx0;
tFixPoint ty0;
tFixPoint r0, g0, b0;
tFixPoint r1, g1, b1;
tFixPoint r2, g2, b2;
for ( s32 i = 0; i <= dx; ++i )
{
#ifdef CMP_Z
if ( line.z[0] < z[i] )
#endif
#ifdef CMP_W
if ( line.w[0] >= z[i] )
#endif
{
#ifdef IPOL_W
inversew = fix_inverse32 ( line.w[0] );
tx0 = tofix ( line.t[0][0].x,inversew);
ty0 = tofix ( line.t[0][0].y,inversew);
#else
tx0 = tofix ( line.t[0][0].x );
ty0 = tofix ( line.t[0][0].y );
#endif
getSample_texture ( r0, g0, b0, &IT[0], tx0,ty0 );
color_to_fix ( r1, g1, b1, dst[i] );
r2 = clampfix_maxcolor ( r1 + r0 );
g2 = clampfix_maxcolor ( g1 + g0 );
b2 = clampfix_maxcolor ( b1 + b0 );
dst[i] = fix_to_color ( r2, g2, b2 );
#ifdef WRITE_Z
z[i] = line.z[0];
#endif
#ifdef WRITE_W
z[i] = line.w[0];
#endif
}
#ifdef IPOL_Z
line.z[0] += slopeZ;
#endif
#ifdef IPOL_W
line.w[0] += slopeW;
#endif
#ifdef IPOL_C0
line.c[0] += slopeC;
#endif
#ifdef IPOL_T0
line.t[0][0] += slopeT[0];
#endif
#ifdef IPOL_T1
line.t[1][0] += slopeT[1];
#endif
}
}
void CTRTextureGouraudAddNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c )
{
// sort on height, y
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
const f32 ca = c->Pos.y - a->Pos.y;
const f32 ba = b->Pos.y - a->Pos.y;
const f32 cb = c->Pos.y - b->Pos.y;
// calculate delta y of the edges
scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f;
scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f;
scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f;
if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
return;
// find if the major edge is left or right aligned
f32 temp[4];
temp[0] = a->Pos.x - c->Pos.x;
temp[1] = -ca;
temp[2] = b->Pos.x - a->Pos.x;
temp[3] = ba;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
scan.right = 1 - scan.left;
// calculate slopes for the major edge
scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0];
scan.x[0] = a->Pos.x;
#ifdef IPOL_Z
scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0];
scan.z[0] = a->Pos.z;
#endif
#ifdef IPOL_W
scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0];
scan.w[0] = a->Pos.w;
#endif
#ifdef IPOL_C0
scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0];
scan.c[0] = a->Color[0];
#endif
#ifdef IPOL_T0
scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0];
scan.t[0][0] = a->Tex[0];
#endif
#ifdef IPOL_T1
scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0];
scan.t[1][0] = a->Tex[1];
#endif
// top left fill convention y run
s32 yStart;
s32 yEnd;
#ifdef SUBTEXEL
f32 subPixel;
#endif
// rasterize upper sub-triangle
if ( (f32) 0.0 != scan.invDeltaY[1] )
{
// calculate slopes for top edge
scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1];
scan.x[1] = a->Pos.x;
#ifdef IPOL_Z
scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1];
scan.z[1] = a->Pos.z;
#endif
#ifdef IPOL_W
scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1];
scan.w[1] = a->Pos.w;
#endif
#ifdef IPOL_C0
scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1];
scan.c[1] = a->Color[0];
#endif
#ifdef IPOL_T0
scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1];
scan.t[0][1] = a->Tex[0];
#endif
#ifdef IPOL_T1
scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1];
scan.t[1][1] = a->Tex[1];
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( a->Pos.y );
yEnd = core::ceil32( b->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - a->Pos.y;
// correct to pixel center
scan.x[0] += scan.slopeX[0] * subPixel;
scan.x[1] += scan.slopeX[1] * subPixel;
#ifdef IPOL_Z
scan.z[0] += scan.slopeZ[0] * subPixel;
scan.z[1] += scan.slopeZ[1] * subPixel;
#endif
#ifdef IPOL_W
scan.w[0] += scan.slopeW[0] * subPixel;
scan.w[1] += scan.slopeW[1] * subPixel;
#endif
#ifdef IPOL_C0
scan.c[0] += scan.slopeC[0] * subPixel;
scan.c[1] += scan.slopeC[1] * subPixel;
#endif
#ifdef IPOL_T0
scan.t[0][0] += scan.slopeT[0][0] * subPixel;
scan.t[0][1] += scan.slopeT[0][1] * subPixel;
#endif
#ifdef IPOL_T1
scan.t[1][0] += scan.slopeT[1][0] * subPixel;
scan.t[1][1] += scan.slopeT[1][1] * subPixel;
#endif
#endif
// rasterize the edge scanlines
for( line.y = yStart; line.y <= yEnd; ++line.y)
{
line.x[scan.left] = scan.x[0];
line.x[scan.right] = scan.x[1];
#ifdef IPOL_Z
line.z[scan.left] = scan.z[0];
line.z[scan.right] = scan.z[1];
#endif
#ifdef IPOL_W
line.w[scan.left] = scan.w[0];
line.w[scan.right] = scan.w[1];
#endif
#ifdef IPOL_C0
line.c[scan.left] = scan.c[0];
line.c[scan.right] = scan.c[1];
#endif
#ifdef IPOL_T0
line.t[0][scan.left] = scan.t[0][0];
line.t[0][scan.right] = scan.t[0][1];
#endif
#ifdef IPOL_T1
line.t[1][scan.left] = scan.t[1][0];
line.t[1][scan.right] = scan.t[1][1];
#endif
// render a scanline
scanline_bilinear ();
scan.x[0] += scan.slopeX[0];
scan.x[1] += scan.slopeX[1];
#ifdef IPOL_Z
scan.z[0] += scan.slopeZ[0];
scan.z[1] += scan.slopeZ[1];
#endif
#ifdef IPOL_W
scan.w[0] += scan.slopeW[0];
scan.w[1] += scan.slopeW[1];
#endif
#ifdef IPOL_C0
scan.c[0] += scan.slopeC[0];
scan.c[1] += scan.slopeC[1];
#endif
#ifdef IPOL_T0
scan.t[0][0] += scan.slopeT[0][0];
scan.t[0][1] += scan.slopeT[0][1];
#endif
#ifdef IPOL_T1
scan.t[1][0] += scan.slopeT[1][0];
scan.t[1][1] += scan.slopeT[1][1];
#endif
}
}
// rasterize lower sub-triangle
if ( (f32) 0.0 != scan.invDeltaY[2] )
{
// advance to middle point
if( (f32) 0.0 != scan.invDeltaY[1] )
{
temp[0] = b->Pos.y - a->Pos.y; // dy
scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0];
#ifdef IPOL_Z
scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0];
#endif
#ifdef IPOL_W
scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0];
#endif
#ifdef IPOL_C0
scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0];
#endif
#ifdef IPOL_T0
scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0];
#endif
#ifdef IPOL_T1
scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0];
#endif
}
// calculate slopes for bottom edge
scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2];
scan.x[1] = b->Pos.x;
#ifdef IPOL_Z
scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2];
scan.z[1] = b->Pos.z;
#endif
#ifdef IPOL_W
scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2];
scan.w[1] = b->Pos.w;
#endif
#ifdef IPOL_C0
scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2];
scan.c[1] = b->Color[0];
#endif
#ifdef IPOL_T0
scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2];
scan.t[0][1] = b->Tex[0];
#endif
#ifdef IPOL_T1
scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2];
scan.t[1][1] = b->Tex[1];
#endif
// apply top-left fill convention, top part
yStart = core::ceil32( b->Pos.y );
yEnd = core::ceil32( c->Pos.y ) - 1;
#ifdef SUBTEXEL
subPixel = ( (f32) yStart ) - b->Pos.y;
// correct to pixel center
scan.x[0] += scan.slopeX[0] * subPixel;
scan.x[1] += scan.slopeX[1] * subPixel;
#ifdef IPOL_Z
scan.z[0] += scan.slopeZ[0] * subPixel;
scan.z[1] += scan.slopeZ[1] * subPixel;
#endif
#ifdef IPOL_W
scan.w[0] += scan.slopeW[0] * subPixel;
scan.w[1] += scan.slopeW[1] * subPixel;
#endif
#ifdef IPOL_C0
scan.c[0] += scan.slopeC[0] * subPixel;
scan.c[1] += scan.slopeC[1] * subPixel;
#endif
#ifdef IPOL_T0
scan.t[0][0] += scan.slopeT[0][0] * subPixel;
scan.t[0][1] += scan.slopeT[0][1] * subPixel;
#endif
#ifdef IPOL_T1
scan.t[1][0] += scan.slopeT[1][0] * subPixel;
scan.t[1][1] += scan.slopeT[1][1] * subPixel;
#endif
#endif
// rasterize the edge scanlines
for( line.y = yStart; line.y <= yEnd; ++line.y)
{
line.x[scan.left] = scan.x[0];
line.x[scan.right] = scan.x[1];
#ifdef IPOL_Z
line.z[scan.left] = scan.z[0];
line.z[scan.right] = scan.z[1];
#endif
#ifdef IPOL_W
line.w[scan.left] = scan.w[0];
line.w[scan.right] = scan.w[1];
#endif
#ifdef IPOL_C0
line.c[scan.left] = scan.c[0];
line.c[scan.right] = scan.c[1];
#endif
#ifdef IPOL_T0
line.t[0][scan.left] = scan.t[0][0];
line.t[0][scan.right] = scan.t[0][1];
#endif
#ifdef IPOL_T1
line.t[1][scan.left] = scan.t[1][0];
line.t[1][scan.right] = scan.t[1][1];
#endif
// render a scanline
scanline_bilinear ( );
scan.x[0] += scan.slopeX[0];
scan.x[1] += scan.slopeX[1];
#ifdef IPOL_Z
scan.z[0] += scan.slopeZ[0];
scan.z[1] += scan.slopeZ[1];
#endif
#ifdef IPOL_W
scan.w[0] += scan.slopeW[0];
scan.w[1] += scan.slopeW[1];
#endif
#ifdef IPOL_C0
scan.c[0] += scan.slopeC[0];
scan.c[1] += scan.slopeC[1];
#endif
#ifdef IPOL_T0
scan.t[0][0] += scan.slopeT[0][0];
scan.t[0][1] += scan.slopeT[0][1];
#endif
#ifdef IPOL_T1
scan.t[1][0] += scan.slopeT[1][0];
scan.t[1][1] += scan.slopeT[1][1];
#endif
}
}
}
} // end namespace video
} // end namespace irr
#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
namespace irr
{
namespace video
{
//! creates a flat triangle renderer
IBurningShader* createTRTextureGouraudAddNoZ2(IDepthBuffer* zbuffer)
{
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
return new CTRTextureGouraudAddNoZ2(zbuffer);
#else
return 0;
#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
}
} // end namespace video
} // end namespace irr
| [
"[email protected]"
]
| [
[
[
1,
649
]
]
]
|
1534383c9890855e4dd7bcf328944dd51eebe592 | 13ab3c3dbedde1ef5374dde02d7162bbfd728f44 | /glib/lx.h | 950c79963b0eccc0bb914eb59f3b9dd968219d33 | []
| no_license | pikma/Snap | f4dbb4f99a4ca7a98243c9d10bdb5e0b94ef574e | 911f40a2eb0ef5330ecde983137557526955e28a | refs/heads/master | 2020-05-20T04:41:03.292112 | 2011-12-11T22:44:18 | 2011-12-11T22:44:18 | 2,729,964 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,262 | h | #ifndef GLIB_LX_H
#define GLIB_LX_H
#include "hash.h"
#include "tm.h"
#include "bits.h"
/////////////////////////////////////////////////
// Lexical-Char-Definition
typedef enum {lctUndef, lctSpace, lctNum, lctAlpha, lctSSym, lctTerm} TLxChTy;
typedef enum {lcdtUsAscii, lcdtYuAscii} TLxChDefTy;
ClassTP(TLxChDef, PLxChDef)//{
private:
TIntV ChTyV;
TChV UcChV;
void SetUcCh(const TStr& Str);
void SetChTy(const TLxChTy& ChTy, const TStr& Str);
public:
TLxChDef(const TLxChDefTy& ChDefTy);
static PLxChDef New(const TLxChDefTy& ChDefTy=lcdtUsAscii){
return PLxChDef(new TLxChDef(ChDefTy));}
TLxChDef(TSIn& SIn): ChTyV(SIn), UcChV(SIn){}
static PLxChDef Load(TSIn& SIn){return new TLxChDef(SIn);}
void Save(TSOut& SOut){ChTyV.Save(SOut); UcChV.Save(SOut);}
TLxChDef& operator=(const TLxChDef& ChDef){
ChTyV=ChDef.ChTyV; UcChV=ChDef.UcChV; return *this;}
int GetChTy(const char& Ch) const {return ChTyV[Ch-TCh::Mn];}
bool IsTerm(const char& Ch) const {return ChTyV[Ch-TCh::Mn]==TInt(lctTerm);}
bool IsSpace(const char& Ch) const {return ChTyV[Ch-TCh::Mn]==TInt(lctSpace);}
bool IsAlpha(const char& Ch) const {return ChTyV[Ch-TCh::Mn]==TInt(lctAlpha);}
bool IsNum(const char& Ch) const {return ChTyV[Ch-TCh::Mn]==TInt(lctNum);}
bool IsAlNum(const char& Ch) const {
return (ChTyV[Ch-TCh::Mn]==TInt(lctAlpha))||(ChTyV[Ch-TCh::Mn]==TInt(lctNum));}
char GetUc(const char& Ch) const {return UcChV[Ch-TCh::Mn];}
bool IsNmStr(const TStr& Str) const;
TStr GetUcStr(const TStr& Str) const;
// standard entry points
static PLxChDef GetChDef(const TLxChDefTy& ChDefTy=lcdtUsAscii);
// static TLxChDef& GetChDefRef(const TLxChDefTy& ChDefTy=lcdtUsAscii);
};
/////////////////////////////////////////////////
// Lexical-Symbols
typedef enum {
syUndef, syLn, syTab, syBool, syInt, syFlt, syStr, syIdStr, syQStr,
syPeriod, syDPeriod, syComma, syColon, syDColon, sySemicolon,
syPlus, syMinus, syAsterisk, sySlash, syPercent,
syExclamation, syVBar, syAmpersand, syQuestion, syHash,
syEq, syNEq, syLss, syGtr, syLEq, syGEq,
syLParen, syRParen, syLBracket, syRBracket, syLBrace, syRBrace,
syEoln, syEof,
syMnRw, syRw1, syRw2, syRw3, syRw4, syRw5, syRw6, syRw7, syRw8, syRw9,
syRw10, syRw11, syRw12, syRw13, syRw14, syRw15, syRw16, syRw17, syMxRw
} TLxSym;
class TLxSymStr{
public:
static const TStr UndefStr;
static const TStr LnStr;
static const TStr TabStr;
static const TStr BoolStr;
static const TStr IntStr;
static const TStr FltStr;
static const TStr StrStr;
static const TStr IdStrStr;
static const TStr QStrStr;
static const TStr PeriodStr;
static const TStr DPeriodStr;
static const TStr CommaStr;
static const TStr ColonStr;
static const TStr DColonStr;
static const TStr SemicolonStr;
static const TStr PlusStr;
static const TStr MinusStr;
static const TStr AsteriskStr;
static const TStr SlashStr;
static const TStr PercentStr;
static const TStr ExclamationStr;
static const TStr VBarStr;
static const TStr AmpersandStr;
static const TStr QuestionStr;
static const TStr HashStr;
static const TStr EqStr;
static const TStr NEqStr;
static const TStr LssStr;
static const TStr GtrStr;
static const TStr LEqStr;
static const TStr GEqStr;
static const TStr LParenStr;
static const TStr RParenStr;
static const TStr LBracketStr;
static const TStr RBracketStr;
static const TStr LBraceStr;
static const TStr RBraceStr;
static const TStr EolnStr;
static const TStr EofStr;
static TStr GetSymStr(const TLxSym& Sym);
static TLxSym GetSSym(const TStr& Str);
public:
static bool IsSep(const TLxSym& PrevSym, const TLxSym& Sym);
};
/////////////////////////////////////////////////
// Lexical-Input-Symbol-State
class TILx;
class TILxSymSt{
private:
TLxSym Sym;
TStr Str, UcStr, CmtStr;
bool Bool; int Int; double Flt;
int SymLnN, SymLnChN, SymChN;
public:
TILxSymSt();
TILxSymSt(const TILxSymSt& SymSt);
TILxSymSt(TILx& Lx);
TILxSymSt(TSIn&){Fail;}
void Save(TSOut&){Fail;}
void Restore(TILx& Lx);
};
/////////////////////////////////////////////////
// Lexical-Input
typedef enum {
iloCmtAlw, iloRetEoln, iloSigNum, iloUniStr, iloCsSens,
iloExcept, iloTabSep, iloList, iloMx} TILxOpt;
class TILx{
private:
PLxChDef ChDef;
PSIn SIn;
TSIn& RSIn;
char PrevCh, Ch;
int LnN, LnChN, ChN;
TSStack<TILxSymSt> PrevSymStStack;
TStrIntH RwStrH;
bool IsCmtAlw, IsRetEoln, IsSigNum, IsUniStr, IsCsSens;
bool IsExcept, IsTabSep, IsList;
char GetCh(){
Assert(Ch!=TCh::EofCh);
PrevCh=Ch; LnChN++; ChN++;
Ch=((RSIn.Eof()) ? TCh::EofCh : RSIn.GetCh());
if (IsList){putchar(Ch);}
return Ch;
}
char GetCh1(){char Ch=GetCh1(); printf("%c", Ch); return Ch;}
public: // symbol state
TLxSym Sym;
TChA Str, UcStr, CmtStr;
bool Bool; int Int; double Flt;
int SymLnN, SymLnChN, SymChN;
bool QuoteP;
char QuoteCh;
public:
TILx(const PSIn& _SIn, const TFSet& OptSet=TFSet(),
const TLxChDefTy& ChDefTy=lcdtUsAscii);
TILx& operator=(const TILx&){Fail; return *this;}
void SetOpt(const int& Opt, const bool& Val);
TLxSym AddRw(const TStr& Str);
TLxSym GetRw(const TStr& Str){
return TLxSym(int(RwStrH.GetDat(Str)));}
PSIn GetSIn(const char& SepCh);
int GetLnN() const {return LnN;}
bool IsBof() const {return ChN==-1;}
bool IsEof() const {return Ch==TCh::EofCh;}
TLxSym GetSym(const TFSet& Expect);
TLxSym GetSym(){return GetSym(TFSet());}
TLxSym GetSym(const TLxSym& Sym){return GetSym(TFSet()|Sym);}
TLxSym GetSym(const TLxSym& Sym1, const TLxSym& Sym2){
return GetSym(TFSet()|Sym1|Sym2);}
TLxSym GetSym(const TLxSym& Sym1, const TLxSym& Sym2, const TLxSym& Sym3){
return GetSym(TFSet()|Sym1|Sym2|Sym3);}
TLxSym GetSym(const TLxSym& Sym1, const TLxSym& Sym2, const TLxSym& Sym3,
const TLxSym& Sym4){
return GetSym(TFSet()|Sym1|Sym2|Sym3|Sym4);}
bool GetBool(){GetSym(TFSet()|syBool); return Bool;}
int GetInt(){GetSym(TFSet()|syInt); return Int;}
double GetFlt(){GetSym(TFSet()|syFlt); return Flt;}
TStr GetStr(const TStr& _Str=TStr()){
GetSym(TFSet()|syStr); IAssert(_Str.Empty()||(_Str==Str)); return Str;}
TStr GetIdStr(const TStr& IdStr=TStr()){
GetSym(TFSet()|syIdStr); IAssert(IdStr.Empty()||(IdStr==Str)); return Str;}
TStr GetQStr(const TStr& QStr=TStr()){
GetSym(TFSet()|syQStr); IAssert(QStr.Empty()||(Str==QStr)); return Str;}
void GetEoln(){GetSym(TFSet()|syEoln);}
TStr GetStrToCh(const char& ToCh);
TStr GetStrToEolnOrCh(const char& ToCh);
TStr GetStrToEoln(const bool& DoTrunc=false);
TStr GetStrToEolnAndCh(const char& ToCh);
void SkipToEoln();
void SkipToSym(const TLxSym& SkipToSym){
while (Sym!=SkipToSym){GetSym();}}
void PutSym(const TILxSymSt& SymSt){PrevSymStStack.Push(TILxSymSt(SymSt));}
void PutSym(){PrevSymStStack.Push(TILxSymSt(*this));}
TLxSym PeekSym(){TLxSym NextSym=GetSym(); PutSym(); return NextSym;}
TLxSym PeekSym(const int& Syms);
TStr GetSymStr() const;
TStr GetFPosStr() const;
static TStr GetQStr(const TStr& Str, const bool& QuoteP, const char& QuoteCh);
bool IsVar(const TStr& VarNm){
GetSym(); bool Var=((Sym==syIdStr)&&(Str==VarNm)); PutSym(); return Var;}
void GetVar(const TStr& VarNm,
const bool& LBracket=false, const bool& NewLn=false){
GetIdStr(VarNm); GetSym(syColon);
if (LBracket){GetSym(syLBracket);} if (NewLn){GetEoln();}}
void GetVarEnd(const bool& RBracket=false, const bool& NewLn=false){
if (RBracket){GetSym(syRBracket);}
if (NewLn){GetEoln();}}
bool PeekVarEnd(const bool& RBracket=false, const bool& NewLn=false){
if (RBracket){return PeekSym()==syRBracket;}
if (NewLn){return PeekSym()==syEoln;} Fail; return false;}
bool GetVarBool(const TStr& VarNm, const bool& NewLn=true){
GetIdStr(VarNm); GetSym(syColon); bool Bool=GetBool();
if (NewLn){GetEoln();} return Bool;}
int GetVarInt(const TStr& VarNm, const bool& NewLn=true){
GetIdStr(VarNm); GetSym(syColon); int Int=GetInt();
if (NewLn){GetEoln();} return Int;}
double GetVarFlt(const TStr& VarNm, const bool& NewLn=true){
GetIdStr(VarNm); GetSym(syColon); double Flt=GetFlt();
if (NewLn){GetEoln();} return Flt;}
TStr GetVarStr(const TStr& VarNm, const bool& NewLn=true){
GetIdStr(VarNm); GetSym(syColon); TStr Str=GetQStr();
if (NewLn){GetEoln();} return Str;}
TSecTm GetVarSecTm(const TStr& VarNm, const bool& NewLn=true){
GetIdStr(VarNm); GetSym(syColon); TSecTm SecTm=TSecTm::LoadTxt(*this);
if (NewLn){GetEoln();} return SecTm;}
void GetVarBoolV(const TStr& VarNm, TBoolV& BoolV, const bool& NewLn=true);
void GetVarIntV(const TStr& VarNm, TIntV& IntV, const bool& NewLn=true);
void GetVarFltV(const TStr& VarNm, TFltV& FltV, const bool& NewLn=true);
void GetVarStrV(const TStr& VarNm, TStrV& StrV, const bool& NewLn=true);
void GetVarStrPrV(const TStr& VarNm, TStrPrV& StrPrV, const bool& NewLn=true);
void GetVarStrVV(const TStr& VarNm, TVec<TStrV>& StrVV, const bool& NewLn=true);
// file-of-lines
static void GetLnV(const TStr& FNm, TStrV& LnV);
};
/////////////////////////////////////////////////
// Lexical-Output
typedef enum {
oloCmtAlw, oloFrcEoln, oloSigNum, oloUniStr,
oloCsSens, oloTabSep, oloVarIndent, oloMx} TOLxOpt;
class TOLx{
private:
PLxChDef ChDef;
PSOut SOut;
TSOut& RSOut;
bool IsCmtAlw, IsFrcEoln, IsSigNum, IsUniStr;
bool IsCsSens, IsTabSep, IsVarIndent;
int VarIndentLev;
TStrIntH RwStrH;
TIntStrH RwSymH;
TLxSym PrevSym;
void PutSep(const TLxSym& Sym);
public:
TOLx(const PSOut& _SOut, const TFSet& OptSet,
const TLxChDefTy& ChDefTy=lcdtUsAscii);
TOLx& operator=(const TOLx&){Fail; return *this;}
void SetOpt(const int& Opt, const bool& Val);
TLxSym AddRw(const TStr& Str);
PSOut GetSOut(const char& SepCh){
RSOut.PutCh(SepCh); return SOut;}
void PutSym(const TLxSym& Sym);
void PutBool(const TBool& Bool){
PutSep(syIdStr); RSOut.PutStr(TBool::GetStr(Bool));}
void PutInt(const TInt& Int){
if (!IsSigNum){Assert(int(Int)>=0);}
PutSep(syInt); RSOut.PutStr(TInt::GetStr(Int));}
void PutFlt(const TFlt& Flt, const int& Width=-1, const int& Prec=-1){
if (!IsSigNum){Assert(Flt>=0);}
PutSep(syFlt); RSOut.PutStr(TFlt::GetStr(Flt, Width, Prec));}
void PutStr(const TStr& Str){
if ((IsUniStr)&&(ChDef->IsNmStr(Str))){PutSep(syIdStr); RSOut.PutStr(Str);}
else {PutSep(syStr); RSOut.PutCh('"'); RSOut.PutStr(Str); RSOut.PutCh('"');}}
void PutIdStr(const TStr& Str, const bool& CheckIdStr=true){
if (CheckIdStr){Assert(ChDef->IsNmStr(Str));}
PutSep(syIdStr); RSOut.PutStr(Str);}
void PutQStr(const TStr& Str){
PutSep(syQStr); RSOut.PutCh('"'); RSOut.PutStr(Str); RSOut.PutCh('"');}
void PutQStr(const TChA& ChA){
PutSep(syQStr); RSOut.PutCh('"'); RSOut.PutStr(ChA); RSOut.PutCh('"');}
void PutUQStr(const TStr& Str){
PutSep(syIdStr); RSOut.PutStr(Str);}
void PutLnCmt(const TStr& Str, const int& IndentLev=0){
Assert(IsCmtAlw); PutStr(" // "); PutStr(Str); PutLn(IndentLev);}
void PutParCmt(const TStr& Str){
Assert(IsCmtAlw); PutStr(" /* "); PutStr(Str); PutStr(" */ ");}
void PutIndent(const int& IndentLev){
RSOut.PutCh(' ', IndentLev*2);}
void PutTab() const {RSOut.PutCh(TCh::TabCh);}
void PutLn(const int& IndentLev=0){
Assert(IsFrcEoln);
PutSep(syEoln); RSOut.PutLn(); RSOut.PutCh(' ', IndentLev*2);}
void PutDosLn(const int& IndentLev=0){
Assert(IsFrcEoln);
PutSep(syEoln); RSOut.PutDosLn(); RSOut.PutCh(' ', IndentLev*2);}
void PutVar(const TStr& VarNm, const bool& LBracket=false,
const bool& NewLn=false, const bool& CheckIdStr=true){
if (IsVarIndent){PutIndent(VarIndentLev);}
PutIdStr(VarNm, CheckIdStr); PutSym(syColon);
if (LBracket){PutSym(syLBracket);}
if (NewLn){PutLn(); VarIndentLev++;}}
void PutVarEnd(const bool& RBracket=false, const bool& NewLn=false){
if (IsVarIndent){PutIndent(VarIndentLev-1);}
if (RBracket){PutSym(syRBracket);}
if (NewLn){PutLn(); VarIndentLev--;}}
void PutVarBool(const TStr& VarNm, const bool& Bool,
const bool& NewLn=true, const bool& CheckIdStr=true){
if (IsVarIndent){PutIndent(VarIndentLev);}
PutIdStr(VarNm, CheckIdStr); PutSym(syColon); PutBool(Bool);
if (NewLn){PutLn();}}
void PutVarInt(const TStr& VarNm, const int& Int,
const bool& NewLn=true, const bool& CheckIdStr=true){
if (IsVarIndent){PutIndent(VarIndentLev);}
PutIdStr(VarNm, CheckIdStr); PutSym(syColon); PutInt(Int);
if (NewLn){PutLn();}}
void PutVarFlt(const TStr& VarNm, const double& Flt,
const bool& NewLn=true, const bool& CheckIdStr=true){
if (IsVarIndent){PutIndent(VarIndentLev);}
PutIdStr(VarNm, CheckIdStr); PutSym(syColon); PutFlt(Flt);
if (NewLn){PutLn();}}
void PutVarStr(const TStr& VarNm, const TStr& Str,
const bool& NewLn=true, const bool& CheckIdStr=true){
if (IsVarIndent){PutIndent(VarIndentLev);}
PutIdStr(VarNm, CheckIdStr); PutSym(syColon); PutQStr(Str);
if (NewLn){PutLn();}}
void PutVarSecTm(const TStr& VarNm, const TSecTm& SecTm,
const bool& NewLn=true, const bool& CheckIdStr=true){
if (IsVarIndent){PutIndent(VarIndentLev);}
PutIdStr(VarNm, CheckIdStr); PutSym(syColon); SecTm.SaveTxt(*this);
if (NewLn){PutLn();}}
void PutVarBoolV(const TStr& VarNm, const TBoolV& BoolV,
const bool& NewLn=true, const bool& CheckIdStr=true);
void PutVarIntV(const TStr& VarNm, const TIntV& IntV,
const bool& NewLn=true, const bool& CheckIdStr=true);
void PutVarFltV(const TStr& VarNm, const TFltV& FltV,
const bool& NewLn=true, const bool& CheckIdStr=true);
void PutVarStrV(const TStr& VarNm, const TStrV& StrV,
const bool& NewLn=true, const bool& CheckIdStr=true);
void PutVarStrPrV(const TStr& VarNm, const TStrPrV& StrPrV,
const bool& NewLn=true, const bool& CheckIdStr=true);
void PutVarStrVV(const TStr& VarNm, const TVec<TStrV>& StrVV,
const bool& NewLn=true, const bool& CheckIdStr=true);
};
/////////////////////////////////////////////////
// Preprocessor
class TPreproc{
private:
PSIn SIn;
TStrV SubstKeyIdV;
char PrevCh, Ch;
THash<TStr, TStrPrV> SubstIdToKeyIdValPrVH;
char GetCh();
bool IsSubstId(const TStr& SubstId, TStr& SubstValStr) const;
UndefDefaultCopyAssign(TPreproc);
public:
TPreproc(const TStr& InFNm, const TStr& OutFNm,
const TStr& SubstFNm, const TStrV& _SubstKeyIdV);
static void Execute(const TStr& InFNm, const TStr& OutFNm,
const TStr& InSubstFNm, const TStrV& SubstKeyIdV){
TPreproc Preproc(InFNm, OutFNm, InSubstFNm, SubstKeyIdV);}
};
/* Sample Subst-File
<SubstList>
<Subst Id="TId">
<Str Key="MSSQL">TId</Str>
<Str Key="Oracle">NUMBER(15) NOT NULL</Str>
</Subst>
<Subst Id="TStr2NN">
<Str Key="MSSQL">TStr2NN</Str>
<Str Key="Oracle">VARCHAR2(2) NOT NULL</Str>
</Subst>
</SubstList>
*/
#endif
| [
"[email protected]"
]
| [
[
[
1,
399
]
]
]
|
73b92039e4c13bc2bae589762fdf581168305bce | 95a3e8914ddc6be5098ff5bc380305f3c5bcecb2 | /src/Tests/TestBaseEntity.h | 591796c933218be190df6bc075e3638380b48712 | []
| no_license | danishcake/FusionForever | 8fc3b1a33ac47177666e6ada9d9d19df9fc13784 | 186d1426fe6b3732a49dfc8b60eb946d62aa0e3b | refs/heads/master | 2016-09-05T16:16:02.040635 | 2010-04-24T11:05:10 | 2010-04-24T11:05:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 217 | h | #pragma once
#include <list>
#include "BaseEntity.h"
class TestBaseEntity :
public BaseEntity
{
public:
TestBaseEntity(void);
virtual ~TestBaseEntity(void);
virtual void InitialiseGraphics() {}
};
| [
"Edward Woolhouse@e6f1df29-e57c-d74d-9e6e-27e3b006b1a7"
]
| [
[
[
1,
13
]
]
]
|
6e2813ac20eb85a2cbed30a4a0a102ee548f311c | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/os/ossrv/stdlibs/apps/libc/testwideapis/inc/twideapis.h | 4cdccec67fda23fecfda391ef659e4c9f7d338c1 | []
| no_license | SymbianSource/oss.FCL.sftools.ana.compatanamdw | a6a8abf9ef7ad71021d43b7f2b2076b504d4445e | 1169475bbf82ebb763de36686d144336fcf9d93b | refs/heads/master | 2020-12-24T12:29:44.646072 | 2010-11-11T14:03:20 | 2010-11-11T14:03:20 | 72,994,432 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,085 | 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:
*
*/
#ifndef TWIDEAPIS_H
#define TWIDEAPIS_H
// INCLUDES
#include <test/TestExecuteStepBase.h>
#include <e32svr.h>
#include <wchar.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <sys\stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <utime.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <sys/uio.h>
#include <sys/syslimits.h>
_LIT(Kwfreopen_val, "wfreopen_val");
_LIT(Kwfreopen_valm, "wfreopen_valm");
_LIT(Kwfreopen_valinv, "wfreopen_valinv");
_LIT(Kwfdopen_val, "wfdopen_val");
_LIT(Kwfdopen_ivalm, "wfdopen_ivalm");
_LIT(Kgetws_val, "getws_val");
_LIT(Kgetws_null, "getws_null");
_LIT(Kputws_val1, "putws_val1");
_LIT(Kputws_val2, "putws_val2");
_LIT(Kputws_null, "putws_null");
_LIT(Kwremove_val1, "wremove_val1");
_LIT(Kwremove_val2, "wremove_val2");
_LIT(Kwremove_val3, "wremove_val3");
_LIT(Kwremove_null, "wremove_null");
_LIT(Kwfdopen_ivalm1, "wfdopen_ivalm1");
_LIT(Kwpopen_1, "wpopen_1");
class CTestWideApi : public CTestStep
{
public:
~CTestWideApi();
CTestWideApi(const TDesC& aStepName);
TVerdict doTestStepL();
TVerdict doTestStepPreambleL();
TVerdict doTestStepPostambleL();
protected:
TInt wfreopen_val();
TInt wfreopen_valm();
TInt wfreopen_valinv();
TInt wfdopen_val();
TInt wfdopen_ivalm();
TInt getws_val();
TInt getws_null();
TInt putws_val1();
TInt putws_val2();
TInt putws_null();
TInt wremove_val1();
TInt wremove_val2();
TInt wremove_val3();
TInt wremove_null();
TInt wfdopen_ivalm1();
TInt wpopen_1();
};
#endif //TWIDEAPIS_H
| [
"none@none"
]
| [
[
[
1,
88
]
]
]
|
da23c54772f735b4410bc2d7f2a47f070adebbaa | 5369484c0feeaacfc6ab319bd31f0810dc5a5f17 | /inc/CBall.h | 78a329b4286019f18c82badcbf176f92045af7ed | []
| no_license | rroc/rtdof | 0cd8c46e11d6d6c0ac2fdbe580f4c54ee738008c | 094546ae001bbd250adaff53ca9f22d64493d990 | refs/heads/master | 2021-03-12T20:45:13.757699 | 2007-06-24T18:57:55 | 2007-06-24T18:57:55 | 34,713,465 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 638 | h | #ifndef CBALL_H
#define CBALL_H
#include "Basic.h"
#include "TTriangle.h"
#include "TVector3.h"
#include "TMatrix4.h"
#include "CMesh.h"
/** \brief Class that defines a ball
*
* Class that defines a ball
* data is entered into
* - vertices
* - triangles
* - faceVisibility (true)
*
* These are inherited from the CMesh object.
*
*
*/
class CBall : public CMesh
{
public:
CBall();
CBall( int aRowSize );
CBall( int aRowSize, float aScale );
~CBall();
void randomColors(); //virtual function
private:
void init( int aRowSize, float aScale );
private:
int iRowSize;
};
#endif
| [
"wfrishert@ca3e50fa-a833-0410-acf5-ede8d4831469"
]
| [
[
[
1,
39
]
]
]
|
add032fa14e03b5af158227ddf3faabd574e71ac | 672d6cf9be825165e485e5310600993c0ef959d7 | /dev/CDODWeaponInfo.h | 6b2b2e78cff4f1aa70ef801946bfbba05475cfbd | []
| no_license | awstanley/ctx-hg-tmp | 6fbcc94b7086a627c0ae9567c0868f4b19578349 | 3645e20e2797268b10c481394cd3b77b474355f9 | refs/heads/master | 2020-11-24T17:43:18.704308 | 2011-07-07T06:13:21 | 2011-07-07T06:13:21 | 228,278,049 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,261 | h | /*
* ================================================================================
* SourceMod Weapon Patcher Extension
* Copyright (C) 2010 A.W. 'Swixel' Stanley. All rights reserved.
*
* Special thanks to Paul 'Wazz' Clothier for exposing the ability to patch
* precached CTX weapon data.
* ================================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, 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 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 _INCLUDE_CDODPlayerClassInfo_H
#define _INCLUDE_CDODPlayerClassInfo_H
#include <utldict.h>
// Do not trust Valve.
class DODS_FileWeaponInfo_t
{
public :
void *vtable; // +0 - yay \O/
bool m_bInitialised; // +4 - Have we initialised this?
char DO_NOT_USE[1]; // +5 - I hate you Valve.
char m_achClassname[80]; // +6 - Classname
char m_achPrintname[80]; // +86 - Print name
char m_achViewModel[80]; // +166 - View Model
char m_achPlayerModel[80]; // +246 - Player Model
char m_achAnimPrefix[80]; // +326 - Animation Prefix
int m_nBucket; // +344 - Bucket
int m_nBucketPosition; // +348 - Bucket Position
int m_nClipSize1; // +352 - Clip Size #1
int m_nClipSize2; // +356 - Clip Size #2
int m_nDefaultClip1; // +360 - Default Clip #1
int m_nDefaultClip2; // +364 - Default Clip #2
int m_nWeight; // +368 - Weight
int m_nRumble; // +372 - Rumble
bool m_bAutoSwitchTo; // +376 - Auto Switch To Weapon
bool m_bAutoSwitchFrom; // +377 - Auto Switch From Weapon
int m_nItemFlags; // +380 - Item Flags
char m_achPrimaryAmmoType[32]; // +384 - Primary Ammo Type
char m_achSecondaryAmmoType[32]; // +416 - Secondary Ammo Type
char m_achSoundData[16]; // +448 - Sound Data
int m_nDefaultPrimaryAmmo; // +1732 - Default Primary Ammo
int m_nDefaultSecondaryAmmo; // +1732 - Default Secondary Ammo
bool m_bMeleeWeapon; // +1736 - Is it a Melee Weapon?
bool m_bBuildRightHanded; // +1737 - Is Right Handed
bool m_bAllowFlipping; // +1738 - Allow Flipping
char DO_NOT_USE[41]; // +1739 - I hate you Valve.
bool m_bShowUsageHint; // +1780 - Show Usage Hint
};
class CDODWeaponInfo :
public DODS_FileWeaponInfo_t // +0
{
public :
int m_nPrimaryDamage; // +1784 - Primary Projectile Damage
float m_fPenetration; // +1788 - .
bool m_bBulletsPerShot; // +1792 - .
float m_fMuzzleFlashType; // +1796 - .
float m_fMuzzleFlashScale; // +1800 - .
bool m_bCanDrop; // +1804 - .
float m_fRecoil; // +1808 - .
char DO_NOT_USE[8]; // +1812 - Why me?
float m_fAccuracy; // +1820 - .
float m_fUnknown1; // +1824 - Secondary related, unknown. Probably related to accuracy.
float m_fAccuracyMovePenalty; // +1828 - .
float m_fFireDelay; // +1832 - .
float m_fUnkown2; // +1836 - Likely to be delay related, something to do with 'SECONDARY'
int m_nCrosshairMinDistance; // +1840 - .
int m_nCrosshairDeltaDistance; // +1844 - .
int m_nWeaponType; // +1848 - .
// 1 - Melee
// 2 - Grenade
// 8 Pistol
// 16 Rifle
// 32 sniper
// 64 SMG
// 128 SMGAmmo
// 256 Bazooka
// 512 Bandage
// 1024 Sidearm
// 2048 RifleGrenade
// 4096 Bomb
float m_fBotAudibleRange; // +1852 - .
char m_achReloadModel[80]; // +1856 - .
char m_achDeployedModel[80]; // +1936 - .
char m_achProneModel[80]; // +2016 - .
char m_achIronSightModel[80]; // +2096 - .
float m_fIdleTimeAfterFire; // +2176 - .
float m_fIdleInterval; // +2180 - .
int m_nDefaultAmmoClips; // +2184 - .
int m_nAmmoPickupClips; // +2188 - .
int m_nHudClipHeight; // +2192 - .
int m_nHudClipBaseHeight; // +2196 - .
int m_nHudClipBulletHeight; // +2200 - .
int m_nTracer; // +2204 - .
float m_fViewModelFOV; // +2208 - .
int m_nAltFireAbility; // +2212 - .
float m_fNormalOffset_1; // +2216 - .
float m_fNormalOffset_2; // +2220 - .
float m_fNormalOffset_3; // +2224 - .
float m_fProneOffset_1; // +2228 - .
float m_fProneOffset_2; // +2232 - .
float m_fProneOffset_3; // +2236 - .
float m_fIronSightOffset_1; // +2240 - .
float m_fIronSightOffset_2; // +2244 - .
float m_fIronSightOffset_3; // +2248 - .
int m_nDefaultTeam; // +2252 - .
};
#endif // +_INCLUDE_CDODPlayerClassInfo_H
| [
"[email protected]"
]
| [
[
[
1,
123
]
]
]
|
93bd74757506505e709db71297e6aab077e40b85 | a86ab590320fbbf2c3d8cac5cea9622bef28944b | /src/guicon.cpp | f39411e1461a1c57e12af471e48359def5c42b4f | []
| no_license | wumingbo/itunes-habit | c6318344f8fa9ceded030a7b2bb7cbae36fb9032 | 79670b45ad253ab3f5d2c5c07547844ca49d283b | refs/heads/master | 2021-01-22T15:21:37.165310 | 2010-06-30T06:15:48 | 2010-06-30T06:15:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,673 | cpp | #include "guicon.h"
#include <fcntl.h>
#include <io.h>
#include <windows.h>
#include <iostream>
using namespace std;
// maximum mumber of lines the output console should have
static const WORD MAX_CONSOLE_LINES = 500;
void RedirectIOToConsole()
{
int hConHandle;
long lStdHandle;
CONSOLE_SCREEN_BUFFER_INFO coninfo;
FILE *fp;
// allocate a console for this app
AllocConsole();
// set the screen buffer to be big enough to let us scroll text
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),
&coninfo);
coninfo.dwSize.Y = MAX_CONSOLE_LINES;
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE),
coninfo.dwSize);
// redirect unbuffered STDOUT to the console
lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
fp = _fdopen( hConHandle, "w" );
*stdout = *fp;
setvbuf( stdout, NULL, _IONBF, 0 );
// redirect unbuffered STDIN to the console
lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);
hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
fp = _fdopen( hConHandle, "r" );
*stdin = *fp;
setvbuf( stdin, NULL, _IONBF, 0 );
// redirect unbuffered STDERR to the console
lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
fp = _fdopen( hConHandle, "w" );
*stderr = *fp;
setvbuf( stderr, NULL, _IONBF, 0 );
// make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog
// point to console as well
ios::sync_with_stdio();
}
//End of File
| [
"Colin Diesh@Colin_Dell.(none)",
"[email protected]"
]
| [
[
[
1,
2
],
[
5,
5
],
[
7,
7
]
],
[
[
3,
4
],
[
6,
6
],
[
8,
66
]
]
]
|
f59280d5255226ca2cf7e13cbd18ef63d60f3f77 | c54f5a7cf6de3ed02d2e02cf867470ea48bd9258 | /pyobjc/PyOpenGL-2.0.2.01/src/interface/GL.EXT._histogram.011f.inc | 22c469406d56a27b641aee05f1025b01face5788 | []
| no_license | orestis/pyobjc | 01ad0e731fbbe0413c2f5ac2f3e91016749146c6 | c30bf50ba29cb562d530e71a9d6c3d8ad75aa230 | refs/heads/master | 2021-01-22T06:54:35.401551 | 2009-09-01T09:24:47 | 2009-09-01T09:24:47 | 16,895 | 8 | 5 | null | null | null | null | UTF-8 | C++ | false | false | 54,393 | inc | /* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.23
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
* changes to this file unless you know what you are doing--modify the SWIG
* interface file instead.
* ----------------------------------------------------------------------------- */
#define SWIGPYTHON
#ifndef SWIG_TEMPLATE_DISAMBIGUATOR
# if defined(__SUNPRO_CC)
# define SWIG_TEMPLATE_DISAMBIGUATOR template
# else
# define SWIG_TEMPLATE_DISAMBIGUATOR
# endif
#endif
#include <Python.h>
/***********************************************************************
* common.swg
*
* This file contains generic SWIG runtime support for pointer
* type checking as well as a few commonly used macros to control
* external linkage.
*
* Author : David Beazley ([email protected])
*
* Copyright (c) 1999-2000, The University of Chicago
*
* This file may be freely redistributed without license or fee provided
* this copyright message remains intact.
************************************************************************/
#include <string.h>
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# if !defined(STATIC_LINKED)
# define SWIGEXPORT(a) __declspec(dllexport) a
# else
# define SWIGEXPORT(a) a
# endif
#else
# define SWIGEXPORT(a) a
#endif
#define SWIGRUNTIME(x) static x
#ifndef SWIGINLINE
#if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
# define SWIGINLINE inline
#else
# define SWIGINLINE
#endif
#endif
/* This should only be incremented when either the layout of swig_type_info changes,
or for whatever reason, the runtime changes incompatibly */
#define SWIG_RUNTIME_VERSION "1"
/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
#ifdef SWIG_TYPE_TABLE
#define SWIG_QUOTE_STRING(x) #x
#define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
#define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
#else
#define SWIG_TYPE_TABLE_NAME
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef void *(*swig_converter_func)(void *);
typedef struct swig_type_info *(*swig_dycast_func)(void **);
typedef struct swig_type_info {
const char *name;
swig_converter_func converter;
const char *str;
void *clientdata;
swig_dycast_func dcast;
struct swig_type_info *next;
struct swig_type_info *prev;
} swig_type_info;
static swig_type_info *swig_type_list = 0;
static swig_type_info **swig_type_list_handle = &swig_type_list;
/*
Compare two type names skipping the space characters, therefore
"char*" == "char *" and "Class<int>" == "Class<int >", etc.
Return 0 when the two name types are equivalent, as in
strncmp, but skipping ' '.
*/
static int
SWIG_TypeNameComp(const char *f1, const char *l1,
const char *f2, const char *l2) {
for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
while ((*f1 == ' ') && (f1 != l1)) ++f1;
while ((*f2 == ' ') && (f2 != l2)) ++f2;
if (*f1 != *f2) return *f1 - *f2;
}
return (l1 - f1) - (l2 - f2);
}
/*
Check type equivalence in a name list like <name1>|<name2>|...
*/
static int
SWIG_TypeEquiv(const char *nb, const char *tb) {
int equiv = 0;
const char* te = tb + strlen(tb);
const char* ne = nb;
while (!equiv && *ne) {
for (nb = ne; *ne; ++ne) {
if (*ne == '|') break;
}
equiv = SWIG_TypeNameComp(nb, ne, tb, te) == 0;
if (*ne) ++ne;
}
return equiv;
}
/* Register a type mapping with the type-checking */
static swig_type_info *
SWIG_TypeRegister(swig_type_info *ti) {
swig_type_info *tc, *head, *ret, *next;
/* Check to see if this type has already been registered */
tc = *swig_type_list_handle;
while (tc) {
/* check simple type equivalence */
int typeequiv = (strcmp(tc->name, ti->name) == 0);
/* check full type equivalence, resolving typedefs */
if (!typeequiv) {
/* only if tc is not a typedef (no '|' on it) */
if (tc->str && ti->str && !strstr(tc->str,"|")) {
typeequiv = SWIG_TypeEquiv(ti->str,tc->str);
}
}
if (typeequiv) {
/* Already exists in the table. Just add additional types to the list */
if (ti->clientdata) tc->clientdata = ti->clientdata;
head = tc;
next = tc->next;
goto l1;
}
tc = tc->prev;
}
head = ti;
next = 0;
/* Place in list */
ti->prev = *swig_type_list_handle;
*swig_type_list_handle = ti;
/* Build linked lists */
l1:
ret = head;
tc = ti + 1;
/* Patch up the rest of the links */
while (tc->name) {
head->next = tc;
tc->prev = head;
head = tc;
tc++;
}
if (next) next->prev = head;
head->next = next;
return ret;
}
/* Check the typename */
static swig_type_info *
SWIG_TypeCheck(char *c, swig_type_info *ty) {
swig_type_info *s;
if (!ty) return 0; /* Void pointer */
s = ty->next; /* First element always just a name */
do {
if (strcmp(s->name,c) == 0) {
if (s == ty->next) return s;
/* Move s to the top of the linked list */
s->prev->next = s->next;
if (s->next) {
s->next->prev = s->prev;
}
/* Insert s as second element in the list */
s->next = ty->next;
if (ty->next) ty->next->prev = s;
ty->next = s;
s->prev = ty;
return s;
}
s = s->next;
} while (s && (s != ty->next));
return 0;
}
/* Cast a pointer up an inheritance hierarchy */
static SWIGINLINE void *
SWIG_TypeCast(swig_type_info *ty, void *ptr) {
if ((!ty) || (!ty->converter)) return ptr;
return (*ty->converter)(ptr);
}
/* Dynamic pointer casting. Down an inheritance hierarchy */
static swig_type_info *
SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
swig_type_info *lastty = ty;
if (!ty || !ty->dcast) return ty;
while (ty && (ty->dcast)) {
ty = (*ty->dcast)(ptr);
if (ty) lastty = ty;
}
return lastty;
}
/* Return the name associated with this type */
static SWIGINLINE const char *
SWIG_TypeName(const swig_type_info *ty) {
return ty->name;
}
/* Return the pretty name associated with this type,
that is an unmangled type name in a form presentable to the user.
*/
static const char *
SWIG_TypePrettyName(const swig_type_info *type) {
/* The "str" field contains the equivalent pretty names of the
type, separated by vertical-bar characters. We choose
to print the last name, as it is often (?) the most
specific. */
if (type->str != NULL) {
const char *last_name = type->str;
const char *s;
for (s = type->str; *s; s++)
if (*s == '|') last_name = s+1;
return last_name;
}
else
return type->name;
}
/* Search for a swig_type_info structure */
static swig_type_info *
SWIG_TypeQuery(const char *name) {
swig_type_info *ty = *swig_type_list_handle;
while (ty) {
if (ty->str && (SWIG_TypeEquiv(ty->str,name))) return ty;
if (ty->name && (strcmp(name,ty->name) == 0)) return ty;
ty = ty->prev;
}
return 0;
}
/* Set the clientdata field for a type */
static void
SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
swig_type_info *tc, *equiv;
if (ti->clientdata) return;
/* if (ti->clientdata == clientdata) return; */
ti->clientdata = clientdata;
equiv = ti->next;
while (equiv) {
if (!equiv->converter) {
tc = *swig_type_list_handle;
while (tc) {
if ((strcmp(tc->name, equiv->name) == 0))
SWIG_TypeClientData(tc,clientdata);
tc = tc->prev;
}
}
equiv = equiv->next;
}
}
/* Pack binary data into a string */
static char *
SWIG_PackData(char *c, void *ptr, size_t sz) {
static char hex[17] = "0123456789abcdef";
unsigned char *u = (unsigned char *) ptr;
const unsigned char *eu = u + sz;
register unsigned char uu;
for (; u != eu; ++u) {
uu = *u;
*(c++) = hex[(uu & 0xf0) >> 4];
*(c++) = hex[uu & 0xf];
}
return c;
}
/* Unpack binary data from a string */
static char *
SWIG_UnpackData(char *c, void *ptr, size_t sz) {
register unsigned char uu = 0;
register int d;
unsigned char *u = (unsigned char *) ptr;
const unsigned char *eu = u + sz;
for (; u != eu; ++u) {
d = *(c++);
if ((d >= '0') && (d <= '9'))
uu = ((d - '0') << 4);
else if ((d >= 'a') && (d <= 'f'))
uu = ((d - ('a'-10)) << 4);
d = *(c++);
if ((d >= '0') && (d <= '9'))
uu |= (d - '0');
else if ((d >= 'a') && (d <= 'f'))
uu |= (d - ('a'-10));
*u = uu;
}
return c;
}
/* This function will propagate the clientdata field of type to
* any new swig_type_info structures that have been added into the list
* of equivalent types. It is like calling
* SWIG_TypeClientData(type, clientdata) a second time.
*/
static void
SWIG_PropagateClientData(swig_type_info *type) {
swig_type_info *equiv = type->next;
swig_type_info *tc;
if (!type->clientdata) return;
while (equiv) {
if (!equiv->converter) {
tc = *swig_type_list_handle;
while (tc) {
if ((strcmp(tc->name, equiv->name) == 0) && !tc->clientdata)
SWIG_TypeClientData(tc, type->clientdata);
tc = tc->prev;
}
}
equiv = equiv->next;
}
}
#ifdef __cplusplus
}
#endif
/* -----------------------------------------------------------------------------
* SWIG API. Portion that goes into the runtime
* ----------------------------------------------------------------------------- */
#ifdef __cplusplus
extern "C" {
#endif
/* -----------------------------------------------------------------------------
* for internal method declarations
* ----------------------------------------------------------------------------- */
#ifndef SWIGINTERN
#define SWIGINTERN static
#endif
#ifndef SWIGINTERNSHORT
#ifdef __cplusplus
#define SWIGINTERNSHORT static inline
#else /* C case */
#define SWIGINTERNSHORT static
#endif /* __cplusplus */
#endif
/* Common SWIG API */
#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Python_ConvertPtr(obj, pp, type, flags)
#define SWIG_NewPointerObj(p, type, flags) SWIG_Python_NewPointerObj(p, type, flags)
#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags)
/* Python-specific SWIG API */
#define SWIG_newvarlink() SWIG_Python_newvarlink()
#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr)
#define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags)
#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants)
/*
Exception handling in wrappers
*/
#define SWIG_fail goto fail
#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg)
#define SWIG_append_errmsg(msg) SWIG_Python_AddErrMesg(msg,0)
#define SWIG_preppend_errmsg(msg) SWIG_Python_AddErrMesg(msg,1)
#define SWIG_type_error(type,obj) SWIG_Python_TypeError(type,obj)
#define SWIG_null_ref(type) SWIG_Python_NullRef(type)
/*
Contract support
*/
#define SWIG_contract_assert(expr, msg) \
if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg ); goto fail; } else
/* -----------------------------------------------------------------------------
* Constant declarations
* ----------------------------------------------------------------------------- */
/* Constant Types */
#define SWIG_PY_INT 1
#define SWIG_PY_FLOAT 2
#define SWIG_PY_STRING 3
#define SWIG_PY_POINTER 4
#define SWIG_PY_BINARY 5
/* Constant information structure */
typedef struct swig_const_info {
int type;
char *name;
long lvalue;
double dvalue;
void *pvalue;
swig_type_info **ptype;
} swig_const_info;
/* -----------------------------------------------------------------------------
* Pointer declarations
* ----------------------------------------------------------------------------- */
/*
Use SWIG_NO_COBJECT_TYPES to force the use of strings to represent
C/C++ pointers in the python side. Very useful for debugging, but
not always safe.
*/
#if !defined(SWIG_NO_COBJECT_TYPES) && !defined(SWIG_COBJECT_TYPES)
# define SWIG_COBJECT_TYPES
#endif
/* Flags for pointer conversion */
#define SWIG_POINTER_EXCEPTION 0x1
#define SWIG_POINTER_DISOWN 0x2
/* -----------------------------------------------------------------------------
* Alloc. memory flags
* ----------------------------------------------------------------------------- */
#define SWIG_OLDOBJ 1
#define SWIG_NEWOBJ SWIG_OLDOBJ + 1
#define SWIG_PYSTR SWIG_NEWOBJ + 1
#ifdef __cplusplus
}
#endif
/***********************************************************************
* pyrun.swg
*
* This file contains the runtime support for Python modules
* and includes code for managing global variables and pointer
* type checking.
*
* Author : David Beazley ([email protected])
************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/* -----------------------------------------------------------------------------
* global variable support code.
* ----------------------------------------------------------------------------- */
typedef struct swig_globalvar {
char *name; /* Name of global variable */
PyObject *(*get_attr)(); /* Return the current value */
int (*set_attr)(PyObject *); /* Set the value */
struct swig_globalvar *next;
} swig_globalvar;
typedef struct swig_varlinkobject {
PyObject_HEAD
swig_globalvar *vars;
} swig_varlinkobject;
static PyObject *
swig_varlink_repr(swig_varlinkobject *v) {
v = v;
return PyString_FromString("<Global variables>");
}
static int
swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) {
swig_globalvar *var;
flags = flags;
fprintf(fp,"Global variables { ");
for (var = v->vars; var; var=var->next) {
fprintf(fp,"%s", var->name);
if (var->next) fprintf(fp,", ");
}
fprintf(fp," }\n");
return 0;
}
static PyObject *
swig_varlink_getattr(swig_varlinkobject *v, char *n) {
swig_globalvar *var = v->vars;
while (var) {
if (strcmp(var->name,n) == 0) {
return (*var->get_attr)();
}
var = var->next;
}
PyErr_SetString(PyExc_NameError,"Unknown C global variable");
return NULL;
}
static int
swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
swig_globalvar *var = v->vars;
while (var) {
if (strcmp(var->name,n) == 0) {
return (*var->set_attr)(p);
}
var = var->next;
}
PyErr_SetString(PyExc_NameError,"Unknown C global variable");
return 1;
}
static PyTypeObject varlinktype = {
PyObject_HEAD_INIT(0)
0, /* Number of items in variable part (ob_size) */
(char *)"swigvarlink", /* Type name (tp_name) */
sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */
0, /* Itemsize (tp_itemsize) */
0, /* Deallocator (tp_dealloc) */
(printfunc) swig_varlink_print, /* Print (tp_print) */
(getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */
(setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */
0, /* tp_compare */
(reprfunc) swig_varlink_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
0, /* tp_flags */
0, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
#if PY_VERSION_HEX >= 0x02020000
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
0, /* tp_new */
0, /* tp_free */
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_subclasses */
0, /* tp_weaklist */
#endif
#if PY_VERSION_HEX >= 0x02030000
0, /* tp_del */
#endif
#ifdef COUNT_ALLOCS
/* these must be last */
0, /* tp_alloc */
0, /* tp_free */
0, /* tp_maxalloc */
0, /* tp_next */
#endif
};
/* Create a variable linking object for use later */
static PyObject *
SWIG_Python_newvarlink(void) {
swig_varlinkobject *result = 0;
result = PyMem_NEW(swig_varlinkobject,1);
varlinktype.ob_type = &PyType_Type; /* Patch varlinktype into a PyType */
result->ob_type = &varlinktype;
result->vars = 0;
result->ob_refcnt = 0;
Py_XINCREF((PyObject *) result);
return ((PyObject*) result);
}
static void
SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
swig_varlinkobject *v;
swig_globalvar *gv;
v= (swig_varlinkobject *) p;
gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
gv->name = (char *) malloc(strlen(name)+1);
strcpy(gv->name,name);
gv->get_attr = get_attr;
gv->set_attr = set_attr;
gv->next = v->vars;
v->vars = gv;
}
/* -----------------------------------------------------------------------------
* errors manipulation
* ----------------------------------------------------------------------------- */
static void
SWIG_Python_TypeError(const char *type, PyObject *obj)
{
if (type) {
if (!PyCObject_Check(obj)) {
const char *otype = (obj ? obj->ob_type->tp_name : 0);
if (otype) {
PyObject *str = PyObject_Str(obj);
const char *cstr = str ? PyString_AsString(str) : 0;
if (cstr) {
PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
type, otype, cstr);
} else {
PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
type, otype);
}
Py_DECREF(str);
return;
}
} else {
const char *otype = (char *) PyCObject_GetDesc(obj);
if (otype) {
PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PyCObject(%s)' is received",
type, otype);
return;
}
}
PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
} else {
PyErr_Format(PyExc_TypeError, "unexpected type is received");
}
}
static SWIGINLINE void
SWIG_Python_NullRef(const char *type)
{
if (type) {
PyErr_Format(PyExc_TypeError, "null reference of type '%s' was received",type);
} else {
PyErr_Format(PyExc_TypeError, "null reference was received");
}
}
static int
SWIG_Python_AddErrMesg(const char* mesg, int infront)
{
if (PyErr_Occurred()) {
PyObject *type = 0;
PyObject *value = 0;
PyObject *traceback = 0;
PyErr_Fetch(&type, &value, &traceback);
if (value) {
PyObject *old_str = PyObject_Str(value);
Py_XINCREF(type);
PyErr_Clear();
if (infront) {
PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str));
} else {
PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
}
Py_DECREF(old_str);
}
return 1;
} else {
return 0;
}
}
static int
SWIG_Python_ArgFail(int argnum)
{
if (PyErr_Occurred()) {
/* add information about failing argument */
char mesg[256];
sprintf(mesg, "argument number %d:", argnum);
return SWIG_Python_AddErrMesg(mesg, 1);
} else {
return 0;
}
}
/* -----------------------------------------------------------------------------
* pointers/data manipulation
* ----------------------------------------------------------------------------- */
/* Convert a pointer value */
static int
SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) {
swig_type_info *tc;
char *c = 0;
static PyObject *SWIG_this = 0;
int newref = 0;
PyObject *pyobj = 0;
void *vptr;
if (!obj) return 0;
if (obj == Py_None) {
*ptr = 0;
return 0;
}
#ifdef SWIG_COBJECT_TYPES
if (!(PyCObject_Check(obj))) {
if (!SWIG_this)
SWIG_this = PyString_FromString("this");
pyobj = obj;
obj = PyObject_GetAttr(obj,SWIG_this);
newref = 1;
if (!obj) goto type_error;
if (!PyCObject_Check(obj)) {
Py_DECREF(obj);
goto type_error;
}
}
vptr = PyCObject_AsVoidPtr(obj);
c = (char *) PyCObject_GetDesc(obj);
if (newref) Py_DECREF(obj);
goto type_check;
#else
if (!(PyString_Check(obj))) {
if (!SWIG_this)
SWIG_this = PyString_FromString("this");
pyobj = obj;
obj = PyObject_GetAttr(obj,SWIG_this);
newref = 1;
if (!obj) goto type_error;
if (!PyString_Check(obj)) {
Py_DECREF(obj);
goto type_error;
}
}
c = PyString_AS_STRING(obj);
/* Pointer values must start with leading underscore */
if (*c != '_') {
if (strcmp(c,"NULL") == 0) {
if (newref) { Py_DECREF(obj); }
*ptr = (void *) 0;
return 0;
} else {
if (newref) { Py_DECREF(obj); }
goto type_error;
}
}
c++;
c = SWIG_UnpackData(c,&vptr,sizeof(void *));
if (newref) { Py_DECREF(obj); }
#endif
type_check:
if (ty) {
tc = SWIG_TypeCheck(c,ty);
if (!tc) goto type_error;
*ptr = SWIG_TypeCast(tc,vptr);
}
if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) {
PyObject_SetAttrString(pyobj,(char*)"thisown",Py_False);
}
return 0;
type_error:
PyErr_Clear();
if (pyobj && !obj) {
obj = pyobj;
if (PyCFunction_Check(obj)) {
/* here we get the method pointer for callbacks */
char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
c = doc ? strstr(doc, "swig_ptr: ") : 0;
if (c) {
c += 10;
if (*c == '_') {
c++;
c = SWIG_UnpackData(c,&vptr,sizeof(void *));
goto type_check;
}
}
}
}
if (flags & SWIG_POINTER_EXCEPTION) {
if (ty) {
SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
} else {
SWIG_Python_TypeError("C/C++ pointer", obj);
}
}
return -1;
}
/* Convert a pointer value, signal an exception on a type mismatch */
static void *
SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) {
void *result;
if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
PyErr_Clear();
if (flags & SWIG_POINTER_EXCEPTION) {
SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
SWIG_Python_ArgFail(argnum);
}
}
return result;
}
/* Convert a packed value value */
static int
SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty, int flags) {
swig_type_info *tc;
char *c = 0;
if ((!obj) || (!PyString_Check(obj))) goto type_error;
c = PyString_AS_STRING(obj);
/* Pointer values must start with leading underscore */
if (*c != '_') goto type_error;
c++;
c = SWIG_UnpackData(c,ptr,sz);
if (ty) {
tc = SWIG_TypeCheck(c,ty);
if (!tc) goto type_error;
}
return 0;
type_error:
PyErr_Clear();
if (flags & SWIG_POINTER_EXCEPTION) {
if (ty) {
SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
} else {
SWIG_Python_TypeError("C/C++ packed data", obj);
}
}
return -1;
}
/* Create a new pointer string */
static char *
SWIG_Python_PointerStr(char *buff, void *ptr, const char *name, size_t bsz) {
char *r = buff;
if ((2*sizeof(void *) + 2) > bsz) return 0;
*(r++) = '_';
r = SWIG_PackData(r,&ptr,sizeof(void *));
if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
strcpy(r,name);
return buff;
}
/* Create a new pointer object */
static PyObject *
SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) {
PyObject *robj;
if (!ptr) {
Py_INCREF(Py_None);
return Py_None;
}
#ifdef SWIG_COBJECT_TYPES
robj = PyCObject_FromVoidPtrAndDesc((void *) ptr, (char *) type->name, NULL);
#else
{
char result[1024];
SWIG_Python_PointerStr(result, ptr, type->name, 1024);
robj = PyString_FromString(result);
}
#endif
if (!robj || (robj == Py_None)) return robj;
if (type->clientdata) {
PyObject *inst;
PyObject *args = Py_BuildValue((char*)"(O)", robj);
Py_DECREF(robj);
inst = PyObject_CallObject((PyObject *) type->clientdata, args);
Py_DECREF(args);
if (inst) {
if (own) {
PyObject_SetAttrString(inst,(char*)"thisown",Py_True);
}
robj = inst;
}
}
return robj;
}
static PyObject *
SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
char result[1024];
char *r = result;
if ((2*sz + 2 + strlen(type->name)) > 1024) return 0;
*(r++) = '_';
r = SWIG_PackData(r,ptr,sz);
strcpy(r,type->name);
return PyString_FromString(result);
}
/* -----------------------------------------------------------------------------
* constants/methods manipulation
* ----------------------------------------------------------------------------- */
/* Install Constants */
static void
SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
int i;
PyObject *obj;
for (i = 0; constants[i].type; i++) {
switch(constants[i].type) {
case SWIG_PY_INT:
obj = PyInt_FromLong(constants[i].lvalue);
break;
case SWIG_PY_FLOAT:
obj = PyFloat_FromDouble(constants[i].dvalue);
break;
case SWIG_PY_STRING:
if (constants[i].pvalue) {
obj = PyString_FromString((char *) constants[i].pvalue);
} else {
Py_INCREF(Py_None);
obj = Py_None;
}
break;
case SWIG_PY_POINTER:
obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
break;
case SWIG_PY_BINARY:
obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
break;
default:
obj = 0;
break;
}
if (obj) {
PyDict_SetItemString(d,constants[i].name,obj);
Py_DECREF(obj);
}
}
}
/* Fix SwigMethods to carry the callback ptrs when needed */
static void
SWIG_Python_FixMethods(PyMethodDef *methods,
swig_const_info *const_table,
swig_type_info **types,
swig_type_info **types_initial) {
int i;
for (i = 0; methods[i].ml_name; ++i) {
char *c = methods[i].ml_doc;
if (c && (c = strstr(c, "swig_ptr: "))) {
int j;
swig_const_info *ci = 0;
char *name = c + 10;
for (j = 0; const_table[j].type; j++) {
if (strncmp(const_table[j].name, name,
strlen(const_table[j].name)) == 0) {
ci = &(const_table[j]);
break;
}
}
if (ci) {
size_t shift = (ci->ptype) - types;
swig_type_info *ty = types_initial[shift];
size_t ldoc = (c - methods[i].ml_doc);
size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
char *ndoc = (char*)malloc(ldoc + lptr + 10);
char *buff = ndoc;
void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue: (void *)(ci->lvalue);
strncpy(buff, methods[i].ml_doc, ldoc);
buff += ldoc;
strncpy(buff, "swig_ptr: ", 10);
buff += 10;
SWIG_Python_PointerStr(buff, ptr, ty->name, lptr);
methods[i].ml_doc = ndoc;
}
}
}
}
/* -----------------------------------------------------------------------------
* Lookup type pointer
* ----------------------------------------------------------------------------- */
#if PY_MAJOR_VERSION < 2
/* PyModule_AddObject function was introduced in Python 2.0. The following function
is copied out of Python/modsupport.c in python version 2.3.4 */
static int
PyModule_AddObject(PyObject *m, char *name, PyObject *o)
{
PyObject *dict;
if (!PyModule_Check(m)) {
PyErr_SetString(PyExc_TypeError,
"PyModule_AddObject() needs module as first arg");
return -1;
}
if (!o) {
PyErr_SetString(PyExc_TypeError,
"PyModule_AddObject() needs non-NULL value");
return -1;
}
dict = PyModule_GetDict(m);
if (dict == NULL) {
/* Internal error -- modules must have a dict! */
PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
PyModule_GetName(m));
return -1;
}
if (PyDict_SetItemString(dict, name, o))
return -1;
Py_DECREF(o);
return 0;
}
#endif
static PyMethodDef swig_empty_runtime_method_table[] = {
{NULL, NULL, 0, NULL} /* Sentinel */
};
static void
SWIG_Python_LookupTypePointer(swig_type_info ***type_list_handle) {
PyObject *module, *pointer;
void *type_pointer;
/* first check if module already created */
type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
if (type_pointer) {
*type_list_handle = (swig_type_info **) type_pointer;
} else {
PyErr_Clear();
/* create a new module and variable */
module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table);
pointer = PyCObject_FromVoidPtr((void *) (*type_list_handle), NULL);
if (pointer && module) {
PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
}
}
}
#ifdef __cplusplus
}
#endif
/* -------- TYPES TABLE (BEGIN) -------- */
#define SWIGTYPE_p_GLsizei swig_types[0]
#define SWIGTYPE_p_GLshort swig_types[1]
#define SWIGTYPE_p_GLboolean swig_types[2]
#define SWIGTYPE_size_t swig_types[3]
#define SWIGTYPE_p_GLushort swig_types[4]
#define SWIGTYPE_p_GLenum swig_types[5]
#define SWIGTYPE_p_GLvoid swig_types[6]
#define SWIGTYPE_p_GLint swig_types[7]
#define SWIGTYPE_p_char swig_types[8]
#define SWIGTYPE_p_GLclampd swig_types[9]
#define SWIGTYPE_p_GLclampf swig_types[10]
#define SWIGTYPE_p_GLuint swig_types[11]
#define SWIGTYPE_ptrdiff_t swig_types[12]
#define SWIGTYPE_p_GLbyte swig_types[13]
#define SWIGTYPE_p_GLbitfield swig_types[14]
#define SWIGTYPE_p_GLfloat swig_types[15]
#define SWIGTYPE_p_GLubyte swig_types[16]
#define SWIGTYPE_p_GLdouble swig_types[17]
static swig_type_info *swig_types[19];
/* -------- TYPES TABLE (END) -------- */
/*-----------------------------------------------
@(target):= _histogram.so
------------------------------------------------*/
#define SWIG_init init_histogram
#define SWIG_name "_histogram"
SWIGINTERN PyObject *
SWIG_FromCharPtr(const char* cptr)
{
if (cptr) {
size_t size = strlen(cptr);
if (size > INT_MAX) {
return SWIG_NewPointerObj((char*)(cptr),
SWIG_TypeQuery("char *"), 0);
} else {
if (size != 0) {
return PyString_FromStringAndSize(cptr, size);
} else {
return PyString_FromString(cptr);
}
}
}
Py_INCREF(Py_None);
return Py_None;
}
/*@C:\\bin\\SWIG-1.3.23\\Lib\\python\\pymacros.swg,66,SWIG_define@*/
#define SWIG_From_int PyInt_FromLong
/*@@*/
/**
*
* GL.EXT.histogram Module for PyOpenGL
*
* Date: October 2001
*
* Authors: Tarn Weisner Burton <[email protected]>
*
***/
GLint PyOpenGL_round(double x) {
if (x >= 0) {
return (GLint) (x+0.5);
} else {
return (GLint) (x-0.5);
}
}
int __PyObject_AsArray_Size(PyObject* x);
#ifdef NUMERIC
#define _PyObject_AsArray_Size(x) ((x == Py_None) ? 0 : ((PyArray_Check(x)) ? PyArray_Size(x) : __PyObject_AsArray_Size(x)))
#else /* NUMERIC */
#define _PyObject_AsArray_Size(x) ((x == Py_None) ? 0 : __PyObject_AsArray_Size(x))
#endif /* NUMERIC */
#define _PyObject_As(NAME, BASE) BASE* _PyObject_As##NAME(PyObject* source, PyObject** temp, int* len);
#define _PyObject_AsArray_Cleanup(target, temp) if (temp) Py_XDECREF(temp); else PyMem_Del(target)
_PyObject_As(FloatArray, float)
_PyObject_As(DoubleArray, double)
_PyObject_As(CharArray, signed char)
_PyObject_As(UnsignedCharArray, unsigned char)
_PyObject_As(ShortArray, short)
_PyObject_As(UnsignedShortArray, unsigned short)
_PyObject_As(IntArray, int)
_PyObject_As(UnsignedIntArray, unsigned int)
void* _PyObject_AsArray(GLenum type, PyObject* source, PyObject** temp, int* len);
#define PyErr_XPrint() if (PyErr_Occurred()) PyErr_Print()
#if HAS_DYNAMIC_EXT
#define DECLARE_EXT(PROC_NAME, RET, ERROR_RET, PROTO, CALL)\
RET PROC_NAME PROTO\
{\
typedef RET (APIENTRY *proc_##PROC_NAME) PROTO;\
proc_##PROC_NAME proc = (proc_##PROC_NAME)GL_GetProcAddress(#PROC_NAME);\
if (proc) return proc CALL;\
PyErr_SetGLErrorMessage( GL_INVALID_OPERATION, "Dynamic function loading not implemented/supported on this platform" );\
return ERROR_RET;\
}
#define DECLARE_VOID_EXT(PROC_NAME, PROTO, CALL)\
void PROC_NAME PROTO\
{\
typedef void (APIENTRY *proc_##PROC_NAME) PROTO;\
proc_##PROC_NAME proc = (proc_##PROC_NAME)GL_GetProcAddress(#PROC_NAME);\
if (proc) proc CALL;\
else {\
PyErr_SetGLErrorMessage( GL_INVALID_OPERATION, "Dynamic function loading not implemented/supported on this platform" );\
}\
}
#else
#define DECLARE_EXT(PROC_NAME, RET, ERROR_RET, PROTO, CALL)\
RET PROC_NAME PROTO\
{\
PyErr_SetGLErrorMessage( GL_INVALID_OPERATION, "Dynamic function loading not implemented/supported on this platform" );\
return ERROR_RET;\
}
#define DECLARE_VOID_EXT(PROC_NAME, PROTO, CALL)\
void PROC_NAME PROTO\
{\
PyErr_SetGLErrorMessage( GL_INVALID_OPERATION, "Dynamic function loading not implemented/supported on this platform" );\
}
#endif
#define _PyTuple_From(NAME, BASE) PyObject* _PyTuple_From##NAME(int len, BASE* data);
_PyTuple_From(UnsignedCharArray, unsigned char)
_PyTuple_From(CharArray, signed char)
_PyTuple_From(UnsignedShortArray, unsigned short)
_PyTuple_From(ShortArray, short)
_PyTuple_From(UnsignedIntArray, unsigned int)
_PyTuple_From(IntArray, int)
_PyTuple_From(FloatArray, float)
_PyTuple_From(DoubleArray, double)
#define _PyObject_From(NAME, BASE) PyObject* _PyObject_From##NAME(int nd, int* dims, BASE* data, int own);
_PyObject_From(UnsignedCharArray, unsigned char)
_PyObject_From(CharArray, signed char)
_PyObject_From(UnsignedShortArray, unsigned short)
_PyObject_From(ShortArray, short)
_PyObject_From(UnsignedIntArray, unsigned int)
_PyObject_From(IntArray, int)
_PyObject_From(FloatArray, float)
_PyObject_From(DoubleArray, double)
PyObject* _PyObject_FromArray(GLenum type, int nd, int *dims, void* data, int own);
void* SetupPixelRead(int rank, GLenum format, GLenum type, int *dims);
void SetupPixelWrite(int rank);
void* SetupRawPixelRead(GLenum format, GLenum type, int n, const int *dims, int* size);
void* _PyObject_AsPointer(PyObject* x);
/* The following line causes a warning on linux and cygwin
The function is defined in interface_utils.c, which is
linked to each extension module. For some reason, though,
this declaration doesn't get recognised as a declaration
prototype for that function.
*/
void init_util();
typedef void *PTR;
typedef struct
{
void (*_decrement)(void* pointer);
void (*_decrementPointer)(GLenum pname);
int (*_incrementLock)(void *pointer);
int (*_incrementPointerLock)(GLenum pname);
void (*_acquire)(void* pointer);
void (*_acquirePointer)(GLenum pname);
#if HAS_DYNAMIC_EXT
PTR (*GL_GetProcAddress)(const char* name);
#endif
int (*InitExtension)(const char *name, const char** procs);
PyObject *_GLerror;
PyObject *_GLUerror;
} util_API;
static util_API *_util_API = NULL;
#define decrementLock(x) (*_util_API)._decrement(x)
#define decrementPointerLock(x) (*_util_API)._decrementPointer(x)
#define incrementLock(x) (*_util_API)._incrementLock(x)
#define incrementPointerLock(x) (*_util_API)._incrementPointerLock(x)
#define acquire(x) (*_util_API)._acquire(x)
#define acquirePointer(x) (*_util_API)._acquirePointer(x)
#define GLerror (*_util_API)._GLerror
#define GLUerror (*_util_API)._GLUerror
#if HAS_DYNAMIC_EXT
#define GL_GetProcAddress(x) (*_util_API).GL_GetProcAddress(x)
#endif
#define InitExtension(x, y) (*_util_API).InitExtension(x, (const char**)y)
#define PyErr_SetGLerror(code) PyErr_SetObject(GLerror, Py_BuildValue("is", code, gluErrorString(code)));
#define PyErr_SetGLUerror(code) PyErr_SetObject(GLUerror, Py_BuildValue("is", code, gluErrorString(code)));
int _PyObject_Dimension(PyObject* x, int rank);
#define ERROR_MSG_SEP ", "
#define ERROR_MSG_SEP_LEN 2
int GLErrOccurred()
{
if (PyErr_Occurred()) return 1;
if (CurrentContextIsValid())
{
GLenum error, *errors = NULL;
char *msg = NULL;
const char *this_msg;
int count = 0;
error = glGetError();
while (error != GL_NO_ERROR)
{
this_msg = gluErrorString(error);
if (count)
{
msg = realloc(msg, (strlen(msg) + strlen(this_msg) + ERROR_MSG_SEP_LEN + 1)*sizeof(char));
strcat(msg, ERROR_MSG_SEP);
strcat(msg, this_msg);
errors = realloc(errors, (count + 1)*sizeof(GLenum));
}
else
{
msg = malloc((strlen(this_msg) + 1)*sizeof(char));
strcpy(msg, this_msg);
errors = malloc(sizeof(GLenum));
}
errors[count++] = error;
error = glGetError();
}
if (count)
{
PyErr_SetObject(GLerror, Py_BuildValue("Os", _PyTuple_FromIntArray(count, (int*)errors), msg));
free(errors);
free(msg);
return 1;
}
}
return 0;
}
void PyErr_SetGLErrorMessage( int id, char * message ) {
/* set a GLerror with an ID and string message
This tries pretty hard to look just like a regular
error as produced by GLErrOccurred()'s formatter,
save that there's only the single error being reported.
Using id 0 is probably best for any future use where
there isn't a good match for the exception description
in the error-enumeration set.
*/
PyObject * args = NULL;
args = Py_BuildValue( "(i)s", id, message );
if (args) {
PyErr_SetObject( GLerror, args );
Py_XDECREF( args );
} else {
PyErr_SetGLerror(id);
}
}
#if !EXT_DEFINES_PROTO || !defined(GL_EXT_histogram)
DECLARE_VOID_EXT(glHistogramEXT,\
(GLenum target, GLsizei width, GLenum internalformat, GLboolean sink),\
(target, width, internalformat, sink))
DECLARE_VOID_EXT(glResetHistogramEXT,\
(GLenum target),\
(target))
DECLARE_VOID_EXT(glGetHistogramEXT,\
(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid* values),\
(target, reset, format, type, values))
DECLARE_VOID_EXT(glGetHistogramParameterivEXT,\
(GLenum target, GLenum pname, GLint* params),\
(target, pname, params))
DECLARE_VOID_EXT(glGetHistogramParameterfvEXT,\
(GLenum target, GLenum pname, GLfloat* params),\
(target, pname, params))
DECLARE_VOID_EXT(glMinmaxEXT,\
(GLenum target, GLenum internalformat, GLboolean sink),\
(target, internalformat, sink))
DECLARE_VOID_EXT(glResetMinmaxEXT,\
(GLenum target),\
(target))
DECLARE_VOID_EXT(glGetMinmaxEXT,\
(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid* values),\
(target, reset, format, type, values))
DECLARE_VOID_EXT(glGetMinmaxParameterivEXT,\
(GLenum target, GLenum pname, GLint* params),\
(target, pname, params))
DECLARE_VOID_EXT(glGetMinmaxParameterfvEXT,\
(GLenum target, GLenum pname, GLfloat* params),\
(target, pname, params))
#endif
#include <limits.h>
SWIGINTERNSHORT int
SWIG_CheckUnsignedLongInRange(unsigned long value,
unsigned long max_value,
const char *errmsg)
{
if (value > max_value) {
if (errmsg) {
PyErr_Format(PyExc_OverflowError,
"value %lu is greater than '%s' minimum %lu",
value, errmsg, max_value);
}
return 0;
}
return 1;
}
SWIGINTERN int
SWIG_AsVal_unsigned_SS_long(PyObject *obj, unsigned long *val)
{
if (PyInt_Check(obj)) {
long v = PyInt_AS_LONG(obj);
if (v >= 0) {
if (val) *val = v;
return 1;
}
}
if (PyLong_Check(obj)) {
unsigned long v = PyLong_AsUnsignedLong(obj);
if (!PyErr_Occurred()) {
if (val) *val = v;
return 1;
} else {
if (!val) PyErr_Clear();
return 0;
}
}
if (val) {
SWIG_type_error("unsigned long", obj);
}
return 0;
}
#if UINT_MAX != ULONG_MAX
SWIGINTERN int
SWIG_AsVal_unsigned_SS_int(PyObject *obj, unsigned int *val)
{
const char* errmsg = val ? "unsigned int" : (char*)0;
unsigned long v;
if (SWIG_AsVal_unsigned_SS_long(obj, &v)) {
if (SWIG_CheckUnsignedLongInRange(v, INT_MAX, errmsg)) {
if (val) *val = (unsigned int)(v);
return 1;
}
} else {
PyErr_Clear();
}
if (val) {
SWIG_type_error(errmsg, obj);
}
return 0;
}
#else
SWIGINTERNSHORT unsigned int
SWIG_AsVal_unsigned_SS_int(PyObject *obj, unsigned int *val)
{
return SWIG_AsVal_unsigned_SS_long(obj,(unsigned long *)val);
}
#endif
SWIGINTERNSHORT unsigned int
SWIG_As_unsigned_SS_int(PyObject* obj)
{
unsigned int v;
if (!SWIG_AsVal_unsigned_SS_int(obj, &v)) {
/*
this is needed to make valgrind/purify happier.
*/
memset((void*)&v, 0, sizeof(unsigned int));
}
return v;
}
SWIGINTERNSHORT int
SWIG_Check_unsigned_SS_int(PyObject* obj)
{
return SWIG_AsVal_unsigned_SS_int(obj, (unsigned int*)0);
}
static char _doc_glResetHistogramEXT[] = "glResetHistogramEXT(target) -> None";
static char *proc_names[] =
{
#if !EXT_DEFINES_PROTO || !defined(GL_EXT_histogram)
"glHistogramEXT",
"glResetHistogramEXT",
"glGetHistogramEXT",
"glGetHistogramParameterivEXT",
"glGetHistogramParameterfvEXT",
"glMinmaxEXT",
"glResetMinmaxEXT",
"glGetMinmaxEXT",
"glGetMinmaxParameterivEXT",
"glGetMinmaxParameterfvEXT",
#endif
NULL
};
#define glInitHistogramEXT() InitExtension("GL_EXT_histogram", proc_names)
static char _doc_glInitHistogramEXT[] = "glInitHistogramEXT() -> bool";
PyObject *__info()
{
if (glInitHistogramEXT())
{
PyObject *info = PyList_New(0);
return info;
}
Py_INCREF(Py_None);
return Py_None;
}
#ifdef __cplusplus
extern "C" {
#endif
static PyObject *_wrap_glResetHistogramEXT(PyObject *self, PyObject *args) {
PyObject *resultobj;
GLenum arg1 ;
PyObject * obj0 = 0 ;
if(!PyArg_ParseTuple(args,(char *)"O:glResetHistogramEXT",&obj0)) goto fail;
{
arg1 = (GLenum)(SWIG_As_unsigned_SS_int(obj0));
if (SWIG_arg_fail(1)) SWIG_fail;
}
{
glResetHistogramEXT(arg1);
if (GLErrOccurred()) {
return NULL;
}
}
Py_INCREF(Py_None); resultobj = Py_None;
return resultobj;
fail:
return NULL;
}
static PyObject *_wrap_glInitHistogramEXT(PyObject *self, PyObject *args) {
PyObject *resultobj;
int result;
if(!PyArg_ParseTuple(args,(char *)":glInitHistogramEXT")) goto fail;
{
result = (int)glInitHistogramEXT();
if (GLErrOccurred()) {
return NULL;
}
}
{
resultobj = SWIG_From_int((int)(result));
}
return resultobj;
fail:
return NULL;
}
static PyObject *_wrap___info(PyObject *self, PyObject *args) {
PyObject *resultobj;
PyObject *result;
if(!PyArg_ParseTuple(args,(char *)":__info")) goto fail;
{
result = (PyObject *)__info();
if (GLErrOccurred()) {
return NULL;
}
}
{
resultobj= result;
}
return resultobj;
fail:
return NULL;
}
static PyMethodDef SwigMethods[] = {
{ (char *)"glResetHistogramEXT", _wrap_glResetHistogramEXT, METH_VARARGS, NULL},
{ (char *)"glInitHistogramEXT", _wrap_glInitHistogramEXT, METH_VARARGS, NULL},
{ (char *)"__info", _wrap___info, METH_VARARGS, NULL},
{ NULL, NULL, 0, NULL }
};
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
static swig_type_info _swigt__p_GLsizei[] = {{"_p_GLsizei", 0, "int *|GLsizei *", 0, 0, 0, 0},{"_p_GLint", 0, 0, 0, 0, 0, 0},{"_p_GLsizei", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLshort[] = {{"_p_GLshort", 0, "short *|GLshort *", 0, 0, 0, 0},{"_p_GLshort", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLboolean[] = {{"_p_GLboolean", 0, "unsigned char *|GLboolean *", 0, 0, 0, 0},{"_p_GLboolean", 0, 0, 0, 0, 0, 0},{"_p_GLubyte", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__size_t[] = {{"_size_t", 0, "size_t", 0, 0, 0, 0},{"_size_t", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLushort[] = {{"_p_GLushort", 0, "unsigned short *|GLushort *", 0, 0, 0, 0},{"_p_GLushort", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLenum[] = {{"_p_GLenum", 0, "unsigned int *|GLenum *", 0, 0, 0, 0},{"_p_GLuint", 0, 0, 0, 0, 0, 0},{"_p_GLenum", 0, 0, 0, 0, 0, 0},{"_p_GLbitfield", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLvoid[] = {{"_p_GLvoid", 0, "void *|GLvoid *", 0, 0, 0, 0},{"_p_GLvoid", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLint[] = {{"_p_GLint", 0, "int *|GLint *", 0, 0, 0, 0},{"_p_GLint", 0, 0, 0, 0, 0, 0},{"_p_GLsizei", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_char[] = {{"_p_char", 0, "char *", 0, 0, 0, 0},{"_p_char", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLclampd[] = {{"_p_GLclampd", 0, "double *|GLclampd *", 0, 0, 0, 0},{"_p_GLclampd", 0, 0, 0, 0, 0, 0},{"_p_GLdouble", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLclampf[] = {{"_p_GLclampf", 0, "float *|GLclampf *", 0, 0, 0, 0},{"_p_GLfloat", 0, 0, 0, 0, 0, 0},{"_p_GLclampf", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLuint[] = {{"_p_GLuint", 0, "unsigned int *|GLuint *", 0, 0, 0, 0},{"_p_GLuint", 0, 0, 0, 0, 0, 0},{"_p_GLenum", 0, 0, 0, 0, 0, 0},{"_p_GLbitfield", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__ptrdiff_t[] = {{"_ptrdiff_t", 0, "ptrdiff_t", 0, 0, 0, 0},{"_ptrdiff_t", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLbyte[] = {{"_p_GLbyte", 0, "signed char *|GLbyte *", 0, 0, 0, 0},{"_p_GLbyte", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLbitfield[] = {{"_p_GLbitfield", 0, "unsigned int *|GLbitfield *", 0, 0, 0, 0},{"_p_GLuint", 0, 0, 0, 0, 0, 0},{"_p_GLbitfield", 0, 0, 0, 0, 0, 0},{"_p_GLenum", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLfloat[] = {{"_p_GLfloat", 0, "float *|GLfloat *", 0, 0, 0, 0},{"_p_GLfloat", 0, 0, 0, 0, 0, 0},{"_p_GLclampf", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLubyte[] = {{"_p_GLubyte", 0, "unsigned char *|GLubyte *", 0, 0, 0, 0},{"_p_GLboolean", 0, 0, 0, 0, 0, 0},{"_p_GLubyte", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info _swigt__p_GLdouble[] = {{"_p_GLdouble", 0, "double *|GLdouble *", 0, 0, 0, 0},{"_p_GLclampd", 0, 0, 0, 0, 0, 0},{"_p_GLdouble", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
static swig_type_info *swig_types_initial[] = {
_swigt__p_GLsizei,
_swigt__p_GLshort,
_swigt__p_GLboolean,
_swigt__size_t,
_swigt__p_GLushort,
_swigt__p_GLenum,
_swigt__p_GLvoid,
_swigt__p_GLint,
_swigt__p_char,
_swigt__p_GLclampd,
_swigt__p_GLclampf,
_swigt__p_GLuint,
_swigt__ptrdiff_t,
_swigt__p_GLbyte,
_swigt__p_GLbitfield,
_swigt__p_GLfloat,
_swigt__p_GLubyte,
_swigt__p_GLdouble,
0
};
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
static swig_const_info swig_const_table[] = {
{ SWIG_PY_POINTER, (char*)"__version__", 0, 0, (void *)"1.1.6.1", &SWIGTYPE_p_char},
{ SWIG_PY_POINTER, (char*)"__date__", 0, 0, (void *)"2004/11/14 23:19:04", &SWIGTYPE_p_char},
{ SWIG_PY_POINTER, (char*)"__author__", 0, 0, (void *)"Tarn Weisner Burton <[email protected]>", &SWIGTYPE_p_char},
{ SWIG_PY_POINTER, (char*)"__doc__", 0, 0, (void *)"http://oss.sgi.com/projects/ogl-sample/registry/EXT/histogram.txt", &SWIGTYPE_p_char},
{0, 0, 0, 0.0, 0, 0}};
#ifdef __cplusplus
}
#endif
#ifdef SWIG_LINK_RUNTIME
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# if defined(_MSC_VER) || defined(__GNUC__)
# define SWIGIMPORT(a) extern a
# else
# if defined(__BORLANDC__)
# define SWIGIMPORT(a) a _export
# else
# define SWIGIMPORT(a) a
# endif
# endif
#else
# define SWIGIMPORT(a) a
#endif
#ifdef __cplusplus
extern "C"
#endif
SWIGEXPORT(void *) SWIG_ReturnGlobalTypeList(void *);
#endif
#ifdef __cplusplus
extern "C"
#endif
SWIGEXPORT(void) SWIG_init(void) {
static PyObject *SWIG_globals = 0;
static int typeinit = 0;
PyObject *m, *d;
int i;
if (!SWIG_globals) SWIG_globals = SWIG_newvarlink();
/* Fix SwigMethods to carry the callback ptrs when needed */
SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_types_initial);
m = Py_InitModule((char *) SWIG_name, SwigMethods);
d = PyModule_GetDict(m);
if (!typeinit) {
#ifdef SWIG_LINK_RUNTIME
swig_type_list_handle = (swig_type_info **) SWIG_ReturnGlobalTypeList(swig_type_list_handle);
#else
# ifndef SWIG_STATIC_RUNTIME
SWIG_Python_LookupTypePointer(&swig_type_list_handle);
# endif
#endif
for (i = 0; swig_types_initial[i]; i++) {
swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
}
typeinit = 1;
}
SWIG_InstallConstants(d,swig_const_table);
PyDict_SetItemString(d,"__version__", SWIG_FromCharPtr("1.1.6.1"));
PyDict_SetItemString(d,"__date__", SWIG_FromCharPtr("2004/11/14 23:19:04"));
{
PyDict_SetItemString(d,"__api_version__", SWIG_From_int((int)(287)));
}
PyDict_SetItemString(d,"__author__", SWIG_FromCharPtr("Tarn Weisner Burton <[email protected]>"));
PyDict_SetItemString(d,"__doc__", SWIG_FromCharPtr("http://oss.sgi.com/projects/ogl-sample/registry/EXT/histogram.txt"));
#ifdef NUMERIC
PyArray_API = NULL;
import_array();
init_util();
PyErr_Clear();
#endif
{
PyObject *util = PyImport_ImportModule("OpenGL.GL._GL__init__");
if (util)
{
PyObject *api_object = PyDict_GetItemString(PyModule_GetDict(util), "_util_API");
if (PyCObject_Check(api_object)) _util_API = (util_API*)PyCObject_AsVoidPtr(api_object);
}
}
{
PyDict_SetItemString(d,"GL_HISTOGRAM_EXT", SWIG_From_int((int)(0x8024)));
}
{
PyDict_SetItemString(d,"GL_PROXY_HISTOGRAM_EXT", SWIG_From_int((int)(0x8025)));
}
{
PyDict_SetItemString(d,"GL_HISTOGRAM_WIDTH_EXT", SWIG_From_int((int)(0x8026)));
}
{
PyDict_SetItemString(d,"GL_HISTOGRAM_FORMAT_EXT", SWIG_From_int((int)(0x8027)));
}
{
PyDict_SetItemString(d,"GL_HISTOGRAM_RED_SIZE_EXT", SWIG_From_int((int)(0x8028)));
}
{
PyDict_SetItemString(d,"GL_HISTOGRAM_GREEN_SIZE_EXT", SWIG_From_int((int)(0x8029)));
}
{
PyDict_SetItemString(d,"GL_HISTOGRAM_BLUE_SIZE_EXT", SWIG_From_int((int)(0x802A)));
}
{
PyDict_SetItemString(d,"GL_HISTOGRAM_ALPHA_SIZE_EXT", SWIG_From_int((int)(0x802B)));
}
{
PyDict_SetItemString(d,"GL_HISTOGRAM_LUMINANCE_SIZE_EXT", SWIG_From_int((int)(0x802C)));
}
{
PyDict_SetItemString(d,"GL_HISTOGRAM_SINK_EXT", SWIG_From_int((int)(0x802D)));
}
{
PyDict_SetItemString(d,"GL_MINMAX_EXT", SWIG_From_int((int)(0x802E)));
}
{
PyDict_SetItemString(d,"GL_MINMAX_FORMAT_EXT", SWIG_From_int((int)(0x802F)));
}
{
PyDict_SetItemString(d,"GL_MINMAX_SINK_EXT", SWIG_From_int((int)(0x8030)));
}
}
| [
"ronaldoussoren@f55f28a5-9edb-0310-a011-a803cfcd5d25"
]
| [
[
[
1,
1810
]
]
]
|
0e5801b0955cbd9373b4f748b185ef7dd81246c6 | c27c037c99c3c80bf976f9eb2f841488516c640b | /demo/sample_00/csample0application.cpp | 23a13656eb5d47c5ef75773300f381d598075655 | [
"MIT"
]
| permissive | leandronunescorreia/realtimecameras | 7ccfabdaa80bb5e89e19b7b65e9b2d7f97ef6fe7 | f4c3a532d5c5c2747f68dd45cdf3fbf1aebf403f | refs/heads/master | 2016-09-02T01:08:42.182481 | 2009-04-09T08:03:49 | 2009-04-09T08:03:49 | 39,148,159 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,662 | cpp | #include "csample0application.h"
#include "csample0framelistener.h"
//------------------------------------------------------------------------------------------
using namespace rtc;
using namespace Ogre;
//------------------------------------------------------------------------------------------
CSample0Application::CSample0Application()
: CRtcApplication()
, mpFrameListener( NULL )
{
}
//------------------------------------------------------------------------------------------
CSample0Application::~CSample0Application()
{
delete mpFrameListener;
}
//------------------------------------------------------------------------------------------
void CSample0Application::createFrameListener()
{
mpFrameListener= new CSample0FrameListener(*mpSceneMgr, *mpWindow);
mpRoot->addFrameListener(mpFrameListener);
}
//------------------------------------------------------------------------------------------
void CSample0Application::createScene()
{
createFrameListener();
mpSceneMgr->setAmbientLight(ColourValue(0, 0, 0));
mpSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);
Entity *ent = mpSceneMgr->createEntity("Ninja", "ninja.mesh");
ent->setCastShadows(true);
mpSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);
Plane plane(Vector3::UNIT_Y, 0);
MeshManager::getSingleton().createPlane("ground",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
1500,1500,20,20,true,1,5,5,Vector3::UNIT_Z);
ent = mpSceneMgr->createEntity("GroundEntity", "ground");
mpSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);
ent->setMaterialName("Examples/Rockwall");
ent->setCastShadows(false);
Light *light = mpSceneMgr->createLight("Light1");
light->setType(Light::LT_POINT);
light->setPosition(Vector3(0, 150, 250));
light->setDiffuseColour(1.0, 0.0, 0.0);
light->setSpecularColour(1.0, 0.0, 0.0);
light = mpSceneMgr->createLight("Light3");
light->setType(Light::LT_DIRECTIONAL);
light->setDiffuseColour(ColourValue(.25, .25, 0));
light->setSpecularColour(ColourValue(.25, .25, 0));
light->setDirection(Vector3( 0, -1, 1 ));
light = mpSceneMgr->createLight("Light2");
light->setType(Light::LT_SPOTLIGHT);
light->setDiffuseColour(0, 0, 1.0);
light->setSpecularColour(0, 0, 1.0);
light->setDirection(-1, -1, 0);
light->setPosition(Vector3(300, 300, 0));
light->setSpotlightRange(Degree(35), Degree(50));
}
//------------------------------------------------------------------------------------------
| [
"jmathews@5c5f61b4-215a-11de-a108-cd2f117ce590"
]
| [
[
[
1,
78
]
]
]
|
94e8f9104c335e3a294c8a97f89200aa54f3a970 | 216ae2fd7cba505c3690eaae33f62882102bd14a | /utils/nxogre/include/NxOgreResource.h | 904722d6cc3d99b4a3326f5e1899f95a9683ebea | []
| no_license | TimelineX/balyoz | c154d4de9129a8a366c1b8257169472dc02c5b19 | 5a0f2ee7402a827bbca210d7c7212a2eb698c109 | refs/heads/master | 2021-01-01T05:07:59.597755 | 2010-04-20T19:53:52 | 2010-04-20T19:53:52 | 56,454,260 | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 14,086 | h | /** File: NxOgreResource.h
Created on: 15-Nov-08
Author: Robin Southern "betajaen"
SVN: $Id$
© Copyright, 2008-2009 by Robin Southern, http://www.nxogre.org
This file is part of NxOgre.
NxOgre is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
NxOgre is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with NxOgre. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NXOGRE_RESOURCE_H
#define NXOGRE_RESOURCE_H
#include "NxOgreStable.h"
#include "NxOgreCommon.h"
#include "NxOgreArchive.h"
namespace NxOgre_Namespace
{
/** \brief A Resource represents a file or a block of data. It can be streamed from or accessed randomly. Resources should
be created via the ResourceSystem and handled safely in a Resource*.
\example
<code>
Resource* res = ResourceSystem::getSingleton()->open("file://test.bin", Enums::ResourceAccess_ReadAndWrite);
res->writeChar('d');
res->seekBack(5);
char* c = (char*) NxOgre_Allocate(Classes::_char, sizeof(char) * 5);
res->readCharArray(c, sizeof(char) * 5);
</code>
*/
class NxOgrePublicClass Resource
{
public: // Functions
/** \brief Required abstract constructor
*/
Resource(const ArchiveResourceIdentifier&, Archive*);
/** \brief Required virtual destructor
*/
virtual ~Resource(void);
/** \brief Get the parent Archive.
*/
Archive* getArchive();
/** \brief Get the ArchiveResourceIdentifier that identifies the Resource and Archive's name.
*/
ArchiveResourceIdentifier getArchiveResourceIdentifier();
/** \brief Has the resource been "touched" by a write operation?
*/
bool hasTouched() const;
/** \brief Get the number of read operations on that resource.
*/
unsigned int getNbReadOperations() const;
/** \brief Get the number of write operations on that resource.
*/
unsigned int getNbWriteOperations() const;
/** \brief What is the resources status?
*/
virtual Enums::ResourceStatus getStatus(void) const = 0;
/** \brief Get the directionality of the resource
*/
virtual Enums::ResourceDirectionality getDirectionality(void) const = 0;
/** \brief Get the type of access of the resource
*/
virtual Enums::ResourceAccess getAccess(void) const = 0;
/** \brief Get the size (in bytes) of the resource, or Constants::ResourceSizeUnknown.
\note If the Directionality is sucessional or the status is anything but open then
the file size will be Constants::ResourceSizeUnknown.
*/
virtual size_t getSize(void) const = 0;
/** \brief Go somewhere into the resource from, this is relative to the ReadWrite pointer and not an absolute.
\note Depending on status, or directionality this will not be possible.
\return True if the seek did happen, or false if it did not.
*/
virtual bool seek(size_t) = 0;
/** \brief Go to the beginning of the resource.
\note Depending on status, or directionality this will not be possible.
\return True if the seek did happen, or false if it did not.
*/
virtual bool seekBeginning(void) = 0;
/** \brief Go to the end of the resource.
\note Depending on status, or directionality this will not be possible.
\return True if the seek did happen, or false if it did not.
*/
virtual bool seekEnd(void) = 0;
/** \brief Is the ReadWrite pointer at the end of Resource?
*/
virtual bool atBeginning(void) const = 0;
/** \brief Is the ReadWrite pointer at the end of Resource, just like a standard "EOF" function.
*/
virtual bool atEnd(void) const = 0;
/** \brief Where the ReadWrite is from the beginning of the resource.
\note Constants::ResourceSizeUnknown will be returned if it is an unknown.
*/
virtual size_t at(void) const = 0;
/** \brief Write something otherwise fail.
*/
virtual bool write(const void* src, size_t src_size) = 0;
/** \brief Write a single null (0x00) to the resource otherwise fail.
*/
virtual bool writeNull(void) = 0;
/** \brief Write a bool otherwise fail.
*/
virtual bool writeBool(bool) = 0;
/** \brief Write a bool* array otherwise fail.
\note Length should be given as "array_size * sizeof(T)" or the same value you give
to NxOgre_Allocate as a size.
*/
virtual bool writeBool(bool*, size_t length) = 0;
/** \brief Write a single unsigned char otherwise fail.
*/
virtual bool writeUChar(unsigned char) = 0;
/** \brief Write a unsigned char* array otherwise fail.
\note Length should be given as "array_size * sizeof(T)" or the same value you give
to NxOgre_Allocate as a size.
*/
virtual bool writeUChar(unsigned char*, size_t length) = 0;
/** \brief Write a single char otherwise fail.
*/
virtual bool writeChar(char) = 0;
/** \brief Write a char* array otherwise fail.
*/
virtual bool writeChar(char*, size_t length) = 0;
/** \brief Write a single unsigned short otherwise fail.
*/
virtual bool writeUShort(unsigned short) = 0;
/** \brief Write a unsigned short* array otherwise fail.
*/
virtual bool writeUShort(unsigned short*, size_t length) = 0;
/** \brief Write a single short otherwise fail.
*/
virtual bool writeShort(short) = 0;
/** \brief Write a short* array otherwise fail.
*/
virtual bool writeShort(short*, size_t length) = 0;
/** \brief Write a single unsigned int otherwise fail.
*/
virtual bool writeUInt(unsigned int) = 0;
/** \brief Write a unsigned int* array otherwise fail.
*/
virtual bool writeUInt(unsigned int*, size_t length) = 0;
/** \brief Write a single int otherwise fail.
*/
virtual bool writeInt(int) = 0;
/** \brief Write a int* array otherwise fail.
*/
virtual bool writeInt(int*, size_t length) = 0;
/** \brief Write a single float otherwise fail.
*/
virtual bool writeFloat(float) = 0;
/** \brief Write a float* array otherwise fail.
*/
virtual bool writeFloat(float*, size_t length) = 0;
/** \brief Write a single double otherwise fail.
*/
virtual bool writeDouble(double) = 0;
/** \brief Write a double* array otherwise fail.
*/
virtual bool writeDouble(double*, size_t length) = 0;
/** \brief Write a float or double otherwise fail
*/
virtual bool writeReal(NxOgreRealType) = 0;
/** \brief Write a float or double array otherwise fail
*/
virtual bool writeReal(NxOgreRealType*, size_t length) = 0;
/** \brief Write a single long otherwise fail.
*/
virtual bool writeLong(long) = 0;
/** \brief Write a long* array otherwise fail.
*/
virtual bool writeLong(long*, size_t length) = 0;
/** \brief Read a bool otherwise fail.
*/
virtual bool readBool(void) = 0;
/** \brief Read a bool* array otherwise fail.
\note Length should be given as "array_size * sizeof(T)" or the same value you give
to NxOgre_Allocate as a size.
*/
virtual void readBoolArray(bool*, size_t length) = 0;
/** \brief Read a single unsigned char otherwise fail.
*/
virtual unsigned char readUChar(void) = 0;
/** \brief Read a unsigned char* array otherwise fail.
\note Length should be given as "array_size * sizeof(T)" or the same value you give
to NxOgre_Allocate as a size.
*/
virtual void readUCharArray(unsigned char*, size_t length) = 0;
/** \brief Read a single char otherwise fail.
*/
virtual char readChar(void) = 0;
/** \brief Read a char* array otherwise fail.
\note Length should be given as "array_size * sizeof(T)" or the same value you give
to NxOgre_Allocate as a size.
*/
virtual void readCharArray(char*, size_t length) = 0;
/** \brief Read a single unsigned short otherwise fail.
*/
virtual unsigned short readUShort(void) = 0;
/** \brief Read a unsigned short* array otherwise fail.
\note Length should be given as "array_size * sizeof(T)" or the same value you give
to NxOgre_Allocate as a size.
*/
virtual void readUShortArray(unsigned short*, size_t length) = 0;
/** \brief Read a single short otherwise fail.
*/
virtual short readShort(void) = 0;
/** \brief Read a short* array otherwise fail.
*/
virtual void readShortArray(short*, size_t length) = 0;
/** \brief Read a single unsigned int otherwise fail.
*/
virtual unsigned int readUInt(void) = 0;
/** \brief Read a unsigned int* array otherwise fail.
*/
virtual void readUIntArray(unsigned int*, size_t length) = 0;
/** \brief Read a single int otherwise fail.
*/
virtual int readInt(void) = 0;
/** \brief Read a int* array otherwise fail.
*/
virtual void readIntArray(int*, size_t length) = 0;
/** \brief Read a single float otherwise fail.
*/
virtual float readFloat(void) = 0;
/** \brief Read a float* array otherwise fail.
*/
virtual void readFloatArray(float*, size_t length) = 0;
/** \brief Read a single double otherwise fail.
*/
virtual double readDouble(void) = 0;
/** \brief Read a double* array otherwise fail.
*/
virtual void readDouble(double*, size_t length) = 0;
/** \brief Read a float or double otherwise fail
*/
virtual Real readReal(void) = 0;
/** \brief Read a float or double array otherwise fail
*/
virtual void readRealArray(NxOgreRealType*, size_t length) = 0;
/** \brief Read a single long otherwise fail.
*/
virtual long readLong(void) = 0;
/** \brief Read a long* array otherwise fail.
*/
virtual void readLongArray(long*, size_t length) = 0;
/** \brief Force any changes to the resource
*/
virtual void flush() = 0;
protected: // Functions
/** \brief Open the resource.
*/
void open(void);
/** \brief Close the resource.
*/
void close(void);
protected: // Variables
/** \internal Local copy of the resource identifier
*/
ArchiveResourceIdentifier mArchiveResourceIdentifier;
/** \internal Local copy of the resource status. Updated often throughout the resources lifetime.
*/
Enums::ResourceStatus mStatus;
/** \internal Local copy of the resource directionality.
*/
Enums::ResourceDirectionality mDirectionality;
/** \internal Local copy of the resource resource access.
*/
Enums::ResourceAccess mAccess;
/** \brief Parent archive
*/
Archive* mArchive;
/** \brief Number of Read Operations.
*/
unsigned int mNbReadOperations;
/** \brief Number of Write operations.
*/
unsigned int mNbWriteOperations;
/** \internal A single null byte
*/
static const char NULL_BYTE;
}; // class ClassName
} // namespace NxOgre_Namespace
#endif
| [
"umutert@b781d008-8b8c-11de-b664-3b115b7b7a9b"
]
| [
[
[
1,
386
]
]
]
|
b36e35caab796a63f51d9ea3850b68e3b7feed59 | d397b0d420dffcf45713596f5e3db269b0652dee | /src/Axe/ConnectionCache.hpp | c32e1c203cce7bd29cd951c1a256799f4f38cee2 | []
| no_license | irov/Axe | 62cf29def34ee529b79e6dbcf9b2f9bf3709ac4f | d3de329512a4251470cbc11264ed3868d9261d22 | refs/heads/master | 2021-01-22T20:35:54.710866 | 2010-09-15T14:36:43 | 2010-09-15T14:36:43 | 85,337,070 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,639 | hpp | # pragma once
# include <AxeUtil/Shared.hpp>
# include <map>
namespace Axe
{
typedef AxeHandle<class Connection> ConnectionPtr;
typedef AxeHandle<class ServantConnection> ServantConnectionPtr;
typedef AxeHandle<class ProxyConnectionProvider> ProxyConnectionProviderPtr;
class ConnectionProvider
: virtual public AxeUtil::Shared
{
public:
virtual ConnectionPtr createAdapterConnection( std::size_t _adapterId ) = 0;
virtual ConnectionPtr createServantConnection( const std::string & _name, const boost::asio::ip::tcp::endpoint & _endpoint ) = 0;
virtual ConnectionPtr createRouterConnection( const boost::asio::ip::tcp::endpoint & _endpoint ) = 0;
};
typedef AxeHandle<ConnectionProvider> ConnectionProviderPtr;
class ConnectionCache
: virtual public AxeUtil::Shared
{
public:
ConnectionCache( const ConnectionProviderPtr & _provider );
public:
void addAdapterConnection( std::size_t _adapterId, const ConnectionPtr & _connection );
const ConnectionPtr & getAdapterConnection( std::size_t _adapterId );
void addServantConnection( const std::string & _name, const ConnectionPtr & _connection );
const ConnectionPtr & getServantConnection( const std::string & _name, const boost::asio::ip::tcp::endpoint & _endpoint );
void addRouterConnection( const boost::asio::ip::tcp::endpoint & _endpoint, const ConnectionPtr & _connection );
const ConnectionPtr & getRouterConnection( const boost::asio::ip::tcp::endpoint & _endpoint );
const ProxyConnectionProviderPtr & getProxyAdapterProvider( std::size_t _servantId, std::size_t _adapterId );
const ProxyConnectionProviderPtr & getProxyServantProvider( const std::string & _name, const boost::asio::ip::tcp::endpoint & _endpoint );
public:
void relocateProxy( std::size_t _servantId, std::size_t _adapterId );
protected:
ConnectionProviderPtr m_provider;
typedef std::map<std::size_t, ConnectionPtr> TMapAdapterConnections;
TMapAdapterConnections m_adapterConnections;
typedef std::map<std::string, ConnectionPtr> TMapServantConnections;
TMapServantConnections m_servantConnections;
typedef std::map<boost::asio::ip::tcp::endpoint, ConnectionPtr> TMapRouterConnections;
TMapRouterConnections m_routerConnections;
typedef std::map<std::size_t, ProxyConnectionProviderPtr> TMapProxyAdapterProviders;
TMapProxyAdapterProviders m_proxyAdapterProviders;
typedef std::map<std::string, ProxyConnectionProviderPtr> TMapProxyServantProviders;
TMapProxyServantProviders m_proxyServantProviders;
};
typedef AxeHandle<ConnectionCache> ConnectionCachePtr;
} | [
"yuriy_levchenko@b35ac3e7-fb55-4080-a4c2-184bb04a16e0"
]
| [
[
[
1,
67
]
]
]
|
a5ee7e64bfefe4262eff0e83978aaac8356f6256 | dadf8e6f3c1adef539a5ad409ce09726886182a7 | /airplay/h/toeBox2DDraggable.h | d56e1f147036d94324953c5b9c10b595c286d924 | []
| no_license | sarthakpandit/toe | 63f59ea09f2c1454c1270d55b3b4534feedc7ae3 | 196aa1e71e9f22f2ecfded1c3da141e7a75b5c2b | refs/heads/master | 2021-01-10T04:04:45.575806 | 2011-06-09T12:56:05 | 2011-06-09T12:56:05 | 53,861,788 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 755 | h | #pragma once
#include <toeComponent.h>
namespace TinyOpenEngine
{
class CtoeBox2DWorld;
class CtoeBox2DDraggable : public CtoeComponent
{
protected:
public:
//Declare managed class
IW_MANAGED_DECLARE(CtoeBox2DDraggable);
//Constructor
CtoeBox2DDraggable();
//Desctructor
virtual ~CtoeBox2DDraggable();
//Reads/writes a binary file using @a IwSerialise interface.
virtual void Serialise ();
// Recieve message sent by CtoeEntity->SendMessage
virtual void RecieveMessage(uint32 eventNameHast, CtoeEventArgs*eventArgs);
#ifdef IW_BUILD_RESOURCES
//Parses from text file: parses attribute/value pair.
virtual bool ParseAttribute(CIwTextParserITX* pParser, const char* pAttrName);
#endif
};
} | [
"[email protected]"
]
| [
[
[
1,
31
]
]
]
|
7d1d6dd1164cfa10231cceb68d6b08961d1ba6e6 | c230747fdbb8be4c54b624e3bb9b89d1aef630db | /mini_Project/song.h | 964738e438599877cb4acd4a186a922114d809c3 | []
| no_license | dgbrahle/Arduino | 0ebc2981e98765158b2e4728cfa9ac16428ead87 | 83be4218740b2c5b5942aad7421f98b8612d442f | refs/heads/master | 2020-05-31T11:31:03.776387 | 2011-05-31T22:22:38 | 2011-05-31T22:22:38 | 1,828,978 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 384 | h | /*
* song.hpp
*
* Created on: May 31, 2011
* Author: Mike
*/
#ifndef SONG_H_
#define SONG_H_
class Song{
public:
Song(int [], int [], int);
void Play();
private:
int melody[];
int noteDurations[];
int numOfnotes;
};
Song::Song(int m[], int nD[], int n){
numOfnotes = n;
melody[numOfnotes] = *m;
noteDurations[numOfnotes] = *nD;
}
#endif /* SONG_H_ */
| [
"[email protected]"
]
| [
[
[
1,
28
]
]
]
|
9ec23d20721badae49c86bb9e3a1107162906417 | b22c254d7670522ec2caa61c998f8741b1da9388 | /NewClient/OptionsGUI.cpp | 0ab466ee0ace7c2a647c1f15a72dbda79101d4aa | []
| 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 | 16,734 | cpp | /*
------------------------[ 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/>.
-----------------------------------------------------------------------------
*/
#include "OptionsGUI.h"
#include <CEGUI.h>
#include <iostream>
#include "ConfigurationManager.h"
#include "InternalWorkpile.h"
#include "GameEvents.h"
#include "LogHandler.h"
#include "OSGHandler.h"
#include "MusicHandler.h"
#include "InternalWorkpile.h"
#include "GameEvents.h"
//
//#include "TextWritter.h"
//#include "DataLoader.h"
// Sample sub-class for ListboxTextItem that auto-sets the selection brush
// image. This saves doing it manually every time in the code.
class MyOptListItem : public CEGUI::ListboxTextItem
{
public:
MyOptListItem (const CEGUI::String& text) : CEGUI::ListboxTextItem(text)
{
setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush");
}
};
/***********************************************************
constructor
***********************************************************/
OptionsGUI::OptionsGUI()
{
}
/***********************************************************
destructor
***********************************************************/
OptionsGUI::~OptionsGUI()
{
}
/***********************************************************
initialize the GUI
***********************************************************/
void OptionsGUI::Initialize()
{
try
{
// Load the Imageset that has the pictures for our button.
_root = CEGUI::WindowManager::getSingleton().loadWindowLayout( "Options.layout" );
static_cast<CEGUI::PushButton *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsFrameW/OK"))->subscribeEvent (
CEGUI::PushButton::EventClicked,
CEGUI::Event::Subscriber (&OptionsGUI::HandleOK, this));
static_cast<CEGUI::PushButton *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsFrameW/Cancel"))->subscribeEvent (
CEGUI::PushButton::EventClicked,
CEGUI::Event::Subscriber (&OptionsGUI::HandleCancel, this));
static_cast<CEGUI::PushButton *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsFrameW/Apply"))->subscribeEvent (
CEGUI::PushButton::EventClicked,
CEGUI::Event::Subscriber (&OptionsGUI::HandleApply, this));
static_cast<CEGUI::FrameWindow *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsFrameW"))->subscribeEvent (
CEGUI::FrameWindow::EventCloseClicked,
CEGUI::Event::Subscriber (&OptionsGUI::HandleCancel, this));
// add screen resolutions to the combo box
CEGUI::Combobox * cb = static_cast<CEGUI::Combobox *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/Video/ComboRes"));
std::ifstream filesc("Data/screen_resolutions.txt");
std::string restmp;
while(!filesc.eof())
{
filesc >> restmp;
cb->addItem(new CEGUI::ListboxTextItem(restmp));
}
//{
//CEGUI::Combobox * cbatype = static_cast<CEGUI::Combobox *> (
// CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/General/lbltxtLangcb"));
// cbatype->addItem(new MyOptListItem("en"));
// cbatype->addItem(new MyOptListItem("fr"));
// cbatype->addItem(new MyOptListItem("de"));
// cbatype->addItem(new MyOptListItem("sp"));
// cbatype->addItem(new MyOptListItem("it"));
// _lang = DataLoader::getInstance()->GetLanguage();
// cbatype->setText(_lang);
//}
Displayed();
SendNameColor();
static_cast<CEGUI::TabControl *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab"))->setSelectedTab("OptionsTab/General");
}
catch(CEGUI::Exception &ex)
{
LogHandler::getInstance()->LogToFile(std::string("Exception init login gui: ") + ex.getMessage().c_str());
_root = NULL;
}
}
/***********************************************************
handle connect button event
***********************************************************/
bool OptionsGUI::HandleOK(const CEGUI::EventArgs& e)
{
Apply();
Quit();
return true;
}
/***********************************************************
handle cancel button event
***********************************************************/
bool OptionsGUI::HandleCancel (const CEGUI::EventArgs& e)
{
Cancel();
Quit();
return true;
}
/***********************************************************
handle cancel button event
***********************************************************/
bool OptionsGUI::HandleApply (const CEGUI::EventArgs& e)
{
Apply();
return true;
}
/***********************************************************
apply new changes
***********************************************************/
void OptionsGUI::Apply()
{
try
{
//------------- handle general tab
{
//CEGUI::Combobox * cbatype = static_cast<CEGUI::Combobox *> (
// CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/General/lbltxtLangcb"));
//if(cbatype)
//{
// std::string sp = cbatype->getText().c_str();
// if(_lang != sp)
// {
// _lang = sp;
// DataLoader::getInstance()->SetLanguage(_lang);
// ConfigurationManager::GetInstance()->SetString("Options.General.Language", _lang);
// }
//}
{
bool nchanged = false;
//handle name R
CEGUI::Spinner *sbgs = static_cast<CEGUI::Spinner *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/General/lbltextRv_name"));
if(sbgs)
{
int sp = (int)sbgs->getCurrentValue();
if(_nameR != sp)
{
nchanged = true;
_nameR = sp;
ConfigurationManager::GetInstance()->SetInt("Options.General.NameR", _nameR);
}
}
//handle name G
CEGUI::Spinner *sbgsG = static_cast<CEGUI::Spinner *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/General/lbltextGv_name"));
if(sbgsG)
{
int sp = (int)sbgsG->getCurrentValue();
if(_nameG != sp)
{
nchanged = true;
_nameG = sp;
ConfigurationManager::GetInstance()->SetInt("Options.General.NameG", _nameG);
}
}
//handle name B
CEGUI::Spinner *sbgsB = static_cast<CEGUI::Spinner *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/General/lbltextBv_name"));
if(sbgsB)
{
int sp = (int)sbgsB->getCurrentValue();
if(_nameB != sp)
{
nchanged = true;
_nameB = sp;
ConfigurationManager::GetInstance()->SetInt("Options.General.NameB", _nameB);
}
}
if(nchanged)
SendNameColor();
}
}
//------------- handle video tab
{
bool changeRes = false;
//handle screen resolution
CEGUI::Combobox * cb = static_cast<CEGUI::Combobox *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/Video/ComboRes"));
if(cb)
{
CEGUI::ListboxItem *itm = cb->getSelectedItem();
if(itm)
{
std::string selectedres = itm->getText().c_str();
int posX = selectedres.find("x");
int xs = atoi(selectedres.substr(0, posX).c_str());
int ys = atoi(selectedres.substr(posX+1).c_str());
if(xs != _currScreenX || ys != _currScreenY)
{
changeRes = true;
_currScreenX = xs;
_currScreenY = ys;
}
}
}
//handle fullscreen
CEGUI::Checkbox * checkbfull = static_cast<CEGUI::Checkbox *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/Video/cbfullscreen"));
if(checkbfull)
{
bool selectedb = checkbfull->isSelected();
if(selectedb != _currFullscreen)
{
changeRes = true;
_currFullscreen = selectedb;
}
}
//handle perpective
CEGUI::Checkbox * checkbpers = static_cast<CEGUI::Checkbox *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/Video/cbperspective"));
if(checkbpers)
{
bool selectedb = checkbpers->isSelected();
if(selectedb != _currPerspective)
{
_currPerspective = selectedb;
OsgHandler::getInstance()->TogglePerspectiveView(_currPerspective);
}
}
//handle exits
//CEGUI::Checkbox * checkbexd = static_cast<CEGUI::Checkbox *> (
// CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/Video/displayexits"));
//if(checkbexd)
//{
// bool selectedb = checkbexd->isSelected();
// if(selectedb != _currDisplayExit)
// {
// _currDisplayExit = selectedb;
// ThreadSafeWorkpile::getInstance()->AddEvent(new DisplayExitsEvent(_currDisplayExit));
// ConfigurationManager::GetInstance()->SetBool("Options.Video.DisplayExits", _currDisplayExit);
// }
//}
if(changeRes)
OsgHandler::getInstance()->SetScreenAttributes(_currScreenX, _currScreenY, _currFullscreen);
}
//------------- handle sound tab
{
//handle general sound
CEGUI::Scrollbar *sbgs = static_cast<CEGUI::Scrollbar *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/Sound/sbgeneralvolume"));
if(sbgs)
{
int sp = (int)sbgs->getScrollPosition ();
if(_currGenVolume != sp)
{
_currGenVolume = sp;
MusicHandler::getInstance()->SetGeneralVolume(_currGenVolume);
ConfigurationManager::GetInstance()->SetInt("Options.Sound.GeneralVolume", _currGenVolume);
}
}
//handle music sound
CEGUI::Scrollbar *sbms = static_cast<CEGUI::Scrollbar *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/Sound/sbMusicVolume"));
if(sbms)
{
int sp = (int)sbms->getScrollPosition ();
if(_currMusicVolume != sp)
{
_currMusicVolume = sp;
MusicHandler::getInstance()->SetMusicVolume(_currMusicVolume);
ConfigurationManager::GetInstance()->SetInt("Options.Sound.MusicVolume", _currMusicVolume);
}
}
}
//------------- handle gui tab
{
//handle font size
CEGUI::Spinner *sbgs = static_cast<CEGUI::Spinner *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/Gui/fontsize"));
if(sbgs)
{
int sp = (int)sbgs->getCurrentValue();
if(_fontSize != sp)
{
_fontSize = sp;
ConfigurationManager::GetInstance()->SetInt("Options.Gui.FontSize", _fontSize);
InternalWorkpile::getInstance()->AddEvent(new NewFontSizeEvent());
}
}
}
}
catch(CEGUI::Exception &ex)
{
LogHandler::getInstance()->LogToFile(std::string("Exception applying options: ") + ex.getMessage().c_str());
_root = NULL;
}
}
/***********************************************************
cancel changes
***********************************************************/
void OptionsGUI::Cancel()
{
try
{
//------------- handle general tab
{
//CEGUI::Combobox * cbatype = static_cast<CEGUI::Combobox *> (
// CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/General/lbltxtLangcb"));
//if(cbatype)
// cbatype->setText(_lang);
{
//handle name R
CEGUI::Spinner *sbgs = static_cast<CEGUI::Spinner *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/General/lbltextRv_name"));
if(sbgs)
{
std::stringstream strs;
strs<<_nameR;
sbgs->setText(strs.str());
}
//handle name G
CEGUI::Spinner *sbgsG = static_cast<CEGUI::Spinner *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/General/lbltextGv_name"));
if(sbgsG)
{
std::stringstream strs;
strs<<_nameG;
sbgsG->setText(strs.str());
}
//handle name B
CEGUI::Spinner *sbgsB = static_cast<CEGUI::Spinner *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/General/lbltextBv_name"));
if(sbgsB)
{
std::stringstream strs;
strs<<_nameB;
sbgsB->setText(strs.str());
}
}
}
//------------- handle video tab
{
//handle screen resolution
CEGUI::Combobox * cb = static_cast<CEGUI::Combobox *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/Video/ComboRes"));
if(cb)
{
std::stringstream strs;
strs<<_currScreenX<<"x"<<_currScreenY;
cb->setText(strs.str());
}
//handle fullscreen
CEGUI::Checkbox * checkbfull = static_cast<CEGUI::Checkbox *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/Video/cbfullscreen"));
if(checkbfull)
checkbfull->setSelected(_currFullscreen);
//handle disaply FPS
CEGUI::Checkbox * checkbfps = static_cast<CEGUI::Checkbox *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/Video/cbshowfps"));
if(checkbfps)
checkbfps->setSelected(_currDisplayFPS);
//handle perspective
CEGUI::Checkbox * checkbpers = static_cast<CEGUI::Checkbox *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/Video/cbperspective"));
if(checkbpers)
checkbpers->setSelected(_currPerspective);
//handle disaply exits
CEGUI::Checkbox * checkbdex = static_cast<CEGUI::Checkbox *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/Video/displayexits"));
if(checkbdex)
checkbdex->setSelected(_currDisplayExit);
}
//------------- handle sound tab
{
//handle general sound
CEGUI::Scrollbar *sbgs = static_cast<CEGUI::Scrollbar *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/Sound/sbgeneralvolume"));
if(sbgs)
sbgs->setScrollPosition((float)_currGenVolume);
//handle music sound
CEGUI::Scrollbar *sbms = static_cast<CEGUI::Scrollbar *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/Sound/sbMusicVolume"));
if(sbms)
sbms->setScrollPosition((float)_currMusicVolume);
}
//------------- handle gui tab
{
//handle font size
CEGUI::Spinner *sbgs = static_cast<CEGUI::Spinner *> (
CEGUI::WindowManager::getSingleton().getWindow("OptionsTab/Gui/fontsize"));
if(sbgs)
{
std::stringstream strs;
strs<<_fontSize;
sbgs->setText(strs.str());
}
}
}
catch(CEGUI::Exception &ex)
{
LogHandler::getInstance()->LogToFile(std::string("Exception cancelling options: ") + ex.getMessage().c_str());
_root = NULL;
}
}
/***********************************************************
quit windows
***********************************************************/
void OptionsGUI::Quit()
{
InternalWorkpile::getInstance()->AddEvent(new GuiExitEvent());
}
/***********************************************************
called to infrom the gui that it is displayed
***********************************************************/
void OptionsGUI::Displayed()
{
//init the values from file
ConfigurationManager::GetInstance()->GetInt("Options.General.NameR", _nameR);
ConfigurationManager::GetInstance()->GetInt("Options.General.NameG", _nameG);
ConfigurationManager::GetInstance()->GetInt("Options.General.NameB", _nameB);
//ConfigurationManager::GetInstance()->GetBool("Options.Video.DisplayExits", _currDisplayExit);
ConfigurationManager::GetInstance()->GetInt("Options.Sound.GeneralVolume", _currGenVolume);
ConfigurationManager::GetInstance()->GetInt("Options.Sound.MusicVolume", _currMusicVolume);
ConfigurationManager::GetInstance()->GetInt("Options.Gui.FontSize", _fontSize);
OsgHandler::getInstance()->GetScreenAttributes(_currScreenX, _currScreenY, _currFullscreen);
_currPerspective = OsgHandler::getInstance()->IsPerspectiveView();
Cancel();
}
/***********************************************************
send name color
***********************************************************/
void OptionsGUI::SendNameColor()
{
std::stringstream colorstr;
colorstr << "FF" ;
colorstr <<((_nameR < 16)?"0":"") << std::uppercase <<std::hex << _nameR;
colorstr <<((_nameG < 16)?"0":"") << std::uppercase << std::hex << _nameG;
colorstr <<((_nameB < 16)?"0":"") << std::uppercase << std::hex << _nameB;
InternalWorkpile::getInstance()->ChangeNameColor(colorstr.str());
} | [
"vdelage@3806491c-8dad-11de-9a8c-6d5b7d1e4d13"
]
| [
[
[
1,
554
]
]
]
|
18058d6e8d16c7ebcf1dc93f56a76dc86be6d51d | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/mw/classicui/uifw/apps/S60_SDK3.0/bctestappfrm/inc/bctestappfrmeiksrvcase.h | 5503bf5ae7d4e16ae19b2dd7527ccfdfbbd621aa | []
| no_license | SymbianSource/oss.FCL.sftools.ana.compatanamdw | a6a8abf9ef7ad71021d43b7f2b2076b504d4445e | 1169475bbf82ebb763de36686d144336fcf9d93b | refs/heads/master | 2020-12-24T12:29:44.646072 | 2010-11-11T14:03:20 | 2010-11-11T14:03:20 | 72,994,432 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,271 | h | /*
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: test case
*
*/
#ifndef C_CBCTESTAPPFRMEIKSRVCASE_H
#define C_CBCTESTAPPFRMEIKSRVCASE_H
#include "bctestcase.h"
class CBCTestAppFrmContainer;
class CCoeControl;
/**
* test case for various list classes
*/
class CBCTestAppFrmEikSrvCase: public CBCTestCase
{
public: // constructor and destructor
/**
* Symbian 2nd static constructor
*/
static CBCTestAppFrmEikSrvCase* NewL( CBCTestAppFrmContainer* aContainer );
/**
* Destructor
*/
virtual ~CBCTestAppFrmEikSrvCase();
public: // from CBCTestCase
/**
* Execute corresponding test functions for UI command
* @param aCmd, UI command
*/
void RunL( TInt aCmd );
protected: // new functions
/**
* Build autotest script
*/
void BuildScriptL();
/**
* Create control or allocate resource for test
* @param aCmd UI command, maybe you need to do some work
* for different outline
*/
void PrepareCaseL( TInt aCmd );
/**
* Release resource used in test
*/
void ReleaseCaseL();
/**
* Test functions
*/
void TestFunction();
void TestPublicFunction();
void TestProtectedFunction();
private: // constructor
/**
* C++ default constructor
*/
CBCTestAppFrmEikSrvCase( CBCTestAppFrmContainer* aContainer );
/**
* Symbian 2nd constructor
*/
void ConstructL();
private: // data
/**
* Pointer to a control, maybe you need one in your test
* own
*/
CCoeControl* iControl;
/**
* Pointer to container.
* not own
*/
CBCTestAppFrmContainer* iContainer;
};
#endif // C_CBCTESTAPPFRMEIKSRVCASE_H | [
"none@none"
]
| [
[
[
1,
107
]
]
]
|
a27db8e6497ce3b6e17db3dc6beee716f6859f47 | 3d8839cf7e6df0623a22a793c6df6a7cdf1f4507 | /ofxMSABulletPhysics/lib/bullet/BulletMultiThreaded/btGpu3DGridBroadphase.cpp | 69bf94cc096c09d8a67f3431cecdcf15bf34af29 | []
| no_license | mchinen/ofxMSA | 4bb29d8f45ab3a8207f8559136702c4b69375654 | 2fe66a4a0e28905d4ded437e92f7f4d7c787fcfe | refs/heads/master | 2021-01-16T19:14:18.919300 | 2010-12-05T02:28:42 | 2010-12-05T02:28:42 | 766,201 | 6 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 16,390 | cpp | /*
Bullet Continuous Collision Detection and Physics Library, http://bulletphysics.org
Copyright (C) 2006, 2009 Sony Computer Entertainment Inc.
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "LinearMath/btAlignedAllocator.h"
#include "LinearMath/btQuickprof.h"
#include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h"
#include "btGpuDefines.h"
#include "btGpuUtilsSharedDefs.h"
#include "btGpu3DGridBroadphaseSharedDefs.h"
#include "btGpu3DGridBroadphase.h"
#include <string.h> //for memset
#include <stdio.h>
static bt3DGridBroadphaseParams s3DGridBroadphaseParams;
btGpu3DGridBroadphase::btGpu3DGridBroadphase( const btVector3& worldAabbMin,const btVector3& worldAabbMax,
int gridSizeX, int gridSizeY, int gridSizeZ,
int maxSmallProxies, int maxLargeProxies, int maxPairsPerBody,
int maxBodiesPerCell,
btScalar cellFactorAABB) :
btSimpleBroadphase(maxSmallProxies,
// new (btAlignedAlloc(sizeof(btSortedOverlappingPairCache),16)) btSortedOverlappingPairCache),
new (btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16)) btHashedOverlappingPairCache),
m_bInitialized(false),
m_numBodies(0)
{
_initialize(worldAabbMin, worldAabbMax, gridSizeX, gridSizeY, gridSizeZ,
maxSmallProxies, maxLargeProxies, maxPairsPerBody,
maxBodiesPerCell, cellFactorAABB);
}
btGpu3DGridBroadphase::btGpu3DGridBroadphase( btOverlappingPairCache* overlappingPairCache,
const btVector3& worldAabbMin,const btVector3& worldAabbMax,
int gridSizeX, int gridSizeY, int gridSizeZ,
int maxSmallProxies, int maxLargeProxies, int maxPairsPerBody,
int maxBodiesPerCell,
btScalar cellFactorAABB) :
btSimpleBroadphase(maxSmallProxies, overlappingPairCache),
m_bInitialized(false),
m_numBodies(0)
{
_initialize(worldAabbMin, worldAabbMax, gridSizeX, gridSizeY, gridSizeZ,
maxSmallProxies, maxLargeProxies, maxPairsPerBody,
maxBodiesPerCell, cellFactorAABB);
}
btGpu3DGridBroadphase::~btGpu3DGridBroadphase()
{
//btSimpleBroadphase will free memory of btSortedOverlappingPairCache, because m_ownsPairCache
assert(m_bInitialized);
_finalize();
}
void btGpu3DGridBroadphase::_initialize( const btVector3& worldAabbMin,const btVector3& worldAabbMax,
int gridSizeX, int gridSizeY, int gridSizeZ,
int maxSmallProxies, int maxLargeProxies, int maxPairsPerBody,
int maxBodiesPerCell,
btScalar cellFactorAABB)
{
// set various paramerers
m_ownsPairCache = true;
m_params.m_gridSizeX = gridSizeX;
m_params.m_gridSizeY = gridSizeY;
m_params.m_gridSizeZ = gridSizeZ;
m_params.m_numCells = m_params.m_gridSizeX * m_params.m_gridSizeY * m_params.m_gridSizeZ;
btVector3 w_org = worldAabbMin;
m_params.m_worldOriginX = w_org.getX();
m_params.m_worldOriginY = w_org.getY();
m_params.m_worldOriginZ = w_org.getZ();
btVector3 w_size = worldAabbMax - worldAabbMin;
m_params.m_cellSizeX = w_size.getX() / m_params.m_gridSizeX;
m_params.m_cellSizeY = w_size.getY() / m_params.m_gridSizeY;
m_params.m_cellSizeZ = w_size.getZ() / m_params.m_gridSizeZ;
m_maxRadius = btMin(btMin(m_params.m_cellSizeX, m_params.m_cellSizeY), m_params.m_cellSizeZ);
m_maxRadius *= btScalar(0.5f);
m_params.m_numBodies = m_numBodies;
m_params.m_maxBodiesPerCell = maxBodiesPerCell;
m_numLargeHandles = 0;
m_maxLargeHandles = maxLargeProxies;
m_maxPairsPerBody = maxPairsPerBody;
m_cellFactorAABB = cellFactorAABB;
m_LastLargeHandleIndex = -1;
assert(!m_bInitialized);
// allocate host storage
m_hBodiesHash = new unsigned int[m_maxHandles * 2];
memset(m_hBodiesHash, 0x00, m_maxHandles*2*sizeof(unsigned int));
m_hCellStart = new unsigned int[m_params.m_numCells];
memset(m_hCellStart, 0x00, m_params.m_numCells * sizeof(unsigned int));
m_hPairBuffStartCurr = new unsigned int[m_maxHandles * 2 + 2];
// --------------- for now, init with m_maxPairsPerBody for each body
m_hPairBuffStartCurr[0] = 0;
m_hPairBuffStartCurr[1] = 0;
for(int i = 1; i <= m_maxHandles; i++)
{
m_hPairBuffStartCurr[i * 2] = m_hPairBuffStartCurr[(i-1) * 2] + m_maxPairsPerBody;
m_hPairBuffStartCurr[i * 2 + 1] = 0;
}
//----------------
unsigned int numAABB = m_maxHandles + m_maxLargeHandles;
m_hAABB = new bt3DGrid3F1U[numAABB * 2]; // AABB Min & Max
m_hPairBuff = new unsigned int[m_maxHandles * m_maxPairsPerBody];
memset(m_hPairBuff, 0x00, m_maxHandles * m_maxPairsPerBody * sizeof(unsigned int)); // needed?
m_hPairScan = new unsigned int[m_maxHandles + 1];
m_hPairOut = new unsigned int[m_maxHandles * m_maxPairsPerBody];
// large proxies
// allocate handles buffer and put all handles on free list
m_pLargeHandlesRawPtr = btAlignedAlloc(sizeof(btSimpleBroadphaseProxy) * m_maxLargeHandles, 16);
m_pLargeHandles = new(m_pLargeHandlesRawPtr) btSimpleBroadphaseProxy[m_maxLargeHandles];
m_firstFreeLargeHandle = 0;
{
for (int i = m_firstFreeLargeHandle; i < m_maxLargeHandles; i++)
{
m_pLargeHandles[i].SetNextFree(i + 1);
m_pLargeHandles[i].m_uniqueId = m_maxHandles+2+i;
}
m_pLargeHandles[m_maxLargeHandles - 1].SetNextFree(0);
}
// debug data
m_numPairsAdded = 0;
m_numOverflows = 0;
m_bInitialized = true;
}
void btGpu3DGridBroadphase::_finalize()
{
assert(m_bInitialized);
delete [] m_hBodiesHash;
delete [] m_hCellStart;
delete [] m_hPairBuffStartCurr;
delete [] m_hAABB;
delete [] m_hPairBuff;
delete [] m_hPairScan;
delete [] m_hPairOut;
btAlignedFree(m_pLargeHandlesRawPtr);
m_bInitialized = false;
}
void btGpu3DGridBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
{
if(m_numHandles <= 0)
{
BT_PROFILE("addLarge2LargePairsToCache");
addLarge2LargePairsToCache(dispatcher);
return;
}
// update constants
setParameters(&m_params);
// prepare AABB array
prepareAABB();
// calculate hash
calcHashAABB();
// sort bodies based on hash
sortHash();
// find start of each cell
findCellStart();
// findOverlappingPairs (small/small)
findOverlappingPairs();
// findOverlappingPairs (small/large)
findPairsLarge();
// add pairs to CPU cache
computePairCacheChanges();
scanOverlappingPairBuff();
squeezeOverlappingPairBuff();
addPairsToCache(dispatcher);
// find and add large/large pairs to CPU cache
addLarge2LargePairsToCache(dispatcher);
return;
}
void btGpu3DGridBroadphase::addPairsToCache(btDispatcher* dispatcher)
{
m_numPairsAdded = 0;
m_numPairsRemoved = 0;
for(int i = 0; i < m_numHandles; i++)
{
unsigned int num = m_hPairScan[i+1] - m_hPairScan[i];
if(!num)
{
continue;
}
unsigned int* pInp = m_hPairOut + m_hPairScan[i];
unsigned int index0 = m_hAABB[i * 2].uw;
btSimpleBroadphaseProxy* proxy0 = &m_pHandles[index0];
for(unsigned int j = 0; j < num; j++)
{
unsigned int indx1_s = pInp[j];
unsigned int index1 = indx1_s & (~BT_3DGRID_PAIR_ANY_FLG);
btSimpleBroadphaseProxy* proxy1;
if(index1 < (unsigned int)m_maxHandles)
{
proxy1 = &m_pHandles[index1];
}
else
{
index1 -= m_maxHandles;
btAssert((index1 >= 0) && (index1 < (unsigned int)m_maxLargeHandles));
proxy1 = &m_pLargeHandles[index1];
}
if(indx1_s & BT_3DGRID_PAIR_NEW_FLG)
{
m_pairCache->addOverlappingPair(proxy0,proxy1);
m_numPairsAdded++;
}
else
{
m_pairCache->removeOverlappingPair(proxy0,proxy1,dispatcher);
m_numPairsRemoved++;
}
}
}
}
btBroadphaseProxy* btGpu3DGridBroadphase::createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* multiSapProxy)
{
btBroadphaseProxy* proxy;
bool bIsLarge = isLargeProxy(aabbMin, aabbMax);
if(bIsLarge)
{
if (m_numLargeHandles >= m_maxLargeHandles)
{
///you have to increase the cell size, so 'large' proxies become 'small' proxies (fitting a cell)
btAssert(0);
return 0; //should never happen, but don't let the game crash ;-)
}
btAssert((aabbMin[0]<= aabbMax[0]) && (aabbMin[1]<= aabbMax[1]) && (aabbMin[2]<= aabbMax[2]));
int newHandleIndex = allocLargeHandle();
proxy = new (&m_pLargeHandles[newHandleIndex])btSimpleBroadphaseProxy(aabbMin,aabbMax,shapeType,userPtr,collisionFilterGroup,collisionFilterMask,multiSapProxy);
}
else
{
proxy = btSimpleBroadphase::createProxy(aabbMin, aabbMax, shapeType, userPtr, collisionFilterGroup, collisionFilterMask, dispatcher, multiSapProxy);
}
return proxy;
}
void btGpu3DGridBroadphase::destroyProxy(btBroadphaseProxy* proxy, btDispatcher* dispatcher)
{
bool bIsLarge = isLargeProxy(proxy);
if(bIsLarge)
{
btSimpleBroadphaseProxy* proxy0 = static_cast<btSimpleBroadphaseProxy*>(proxy);
freeLargeHandle(proxy0);
m_pairCache->removeOverlappingPairsContainingProxy(proxy,dispatcher);
}
else
{
btSimpleBroadphase::destroyProxy(proxy, dispatcher);
}
return;
}
void btGpu3DGridBroadphase::resetPool(btDispatcher* dispatcher)
{
m_hPairBuffStartCurr[0] = 0;
m_hPairBuffStartCurr[1] = 0;
for(int i = 1; i <= m_maxHandles; i++)
{
m_hPairBuffStartCurr[i * 2] = m_hPairBuffStartCurr[(i-1) * 2] + m_maxPairsPerBody;
m_hPairBuffStartCurr[i * 2 + 1] = 0;
}
}
bool btGpu3DGridBroadphase::isLargeProxy(const btVector3& aabbMin, const btVector3& aabbMax)
{
btVector3 diag = aabbMax - aabbMin;
///use the bounding sphere radius of this bounding box, to include rotation
btScalar radius = diag.length() * btScalar(0.5f);
radius *= m_cellFactorAABB; // user-defined factor
return (radius > m_maxRadius);
}
bool btGpu3DGridBroadphase::isLargeProxy(btBroadphaseProxy* proxy)
{
return (proxy->getUid() >= (m_maxHandles+2));
}
void btGpu3DGridBroadphase::addLarge2LargePairsToCache(btDispatcher* dispatcher)
{
int i,j;
if (m_numLargeHandles <= 0)
{
return;
}
int new_largest_index = -1;
for(i = 0; i <= m_LastLargeHandleIndex; i++)
{
btSimpleBroadphaseProxy* proxy0 = &m_pLargeHandles[i];
if(!proxy0->m_clientObject)
{
continue;
}
new_largest_index = i;
for(j = i + 1; j <= m_LastLargeHandleIndex; j++)
{
btSimpleBroadphaseProxy* proxy1 = &m_pLargeHandles[j];
if(!proxy1->m_clientObject)
{
continue;
}
btAssert(proxy0 != proxy1);
btSimpleBroadphaseProxy* p0 = getSimpleProxyFromProxy(proxy0);
btSimpleBroadphaseProxy* p1 = getSimpleProxyFromProxy(proxy1);
if(aabbOverlap(p0,p1))
{
if (!m_pairCache->findPair(proxy0,proxy1))
{
m_pairCache->addOverlappingPair(proxy0,proxy1);
}
}
else
{
if(m_pairCache->findPair(proxy0,proxy1))
{
m_pairCache->removeOverlappingPair(proxy0,proxy1,dispatcher);
}
}
}
}
m_LastLargeHandleIndex = new_largest_index;
return;
}
void btGpu3DGridBroadphase::rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback)
{
btSimpleBroadphase::rayTest(rayFrom, rayTo, rayCallback);
for (int i=0; i <= m_LastLargeHandleIndex; i++)
{
btSimpleBroadphaseProxy* proxy = &m_pLargeHandles[i];
if(!proxy->m_clientObject)
{
continue;
}
rayCallback.process(proxy);
}
}
//
// overrides for CPU version
//
void btGpu3DGridBroadphase::prepareAABB()
{
BT_PROFILE("prepareAABB");
bt3DGrid3F1U* pBB = m_hAABB;
int i;
int new_largest_index = -1;
unsigned int num_small = 0;
for(i = 0; i <= m_LastHandleIndex; i++)
{
btSimpleBroadphaseProxy* proxy0 = &m_pHandles[i];
if(!proxy0->m_clientObject)
{
continue;
}
new_largest_index = i;
pBB->fx = proxy0->m_aabbMin.getX();
pBB->fy = proxy0->m_aabbMin.getY();
pBB->fz = proxy0->m_aabbMin.getZ();
pBB->uw = i;
pBB++;
pBB->fx = proxy0->m_aabbMax.getX();
pBB->fy = proxy0->m_aabbMax.getY();
pBB->fz = proxy0->m_aabbMax.getZ();
pBB->uw = num_small;
pBB++;
num_small++;
}
m_LastHandleIndex = new_largest_index;
new_largest_index = -1;
unsigned int num_large = 0;
for(i = 0; i <= m_LastLargeHandleIndex; i++)
{
btSimpleBroadphaseProxy* proxy0 = &m_pLargeHandles[i];
if(!proxy0->m_clientObject)
{
continue;
}
new_largest_index = i;
pBB->fx = proxy0->m_aabbMin.getX();
pBB->fy = proxy0->m_aabbMin.getY();
pBB->fz = proxy0->m_aabbMin.getZ();
pBB->uw = i + m_maxHandles;
pBB++;
pBB->fx = proxy0->m_aabbMax.getX();
pBB->fy = proxy0->m_aabbMax.getY();
pBB->fz = proxy0->m_aabbMax.getZ();
pBB->uw = num_large + m_maxHandles;
pBB++;
num_large++;
}
m_LastLargeHandleIndex = new_largest_index;
// paranoid checks
btAssert(num_small == m_numHandles);
btAssert(num_large == m_numLargeHandles);
return;
}
void btGpu3DGridBroadphase::setParameters(bt3DGridBroadphaseParams* hostParams)
{
s3DGridBroadphaseParams = *hostParams;
return;
}
void btGpu3DGridBroadphase::calcHashAABB()
{
BT_PROFILE("bt3DGrid_calcHashAABB");
btGpu_calcHashAABB(m_hAABB, m_hBodiesHash, m_numHandles);
return;
}
void btGpu3DGridBroadphase::sortHash()
{
class bt3DGridHashKey
{
public:
unsigned int hash;
unsigned int index;
void quickSort(bt3DGridHashKey* pData, int lo, int hi)
{
int i=lo, j=hi;
bt3DGridHashKey x = pData[(lo+hi)/2];
do
{
while(pData[i].hash > x.hash) i++;
while(x.hash > pData[j].hash) j--;
if(i <= j)
{
bt3DGridHashKey t = pData[i];
pData[i] = pData[j];
pData[j] = t;
i++; j--;
}
} while(i <= j);
if(lo < j) pData->quickSort(pData, lo, j);
if(i < hi) pData->quickSort(pData, i, hi);
}
};
BT_PROFILE("bt3DGrid_sortHash");
bt3DGridHashKey* pHash = (bt3DGridHashKey*)m_hBodiesHash;
pHash->quickSort(pHash, 0, m_numHandles - 1);
return;
}
void btGpu3DGridBroadphase::findCellStart()
{
BT_PROFILE("bt3DGrid_findCellStart");
btGpu_findCellStart(m_hBodiesHash, m_hCellStart, m_numHandles, m_params.m_numCells);
return;
}
void btGpu3DGridBroadphase::findOverlappingPairs()
{
BT_PROFILE("bt3DGrid_findOverlappingPairs");
btGpu_findOverlappingPairs(m_hAABB, m_hBodiesHash, m_hCellStart, m_hPairBuff, m_hPairBuffStartCurr, m_numHandles);
return;
}
void btGpu3DGridBroadphase::findPairsLarge()
{
BT_PROFILE("bt3DGrid_findPairsLarge");
btGpu_findPairsLarge(m_hAABB, m_hBodiesHash, m_hCellStart, m_hPairBuff, m_hPairBuffStartCurr, m_numHandles, m_numLargeHandles);
return;
}
void btGpu3DGridBroadphase::computePairCacheChanges()
{
BT_PROFILE("bt3DGrid_computePairCacheChanges");
btGpu_computePairCacheChanges(m_hPairBuff, m_hPairBuffStartCurr, m_hPairScan, m_hAABB, m_numHandles);
return;
}
void btGpu3DGridBroadphase::scanOverlappingPairBuff()
{
BT_PROFILE("bt3DGrid_scanOverlappingPairBuff");
m_hPairScan[0] = 0;
for(int i = 1; i <= m_numHandles; i++)
{
unsigned int delta = m_hPairScan[i];
m_hPairScan[i] = m_hPairScan[i-1] + delta;
}
return;
}
void btGpu3DGridBroadphase::squeezeOverlappingPairBuff()
{
BT_PROFILE("bt3DGrid_squeezeOverlappingPairBuff");
btGpu_squeezeOverlappingPairBuff(m_hPairBuff, m_hPairBuffStartCurr, m_hPairScan, m_hPairOut, m_hAABB, m_numHandles);
return;
}
#include "btGpu3DGridBroadphaseSharedCode.h"
| [
"[email protected]"
]
| [
[
[
1,
585
]
]
]
|
9c09bfe56f10376fda3ac225d354f48cc4b7ba70 | 465943c5ffac075cd5a617c47fd25adfe496b8b4 | /INCIRCLE.H | a4f9b386c6759c3c5a82ad62f67bf6726c1923c8 | []
| no_license | paulanthonywilson/airtrafficcontrol | 7467f9eb577b24b77306709d7b2bad77f1b231b7 | 6c579362f30ed5f81cabda27033f06e219796427 | refs/heads/master | 2016-08-08T00:43:32.006519 | 2009-04-09T21:33:22 | 2009-04-09T21:33:22 | 172,292 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 411 | h | /*
First stage in put for circle command
Paul Wilson
*/
# ifndef _INCIRCLE_H
# define _INCIRCLE_H
# include "dlyblste.h"
# include "delayorc.h"
class InCircle : public DelayableStep {
public :
InCircle (const WithPlaneStep &Last_i) :
DelayableStep (Last_i)
{
PromptMsg();
}
void ProcessInput (char KeyHit_i);
void Undo();
virtual void PromptMsg ();
};
# endif
| [
"[email protected]"
]
| [
[
[
1,
30
]
]
]
|
e2032a98307135892fb7d473244e030b1324dee0 | c70941413b8f7bf90173533115c148411c868bad | /core/include/vtxMoveObjectEvent.h | af3b287f3ecbeaac78f032a39b6934108668bf61 | []
| no_license | cnsuhao/vektrix | ac6e028dca066aad4f942b8d9eb73665853fbbbe | 9b8c5fa7119ff7f3dc80fb05b7cdba335cf02c1a | refs/heads/master | 2021-06-23T11:28:34.907098 | 2011-03-27T17:39:37 | 2011-03-27T17:39:37 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,287 | h | /*
-----------------------------------------------------------------------------
This source file is part of "vektrix"
(the rich media and vector graphics rendering library)
For the latest info, see http://www.fuse-software.com/
Copyright (c) 2009-2010 Fuse-Software (tm)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __vtxMoveObjectEvent_H__
#define __vtxMoveObjectEvent_H__
#include "vtxPrerequisites.h"
#include "vtxCXForm.h"
#include "vtxFrameEvent.h"
#include "vtxMatrix.h"
namespace vtx
{
//-----------------------------------------------------------------------
/** An event which moves an existing DisplayObject from a certain layer of an DisplayObjectContainer */
class vtxExport MoveObjectEvent : public FrameEvent
{
public:
MoveObjectEvent(const uint& layer, const Matrix& matrix, const CXForm& cxform);
/** @copybrief FrameEvent::clone */
FrameEvent* clone(DisplayObjectContainer* container);
/** @copybrief FrameEvent::execute */
void execute();
protected:
uint mLayer;
Matrix mMatrix;
CXForm mCXForm;
DisplayObject* mObject;
};
//-----------------------------------------------------------------------
}
#endif
| [
"stonecold_@9773a11d-1121-4470-82d2-da89bd4a628a",
"fixxxeruk@9773a11d-1121-4470-82d2-da89bd4a628a"
]
| [
[
[
1,
31
],
[
33,
61
]
],
[
[
32,
32
]
]
]
|
b81355bdf5260ef544f79a860e4f13faa83f7978 | de13bb58f0b0a0c5b7a533bb7a4ef8f255cbf35a | /Grapplon/SpeedUpPowerUp.h | de9aa2fa828023804075390af43de00f7de25789 | []
| no_license | TimToxopeus/grapplon | 96a34cc1fcefc2582c8702600727f5748ee894a9 | f63c258357fe4b993e854089e7222c14a00ed731 | refs/heads/master | 2016-09-06T15:05:15.328601 | 2008-06-05T11:24:14 | 2008-06-05T11:24:14 | 41,954,511 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 193 | h | #pragma once
#include "PowerUp.h"
class CSpeedUpPowerUp :
public CPowerUp
{
public:
CSpeedUpPowerUp(void);
~CSpeedUpPowerUp(void);
void CollideWith(CBaseObject* pOther);
};
| [
"[email protected]"
]
| [
[
[
1,
13
]
]
]
|
29bc7f784e760b80e1ef2c664074d0b340e20c1b | 5dc78c30093221b4d2ce0e522d96b0f676f0c59a | /src/modules/event/signal/Event.cpp | 400bbfb86aa33d27e6c14a22bef9defdb47a034d | [
"Zlib"
]
| permissive | JackDanger/love | f03219b6cca452530bf590ca22825170c2b2eae1 | 596c98c88bde046f01d6898fda8b46013804aad6 | refs/heads/master | 2021-01-13T02:32:12.708770 | 2009-07-22T17:21:13 | 2009-07-22T17:21:13 | 142,595 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,671 | cpp | /**
* Copyright (c) 2006-2009 LOVE Development Team
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
**/
#include "Event.h"
namespace love
{
namespace event
{
namespace signal
{
Event::Event()
: signals(0)
{
cb = 0;
}
Event::~Event()
{
::signal(signals, SIG_DFL);
}
bool Event::registerSignal(int sgn)
{
signals |= sgn;
return ::signal(sgn, (void (*)(int)) &handler) != SIG_ERR;
}
void Event::setCallback(lua_State *L)
{
luax_assert_argc(L, 1, 1);
luax_assert_function(L, -1);
if(cb != 0)
{
delete cb;
cb = 0;
}
cb = new Reference(L);
}
void handler(int signal)
{
if (cb == 0)
return;
lua_State *L = cb->getL();
cb->push();
lua_pushnumber(L, signal);
lua_call(L, 1, 0);
}
const char * Event::getName() const
{
return "love.event.signal";
}
} // signal
} // event
} // love
| [
"bartbes@3494dbca-881a-0410-bd34-8ecbaf855390"
]
| [
[
[
1,
78
]
]
]
|
cc81a9e88bd6974e1a394ad9ea446dbd62e56bc9 | 8bb0a1d6c74f3a17d90c64d9ee40ae5153d15acb | / cs191-nds-project/splash_screen/CS191_Project/include/CButton.h | f6dbdd8df4211f0f151106d95249f61ca74cc2ea | []
| no_license | btuduri/cs191-nds-project | 9b12382316c0a59d4e48acd7f40ed55c5c4cde41 | 146b2218cc53f960a034d053238a4cf111726279 | refs/heads/master | 2020-03-30T19:13:10.122474 | 2008-05-19T02:26:19 | 2008-05-19T02:26:19 | 32,271,764 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 987 | h | #ifndef CBUTTON_H_
#define CBUTTON_H_
#pragma once
#include "ProjectLib.h"
#include "CBasicObject.h"
#define DEFAULT_CLICK_RANGE 20
class CButton : public CBasicObject {
public:
CButton() {};
CButton(int16 x, int16 y, bool click=false);
CButton(int16 x, int16 y, int16 startX, int16 startY, int16 endX, int16 endY, bool click=false, bool pressed=false);
void setButtonPressed(){isPressed=true;}
void setButtonReleased(){isPressed=false;}
bool isButtonPressed(){return isPressed;}
void toggleButton(){isPressed = !isPressed;}
// bool wasClicked(touchXY.px, touchXY.py);
bool wasClicked(int16 x, int16 y);
void setRange(int16 startX, int16 startY, int16 endX, int16 endY);
void setStartPos(int16 x, int16 y);
bool canBeClicked();
private:
typedef struct clickRange{
int16 startX;
int16 endX;
int16 startY;
int16 endY;
} ClickRange;
bool isClickable;
ClickRange range;
bool isPressed;
};
#endif /*CBUTTON_H_*/
| [
"kingofcode@67d8362a-e844-0410-8493-f333cf7aaa27"
]
| [
[
[
1,
42
]
]
]
|
7223b53bcbbc0430110438fb9f85071f01c23ad9 | 975d45994f670a7f284b0dc88d3a0ebe44458a82 | /servidor/WarBugsServer/WarBugsServer/Includes/CBolsaList.h | 6bf1cc07d5a40d911d7f27ca85cf5f5f2cf099d2 | []
| 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 | 635 | h | #pragma once
#include <iostream>
using namespace std;
#include "Enumerators.h"
#include "CBolsa.h"
typedef SCelula<CBolsa> SBagElemento;
class CBolsaList : public CWarBugObject
{
private:
SBagElemento *_first;
int _size;
public:
CBolsaList(void);
CBolsaList(CBolsa * Bolsa);
bool isEmpty();
int size();
void addBag(CBolsa *Bolsa);
CBolsa *removeBagAt(int pos);
CBolsa *removeBag(int ID);
CBolsa *removeSceneBag(int sceneID);
//CBolsa *removeBolsa(CBolsa *Bolsa);
CBolsa *getBag(int IDBolsa);
CBolsa *getSceneBag(int sceneID);
CBolsa *getElementAt(int index);
bool haveBag(int ID);
};
| [
"[email protected]"
]
| [
[
[
1,
31
]
]
]
|
e57de701362fff7a34c5e88de7ebd2a98ab8f110 | 96e96a73920734376fd5c90eb8979509a2da25c0 | /C3DE/Scene.h | 724f24525eb302069ed46859203dc2b1d5eb306a | []
| no_license | lianlab/c3de | 9be416cfbf44f106e2393f60a32c1bcd22aa852d | a2a6625549552806562901a9fdc083c2cacc19de | refs/heads/master | 2020-04-29T18:07:16.973449 | 2009-11-15T10:49:36 | 2009-11-15T10:49:36 | 32,124,547 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,308 | h | #ifndef SCENE_H
#define SCENE_H
#include <vector>
#include "DiffuseLight.h"
#include "SpecularLight.h"
#include "AmbientLight.h"
#include "PointLight.h"
#include "Mesh.h"
#include "Mirror.h"
#include "ShadowSurface.h"
#include "Terrain.h"
#include "ParticleSystem.h"
#include "SceneNode.h"
using namespace std;
class Scene
{
public:
Scene();
virtual ~Scene();
void SetUpFromXMLFile(char *xmlPath){};
void AddMesh(Mesh*mesh);
void RemoveMesh(Mesh*mesh);
void AddNode(SceneNode *a_node);
void RemoveNode(SceneNode *a_node);
void ClearAllNodes();
void AddTerrain(Terrain *a_terrain);
void RemoveTerrain(Terrain *a_terrain);
void AddParticleSystem(ParticleSystem *a_particleSystem);
vector<ParticleSystem*> *GetParticleSystems();
void RemoveParticleSystem(ParticleSystem* a_particleSystem);
vector<Terrain*> *GetTerrains(){return m_terrains;}
vector<Mesh *> *GetMeshesVector()
{
return m_meshes;
}
void AddMirror(Mirror*mirror);
void RemoveMirror(Mirror*mirror);
vector<Mirror *> *GetMirrorsVector(){return m_mirrors;}
void AddShadowSurface(ShadowSurface*shadowSurface);
void RemoveShadowSurface(ShadowSurface*shadowSurface);
vector<ShadowSurface *> *GetShadowSurfacesVector(){return m_shadowSurfaces;}
AmbientLight * GetAmbientLight(){return m_ambientLight;}
DiffuseLight* GetDiffuseLight(){return m_diffuseLight;}
SpecularLight * GetSpecularLight(){return m_specularLight;}
PointLight * GetPointLight(){ return m_pointLight;}
void SetAmbientLight(AmbientLight *light);
void SetDiffuseLight(DiffuseLight *light);
void SetSpecularLight(SpecularLight *light);
void SetPointLight(PointLight *light);
void FreeMeshes();
void FreeTerrains();
vector<SceneNode*> *GetSceneNodes();
virtual void Update(int deltaTime);
protected:
vector<Mesh *> *m_meshes;
vector<Mirror *> *m_mirrors;
vector<ShadowSurface *> *m_shadowSurfaces;
vector<Terrain*> * m_terrains;
vector<ParticleSystem*> * m_particleSystems;
vector<SceneNode *> *m_sceneNodes;
AmbientLight * m_ambientLight;
DiffuseLight * m_diffuseLight;
SpecularLight * m_specularLight;
PointLight * m_pointLight;
void FreeShadowSurfaces();
void FreeMirrors();
void FreeParticleSystems();
};
#endif | [
"caiocsabino@7e2be596-0d54-0410-9f9d-cf4183935158"
]
| [
[
[
1,
95
]
]
]
|
3eb32b1f5e65354b7e90038982dbde5ffb7622a9 | ccc3e2995bc64d09b9e88fea8c1c7e2029a60ed8 | /SO/Trabalhos/Trabalho 2/tmp_src/31529/versao4 conditional variables/IGestorDePistas.h | 56d339569f0dd3be718eca3f26fe2d7a9a115ef8 | []
| no_license | masterzdran/semestre5 | e559e93017f5e40c29e9f28466ae1c5822fe336e | 148d65349073f8ae2f510b5659b94ddf47adc2c7 | refs/heads/master | 2021-01-25T10:05:42.513229 | 2011-02-20T17:46:14 | 2011-02-20T17:46:14 | 35,061,115 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 588 | h | #include "stdafx.h"
#ifndef IGESTORPISTAS_HEADER
#define IGESTORPISTAS_HEADER
class IGestorDePistas {
public:
virtual Plane * criarAviaoPara(Plane::PlaneDirection direction)= 0;
virtual Plane * esperarPistaParaAterrar() = 0;
virtual Plane * esperarPistaParaDescolar() = 0;
virtual void libertarPista(Plane * p) = 0;
virtual BOOL SetLanePriorityTo (Plane::PlaneDirection direction, int idLane) = 0;
virtual void fecharPista (int idPista) = 0;
virtual void abrirPista (int idPista) = 0;
virtual void alertaFuracao(bool bFuracao) = 0;
};
#endif IGESTORPISTAS_HEADER | [
"the.whinner@b139f23c-5e1e-54d6-eab5-85b03e268133"
]
| [
[
[
1,
17
]
]
]
|
0d9b8126e86b5b46893b32d97cfba69d9a24f656 | 15732b8e4190ae526dcf99e9ffcee5171ed9bd7e | /INC/location.h | 2be358a22b93a93f65fb0f9fae9333e1c94c14c4 | []
| 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 | 4,873 | h | //Copyright (c) 2010, Information Security Institute of Wuhan Universtiy(ISIWhu)
//All rights reserved.
//
//PLEASE READ THIS DOCUMENT CAREFULLY BEFORE UTILIZING THE PROGRAM
//BY UTILIZING THIS PROGRAM, YOU AGREE TO BECOME BOUND BY THE TERMS OF
//THIS LICENSE. IF YOU DO NOT AGREE TO THE TERMS OF THIS LICENSE, DO
//NOT USE THIS PROGRAM OR ANY PORTION THEREOF IN ANY FORM OR MANNER.
//
//This License allows you to:
//1. Make copies and distribute copies of the Program's source code provide that any such copy
// clearly displays any and all appropriate copyright notices and disclaimer of warranty as set
// forth in this License.
//2. Modify the original copy or copies of the Program or any portion thereof ("Modification(s)").
// Modifications may be copied and distributed under the terms and conditions as set forth above.
// Any and all modified files must be affixed with prominent notices that you have changed the
// files and the date that the changes occurred.
//Termination:
// If at anytime you are unable to comply with any portion of this License you must immediately
// cease use of the Program and all distribution activities involving the Program or any portion
// thereof.
//Statement:
// In this program, part of the code is from the GTNetS project, The Georgia Tech Network
// Simulator (GTNetS) is a full-featured network simulation environment that allows researchers in
// computer networks to study the behavior of moderate to large scale networks, under a variety of
// conditions. Our work have great advance due to this project, Thanks to Dr. George F. Riley from
// Georgia Tech Research Corporation. Anyone who wants to study the GTNetS can come to its homepage:
// http://www.ece.gatech.edu/research/labs/MANIACS/GTNetS/
//
//File Information:
//
//
//File Name:
//File Purpose:
//Original Author:
//Author Organization:
//Construct Data:
//Modify Author:
//Author Organization:
//Modify Data:
// Define locations and regions.
// George F. Riley, Georgia Tech, Summer 2003
#ifndef __location_h__
#define __location_h__
#include <vector>
#include "G_common_defs.h"
//Doc:ClassXRef
class Location {
//Doc:Class Contains location information in the X--Y--Z coordinate for nodes.
public:
//Doc:Method
Location() : xPos(0), yPos(0), zPos(0) {}
//Doc:Desc Default constructor. Sets both X, Y and Z position to zero.
//Doc:Method
Location(Meters_t x, Meters_t y, Meters_t z=0) : xPos(x), yPos(y), zPos(z) {}
//Doc:Desc Specifies X, Y and Z locations.
//Doc:Arg1 X location (meters)
//Doc:Arg2 Y location (meters)
//Doc:Arg3 Z location (meters)
Location(const Location& l) : xPos(l.X()), yPos(l.Y()), zPos(l.Z()) {}
//Doc:Method
Meters_t X() const { return xPos; }
//Doc:Desc Get the X location.
//Doc:Return The X location (meters)
Meters_t Y() const { return yPos; }
//Doc:Desc Get the Y location.
//Doc:Return The Y location (meters)
Meters_t Z() const { return zPos; }
//Doc:Desc Get the Z location.
//Doc:Return The Z location (meters)
void X(Meters_t x) { xPos = x; }
//Doc:Desc Set the X location.
//Doc:Arg1 The X location (meters)
void Y(Meters_t y) { yPos = y; }
//Doc:Desc Set the Y location.
//Doc:Arg1 The Y location (meters)
void Z(Meters_t z) { zPos = z; }
//Doc:Desc Set the Z location.
//Doc:Arg1 The Z location (meters)
private:
Meters_t xPos;
Meters_t yPos;
Meters_t zPos;
};
bool operator==(const Location& l, const Location& r);
//Doc:ClassXRef
class RectRegion {
//Doc:Class Contains information about a rectangular region on the grid.
public:
//Doc:Method
RectRegion() : ll(), ur() {}
//Doc:Desc Default constructor for an empty region.
//Doc:Method
RectRegion(const Location& l, const Location& u) : ll(l), ur(u) {}
//Doc:Desc Construct a region from lower left and upper right locations.
//Doc:Arg1 Lower left location.
//Doc:Arg2 Upper right location.
//Doc:Method
Location& LowerLeft() { return ll;}
//Doc:Desc Query the lower left corner of the region.
//Doc:Return Lower left corner.
//Doc:Method
Location& UpperRight() { return ur;}
//Doc:Desc Query the upper right corner of the region.
//Doc:Return Upper right corner.
bool InRegion(const Location& p) const
{
return p.X() >= ll.X() && p.X() <= ur.X() &&
p.Y() >= ll.Y() && p.Y() <= ur.Y();
}
bool Empty() const { return ll.X() == ur.X() && ll.Y() == ur.Y(); }
private:
Location ll;
Location ur;
};
typedef std::vector<Location> LocationVec_t; // List of x/y/z points
typedef std::vector<LocationVec_t> LocationVecVec_t; // List of LocationVec
#endif
| [
"pengelmer@f37e807c-cba8-11de-937e-2741d7931076"
]
| [
[
[
1,
148
]
]
]
|
5ff0a7455ff0250128849ad9a31d0840edabe36c | 2a0a607b23961936b9bda50ba7ebcf1dbd181fc5 | /src/unittest/old/MovableObjectTest.h | db6ab1924e533080f70920f41912d67719327288 | []
| no_license | egparedes/tinysg | ba7ab579e0cc42fb5c6ffaaaf29a31603506331f | 1d6a8f49f29c753cc02722e2262127fd377849f2 | refs/heads/master | 2021-01-10T12:31:08.437564 | 2010-06-10T21:01:03 | 2010-06-10T21:01:03 | 47,564,405 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,954 | h | /*
* EntityTest.h
*
* Created on: Aug 11, 2008
* Author: yamokosk
*/
#ifndef MOVABLEOBJECT_TEST_H_
#define MOVABLEOBJECT_TEST_H_
// Logging
#include <log4cxx/logger.h>
// CppUnit
#include <cppunit/extensions/HelperMacros.h>
// Class to test
#include <tinysg/MovableObject.h>
#include <tinysg/SceneNode.h>
// TEST CLASSES (class to test is pure virtual)
class TestObject : public TinySG::MovableObject
{
public:
TestObject() : moved_(false) {};
virtual ~TestObject() {};
virtual TinySG::MovableObject* clone() const {return NULL;}
virtual void save(TinySG::PropertyCollection& pc) const {return;}
bool moved_;
protected:
virtual void notifyMoved(void) {moved_ = true;}
};
class TestObjectFactory : public TinySG::ObjectFactory
{
protected:
// To be overloaded by specific object factories
virtual TinySG::Object* createInstanceImpl(const TinySG::PropertyCollection* params = 0);
public:
TestObjectFactory() : TinySG::ObjectFactory("TestObject") {};
virtual ~TestObjectFactory() {};
// To be overloaded by specific object factories
virtual void destroyInstance(TinySG::Object* obj);
};
class MovableObjectTest : public CppUnit::TestFixture
{
static log4cxx::LoggerPtr logger;
CPPUNIT_TEST_SUITE(MovableObjectTest);
CPPUNIT_TEST(testNumAttachedObjects);
CPPUNIT_TEST(testGetObjectByName);
CPPUNIT_TEST(testGetObjectByIndex);
CPPUNIT_TEST(testDetachObjectByPointer);
CPPUNIT_TEST(testDetachObjectByName);
CPPUNIT_TEST(testDetachObjectByIndex);
CPPUNIT_TEST(testDetachAllObjects);
CPPUNIT_TEST(testMovedNotification);
CPPUNIT_TEST_EXCEPTION( testAttachAttachedObject, TinySG::InvalidParametersException );
CPPUNIT_TEST_EXCEPTION( testAttachObjectWithSameName, TinySG::ItemIdentityException );
CPPUNIT_TEST_EXCEPTION( testGetAttachedObjectByBadIndex, TinySG::ItemIdentityException );
CPPUNIT_TEST_EXCEPTION( testGetAttachedObjectByBadName, TinySG::ItemIdentityException );
CPPUNIT_TEST_EXCEPTION( testDetachObjectByBadIndex, TinySG::ItemIdentityException );
CPPUNIT_TEST_EXCEPTION( testDetachObjectByBadName, TinySG::ItemIdentityException );
CPPUNIT_TEST_SUITE_END();
private:
TestObjectFactory objfact;
TestObject *obj, *obj_copy;
TinySG::SceneNode *n1, *n2, *n3, *n4;
//TinySG::NodeFactory nodefact;
public:
void setUp();
void tearDown();
protected:
// Unittest declarations
void testNumAttachedObjects();
void testGetObjectByName();
void testGetObjectByIndex();
void testDetachObjectByPointer();
void testDetachObjectByName();
void testDetachObjectByIndex();
void testDetachAllObjects();
void testMovedNotification();
// Exception tests
void testAttachAttachedObject();
void testAttachObjectWithSameName();
void testGetAttachedObjectByBadIndex();
void testGetAttachedObjectByBadName();
void testDetachObjectByBadIndex();
void testDetachObjectByBadName();
};
#endif /* ENTITYTEST_H_ */
| [
"[email protected]"
]
| [
[
[
1,
97
]
]
]
|
f4ce54e43bd44e9b742063846cc74f9de02d9ff6 | 5d3c1be292f6153480f3a372befea4172c683180 | /trunk/Event Heap/c++/Mac OS X/include/eh2_ErrorContext.h | 99ffc66474e96439cdbbbfc944ca3d3d2d2c17d5 | [
"Artistic-2.0"
]
| permissive | BackupTheBerlios/istuff-svn | 5f47aa73dd74ecf5c55f83765a5c50daa28fa508 | d0bb9963b899259695553ccd2b01b35be5fb83db | refs/heads/master | 2016-09-06T04:54:24.129060 | 2008-05-02T22:33:26 | 2008-05-02T22:33:26 | 40,820,013 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,627 | h | /* Copyright (c) 2003 The Board of Trustees of The Leland Stanford Junior
* University. All Rights Reserved.
*
* See the file LICENSE.txt for information on redistributing this software.
*/
/* $Id: eh2_ErrorContext.h,v 1.5 2003/06/02 08:02:04 tomoto Exp $ */
#ifndef _EH2_ERRORCONTEXT_H_
#define _EH2_ERRORCONTEXT_H_
#include <eh2_Base.h>
#include <eh2_Types.h>
#include <idk_ne_SocketAddress.h>
/** @file
Definition of eh2_ErrorContext class.
@internal This header belongs to the eh2i_cl component.
*/
class eh2i_cl_ErrorContext; // impl
/**
Provides the context information for eh2_ConnectErrorHandler.
<p>The handler can know about the context (e.g. the current thread is
background or not) by querying to this object.
*/
class EH2_DECL eh2_ErrorContext :
public idk_ut_TProxyObject<eh2i_cl_ErrorContext>
{
private:
friend class eh2i_cl_ErrorContext;
eh2_ErrorContext(eh2i_cl_ErrorContext* impl);
public:
~eh2_ErrorContext();
/**
Returns if the current thread is executed in background.
@return Non-zero if the current thread is in background
(i.e. receiver or sender thread).
Zero if otherwise (i.e. the caller's thread).
*/
int isBackgroundThread() const;
/**
Returns the server's address of the connection.
<i>This method would be useful when an instance of the handler
is shared among two or more connections.
By the way, why not eh2_Connection object? Because the handler
may be called during the connection object is under constuction.
</i>
*/
const idk_ne_SocketAddress* getAddress() const;
};
#endif
| [
"ballagas@2a53cb5c-8ff1-0310-8b75-b3ec22923d26"
]
| [
[
[
1,
59
]
]
]
|
80de0f99a1066bec3935da9975334214f61a946f | ad195eb05955ffbbbf14073bec424e6952be048e | /src/network/socket.cpp | 768df96c17f1c0dd3c400fcf25170025fdc245d1 | []
| no_license | mvan/4985Final | 761c99c3b59c077c6ba0700a8c7ed179e5e71d68 | 00f43f5cffb2329ffd782aefc9763ba61debdb3f | refs/heads/master | 2020-05-18T10:30:36.884438 | 2011-04-06T15:12:06 | 2011-04-06T15:12:06 | 1,431,979 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,324 | cpp | #include <winsock2.h>
#include <ws2tcpip.h>
#include "network.h"
#include "socket.h"
#include "errors.cpp"
/*------------------------------------------------------------------------------------------------------------------
-- FUNCTION: TCPSocket_Init
--
-- DATE: Feb 19, 2011
--
-- REVISIONS: (Date and Description)
--
-- DESIGNER: Duncan Donaldson
--
-- PROGRAMMER: Duncan Donaldson
--
-- INTERFACE: void TCPSocket_Init(SOCKET* socket)
-- socket - pointer to the socket to be initialized
--
-- RETURNS: void
--
-- NOTES:
-- initializes a TCP socket.
----------------------------------------------------------------------------------------------------------------------*/
void sock::TCPSocket_Init() {
int sizebuf = BUFSIZE;
bool reuseaddr = true;
if ((sock_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {
WSAError(SOCK_ERROR);
}
if(setsockopt(sock_, SOL_SOCKET, SO_REUSEADDR, (char*)&reuseaddr, sizeof(bool)) == SOCKET_ERROR){
WSAError(SOCK_ERROR);
}
if(setsockopt(sock_, SOL_SOCKET, SO_RCVBUF, (char*)&sizebuf, sizeof(int)) == SOCKET_ERROR){
WSAError(SOCK_ERROR);
}
if(setsockopt(sock_, SOL_SOCKET, SO_SNDBUF, (char*)&sizebuf, sizeof(int)) == SOCKET_ERROR){
WSAError(SOCK_ERROR);
}
}
/*------------------------------------------------------------------------------------------------------------------
-- FUNCTION: TCPSocket_Bind
--
-- DATE: Feb 19, 2011
--
-- REVISIONS: (Date and Description)
--
-- DESIGNER: Duncan Donaldson
--
-- PROGRAMMER: Duncan Donaldson
--
-- INTERFACE: void TCPSocket_Bind(int portNo)
-- PortNo - the port number to bind to.
--
-- RETURNS: void
--
-- NOTES:
-- binds a TCP socket to a port, and sets it to the listen state.
----------------------------------------------------------------------------------------------------------------------*/
void sock::TCPSocket_Bind(int portNo) {
ZeroMemory(&addr_, sizeof(struct sockaddr_in));
addr_.sin_family = AF_INET;
addr_.sin_port = htons(portNo);
addr_.sin_addr.s_addr = htonl(INADDR_ANY);
if (bind(sock_, (struct sockaddr *)&addr_, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
WSAError(SOCK_ERROR);
}
}
/*------------------------------------------------------------------------------------------------------------------
-- FUNCTION: TCPSocket_Listen
--
-- DATE: Feb 19, 2011
--
-- REVISIONS: (Date and Description)
--
-- DESIGNER: Duncan Donaldson
--
-- PROGRAMMER: Duncan Donaldson
--
-- INTERFACE: void TCPSocket_Listen(SOCKET* socket, int PortNo)
-- socket - pointer to the socket to be initialized
-- PortNo - the port number to bind to.
--
-- RETURNS: void
--
-- NOTES:
-- Sets a TCP socket to the listen state.
----------------------------------------------------------------------------------------------------------------------*/
void sock::TCPSocket_Listen() {
if(listen(sock_, 5)) {
WSAError(SOCK_ERROR);
}
}
/*------------------------------------------------------------------------------------------------------------------
-- FUNCTION: TCPSocket_Connect
--
-- DATE: Feb 19, 2011
--
-- REVISIONS: (Date and Description)
--
-- DESIGNER: Duncan Donaldson
--
-- PROGRAMMER: Duncan Donaldson
--
-- INTERFACE: void TCPSocket_Connect(SOCKET* socket, int PortNo, char* serv_addr)
-- socket - pointer to the socket to be initialized
-- PortNo - the port number to connect on.
-- serv_addr - the server address to connect to.
--
-- RETURNS: void
--
-- NOTES:
-- attempts to connect a TCP socket to a server.
----------------------------------------------------------------------------------------------------------------------*/
BOOL sock::TCPSocket_Connect(char* servAddr, int portNo) {
struct hostent *host;
ZeroMemory(&addr_, sizeof(struct sockaddr_in));
addr_.sin_family = AF_INET;
addr_.sin_port = htons(portNo);
if ((host = gethostbyname(servAddr)) == NULL) {
return FALSE;
}
mut_->lock();
memmove((char *)&addr_.sin_addr, host -> h_addr, host -> h_length);
if (connect (sock_, (struct sockaddr *)&addr_, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
mut_->unlock();
return FALSE;
}
mut_->unlock();
return TRUE;
}
SOCKET sock::TCPSocket_Accept() {
SOCKET s = 0;
mut_->lock();
if((s = accept(sock_, NULL, NULL)) == INVALID_SOCKET) {
mut_->unlock();
return 0;
}
mut_->unlock();
return s;
}
/*------------------------------------------------------------------------------------------------------------------
-- FUNCTION: UDPSocket_Init
--
-- DATE: Feb 19, 2011
--
-- REVISIONS: (Date and Description)
--
-- DESIGNER: Duncan Donaldson
--
-- PROGRAMMER: Duncan Donaldson
--
-- INTERFACE: void UDPSocket_Init(SOCKET* socket)
-- socket - pointer to the socket to be initialized
--
-- RETURNS: void
--
-- NOTES:
-- initializes a UDP socket.
----------------------------------------------------------------------------------------------------------------------*/
void sock::UDPSocket_Init(int port) {
int sizebuf = BUFSIZE;
bool reuseaddr = true;
this->udpPort = port;
mc_ = true;
if ((sock_ = WSASocket(PF_INET, SOCK_DGRAM, 0, NULL, 0, WSA_FLAG_OVERLAPPED)) == INVALID_SOCKET) {
WSAError(SOCK_ERROR);
}
if(setsockopt(sock_, SOL_SOCKET, SO_REUSEADDR, (char*)&reuseaddr, sizeof(bool)) == SOCKET_ERROR) {
WSAError(SOCK_ERROR);
}
if(setsockopt(sock_, SOL_SOCKET, SO_RCVBUF, (char*)&sizebuf, sizeof(int)) == SOCKET_ERROR) {
WSAError(SOCK_ERROR);
}
if(setsockopt(sock_, SOL_SOCKET, SO_SNDBUF, (char*)&sizebuf, sizeof(int)) == SOCKET_ERROR) {
WSAError(SOCK_ERROR);
}
}
/*------------------------------------------------------------------------------------------------------------------
-- FUNCTION: UDPSocket_Bind
--
-- DATE: Feb 19, 2011
--
-- REVISIONS: (Date and Description)
--
-- DESIGNER: Duncan Donaldson
--
-- PROGRAMMER: Duncan Donaldson
--
-- INTERFACE: void UDPSocket_Bind(SOCKET* socket, int PortNo)
-- socket - pointer to the socket to be initialized
-- PortNo - the port to bind to.
--
-- RETURNS: void
--
-- NOTES:
-- binds a UDP ocket to a port.
----------------------------------------------------------------------------------------------------------------------*/
BOOL sock::UDPSocket_Bind_Multicast() {
struct ip_mreq mc_addr;
int ttl = MULTICAST_TTL;
BOOL loopback = FALSE;
ZeroMemory(&addr_, sizeof(struct sockaddr_in));
addr_.sin_family = AF_INET;
addr_.sin_port = htons(udpPort);
addr_.sin_addr.s_addr = htonl(INADDR_ANY);
if (bind(sock_, (struct sockaddr *)&addr_, sizeof(addr_)) == SOCKET_ERROR) {
return FALSE;
}
mc_addr.imr_multiaddr.s_addr = inet_addr(MULTICAST_ADDR);
mc_addr.imr_interface.s_addr = INADDR_ANY;
if(setsockopt(sock_, IPPROTO_IP, IP_ADD_MEMBERSHIP,
(char *)&mc_addr, sizeof(mc_addr)) == SOCKET_ERROR) {
return FALSE;
}
if(setsockopt(sock_, IPPROTO_IP, IP_MULTICAST_TTL,
(char *)&ttl, sizeof(ttl)) == SOCKET_ERROR) {
return FALSE;
}
if(setsockopt(sock_, IPPROTO_IP, IP_MULTICAST_LOOP,
(char *)&loopback, sizeof(BOOL)) == SOCKET_ERROR) {
return FALSE;
}
return TRUE;
}
int sock::TCPSend() {
DWORD nRead;
mut_->lock();
nRead = send(sock_, packet_, PACKETSIZE, 0);
mut_->unlock();
return nRead;
}
int sock::UDPSend_Multicast() {
WSABUF buf;
buf.buf = packet_;
buf.len = PACKETSIZE;
addr_.sin_family = AF_INET;
addr_.sin_addr.s_addr = inet_addr(MULTICAST_ADDR);
addr_.sin_port = htons(udpPort);
WSASendTo(this->sock_, &buf, 1, NULL, 0, (struct sockaddr*)&addr_,
sizeof(addr_), &(this->ol_), sendCompRoutine);
return 1;
}
int sock::TCPRecv() {
int nRead;
int total = 0, toRead = PACKETSIZE;
mut_->lock();
while(toRead > 0) {
if((nRead = recv(sock_, packet_+total, toRead, 0)) == 0) {
mut_->unlock();
return 0;
}
toRead -= nRead;
total += nRead;
}
mut_->unlock();
return total;
}
int sock::UDPRecv_Multicast() {
DWORD flags = 0, wait;
createOLEvent();
WSARecv(sock_, &(this->buffer_), 1, NULL, &flags, (LPWSAOVERLAPPED)this, UDPCompRoutine);
wait = WSAWaitForMultipleEvents(1, &(ol_.hEvent), FALSE, INFINITE, TRUE);
CloseHandle(ol_.hEvent);
if(wait == WSA_WAIT_FAILED) {
return 0;
}
return 1;
}
void CALLBACK UDPCompRoutine(DWORD error, DWORD cbTransferred,
LPWSAOVERLAPPED lpOverlapped, DWORD dwFlags) {
if(cbTransferred == 0 || error != 0) {
WSAError(RD_ERROR);
}
}
void CALLBACK sendCompRoutine(DWORD error, DWORD cbTransferred,
LPWSAOVERLAPPED lpOverlapped, DWORD dwFlags) {
if(cbTransferred == 0 || error != 0) {
WSAError(WR_ERROR);
}
}
| [
"[email protected]",
"Admin@.(none)",
"[email protected]"
]
| [
[
[
1,
26
],
[
28,
28
],
[
33,
34
],
[
41,
42
],
[
44,
52
],
[
54,
60
],
[
62,
62
],
[
64,
67
],
[
70,
128
],
[
130,
131
],
[
134,
135
],
[
137,
140
],
[
142,
142
],
[
148,
148
],
[
151,
172
],
[
174,
174
],
[
178,
181
],
[
191,
211
],
[
213,
216
],
[
219,
219
],
[
221,
225
],
[
227,
228
],
[
231,
233
],
[
236,
238
],
[
241,
247
],
[
253,
256
],
[
258,
261
],
[
263,
263
],
[
265,
269
],
[
282,
282
],
[
284,
287
],
[
291,
291
],
[
293,
305
],
[
307,
311
]
],
[
[
27,
27
],
[
29,
32
],
[
35,
40
],
[
43,
43
],
[
53,
53
],
[
61,
61
],
[
68,
69
],
[
129,
129
],
[
132,
133
],
[
136,
136
],
[
141,
141
],
[
143,
147
],
[
149,
150
],
[
173,
173
],
[
175,
177
],
[
182,
190
],
[
212,
212
],
[
220,
220
],
[
248,
252
],
[
257,
257
],
[
262,
262
],
[
264,
264
],
[
270,
281
],
[
283,
283
],
[
288,
290
],
[
292,
292
],
[
306,
306
]
],
[
[
63,
63
],
[
217,
218
],
[
226,
226
],
[
229,
230
],
[
234,
235
],
[
239,
240
]
]
]
|
e5bc3da1b452b697de4b1a800c0601730bf88818 | 6dac9369d44799e368d866638433fbd17873dcf7 | /src/branches/26042005/vfs/VFSPlugin_BIN.cpp | afd2f8307db8ca15186ff40f2d5a4646f34f0bc2 | []
| no_license | christhomas/fusionengine | 286b33f2c6a7df785398ffbe7eea1c367e512b8d | 95422685027bb19986ba64c612049faa5899690e | refs/heads/master | 2020-04-05T22:52:07.491706 | 2006-10-24T11:21:28 | 2006-10-24T11:21:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,975 | cpp | #include <VFSPlugin_BIN.h>
/** Function to build all the appropiate plugins associated with this file type
* @ingroup VFSPlugin_BIN_Group
*
* @param f A pointer to the Fusion Core object, so if required, access to Fusion resources is possible
*
* @returns A pointer to the plugin created by calling this method
*
* It's worth noting that some File formats will require multiple filters to be applied to the data it holds.
* A format could be a simple text file, but it could be encrypted, or compressed, or both
* So filters to decrypt, decompress might be required to read the contents of the file correctly.
*/
VFSPlugin * CreateBinaryPlugin(Fusion *f)
{
static int counter=0;
if(counter++ == 0){ return new VFSPlugin_BIN(); }
return NULL;
}
/** Binary file format Plugin Constructor
*
* Sets the default extension to bin, although this
* format will happily accomodate ANY file format as a pure bytestream
*
* @todo Should a plugin to handle binary files, which are "unformatted"
* or not decoded, for example, reading a file from an archive and
* writing to the disk, you want to treat as anonymous binary data,
* should a file of this type, have an extension? sounds silly to me
* surely the data could have any extension and there shouldnt be an
* extension set aside for it
*/
VFSPlugin_BIN::VFSPlugin_BIN()
{
m_type = "binary";
m_offset = 0;
m_length = 0;
m_fileinfo = NULL;
m_buffer = NULL;
}
/** Binary file format plugin Deconstructor */
VFSPlugin_BIN::~VFSPlugin_BIN(){}
/** Adds a Data filter
*
* @param filter The filter to add to the plugin
*
*/
void VFSPlugin_BIN::AddFilter(VFSFilter *filter)
{
if(filter != NULL){
m_filters.push_back(filter);
}
}
/** Retrieves a plugin Identifier
*
* @returns The plugin Identifier string
*/
char * VFSPlugin_BIN::Type(void)
{
return m_type;
}
/** Decodes the file contents into a structured format
*
* @param buffer A bytestream containing the files contents
* @param length The length of the bytestream
*
* @returns A FileInfo structure containing the file's contents
*/
FileInfo * VFSPlugin_BIN::Read(unsigned char *buffer, unsigned int length)
{
for(unsigned int a=0;a<m_filters.size();a++){
buffer = m_filters[a]->Decode(buffer,length);
}
m_fileinfo = new BinaryFileInfo();
m_fileinfo->filelength = length;
m_fileinfo->data = new unsigned char[length];
memcpy(m_fileinfo->data,buffer,length);
return m_fileinfo;
}
/** Writes the contents of a FileInfo structure to a bytestream
*
* @param data A FileInfo structure containing the data to write to the bytestream
* @param length The length of the bytestream created
*
* @returns A Bytestream containing the data to write to the file
*/
char * VFSPlugin_BIN::Write(FileInfo *data, unsigned int &length)
{
// Not Implemented
length = 0;
return NULL;
}
| [
"chris_a_thomas@1bf15c89-c11e-0410-aefd-b6ca7aeaabe7"
]
| [
[
[
1,
103
]
]
]
|
00d231f7ebf263f9f02fa94e58a2fa76969c224d | fcf03ead74f6dc103ec3b07ffe3bce81c820660d | /Base/MemMan/Cleanup/ErrorOnFail/ErrorOnFail.cpp | 4bf822ea7be460475a4776b42ef5a58cabfb3a6c | []
| no_license | huellif/symbian-example | 72097c9aec6d45d555a79a30d576dddc04a65a16 | 56f6c5e67a3d37961408fc51188d46d49bddcfdc | refs/heads/master | 2016-09-06T12:49:32.021854 | 2010-10-14T06:31:20 | 2010-10-14T06:31:20 | 38,062,421 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,010 | cpp | // ErrorOnFail.cpp
//
// Copyright (C) Symbian Software Ltd 2000-2005. All rights reserved.
//
// Example shows attempt to construct an object and return an
// appropriate error code on failure.
//
// NOTE: the structure of this example is different to standard E32 examples
#include <e32cons.h>
//
// Common formats
//
_LIT(KCommonFormat1,"Value of iInt is %d.\n");
// All messages written to this
LOCAL_D CConsoleBase* console;
// Flag which determines whether the doSomething() member function
// of the CExample class should leave when called.
LOCAL_D TBool leaveFlag = ETrue;
// Parameter for __UHEAP_SETFAIL
// Allocation guaranteed to fail at this number of allocation attempts;
// i.e. if set to n, allocation fails on the nth attempt.
// NB only used in debug mode
#ifdef _DEBUG
LOCAL_D TInt allocFailNumber = 1;
#endif
// Function prototypes
LOCAL_C TInt doExample();
LOCAL_C void callExampleL();
//////////////////////////////////////////////////////////////////////////////
//
// -----> CExample (definition)
//
// The class is used by the example code
//
//////////////////////////////////////////////////////////////////////////////
class CExample : public CBase
{
public :
void DoSomethingL();
public :
TInt iInt;
};
//////////////////////////////////////////////////////////////////////////////
//
// -----> CExample (implementation)
//
//////////////////////////////////////////////////////////////////////////////
void CExample::DoSomethingL()
{
// Leave if the global flag is set
if (leaveFlag)
{
_LIT(KMsgLeaving,"DoSomethingL leaving.\n");
console->Printf(KMsgLeaving);
User::Leave(KErrGeneral);
}
console->Printf(KCommonFormat1,iInt);
}
//////////////////////////////////////////////////////////////////////////////
//
// Main function called by E32
//
//////////////////////////////////////////////////////////////////////////////
GLDEF_C TInt E32Main()
{
// Get cleanup stack
CTrapCleanup* cleanup=CTrapCleanup::New();
// Some more initialization, then do the example
TRAPD(error,callExampleL());
// callExampleL() should never leave.
_LIT(KMsgPanicEpoc32ex,"EPOC32EX");
__ASSERT_ALWAYS(!error,User::Panic(KMsgPanicEpoc32ex,error));
// destroy the cleanup stack
delete cleanup;
// return
return 0;
}
//////////////////////////////////////////////////////////////////////////////
//
//
//
//////////////////////////////////////////////////////////////////////////////
LOCAL_C void callExampleL()
{
// Initialize and call the example code under cleanup stack
_LIT(KMsgExampleCode,"Symbian OS Example Code");
console = Console::NewL(KMsgExampleCode,TSize(KConsFullScreen,KConsFullScreen));
// Put console onto the cleanup stack
CleanupStack::PushL(console);
// Perform the example function
TInt retVal;
retVal = doExample();
// Show the value returned from the example
_LIT(KFormat2,"Return code=%d.\n");
console->Printf(KFormat2, retVal);
_LIT(KMsgPressAnyKey," [press any key]");
console->Printf(KMsgPressAnyKey);
console->Getch();
// Remove the console object from the cleanupstack
// and destroy it
CleanupStack::PopAndDestroy();
}
//////////////////////////////////////////////////////////////////////////////
//
// Do the example
//
//////////////////////////////////////////////////////////////////////////////
TInt doExample()
{
// Memory alloc fails on the 'allocFailNumber' attempt.
__UHEAP_SETFAIL(RHeap::EDeterministic,allocFailNumber);
// Allocate and test
CExample* myExample = new CExample;
if (!myExample) return(KErrNoMemory);
// Do something with the CExample object
myExample->iInt = 5;
//
console->Printf(KCommonFormat1,myExample->iInt);
// Delete the CExample object
delete myExample;
// Completed OK
return KErrNone;
}
| [
"liuxk99@bdc341c6-17c0-11de-ac9f-1d9250355bca"
]
| [
[
[
1,
159
]
]
]
|
c16704dbbb8531d85b35085a60fe3d65fbdb9ad2 | 221e3e713891c951e674605eddd656f3a4ce34df | /core/OUE/Vector.h | 8ab6d14bce0cefde642a5997bf5f23e6debe0045 | [
"MIT"
]
| permissive | zacx-z/oneu-engine | da083f817e625c9e84691df38349eab41d356b76 | d47a5522c55089a1e6d7109cebf1c9dbb6860b7d | refs/heads/master | 2021-05-28T12:39:03.782147 | 2011-10-18T12:33:45 | 2011-10-18T12:33:45 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 4,307 | h | /*
This source file is part of OneU Engine.
Copyright (c) 2011 Ladace
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.
*/
/**
* @file Vector.h
* @brief ÏòÁ¿¼°ÐÎ×´
* @author Ladace
* @version 1.0.0.1
* @date 2011-04-09
*/
#pragma once
#include "OUEDefs.h"
namespace OneU
{
template<typename T>
struct rect_t
{
T left, top, right, bottom;
rect_t(){}
rect_t(T left, T top, T right, T bottom)
: left(left), top(top), right(right), bottom(bottom){}
};
template<typename T>
struct Vector2
{
T x, y;
Vector2(){}
Vector2(T x, T y) : x(x), y(y){}
template<typename U>
Vector2(Vector2<U>& rhs) : x((T)rhs.x), y((T)rhs.y){}
float length(){ return sqrt((float)x * x + y * y);}
};
template<class T>
inline Vector2<T> operator+(const Vector2<T>& lhs, const Vector2<T>& rhs){
return Vector2<T>(lhs.x + rhs.x, lhs.y + rhs.y);
}
template<class T>
inline Vector2<T> operator-(const Vector2<T>& lhs){
return Vector2<T>(-lhs.x, -lhs.y);
}
template<class T>
inline Vector2<T> operator-(const Vector2<T>& lhs, const Vector2<T>& rhs){
return lhs + (-rhs);
}
template<class T>
inline Vector2<T> operator*(T lhs, const Vector2<T>& rhs){
return Vector2<T>(lhs * rhs.x, lhs * rhs.y);
}
template<class T>
inline Vector2<T> operator*(const Vector2<T>& lhs, T rhs){
return rhs * lhs;
}
template<class T>
inline Vector2<T> operator/(const Vector2<T>& lhs, T rhs){
return Vector2<T>(lhs.x / rhs, lhs.y / rhs);
}
template<class T>
inline T operator*(const Vector2<T>& lhs, const Vector2<T>& rhs){
return lhs.x * rhs.x + lhs.y * rhs.y;
}
template<typename T>
struct Vector3
{
T x, y, z;
Vector3(){}
Vector3(T x, T y, T z) : x(x), y(y), z(z){}
template<typename U>
Vector3(Vector3<U>& rhs) : x((T)rhs.x), y((T)rhs.y), z((T)rhs.z){}
float length(){ return sqrt((float)x * x + y * y); }
};
template<class T>
inline Vector3<T> operator+(const Vector3<T>& lhs, const Vector3<T>& rhs){
return Vector3<T>(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z);
}
template<class T>
inline Vector3<T> operator-(const Vector3<T>& lhs){
return Vector3<T>(-lhs.x, -lhs.y, -lhs.z);
}
template<class T>
inline Vector3<T> operator-(const Vector3<T>& lhs, const Vector3<T>& rhs){
return lhs + (-rhs);
}
template<class T>
inline Vector3<T> operator*(T lhs, const Vector3<T>& rhs){
return Vector3<T>(lhs * rhs.x, lhs * rhs.y, lhs * rhs.z);
}
template<class T>
inline Vector3<T> operator*(const Vector3<T>& lhs, T rhs){
return rhs * lhs;
}
template<class T>
inline Vector3<T> operator/(const Vector3<T>& lhs, T rhs){
return Vector3<T>(lhs.x / rhs, lhs.y / rhs, lhs.z / rhs);
}
template<class T>
inline T operator*(const Vector3<T>& lhs, const Vector3<T>& rhs){
return lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z;
}
template<typename T>
struct Vector4
{
T x, y, z, w;
Vector4(){}
Vector4(T x, T y, T z, T w) : x(x), y(y), z(z), w(w){}
};
typedef rect_t<int> recti_t;
typedef rect_t<float> rect;
typedef Vector2<int> vector2i_t;
typedef Vector2<float> vector2;
typedef Vector3<int> vector3i_t;
typedef Vector3<float> vector3;
typedef Vector4<int> vector4i_t;
typedef Vector4<float> vector4;
}
| [
"[email protected]@d30a3831-f586-b1a3-add9-2db6dc386f9c"
]
| [
[
[
1,
143
]
]
]
|
724bebf18ec388196287527192b917ef558a0ab3 | 9a48be80edc7692df4918c0222a1640545384dbb | /Libraries/Boost1.40/libs/spirit/example/qi/mini_c/mini_ca.cpp | eeb9bd270b30dbea7ff5f3c0ec8f65c32926be96 | [
"BSL-1.0"
]
| permissive | fcrick/RepSnapper | 05e4fb1157f634acad575fffa2029f7f655b7940 | a5809843f37b7162f19765e852b968648b33b694 | refs/heads/master | 2021-01-17T21:42:29.537504 | 2010-06-07T05:38:05 | 2010-06-07T05:38:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,502 | cpp | /*=============================================================================
Copyright (c) 2001-2007 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include "mini_c.hpp"
# pragma warning(disable: 4800) // forcing value to bool 'true' or 'false'
// (performance warning)
int vmachine::execute(
std::vector<int> const& code
, std::vector<int>::const_iterator pc
, std::vector<int>::iterator frame_ptr
)
{
std::vector<int>::iterator stack_ptr = frame_ptr;
while (true)
{
BOOST_ASSERT(pc != code.end());
switch (*pc++)
{
case op_neg:
stack_ptr[-1] = -stack_ptr[-1];
break;
case op_not:
stack_ptr[-1] = !bool(stack_ptr[-1]);
break;
case op_add:
--stack_ptr;
stack_ptr[-1] += stack_ptr[0];
break;
case op_sub:
--stack_ptr;
stack_ptr[-1] -= stack_ptr[0];
break;
case op_mul:
--stack_ptr;
stack_ptr[-1] *= stack_ptr[0];
break;
case op_div:
--stack_ptr;
stack_ptr[-1] /= stack_ptr[0];
break;
case op_eq:
--stack_ptr;
stack_ptr[-1] = bool(stack_ptr[-1] == stack_ptr[0]);
break;
case op_neq:
--stack_ptr;
stack_ptr[-1] = bool(stack_ptr[-1] != stack_ptr[0]);
break;
case op_lt:
--stack_ptr;
stack_ptr[-1] = bool(stack_ptr[-1] < stack_ptr[0]);
break;
case op_lte:
--stack_ptr;
stack_ptr[-1] = bool(stack_ptr[-1] <= stack_ptr[0]);
break;
case op_gt:
--stack_ptr;
stack_ptr[-1] = bool(stack_ptr[-1] > stack_ptr[0]);
break;
case op_gte:
--stack_ptr;
stack_ptr[-1] = bool(stack_ptr[-1] >= stack_ptr[0]);
break;
case op_and:
--stack_ptr;
stack_ptr[-1] = bool(stack_ptr[-1]) && bool(stack_ptr[0]);
break;
case op_or:
--stack_ptr;
stack_ptr[-1] = bool(stack_ptr[-1]) || bool(stack_ptr[0]);
break;
case op_load:
*stack_ptr++ = frame_ptr[*pc++];
break;
case op_store:
--stack_ptr;
frame_ptr[*pc++] = stack_ptr[0];
break;
case op_int:
*stack_ptr++ = *pc++;
break;
case op_true:
*stack_ptr++ = true;
break;
case op_false:
*stack_ptr++ = false;
break;
case op_jump:
pc = code.begin() + *pc;
break;
case op_jump_if:
if (!bool(stack_ptr[-1]))
pc = code.begin() + *pc;
else
++pc;
--stack_ptr;
break;
case op_stk_adj:
stack_ptr += *pc++;
break;
case op_call:
{
int nargs = *pc++;
int jump = *pc++;
// a function call is a recursive call to execute
int r = execute(
code
, code.begin() + jump
, stack_ptr - nargs
);
// cleanup after return from function
stack_ptr[-nargs] = r; // get return value
stack_ptr -= (nargs - 1); // the stack will now contain
// the return value
}
break;
case op_return:
return stack_ptr[-1];
}
}
}
| [
"metrix@Blended.(none)"
]
| [
[
[
1,
155
]
]
]
|
b1347f54e08bf88bdd39b11e1e5ab4962f66b7ed | 9c62af23e0a1faea5aaa8dd328ba1d82688823a5 | /rl/trunk/engine/core/src/Zone.cpp | 01c87bbc6bc7e62bf64241dfe2b30cc404196f9b | [
"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 | 4,015 | cpp | /* This source file is part of Rastullahs Lockenpracht.
* Copyright (C) 2003-2008 Team Pantheon. http://www.team-pantheon.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the Clarified Artistic License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Clarified Artistic License for more details.
*
* You should have received a copy of the Clarified Artistic License
* along with this program; if not you can get it here
* http://www.jpaulmorrison.com/fbp/artistic2.htm.
*/
#include "stdinc.h" //precompiled header
#include "Zone.h"
#include "ActorManager.h"
#include "GameAreaEvent.h"
#include "GameEventManager.h"
#include "Trigger.h"
#include "ZoneManager.h"
namespace rl
{
Zone::Zone(long id, bool needsToBeSaved) : mId(id), mEaxPreset(""), mNeedsToBeSaved(needsToBeSaved), mPersonsInside(0)
{
}
Zone::~Zone()
{
}
void Zone::addLight(Actor* lo)
{
if (lo != NULL)
{
mLights.push_back(lo);
}
}
void Zone::addSound(const Ogre::String& sound)
{
if (sound.length() > 0)
{
mSounds.push_back(sound);
}
}
void Zone::addTrigger(Trigger* trigger)
{
if (trigger != NULL)
{
mTriggers.push_back(trigger);
}
}
void Zone::setEaxPreset(const Ogre::String& name)
{
mEaxPreset = name;
}
std::list<Actor*> Zone::getLights() const
{
std::list<Actor*> rval(mLights);
return rval;
}
std::list<Ogre::String> Zone::getSounds() const
{
std::list<Ogre::String> rval(mSounds);
return rval;
}
std::list<Trigger*> Zone::getTriggers() const
{
std::list<Trigger*> rval(mTriggers);
return rval;
}
const Ogre::String& Zone::getEaxPreset() const
{
return mEaxPreset;
}
void Zone::removeLight(Actor *light)
{
if( !light )
Throw(NullPointerException, "Light-Actor is NULL!");
std::list<Actor*>::iterator it =
std::find(mLights.begin(), mLights.end(), light);
if( it == mLights.end() )
Throw(IllegalArgumentException, "Could not find light-actor '" + light->getName() + "' in this zone!");
mLights.erase(it);
}
void Zone::removeSound(const Ogre::String& sound)
{
std::list<Ogre::String>::iterator it =
std::find(mSounds.begin(), mSounds.end(), sound);
if( it == mSounds.end() )
Throw(IllegalArgumentException, "Could not find sound '" + sound + "' in this zone!");
mSounds.erase(it);
}
void Zone::removeTrigger(Trigger* trigger)
{
if( !trigger )
Throw(NullPointerException, "Trigger is NULL!");
std::list<Trigger*>::iterator it =
std::find(mTriggers.begin(), mTriggers.end(), trigger);
if( it == mTriggers.end() )
Throw(IllegalArgumentException, "Could not find the Trigger in this zone!");
mTriggers.erase(it);
}
void Zone::addEventSource(GameAreaEventSource *gam)
{
if( gam != NULL )
mEventSources.insert(gam);
}
void Zone::removeEventSource(GameAreaEventSource *gam)
{
if( gam )
{
GameAreaEventSourceList::iterator it = mEventSources.find(gam);
if( it == mEventSources.end() )
LOG_ERROR(Logger::CORE, "Could not find the GameAreaEventSource in this zone!");
mEventSources.erase(it);
}
}
GameAreaEventSourceList& Zone::getEventSources()
{
return mEventSources;
}
bool Zone::isActive() const
{
return mPersonsInside > 0;
}
void Zone::personEntered()
{
mPersonsInside++;
}
void Zone::personLeft()
{
mPersonsInside--;
}
}
| [
"blakharaz@4c79e8ff-cfd4-0310-af45-a38c79f83013",
"ablock@4c79e8ff-cfd4-0310-af45-a38c79f83013",
"melven@4c79e8ff-cfd4-0310-af45-a38c79f83013"
]
| [
[
[
1,
2
],
[
4,
15
],
[
18,
25
],
[
27,
29
],
[
33,
33
],
[
37,
53
],
[
67,
71
],
[
73,
78
],
[
80,
80
],
[
84,
84
],
[
145,
145
],
[
161,
161
]
],
[
[
3,
3
],
[
16,
17
],
[
26,
26
],
[
72,
72
]
],
[
[
30,
32
],
[
34,
36
],
[
54,
66
],
[
79,
79
],
[
81,
83
],
[
85,
144
],
[
146,
160
]
]
]
|
3a5830f94670eeee3855309c7ee3b01dc65982ea | 85d9531c984cd9ffc0c9fe8058eb1210855a2d01 | /QxOrm/include/QxSerialize/Qt/QxSerialize_QMap.h | f29384eaa280f02a13e619290433aa1c82ef47c4 | []
| no_license | padenot/PlanningMaker | ac6ece1f60345f857eaee359a11ee6230bf62226 | d8aaca0d8cdfb97266091a3ac78f104f8d13374b | refs/heads/master | 2020-06-04T12:23:15.762584 | 2011-02-23T21:36:57 | 2011-02-23T21:36:57 | 1,125,341 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,822 | h | /****************************************************************************
**
** http://www.qxorm.com/
** http://sourceforge.net/projects/qxorm/
** Original file by Lionel Marty
**
** This file is part of the QxOrm library
**
** This software is provided 'as-is', without any express or implied
** warranty. In no event will the authors be held liable for any
** damages arising from the use of this software.
**
** GNU Lesser General Public License Usage
** This file must be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file 'license.lgpl.txt' included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you have questions regarding the use of this file, please contact :
** [email protected]
**
****************************************************************************/
#ifndef _QX_SERIALIZE_QMAP_H_
#define _QX_SERIALIZE_QMAP_H_
#ifdef _MSC_VER
#pragma once
#endif
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/split_free.hpp>
#include <boost/serialization/version.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/utility.hpp>
#include <QtCore/qmap.h>
namespace boost {
namespace serialization {
template <class Archive, typename Key, typename Value>
inline void save(Archive & ar, const QMap<Key, Value> & t, const unsigned int file_version)
{
Q_UNUSED(file_version);
long lCount = t.count();
ar << boost::serialization::make_nvp("count", lCount);
QMapIterator<Key, Value> itr(t);
while (itr.hasNext())
{
itr.next();
std::pair<Key, Value> pair_key_value = std::make_pair(itr.key(), itr.value());
ar << boost::serialization::make_nvp("item", pair_key_value);
}
}
template <class Archive, typename Key, typename Value>
inline void load(Archive & ar, QMap<Key, Value> & t, const unsigned int file_version)
{
Q_UNUSED(file_version);
long lCount = 0;
ar >> boost::serialization::make_nvp("count", lCount);
t.clear();
std::pair<Key, Value> pair_key_value;
for (long l = 0; l < lCount; l++)
{
ar >> boost::serialization::make_nvp("item", pair_key_value);
t.insert(pair_key_value.first, pair_key_value.second);
}
}
template <class Archive, typename Key, typename Value>
inline void serialize(Archive & ar, QMap<Key, Value> & t, const unsigned int file_version)
{
boost::serialization::split_free(ar, t, file_version);
}
} // namespace boost
} // namespace serialization
#endif // _QX_SERIALIZE_QMAP_H_
| [
"[email protected]"
]
| [
[
[
1,
86
]
]
]
|
ff429de195635feed52c236a386dac65c34b6435 | 58496be10ead81e2531e995f7d66017ffdfc6897 | /Include/DBWrapper.h | 9980f9beeeab1c1f842f1cfdfa6a43bae175f5be | []
| no_license | Diego160289/cross-fw | ba36fc6c3e3402b2fff940342315596e0365d9dd | 532286667b0fd05c9b7f990945f42279bac74543 | refs/heads/master | 2021-01-10T19:23:43.622578 | 2011-01-09T14:54:12 | 2011-01-09T14:54:12 | 38,457,864 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,312 | h | //============================================================================
// Date : 26.12.2010
// Author : Tkachenko Dmitry
// Copyright : (c) Tkachenko Dmitry ([email protected])
//============================================================================
#ifndef __DBWRAPPERS_H__
#define __DBWRAPPERS_H__
#include "DBClient.h"
#include "RefObjPtr.h"
#include "Exceptions.h"
#include <string>
namespace Common
{
namespace Wrappers
{
namespace DB
{
typedef Common::RefObjPtr<IFaces::DBIFaces::IConnection> IConnectionPtr;
typedef Common::RefObjPtr<IFaces::DBIFaces::ITransaction> ITransactionPtr;
typedef Common::RefObjPtr<IFaces::DBIFaces::IStatement> IStatementPtr;
typedef Common::RefObjPtr<IFaces::DBIFaces::IParameter> IParameterPtr;
typedef Common::RefObjPtr<IFaces::DBIFaces::IField> IFieldPtr;
DECLARE_RUNTIME_EXCEPTION(Connection)
class Connection
{
public:
Connection(IConnectionPtr conn);
void Connect(const std::string &connectionString, const std::string &userName, const std::string &password);
void Disconnect();
ITransactionPtr CreateTransaction();
IStatementPtr CreateStatement();
private:
IConnectionPtr Conn;
};
DECLARE_RUNTIME_EXCEPTION(Transaction)
class Transaction
{
public:
Transaction(ITransactionPtr tr);
void Commit();
void Rollback();
private:
ITransactionPtr Tr;
};
DECLARE_RUNTIME_EXCEPTION(Statement)
class Statement
{
public:
Statement(IStatementPtr stmt);
void Prepare(const std::string &str);
void ExecuteDirect(const std::string &str);
void Execute();
bool Fetch();
IParameterPtr GetParameter(unsigned index);
IFieldPtr GetField(unsigned index) const;
unsigned GetFieldsCount() const;
private:
IStatementPtr Stmt;
};
DECLARE_RUNTIME_EXCEPTION(Parameter)
class Parameter
{
public:
Parameter(IParameterPtr prm);
void SetParam(long value);
void SetParam(unsigned long value);
void SetParam(double value);
void SetParam(const std::string &value);
void SetParam(const std::wstring &value);
void SetParam(const IFaces::DBIFaces::DateTime &value);
void SetParam(const IFaces::DBIFaces::Date &value);
void SetParam(const IFaces::DBIFaces::Time &value);
void SetParam(bool value);
private:
IParameterPtr Prm;
};
DECLARE_RUNTIME_EXCEPTION(Field)
class Field
{
public:
Field(IFieldPtr fld);
operator long () const;
operator unsigned long () const;
operator double () const;
operator std::string () const;
operator std::wstring () const;
operator IFaces::DBIFaces::DateTime () const;
operator IFaces::DBIFaces::Date () const;
operator IFaces::DBIFaces::Time () const;
operator bool () const;
private:
IFieldPtr Fld;
};
}
}
}
#endif // !__DBWRAPPERS_H__
| [
"TkachenkoDmitryV@d548627a-540d-11de-936b-e9512c4d2277"
]
| [
[
[
1,
123
]
]
]
|
2a20ef8b0f18023801fc5db0cb2ea777c1761f97 | e192bb584e8051905fc9822e152792e9f0620034 | /tags/sources_0_1/noyau/modele.h | 3789ae662f69c1807b7681993fc313804576c48f | []
| no_license | BackupTheBerlios/projet-univers-svn | 708ffadce21f1b6c83e3b20eb68903439cf71d0f | c9488d7566db51505adca2bc858dab5604b3c866 | refs/heads/master | 2020-05-27T00:07:41.261961 | 2011-07-31T20:55:09 | 2011-07-31T20:55:09 | 40,817,685 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 2,298 | h | /***************************************************************************
* Copyright (C) 2004 by Equipe Projet Univers *
* [email protected] *
* *
* 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 _PU_NOYAU_MODELE_H_
#define _PU_NOYAU_MODELE_H_
namespace ProjetUnivers {
namespace Noyau {
/*
CLASS
Modele
Classe abstraite des données utilisateur.
TYPE_DE_CLASSE
Objet
Abstrait
*/
class Modele {
public:
// *******************
// GROUP: Destructeur
// *******************
//////////////////
// Classe abstraite donc destructeur virtuel.
virtual ~Modele() ;
protected:
// *******************
// GROUP: Constructeur
// *******************
//////////////////////
// Classe abstraite donc constructeur protégé.
Modele() ;
};
}
}
#endif
| [
"rogma@fb75c231-3be1-0310-9bb4-c95e2f850c73"
]
| [
[
[
1,
73
]
]
]
|
3215dd693dc0f2310671a503d48c9ed75630c93a | a84b013cd995870071589cefe0ab060ff3105f35 | /webdriver/branches/jsapi/third_party/gecko-1.9.0.11/win32/include/nsIDOMDOMImplementation.h | 4f2d56e43d0abc9a8ecc9232d30d6e06e186fb65 | [
"Apache-2.0"
]
| permissive | vdt/selenium | 137bcad58b7184690b8785859d77da0cd9f745a0 | 30e5e122b068aadf31bcd010d00a58afd8075217 | refs/heads/master | 2020-12-27T21:35:06.461381 | 2009-08-18T15:56:32 | 2009-08-18T15:56:32 | 13,650,409 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,137 | h | /*
* DO NOT EDIT. THIS FILE IS GENERATED FROM e:/xr19rel/WINNT_5.2_Depend/mozilla/dom/public/idl/core/nsIDOMDOMImplementation.idl
*/
#ifndef __gen_nsIDOMDOMImplementation_h__
#define __gen_nsIDOMDOMImplementation_h__
#ifndef __gen_domstubs_h__
#include "domstubs.h"
#endif
/* For IDL files that don't want to include root IDL files. */
#ifndef NS_NO_VTABLE
#define NS_NO_VTABLE
#endif
/* starting interface: nsIDOMDOMImplementation */
#define NS_IDOMDOMIMPLEMENTATION_IID_STR "a6cf9074-15b3-11d2-932e-00805f8add32"
#define NS_IDOMDOMIMPLEMENTATION_IID \
{0xa6cf9074, 0x15b3, 0x11d2, \
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 }}
class NS_NO_VTABLE NS_SCRIPTABLE nsIDOMDOMImplementation : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMDOMIMPLEMENTATION_IID)
/**
* The nsIDOMDOMImplementation interface provides a number of methods for
* performing operations that are independent of any particular instance
* of the document object model.
*
* For more information on this interface please see
* http://www.w3.org/TR/DOM-Level-2-Core/
*
* @status FROZEN
*/
/* boolean hasFeature (in DOMString feature, in DOMString version); */
NS_SCRIPTABLE NS_IMETHOD HasFeature(const nsAString & feature, const nsAString & version, PRBool *_retval) = 0;
/* nsIDOMDocumentType createDocumentType (in DOMString qualifiedName, in DOMString publicId, in DOMString systemId) raises (DOMException); */
NS_SCRIPTABLE NS_IMETHOD CreateDocumentType(const nsAString & qualifiedName, const nsAString & publicId, const nsAString & systemId, nsIDOMDocumentType **_retval) = 0;
/* nsIDOMDocument createDocument (in DOMString namespaceURI, in DOMString qualifiedName, in nsIDOMDocumentType doctype) raises (DOMException); */
NS_SCRIPTABLE NS_IMETHOD CreateDocument(const nsAString & namespaceURI, const nsAString & qualifiedName, nsIDOMDocumentType *doctype, nsIDOMDocument **_retval) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMDOMImplementation, NS_IDOMDOMIMPLEMENTATION_IID)
/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_NSIDOMDOMIMPLEMENTATION \
NS_SCRIPTABLE NS_IMETHOD HasFeature(const nsAString & feature, const nsAString & version, PRBool *_retval); \
NS_SCRIPTABLE NS_IMETHOD CreateDocumentType(const nsAString & qualifiedName, const nsAString & publicId, const nsAString & systemId, nsIDOMDocumentType **_retval); \
NS_SCRIPTABLE NS_IMETHOD CreateDocument(const nsAString & namespaceURI, const nsAString & qualifiedName, nsIDOMDocumentType *doctype, nsIDOMDocument **_retval);
/* Use this macro to declare functions that forward the behavior of this interface to another object. */
#define NS_FORWARD_NSIDOMDOMIMPLEMENTATION(_to) \
NS_SCRIPTABLE NS_IMETHOD HasFeature(const nsAString & feature, const nsAString & version, PRBool *_retval) { return _to HasFeature(feature, version, _retval); } \
NS_SCRIPTABLE NS_IMETHOD CreateDocumentType(const nsAString & qualifiedName, const nsAString & publicId, const nsAString & systemId, nsIDOMDocumentType **_retval) { return _to CreateDocumentType(qualifiedName, publicId, systemId, _retval); } \
NS_SCRIPTABLE NS_IMETHOD CreateDocument(const nsAString & namespaceURI, const nsAString & qualifiedName, nsIDOMDocumentType *doctype, nsIDOMDocument **_retval) { return _to CreateDocument(namespaceURI, qualifiedName, doctype, _retval); }
/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
#define NS_FORWARD_SAFE_NSIDOMDOMIMPLEMENTATION(_to) \
NS_SCRIPTABLE NS_IMETHOD HasFeature(const nsAString & feature, const nsAString & version, PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->HasFeature(feature, version, _retval); } \
NS_SCRIPTABLE NS_IMETHOD CreateDocumentType(const nsAString & qualifiedName, const nsAString & publicId, const nsAString & systemId, nsIDOMDocumentType **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->CreateDocumentType(qualifiedName, publicId, systemId, _retval); } \
NS_SCRIPTABLE NS_IMETHOD CreateDocument(const nsAString & namespaceURI, const nsAString & qualifiedName, nsIDOMDocumentType *doctype, nsIDOMDocument **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->CreateDocument(namespaceURI, qualifiedName, doctype, _retval); }
#if 0
/* Use the code below as a template for the implementation class for this interface. */
/* Header file */
class nsDOMDOMImplementation : public nsIDOMDOMImplementation
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMDOMIMPLEMENTATION
nsDOMDOMImplementation();
private:
~nsDOMDOMImplementation();
protected:
/* additional members */
};
/* Implementation file */
NS_IMPL_ISUPPORTS1(nsDOMDOMImplementation, nsIDOMDOMImplementation)
nsDOMDOMImplementation::nsDOMDOMImplementation()
{
/* member initializers and constructor code */
}
nsDOMDOMImplementation::~nsDOMDOMImplementation()
{
/* destructor code */
}
/* boolean hasFeature (in DOMString feature, in DOMString version); */
NS_IMETHODIMP nsDOMDOMImplementation::HasFeature(const nsAString & feature, const nsAString & version, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIDOMDocumentType createDocumentType (in DOMString qualifiedName, in DOMString publicId, in DOMString systemId) raises (DOMException); */
NS_IMETHODIMP nsDOMDOMImplementation::CreateDocumentType(const nsAString & qualifiedName, const nsAString & publicId, const nsAString & systemId, nsIDOMDocumentType **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIDOMDocument createDocument (in DOMString namespaceURI, in DOMString qualifiedName, in nsIDOMDocumentType doctype) raises (DOMException); */
NS_IMETHODIMP nsDOMDOMImplementation::CreateDocument(const nsAString & namespaceURI, const nsAString & qualifiedName, nsIDOMDocumentType *doctype, nsIDOMDocument **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* End of implementation class template. */
#endif
#endif /* __gen_nsIDOMDOMImplementation_h__ */
| [
"simon.m.stewart@07704840-8298-11de-bf8c-fd130f914ac9"
]
| [
[
[
1,
125
]
]
]
|
25c9c9f7a08a9bba0b42876277b0012af2a01d8e | 29e87c19d99b77d379b2f9760f5e7afb3b3790fa | /src/audio/decoder_oggvorbisfile.h | ed37e9208756e1971d8b4225077df9d902dcbbbb | []
| no_license | wilcobrouwer/dmplayer | c0c63d9b641a0f76e426ed30c3a83089166d0000 | 9f767a15e25016f6ada4eff6a1cdd881ad922915 | refs/heads/master | 2021-05-30T17:23:21.889844 | 2011-03-29T08:51:52 | 2011-03-29T08:51:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 569 | h | #ifndef DECODER_OGGVORBISFILE_H
#define DECODER_OGGVORBISFILE_H
#include "decoder_interface.h"
#include <vorbis/vorbisfile.h>
class OGGVorbisFileDecoder : public IDecoder{
private:
IDataSourceRef datasource;
OggVorbis_File* oggFile;
OGGVorbisFileDecoder(AudioFormat af, IDataSourceRef ds, OggVorbis_File* oggFile);
int bitStream;
bool eos;
public:
~OGGVorbisFileDecoder();
static IDecoderRef tryDecode(IDataSourceRef datasource);
uint32 getData(uint8* buf, uint32 max);
bool exhausted();
};
#endif//DECODER_OGGVORBISFILE_H
| [
"simon.sasburg@e69229e2-1541-0410-bedc-87cb2d1b0d4b",
"daniel.geelen@e69229e2-1541-0410-bedc-87cb2d1b0d4b"
]
| [
[
[
1,
13
],
[
15,
18
],
[
20,
22
]
],
[
[
14,
14
],
[
19,
19
]
]
]
|
9d91bbec28ee4977b28c53f6d6267c497a258f8c | 97fd2a81a3baffb26dc5b627c08aa4a69574a761 | /inc/Content/FeedItem.h | 39326bf19bd47536de2464922a92b28b06e50fa3 | []
| no_license | drstrangecode/Bada_RssReader_DrStrangecode | c4c61dacabacf9419a0335d70a141dc8374c8b2e | b3cf7b1f6afc43af782c0713fa6b54b1e95d0c1a | refs/heads/master | 2016-09-06T05:34:10.075095 | 2011-10-16T16:08:46 | 2011-10-16T16:08:46 | 2,542,044 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,051 | h | /*
* FeedItem.h
*
* Created by: Dr. Strangecode
* ---------------------------------------------
* This is free code, it can be used, modified,
* destroyed, raped and whatever without limits.
* I own no copyrights over it.
* This code is provided AS IS without warranty
* of any kind either expressed or implied,
* including but not limited to the implied
* warranties of merchantability and/or fitness
* for a particular purpose.
* ---------------------------------------------
* For more free code visit http://drstrangecode.org
*/
#ifndef FEEDITEM_H_
#define FEEDITEM_H_
#include <FBase.h>
class FeedItem : public Osp::Base::Object {
public:
FeedItem();
result Construct();
virtual ~FeedItem();
Osp::Base::String title;
Osp::Base::String link;
Osp::Base::String pubDate;
Osp::Base::String creator;
Osp::Base::Collection::ArrayList categories;
Osp::Base::String commentsRssUrl;
Osp::Base::String description;
Osp::Base::Integer commentsCount;
};
#endif /* FEEDITEM_H_ */
| [
"[email protected]"
]
| [
[
[
1,
43
]
]
]
|
8ae7e1439a143f6f45a98fe35a5816093c70f08f | a2ba072a87ab830f5343022ed11b4ac365f58ef0 | / urt-bumpy-q3map2 --username [email protected]/libs/splines/math_matrix.h | 15d028288cccc4d9e411666ecac2d36b8a85dc89 | []
| no_license | Garey27/urt-bumpy-q3map2 | 7d0849fc8eb333d9007213b641138e8517aa092a | fcc567a04facada74f60306c01e68f410cb5a111 | refs/heads/master | 2021-01-10T17:24:51.991794 | 2010-06-22T13:19:24 | 2010-06-22T13:19:24 | 43,057,943 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,535 | h | /*
This code is based on source provided under the terms of the Id Software
LIMITED USE SOFTWARE LICENSE AGREEMENT, a copy of which is included with the
GtkRadiant sources (see LICENSE_ID). If you did not receive a copy of
LICENSE_ID, please contact Id Software immediately at [email protected].
All changes and additions to the original source which have been developed by
other contributors (see CONTRIBUTORS) are provided under the terms of the
license the contributors choose (see LICENSE), to the extent permitted by the
LICENSE_ID. If you did not receive a copy of the contributor license,
please contact the GtkRadiant maintainers at [email protected] immediately.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __MATH_MATRIX_H__
#define __MATH_MATRIX_H__
#include <string.h>
#include "math_vector.h"
#ifndef ID_INLINE
#ifdef _WIN32
#define ID_INLINE __inline
#else
#define ID_INLINE inline
#endif
#endif
class quat_t;
class angles_t;
class mat3_t {
public:
idVec3 mat[ 3 ];
mat3_t();
mat3_t( float src[ 3 ][ 3 ] );
mat3_t( idVec3 const &x, idVec3 const &y, idVec3 const &z );
mat3_t( const float xx, const float xy, const float xz, const float yx, const float yy, const float yz, const float zx, const float zy, const float zz );
friend void toMatrix( quat_t const &src, mat3_t &dst );
friend void toMatrix( angles_t const &src, mat3_t &dst );
friend void toMatrix( idVec3 const &src, mat3_t &dst );
idVec3 operator[]( int index ) const;
idVec3 &operator[]( int index );
idVec3 operator*( const idVec3 &vec ) const;
mat3_t operator*( const mat3_t &a ) const;
mat3_t operator*( float a ) const;
mat3_t operator+( mat3_t const &a ) const;
mat3_t operator-( mat3_t const &a ) const;
friend idVec3 operator*( const idVec3 &vec, const mat3_t &mat );
friend mat3_t operator*( float a, mat3_t const &b );
mat3_t &operator*=( float a );
mat3_t &operator+=( mat3_t const &a );
mat3_t &operator-=( mat3_t const &a );
void Clear( void );
void ProjectVector( const idVec3 &src, idVec3 &dst ) const;
void UnprojectVector( const idVec3 &src, idVec3 &dst ) const;
void OrthoNormalize( void );
void Transpose( mat3_t &matrix );
void Transpose( void );
mat3_t Inverse( void ) const;
void Identity( void );
friend void InverseMultiply( const mat3_t &inv, const mat3_t &b, mat3_t &dst );
friend mat3_t SkewSymmetric( idVec3 const &src );
};
ID_INLINE mat3_t::mat3_t() {
}
ID_INLINE mat3_t::mat3_t( float src[ 3 ][ 3 ] ) {
memcpy( mat, src, sizeof( src ) );
}
ID_INLINE mat3_t::mat3_t( idVec3 const &x, idVec3 const &y, idVec3 const &z ) {
mat[ 0 ].x = x.x; mat[ 0 ].y = x.y; mat[ 0 ].z = x.z;
mat[ 1 ].x = y.x; mat[ 1 ].y = y.y; mat[ 1 ].z = y.z;
mat[ 2 ].x = z.x; mat[ 2 ].y = z.y; mat[ 2 ].z = z.z;
}
ID_INLINE mat3_t::mat3_t( const float xx, const float xy, const float xz, const float yx, const float yy, const float yz, const float zx, const float zy, const float zz ) {
mat[ 0 ].x = xx; mat[ 0 ].y = xy; mat[ 0 ].z = xz;
mat[ 1 ].x = yx; mat[ 1 ].y = yy; mat[ 1 ].z = yz;
mat[ 2 ].x = zx; mat[ 2 ].y = zy; mat[ 2 ].z = zz;
}
ID_INLINE idVec3 mat3_t::operator[]( int index ) const {
assert( ( index >= 0 ) && ( index < 3 ) );
return mat[ index ];
}
ID_INLINE idVec3& mat3_t::operator[]( int index ) {
assert( ( index >= 0 ) && ( index < 3 ) );
return mat[ index ];
}
ID_INLINE idVec3 mat3_t::operator*( const idVec3 &vec ) const {
return idVec3(
mat[ 0 ].x * vec.x + mat[ 1 ].x * vec.y + mat[ 2 ].x * vec.z,
mat[ 0 ].y * vec.x + mat[ 1 ].y * vec.y + mat[ 2 ].y * vec.z,
mat[ 0 ].z * vec.x + mat[ 1 ].z * vec.y + mat[ 2 ].z * vec.z );
}
ID_INLINE mat3_t mat3_t::operator*( const mat3_t &a ) const {
return mat3_t(
mat[0].x * a[0].x + mat[0].y * a[1].x + mat[0].z * a[2].x,
mat[0].x * a[0].y + mat[0].y * a[1].y + mat[0].z * a[2].y,
mat[0].x * a[0].z + mat[0].y * a[1].z + mat[0].z * a[2].z,
mat[1].x * a[0].x + mat[1].y * a[1].x + mat[1].z * a[2].x,
mat[1].x * a[0].y + mat[1].y * a[1].y + mat[1].z * a[2].y,
mat[1].x * a[0].z + mat[1].y * a[1].z + mat[1].z * a[2].z,
mat[2].x * a[0].x + mat[2].y * a[1].x + mat[2].z * a[2].x,
mat[2].x * a[0].y + mat[2].y * a[1].y + mat[2].z * a[2].y,
mat[2].x * a[0].z + mat[2].y * a[1].z + mat[2].z * a[2].z );
}
ID_INLINE mat3_t mat3_t::operator*( float a ) const {
return mat3_t(
mat[0].x * a, mat[0].y * a, mat[0].z * a,
mat[1].x * a, mat[1].y * a, mat[1].z * a,
mat[2].x * a, mat[2].y * a, mat[2].z * a );
}
ID_INLINE mat3_t mat3_t::operator+( mat3_t const &a ) const {
return mat3_t(
mat[0].x + a[0].x, mat[0].y + a[0].y, mat[0].z + a[0].z,
mat[1].x + a[1].x, mat[1].y + a[1].y, mat[1].z + a[1].z,
mat[2].x + a[2].x, mat[2].y + a[2].y, mat[2].z + a[2].z );
}
ID_INLINE mat3_t mat3_t::operator-( mat3_t const &a ) const {
return mat3_t(
mat[0].x - a[0].x, mat[0].y - a[0].y, mat[0].z - a[0].z,
mat[1].x - a[1].x, mat[1].y - a[1].y, mat[1].z - a[1].z,
mat[2].x - a[2].x, mat[2].y - a[2].y, mat[2].z - a[2].z );
}
ID_INLINE idVec3 operator*( const idVec3 &vec, const mat3_t &mat ) {
return idVec3(
mat[ 0 ].x * vec.x + mat[ 1 ].x * vec.y + mat[ 2 ].x * vec.z,
mat[ 0 ].y * vec.x + mat[ 1 ].y * vec.y + mat[ 2 ].y * vec.z,
mat[ 0 ].z * vec.x + mat[ 1 ].z * vec.y + mat[ 2 ].z * vec.z );
}
ID_INLINE mat3_t operator*( float a, mat3_t const &b ) {
return mat3_t(
b[0].x * a, b[0].y * a, b[0].z * a,
b[1].x * a, b[1].y * a, b[1].z * a,
b[2].x * a, b[2].y * a, b[2].z * a );
}
ID_INLINE mat3_t &mat3_t::operator*=( float a ) {
mat[0].x *= a; mat[0].y *= a; mat[0].z *= a;
mat[1].x *= a; mat[1].y *= a; mat[1].z *= a;
mat[2].x *= a; mat[2].y *= a; mat[2].z *= a;
return *this;
}
ID_INLINE mat3_t &mat3_t::operator+=( mat3_t const &a ) {
mat[0].x += a[0].x; mat[0].y += a[0].y; mat[0].z += a[0].z;
mat[1].x += a[1].x; mat[1].y += a[1].y; mat[1].z += a[1].z;
mat[2].x += a[2].x; mat[2].y += a[2].y; mat[2].z += a[2].z;
return *this;
}
ID_INLINE mat3_t &mat3_t::operator-=( mat3_t const &a ) {
mat[0].x -= a[0].x; mat[0].y -= a[0].y; mat[0].z -= a[0].z;
mat[1].x -= a[1].x; mat[1].y -= a[1].y; mat[1].z -= a[1].z;
mat[2].x -= a[2].x; mat[2].y -= a[2].y; mat[2].z -= a[2].z;
return *this;
}
ID_INLINE void mat3_t::OrthoNormalize( void ) {
mat[ 0 ].Normalize();
mat[ 2 ].Cross( mat[ 0 ], mat[ 1 ] );
mat[ 2 ].Normalize();
mat[ 1 ].Cross( mat[ 2 ], mat[ 0 ] );
mat[ 1 ].Normalize();
}
ID_INLINE void mat3_t::Identity( void ) {
mat[ 0 ].x = 1.f; mat[ 0 ].y = 0.f; mat[ 0 ].z = 0.f;
mat[ 1 ].x = 0.f; mat[ 1 ].y = 1.f; mat[ 1 ].z = 0.f;
mat[ 2 ].x = 0.f; mat[ 2 ].y = 0.f; mat[ 2 ].z = 1.f;
}
ID_INLINE void InverseMultiply( const mat3_t &inv, const mat3_t &b, mat3_t &dst ) {
dst[0].x = inv[0].x * b[0].x + inv[1].x * b[1].x + inv[2].x * b[2].x;
dst[0].y = inv[0].x * b[0].y + inv[1].x * b[1].y + inv[2].x * b[2].y;
dst[0].z = inv[0].x * b[0].z + inv[1].x * b[1].z + inv[2].x * b[2].z;
dst[1].x = inv[0].y * b[0].x + inv[1].y * b[1].x + inv[2].y * b[2].x;
dst[1].y = inv[0].y * b[0].y + inv[1].y * b[1].y + inv[2].y * b[2].y;
dst[1].z = inv[0].y * b[0].z + inv[1].y * b[1].z + inv[2].y * b[2].z;
dst[2].x = inv[0].z * b[0].x + inv[1].z * b[1].x + inv[2].z * b[2].x;
dst[2].y = inv[0].z * b[0].y + inv[1].z * b[1].y + inv[2].z * b[2].y;
dst[2].z = inv[0].z * b[0].z + inv[1].z * b[1].z + inv[2].z * b[2].z;
}
ID_INLINE mat3_t SkewSymmetric( idVec3 const &src ) {
return mat3_t( 0.0f, -src.z, src.y, src.z, 0.0f, -src.x, -src.y, src.x, 0.0f );
}
extern mat3_t mat3_default;
#endif /* !__MATH_MATRIX_H__ */
| [
"[email protected]"
]
| [
[
[
1,
226
]
]
]
|
de0b3014e7f206d20422175653676895ddc2cb3a | 36bf908bb8423598bda91bd63c4bcbc02db67a9d | /Library/CImage.cpp | 7992ecc222ed546d800b6ac6b39d79018431321c | []
| no_license | code4bones/crawlpaper | edbae18a8b099814a1eed5453607a2d66142b496 | f218be1947a9791b2438b438362bc66c0a505f99 | refs/heads/master | 2021-01-10T13:11:23.176481 | 2011-04-14T11:04:17 | 2011-04-14T11:04:17 | 44,686,513 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 55,656 | cpp | /*
CImage.cpp
Classe base per l'interfaccia con le librerie.
Luca Piergentili, 01/09/00
[email protected]
Ad memoriam - Nemo me impune lacessit.
*/
#include "env.h"
#include "pragma.h"
#include "macro.h"
#include <string.h>
#include <math.h>
#include "window.h"
#include "CImage.h"
#include "CNodeList.h"
#include "libjpeg.h"
#include "libtiff.h"
#include "traceexpr.h"
//#define _TRACE_FLAG _TRFLAG_TRACEOUTPUT
//#define _TRACE_FLAG _TRFLAG_NOTRACE
#define _TRACE_FLAG _TRFLAG_NOTRACE
#define _TRACE_FLAG_INFO _TRFLAG_NOTRACE
#define _TRACE_FLAG_WARN _TRFLAG_NOTRACE
#define _TRACE_FLAG_ERR _TRFLAG_NOTRACE
#if (defined(_DEBUG) && defined(_WINDOWS)) && (defined(_AFX) || defined(_AFXDLL))
#ifdef PRAGMA_MESSAGE_VERBOSE
#pragma message("\t\t\t"__FILE__"("STR(__LINE__)"): using DEBUG_NEW macro")
#endif
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/*
CImage()
*/
CImage::CImage()
{
memset(m_szFileName,'\0',sizeof(m_szFileName));
memset(m_szFileExt,'\0',sizeof(m_szFileExt));
m_InfoHeader.type = NULL_PICTURE;
m_InfoHeader.xres = -1;
m_InfoHeader.yres = -1;
m_InfoHeader.restype = -1;
m_InfoHeader.compression = -1;
m_InfoHeader.quality = -1;
m_InfoHeader.filesize = (unsigned long)-1L;
m_InfoHeader.width = (unsigned long)-1L;
m_InfoHeader.height = (unsigned long)-1L;
m_ImageType = NULL_PICTURE;
m_ImageTypeList.DeleteAll();
m_ImageOperationList.DeleteAll();
m_TiffTypeList.DeleteAll();
m_bShowErrors = TRUE;
}
/*
GetFileName()
*/
LPCSTR CImage::GetFileName(void)
{
char *p = strrchr(m_szFileName,'\\');
if(p)
p++;
if(!p)
p = m_szFileName;
return(p);
}
/*
GetFileSize()
*/
DWORD CImage::GetFileSize(void)
{
if(m_InfoHeader.filesize==(unsigned long)-1L)
GetHeaderInfo(m_szFileName,&m_InfoHeader);
return(m_InfoHeader.filesize);
}
/*
GetXRes()
*/
float CImage::GetXRes(void)
{
if(m_InfoHeader.xres==-1)
GetHeaderInfo(m_szFileName,&m_InfoHeader);
return(m_InfoHeader.xres);
}
/*
GetYRes()
*/
float CImage::GetYRes(void)
{
if(m_InfoHeader.yres==-1)
GetHeaderInfo(m_szFileName,&m_InfoHeader);
return(m_InfoHeader.yres);
}
/*
GetURes()
*/
int CImage::GetURes(void)
{
if(m_InfoHeader.restype==-1)
GetHeaderInfo(m_szFileName,&m_InfoHeader);
return(m_InfoHeader.restype);
}
/*
SetURes()
*/
void CImage::SetURes(UINT nURes)
{
if(m_InfoHeader.restype!=(int)nURes && m_InfoHeader.restype!=RESUNITNONE && nURes!=RESUNITNONE && m_InfoHeader.restype!=-1)
{
switch(nURes)
{
case RESUNITINCH:
{
// centimetri
float nXRes = GetXRes() / 2.54f;
float nYRes = GetYRes() / 2.54f;
SetXRes(nXRes);
SetYRes(nYRes);
break;
}
case RESUNITCENTIMETER:
{
// inch
float nXRes = GetXRes() * 2.54f;
float nYRes = GetYRes() * 2.54f;
SetXRes(nXRes);
SetYRes(nYRes);
break;
}
default:
return;
}
}
m_InfoHeader.restype = nURes;
}
/*
GetDPI()
*/
void CImage::GetDPI(float& nXRes,float& nYRes)
{
if(m_InfoHeader.xres==-1 || m_InfoHeader.yres==-1)
GetHeaderInfo(m_szFileName,&m_InfoHeader);
nXRes = m_InfoHeader.xres;
nYRes = m_InfoHeader.yres;
}
/*
GetCompression()
*/
int CImage::GetCompression(void)
{
if(m_InfoHeader.compression==-1)
GetHeaderInfo(m_szFileName,&m_InfoHeader);
return(m_InfoHeader.compression);
}
/*
GetQuality()
*/
int CImage::GetQuality(void)
{
if(m_InfoHeader.quality==-1)
GetHeaderInfo(m_szFileName,&m_InfoHeader);
return(m_InfoHeader.quality);
}
/*
GetPhotometric()
*/
PHOTOMETRIC CImage::GetPhotometric(void)
{
BITMAPINFO* pBmi = GetBMI();
BITMAPINFOHEADER* pBitmapInfoHeader = (BITMAPINFOHEADER*)pBmi;
PHOTOMETRIC photometric = NOPHOTOMETRIC;
if(pBitmapInfoHeader)
{
switch(pBitmapInfoHeader->biBitCount)
{
case 1:
{
if(pBmi->bmiColors[0].rgbRed==0 && pBmi->bmiColors[0].rgbGreen==0 && pBmi->bmiColors[0].rgbBlue==0)
photometric = PHOTOMETRICMINISBLACK;
else
photometric = PHOTOMETRICMINISWHITE;
break;
}
case 4:
case 8:
photometric = PHOTOMETRICPALETTE;
break;
default:
photometric = PHOTOMETRICRGB;
break;
}
}
return(photometric);
}
/*
GetNumColors()
*/
UINT CImage::GetNumColors(void)
{
UINT nNumColors = 0;
switch(GetBPP())
{
case 1:
nNumColors = 2;
break;
case 4:
nNumColors = 16;
break;
case 8:
nNumColors = 256;
break;
}
return(nNumColors);
}
/*
CountBWColors()
*/
BOOL CImage::CountBWColors(unsigned int* pColors,unsigned char nNumColors)
{
BOOL bCount = FALSE;
unsigned int nBitsPerPixel = GetBPP();
unsigned int nHeight = GetHeight();
unsigned int nWidth = GetWidth();
unsigned int nColBytesReal = (nWidth * nBitsPerPixel) / 8;
unsigned int nBitsEnd = (nWidth * nBitsPerPixel) % 8;
unsigned int nColBytes = ((((nWidth * nBitsPerPixel) + 31) & ~31) >> 3);
unsigned int nRestBytesAlig = nColBytes - nColBytesReal - (nBitsEnd ? 1 : 0);
if(LockData())
{
unsigned char* pData = (unsigned char*)GetPixels();
if(pData)
{
memset(pColors,'\0',sizeof(unsigned int) * nNumColors);
switch(nBitsPerPixel)
{
case 1:
case 4:
case 8:
{
unsigned char mask = 0xff;
unsigned int nBitsByte = 8 / nBitsPerPixel;
mask >>= (8 - nBitsPerPixel);
for(unsigned int i = 0; i < nHeight ; i++)
{
for(unsigned int j = 0; j < nColBytesReal; j++)
{
unsigned char uByte = *pData++;
for(unsigned int k = 0; k < nBitsByte; k++)
{
unsigned char uColor = (unsigned char)(uByte & mask);
if(uColor < nNumColors)
pColors[uColor]++;
uByte >>= nBitsPerPixel;
}
}
if(nBitsEnd)
{
unsigned char uByte = *pData++;
for(unsigned int k = 0; k < nBitsEnd; k++)
{
unsigned char uColor = (unsigned char)(uByte & mask);
if(uColor < nNumColors)
pColors[uColor]++;
uByte >>= nBitsPerPixel;
}
}
pData += nRestBytesAlig;
}
bCount = TRUE;
}
break;
case 16:
case 24:
case 32:
break;
default:
break;
}
}
UnlockData();
}
return(bCount);
}
/*
CountRGBColors()
*/
BOOL CImage::CountRGBColors(COLORREF* pColors,unsigned int* pCountColors,unsigned char nNumColors)
{
BOOL bCount = FALSE;
unsigned int nBitsPerPixel = GetBPP();
unsigned int iBytesPerPixel = nBitsPerPixel / 8;
unsigned int nHeight = GetHeight();
unsigned int nWidth = GetWidth();
unsigned int nColBytesReal = (nWidth* nBitsPerPixel) / 8;
unsigned int nBitsEnd = (nWidth* nBitsPerPixel) % 8;
unsigned int nColBytes = ((((nWidth * nBitsPerPixel) + 31) & ~31) >> 3);
unsigned int nRestBytesAlig = nColBytes - nColBytesReal - (nBitsEnd ? 1 : 0);
if(LockData())
{
unsigned char* pData = (unsigned char*)GetPixels();
if(pData)
{
memset(pCountColors,'\0',sizeof(unsigned int) * nNumColors);
switch(nBitsPerPixel)
{
case 1:
case 4:
case 8:
case 16:
break;
case 24:
case 32:
{
for(unsigned int i = 0; i < nHeight ; i++)
{
for(unsigned int j = 0; j < nWidth; j++)
{
for(int k = 0; k < nNumColors; k++)
{
if(GetRValue(pColors[k])==pData[RGB_RED] && GetGValue(pColors[k])==pData[RGB_GREEN] && GetBValue(pColors[k])==pData[RGB_BLUE])
{
pCountColors[k]++;
break;
}
}
pData += iBytesPerPixel;
}
pData += nRestBytesAlig;
}
bCount = TRUE;
}
break;
default:
break;
}
}
UnlockData();
}
return(bCount);
}
/*
ConvertToBPP()
*/
UINT CImage::ConvertToBPP(UINT nBitsPerPixel,UINT nFlags,RGBQUAD *pPalette/*=NULL*/,UINT nColors/*=0*/)
{
UINT nRet = GDI_ERROR;
BOOL bLocked = FALSE;
void* pVoid = NULL;
HDC hDC = NULL;
BITMAPINFO* pBitmapInfoSrc = NULL;
BITMAPINFO* pBitmapInfo = NULL;
HBITMAP hBitmap = NULL;
HBITMAP hOldBitmap = NULL;
HPALETTE hPal = NULL;
HPALETTE hOldPal = NULL;
UINT nColorData = 0;
if(LockData())
{
bLocked = TRUE;
if(nBitsPerPixel <= 8)
{
nColorData = 1 << nBitsPerPixel;
if(!pPalette)
goto done;
}
hDC = ::CreateCompatibleDC(NULL);
if(!hDC)
goto done;
pBitmapInfoSrc = GetBMI();
if(!pBitmapInfoSrc)
goto done;
pBitmapInfo = (BITMAPINFO*)new char[sizeof(BITMAPINFOHEADER)+(nColorData*sizeof(RGBQUAD))];
if(!pBitmapInfo)
goto done;
memset(pBitmapInfo,'\0',sizeof(BITMAPINFOHEADER)+(nColorData*sizeof(RGBQUAD)));
pBitmapInfo->bmiHeader.biBitCount = (unsigned short)nBitsPerPixel;
pBitmapInfo->bmiHeader.biHeight = GetHeight();
pBitmapInfo->bmiHeader.biWidth = GetWidth();
pBitmapInfo->bmiHeader.biPlanes = 1;
pBitmapInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pBitmapInfo->bmiHeader.biCompression = BI_RGB;
if(pPalette && nColorData)
memcpy(pBitmapInfo->bmiColors,pPalette,min(nColorData,nColors));
hBitmap = ::CreateDIBSection(hDC,(LPBITMAPINFO)pBitmapInfo,DIB_RGB_COLORS,&pVoid,0,0);
if(!hBitmap)
goto done;
hOldBitmap = (HBITMAP)::SelectObject(hDC,hBitmap);
hPal = CreateDIBPalette((BITMAPINFO*)pBitmapInfoSrc);
if(hPal)
{
hOldPal = ::SelectPalette(hDC,hPal,FALSE);
::RealizePalette(hDC);
}
int nCurrentMode = HALFTONE;
if((nFlags & 0xffff0000)==QUANTIZE_NODITHERING)
{
switch(GetPhotometric())
{
case PHOTOMETRICMINISBLACK:
nCurrentMode = WHITEONBLACK;
break;
case PHOTOMETRICMINISWHITE:
nCurrentMode = BLACKONWHITE;
break;
default:
nCurrentMode = COLORONCOLOR;
break;
}
}
int nMode = ::SetStretchBltMode(hDC,nCurrentMode);
nRet = ::StretchDIBits( hDC,
0,
0,
pBitmapInfo->bmiHeader.biWidth,
pBitmapInfo->bmiHeader.biHeight,
0,
0,
pBitmapInfoSrc->bmiHeader.biWidth,
pBitmapInfo->bmiHeader.biHeight,
(LPSTR)GetPixels(),
(BITMAPINFO*)pBitmapInfoSrc,
DIB_RGB_COLORS,
SRCCOPY
);
::SetStretchBltMode(hDC,nMode);
::SelectObject(hDC,hOldBitmap);
bLocked = !UnlockData();
if(nRet!=GDI_ERROR)
nRet = NO_ERROR;
if(nRet==NO_ERROR)
{
nRet = GDI_ERROR;
if(Create(pBitmapInfo,NULL) && LockData())
{
nRet = ::GetDIBits(hDC,hBitmap,0,GetHeight(),GetPixels(),GetBMI(),DIB_RGB_COLORS) ? NO_ERROR : GDI_ERROR;
bLocked = !UnlockData(TRUE);
}
}
if(hOldPal)
::SelectPalette(hDC,hOldPal,TRUE);
}
done:
if(hDC)
::DeleteDC(hDC);
if(pBitmapInfo)
delete [] pBitmapInfo;
if(hBitmap)
::DeleteObject(hBitmap);
if(hPal)
::DeleteObject(hPal);
if(bLocked)
UnlockData();
return(nRet);
}
/*
GetDIBNumColors()
*/
WORD CImage::GetDIBNumColors(LPSTR lpbi)
{
WORD wNumColors = 0;
WORD wBitCount;
if(IS_WIN30_DIB(lpbi))
{
DWORD dwClrUsed = ((LPBITMAPINFOHEADER)lpbi)->biClrUsed;
if(dwClrUsed!=0)
return((WORD)dwClrUsed);
}
if(IS_WIN30_DIB(lpbi))
wBitCount = ((LPBITMAPINFOHEADER)lpbi)->biBitCount;
else
wBitCount = ((LPBITMAPCOREHEADER)lpbi)->bcBitCount;
switch(wBitCount)
{
case 1:
wNumColors = 2;
break;
case 4:
wNumColors = 16;
break;
case 8:
wNumColors = 256;
break;
}
return(wNumColors);
}
/*
CreateDIBPalette()
*/
HPALETTE CImage::CreateDIBPalette(LPBITMAPINFO lpbmi)
{
LPLOGPALETTE lpPal;
HANDLE hLogPal;
HPALETTE hPal = NULL;
WORD wNumColors;
LPBITMAPCOREINFO lpbmc;
BOOL bWinStyleDIB;
if(lpbmi)
{
lpbmc = (LPBITMAPCOREINFO)lpbmi;
if((wNumColors = GetDIBNumColors((LPSTR)lpbmi))!=0)
{
if((hLogPal = ::GlobalAlloc(GHND,sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * wNumColors))!=(HGLOBAL)NULL)
{
lpPal = (LPLOGPALETTE)::GlobalLock((HGLOBAL)hLogPal);
lpPal->palVersion = PALVERSION;
lpPal->palNumEntries = (WORD)wNumColors;
bWinStyleDIB = IS_WIN30_DIB((LPSTR)lpbmi);
for(int i = 0; i < (int)wNumColors; i++)
{
if(bWinStyleDIB)
{
lpPal->palPalEntry[i].peRed = lpbmi->bmiColors[i].rgbRed;
lpPal->palPalEntry[i].peGreen = lpbmi->bmiColors[i].rgbGreen;
lpPal->palPalEntry[i].peBlue = lpbmi->bmiColors[i].rgbBlue;
lpPal->palPalEntry[i].peFlags = 0;
}
else
{
lpPal->palPalEntry[i].peRed = lpbmc->bmciColors[i].rgbtRed;
lpPal->palPalEntry[i].peGreen = lpbmc->bmciColors[i].rgbtGreen;
lpPal->palPalEntry[i].peBlue = lpbmc->bmciColors[i].rgbtBlue;
lpPal->palPalEntry[i].peFlags = 0;
}
}
hPal = ::CreatePalette(lpPal);
::GlobalUnlock((HGLOBAL)hLogPal);
::GlobalFree((HGLOBAL)hLogPal);
}
}
}
return(hPal);
}
/*
GetType()
*/
IMAGE_TYPE CImage::GetType(void)
{
if(m_InfoHeader.type==NULL_PICTURE)
GetHeaderInfo(m_szFileName,&m_InfoHeader);
return(m_InfoHeader.type);
}
/*
GetHeaderInfo()
*/
void CImage::GetHeaderInfo(LPCSTR lpcszFileName,LPIMAGEHEADERINFO pHeaderInfo)
{
pHeaderInfo->type = NULL_PICTURE;
pHeaderInfo->xres = 0;
pHeaderInfo->yres = 0;
pHeaderInfo->restype = RESUNITNONE;
pHeaderInfo->compression = 0;
pHeaderInfo->quality = 0;
HANDLE hHandle = INVALID_HANDLE_VALUE;
HANDLE hMap = INVALID_HANDLE_VALUE;
LPVOID pMap = NULL;
if((hHandle = ::CreateFile(lpcszFileName,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL))!=INVALID_HANDLE_VALUE)
{
DWORD dwSize = pHeaderInfo->filesize = ::GetFileSize(hHandle,NULL);
DWORD dwRead = dwSize;
if((hMap = ::CreateFileMapping(hHandle,NULL,PAGE_READONLY,0,0,NULL))!=INVALID_HANDLE_VALUE)
{
if((pMap = ::MapViewOfFile(hMap,FILE_MAP_READ,0,0,0))!=NULL)
{
BYTE* pData = (BYTE*)pMap;
// formato
// BMP
if(pHeaderInfo->type==NULL_PICTURE)
{
BITMAPFILEHEADER* pBi = (BITMAPFILEHEADER*)pData;
if(pBi->bfType==0x4d42) // 0x4d42=win, 0x424d=altri
pHeaderInfo->type = BMP_PICTURE;
}
// JPEG/JFIF
if(pHeaderInfo->type==NULL_PICTURE)
{
if((*pData==0xFF) && (*(pData+1)==0xD8) && (*(pData+2)==0xFF))
pHeaderInfo->type = JPEG_PICTURE;
}
// GIF
if(pHeaderInfo->type==NULL_PICTURE)
{
ULONG GIFSig = *((ULONG*)pData);
if(GIFSig==0x38464947)
pHeaderInfo->type = GIF_PICTURE;
}
// TIFF
if(pHeaderInfo->type==NULL_PICTURE)
{
ULONG TIFFSig = *((ULONG *)pData);
if(TIFFSig==0x002A4949 || TIFFSig==0x2A004D4D)
pHeaderInfo->type = TIFF_PICTURE;
}
// PNG
if(pHeaderInfo->type==NULL_PICTURE)
{
if((*pData==0x89) && (*(pData+1)==0x50) && (*(pData+2)==0x4E) && (*(pData+3)==0x47))
pHeaderInfo->type = PNG_PICTURE;
}
// PGM
if(pHeaderInfo->type==NULL_PICTURE)
{
if(pData[0]==0x50 && ((pData[1]==0x32)||(pData[1]==0x35)))
pHeaderInfo->type = PGM_PICTURE;
}
// PCX
if(pHeaderInfo->type==NULL_PICTURE)
{
if(pData[0]==0x0A && pData[2]==0x01)
pHeaderInfo->type = PCX_PICTURE;
}
// PICT
if(pHeaderInfo->type==NULL_PICTURE)
{
if(dwRead > 540)
{
BYTE* pPictSig = (BYTE*)(pData+0x20a);
if((pPictSig[0]==0x00 && pPictSig[1]==0x11 && pPictSig[2]==0x02 && pPictSig[3]==0xFF) || (pPictSig[0]==0x00 && pPictSig[1]==0x11 && pPictSig[2]==0x01) || (pPictSig[0]==0x11 && pPictSig[1]==0x01 && pPictSig[2]==0x01 && pPictSig[3]==0x00))
pHeaderInfo->type = PICT_PICTURE;
}
}
// TGA (senza signature)
if(pHeaderInfo->type==NULL_PICTURE)
{
BOOL bCouldBeTGA = TRUE;
if(*(pData+1) > 1)
bCouldBeTGA = FALSE;
BYTE TGAImgType = *(pData+2);
if((TGAImgType > 11) || (TGAImgType > 3 && TGAImgType < 9))
bCouldBeTGA = FALSE;
BYTE TGAColMapDepth = *(pData+7);
if(TGAColMapDepth != 8 && TGAColMapDepth != 15 &&
TGAColMapDepth != 16 && TGAColMapDepth != 24 && TGAColMapDepth != 32 && TGAColMapDepth != 0)
bCouldBeTGA = FALSE;
BYTE TGAPixDepth = *(pData+16);
if(TGAPixDepth != 8 && TGAPixDepth != 15 && TGAPixDepth != 16 && TGAPixDepth != 24 && TGAPixDepth != 32)
bCouldBeTGA = FALSE;
if(bCouldBeTGA)
pHeaderInfo->type = TGA_PICTURE;
}
// header
if(pHeaderInfo->type==JPEG_PICTURE)
{
jpeg_decompress_struct cinfo;
jpeg_error_mgr jerr;
cinfo.err = jpeg_std_error (&jerr);
jerr.error_exit = jpeg_error_exit;
jpeg_create_decompress(&cinfo);
jpeg_mem_src(&cinfo,pData,dwSize,(void*)pData);
jpeg_read_header(&cinfo,0);
//???
int nQuality = 0;
if(cinfo.quant_tbl_ptrs!=NULL)
{
nQuality = cinfo.quant_tbl_ptrs[0]->quantval[61];
int nMin,nMax;
GetQualityRange(nMin,nMax);
if(nMax==255) // leadtools
nQuality = 100;
else //paintlib, nexgen
{
if(nQuality==255)
nQuality = 1;
else
{
if(nQuality==1)
nQuality = 100;
else
{
if(nQuality > 100)
nQuality = 5000 / nQuality;
else
nQuality = (200 - nQuality) / 2;
}
}
}
pHeaderInfo->quality = nQuality;
}
//???
jpeg_destroy_decompress(&cinfo);
int nDPI;
nDPI = cinfo.X_density;
if(nDPI <= 1)
nDPI = 72;
pHeaderInfo->xres = (float)nDPI;
nDPI = cinfo.Y_density;
if(nDPI <= 1)
nDPI = 72;
pHeaderInfo->yres = (float)nDPI;
switch(cinfo.density_unit)
{
// no meaningful units
case 0:
pHeaderInfo->restype = RESUNITNONE;
break;
// english
case 1:
pHeaderInfo->restype = RESUNITINCH;
break;
// metric
case 2:
pHeaderInfo->restype = RESUNITCENTIMETER;
break;
}
}
else if(pHeaderInfo->type==TIFF_PICTURE)
{
TIFFSetWarningHandler(NULL);
TIFF* tif = TIFFOpenMem(pData,dwSize,NULL);
if(tif)
{
float nRes;
nRes = 0.0;
TIFFGetField(tif,TIFFTAG_XRESOLUTION,&nRes);
if(nRes <= 1.0)
nRes = 300.0;
pHeaderInfo->xres = nRes;
nRes = 0.0;
TIFFGetField(tif,TIFFTAG_YRESOLUTION,&nRes);
if(nRes <= 1.0)
nRes = 300.0;
pHeaderInfo->yres = nRes;
TIFFGetFieldDefaulted(tif,TIFFTAG_RESOLUTIONUNIT,&pHeaderInfo->restype);
switch(pHeaderInfo->restype)
{
// no meaningful units
case RESUNIT_NONE:
pHeaderInfo->restype = RESUNITNONE;
break;
// english
case RESUNIT_INCH:
pHeaderInfo->restype = RESUNITINCH;
break;
// metric
case RESUNIT_CENTIMETER:
pHeaderInfo->restype = RESUNITCENTIMETER;
break;
default:
pHeaderInfo->restype = RESUNITNONE;
break;
}
unsigned short int nComp;
if(TIFFGetField(tif,TIFFTAG_COMPRESSION,&nComp))
pHeaderInfo->compression = nComp;
TIFFClose(tif);
}
}
else if(pHeaderInfo->type==BMP_PICTURE)
{
BITMAPINFO* bi = (BITMAPINFO*)(pData+sizeof(BITMAPFILEHEADER));
float nDPI;
nDPI = 0;
if(bi->bmiHeader.biXPelsPerMeter > 0)
nDPI = ((float)bi->bmiHeader.biXPelsPerMeter / 39.37f);
if(nDPI <= 1)
nDPI = 150;
pHeaderInfo->xres = nDPI;
nDPI = 0;
if(bi->bmiHeader.biYPelsPerMeter > 0)
nDPI = ((float)bi->bmiHeader.biYPelsPerMeter / 39.37f);
if(nDPI <= 1)
nDPI = 150;
pHeaderInfo->yres = nDPI;
pHeaderInfo->restype = RESUNITINCH;
}
::UnmapViewOfFile(pMap);
}
::CloseHandle(hMap);
}
::CloseHandle(hHandle);
}
}
/*
Load()
*/
BOOL CImage::Load(LPCSTR)
{
m_InfoHeader.type = NULL_PICTURE;
m_InfoHeader.xres = -1;
m_InfoHeader.yres = -1;
m_InfoHeader.restype = -1;
m_InfoHeader.compression = -1;
m_InfoHeader.quality = -1;
m_InfoHeader.filesize = (unsigned long)-1L;
m_InfoHeader.width = (unsigned long)-1L;
m_InfoHeader.height = (unsigned long)-1L;
m_ImageType = NULL_PICTURE;
return(FALSE);
}
/*
Copy()
*/
HANDLE CImage::Copy(RECT& rect)
{
BOOL bRet = FALSE;
BOOL bLocked = FALSE;
HDC hDC = NULL;
BITMAPINFO* pBitmapInfoSrc = NULL;
BITMAPINFO* pBitmapInfo = NULL;
HDIB hDIB = (HDIB)NULL;
HBITMAP hBitmap = NULL;
HBITMAP hOldBitmap = NULL;
HPALETTE hOldPal = NULL;
HPALETTE hPal = NULL;
if(LockData())
{
bLocked = TRUE;
hDC = ::CreateCompatibleDC(NULL);
if(!hDC)
goto done;
pBitmapInfoSrc = GetBMI();
if(!pBitmapInfoSrc)
goto done;
int nColorBytes = GetNumColors() * sizeof(RGBQUAD);
int nTotalBytes = sizeof(BITMAPINFOHEADER) + nColorBytes + (GetBytesWidth(rect.right,GetBPP(),GetAlignment())*rect.bottom);
hDIB = (HDIB)::GlobalAlloc(GHND,nTotalBytes);
if(!hDIB)
goto done;
pBitmapInfo = (BITMAPINFO*)::GlobalLock(hDIB);
if(!pBitmapInfo)
goto done;
memcpy(pBitmapInfo,pBitmapInfoSrc,sizeof(BITMAPINFOHEADER)+nColorBytes);
pBitmapInfo->bmiHeader.biHeight = rect.bottom;
pBitmapInfo->bmiHeader.biWidth = rect.right;
pBitmapInfo->bmiHeader.biSizeImage = 0;
void* pVoid = NULL;
hBitmap = ::CreateDIBSection(hDC,(LPBITMAPINFO)pBitmapInfo,DIB_RGB_COLORS,&pVoid,0,0);
if(!hBitmap)
goto done;
hOldBitmap = (HBITMAP)::SelectObject(hDC,hBitmap);
hOldPal = NULL;
hPal = CreateDIBPalette((BITMAPINFO*)pBitmapInfoSrc);
if(hPal)
{
hOldPal = ::SelectPalette(hDC,hPal,FALSE);
::RealizePalette(hDC);
}
bRet = ::StretchDIBits( hDC,
0,
0,
pBitmapInfo->bmiHeader.biWidth,
pBitmapInfo->bmiHeader.biHeight,
rect.left,
GetHeight() - rect.top-rect.bottom,
pBitmapInfo->bmiHeader.biWidth,
pBitmapInfo->bmiHeader.biHeight,
(LPSTR)GetPixels(),
(BITMAPINFO*)pBitmapInfoSrc,
DIB_RGB_COLORS,
SRCCOPY)!=GDI_ERROR;
::SelectObject(hDC,hOldBitmap);
if(bRet)
{
pBitmapInfo->bmiHeader.biSizeImage = nTotalBytes - sizeof(BITMAPINFOHEADER) - nColorBytes;
bRet = ::GetDIBits(hDC,hBitmap,0,pBitmapInfo->bmiHeader.biHeight,(LPSTR)pBitmapInfo+sizeof(BITMAPINFOHEADER)+nColorBytes,pBitmapInfo,DIB_RGB_COLORS)!=0;
}
if(hOldPal)
::SelectPalette(hDC,hOldPal,TRUE);
::GlobalUnlock(hDIB);
if(!bRet)
{
::GlobalFree(hDIB);
hDIB = NULL;
}
}
done:
if(hDC)
::DeleteDC(hDC);
if(hBitmap)
::DeleteObject(hBitmap);
if(hPal)
::DeleteObject(hPal);
if(bLocked)
UnlockData();
return(hDIB);
}
/*
Brightness()
*/
UINT CImage::Brightness(CImageParams* pCImageParams)
{
UINT nRet = GDI_ERROR;
int nFactor = (int)pCImageParams->GetBrightness();
if(nFactor >= 0)
{
RECT r;
r.top = r.left = 0;
r.right = GetWidth();
r.bottom = GetHeight();
for(int y = r.top; y < r.bottom; y++)
{
for(int x = r.left; x < r.right; x++)
{
COLORREF c = GetPixel(x,y);
int r = min(GetRValue(c) * nFactor / 100,255);
int g = min(GetGValue(c) * nFactor / 100,255);
int b = min(GetBValue(c) * nFactor / 100,255);
r = max(r,0);
g = max(g,0);
b = max(b,0);
// c = RGB(r,g,b);
c = RGB(b,g,r);
SetPixel(x,y,c);
}
}
nRet = NO_ERROR;
}
return(nRet);
}
/*
Contrast()
*/
UINT CImage::Contrast(CImageParams* pCImageParams)
{
UINT nRet = GDI_ERROR;
int nFactor = (int)pCImageParams->GetContrast();
if(nFactor >= 0)
{
RECT r;
r.top = r.left = 0;
r.right = GetWidth();
r.bottom = GetHeight();
for(int y = r.top; y < r.bottom; y++)
{
for(int x = r.left; x < r.right; x++)
{
COLORREF c = GetPixel(x,y);
int r = min(128 + ((GetRValue(c) - 128) * nFactor / 100),255);
int g = min(128 + ((GetGValue(c) - 128) * nFactor / 100),255);
int b = min(128 + ((GetBValue(c) - 128) * nFactor / 100),255);
r = max(r,0);
g = max(g,0);
b = max(b,0);
// c = RGB(r,g,b);
c = RGB(b,g,r);
SetPixel(x,y,c);
}
}
nRet = NO_ERROR;
}
return(nRet);
}
/*
GammaCorrection()
*/
UINT CImage::GammaCorrection(CImageParams* pCImageParams)
{
UINT nRet = GDI_ERROR;
double Value = pCImageParams->GetGamma();
double MaxRange = pow((double)255,Value) / (double)255;
if(MaxRange >= 0)
{
RECT r;
r.top = r.left = 0;
r.right = GetWidth();
r.bottom = GetHeight();
for(int y = r.top; y < r.bottom; y++)
{
for(int x = r.left; x < r.right; x++)
{
COLORREF c = GetPixel(x,y);
double dblR = pow((double)GetRValue(c),Value) / (double)MaxRange;
double dblG = pow((double)GetGValue(c),Value) / (double)MaxRange;
double dblB = pow((double)GetBValue(c),Value) / (double)MaxRange;
int r = min((int)(dblR + 0.5),255);
int g = min((int)(dblG + 0.5),255);
int b = min((int)(dblB + 0.5),255);
r = max(r,0);
g = max(g,0);
b = max(b,0);
// c = RGB(r,g,b);
c = RGB(b,g,r);
SetPixel(x,y,c);
}
}
nRet = NO_ERROR;
}
return(nRet);
}
/*
Halftone()
*/
UINT CImage::Halftone(CImageParams*)
{
UINT nRet = GDI_ERROR;
BOOL bLocked = FALSE;
HDC hDC = NULL;
BITMAPINFO* pBitmapInfoSrc = NULL;
BITMAPINFO* pBitmapInfo = NULL;
HBITMAP hBitmap = NULL;
HBITMAP hOldBitmap = NULL;
HPALETTE hPal = NULL;
HPALETTE hOldPal = NULL;
if(GetBPP()!=1)
{
if(LockData())
{
bLocked = TRUE;
hDC = ::CreateCompatibleDC(NULL);
if(!hDC)
goto done;
pBitmapInfoSrc = GetBMI();
if(!pBitmapInfoSrc)
goto done;
pBitmapInfo = (BITMAPINFO*)new char[sizeof(BITMAPINFOHEADER)+(2*sizeof(RGBQUAD))];
if(!pBitmapInfo)
goto done;
memset(pBitmapInfo,'\0',sizeof(BITMAPINFOHEADER)+(2*sizeof(RGBQUAD)));
pBitmapInfo->bmiHeader.biBitCount = 1;
pBitmapInfo->bmiHeader.biHeight = GetHeight();
pBitmapInfo->bmiHeader.biWidth = GetWidth();
pBitmapInfo->bmiHeader.biPlanes = 1;
pBitmapInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pBitmapInfo->bmiHeader.biCompression = BI_RGB;
pBitmapInfo->bmiColors[0].rgbBlue = 0;
pBitmapInfo->bmiColors[0].rgbRed = 0;
pBitmapInfo->bmiColors[0].rgbGreen = 0;
pBitmapInfo->bmiColors[1].rgbBlue = 255;
pBitmapInfo->bmiColors[1].rgbRed = 255;
pBitmapInfo->bmiColors[1].rgbGreen = 255;
void* pVoid;
hBitmap = ::CreateDIBSection(hDC,(LPBITMAPINFO)pBitmapInfo,DIB_RGB_COLORS,&pVoid,0,0);
if(!hBitmap)
goto done;
hOldBitmap = (HBITMAP)::SelectObject(hDC,hBitmap);
hPal = CreateDIBPalette((BITMAPINFO*)pBitmapInfoSrc);
if(hPal)
{
hOldPal = ::SelectPalette(hDC,hPal,FALSE);
::RealizePalette(hDC);
}
int nMode = ::SetStretchBltMode(hDC,HALFTONE);
nRet = ::StretchDIBits( hDC,
0,
0,
pBitmapInfo->bmiHeader.biWidth,
pBitmapInfo->bmiHeader.biHeight,
0,
0,
pBitmapInfoSrc->bmiHeader.biWidth,
pBitmapInfo->bmiHeader.biHeight,
(LPSTR)GetPixels(),
(BITMAPINFO*)pBitmapInfoSrc,
DIB_RGB_COLORS,SRCCOPY)!=GDI_ERROR ? NO_ERROR : GDI_ERROR;
::SetStretchBltMode(hDC,nMode);
::SelectObject(hDC,hOldBitmap);
if(nRet==GDI_ERROR)
goto done;
else
nRet = NO_ERROR;
bLocked = !UnlockData();
if(Create(pBitmapInfo,0) && LockData())
{
nRet = ::GetDIBits(hDC,hBitmap,0,GetHeight(),GetPixels(),GetBMI(),DIB_RGB_COLORS) ? NO_ERROR : GDI_ERROR;
bLocked = !UnlockData(TRUE);
}
if(hOldPal)
::SelectPalette(hDC,hOldPal,TRUE);
}
}
else
nRet = NO_ERROR;
done:
if(hDC)
::DeleteDC(hDC);
if(pBitmapInfo)
delete [] pBitmapInfo;
if(hBitmap)
::DeleteObject(hBitmap);
if(hPal)
::DeleteObject(hPal);
if(bLocked)
UnlockData();
return(nRet);
}
/*
Hue()
*/
UINT CImage::Hue(CImageParams* pCImageParams)
{
UINT nRet = GDI_ERROR;
int nFactor = (int)pCImageParams->GetHue();
if(nFactor >= 0)
{
RECT r;
r.top = r.left = 0;
r.right = GetWidth();
r.bottom = GetHeight();
for(int y = r.top; y < r.bottom; y++)
{
for(int x = r.left; x < r.right; x++)
{
COLORREF c = GetPixel(x,y);
double H,S,L;
RGBtoHSL(c,&H,&S,&L);
H = (double)(H * nFactor / 100.0);
SetPixel(x,y,HLStoRGB(H,L,S));
}
}
nRet = NO_ERROR;
}
return(nRet);
}
/*
Mirror()
*/
UINT CImage::Mirror(UINT nDirection/*0=horiz, 1=vert*/)
{
UINT nRet = GDI_ERROR;
BOOL bLocked = FALSE;
HDC hDC = NULL;
BITMAPINFO *pBitmapInfoSrc = NULL;
BITMAPINFO *pBitmapInfo = NULL;
HBITMAP hBitmap = NULL;
HBITMAP hOldBitmap = NULL;
HPALETTE hPal = NULL;
HPALETTE hOldPal = NULL;
UINT nWidth;
UINT nHeight;
if(LockData())
{
bLocked = TRUE;
hDC = ::CreateCompatibleDC(NULL);
if(!hDC)
goto done;
pBitmapInfoSrc = GetBMI();
unsigned char *pDataSrc = (unsigned char*)GetPixels();
if(!pBitmapInfoSrc || !pDataSrc)
goto done;
pBitmapInfo = (BITMAPINFO*)new char[sizeof(BITMAPINFOHEADER) + (GetMaxPaletteColors() * sizeof(RGBQUAD))];
if(!pBitmapInfo)
goto done;
memset(pBitmapInfo,'\0',sizeof(BITMAPINFOHEADER) + (GetMaxPaletteColors() * sizeof(RGBQUAD)));
memcpy(pBitmapInfo,pBitmapInfoSrc,sizeof(BITMAPINFOHEADER) + (GetNumColors() * sizeof(RGBQUAD)));
void* pVoid;
hBitmap = ::CreateDIBSection(hDC,(LPBITMAPINFO)pBitmapInfo,DIB_RGB_COLORS,&pVoid,0,0);
if(!hBitmap)
goto done;
hOldBitmap = (HBITMAP)::SelectObject(hDC,hBitmap);
hPal = CreateDIBPalette((BITMAPINFO*)pBitmapInfoSrc);
if(hPal)
{
hOldPal = ::SelectPalette(hDC,hPal,FALSE);
::RealizePalette(hDC);
}
nWidth = GetWidth();
nHeight = GetHeight();
if(nDirection==0)
{
nRet = ::StretchDIBits( hDC,
0,
0,
nWidth,
nHeight,
0,
nHeight-1,
nWidth,
(-1)*nHeight,
(LPSTR)GetPixels(),
(BITMAPINFO*)pBitmapInfoSrc,
DIB_RGB_COLORS,
SRCCOPY);
}
else if(nDirection==1)
{
nRet = ::StretchDIBits( hDC,
0,
0,
nWidth,
nHeight,
nWidth-1,
0,
(-1)*nWidth,
nHeight,
(LPSTR)GetPixels(),
(BITMAPINFO*)pBitmapInfoSrc,
DIB_RGB_COLORS,
SRCCOPY);
}
else
nRet = GDI_ERROR;
::SelectObject(hDC,hOldBitmap);
if(nRet==GDI_ERROR)
goto done;
else
nRet = NO_ERROR;
bLocked = !UnlockData();
if(Create(pBitmapInfo,0) && LockData())
{
nRet = ::GetDIBits(hDC,hBitmap,0,nHeight,GetPixels(),GetBMI(),DIB_RGB_COLORS)!=0 ? NO_ERROR : GDI_ERROR;
bLocked = !UnlockData(TRUE);
}
if(hOldPal)
::SelectPalette(hDC,hOldPal,TRUE);
}
done:
if(hDC)
::DeleteDC(hDC);
if(pBitmapInfo)
delete [] pBitmapInfo;
if(hBitmap)
::DeleteObject(hBitmap);
if(hPal)
::DeleteObject(hPal);
if(bLocked)
UnlockData();
return(nRet);
}
/*
Text()
*/
UINT CImage::Text(LPCSTR lpcszText,CHOOSEFONT* cf,COLORREF foregroundColor,COLORREF backgroundColor,int nBackgroundMode,SIZE* size)
{
UINT nRet = GDI_ERROR;
BOOL bLocked = FALSE;
HDC hDC = NULL;
BITMAPINFO *pBitmapInfoSrc = NULL;
BITMAPINFO *pBitmapInfo = NULL;
HBITMAP hBitmap = NULL;
HBITMAP hOldBitmap = NULL;
HPALETTE hPal = NULL;
HPALETTE hOldPal = NULL;
UINT nWidth;
UINT nHeight;
if(LockData())
{
bLocked = TRUE;
hDC = ::CreateCompatibleDC(NULL);
if(!hDC)
goto done;
pBitmapInfoSrc = GetBMI();
unsigned char *pDataSrc = (unsigned char*)GetPixels();
if(!pBitmapInfoSrc || !pDataSrc)
goto done;
pBitmapInfo = (BITMAPINFO*)new char[sizeof(BITMAPINFOHEADER) + (GetMaxPaletteColors() * sizeof(RGBQUAD))];
if(!pBitmapInfo)
goto done;
memset(pBitmapInfo,'\0',sizeof(BITMAPINFOHEADER) + (GetMaxPaletteColors() * sizeof(RGBQUAD)));
memcpy(pBitmapInfo,pBitmapInfoSrc,sizeof(BITMAPINFOHEADER) + (GetNumColors() * sizeof(RGBQUAD)));
void* pVoid;
hBitmap = ::CreateDIBSection(hDC,(LPBITMAPINFO)pBitmapInfo,DIB_RGB_COLORS,&pVoid,0,0);
if(!hBitmap)
goto done;
hOldBitmap = (HBITMAP)::SelectObject(hDC,hBitmap);
hPal = CreateDIBPalette((BITMAPINFO*)pBitmapInfoSrc);
if(hPal)
{
hOldPal = ::SelectPalette(hDC,hPal,FALSE);
::RealizePalette(hDC);
}
nWidth = GetWidth();
nHeight = GetHeight();
nRet = ::StretchDIBits( hDC,
0,
0,
nWidth,
nHeight,
0,
0,
nWidth,
nHeight,
(LPSTR)GetPixels(),
(BITMAPINFO*)pBitmapInfoSrc,
DIB_RGB_COLORS,
SRCCOPY);
DWORD rgbCurrent;
HFONT hfont,hfontPrev;
hfont = CreateFontIndirect(cf->lpLogFont);
hfontPrev = (HFONT)SelectObject(hDC,hfont);
rgbCurrent= cf->rgbColors;
//rgbPrev = SetTextColor(hDC,rgbCurrent);
SetTextColor(hDC,RGB(GetRValue(foregroundColor),GetGValue(foregroundColor),GetBValue(foregroundColor)));
SetBkColor(hDC,RGB(GetRValue(backgroundColor),GetGValue(backgroundColor),GetBValue(backgroundColor)));
SetBkMode(hDC,nBackgroundMode);
TextOut(hDC,size->cx,size->cy,lpcszText,strlen(lpcszText));
SIZE Size;
GetTextExtentPoint32(hDC,lpcszText,strlen(lpcszText),&Size);
size->cy += Size.cy;
DeleteObject(hfont);
::SelectObject(hDC,hOldBitmap);
if(nRet==GDI_ERROR)
goto done;
else
nRet = NO_ERROR;
bLocked = !UnlockData();
if(Create(pBitmapInfo) && LockData())
{
nRet = ::GetDIBits(hDC,hBitmap,0,nHeight,GetPixels(),GetBMI(),DIB_RGB_COLORS)!=0 ? NO_ERROR : GDI_ERROR;
bLocked = !UnlockData(TRUE);
}
if(hOldPal)
::SelectPalette(hDC,hOldPal,TRUE);
}
done:
if(hDC)
::DeleteDC(hDC);
if(pBitmapInfo)
delete [] pBitmapInfo;
if(hBitmap)
::DeleteObject(hBitmap);
if(hPal)
::DeleteObject(hPal);
if(bLocked)
UnlockData();
return(nRet);
}
/*
Negate()
*/
UINT CImage::Negate(CImageParams*)
{
UINT nRet = GDI_ERROR;
UINT nBitsPerPixel = GetBPP();
switch(nBitsPerPixel)
{
case 1:
if(LockData())
{
unsigned char* pData = (unsigned char*)GetPixels();
if(pData)
{
UINT nHeight = GetHeight();
UINT nBytesWidth = GetBytesWidth();
UINT nTot = nHeight * nBytesWidth;
for(register int i = nTot; i > 0; i--,pData++)
(*pData) = ~(*pData);
nRet = NO_ERROR;
}
UnlockData(TRUE);
}
break;
default:
break;
}
return(nRet);
}
/*
SaturationHorizontal()
*/
UINT CImage::SaturationHorizontal(CImageParams* pCImageParams)
{
UINT nRet = GDI_ERROR;
int nFactor = (int)pCImageParams->GetSaturation();
if(nFactor < 0)
return(nRet);
return(Saturation(nFactor));
}
/*
SaturationVertical()
*/
UINT CImage::SaturationVertical(CImageParams* pCImageParams)
{
UINT nRet = GDI_ERROR;
int nFactor = (int)pCImageParams->GetSaturation();
if(nFactor < 0)
return(nRet);
return(Saturation(nFactor));
}
/*
Saturation()
*/
UINT CImage::Saturation(int nFactor)
{
UINT nRet = NO_ERROR;
RECT rc;
rc.top = rc.left = 0;
rc.right = GetWidth();
rc.bottom = GetHeight();
for(int y = rc.top; y < rc.bottom; y++)
{
for(int x = rc.left; x < rc.right; x++)
{
COLORREF c = GetPixel(x,y);
double H,S,L;
RGBtoHSL(c,&H,&S,&L);
S = (double)(S*(nFactor)/100);
SetPixel(x,y,HLStoRGB(H,L,S));
}
}
return(nRet);
}
/*
RGBtoHSL()
*/
void CImage::RGBtoHSL(COLORREF rgb,double* H,double* S,double* L)
{
double delta;
double r = (double)GetRValue(rgb) / 255;
double g = (double)GetGValue(rgb) / 255;
double b = (double)GetBValue(rgb) / 255;
double cmax = max(r,max(g,b));
double cmin = min(r,min(g,b));
*L = (cmax + cmin) / 2.0f;
if(cmax==cmin)
{
*S = 0;
*H = 0; // it's really undefined
}
else
{
if(*L < 0.5f)
*S = (cmax - cmin) / (cmax + cmin);
else
*S = (cmax - cmin) / (2.0f - cmax - cmin);
delta = cmax - cmin;
if(r==cmax)
*H = (g - b) / delta;
else if(g==cmax)
*H = 2.0f + (b - r) / delta;
else
*H = 4.0f + (r - g) / delta;
*H /= 6.0f;
if(*H < 0.0f)
*H += 1;
}
}
/*
HLStoRGB()
*/
COLORREF CImage::HLStoRGB(const double& H,const double& L,const double& S)
{
double r,g,b;
double m1,m2;
if(S==0)
{
r = g = b = L;
}
else
{
if(L <= 0.5f)
m2 = L * (1.0f + S);
else
m2 = L + S - L * S;
m1 = 2.0f * L - m2;
r = HuetoRGB(m1,m2,H + 1.0f / 3.0f);
g = HuetoRGB(m1,m2,H);
b = HuetoRGB(m1,m2,H - 1.0f / 3.0f);
}
// return(RGB((BYTE)(r*255),(BYTE)(g*255),(BYTE)(b*255)));
return(RGB((BYTE)(b*255),(BYTE)(g*255),(BYTE)(r*255)));
}
/*
HuetoRGB()
*/
double CImage::HuetoRGB(double m1,double m2,double h)
{
if(h < 0)
h += 1.0;
if(h > 1)
h -= 1.0;
if((6.0f * h) < 1)
return(m1 + (m2 - m1) * h * 6.0f);
if((2.0f * h) < 1)
return(m2);
if((3.0f * h) < 2.0f)
return(m1 + (m2 - m1) * ((2.0f / 3.0f) - h) * 6.0f);
return(m1);
}
#define WIDTH_BYTES(bits) (((bits) + 31) / 32 * 4)
#ifndef _HDIB_DECLARED
DECLARE_HANDLE(HDIB);
#define _HDIB_DECLARED 1
#endif
DECLARE_HANDLE(HMEMBMPFILE);
/* DIB constants */
#define PALVERSION 0x300
#define MAXPALCOLORS 256
/* DIB Macros*/
#define RECTWIDTH(lpRect) ((lpRect)->right - (lpRect)->left)
#define RECTHEIGHT(lpRect) ((lpRect)->bottom - (lpRect)->top)
/*
WindowToDIB()
From dibapi.cpp, part of the Microsoft Foundation Classes C++ library.
*/
HDIB CImage::WindowToDIB(CWnd *pWnd, CRect* pScreenRect)
{
CBitmap bitmap;
CWindowDC dc(pWnd);
CDC memDC;
CRect rect;
memDC.CreateCompatibleDC(&dc);
if ( pScreenRect == NULL )
pWnd->GetWindowRect(rect);
else
rect = *pScreenRect;
bitmap.CreateCompatibleBitmap(&dc, rect.Width(),rect.Height() );
CBitmap* pOldBitmap = memDC.SelectObject(&bitmap);
memDC.BitBlt(0, 0, rect.Width(),rect.Height(), &dc, rect.left, rect.top, SRCCOPY);
// Create logical palette if device support a palette
CPalette pal;
if ( dc.GetDeviceCaps(RASTERCAPS) & RC_PALETTE )
{
UINT nSize = sizeof(LOGPALETTE) + (sizeof(PALETTEENTRY) * MAXPALCOLORS);
LOGPALETTE *pLP = (LOGPALETTE *) new BYTE[nSize];
pLP->palVersion = PALVERSION;
pLP->palNumEntries = (USHORT) GetSystemPaletteEntries( dc, 0, MAXPALCOLORS-1, pLP->palPalEntry );
// Create the palette
pal.CreatePalette( pLP );
delete[] pLP;
}
memDC.SelectObject(pOldBitmap);
HDIB hDib = BitmapToDIB( bitmap, pal );
return hDib;
}
/*************************************************************************
*
* BitmapToDIB()
*
* Parameter:
*
* HBITMAP - handle to a Bitmap that the DIB is to be
* created from
* HPALETTE - palette to use in creation of DIB
*
* Return Value:
*
* HDIB - handle of the DIB created from the Bitmap, NULL
* on error
*
* Description:
*
* Returns an HDIB created from an HBITMAP.
* This function creates a DIB from a bitmap using the
* specified palette.
************************************************************************/
HDIB CImage::BitmapToDIB(HBITMAP hBitmap, HPALETTE hPal)
{
ASSERT(hBitmap);
BITMAP bm; // bitmap structure
BITMAPINFOHEADER bi; // bitmap header
LPBITMAPINFOHEADER lpbi; // pointer to BITMAPINFOHEADER
DWORD dwLen; // size of memory block
HDIB hDib, h; // handle to DIB, temp handle
HDC hDC; // handle to DC
WORD biBits; // bits per pixel
UINT wLineLen;
DWORD dwSize;
DWORD wColSize;
// check if bitmap handle is valid
if (!hBitmap)
{
return NULL;
}
// fill in BITMAP structure, return NULL if it didn't work
if (!::GetObject(hBitmap, sizeof(bm), &bm))
{
return NULL;
}
// if no palette is specified, use default palette
if (hPal == NULL)
hPal = (HPALETTE)::GetStockObject(DEFAULT_PALETTE);
// calculate bits per pixel
biBits = (WORD) (bm.bmPlanes * bm.bmBitsPixel);
wLineLen = ( bm.bmWidth * biBits + 31 ) / 32 * 4;
wColSize = sizeof(RGBQUAD) * (( biBits <= 8 ) ?
1 << biBits : 0 );
dwSize = sizeof( BITMAPINFOHEADER ) + wColSize +
(DWORD)(UINT)wLineLen * (DWORD)(UINT)bm.bmHeight;
// make sure bits per pixel is valid
if (biBits <= 1)
biBits = 1;
else if (biBits <= 4)
biBits = 4;
else if (biBits <= 8)
biBits = 8;
else // if greater than 8-bit, force to 24-bit
biBits = 24;
// initialize BITMAPINFOHEADER
bi.biSize = sizeof(BITMAPINFOHEADER);
bi.biWidth = bm.bmWidth;
bi.biHeight = bm.bmHeight;
bi.biPlanes = 1;
bi.biBitCount = biBits;
bi.biCompression = BI_RGB;
bi.biSizeImage = dwSize - sizeof(BITMAPINFOHEADER) - wColSize;
bi.biXPelsPerMeter = 0;
bi.biYPelsPerMeter = 0;
bi.biClrUsed = ( biBits <= 8 ) ? 1 << biBits : 0;
bi.biClrImportant = 0;
// calculate size of memory block required to store BITMAPINFO
dwLen = bi.biSize + PaletteSize((LPSTR) &bi);
// get a DC
hDC = ::GetDC(NULL);
// select and realize our palette
hPal = ::SelectPalette(hDC, hPal, FALSE);
::RealizePalette(hDC);
// alloc memory block to store our bitmap
hDib = (HDIB)::GlobalAlloc(GHND, dwLen);
// if we couldn't get memory block
if (!hDib)
{
// clean up and return NULL
::SelectPalette(hDC, hPal, TRUE);
::RealizePalette(hDC);
::ReleaseDC(NULL, hDC);
return NULL;
}
// lock memory and get pointer to it
lpbi = (LPBITMAPINFOHEADER)::GlobalLock((HGLOBAL)hDib);
if (!lpbi)
{
// clean up and return NULL
::SelectPalette(hDC, hPal, TRUE);
::RealizePalette(hDC);
::ReleaseDC(NULL, hDC);
return NULL;
}
// use our bitmap info. to fill BITMAPINFOHEADER
*lpbi = bi;
// call GetDIBits with a NULL lpBits param, so it will
// calculate the biSizeImage field for us
::GetDIBits(hDC, hBitmap, 0, (WORD)bi.biHeight, NULL,
(LPBITMAPINFO)lpbi, DIB_RGB_COLORS);
// get the info. returned by GetDIBits and unlock
// memory block
bi = *lpbi;
bi.biClrUsed = ( biBits <= 8 ) ? 1 << biBits : 0;
::GlobalUnlock(hDib);
// if the driver did not fill in the biSizeImage field,
// make one up
if (bi.biSizeImage == 0)
bi.biSizeImage = WIDTH_BYTES((DWORD)bm.bmWidth * biBits) * bm.bmHeight;
// realloc the buffer big enough to hold all the bits
dwLen = bi.biSize + PaletteSize((LPSTR) &bi) +
bi.biSizeImage;
h = (HDIB)::GlobalReAlloc(hDib, dwLen, 0);
if ( h )
{
hDib = h;
}
else
{
// clean up and return NULL
::GlobalFree(hDib);
hDib = NULL;
::SelectPalette(hDC, hPal, TRUE);
::RealizePalette(hDC);
::ReleaseDC(NULL, hDC);
return NULL;
}
// lock memory block and get pointer to it
lpbi = (LPBITMAPINFOHEADER)::GlobalLock((HGLOBAL)hDib);
if (!lpbi)
{
// clean up and return NULL
::GlobalFree(hDib);
hDib = NULL;
::SelectPalette(hDC, hPal, TRUE);
::RealizePalette(hDC);
::ReleaseDC(NULL, hDC);
return NULL;
}
// call GetDIBits with a NON-NULL lpBits param, and
// actualy get the bits this time
if (::GetDIBits(hDC, hBitmap, 0, (WORD)bi.biHeight,
(LPSTR)lpbi + (WORD)lpbi->biSize +
PaletteSize((LPSTR) lpbi), (LPBITMAPINFO)lpbi,
DIB_RGB_COLORS) == 0)
{
// clean up and return NULL
::GlobalUnlock(hDib);
hDib = NULL;
::SelectPalette(hDC, hPal, TRUE);
::RealizePalette(hDC);
::ReleaseDC(NULL, hDC);
return NULL;
}
bi = *lpbi;
// clean up
::GlobalUnlock(hDib);
::SelectPalette(hDC, hPal, TRUE);
::RealizePalette(hDC);
::ReleaseDC(NULL, hDC);
// return handle to the DIB
return hDib;
}
/*************************************************************************
*
* DIBToBitmap()
*
* Parameters:
* HDIB - handle to a DIB that the Bitmap (DDB) is to be
* created from
*
* HPALETTE - palette to use in creation of bitmap (DDB)
*
* Return Value:
*
* HBITMAP - handle of the Bitmap created from the DIB,
* NULL on error
* Description:
*
* Returns an HBITMAP created from an HDIB.
* This function creates a bitmap from a DIB using the
* specified palette. If no palette is specified, one is
* created, used for the conversion, and then deleted.
*
* The bitmap returned from this funciton is always a
* bitmap compatible with the screen (e.g. same
* bits/pixel and color planes) rather than a bitmap
* with the same attributes as the DIB.
* This behavior is by design, and occurs because this
* function calls CreateDIBitmap to do its work, and
* CreateDIBitmap always creates a bitmap compatible with
* the hDC parameter passed in (because it in turn calls
* CreateCompatibleBitmap).
*
* So for instance, if your DIB is a monochrome DIB and
* you call this function, you will not get back a
* monochrome HBITMAP -- you will get an HBITMAP
* compatible with the screen DC, but with only 2 colors
* used in the bitmap.
*
* if your application requires a monochrome HBITMAP
* returned for a monochrome DIB, use the function SetDIBits().
************************************************************************/
HBITMAP CImage::DIBToBitmap(HDIB hDib, HPALETTE hPal)
{
ASSERT(hDib);
LPVOID lpDIBHdr = NULL; // pointer to DIB header
LPVOID lpDIBBits = NULL; // pointer to DIB bits
HBITMAP hBitmap = NULL; // handle to DDB
HDC hDC = NULL; // handle to DC
HPALETTE hOldPal = NULL; // handle to a palette
BOOL bPalCreated = FALSE;
// if invalid handle, return NULL
if (!hDib)
{
return NULL;
}
// lock memory block and get a pointer to it
lpDIBHdr = ::GlobalLock((HGLOBAL)hDib);
if (!lpDIBHdr)
{
return NULL;
}
// get a pointer to the DIB bits
lpDIBBits = FindDIBBits((LPSTR) lpDIBHdr);
if (!lpDIBBits)
return NULL;
// get a DC
hDC = ::GetDC(NULL);
if (!hDC)
{
// clean up and return NULL
::GlobalUnlock(hDib);
return NULL;
}
// select and realize palette
if (!hPal)
{
CPalette DibPal;
CreateDIBPalette(hDib,&DibPal);
hPal = (HPALETTE) DibPal.Detach();
bPalCreated = TRUE;
}
hOldPal = ::SelectPalette(hDC, hPal, FALSE);
::RealizePalette(hDC);
// create bitmap from DIB info. and bits
hBitmap = ::CreateDIBitmap(hDC, (LPBITMAPINFOHEADER)lpDIBHdr,
CBM_INIT, lpDIBBits, (LPBITMAPINFO)lpDIBHdr,
DIB_RGB_COLORS);
if (!hBitmap)
{
if (hOldPal)
::SelectPalette(hDC, hOldPal, FALSE);
::DeleteObject(hPal);
return NULL;
}
// restore previous palette
if (hOldPal)
::SelectPalette(hDC, hOldPal, FALSE);
// if we created the palette then we clean it up
if (bPalCreated && hPal)
::DeleteObject(hPal);
// clean up
::ReleaseDC(NULL, hDC);
::GlobalUnlock(hDib);
// return handle to the bitmap
return hBitmap;
}
/*************************************************************************
*
* PaletteSize()
*
* Parameter:
*
* LPSTR lpbi - pointer to packed-DIB memory block
*
* Return Value:
*
* WORD - size of the color palette of the DIB
*
* Description:
*
* This function gets the size required to store the DIB's palette by
* multiplying the number of colors by the size of an RGBQUAD (for a
* Windows 3.0-style DIB) or by the size of an RGBTRIPLE (for an other-
* style DIB).
*
************************************************************************/
WORD CImage::PaletteSize(LPSTR lpbi)
{
/* calculate the size required by the palette */
if (IS_WIN30_DIB (lpbi))
return (WORD)(DIBNumColors(lpbi) * sizeof(RGBQUAD));
else
return (WORD)(DIBNumColors(lpbi) * sizeof(RGBTRIPLE));
}
/*************************************************************************
*
* FindDIBBits()
*
* Parameter:
*
* LPSTR lpbi - pointer to packed-DIB memory block
*
* Return Value:
*
* LPSTR - pointer to the DIB bits
*
* Description:
*
* This function calculates the address of the DIB's bits and returns a
* pointer to the DIB bits.
*
************************************************************************/
LPSTR CImage::FindDIBBits(LPSTR lpbi)
{
return (lpbi + *(LPDWORD)lpbi + PaletteSize(lpbi));
}
/*************************************************************************
*
* CreateDIBPalette()
*
* Parameter:
*
* HDIB hDIB - specifies the DIB
*
* Return Value:
*
* HPALETTE - specifies the palette
*
* Description:
*
* This function creates a palette from a DIB by allocating memory for the
* logical palette, reading and storing the colors from the DIB's color table
* into the logical palette, creating a palette from this logical palette,
* and then returning the palette's handle. This allows the DIB to be
* displayed using the best possible colors (important for DIBs with 256 or
* more colors).
*
************************************************************************/
BOOL CImage::CreateDIBPalette(HDIB hDIB, CPalette* pPal)
{
LPLOGPALETTE lpPal; // pointer to a logical palette
HANDLE hLogPal; // handle to a logical palette
int i; // loop index
WORD wNumColors; // number of colors in color table
LPSTR lpbi; // pointer to packed-DIB
LPBITMAPINFO lpbmi; // pointer to BITMAPINFO structure (Win3.0)
LPBITMAPCOREINFO lpbmc; // pointer to BITMAPCOREINFO structure (old)
BOOL bWinStyleDIB; // flag which signifies whether this is a Win3.0 DIB
BOOL bResult = FALSE;
/* if handle to DIB is invalid, return FALSE */
if (hDIB == NULL)
return FALSE;
lpbi = (LPSTR) ::GlobalLock((HGLOBAL) hDIB);
/* get pointer to BITMAPINFO (Win 3.0) */
lpbmi = (LPBITMAPINFO)lpbi;
/* get pointer to BITMAPCOREINFO (old 1.x) */
lpbmc = (LPBITMAPCOREINFO)lpbi;
/* get the number of colors in the DIB */
wNumColors = DIBNumColors(lpbi);
if (wNumColors != 0)
{
/* allocate memory block for logical palette */
hLogPal = ::GlobalAlloc(GHND, sizeof(LOGPALETTE)
+ sizeof(PALETTEENTRY)
* wNumColors);
/* if not enough memory, clean up and return NULL */
if (hLogPal == 0)
{
::GlobalUnlock((HGLOBAL) hDIB);
return FALSE;
}
lpPal = (LPLOGPALETTE) ::GlobalLock((HGLOBAL) hLogPal);
/* set version and number of palette entries */
lpPal->palVersion = PALVERSION;
lpPal->palNumEntries = (WORD)wNumColors;
/* is this a Win 3.0 DIB? */
bWinStyleDIB = IS_WIN30_DIB(lpbi);
for (i = 0; i < (int)wNumColors; i++)
{
if (bWinStyleDIB)
{
lpPal->palPalEntry[i].peRed = lpbmi->bmiColors[i].rgbRed;
lpPal->palPalEntry[i].peGreen = lpbmi->bmiColors[i].rgbGreen;
lpPal->palPalEntry[i].peBlue = lpbmi->bmiColors[i].rgbBlue;
lpPal->palPalEntry[i].peFlags = 0;
}
else
{
lpPal->palPalEntry[i].peRed = lpbmc->bmciColors[i].rgbtRed;
lpPal->palPalEntry[i].peGreen = lpbmc->bmciColors[i].rgbtGreen;
lpPal->palPalEntry[i].peBlue = lpbmc->bmciColors[i].rgbtBlue;
lpPal->palPalEntry[i].peFlags = 0;
}
}
/* create the palette and get handle to it */
bResult = pPal->CreatePalette(lpPal);
::GlobalUnlock((HGLOBAL) hLogPal);
::GlobalFree((HGLOBAL) hLogPal);
}
else
{
CWindowDC dcScreen(NULL);
if ( dcScreen.GetDeviceCaps(RASTERCAPS) & RC_PALETTE )
{
/* create the palette and get handle to it */
bResult = pPal->CreateHalftonePalette(&dcScreen);
}
else
{
pPal->DeleteObject();
bResult = TRUE;
}
}
::GlobalUnlock((HGLOBAL) hDIB);
return bResult;
}
/*************************************************************************
*
* DIBNumColors()
*
* Parameter:
*
* LPSTR lpbi - pointer to packed-DIB memory block
*
* Return Value:
*
* WORD - number of colors in the color table
*
* Description:
*
* This function calculates the number of colors in the DIB's color table
* by finding the bits per pixel for the DIB (whether Win3.0 or other-style
* DIB). If bits per pixel is 1: colors=2, if 4: colors=16, if 8: colors=256,
* if 24, no colors in color table.
*
************************************************************************/
WORD CImage::DIBNumColors(LPSTR lpbi)
{
WORD wBitCount; // DIB bit count
/* If this is a Windows-style DIB, the number of colors in the
* color table can be less than the number of bits per pixel
* allows for (i.e. lpbi->biClrUsed can be set to some value).
* If this is the case, return the appropriate value.
*/
if (IS_WIN30_DIB(lpbi))
{
DWORD dwClrUsed;
dwClrUsed = ((LPBITMAPINFOHEADER)lpbi)->biClrUsed;
if (dwClrUsed != 0)
return (WORD)dwClrUsed;
}
/* Calculate the number of colors in the color table based on
* the number of bits per pixel for the DIB.
*/
if (IS_WIN30_DIB(lpbi))
wBitCount = ((LPBITMAPINFOHEADER)lpbi)->biBitCount;
else
wBitCount = ((LPBITMAPCOREHEADER)lpbi)->bcBitCount;
/* return number of colors based on bits per pixel */
switch (wBitCount)
{
case 1:
return 2;
case 4:
return 16;
case 8:
return 256;
default:
return 0;
}
}
| [
"[email protected]"
]
| [
[
[
1,
2357
]
]
]
|
337315f67680ee0fe7a998dd9fb733b4a6211965 | 57574cc7192ea8564bd630dbc2a1f1c4806e4e69 | /Poker/Cliente/OpUIClientePasar.cpp | fad2117e25cd854d93db214cdcdf0e46b88e8fc9 | []
| no_license | natlehmann/taller-2010-2c-poker | 3c6821faacccd5afa526b36026b2b153a2e471f9 | d07384873b3705d1cd37448a65b04b4105060f19 | refs/heads/master | 2016-09-05T23:43:54.272182 | 2010-11-17T11:48:00 | 2010-11-17T11:48:00 | 32,321,142 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 247 | cpp | #include "OpUIClientePasar.h"
OpUIClientePasar::OpUIClientePasar(void)
{
}
OpUIClientePasar::~OpUIClientePasar(void)
{
}
bool OpUIClientePasar::ejecutarAccion(Ventana* ventana) {
return this->enviarPedido("OpPasar", ventana);
}
| [
"[email protected]@a9434d28-8610-e991-b0d0-89a272e3a296"
]
| [
[
[
1,
14
]
]
]
|
58aad8b07e646b46ba900d1f4511381ea76e7218 | 35aea6d59e313063cc53fb48cfb32bf1ca7c7919 | /src/OSSClientTools/UtilityClasses/UtilityClasses.h | 8369b09b4487ba97bc914f437f86deb63d70ca0e | []
| no_license | abb-wcheung/opensign-project | c0d810cea2eb9c497dfaeab84f80909bf4d93acd | 0856a3e7cb8cd736384362ae8bad6f8362058a2e | refs/heads/master | 2016-09-01T21:26:14.317040 | 2008-11-02T17:46:44 | 2008-11-02T17:46:44 | 39,601,116 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,431 | h | // UtilityClasses.h
#pragma once
#pragma unmanaged
#include "windows.h"
namespace RP {
namespace Implementation {
namespace Owasp {
class IconUtilityUnmanaged
{
public:
IconUtilityUnmanaged(LPCWSTR path);
~IconUtilityUnmanaged();
void LoadIcons(void);
// callback function
static BOOL CALLBACK EnumResNameProcImpl(HMODULE hModule, LPCWSTR lpszType, LPWSTR lpszName, LONG_PTR lParam);
private:
LPCWSTR m_path;
// unmanaged
HMODULE hIconLibrary;
};
typedef struct
{
BYTE bWidth; // Width, in pixels, of the image
BYTE bHeight; // Height, in pixels, of the image
BYTE bColorCount; // Number of colors in image (0 if >=8bpp)
BYTE bReserved; // Reserved ( must be 0)
WORD wPlanes; // Color Planes
WORD wBitCount; // Bits per pixel
DWORD dwBytesInRes; // How many bytes in this resource?
DWORD dwImageOffset; // Where in the file is this image?
} ICONDIRENTRY, *LPICONDIRENTRY;
typedef struct
{
WORD idReserved; // Reserved (must be 0)
WORD idType; // Resource Type (1 for icons)
WORD idCount; // How many images?
ICONDIRENTRY idEntries[1]; // An entry for each image (idCount of 'em)
} ICONDIR, *LPICONDIR;
}
}
}
| [
"philipp.potisk@725ea65b-bb50-0410-bc28-9f83e2431ff3"
]
| [
[
[
1,
48
]
]
]
|
1b0cceaa1fe18929ebffe1a4a4e560adb0562df7 | 41371839eaa16ada179d580f7b2c1878600b718e | /UVa/Volume II/00264.cpp | 1ec82809055e58182debc013e862f05a026931ca | []
| no_license | marinvhs/SMAS | 5481aecaaea859d123077417c9ee9f90e36cc721 | 2241dc612a653a885cf9c1565d3ca2010a6201b0 | refs/heads/master | 2021-01-22T16:31:03.431389 | 2009-10-01T02:33:01 | 2009-10-01T02:33:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 444 | cpp | /////////////////////////////////
// 00264 - Count on Cantor
/////////////////////////////////
#include<cstdio>
#include<cmath>
int ntri, tri, n;
int nup(int k){
return (int)ceil((-1+sqrt(1+8*k))/2);
}
int main(void){
while(scanf("%d",&n)!=EOF){
ntri = nup(n);
tri = ntri*(ntri+1)/2;
if(ntri&1) printf("TERM %d IS %d/%d\n",n,1+(tri-n),ntri-(tri-n));
else printf("TERM %d IS %d/%d\n",n,ntri-(tri-n),1+(tri-n));
}
}
| [
"[email protected]"
]
| [
[
[
1,
18
]
]
]
|
6ccd0d58c4db57a7cdb93d49fd206d8c506009c7 | 8f5d0d23e857e58ad88494806bc60c5c6e13f33d | /Texture/cTextureManager.cpp | 6c12ecacf036d36937e5ad5554e5e89b41664ebd | []
| no_license | markglenn/projectlife | edb14754118ec7b0f7d83bd4c92b2e13070dca4f | a6fd3502f2c2713a8a1a919659c775db5309f366 | refs/heads/master | 2021-01-01T15:31:30.087632 | 2011-01-30T16:03:41 | 2011-01-30T16:03:41 | 1,704,290 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,693 | cpp | #include <algorithm>
#include "cTextureManager.h"
#include "cBMPImage.h"
#include "../File/cFileManager.h"
#include "../Core/cLog.h"
// Include Paul Nettle's memory manager
#include "../Memory/mmgr.h"
/////////////////////////////////////////////////////////////////////////////////////
cTextureManager::cTextureManager(void)
/////////////////////////////////////////////////////////////////////////////////////
{
Singleton ();
glEnable (GL_TEXTURE_2D);
}
/////////////////////////////////////////////////////////////////////////////////////
cTextureManager::~cTextureManager(void)
/////////////////////////////////////////////////////////////////////////////////////
{
// Delete the textures from memory
ClearAll ();
}
/////////////////////////////////////////////////////////////////////////////////////
int cTextureManager::LoadTexture (std::string filename)
/////////////////////////////////////////////////////////////////////////////////////
{
std::vector <cTexture *>::iterator i;
std::string extension;
cImage *image;
cTexture *texture;
cIFile *file;
// Check to see if this texture is already loaded
for (unsigned int i = 0; i < m_textures.size(); i++)
if (m_textures[i]->IsFile (filename))
return i;
file = cFileManager::Singleton()->OpenFile (filename);
// Make sure this is a valid file
if (file == NULL)
return -1;
unsigned int pos = filename.find ('.');
// File has no extension
if (std::string::npos == pos)
return -1;
// Extract the uppercase file extension
extension = filename.substr(pos);
std::transform (extension.begin(), extension.end(),
extension.begin(), toupper);
// Create the image based on the file extension
image = cFactory<cImage>::Instance().Create(extension.c_str());
if (!image)
{
// Unsupported image format
cLog::Singleton()->Print ("%s is in an unsupported image format", filename.c_str());
return -1;
}
// Load the image
if (!image->LoadTexture (file))
{
delete image;
return -1;
}
// Close the file
cFileManager::Singleton()->CloseFile (file);
// Create the texture from the image
texture = new cTexture ();
texture->SetImage (filename, image);
if (UNDEFINED_TEXTURE == texture->GetTextureNumber())
{
delete texture;
delete image;
return -1;
}
// Place the texture in the first free spot
int num = GetFreeTexture();
m_textures[num] = texture;
delete image;
return num;
}
/////////////////////////////////////////////////////////////////////////////////////
void cTextureManager::ClearAll ()
/////////////////////////////////////////////////////////////////////////////////////
{
std::vector <cTexture *>::iterator i;
// Delete any textures still allocated
for (i = m_textures.begin(); i != m_textures.end(); i++)
if ((*i) != NULL)
delete *i;
// Reset the size of the texture holder
m_textures.clear();
}
/////////////////////////////////////////////////////////////////////////////////////
void cTextureManager::DeleteTexture (int texNum)
/////////////////////////////////////////////////////////////////////////////////////
{
// If the texture exists, delete it and mark its spot as free
if (m_textures[texNum] != NULL)
{
delete m_textures[texNum];
m_textures[texNum] = NULL;
}
}
/////////////////////////////////////////////////////////////////////////////////////
int cTextureManager::GetFreeTexture ()
/////////////////////////////////////////////////////////////////////////////////////
{
// Return at the first unallocated spot in the vector
for (unsigned int i = 0; i < m_textures.size(); i++)
{
if (m_textures[i] == NULL)
return i;
}
// Create a new spot for the texture
m_textures.push_back (NULL);
return m_textures.size() - 1;
}
/////////////////////////////////////////////////////////////////////////////////////
int cTextureManager::LoadTexture (unsigned char *image, unsigned int width,
unsigned int height, unsigned int bpp)
/////////////////////////////////////////////////////////////////////////////////////
{
cImage cImage;
int num;
cTexture *texture;
cImage.SetDimensions(width, height, bpp);
cImage.SetImage(image);
texture = new cTexture ();
// Have to create a unique filename
std::string filename;
filename = GetFreeTexture();
filename += "_UNIQUE_TEXTURE_FILENAME";
texture->SetImage (filename, &cImage);
if (UNDEFINED_TEXTURE == texture->GetTextureNumber())
return -1;
// Place the texture in the first free spot
num = GetFreeTexture();
m_textures[num] = texture;
return num;
} | [
"[email protected]"
]
| [
[
[
1,
173
]
]
]
|
d7186b59643aa89dc573010224d3440749185dd1 | a8157564af47618589001d80f0f4571c6328f3e0 | /room.cpp | e24d59434ba04f5a10c263e34c4ca223466511a9 | [
"MIT"
]
| permissive | dionyziz/cador | 83848185094c0198ec7b217fdaf2d94c39e541ba | ee939b5556aebdea692d3cea5badbe3c85b49a7d | refs/heads/master | 2020-06-06T07:11:55.517376 | 2011-11-23T21:45:58 | 2011-11-23T21:45:58 | 2,240,956 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,594 | cpp | #include "room.h"
map< unsigned int, Room* > Vilundo_Rooms;
///<static>///
Room* Room::Create( unsigned int roomid, string roomname ) {
Room* rm;
assert( Vilundo::Alphanumeric( roomname ) );
assert( roomname.length() > 0 );
Trace << "Setting up room `" << roomname << "' (" << roomid << ")";
if ( !Vilundo::Alphanumeric( roomname ) ) {
Warning << "Vilundo roomname is not alphanumeric (roomid: " << roomid;
return 0;
}
if ( Vilundo_Rooms.find( roomid ) != Vilundo_Rooms.end() ) {
Warning << "Duplicate vilundo roomid: " << roomid;
return 0;
}
return Vilundo_Rooms[ roomid ] = new Room( roomid, roomname );
}
///</static>///
void Room::Init() {
vector< string > rooms = conf->GetMultiSetting( "rooms" );
vector< string > roomdata;
unsigned int roomid;
string roomname;
for ( vector< string >::iterator i = rooms.begin(); i != rooms.end(); ++i ) {
roomdata = explode( ":", *i, 2 );
if ( roomdata.size() != 2 ) {
Warning << "Invalid room configuration specified (no : character found)";
}
roomid = atoi( trim( roomdata[ 0 ] ).c_str() );
roomname = trim( roomdata[ 1 ] );
Room::Create( roomid, roomname );
}
}
void Room::UserJoins( unsigned int userid ) {
string s = "";
unsigned char croomid[ 2 ];
unsigned char cuserid[ 4 ];
assert( userid > 0 );
pair< set< unsigned int >::iterator, bool > r = this->mUsers.insert( userid );
Trace << "User " << userid << " joining room " << this->mRoomName;
if ( !r.second ) {
Warning << "User " << userid << " is already in room " << this->mRoomName;
return;
}
Vilundo::AppendHeader( s, VILUNDO_OUTGOING_JOINED );
Vilundo::Encode4B( userid, cuserid );
Vilundo::Encode2B( this->mRoomId, croomid );
s.append( ( char* )cuserid, 4 );
s.append( ( char* )croomid, 2 );
Vilundo::Broadcast( s, this->mUsers );
}
void Room::UserParts( unsigned int userid ) {
string s = "";
unsigned char croomid[ 2 ];
unsigned char cuserid[ 4 ];
assert( userid > 0 );
Trace << "User " << userid << " parting room " << this->mRoomName;
if ( this->mUsers.erase( userid ) != 1 ) {
Warning << "User " << userid << " is not in room " << this->mRoomName;
}
Vilundo::AppendHeader( s, VILUNDO_OUTGOING_PARTED );
Vilundo::Encode4B( userid, cuserid );
Vilundo::Encode2B( this->mRoomId, croomid );
s.append( ( char* )cuserid, 4 );
s.append( ( char* )croomid, 2 );
Vilundo::Broadcast( s, this->mUsers );
}
void Room::UserMessage( unsigned int userid, string message ) {
string s1 = "";
string s2 = "";
string s;
unsigned char cmessageid[ 2 ];
unsigned char cuserid[ 4 ];
unsigned char croomid[ 2 ];
if ( message.length() == 0 ) {
Notice << "User " << userid << " attempted to send an empty message to room " << this->mRoomId << "; skipping";
return;
}
if( !Vilundo::Alphanumeric( message ) ) {
Notice << "User " << userid << " attempted to send non-alphanumeric message to room " << this->mRoomId << "; skipping";
return;
}
Vilundo::AppendHeader( s1, VILUNDO_OUTGOING_ROOM_MESSAGE );
Vilundo::Encode4B( userid, cuserid );
s1.append( ( char* )cuserid, 4 );
Vilundo::Encode2B( this->mRoomId, croomid );
s1.append( ( char* )croomid, 2 );
s2.append( message );
s2.append( 1, '\0' );
for ( set< unsigned int >::iterator i = this->mUsers.begin(); i != this->mUsers.end(); ++i ) {
if ( *i != userid ) {
s = "";
s.append( s1 );
Vilundo::Encode2B( Vilundo_FromUserId[ *i ]->NextMessageId(), cmessageid );
s.append( ( char* )cmessageid, 2 );
s.append( s2 );
Vilundo_FromUserId[ *i ]->SendRawData( s );
}
}
}
Room::Room( unsigned int roomid, string roomname ) {
assert( roomid > 0 );
assert( Vilundo::Alphanumeric( roomname ) );
assert( roomname.length() > 0 );
this->mRoomId = roomid;
this->mRoomName = roomname;
}
bool Room::UserInRoom( unsigned int userid ) {
assert( userid > 0 );
return this->mUsers.find( userid ) != this->mUsers.end();
}
set< unsigned int > Room::Users() {
return this->mUsers;
}
string Room::Name() {
return this->mRoomName;
}
| [
"[email protected]"
]
| [
[
[
1,
151
]
]
]
|
0738c1a752fad9ebf7efeb1bf054ed32e8f7c8cc | cd61c8405fae2fa91760ef796a5f7963fa7dbd37 | /Sauron/VisionTests/VisionModelTest.cpp | 30e6b84dd02b7d5a9c6db19ce4041a29e0a43125 | []
| no_license | rafaelhdr/tccsauron | b61ec89bc9266601140114a37d024376a0366d38 | 027ecc2ab3579db1214d8a404d7d5fa6b1a64439 | refs/heads/master | 2016-09-05T23:05:57.117805 | 2009-12-14T09:41:58 | 2009-12-14T09:41:58 | 32,693,544 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,318 | cpp | #include <iostream>
#include <ctime>
#include <sstream>
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include "../Vision/VisionModel.h"
extern void drawProjection( sauron::Image &im, const sauron::Projection &proj, CvFont &font, byte r, byte g, byte b, std::string txt = "" );
int testVisionModel()
{
sauron::Image frame( 320, 240, 8, sauron::Pixel::PF_RGB );
sauron::VisionModel visionModel;
CvFont font;
cvInitFont( &font, CV_FONT_HERSHEY_PLAIN, 1.0, 1.0, 0 );
cvNamedWindow( "Frame", CV_WINDOW_AUTOSIZE );
clock_t fpsStartTime = clock();
unsigned int framesCount = 0;
char key = 0;
while ( key != 'q' && key != 'Q' && key != 27 )
{
//visionModel.getLastFrame( frame );
//visionModel.getLastFrameWithTrackedProjections( frame );
cvShowImage( "Frame", frame );
if ( clock() - fpsStartTime > CLOCKS_PER_SEC )
{
std::cout << "Main Loop: " << (double)framesCount * CLOCKS_PER_SEC / (double)(clock() - fpsStartTime) << " <=> " << framesCount << std::endl;
framesCount = 0;
fpsStartTime = clock();
}
else
++framesCount;
key = (char)cvWaitKey( 1 );
}
cvDestroyAllWindows();
return 0;
} | [
"fggodoy@8373e73c-ebb0-11dd-9ba5-89a75009fd5d"
]
| [
[
[
1,
46
]
]
]
|
cb558fcf261eca799948a0e22678a52bf91c79b4 | 5ed707de9f3de6044543886ea91bde39879bfae6 | /ASBasketball/ASFIsOrb/Source/ASBasketballPlayerScoutRqst.cpp | b8e80f74e57ba7a9606b19c1d6416d38fe1929f0 | []
| no_license | grtvd/asifantasysports | 9e472632bedeec0f2d734aa798b7ff00148e7f19 | 76df32c77c76a76078152c77e582faa097f127a8 | refs/heads/master | 2020-03-19T02:25:23.901618 | 1999-12-31T16:00:00 | 2018-05-31T19:48:19 | 135,627,290 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,156 | cpp | /* ASBasketballPlayerScoutRqst.cpp */
/******************************************************************************/
/******************************************************************************/
#include "CBldVCL.h"
#pragma hdrstop
#include "ASBasketballType.h"
#include "ASBasketballPlayerScoutRqst.h"
namespace asbasketball
{
/******************************************************************************/
/******************************************************************************/
PlayerStatValue ASBasketballPlayerScoutRqst::getDefaultPlayerStatValue(
int playerStatType)
{
//BOB if(isPlayerStatTypeOffensive(playerStatType))
return(TBasketballOffGameStat::getDefaultStatStr(playerStatType).c_str());
//BOB return(TBasketballDefGameStat::getDefaultStatStr(playerStatType).c_str());
}
/******************************************************************************/
bool ASBasketballPlayerScoutRqst::isPlayerStatTypeOffensive(int playerStatType)
{
#if 1 //BOB
TBasketballPlayerStatType basketballPlayerStatType(playerStatType); //validate playerStatType
return(true);
#else //BOB
TBasketballPlayerStatType basketballPlayerStatType(playerStatType);
if((basketballPlayerStatType == pst_TotalPoints) ||
(basketballPlayerStatType == pst_GamesPlayed))
return(true);
return(basketballPlayerStatType.isOffensive());
#endif //BOB
}
/******************************************************************************/
bool ASBasketballPlayerScoutRqst::isPlayerStatTypeDefensive(int playerStatType)
{
#if 1 //BOB
return(false);
#else //BOB
TBasketballPlayerStatType basketballPlayerStatType(playerStatType);
if((basketballPlayerStatType == pst_TotalPoints) ||
(basketballPlayerStatType == pst_GamesPlayed))
return(true);
return(!basketballPlayerStatType.isOffensive());
#endif //BOB
}
/******************************************************************************/
}; // asbasketball
/******************************************************************************/
/******************************************************************************/
| [
"[email protected]"
]
| [
[
[
1,
68
]
]
]
|
38c487515820980237f0f0a880a00b606cf1b440 | 485c5413e1a4769516c549ed7f5cd4e835751187 | /Source/Engine/FBO.h | 2efbde06cb9d998c987c88d598d9295223dc0869 | []
| no_license | FranckLetellier/rvstereogram | 44d0a78c47288ec0d9fc88efac5c34088af88d41 | c494b87ee8ebb00cf806214bc547ecbec9ad0ca0 | refs/heads/master | 2021-05-29T12:00:15.042441 | 2010-03-25T13:06:10 | 2010-03-25T13:06:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,712 | h | /*************************************
*
* ImacDemo Project
*
* Created : 07/12/09
* Authors : Franck Letellier
* Baptiste Malaga
* Fabien Kapala
*
**************************************/
#ifndef __FBO_H__
#define __FBO_H__
/**
* @name FBO.h
* @brief Create and handle a Frame buffer object
* @author Franck Letellier
* @date 07/12/09
*/
#include <string>
#include <GL/glew.h>
#include <GL/glut.h>
#include <GL/glu.h>
#include "Enum.h"
class FBO
{
private:
//public :
///Check the statue of the FBO created
bool checkFramebufferStatus();
void generateID();
void destroy();
GLuint m_iTexId;
GLuint m_iTexDepthId;
GLuint m_iRenderId;
GLuint m_iId;
bool m_bIsActivated;
bool m_bIsCubeMap;
unsigned int m_iWidth;
unsigned int m_iHeight;
///Type : 0 = Color only , 1 = Depth only , 2 = Depth+Color
///TODO : Enum
unsigned int m_iType;
FboEnum m_eDefinitionType;
GLuint m_eTextureType;
public:
FBO(unsigned int iWidth, unsigned int iHeight, FboEnum eType);
~FBO(){destroy();};
void generateDepthOnly();
void generateColorOnly(bool tex16f = false);
void generate();
//To activate the texture
void activateTexture();
void desactivateTexture();
//To activate the depth texture
void activateDepthTexture();
void desactivateDepthTexture();
//To activate the FBO (in order to write)
void activate();
void desactivate();
//To choose a face for the cube
void activate(unsigned int iFace);
inline const unsigned int& getWidth(){return m_iWidth;};
inline const unsigned int& getHeight(){return m_iHeight;};
};
#endif //__FBO_H__
| [
"[email protected]"
]
| [
[
[
1,
88
]
]
]
|
b732a55b9350132c61f8c49d093585eb260d903c | 58ef4939342d5253f6fcb372c56513055d589eb8 | /WallpaperChanger/WallpaperChange/source/Views/src/ThemeChangeAppView.cpp | ffd1f0f77e007ac8dbb1f8559103e388241b54b8 | []
| no_license | flaithbheartaigh/lemonplayer | 2d77869e4cf787acb0aef51341dc784b3cf626ba | ea22bc8679d4431460f714cd3476a32927c7080e | refs/heads/master | 2021-01-10T11:29:49.953139 | 2011-04-25T03:15:18 | 2011-04-25T03:15:18 | 50,263,327 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,647 | cpp | /*
============================================================================
Name : ThemeChangeAppView.cpp
Author : zengcity
Copyright : Your copyright notice
Description : Application view implementation
============================================================================
*/
// INCLUDE FILES
#include <aknviewappui.h>
#include "ThemeChangeAppView.h"
#include <eikmenup.h>
#include <ThemeChange_0xEAC842A2.rsg>
#include "ThemeChange.hrh"
#include "ThemeChangeDef.h"
// ============================ MEMBER FUNCTIONS ===============================
CThemeChangeAppView::CThemeChangeAppView()
{
// No implementation required
iContainer = NULL;
}
CThemeChangeAppView::~CThemeChangeAppView()
{
DoDeactivate();
}
CThemeChangeAppView* CThemeChangeAppView::NewLC()
{
CThemeChangeAppView* self = new (ELeave) CThemeChangeAppView();
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
CThemeChangeAppView* CThemeChangeAppView::NewL()
{
CThemeChangeAppView* self = CThemeChangeAppView::NewLC();
CleanupStack::Pop(); // self;
return self;
}
void CThemeChangeAppView::ConstructL()
{
BaseConstructL(R_VIEW_APP);
//add your code here...
}
/**
*
* */
TUid CThemeChangeAppView::Id() const
{
return TUid::Uid(EThemeChangeAppViewId);
}
void CThemeChangeAppView::HandleCommandL(TInt aCommand)
{
switch (aCommand)
{
case ECommandChoose:
if (iContainer)
iContainer->Selected();
break;
case ECommandRemove:
if (iContainer)
iContainer->UninstallL();
break;
case ECommandStart:
if (iContainer)
iContainer->StartServer();
break;
case ECommandStop:
if (iContainer)
iContainer->StopServer();
break;
case ECommandSettingTheme:
case ECommandSettingService:
break;
case ECommandRegister:
if (iContainer)
iContainer->StartPaymentWaitDlg();
break;
default:
AppUi()->HandleCommandL(aCommand);
}
}
void CThemeChangeAppView::HandleStatusPaneSizeChange()
{
if (iContainer != NULL)
iContainer->SetRect(ClientRect());
}
/**
*
* */
void CThemeChangeAppView::DoActivateL(const TVwsViewId& aPrevViewId,
TUid /*aCustomMessageId*/, const TDesC8& aCustomMessage)
{
if (iContainer == NULL)
{
iContainer = CThemeChangeAppContainer::NewL(ClientRect());
iContainer->SetMopParent(this);
AppUi()->AddToStackL(*this, iContainer);
//add your init code ...
if (aCustomMessage.Length() > 0)
{
if (aCustomMessage.Compare(KMsgCfgChange))
{
iContainer->RefreshServer();
}
}
}
}
void CThemeChangeAppView::DoDeactivate()
{
if (iContainer != NULL)
{
AppUi()->RemoveFromViewStack(*this, iContainer);
delete iContainer;
iContainer = NULL;
}
}
void CThemeChangeAppView::DynInitMenuPaneL( TInt aResourceId,
CEikMenuPane* aMenuPane )
{
if (aResourceId == R_MENU_SERVICE)
{
if (iContainer->IsServerActive())
{
aMenuPane->SetItemDimmed(ECommandStart, ETrue);
aMenuPane->SetItemDimmed(ECommandStop, EFalse);
}
else
{
aMenuPane->SetItemDimmed(ECommandStart, EFalse);
aMenuPane->SetItemDimmed(ECommandStop, ETrue);
}
}
else if (aResourceId == R_MENU_THEME)
{
if (iContainer->IsCurrentDeletable())
{
aMenuPane->SetItemDimmed(ECommandRemove, EFalse);
}
else
{
aMenuPane->SetItemDimmed(ECommandRemove, ETrue);
}
}
}
void CThemeChangeAppView::StopWaitDlg()
{
if (iContainer)
iContainer->StopWaitDlg();
}
// End of File
| [
"zengcity@415e30b0-1e86-11de-9c9a-2d325a3e6494"
]
| [
[
[
1,
164
]
]
]
|
b6b4a8919d0f22b4722bc6d24e4370ed2bb7a460 | cd07acbe92f87b59260478f62a6f8d7d1e218ba9 | /src/MorphaDataGather.h | 5994e318443062baf4e42d1491c2033c521f6bec | []
| no_license | niepp/sperm-x | 3a071783e573d0c4bae67c2a7f0fe9959516060d | e8f578c640347ca186248527acf82262adb5d327 | refs/heads/master | 2021-01-10T06:27:15.004646 | 2011-09-24T03:33:21 | 2011-09-24T03:33:21 | 46,690,957 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,881 | h | #if !defined(AFX_MORPHADATAGATHER_H__3A6D1D2A_7AA5_4A56_926B_109EA256B5D3__INCLUDED_)
#define AFX_MORPHADATAGATHER_H__3A6D1D2A_7AA5_4A56_926B_109EA256B5D3__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MorphaDataGather.h : header file
//
#include "datalistctrl.h"
/////////////////////////////////////////////////////////////////////////////
// CMorphaDataGather dialog
class CMorphaDataGather : public CDialog
{
// Construction
public:
CMorphaDataGather(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CMorphaDataGather)
enum { IDD = IDD_DIALOG_MORPHA_DATA_GATHER };
CDataListCtrl m_List;
CString m_strInfo;
CString m_length;
CString m_width;
CString m_area;
CString m_ellipticity;
CString m_perfor_area;
CString m_head_area;
CString m_perimeter;
CString m_head_perfor_area;
CString m_tail_length;
CString m_tail_width;
CString m_tail_angle;
CString m_extension;
CString m_symmetry;
CString m_ruga;
//}}AFX_DATA
LPBYTE m_lpData;
LPBITMAPINFOHEADER m_lpInfo;
void ReadImage(const CString& pID);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMorphaDataGather)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CMorphaDataGather)
virtual BOOL OnInitDialog();
afx_msg void OnClickListMorphadata(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnPaint();
afx_msg void OnClose();
virtual void OnOK();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MORPHADATAGATHER_H__3A6D1D2A_7AA5_4A56_926B_109EA256B5D3__INCLUDED_)
| [
"harithchen@e030fd90-5f31-5877-223c-63bd88aa7192"
]
| [
[
[
1,
70
]
]
]
|
274e9a3213f75c19a0ce3aeeebc96b5174cb644b | 22b6d8a368ecfa96cb182437b7b391e408ba8730 | /engine/include/qvProtothread.h | f402b48ace39e4273d162fcc7e86b2c7468908a4 | [
"MIT"
]
| permissive | drr00t/quanticvortex | 2d69a3e62d1850b8d3074ec97232e08c349e23c2 | b780b0f547cf19bd48198dc43329588d023a9ad9 | refs/heads/master | 2021-01-22T22:16:50.370688 | 2010-12-18T12:06:33 | 2010-12-18T12:06:33 | 85,525,059 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,220 | h | // Restart protothread.// Protothread class and macros for lightweight, stackless threads in C++.
//
// This was "ported" to C++ from Adam Dunkels' protothreads C library at:
// http://www.sics.se/~adam/pt/
//
// Originally ported for use by Hamilton Jet (www.hamiltonjet.co.nz) by
// Ben Hoyt, but stripped down for public release. See his blog entry about
// it for more information:
// http://blog.micropledge.com/2008/07/protothreads/
//
// Visual Studio users: There's a quirk with VS where it defines __LINE__
// as a non-constant when you've got a project's Debug Information Format
// set to "Program Database for Edit and Continue (/ZI)" -- the default.
// To fix, just go to the project's Properties, Configuration Properties,
// C/C++, General, Debug Information Format, and change it to "Program
// Database (/Zi)".
//
// --------------------------
// Original BSD-style license
// --------------------------
// Copyright (c) 2004-2005, Swedish Institute of Computer Science.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the Institute 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 Institute 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 Institute 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 __PROTOTHREAD_H__
#define __PROTOTHREAD_H__
// A lightweight, stackless thread. Override the Run() method and use
// the PT_* macros to do work of the thread.
//
// A simple example
// ----------------
// class LEDFlasher : public Protothread
// {
// public:
// virtual bool Run();
//
// private:
// ExpiryTimer _timer;
// uintf _i;
// };
//
// bool LEDFlasher::Run()
// {
// PT_BEGIN();
//
// for (_i = 0; _i < 10; _i++)
// {
// SetLED(true);
// _timer.Start(250);
// PT_WAIT_UNTIL(_timer.Expired());
//
// SetLED(false);
// _timer.Start(750);
// PT_WAIT_UNTIL(_timer.Expired());
// }
//
// PT_END();
// }
//
class Protothread
{
public:
// Construct a new protothread that will start from the beginning
// of its Run() function.
Protothread() : _ptLine(0) { }
void restart() { _ptLine = 0; }
// Stop the protothread from running. Happens automatically at PT_END.
// Note: this differs from the Dunkels' original protothread behaviour
// (his restart automatically, which is usually not what you want).
void stop() { _ptLine = LineNumberInvalid; }
// Return true if the protothread is running or waiting, false if it has
// ended or exited.
bool running() { return _ptLine != LineNumberInvalid; }
// Run next part of protothread or return immediately if it's still
// waiting. Return true if protothread is still running, false if it
// has finished. Implement this method in your Protothread subclass.
virtual bool run() const = 0;
protected:
// Used to store a protothread's position (what Dunkels calls a
// "local continuation").
typedef unsigned short LineNumber;
// An invalid line number, used to mark the protothread has ended.
static const LineNumber LineNumberInvalid = (LineNumber)(-1);
// Stores the protothread's position (by storing the line number of
// the last PT_WAIT, which is then switched on at the next Run).
LineNumber _ptLine;
};
// Declare start of protothread (use at start of Run() implementation).
#define PT_BEGIN() bool ptYielded = true; switch (_ptLine) { case 0:
// Stop protothread and end it (use at end of Run() implementation).
#define PT_END() default: ; } stop(); return false;
// Cause protothread to wait until given condition is true.
#define PT_WAIT_UNTIL(condition) \
do { _ptLine = __LINE__; case __LINE__: \
if (!(condition)) return true; } while (0)
// Cause protothread to wait while given condition is true.
#define PT_WAIT_WHILE(condition) PT_WAIT_UNTIL(!(condition))
// Cause protothread to wait until given child protothread completes.
#define PT_WAIT_THREAD(child) PT_WAIT_WHILE((child).run())
// Restart and spawn given child protothread and wait until it completes.
#define PT_SPAWN(child) \
do { (child).restart(); PT_WAIT_THREAD(child); } while (0)
// Restart protothread's execution at its PT_BEGIN.
#define PT_RESTART() do { restart(); return true; } while (0)
// Stop and exit from protothread.
#define PT_EXIT() do { stop(); return false; } while (0)
// Yield protothread till next call to its Run().
#define PT_YIELD() \
do { ptYielded = false; _ptLine = __LINE__; case __LINE__: \
if (!ptYielded) return true; } while (0)
// Yield protothread until given condition is true.
#define PT_YIELD_UNTIL(condition) \
do { ptYielded = false; _ptLine = __LINE__; case __LINE__: \
if (!ptYielded || !(condition)) return true; } while (0)
#endif // __PROTOTHREAD_H__
| [
"[email protected]"
]
| [
[
[
1,
159
]
]
]
|
fc2d03e13b8d8894dd3bc2cf15d9abe30849e231 | bd0aeddb7bc001052641c9d99148c9e900502e31 | /apps/examples/eventsExample/src/testApp.cpp | 7d3be795dbc617c6b75c7a34efde85008827aae2 | []
| no_license | scottmac/openFrameworks | f3be725f3ce6d24030f8a5c6b3a0ecc1c031c60c | 23bd71bc88030419ec0bce5773b4b8c18b2cc6b3 | refs/heads/master | 2021-01-18T08:25:58.385835 | 2011-01-23T22:56:44 | 2011-01-23T22:56:44 | 1,285,888 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,184 | cpp | #include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
counter = 0;
vagRounded.loadFont("vag.ttf", 32);
ofBackground(50,50,50);
}
//--------------------------------------------------------------
void testApp::update(){
counter = counter + 0.033f;
}
//--------------------------------------------------------------
void testApp::draw(){
sprintf (timeString, "time: %0.2i:%0.2i:%0.2i \nelapsed time %i", ofGetHours(), ofGetMinutes(), ofGetSeconds(), ofGetElapsedTimeMillis());
float w = vagRounded.stringWidth(eventString);
float h = vagRounded.stringHeight(eventString);
ofSetHexColor(0xffffff);
vagRounded.drawString(eventString, 98,198);
ofSetColor(255,122,220);
vagRounded.drawString(eventString, 100,200);
ofSetHexColor(0xffffff);
vagRounded.drawString(timeString, 98,98);
ofSetColor(255,122,220);
vagRounded.drawString(timeString, 100,100);
}
//--------------------------------------------------------------
void testApp::keyPressed (int key){
sprintf(eventString, "keyPressed = (%i)", key);
}
//--------------------------------------------------------------
void testApp::keyReleased(int key){
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
sprintf(eventString, "mouseMoved = (%i,%i)", x, y);
}
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
sprintf(eventString, "mouseDragged = (%i,%i - button %i)", x, y, button);
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
sprintf(eventString, "mousePressed = (%i,%i - button %i)", x, y, button);
}
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
sprintf(eventString, "mouseReleased = (%i,%i - button %i)", x, y, button);
}
//--------------------------------------------------------------
void testApp::windowResized(int w, int h){
sprintf(eventString, "resized = (%i,%i)", w, h);
}
| [
"arturo@adcd5791-1b6c-4787-a4a6-ffef2f616413",
"[email protected]"
]
| [
[
[
1,
23
],
[
25,
30
],
[
32,
73
]
],
[
[
24,
24
],
[
31,
31
]
]
]
|
94bc35479e3f103c197518b5b9cf6bfec482a11a | cc336f796b029620d6828804a866824daa6cc2e0 | /cximage/CxImage/ximatran.cpp | 91ce1fa60854f72775bdd521890bc4299a52adb5 | []
| no_license | tokyovigilante/xbmc-sources-fork | 84fa1a4b6fec5570ce37a69d667e9b48974e3dc3 | ac3c6ef8c567f1eeb750ce6e74c63c2d53fcde11 | refs/heads/master | 2021-01-19T10:11:37.336476 | 2009-03-09T20:33:58 | 2009-03-09T20:33:58 | 29,232 | 2 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 40,410 | cpp | // Place the code and data below here into the CXIMAGE section.
#ifndef _DLL
#pragma code_seg( "CXIMAGE" )
#pragma data_seg( "CXIMAGE_RW" )
#pragma bss_seg( "CXIMAGE_RW" )
#pragma const_seg( "CXIMAGE_RD" )
#pragma comment(linker, "/merge:CXIMAGE_RW=CXIMAGE")
#pragma comment(linker, "/merge:CXIMAGE_RD=CXIMAGE")
#endif
// xImaTran.cpp : Transformation functions
/* 07/08/2001 v1.00 - [email protected]
* CxImage version 5.80 29/Sep/2003
*/
#include "ximage.h"
#if CXIMAGE_SUPPORT_BASICTRANSFORMATIONS
////////////////////////////////////////////////////////////////////////////////
bool CxImage::GrayScale()
{
if (!pDib) return false;
if (head.biBitCount<=8){
RGBQUAD* ppal=GetPalette();
int gray;
//converts the colors to gray, use the blue channel only
for(DWORD i=0;i<head.biClrUsed;i++){
gray=(int)RGB2GRAY(ppal[i].rgbRed,ppal[i].rgbGreen,ppal[i].rgbBlue);
ppal[i].rgbBlue = (BYTE)gray;
}
// preserve transparency
if (info.nBkgndIndex != -1) info.nBkgndIndex = ppal[info.nBkgndIndex].rgbBlue;
//create a "real" 8 bit gray scale image
if (head.biBitCount==8){
BYTE *img=info.pImage;
for(DWORD i=0;i<head.biSizeImage;i++) img[i]=ppal[img[i]].rgbBlue;
SetGrayPalette();
}
//transform to 8 bit gray scale
if (head.biBitCount==4 || head.biBitCount==1){
CxImage ima;
ima.CopyInfo(*this);
if (!ima.Create(head.biWidth,head.biHeight,8,info.dwType)) return false;
ima.SetGrayPalette();
#if CXIMAGE_SUPPORT_SELECTION
ima.SelectionCopy(*this);
#endif //CXIMAGE_SUPPORT_SELECTION
#if CXIMAGE_SUPPORT_ALPHA
ima.AlphaCopy(*this);
#endif //CXIMAGE_SUPPORT_ALPHA
BYTE *img=ima.GetBits();
long l=ima.GetEffWidth();
for (long y=0;y<head.biHeight;y++){
for (long x=0;x<head.biWidth; x++){
img[x+y*l]=ppal[GetPixelIndex(x,y)].rgbBlue;
}
}
Transfer(ima);
}
} else { //from RGB to 8 bit gray scale
BYTE *iSrc=info.pImage;
CxImage ima;
ima.CopyInfo(*this);
if (!ima.Create(head.biWidth,head.biHeight,8,info.dwType)) return false;
ima.SetGrayPalette();
#if CXIMAGE_SUPPORT_SELECTION
ima.SelectionCopy(*this);
#endif //CXIMAGE_SUPPORT_SELECTION
#if CXIMAGE_SUPPORT_ALPHA
ima.AlphaCopy(*this);
#endif //CXIMAGE_SUPPORT_ALPHA
BYTE *img=ima.GetBits();
long l8=ima.GetEffWidth();
long l=head.biWidth * 3;
for(long y=0; y < head.biHeight; y++) {
for(long x=0,x8=0; x < l; x+=3,x8++) {
img[x8+y*l8]=(BYTE)RGB2GRAY(*(iSrc+x+2),*(iSrc+x+1),*(iSrc+x+0));
}
iSrc+=info.dwEffWidth;
}
Transfer(ima);
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
bool CxImage::Flip()
{
if (!pDib) return false;
CxImage* imatmp = new CxImage(*this,false,false,true);
if (!imatmp) return false;
BYTE *iSrc,*iDst;
iSrc=info.pImage + (head.biHeight-1)*info.dwEffWidth;
iDst=imatmp->info.pImage;
for(long y=0; y < head.biHeight; y++){
memcpy(iDst,iSrc,info.dwEffWidth);
iSrc-=info.dwEffWidth;
iDst+=info.dwEffWidth;
}
#if CXIMAGE_SUPPORT_ALPHA
imatmp->AlphaFlip();
#endif //CXIMAGE_SUPPORT_ALPHA
Transfer(*imatmp);
delete imatmp;
return true;
}
////////////////////////////////////////////////////////////////////////////////
bool CxImage::Mirror()
{
if (!pDib) return false;
CxImage* imatmp = new CxImage(*this,false,false,true);
if (!imatmp) return false;
BYTE *iSrc,*iDst;
long wdt=(head.biWidth-1) * (head.biBitCount==24 ? 3:1);
iSrc=info.pImage + wdt;
iDst=imatmp->info.pImage;
long x,y;
switch (head.biBitCount){
case 24:
for(y=0; y < head.biHeight; y++){
for(x=0; x <= wdt; x+=3){
*(iDst+x)=*(iSrc-x);
*(iDst+x+1)=*(iSrc-x+1);
*(iDst+x+2)=*(iSrc-x+2);
}
iSrc+=info.dwEffWidth;
iDst+=info.dwEffWidth;
}
break;
case 8:
for(y=0; y < head.biHeight; y++){
for(x=0; x <= wdt; x++)
*(iDst+x)=*(iSrc-x);
iSrc+=info.dwEffWidth;
iDst+=info.dwEffWidth;
}
break;
default:
for(y=0; y < head.biHeight; y++){
for(x=0; x <= wdt; x++)
imatmp->SetPixelIndex(x,y,GetPixelIndex(wdt-x,y));
}
}
#if CXIMAGE_SUPPORT_ALPHA
imatmp->AlphaMirror();
#endif //CXIMAGE_SUPPORT_ALPHA
Transfer(*imatmp);
delete imatmp;
return true;
}
#ifdef XBMC
bool CxImage::RotateExif(int orientation /* = 0 */)
{
bool ret = true;
if (orientation <= 0)
orientation = info.ExifInfo.Orientation;
if (orientation == 3)
ret = Rotate180();
else if (orientation == 6)
ret = RotateRight();
else if (orientation == 8)
ret = RotateLeft();
info.ExifInfo.Orientation = 1;
return ret;
}
#endif
////////////////////////////////////////////////////////////////////////////////
bool CxImage::RotateLeft(CxImage* iDst)
{
if (!pDib) return false;
long newWidth = GetHeight();
long newHeight = GetWidth();
CxImage imgDest;
imgDest.CopyInfo(*this);
imgDest.Create(newWidth,newHeight,GetBpp(),GetType());
imgDest.SetPalette(GetPalette());
long x,x2,y,dlineup;
// Speedy rotate for BW images <Robert Abram>
if (head.biBitCount == 1) {
BYTE *sbits, *dbits, *dbitsmax, bitpos, *nrow,*srcdisp;
div_t div_r;
BYTE *bsrc = GetBits(), *bdest = imgDest.GetBits();
dbitsmax = bdest + imgDest.head.biSizeImage - 1;
dlineup = 8 * imgDest.info.dwEffWidth - imgDest.head.biWidth;
imgDest.Clear(0);
for (y = 0; y < head.biHeight; y++) {
// Figure out the Column we are going to be copying to
div_r = div(y + dlineup, 8);
// set bit pos of src column byte
bitpos = 1 << div_r.rem;
srcdisp = bsrc + y * info.dwEffWidth;
for (x = 0; x < (long)info.dwEffWidth; x++) {
// Get Source Bits
sbits = srcdisp + x;
// Get destination column
nrow = bdest + (x * 8) * imgDest.info.dwEffWidth + imgDest.info.dwEffWidth - 1 - div_r.quot;
for (long z = 0; z < 8; z++) {
// Get Destination Byte
dbits = nrow + z * imgDest.info.dwEffWidth;
if ((dbits < bdest) || (dbits > dbitsmax)) break;
if (*sbits & (128 >> z)) *dbits |= bitpos;
}
}
}
} else {
for (x = 0; x < newWidth; x++){
info.nProgress = (long)(100*x/newWidth); //<Anatoly Ivasyuk>
x2=newWidth-x-1;
for (y = 0; y < newHeight; y++){
if(head.biClrUsed==0) //RGB
imgDest.SetPixelColor(x, y, GetPixelColor(y, x2));
else //PALETTE
imgDest.SetPixelIndex(x, y, GetPixelIndex(y, x2));
}
}
}
#if CXIMAGE_SUPPORT_ALPHA
if (AlphaIsValid()){
imgDest.AlphaCreate();
for (x = 0; x < newWidth; x++){
x2=newWidth-x-1;
for (y = 0; y < newHeight; y++){
imgDest.AlphaSet(x,y,AlphaGet(y, x2));
}
}
}
#endif //CXIMAGE_SUPPORT_ALPHA
//select the destination
if (iDst) iDst->Transfer(imgDest);
else Transfer(imgDest);
return true;
}
////////////////////////////////////////////////////////////////////////////////
bool CxImage::RotateRight(CxImage* iDst)
{
if (!pDib) return false;
long newWidth = GetHeight();
long newHeight = GetWidth();
CxImage imgDest;
imgDest.CopyInfo(*this);
imgDest.Create(newWidth,newHeight,GetBpp(),GetType());
imgDest.SetPalette(GetPalette());
long x,y,y2;
// Speedy rotate for BW images <Robert Abram>
if (head.biBitCount == 1) {
BYTE *sbits, *dbits, *dbitsmax, bitpos, *nrow,*srcdisp;
div_t div_r;
BYTE *bsrc = GetBits(), *bdest = imgDest.GetBits();
dbitsmax = bdest + imgDest.head.biSizeImage - 1;
imgDest.Clear(0);
for (y = 0; y < head.biHeight; y++) {
// Figure out the Column we are going to be copying to
div_r = div(y, 8);
// set bit pos of src column byte
bitpos = 128 >> div_r.rem;
srcdisp = bsrc + y * info.dwEffWidth;
for (x = 0; x < (long)info.dwEffWidth; x++) {
// Get Source Bits
sbits = srcdisp + x;
// Get destination column
nrow = bdest + (imgDest.head.biHeight-1-(x*8)) * imgDest.info.dwEffWidth + div_r.quot;
for (long z = 0; z < 8; z++) {
// Get Destination Byte
dbits = nrow - z * imgDest.info.dwEffWidth;
if ((dbits < bdest) || (dbits > dbitsmax)) break;
if (*sbits & (128 >> z)) *dbits |= bitpos;
}
}
}
} else {
for (y = 0; y < newHeight; y++){
info.nProgress = (long)(100*y/newHeight); //<Anatoly Ivasyuk>
y2=newHeight-y-1;
for (x = 0; x < newWidth; x++){
if(head.biClrUsed==0) //RGB
imgDest.SetPixelColor(x, y, GetPixelColor(y2, x));
else //PALETTE
imgDest.SetPixelIndex(x, y, GetPixelIndex(y2, x));
}
}
}
#if CXIMAGE_SUPPORT_ALPHA
if (AlphaIsValid()){
imgDest.AlphaCreate();
for (y = 0; y < newHeight; y++){
y2=newHeight-y-1;
for (x = 0; x < newWidth; x++){
imgDest.AlphaSet(x,y,AlphaGet(y2, x));
}
}
}
#endif //CXIMAGE_SUPPORT_ALPHA
//select the destination
if (iDst) iDst->Transfer(imgDest);
else Transfer(imgDest);
return true;
}
////////////////////////////////////////////////////////////////////////////////
bool CxImage::Negative()
{
if (!pDib) return false;
if (head.biBitCount<=8){
if (IsGrayScale()){ //GRAYSCALE, selection
if (pSelection){
for(long y=info.rSelectionBox.bottom; y<info.rSelectionBox.top; y++){
for(long x=info.rSelectionBox.left; x<info.rSelectionBox.right; x++){
#if CXIMAGE_SUPPORT_SELECTION
if (SelectionIsInside(x,y))
#endif //CXIMAGE_SUPPORT_SELECTION
{
SetPixelIndex(x,y,(BYTE)(255-GetPixelIndex(x,y)));
}
}
}
} else {
for(long y=0; y<head.biHeight; y++){
for(long x=0; x<head.biWidth; x++){
SetPixelIndex(x,y,(BYTE)(255-GetPixelIndex(x,y)));
}
}
}
} else { //PALETTE, full image
RGBQUAD* ppal=GetPalette();
for(DWORD i=0;i<head.biClrUsed;i++){
ppal[i].rgbBlue =(BYTE)(255-ppal[i].rgbBlue);
ppal[i].rgbGreen =(BYTE)(255-ppal[i].rgbGreen);
ppal[i].rgbRed =(BYTE)(255-ppal[i].rgbRed);
}
}
} else {
if (pSelection==NULL){ //RGB, full image
BYTE *iSrc=info.pImage;
for(unsigned long i=0; i < head.biSizeImage ; i++){
*iSrc=(BYTE)~(*(iSrc));
iSrc++;
}
} else { // RGB with selection
RGBQUAD color;
for(long y=info.rSelectionBox.bottom; y<info.rSelectionBox.top; y++){
for(long x=info.rSelectionBox.left; x<info.rSelectionBox.right; x++){
#if CXIMAGE_SUPPORT_SELECTION
if (SelectionIsInside(x,y))
#endif //CXIMAGE_SUPPORT_SELECTION
{
color = GetPixelColor(x,y);
color.rgbRed = (BYTE)(255-color.rgbRed);
color.rgbGreen = (BYTE)(255-color.rgbGreen);
color.rgbBlue = (BYTE)(255-color.rgbBlue);
SetPixelColor(x,y,color);
}
}
}
}
//<DP> invert transparent color too
info.nBkgndColor.rgbBlue = (BYTE)(255-info.nBkgndColor.rgbBlue);
info.nBkgndColor.rgbGreen = (BYTE)(255-info.nBkgndColor.rgbGreen);
info.nBkgndColor.rgbRed = (BYTE)(255-info.nBkgndColor.rgbRed);
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
#endif //CXIMAGE_SUPPORT_BASICTRANSFORMATIONS
////////////////////////////////////////////////////////////////////////////////
#if CXIMAGE_SUPPORT_TRANSFORMATION
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
bool CxImage::Rotate(float angle, CxImage* iDst)
{
if (!pDib) return false;
// $Id: FilterRotate.cpp,v 1.10 2000/12/18 22:42:53 uzadow Exp $
// Copyright (c) 1996-1998 Ulrich von Zadow
// Negative the angle, because the y-axis is negative.
double ang = -angle*acos((float)0)/90;
int newWidth, newHeight;
int nWidth = GetWidth();
int nHeight= GetHeight();
double cos_angle = cos(ang);
double sin_angle = sin(ang);
// Calculate the size of the new bitmap
POINT p1={0,0};
POINT p2={nWidth,0};
POINT p3={0,nHeight};
POINT p4={nWidth-1,nHeight};
POINT newP1,newP2,newP3,newP4, leftTop, rightTop, leftBottom, rightBottom;
newP1.x = p1.x;
newP1.y = p1.y;
newP2.x = (long)floor(p2.x*cos_angle - p2.y*sin_angle);
newP2.y = (long)floor(p2.x*sin_angle + p2.y*cos_angle);
newP3.x = (long)floor(p3.x*cos_angle - p3.y*sin_angle);
newP3.y = (long)floor(p3.x*sin_angle + p3.y*cos_angle);
newP4.x = (long)floor(p4.x*cos_angle - p4.y*sin_angle);
newP4.y = (long)floor(p4.x*sin_angle + p4.y*cos_angle);
leftTop.x = min(min(newP1.x,newP2.x),min(newP3.x,newP4.x));
leftTop.y = min(min(newP1.y,newP2.y),min(newP3.y,newP4.y));
rightBottom.x = max(max(newP1.x,newP2.x),max(newP3.x,newP4.x));
rightBottom.y = max(max(newP1.y,newP2.y),max(newP3.y,newP4.y));
leftBottom.x = leftTop.x;
leftBottom.y = 2+rightBottom.y;
rightTop.x = 2+rightBottom.x;
rightTop.y = leftTop.y;
newWidth = rightTop.x - leftTop.x;
newHeight= leftBottom.y - leftTop.y;
CxImage imgDest;
imgDest.CopyInfo(*this);
imgDest.Create(newWidth,newHeight,GetBpp(),GetType());
imgDest.SetPalette(GetPalette());
#if CXIMAGE_SUPPORT_ALPHA
if(AlphaIsValid()) //MTA: Fix for rotation problem when the image has an alpha channel
{
imgDest.AlphaCreate();
imgDest.AlphaClear();
}
#endif //CXIMAGE_SUPPORT_ALPHA
int x,y,newX,newY,oldX,oldY;
if (head.biClrUsed==0){ //RGB
for (y = leftTop.y, newY = 0; y<=leftBottom.y; y++,newY++){
info.nProgress = (long)(100*newY/newHeight);
if (info.nEscape) break;
for (x = leftTop.x, newX = 0; x<=rightTop.x; x++,newX++){
oldX = (long)(x*cos_angle + y*sin_angle - 0.5);
oldY = (long)(y*cos_angle - x*sin_angle - 0.5);
imgDest.SetPixelColor(newX,newY,GetPixelColor(oldX,oldY));
#if CXIMAGE_SUPPORT_ALPHA
imgDest.AlphaSet(newX,newY,AlphaGet(oldX,oldY)); //MTA: copy the alpha value
#endif //CXIMAGE_SUPPORT_ALPHA
}
}
} else { //PALETTE
for (y = leftTop.y, newY = 0; y<=leftBottom.y; y++,newY++){
info.nProgress = (long)(100*newY/newHeight);
if (info.nEscape) break;
for (x = leftTop.x, newX = 0; x<=rightTop.x; x++,newX++){
oldX = (long)(x*cos_angle + y*sin_angle - 0.5);
oldY = (long)(y*cos_angle - x*sin_angle - 0.5);
imgDest.SetPixelIndex(newX,newY,GetPixelIndex(oldX,oldY));
#if CXIMAGE_SUPPORT_ALPHA
imgDest.AlphaSet(newX,newY,AlphaGet(oldX,oldY)); //MTA: copy the alpha value
#endif //CXIMAGE_SUPPORT_ALPHA
}
}
}
//select the destination
if (iDst) iDst->Transfer(imgDest);
else Transfer(imgDest);
return true;
}
////////////////////////////////////////////////////////////////////////////////
bool CxImage::Rotate180(CxImage* iDst)
{
if (!pDib) return false;
long wid = GetWidth();
long ht = GetHeight();
CxImage imgDest;
imgDest.CopyInfo(*this);
imgDest.Create(wid,ht,GetBpp(),GetType());
imgDest.SetPalette(GetPalette());
#if CXIMAGE_SUPPORT_ALPHA
if (AlphaIsValid()) imgDest.AlphaCreate();
#endif //CXIMAGE_SUPPORT_ALPHA
long x,y,y2;
for (y = 0; y < ht; y++){
info.nProgress = (long)(100*y/ht); //<Anatoly Ivasyuk>
y2=ht-y-1;
for (x = 0; x < wid; x++){
if(head.biClrUsed==0)//RGB
imgDest.SetPixelColor(wid-x-1, y2, GetPixelColor(x, y));
else //PALETTE
imgDest.SetPixelIndex(wid-x-1, y2, GetPixelIndex(x, y));
#if CXIMAGE_SUPPORT_ALPHA
if (AlphaIsValid()) imgDest.AlphaSet(wid-x-1, y2,AlphaGet(x, y));
#endif //CXIMAGE_SUPPORT_ALPHA
}
}
//select the destination
if (iDst) iDst->Transfer(imgDest);
else Transfer(imgDest);
return true;
}
////////////////////////////////////////////////////////////////////////////////
bool CxImage::Resample(long newx, long newy, int mode, CxImage* iDst)
{
if (newx==0 || newy==0) return false;
if (head.biWidth==newx && head.biHeight==newy){
if (iDst) iDst->Copy(*this);
return true;
}
float xScale, yScale, fX, fY;
xScale = (float)head.biWidth / (float)newx;
yScale = (float)head.biHeight / (float)newy;
CxImage newImage;
newImage.CopyInfo(*this);
newImage.Create(newx,newy,head.biBitCount,GetType());
newImage.SetPalette(GetPalette());
if (!newImage.IsValid()) return false;
if (head.biWidth==newx && head.biHeight==newy){
Transfer(newImage);
return true;
}
switch (mode) {
case 1: // nearest pixel
{
for(long y=0; y<newy; y++){
info.nProgress = (long)(100*y/newy);
if (info.nEscape) break;
fY = y * yScale;
for(long x=0; x<newx; x++){
fX = x * xScale;
newImage.SetPixelColor(x,y,GetPixelColor((long)fX,(long)fY));
}
}
break;
}
case 2: // bicubic interpolation by Blake L. Carlson <blake-carlson(at)uiowa(dot)edu
{
float f_x, f_y, a, b, rr, gg, bb, r1, r2;
int i_x, i_y, xx, yy;
RGBQUAD rgb;
BYTE* iDst;
for(long y=0; y<newy; y++){
info.nProgress = (long)(100*y/newy);
if (info.nEscape) break;
f_y = (float) y * yScale - 0.5f;
i_y = (int) floor(f_y);
a = f_y - (float)floor(f_y);
for(long x=0; x<newx; x++){
f_x = (float) x * xScale - 0.5f;
i_x = (int) floor(f_x);
b = f_x - (float)floor(f_x);
rr = gg = bb = 0.0f;
for(int m=-1; m<3; m++) {
r1 = b3spline((float) m - a);
yy = i_y+m;
if (yy<0) yy=0;
if (yy>=head.biHeight) yy = head.biHeight-1;
for(int n=-1; n<3; n++) {
r2 = r1 * b3spline(b - (float)n);
xx = i_x+n;
if (xx<0) xx=0;
if (xx>=head.biWidth) xx=head.biWidth-1;
if (head.biClrUsed){
rgb = GetPixelColor(xx,yy);
} else {
iDst = info.pImage + yy*info.dwEffWidth + xx*3;
rgb.rgbBlue = *iDst++;
rgb.rgbGreen= *iDst++;
rgb.rgbRed = *iDst;
}
rr += rgb.rgbRed * r2;
gg += rgb.rgbGreen * r2;
bb += rgb.rgbBlue * r2;
}
}
if (head.biClrUsed)
newImage.SetPixelColor(x,y,RGB(rr,gg,bb));
else {
iDst = newImage.info.pImage + y*newImage.info.dwEffWidth + x*3;
*iDst++ = (BYTE)bb;
*iDst++ = (BYTE)gg;
*iDst = (BYTE)rr;
}
}
}
break;
}
default: // bilinear interpolation
if (!(head.biWidth>newx && head.biHeight>newy && head.biBitCount==24)) {
//© 1999 Steve McMahon ([email protected])
long ifX, ifY, ifX1, ifY1, xmax, ymax;
float ir1, ir2, ig1, ig2, ib1, ib2, dx, dy;
BYTE r,g,b;
RGBQUAD rgb1, rgb2, rgb3, rgb4;
xmax = head.biWidth-1;
ymax = head.biHeight-1;
for(long y=0; y<newy; y++){
info.nProgress = (long)(100*y/newy);
if (info.nEscape) break;
fY = y * yScale;
ifY = (int)fY;
ifY1 = min(ymax, ifY+1);
dy = fY - ifY;
for(long x=0; x<newx; x++){
fX = x * xScale;
ifX = (int)fX;
ifX1 = min(xmax, ifX+1);
dx = fX - ifX;
// Interpolate using the four nearest pixels in the source
if (head.biClrUsed){
rgb1=GetPaletteColor(GetPixelIndex(ifX,ifY));
rgb2=GetPaletteColor(GetPixelIndex(ifX1,ifY));
rgb3=GetPaletteColor(GetPixelIndex(ifX,ifY1));
rgb4=GetPaletteColor(GetPixelIndex(ifX1,ifY1));
}
else {
BYTE* iDst;
iDst = info.pImage + ifY*info.dwEffWidth + ifX*3;
rgb1.rgbBlue = *iDst++; rgb1.rgbGreen= *iDst++; rgb1.rgbRed =*iDst;
iDst = info.pImage + ifY*info.dwEffWidth + ifX1*3;
rgb2.rgbBlue = *iDst++; rgb2.rgbGreen= *iDst++; rgb2.rgbRed =*iDst;
iDst = info.pImage + ifY1*info.dwEffWidth + ifX*3;
rgb3.rgbBlue = *iDst++; rgb3.rgbGreen= *iDst++; rgb3.rgbRed =*iDst;
iDst = info.pImage + ifY1*info.dwEffWidth + ifX1*3;
rgb4.rgbBlue = *iDst++; rgb4.rgbGreen= *iDst++; rgb4.rgbRed =*iDst;
}
// Interplate in x direction:
ir1 = rgb1.rgbRed * (1 - dy) + rgb3.rgbRed * dy;
ig1 = rgb1.rgbGreen * (1 - dy) + rgb3.rgbGreen * dy;
ib1 = rgb1.rgbBlue * (1 - dy) + rgb3.rgbBlue * dy;
ir2 = rgb2.rgbRed * (1 - dy) + rgb4.rgbRed * dy;
ig2 = rgb2.rgbGreen * (1 - dy) + rgb4.rgbGreen * dy;
ib2 = rgb2.rgbBlue * (1 - dy) + rgb4.rgbBlue * dy;
// Interpolate in y:
r = (BYTE)(ir1 * (1 - dx) + ir2 * dx);
g = (BYTE)(ig1 * (1 - dx) + ig2 * dx);
b = (BYTE)(ib1 * (1 - dx) + ib2 * dx);
// Set output
newImage.SetPixelColor(x,y,RGB(r,g,b));
}
}
} else {
//high resolution shrink, thanks to Henrik Stellmann <[email protected]>
const long ACCURACY = 1000;
long i,j; // index for faValue
long x,y; // coordinates in source image
BYTE* pSource;
BYTE* pDest = newImage.info.pImage;
long* naAccu = new long[3 * newx + 3];
long* naCarry = new long[3 * newx + 3];
long* naTemp;
long nWeightX,nWeightY;
float fEndX;
long nScale = (long)(ACCURACY * xScale * yScale);
memset(naAccu, 0, sizeof(long) * 3 * newx);
memset(naCarry, 0, sizeof(long) * 3 * newx);
int u, v = 0; // coordinates in dest image
float fEndY = yScale - 1.0f;
for (y = 0; y < head.biHeight; y++){
info.nProgress = (long)(100*y/head.biHeight); //<Anatoly Ivasyuk>
if (info.nEscape) break;
pSource = info.pImage + y * info.dwEffWidth;
u = i = 0;
fEndX = xScale - 1.0f;
if ((float)y < fEndY) { // complete source row goes into dest row
for (x = 0; x < head.biWidth; x++){
if ((float)x < fEndX){ // complete source pixel goes into dest pixel
for (j = 0; j < 3; j++) naAccu[i + j] += (*pSource++) * ACCURACY;
} else { // source pixel is splitted for 2 dest pixels
nWeightX = (long)(((float)x - fEndX) * ACCURACY);
for (j = 0; j < 3; j++){
naAccu[i] += (ACCURACY - nWeightX) * (*pSource);
naAccu[3 + i++] += nWeightX * (*pSource++);
}
fEndX += xScale;
u++;
}
}
} else { // source row is splitted for 2 dest rows
nWeightY = (long)(((float)y - fEndY) * ACCURACY);
for (x = 0; x < head.biWidth; x++){
if ((float)x < fEndX){ // complete source pixel goes into 2 pixel
for (j = 0; j < 3; j++){
naAccu[i + j] += ((ACCURACY - nWeightY) * (*pSource));
naCarry[i + j] += nWeightY * (*pSource++);
}
} else { // source pixel is splitted for 4 dest pixels
nWeightX = (int)(((float)x - fEndX) * ACCURACY);
for (j = 0; j < 3; j++) {
naAccu[i] += ((ACCURACY - nWeightY) * (ACCURACY - nWeightX)) * (*pSource) / ACCURACY;
*pDest++ = (BYTE)(naAccu[i] / nScale);
naCarry[i] += (nWeightY * (ACCURACY - nWeightX) * (*pSource)) / ACCURACY;
naAccu[i + 3] += ((ACCURACY - nWeightY) * nWeightX * (*pSource)) / ACCURACY;
naCarry[i + 3] = (nWeightY * nWeightX * (*pSource)) / ACCURACY;
i++;
pSource++;
}
fEndX += xScale;
u++;
}
}
if (u < newx){ // possibly not completed due to rounding errors
for (j = 0; j < 3; j++) *pDest++ = (BYTE)(naAccu[i++] / nScale);
}
naTemp = naCarry;
naCarry = naAccu;
naAccu = naTemp;
memset(naCarry, 0, sizeof(int) * 3); // need only to set first pixel zero
pDest = newImage.info.pImage + (++v * newImage.info.dwEffWidth);
fEndY += yScale;
}
}
if (v < newy){ // possibly not completed due to rounding errors
for (i = 0; i < 3 * newx; i++) *pDest++ = (BYTE)(naAccu[i] / nScale);
}
delete [] naAccu;
delete [] naCarry;
}
}
#if CXIMAGE_SUPPORT_ALPHA
if (AlphaIsValid()){
newImage.AlphaCreate();
for(long y=0; y<newy; y++){
fY = y * yScale;
for(long x=0; x<newx; x++){
fX = x * xScale;
newImage.AlphaSet(x,y,AlphaGet((long)fX,(long)fY));
}
}
}
#endif //CXIMAGE_SUPPORT_ALPHA
//select the destination
if (iDst) iDst->Transfer(newImage);
else Transfer(newImage);
return true;
}
////////////////////////////////////////////////////////////////////////////////
bool CxImage::DecreaseBpp(DWORD nbit, bool errordiffusion, RGBQUAD* ppal, DWORD clrimportant)
{
if (!pDib) return false;
if (head.biBitCount < nbit) return false;
if (head.biBitCount == nbit){
if (clrimportant==0) return true;
if (head.biClrImportant && (head.biClrImportant<clrimportant)) return true;
}
long er,eg,eb;
RGBQUAD c,ce;
CxImage tmp;
tmp.CopyInfo(*this);
tmp.Create(head.biWidth,head.biHeight,(WORD)nbit,info.dwType);
if (clrimportant) tmp.SetClrImportant(clrimportant);
#if CXIMAGE_SUPPORT_SELECTION
tmp.SelectionCopy(*this);
#endif //CXIMAGE_SUPPORT_SELECTION
#if CXIMAGE_SUPPORT_ALPHA
tmp.AlphaCopy(*this);
#endif //CXIMAGE_SUPPORT_ALPHA
switch (tmp.head.biBitCount){
case 1:
if (ppal) tmp.SetPalette(ppal,2);
else {
tmp.SetPaletteColor(0,0,0,0);
tmp.SetPaletteColor(1,255,255,255);
}
break;
case 4:
if (ppal) tmp.SetPalette(ppal,16);
else tmp.SetStdPalette();
break;
case 8:
if (ppal) tmp.SetPalette(ppal);
else tmp.SetStdPalette();
break;
default:
return false;
}
for (long y=0;y<head.biHeight;y++){
if (info.nEscape) break;
info.nProgress = (long)(100*y/head.biHeight);
for (long x=0;x<head.biWidth;x++){
if (!errordiffusion){
tmp.SetPixelColor(x,y,GetPixelColor(x,y));
} else {
c=GetPixelColor(x,y);
tmp.SetPixelColor(x,y,c);
ce=tmp.GetPixelColor(x,y);
er=(long)c.rgbRed - (long)ce.rgbRed;
eg=(long)c.rgbGreen - (long)ce.rgbGreen;
eb=(long)c.rgbBlue - (long)ce.rgbBlue;
c = GetPixelColor(x+1,y);
c.rgbRed = (BYTE)min(255L,max(0L,(long)c.rgbRed + ((er*7)/16)));
c.rgbGreen = (BYTE)min(255L,max(0L,(long)c.rgbGreen + ((eg*7)/16)));
c.rgbBlue = (BYTE)min(255L,max(0L,(long)c.rgbBlue + ((eb*7)/16)));
SetPixelColor(x+1,y,c);
int coeff;
for(int i=-1; i<2; i++){
switch(i){
case -1:
coeff=2; break;
case 0:
coeff=4; break;
case 1:
coeff=1; break;
}
c = GetPixelColor(x+i,y+1);
c.rgbRed = (BYTE)min(255L,max(0L,(long)c.rgbRed + ((er * coeff)/16)));
c.rgbGreen = (BYTE)min(255L,max(0L,(long)c.rgbGreen + ((eg * coeff)/16)));
c.rgbBlue = (BYTE)min(255L,max(0L,(long)c.rgbBlue + ((eb * coeff)/16)));
SetPixelColor(x+i,y+1,c);
}
}
}
}
if (head.biBitCount==1){
tmp.SetPaletteColor(0,0,0,0);
tmp.SetPaletteColor(1,255,255,255);
}
Transfer(tmp);
return true;
}
////////////////////////////////////////////////////////////////////////////////
bool CxImage::IncreaseBpp(DWORD nbit)
{
if (!pDib) return false;
switch (nbit){
case 4:
{
if (head.biBitCount==4) return true;
if (head.biBitCount>4) return false;
CxImage tmp;
tmp.CopyInfo(*this);
tmp.Create(head.biWidth,head.biHeight,4,info.dwType);
tmp.SetPalette(GetPalette(),GetNumColors());
#if CXIMAGE_SUPPORT_SELECTION
tmp.SelectionCopy(*this);
#endif //CXIMAGE_SUPPORT_SELECTION
#if CXIMAGE_SUPPORT_ALPHA
tmp.AlphaCopy(*this);
#endif //CXIMAGE_SUPPORT_ALPHA
for (long y=0;y<head.biHeight;y++){
if (info.nEscape) break;
for (long x=0;x<head.biWidth;x++){
tmp.SetPixelIndex(x,y,GetPixelIndex(x,y));
}
}
Transfer(tmp);
return true;
}
case 8:
{
if (head.biBitCount==8) return true;
if (head.biBitCount>8) return false;
CxImage tmp;
tmp.CopyInfo(*this);
tmp.Create(head.biWidth,head.biHeight,8,info.dwType);
tmp.SetPalette(GetPalette(),GetNumColors());
#if CXIMAGE_SUPPORT_SELECTION
tmp.SelectionCopy(*this);
#endif //CXIMAGE_SUPPORT_SELECTION
#if CXIMAGE_SUPPORT_ALPHA
tmp.AlphaCopy(*this);
#endif //CXIMAGE_SUPPORT_ALPHA
for (long y=0;y<head.biHeight;y++){
if (info.nEscape) break;
for (long x=0;x<head.biWidth;x++){
tmp.SetPixelIndex(x,y,GetPixelIndex(x,y));
}
}
Transfer(tmp);
return true;
}
case 24:
{
if (head.biBitCount==24) return true;
if (head.biBitCount>24) return false;
CxImage tmp;
tmp.CopyInfo(*this);
tmp.Create(head.biWidth,head.biHeight,24,info.dwType);
if (info.nBkgndIndex>=0) //translate transparency
tmp.info.nBkgndColor=GetPaletteColor((BYTE)info.nBkgndIndex);
#if CXIMAGE_SUPPORT_SELECTION
tmp.SelectionCopy(*this);
#endif //CXIMAGE_SUPPORT_SELECTION
#if CXIMAGE_SUPPORT_ALPHA
tmp.AlphaCopy(*this);
if (AlphaPaletteIsValid() && !AlphaIsValid()) tmp.AlphaCreate();
#endif //CXIMAGE_SUPPORT_ALPHA
for (long y=0;y<head.biHeight;y++){
if (info.nEscape) break;
for (long x=0;x<head.biWidth;x++){
tmp.SetPixelColor(x,y,GetPixelColor(x,y),true);
}
}
Transfer(tmp);
return true;
}
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool CxImage::Dither(long method)
{
if (!pDib) return false;
if (head.biBitCount == 1) return true;
switch (method){
case 1:
{
// Multi-Level Ordered-Dithering by Kenny Hoff (Oct. 12, 1995)
#define NumRows 4
#define NumCols 4
#define NumIntensityLevels 2
#define NumRowsLessOne (NumRows-1)
#define NumColsLessOne (NumCols-1)
#define RowsXCols (NumRows*NumCols)
#define MaxIntensityVal 255
#define MaxDitherIntensityVal (NumRows*NumCols*(NumIntensityLevels-1))
int DitherMatrix[NumRows][NumCols] = {{0,8,2,10}, {12,4,14,6}, {3,11,1,9}, {15,7,13,5} };
unsigned char Intensity[NumIntensityLevels] = { 0,1 }; // 2 LEVELS B/W
//unsigned char Intensity[NumIntensityLevels] = { 0,255 }; // 2 LEVELS
//unsigned char Intensity[NumIntensityLevels] = { 0,127,255 }; // 3 LEVELS
//unsigned char Intensity[NumIntensityLevels] = { 0,85,170,255 }; // 4 LEVELS
//unsigned char Intensity[NumIntensityLevels] = { 0,63,127,191,255 }; // 5 LEVELS
//unsigned char Intensity[NumIntensityLevels] = { 0,51,102,153,204,255 }; // 6 LEVELS
//unsigned char Intensity[NumIntensityLevels] = { 0,42,85,127,170,213,255 }; // 7 LEVELS
//unsigned char Intensity[NumIntensityLevels] = { 0,36,73,109,145,182,219,255 }; // 8 LEVELS
int DitherIntensity, DitherMatrixIntensity, Offset, DeviceIntensity;
unsigned char DitherValue;
GrayScale();
CxImage tmp(head.biWidth,head.biHeight,1,info.dwType);
#if CXIMAGE_SUPPORT_SELECTION
tmp.SelectionCopy(*this);
#endif //CXIMAGE_SUPPORT_SELECTION
#if CXIMAGE_SUPPORT_ALPHA
tmp.AlphaCopy(*this);
#endif //CXIMAGE_SUPPORT_ALPHA
for (long y=0;y<head.biHeight;y++){
info.nProgress = (long)(100*y/head.biHeight);
if (info.nEscape) break;
for (long x=0;x<head.biWidth;x++){
DeviceIntensity = GetPixelIndex(x,y);
DitherIntensity = DeviceIntensity*MaxDitherIntensityVal/MaxIntensityVal;
DitherMatrixIntensity = DitherIntensity % RowsXCols;
Offset = DitherIntensity / RowsXCols;
if (DitherMatrix[y&NumRowsLessOne][x&NumColsLessOne] < DitherMatrixIntensity)
DitherValue = Intensity[1+Offset];
else
DitherValue = Intensity[0+Offset];
tmp.SetPixelIndex(x,y,DitherValue);
}
}
tmp.SetPaletteColor(0,0,0,0);
tmp.SetPaletteColor(1,255,255,255);
Transfer(tmp);
break;
}
default:
{
// Floyd-Steinberg error diffusion (Thanks to Steve McMahon)
long error,nlevel,coeff;
BYTE level;
GrayScale();
CxImage tmp(head.biWidth,head.biHeight,1,info.dwType);
#if CXIMAGE_SUPPORT_SELECTION
tmp.SelectionCopy(*this);
#endif //CXIMAGE_SUPPORT_SELECTION
#if CXIMAGE_SUPPORT_ALPHA
tmp.AlphaCopy(*this);
#endif //CXIMAGE_SUPPORT_ALPHA
for (long y=0;y<head.biHeight;y++){
info.nProgress = (long)(100*y/head.biHeight);
if (info.nEscape) break;
for (long x=0;x<head.biWidth;x++){
level=GetPixelIndex(x,y);
if (level > 128){
tmp.SetPixelIndex(x,y,1);
error = level-255;
} else {
tmp.SetPixelIndex(x,y,0);
error = level;
}
nlevel = GetPixelIndex(x+1,y) + (error * 7)/16;
level = (BYTE)min(255,max(0,(int)nlevel));
SetPixelIndex(x+1,y,level);
for(int i=-1; i<2; i++){
switch(i){
case -1:
coeff=3; break;
case 0:
coeff=5; break;
case 1:
coeff=1; break;
}
nlevel = GetPixelIndex(x+i,y+1) + (error * coeff)/16;
level = (BYTE)min(255,max(0,(int)nlevel));
SetPixelIndex(x+i,y+1,level);
}
}
}
tmp.SetPaletteColor(0,0,0,0);
tmp.SetPaletteColor(1,255,255,255);
Transfer(tmp);
}
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
bool CxImage::Crop(long left, long top, long right, long bottom, CxImage* iDst)
{
if (!pDib) return false;
long startx = max(0L,min(left,head.biWidth));
long endx = max(0L,min(right,head.biWidth));
long starty = head.biHeight - max(0L,min(top,head.biHeight));
long endy = head.biHeight - max(0L,min(bottom,head.biHeight));
if (startx==endx || starty==endy) return false;
if (startx>endx) {long tmp=startx; startx=endx; endx=tmp;}
if (starty>endy) {long tmp=starty; starty=endy; endy=tmp;}
CxImage tmp(endx-startx,endy-starty,head.biBitCount,info.dwType);
tmp.SetPalette(GetPalette(),head.biClrUsed);
tmp.info.nBkgndIndex = info.nBkgndIndex;
tmp.info.nBkgndColor = info.nBkgndColor;
switch (head.biBitCount) {
case 1:
case 4:
{
for(long y=starty, yd=0; y<endy; y++, yd++){
info.nProgress = (long)(100*y/endy); //<Anatoly Ivasyuk>
for(long x=startx, xd=0; x<endx; x++, xd++){
tmp.SetPixelIndex(xd,yd,GetPixelIndex(x,y));
}
}
break;
}
case 8:
case 24:
{
BYTE* pDest = tmp.info.pImage;
BYTE* pSrc = info.pImage + starty * info.dwEffWidth + (startx*head.biBitCount >> 3);
for(long y=starty; y<endy; y++){
info.nProgress = (long)(100*y/endy); //<Anatoly Ivasyuk>
memcpy(pDest,pSrc,tmp.info.dwEffWidth);
pDest+=tmp.info.dwEffWidth;
pSrc+=info.dwEffWidth;
}
}
}
#if CXIMAGE_SUPPORT_ALPHA
if (AlphaIsValid()){ //<oboolo>
tmp.AlphaCreate();
BYTE* pDest = tmp.pAlpha;
BYTE* pSrc = pAlpha + startx + starty*head.biWidth;
for (long y=starty; y<endy; y++){
memcpy(pDest,pSrc,endx-startx);
pDest+=tmp.head.biWidth;
pSrc+=head.biWidth;
}
}
#endif //CXIMAGE_SUPPORT_ALPHA
//select the destination
if (iDst) iDst->Transfer(tmp);
else Transfer(tmp);
return true;
}
////////////////////////////////////////////////////////////////////////////////
float CxImage::b3spline(float x)
{
// thanks to Kristian Kratzenstein
float a, b, c, d;
float xm1 = x - 1.0f; // Was calculatet anyway cause the "if((x-1.0f) < 0)"
float xp1 = x + 1.0f;
float xp2 = x + 2.0f;
if ((xp2) <= 0.0f) a = 0.0f; else a = xp2*xp2*xp2; // Only float, not float -> double -> float
if ((xp1) <= 0.0f) b = 0.0f; else b = xp1*xp1*xp1;
if (x <= 0) c = 0.0f; else c = x*x*x;
if ((xm1) <= 0.0f) d = 0.0f; else d = xm1*xm1*xm1;
return (0.16666666666666666667f * (a - (4.0f * b) + (6.0f * c) - (4.0f * d)));
}
////////////////////////////////////////////////////////////////////////////////
bool CxImage::Skew(float xgain, float ygain, long xpivot, long ypivot)
{
if (!pDib) return false;
long nx,ny;
CxImage tmp(*this,pSelection!=0,true,true);
long xmin,xmax,ymin,ymax;
if (pSelection){
xmin = info.rSelectionBox.left; xmax = info.rSelectionBox.right;
ymin = info.rSelectionBox.bottom; ymax = info.rSelectionBox.top;
} else {
xmin = ymin = 0;
xmax = head.biWidth; ymax=head.biHeight;
}
for(long y=ymin; y<ymax; y++){
info.nProgress = (long)(100*y/head.biHeight);
if (info.nEscape) break;
for(long x=xmin; x<xmax; x++){
#if CXIMAGE_SUPPORT_SELECTION
if (SelectionIsInside(x,y))
#endif //CXIMAGE_SUPPORT_SELECTION
{
nx = x + (long)(xgain*(y - ypivot));
ny = y + (long)(ygain*(x - xpivot));
if (head.biClrUsed==0){
tmp.SetPixelColor(x,y,GetPixelColor(nx,ny));
} else {
tmp.SetPixelIndex(x,y,GetPixelIndex(nx,ny));
}
#if CXIMAGE_SUPPORT_ALPHA
tmp.AlphaSet(x,y,AlphaGet(nx,ny));
#endif //CXIMAGE_SUPPORT_ALPHA
}
}
}
Transfer(tmp);
return true;
}
////////////////////////////////////////////////////////////////////////////////
bool CxImage::Expand(long left, long top, long right, long bottom, RGBQUAD canvascolor, CxImage* iDst)
{
//thanks to <Colin Urquhart>
if (!pDib) return false;
if ((left < 0) || (right < 0) || (bottom < 0) || (top < 0)) return false;
long newWidth = head.biWidth + left + right;
long newHeight = head.biHeight + top + bottom;
right = left + head.biWidth - 1;
top = bottom + head.biHeight - 1;
CxImage tmp(newWidth, newHeight, head.biBitCount, info.dwType);
tmp.SetPalette(GetPalette(),head.biClrUsed);
tmp.info.nBkgndIndex = info.nBkgndIndex;
tmp.info.nBkgndColor = info.nBkgndColor;
switch (head.biBitCount) {
case 1:
case 4:
{
BYTE pixel = tmp.GetNearestIndex(canvascolor);
for(long y=0; y < newHeight; y++){
info.nProgress = (long)(100*y/newHeight); //
for(long x=0; x < newWidth; x++){
if ((y < bottom) || (y > top) || (x < left) || (x > right)) {
tmp.SetPixelIndex(x,y, pixel);
} else {
tmp.SetPixelIndex(x,y,GetPixelIndex(x-left,y-bottom));
}
}
}
break;
}
case 8:
case 24:
{
if (head.biBitCount == 8) {
BYTE pixel = tmp.GetNearestIndex( canvascolor);
memset(tmp.info.pImage, pixel, + (tmp.info.dwEffWidth * newHeight));
} else {
for (long y = 0; y < newHeight; ++y) {
BYTE *pDest = tmp.info.pImage + (y * tmp.info.dwEffWidth);
for (long x = 0; x < newWidth; ++x) {
*pDest++ = canvascolor.rgbBlue;
*pDest++ = canvascolor.rgbGreen;
*pDest++ = canvascolor.rgbRed;
}
}
}
BYTE* pDest = tmp.info.pImage + (tmp.info.dwEffWidth * bottom) + (left*(head.biBitCount >> 3));
BYTE* pSrc = info.pImage;
for(long y=bottom; y <= top; y++){
info.nProgress = (long)(100*y/(1 + top - bottom));
memcpy(pDest,pSrc,(head.biBitCount >> 3) * (right - left + 1));
pDest+=tmp.info.dwEffWidth;
pSrc+=info.dwEffWidth;
}
}
}
//select the destination
if (iDst) iDst->Transfer(tmp);
else Transfer(tmp);
return true;
}
////////////////////////////////////////////////////////////////////////////////
bool CxImage::Expand(long newx, long newy, RGBQUAD canvascolor, CxImage* iDst)
{
//thanks to <Colin Urquhart>
if (!pDib) return false;
if ((newx < head.biWidth) || (newy < head.biHeight)) return false;
int nAddLeft = (newx - head.biWidth) / 2;
int nAddTop = (newy - head.biHeight) / 2;
return Expand(nAddLeft, nAddTop, newx - (head.biWidth + nAddLeft), newy - (head.biHeight + nAddTop), canvascolor, iDst);
}
////////////////////////////////////////////////////////////////////////////////
bool CxImage::Thumbnail(long newx, long newy, RGBQUAD canvascolor, CxImage* iDst)
{
//thanks to <Colin Urquhart>
if (!pDib) return false;
if ((newx <= 0) || (newy <= 0)) return false;
CxImage tmp(*this);
// determine whether we need to shrink the image
if ((head.biWidth > newx) || (head.biHeight > newy)) {
float fScale;
float fAspect = (float) newx / (float) newy;
if (fAspect * head.biHeight > head.biWidth) {
fScale = (float) newy / head.biHeight;
} else {
fScale = (float) newx / head.biWidth;
}
tmp.Resample((long) (fScale * head.biWidth), (long) (fScale * head.biHeight), 0);
}
// expand the frame
tmp.Expand(newx, newy, canvascolor, iDst);
//select the destination
if (iDst) iDst->Transfer(tmp);
else Transfer(tmp);
return true;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
#endif //CXIMAGE_SUPPORT_TRANSFORMATION
| [
"jmarshallnz@568bbfeb-2a22-0410-94d2-cc84cf5bfa90"
]
| [
[
[
1,
1323
]
]
]
|
52302362e3b67cf0ba293224caa08df8822ce75e | cfc9acc69752245f30ad3994cce0741120e54eac | /bikini/private/source/flash/gameswf/base/tu_gc.h | dfcb71c4380bbab57bd80741bc7cf595a6075f2c | []
| no_license | Heartbroken/bikini-iii | 3b7852d1af722b380864ac87df57c37862eb759b | 93ffa5d43d9179b7c5e7f7c2df9df7dafd79a739 | refs/heads/master | 2020-03-28T00:41:36.281253 | 2009-04-30T14:58:10 | 2009-04-30T14:58:10 | 37,190,689 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,413 | h | // tu_gc.h -- Thatcher Ulrich <http://tulrich.com> 2007
// This source code has been donated to the Public Domain. Do
// whatever you want with it.
// A simple smart pointer and framework for garbage collection. A
// variety of different collectors may be plugged in, so the gc_ptr is
// parameterized by the collector.
//
// This differs from the boost gc_ptr proposals I've seen in that it
// is "intrusive" -- any classes that you want garbage-collected must
// derive from gc_object_base. All gc_objects must be allocated on
// the heap via gc_object_base::new. C++ will handle this
// automatically when you use ordinary 'new' syntax. The
// implementation may assert if you accidentally try to create a
// gc_object on the stack or inside another object.
//
// gc_ptr's can live anywhere; on the stack, on the garbage-collected
// heap, on the regular heap. gc_ptr's outside the garbage-collected
// heap are "roots"; i.e. they cannot be collected by the garbage
// collector. Objects on the gc heap are collected automatically,
// according to the policy of the specific collector being used.
//
// gc_ptr's are parameterized by garbage collector type. Different gc
// types have different characteristics.
//
// Note: if you feel the desire to point a gc_ptr at a type that is
// not derived from gc_object_base, you probably want a scoped_ptr
// instead.
//
// Usage:
//
// #include <base/tu_gc.h>
// #include <base/tu_gc_singlethreaded_marksweep.h> // specific collector
//
// // Declare the types gc_ptr<T>, gc_object, and gc_collector,
// // parameterized by the specific garbage collector you are using.
// DECLARE_GC_TYPES(tu_gc::singlethreaded_marksweep);
//
// ...
// class my_object : public gc_object {
// gc_ptr<my_object> m_ptr;
// gc_ptr<other_object> m_ptr2;
//
// ...
// m_ptr = new my_object(args);
// m_ptr->some_method();
// };
//
// ...
// gc_ptr<my_object> obj1 = new my_object;
// gc_ptr<my_object> obj2 = new my_object;
// obj1->m_ptr2 = obj2;
// obj2->m_ptr = obj2;
// obj2->m_ptr2 = obj1;
// ...
// gc_collector::collect_garbage(); // optional
//
// // etc.
// Here's an interesting article on C++ garbage collection:
// http://home.elka.pw.edu.pl/~pkolaczk/papers/gc-prodialog.pdf
// TODO:
//
// implement gc_weak_ptr
//
// implement GC_CONTAINER for associative containers like map<>.
//
// improve type-inference & safety for GC_CONTAINER, it's pretty ugly
// right now. Need it to be less verbose and more foolproof.
#ifndef TU_GC_H
#define TU_GC_H
#include <assert.h>
namespace tu_gc {
class collector_access;
// Used by the collector to help keep blocks alive during
// construction (between allocation and when they are finally
// assigned to a gc_ptr).
//
// Relies on standard C++ guarantee: temporary objects are not
// destroyed until the end of the full statement in which they
// appear.
//
// Thanks to cppgc (boost gc_ptr proposal by ...) for the idea.
class block_construction_locker_base {
public:
block_construction_locker_base() : m_block(0) {
}
protected:
friend collector_access;
void* m_block;
};
template<class garbage_collector>
class block_construction_locker : public block_construction_locker_base {
public:
~block_construction_locker() {
garbage_collector::block_construction_finished(m_block);
}
};
class gc_object_generic_base {
public:
virtual ~gc_object_generic_base() {}
};
// (The collector defines gc_object_generic_base which
// inherits from gc_object_generic_base and optionally adds
// collector-specific properties.)
template<class garbage_collector>
class gc_object_base : public garbage_collector::gc_object_collector_base {
public:
gc_object_base() {
garbage_collector::constructing_gc_object_base(this);
}
static void* operator new(size_t sz, block_construction_locker_base* lock = &block_construction_locker<garbage_collector>()) {
return garbage_collector::allocate(sz, lock);
}
static void operator delete(void* p, block_construction_locker_base* lock) {
return garbage_collector::deallocate(p);
}
static void operator delete(void* p) {
return garbage_collector::deallocate(p);
}
private:
// TODO: are arrays worth implementing?
static void* operator new[](size_t sz) {
assert(0);
}
};
// The smart pointer.
template<class T, class garbage_collector>
class gc_ptr {
public:
gc_ptr() : m_ptr(0) {
garbage_collector::construct_pointer(this);
}
gc_ptr(T* p) : m_ptr(0) {
garbage_collector::construct_pointer(this);
reset(p);
}
gc_ptr(const gc_ptr& p) : m_ptr(0) {
garbage_collector::construct_pointer(this);
reset((T*) p.m_ptr);
}
~gc_ptr() {
reset(0);
garbage_collector::destruct_pointer(this);
}
T* operator->() const {
return (T*) m_ptr;
}
T& operator*() const {
return *(T*) m_ptr;
}
void operator=(const gc_ptr& p) {
reset(p.get());
}
void operator=(T* p) {
reset(p);
}
bool operator==(const gc_ptr& p) const {
return m_ptr == p.m_ptr;
}
bool operator==(const T* p) const {
return m_ptr == p;
}
T* get() const {
return m_ptr;
}
void reset(T* p) {
garbage_collector::write_barrier(this, p);
}
// This is only for use by the garbage collector. Don't use it!
// TODO: figure out how to protect it.
void raw_set_ptr_gc_access_only(T* p) {
m_ptr = p;
}
private:
T* m_ptr;
};
// TODO: gc_weak_ptr
// For pointers to gc_object that are kept in containers.
// NOTE: work in progress, subject to change.
template<class T, class garbage_collector>
class contained_gc_ptr {
public:
typedef void i_am_a_contained_gc_ptr; // For asserting type; I gotta re-read Modern C++ Design :(
contained_gc_ptr() : m_ptr(0) {
garbage_collector::construct_contained_pointer(this);
}
contained_gc_ptr(T* p) : m_ptr(0) {
garbage_collector::construct_contained_pointer(this);
reset(p);
}
contained_gc_ptr(const contained_gc_ptr& p) : m_ptr(0) {
garbage_collector::construct_contained_pointer(this);
reset((T*) p.m_ptr);
}
~contained_gc_ptr() {
reset(0);
garbage_collector::destruct_contained_pointer(this);
}
T* operator->() const {
return (T*) m_ptr;
}
T& operator*() const {
return *(T*) m_ptr;
}
void operator=(const contained_gc_ptr& p) {
reset(p.get());
}
void operator=(T* p) {
reset(p);
}
bool operator==(const contained_gc_ptr& p) const {
return m_ptr == p.m_ptr;
}
bool operator==(const T* p) const {
return m_ptr == p;
}
T* get() const {
return m_ptr;
}
void reset(T* p) {
garbage_collector::contained_pointer_write_barrier(this, p);
}
// This is only for use by the garbage collector. Don't use it!
// TODO: figure out how to protect it.
void raw_set_ptr_gc_access_only(T* p) {
m_ptr = p;
}
private:
T* m_ptr;
};
// Garbage collectors can inherit from this to get access
// block_construction_locker_base::m_block.
class collector_access {
protected:
static void*& block_ref(block_construction_locker_base* lock) {
return lock->m_block;
}
};
// Use this to declare the types gc_ptr<T>, gc_object, and
// gc_collector using your chosen collector, in whatever
// namespace is convenient for you.
//
// E.g.:
//
// namespace my_namespace {
// DECLARE_GC_TYPES(tu_gc::singlethreaded_marksweep);
// }
//
// Then use gc_ptr<T> and gc_object in my_namespace.
//
#define DECLARE_GC_TYPES(collector_classname) \
typedef collector_classname gc_collector; \
typedef tu_gc::gc_object_base<gc_collector> gc_object; \
\
template<class T> \
class gc_ptr : public tu_gc::gc_ptr<T, collector_classname> { \
public: \
gc_ptr() {} \
gc_ptr(T* p) : tu_gc::gc_ptr<T, collector_classname>(p) {} \
}; \
\
template<class T> \
class contained_gc_ptr : public tu_gc::contained_gc_ptr<T, collector_classname> { \
public: \
contained_gc_ptr() {} \
contained_gc_ptr(T* p) : tu_gc::contained_gc_ptr<T, collector_classname>(p) {} \
}; \
\
template<class T> \
class gc_container : public collector_classname::gc_container<T> { \
public: \
gc_container() {} \
};
// For STL containers inside gc_objects whose values point at
// other gc_objects. Use like:
//
// class my_class : public gc_object {
// ...
// GC_CONTAINER(std::vector, my_class) m_pointers;
// ...
// // Use m_pointers just like a regular std::vector.
// for (int i = 0; i < m_pointers.size(); i++) {
// m_pointers[i]->something();
// }
// };
//
// TODO: not sure about this macro, maybe not easy enough to
// use, and need to work on better ways to infer the container
// types, like for associative containers, containers of
// containers, etc.
#define GC_CONTAINER(container_type, T) gc_container<container_type<contained_gc_ptr<T> > >
// TODO: incremental gc
// TODO: incremental generational gc
// TODO: multithreaded variants
} // tu_gc
#endif // TU_GC_H
| [
"[email protected]"
]
| [
[
[
1,
343
]
]
]
|
98d858b631ea6e0019416fe2bd0a5ebbc80f27ca | a2904986c09bd07e8c89359632e849534970c1be | /topcoder/DivToZero.cpp | 804e787a7030df19b33a0a3461bfda2390d2158f | []
| 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,811 | cpp | // BEGIN CUT HERE
// END CUT HERE
#line 5 "DivToZero.cpp"
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
#define debug(p) cout << #p << "=" << p << endl;
#define forv(i, v) for (int i = 0; i < (int)(v.size()); ++i)
#define fors(i, s) for (int i = 0; i < (int)(s.length()); ++i)
#define all(a) a.begin(), a.end()
#define pb push_back
class DivToZero {
public:
string lastTwo(int num, int factor) {
string ret="";
stringstream ss;
string str;
int u_digit = num/100;
u_digit *=100;
if(u_digit%factor ==0){
ss << u_digit;
ss >> str;
ret = str[(int)str.size()-2];
ret += str[(int)str.size()-1];
return ret;
}
int near = u_digit/factor;
near *= factor;
if(near != num){
near += factor;
}
ss << near;
ss >> str;
ret = str[(int)str.size()-2];
ret += str[(int)str.size()-1];
return ret;
}
// BEGIN CUT HERE
public:
void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); 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 string &Expected, const string &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } }
void test_case_0() { int Arg0 = 2000000000; int Arg1 = 100; string Arg2 = "00"; verify_case(0, Arg2, lastTwo(Arg0, Arg1)); }
void test_case_1() { int Arg0 = 1000; int Arg1 = 3; string Arg2 = "02"; verify_case(1, Arg2, lastTwo(Arg0, Arg1)); }
void test_case_2() { int Arg0 = 23442; int Arg1 = 75; string Arg2 = "00"; verify_case(2, Arg2, lastTwo(Arg0, Arg1)); }
void test_case_3() { int Arg0 = 428392; int Arg1 = 17; string Arg2 = "15"; verify_case(3, Arg2, lastTwo(Arg0, Arg1)); }
void test_case_4() { int Arg0 = 32442; int Arg1 = 99; string Arg2 = "72"; verify_case(4, Arg2, lastTwo(Arg0, Arg1)); }
// END CUT HERE
};
// BEGIN CUT HERE
int main() {
DivToZero ___test;
___test.run_test(-1);
}
// END CUT HERE
| [
"shin@CF-7AUJ41TT52JO.(none)"
]
| [
[
[
1,
87
]
]
]
|
785cdecd48a7309e0159556652d6f86bbd8e4f17 | 122ef9ac514911e01fa262bd0dec7ee21550864c | /KaiUI/KaiDoc.cpp | f71b4e1ef10013162caad6605c672b25c38115b6 | []
| no_license | kbogatyrev/Kai | e69ea97dea9948a0270cb60dc5477ea9bdc6ce52 | 684c7798ab80348f7e025dc5de4bf2a925a66a34 | refs/heads/master | 2021-01-01T15:44:23.996015 | 2010-02-17T23:02:50 | 2010-02-17T23:02:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,360 | cpp | //==============================================================================
//
// Copyright (c) Konstantin Bogatyrev, 2001
//
// Facility: Kai 1.2
//
// Module description: MFC CDocument class implementation
//
// $Id: KaiDoc.cpp,v 1.28 2008-02-20 20:13:22 kostya Exp $
//
//==============================================================================
#pragma warning (disable: 4786) // Isn't MFC a shared DLL?!
#pragma warning (disable: 4275) // MSVC issue
#include "KaiStdAfx.h"
#include "Kai.h"
#include "KaiUndoStack.h"
#include "shlwapi.h"
#include "KaiDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CKaiDoc, CDocument)
BEGIN_MESSAGE_MAP(CKaiDoc, CDocument)
//{{AFX_MSG_MAP(CKaiDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
ON_COMMAND(ID_FILE_SAVE, OnFileSave)
ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
END_MESSAGE_MAP()
//
// Ctor
//
CKaiDoc::CKaiDoc()
{
EnableAutomation();
AfxOleLockApp();
pco_Doc_ = new CT_DocDescriptor;
// v_Null();
}
//
// Dtor
//
CKaiDoc::~CKaiDoc()
{
AfxOleUnlockApp();
v_Null_();
}
void CKaiDoc::v_Null_()
{
delete pco_Doc_;
}
BOOL CKaiDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
void CKaiDoc::Serialize (CArchive& ar)
{
CFile * pco_file = ar.GetFile();
ULONGLONG qwLength = pco_file->GetLength();
if (qwLength > INT_MAX)
{
AfxMessageBox (_T("File too long."), MB_ICONEXCLAMATION);
return;
}
bool b_result = true;
if (ar.IsStoring())
{
b_result = pco_Doc_->b_Store (*pco_file);
if (b_result)
{
// SetModifiedFlag(0);
v_ClearModified();
pco_Doc_->b_Imported_ = false;
}
}
else
{
pco_Doc_->b_Unrenderable_ = false;
unsigned int ui_version = 0;
b_result = pco_Doc_->b_CheckDocFormat (*pco_file, ui_version);
if (b_result)
{
b_result = pco_Doc_->b_Load (*pco_file);
}
else
{
b_result = pco_Doc_->b_ImportTextFile (*pco_file);
if (b_result)
{
// SetModifiedFlag();
v_SetModified();
}
else
{
pco_Doc_->b_Unrenderable_ = true;
}
}
if (!b_result)
{
AfxMessageBox (_T("Unable to read this file."), MB_ICONEXCLAMATION);
}
}
}
#ifdef _DEBUG
void CKaiDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CKaiDoc::Dump (CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
BOOL CKaiDoc::OnOpenDocument (LPCTSTR cchr0_pathname)
{
if (!CDocument::OnOpenDocument (cchr0_pathname))
return FALSE;
if (pco_Doc_->b_Unrenderable_)
{
return FALSE;
}
// TODO: Add your specialized creation code here
return TRUE;
}
void CKaiDoc::v_CreateDeafultParagraph (CT_Paragraph *& pco_paragraph)
{
int i_defaultLineWidth = 0;
int i_defaultLeftIndent = 0;
int i_defaultRightIndent = 0;
int i_defaultSpacing = 0;
ET_Alignment eo_defaultAlignment = ec_AlignmentFront;
bool b_ = pco_Doc_->b_GetDefaultParStyle (i_defaultLineWidth,
i_defaultLeftIndent,
i_defaultRightIndent,
eo_defaultAlignment);
if (!b_)
{
STL_STRING str_ (_T("Warning: Unable to find default paragraph style"));
ERROR_TRACE (str_);
i_defaultLineWidth = 800;
i_defaultSpacing = 10;
eo_defaultAlignment = ec_Left;
}
pco_Doc_->v_SetMaxParagraphWidth (i_defaultLineWidth);
STL_STRING str_typeface;
int i_size = 0;
ET_Charset eo_charset = ec_CharsetFront;
b_ = pco_Doc_->b_GetDefaultFont (str_typeface, i_size, eo_charset);
if (!b_)
{
ERROR_TRACE (_T("Warning: b_GetDefaultFont returned \"false\""));
str_typeface = _T("Courier New");
i_size = 10;
eo_charset = ec_RussianCharset;
}
CT_FontDescriptor co_fd (CT_KaiString (str_typeface), eo_charset, i_size);
pco_Doc_->v_CreateDefaultParagraph (i_defaultLeftIndent,
i_defaultRightIndent,
eo_defaultAlignment,
STL_STRING(_T("")),
co_fd,
pco_paragraph);
} // v_CreateDeafultParagraph (...)
BOOL CKaiDoc::SaveModified()
{
// TODO: Add your specialized code here and/or call the base class
if (pco_Doc_->b_IsImported())
{
// Adapted from MFC code: doccore.cpp
CString cstr_prompt;
AfxFormatString1 (cstr_prompt, AFX_IDP_ASK_TO_SAVE, GetPathName());
switch (AfxMessageBox ( cstr_prompt, MB_YESNOCANCEL, AFX_IDP_ASK_TO_SAVE))
{
case IDCANCEL:
{
return FALSE; // don't continue
}
case IDYES:
{
OnFileSaveAs();
break;
}
case IDNO:
{
// If not saving changes, revert the document
break;
}
default:
{
ATLASSERT(FALSE);
break;
}
}
// OnFileSaveAs();
return TRUE;
}
if (!pco_GetUndoStack()->b_EventsAvailable())
{
return TRUE;
}
SetTitle (pco_Doc_->str_Title_.data());
BOOL ui_ = CDocument::SaveModified();
if (ui_)
{
SetModifiedFlag (FALSE);
}
else
{
SetTitle (CString (pco_Doc_->str_Title_.data()) + _T("*"));
}
return ui_;
}
void CKaiDoc::OnFileSave()
{
// TODO: Add your command handler code here
if (pco_Doc_->b_IsImported())
{
OnFileSaveAs();
return;
}
CString cstr_path = GetPathName();
if (!cstr_path.IsEmpty())
{
CString cstr_ext = PathFindExtension (cstr_path);
SetPathName (CString (cstr_path.Left (cstr_path.GetLength() -
cstr_ext.GetLength())) +
_T(".kai"));
}
else
{
SetTitle (pco_Doc_->str_Title_.data());
}
CDocument::OnFileSave();
if (IsModified())
{
SetTitle (CString (pco_Doc_->str_Title_.data()) + _T("*"));
}
}
void CKaiDoc::OnFileSaveAs()
{
// TODO: Add your command handler code here
CString cstr_path = GetPathName();
if (!cstr_path.IsEmpty())
{
CString cstr_ext = PathFindExtension (cstr_path);
cstr_path = CString (cstr_path.Left (cstr_path.GetLength() -
cstr_ext.GetLength()) +
_T(".kai"));
}
else
{
SetTitle (pco_Doc_->str_Title_.data());
}
// CDocument::OnFileSaveAs();
bool b_continue = false;
INT_PTR i_ret = 0;
do
{
CFileDialog co_dlg (FALSE, // i.e. use Save As dlg template
_T("*.kai"),
cstr_path,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
_T("Kai Documents|*.kai|Unicode Texts|*.txt|All Files|*.*||"));
i_ret = co_dlg.DoModal();
if (IDOK == i_ret)
{
if (1 == co_dlg.m_ofn.nFilterIndex) // *.kai (it's zero-based)
{
try
{
CFile co_file (co_dlg.GetPathName(), CFile::modeWrite | CFile::modeCreate);
bool b_result = pco_Doc_->b_Store (co_file);
if (b_result)
{
SetTitle (co_dlg.GetFileName());
v_ClearModified();
pco_Doc_->b_Imported_ = false;
}
}
catch (CFileException * pco_ex)
{
STL_STRING str_ (_T("Unable to save document. "));
TCHAR psz_errData[1000] = { 0 };
pco_ex->GetErrorMessage (psz_errData, 1000);
str_ += STL_STRING (psz_errData);
str_ += _T(".");
ERROR_TRACE (str_);
AfxMessageBox (str_.c_str(), MB_ICONEXCLAMATION);
}
}
else
{
CString cstr_text (_T("You chose to save the document as a Unicode text. "));
cstr_text += _T("\nFormatting, linguistic data, and some diacritics may be lost. ");
cstr_text += _T("\nTo continue, click OK. To keep all data, click Cancel and then ");
cstr_text += _T("\nselect the \"Kai Documents\" option from the menu");
int i_ret = AfxMessageBox (cstr_text, MB_ICONEXCLAMATION | MB_OKCANCEL);
if (IDOK == i_ret)
{
CFile co_file (co_dlg.GetPathName(), CFile::modeWrite | CFile::modeCreate);
bool b_result = pco_Doc_->b_StoreAsPlainText (co_file);
if (b_result)
{
SetTitle (co_dlg.GetFileName());
v_ClearModified();
pco_Doc_->b_Imported_ = false;
}
}
else
{
if (IDCANCEL == i_ret)
{
b_continue = true;
}
else
{
ERROR_TRACE (_T("Unexpected return from AfxMessageBox"));
AfxMessageBox (_T("Internal error. Unable to save document."),
MB_ICONEXCLAMATION);
}
}
}
} // if (IDOK == i_ret)
else
{
if (IDCANCEL == i_ret)
{
if (IsModified())
{
SetTitle (CString (pco_Doc_->str_Title_.data()) + _T("*"));
}
}
else
{
STL_STRING str_ (_T("Unexpected return from CFileDialog::DoModal(). Return value = "));
str_ += STR_IToStr (i_ret);
str_ += _T(".");
ERROR_TRACE (str_);
AfxMessageBox (_T("Unexpected error. Document may not be saved correctly"),
MB_ICONEXCLAMATION);
}
}
} while (b_continue);
} // OnFileSaveAs()
| [
"kostya@4a411af2-12c4-46b1-bc79-72289035148e"
]
| [
[
[
1,
399
]
]
]
|
e88ace53d24ed89c36a4ba8d904819550386f490 | 8a783a44653ac0b203bcd23d010747218568a401 | /pi-counter/pi-counter/Function.h | 1456a2b00edf795d60c52a695780166df0db8035 | []
| no_license | stankiewicz/pi-counter | b08642149ea1af9c88c8acad9cf60c44e80f64de | f6418053b2241efb83a6d2d4c0091356f87e7d0f | refs/heads/master | 2021-01-15T13:48:34.288727 | 2008-09-03T18:14:14 | 2008-09-03T18:14:14 | 32,282,826 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 424 | h | #ifndef _FUNCTION_H_
#define _FUNCTION_H_
#include "gmp.h"
#include "PiGenerator.h"
class Function
{
public:
unsigned int *Calculate(CoolListener listener, unsigned __int64 *resultLength, char *pi, int checkNumberOfDigits, mpf_t a, mpf_t b, int lengthA, int lengthB, unsigned __int64 *numberOfFound, unsigned int *digitsChecked, int maxTimeMs = 1000000000, unsigned int firstIndex = 1);
private:
};
#endif | [
"tomasz.czekala@8d1154ae-3347-0410-a901-cdf36a16b7d0"
]
| [
[
[
1,
15
]
]
]
|
8cb4b42ad28f4648bf4609357a9f3bf1647772c8 | 7f72fc855742261daf566d90e5280e10ca8033cf | /branches/full-calibration/ground/src/plugins/config/configtaskwidget.h | 703cbf86241757c0ba07bc3f44c6af0aa0d9a343 | []
| no_license | caichunyang2007/my_OpenPilot_mods | 8e91f061dc209a38c9049bf6a1c80dfccb26cce4 | 0ca472f4da7da7d5f53aa688f632b1f5c6102671 | refs/heads/master | 2023-06-06T03:17:37.587838 | 2011-02-28T10:25:56 | 2011-02-28T10:25:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,002 | h | /**
******************************************************************************
*
* @file configtaskwidget.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ConfigPlugin Config Plugin
* @{
* @brief The Configuration Gadget used to update settings in the firmware (task widget)
*****************************************************************************/
/*
* 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, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef CONFIGTASKWIDGET_H
#define CONFIGTASKWIDGET_H
#include "extensionsystem/pluginmanager.h"
#include "uavobjects/uavobjectmanager.h"
#include "uavobjects/uavobject.h"
#include "uavobjects/objectpersistence.h"
#include <QQueue>
#include <QtGui/QWidget>
#include <QList>
class ConfigTaskWidget: public QWidget
{
Q_OBJECT
public:
ConfigTaskWidget(QWidget *parent = 0);
~ConfigTaskWidget();
void saveObjectToSD(UAVObject *obj);
void updateObjectPersistance(ObjectPersistence::OperationOptions op, UAVObject *obj);
UAVObjectManager* getObjectManager();
public slots:
void transactionCompleted(UAVObject* obj, bool success);
private:
QQueue<UAVObject*> queue;
void saveNextObject();
};
#endif // CONFIGTASKWIDGET_H
| [
"jonathan@ebee16cc-31ac-478f-84a7-5cbb03baadba"
]
| [
[
[
1,
62
]
]
]
|
2c66f582f11ebf2ac65499049bd46a07fc97a0f1 | 1caba14ec096b36815b587f719dda8c963d60134 | /branches/smxgroup/smx/libsmx/hset.h | 133ee573e56e262d49b83429ad6d2e56368c09df | []
| no_license | BackupTheBerlios/smx-svn | 0502dff1e494cffeb1c4a79ae8eaa5db647e5056 | 7955bd611e88b76851987338b12e47a97a327eaf | refs/heads/master | 2021-01-10T19:54:39.450497 | 2009-03-01T12:24:56 | 2009-03-01T12:24:56 | 40,749,397 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,301 | h | /* COPYRIGHT 1998 Prime Data Corp.
All Rights Reserved. Use of this file without prior written
authorization is strictly prohibited.
*/
#ifndef _QHSET_
#define _QHSET_
/////// %hset/%hget object, uses a threadsafe (TS) context
#include "dbpset.h"
class qObjHCtx : public qObjTS
{
protected:
#ifdef WIN32
bool myTemp;
#endif
CDBHash myHash;
qCtx *myParent;
public:
// construct / destruct
~qObjHCtx() {
Cleanup();
}
virtual void Cleanup(bool aborted = false);
public:
qObjHCtx(qCtx *parent) {
#ifdef WIN32
myTemp = false;
#endif
myParent = parent;
}
void SetPath(char *path, bool temp = false) {
#ifdef WIN32
myTemp = temp;
#endif
myHash.SetPath(path);
}
void HGet(qCtx *ctx, qStr *out, qArgAry *args);
void HExists(qCtx *ctx, qStr *out, qArgAry *args);
void HSet(qCtx *ctx, qStr *out, qArgAry *args);
void HDel(qCtx *ctx, qStr *out, qArgAry *args);
void HEnum(qCtx *ctx, qStr *out, qArgAry *args);
void HFile(qCtx *ctx, qStr *out, qArgAry *args);
};
void EvalHEnumValues(const void *data, qCtx *ctx, qStr *out, qArgAry *args);
void EvalHEnumKeys(const void *data, qCtx *ctx, qStr *out, qArgAry *args);
void EvalHEnumTree(const void *data, qCtx *ctx, qStr *out, qArgAry *args);
#endif //#ifndef _QHSET_
| [
"simul@407f561b-fe63-0410-8234-8332a1beff53"
]
| [
[
[
1,
57
]
]
]
|
76afac9f967733ef241af20e08596c605533328f | 40b507c2dde13d14bb75ee1b3c16b4f3f82912d1 | /core/smn_timers.cpp | be8bc64f38f79a48e6cf676ef3db64a63515074a | []
| no_license | Nephyrin/-furry-octo-nemesis | 5da2ef75883ebc4040e359a6679da64ad8848020 | dd441c39bd74eda2b9857540dcac1d98706de1de | refs/heads/master | 2016-09-06T01:12:49.611637 | 2008-09-14T08:42:28 | 2008-09-14T08:42:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,080 | cpp | /**
* vim: set ts=4 :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, 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 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/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#include "HandleSys.h"
#include "TimerSys.h"
#include "PluginSys.h"
#include "Logger.h"
#include "DebugReporter.h"
#define TIMER_HNDL_CLOSE (1<<9)
HandleType_t g_TimerType;
struct TimerInfo
{
ITimer *Timer;
IPluginFunction *Hook;
IPluginContext *pContext;
Handle_t TimerHandle;
int UserData;
int Flags;
};
class TimerNatives :
public SMGlobalClass,
public IHandleTypeDispatch,
public ITimedEvent
{
public:
~TimerNatives();
public: //ITimedEvent
ResultType OnTimer(ITimer *pTimer, void *pData);
void OnTimerEnd(ITimer *pTimer, void *pData);
public: //IHandleTypeDispatch
void OnHandleDestroy(HandleType_t type, void *object);
public: //SMGlobalClass
void OnSourceModAllInitialized();
void OnSourceModShutdown();
public:
TimerInfo *CreateTimerInfo();
void DeleteTimerInfo(TimerInfo *pInfo);
private:
CStack<TimerInfo *> m_FreeTimers;
};
TimerNatives::~TimerNatives()
{
CStack<TimerInfo *>::iterator iter;
for (iter=m_FreeTimers.begin(); iter!=m_FreeTimers.end(); iter++)
{
delete (*iter);
}
m_FreeTimers.popall();
}
void TimerNatives::OnSourceModAllInitialized()
{
HandleAccess sec;
g_HandleSys.InitAccessDefaults(NULL, &sec);
sec.access[HandleAccess_Clone] = HANDLE_RESTRICT_IDENTITY;
g_TimerType = g_HandleSys.CreateType("Timer", this, 0, NULL, &sec, g_pCoreIdent, NULL);
}
void TimerNatives::OnSourceModShutdown()
{
g_HandleSys.RemoveType(g_TimerType, g_pCoreIdent);
g_TimerType = 0;
}
void TimerNatives::OnHandleDestroy(HandleType_t type, void *object)
{
TimerInfo *pTimer = reinterpret_cast<TimerInfo *>(object);
g_Timers.KillTimer(pTimer->Timer);
}
TimerInfo *TimerNatives::CreateTimerInfo()
{
TimerInfo *pInfo;
if (m_FreeTimers.empty())
{
pInfo = new TimerInfo;
} else {
pInfo = m_FreeTimers.front();
m_FreeTimers.pop();
}
return pInfo;
}
void TimerNatives::DeleteTimerInfo(TimerInfo *pInfo)
{
m_FreeTimers.push(pInfo);
}
ResultType TimerNatives::OnTimer(ITimer *pTimer, void *pData)
{
TimerInfo *pInfo = reinterpret_cast<TimerInfo *>(pData);
IPluginFunction *pFunc = pInfo->Hook;
cell_t res = static_cast<ResultType>(Pl_Continue);
pFunc->PushCell(pInfo->TimerHandle);
pFunc->PushCell(pInfo->UserData);
pFunc->Execute(&res);
return static_cast<ResultType>(res);
}
void TimerNatives::OnTimerEnd(ITimer *pTimer, void *pData)
{
HandleSecurity sec;
HandleError herr;
TimerInfo *pInfo = reinterpret_cast<TimerInfo *>(pData);
Handle_t usrhndl = static_cast<Handle_t>(pInfo->UserData);
sec.pOwner = pInfo->pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent;
if (pInfo->Flags & TIMER_HNDL_CLOSE)
{
if ((herr=g_HandleSys.FreeHandle(usrhndl, &sec)) != HandleError_None)
{
g_DbgReporter.GenerateError(pInfo->pContext,
pInfo->Hook->GetFunctionID(),
SP_ERROR_NATIVE,
"Invalid data handle %x (error %d) passed during timer end",
usrhndl,
herr);
}
}
if ((herr=g_HandleSys.FreeHandle(pInfo->TimerHandle, &sec)) != HandleError_None)
{
g_DbgReporter.GenerateError(pInfo->pContext,
pInfo->Hook->GetFunctionID(),
SP_ERROR_NATIVE,
"Invalid timer handle %x (error %d) during timer end, displayed function is timer callback, not the stack trace",
pInfo->TimerHandle,
herr);
return;
}
DeleteTimerInfo(pInfo);
}
/*******************************
* *
* TIMER NATIVE IMPLEMENTATIONS *
* *
********************************/
static TimerNatives s_TimerNatives;
static cell_t smn_CreateTimer(IPluginContext *pCtx, const cell_t *params)
{
IPluginFunction *pFunc;
TimerInfo *pInfo;
ITimer *pTimer;
Handle_t hndl;
int flags = params[4];
pFunc = pCtx->GetFunctionById(params[2]);
if (!pFunc)
{
return pCtx->ThrowNativeError("Invalid function id (%X)", params[2]);
}
pInfo = s_TimerNatives.CreateTimerInfo();
pTimer = g_Timers.CreateTimer(&s_TimerNatives, sp_ctof(params[1]), pInfo, flags);
if (!pTimer)
{
s_TimerNatives.DeleteTimerInfo(pInfo);
return 0;
}
hndl = g_HandleSys.CreateHandle(g_TimerType, pInfo, pCtx->GetIdentity(), g_pCoreIdent, NULL);
pInfo->UserData = params[3];
pInfo->Flags = flags;
pInfo->TimerHandle = hndl;
pInfo->Hook = pFunc;
pInfo->Timer = pTimer;
pInfo->pContext = pCtx;
return hndl;
}
static cell_t smn_KillTimer(IPluginContext *pCtx, const cell_t *params)
{
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError herr;
HandleSecurity sec;
TimerInfo *pInfo;
sec.pOwner = pCtx->GetIdentity();
sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_TimerType, &sec, (void **)&pInfo))
!= HandleError_None)
{
return pCtx->ThrowNativeError("Invalid timer handle %x (error %d)", hndl, herr);
}
g_Timers.KillTimer(pInfo->Timer);
if (params[2] && !(pInfo->Flags & TIMER_HNDL_CLOSE))
{
sec.pOwner = pInfo->pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.FreeHandle(static_cast<Handle_t>(pInfo->UserData), &sec)) != HandleError_None)
{
return pCtx->ThrowNativeError("Invalid data handle %x (error %d)", hndl, herr);
}
}
return 1;
}
static cell_t smn_TriggerTimer(IPluginContext *pCtx, const cell_t *params)
{
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError herr;
HandleSecurity sec;
TimerInfo *pInfo;
sec.pOwner = pCtx->GetIdentity();
sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_TimerType, &sec, (void **)&pInfo))
!= HandleError_None)
{
return pCtx->ThrowNativeError("Invalid timer handle %x (error %d)", hndl, herr);
}
g_Timers.FireTimerOnce(pInfo->Timer, params[2] ? true : false);
return 1;
}
static cell_t smn_GetTickedTime(IPluginContext *pContext, const cell_t *params)
{
return sp_ftoc(*g_pUniversalTime);
}
static cell_t smn_GetMapTimeLeft(IPluginContext *pContext, const cell_t *params)
{
float time_left;
if (!g_Timers.GetMapTimeLeft(&time_left))
{
return 0;
}
cell_t *addr;
pContext->LocalToPhysAddr(params[1], &addr);
*addr = (int)time_left;
return 1;
}
static cell_t smn_GetMapTimeLimit(IPluginContext *pContext, const cell_t *params)
{
IMapTimer *pMapTimer = g_Timers.GetMapTimer();
if (!pMapTimer)
{
return 0;
}
cell_t *addr;
pContext->LocalToPhysAddr(params[1], &addr);
*addr = pMapTimer->GetMapTimeLimit();
return 1;
}
static cell_t smn_ExtendMapTimeLimit(IPluginContext *pContext, const cell_t *params)
{
IMapTimer *pMapTimer = g_Timers.GetMapTimer();
if (!pMapTimer)
{
return 0;
}
pMapTimer->ExtendMapTimeLimit(params[1]);
return 1;
}
static cell_t smn_IsServerProcessing(IPluginContext *pContext, const cell_t *params)
{
return (gpGlobals->frametime > 0.0f) ? 1 : 0;
}
static cell_t smn_GetTickInterval(IPluginContext *pContext, const cell_t *params)
{
return sp_ftoc(gpGlobals->interval_per_tick);
}
REGISTER_NATIVES(timernatives)
{
{"CreateTimer", smn_CreateTimer},
{"KillTimer", smn_KillTimer},
{"TriggerTimer", smn_TriggerTimer},
{"GetTickedTime", smn_GetTickedTime},
{"GetMapTimeLeft", smn_GetMapTimeLeft},
{"GetMapTimeLimit", smn_GetMapTimeLimit},
{"ExtendMapTimeLimit", smn_ExtendMapTimeLimit},
{"IsServerProcessing", smn_IsServerProcessing},
{"GetTickInterval", smn_GetTickInterval},
{NULL, NULL}
};
| [
"[email protected]",
"[email protected]",
"[email protected]"
]
| [
[
[
1,
1
],
[
31,
199
],
[
207,
225
],
[
227,
271
],
[
333,
337
],
[
344,
345
]
],
[
[
2,
3
],
[
6,
10
],
[
12,
15
],
[
17,
18
],
[
20,
30
]
],
[
[
4,
5
],
[
11,
11
],
[
16,
16
],
[
19,
19
],
[
200,
206
],
[
226,
226
],
[
272,
332
],
[
338,
343
],
[
346,
346
]
]
]
|
cd90415545ef65aee30a76e683e90450d34bbee5 | e07af5d5401cec17dc0bbf6dea61f6c048f07787 | /field.hpp | ad5c35afdf7ac3623fc4aca312296168c1444388 | []
| no_license | Mosesofmason/nineo | 4189c378026f46441498a021d8571f75579ce55e | c7f774d83a7a1f59fde1ac089fde9aa0b0182d83 | refs/heads/master | 2016-08-04T16:33:00.101017 | 2009-12-26T15:25:54 | 2009-12-26T15:25:54 | 32,200,899 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 664 | hpp | #ifndef __NEXT_NINEO_FIELD_DEFINE__
#define __NEXT_NINEO_FIELD_DEFINE__
#include <wx/wx.h>
#include "regex.hpp"
#include "utils.hpp"
namespace NiField
{
class Field
{
public:
Field ();
~Field ();
bool operator () ( const wxString& data );
bool Parser ( const wxString& data );
wxString Data () const;
wxString DataStripRe () const;
wxString Charset () const;
NiUtils::HASH DataStripReHash () const;
private:
wxString m_data, m_charset, m_rawdata;
wxChar m_encodetype;
};
};
#endif //
| [
"[email protected]"
]
| [
[
[
1,
28
]
]
]
|
9717a423552ce5e806a18da288374fb794275312 | c5ecda551cefa7aaa54b787850b55a2d8fd12387 | /src/UILayer/Functions/AddTask/DlgAddTask.cpp | ba306e8d0075c6086140cb22c935c164456d701c | []
| no_license | firespeed79/easymule | b2520bfc44977c4e0643064bbc7211c0ce30cf66 | 3f890fa7ed2526c782cfcfabb5aac08c1e70e033 | refs/heads/master | 2021-05-28T20:52:15.983758 | 2007-12-05T09:41:56 | 2007-12-05T09:41:56 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 22,077 | cpp | // DlgAddTask.cpp : 实现文件
//
#include "stdafx.h"
#include "DlgAddTask.h"
#include ".\dlgaddtask.h"
#include "otherfunctions.h"
#include "Preferences.h"
#include "UserMsgs.h"
#include "GlobalVariable.h"
#include "Util.h"
#include "CmdGotoPage.h"
#include "CmdFuncs.h"
#include "Util.h"
#include <strsafe.h>
#include "SourceURL.h"
#include "DNSManager.h"
#include "StringConversion.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
ULONG CDlgAddTask::m_uAddState = 0;
CDlgAddTask::ItemData::ItemData()
{
cat = 0;
pLink = NULL;
pSearchFile = NULL;
paused = FALSE;
}
CDlgAddTask::ItemData::~ItemData()
{
}
// CDlgAddTask 对话框
CDlgAddTask* CDlgAddTask::ms_pInstance = NULL;
IMPLEMENT_DYNAMIC(CDlgAddTask, CDialog)
CDlgAddTask::CDlgAddTask(CWnd* pParent /*=NULL*/)
: CDialog(CDlgAddTask::IDD, pParent)
, m_bCheckSaveDirectly(FALSE)
{
}
CDlgAddTask::~CDlgAddTask()
{
}
void CDlgAddTask::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_COMBO_LOCATION, m_cmbLocation);
DDX_Control(pDX, IDC_LIST_CONTENT, m_lcContent);
DDX_Control(pDX, IDC_EDIT_LINKS, m_editLinks);
DDX_Check(pDX, IDC_CHECK_SAVE_DIRECTLY, m_bCheckSaveDirectly);
}
BEGIN_MESSAGE_MAP(CDlgAddTask, CDialog)
ON_BN_CLICKED(IDC_BN_BROWSE, OnBnClickedBnBrowse)
ON_WM_NCDESTROY()
ON_WM_DESTROY()
ON_CBN_SELCHANGE(IDC_COMBO_LOCATION, OnCbnSelchangeComboLocation)
ON_CBN_EDITCHANGE(IDC_COMBO_LOCATION, OnCbnEditchangeComboLocation)
END_MESSAGE_MAP()
void CDlgAddTask::PopBlankTaskDlg(void)
{
GetInstance()->PopupDlg(TRUE);
BOOL bValidLinks = FALSE;
CString strText = theApp.CopyTextFromClipboard();
CString strLeft;
strLeft = strText.Left(7);
if (0 == strLeft.CompareNoCase(_T("ed2k://"))
|| 0 == strLeft.CompareNoCase(_T("http://")))
bValidLinks = TRUE;
else
{
strLeft = strText.Left(6);
if (0 == strLeft.CompareNoCase(_T("ftp://")))
bValidLinks = TRUE;
}
if (bValidLinks)
{
GetInstance()->AddLinks(strText);
//CString strRight = strText.Right(2);
//if (strRight != _T("\r\n"))
// strText += _T("\r\n");
//GetInstance()->m_editLinks.SetWindowText(strText);
//GetInstance()->m_editLinks.SetSel(0, -1);
//GetInstance()->m_editLinks.SetSel(-1, -1);
//GetInstance()->m_editLinks.UpdateLinksByWindowText();
}
}
void CDlgAddTask::AddNewTask(LPCTSTR lpszLink, int cat)
{
CED2KFileLink *pLink = NULL;
CFileHashKey key;
CAddTaskDoc::SItem item;
pLink = CreateFileLinkFromUrl(lpszLink);
if (NULL != pLink)
{
key = pLink->GetHashKey();
item.strLinkText = lpszLink;
item.bCheck = TRUE;
item.iCategory = cat;
GetInstance()->AddTask(key, item);
SAFE_DELETE(pLink);
}
}
void CDlgAddTask::AddNewTask(CED2KFileLink* pLink, int cat)
{
CFileHashKey key;
CAddTaskDoc::SItem item;
if (NULL != pLink)
{
key = pLink->GetHashKey();
pLink->GetLink(item.strLinkText);
item.bCheck = TRUE;
item.iCategory = cat;
GetInstance()->AddTask(key, item);
}
}
void CDlgAddTask::AddNewTask(CSearchFile* toadd, uint8 paused, int cat)
{
CFileHashKey key;
CAddTaskDoc::SItem item;
if (NULL != toadd)
{
key = toadd->GetFileHash();
item.strLinkText = CreateED2kLink(toadd);
item.bCheck = TRUE;
item.iCategory = cat;
item.uPause = paused;
GetInstance()->AddTask(key, item);
}
}
void CDlgAddTask::AddNewTask(LPCTSTR lpszLink, uint8 paused, int cat)
{
CED2KFileLink *pLink = NULL;
CFileHashKey key;
CAddTaskDoc::SItem item;
pLink = CreateFileLinkFromUrl(lpszLink);
if (NULL != pLink)
{
key = pLink->GetHashKey();
item.strLinkText = lpszLink;
item.bCheck = TRUE;
item.iCategory = cat;
item.uPause = paused;
GetInstance()->AddTask(key, item);
SAFE_DELETE(pLink);
}
}
void CDlgAddTask::AddNewUrlTask(LPCTSTR lpszUrl)
{
GetInstance()->AddTask(lpszUrl);
}
void CDlgAddTask::AddMultiLinks(LPCTSTR lpszLinks)
{
GetInstance()->PopupDlg(FALSE);
GetInstance()->AddLinks(lpszLinks);
}
void CDlgAddTask::Localize(void)
{
this->SetWindowText(GetResString(IDS_ADD_TASK));
GetDlgItem(IDC_BN_BROWSE)->SetWindowText(GetResString(IDS_PW_BROWSE));
GetDlgItem(IDC_STATIC_SAVE_LOCATION)->SetWindowText(GetResString(IDS_ADDTASKDLG_SAVE_LOCATION));
GetDlgItem(IDC_STATIC_CONTENT)->SetWindowText(GetResString(IDS_ADDTASKDLG_CONTENTS));
GetDlgItem(IDC_STATIC_DL_TASK)->SetWindowText(GetResString(IDS_ADDTASKDLG_DL_TASK));
GetDlgItem(IDC_STATIC_LINKS)->SetWindowText(GetResString(IDS_ADDTASKDLG_LINKS));
GetDlgItem(IDC_CHECK_SAVE_DIRECTLY)->SetWindowText(GetResString(IDS_ADDTASKDLG_DIRECTLY));
GetDlgItem(IDC_STATIC_FREE_SPACE)->SetWindowText(GetResString(IDS_ADDTASKDLG_FREE_SPACE));
GetDlgItem(IDOK)->SetWindowText(GetResString(IDS_OK));
GetDlgItem(IDCANCEL)->SetWindowText(GetResString(IDS_CANCEL));
m_ttc.UpdateTipText(GetResString(IDS_TIP_NEEDNT_ADDTASKDLG), GetDlgItem(IDC_CHECK_SAVE_DIRECTLY));
}
void CDlgAddTask::AddTask(const CFileHashKey &key, const CAddTaskDoc::SItem &item)
{
if (!IsDlgPopedUp())
{
if (!thePrefs.m_bShowNewTaskDlg)
{
int iState = CGlobalVariable::filemgr.GetFileState((const uchar*)&key);
CString strPrompt;
m_uAddState = 1;
switch (iState)
{
case FILESTATE_DOWNLOAD:
strPrompt = GetResString(IDS_TASK_IN_DOWNLOADING);
strPrompt += item.strLinkText;
CGlobalVariable::ShowNotifier(strPrompt,TBN_IMPORTANTEVENT);
break;
case FILESTATE_COMPLETED:
case FILESTATE_HASH:
case FILESTATE_LOCAL_SHARE:
case FILESTATE_SHARE:
case FILESTATE_SHARE_TASK_DELED:
//case FILESTATE_ZEROSIZE_DOWNLOADED:
strPrompt = GetResString(IDS_ALREADY_DOWNLOAD);
strPrompt += item.strLinkText;
CGlobalVariable::ShowNotifier(strPrompt,TBN_IMPORTANTEVENT);
break;
case FILESTATE_DELETED:
strPrompt = GetResString(IDS_DOWN_DELED_LINKS);
strPrompt += item.strLinkText;
if(IDNO == MessageBox(strPrompt,GetResString(IDS_CAPTION),MB_YESNO))
break;
case FILESTATE_NOT_EXIST:
CGlobalVariable::filemgr.NewDownloadFile(item.strLinkText, thePrefs.GetMuleDirectory(EMULE_INCOMINGDIR), item.iCategory);
CCmdGotoPage cmdGotoPage;
if(thePrefs.bringtoforeground == 1)
cmdGotoPage.GotoDownloading();
break;
}
return;
}
else
{
PopupDlg();
}
}
m_doc.SetItem(key, item);
}
void CDlgAddTask::AddTask(LPCTSTR lpszUrl)
{
if (!IsDlgPopedUp())
{
if (!thePrefs.m_bShowNewTaskDlg)
{
int iState = CGlobalVariable::filemgr.GetUrlTaskState(lpszUrl); //< 统一转换后再判断,避免实际是重复的Url
CString strPrompt;
m_uAddState = 1;
switch (iState)
{
case FILESTATE_DOWNLOAD:
strPrompt = GetResString(IDS_TASK_IN_DOWNLOADING);
strPrompt += CString(lpszUrl);
CGlobalVariable::ShowNotifier(strPrompt,TBN_IMPORTANTEVENT);
break;
case FILESTATE_COMPLETED:
case FILESTATE_HASH:
case FILESTATE_LOCAL_SHARE:
strPrompt = GetResString(IDS_ALREADY_DOWNLOAD);
strPrompt += CString(lpszUrl);
CGlobalVariable::ShowNotifier(strPrompt,TBN_IMPORTANTEVENT);
break;
case FILESTATE_SHARE:
case FILESTATE_SHARE_TASK_DELED:
case FILESTATE_DELETED:
case FILESTATE_ZEROSIZE_DOWNLOADED:
strPrompt = GetResString(IDS_DOWN_DELED_LINKS);
strPrompt += CString(lpszUrl);
if(IDNO == MessageBox(strPrompt,GetResString(IDS_CAPTION),MB_YESNO))
break;
case FILESTATE_NOT_EXIST:
CmdFuncs::ActualllyAddUrlDownload(lpszUrl,thePrefs.GetMuleDirectory(EMULE_INCOMINGDIR));
CCmdGotoPage cmdGotoPage;
cmdGotoPage.GotoDownloading();
break;
}
return;
}
else
{
PopupDlg();
}
}
m_doc.AddUrl(lpszUrl);
}
void CDlgAddTask::AddLinks(LPCTSTR lpszLinks)
{
if (NULL == lpszLinks || _T('\0') == lpszLinks[0])
return;
CString strText;
m_editLinks.GetWindowText(strText);
CString strRight = strText.Right(2);
if (!strText.IsEmpty()
&& strRight != _T("\r\n"))
strText += _T("\r\n");
if (-1 != strText.Find(lpszLinks)) // 如果已经存在则不用加了。
return;
strText += lpszLinks;
strRight = strText.Right(2);
if (strRight != _T("\r\n"))
strText += _T("\r\n");
m_editLinks.SetWindowText(strText);
m_editLinks.SetSel(0, -1);
m_editLinks.SetSel(-1, -1);
m_editLinks.UpdateLinksByWindowText();
}
BOOL CDlgAddTask::IsDlgPopedUp(void)
{
return (::IsWindow(m_hWnd));
}
void CDlgAddTask::PopupDlg(BOOL bBlank)
{
if (IsDlgPopedUp())
return;
m_uAddState = 2; // Added by Soar Chin 09/06/2007
Create(CDlgAddTask::IDD);
ShowWindow(SW_SHOW);
SetWindowPos(&CWnd::wndTopMost, 0, 0, 0, 0,SWP_NOMOVE|SWP_NOSIZE);
SetActiveWindow();
SetFocus();
if (!bBlank)
GetDlgItem(IDOK)->SetFocus();
}
CDlgAddTask* CDlgAddTask::GetInstance()
{
if (NULL == ms_pInstance)
{
ms_pInstance = new CDlgAddTask;
//ms_pInstance->Create(CDlgAddTask::IDD);
//ms_pInstance->ShowWindow(SW_SHOW);
}
return ms_pInstance;
}
void CDlgAddTask::LoadHistoryLocs()
{
m_cmbLocation.ResetContent();
int i;
int iIndex;
BOOL bHasIncomingDir;
BOOL bFirstItem;
CString str;
bFirstItem = TRUE;
bHasIncomingDir = FALSE;
int iCount = thePrefs.GetSaveLocationsCount();
for (i = 0; i < iCount; i++)
{
str = thePrefs.GetSaveLocation(i);
if (!str.IsEmpty())
{
if (str == thePrefs.GetMuleDirectory(EMULE_INCOMINGDIR))
bHasIncomingDir = TRUE;
iIndex = m_cmbLocation.InsertString(-1, str);
m_cmbLocation.SetItemData(iIndex, 0);
if (bFirstItem)
{
m_cmbLocation.SetCurSel(iIndex);
bFirstItem = FALSE;
}
}
}
if (! bHasIncomingDir)
{
iIndex = m_cmbLocation.InsertString(-1, thePrefs.GetMuleDirectory(EMULE_INCOMINGDIR));
m_cmbLocation.SetItemData(iIndex, 0);
if (bFirstItem)
{
m_cmbLocation.SetCurSel(iIndex);
bFirstItem = FALSE;
}
}
iIndex = m_cmbLocation.InsertString(-1, GetResString(IDS_DELETE_HISTORY));
m_cmbLocation.SetItemData(iIndex, 1);
}
void CDlgAddTask::SaveHistoryLocs()
{
CString strCurLoc;
m_cmbLocation.GetWindowText(strCurLoc);
thePrefs.SetSaveLocation(0, strCurLoc);
int iCmbIndex;
int iPrefIndex;
DWORD dwData;
CString strLoc;
iPrefIndex = 1;
iCmbIndex = 0;
while (iPrefIndex < thePrefs.GetSaveLocationsCount()
&& iCmbIndex < m_cmbLocation.GetCount())
{
dwData = m_cmbLocation.GetItemData(iCmbIndex);
if (0 == dwData)
{
m_cmbLocation.GetLBText(iCmbIndex, strLoc);
if (strLoc != strCurLoc)
{
thePrefs.SetSaveLocation(iPrefIndex, strLoc);
iPrefIndex++;
}
}
iCmbIndex++;
}
thePrefs.SaveSaveLocations();
}
int CDlgAddTask::AddLocToCmb(LPCTSTR lpszLoc)
{
if (NULL == lpszLoc || _T('\0') == lpszLoc[0])
return -1;
int i;
int iCount = m_cmbLocation.GetCount();
DWORD dwData;
CString strItemText;
for (i = 0; i < iCount; i++)
{
dwData = m_cmbLocation.GetItemData(i);
if (0 == dwData)
{
m_cmbLocation.GetLBText(i, strItemText);
if (strItemText == lpszLoc)
return i;
}
}
return m_cmbLocation.InsertString(0, lpszLoc);
}
BOOL CDlgAddTask::CheckLocation(const CString &strLocation)
{
if (strLocation.IsEmpty())
{
::AfxMessageBox(GetResString(IDS_LOC_CANNT_BE_EMPTY));
return FALSE;
}
if (PathFileExists(strLocation))
return TRUE;
int iResult = SHCreateDirectoryEx(NULL, strLocation, NULL);
if (ERROR_SUCCESS != iResult && ERROR_ALREADY_EXISTS != iResult)
{
::AfxMessageBox(GetResString(IDS_CANNT_CREATE_THIS_DIR));
return FALSE;
}
return TRUE;
}
CString UrlConvert( CString strUrl )
{
CString urlConverted;
//this is another way to process ftp url Decode
if( (strUrl.Left(7).CompareNoCase(_T("http://")) != 0) ) //ftp...
{
CStringA strUrlA(strUrl);
char szUrl[1024];
memset(szUrl,0,1024);
UnFormatString( szUrl,1024,strUrlA );
return CString(szUrl);
}
else
{
//return OptUtf8ToStr(URLDecode(strUrl));
return EncodeUrlUtf8(strUrl); //for http
}
}
void CDlgAddTask::ApplyDocToTaskMgr(LPCTSTR lpszLocation)
{
// ed2k tasks <begin>
const map<CFileHashKey, CAddTaskDoc::SItem> *pMap;
map<CFileHashKey, CAddTaskDoc::SItem>::const_iterator it;
CArray<SSpDownLink*, SSpDownLink*> arrSpDownLinks; //special download links
CArray<SSpDownLink*, SSpDownLink*> arrDowningLinks; //downloading links
CArray<SSpDownLink*, SSpDownLink*> arrReDownLinks; //ask whether redownload links
int iState;
pMap = m_doc.GetData();
for (it = pMap->begin();
it != pMap->end();
it++)
{
if (it->second.bCheck)
{
iState = CGlobalVariable::filemgr.GetFileState(it->second.strLinkText);
switch (iState)
{
case FILESTATE_DOWNLOAD:
{
SSpDownLink* psdl = new SSpDownLink;
psdl->iLinkType = 0;
psdl->strLink = it->second.strLinkText;
psdl->iCat = it->second.iCategory;
psdl->iState = iState;
arrDowningLinks.Add(psdl);
}
break;
case FILESTATE_COMPLETED:
case FILESTATE_HASH:
case FILESTATE_SHARE:
case FILESTATE_LOCAL_SHARE:
case FILESTATE_SHARE_TASK_DELED:
{
SSpDownLink* psdl = new SSpDownLink;
psdl->iLinkType = 0;
psdl->strLink = it->second.strLinkText;
psdl->iCat = it->second.iCategory;
psdl->iState = iState;
arrSpDownLinks.Add(psdl);
}
break;
case FILESTATE_DELETED:
{
SSpDownLink* psdl = new SSpDownLink;
psdl->iLinkType = 0;
psdl->strLink = it->second.strLinkText;
psdl->iCat = it->second.iCategory;
psdl->iState = iState;
arrReDownLinks.Add(psdl);
}
break;
default:
CGlobalVariable::filemgr.NewDownloadFile(it->second.strLinkText, lpszLocation, it->second.iCategory);
break;
}
}
}
// ed2k tasks <end>
// Url tasks <begin>
CString strUrl;
BOOL bCheck;
const CMapStringToPtr* pUrlData = m_doc.GetUrlData();
POSITION pos = pUrlData->GetStartPosition();
while (NULL != pos)
{
pUrlData->GetNextAssoc(pos, strUrl, (void*&)bCheck);
strUrl.Trim();
if( _tcsrchr((LPCTSTR)strUrl+7,_T('/'))==NULL )
strUrl += _T('/');
/*
int len=strUrl.GetLength();
bool state=false;
int index = strUrl.Find(_T("//"),0);
for(int i = index + 2;i < len;i++)
{
if(strUrl[i] == _T('/'))
{
state = true;
break;
}
}
if(state ==false)
strUrl+='/';*/
if (bCheck)
{
iState = CGlobalVariable::filemgr.GetUrlTaskState(strUrl); //< 统一转换后再判断,避免实际是重复的Url
switch (iState)
{
case FILESTATE_DOWNLOAD:
{
SSpDownLink* psdl = new SSpDownLink;
psdl->iLinkType = 1;
psdl->strLink = strUrl;
psdl->iCat = 0;
psdl->iState = iState;
arrDowningLinks.Add(psdl);
}
break;
case FILESTATE_COMPLETED:
case FILESTATE_HASH:
case FILESTATE_LOCAL_SHARE:
{
SSpDownLink* psdl = new SSpDownLink;
psdl->iLinkType = 1;
psdl->strLink = strUrl;
psdl->iCat = 0;
psdl->iState = iState;
arrSpDownLinks.Add(psdl);
}
break;
case FILESTATE_SHARE:
case FILESTATE_SHARE_TASK_DELED:
case FILESTATE_DELETED:
case FILESTATE_ZEROSIZE_DOWNLOADED:
{
SSpDownLink* psdl = new SSpDownLink;
psdl->iLinkType = 1;
psdl->strLink = strUrl;
psdl->iCat = 0;
psdl->iState = iState;
arrReDownLinks.Add(psdl);
}
break;
default:
CmdFuncs::ActualllyAddUrlDownload(strUrl,lpszLocation);
break;
}
}
}
// URL tasks <end>
int i;
CString strPrompt;
if (!arrSpDownLinks.IsEmpty())
{
strPrompt = GetResString(IDS_ALREADY_DOWNLOAD);
for (i = 0; i < arrSpDownLinks.GetCount(); i++)
{
strPrompt += arrSpDownLinks[i]->strLink;
strPrompt += _T("\n");
}
for (i = 0; i < arrSpDownLinks.GetCount(); i++)
delete arrSpDownLinks[i];
arrSpDownLinks.RemoveAll();
}
if (!arrDowningLinks.IsEmpty())
{
if (!strPrompt.IsEmpty())
strPrompt += _T("\n\n");
strPrompt += GetResString(IDS_TASK_IN_DOWNLOADING);
for (i = 0; i < arrDowningLinks.GetCount(); i++)
{
strPrompt += arrDowningLinks[i]->strLink;
strPrompt += _T("\n");
}
for (i = 0; i < arrDowningLinks.GetCount(); i++)
delete arrDowningLinks[i];
arrDowningLinks.RemoveAll();
}
if (!strPrompt.IsEmpty())
MessageBox(strPrompt,GetResString(IDS_CAPTION),MB_OK|MB_ICONWARNING);
//if (IDYES == ::AfxMessageBox(strPrompt, MB_YESNO))
//{
// for (i = 0; i < arrDledLink.GetCount(); i++)
// CGlobalVariable::filemgr.NewDownloadFile(arrDledLink[i], lpszLocation, arrDledLinkCat[i]);
// for (i = 0; i < arrDledUrl.GetCount(); i++)
// ActualllyAddUrlDownload(arrDledUrl[i], lpszLocation);
//}
if (!arrReDownLinks.IsEmpty())
{
strPrompt = GetResString(IDS_DOWN_DELED_LINKS);
for (i = 0; i < arrReDownLinks.GetCount(); i++)
{
strPrompt += arrReDownLinks[i]->strLink;
strPrompt += _T("\n");
}
if(IDYES == MessageBox(strPrompt,GetResString(IDS_CAPTION),MB_YESNO|MB_ICONWARNING))
{
for (i = 0; i < arrReDownLinks.GetCount(); i++)
{
switch (arrReDownLinks[i]->iLinkType)
{
case 0:
CGlobalVariable::filemgr.NewDownloadFile(arrReDownLinks[i]->strLink, lpszLocation, arrReDownLinks[i]->iCat);
break;
case 1:
//ActualllyAddUrlDownload(arrReDownLinks[i]->strLink, lpszLocation);
CmdFuncs::ActualllyAddUrlDownload(arrReDownLinks[i]->strLink,lpszLocation);
break;
default:
break;
}
}
}
for (i = 0; i < arrReDownLinks.GetCount(); i++)
delete arrReDownLinks[i];
arrReDownLinks.RemoveAll();
}
}
void CDlgAddTask::UpdateFreeSpaceValue(void)
{
CString strText;
m_cmbLocation.GetWindowText(strText);
uint64 uFreeSpace;
if (strText.GetLength()<3 || strText.GetAt(1)!=_T(':') || strText.GetAt(2)!=_T('\\'))
uFreeSpace = 0;
else
uFreeSpace = GetFreeDiskSpaceX(strText.Left(3));
CString strSize = CastItoXBytes(uFreeSpace);
GetDlgItem(IDC_STATIC_SPACE_VALUE)->SetWindowText(strSize);
}
// CDlgAddTask 消息处理程序
BOOL CDlgAddTask::OnInitDialog()
{
CDialog::OnInitDialog();
m_cmbLocation.LimitText(MAX_PATH);
m_editLinks.SetLimitText(MAX_PATH * 256);
m_editLinks.SetDoc(&m_doc);
m_lcContent.SetDoc(&m_doc);
m_doc.RegisterWnd(m_editLinks.GetSafeHwnd());
m_doc.RegisterWnd(m_lcContent.GetSafeHwnd());
CenterWindow();
m_lcContent.SetExtendedStyle(LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT);
m_ttc.Create(this);
m_ttc.SetDelayTime(TTDT_AUTOPOP, INFINITE);
m_ttc.SetDelayTime(TTDT_INITIAL, 100);
m_ttc.AddTool(GetDlgItem(IDC_CHECK_SAVE_DIRECTLY), GetResString(IDS_TIP_NEEDNT_ADDTASKDLG));
Localize();
LoadHistoryLocs();
m_lcContent.InsertColumn(0, GetResString(IDS_ADDTASKDLG_FILENAME), LVCFMT_LEFT, 300);
m_lcContent.InsertColumn(1, GetResString(IDS_ADDTASKDLG_FILESIZE), LVCFMT_LEFT, 80);
if (m_lcContent.GetSafeHwnd())
{
CRect rect;
m_lcContent.GetClientRect(rect);
ScreenToClient(rect);
m_lcContent.SetColumnWidth(1, rect.right + 162);
}
m_bCheckSaveDirectly = !thePrefs.m_bShowNewTaskDlg;
UpdateData(FALSE);
UpdateFreeSpaceValue();
BringWindowToTopExtremely(m_hWnd);
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void CDlgAddTask::OnBnClickedBnBrowse()
{
// TODO: 在此添加控件通知处理程序代码
CString str;
m_cmbLocation.GetWindowText(str);
TCHAR buffer[MAX_PATH] = {0};
::StringCchCopy(buffer, MAX_PATH, str);
if(SelectDir(GetSafeHwnd(),buffer,GetResString(IDS_CHOOSE_SAVE_LOCATION)))
{
m_cmbLocation.SetWindowText(buffer);
//m_cmbLocation.SetCurSel(AddLocToCmb(buffer));
UpdateFreeSpaceValue();
}
}
void CDlgAddTask::OnNcDestroy()
{
CDialog::OnNcDestroy();
// TODO: 在此处添加消息处理程序代码
ms_pInstance = NULL;
m_uAddState &= ~2; // Added by Soar Chin 09/06/2007
delete this; // modify by nightsuns 2007/11/22: 从上面移下来
}
void CDlgAddTask::OnOK()
{
CString strLocation;
m_cmbLocation.GetWindowText(strLocation);
if (!CheckLocation(strLocation))
return;
UpdateData();
thePrefs.m_bShowNewTaskDlg = !m_bCheckSaveDirectly;
SaveHistoryLocs();
ApplyDocToTaskMgr(strLocation);
CCmdGotoPage cmdGotoPage;
cmdGotoPage.GotoDownloading();
//CDialog::OnOK();
DestroyWindow();
m_uAddState |= 1; // Added by Soar Chin 09/06/2007
}
void CDlgAddTask::OnCancel()
{
// TODO: 在此添加专用代码和/或调用基类
//CDialog::OnCancel();
DestroyWindow();
m_uAddState &= ~1; // Added by Soar Chin 09/06/2007
}
void CDlgAddTask::OnDestroy()
{
CDialog::OnDestroy();
// TODO: 在此处添加消息处理程序代码
m_uAddState &= ~2; // Added by Soar Chin 09/06/2007
}
void CDlgAddTask::OnCbnSelchangeComboLocation()
{
// TODO: 在此添加控件通知处理程序代码
DWORD dwData = m_cmbLocation.GetItemData(m_cmbLocation.GetCurSel());
if (1 == dwData)
{
thePrefs.DeleteSaveLocations();
LoadHistoryLocs();
}
UpdateFreeSpaceValue();
}
void CDlgAddTask::OnCbnEditchangeComboLocation()
{
// TODO: 在此添加控件通知处理程序代码
UpdateFreeSpaceValue();
}
BOOL CDlgAddTask::PreTranslateMessage(MSG* pMsg)
{
// TODO: 在此添加专用代码和/或调用基类
m_ttc.RelayEvent(pMsg);
return CDialog::PreTranslateMessage(pMsg);
}
void CDlgAddTask::DeletedDownloadedFile(void)
{
}
// Added by Soar Chin 09/06/2007
BOOL CDlgAddTask::GetAddState(void)
{
return GetInstance()->m_uAddState;
}
| [
"LanceFong@4a627187-453b-0410-a94d-992500ef832d"
]
| [
[
[
1,
903
]
]
]
|
2b2eff39d531b5be52a21bb2718d65edc57cafa1 | 60791ce953e9891f156b6862ad59ac4830a7cad2 | /CATL/field.h | 94283692571cc28491629fd1272efe90c9562bc6 | []
| no_license | siavashmi/catl-code | 05283c6e24a1d3aa9652421a93f094c46c477014 | a668431b661c59f597c6f9408c371ec013bb9072 | refs/heads/master | 2021-01-10T03:17:38.898659 | 2011-06-30T10:27:35 | 2011-06-30T10:27:35 | 36,600,037 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,293 | h | #ifndef FIELD_H
#define FIELD_H
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include "math.h"
#include "geometry3D.h"
#include "common.h"
#include "sensor.h"
using namespace std;
class Sensor;
class Field;
class Field
{
public:
Field();
~Field();
void readSensorLocation3D(const char* topoFile);// read the sensor location file from 3D topology
void readSensorLocation2D(const char * topoFile);// read the sneosr location file from 2D topology
void connectivityTest();// test the connectivity if the network is not connected, the algorithm will not go on
void determineEdgeNodes(); //find nodes on the edge
void determineNotches(); //find notches
void determineInitLandmarks(); //find landmarks
void determineLandmarkNeighborhoods(); // establish links between nearby initLandmarks
void determineSeeds3D(); //determine seed nodes in 3D
void determineSeeds2D();// determine seed nodes in 2D
void seedCoordinates2D();// seed coordinates for 2D
void seedCoordinates3D();// seed coordinates for 3D
double estimatePathQuality(vector<Sensor*> & path); //calculate the path quality
void iterativeLocalization(); //iterative localization process
void checkLoclizedResult();//check if the node is far from its neighbors
void springMassAdjustLandmarks(int numIterations);// spring mass on the landmark level
void springMassAdjustNonLandmarks(int numIterations);// spring mass on the common node level
void landmarkLinkAligning();// adjust the nodes on the link between the landmarks
bool initLandmarksLocalized();// check if all the landmarks are localized
void getDisplacementByVirtualForceFromNeighbors(Sensor* sensor, vector<Sensor*> & neighbors, vector<double> & results);// commmon node level
void getDisplacementByVirtualForceFromLandmarks(Sensor* sensor, vector<Sensor*> & neighbors, vector<double> & results);// landmark level
void scheduleFlooding();// newly localized nodes will flood in the next round
void cleanup();// use the neighbor information to clean up the unlocalized nodes
int nSensors;// total number of sensors
Sensor *sensorPool;// pointer to the sensor
set<Sensor*> initLandmarks;// store the landmarks
set<Sensor*> edgeLandmarks;// store the landmarks on the edge
int diameter; // measure the size of the network
double avg1HopNeighborhoodSize;// average 1 hop degree
double avg2HopNeighborhoodSize;// average 2 hop degree
double avgNodeDistance;// one in the algorithm to represent one hop
double averageDistance;// distance one hop represents
int totalNumFloodings;// total floodings
int findNotchFloodings;// notch floodings
int iterativeLocalizationFloodings;// localization floodings
//////////////////////////////////////////////////////////////////////////
void generateSensors3D(const char*topoFile);// generate the sensors for 3D
void initSensors8(const char* topoFile);// generating the topology 8
void initSensorsSmile(const char* topoFile);//generating the topology smile
void initSensorsTorus(const char*topoFile);// generating the topology torus
void initSensorsHourGlass(const char *topoFile);
void initSensorscrossRing(const char *topoFile);
void calNeighbor();// calculate the neighbor for the sensors
void ouPutConnectivity();// output the connectivity
void inputConnectivity();// input the connectivity
void inputParameters3D(int ind);// input the parameters for 3D
void inputParameters2D(int index);// input the parameters for 2D
void coordinatesTransform2D();// transform the localized coordinates to the real system
void coordinatesTransform3D();// transform the localized coordinates to the real system
void calAvgNeighborsize();// calculate the average neighbor size
void display2DResult();// display 2D result
void display3DResult();// display 3D result
void errorRrport();// report the error
void inputParametersForConnectivityFile();// input parameters for connectivity file
void outputResult();// output the flooding
//////////////////////////////////////////////////////////////////////////Dv-Hop
double avgNodeDistanceDvHop;
void localizationDvHop2D();
void localizationDvHop3D();
void dvError();
};
#endif | [
"[email protected]"
]
| [
[
[
1,
99
]
]
]
|
0dce5fe836679e5a1b4a15eb47a644c9d5892bd5 | 21da454a8f032d6ad63ca9460656c1e04440310e | /src/wcpp/net/impl/wscDatagramSocketImpl_linux.h | ecc0199e3777fea42709e48c3906a14bbd0436a6 | []
| no_license | merezhang/wcpp | d9879ffb103513a6b58560102ec565b9dc5855dd | e22eb48ea2dd9eda5cd437960dd95074774b70b0 | refs/heads/master | 2021-01-10T06:29:42.908096 | 2009-08-31T09:20:31 | 2009-08-31T09:20:31 | 46,339,619 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 375 | h | #pragma once
#include <wcpp/net/wscDatagramSocketImpl.h>
#if (WS_PLATFORM == WS_PLATFORM_LINUX)
class wscDatagramSocketImpl_linux : public wscDatagramSocketImpl
{
public:
static const ws_char * const s_class_name;
public:
wscDatagramSocketImpl_linux(void);
~wscDatagramSocketImpl_linux(void);
};
#endif // (WS_PLATFORM == WS_PLATFORM_LINUX)
| [
"xukun0217@98f29a9a-77f1-11de-91f8-ab615253d9e8"
]
| [
[
[
1,
17
]
]
]
|
1dd67c4c643544ebd71ab131c6f4ca555ae1649c | c307dc6026aa8294568144317923b58d71e74113 | /src/RRDUpdater.h | 3ed4ea758653ddfc737fe3c69c1dfbab1e246d97 | []
| no_license | bLuma/PcapRRD | 724ad1bc9a349ad26d8fd357ff381b8ae49d4b0d | ccea2843015bcd7300d69007364be9f3138a9452 | refs/heads/master | 2021-01-23T07:33:51.686731 | 2011-12-04T13:53:20 | 2011-12-04T13:53:20 | 102,508,696 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 872 | h | /*
* File: RRDAdapter.h
* Author: roman
*
* Created on 22. říjen 2011, 13:25
*/
#ifndef RRDADAPTER_H
#define RRDADAPTER_H
#include "common.h"
#include "Stats.h"
#define PATH_CONCAT(a, b) (a + "/" + b)
#define COLLECTD_TYPE "prenosy-"
/**
* Trida pro opakovane ukladani dat do RRD databazi.
*/
class RRDUpdater {
public:
RRDUpdater();
RRDUpdater(const RRDUpdater& orig);
virtual ~RRDUpdater();
void start();
/**
* Spoji vlakna a pocka na ukonceni vlakna RRDUpdateru.
*/
void join() {
pthread_join(m_thread, NULL);
}
private:
static void* loggerThread(void* rrdAdapter);
/**
* Reference na statistiky.
*/
Stats& m_stats;
/**
* Vlakno RRDUpdateru.
*/
pthread_t m_thread;
};
#endif /* RRDADAPTER_H */
| [
"[email protected]"
]
| [
[
[
1,
50
]
]
]
|
c6bbff3fe46201039502330e7061ae41a1609aa5 | 36bf908bb8423598bda91bd63c4bcbc02db67a9d | /Include/CeXDib.h | 6f6d79ab3135d12a660f22d3f413192981313ae6 | []
| no_license | code4bones/crawlpaper | edbae18a8b099814a1eed5453607a2d66142b496 | f218be1947a9791b2438b438362bc66c0a505f99 | refs/heads/master | 2021-01-10T13:11:23.176481 | 2011-04-14T11:04:17 | 2011-04-14T11:04:17 | 44,686,513 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,468 | h | //
// Class: CCeXDib
//
// Compiler: Visual C++
// eMbedded Visual C++
// Tested on: Visual C++ 6.0
// Windows CE 3.0
//
// Author: Davide Calabro' [email protected]
// http://www.softechsoftware.it
//
// Note: This class uses code snippets taken from a similar class written
// for the Win32 enviroment by Davide Pizzolato ([email protected])
//
// Disclaimer
// ----------
// THIS SOFTWARE AND THE ACCOMPANYING FILES ARE DISTRIBUTED "AS IS" AND WITHOUT
// ANY WARRANTIES WHETHER EXPRESSED OR IMPLIED. NO REPONSIBILITIES FOR POSSIBLE
// DAMAGES OR EVEN FUNCTIONALITY CAN BE TAKEN. THE USER MUST ASSUME THE ENTIRE
// RISK OF USING THIS SOFTWARE.
//
// Terms of use
// ------------
// THIS SOFTWARE IS FREE FOR PERSONAL USE OR FREEWARE APPLICATIONS.
// IF YOU USE THIS SOFTWARE IN COMMERCIAL OR SHAREWARE APPLICATIONS YOU
// ARE GENTLY ASKED TO DONATE 1$ (ONE U.S. DOLLAR) TO THE AUTHOR:
//
// Davide Calabro'
// P.O. Box 65
// 21019 Somma Lombardo (VA)
// Italy
//
//
#ifndef _CEXDIB_H_
#define _CEXDIB_H_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
//LPI
/*#ifndef HDIB
#define HDIB HANDLE
#endif
*/
#ifndef _HDIB_DECLARED
DECLARE_HANDLE(HDIB);
#define _HDIB_DECLARED 1
#endif
#ifndef WIDTHBYTES
#define WIDTHBYTES(bits) (((bits) + 31) / 32 * 4)
#endif
#ifndef BFT_BITMAP
#define BFT_BITMAP 0x4d42 // 'BM'
#endif
class CCeXDib
{
public:
CCeXDib();
virtual ~CCeXDib();
HDIB Create(DWORD dwWidth, DWORD dwHeight, WORD wBitCount);
void Clone(CCeXDib* src);
void Draw(HDC hDC, DWORD dwX, DWORD dwY);
void Copy(HDC hDC, DWORD dwX, DWORD dwY);
LPBYTE GetBits();
void Clear(BYTE byVal = 0);
void SetGrayPalette();
void SetPaletteIndex(BYTE byIdx, BYTE byR, BYTE byG, BYTE byB);
void SetPixelIndex(DWORD dwX, DWORD dwY, BYTE byI);
void BlendPalette(COLORREF crColor, DWORD dwPerc);
WORD GetBitCount();
DWORD GetLineWidth();
DWORD GetWidth();
DWORD GetHeight();
WORD GetNumColors();
BOOL WriteBMP(LPCTSTR bmpFileName);
private:
void FreeResources();
DWORD GetPaletteSize();
DWORD GetSize();
RGBQUAD RGB2RGBQUAD(COLORREF cr);
HDIB m_hDib;
BITMAPINFOHEADER m_bi;
DWORD m_dwLineWidth;
WORD m_wColors;
HBITMAP m_hBitmap; // Handle to bitmap
HDC m_hMemDC; // Handle to memory DC
LPVOID m_lpBits; // Pointer to actual bitmap bits
};
#endif
| [
"[email protected]"
]
| [
[
[
1,
103
]
]
]
|
27203284469df29c3189e6b563346ac8dbf4fd33 | e5ded38277ec6db30ef7721a9f6f5757924e130e | /Cpp/SoSe10/Blatt08.Aufgabe01/stdafx.cpp | 1920f22b50fcc19461896c593a753f2ca1ca7f62 | []
| no_license | TetsuoCologne/sose10 | 67986c8a014c4bdef19dc52e0e71e91602600aa0 | 67505537b0eec497d474bd2d28621e36e8858307 | refs/heads/master | 2020-05-27T04:36:02.620546 | 2010-06-22T20:47:08 | 2010-06-22T20:47:08 | 32,480,813 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 304 | cpp | // stdafx.cpp : source file that includes just the standard includes
// Blatt08.Aufgabe01.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| [
"[email protected]@f2f8bf26-27bb-74d3-be08-1e18597623ec"
]
| [
[
[
1,
8
]
]
]
|
f990f42db50e8badb605cdceacb9261745f5497a | f0c08b3ddefc91f1fa342f637b0e947a9a892556 | /branches/develop/calcioIA/GlutApp/Application.cpp | b34bd64d21b3def1439cae40f510410b72a567c4 | []
| no_license | BackupTheBerlios/coffeestore-svn | 1db0f60ddb85ccbbdfeb9b3271a687b23e29fc8f | ddee83284fe9875bf0d04e6b7da7a2113e85a040 | refs/heads/master | 2021-01-01T05:30:22.345767 | 2009-10-11T08:55:35 | 2009-10-11T08:55:35 | 40,725,038 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,397 | cpp | #include "Application.h"
#include "GlutLoggerWriter.h"
#include <Point.h>
#include <cstdlib>
#include <cassert>
#include <GL/glut.h>
Application* Application::_instance = NULL;
Application::Application(int width, int height)
: _width(width), _height(height)
{
_instance = this;
Logger::setWriter(_loggerWriter);
}
Application::~Application()
{
}
void Application::initialize(int argc, char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowSize(_width, _height);
glutCreateWindow(title().c_str());
glClearColor(0.0f, 0.7f, 0.0f, 0.0f);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glutKeyboardFunc(_keyboard);
glutSpecialFunc(_special);
glutSpecialUpFunc(_specialUp);
glutIdleFunc(_idle);
glutDisplayFunc(_display);
glutMainLoop();
}
void Application::specialKeyUp(SpecialKey specialKey)
{
}
void Application::specialKeyDown(SpecialKey specialKey)
{
}
std::string Application::title() const
{
return "Application";
}
int Application::width() const
{
return _width;
}
int Application::height() const
{
return _height;
}
void Application::_idle()
{
glutPostRedisplay();
}
void Application::_display()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-110.0f,110,-110.0f,110.0f);
glDisable(GL_LIGHT0);
glDisable(GL_LIGHTING);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
_instance->update();
_instance->display();
_instance->_loggerWriter.flush(*_instance);
assert(glGetError() == GL_NO_ERROR);
glutSwapBuffers();
glFlush();
}
void Application::_keyboard(unsigned char key, int x, int y)
{
_instance->keyboard(key);
}
void Application::_special(int key, int x, int y)
{
switch (key)
{
case GLUT_KEY_LEFT:
_instance->specialKeyDown(SpecialKey_Left);
break;
case GLUT_KEY_RIGHT:
_instance->specialKeyDown(SpecialKey_Right);
break;
case GLUT_KEY_DOWN:
_instance->specialKeyDown(SpecialKey_Down);
break;
case GLUT_KEY_UP:
_instance->specialKeyDown(SpecialKey_Up);
break;
default:
break;
}
}
void Application::_specialUp(int key, int x, int y)
{
switch (key)
{
case GLUT_KEY_LEFT:
_instance->specialKeyUp(SpecialKey_Left);
break;
case GLUT_KEY_RIGHT:
_instance->specialKeyUp(SpecialKey_Right);
break;
case GLUT_KEY_DOWN:
_instance->specialKeyUp(SpecialKey_Down);
break;
case GLUT_KEY_UP:
_instance->specialKeyUp(SpecialKey_Up);
break;
default:
break;
}
}
void Application::writeString(const Point& position, const std::string& str) const
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0, _width, 0, _height);
void* font = GLUT_BITMAP_HELVETICA_12;
float x = position.x();
glPushAttrib(GL_COLOR_BUFFER_BIT);
glColor3f(0.0f, 0.0f, 0.0f);
for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)
{
glRasterPos3f(x, _height - position.y(), 1.0f);
glutBitmapCharacter(font, *it);
x += glutBitmapWidth(font, *it);
}
glPopAttrib();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}
| [
"fabioppp@e591b805-c13a-0410-8b2d-a75de64125fb"
]
| [
[
[
1,
170
]
]
]
|
a7df2f001c1056183c160159673ad8fea81af938 | 5563be0561e6271b7b2a6bf39a87bfa630885504 | /include/falcon/comm/FalconCommFTD2XX.h | d0790ae6dcc523a80b008b1d0f7c51c61203573f | []
| no_license | nia11/libnifalcon | d84176eb0b707f799f30f31728c6791035ecb60a | 2e4a36468bbeb7b235632437a0e6e985461dcdca | refs/heads/master | 2020-12-25T00:55:13.119968 | 2009-06-23T07:13:50 | 2009-06-23T07:13:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,383 | h | /***
* @file FalconCommFTD2XX.h
* @brief FTD2XX (http://www.ftdichip.com) based implementation of FTDI communication for the falcon
* @author Kyle Machulis ([email protected])
* @copyright (c) 2007-2009 Nonpolynomial Labs/Kyle Machulis
* @license BSD License
*
* Project info at http://libnifalcon.sourceforge.net/
*
*/
#ifndef FALCONFTD2XXCOMM_H
#define FALCONFTD2XXCOMM_H
#include "falcon/core/FalconComm.h"
namespace libnifalcon
{
class FalconCommFTD2XX : public FalconComm
{
public:
FalconCommFTD2XX() { m_requiresPoll = true; }
virtual ~FalconCommFTD2XX();
virtual bool getDeviceCount(unsigned int& );
virtual void poll();
virtual bool open(unsigned int );
virtual bool close();
virtual bool read(uint8_t*, unsigned int);
virtual bool write(uint8_t*, unsigned int);
virtual bool readBlocking(uint8_t*, unsigned int); //{ return read(size, buffer); }
virtual bool writeBlocking(uint8_t* buffer, unsigned int size) { return write(buffer, size); }
virtual bool setFirmwareMode();
virtual bool setNormalMode();
protected:
const static char* FALCON_DESCRIPTION;
int8_t openDeviceFTD2XX(unsigned int , bool );
//This would usually be a FT_HANDLE, but FT_HANDLE
//is just a void*, so this saves us having to deal
//with the include at this level.
void* m_falconDevice;
};
};
#endif
| [
"qdot@afroken.(none)",
"[email protected]"
]
| [
[
[
1,
4
],
[
6,
7
],
[
9,
23
],
[
25,
25
],
[
27,
27
],
[
32,
35
],
[
37,
44
]
],
[
[
5,
5
],
[
8,
8
],
[
24,
24
],
[
26,
26
],
[
28,
31
],
[
36,
36
]
]
]
|
1452ceeab20b57f939546e4e5deb4505115b8400 | 9907be749dc7553f97c9e51c5f35e69f55bd02c0 | /april5/framework code & project/image_file.h | b33c1392107fac55808355611c225696eb48777b | []
| no_license | jdeering/csci476winthrop | bc8907b9cc0406826de76aca05e6758810377813 | 2bc485781f819c8fd82393ac86de33404e7ad6d3 | refs/heads/master | 2021-01-10T19:53:14.853438 | 2009-04-24T14:26:36 | 2009-04-24T14:26:36 | 32,223,762 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,819 | h | /*
Jason Deering
image_file.h
This class is for use in the Framework.
It requires Allegro header files included for the BITMAP struct.
The ImageFile class controls the information for each bitmap file that may be displayed
by the Framework and is used to provide sprites with their current frame to draw.
DATA ITEMS
std::string filePath - the path to the associated bitmap file
int frameWidth - width of one frame of animation in the file
int frameHeight - height of one frame of animation in the file
int numFrames - number of frames of animation provided in the bitmap file
int numCols - max number of columns of frames in the bitmap file
BITMAP *img - pointer to the BITMAP struct loaded from the associated bitmap file
FUNCTIONS
BITMAP* GetFrame(int frameNum, int width, int height) - returns a BITMAP pointer that contains
the specified frame of animation at a stretched or condensed size of width and height specified
int GetNumFrames() - returns the number of frames for animation
int GetNumCols() - returns the number of columns of frames
int GetWidth() - returns the width of a frame of animation
int GetHeight() - returns the height of a frame of animation
bool isValid() - returns true if the BITMAP pointer is valid and able to be referenced
*/
#ifndef _IMAGE_FILE_H
#define _IMAGE_FILE_H
#include "allegro.h"
#include <string>
class ImageFile
{
private:
std::string filePath;
int frameWidth, frameHeight;
int numFrames, numCols;
BITMAP *img;
public:
ImageFile();
~ImageFile();
ImageFile(std::string filePath, int frame_count, int col_count, int w, int h);
BITMAP* GetFrame(int frameNum, int width, int height);
int GetNumFrames();
int GetNumCols();
int GetWidth();
int GetHeight();
bool isValid();
};
#endif | [
"lcairco@2656ef14-ecf4-11dd-8fb1-9960f2a117f8",
"deeringj2@2656ef14-ecf4-11dd-8fb1-9960f2a117f8"
]
| [
[
[
1,
34
],
[
36,
59
]
],
[
[
35,
35
]
]
]
|
da183d1976fc34b202a865b5f94cdacddb134a22 | faaac39c2cc373003406ab2ac4f5363de07a6aae | / zenithprime/inc/controller/BattleBoard/BBStateEnemyShip.h | 2c402c979af4285f61888501deec31e28a2573ec | []
| no_license | mgq812/zenithprime | 595625f2ec86879eb5d0df4613ba41a10e3158c0 | 3c8ff4a46fb8837e13773e45f23974943a467a6f | refs/heads/master | 2021-01-20T06:57:05.754430 | 2011-02-05T17:20:19 | 2011-02-05T17:20:19 | 32,297,284 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 522 | h | #ifndef BBSTATEENEMYSHIP_H
#define BBSTATEENEMYSHIP_H
#include <string>
#include "BBState.h"
class BBStateEnemyShip : public BBState
{
public:
virtual BBState* LClickNothing(BBModel* model);
virtual BBState* LClickEnemy(BBModel* model, BBPlayerModel* player, BBShipModel* ship);
virtual BBState* LClickShip(BBModel* model, BBShipModel* ship);
virtual BBState* RClickValidMove(BBModel* model);
virtual BBState* RClickBadMove(BBModel* model);
virtual string toString();
private:
};
#endif | [
"ElderGrimes@2c223db4-e1a0-a0c7-f360-d8b483a75394"
]
| [
[
[
1,
23
]
]
]
|
394affb5e77b7df3ffe118bc630560de5962c457 | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/mw/classicui/uifw/apps/S60_SDK3.0/bctestlist/inc/bctestlistbasecase.h | 151ea76da81eb695d8927eda789ad499cc7fd1e3 | []
| no_license | SymbianSource/oss.FCL.sftools.ana.compatanamdw | a6a8abf9ef7ad71021d43b7f2b2076b504d4445e | 1169475bbf82ebb763de36686d144336fcf9d93b | refs/heads/master | 2020-12-24T12:29:44.646072 | 2010-11-11T14:03:20 | 2010-11-11T14:03:20 | 72,994,432 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,233 | h | /*
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: base test case for various list classes
*
*/
#ifndef C_BCTESTLISTBASECASE_H
#define C_BCTESTLISTBASECASE_H
#include "bctestcase.h"
class CBCTestListContainer;
class CEikListBox;
class CEikTextListBox;
class CEikColumnListBox;
class CEikFormattedCellListBox;
class CTextListBoxModel;
class CEikonEnv;
class CGulIcon;
const TInt KBCTestListInitListResourceId = 0;
const TInt KBCTestListInitEmptyResourceId = 0;
const TInt KBCTestListMessageInitId = 0;
const TInt KBCTestListAddInitCount = 0;
const TInt KBCTestListRemoveInitCount = 0;
const TInt KBCTestListGraphicGulIconIndex = 10;
const TInt KBCTestListDefaultFlag = 0;
_LIT(KAvkonMbmFileName, "\\resource\\apps\\avkon2.mbm");
_LIT(KBCTestListMbmFileName, "\\resource\\apps\\bctestlist.mbm");
//Define .mif file for .svg icons
_LIT(KBCTestListMifFileName, "\\resource\\apps\\bctestlist.mif");
/**
* list base case class
*/
class CBCTestListBaseCase: public CBCTestCase
{
public:
// constructor and destructor
CBCTestListBaseCase( CBCTestListContainer* iContainer,
CEikonEnv* aEikEnv = NULL );
~CBCTestListBaseCase();
// new functions
/**
* Sets listbox from resource using ConstructFromResourceL() of
* CEikColumnListBox class.
* @param aListBox Pointer of listbox.
* @param aResourceId Resource ID of listbox.
*/
void SetListBoxFromResourceL( CEikColumnListBox* aListBox,
const TInt aResourceId );
/**
* Sets listbox from resource using ConstructFromResourceL() of
* CEikFormattedCellListBox class.
* @param aListBox Pointer of listbox.
* @param aResourceId Resource ID of listbox.
*/
void SetListBoxFromResourceL( CEikFormattedCellListBox* aListBox,
const TInt aResourceId );
/**
* Sets listbox from inner description using ConstructL() of
* CEikColumnListBox class.
* @param aListBox Pointer of listbox.
* @param aFlags Flags of listbox.
* @param textArray List items as CDesCArray.
*/
void SetListBoxFromInnerDescriptionL(
CEikColumnListBox* aListBox,
const TInt aFlags = KBCTestListDefaultFlag,
CDesCArray* textArray = NULL );
/**
* Sets listbox from inner description using ConstructL() of
* CEikFormattedCellListBox class.
* @param aListBox Pointer of listbox.
* @param aFlags Flags of listbox.
* @param textArray List items as CDesCArray.
*/
void SetListBoxFromInnerDescriptionL(
CEikFormattedCellListBox* aListBox,
const TInt aFlags = KBCTestListDefaultFlag,
CDesCArray* textArray = NULL );
/**
* Sets graphic icon using listbox as CEikColumnListBox.
* @param aListBox Pointer of listbox.
*/
void SetGraphicIconL( CEikColumnListBox* aListBox );
/**
* Sets graphic icon using listbox as CEikFormattedCellListBox.
* @param aListBox Pointer of listbox.
*/
void SetGraphicIconL( CEikFormattedCellListBox* aListBox );
/**
* Creates the icon and adds it to the array if it was successful
*/
void CreateIconAndAddToArrayL( CArrayPtr<CGulIcon>*& aIconsArray,
const TDesC& aIconFile,
TInt aBitmap, TInt aMask = -1);
private: // New Function
/**
* Appends graphics data.
* @param Pointer of icon using graphics for listbox.
*/
virtual void GraphicIconL( CArrayPtr<CGulIcon>* aIcons );
protected: // data
CBCTestListContainer* iContainer; // not own
CEikonEnv* iEikEnv; // not own
TInt iOutlineId;
};
#endif // C_BCTESTLISTBASECASE_H | [
"none@none"
]
| [
[
[
1,
139
]
]
]
|
8973b4d7fc663bae5e751dc90e599df152f08515 | da9b11cab53e4771eaa6c0d2c885e4331580b2f3 | /src/timer.cpp | 87123b5ca324b684ed216e4d8f65edebb98b6bc1 | []
| no_license | ud1/dhtpp | 305913dea8f3c65d52bdb872aa6f26f5aca7a9a6 | 016aa4e0b628f92614e9a38e90461cea8bc4df78 | refs/heads/master | 2021-01-13T16:44:30.537380 | 2010-05-31T22:22:55 | 2010-05-31T22:22:55 | 77,243,109 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 123 | cpp | #include "timer.h"
namespace dhtpp {
Ctimer *GetTimerInstance() {
static Ctimer timer;
return &timer;
}
}
| [
"[email protected]"
]
| [
[
[
1,
9
]
]
]
|
d3452490dd30909b4ba0852a6423f1e7e81638c2 | 8ffc2ad8cf32ffd9ba2974ee9bb4ae36de90a860 | /SIFTCustom/src/VectorCustom.h | 23d4d2f43cfb68f9bdcb155c63cd50e99bd8c173 | []
| no_license | mhlee1215/sift-custom | ca40895d3b3ba6e3e2c6b45947e21a4e07a5270e | ec3910e172eae4bafa6e21952e058f6875362569 | refs/heads/master | 2016-09-06T10:54:10.910652 | 2010-06-10T08:52:48 | 2010-06-10T08:52:48 | 33,061,761 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 364 | h | /*
* VectorCustom.h
*
* Created on: 2010. 5. 26.
* Author: hp
*/
#ifndef VECTORCUSTOM_H_
#define VECTORCUSTOM_H_
using namespace std;
#include "CvPointCustom.h"
#include <vector>
class VectorCustom
{
private:
vector<CvPointCustom> points;
public:
VectorCustom();
virtual ~VectorCustom();
};
#endif /* VECTORCUSTOM_H_ */
| [
"mhlee1215@6231343e-7b99-2e4e-8751-d345bb62f328"
]
| [
[
[
1,
25
]
]
]
|
0aa727f1c6a5c6a5e5fd494c60864497ae075976 | 998c99766794d0740cd36a1bfb3da52cfd152671 | /TcpServerNonBlock.h | c81d6112d910d92aecbb44953e480d80e16203a9 | []
| no_license | shachar-b/computer-networking-101-tcp-server | 04dabf6448637b92f988b880c6731eddd1a09bba | 05d6e5ea33493087a6dd363045def3d9eaeef51b | refs/heads/master | 2021-01-10T04:15:35.181511 | 2011-01-02T00:22:30 | 2011-01-02T00:22:30 | 48,319,895 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,369 | h | #define _CRT_SECURE_NO_WARNINGS //Suppress warnings on strcpy,ctime,itoa etc...
#include <iostream>
using namespace std;
// Don't forget to include "Ws2_32.lib" in the library list.
#include <fstream>
#include <winsock2.h>
#include <string.h>
#include <vector>
#include "utilityFunctions.h"
#pragma comment(lib, "Ws2_32.lib")
#define CRLF "\r\n"
#define DEBUG_OUTGOING_MESSAGE 0 //Use these to see content of messages sent
#define DEBUG_INCOMING_MESSAGE 0 //or received.
#define FAIL -1
#define TIMEOUT 0
//Consts
const int LISTEN_PORT = 80;
const int MAX_SOCKETS = 60;
const int EMPTY = 0;
const int LISTEN = 1;
const int RECEIVE = 2;
const int IDLE = 3;
const int SEND = 4;
//Services
const int SEND_TIME = 1;
const int SEND_SECONDS = 2;
enum eReqType {GET, HEAD, PUT, DELETE_REQ,OK=200,BAD_REQUEST=400,Forbidden=403,Not_Found=404,Request_Too_Large=413,Internal_Server_Error=500,NOT_IMPLEMENTED=501};
//Structs
struct header{
string name;
string val;
};
struct request
{
eReqType methodType;
string uri;//path
int http_version_major;
int http_version_minor;
vector<header> headers;
string body;
};
struct SocketState
{
SOCKET id; // Socket handle
int recv; // Receiving?
int send; // Sending?
int sendSubType; // Sending sub-type
char buffer[4096]; //4k
string recvBuffer;
string sendBuffer;
int len;
};
//Function declarations
void initWinsock();
SOCKET setupSocket();
bool closeWinsock(SOCKET listenSocket);
bool addSocket(SOCKET id, int what);
void removeSocket(int index);
void acceptConnection(int index);
void receiveMessage(int index);
void sendMessage(int index);
void readHeaders(char * & buffer,request & req);
void readBody(char * & buffer,request & req);
request makeNewReq();
int ParseHTTPMessage(char * buffer, request & reqinfo);
int makeresponse(request & reqinfo, string &sendbuffer);
void writeDateHeader(string & response);
void writeContentLengthHeader(string & response, int contentLength);
string ReqToString (eReqType methodType);
int actOnRequest(request & reqinfo);
void getFile(request & reqinfo);
void putFile(request & reqinfo);
void deleteFile(request & reqinfo);
bool operator==(const string& str,const char * str2);
void CleanURI(string & uri);
//Globals
struct SocketState sockets[MAX_SOCKETS]={0};
int socketsCount = 0; | [
"darklinger@a149d1aa-10a4-bf9f-5acb-b7c8e26e06d8",
"blame.me@a149d1aa-10a4-bf9f-5acb-b7c8e26e06d8"
]
| [
[
[
1,
53
],
[
55,
71
],
[
73,
85
]
],
[
[
54,
54
],
[
72,
72
]
]
]
|
6f5ce4d2f284363f0fe24b1ad4f30a76b0bb9779 | d9a78f212155bb978f5ac27d30eb0489bca87c3f | /PB/src/PbFt/ftdefs.h | 818b5c601b986e8abf53f064a03c80c2bd4e3333 | []
| no_license | marchon/pokerbridge | 1ed4a6a521f8644dcd0b6ec66a1ac46879b8473c | 97d42ef318bf08f3bc0c0cb1d95bd31eb2a3a8a9 | refs/heads/master | 2021-01-10T07:15:26.496252 | 2010-05-17T20:01:29 | 2010-05-17T20:01:29 | 36,398,892 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 216 | h | #pragma once
typedef QString FTTableId;
typedef QString FTHandId;
class FTTable;
class FTHero;
class FTLobby;
class FTTables;
class PBHandInfo;
#define ftSngLobbyModel "CBrowseSitAndGoLobbyProxyModel" | [
"[email protected]"
]
| [
[
[
1,
13
]
]
]
|
534b0848a0e5eae32616e74e709e1c68607e76a3 | b2d46af9c6152323ce240374afc998c1574db71f | /cursovideojuegos/theflostiproject/3rdParty/boost/libs/lambda/test/bind_tests_simple.cpp | 7f3c3cdcb7c554d0e04b5dadaeb24ba0c720eba5 | []
| 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 | ISO-8859-1 | C++ | false | false | 6,966 | cpp | // bind_tests_simple.cpp -- The Boost Lambda Library ------------------
//
// Copyright (C) 2000-2003 Jaakko Järvi ([email protected])
// Copyright (C) 2000-2003 Gary Powell ([email protected])
//
// 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)
//
// For more information, see www.boost.org
// -----------------------------------------------------------------------
#include <boost/test/minimal.hpp> // see "Header Implementation Option"
#include "boost/lambda/bind.hpp"
#include <iostream>
using namespace std;
using namespace boost::lambda;
int sum_of_args_0() { return 0; }
int sum_of_args_1(int a) { return a; }
int sum_of_args_2(int a, int b) { return a+b; }
int sum_of_args_3(int a, int b, int c) { return a+b+c; }
int sum_of_args_4(int a, int b, int c, int d) { return a+b+c+d; }
int sum_of_args_5(int a, int b, int c, int d, int e) { return a+b+c+d+e; }
int sum_of_args_6(int a, int b, int c, int d, int e, int f) { return a+b+c+d+e+f; }
int sum_of_args_7(int a, int b, int c, int d, int e, int f, int g) { return a+b+c+d+e+f+g; }
int sum_of_args_8(int a, int b, int c, int d, int e, int f, int g, int h) { return a+b+c+d+e+f+g+h; }
int sum_of_args_9(int a, int b, int c, int d, int e, int f, int g, int h, int i) { return a+b+c+d+e+f+g+h+i; }
// ----------------------------
class A {
int i;
public:
A(int n) : i(n) {};
int add(const int& j) { return i + j; }
int add2(int a1, int a2) { return i + a1 + a2; }
int add3(int a1, int a2, int a3) { return i + a1 + a2 + a3; }
int add4(int a1, int a2, int a3, int a4) { return i + a1 + a2 + a3 + a4; }
int add5(int a1, int a2, int a3, int a4, int a5)
{ return i + a1 + a2 + a3 + a4 + a5; }
int add6(int a1, int a2, int a3, int a4, int a5, int a6)
{ return i + a1 + a2 + a3 + a4 + a5 + a6; }
int add7(int a1, int a2, int a3, int a4, int a5, int a6, int a7)
{ return i + a1 + a2 + a3 + a4 + a5 + a6 + a7; }
int add8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8)
{ return i + a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8; }
};
void test_member_functions()
{
using boost::ref;
A a(10);
int i = 1;
BOOST_TEST(bind(&A::add, ref(a), _1)(i) == 11);
BOOST_TEST(bind(&A::add, &a, _1)(i) == 11);
BOOST_TEST(bind(&A::add, _1, 1)(a) == 11);
BOOST_TEST(bind(&A::add, _1, 1)(make_const(&a)) == 11);
BOOST_TEST(bind(&A::add2, _1, 1, 1)(a) == 12);
BOOST_TEST(bind(&A::add3, _1, 1, 1, 1)(a) == 13);
BOOST_TEST(bind(&A::add4, _1, 1, 1, 1, 1)(a) == 14);
BOOST_TEST(bind(&A::add5, _1, 1, 1, 1, 1, 1)(a) == 15);
BOOST_TEST(bind(&A::add6, _1, 1, 1, 1, 1, 1, 1)(a) == 16);
BOOST_TEST(bind(&A::add7, _1, 1, 1, 1, 1, 1, 1, 1)(a) == 17);
BOOST_TEST(bind(&A::add8, _1, 1, 1, 1, 1, 1, 1, 1, 1)(a) == 18);
// This should fail, as lambda functors store arguments as const
// bind(&A::add, a, _1);
}
int test_main(int, char *[]) {
int i = 1; int j = 2; int k = 3;
int result;
// bind all parameters
BOOST_TEST(bind(&sum_of_args_0)()==0);
BOOST_TEST(bind(&sum_of_args_1, 1)()==1);
BOOST_TEST(bind(&sum_of_args_2, 1, 2)()==3);
BOOST_TEST(bind(&sum_of_args_3, 1, 2, 3)()==6);
BOOST_TEST(bind(&sum_of_args_4, 1, 2, 3, 4)()==10);
BOOST_TEST(bind(&sum_of_args_5, 1, 2, 3, 4, 5)()==15);
BOOST_TEST(bind(&sum_of_args_6, 1, 2, 3, 4, 5, 6)()==21);
BOOST_TEST(bind(&sum_of_args_7, 1, 2, 3, 4, 5, 6, 7)()==28);
BOOST_TEST(bind(&sum_of_args_8, 1, 2, 3, 4, 5, 6, 7, 8)()==36);
BOOST_TEST(bind(&sum_of_args_9, 1, 2, 3, 4, 5, 6, 7, 8, 9)()==45);
// first parameter open
BOOST_TEST(bind(&sum_of_args_0)()==0);
BOOST_TEST(bind(&sum_of_args_1, _1)(i)==1);
BOOST_TEST(bind(&sum_of_args_2, _1, 2)(i)==3);
BOOST_TEST(bind(&sum_of_args_3, _1, 2, 3)(i)==6);
BOOST_TEST(bind(&sum_of_args_4, _1, 2, 3, 4)(i)==10);
BOOST_TEST(bind(&sum_of_args_5, _1, 2, 3, 4, 5)(i)==15);
BOOST_TEST(bind(&sum_of_args_6, _1, 2, 3, 4, 5, 6)(i)==21);
BOOST_TEST(bind(&sum_of_args_7, _1, 2, 3, 4, 5, 6, 7)(i)==28);
BOOST_TEST(bind(&sum_of_args_8, _1, 2, 3, 4, 5, 6, 7, 8)(i)==36);
BOOST_TEST(bind(&sum_of_args_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i)==45);
// two open arguments
BOOST_TEST(bind(&sum_of_args_0)()==0);
BOOST_TEST(bind(&sum_of_args_1, _1)(i)==1);
BOOST_TEST(bind(&sum_of_args_2, _1, _2)(i, j)==3);
BOOST_TEST(bind(&sum_of_args_3, _1, _2, 3)(i, j)==6);
BOOST_TEST(bind(&sum_of_args_4, _1, _2, 3, 4)(i, j)==10);
BOOST_TEST(bind(&sum_of_args_5, _1, _2, 3, 4, 5)(i, j)==15);
BOOST_TEST(bind(&sum_of_args_6, _1, _2, 3, 4, 5, 6)(i, j)==21);
BOOST_TEST(bind(&sum_of_args_7, _1, _2, 3, 4, 5, 6, 7)(i, j)==28);
BOOST_TEST(bind(&sum_of_args_8, _1, _2, 3, 4, 5, 6, 7, 8)(i, j)==36);
BOOST_TEST(bind(&sum_of_args_9, _1, _2, 3, 4, 5, 6, 7, 8, 9)(i, j)==45);
// three open arguments
BOOST_TEST(bind(&sum_of_args_0)()==0);
BOOST_TEST(bind(&sum_of_args_1, _1)(i)==1);
BOOST_TEST(bind(&sum_of_args_2, _1, _2)(i, j)==3);
BOOST_TEST(bind(&sum_of_args_3, _1, _2, _3)(i, j, k)==6);
BOOST_TEST(bind(&sum_of_args_4, _1, _2, _3, 4)(i, j, k)==10);
BOOST_TEST(bind(&sum_of_args_5, _1, _2, _3, 4, 5)(i, j, k)==15);
BOOST_TEST(bind(&sum_of_args_6, _1, _2, _3, 4, 5, 6)(i, j, k)==21);
BOOST_TEST(bind(&sum_of_args_7, _1, _2, _3, 4, 5, 6, 7)(i, j, k)==28);
BOOST_TEST(bind(&sum_of_args_8, _1, _2, _3, 4, 5, 6, 7, 8)(i, j, k)==36);
BOOST_TEST(bind(&sum_of_args_9, _1, _2, _3, 4, 5, 6, 7, 8, 9)(i, j, k)==45);
// function compositions with bind
BOOST_TEST(bind(&sum_of_args_3, bind(&sum_of_args_2, _1, 2), 2, 3)(i)==8);
BOOST_TEST(
bind(&sum_of_args_9,
bind(&sum_of_args_0), // 0
bind(&sum_of_args_1, _1), // 1
bind(&sum_of_args_2, _1, _2), // 3
bind(&sum_of_args_3, _1, _2, _3), // 6
bind(&sum_of_args_4, _1, _2, _3, 4), // 10
bind(&sum_of_args_5, _1, _2, _3, 4, 5), // 15
bind(&sum_of_args_6, _1, _2, _3, 4, 5, 6), // 21
bind(&sum_of_args_7, _1, _2, _3, 4, 5, 6, 7), // 28
bind(&sum_of_args_8, _1, _2, _3, 4, 5, 6, 7, 8) // 36
)(i, j, k) == 120);
// deeper nesting
result =
bind(&sum_of_args_1, // 12
bind(&sum_of_args_4, // 12
bind(&sum_of_args_2, // 3
bind(&sum_of_args_1, // 1
bind(&sum_of_args_1, _1) // 1
),
_2),
_2,
_3,
4)
)(i, j, k);
BOOST_TEST(result == 12);
test_member_functions();
return 0;
}
| [
"ohernandezba@71d53fa2-cca5-e1f2-4b5e-677cbd06613a"
]
| [
[
[
1,
172
]
]
]
|
b92c08aaf1273a62e9ebc881ad04f47d9f9983da | 586d729da30e04cd561605ec321ff835d95d7e01 | /Reseau/tp-Serveur/debug/moc_client.cpp | 0a77f7f44b488ec72ca9e79200dc31c46f769b30 | []
| no_license | coralie-saysset/insaLyon | f2b2fae17e68407348eb4d6e590a164f2f5d6f24 | ad6e6dc7ec09b1b5494328113fde799e4b846a9e | refs/heads/master | 2021-01-10T19:38:10.830958 | 2011-12-12T02:59:52 | 2011-12-12T02:59:52 | 2,747,230 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,613 | cpp | /****************************************************************************
** Meta object code from reading C++ file 'client.h'
**
** Created: Tue 29. Nov 17:14:16 2011
** by: The Qt Meta Object Compiler version 61 (Qt 4.5.1)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../client.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'client.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 61
#error "This file was generated using the moc from 4.5.1. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_Client[] = {
// content:
2, // revision
0, // classname
0, 0, // classinfo
4, 12, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
// signals: signature, parameters, type, tag, flags
8, 7, 7, 7, 0x05,
// slots: signature, parameters, type, tag, flags
34, 26, 7, 7, 0x09,
60, 7, 7, 7, 0x09,
74, 7, 7, 7, 0x09,
0 // eod
};
static const char qt_meta_stringdata_Client[] = {
"Client\0\0requeteComplete()\0message\0"
"demandeClient(QByteArray)\0requeteRecu()\0"
"traiterRequete()\0"
};
const QMetaObject Client::staticMetaObject = {
{ &QObject::staticMetaObject, qt_meta_stringdata_Client,
qt_meta_data_Client, 0 }
};
const QMetaObject *Client::metaObject() const
{
return &staticMetaObject;
}
void *Client::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_Client))
return static_cast<void*>(const_cast< Client*>(this));
return QObject::qt_metacast(_clname);
}
int Client::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QObject::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: requeteComplete(); break;
case 1: demandeClient((*reinterpret_cast< QByteArray(*)>(_a[1]))); break;
case 2: requeteRecu(); break;
case 3: traiterRequete(); break;
default: ;
}
_id -= 4;
}
return _id;
}
// SIGNAL 0
void Client::requeteComplete()
{
QMetaObject::activate(this, &staticMetaObject, 0, 0);
}
QT_END_MOC_NAMESPACE
| [
"[email protected]"
]
| [
[
[
1,
89
]
]
]
|
7b9373a83fac8417b6a4560ca96fb6b5fb7e6564 | 36bf908bb8423598bda91bd63c4bcbc02db67a9d | /Include/COptionsTree.h | c5147bcc65670c9f1d463d0bf7df4a720855a1bf | []
| no_license | code4bones/crawlpaper | edbae18a8b099814a1eed5453607a2d66142b496 | f218be1947a9791b2438b438362bc66c0a505f99 | refs/heads/master | 2021-01-10T13:11:23.176481 | 2011-04-14T11:04:17 | 2011-04-14T11:04:17 | 44,686,513 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 691 | h | #ifndef _COPTIONSTREE_H
#define _COPTIONSTREE_H 1
#include "window.h"
class COptionsTree : public CTreeCtrl
{
public:
COptionsTree();
virtual ~COptionsTree() {}
BOOL AddControl(HTREEITEM hItem,CWnd* pWnd,UINT nId = (UINT)-1);
BOOL UpdateControl(HTREEITEM hItem,UINT nId,BOOL bFlag);
BOOL SetItemData(HTREEITEM hItem,DWORD dwData);
DWORD GetItemData(HTREEITEM hItem) const;
void SetCallback(HWND hWnd,UINT nMessage);
protected:
void OnSelchanged(NMHDR* pNMHDR,LRESULT* pResult);
void OnDestroy(void);
void OnDeleteItem(NMHDR* pNMHDR,LRESULT* pResult);
private:
HWND m_hWnd;
UINT m_nMessage;
DECLARE_MESSAGE_MAP()
};
#endif // _COPTIONSTREE_H
| [
"[email protected]"
]
| [
[
[
1,
30
]
]
]
|
4c38c70a48913acb80985ef1a47c4317ecdb7e6a | 27d5670a7739a866c3ad97a71c0fc9334f6875f2 | /CPP/Targets/MapLib/Shared/src/PositionInterpolator.cpp | 4153bb0b07ca53f3089aee6c0e9af76df94ec905 | [
"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 | 20,332 | cpp | /*
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.
*/
#include "config.h"
#include "PositionInterpolator.h"
#include "GfxUtility.h"
#include <algorithm>
#include "Utility.h"
#include "GfxConstants.h"
#include <math.h>
#include "PositionInterpolatorMath.h"
inline float64 getCosLat( int32 lat )
{
static const float64 mc2scaletoradians = 1.0 / (11930464.7111*
180.0/3.14159265358979323846);
return cos( mc2scaletoradians * lat );
}
PositionInterpolator::PositionInterpolator()
{
m_convertFromMC2 = true;
m_angleLookAheadTimeMillis = 700;
m_debugVals.curConfig = 0;
m_debugVals.deltaMeters = -1.0;
m_debugVals.deltaCompareAngle = 0.0;
m_debugVals.calcSpeedKMPH = 0.0;
m_debugVals.correctSpeedKMPH = 0.0;
m_startTimeMillis = MAX_INT32;
m_catchUp.allowedCatchUpFactor = 0;
m_debugVals.disableInterpolation = false;
m_numReturnedPositions = 0;
setConfiguration();
}
PositionInterpolator::~PositionInterpolator()
{
}
PositionInterpolator::NodeIterPair
PositionInterpolator::getCurrentNodeIterPair( float64 timeSec ) const
{
NodeVec::const_iterator it = m_data.begin();
NodeVec::const_iterator end = m_data.end();
/**
* We traverse the data set to find the pair of nodes that
* timeSec lies between.
*/
while( it != end && timeSec >= it->nodeTimeSec ) {
it++;
}
if( it == end ) {
/** Then our time is later than that of all the nodes,
* meaning that we do not have a path to interpolate
* on. So we return two iterators both pointing to
* the last element.
*/
NodeIterPair ret;
ret.first = end - 1;
ret.second = end -1;
// return std::make_pair( end - 1, end - 1 );
return ret;
} else {
/**
* We have now found the two nodes that timeSec lies between.
*/
return std::make_pair( it - 1, it );
}
}
float64
PositionInterpolator::getTraversedDistanceAlongPathMeters(
unsigned int timeMillis ) const
{
MC2Coordinate coord = getPosition( timeMillis );
return getTraversedDistanceAlongPathMeters( timeMillis,
coord );
}
float64
PositionInterpolator:: getTraversedDistanceAlongPathMeters(
unsigned int timeMillis,
MC2Coordinate lastPositionCoord ) const
{
NodeIterPair curNodePair = getCurrentNodeIterPair( timeMillis / 1000.0 );
/**
* Start by calculating the length between the last node
* and the last coordinate.
*/
float64 totalDistanceMeters = PositionInterpolatorMath::
getDistanceMeters( curNodePair.first->coord,
lastPositionCoord,
m_convertFromMC2 );
/**
* Three cases for the calculations.
*
* (A)------------(B)
* \
* \
* \
* (C)---x------(D)
*
*/
if( curNodePair.first == m_data.begin() ) {
/**
* At the beginning of the set, i.e. between A and B.
* We have no preceding node and can return the distance
* as the distance between A and the coordinate requested.
*/
return totalDistanceMeters;
} else if ( curNodePair.second == curNodePair.first ) {
/**
* At the end of the set, i.e. past D. Both nodes are
* then set to point at D. Subtract the first node to
* C and then sum length backwards.
*/
curNodePair.first--;
if( curNodePair.first == m_data.begin() ) {
return totalDistanceMeters;
}
} else {
/**
* Between two nodes, i.e. C and D. Subtract both
* iterators to point at B and C and then sum the
* length backwards.
*/
curNodePair.first--;
curNodePair.second--;
}
/**
* Continually sum the path length backwards.
*/
while( true ) {
totalDistanceMeters += PositionInterpolatorMath::
getDistanceMeters( curNodePair.first->coord,
curNodePair.second->coord,
m_convertFromMC2 );
/**
* If we've reached the end, we are done. Otherwise,
* step pairwise backwards again.
*/
if( curNodePair.first == m_data.begin() ) {
break;
} else {
curNodePair.first--;
curNodePair.second--;
}
}
return totalDistanceMeters;
}
PositionInterpolator::NodePair
PositionInterpolator::getCurrentNodePair( float64 timeSec ) const
{
NodeIterPair iterPair = getCurrentNodeIterPair( timeSec );
return std::make_pair( *iterPair.first, *iterPair.second );
}
MC2Coordinate
PositionInterpolator::getPosition( unsigned int timeMillis ) const
{
/**
* If we have no data, then we cannot perform any calculations.
*/
if( m_data.empty() ) {
return MC2Coordinate();
} else if( m_data.size() == 1 ) {
return m_data.back().coord;
}
/**
* Likewise, if we have data but the data is only valid in a
* time interval which our time does not lie within, we cannot
* perform any calculations.
*/
float64 curTimeSec = timeMillis / 1000.0;
if( curTimeSec < m_data.front().nodeTimeSec ) {
return m_data.front().coord;
} else if( curTimeSec > m_data.back().nodeTimeSec ) {
return m_data.back().coord;
}
/**
* First, find the two nodes that the position will lie between.
*/
NodePair nodes = getCurrentNodePair( curTimeSec );
/**
* Then, find out how far along (in meters) the position will lie
* on the path between these nodes.
*/
float64 traversedDistanceMeters = PositionInterpolatorMath::
getTraversedDistanceMeters( curTimeSec,
nodes.first.nodeTimeSec,
nodes.second.nodeTimeSec,
nodes.first.velocityMPS,
nodes.second.velocityMPS );
/**
* Finally, use this data to determine the final position.
*/
return PositionInterpolatorMath::
getInterpolatedPosition( nodes.first.coord,
nodes.second.coord,
traversedDistanceMeters,
m_convertFromMC2 );
}
void PositionInterpolator::disableMC2Conversion()
{
m_convertFromMC2 = false;
}
void PositionInterpolator::prepareNewData( unsigned int startTimeMillis )
{
m_debugVals.deltaCompareCoordinate = getPosition( startTimeMillis );
m_debugVals.deltaCompareAngle = getDirectionDegrees( startTimeMillis );
m_debugVals.calcSpeedKMPH = getVelocityMPS( startTimeMillis ) * 3.6;
/**
* Setup the start position for the catch up phase
*/
if( m_catchUp.allowedCatchUpFactor > 0 ) {
m_catchUp.startPosition = peekInterpolatedPosition( startTimeMillis );
}
m_data.clear();
m_dataPeriodMillis.updatePeriod( startTimeMillis );
m_startTimeMillis = startTimeMillis;
}
void PositionInterpolator::addDataPoint( const MC2Coordinate& coord,
int velocityCmPS )
{
InterpolationNode node;
node.coord = coord;
node.velocityMPS = velocityCmPS / 100.0f;
node.nodeTimeSec = -1.0;
m_data.push_back( node );
}
void PositionInterpolator::finalizeNewData()
{
m_numReturnedPositions = 0;
if( m_data.empty() ) {
m_debugVals.deltaMeters = -1.0;
return;
}
m_debugVals.correctSpeedKMPH = ( m_data.front().velocityMPS ) * 3.6;
if( m_debugVals.deltaCompareCoordinate.isValid() &&
m_data.front().coord.isValid() )
{
/**
* Find the angle between the two points.
*/
float64 angleDegrees =
GfxUtility::getAngleFromNorthDegrees(
m_debugVals.deltaCompareCoordinate.lat,
m_debugVals.deltaCompareCoordinate.lon,
m_data.front().coord.lat,
m_data.front().coord.lon,
getCosLat( m_data.front().coord.lat/2 +
m_debugVals.deltaCompareCoordinate.lat / 2 )
);
/**
* Get the closest offset (1-d vector) going from
* angleDegrees -> m_debugVals.deltaCompareAngle
*/
float64 angleDiffDegrees =
PositionInterpolatorMath::getClosestAngleOffset(
angleDegrees, m_debugVals.deltaCompareAngle );
/**
* Find the distance from the simulated position and the
* correct position.
*/
m_debugVals.deltaMeters =
PositionInterpolatorMath::getDistanceMeters(
m_debugVals.deltaCompareCoordinate,
m_data.front().coord,
m_convertFromMC2 );
/**
* If the simulated position was ahead of the correct position,
* negate the sign (since we're going backwards to reach it)
*/
if( angleDiffDegrees > 90 || angleDiffDegrees < -90 ) {
m_debugVals.deltaMeters = -m_debugVals.deltaMeters;
}
}
float64 cumulativeTimeSec = m_startTimeMillis / 1000.0;
/**
* Iterate over the path of nodes and determine the individual
* times of the nodes.
*/
for( unsigned int i = 0; i < m_data.size() - 1; i++ ){
InterpolationNode& n0 = m_data[ i ];
InterpolationNode& n1 = m_data[ i + 1 ];
/**
* Determine the distance between this node and the next.
*/
float64 distanceMeters =
PositionInterpolatorMath::getDistanceMeters( n0.coord,
n1.coord,
m_convertFromMC2 );
/**
* Determine the average velocity of the path.
*/
float64 averageVelocityMPS = ( n0.velocityMPS + n1.velocityMPS ) / 2.0;
/**
* Determine how it will take to traverse the path between
* the nodes.
*/
float64 segmentTimeSec = distanceMeters / averageVelocityMPS;
m_data[ i ].nodeTimeSec = cumulativeTimeSec;
cumulativeTimeSec += segmentTimeSec;
}
m_data.back().nodeTimeSec = cumulativeTimeSec;
/**
* We only want the "Catch up" mechanism if the allowed time to catch
* up is larger than zero, and the new data set has a larger timestamp
* than the previous one. Also, the previous set must also have
* returned a coordinate from getPosition.
*/
if( m_catchUp.allowedCatchUpFactor > 0 &&
m_dataPeriodMillis.isValid() &&
m_catchUp.startPosition.isValid() )
{
initializeCatchUp();
}
}
bool PositionInterpolator::hasUsefulInterpolationData() const
{
bool disable =
m_debugVals.disableInterpolation && m_numReturnedPositions > 0;
return
!m_data.empty() && m_data.size() != 1 &&
!disable;
}
bool PositionInterpolator::withinRange( unsigned int timeMillis ) const
{
float64 curTimeSec = static_cast<float64>( timeMillis ) / 1000.0;
return
curTimeSec >= m_data.front().nodeTimeSec &&
curTimeSec <= m_data.back().nodeTimeSec;
}
bool PositionInterpolator::insideCatchUpPhase( unsigned int timeMillis ) const
{
return m_catchUp.periodMillis.withinPeriod( timeMillis );
}
float64
PositionInterpolator::getDirectionDegrees( unsigned int timeMillis ) const
{
/**
* Look back and ahead to determine two positions that
* we will use to determine the current angle.
*/
unsigned int lookupTimeA =
timeMillis - m_angleLookAheadTimeMillis / 2;
unsigned int lookupTimeB =
timeMillis + m_angleLookAheadTimeMillis / 2;
MC2Coordinate posA = getPosition( lookupTimeA );
MC2Coordinate posB = getPosition( lookupTimeB );
float64 cosLat = getCosLat( ( posA.lat + posB.lat ) / 2 );
float64 resultAngle =
GfxUtility::getAngleFromNorthDegrees( posA.lat, posA.lon,
posB.lat, posB.lon,
cosLat );
return resultAngle;
}
float64
PositionInterpolator::getVelocityMPS( unsigned int timeMillis ) const
{
if( m_data.empty() ) {
return 0.0;
} else if( m_data.size() == 1 ) {
return m_data.back().velocityMPS;
}
float64 curTimeSec = timeMillis / 1000.0;
if( curTimeSec < m_data.front().nodeTimeSec ) {
return m_data.front().velocityMPS;
} else if( curTimeSec > m_data.back().nodeTimeSec ) {
return m_data.back().velocityMPS;
}
NodePair nodes = getCurrentNodePair( curTimeSec );
if ( nodes.first.nodeTimeSec == nodes.second.nodeTimeSec ) {
return nodes.second.velocityMPS;
}
float64 timeDiff = nodes.second.nodeTimeSec - nodes.first.nodeTimeSec;
float64 speedDiff = nodes.second.velocityMPS - nodes.first.velocityMPS;
float64 curRelativePosition =
( curTimeSec - nodes.first.nodeTimeSec ) / timeDiff;
return nodes.first.velocityMPS + curRelativePosition * speedDiff;
}
void PositionInterpolator::setAllowedCatchUpFactor( float64 factor )
{
m_catchUp.allowedCatchUpFactor = factor;
}
float64 PositionInterpolator::getPositionDeltaMeters() const
{
return m_debugVals.deltaMeters;
}
float64 PositionInterpolator::getPrevCorrectSpeedKMPH() const
{
return m_debugVals.correctSpeedKMPH;
}
float64 PositionInterpolator::getPrevCalcSpeedKMPH() const
{
return m_debugVals.calcSpeedKMPH;
}
std::vector<PositionInterpolator::InterpolationNode>
PositionInterpolator::getInterpolationVector() const
{
return m_data;
}
InterpolatedPosition
PositionInterpolator::getInterpolatedPosition( unsigned int timeMillis )
{
m_numReturnedPositions++;
InterpolatedPosition ret;
if( m_debugVals.disableInterpolation ||
!insideCatchUpPhase( timeMillis ) )
{
ret = peekInterpolatedPosition( timeMillis );
} else {
ret = getCatchUpPosition( timeMillis );
}
return ret;
}
InterpolatedPosition
PositionInterpolator::peekInterpolatedPosition( unsigned int timeMillis ) const
{
InterpolatedPosition ret;
ret.coord = getPosition( timeMillis );
ret.velocityMPS = getVelocityMPS( timeMillis );
ret.directionDegrees = getDirectionDegrees( timeMillis );
return ret;
}
InterpolatedPosition
PositionInterpolator::getCatchUpPosition( unsigned int timeMillis )
{
InterpolatedPosition ret;
float64 traversedDistanceMeters =
PositionInterpolatorMath::getTraversedDistanceMeters(
timeMillis / 1000.0,
m_catchUp.periodMillis.start / 1000.0,
m_catchUp.periodMillis.end / 1000.0,
m_catchUp.startPosition.velocityMPS,
m_catchUp.endPosition.velocityMPS );
ret.coord =
PositionInterpolatorMath::getInterpolatedPosition(
m_catchUp.startPosition.coord,
m_catchUp.endPosition.coord,
traversedDistanceMeters,
m_convertFromMC2 );
ret.directionDegrees =
PositionInterpolatorMath::getInterpolatedAngleDegrees(
m_catchUp.startPosition.coord,
m_catchUp.endPosition.coord,
m_catchUp.startPosition.directionDegrees,
m_catchUp.endPosition.directionDegrees,
traversedDistanceMeters,
m_convertFromMC2 );
float normalizedTimeMillis =
m_catchUp.periodMillis.normalizedTime( timeMillis );
ret.velocityMPS =
m_catchUp.startPosition.velocityMPS * ( 1.0 - normalizedTimeMillis ) +
m_catchUp.endPosition.velocityMPS * normalizedTimeMillis;
return ret;
}
void PositionInterpolator::initializeCatchUp()
{
/**
* Initialize the period that the catchup phase will work on.
*/
unsigned int catchUpLengthMillis =
static_cast<unsigned int> ( m_dataPeriodMillis.length() *
m_catchUp.allowedCatchUpFactor );
m_catchUp.periodMillis.updatePeriod( m_dataPeriodMillis.end,
m_dataPeriodMillis.end +
catchUpLengthMillis );
/**
* Initialize the end position of the catchup algorithm.
*/
m_catchUp.endPosition =
peekInterpolatedPosition( m_catchUp.periodMillis.end );
/**
* Get the distance in meters between the start and end
* of the catchup algorithm.
*/
float64 pathLengthMeters =
PositionInterpolatorMath::getDistanceMeters(
m_catchUp.startPosition.coord,
m_catchUp.endPosition.coord,
m_convertFromMC2 );
float64 timeDiffSec = m_catchUp.periodMillis.length() / 1000.0;
/**
* timeDiffSec can't be zero, so this division should be ok.
*/
float64 avgSpeedMPS = pathLengthMeters / timeDiffSec;
/**
* If we solve
*
* ( startPosition.velocityMPS + endPosition.velocityMPS )
* avgSpeedMPS = --------------------------------------------------------
* 2.0
*
* for startPosition.velocityMPS, we get the following:
*/
m_catchUp.startPosition.velocityMPS =
2.0 * avgSpeedMPS - m_catchUp.endPosition.velocityMPS;
}
void PositionInterpolator::cycleConfigurationForward()
{
m_debugVals.curConfig =
( m_debugVals.curConfig + 1 ) % NUM_CONFIGS;
setConfiguration();
}
void PositionInterpolator::cycleConfigurationBackward()
{
m_debugVals.curConfig--;
if( m_debugVals.curConfig < 0 ) {
m_debugVals.curConfig = NUM_CONFIGS - 1;
}
setConfiguration();
}
void PositionInterpolator::setConfiguration()
{
m_debugVals.disableInterpolation = false;
switch( m_debugVals.curConfig ) {
case CONFIG_A:
m_catchUp.allowedCatchUpFactor = 0.25;
break;
case CONFIG_B:
m_catchUp.allowedCatchUpFactor = 0.5;
break;
case CONFIG_C:
m_catchUp.allowedCatchUpFactor = 0.9;
break;
case CONFIG_D:
m_debugVals.disableInterpolation = true;
break;
}
}
int PositionInterpolator::getConfiguration() const
{
return m_debugVals.curConfig;
}
| [
"[email protected]"
]
| [
[
[
1,
669
]
]
]
|
8159480e8eb6b71a5eb9e610b2cf09488be36b7a | 62874cd4e97b2cfa74f4e507b798f6d5c7022d81 | /src/libMidi-Me/Serializer.cpp | 55e96d7987afb01cec63f2ecfd957a0c5eb798e4 | []
| no_license | rjaramih/midi-me | 6a4047e5f390a5ec851cbdc1b7495b7fe80a4158 | 6dd6a1a0111645199871f9951f841e74de0fe438 | refs/heads/master | 2021-03-12T21:31:17.689628 | 2011-07-31T22:42:05 | 2011-07-31T22:42:05 | 36,944,802 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,216 | cpp | // Includes
#include "Serializer.h"
#include "Chain.h"
#include "Input.h"
#include "Output.h"
#include "ChainStart.h"
#include "ChainEnd.h"
#include "Processor.h"
#include "Connection.h"
#include "InputDevice.h"
#include "MidiOutput.h"
#include "DeviceManager.h"
#include <Properties/StandardProperties.h>
#include <Properties/StringUtil.h>
using namespace MidiMe;
#include <XmlParser/SimpleDomParser.h>
#include <XmlParser/XmlElement.h>
#include <fstream>
/******************************
* Constructors and destructor *
******************************/
Serializer::Serializer()
: m_pChain(0), m_currentOutputID(0), m_currentInputID(0)
{
}
Serializer::~Serializer()
{
}
/******************
* Other functions *
******************/
bool Serializer::load(Chain *pChain, const string &filename)
{
m_pChain = pChain;
if(!m_pChain)
{
setLastError("Null chain");
return false;
}
m_outputs.clear();
m_inputs.clear();
// Try to load the XML file
SimpleDomParser parser;
if(!parser.parse(filename, false)) //!< @todo Create DTD to check from
{
setLastError("Error parsing '" + filename + "': " + parser.getLastError());
return false;
}
XmlElement *pChainEl = parser.getRootElement();
if(pChainEl->getName() != "chain")
{
setLastError("The root element is not 'chain'");
return false;
}
// Parse the chain
if(!readChain(pChainEl))
return false;
return true;
}
bool Serializer::save(Chain *pChain, const string &filename)
{
m_pChain = pChain;
if(!m_pChain)
{
setLastError("Null chain");
return false;
}
m_outputIDs.clear();
m_inputIDs.clear();
m_currentOutputID = m_currentInputID = 0;
// Try to open the file
std::ofstream stream(filename.c_str());
if(!stream)
{
setLastError("Error opening output stream for '" + filename + "'");
return false;
}
if(!writeHeader(stream))
{
setLastError("Error writing the header");
return false;
}
if(!writeChain(stream, pChain))
{
setLastError("Error writing the chain");
return false;
}
return true;
}
/*****************
* Read functions *
*****************/
bool Serializer::readChain(XmlElement *pChainEl)
{
// Read chain start
XmlElement *pEl = pChainEl->getFirstChild("start");
while(pEl)
{
if(!readChainStart(pEl))
{
setLastError("Error reading chain start");
return false;
}
pEl = pEl->getNextSibling("start");
}
// Read chain end
pEl = pChainEl->getFirstChild("end");
while(pEl)
{
if(!readChainEnd(pEl))
{
setLastError("Error reading chain end");
return false;
}
pEl = pEl->getNextSibling("end");
}
// Read processors
pEl = pChainEl->getFirstChild("processor");
while(pEl)
{
if(!readProcessor(pEl))
{
setLastError("Error reading processor");
return false;
}
pEl = pEl->getNextSibling("processor");
}
// Read connections
pEl = pChainEl->getFirstChild("connection");
while(pEl)
{
if(!readConnection(pEl))
{
setLastError("Error reading connection");
return false;
}
pEl = pEl->getNextSibling("connection");
}
return true;
}
bool Serializer::readChainStart(XmlElement *pElement)
{
// The device name (required attribute)
const string &name = pElement->getAttribute("device");
InputDevice *pDevice = DeviceManager::getInstance().getInputDevice(name);
if(!pDevice)
return false;
// The output ID (required attribute)
unsigned int outputID = StringUtil::toUInt(pElement->getAttribute("outputID"));
// Add the chain start
ChainStart *pStart = m_pChain->addChainStart(pDevice, outputID);
// Read properties
readProperties(pElement, pStart);
// Index the output
m_outputs.push_back(pStart->getOutput());
return (pStart != 0);
}
bool Serializer::readChainEnd(XmlElement *pElement)
{
// Add the chain end
ChainEnd *pEnd = m_pChain->addChainEnd();
if(!pEnd)
return false;
// Read properties
readProperties(pElement, pEnd);
// Index the input
m_inputs.push_back(pEnd->getInput());
return true;
}
bool Serializer::readProcessor(XmlElement *pElement)
{
// The processor type (required)
const string &type = pElement->getAttribute("type");
Processor *pProcessor = m_pChain->addProcessor(type);
if(!pProcessor)
return false;
// Read properties
readProperties(pElement, pProcessor);
// Index the outputs
const OutputList &outputs = pProcessor->getOutputs();
for(OutputList::const_iterator it = outputs.begin(); it != outputs.end(); ++it)
m_outputs.push_back(*it);
// Index the inputs
const InputList &inputs = pProcessor->getInputs();
for(InputList::const_iterator it = inputs.begin(); it != inputs.end(); ++it)
m_inputs.push_back(*it);
return true;
}
/** Connect the previously created components. */
bool Serializer::readConnection(XmlElement *pElement)
{
// Note: the IDs only match if the elements get read and written in the same order!
unsigned int outputID = StringUtil::toUInt(pElement->getAttribute("outputID"));
unsigned int inputID = StringUtil::toUInt(pElement->getAttribute("inputID"));
if(m_outputs.size() <= outputID || m_inputs.size() <= inputID)
return false;
Output *pOutput = m_outputs.at(outputID);
Input *pInput = m_inputs.at(inputID);
// Create the connection
Connection *pConnection = m_pChain->addConnection(pInput, pOutput);
if(!pConnection)
return false;
// Read properties
readProperties(pElement, pConnection);
return true;
}
void Serializer::readProperties(XmlElement *pElement, PropertyCollection *pProperties)
{
XmlElement *pPropEl = pElement->getFirstChild("property");
while(pPropEl)
{
const string &type = pPropEl->getAttribute("type");
const string &name = pPropEl->getAttribute("name");
Property *pProperty = pProperties->getProperty(name);
if(pProperty)
{
if(type == "compound")
readCompoundProperty(pPropEl, (CompoundProperty *) pProperty);
else
pProperty->fromString(pPropEl->getAttribute("value"));
}
pPropEl = pPropEl->getNextSibling("property");
}
}
void Serializer::readCompoundProperty(XmlElement *pElement, CompoundProperty *pProperty)
{
XmlElement *pPropEl = pElement->getFirstChild("property");
while(pPropEl)
{
const string &type = pPropEl->getAttribute("type");
const string &name = pPropEl->getAttribute("name");
Property *pChildProp = pProperty->getProperty(name);
if(pChildProp)
{
if(type == "compound")
readCompoundProperty(pPropEl, (CompoundProperty *) pChildProp);
else
pChildProp->fromString(pPropEl->getAttribute("value"));
}
pPropEl = pPropEl->getNextSibling("property");
}
}
/******************
* Write functions *
******************/
bool Serializer::writeHeader(std::ostream &stream)
{
stream << "<?xml version=\"1.0\"?>\n";
stream << "<!DOCTYPE chain SYSTEM \"chain.dtd\">\n\n";
return true;
}
bool Serializer::writeChain(std::ostream &stream, Chain *pChain)
{
stream << "<chain>\n";
// Serialize chain starts
const ChainStartSet &start = pChain->getChainStart();
for(ChainStartSet::const_iterator it = start.begin(); it != start.end(); ++it)
writeChainStart(stream, *it);
stream << "\n";
// Serialize chain ends
const ChainEndSet &end = pChain->getChainEnd();
for(ChainEndSet::const_iterator it = end.begin(); it != end.end(); ++it)
writeChainEnd(stream, *it);
stream << "\n";
// Serialize processors
const ProcessorSet &processors = pChain->getProcessors();
for(ProcessorSet::const_iterator it = processors.begin(); it != processors.end(); ++it)
writeProcessor(stream, *it);
stream << "\n";
// Serialize the connections
const ConnectionMap &connections = pChain->getConnections();
for(ConnectionMap::const_iterator it = connections.begin(); it != connections.end(); ++it)
writeConnection(stream, it->second);
stream << "</chain>\n";
return true;
}
bool Serializer::writeChainStart(std::ostream &stream, ChainStart *pStart)
{
stream << "\t<start";
stream << " device=\"" << pStart->getDevice()->getName() << "\"";
stream << " outputID=\"" << pStart->getOutputID() << "\">" << endl;
writeProperties(stream, pStart, 1);
stream << "\t</start>" << endl;
// Index the output
m_outputIDs[pStart->getOutput()] = m_currentOutputID++;
return true;
}
bool Serializer::writeChainEnd(std::ostream &stream, ChainEnd *pEnd)
{
stream << "\t<end>" << endl;
writeProperties(stream, pEnd, 1);
stream << "\t</end>" << endl;
// Index the input
m_inputIDs[pEnd->getInput()] = m_currentInputID++;
return true;
}
bool Serializer::writeProcessor(std::ostream &stream, Processor *pProcessor)
{
stream << "\t<processor type=\"" << pProcessor->getType() << "\">" << endl;;
writeProperties(stream, pProcessor, 1);
stream << "\t</processor>" << endl;
// Index the outputs
const OutputList &outputs = pProcessor->getOutputs();
for(OutputList::const_iterator it = outputs.begin(); it != outputs.end(); ++it)
m_outputIDs[*it] = m_currentOutputID++;
// Index the inputs
const InputList &inputs = pProcessor->getInputs();
for(InputList::const_iterator it = inputs.begin(); it != inputs.end(); ++it)
m_inputIDs[*it] = m_currentInputID++;
return true;
}
bool Serializer::writeConnection(std::ostream &stream, Connection *pConnection)
{
stream << "\t<connection";
stream << " outputID=\"" << m_outputIDs[pConnection->getOutput()] << "\"";
stream << " inputID=\"" << m_inputIDs[pConnection->getInput()] << "\">" << endl;
writeProperties(stream, pConnection, 1);
stream << "\t</connection>" << endl;
return true;
}
bool Serializer::writeProperties(std::ostream &stream, PropertyCollection *pProperties, unsigned int indentLevel)
{
// Write all the properties
const PropertyList &props = pProperties->getPropertiesList();
PropertyList::const_iterator it;
for(it = props.begin(); it != props.end(); ++it)
{
Property *pProperty = *it;
writeProperty(stream, pProperty, indentLevel + 1);
}
return true;
}
bool Serializer::writeProperty(std::ostream &stream, Property *pProperty, unsigned int indentLevel)
{
if(pProperty->getType() == "compound")
{
writeTabs(stream, indentLevel);
stream << "<property type=\"compound\" name=\"" << pProperty->getName() << "\">" << endl;
CompoundProperty *pCompound = (CompoundProperty *) pProperty;
const PropertyMap &children = pCompound->getProperties();
for(PropertyMap::const_iterator it = children.begin(); it != children.end(); ++it)
writeProperty(stream, it->second, indentLevel + 1);
writeTabs(stream, indentLevel);
stream << "</property>" << endl;
}
else
{
writeTabs(stream, indentLevel);
stream << "<property type=\"" << pProperty->getType();
stream << "\" name=\"" << pProperty->getName();
stream << "\" value=\"" << pProperty->toString() << "\" />" << endl;
}
return true;
}
void Serializer::writeTabs(std::ostream &stream, unsigned int num)
{
for(unsigned int i = 0; i < num; ++i)
stream << "\t";
}
| [
"Jeroen.Dierckx@d8a2fbcc-2753-0410-82a0-8bc2cd85795f"
]
| [
[
[
1,
454
]
]
]
|
b8bb049e97934791bb80217751b8e05b20842f1c | 208475bcab65438eed5d8380f26eacd25eb58f70 | /ComuExe/GpsSrc.h | 495e48715d9913973a799025e75bda1af32df53d | []
| no_license | awzhang/MyWork | 83b3f0b9df5ff37330c0e976310d75593f806ec4 | 075ad5d0726c793a0c08f9158080a144e0bb5ea5 | refs/heads/master | 2021-01-18T07:57:03.219372 | 2011-07-05T02:41:55 | 2011-07-05T02:46:30 | 15,523,223 | 1 | 2 | null | null | null | null | GB18030 | C++ | false | false | 1,741 | h | #ifndef _GPS_H_
#define _GPS_H_
unsigned int G_GpsReadThread( void* v_pPar );
class CGpsSrc
{
public:
CGpsSrc();
virtual ~CGpsSrc();
bool GetSatellitesInfo( SATELLITEINFO &v_objSatsInfo );
unsigned int P_GpsReadThread();
bool InitGpsAll();
bool ReleaseGpsAll();
void GpsSigHandler();
bool GpsSwitch;
private:
bool _ReleaseGps();
bool _InitGps();
bool _InitGpsSrc();
bool _ReleaseGpsSrc();
int _SemInit();
bool _SemaphoreP();
bool _SemaphoreV();
int _ShmInit();
int _ForkSiRFNav();
int _SigChldHandler();
void *_GetShm(int v_iShmid);
BOOL _DecodeGSVData(const char *const szGps, SATELLITEINFO &info);
BOOL _DecodeGSAData(const char *const szGps, GPSDATA &gps);
BOOL _DecodeRMCData(const char *const szGps, GPSDATA &gps);
bool _KillSirfReq();
bool _GetGpsOrigData(gps_data_share* v_p_objGpsData);
bool _SetTimeToRtc(struct tm* v_SetTime);
bool _SetGpsTime( int v_Year, int v_Month, int v_Day, int v_Hour, int v_Minute, int v_Second );
public:
//bool m_bUpdateQuit; //升级root前,关闭GPS进程
bool m_bNeedGpsOn;
private:
SATELLITEINFO m_objSatsInfo;
gps_data_share m_objGpsDataShm;
#if GPS_TYPE == SIMULATE_GPS
int m_imGpsComPort;
bool _mGpsComOpen();
#endif
pthread_t m_pthreadGpsRead;
pthread_mutex_t m_hMutexGsv;
struct timeval m_objRecentTime;
DWORD m_dwInvalidTime;
DWORD m_dwGsvGetTm;
int m_iSemid;
int m_iShmid;
void *m_pShm;
bool m_bGpsInit;//未进行互斥操作
volatile int m_iGpsSta;
pid_t m_pidNum;
pid_t m_ChildPid;
volatile bool m_bGpsChildClose;
volatile bool m_bFinishKill;
volatile bool m_bGpsSleep;
bool m_bRtcTimeChecked;//RTC校时标志
};
#endif // #ifndef _GPS_H_
| [
"[email protected]"
]
| [
[
[
1,
74
]
]
]
|
04b4a4d320214f59c8096efa30c3f0c1dbc6865e | 85556d2252328c785bb57528878b7ad621a4af76 | /LuaCppFSM/src/BaseGameEntity.cpp | d3a3f05bc8d25ff7f95304025560cb93ff1a93f2 | []
| no_license | turdann/luacppfsm | 86ace1cf742e767597e452ef58ef1495422f1441 | 0bc5334c88e4eeae6caa926ee6a3546ea0f34cd4 | refs/heads/master | 2021-01-10T02:01:14.662585 | 2008-08-08T09:45:15 | 2008-08-08T09:45:15 | 52,820,764 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 753 | cpp | #include "BaseGameEntity.h"
#include <cassert>
int BaseGameEntity::m_iNextValidID = 0;
//----------------------------- SetID -----------------------------------------
//
// this must be called within each constructor to make sure the ID is set
// correctly. It verifies that the value passed to the method is greater
// or equal to the next valid ID, before setting the ID and incrementing
// the next valid ID
//-----------------------------------------------------------------------------
void BaseGameEntity::SetID(int val)
{
//make sure the val is equal to or greater than the next available ID
assert ( (val >= m_iNextValidID) && "<BaseGameEntity::SetID>: invalid ID");
m_ID = val;
m_iNextValidID = m_ID + 1;
}
| [
"[email protected]"
]
| [
[
[
1,
21
]
]
]
|
fe35bfbcc46bc2466bfde50e7920796212db8c93 | 1f94e01a5fc5de1f0e858da37f07099feab5988b | /src/Depth_2d_viewer/Length_value_view_widget.cpp | a1df6af02ae25b8b20413ce73ba0a992859ddb19 | []
| no_license | satofumi/OpenNI_practice | 30c00876efc2c7bde7bcec881177ba91c0526067 | f9428bf0712f1a02d79d137c9b7df0cdf5887bf3 | refs/heads/master | 2020-06-04T01:40:28.735112 | 2011-07-10T11:20:26 | 2011-07-10T11:20:26 | 1,368,887 | 1 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 6,918 | cpp | /*!
\file
\brief 距離データの値を表示
\author Satofumi KAMIMURA
$Id$
\todo 距離データの更新、ボタンがタブを切替えると押せるようになるのを修正する。
*/
#include "Length_value_view_widget.h"
#include "Lidar.h"
namespace
{
enum {
Default_column_size = 768 + 1,
Default_minimum_length = 23,
Default_maximum_length = 60000,
};
typedef enum {
Length,
Intensity,
} value_type_t;
}
struct Length_value_view_widget::pImpl
{
Length_value_view_widget* widget_;
bool data_updated_;
long minimum_length_;
long maximum_length_;
int previous_select_index_;
pImpl(Length_value_view_widget* widget)
: widget_(widget), data_updated_(false),
minimum_length_(Default_minimum_length),
maximum_length_(Default_maximum_length),
previous_select_index_(0)
{
}
void initialize_form(void)
{
enum { Horizontal_header_size = 2, };
for (int i = 0; i < Horizontal_header_size; ++i) {
widget_->table_->horizontalHeader()->
setResizeMode(i, QHeaderView::Stretch);
}
widget_->table_->verticalHeader()->setDefaultAlignment(Qt::AlignCenter);
// !!! set???Enable() を作ったときに、この呼び出しも含めること
widget_->update_button_->setEnabled(true);
connect(widget_->update_button_, SIGNAL(clicked()),
widget_, SLOT(update_button_clicked()));
connect(widget_->table_, SIGNAL(itemSelectionChanged()),
widget_, SLOT(current_cell_changed_slot()));
}
void reset_form(void)
{
set_row_size(Default_column_size);
minimum_length_ = Default_minimum_length;
buttons_set_enabled(false);
}
void set_length(QTableWidgetItem* item, long length,
value_type_t type = Length)
{
QString value = QString("%1").arg(length);
if (type == Length) {
if (length < minimum_length_) {
// 距離値がエラーのときは赤色で表示する
item->setForeground(QBrush(Qt::red));
} else {
item->setForeground(QBrush(Qt::black));
}
}
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
item->setText(value);
}
void set_row_size(size_t row_size)
{
QTableWidget* p = widget_->table_;
p->clearContents();
p->setRowCount(row_size);
QStringList row_labels;
QString zero_value = "0";
for (size_t i = 0; i < row_size; ++i) {
row_labels << QString("%1").arg(i);
// 距離
QTableWidgetItem* item = new QTableWidgetItem;
set_length(item, 0);
p->setItem(i, 0, item);
// 強度
item = new QTableWidgetItem;
set_length(item, 0, Intensity);
p->setItem(i, 1, item);
}
p->setVerticalHeaderLabels(row_labels);
}
void set_table_zero(void)
{
size_t row_size = widget_->table_->rowCount();
QString zero_value = "0";
for (size_t i = 0; i < row_size; ++i) {
QTableWidgetItem* item = widget_->table_->item(i, 0);
set_length(item, 0);
item = widget_->table_->item(i, 1);
set_length(item, 0, Intensity);
}
}
void set_length_range(long minimum_length, long maximum_length)
{
minimum_length_ = minimum_length;
maximum_length_ = maximum_length;
}
void buttons_set_enabled(bool enable)
{
widget_->update_button_->setEnabled(enable);
}
};
Length_value_view_widget::Length_value_view_widget(QWidget* parent)
: QWidget(parent), pimpl(new pImpl(this))
{
setupUi(this);
pimpl->initialize_form();
}
Length_value_view_widget::~Length_value_view_widget(void)
{
}
void Length_value_view_widget::reset_form(void)
{
pimpl->reset_form();
}
void Length_value_view_widget::start_measurement(void)
{
pimpl->buttons_set_enabled(true);
}
void Length_value_view_widget::stop_measurement(void)
{
pimpl->buttons_set_enabled(false);
pimpl->set_table_zero();
}
void Length_value_view_widget::set_sensor_parameter(qrk::Lidar& lidar)
{
pimpl->set_row_size(lidar.max_data_size());
pimpl->set_length_range(lidar.min_distance(), lidar.max_distance());
}
void Length_value_view_widget::update_view_data(void)
{
pimpl->data_updated_ = false;
}
void Length_value_view_widget::focus_step_index(int index)
{
// 選択中のセルを非選択にする
QTableWidgetItem* previous_item =
table_->item(pimpl->previous_select_index_, 0);
if (previous_item) {
previous_item->setSelected(false);
}
QTableWidgetItem* item = table_->item(index, 0);
if (item) {
item->setSelected(true);
table_->scrollToItem(item);
table_->setCurrentItem(item);
}
pimpl->previous_select_index_ = index;
}
void Length_value_view_widget::data_received(const long* length,
int length_size,
const unsigned short* intensity,
int intensity_size,
long timestamp)
{
static_cast<void>(timestamp);
if (pimpl->data_updated_) {
return;
}
// 表示データの更新
for (int i = 0; i < length_size; ++i) {
QTableWidgetItem* item = table_->item(i, 0);
if (!item) {
break;
}
pimpl->set_length(item, length[i]);
}
for (int i = 0; i < intensity_size; ++i) {
QTableWidgetItem* item = table_->item(i, 1);
if (!item) {
break;
}
pimpl->set_length(item, intensity[i], Intensity);
}
// データが登録されたら、ボタンを有効にする
pimpl->data_updated_ = true;
update_button_->setEnabled(true);
}
void Length_value_view_widget::update_button_clicked(void)
{
// Length_receive_thread に対してデータの配置を要求する
update_button_->setEnabled(false);
pimpl->data_updated_ = false;
}
void Length_value_view_widget::current_cell_changed_slot(void)
{
QTableWidgetItem* item = table_->currentItem();
if (item) {
int index = item->row();
emit current_cell_changed(true, index);
} else {
emit current_cell_changed(false, 0);
}
}
| [
"satofumi@twinstar.(none)"
]
| [
[
[
1,
268
]
]
]
|
ff2ac1166da1f218f0a73ec185d3756cde4c429e | 9ad9345e116ead00be7b3bd147a0f43144a2e402 | /Integration_WAH_&_Extraction/SMDataExtraction/Algorithm/NominalAttribute.cpp | 11ddf6a9d84f24030daaa24a0b85d2618c4fb58f | []
| no_license | asankaf/scalable-data-mining-framework | e46999670a2317ee8d7814a4bd21f62d8f9f5c8f | 811fddd97f52a203fdacd14c5753c3923d3a6498 | refs/heads/master | 2020-04-02T08:14:39.589079 | 2010-07-18T16:44:56 | 2010-07-18T16:44:56 | 33,870,353 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,189 | cpp | #include "StdAfx.h"
#include "NominalAttribute.h"
NominalAttribute::NominalAttribute(void)
{
}
NominalAttribute::NominalAttribute(double _weight, std::vector<BayesDistinct *> &_values)
{
m_weight = _weight;
m_uniqueValues = _values;
m_uniqueValNo = _values.size();
}
BayesDistinct * NominalAttribute::distinctValueAt(size_t post)
{
return m_uniqueValues[post];
}
BitStreamInfo * NominalAttribute::bitStreamAt(size_t position)
{
return this->m_uniqueValues[position]->Value();
}
void NominalAttribute::Print()
{
cout <<"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" << endl;
cout << "Printing Attribute :"<< endl;
cout <<"Attr Name : " << m_name << endl;
cout << "Unique Value : " << m_uniqueValNo << endl;
for (size_t i = 0 ; i < m_uniqueValues.size() ; i++)
{
cout << "Value Index : " << i << endl;
m_uniqueValues[i]->Print();
}
cout <<"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" << endl;
}
string NominalAttribute::value(int valIndex)
{
return m_uniqueValues[valIndex]->name();
}
NominalAttribute::~NominalAttribute(void)
{
for (size_t i = 0 ; i < m_uniqueValues.size() ; i++)
{
delete m_uniqueValues[i];
}
} | [
"jaadds@c7f6ba40-6498-11de-987a-95e5a5a5d5f1"
]
| [
[
[
1,
51
]
]
]
|
15b573127b8be5a58ff6ce7ec7628c6f12ef248f | b84a38aad619acf34c22ed6e6caa0f7b00ebfa0a | /Code/TootleCore/TArray.h | 822d3edbba7a4e7a03ce92f538863651e04038f9 | []
| no_license | SoylentGraham/Tootle | 4ae4e8352f3e778e3743e9167e9b59664d83b9cb | 17002da0936a7af1f9b8d1699d6f3e41bab05137 | refs/heads/master | 2021-01-24T22:44:04.484538 | 2010-11-03T22:53:17 | 2010-11-03T22:53:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,208 | h | /*------------------------------------------------------
TArray is the base array interface.
-------------------------------------------------------*/
#pragma once
#include "TLTypes.h"
#include "TLDebug.h"
#include "TLRandom.h"
// enable this to do extensive array sorting checks at runtime. The sort checks are always done in the unit test
// gr: I've only enabled this on the mac as my PC (in VM) is too slow, but my mac is fast enough
#if defined(_DEBUG) && defined(TL_USER_GR) && defined(TL_TARGET_MAC)
#define ARRAY_SORT_CHECK
#endif
class TBinary;
namespace TLArray
{
// added this wrapper for TLDebug_Break so we don't include the string type
namespace Debug
{
Bool Break(const char* pErrorString,const char* pSourceFunction);
void Print(const char* pErrorString,const char* pSourceFunction);
template<typename TYPE>
FORCEINLINE void PrintSizeWarning(const TYPE& DummyElement,u32 ElementCount,const char* pSourceFunction)
{
#ifdef _DEBUG
if ( ElementCount > 300 )
Print("Warning: Copying/Setting over 300 elements in a non-data type array", pSourceFunction );
#endif
}
}
#define TArray_GrowByDefault 4
};
#include "TArraySort.h" // Array Sorting policies
#include "TArrayAllocator.h" // Allocator policies
template<typename TYPE>
class TArray
{
friend class TBinary;
public:
typedef TArray<TYPE> TArrayType; // short hand for this array type
public:
virtual ~TArray() { }
virtual u32 GetSize() const=0; // number of elements
FORCEINLINE bool IsEmpty() const { return GetSize() == 0; }
FORCEINLINE s32 GetRandomIndex() const { return TLMaths::Rand( GetSize() ); };
FORCEINLINE s32 GetLastIndex() const { return (s32)GetSize() - 1; };
virtual TYPE* GetData()=0;
virtual const TYPE* GetData() const=0;
FORCEINLINE u32 GetDataSize() const { return ( GetSize() * sizeof(TYPE) ); }; // memory consumption of elements
FORCEINLINE Bool IsElementDataType() const { return TLCore::IsDataType<TYPE>(); }
template<typename ARRAYTYPE>
void Copy(const ARRAYTYPE& Array); // make this a copy of the specified array
// template<> void Copy(const TArrayType& Array); // make this a copy of the specified array
void SetAll(const TYPE& Val); // set all elements to match this one (uses = operator)
Bool SetSize(s32 Size); // resize the array.
void Empty(Bool Dealloc=FALSE) { SetSize(0); if ( Dealloc ) SetAllocSize(0); };
virtual u32 GetAllocSize() const=0; // get the currently allocated amount of data
virtual u32 GetMaxAllocSize() const { return TLTypes::GetIntegerMax<s32>(); } // gr: though technically we can store u32 elements, we use s32 because sometimes we return signed indexes.
virtual bool SetAllocSize(u32 Size)=0; // set new amount of allocated data
FORCEINLINE bool AddAllocSize(u32 Size) { return SetAllocSize( GetSize() + Size ); } // alloc N extra data than we already have
void Compact() { SetAllocSize( GetSize() ); } // free-up over-allocated data
TYPE& ElementAt(u32 Index) { TLDebug_CheckIndex( Index, GetSize() ); return GetData()[Index]; }
const TYPE& ElementAtConst(u32 Index) const { TLDebug_CheckIndex( Index, GetSize() ); return GetData()[Index]; }
FORCEINLINE TYPE& ElementLast() { return ElementAt( GetLastIndex() ); };
FORCEINLINE const TYPE& ElementLastConst() const { return ElementAtConst( GetLastIndex() ); };
FORCEINLINE TYPE& ElementRandom() { return ElementAt( GetRandomIndex() ); }
FORCEINLINE const TYPE& ElementRandomConst() const { return ElementAtConst( GetRandomIndex() ); }
s32 Add(const TYPE& val,u32 Count=1); // add an element onto the end of the list. returns index of FIRST element added
FORCEINLINE s32 AddUnique(const TYPE& val) { s32 Index = FindIndex( val ); return (Index == -1) ? Add( val ) : Index; }
s32 Add(const TYPE* pData,u32 Length=1); // add a number of elements onto the end of the list. returns index of FIRST element added
template<class ARRAYTYPE>
s32 Add(const TArray<ARRAYTYPE>& Array); // add a whole array of this type onto the end of the list
// template<> s32 Add(const TArrayType& Array) { return Add( Array.GetData(), Array.GetSize() ); }
s32 AddUnique(const TArrayType& Array); // add each element from an array using AddUnique
TYPE* AddNew(); // add a new element onto the end of the array and return it. often fastest because if we dont need to grow there's no copying
template<class MATCHTYPE>
FORCEINLINE Bool Remove(const MATCHTYPE& val); // remove the specifed object
Bool RemoveAt(u32 Index); // remove an element from the array at the specified index
void RemoveAt(u32 Index,u32 Amount); // remove a range of elements from the array
Bool RemoveLast() { return ( GetSize() ? RemoveAt( GetLastIndex() ) : FALSE ); };
s32 InsertAt(u32 Index, const TYPE& val,Bool ForcePosition=FALSE);
s32 InsertAt(u32 Index, const TYPE* val, u32 Length, Bool ForcePosition=FALSE);
s32 InsertAt(u32 Index, const TArrayType& array, Bool ForcePosition=FALSE) { return InsertAt( Index, array.GetData(), array.GetSize(), ForcePosition ); };
FORCEINLINE bool IsSorted() const { return GetSortPolicy().IsSorted(); }
FORCEINLINE void SetSortOrder(TLArray::TSortOrder::Type Order) { GetSortPolicy().SetSortOrder( Order ); }
FORCEINLINE void Sort() { GetSortPolicy().Sort( GetData(), GetSize() ); }
FORCEINLINE void SetUnsorted() { GetSortPolicy().SetUnsorted(); }
DEPRECATED FORCEINLINE void SwapElements(u32 a, u32 b); // swap 2 elements in the array - DB Deprecated. Do we want to allow this externally? The sort policy implements this internally now so this shouldn't be necessary
// simple templated item index finding (defined inline as some compilers need to have template functions for template classes inside the declaration)
template<typename MATCHTYPE> s32 FindIndex(const MATCHTYPE& Match,u32 FromIndex=0);
template<typename MATCHTYPE> s32 FindIndex(const MATCHTYPE& Match,u32 FromIndex=0) const;
template<typename MATCHTYPE> s32 FindIndexReverse(const MATCHTYPE& Match,s32 FromIndex=-1) const;
template<class MATCHTYPE> TYPE* Find(const MATCHTYPE& val) { s32 Index = FindIndex(val); return (Index==-1) ? NULL : &ElementAt(Index); };
template<class MATCHTYPE> const TYPE* FindConst(const MATCHTYPE& val) const { u32 Index = FindIndex(val); return (Index==-1) ? NULL : &ElementAtConst(Index); };
template<class MATCHTYPE,class ARRAYTYPE>
u32 FindAll(ARRAYTYPE& Array,const MATCHTYPE& val); // find all matches to this value and put them in an array
template<class MATCHTYPE> Bool Exists(const MATCHTYPE& val) const { return FindIndex(val)!=-1; };
template<class MATCHTYPE> Bool Exists(const MATCHTYPE& val) { return FindIndex(val)!=-1; };
template<typename FUNCTIONPOINTER>
FORCEINLINE void FunctionAll(FUNCTIONPOINTER pFunc); // execute this function on every member. will fail if the TYPE isn't a pointer of somekind
template<typename FUNCTIONPOINTER>
FORCEINLINE void FunctionAllAsParam(FUNCTIONPOINTER pFunc); // execute this function for every member as a parameter. Like FunctionAll but can be used with other types of elements.
bool Debug_VerifyIsSorted() const; // if the array claims to be sorted, ensure it is
// operators
FORCEINLINE TYPE& operator[](s32 Index) { return ElementAt(Index); }
FORCEINLINE TYPE& operator[](u32 Index) { return ElementAt(Index); }
FORCEINLINE const TYPE& operator[](s32 Index) const { return ElementAtConst(Index); }
FORCEINLINE const TYPE& operator[](u32 Index) const { return ElementAtConst(Index); }
// append operator - this means you can now initialise an array in a constructor like so (without a massive performance penalty, but convience can be worth it:)
// : m_Array ( TFixedArray<TYPE>() << 0 << 1 << 2 << 3 )
// no need to wait for the gcc array initialiser :) (4.5 spec IIRC)
// not tested this to see if we can use it in a global, but will try. An in-place array type will be made up and can serve that purpose too.
FORCEINLINE TArrayType& operator<<(const TYPE& val) { Add( val ); return *this; }
FORCEINLINE TArrayType& operator=(const TArray<TYPE>& Array) { Copy( Array ); return *this; }
FORCEINLINE Bool operator<(const TArray<TYPE>& Array) const { return FALSE; }
FORCEINLINE bool operator==(const TArray<TYPE>& Array) const;
FORCEINLINE bool operator!=(const TArray<TYPE>& Array) const;
public: // gr: temporarily exposed for the sort policies
void ShiftArray(u32 From, s32 Amount ); // move blocks of data in the array
protected:
virtual void DoSetSize(u32 Size)=0; // set a new size. no return as the size has already been calculated to be okay
virtual TSortPolicy<TYPE>& GetSortPolicy()=0; // get the sort policy
virtual const TSortPolicy<TYPE>& GetSortPolicy() const=0; // get the sort policy
virtual void Move(u32 CurrIndex,u32 NewIndex); // remove from list in one place and insert it back in
Bool CopyElements(const TYPE* pData,u32 Length,u32 Index=0);
virtual void OnArrayShrink(u32 OldSize,u32 NewSize) { } // callback when the array is SHRUNK but nothing is deallocated. added so specific types can clean up as needed (e.g. NULL pointers that are "removed" but not deallocated
};
/*
// gr: we ignore the size warning for arrays as we cannot doing anything about it :(
template<>
template<typename ARRAYTYPE>
FORCEINLINE void TLArray::Debug::PrintSizeWarning(const TArray<ARRAYTYPE>& DummyElement,u32 ElementCount,const char* pSourceFunction)
{
}
*/
template<typename TYPE,typename STORAGETYPE=u32,class SORTPOLICY=TSortPolicyNone<TYPE> >
class TInPlaceArray : public TArray<TYPE>
{
private:
typedef TArray<TYPE> TSuper;
typedef TInPlaceArray<TYPE,STORAGETYPE,SORTPOLICY> TThis;
public:
TInPlaceArray(TYPE* pData,STORAGETYPE DataSize,STORAGETYPE* pSizeCounter=NULL) :
m_pData ( pData ),
m_DataSize ( DataSize ),
m_pSize ( pSizeCounter )
{
}
// gr: not worked out how to return a const TInplaceArray yet
TInPlaceArray(const TYPE* pData,STORAGETYPE DataSize,const STORAGETYPE* pSizeCounter=NULL) :
m_pData ( const_cast<TYPE*>(pData) ),
m_DataSize ( DataSize ),
m_pSize ( const_cast<STORAGETYPE*>(pSizeCounter) )
{
}
virtual u32 GetSize() const { return m_pSize ? (*m_pSize) : GetAllocSize(); }
virtual TYPE* GetData() { return m_pData; }
virtual const TYPE* GetData() const { return m_pData; }
virtual u32 GetAllocSize() const { return m_DataSize; }
virtual bool SetAllocSize(u32 Size) { return Size <= GetAllocSize(); }
FORCEINLINE TThis& operator=(const TArray<TYPE>& Array) { TSuper::Copy( Array ); return *this; }
protected:
virtual void DoSetSize(u32 Size) { if ( m_pSize ) *m_pSize = Size; }
virtual TSortPolicy<TYPE>& GetSortPolicy() { return m_SortPolicy; }
virtual const TSortPolicy<TYPE>& GetSortPolicy() const { return m_SortPolicy; }
private:
TYPE* m_pData; // data
STORAGETYPE m_DataSize; // size of buffer
STORAGETYPE* m_pSize; // size counter if applicable
SORTPOLICY m_SortPolicy; //
};
//----------------------------------------------------------
// gr: this is the new dynamically allocated array!
//----------------------------------------------------------
template<typename TYPE,u32 GROWBY=10,class SORTPOLICY=TSortPolicyNone<TYPE> >
class THeapArray : public TArray<TYPE>
{
private:
typedef TArray<TYPE> TSuper;
typedef THeapArray<TYPE,GROWBY,SORTPOLICY> TThis;
public:
THeapArray() :
m_pData ( NULL ),
m_Size ( 0 ),
m_Alloc ( 0 ),
m_SortPolicy ()
{
}
THeapArray(const TThis& Array) :
m_pData ( NULL ),
m_Size ( 0 ),
m_Alloc ( 0 ),
m_SortPolicy ()
{
TSuper::Copy( Array );
}
THeapArray(const TArray<TYPE>& Array) :
m_pData ( NULL ),
m_Size ( 0 ),
m_Alloc ( 0 ),
m_SortPolicy ()
{
TSuper::Copy( Array );
}
virtual ~THeapArray()
{
// Release the array data
if(m_pData)
{
TLMemory::DeleteArray( m_pData );
m_Alloc = 0;
m_Size = 0;
m_pData = NULL;
}
}
virtual u32 GetSize() const { return m_Size; }
virtual TYPE* GetData() { return m_pData; }
virtual const TYPE* GetData() const { return m_pData; }
virtual bool SetAllocSize(u32 NewSize);
virtual u32 GetAllocSize() const { return m_Alloc; }
FORCEINLINE TThis& operator=(const TArray<TYPE>& Array) { TSuper::Copy( Array ); return *this; }
FORCEINLINE TThis& operator=(const TThis& Array) { TSuper::Copy( Array ); return *this; }
protected:
virtual void DoSetSize(u32 Size) { m_Size = Size; }
virtual TSortPolicy<TYPE>& GetSortPolicy() { return m_SortPolicy; }
virtual const TSortPolicy<TYPE>& GetSortPolicy() const { return m_SortPolicy; }
private:
TYPE* m_pData; // array itself
u32 m_Size; // runtime size of the array
u32 m_Alloc; // allocated amount of data in the array
SORTPOLICY m_SortPolicy; // sort policy - gr: we can save a little memory by inheriting from this class, but we will need to rename the functions
};
//--------------------------------------------------------
// reallocate the memory in the array to a new sized array
//--------------------------------------------------------
template<typename TYPE,u32 GROWBY,class SORTPOLICY>
bool THeapArray<TYPE,GROWBY,SORTPOLICY>::SetAllocSize(u32 NewSize)
{
// 0 size specified delete all data
if ( NewSize <= 0 )
{
TLMemory::DeleteArray( m_pData );
m_Alloc = 0;
m_Size = 0;
return true;
}
// pad out new alloc size
u32 NewAlloc = NewSize + GROWBY - (NewSize % GROWBY);
// no need to change allocation
if ( NewSize <= m_Alloc )
return true;
// save off the old data
//u32 OldAlloc = m_Alloc;
TYPE* pOldData = m_pData;
// alloc new data
TYPE* pNewData = TLMemory::AllocArray<TYPE>( NewAlloc );
// failed to alloc...
if ( !pNewData )
{
TLArray::Debug::Break("Failed to allocate array", __FUNCTION__ );
return false;
}
// update alloc info
m_pData = pNewData;
m_Alloc = NewAlloc;
// force removal of items if we have less mem allocated now
if ( m_Size > m_Alloc )
m_Size = m_Alloc;
// copy old elements
if ( pOldData )
{
// copy as many of the old items as possible
u32 CopySize = m_Size;
if ( NewAlloc < CopySize )
CopySize = NewAlloc;
if ( TArray<TYPE>::IsElementDataType() )
{
TLMemory::CopyData( m_pData, pOldData, CopySize );
}
else
{
TLArray::Debug::PrintSizeWarning( m_pData[0], CopySize, __FUNCTION__ );
for ( u32 i=0; i<CopySize; i++ )
{
m_pData[i] = pOldData[i];
}
}
// delete old data
TLMemory::DeleteArray( pOldData );
}
return true;
}
#include "TArray.inc.h"
| [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
2
],
[
4,
10
],
[
16,
40
],
[
43,
45
],
[
49,
51
],
[
53,
53
],
[
80,
81
],
[
84,
84
],
[
106,
108
],
[
116,
116
],
[
122,
123
],
[
125,
125
],
[
127,
127
],
[
130,
130
],
[
135,
135
],
[
149,
150
],
[
156,
156
],
[
159,
161
],
[
249,
262
],
[
268,
268
],
[
272,
272
],
[
274,
274
],
[
278,
279
],
[
281,
281
],
[
284,
286
],
[
293,
293
],
[
358,
362
]
],
[
[
3,
3
],
[
11,
15
],
[
41,
42
],
[
46,
48
],
[
52,
52
],
[
54,
79
],
[
82,
83
],
[
85,
105
],
[
109,
115
],
[
117,
121
],
[
124,
124
],
[
126,
126
],
[
128,
129
],
[
131,
134
],
[
136,
148
],
[
151,
155
],
[
157,
158
],
[
162,
248
],
[
263,
267
],
[
269,
271
],
[
273,
273
],
[
275,
277
],
[
280,
280
],
[
282,
283
],
[
287,
292
],
[
294,
357
]
]
]
|
18f2a344e8a1027cf67e62a1f9f4dc16b8b191d8 | 33a6be59df2f704fcad3288c7ee3b7eae4939014 | /c++Einfuehrung_programmiererin/auszug_ueberladen_fn/funueber.cpp | 6bc217e09f5071092c4b81a3fd0cd9386bed5f3a | []
| no_license | jjoe64/babydevelop | 49670ae5d8b01a13fffaf715751bc01b141efe89 | e2797f2b204adebe4bd0e60b98730f6685f523b4 | refs/heads/master | 2020-04-04T01:46:01.594675 | 2011-08-04T12:46:07 | 2011-08-04T12:46:07 | 1,991,958 | 1 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 2,266 | cpp | // Kapitel 6 - Programm 9 - FUNUEBER.CPP
#include <iostream.h>
class VieleNamen
{
private:
int Laenge;
int Breite;
public:
VieleNamen(void); // Konstruktoren
VieleNamen(int L);
VieleNamen(int L, int B);
void Zeige(void); // Anzeigefunktionen
void Zeige(int Eins);
void Zeige(int Eins, int Zwei);
void Zeige(float Zahl);
};
//--------------------------------------------------------------
VieleNamen::VieleNamen(void)
{
Laenge = 8;
Breite = 8;
}
//--------------------------------------------------------------
VieleNamen::VieleNamen(int L)
{
Laenge = L;
Breite = 8;
}
//--------------------------------------------------------------
VieleNamen::VieleNamen(int L, int B)
{
Laenge = L;
Breite = B;
}
//--------------------------------------------------------------
void VieleNamen::Zeige(void)
{
cout << "Anzeigefunktion (void), Flaecheninhalt = " <<
Laenge * Breite << "\n";
}
//--------------------------------------------------------------
void VieleNamen::Zeige(int Eins)
{
cout << "Anzeigefunktion (int), Flaecheninhalt = " <<
Laenge * Breite << "\n";
}
//--------------------------------------------------------------
void VieleNamen::Zeige(int Eins, int Zwei)
{
cout << "Anzeigefunktion (int, int), Flaecheninhalt = " <<
Laenge * Breite << "\n";
}
//--------------------------------------------------------------
void VieleNamen::Zeige(float Zahl)
{
cout << "Anzeigefunktion (float), Flaecheninhalt = " <<
Laenge * Breite << "\n";
}
//--------------------------------------------------------------
int main()
{
VieleNamen Klein, Mittel(10), Grosz(12, 15);
int BIP = 144;
float Pi = 3.1415, Lohn = 12.50;
Klein.Zeige();
Klein.Zeige(100);
Klein.Zeige(BIP,100);
Klein.Zeige(Lohn);
Mittel.Zeige();
Grosz.Zeige(Pi);
return 0;
}
// Ergebnis beim Ausführen
//
// Anzeigefunktion (void), Flaecheninhalt = 64
// Anzeigefunktion (int), Flaecheninhalt = 64
// Anzeigefunktion (int, int), Flaecheninhalt = 64
// Anzeigefunktion (float), Flaecheninhalt = 64
// Anzeigefunktion (void), Flaecheninhalt = 80
// Anzeigefunktion (float), Flaecheninhalt = 180
| [
"[email protected]"
]
| [
[
[
1,
94
]
]
]
|
cbfecf567f8fb6f45c445472d47be0f22f9560b6 | daa67e21cc615348ba166d31eb25ced40fba9dc7 | /GameCode/StdAfx.h | f8571821e31d42844fb4850e60cba5b014dc7e51 | []
| no_license | gearsin/geartesttroject | 443d48b7211f706ab2c5104204bad7228458c3f2 | f86f255f5e9d1d34a00a4095f601a8235e39aa5a | refs/heads/master | 2020-05-19T14:27:35.821340 | 2008-09-02T19:51:16 | 2008-09-02T19:51:16 | 32,342,555 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,431 | h | //------------------------------------------------------------------------------------------------------------------
#ifndef STDA_FX_H
#define STDA_FX_H
//------------------------------------------------------------------------------------------------------------------
#pragma once
//------------------------------------------------------------------------------------------------------------------
#include <windows.h>
#include <map>
#include <string>
#include <vector>
#include <list>
#include "DXUT.h"
#include "DXUTCamera.h"
#include "SdkMisc.h"
#include "SDKMesh.h"
#include "Typedef.h"
#include "Vector.h"
#include "GeometricPrimitives.h"
#include "UtilityFunction.h"
//----------------------------------------------------------------------------------------------------
#define DIRECTINPUT_VERSION DIRECTINPUT_HEADER_VERSION
#include <DInput.h>
//------------------------------------------------------------------------------------------------------------------
#pragma warning ( disable : 4995 )
#pragma warning ( disable : 4996 )
//------------------------------------------------------------------------------------------------------------------
#define OBJECTS_DIR L"\\GameData\\Objects\\"
#define LEVELS_DIR L"\\GameData\\Levels\\"
//------------------------------------------------------------------------------------------------------------------
#endif | [
"sunil.ssingh@592c7993-d951-0410-8115-35849596357c"
]
| [
[
[
1,
42
]
]
]
|
4800b267344e197bb8ce340a6bd941da9a568494 | 854ee643a4e4d0b7a202fce237ee76b6930315ec | /arcemu_svn/src/arcemu-shared/MersenneTwister.cpp | 8810e730b013257d39e7637d2b25dfe811345bcc | []
| 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 | 8,358 | cpp | /*
* ArcEmu MMORPG Server
* Copyright (C) 2005-2007 Ascent Team <http://www.ascentemu.com/>
* 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/>.
*
*/
#include "MersenneTwister.h"
#include "Timer.h"
#define NUMBER_OF_GENERATORS 5
Mutex * m_locks[NUMBER_OF_GENERATORS];
CRandomMersenne * m_generators[NUMBER_OF_GENERATORS];
uint32 counter=0;
uint32 generate_seed()
{
uint32 mstime = getMSTime();
uint32 stime = (uint32)time(NULL);
uint32 rnd[2];
rnd[0] = rand()*rand()*rand();
rnd[1] = rand()*rand()*rand();
uint32 val = mstime ^ rnd[0];
val += stime ^ rnd[1];
return val;
}
void InitRandomNumberGenerators()
{
srand(getMSTime());
for(uint32 i = 0; i < NUMBER_OF_GENERATORS; ++i) {
m_generators[i] = new CRandomMersenne(generate_seed());
m_locks[i] = new Mutex();
}
}
void CleanupRandomNumberGenerators()
{ srand(getMSTime());
for(uint32 i = 0; i < NUMBER_OF_GENERATORS; ++i) {
delete m_generators[i];
delete m_locks[i];
}
}
double RandomDouble()
{
double ret;
uint32 c;
counter = 0; // added cebernic: 10/06/2008 why not init ?
// might be overflow couple days?
for(;;)
{
c=counter%NUMBER_OF_GENERATORS;
if(m_locks[c]->AttemptAcquire())
{
ret = m_generators[c]->Random();
m_locks[c]->Release();
return ret;
}
++counter;
}
}
uint32 RandomUInt(uint32 n)
{
uint32 ret;
uint32 c;
counter = 0;
for(;;)
{
c=counter%NUMBER_OF_GENERATORS;
if(m_locks[c]->AttemptAcquire())
{
ret = m_generators[c]->IRandom(0, n);
m_locks[c]->Release();
return ret;
}
++counter;
}
}
double RandomDouble(double n)
{
return RandomDouble() * n;
}
float RandomFloat(float n)
{
return float(RandomDouble() * double(n));
}
float RandomFloat()
{
return float(RandomDouble());
}
uint32 RandomUInt()
{
uint32 ret;
uint32 c;
counter = 0;
for(;;)
{
c=counter%NUMBER_OF_GENERATORS;
if(m_locks[c]->AttemptAcquire())
{
ret = m_generators[c]->IRandom(0, RAND_MAX);
m_locks[c]->Release();
return ret;
}
++counter;
}
}
//////////////////////////////////////////////////////////////////////////
void CRandomMersenne::Init0(uint32 seed) {
// Detect computer architecture
union {double f; uint32 i[2];} convert;
convert.f = 1.0;
if (convert.i[1] == 0x3FF00000) Architecture = LITTLE_ENDIAN1;
else if (convert.i[0] == 0x3FF00000) Architecture = BIG_ENDIAN1;
else Architecture = NONIEEE;
// Seed generator
mt[0]= seed;
for (mti=1; mti < MERS_N; mti++) {
mt[mti] = (1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
}
}
void CRandomMersenne::RandomInit(uint32 seed) {
// Initialize and seed
Init0(seed);
// Randomize some more
for (int i = 0; i < 37; i++) BRandom();
}
void CRandomMersenne::RandomInitByArray(uint32 seeds[], int length) {
// Seed by more than 32 bits
int i, j, k;
// Initialize
Init0(19650218);
if (length <= 0) return;
// Randomize mt[] using whole seeds[] array
i = 1; j = 0;
k = (MERS_N > length ? MERS_N : length);
for (; k; k--) {
mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525UL)) + seeds[j] + j;
i++; j++;
if (i >= MERS_N) {mt[0] = mt[MERS_N-1]; i=1;}
if (j >= length) j=0;}
for (k = MERS_N-1; k; k--) {
mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941UL)) - i;
if (++i >= MERS_N) {mt[0] = mt[MERS_N-1]; i=1;}}
mt[0] = 0x80000000UL; // MSB is 1; assuring non-zero initial array
// Randomize some more
mti = 0;
for (int i = 0; i <= MERS_N; i++) BRandom();
}
uint32 CRandomMersenne::BRandom() {
// Generate 32 random bits
uint32 y;
if (mti >= MERS_N) {
// Generate MERS_N words at one time
const uint32 LOWER_MASK = (1LU << MERS_R) - 1; // Lower MERS_R bits
const uint32 UPPER_MASK = 0xFFFFFFFF << MERS_R; // Upper (32 - MERS_R) bits
static const uint32 mag01[2] = {0, MERS_A};
int kk;
for (kk=0; kk < MERS_N-MERS_M; kk++) {
y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK);
mt[kk] = mt[kk+MERS_M] ^ (y >> 1) ^ mag01[y & 1];}
for (; kk < MERS_N-1; kk++) {
y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK);
mt[kk] = mt[kk+(MERS_M-MERS_N)] ^ (y >> 1) ^ mag01[y & 1];}
y = (mt[MERS_N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK);
mt[MERS_N-1] = mt[MERS_M-1] ^ (y >> 1) ^ mag01[y & 1];
mti = 0;
}
y = mt[mti++];
#if 1
// Tempering (May be omitted):
y ^= y >> MERS_U;
y ^= (y << MERS_S) & MERS_B;
y ^= (y << MERS_T) & MERS_C;
y ^= y >> MERS_L;
#endif
return y;
}
double CRandomMersenne::Random() {
// Output random float number in the interval 0 <= x < 1
union {double f; uint32 i[2];} convert;
uint32 r = BRandom(); // Get 32 random bits
// The fastest way to convert random bits to floating point is as follows:
// Set the binary exponent of a floating point number to 1+bias and set
// the mantissa to random bits. This will give a random number in the
// interval [1,2). Then subtract 1.0 to get a random number in the interval
// [0,1). This procedure requires that we know how floating point numbers
// are stored. The storing method is tested in function RandomInit and saved
// in the variable Architecture.
// This shortcut allows the compiler to optimize away the following switch
// statement for the most common architectures:
#if defined(_M_IX86) || defined(_M_X64) || defined(__LITTLE_ENDIAN__)
Architecture = LITTLE_ENDIAN1;
#elif defined(__BIG_ENDIAN__)
Architecture = BIG_ENDIAN1;
#endif
#ifdef USING_BIG_ENDIAN
convert.i[1] = r << 20;
convert.i[0] = (r >> 12) | 0x3FF00000;
return convert.f - 1.0;
#else
convert.i[0] = r << 20;
convert.i[1] = (r >> 12) | 0x3FF00000;
return convert.f - 1.0;
#endif
// This somewhat slower method works for all architectures, including
// non-IEEE floating point representation:
//return (double)r * (1./((double)(uint32)(-1L)+1.));
}
int CRandomMersenne::IRandom(int min, int max) {
// Output random integer in the interval min <= x <= max
// Relative error on frequencies < 2^-32
if (max <= min) {
if (max == min) return min; else return 0x80000000;
}
// Multiply interval with random and truncate
int r = int((max - min + 1) * Random()) + min;
if (r > max) r = max;
return r;
}
int CRandomMersenne::IRandomX(int min, int max) {
// Output random integer in the interval min <= x <= max
// Each output value has exactly the same probability.
// This is obtained by rejecting certain bit values so that the number
// of possible bit values is divisible by the interval length
if (max <= min) {
if (max == min) return min; else return 0x80000000;
}
// 64 bit integers available. Use multiply and shift method
uint32 interval; // Length of interval
uint64 longran; // Random bits * interval
uint32 iran; // Longran / 2^32
uint32 remainder; // Longran % 2^32
interval = uint32(max - min + 1);
if (interval != LastInterval) {
// Interval length has changed. Must calculate rejection limit
// Reject when remainder = 2^32 / interval * interval
// RLimit will be 0 if interval is a power of 2. No rejection then
RLimit = uint32(((uint64)1 << 32) / interval) * interval - 1;
LastInterval = interval;
}
do { // Rejection loop
longran = (uint64)BRandom() * interval;
iran = (uint32)(longran >> 32);
remainder = (uint32)longran;
} while (remainder > RLimit);
// Convert back to signed and return result
return (int32)iran + min;
}
| [
"[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef",
"[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef"
]
| [
[
[
1,
1
],
[
5,
62
],
[
66,
82
],
[
85,
116
],
[
118,
305
]
],
[
[
2,
4
],
[
63,
65
],
[
83,
84
],
[
117,
117
]
]
]
|
1afa2ec6c95114edacb847da857c5f2cd9d9b87b | d71665b4e115bbf0abc680bb1c7eb31e69d86a1d | /SpacescapePlugin/include/SpacescapeNoiseMaterial.h | e4b0987b7ff3862e86eb08a62ebea55fd6a1d45d | [
"MIT"
]
| permissive | svenstaro/Spacescape | 73c140d06fe4ae76ac1a613295f1e9f96cdda3bb | 5a53ba43f8e4e78ca32ee5bb3d396ca7b0b71f7d | refs/heads/master | 2021-01-02T09:08:59.624369 | 2010-04-05T04:28:57 | 2010-04-05T04:28:57 | 589,597 | 7 | 6 | null | null | null | null | UTF-8 | C++ | false | false | 2,194 | h | /*
This source file is part of Spacescape
For the latest info, see http://alexcpeterson.com/spacescape
"He determines the number of the stars and calls them each by name. "
Psalm 147:4
The MIT License
Copyright (c) 2010 Alex Peterson
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 __SPACESCAPENOISEMATERIAL_H__
#define __SPACESCAPENOISEMATERIAL_H__
#include "SpacescapePrerequisites.h"
namespace Ogre
{
/** The SpacescapeNoiseMaterial class defines an Ogre Material
with two techniques - one for each of the noise shaders. One
noise shader is FBM (Fractal Brownian Motion) and the other is
Ridged FBM. The shaders are in the SpacescapeNoiseMaterial.cpp file
*/
class _SpacescapePluginExport SpacescapeNoiseMaterial
{
public:
/** Constructor
*/
SpacescapeNoiseMaterial(void);
/** Destructor
*/
~SpacescapeNoiseMaterial(void);
/** Get the noise material (create if necessary)
@return the noise material
*/
MaterialPtr getMaterial();
private:
// Noise material name
String mMaterialName;
};
}
#endif | [
"[email protected]"
]
| [
[
[
1,
63
]
]
]
|
1d3b5e86bf783ce03731e802554fee532f920679 | 6b3fa487428d3e2c66376572fd3c6dd3501b282c | /sapien190/trunk/source/Sandbox/Sapien/rpy/Application.cpp | 806b2b844e78db17b48f37a69eee243e1bac07ae | []
| no_license | kimbjerge/iirtsf10grp5 | 8626a10b23ee5cdde9944280c3cd06833e326adb | 3cbdd2ded74369d2cd455f63691abc834edfb95c | refs/heads/master | 2021-01-25T06:36:48.487881 | 2010-06-03T09:26:19 | 2010-06-03T09:26:19 | 32,920,746 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,081 | cpp | /********************************************************************
Rhapsody : 7.5
Login : KBE
Component : DefaultComponent
Configuration : DefaultConfig
Model Element : Application
//! Generated Date : Fri, 30, Apr 2010
File Path : DefaultComponent/DefaultConfig/Application.cpp
*********************************************************************/
//## auto_generated
#include "Application.h"
//## auto_generated
#include "Control.h"
//## auto_generated
#include "ECG.h"
//## auto_generated
#include "EDR.h"
//## auto_generated
#include "Execute.h"
//## auto_generated
#include "Pulse.h"
//## auto_generated
#include "Signal.h"
//## auto_generated
#include "Simulator.h"
//## auto_generated
#include "SmartPtr.h"
//## auto_generated
#include "Subject.h"
//## auto_generated
#include "Waveform.h"
//## package Application
/*********************************************************************
File Path : DefaultComponent/DefaultConfig/Application.cpp
*********************************************************************/
| [
"bjergekim@49e60964-1571-11df-9d2a-2365f6df44e6"
]
| [
[
[
1,
38
]
]
]
|
5488b3c5e1bb052dd38b26a797db8b13dbeea7f4 | f317b6eba86e00052f684e2001e1ea81f5357ee9 | /face_pickup/trunk/face_pickup/FaceComDetectionLoop.cpp | ace0ca88350fadf96bd8428d5fa817f47b6ecc68 | []
| no_license | Habib120/apmayfes2011-kao | 2ef24ff490511a6a08606f3ab05d4152069721b8 | cb167c9ab6182ad13077c9ffe851bdc5be6f4256 | refs/heads/master | 2016-09-01T17:54:20.659856 | 2011-10-06T03:47:33 | 2011-10-06T03:47:33 | 33,204,831 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 954 | cpp | #include "network.h"
#include "tracker.h"
#include "detection_thread.h"
#include "extractors.h"
#include <boost/ref.hpp>
using namespace std;
void FaceComDetectionLoop::Start()
{
loop_thread = new boost::thread(boost::ref(*this));
}
void FaceComDetectionLoop::Stop()
{
stop = true;
loop_thread->join();
}
void FaceComDetectionLoop::operator()()
{
SocketClient client;
while (!stop)
{
HeadData *data = tracker->GetCurrentHeadData();
if (data != 0)
{
std::vector<FaceComDetectionResult> results = detector->Detect(*data);
if (results.size() > 0)
{
FaceComDetectionResult result = results.at(0);
if (result.is_smiling)
{
client.Send("customer_smiled");
}
else if (!result.is_smiling)
{
client.Send("customer_dissmiled");
}
is_smiling = result.is_smiling;
}
data->ReleaseImage();
delete data;
}
else
{
Sleep(50);
}
}
}
| [
"[email protected]@4f86e157-8500-1dc0-33fe-d8cc54530173",
"[email protected]@4f86e157-8500-1dc0-33fe-d8cc54530173"
]
| [
[
[
1,
30
],
[
32,
34
],
[
36,
50
]
],
[
[
31,
31
],
[
35,
35
]
]
]
|
96ed97fad9dc9bda85156da098821529eb68c3e3 | 6581dacb25182f7f5d7afb39975dc622914defc7 | /easyMule/easyMule/src/UILayer/AdvanceTabWnd.h | c4f72b148bc7ba50b130f7adfc18207f50c2dcf4 | []
| no_license | dice2019/alexlabonline | caeccad28bf803afb9f30b9e3cc663bb2909cc4f | 4c433839965ed0cff99dad82f0ba1757366be671 | refs/heads/master | 2021-01-16T19:37:24.002905 | 2011-09-21T15:20:16 | 2011-09-21T15:20:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,625 | h | /*
* $Id: AdvanceTabWnd.h 8435 2008-11-24 08:52:24Z huby $
*
* this file is part of easyMule
* Copyright (C)2002-2008 VeryCD Dev Team ( strEmail.Format("%s@%s", "emuledev", "verycd.com") / http: * www.easymule.org )
*
* 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.
*/
#pragma once
#include "TabWnd.h"
#include "Localizee.h"
#include "TbcAdvance.h"
// CAdvanceTabWnd
class CAdvanceTabWnd : public CTabWnd , public CLocalizee
{
DECLARE_DYNAMIC(CAdvanceTabWnd)
LOCALIZEE_WND_CANLOCALIZE()
public:
CAdvanceTabWnd();
virtual ~CAdvanceTabWnd();
void Localize();
enum ETabId
{
TI_SERVER,
TI_KAD,
TI_STAT,
TI_MAX
};
protected:
POSITION m_aposTabs[TI_MAX];
CTbcAdvance m_toolbar;
void InitToolBar(void);
protected:
DECLARE_MESSAGE_MAP()
public:
BOOL IsTabActive(ETabId eTabId){return m_aposTabs[eTabId]==GetActiveTab();}
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};
| [
"damoguyan8844@3a4e9f68-f5c2-36dc-e45a-441593085838"
]
| [
[
[
1,
61
]
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.