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
dae969c453ee64cdd6c3c55ec9bfa58cbe3bf63d
bef7d0477a5cac485b4b3921a718394d5c2cf700
/dingus/dingus/gfx/VertexFormat.cpp
a605eaa14afeae054f78c790b68bd10a2710d01e
[ "MIT" ]
permissive
TomLeeLive/aras-p-dingus
ed91127790a604e0813cd4704acba742d3485400
22ef90c2bf01afd53c0b5b045f4dd0b59fe83009
refs/heads/master
2023-04-19T20:45:14.410448
2011-10-04T10:51:13
2011-10-04T10:51:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,698
cpp
// -------------------------------------------------------------------------- // Dingus project - a collection of subsystems for game/graphics applications // -------------------------------------------------------------------------- #include "stdafx.h" #include "VertexFormat.h" using namespace dingus; int CVertexFormat::calcFloat3Size( eFloat3Mode flt3 ) { assert( flt3 >= FLT3_NONE && flt3 <= FLT3_DEC3N ); int sizes[] = { 0, 3*4, 4, 4 }; return sizes[flt3]; } int CVertexFormat::calcFloat3Type( eFloat3Mode flt3 ) { assert( flt3 > FLT3_NONE && flt3 <= FLT3_DEC3N ); int types[] = { 0, D3DDECLTYPE_FLOAT3, D3DDECLTYPE_D3DCOLOR, D3DDECLTYPE_DEC3N }; return types[flt3]; } int CVertexFormat::calcSkinSize() const { eFloat3Mode data = getSkinDataMode(); if( data == FLT3_NONE ) return 0; eSkinMode skin = getSkinMode(); int skinsize = 4; // indices if( skin == SKIN_1BONE ) return skinsize; if( data != FLT3_FLOAT3 ) skinsize += 4; // non-float case: all weights packed into single DWORD else skinsize += skin * 4; // float case: (bones-1) floats return skinsize; } int CVertexFormat::calcSkinDataType() const { eFloat3Mode data = getSkinDataMode(); assert( data != FLT3_NONE ); if( data != FLT3_FLOAT3 ) return calcFloat3Type( data ); // non-float case else { // float case eSkinMode skin = getSkinMode(); switch( skin ) { case SKIN_2BONE: return D3DDECLTYPE_FLOAT1; case SKIN_3BONE: return D3DDECLTYPE_FLOAT2; case SKIN_4BONE: return D3DDECLTYPE_FLOAT3; } assert( false ); return D3DDECLTYPE_FLOAT1; } } int CVertexFormat::calcUVType( eUVMode uv ) { assert( uv > UV_NONE && uv <= UV_3D ); int types[] = { 0, D3DDECLTYPE_FLOAT1, D3DDECLTYPE_FLOAT2, D3DDECLTYPE_FLOAT3 }; return types[uv]; } int CVertexFormat::calcVertexSize() const { int size = 0; // position if( hasPosition() ) size += 3*4; // normals, tangents, binormals size += calcFloat3Size( getNormalMode() ); size += calcFloat3Size( getTangentMode() ); size += calcFloat3Size( getBinormMode() ); // skin size += calcSkinSize(); // color if( hasColor() ) size += 4; // UVs for( int i = 0; i < UV_COUNT; ++i ) { size += calcUVSize( getUVMode(i) ); } return size; } int CVertexFormat::calcComponentCount() const { int size = 0; // position if( hasPosition() ) ++size; // normals, tangents, binormals if( getNormalMode() ) ++size; if( getTangentMode() ) ++size; if( getBinormMode() ) ++size; // skin if( getSkinDataMode() ) { if( getSkinMode() ) size += 2; // weights and indices else ++size; // just 1-bone indices } // color if( hasColor() ) ++size; // UVs for( int i = 0; i < UV_COUNT; ++i ) if( getUVMode(i) ) ++size; return size; } #define COMMON_ELS { els->Stream = (WORD)stream; els->Offset = (WORD)offset; els->Method = D3DDECLMETHOD_DEFAULT; } void CVertexFormat::calcVertexDecl( D3DVERTEXELEMENT9* els, int stream, int uvIdx ) const { int offset = 0; // position if( hasPosition() ) { COMMON_ELS; els->Type = D3DDECLTYPE_FLOAT3; els->Usage = D3DDECLUSAGE_POSITION; els->UsageIndex = static_cast<BYTE>(stream); ++els; offset += 4*3; } // skin if( getSkinDataMode() ) { // weights (only if non-1-bone) if( getSkinMode() != SKIN_1BONE ) { COMMON_ELS; els->Type = static_cast<BYTE>(calcSkinDataType()); els->Usage = D3DDECLUSAGE_BLENDWEIGHT; els->UsageIndex = static_cast<BYTE>(stream); ++els; offset += calcSkinSize()-4; } // indices COMMON_ELS; els->Type = D3DDECLTYPE_D3DCOLOR; els->Usage = D3DDECLUSAGE_BLENDINDICES; els->UsageIndex = static_cast<BYTE>(stream); ++els; offset += 4; } // normal if( getNormalMode() ) { COMMON_ELS; els->Type = static_cast<BYTE>(calcFloat3Type(getNormalMode())); els->Usage = D3DDECLUSAGE_NORMAL; els->UsageIndex = static_cast<BYTE>(stream); ++els; offset += calcFloat3Size(getNormalMode()); } // tangent if( getTangentMode() ) { COMMON_ELS; els->Type = static_cast<BYTE>(calcFloat3Type(getTangentMode())); els->Usage = D3DDECLUSAGE_TANGENT; els->UsageIndex = static_cast<BYTE>(stream); ++els; offset += calcFloat3Size(getTangentMode()); } // binormal if( getBinormMode() ) { COMMON_ELS; els->Type = static_cast<BYTE>(calcFloat3Type(getBinormMode())); els->Usage = D3DDECLUSAGE_BINORMAL; els->UsageIndex = static_cast<BYTE>(stream); ++els; offset += calcFloat3Size(getBinormMode()); } // color if( hasColor() ) { COMMON_ELS; els->Type = D3DDECLTYPE_D3DCOLOR; els->Usage = D3DDECLUSAGE_COLOR; els->UsageIndex = static_cast<BYTE>(stream); ++els; offset += 4; } // UVs for( int i = 0; i < UV_COUNT; ++i ) { eUVMode uv = getUVMode(i); if( uv ) { COMMON_ELS; els->Type = static_cast<BYTE>(calcUVType(uv)); els->Usage = D3DDECLUSAGE_TEXCOORD; els->UsageIndex = static_cast<BYTE>(uvIdx + i); ++els; offset += calcUVSize(uv); } } } int CVertexFormat::calcSkinWeightsOffset() const { return hasPosition() ? 4*3 : 0; } int CVertexFormat::calcSkinIndicesOffset() const { int offset = calcSkinWeightsOffset(); if( getSkinDataMode() ) offset += calcSkinSize()-4; return offset; } int CVertexFormat::calcNormalOffset() const { int offset = calcSkinIndicesOffset(); if( getSkinDataMode() ) offset += 4; return offset; } int CVertexFormat::calcTangentOffset() const { return calcNormalOffset() + calcFloat3Size( getNormalMode() ); } int CVertexFormat::calcBinormOffset() const { return calcTangentOffset() + calcFloat3Size( getTangentMode() ); }
[ "aras@unity3d.com" ]
[ [ [ 1, 216 ] ] ]
1c27a073b8a8b102b3891f63ab5b411684bf55dc
299a1b0fca9e1de3858a5ebeaf63be6dc3a02b48
/tags/051101/dingus/dingus/resource/StorageResourceBundle.h
fba447394fc629ff99fdde11cb92e4e491f295a8
[]
no_license
BackupTheBerlios/dingus-svn
331d7546a6e7a5a3cb38ffb106e57b224efbf5df
1223efcf4c2079f58860d7fa685fa5ded8f24f32
refs/heads/master
2016-09-05T22:15:57.658243
2006-09-02T10:10:47
2006-09-02T10:10:47
40,673,143
0
0
null
null
null
null
UTF-8
C++
false
false
4,190
h
// -------------------------------------------------------------------------- // Dingus project - a collection of subsystems for game/graphics applications // -------------------------------------------------------------------------- #ifndef __STORAGE_RESOURCE_BUNDLE_H #define __STORAGE_RESOURCE_BUNDLE_H #include "ResourceBundle.h" #include "ResourceId.h" #include "../console/Console.h" #include "../utils/Errors.h" namespace dingus { template<class T> class CStorageResourceBundle : public IResourceBundle { private: typedef std::map<CResourceId, T*> TResourceMap; public: virtual ~CStorageResourceBundle() = 0 {} /** * Gets or loads resource given it's name. * Name is without pre-path and without file extension. */ T* getResourceById( const CResourceId& id ) { T* resource = trygetResourceById( id ); if( resource ) return resource; // error std::string msg = "Can't find resource '" + id.getUniqueName() + "'"; CConsole::CON_ERROR.write( msg ); THROW_ERROR( msg ); } /** * Gets or loads resource given it's name, doesn't throw. * Name is without pre-path and without file extension. */ T* trygetResourceById( const CResourceId& id ) { // find if already loaded T* resource = findResource( id ); if( resource ) return resource; // try load resource = tryLoadResourceById( id ); if( resource ) { mResourceMap.insert( std::make_pair( id, resource ) ); return resource; } return NULL; } // NOTE: deletes the resource, so make sure no one references it! void clearResourceById( CResourceId const& id ) { TResourceMap::iterator it = mResourceMap.find( id ); if( it != mResourceMap.end() ) { assert( (*it).second ); // error std::string msg = "Clearing resource '" + id.getUniqueName() + "'"; CONSOLE.write( msg ); deleteResource( *it->second ); mResourceMap.erase( it ); } } void clear() { for( TResourceMap::iterator it = mResourceMap.begin(); it != mResourceMap.end(); ) { assert( (*it).second ); deleteResource( *it->second ); it = mResourceMap.erase( it ); } } void addDirectory( const std::string& d ) { mDirectories.push_back(d); } protected: CStorageResourceBundle() { } T* findResource( CResourceId const& id ) { TResourceMap::const_iterator it = mResourceMap.find( id ); return ( ( it != mResourceMap.end() ) ? it->second : NULL ); } /** * Try to load resource. Default implementation tries * all extensions. Simpler ones can just append pre-dir and extension * to id and use loadResourceById(), or some other bundle to load. */ virtual T* tryLoadResourceById( const CResourceId& id ) { int nd = mDirectories.size(); int ne = mExtensions.size(); // try all directories for( int d = 0; d < nd; ++d ) { // try all extensions for( int e = 0; e < ne; ++e ) { CResourceId fullid( mDirectories[d] + id.getUniqueName() + mExtensions[e] ); T* resource = loadResourceById( id, fullid ); if( resource ) return resource; } } // If all that failed, maybe ID already contains full path and extension // (maybe useful in tools). Try loading it. return loadResourceById( id, id ); } /** * Performs actual loading of resource. * On failure to find resource, should silently return NULL - storage * bundle will attempt another extension. On other failure * (eg. format mismatch) can assert/throw etc. * * @param id Resource ID. * @param fullName Full path to resource (with pre-dir(s) and extension). */ virtual T* loadResourceById( const CResourceId& id, const CResourceId& fullName ) = 0; virtual void deleteResource( T& resource ) = 0; protected: typedef std::vector<std::string> TStringVector; void addExtension( const char* e ) { mExtensions.push_back(e); } const TStringVector& getExtensions() const { return mExtensions; } const TStringVector& getDirectories() const { return mDirectories; } protected: TResourceMap mResourceMap; private: TStringVector mDirectories; TStringVector mExtensions; }; }; // namespace #endif
[ "nearaz@73827abb-88f4-0310-91e6-a2b8c1a3e93d" ]
[ [ [ 1, 141 ] ] ]
1e5fe557e9aeab11b62464bf0b33f9fd18db6262
96e96a73920734376fd5c90eb8979509a2da25c0
/C3DE/Grass.cpp
0b2b70d29ae3a233dad1b1580f47e69037a54f1b
[]
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
7,149
cpp
#include "Grass.h" #include "D3DRenderer.h" #include "Math.h" #include "GrassFX.h" #include "ResourceManager.h" IDirect3DVertexDeclaration9* GrassVertex::Decl = 0; Grass::Grass(int a_numBlocks, D3DXVECTOR3 a_blockOffset) : D3DMesh() { m_numBlocks = a_numBlocks; m_blockOffset = a_blockOffset; BuildGrass(); D3DImage * d3dImage = new D3DImage(ResourceManager::GetInstance()->GetTextureByID(IMAGE_GRASS_BILLBOARD_ID)); AddTexture((Image *) d3dImage); Material *t_material = new Material( D3DXCOLOR(1.0f, 1.0f, 1.0f,1.0f),D3DXCOLOR(1.0f, 1.0f, 1.0f,1.0f), D3DXCOLOR(1.0f, 1.0f, 1.0f,1.0f), 16.0f); AddMaterial(t_material); m_effect = ShaderManager::GetInstance()->GetFXByID(SHADER_GRASS_FX_ID); } Grass::~Grass() { } void Grass::BuildGrass() { IDirect3DDevice9 *t_device = D3DRenderer::GetDevice(); D3DVERTEXELEMENT9 GrassVertexElements[] = { {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, {0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0}, {0, 24, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1}, {0, 32, D3DDECLTYPE_FLOAT1, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 2}, {0, 36, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, D3DDECL_END() }; HR(t_device->CreateVertexDeclaration(GrassVertexElements, &GrassVertex::Decl)); D3DVERTEXELEMENT9 elems[MAX_FVF_DECL_SIZE]; UINT numElems = 0; HR(GrassVertex::Decl->GetDeclaration(elems, &numElems)); //const int NUM_GRASS_BLOCKS = 5; HR(D3DXCreateMesh(m_numBlocks*2, m_numBlocks*4, D3DXMESH_MANAGED, elems, t_device, &m_xMesh)); GrassVertex* v = 0; WORD* k = 0; HR(m_xMesh->LockVertexBuffer(0, (void**)&v)); HR(m_xMesh->LockIndexBuffer(0, (void**)&k)); int indexOffset = 0; // Randomly generate a grass block (three intersecting quads) around the // terrain in the height range [35, 50] (similar to the trees). for(int i = 0; i < m_numBlocks; ++i) { //============================================ // Construct vertices. // Generate random position in region. Note that we also shift // this region to place it in the world. float x = m_blockOffset.x*i; float z = m_blockOffset.z*i; float y = m_blockOffset.y*i; float sx = GetRandomFloat(0.75f, 1.25f); float sy = GetRandomFloat(0.75f, 1.25f); float sz = GetRandomFloat(0.75f, 1.25f); D3DXVECTOR3 pos(x, y, z); D3DXVECTOR3 scale(sx, sy, sz); ///////////////////////// float amp = GetRandomFloat(0.5f, 1.0f); #if 0 v[i*4] = GrassVertex(D3DXVECTOR3(-1.0f, -0.5f, 0.0f), D3DXVECTOR2(0.0f, 1.0f), 0.0f); v[i*4 + 1] = GrassVertex(D3DXVECTOR3(-1.0f, 0.5f, 0.0f), D3DXVECTOR2(0.0f, 0.0f), amp); v[i*4 + 2] = GrassVertex(D3DXVECTOR3(1.0f, 0.5f, 0.0f), D3DXVECTOR2(1.0f, 0.0f), amp); v[i*4 + 3] = GrassVertex(D3DXVECTOR3(1.0f, -0.5f, 0.0f), D3DXVECTOR2(1.0f, 1.0f), 0.0f); #else float t_width = 2.0f; float t_height = 1.0f; float t_minX = -1.0f; float t_minY = -0.5f; float t_halfHeight = t_height/2.0f; v[i*4] = GrassVertex(D3DXVECTOR3(t_minX + x, t_minY + y + t_halfHeight, z), D3DXVECTOR2(0.0f, 1.0f), 0.0f); v[i*4 + 1] = GrassVertex(D3DXVECTOR3(t_minX + x, t_minY + t_height + y + t_halfHeight, z), D3DXVECTOR2(0.0f, 0.0f), amp); v[i*4 + 2] = GrassVertex(D3DXVECTOR3(t_minX + t_width + x, t_minY + t_height + y + t_halfHeight, z), D3DXVECTOR2(1.0f, 0.0f), amp); v[i*4 + 3] = GrassVertex(D3DXVECTOR3(t_minX + t_width + x, t_minY + y + t_halfHeight, z), D3DXVECTOR2(1.0f, 1.0f), 0.0f); #endif k[i*6] = 0 + indexOffset; k[i*6 + 1] = 1 + indexOffset; k[i*6 + 2] = 2 + indexOffset; k[i*6 + 3] = 0 + indexOffset; k[i*6 + 4] = 2 + indexOffset; k[i*6 + 5] = 3 + indexOffset; indexOffset += 4; for(int j = 0; j < 4; ++j) { //v[i*4 + j].pos.x *= scale.x; //v[i*4 + j].pos.y *= scale.y; //v[i*4 + j].pos.z *= scale.z; //v[i].colorOffset = D3DXCOLOR(GetRandomFloat(0.0f, 1.0f), GetRandomFloat(0.0f, 0.2f), GetRandomFloat(0.0f, 0.1f), 0.0f); v[i*4 + j].colorOffset = D3DXCOLOR(0.0f, 0.0f, 0.0f, 0.0f); } float heightOver2 = (v[i*4 + 1].pos.y - v[i*4].pos.y) /2; pos.y += heightOver2; v[i*4].quadPos = pos; v[i*4 + 1].quadPos = pos; v[i*4 + 2].quadPos = pos; v[i*4 + 3].quadPos = pos; ////////////////////////////// //v += 4; //k += 6; } HR(m_xMesh->UnlockVertexBuffer()); HR(m_xMesh->UnlockIndexBuffer()); HR(m_xMesh->LockVertexBuffer(0, (void**)&v)); D3DXVECTOR3 t_min; D3DXVECTOR3 t_max; HR(D3DXComputeBoundingBox(&v->pos, m_xMesh->GetNumVertices(), m_xMesh->GetNumBytesPerVertex(), &t_min, &t_max)); //t_min = D3DXVECTOR3(-1.0f, 0.0f, 0.0f); //t_max = D3DXVECTOR3(21.0f, 1.0f, 4.0f); m_boundingBox = new AABB(t_min, t_max); //m_boundingBox = new AABB(); HR(m_xMesh->UnlockVertexBuffer()); // Fill in the attribute buffer (everything in subset 0) DWORD* attributeBufferPtr = 0; HR(m_xMesh->LockAttributeBuffer(0, &attributeBufferPtr)); for(UINT i = 0; i < m_xMesh->GetNumFaces(); ++i) attributeBufferPtr[i] = 0; HR(m_xMesh->UnlockAttributeBuffer()); DWORD* adj = new DWORD[m_xMesh->GetNumFaces()*3]; HR(m_xMesh->GenerateAdjacency(EPSILON, adj)); HR(m_xMesh->OptimizeInplace(D3DXMESHOPT_ATTRSORT|D3DXMESHOPT_VERTEXCACHE, adj, 0, 0, 0)); delete [] adj; } void Grass::SetShaderHandlers() { GrassFX *t_effect = (GrassFX *) m_effect; t_effect->SetObjectMaterials( m_currentMaterial->GetAmbient(), m_currentMaterial->GetDiffuse(), m_currentMaterial->GetSpecular(), m_currentMaterial->GetSpecularPower()); D3DImage *t_d3dText = (D3DImage *) m_currentTexture; t_effect->SetObjectTexture(t_d3dText->GetTexture()); t_effect->SetTransformMatrix(GetTransformMatrix()); //t_effect->SetAlpha(m_alpha); } void Grass::BuildGrassFin(GrassVertex *v, WORD *k, int & indexOffset, D3DXVECTOR3 &worldPos, D3DXVECTOR3 &scale) { float amp = GetRandomFloat(0.5f, 1.0f); v[0] = GrassVertex(D3DXVECTOR3(-1.0f, -0.5f, 0.0f), D3DXVECTOR2(0.0f, 1.0f), 0.0f); v[1] = GrassVertex(D3DXVECTOR3(-1.0f, 0.5f, 0.0f), D3DXVECTOR2(0.0f, 0.0f), amp); v[2] = GrassVertex(D3DXVECTOR3(1.0f, 0.5f, 0.0f), D3DXVECTOR2(1.0f, 0.0f), amp); v[3] = GrassVertex(D3DXVECTOR3(1.0f, -0.5f, 0.0f), D3DXVECTOR2(1.0f, 1.0f), 0.0f); k[0] = 0 + indexOffset; k[1] = 1 + indexOffset; k[2] = 2 + indexOffset; k[3] = 0 + indexOffset; k[4] = 2 + indexOffset; k[5] = 3 + indexOffset; indexOffset += 4; for(int i = 0; i < 4; ++i) { v[i].pos.x *= scale.x; v[i].pos.y *= scale.y; v[i].pos.z *= scale.z; //v[i].colorOffset = D3DXCOLOR(GetRandomFloat(0.0f, 1.0f), GetRandomFloat(0.0f, 0.2f), GetRandomFloat(0.0f, 0.1f), 0.0f); v[i].colorOffset = D3DXCOLOR(0.0f, 0.0f, 0.0f, 0.0f); } float heightOver2 = (v[1].pos.y - v[0].pos.y) /2; worldPos.y += heightOver2; v[0].quadPos = worldPos; v[1].quadPos = worldPos; v[2].quadPos = worldPos; v[3].quadPos = worldPos; }
[ "caiocsabino@7e2be596-0d54-0410-9f9d-cf4183935158" ]
[ [ [ 1, 236 ] ] ]
609b491e12b890fe6f8324105e8a7a72b90386c0
6d680e20e4a703f0aa0d4bb5e50568143241f2d5
/src/MobiHealth/buttonlabel.h
d76a648a56f06360697101d855a35346726fe4df
[]
no_license
sirnicolaz/MobiHealt
f7771e53a4a80dcea3d159eca729e9bd227e8660
bbfd61209fb683d5f75f00bbf81b24933922baac
refs/heads/master
2021-01-20T12:21:17.215536
2010-04-21T14:21:16
2010-04-21T14:21:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
543
h
#ifndef BUTTONLABEL_H #define BUTTONLABEL_H #include <QLabel> class ButtonLabel : public QLabel { Q_OBJECT private: /* icons object */ QPixmap normalIcon; QPixmap pressedIcon; public: ButtonLabel(QPixmap normalIcon, QPixmap pressedIcon, QWidget *parent=0); void mousePressEvent( QMouseEvent * event ); void mouseReleaseEvent( QMouseEvent * event ); signals: /* signal to notify the press action */ //void clicked(); /* signal to notify the release action */ void released(); }; #endif // BUTTONLABEL_H
[ "andrea.graz@gmail.com" ]
[ [ [ 1, 25 ] ] ]
cf140aa694b958e467b58e077d141d0affe8ce74
0b66a94448cb545504692eafa3a32f435cdf92fa
/tags/cms/cbear.berlios.de/windows/bool.hpp
471a54b53da6fd6eb1411db7d24389639c3cadab
[ "MIT" ]
permissive
BackupTheBerlios/cbear-svn
e6629dfa5175776fbc41510e2f46ff4ff4280f08
0109296039b505d71dc215a0b256f73b1a60b3af
refs/heads/master
2021-03-12T22:51:43.491728
2007-09-28T01:13:48
2007-09-28T01:13:48
40,608,034
0
0
null
null
null
null
UTF-8
C++
false
false
648
hpp
#ifndef CBEAR_BERLIOS_DE_WINDOWS_BOOL_HPP_INCLUDED #define CBEAR_BERLIOS_DE_WINDOWS_BOOL_HPP_INCLUDED #include <cbear.berlios.de/windows/base.hpp> #include <cbear.berlios.de/policy/main.hpp> namespace cbear_berlios_de { namespace windows { // Boolean variable (should be TRUE or FALSE). class bool_t: public base::initialized< ::BOOL> { private: typedef base::initialized< ::BOOL> base_t; public: bool_t() { } bool_t(bool X): base_t(X ? TRUE: FALSE) { } explicit bool_t(::BOOL X): base_t(X) { } operator bool() const throw() { return this->get() != FALSE; } }; } } #endif
[ "sergey_shandar@e6e9985e-9100-0410-869a-e199dc1b6838" ]
[ [ [ 1, 44 ] ] ]
c29d15a49cb42ea3748a3a291548fa46dbd15f78
968aa9bac548662b49af4e2b873b61873ba6f680
/bintools/checklib/library/library.h
f0ff6bab917d3463423628f866e03eebbe8e1ea3
[]
no_license
anagovitsyn/oss.FCL.sftools.dev.build
b3401a1ee3fb3c8f3d5caae6e5018ad7851963f3
f458a4ce83f74d603362fe6b71eaa647ccc62fee
refs/heads/master
2021-12-11T09:37:34.633852
2010-12-01T08:05:36
2010-12-01T08:05:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,377
h
// Copyright (c) 2008-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: // Class for reading libraries in Unix "ar" format. // // #ifndef LIBRARY_H #define LIBRARY_H #include <vector> #include <utility> class Library { public: Library(const char a_file_name[]); ~Library(); public: bool contains_symbol(const char[]) const; const std::vector< std::pair<const char*, const char*> >* get_objects() const; private: const char* _eat_ar_header(const char*, const char*) const; const char* _eat_sym_table(const char*, const char*) const; const char* _eat_junk_objs(const char*, const char*) const; const char* _eat_obj_header(const char*, const char*, unsigned long*, const char* = 0) const; private: const char* m_mem_p; const char* m_first_p; const char* m_last_p; mutable std::vector<const char*> m_symbols; mutable std::vector< std::pair<const char*, const char*> > m_objects; }; #endif
[ "alex.gilkes@nokia.com" ]
[ [ [ 1, 53 ] ] ]
6a337913ff0f4b0358a1fb8f7eda0397b82ae750
ce1b0d027c41f70bc4cfa13cb05f09bd4edaf6a2
/ edge2d --username zmhn320@163.com/Plugins/IrrSoundSystem/IrrKlang/include/vector3d.h
0ec8181992c4d5eb31c7e5d52ec88c329376ba8c
[]
no_license
ratalaika/edge2d
11189c41b166960d5d7d5dbcf9bfaf833a41c079
79470a0fa6e8f5ea255df1696da655145bbf83ff
refs/heads/master
2021-01-10T04:59:22.495428
2010-02-19T13:45:03
2010-02-19T13:45:03
36,088,756
1
0
null
null
null
null
UTF-8
C++
false
false
8,221
h
// Copyright (C) 2002-2007 Nikolaus Gebhardt // This file is part of the "irrKlang" library. // For conditions of distribution and use, see copyright notice in irrKlang.h #ifndef __IRR_POINT_3D_H_INCLUDED__ #define __IRR_POINT_3D_H_INCLUDED__ #include <math.h> #include "irrMath.h" #include "irrTypes.h" namespace irr { namespace core { //! 3d vector template class with lots of operators and methods. template <class T> class vector3d { public: vector3d(): X(0), Y(0), Z(0) {}; vector3d(T nx, T ny, T nz) : X(nx), Y(ny), Z(nz) {}; vector3d(const vector3d<T>& other) :X(other.X), Y(other.Y), Z(other.Z) {}; // operators vector3d<T> operator-() const { return vector3d<T>(-X, -Y, -Z); } vector3d<T>& operator=(const vector3d<T>& other) { X = other.X; Y = other.Y; Z = other.Z; return *this; } vector3d<T> operator+(const vector3d<T>& other) const { return vector3d<T>(X + other.X, Y + other.Y, Z + other.Z); } vector3d<T>& operator+=(const vector3d<T>& other) { X+=other.X; Y+=other.Y; Z+=other.Z; return *this; } vector3d<T> operator-(const vector3d<T>& other) const { return vector3d<T>(X - other.X, Y - other.Y, Z - other.Z); } vector3d<T>& operator-=(const vector3d<T>& other) { X-=other.X; Y-=other.Y; Z-=other.Z; return *this; } vector3d<T> operator*(const vector3d<T>& other) const { return vector3d<T>(X * other.X, Y * other.Y, Z * other.Z); } vector3d<T>& operator*=(const vector3d<T>& other) { X*=other.X; Y*=other.Y; Z*=other.Z; return *this; } vector3d<T> operator*(const T v) const { return vector3d<T>(X * v, Y * v, Z * v); } vector3d<T>& operator*=(const T v) { X*=v; Y*=v; Z*=v; return *this; } vector3d<T> operator/(const vector3d<T>& other) const { return vector3d<T>(X / other.X, Y / other.Y, Z / other.Z); } vector3d<T>& operator/=(const vector3d<T>& other) { X/=other.X; Y/=other.Y; Z/=other.Z; return *this; } vector3d<T> operator/(const T v) const { T i=(T)1.0/v; return vector3d<T>(X * i, Y * i, Z * i); } vector3d<T>& operator/=(const T v) { T i=(T)1.0/v; X*=i; Y*=i; Z*=i; return *this; } bool operator<=(const vector3d<T>&other) const { return X<=other.X && Y<=other.Y && Z<=other.Z;}; bool operator>=(const vector3d<T>&other) const { return X>=other.X && Y>=other.Y && Z>=other.Z;}; bool operator==(const vector3d<T>& other) const { return other.X==X && other.Y==Y && other.Z==Z; } bool operator!=(const vector3d<T>& other) const { return other.X!=X || other.Y!=Y || other.Z!=Z; } // functions //! returns if this vector equals the other one, taking floating point rounding errors into account bool equals(const vector3d<T>& other) { return core::equals(X, other.X) && core::equals(Y, other.Y) && core::equals(Z, other.Z); } void set(const T nx, const T ny, const T nz) {X=nx; Y=ny; Z=nz; } void set(const vector3d<T>& p) { X=p.X; Y=p.Y; Z=p.Z;} //! Returns length of the vector. f64 getLength() const { return sqrt(X*X + Y*Y + Z*Z); } //! Returns squared length of the vector. /** This is useful because it is much faster then getLength(). */ f64 getLengthSQ() const { return X*X + Y*Y + Z*Z; } //! Returns the dot product with another vector. T dotProduct(const vector3d<T>& other) const { return X*other.X + Y*other.Y + Z*other.Z; } //! Returns distance from an other point. /** Here, the vector is interpreted as point in 3 dimensional space. */ f64 getDistanceFrom(const vector3d<T>& other) const { f64 vx = X - other.X; f64 vy = Y - other.Y; f64 vz = Z - other.Z; return sqrt(vx*vx + vy*vy + vz*vz); } //! Returns squared distance from an other point. /** Here, the vector is interpreted as point in 3 dimensional space. */ f32 getDistanceFromSQ(const vector3d<T>& other) const { f32 vx = X - other.X; f32 vy = Y - other.Y; f32 vz = Z - other.Z; return (vx*vx + vy*vy + vz*vz); } //! Calculates the cross product with another vector vector3d<T> crossProduct(const vector3d<T>& p) const { return vector3d<T>(Y * p.Z - Z * p.Y, Z * p.X - X * p.Z, X * p.Y - Y * p.X); } //! Returns if this vector interpreted as a point is on a line between two other points. /** It is assumed that the point is on the line. */ bool isBetweenPoints(const vector3d<T>& begin, const vector3d<T>& end) const { f32 f = (f32)(end - begin).getLengthSQ(); return (f32)getDistanceFromSQ(begin) < f && (f32)getDistanceFromSQ(end) < f; } //! Normalizes the vector. vector3d<T>& normalize() { T l = (T)getLength(); if (l == 0) return *this; l = (T)1.0 / l; X *= l; Y *= l; Z *= l; return *this; } //! Sets the lenght of the vector to a new value void setLength(T newlength) { normalize(); *this *= newlength; } //! Inverts the vector. void invert() { X *= -1.0f; Y *= -1.0f; Z *= -1.0f; } //! Rotates the vector by a specified number of degrees around the Y //! axis and the specified center. //! \param degrees: Number of degrees to rotate around the Y axis. //! \param center: The center of the rotation. void rotateXZBy(f64 degrees, const vector3d<T>& center) { degrees *=GRAD_PI2; T cs = (T)cos(degrees); T sn = (T)sin(degrees); X -= center.X; Z -= center.Z; set(X*cs - Z*sn, Y, X*sn + Z*cs); X += center.X; Z += center.Z; } //! Rotates the vector by a specified number of degrees around the Z //! axis and the specified center. //! \param degrees: Number of degrees to rotate around the Z axis. //! \param center: The center of the rotation. void rotateXYBy(f64 degrees, const vector3d<T>& center) { degrees *=GRAD_PI2; T cs = (T)cos(degrees); T sn = (T)sin(degrees); X -= center.X; Y -= center.Y; set(X*cs - Y*sn, X*sn + Y*cs, Z); X += center.X; Y += center.Y; } //! Rotates the vector by a specified number of degrees around the X //! axis and the specified center. //! \param degrees: Number of degrees to rotate around the X axis. //! \param center: The center of the rotation. void rotateYZBy(f64 degrees, const vector3d<T>& center) { degrees *=GRAD_PI2; T cs = (T)cos(degrees); T sn = (T)sin(degrees); Z -= center.Z; Y -= center.Y; set(X, Y*cs - Z*sn, Y*sn + Z*cs); Z += center.Z; Y += center.Y; } //! Returns interpolated vector. /** \param other: other vector to interpolate between \param d: value between 0.0f and 1.0f. */ vector3d<T> getInterpolated(const vector3d<T>& other, f32 d) const { f32 inv = 1.0f - d; return vector3d<T>(other.X*inv + X*d, other.Y*inv + Y*d, other.Z*inv + Z*d); } //! Gets the Y and Z rotations of a vector. /** Thanks to Arras on the Irrlicht forums to add this method. \return A vector representing the rotation in degrees of this vector. The Z component of the vector will always be 0. */ vector3d<T> getHorizontalAngle() { vector3d<T> angle; angle.Y = (T)atan2(X, Z); angle.Y *= (f32)GRAD_PI; if (angle.Y < 0.0f) angle.Y += 360.0f; if (angle.Y >= 360.0f) angle.Y -= 360.0f; f32 z1 = (T)sqrt(X*X + Z*Z); angle.X = (T)atan2(z1, Y); angle.X *= (f32)GRAD_PI; angle.X -= 90.0f; if (angle.X < 0.0f) angle.X += 360.0f; if (angle.X >= 360) angle.X -= 360.0f; return angle; } //! Fills an array of 4 values with the vector data (usually floats). /** Useful for setting in shader constants for example. The fourth value will always be 0. */ void getAs4Values(T* array) { array[0] = X; array[1] = Y; array[2] = Z; array[3] = 0; } // member variables T X, Y, Z; }; //! Typedef for a f32 3d vector. typedef vector3d<f32> vector3df; //! Typedef for an integer 3d vector. typedef vector3d<s32> vector3di; template<class S, class T> vector3d<T> operator*(const S scalar, const vector3d<T>& vector) { return vector*scalar; } } // end namespace core } // end namespac irr #endif
[ "zmhn320@163.com@539dfdeb-0f3d-0410-9ace-d34ff1985647" ]
[ [ [ 1, 255 ] ] ]
46f26386d8b3f4676c20fa7b6061efd9338f8b9c
33f59b1ba6b12c2dd3080b24830331c37bba9fe2
/Depend/Foundation/ComputationalGeometry/Wm4DelPolyhedronFace.h
4b5c1f1322cf7eee0d6edf88fb366e75c4d9a08c
[]
no_license
daleaddink/flagship3d
4835c223fe1b6429c12e325770c14679c42ae3c6
6cce5b1ff7e7a2d5d0df7aa0594a70d795c7979a
refs/heads/master
2021-01-15T16:29:12.196094
2009-11-01T10:18:11
2009-11-01T10:18:11
37,734,654
1
0
null
null
null
null
UTF-8
C++
false
false
1,088
h
// Geometric Tools, Inc. // http://www.geometrictools.com // Copyright (c) 1998-2006. All Rights Reserved // // The Wild Magic Version 4 Foundation Library source code is supplied // under the terms of the license agreement // http://www.geometrictools.com/License/Wm4FoundationLicense.pdf // and may not be copied or disclosed except in accordance with the terms // of that agreement. #ifndef WM4DELPOLYHEDRONFACE_H #define WM4DELPOLYHEDRONFACE_H #include "Wm4FoundationLIB.h" #include "Wm4ETManifoldMesh.h" #include "Wm4DelTetrahedron.h" namespace Wm4 { template <class Real> class WM4_FOUNDATION_ITEM DelPolyhedronFace : public ETManifoldMesh::Triangle { public: DelPolyhedronFace (int iV0 = -1, int iV1 = -1, int iV2 = -1, int iNullIndex = -1, DelTetrahedron<Real>* pkTri = 0); static ETManifoldMesh::TPtr TCreator (int iV0, int iV1, int iV2); int NullIndex; DelTetrahedron<Real>* Tetra; }; typedef DelPolyhedronFace<float> DelPolyhedronFacef; typedef DelPolyhedronFace<double> DelPolyhedronFaced; } #endif
[ "yf.flagship@e79fdf7c-a9d8-11de-b950-3d5b5f4ea0aa" ]
[ [ [ 1, 39 ] ] ]
bba6f23f961db9567791d3a2268da669081b1522
68d8ddd1f19bcf70c9429f22ff1075c0c6f5479b
/engine/board.h
b7ec3565a21140fdfe2655be6f47ca9db29b16b6
[]
no_license
kusano/Shogi55GUI
532df08ca2053dedc0b6ac13e0a3ac6e245fc00a
3b1552ee29578a58929a5c5b9f5a27790fa25d1d
refs/heads/master
2021-05-14T02:08:21.126449
2008-12-18T03:56:58
2008-12-18T03:56:58
116,587,616
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
4,034
h
#pragma once #include <vector> #include <string> #include "move.h" #include "simpleevaluator.h" #include "evaluator.h" using namespace std; typedef unsigned long long int HASH; // 駒 enum PIECE { // +1で相手駒 // +PROMOTEで成り SPACE = 0, // 空 WALL = 1, // 壁 FU = 2, // 歩 GIN = 4, // 銀 KAKU = 6, // 角 HI = 8, // 飛 KIN = 10, // 金 GYOKU = 12, // 玉 TO = 14, // と NGIN = 16, // 全 UMA = 18, // 馬 RYU = 20, // 龍 PROMOTE = 12, // 成 }; // 差し手を戻せるように記録 struct LOG { MOVE move; int remove; // 取り除いた駒 int value; // 評価値 }; // 盤面 struct BOARD { char board[5][5]; // [x][y] char hand[6][2]; // [piece][b/w] int step; int turn; }; /* * 盤 */ class CBoard { friend CSimpleEvaluator; friend CEvaluator; public: static const int MAXMOVE = 1024; // 最大着手可能手数(593だけどちょっと余裕を持って) static const int ELEMNUM = CEvaluator::ELEMNUM; // 評価関数の要素数 static const int REPETCOUNT = 0x10000; // 千日手対策用テーブルサイズ enum { MV_CAPTURE = 1, // 駒を取る手のみ有効 }; private: static int PieceMoveNear[30][16]; // 駒の動き(1マス) static int PieceMoveFar[30][16]; // 駒の動き(飛駒) static int *PieceMoveToEffectNear; // 添字の移動に対応する効きのビット(1マス) static int PieceMoveToEffectNearTemp[21]; // static int *PieceMoveToEffectFar; // 添字の移動に対応する効きのビット(飛駒) static int PieceMoveToEffectFarTemp[21]; // static HASH HashBoard[49][32]; // 盤面ハッシュ static HASH HashHand[14][32]; // 持ち駒ハッシュ static HASH HashTurn; // 手番ハッシュ char Board[49]; // 盤面 char Hand[14]; // 持ち駒 int Turn; // 手番 int Step; // 手数 vector<LOG> Log; // これまでに指した手 HASH Hash; // ハッシュ CEvaluator Evaluator; // 評価関数 bool Fu[7][2]; // 歩の有無 int GyokuPosition[2]; // 玉の位置 int Effect[49][2]; // 効き 下位から -8n -7n -6n -1n +1n +6n +7n +8n -8 -7 -6 -1 +1 +6 +7 +8 の方向からの効きがある char RepetitionCount[REPETCOUNT]; // 出現回数を数えておく void GlobalInitialize(); void Update(); bool CheckMoveCore( MOVE move, int flag ) const; void Put( int pos, int piece ); void PutNoValue( int pos, int piece ); void PutHand( int piece ); void PutHandNoValue( int piece ); void Remove( int pos ); void RemoveNoValue( int pos ); void RemoveHand( int piece ); void RemoveHandNoValue( int piece ); bool IsFriend( int p ) const; bool IsEnemy( int p ) const; public: void Initialize(); string ToString() const; bool FromString( string s ); int GetMove( MOVE move[MAXMOVE], int flag=0 ) const; bool CheckMove( MOVE move, int flag=0 ) const; void Move( MOVE move ); void MoveNull(); void Undo(); void LogClear(); int GetPiece( int pos ) const; int GetPiece( int x, int y ) const; int GetHand( int hand ) const; int GetTurn() const; int GetTurnSign() const; int GetStep() const; bool IsFinished() const; bool IsFinished2() const; bool IsEffected( int pos, int turn, bool far=false ) const; bool IsCheckmated( int turn ) const; bool IsCheckedGyoku( int turn ) const; int GetValue() const; HASH GetHash() const; void GetBoard( BOARD *board ) const; void SetBoard( const BOARD *board ); void SetWeight( const int weight[ELEMNUM] ); void GetElement( int element[ELEMNUM] ); int GetCharacter( int threshold, CHARACTER character[], int maxnumber ) const; void Display() const; void DisplayEffect() const; };
[ "kusano@users.noreply.github.com" ]
[ [ [ 1, 156 ] ] ]
1309e05c927ee0c8fc5668d7fa11af16ea8eddd4
580738f96494d426d6e5973c5b3493026caf8b6a
/Source/vcl/wstring.h
9b87a5bd543d75a0a4e73d209c82dd8c021dc5b7
[]
no_license
bravesoftdz/cbuilder-vcl
6b460b4d535d17c309560352479b437d99383d4b
7b91ef1602681e094a6a7769ebb65ffd6f291c59
refs/heads/master
2021-01-10T14:21:03.726693
2010-01-11T11:23:45
2010-01-11T11:23:45
48,485,606
2
1
null
null
null
null
UTF-8
C++
false
false
3,877
h
// wstring.h - support for delphi widestrings in c++ // (WideString) // $Revision: 1.12.1.0.1.1 $ // copyright (c) 1997, 2002 Borland Software Corporation #ifndef WSTRING_H #define WSTRING_H #pragma delphiheader begin #include <wtypes.h> #include <sysmac.h> #include <dstring.h> #include <stdarg.h> namespace System { // NOTE: WideString uses BSTRs as its underlying implementation (i.e. SysAlloc/FreeString etc.) // class RTL_DELPHIRETURN WideString { friend WideString __fastcall PACKAGE operator +(const wchar_t*, const WideString& rhs); //!! not implemented? public: // Constructors // __fastcall WideString(): Data(0) {} __fastcall WideString(const char* src); __fastcall WideString(const WideString& src); __fastcall WideString(const AnsiString& src); __fastcall WideString(const wchar_t* src, int len); __fastcall WideString(const wchar_t* src); __fastcall explicit WideString(const wchar_t src); __fastcall explicit WideString(char src); __fastcall explicit WideString(short src); __fastcall explicit WideString(unsigned short); __fastcall explicit WideString(int src); __fastcall explicit WideString(unsigned int); __fastcall explicit WideString(long); __fastcall explicit WideString(unsigned long); __fastcall explicit WideString(__int64); __fastcall explicit WideString(unsigned __int64); __fastcall explicit WideString(float src); __fastcall explicit WideString(double src); __fastcall explicit WideString(long double src); // Destructor // __fastcall ~WideString(); // Assignments // WideString& __fastcall operator =(const WideString& rhs); WideString& __fastcall operator =(BSTR rhs); WideString& __fastcall operator =(const char* rhs); WideString& __fastcall operator =(const AnsiString& rhs); WideString& __fastcall operator +=(const WideString& rhs); // Comparisons // bool __fastcall operator ==(const WideString& rhs) const; bool __fastcall operator !=(const WideString& rhs) const; bool __fastcall operator < (const WideString& rhs) const; bool __fastcall operator > (const WideString& rhs) const; bool __fastcall operator <=(const WideString& rhs) const; bool __fastcall operator >=(const WideString& rhs) const; // Index // wchar_t& __fastcall operator [](const int idx) { return Data[idx-1]; } // Concatenation // WideString __fastcall operator +(const WideString& rhs) const; // Access Data // BSTR __fastcall c_bstr() const { return Data; } operator BSTR() const { return Data; } // Access internal data (Be careful when using!!) // BSTR* __fastcall operator& () { return &Data; } // Attach/Detach from BSTR, Empty Object // void __fastcall Attach(BSTR src); BSTR __fastcall Detach(); void __fastcall Empty(); // Retrieve copy of data // static wchar_t* __fastcall Copy(wchar_t* src); wchar_t* __fastcall Copy() const { return Copy(Data); } // Query attributes of object // int __fastcall Length() const; bool __fastcall IsEmpty() const; // Modify string // void __fastcall Insert(const WideString& str, int index); void __fastcall Delete(int index, int count); void __fastcall SetLength(int newLength); int __fastcall Pos(const WideString& subStr) const; WideString __fastcall SubString(int index, int count) const; private: int __cdecl vprintf(const wchar_t *fmt, va_list); int __cdecl printf(const wchar_t *fmt, ...); wchar_t *Data; }; } using namespace System; #pragma delphiheader end. #endif
[ "bitscode@7bd08ab0-fa70-11de-930f-d36749347e7b" ]
[ [ [ 1, 129 ] ] ]
79b9d4a5d9c04440830390a1f5ef8fc3074fcd1d
1c80a726376d6134744d82eec3129456b0ab0cbf
/Project/C++/C++/vc源码/金山毒霸界面/ColorButton.cpp
b09387bd44e0d827b9efa5074eb3c1c53b3cc12f
[]
no_license
dabaopku/project_pku
338a8971586b6c4cdc52bf82cdd301d398ad909f
b97f3f15cdc3f85a9407e6bf35587116b5129334
refs/heads/master
2021-01-19T11:35:53.500533
2010-09-01T03:42:40
2010-09-01T03:42:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
946
cpp
// ColorButton.cpp : implementation file // #include "stdafx.h" #include "Interface.h" #include "ColorButton.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CColorButton CColorButton::CColorButton() { // SetBackColor(RGB(222,223,222)); } CColorButton::~CColorButton() { } BEGIN_MESSAGE_MAP(CColorButton, CButton) //{{AFX_MSG_MAP(CColorButton) ON_WM_CTLCOLOR_REFLECT() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CColorButton message handlers void CColorButton::SetBackColor(COLORREF BackColor) { m_BackColor=BackColor; m_brush.CreateSolidBrush(m_BackColor); } HBRUSH CColorButton::CtlColor(CDC* pDC, UINT nCtlColor) { pDC->SetBkMode(TRANSPARENT); return (HBRUSH)m_brush; }
[ "guocong89@gmail.com@592586dc-1302-11df-8689-7786f20063ad" ]
[ [ [ 1, 49 ] ] ]
ad25e3cb6e1da0d5e539160df5f205c376c6c03d
847cccd728e768dc801d541a2d1169ef562311cd
/src/Utils/Properties/TypedProperty.h
2c136f44bf46d78f7a11e53e6a60fe45ebe3a88a
[]
no_license
aadarshasubedi/Ocerus
1bea105de9c78b741f3de445601f7dee07987b96
4920b99a89f52f991125c9ecfa7353925ea9603c
refs/heads/master
2021-01-17T17:50:00.472657
2011-03-25T13:26:12
2011-03-25T13:26:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,122
h
/// @file /// A property knowing what type of values it represents. /// @remarks /// Implementation based on the code from Game Programming Gems 5 (1.4). #ifndef _TYPED_PROPERTY_H #define _TYPED_PROPERTY_H #include "AbstractProperty.h" namespace Reflection { /// This intermediate class defines a property that is typed, but not bound as a member of a particular class. template <class T> class TypedProperty: public AbstractProperty { public: /// Constructor. /// @param accessFlags This parameter controls access to this property. It's similar to visibility in C++. inline TypedProperty(StringKey name, const PropertyAccessFlags accessFlags): AbstractProperty(name, accessFlags) {} /// Returns the type of this property. virtual ePropertyType GetType(void) const { return PropertyTypes::GetTypeID<T>(); } /// Returns true if the properties' values are equal. The properties must be of the same type. virtual bool IsEqual(RTTIBaseClass* owner, const RTTIBaseClass* otherOwner, const AbstractProperty* otherProperty) { if (!IsReadable() || !otherProperty->IsReadable()) return false; return GetValue(owner) == otherProperty->GetValue<T>(otherOwner); } /// Copies data from the specified abstract property. The property must be of the same type as this property. /// Returns true if the copy was performed, false otherwise. virtual bool CopyFrom(RTTIBaseClass* owner, const RTTIBaseClass* otherOwner, const AbstractProperty* otherProperty) { if (IsWriteable() && otherProperty->IsReadable() && PropertyTypes::GetCloning(GetType()) == PC_SHALLOW) { SetValue(owner, otherProperty->GetValue<T>(otherOwner)); return true; } else { return false; } } /// Returns the value of this property. An owner of the property must be specified. virtual T GetValue( const RTTIBaseClass* owner ) const = 0; /// Sets this property to a specified value. An owner of the property must be specified. virtual void SetValue( RTTIBaseClass* owner, T value ) = 0; }; } #endif // _TYPED_PROPERTY_H
[ "ondrej.mocny@gmail.com", "Lukas.Hermann@seznam.cz" ]
[ [ [ 1, 19 ], [ 21, 25 ], [ 39, 45 ], [ 47, 47 ], [ 50, 59 ] ], [ [ 20, 20 ], [ 26, 38 ], [ 46, 46 ], [ 48, 49 ] ] ]
2ec8aa7fda6222991baa635a93712008ab88f5ba
2dbbca065b62a24f47aeb7ec5cd7a4fd82083dd4
/OUAN/OUAN/Src/Graphics/Volume/BufferManager.h
ef1a9c81c93cd794a7dafd017315280e642c1cd9
[]
no_license
juanjmostazo/once-upon-a-night
9651dc4dcebef80f0475e2e61865193ad61edaaa
f8d5d3a62952c45093a94c8b073cbb70f8146a53
refs/heads/master
2020-05-28T05:45:17.386664
2010-10-06T12:49:50
2010-10-06T12:49:50
38,101,059
1
1
null
null
null
null
UTF-8
C++
false
false
628
h
#ifndef BUFFER_MANAGER_H #define BUFFER_MANAGER_H #include "../../OUAN.h" namespace OUAN { class BufferManager { private: BufferManager(); static BufferManager* mInstance; std::string mTexture3DName_1; std::string mTexture3DName_2; public: ~BufferManager(); static BufferManager* getInstance(); void setBuffer( std::string texture3DName, double vCut, double vScale, double juliaGlobalReal, double juliaGlobalImag, double juliaGlobalTheta, double initColorR, double initColorG, double initColorB, double endColorR, double endColorG, double endColorB); }; } #endif
[ "juanj.mostazo@1610d384-d83c-11de-a027-019ae363d039" ]
[ [ [ 1, 29 ] ] ]
6bb03c349bc493b39c12987c0a16730d1b692745
1193b8d2ab6bb40ce2adbf9ada5b3d1124f1abb3
/branches/basicelements/libsonetto/src/SonettoKernel.cpp
db65c9eec93ac48096307da1625647f6725e1dc0
[]
no_license
sonetto/legacy
46bb60ef8641af618d22c08ea198195fd597240b
e94a91950c309fc03f9f52e6bc3293007c3a0bd1
refs/heads/master
2021-01-01T16:45:02.531831
2009-09-10T21:50:42
2009-09-10T21:50:42
32,183,635
0
2
null
null
null
null
UTF-8
C++
false
false
23,207
cpp
/*----------------------------------------------------------------------------- Copyright (c) 2009, Sonetto Project Developers 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 Sonetto Project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -----------------------------------------------------------------------------*/ #include <cstdlib> #ifndef WINDOWS # include <sys/stat.h> # include <dirent.h> #endif #include "SonettoKernel.h" #include "SonettoStaticTextElement.h" namespace Sonetto { // ---------------------------------------------------------------------- // Sonetto::Kernel implementation // ---------------------------------------------------------------------- SONETTO_SINGLETON_IMPLEMENT(Kernel); // ---------------------------------------------------------------------- void Kernel::initialize() { Ogre::NameValuePairList wndParamList; SDL_SysWMinfo wmInfo; const char *defaultCfgName = "defaultcfg.dat"; // Checks if wasn't initialized yet if (mInitialized) { SONETTO_THROW("Kernel is already initialized"); } // Reads Sonetto Project File readSPF(); // ------------------ // SDL Initialisation // ------------------ // Initializes SDL video and joystick subsystems if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) == -1) { SONETTO_THROW("Could not initialize SDL"); } // Creates SDL rendering window with default resolutions // (resize later to the desired resolution) mWindow = SDL_SetVideoMode(mScreenWidth,mScreenHeight,32,0); if (!mWindow) { SONETTO_THROW("Could not create SDL window"); } // Disable cursor, Sonetto does not support mouse for now. SDL_ShowCursor(SDL_DISABLE); SDL_WM_SetCaption("Now Loading...","Now Loading..."); /*if (mLoadingImg.size() > 0) {*/ SDL_Surface *loading; SDL_Rect src,dest; // Fills the screen with the background colour // taken from the SPF file SDL_FillRect(mWindow,NULL,SDL_MapRGB(mWindow->format, mLoadingBGR,mLoadingBGG,mLoadingBGB)); // Loads loading image and checks for errors loading = SDL_LoadBMP(mLoadingImg.c_str()); if (!loading) { SONETTO_THROW("Unable to find " + mLoadingImg); } // Source rectangle: Full image src.x = src.y = 0; src.w = loading->w; src.h = loading->h; // Destination rectangle: Position took from SPF file dest.x = mLoadingImgLeft; dest.y = mLoadingImgTop; // Blits loading image into screen buffer and flips it SDL_BlitSurface(loading,&src,mWindow,&dest); SDL_Flip(mWindow); // Frees loaded loading image //SDL_BlitSurface(loading,&src,mWindow,&dest); //SDL_FreeSurface(loading); /*}*/ // Get window info to attach Ogre at it SDL_VERSION(&wmInfo.version); SDL_GetWMInfo(&wmInfo); #ifdef WINDOWS { // Get the User Application Data directory. mGameData = getenv("APPDATA"); // Append the Sonetto Directory to the end of it; mGameData += "\\Sonetto\\"; // Verify the existence of the directory if((_access(mGameData.c_str(),0)) == -1) { // If it does not exist, create it mkdir(mGameData.c_str()); } mGameDataPath = mGameData + mGameIdentifier + "\\"; if((_access(mGameDataPath.c_str(),0)) == -1) { // If it does not exist, create it mkdir(mGameDataPath.c_str()); } // Check if the configuration file for this project exists. std::string configfile = mGameDataPath + mGameIdentifier + ".INI"; if((_access(configfile.c_str(),0)) == -1) { if(_access(defaultCfgName,0) == -1) { SONETTO_THROW("Missing default configuration file"); } // If not, then copy the default config file from the // game directory if(!CopyFile(defaultCfgName,configfile.c_str(),true)) { SONETTO_THROW("Unable to copy configuration file"); } } } #else { DIR *dir; // Used to check directory existence struct stat fstat; // Used to check file existence // Gets user home directory mGameData = std::string("/home/") + getenv("PWD"); // Appends Sonetto directory to the end of it mGameData += "/.sonetto/"; // Verifies existence of directory dir = opendir(mGameData.c_str(),0); if (!dir) { // If it does not exist, creates it mkdir(mGameData.c_str(),S_IRWXU); } else { // If openned successfuly, closes it closedir(dir); } // Creates path for the actual game data folder mGameDataPath = mGameData + mGameIdentifier + "/"; // Verifies existence of directory dir = opendir(mGameDataPath.c_str(),0); if (!dir) { // If it does not exist, creates it mkdir(mGameDataPath.c_str(),S_IRWXU); } else { // If openned successfuly, closes it closedir(dir); } // Check if the configuration file for this project exists. std::string configfile = mGameDataPath + mGameIdentifier + ".INI"; if (stat(configfile.c_str(),&fstat) < 0) { ifstream src; ofstream dest; // Opens default configuration file src.open(defaultCfgName); if (!src.is_open()) { SONETTO_THROW("Missing default configuration file"); } // Opens local user configuration file dest.open(configfile.c_str()); if (!dest.is_open()) { SONETTO_THROW("Unable to copy configuration file"); } // Copies contents from default to local user config file dest << src.rdbuf(); // Closes handles src.close(); dest.close(); } } #endif // ------------------- // Ogre Initialisation // ------------------- // Produce logs only on debug compilations #ifdef DEBUG mOgre = new Ogre::Root("","",mGameDataPath+"game.log"); #else mOgre = new Ogre::Root("","",""); #endif // Flips loading screen (temporary) SDL_Flip(mWindow); #ifdef WINDOWS wndParamList["externalWindowHandle"] = Ogre::StringConverter::toString((uint32)wmInfo.window); #else #error External window handle is not yet implemented on non Windows \ applications. #endif // Load and configure Sonetto loadConfig(mGameDataPath+mGameIdentifier+".INI",wndParamList); int sdlwindowcfg = 0; // Resets video mode to loaded configurations if(mIsFullScreen) { sdlwindowcfg = SDL_FULLSCREEN; } else { sdlwindowcfg = 0; } mWindow = SDL_SetVideoMode(640,480, 32,sdlwindowcfg); SDL_FillRect(mWindow,NULL,SDL_MapRGB(mWindow->format, mLoadingBGR,mLoadingBGG,mLoadingBGB)); SDL_BlitSurface(loading,&src,mWindow,&dest); SDL_FreeSurface(loading); SDL_Flip(mWindow); // Initialize Ogre Root mOgre->initialise(false); // Get ogre managers and copy them to pointers for easy access. mOverlayMan = Ogre::OverlayManager::getSingletonPtr(); // Flips loading screen (temporary) SDL_Flip(mWindow); // Initializes input manager mInputMan = new InputManager(4); mInputMan->initialize(); mFontMan = new FontManager(); // Initialize Objects/Elements; StaticTextElementFactory * mTextElementFactory = new StaticTextElementFactory(); mOverlayMan->addOverlayElementFactory(mTextElementFactory); // Resets video mode to loaded configurations mWindow = SDL_SetVideoMode(mScreenWidth,mScreenHeight, Ogre::StringConverter::parseUnsignedInt( wndParamList["colourDepth"]),sdlwindowcfg); // Create the Ogre Render Window mRenderWindow = mOgre->createRenderWindow("",mScreenWidth, mScreenHeight,mIsFullScreen,&wndParamList); // Resets caption to real game window caption SDL_WM_SetCaption(mGameTitle.c_str(),mGameTitle.c_str()); // Creates a Boot Module and activates it pushModule(Module::MT_BOOT,MA_CHANGE); // Flags we have initialized mInitialized = true; } // ---------------------------------------------------------------------- Kernel::~Kernel() { // Deinitialize if initialized if (mInitialized) { // Deinitializes and deletes instantiated modules while (!mModuleStack.empty()) { Module *module = mModuleStack.top(); // Deinitializes, deletes and removes from stack module->deinitialize(); delete mModuleStack.top(); mModuleStack.pop(); } // Deletes input manager delete mInputMan; // Remove and delete all Sonetto Resources. delete Ogre::ResourceGroupManager::getSingleton()._getResourceManager("SFont"); // Deletes Ogre delete mOgre; // Deinitialize SDL SDL_Quit(); } } // ---------------------------------------------------------------------- void Kernel::run() { bool running = true; while (running) { Ogre::ControllerValueRealPtr tmpFTV = Ogre::ControllerManager::getSingleton().getFrameTimeSource(); mFrameTime = tmpFTV->getValue(); SDL_Event evt; // Pump events while (SDL_PollEvent(&evt)) { if (evt.type == SDL_QUIT) { // Shutdowns the game when asked to mKernelAction = KA_SHUTDOWN; } } // Stops game while window is deactivated (minimised) if (!(SDL_GetAppState() & SDL_APPACTIVE)) { // Loop until the window gets activated again while (SDL_WaitEvent(&evt)) { if (SDL_GetAppState() & SDL_APPACTIVE) { // Window activated; break the loop and continue the game break; } } } switch (mKernelAction) { case KA_CHANGE_MODULE: if (mModuleAction == MA_RETURN) { // Pops current module, returning to the previous one popModule(); } else { // Pushes desired module with the desired action // (if action is MA_CHANGE, pushModule() will remove // the current one by itself) pushModule(mNextModuleType,mModuleAction); } // Resets action parameters mKernelAction = KA_NONE; mModuleAction = MA_NONE; mNextModuleType = Module::MT_NONE; break; case KA_SHUTDOWN: // Stops running running = false; break; default: break; } // Updates input manager mInputMan->update(); if(mInputMan->getDirectKeyState(SDLK_ESCAPE)) { mKernelAction = KA_SHUTDOWN; } // Checks whether the stack is empty if (mModuleStack.empty()) { SONETTO_THROW("The module stack is empty"); } // Updates active module mModuleStack.top()->update(); // Renders one frame mOgre->renderOneFrame(); } } // ---------------------------------------------------------------------- void Kernel::setAction(KernelAction kact,ModuleAction mact, Module::ModuleType modtype) { switch (kact) { case KA_NONE: // Makes sure parameters are valid assert(mact == MA_NONE && modtype == Module::MT_NONE); // Sets action parameters mKernelAction = KA_NONE; mModuleAction = MA_NONE; mNextModuleType = Module::MT_NONE; break; case KA_CHANGE_MODULE: // Makes sure parameters are valid assert(mact != MA_NONE && modtype != Module::MT_NONE); // Sets action parameters mKernelAction = KA_CHANGE_MODULE; mModuleAction = mact; mNextModuleType = modtype; break; case KA_SHUTDOWN: // Makes sure parameters are valid assert(mact == MA_NONE && modtype == Module::MT_NONE); // Sets action parameters mKernelAction = KA_SHUTDOWN; mModuleAction = MA_NONE; mNextModuleType = Module::MT_NONE; break; } } // ---------------------------------------------------------------------- Ogre::Root * Kernel::getOgre() { return mOgre; } // ---------------------------------------------------------------------- Ogre::RenderWindow * Kernel::getRenderWindow() { return mRenderWindow; } // ---------------------------------------------------------------------- void Kernel::loadConfig(const std::string &fname, Ogre::NameValuePairList &wndParamList) { // Checks for config file existence { const std::string cannotLoadMsg = "Unable to load " + fname + ",\nthe file does not exist"; #ifdef WINDOWS if((_access(fname.c_str(),0)) == -1) { SONETTO_THROW(cannotLoadMsg); } #else struct stat fstat; if (stat(fname.c_str(),&fstat) < 0) { SONETTO_THROW(cannotLoadMsg); } #endif } Ogre::ConfigFile config; Ogre::RenderSystemList *renderers; // Loads file into Ogre::ConfigFile config.load(fname); // Video configuration section name const char *videoSectName = "video"; // Loads the desired render system plugin mOgre->loadPlugin(config.getSetting("renderSystem", videoSectName)); // Gets list of loaded render systems and makes sure it's not empty renderers = mOgre->getAvailableRenderers(); assert(!renderers->empty()); // Sets the render system we've just loaded as active mOgre->setRenderSystem(renderers->back()); // Gets resolution config string std::string resolution = config.getSetting("screenResolution", videoSectName); // Explodes resolution string on the "x" and validates it std::vector<Ogre::String> res = Ogre::StringUtil::split(resolution,"x",1); if (res.size() != 2) { SONETTO_THROW("Invalid screen resolution set in configuration " "file"); } // Parses width and height took from resolution // string as integers mScreenWidth = Ogre::StringConverter::parseUnsignedInt(res[0]); mScreenHeight = Ogre::StringConverter::parseUnsignedInt(res[1]); // Gets fullscreen config string Ogre::String fullscreen = config.getSetting("fullScreen", videoSectName); // Checks its value if(fullscreen == "true") { mIsFullScreen = true; } else if(fullscreen == "false") { mIsFullScreen = false; } else { SONETTO_THROW("Invalid fullscreen value set in configuration " "file"); } // Gets other config strings and set them as // window parameters accordingly wndParamList["vsync"] = config.getSetting("vsync",videoSectName); wndParamList["displayFrequency"] = config. getSetting("displayFrequency",videoSectName); wndParamList["colourDepth"] = config. getSetting("colourDepth",videoSectName); wndParamList["FSAA"] = config.getSetting("FSAA",videoSectName); } // ---------------------------------------------------------------------- void Kernel::pushModule(Module::ModuleType modtype,ModuleAction mact) { Module *newmod,*curmod = NULL; // Makes sure parameters are valid assert(modtype != Module::MT_NONE && mact != MA_NONE && mact != MA_RETURN); // Instantiates new module newmod = mModuleFactory->createModule(modtype); // Gets current active module (if any) if (!mModuleStack.empty()) { curmod = mModuleStack.top(); if (mact == MA_CHANGE) { // Deinitializes, deletes and removes the // current module from the stack curmod->deinitialize(); delete curmod; mModuleStack.pop(); } else { // Halts current module curmod->halt(); } } // Pushes new module into stack and initializes it mModuleStack.push(newmod); newmod->initialize(); } // ---------------------------------------------------------------------- void Kernel::popModule() { Module *module; // Makes sure this won't leave the stack empty if (mModuleStack.size() < 2) { SONETTO_THROW("Cannot empty module stack"); } // Gets current active module, deinitializes and deletes it module = mModuleStack.top(); module->deinitialize(); delete module; // Gets new top module and resume its execution mModuleStack.top()->resume(); } // ---------------------------------------------------------------------- void Kernel::readSPF() { uint32 spffourcc = MKFOURCC('S','P','F','0'); uint32 filefourcc = 0; // Opens SPF file std::ifstream gamespf; gamespf.open("game.spf", std::ios_base::in | std::ios_base::binary); // Checks if it was opened successfuly if (!gamespf.is_open()) { SONETTO_THROW("Unable to find game.spf or the file is in " "use by another proccess"); } // Reads and checks file's fourcc identification gamespf.read((char*)&filefourcc,sizeof(filefourcc)); if(filefourcc != spffourcc) { SONETTO_THROW("Invalid SPF file"); } // Skips the last modification timestamp gamespf.seekg(4,std::ios_base::cur); // Reads information from file mGameTitle = readString(gamespf); mGameIdentifier = readString(gamespf); mGameAuthor = readString(gamespf); mLoadingImg = readString(gamespf); gamespf.read((char *)&mLoadingImgLeft,sizeof(mLoadingImgLeft)); gamespf.read((char *)&mLoadingImgTop,sizeof(mLoadingImgTop)); gamespf.read((char *)&mLoadingBGR,sizeof(mLoadingBGR)); gamespf.read((char *)&mLoadingBGG,sizeof(mLoadingBGG)); gamespf.read((char *)&mLoadingBGB,sizeof(mLoadingBGB)); // Closes file handle gamespf.close(); } // ---------------------------------------------------------------------- std::string Kernel::readString(std::ifstream &stream) { uint16 strsize; stream.read((char*)&strsize, sizeof(strsize)); char * stringbuffer = new char[strsize+1]; stream.read((char*)stringbuffer, strsize); stringbuffer[strsize] = '\0'; std::string rstring = stringbuffer; delete[] stringbuffer; return rstring; } // ---------------------------------------------------------------------- } // namespace
[ "super.driver.512@gmail.com", "carvalho.yoa.arthur@gmail.com" ]
[ [ [ 1, 333 ], [ 336, 391 ], [ 397, 648 ], [ 650, 650 ] ], [ [ 334, 335 ], [ 392, 396 ], [ 649, 649 ] ] ]
ab3dabdf30dd72f1a1b7e142b230be1ba5382e1a
c5534a6df16a89e0ae8f53bcd49a6417e8d44409
/trunk/nGENE Proj/VertexBufferDX9.cpp
d6f4b21ed29dbdf6ce1979701ee096c07764597a
[]
no_license
svn2github/ngene
b2cddacf7ec035aa681d5b8989feab3383dac012
61850134a354816161859fe86c2907c8e73dc113
refs/heads/master
2023-09-03T12:34:18.944872
2011-07-27T19:26:04
2011-07-27T19:26:04
78,163,390
2
0
null
null
null
null
UTF-8
C++
false
false
6,196
cpp
/* --------------------------------------------------------------------------- This source file is part of nGENE Tech. Copyright (c) 2006- Wojciech Toman This program is free software. File: VertexBufferDX9.cpp Version: 0.11 --------------------------------------------------------------------------- */ #include "PrecompiledHeaders.h" #include "VertexBufferDX9.h" #include "DeviceRender.h" #include "DX9Mapping.h" #include "IndexedBuffer.h" #include "VertexBufferManager.h" #include "VertexDeclarationDX9.h" namespace nGENE { // Initialize static members TypeInfo VertexBufferDX9::Type(L"VertexBufferDX9", &VertexBuffer::Type); VertexBufferDX9::VertexBufferDX9(): m_pVB(NULL), m_pD3DDev(NULL) { } //---------------------------------------------------------------------- VertexBufferDX9::VertexBufferDX9(const VERTEXBUFFER_DESC& _desc): VertexBuffer(_desc), m_pVB(NULL), m_pD3DDev(NULL) { } //---------------------------------------------------------------------- VertexBufferDX9::~VertexBufferDX9() { cleanup(); } //---------------------------------------------------------------------- void VertexBufferDX9::init() { dword dwUsage = 0; D3DPOOL pool = D3DPOOL_MANAGED; if(m_VBDesc.type == VB_DYNAMIC) { dwUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY; pool = D3DPOOL_DEFAULT; } // Create DirectX 9.0 Vertex Buffer IDirect3DDevice9* pRenderer = ((IDirect3DDevice9*)(Renderer::getSingleton().getDeviceRender().getDevicePtr())); HRESULT hr = 0; if(FAILED(hr = pRenderer->CreateVertexBuffer(m_VBDesc.verticesNum * m_VBDesc.vertexSize, dwUsage, 0, pool, &m_pVB, NULL))) { Log::log(LET_ERROR, L"nGENE", __WFILE__, __WFUNCTION__, __LINE__, DX9Mapping::getDXErrorDescription(hr).c_str()); return; } m_pD3DDev = reinterpret_cast<IDirect3DDevice9*>(Renderer::getSingleton().getDeviceRender().getDevicePtr()); } //---------------------------------------------------------------------- void VertexBufferDX9::cleanup() { NGENE_RELEASE(m_pVB); } //---------------------------------------------------------------------- void VertexBufferDX9::lock(uint _start, uint _count, void** _vertices) { // Lock DirectX 9.0 Vertex Buffer dword dwLock = 0; if(m_VBDesc.type == VB_DYNAMIC) dwLock = (m_VBDesc.discardData ? D3DLOCK_DISCARD : D3DLOCK_NOOVERWRITE); SharedObject sharedObj(&m_CriticalSection); m_pVB->Lock(_start, _count * m_VBDesc.vertexSize, _vertices, dwLock); } //---------------------------------------------------------------------- void VertexBufferDX9::unlock() { SharedObject sharedObj(&m_CriticalSection); m_pVB->Unlock(); } //---------------------------------------------------------------------- void VertexBufferDX9::setVertexData(void* _data, uint _start, uint _count) { SharedObject sharedObj(&m_CriticalSection); void* pVertices = NULL; lock(_start, _count, &pVertices); if(_data) memcpy(pVertices, _data, _count * m_VBDesc.vertexSize); unlock(); } //---------------------------------------------------------------------- void VertexBufferDX9::bind() { m_pD3DDev->SetStreamSource(m_nStreamIndex, m_pVB, 0, m_VBDesc.vertexSize); } //---------------------------------------------------------------------- void VertexBufferDX9::prepare() { VertexBufferManager& manager = VertexBufferManager::getSingleton(); manager.bindVertexBuffer(this); manager.bindVertexDeclaration(m_VBDesc.vertexDeclaration); if(!m_nStreamIndex && m_VBDesc.indices) { manager.bindIndexedBuffer(m_VBDesc.indices); } } //---------------------------------------------------------------------- void VertexBufferDX9::render() { // Nothing to render if(!m_VBDesc.primitivesNum) return; if(m_VBDesc.indices) { m_pD3DDev->DrawIndexedPrimitive(static_cast<D3DPRIMITIVETYPE>(m_VBDesc.primitivesType), 0, 0, m_VBDesc.verticesNum, 0, m_VBDesc.primitivesNum); } else { m_pD3DDev->DrawPrimitive(static_cast<D3DPRIMITIVETYPE>(m_VBDesc.primitivesType), 0, m_VBDesc.primitivesNum); } } //---------------------------------------------------------------------- void VertexBufferDX9::render(uint _verticesNum, uint _primitivesNum) { if(m_VBDesc.indices) { m_pD3DDev->DrawIndexedPrimitive(static_cast<D3DPRIMITIVETYPE>(m_VBDesc.primitivesType), 0, 0, _verticesNum, 0, _primitivesNum); } else { m_pD3DDev->DrawPrimitive(static_cast<D3DPRIMITIVETYPE>(m_VBDesc.primitivesType), 0, _primitivesNum); } } //---------------------------------------------------------------------- void VertexBufferDX9::render(const VERTEXBUFFER_DESC& _desc) { if(_desc.indices) { m_pD3DDev->DrawIndexedPrimitiveUP(static_cast<D3DPRIMITIVETYPE>(_desc.primitivesType), 0, _desc.verticesNum, _desc.primitivesNum, _desc.indices->getDesc().indices, D3DFMT_INDEX16, _desc.vertices, _desc.vertexSize); } else { m_pD3DDev->DrawPrimitiveUP(static_cast<D3DPRIMITIVETYPE>(_desc.primitivesType), _desc.primitivesNum, _desc.vertices, _desc.vertexSize); } } //---------------------------------------------------------------------- void VertexBufferDX9::getVertexData(void* _data, uint _start, uint _count) const { void* pVertices; dword dwLock = 0; if(m_VBDesc.type == VB_DYNAMIC) dwLock = (m_VBDesc.discardData ? D3DLOCK_DISCARD : D3DLOCK_NOOVERWRITE); m_pVB->Lock(_start, _count * m_VBDesc.vertexSize, &pVertices, 0); if(pVertices) memcpy(_data, pVertices, _count * m_VBDesc.vertexSize); m_pVB->Unlock(); } //---------------------------------------------------------------------- void VertexBufferDX9::onDeviceLost() { if(m_VBDesc.type != VB_DYNAMIC) return; cleanup(); } //---------------------------------------------------------------------- void VertexBufferDX9::onDeviceReset() { if(m_VBDesc.type != VB_DYNAMIC) return; init(); } //---------------------------------------------------------------------- }
[ "Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57" ]
[ [ [ 1, 203 ] ] ]
f70438b61fe3542920848918b05121f61c78df22
b14d5833a79518a40d302e5eb40ed5da193cf1b2
/cpp/extern/xercesc++/2.6.0/src/xercesc/dom/DOMDocumentRange.hpp
8ac32aa0c8d3b5a8ba5f0923b762fba013eee02b
[ "Apache-2.0" ]
permissive
andyburke/bitflood
dcb3fb62dad7fa5e20cf9f1d58aaa94be30e82bf
fca6c0b635d07da4e6c7fbfa032921c827a981d6
refs/heads/master
2016-09-10T02:14:35.564530
2011-11-17T09:51:49
2011-11-17T09:51:49
2,794,411
1
0
null
null
null
null
UTF-8
C++
false
false
3,109
hpp
#ifndef DOMDocumentRange_HEADER_GUARD_ #define DOMDocumentRange_HEADER_GUARD_ /* * Copyright 2002,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * $Id: DOMDocumentRange.hpp,v 1.7 2004/09/08 13:55:39 peiyongz Exp $ */ #include <xercesc/util/XercesDefs.hpp> XERCES_CPP_NAMESPACE_BEGIN class DOMRange; /** * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113'>Document Object Model (DOM) Level 2 Traversal and Range Specification</a>. * @since DOM Level 2 */ class CDOM_EXPORT DOMDocumentRange { protected: // ----------------------------------------------------------------------- // Hidden constructors // ----------------------------------------------------------------------- /** @name Hidden constructors */ //@{ DOMDocumentRange() {}; //@} private: // ----------------------------------------------------------------------- // Unimplemented constructors and operators // ----------------------------------------------------------------------- /** @name Unimplemented constructors and operators */ //@{ DOMDocumentRange(const DOMDocumentRange &); DOMDocumentRange & operator = (const DOMDocumentRange &); //@} public: // ----------------------------------------------------------------------- // All constructors are hidden, just the destructor is available // ----------------------------------------------------------------------- /** @name Destructor */ //@{ /** * Destructor * */ virtual ~DOMDocumentRange() {}; //@} // ----------------------------------------------------------------------- // Virtual DOMDocumentRange interface // ----------------------------------------------------------------------- /** @name Functions introduced in DOM Level 2 */ //@{ /** * To create the range consisting of boundary-points and offset of the * selected contents * * @return The initial state of the Range such that both the boundary-points * are positioned at the beginning of the corresponding DOMDOcument, before * any content. The range returned can only be used to select content * associated with this document, or with documentFragments and Attrs for * which this document is the ownerdocument * @since DOM Level 2 */ virtual DOMRange *createRange() = 0; //@} }; XERCES_CPP_NAMESPACE_END #endif
[ "aburke@bitflood.org" ]
[ [ [ 1, 94 ] ] ]
e3006367c7e0749b5a7c24510bdf785809c61eeb
bfdfb7c406c318c877b7cbc43bc2dfd925185e50
/engine/hyPack.h
cdb233e87a31d058cec2d3c0a138ce9af9e88b96
[ "MIT" ]
permissive
ysei/Hayat
74cc1e281ae6772b2a05bbeccfcf430215cb435b
b32ed82a1c6222ef7f4bf0fc9dedfad81280c2c0
refs/heads/master
2020-12-11T09:07:35.606061
2011-08-01T12:38:39
2011-08-01T12:38:39
null
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
953
h
/* -*- coding: sjis-dos -*- */ /* * copyright 2010 FUKUZAWA Tadashi. All rights reserved. */ // n big endian unsigned 16bit // N big endian 32bit // v little endian unsigned 16bit // V little endian 32bit // c signed char 8bit // C unsigned char 8bit // s signed short 16bit // S unsigned short 16bit // i signed int 32bit // f float 32bit // a ナルバイト区切り文字列 // A バイト数区切り文字列 : 最大65535バイトまで // x pack:ナルバイト / unpack:1byte読み飛ばし #ifndef h_HYPACK_H_ #define h_HYPACK_H_ namespace Hayat { namespace Engine { class ValueArray; class StringBuffer; class Pack { public: static void pack(const char* templ, ValueArray* va, StringBuffer* sb); static void unpack(const char* templ, ValueArray* va, StringBuffer* sb); }; } } #endif /* h_HYPACK_H_ */
[ "applealien@nifty.com" ]
[ [ [ 1, 43 ] ] ]
aa683f08d39f938f836187ce6aaa82492adf0cab
4308e61561bc2b164dffc0b86b38b949d535f775
/AAA/Foundation/Tutorial3_OpenGL3.3_Texturing/GLSLShader.cpp
1b97b099ea039001ed306a6c4b75519d3ab76131
[]
no_license
GunioRobot/all
3526922dfd75047e78521f5716c1db2f3f299c38
22f5d77e12070dc6f60e9a39eb3504184360e061
refs/heads/master
2021-01-22T13:38:14.634356
2011-10-30T23:17:30
2011-10-30T23:17:30
2,995,713
0
0
null
null
null
null
UTF-8
C++
false
false
3,491
cpp
/* * ---------------- www.spacesimulator.net -------------- * ---- Space simulators and 3d engine tutorials ---- * * Original Author: Damiano Vitulli * Porting to OpenGL3.3: Movania Muhammad Mobeen * Shaders Functions: Movania Muhammad Mobeen * * This program is released under the BSD licence * By using this program you agree to licence terms on spacesimulator.net copyright page * */ #include "GLSLShader.h" #include <iostream> GLSLShader::GLSLShader(void) { _totalShaders=0; _shaders[VERTEX_SHADER]=0; _shaders[FRAGMENT_SHADER]=0; _shaders[GEOMETRY_SHADER]=0; _attributeList.clear(); _uniformLocationList.clear(); } GLSLShader::~GLSLShader(void) { _attributeList.clear(); _uniformLocationList.clear(); glDeleteProgram(_program); } void GLSLShader::LoadFromString(GLenum type, const string source) { GLuint shader = glCreateShader (type); const char * ptmp = source.c_str(); glShaderSource (shader, 1, &ptmp, NULL); //check whether the shader loads fine GLint status; glCompileShader (shader); glGetShaderiv (shader, GL_COMPILE_STATUS, &status); if (status == GL_FALSE) { GLint infoLogLength; glGetShaderiv (shader, GL_INFO_LOG_LENGTH, &infoLogLength); GLchar *infoLog= new GLchar[infoLogLength]; glGetShaderInfoLog (shader, infoLogLength, NULL, infoLog); cerr<<"Compile log: "<<infoLog<<endl; delete [] infoLog; } _shaders[_totalShaders++]=shader; } void GLSLShader::CreateAndLinkProgram() { _program = glCreateProgram (); if (_shaders[VERTEX_SHADER] != 0) { glAttachShader (_program, _shaders[VERTEX_SHADER]); } if (_shaders[FRAGMENT_SHADER] != 0) { glAttachShader (_program, _shaders[FRAGMENT_SHADER]); } if (_shaders[GEOMETRY_SHADER] != 0) { glAttachShader (_program, _shaders[GEOMETRY_SHADER]); } //link and check whether the program links fine GLint status; glLinkProgram (_program); glGetProgramiv (_program, GL_LINK_STATUS, &status); if (status == GL_FALSE) { GLint infoLogLength; glGetProgramiv (_program, GL_INFO_LOG_LENGTH, &infoLogLength); GLchar *infoLog= new GLchar[infoLogLength]; glGetProgramInfoLog (_program, infoLogLength, NULL, infoLog); cerr<<"Link log: "<<infoLog<<endl; delete [] infoLog; } glDeleteShader(_shaders[VERTEX_SHADER]); glDeleteShader(_shaders[FRAGMENT_SHADER]); glDeleteShader(_shaders[GEOMETRY_SHADER]); } void GLSLShader::Use() { glUseProgram(_program); } void GLSLShader::UnUse() { glUseProgram(0); } void GLSLShader::AddAttribute(const string attribute) { _attributeList[attribute]= glGetAttribLocation(_program, attribute.c_str()); } //An indexer that returns the location of the attribute GLuint GLSLShader::operator [](const string attribute) { return _attributeList[attribute]; } void GLSLShader::AddUniform(const string uniform) { _uniformLocationList[uniform] = glGetUniformLocation(_program, uniform.c_str()); } GLuint GLSLShader::operator()(const string uniform){ return _uniformLocationList[uniform]; } #include <fstream> void GLSLShader::LoadFromFile(GLenum whichShader, const string filename){ ifstream fp; fp.open(filename.c_str(), ios_base::in); if(fp) { string line, buffer; while(getline(fp, line)) { buffer.append(line); buffer.append("\r\n"); } //copy to source LoadFromString(whichShader, buffer); } else { cerr<<"Error loading shader: "<<filename<<endl; } }
[ "daniel@daniel-desktop.BigPond" ]
[ [ [ 1, 128 ] ] ]
895f416b1d45435e8afe3c33250db39937d1a651
0caca2bf0ec6c1b680d0bd50dd0855ffb78113fb
/src/engine/e_translate.cpp
b822896f9b197aa7d395d11e365cc2f63000ff9d
[ "LicenseRef-scancode-other-permissive", "Zlib" ]
permissive
sanyaade-gamedev/zteeworlds
e029afd193476c25cb24090a31570c175f1668ba
73ad5e6d34d5639c67c93298f21dcd523b06bf73
refs/heads/master
2021-01-18T17:48:47.321015
2010-05-10T15:43:49
2010-05-10T15:43:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,973
cpp
#include "e_translate.h" #include <base/system.h> #include <curl/curl.h> const unsigned long TranslatorLanguagesCount = 88; const char * TranslatorLanguages[88] = { "Afrikaans", "Albanian", "Amharic", "Arabic", "Armenian", "Azerbaijani", "Basque", "Belarusian", "Bengali", "Bihari", "Bulgarian", "Burmese", "Catalan", "Cherokee", "Chinese", "Chinese Simplified", "Chinese Traditional", "Croatian", "Czech", "Danish", "Dhivehi", "Dutch", "English", "Esperanto", "Estonian", "Filipino", "Finnish", "French", "Galician", "Georgian", "German", "Greek", "Guarani", "Gujarati", "Hebrew", "Hindi", "Hungarian", "Icelandic", "Indonesian", "Inuktitut", "Italian", "Japanese", "Kannada", "Kazakh", "Khmer", "Korean", "Kurdish", "Kyrgyz", "Laothian", "Latvian", "Lithuanian", "Macedonian", "Malay", "Malayalam", "Maltese", "Marathi", "Mongolian", "Nepali", "Norwegian", "Oriya", "Pashto", "Persian", "Polish", "Portuguese", "Punjabi", "Romanian", "Russian", "Sanskrit", "Serbian", "Sindhi", "Sinhalese", "Slovak", "Slovenian", "Spanish", "Swahili", "Swedish", "Tajik", "Tamil", "Tagalog", "Telugu", "Thai", "Tibetan", "Turkish", "Ukrainian", "Urdu", "Uzbek", "Uighur", "Vietnamese", }; const char * TranslatorLanguageCodes[88] = { "af", // 0 "sq", // 1 "am", // 2 "ar", // 3 "hy", // 4 "az", // 5 "eu", // 6 "be", // 7 "bn", // 8 "bh", // 9 "bg", // 10 "my", // 11 "ca", // 12 "chr", // 13 "zh", // 14 "zh-CN", // 15 "zh-TW", // 16 "hr", // 17 "cs", // 18 "da", // 19 "dv", // 20 "nl", // 21 "en", // 22 "eo", // 23 "et", // 24 "tl", // 25 "fi", // 26 "fr", // 27 "gl", // 28 "ka", // 29 "de", // 30 "el", // 31 "gn", // 32 "gu", // 33 "iw", // 34 "hi", // 35 "hu", // 36 "is", // 37 "id", // 38 "iu", // 39 "it", // 40 "ja", // 41 "kn", // 42 "kk", // 43 "km", // 44 "ko", // 45 "ku", // 46 "ky", // 47 "lo", // 48 "lv", // 49 "lt", // 50 "mk", // 51 "ms", // 52 "ml", // 53 "mt", // 54 "mr", // 55 "mn", // 56 "ne", // 57 "no", // 58 "or", // 59 "ps", // 60 "fa", // 61 "pl", // 62 "pt-PT", // 63 "pa", // 64 "ro", // 65 "ru", // 66 "sa", // 67 "sr", // 68 "sd", // 69 "si", // 70 "sk", // 71 "sl", // 72 "es", // 73 "sw", // 74 "sv", // 75 "tg", // 76 "ta", // 77 "tl", // 78 "te", // 79 "th", // 80 "bo", // 81 "tr", // 82 "uk", // 83 "ur", // 84 "uz", // 85 "ug", // 86 "vi", // 87 }; const unsigned long TranslationBufferSize = 4096; size_t curlWriteFunc(char *data, size_t size, size_t nmemb, char * buffer) { size_t result = 0; if (buffer != NULL) { result = size * nmemb; memcpy(buffer + strlen(buffer), data, result <= TranslationBufferSize - strlen(buffer) - 1 ? result : TranslationBufferSize - strlen(buffer) - 1); } return result; } char * UnescapeStep1(char * From) { unsigned long Len = str_length(From); char * Result = (char *)mem_alloc(Len * 4 + 1, 1); memset(Result, 0, Len * 4 + 1); unsigned long i = 0; unsigned long j = 0; while (i < Len) { if (From[i] == '\\') { if (From[i + 1] == '\\') { Result[j++] = '\\'; i += 2; } else { if (From[i + 2] == 'u') { unsigned long Code = 0; int q; for (q = 0; q < 4; q++) { if (From[i + 3 + q] >= '0' && From[i + 3 + q] <= '9') q = (q * 16) + From[i + 3 + q] - '0'; else if (From[i + 3 + q] >= 'a' && From[i + 3 + q] <= 'f') q = (q * 16) + 10 + From[i + 3 + q] - 'a'; else if (From[i + 3 + q] >= 'A' && From[i + 3 + q] <= 'F') q = (q * 16) + 10 + From[i + 3 + q] - 'A'; else break; } j += str_utf8_encode(Result, Code); i += 2 + q; } } } else { Result[j++] = From[i++]; } } return Result; } char * UnescapeStep2(char * From) { unsigned long Len = str_length(From); char * Result = (char *)mem_alloc(Len * 4 + 1, 1); memset(Result, 0, Len * 4 + 1); unsigned long i = 0; unsigned long j = 0; while (i < Len) { if (From[i] == '%') { if (From[i + 1] != '&') { Result[j++] = From[i++]; } else { unsigned long Code = 0; int q; for (q = 0; q < 4; q++) { if (From[i + 3 + q] >= '0' && From[i + 3 + q] <= '9') q = (q * 16) + From[i + 3 + q] - '0'; else if (From[i + 3 + q] >= 'a' && From[i + 3 + q] <= 'f') q = (q * 16) + 10 + From[i + 3 + q] - 'a'; else if (From[i + 3 + q] >= 'A' && From[i + 3 + q] <= 'F') q = (q * 16) + 10 + From[i + 3 + q] - 'A'; else break; } j += str_utf8_encode(Result, Code); i += 2 + q; if (From[i] == ';') i++; } } else { Result[j++] = From[i++]; } } return Result; } char * UnescapeStr(char * From) { char * First = UnescapeStep1(From); char * Second = UnescapeStep2(First); mem_free((void *)First); return Second; } char * EscapeStrByLong(const char * From) { unsigned long Len = str_length(From); unsigned long DestLen = Len * 6; char * Result = (char *)mem_alloc(DestLen + 1, 1); memset(Result, 0, DestLen + 1); unsigned long Char; const char * Text = From; char * ToText = Result; unsigned long i; while (Char = str_utf8_decode(&Text)) { *(ToText++) = '\\'; *(ToText++) = 'u'; str_format(ToText, 5, "%04x", Char); ToText += 4; } return Result; } char * EscapeStr(const char * From) { unsigned long Len = str_length(From); unsigned long DestLen = Len * 4; char * Result = (char *)mem_alloc(DestLen + 1, 1); memset(Result, 0, DestLen + 1); unsigned long Char; const char * Text = From; char * ToText = Result; unsigned long i; for (i = 0; i < Len; i++) { if ((From[i] >= 'a' && From[i] <= 'z') || (From[i] >= 'A' && From[i] <= 'Z') || (From[i] >= '0' && From[i] <= '9')) *(ToText++) = From[i]; else { *(ToText++) = '%'; str_format(ToText, 5, "%02x", ((unsigned int)From[i])%0x100); ToText += 2; } } return Result; } void TranslateTextThreadFunc(void * Param) { CURL * curl = NULL; char * Request = NULL; char * Escaped = NULL; char * Str = NULL; char * Result = NULL; TranslateTextThreadData * Data = (TranslateTextThreadData *)Param; try { curl = curl_easy_init(); curl_easy_setopt(curl, CURLOPT_URL, "http://ajax.googleapis.com/ajax/services/language/translate"); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(curl, CURLOPT_POST, 1); Request = (char *)mem_alloc(TranslationBufferSize, 1); Escaped = (char *)EscapeStr(Data->Text); str_format(Request, TranslationBufferSize, "v=1.0&q=%s&langpair=%%7C%s", Escaped, TranslatorLanguageCodes[Data->Language]); mem_free((void *)Escaped); Escaped = NULL; curl_easy_setopt(curl, CURLOPT_POSTFIELDS, Request); Str = (char *)mem_alloc(TranslationBufferSize, 1); memset(Str, 0, TranslationBufferSize); curl_easy_setopt(curl, CURLOPT_WRITEDATA, Str); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curlWriteFunc); CURLcode curlResult = curl_easy_perform(curl); curl_easy_cleanup(curl); mem_free(Request); Request = NULL; const char * TranslatedText = str_find_nocase(Str, "translatedText\":\""); if (TranslatedText) { TranslatedText += strlen("translatedText\":\""); char * TranslationEnd = (char *)str_find_nocase(TranslatedText, "\""); if (TranslationEnd) TranslationEnd[0] = 0; Result = strdup(TranslatedText); } else Result = strdup(Data->Text); mem_free(Str); Str = NULL; Data->Translated = UnescapeStr((char *)Result); free((void *)Result); Result = NULL; (*(Data->Callback))(Data); } catch(...) { if (Request) mem_free(Request); if (Escaped) mem_free(Escaped); if (Str) mem_free(Str); if (Result) free(Result); } try { free((void *)Data->Text); mem_free((void *)Data->Translated); mem_free((void *)Data); } catch(...) { } } unsigned long TranslateText(const char * Text, unsigned int Language, TranslatorCallback * Callback, void * Param) { TranslateTextThreadData * Data = (TranslateTextThreadData *)mem_alloc(sizeof(TranslateTextThreadData), 1); Data->Text = strdup(Text); Data->Language = Language; Data->Callback = Callback; Data->Param = Param; return (unsigned long)thread_create(TranslateTextThreadFunc, (void *)Data); } int TranslateGetLanguageIndex(const char * LangName) { for (unsigned long i = 0; i < TranslatorLanguagesCount; i++) { if (str_comp_nocase(LangName, TranslatorLanguages[i]) == 0 || str_comp_nocase(LangName, TranslatorLanguageCodes[i]) == 0) return i; } return -1; }
[ "Lite@17bf8faa-f2ac-4608-91d1-a55e81355a97" ]
[ [ [ 1, 437 ] ] ]
ac9103d037484d7554b254a6547ee80d1a62653d
b1926128e30ac4dd8a3589f221530855756c3fa0
/codigo2/POC/POC/TerrainMng.h
f5639f7036d4ed5601cbfd150b9262e38dd06d0e
[]
no_license
idaviden/proceduralframework
46d4cf85ecf1ed29035e937d0b245fd8e3cb17fa
81b4a42a1a461491994a7b7323db8f7f8b44083a
refs/heads/master
2021-01-10T09:42:04.812845
2009-03-28T01:21:32
2009-03-28T01:21:32
47,079,419
0
0
null
null
null
null
UTF-8
C++
false
false
279
h
#ifndef TerrainMng_H #define TerrainMng_H #include "Random.h" #include "Vector3.h" #include "Node.h" #include "GL/glew.h" #include "GL/glfw.h" class TerrainMng{ public: TerrainMng(); void Update(); void Render(); Node* m_sceneGraph; }; #endif
[ "fabiom@b1d7fb8e-94a0-11dd-af53-adecad094fb0" ]
[ [ [ 1, 24 ] ] ]
584c0a49b589a683c48fe6c63a34cf50aa6bc16f
59ce53af7ad5a1f9b12a69aadbfc7abc4c4bfc02
/src/SkinResEditor/SkinControlsMgt.h
80cc0589644150c2a03b98902bc5abf6209b9314
[]
no_license
fingomajom/skinengine
444a89955046a6f2c7be49012ff501dc465f019e
6bb26a46a7edac88b613ea9a124abeb8a1694868
refs/heads/master
2021-01-10T11:30:51.541442
2008-07-30T07:13:11
2008-07-30T07:13:11
47,892,418
0
0
null
null
null
null
UTF-8
C++
false
false
990
h
/******************************************************************** * CreatedOn: 2008-2-17 12:25 * FileName: SkinControlsMgt.h * CreatedBy: lidengwang <lidengwang@kingsoft.net> * $LastChangedDate$ * $LastChangedRevision$ * $LastChangedBy$ * $HeadURL: $ * Purpose: *********************************************************************/ #pragma once #include "SkinResDocument.h" #include "SkinResPropertyView.h" #include "SkinTreeControlView.h" class SkinControlsMgt { public: static SkinControlsMgt& Instance() { static SkinControlsMgt gs_skincontrolsmgt_instance; return gs_skincontrolsmgt_instance; } SkinResPropertyView m_skinResPropertyView; SkinTreeControlView m_skinTreeControlView; SkinFrame* m_piSkinFrame; SkinResDocument m_resDocument; public: //BOOL NewRes() //{ // // return TRUE; //} //BOOL OpenRes(); //BOOL SaveRes(); };
[ "wgkujgg@163.com" ]
[ [ [ 1, 48 ] ] ]
67d0b64313bec6d7479d95c8210f6b64d4caa121
506801cd3248f2362795b540a7247a989078468d
/test/TestEnvironment2/glMatrix4f.cpp
24942365ea1a170ea849a9641db89f561890fb44
[]
no_license
galek/gpufrustum
0bb1479fde1794476ff34ff2b4ecdb4bc57c200d
dfac4ead5d12ae4d1540d325f70a295c715bd07b
refs/heads/master
2020-05-29T12:32:30.603607
2010-01-07T12:45:51
2010-01-07T12:45:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
900
cpp
#include "glMatrix4f.h" #include "glVector4f.h" glMatrix4f::glMatrix4f(float* values) { for(int i = 0; i < 16; ++i ) { int ligne = i/4; int colonne = i-(ligne*4); elem[ligne][colonne] = values[i]; } } glVector4f& glMatrix4f::MatVecProduct(glVector4f &vin) { float v0 = this->elem[0][0]*vin[0] + this->elem[0][1]*vin[1] + this->elem[0][2]*vin[2] + this->elem[0][3]*vin[3]; float v1 = this->elem[1][0]*vin[0] + this->elem[1][1]*vin[1] + this->elem[1][2]*vin[2] + this->elem[1][3]*vin[3]; float v2 = this->elem[2][0]*vin[0] + this->elem[2][1]*vin[1] + this->elem[2][2]*vin[2] + this->elem[2][3]*vin[3]; float v3 = this->elem[3][0]*vin[0] + this->elem[3][1]*vin[1] + this->elem[3][2]*vin[2] + this->elem[3][3]*vin[3]; return (glVector4f(v0,v1,v2,v3)*(1.0f/v3)); }
[ "nicolas.said@bbca828e-1ad7-11de-a108-cd2f117ce590" ]
[ [ [ 1, 25 ] ] ]
c45ee7d6303e564664ab96cbc3522adbad4ee5c5
9a48be80edc7692df4918c0222a1640545384dbb
/Libraries/Boost1.40/libs/wave/test/testwave/testfiles/t_6_030.cpp
2e028040e4a49f7eb7ece73d36c4e89cf01aee9a
[ "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
2,408
cpp
/*============================================================================= Boost.Wave: A Standard compliant C++ preprocessor library http://www.boost.org/ Copyright (c) 2001-2009 Hartmut Kaiser. 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) The tests included in this file were initially taken from the mcpp V2.5 preprocessor validation suite and were modified to fit into the Boost.Wave unit test requirements. The original files of the mcpp preprocessor are distributed under the license reproduced at the end of this file. =============================================================================*/ // Tests error reporting: ill-formed group in a source file. // 17.6: Errorneous unterminated #if section in an included file. //E t_6_030.hpp(49): warning: unbalanced #if/#endif in include file: $P(t_6_030.hpp) #include "t_6_030.hpp" #endif /*- * Copyright (c) 1998, 2002-2005 Kiyoshi Matsui <kmatsui@t3.rim.or.jp> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. */
[ "metrix@Blended.(none)" ]
[ [ [ 1, 48 ] ] ]
031363cb31de019067eaf4b6aaa348458a804807
494629c5aef0b284ae75aa0ce57a0b0255a33290
/src/plugins/CorePlugin/idable.h
4511ca7dc7781d437d0b52a4dc9c82f4e7409d00
[]
no_license
cctvbtx/qtalker
9b81648d6252851f0a924685aa9d251597346f20
3aceb5d03fc40be069511959b359c2308ef0f656
refs/heads/master
2021-06-01T06:56:50.278167
2011-01-16T03:02:31
2011-01-16T03:02:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
831
h
#ifndef IDABLE_H #define IDABLE_H #include "CorePlugin_global.h" #include "uniqueidmanager.h" #include <QtCore> namespace CorePlugin { class COREPLUGINSHARED_EXPORT IDAble { public: IDAble(const ID& id) { UniqueIDManager* man = UniqueIDManager::instance(); if (man->hasUID(id)) { qWarning() << QString("%1 ID Already Have").arg(id); return; } else { this->m_id = id; man->insertUID(id); } } bool isIdValid() const { return m_id.isValid(); } int getIdNumber() const { UniqueIDManager* man = UniqueIDManager::instance(); return man->getUID(m_id); } ID getID() const { return m_id; } private: ID m_id; }; } #endif // IDABLE_H
[ "reyoung@126.com@a30f7099-0f1c-977c-82b7-a2b34129996d" ]
[ [ [ 1, 43 ] ] ]
2b6264cabbda253f48f83301d415f6b6a128adec
b2ae843f96b820b8a8b1ffce512d90eb32a2de72
/library/ArduinoPins.h
55548e0c42253fb3c18a555fcabfb624c90bc28d
[]
no_license
ee-444/MissionConsoleComm
eac0bcb05c7dde9a8df96ae4c710ba02f2095c6e
96babda25389df1450aa2856c543a67a6a0c4965
refs/heads/master
2021-01-13T14:29:05.358381
2011-03-03T01:00:49
2011-03-03T01:00:49
1,432,427
0
0
null
null
null
null
UTF-8
C++
false
false
1,243
h
// $Id$ /** * @file ArduinoPins.h * This header file is for enumeration types that are used and associated with Arduino * peripheral classes that reside in the ArduinoLibrary namespace. * * @brief This file contains enumeration types for use with in the ArduinoLibrary namespace. * * @author sgrove * * @version 1.01 * */ // $Log$ #ifndef ARDUINOPINS_H #define ARDUINOPINS_H namespace ArduinoLibrary{ //! Enumerated type for object association with a specific IO pin. enum PinName{ PIN_PA0 = 0x000, PIN_PA1, PIN_PA2, PIN_PA3, PIN_PA4, PIN_PA5, PIN_PA6, PIN_PA7, PIN_PB0 = 0x100, PIN_PB1, PIN_PB2, PIN_PB3, PIN_PB4, PIN_PB5, PIN_PB6, PIN_PB7, PIN_PC0 = 0x200, PIN_PC1, PIN_PC2, PIN_PC3, PIN_PC4, PIN_PC5, PIN_PC6, PIN_PC7, PIN_PD0 = 0x400, PIN_PD1, PIN_PD2, PIN_PD3, PIN_PD4, PIN_PD5, PIN_PD6, PIN_PD7, PA_BASE = 0x000, PB_BASE = 0x100, PC_BASE = 0x200, PD_BASE = 0x400, Px_BASE = 0x800 }; //! Enumerated type for setting up a pin as input or output enum PinType{ PINTYPE_INPUT = 0x00, PINTYPE_OUTPUT }; //! Enumerated type for using the internal pull up circuit enum BuiltInPullUp{ PULLUP_DISABLE = 0x00, PULLUP_ENABLE }; }; #endif
[ "sam.grove@student.csulb.edu" ]
[ [ [ 1, 49 ] ] ]
f24ae4d71a1a4c3d100626255c5c98bb01269df9
d115cf7a1b374d857f6b094d4b4ccd8e9b1ac189
/pygccxml_dev/unittests/data/binary_parsers/mydll.cpp
6735375daab76f27115d4818af6bec8709694875
[ "BSL-1.0" ]
permissive
gatoatigrado/pyplusplusclone
30af9065fb6ac3dcce527c79ed5151aade6a742f
a64dc9aeeb718b2f30bd6a5ff8dcd8bfb1cd2ede
refs/heads/master
2016-09-05T23:32:08.595261
2010-05-16T10:53:45
2010-05-16T10:53:45
700,369
4
2
null
null
null
null
UTF-8
C++
false
false
2,603
cpp
#include "mydll.h" #include <iostream> number_t::number_t() : m_value(0) { // std::cout << "{C++} number_t( 0 )" << std::endl; } number_t::number_t(int value) : m_value(value) { // std::cout << "{C++} number_t( " << value << " )" << std::endl; } number_t::~number_t() { // std::cout << "{C++} ~number_t()" << std::endl; } void number_t::print_it() const { std::cout << "{C++} value: " << m_value << std::endl; } int number_t::get_value() const{ return m_value; } void number_t::set_value(int x){ m_value = x; } number_t number_t::clone() const{ return number_t(*this); } std::auto_ptr<number_t> number_t::clone_ptr() const{ return std::auto_ptr<number_t>( new number_t( *this ) ); } void do_smth( number_aptr_t& ){ } int myclass_t::my_static_member = 99; const int myclass_t::my_const_static_member = 10009; int my_global_int = 90; volatile int my_volatile_global_variable = 9; int my_global_array[10] = {0,1,2,3,4,5,6,7,8,9}; void* get_pvoid(void*){ return 0;} void** get_ppvoid(void){return 0;} int FA10_i_i(int a[10]){ return 0;} int FPi_i(int *a){ return 0;} int Fc_i(char bar){ return 0;} int Ff_i(float bar){ return 0;} int Fg_i(double bar){ return 0;} int Fi_i(int bar){ return 0;} int Fie_i(int bar, ...){ return 0;} int Fii_i(int bar, int goo){ return 0;} int Fiii_i(int bar, int goo, int hoo){ return 0;} void Fmxmx_v(myclass_t arg1, X arg2, myclass_t arg3, X arg4){} void Fmyclass_v(myclass_t m){} const int Fv_Ci(void){ return 0;} long double Fv_Lg(void){ return 0.0;} int& Fv_Ri(void){ return my_global_int;} signed char Fv_Sc(void){ return 0;} unsigned char Fv_Uc(void){ return 0;} unsigned int Fv_Ui(void){ return 0;} unsigned long Fv_Ul(void){ return 0;} unsigned short Fv_Us(void){ return 0;} volatile int Fv_Vi(void){ return 0;} char Fv_c(void){ return 0;} float Fv_f(void){ return 0.0;} double Fv_g(void){ return 0.0;} int Fv_i(void){ return 0;} long Fv_l(void){ return 0;} short Fv_s(void){ return 0;} void Fv_v(void){ return;} int identity( int i){ return i; } /* void __cdecl Fv_v_cdecl(void) void __fastcall Fv_v_fastcall(void) void __stdcall Fv_v_stdcall(void) int Fx_i(x fnptr) int Fxix_i(x fnptr, int i, x fnptr3) int Fxx_i(x fnptr, x fnptr2) int Fxxi_i(x fnptr, x fnptr2, x fnptr3, int i) int Fxxx_i(x fnptr, x fnptr2, x fnptr3) int Fxyxy_i(x fnptr, y fnptr2, x fnptr3, y fnptr4) void __cdecl myclass::Fv_v_cdecl(void) void __fastcall myclass::Fv_v_fastcall(void) void __stdcall myclass::Fv_v_stdcall(void) void* myclass::operator new(size_t size) */
[ "roman_yakovenko@dc5859f9-2512-0410-ae5c-dd123cda1f76" ]
[ [ [ 1, 100 ] ] ]
8c6ea7be695246aa950e417402b468a4dd2db6f1
ea12fed4c32e9c7992956419eb3e2bace91f063a
/zombie/code/zombie/zombieentity/src/zombieentity/graphicsentitylistexp.cc
2fa3e682b800cbe6ab21f986821d8f75625f6180
[]
no_license
ugozapad/TheZombieEngine
832492930df28c28cd349673f79f3609b1fe7190
8e8c3e6225c2ed93e07287356def9fbdeacf3d6a
refs/heads/master
2020-04-30T11:35:36.258363
2011-02-24T14:18:43
2011-02-24T14:18:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,727
cc
#include "precompiled/pchzombieentityexp.h" //------------------------------------------------------------------------------ /** @ingroup NebulaEntity List of all the entities with its configuration. This must be a cc file, even although there is nothing really compiled in. It is a really a header defining some macros, but a cc is required by the build system right now. Graphic entities used by the exporter. (C) 2005 Conjurer Services, S.A. */ //------------------------------------------------------------------------------ // include for define nNebulaEntity #include "entity/ndefinenebulaentity.h" //------------------------------------------------------------------------------ /** */ #ifndef nNebulaEntity #define nNebulaEntity(P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12) #endif //------------------------------------------------------------------------------ /** Graphic entities */ nNebulaEntity( neMirage, nEntityObject, 6, ( ncDictionary, ncSubentity, ncTransform, ncLoader, ncSceneLod, ncSpatial), 2, ( ncPhyPickableObj, ncEditor), neMirageClass, nEntityClass, 6, ( ncDictionaryClass, ncTransformClass, ncAssetClass, ncSceneLodClass, ncSpatialClass, ncPhysicsObjClass), 1, ( ncEditorClass) ); nNebulaEntity( neBrush, nEntityObject, 7, ( ncDictionary, ncSubentity, ncTransform, ncLoader, ncSceneLod, ncSpatial, ncPhyCompositeObj ), 1, ( ncEditor), neBrushClass, nEntityClass, 6, ( ncDictionaryClass, ncTransformClass, ncAssetClass, ncSceneLodClass, ncSpatialClass, ncPhysicsObjClass), 1, ( ncEditorClass) ); nNebulaEntity( neSimpleBrush, nEntityObject, 6, ( ncDictionary, ncTransform, ncLoader, ncSceneLod, ncSpatial, ncPhySimpleObj), 1, ( ncEditor ), neSimpleBrushClass, nEntityClass, 6, ( ncDictionaryClass, ncTransformClass, ncAssetClass, ncSceneLodClass, ncSpatialClass, ncPhysicsObjClass), 1, ( ncEditorClass) ); nNebulaEntity( neCharacter, nEntityObject, 7, ( ncDictionary, ncTransform, ncLoader, ncPhyCharacterObj, ncSceneRagdoll, ncSpatial, ncCharacter), 1, ( ncEditor ), neCharacterClass, nEntityClass, 7, ( ncDictionaryClass, ncTransformClass, ncAssetClass, ncSpatialClass, ncPhysicsObjClass, ncSceneRagdollClass, ncCharacterClass), 1, ( ncEditorClass) ); nNebulaEntity( neSkeleton, nEntityObject, 7, ( ncDictionary, ncLoader, ncTransform, ncPhyCharacterObj, ncSpatial, ncSceneRagdoll, ncCharacter), 1, ( ncEditor), neSkeletonClass, nEntityClass, 6, ( ncDictionaryClass, ncAssetClass, ncSkeletonClass, ncPhysicsObjClass, ncSpatialClass, ncSceneRagdollClass), 1, ( ncEditorClass) ); nNebulaEntity( neHumRagdoll, nEntityObject, 6, ( ncDictionary, ncTransform, ncLoader, ncPhyHumRagDoll, ncHumRagdoll, ncScene), 1, ( ncEditor), neHumRagdollClass, nEntityClass, 5, ( ncDictionaryClass, ncAssetClass, ncPhyHumRagDollClass, ncHumRagdollClass, ncSceneClass), 1, ( ncEditorClass) ); nNebulaEntity( neFourLeggedRagdoll, nEntityObject, 6, ( ncDictionary, ncTransform, ncLoader, ncPhyFourleggedRagDoll, ncFourLeggedRagdoll, ncScene), 1, ( ncEditor), neFourLeggedRagdollClass, nEntityClass, 5, ( ncDictionaryClass, ncAssetClass, ncPhyFourleggedRagDollClass, ncFourLeggedRagdollClass, ncSceneClass), 1, ( ncEditorClass) ); //------------------------------------------------------------------------------
[ "magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91" ]
[ [ [ 1, 102 ] ] ]
8b419a73ed5fdf2094682538a1e2ef78f3024ae2
d2996420f8c3a6bbeef63a311dd6adc4acc40436
/src/net/Address.cpp
36a3b0c56144a10b9212bc31906f6c7119a349e6
[]
no_license
aruwen/graviator
4d2e06e475492102fbf5d65754be33af641c0d6c
9a881db9bb0f0de2e38591478429626ab8030e1d
refs/heads/master
2021-01-19T00:13:10.843905
2011-03-13T13:15:25
2011-03-13T13:15:25
32,136,578
0
0
null
null
null
null
UTF-8
C++
false
false
2,232
cpp
#include "Address.h" #include "..\GraviatorSimpleTypes.h" #include <assert.h> using namespace net; Address::Address() { mAddress = 0; mPort = 0; } Address::Address( unsigned char a, unsigned char b, unsigned char c, unsigned char d, unsigned short port ) { mAddress = ( a << 24 ) | ( b << 16 ) | ( c << 8 ) | d; mPort = port; } Address::Address( unsigned int address, unsigned short port ) { mAddress = address; mPort = port; } Address::Address(string address) { unsigned char a = atoi(address.substr(0, address.find('.')).c_str()); address = address.substr(address.find('.')+1); unsigned char b = atoi(address.substr(0, address.find('.')).c_str()); address = address.substr(address.find('.')+1); unsigned char c = atoi(address.substr(0, address.find('.')).c_str()); address = address.substr(address.find('.')+1); unsigned char d = atoi(address.substr(0, address.find('.')).c_str()); address = address.substr(address.find(':')+1); unsigned short port = atoi(address.c_str()); mAddress = ( a << 24 ) | ( b << 16 ) | ( c << 8 ) | d; mPort = port; } unsigned int Address::getAddress() const { return mAddress; } string Address::getAddressString() { return toString((int)getA()) + "." + toString((int)getB()) + "." + toString((int)getC()) + "." + toString((int)getD()) + ":" + toString(getPort()); } unsigned char Address::getA() const { return ( unsigned char ) ( mAddress >> 24 ); } unsigned char Address::getB() const { return ( unsigned char ) ( mAddress >> 16 ); } unsigned char Address::getC() const { return ( unsigned char ) ( mAddress >> 8 ); } unsigned char Address::getD() const { return ( unsigned char ) ( mAddress ); } unsigned short Address::getPort() const { return mPort; } bool Address::operator == ( const Address & other ) const { return mAddress == other.mAddress && mPort == other.mPort; } bool Address::operator != ( const Address & other ) const { return ! ( *this == other ); }
[ "nightwolve@gmail.com@c8d5bfcc-1391-a108-90e5-e810ef6ef867" ]
[ [ [ 1, 98 ] ] ]
7d79608138382c84069e5af399e2a3055cb0f835
a296df442777ae1e63188cbdf5bcd2ca0adedf3f
/2372/2372/main.cpp
318a08d998ecf6d38f3d1b336774c7c292f139c1
[]
no_license
piyushv94/jpcap-scanner
39b4d710166c12a2fe695d9ec222da7b36787443
8fbf4214586e4f07f1b3ec4819f9a3c7451bd679
refs/heads/master
2021-01-10T06:15:32.064675
2011-11-26T20:23:55
2011-11-26T20:23:55
44,114,378
0
0
null
null
null
null
UTF-8
C++
false
false
143
cpp
#include"Card.h" #include"Item.h" #include"Piece.h" #include"Tower.h" #include"Game.h" int main(){ Game g; g.runGame(); return 0; }
[ "shevchenkozou@gmail.com" ]
[ [ [ 1, 10 ] ] ]
f91f6c543c26648a2f06f12169f92d7182d8863b
d5f525c995dd321375a19a8634a391255f0e5b6f
/graphic_front_end/sp/sp/vbus/vbus_interface.cpp
6bcfd5475c6e6f324d0654fe1abf72c7dffd8539
[]
no_license
shangdawei/cortex-simulator
bac4b8f19be3e2df622ad26e573330642ec97bae
d343b66a88a5b78d5851a3ee5dc2a4888ff00b20
refs/heads/master
2016-09-05T19:45:32.930832
2009-03-19T06:07:47
2009-03-19T06:07:47
42,106,205
1
1
null
null
null
null
UTF-8
C++
false
false
490
cpp
#include "stdafx.h" #include "vbus_interface.h" void vb_nread(int vaddr, char* data, int d_size) { win32_read_bus(vaddr, data, d_size); } char vb_read(int addr) { char data; win32_read_bus(addr, &data, 1); return data; } void vb_nwrite(int vaddr, char* data, int d_size) { win32_write_bus(vaddr, data, d_size); } void vb_write(int addr, char data) { win32_write_bus(addr, &data, 1); } bool vb_load(char* busname) { return win32_load_bus(busname); }
[ "yihengw@3e89f612-834b-0410-bb31-dbad55e6f342" ]
[ [ [ 1, 30 ] ] ]
231a6bc1f5b98f2c4e414a5f657dc19a81017616
74c8da5b29163992a08a376c7819785998afb588
/NetAnimal/Game/wheel/MyWheelController/include/WheelClockListener.h
acf6948c64a8967391698506a6d23bf0e83813c3
[]
no_license
dbabox/aomi
dbfb46c1c9417a8078ec9a516cc9c90fe3773b78
4cffc8e59368e82aed997fe0f4dcbd7df626d1d0
refs/heads/master
2021-01-13T14:05:10.813348
2011-06-07T09:36:41
2011-06-07T09:36:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
303
h
#ifndef __Orz_WheelClockListener_h__ #define __Orz_WheelClockListener_h__ #include "WheelControllerConfig.h" namespace Orz { class _OrzMyWheelControlleExport WheelClockListener { public: virtual ~WheelClockListener(void){} virtual void clockChanged(int second) = 0; }; } #endif
[ "ogre3d@yeah.net" ]
[ [ [ 1, 18 ] ] ]
73bc63c287a009bef096e2e5b5aba1bff08ded16
ea2786bfb29ab1522074aa865524600f719b5d60
/MultimodalSpaceShooter/src/scenes/GameOverScene.cpp
7be6c45f68638dc0baecda1e0bcc8cb68aec8c3c
[]
no_license
jeremysingy/multimodal-space-shooter
90ffda254246d0e3a1e25558aae5a15fed39137f
ca6e28944cdda97285a2caf90e635a73c9e4e5cd
refs/heads/master
2021-01-19T08:52:52.393679
2011-04-12T08:37:03
2011-04-12T08:37:03
1,467,691
0
1
null
null
null
null
UTF-8
C++
false
false
1,743
cpp
#include "scenes/GameOverScene.h" #include "scenes/SceneManager.h" #include "core/Managers.h" #include "core/Game.h" #include <SFML/Graphics.hpp> GameOverScene::GameOverScene(SceneManager& sceneManager) : IScene(sceneManager), myCursor(*imageManager().get("cursor.png")), myMenu("GAME OVER", *imageManager().get("menu.png"), sf::Color::Red) { myMenu.addButton("but_gameover_continue", "Restart the game", this); myMenu.addButton("but_gameover_quit", "Quit", this); } void GameOverScene::update(float frameTime) { if(multimodalManager().getTrackingState() == Tracking::UserTracked) myCursor.SetPosition(multimodalManager().getRightHandPosition()); else myCursor.SetPosition(static_cast<float>(eventManager().getInput().GetMouseX()), static_cast<float>(eventManager().getInput().GetMouseY())); myMenu.update(frameTime); } void GameOverScene::draw(sf::RenderTarget& window) const { myMenu.draw(window); window.Draw(myCursor); } void GameOverScene::onEvent(const sf::Event& event) { if(event.Type == sf::Event::KeyPressed) { if(event.Key.Code == sf::Key::Escape) mySceneManager.changeCurrentScene(Scene::InGame); if(event.Key.Code == sf::Key::Q) Game::instance().quit(); } myMenu.onEvent(event); } void GameOverScene::onMultimodalEvent(Multimodal::Event event) { myMenu.onMultimodalEvent(event); } void GameOverScene::onButtonPress(const std::string& buttonId) { if(buttonId == "but_gameover_continue") mySceneManager.changeCurrentScene(Scene::InGame); else if(buttonId == "but_gameover_quit") Game::instance().quit(); }
[ "jeremy.singy@gmail.com" ]
[ [ [ 1, 59 ] ] ]
341fb6f7dd33291e018c03728576763b9cf2f11b
89e8f2ade84be2f06749083073dc1edd5854451f
/include/gpu_anim.h
81cc762db0be66d1f7f983c124d8dd126e491f6a
[]
no_license
abeastinme/GPU_Nubeam
243f0828d849ce74b10067226fb2196c0f9e778e
d242106ff0a6fccb8159ede83df63013b974ba7e
refs/heads/master
2021-01-17T13:43:46.066740
2011-12-17T05:18:39
2011-12-17T05:18:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,152
h
/* * Copyright 1993-2010 NVIDIA Corporation. All rights reserved. * * NVIDIA Corporation and its licensors retain all intellectual property and * proprietary rights in and to this software and related documentation. * Any use, reproduction, disclosure, or distribution of this software * and related documentation without an express license agreement from * NVIDIA Corporation is strictly prohibited. * * Please refer to the applicable NVIDIA end user license agreement (EULA) * associated with this source code for terms and conditions that govern * your use of this NVIDIA software. * */ #ifndef __GPU_ANIM_H__ #define __GPU_ANIM_H__ #include "gl_helper.h" #include "cuda.h" #include "cutil.h" #include "cuda_gl_interop.h" #include <iostream> PFNGLBINDBUFFERARBPROC glBindBuffer = NULL; PFNGLDELETEBUFFERSARBPROC glDeleteBuffers = NULL; PFNGLGENBUFFERSARBPROC glGenBuffers = NULL; PFNGLBUFFERDATAARBPROC glBufferData = NULL; struct GPUAnimBitmap { GLuint bufferObj; cudaGraphicsResource *resource; int width, height; void *dataBlock; void (*fAnim)(uchar4*,void*,int); void (*animExit)(void*); void (*clickDrag)(void*,int,int,int,int); int dragStartX, dragStartY; GPUAnimBitmap( int w, int h, void *d = NULL ) { width = w; height = h; dataBlock = d; clickDrag = NULL; // first, find a CUDA device and set it to graphic interop cudaDeviceProp prop; int dev = 0; //memset( &prop, 0, sizeof( cudaDeviceProp ) ); prop.major = 2; prop.minor = 0; //CUDA_SAFE_CALL( cudaChooseDevice( &dev, &prop ) ); CUDA_SAFE_CALL(cudaDeviceReset()); CUDA_SAFE_CALL(cudaDeviceSynchronize()); CUDA_SAFE_CALL(cudaGLSetGLDevice( 0 )); CUDA_SAFE_CALL(cudaDeviceSynchronize()); // CUDA_SAFE_CALL(cudaGLSetGLDevice( 0 )); // a bug in the Windows GLUT implementation prevents us from // passing zero arguments to glutInit() int c=1; char* dummy = ""; glutInit( &c, &dummy ); glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA ); glutInitWindowSize( width, height ); glutCreateWindow( "bitmap" ); glBindBuffer = (PFNGLBINDBUFFERARBPROC)GET_PROC_ADDRESS("glBindBuffer"); glDeleteBuffers = (PFNGLDELETEBUFFERSARBPROC)GET_PROC_ADDRESS("glDeleteBuffers"); glGenBuffers = (PFNGLGENBUFFERSARBPROC)GET_PROC_ADDRESS("glGenBuffers"); glBufferData = (PFNGLBUFFERDATAARBPROC)GET_PROC_ADDRESS("glBufferData"); glGenBuffers( 1, &bufferObj ); glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, bufferObj ); glBufferData( GL_PIXEL_UNPACK_BUFFER_ARB, width * height * 4, NULL, GL_DYNAMIC_DRAW_ARB ); CUDA_SAFE_CALL(cudaDeviceSynchronize()); CUDA_SAFE_CALL( cudaGraphicsGLRegisterBuffer( &resource, bufferObj, cudaGraphicsMapFlagsNone ) ); } ~GPUAnimBitmap() { free_resources(); } void free_resources( void ) { CUDA_SAFE_CALL( cudaGraphicsUnregisterResource( resource ) ); glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, 0 ); glDeleteBuffers( 1, &bufferObj ); } long image_size( void ) const { return width * height * 4; } void click_drag( void (*f)(void*,int,int,int,int)) { clickDrag = f; } void anim_and_exit( void (*f)(uchar4*,void*,int), void(*e)(void*) ) { GPUAnimBitmap** bitmap = get_bitmap_ptr(); *bitmap = this; fAnim = f; animExit = e; glutKeyboardFunc( Key ); glutDisplayFunc( Draw ); if (clickDrag != NULL) glutMouseFunc( mouse_func ); glutIdleFunc( idle_func ); glutMainLoop(); } // static method used for glut callbacks static GPUAnimBitmap** get_bitmap_ptr( void ) { static GPUAnimBitmap* gBitmap; return &gBitmap; } // static method used for glut callbacks static void mouse_func( int button, int state, int mx, int my ) { if (button == GLUT_LEFT_BUTTON) { GPUAnimBitmap* bitmap = *(get_bitmap_ptr()); if (state == GLUT_DOWN) { bitmap->dragStartX = mx; bitmap->dragStartY = my; } else if (state == GLUT_UP) { bitmap->clickDrag( bitmap->dataBlock, bitmap->dragStartX, bitmap->dragStartY, mx, my ); } } } // static method used for glut callbacks static void idle_func( void ) { static int ticks = 1; GPUAnimBitmap* bitmap = *(get_bitmap_ptr()); uchar4* devPtr; size_t size; CUDA_SAFE_CALL( cudaGraphicsMapResources( 1, &(bitmap->resource), NULL ) ); CUDA_SAFE_CALL( cudaGraphicsResourceGetMappedPointer( (void**)&devPtr, &size, bitmap->resource) ); bitmap->fAnim( devPtr, bitmap->dataBlock, ticks++ ); CUDA_SAFE_CALL( cudaGraphicsUnmapResources( 1, &(bitmap->resource), NULL ) ); glutPostRedisplay(); } // static method used for glut callbacks static void Key(unsigned char key, int x, int y) { switch (key) { case 27: GPUAnimBitmap* bitmap = *(get_bitmap_ptr()); if (bitmap->animExit) bitmap->animExit( bitmap->dataBlock ); bitmap->free_resources(); exit(0); } } // static method used for glut callbacks static void Draw( void ) { GPUAnimBitmap* bitmap = *(get_bitmap_ptr()); glClearColor( 0.0, 0.0, 0.0, 1.0 ); glClear( GL_COLOR_BUFFER_BIT ); glDrawPixels( bitmap->width, bitmap->height, GL_RGBA, GL_UNSIGNED_BYTE, 0 ); glutSwapBuffers(); } }; #endif // __GPU_ANIM_H__
[ "spad12@mit.edu" ]
[ [ [ 1, 183 ] ] ]
1d66c148be02832e855e5dfd27a48431985e7c6f
e3b3b66c1700f6c678fe7aba71076ba367a66308
/lab.cpp
1fb2a6b276d2883bb1c512a90ff0750c6be15557
[]
no_license
alrock/AI-Lab1
fb8470bdce3d306f4f1f4a565d647b3cef98fac1
6e4199f67e1239b80a617722821b0a0ac6b10ab8
refs/heads/master
2020-12-25T18:20:34.795448
2010-09-25T12:02:04
2010-09-25T12:02:04
null
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
4,256
cpp
#include <QtCore/QCoreApplication> #include <QString> #include <QStringList> #include <QRect> #include <QPoint> #include <QList> #include <QMap> #include <QDebug> class State { public: State() {} State(const QStringList &s); State(const QVector<QVector<int> > &s); State(const State &s): s(s.s) {} QList<State> expand() const; //сравнение двух состояний bool operator == (const State &s) const; // печать состояния operator QString() const { return s; } QString toString() const { return s; } private: QPoint horse_index(); // 0 - пустая / 1 - пешка / 7 - конь QVector<QVector<int> > field; }; State::State(const QStringList &s): field(8) { QStringList::iterator i; for (int k = 0, i = s.begin(); i != s.end(); ++i, ++k) { QString t = (*i); for (int j = 0; j < t.length(); ++j) { switch(t[j]) { case '.': field[k].push_back(0); break; case 'P': field[k].push_back(1); break; case 'K': field[k].push_back(7); break; } } } } State::State(const QVector<QVector<int> > &s): field(s) { } bool State::operator == (const State &s) const { return field == s.field; } QPoint State::horse_index() { for (int i = 0; i < field.size(); ++i) { int index = field[i].indexOf(7); if (index != -1) return QPoint(i, index); } return QPoint(-1, -1); } QList<State> State::expand() const { QList<State> l; QRect f(0,0,7,7); QPoint horse = horse_index(); QPoint n = horse + QPoint(1,3); if (f.contains(n)) { QVector<QVector<int> > t = field; t[horse.y()][horse.x()] = 0; t[n.y()][n.x()] = 7; l.append(State(t)); } n = horse + QPoint(-1,3); if (f.contains(n)) { QVector<QVector<int> > t = field; t[horse.y()][horse.x()] = 0; t[n.y()][n.x()] = 7; l.append(State(t)); } n = horse + QPoint(-3,1); if (f.contains(n)) { QVector<QVector<int> > t = field; t[horse.y()][horse.x()] = 0; t[n.y()][n.x()] = 7; l.append(State(t)); } n = horse + QPoint(-3,-1); if (f.contains(n)) { QVector<QVector<int> > t = field; t[horse.y()][horse.x()] = 0; t[n.y()][n.x()] = 7; l.append(State(t)); } n = horse + QPoint(1,-3); if (f.contains(n)) { QVector<QVector<int> > t = field; t[horse.y()][horse.x()] = 0; t[n.y()][n.x()] = 7; l.append(State(t)); } n = horse + QPoint(-1,-3); if (f.contains(n)) { QVector<QVector<int> > t = field; t[horse.y()][horse.x()] = 0; t[n.y()][n.x()] = 7; l.append(State(t)); } n = horse + QPoint(3,1); if (f.contains(n)) { QVector<QVector<int> > t = field; t[horse.y()][horse.x()] = 0; t[n.y()][n.x()] = 7; l.append(State(t)); } n = horse + QPoint(3,-1); if (f.contains(n)) { QVector<QVector<int> > t = field; t[horse.y()][horse.x()] = 0; t[n.y()][n.x()] = 7; l.append(State(t)); } return l; } class DeepThought { public: DeepThought(const State &begin, const State &end); // Answer to the Ultimate Question of Life, the Universe, and Everything int answer(); void backtrace(); private: State begin; State end; QMap<State, State> tree; }; DeepThought::DeepThought(const State &begin, const State &end) : begin(begin), end(end) { tree.insert(begin, end); } int DeepThought::answer() { QVector<State> iters; iters.append(tree.begin().key()); for (int i = 0; i < iters.size(); ++i) { QList<State> l = iters[i].expand(); if (l.isEmpty()) continue; QList<State>::const_iterator j; for (j = l.begin(); j != l.end(); ++j) { if (tree.find((*j)) == tree.end()) { iters.append((*j)); tree.insert( (*j), iters[i] ); if ((*j) == end) return 42; } } } return 0; } void DeepThought::backtrace() { pair<State, State> s = tree.back(); while (! (s.first == begin)) { o << s.first << endl; list< pair<State, State> >::iterator i = find(s.second); if (i == tree.end()) break; s = (*i); } } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); DeepThought task(State("oooo.xxxx"), State("xxxx.oooo")); task.answer(); //task.backtrace(cout); return a.exec(); }
[ "alexandrsk@gmail.com" ]
[ [ [ 1, 203 ] ] ]
dee6728e31b17c4957249f44e286d2778bab0dd6
74c8da5b29163992a08a376c7819785998afb588
/NetAnimal/Game/wheel/NewWheelController/src/NewHardware.cpp
bd64c0aec56920f021c4baa5f7a8e05f84c47bdb
[]
no_license
dbabox/aomi
dbfb46c1c9417a8078ec9a516cc9c90fe3773b78
4cffc8e59368e82aed997fe0f4dcbd7df626d1d0
refs/heads/master
2021-01-13T14:05:10.813348
2011-06-07T09:36:41
2011-06-07T09:36:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,153
cpp
#include "NewWheelControllerStableHeaders.h" #include "NewHardware.h" #include <orz/View_SingleChip/SingleChipManager.h> #include "NewHardwareCode.h" using namespace Orz; boost::array<unsigned char , 40> container; NewHardware::NewHardware(void) { } void NewHardware::link(void) { unsigned char out[2] = {0xbb, 0xee}; Orz::SingleChipManager::getSingleton().write(out , 2); } void NewHardware::findPC(void) { std::cout<<"Find PC"<<std::endl; unsigned char out[2] = {0xa1,0xee}; Orz::SingleChipManager::getSingleton().write(out , 2); } void NewHardware::end(void) { NewHardwareCode::getSingleton().encode( 0xaa, 0xee, container); //Orz::SingleChipManager::getSingleton().write(container.begin(), 40); } void NewHardware::answerTime(int second) { NewHardwareCode::getSingleton().encode( 0xa2, unsigned char(second), container); //Orz::SingleChipManager::getSingleton().write(container.begin() , 40); } NewHardware & NewHardware::getInstance(void) { return *(getInstancePtr()); } NewHardware * NewHardware::getInstancePtr(void) { static NewHardware instance; return &instance; }
[ "ogre3d@yeah.net" ]
[ [ [ 1, 53 ] ] ]
267562c5f262ac832e8bdb6774f2ca4f50cdfa9e
bc4919e48aa47e9f8866dcfc368a14e8bbabbfe2
/Open GL Basic Engine/source/glutFramework/glutFramework/christianState.cpp
432f15fe6ee3674d5294349be3187dfcfb5f7cc0
[]
no_license
CorwinJV/rvbgame
0f2723ed3a4c1a368fc3bac69052091d2d87de77
a4fc13ed95bd3e5a03e3c6ecff633fe37718314b
refs/heads/master
2021-01-01T06:49:33.445550
2009-11-03T23:14:39
2009-11-03T23:14:39
32,131,378
0
0
null
null
null
null
UTF-8
C++
false
false
301
cpp
#include"christianState.h" christianState::christianState(GameStateManager &Parent, int newID) : GameState() { GSM = &Parent; stateID = newID; } bool christianState::Update() { MyObjectM.Update(); return true; } bool christianState::Draw() { MyObjectM.Draw(); return true; }
[ "corwin.j@5457d560-9b84-11de-b17c-2fd642447241" ]
[ [ [ 1, 19 ] ] ]
d3d3788cbf478df3640c6de124789556c3e53afe
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/graph/test/filtered_graph_cc.cpp
24de69742ad92c38a63cda395c890f68ffdbfd1d
[ "Artistic-2.0", "LicenseRef-scancode-public-domain", "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
willrebuild/flyffsf
e5911fb412221e00a20a6867fd00c55afca593c7
d38cc11790480d617b38bb5fc50729d676aef80d
refs/heads/master
2021-01-19T20:27:35.200154
2011-02-10T12:34:43
2011-02-10T12:34:43
32,710,780
3
0
null
null
null
null
UTF-8
C++
false
false
1,809
cpp
//======================================================================= // Copyright 1997, 1998, 1999, 2000 University of Notre Dame. // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) //======================================================================= #include <boost/graph/graph_concepts.hpp> #include <boost/graph/graph_archetypes.hpp> #include <boost/graph/adjacency_list.hpp> #include <boost/graph/filtered_graph.hpp> int main(int,char*[]) { using namespace boost; // Check filtered_graph { typedef adjacency_list<vecS, vecS, directedS, no_property, property<edge_residual_capacity_t, long> > Graph; typedef property_map<Graph, edge_residual_capacity_t>::type ResCapMap; typedef filtered_graph<Graph, is_residual_edge<ResCapMap> > ResGraph; typedef graph_traits<ResGraph>::edge_descriptor Edge; function_requires< VertexListGraphConcept<ResGraph> >(); function_requires< EdgeListGraphConcept<ResGraph> >(); function_requires< IncidenceGraphConcept<ResGraph> >(); function_requires< AdjacencyGraphConcept<ResGraph> >(); function_requires< PropertyGraphConcept<ResGraph, Edge, edge_residual_capacity_t> >(); } // Check filtered_graph with bidirectional adjacency_list { typedef adjacency_list<vecS, vecS, bidirectionalS, no_property, property<edge_residual_capacity_t, long> > Graph; typedef property_map<Graph, edge_residual_capacity_t>::type ResCapMap; typedef filtered_graph<Graph, is_residual_edge<ResCapMap> > ResGraph; function_requires< BidirectionalGraphConcept<ResGraph> >(); } return 0; }
[ "66430417@qq.com@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 41 ] ] ]
efed23dbc079a5178447325b7bcce295950ef367
a7513d1fb4865ea56dbc1fcf4584fb552e642241
/shiftable_files/osal/windows/osal_windows.hpp
470a54d25f7fcc7ac600e9aa4c9ebb99d4a8ef0b
[ "MIT" ]
permissive
det/avl_array
f0cab062fa94dd94cdf12bea4321c5488fb5cdcc
d57524a623af9cfeeff060b479cc47285486d741
refs/heads/master
2021-01-15T19:40:10.287367
2010-05-06T13:13:35
2010-05-06T13:13:35
35,425,204
0
0
null
null
null
null
UTF-8
C++
false
false
1,618
hpp
/////////////////////////////////////////////////////////////////// // // // Copyright (c) 2010, Universidad de Alcala // // // // See accompanying LICENSE.TXT // // // /////////////////////////////////////////////////////////////////// /* osal_windows.hpp ---------------- Declaration of a concrete OSAL (Operating System Abstraction Layer) that provides memory-mapped files in Windows. */ #ifndef _OSAL_WINDOWS_HPP_ #define _OSAL_WINDOWS_HPP_ #include <windows.h> // Windows SDK required #include "../osal.hpp" namespace shiftable_files { namespace detail { class true_file : public file { private: bool m_open; int8_t * m_pmap; bool m_mapped; uint32_t m_size; HANDLE m_hfile; HANDLE m_hmap; void init () { m_pmap = NULL; m_mapped = m_open = false; m_size = 0; m_hfile = m_hmap = INVALID_HANDLE_VALUE; } true_file (const true_file &) { init (); } const true_file & operator= (const true_file &) { return *this; } public: true_file () { init (); } ~true_file (); bool open (const char * name, open_mode mode); void close (); uint32_t size (); bool resize (uint32_t size); int8_t * map (); void unmap (); }; } // namespace detail } // namespace shiftable_files #endif
[ "martin@ROBOTITO" ]
[ [ [ 1, 71 ] ] ]
858f37f1c38e3039d0f20034dacda1522b01b668
1736474d707f5c6c3622f1cd370ce31ac8217c12
/Pseudo/StackWalk.hpp
fed556a77edb8a8f25d6ce0fe78f5ddf946ea5dc
[]
no_license
arlm/pseudo
6d7450696672b167dd1aceec6446b8ce137591c0
27153e50003faff31a3212452b1aec88831d8103
refs/heads/master
2022-11-05T23:38:08.214807
2011-02-18T23:18:36
2011-02-18T23:18:36
275,132,368
0
0
null
null
null
null
UTF-8
C++
false
false
19,091
hpp
// Copyright (c) John Lyon-Smith. All rights reserved. #pragma once #pragma warning(push) #include <Pseudo\Compiler.hpp> // Windows //#pragma pack(push, 8) // We set the packing to 64 bits to avoid problems with DbgHelp.dll //#define _IMAGEHLP64 #include <dbghelp.h> #include <tlhelp32.h> //#pragma pack(pop) // Pseudo #include <Pseudo\String.hpp> #include <Pseudo\ArrayList.hpp> #include <Pseudo\Macros.hpp> #include <Pseudo\Trace.hpp> #include <Pseudo\Exception.hpp> #include <Pseudo\CountedPtr.hpp> #include <Pseudo\Encoding.hpp> #include <Pseudo\File.hpp> #include <Pseudo\Path.hpp> namespace Pseudo { const int MAX_SYMBOL_NAME_LEN = 1024; /// <summary> /// This structure contains information about one function 'frame' on the stack. This quality of this /// information is largely dependent on whether full and up-to-date debug (.pdb) symbols are available for /// the module containing the function. /// </summary> struct StackFrame { public: // Default constructor StackFrame() { line = 0; address = 0; offset = 0; } // Copy constructor StackFrame(StackFrame const& rhs) { moduleName = rhs.moduleName; fileName = rhs.fileName; methodName = rhs.methodName; line = rhs.line; address = rhs.address; offset = rhs.offset; } String moduleName; // Module name String fileName; // Source file String methodName; // Method name Int line; // Line # void* address; // Address of first instruction in the method IntPtr offset; // Offset of the first instruction in the line from the method base // or the offset of the faulting instruction from the method base if no line information // or the offset of the faulting instruction from the base of the module if no module // information }; typedef struct { DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE64_V2) DWORD64 BaseOfImage; // base load address of module DWORD ImageSize; // virtual size of the loaded module DWORD TimeDateStamp; // date/time stamp from pe header DWORD CheckSum; // checksum from the pe header DWORD NumSyms; // number of symbols in the symbol table SYM_TYPE SymType; // type of symbols loaded CHAR ModuleName[32]; // module name CHAR ImageName[256]; // image name CHAR LoadedImageName[256]; // symbol file name } IMAGEHLP_MODULE64_V2; class StackWalker { // DbgHelp API's private: typedef BOOL (__stdcall *SymCleanupProc)(IN HANDLE hProcess); private: typedef PVOID (__stdcall *SymFunctionTableAccess64Proc)(HANDLE hProcess, DWORD64 AddrBase); private: typedef BOOL (__stdcall *SymGetLineFromAddr64Proc)( IN HANDLE hProcess, IN DWORD64 dwAddr, OUT PDWORD pdwDisplacement, OUT PIMAGEHLP_LINE64 Line); private: typedef DWORD64 (__stdcall *SymGetModuleBase64Proc)(IN HANDLE hProcess, IN DWORD64 dwAddr); private: typedef BOOL (__stdcall *SymGetModuleInfo64Proc)(IN HANDLE hProcess, IN DWORD64 dwAddr, OUT IMAGEHLP_MODULE64_V2 *ModuleInfo); private: typedef DWORD (__stdcall *SymGetOptionsProc)(VOID); private: typedef BOOL (__stdcall *SymFromAddrProc)( IN HANDLE hProcess, IN DWORD64 dwAddr, OUT PDWORD64 pdwDisplacement, OUT PSYMBOL_INFO Symbol); private: typedef BOOL (__stdcall *SymInitializeProc)(IN HANDLE hProcess, IN const Char* UserSearchPath, IN BOOL fInvadeProcess); private: typedef DWORD64 (__stdcall *SymLoadModule64Proc)( IN HANDLE hProcess, IN HANDLE hFile, IN PSTR ImageName, IN PSTR ModuleName, IN DWORD64 BaseOfDll, IN DWORD SizeOfDll); private: typedef DWORD (__stdcall *SymSetOptionsProc)(IN DWORD SymOptions); private: typedef BOOL (__stdcall *StackWalk64Proc)( DWORD MachineType, HANDLE hProcess, HANDLE hThread, LPSTACKFRAME64 StackFrame, PVOID ContextRecord, PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine, PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine, PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine, PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress); private: typedef DWORD (__stdcall WINAPI *UnDecorateSymbolNameProc)( PCSTR DecoratedName, PSTR UnDecoratedName, DWORD UndecoratedLength, DWORD Flags); // ToolHelp API's private: typedef HANDLE (__stdcall *CreateToolhelp32SnapshotProc)(DWORD dwFlags, DWORD th32ProcessID); private: typedef BOOL (__stdcall *Module32FirstWProc)(HANDLE hSnapshot, LPMODULEENTRY32W pme); private: typedef BOOL (__stdcall *Module32NextWProc)(HANDLE hSnapshot, LPMODULEENTRY32W pme); private: SymCleanupProc _SymCleanup; private: SymFunctionTableAccess64Proc _SymFunctionTableAccess64; private: SymGetLineFromAddr64Proc _SymGetLineFromAddr64; private: SymGetModuleBase64Proc _SymGetModuleBase64; private: SymGetModuleInfo64Proc _SymGetModuleInfo64; private: SymGetOptionsProc _SymGetOptions; private: SymFromAddrProc _SymFromAddr; private: SymInitializeProc _SymInitialize; private: SymLoadModule64Proc _SymLoadModule64; private: SymSetOptionsProc _SymSetOptions; private: StackWalk64Proc _StackWalk64; private: UnDecorateSymbolNameProc _UnDecorateSymbolName; private: CreateToolhelp32SnapshotProc _CreateToolhelp32Snapshot; private: Module32FirstWProc _Module32FirstW; private: Module32NextWProc _Module32NextW; private: HANDLE hProcess; private: HMODULE hDbgHelp; private: HMODULE hKernel32; private: bool initialized; public: StackWalker() { } private: void Reset() { hDbgHelp = NULL; hKernel32 = NULL; _SymCleanup = NULL; _SymFunctionTableAccess64 = NULL; _SymGetLineFromAddr64 = NULL; _SymGetModuleBase64 = NULL; _SymGetModuleInfo64 = NULL; _SymGetOptions = NULL; _SymFromAddr = NULL; _SymInitialize = NULL; _SymLoadModule64 = NULL; _SymSetOptions = NULL; _StackWalk64 = NULL; _UnDecorateSymbolName = NULL; _CreateToolhelp32Snapshot = NULL; _Module32FirstW = NULL; _Module32NextW = NULL; initialized = false; } public: bool Initialize() { String fileName; String programFiles; String systemRoot; if (initialized) return true; // This had better not fail! hKernel32 = LoadLibrary(L"kernel32.dll"); ArrayList<String> path; if (Environment::GetVariable(L"ProgramFiles", programFiles)) { // TODO-johnls-4/15/2008: Is there a better way to get this path? path.Add(programFiles + L"\\Debugger"); path.Add(programFiles + L"\\Debugging Tools for Windows"); path.Add(programFiles + L"\\Debugging Tools for Windows 64-Bit"); path.Add(programFiles + L"\\Microsoft Visual Studio 9.0\\Common7\\IDE"); path.Add(programFiles + L"\\Microsoft Visual Studio 9.0\\Team Tools\\Performance Tools\\"); path.Add(programFiles + L"\\Microsoft Visual Studio 8\\Common7\\IDE"); path.Add(programFiles + L"\\Microsoft Visual Studio 8\\Team Tools\\Performance Tools\\"); } if (Environment::GetVariable(L"SystemRoot", systemRoot)) { // TODO: What happens on x64? Eeeek! path.Add(programFiles + L"\\System32"); path.Add(programFiles + L"\\SysWow64"); } for (Int i = 0; i < path.get_Count(); i++) { fileName = path[i] + L"\\dbghelp.dll"; if (File::Exists(fileName)) { this->hDbgHelp = LoadLibrary(fileName); if (this->hDbgHelp != NULL) { break; } } } // We didn't find one - hell must have frozen over if (this->hDbgHelp == NULL) return false; // Get DbgHelp API's _SymInitialize = (SymInitializeProc)GetProcAddress(this->hDbgHelp, "SymInitialize"); _SymCleanup = (SymCleanupProc)GetProcAddress(this->hDbgHelp, "SymCleanup"); _StackWalk64 = (StackWalk64Proc)GetProcAddress(this->hDbgHelp, "StackWalk64"); _SymGetOptions = (SymGetOptionsProc)GetProcAddress(this->hDbgHelp, "SymGetOptions"); _SymSetOptions = (SymSetOptionsProc)GetProcAddress(this->hDbgHelp, "SymSetOptions"); _SymFunctionTableAccess64 = (SymFunctionTableAccess64Proc)GetProcAddress(this->hDbgHelp, "SymFunctionTableAccess64"); _SymGetLineFromAddr64 = (SymGetLineFromAddr64Proc)GetProcAddress(this->hDbgHelp, "SymGetLineFromAddr64"); _SymGetModuleBase64 = (SymGetModuleBase64Proc)GetProcAddress(this->hDbgHelp, "SymGetModuleBase64"); _SymGetModuleInfo64 = (SymGetModuleInfo64Proc)GetProcAddress(this->hDbgHelp, "SymGetModuleInfo64"); _SymFromAddr = (SymFromAddrProc)GetProcAddress(this->hDbgHelp, "SymFromAddr"); _UnDecorateSymbolName = (UnDecorateSymbolNameProc)GetProcAddress(this->hDbgHelp, "UnDecorateSymbolName"); _SymLoadModule64 = (SymLoadModule64Proc)GetProcAddress(this->hDbgHelp, "SymLoadModule64"); if ( _SymInitialize == NULL || _SymCleanup == NULL || _StackWalk64 == NULL || _SymGetOptions == NULL || _SymSetOptions == NULL || _SymFunctionTableAccess64 == NULL || _SymGetLineFromAddr64 == NULL || _SymGetModuleBase64 == NULL || _SymGetModuleInfo64 == NULL || _SymFromAddr == NULL || _UnDecorateSymbolName == NULL || _SymLoadModule64 == NULL) { FreeLibrary(hDbgHelp); hDbgHelp = NULL; _SymCleanup = NULL; return false; } // Get Toolhelp API's _CreateToolhelp32Snapshot = (CreateToolhelp32SnapshotProc)GetProcAddress(this->hKernel32, "CreateToolhelp32Snapshot"); _Module32FirstW = (Module32FirstWProc)GetProcAddress(this->hKernel32, "Module32FirstW"); _Module32NextW = (Module32NextWProc)GetProcAddress(this->hKernel32, "Module32NextW"); if (_SymInitialize(GetCurrentProcess(), GetSymbolPath(), FALSE) == FALSE) { return false; } DWORD symOptions = _SymGetOptions(); symOptions |= SYMOPT_LOAD_LINES; symOptions |= SYMOPT_FAIL_CRITICAL_ERRORS; symOptions = _SymSetOptions(symOptions); return (initialized = true); } public: void Uninitialize() { if (_SymCleanup != NULL) _SymCleanup(GetCurrentProcess()); if (this->hDbgHelp != NULL) FreeLibrary(this->hDbgHelp); if (this->hKernel32 != NULL) FreeLibrary(this->hKernel32); Reset(); } private: String GetSymbolPath() { StringBuilder path(4096); path.Append(L".;"); path.Append(Environment::get_CurrentDirectory()); path.Append(L";"); path.Append(Path::GetDirectoryName(Environment::get_ModuleFileName())); path.Append(L";"); String var; if (Environment::GetVariable(L"_NT_SYMBOL_PATH", var)) { path.Append(var); path.Append(L";"); } if (Environment::GetVariable(L"_NT_ALTERNATE_SYMBOL_PATH", var)) { path.Append(var); path.Append(L";"); } if (Environment::GetVariable(L"SYSTEMROOT", var)) { path.Append(var); path.Append(L";"); // Also add the "system32"-directory: var += L"\\system32"; path.Append(var); path.Append(L";"); } if (Environment::GetVariable(L"SYSTEMDRIVE", var)) { path.Append(L"SRV*"); path.Append(var); path.Append(L"\\websymbols*http://msdl.microsoft.com/download/symbols;"); } else path.Append(L"SRV*c:\\websymbols*http://msdl.microsoft.com/download/symbols;"); return path.ToString(); } /// <summary> /// This method returns information about the program stack from the point at which the method is /// called. The first item on the stack is usually an address outside of any module that is /// a side effect of the mechanism used to obtain a stack walk for the currently executing thread. It /// can safely be ignored. /// </summary> /// <param name="stack">An array that will receive the stack information</param> public: void GetStack(ArrayList<StackFrame>& stack) { ArrayList<void*> addresses; HANDLE hProcess = ::GetCurrentProcess(); HANDLE hThread = ::GetCurrentThread(); stack.Clear(); if (!Initialize()) return; CONTEXT context; ::RtlCaptureContext(&context); STACKFRAME64 frame64; DWORD machineType = InitStackFrameFromContext(&context, &frame64); for (Int frameNum = 0; ; frameNum++) { if (!::StackWalk64( machineType, hProcess, hThread, &frame64, &context, NULL, _SymFunctionTableAccess64, _SymGetModuleBase64, NULL)) { break; } addresses.Add((void*)frame64.AddrPC.Offset); // Catch any stack loop if (frame64.AddrPC.Offset == frame64.AddrReturn.Offset) { break; } } LoadModuleInfo(hProcess); for (Int i = 0; i < addresses.get_Count(); i++) { StackFrame frame; ResolveStackFrame(hProcess, addresses[i], frame); stack.Add(frame); } } public: void Release() { Uninitialize(); } private: DWORD InitStackFrameFromContext(CONTEXT *pContext, STACKFRAME64 *pStackFrame) { ZeroMemory(pStackFrame, sizeof(*pStackFrame)); #if defined(_M_IX86) pStackFrame->AddrPC.Offset = pContext->Eip; pStackFrame->AddrPC.Mode = AddrModeFlat; pStackFrame->AddrStack.Offset = pContext->Esp; pStackFrame->AddrStack.Mode = AddrModeFlat; pStackFrame->AddrFrame.Offset = pContext->Ebp; pStackFrame->AddrFrame.Mode = AddrModeFlat; return IMAGE_FILE_MACHINE_I386; #elif defined(_M_AMD64) pStackFrame->AddrPC.Offset = pContext->Rip; pStackFrame->AddrPC.Mode = AddrModeFlat; pStackFrame->AddrStack.Offset = pContext->Rsp; pStackFrame->AddrStack.Mode = AddrModeFlat; return IMAGE_FILE_MACHINE_AMD64; #else #error Unknown Target Machine #endif } private: void LoadModuleInfo(HANDLE hProcess) { HANDLE hSnap = _CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, ::GetProcessId(hProcess)); MODULEENTRY32 me; me.dwSize = sizeof(me); if (hSnap != (HANDLE)-1) { BOOL keepGoing = _Module32FirstW(hSnap, &me); while (keepGoing) { Array<Byte> moduleBytes; Array<Byte> exePathBytes; Encoding::get_ASCII().GetBytesWithNull(me.szModule, moduleBytes); Encoding::get_ASCII().GetBytesWithNull(me.szExePath, exePathBytes); DWORD64 base = _SymLoadModule64( hProcess, NULL, (char*)exePathBytes.get_Ptr(), (char*)moduleBytes.get_Ptr(), (DWORD64)me.modBaseAddr, me.modBaseSize); (void)base; keepGoing = _Module32NextW(hSnap, &me); } ::CloseHandle(hSnap); } } private: void ResolveStackFrame(HANDLE hProcess, void* addr, StackFrame& frame) { IMAGEHLP_MODULE64_V2 mi = {sizeof(IMAGEHLP_MODULE64_V2)}; CHAR methodName[MAX_SYMBOL_NAME_LEN]; DWORD64 offset; CHAR sourceFile[MAX_PATH]; DWORD lineNumber; HRESULT hr; size_t length; // Filling in this field is easy; the others not so much frame.address = addr; DWORD64 baseAddr = _SymGetModuleBase64(hProcess, (DWORD64)addr); if (baseAddr == 0 || !_SymGetModuleInfo64(hProcess, baseAddr, &mi)) { #if defined(_M_IA64) hr = StringCchPrintfA(methodName, ARRAY_SIZE(methodName), "0x%016x", (UINT_PTR)addr); #else hr = StringCchPrintfA(methodName, ARRAY_SIZE(methodName), "0x%08x", (UINT_PTR)addr); #endif THROW_BAD_HRESULT(hr); hr = StringCchLengthA(methodName, INT_MAX, &length); THROW_BAD_HRESULT(hr); frame.methodName = Encoding::get_ASCII().GetString((Byte*)methodName, static_cast<Int>(length)); frame.moduleName = L""; frame.fileName = L""; frame.offset = 0; frame.address = addr; frame.line = 0; return; } else { hr = StringCchLengthA(mi.ImageName, INT_MAX, &length); THROW_BAD_HRESULT(hr); frame.moduleName = Encoding::get_ASCII().GetString((Byte*)mi.ImageName, static_cast<Int>(length)); } if (!GetMethodDetails(hProcess, (DWORD64)addr, ARRAY_SIZE(methodName), methodName, ARRAY_SIZE(sourceFile), sourceFile, &lineNumber, &offset)) { frame.offset = (IntPtr)((DWORD64)addr - mi.BaseOfImage); frame.address = (void*)mi.BaseOfImage; } else { hr = StringCchLengthA(methodName, INT_MAX, (size_t*)&length); THROW_BAD_HRESULT(hr); frame.methodName = Encoding::get_ASCII().GetString((Byte*)methodName, static_cast<Int>(length)); hr = StringCchLengthA(sourceFile, INT_MAX, (size_t*)&length); THROW_BAD_HRESULT(hr); frame.fileName = Encoding::get_ASCII().GetString((Byte*)sourceFile, static_cast<Int>(length)); frame.offset = (IntPtr)offset; frame.address = (BYTE*)addr - frame.offset; frame.line = lineNumber; } } // This function needs to be C++ free so that we can use SEH (no destructors) private: inline bool GetMethodDetails( HANDLE hProcess, DWORD64 addr, int methodNameSize, __out_ecount_z(methodNameSize) char* methodName, int sourceFileSize, __out_ecount_z(sourceFileSize) char* sourceFile, PDWORD lineNumber, PDWORD64 offset) { DEBUG_ASSERT(methodNameSize > 1); DEBUG_ASSERT(sourceFileSize > 1); // Make space for terminators methodNameSize--; sourceFileSize--; *offset = 0; *methodName = 0; *sourceFile = 0; *lineNumber = 0; __try { int len = sizeof(SYMBOL_INFO) + MAX_SYMBOL_NAME_LEN * sizeof(char); PSYMBOL_INFO symInfo = (PSYMBOL_INFO)STACK_ALLOC(len); ::ZeroMemory(symInfo, len); symInfo->SizeOfStruct = sizeof(SYMBOL_INFO); symInfo->MaxNameLen = MAX_SYMBOL_NAME_LEN; if (_SymFromAddr(hProcess, addr, offset, symInfo)) { char undecName[MAX_SYMBOL_NAME_LEN]; if (_UnDecorateSymbolName(symInfo->Name, undecName, ARRAY_SIZE(undecName), UNDNAME_NO_MS_KEYWORDS | UNDNAME_NO_ACCESS_SPECIFIERS)) { StringCchCopyA(methodName, methodNameSize, undecName); } else { StringCchCopyA(methodName, methodNameSize, symInfo->Name); } // Terminate the name methodName[methodNameSize] = 0; // Get line info. if there is any IMAGEHLP_LINE64 line = {sizeof(IMAGEHLP_LINE64)}; DWORD lineOffset = 0; if (_SymGetLineFromAddr64(hProcess, addr, &lineOffset, &line)) { *lineNumber = line.LineNumber; StringCchCopyA(sourceFile, sourceFileSize, line.FileName); sourceFile[sourceFileSize] = 0; offset -= lineOffset; } } } __except (EXCEPTION_EXECUTE_HANDLER) { return false; } return true; } public: static StackWalker& get_StackWalker() { return stackwalker; } public: static StackWalker stackwalker; }; __declspec(selectany) StackWalker StackWalker::stackwalker; } #pragma warning(pop)
[ "40727305+Lyon-Smith@users.noreply.github.com" ]
[ [ [ 1, 617 ] ] ]
b5d37b3ce23aa44beb86df19df3ed538d7dbe0ab
04d69fa1d0f48adc2033912fe1cb9781a2ee8e8b
/src/SpecialAbility_SpeedUp.h
d1b77d95b64c3cde17097bf148fff6435f8c629a
[ "BSD-3-Clause" ]
permissive
foxostro/heroman
63e4ed9d95bf02586df92c804e94902259734780
7831351af1b7bbad603b184fd25e030ece2d0657
refs/heads/master
2021-01-25T06:37:28.649485
2009-08-02T12:53:38
2009-08-02T12:53:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,901
h
#ifndef SPECIAL_ABILITY_SPEED_UP_H #define SPECIAL_ABILITY_SPEED_UP_H #include "PropertyBag.h" #include "Actor.h" #include "SpecialAbility.h" #include "ComponentSpecialAbility.h" /** Ability: Speed Up This ability speeds up the player for a certain time period. Therefore, it should obviously only be used with characters that move. */ class SpecialAbility_SpeedUp : SpecialAbility { public: /** Constructor */ SpecialAbility_SpeedUp(ActorPtr a, string n, World *w); /** Desctructor */ ~SpecialAbility_SpeedUp(); /** Performs the functions associated with this ability. @return whether the ability was successfully executed */ virtual bool executeAbility(); /** Displays any visual effects or information associated with this component. */ virtual void display(); /** Loads data necessary to construct the ability. @param data the data to load */ virtual void onLoad(const PropertyBag &data); /** Updates the ability, if necessary. @param milliseconds the time (in milliseconds) since the last update */ virtual void update(float milliseconds); protected: /* -- Helper Functions -- */ void chargeByDamageReceived(float milliseconds); /** updates charge meter based on amount of time passed */ private: /* -- Instance Variables -- */ unsigned int duration; /** The amount of time that the effect lasts (in milliseconds) */ float speedFactor; /** The factor by which to multiply the character's speed */ float originalSpeed; /** Holds the original speed of the character */ float originalCool; /** holds the original cooldown time for the weapon */ int timeLeft; /** countdown until the effect is inactive again */ int lastHealth; /** the last health of the character */ float timePassed; /** the time passed, in milliseconds, since the last use of the ability */ }; #endif
[ "foxostro@gmail.com" ]
[ [ [ 1, 65 ] ] ]
02fe1fc3fbad1f0afefcb3ed025dd1e140a17099
23e9e5636c692364688bc9e4df59cb68e2447a58
/Dream/src/Game/YGERenderer.cpp
fe548e1ba8ac9ed5cb2e1b99f583352ae95f5c0d
[]
no_license
yestein/dream-of-idle
e492af2a4758776958b43e4bf0e4db859a224c40
4e362ab98f232d68535ea26f2fab7b3cbf7bc867
refs/heads/master
2016-09-09T19:49:18.215943
2010-04-23T07:24:19
2010-04-23T07:24:19
34,108,886
0
0
null
null
null
null
UTF-8
C++
false
false
605
cpp
/************************************************************************ Copyright (c) Yu Lei. All rights reserved. filename: YGEApplication.h created: 2010/3/23 author: Yu Lei(nl-nl-@163.com) <change list> 1. create file (Yu Lei) purpose: Create a Render ************************************************************************/ #include "YGERenderer.h" #include "YGEDefine.h" YGERenderer::YGERenderer( ): m_wndOwner( NULL ), m_bWindowed( true ), m_uScreenWidth( YGEDefine::DEFAULT_WND_WIDTH ), m_uScreenHeight( YGEDefine::DEFAULT_WND_HEIGHT ), m_uBitCount( 16 ) { }
[ "yestein86@6bb0ce84-d3d1-71f5-47c4-2d9a3e80541b" ]
[ [ [ 1, 23 ] ] ]
962cda1a8d254ffe9e1de76889f2ce0d30cb4dd2
ea12fed4c32e9c7992956419eb3e2bace91f063a
/zombie/code/conjurer/conjurer/inc/conjurer/objecttransformundocmd.h
17910040b545c532c4c05fe693fda117fa09bf40
[]
no_license
ugozapad/TheZombieEngine
832492930df28c28cd349673f79f3609b1fe7190
8e8c3e6225c2ed93e07287356def9fbdeacf3d6a
refs/heads/master
2020-04-30T11:35:36.258363
2011-02-24T14:18:43
2011-02-24T14:18:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,717
h
#ifndef N_OBJECTTRANSFORM_UNDO_CMDS_H #define N_OBJECTTRANSFORM_UNDO_CMDS_H //------------------------------------------------------------------------------ /** @file nobjecttransformundocmd.h @ingroup NebulaConjurerEditor @author Juan Jose Luna Espinosa @brief Class for object transform undo cmds (C) 2004 Conjurer Services, S.A. */ //------------------------------------------------------------------------------ #include "nundo/undocmd.h" #include "nundo/nundoserver.h" #include "mathlib/transform44.h" //------------------------------------------------------------------------------ class ObjectTransformUndoCmd: public UndoCmd { public: /// Constructor ObjectTransformUndoCmd( nArray<InguiObjectTransform>* objects ); /// Destructor virtual ~ObjectTransformUndoCmd(); /// Execute virtual bool Execute( void ); /// Unexecute virtual bool Unexecute( void ); /// Get byte size virtual int GetSize( void ); protected: struct ObjTransformUndoInfo { // Entity id affected by the transform nEntityObjectId entityId; // Transforms for undo and redo transform44 undoTransform, redoTransform; // Entity was dirty before this command? bool entityWasDirty; // Tells if entity was selected by user, or it was contained in an indoor (to restore selection) bool selectedByUser; }; bool firstExecution; // Array of undo info for affected objects nArray<ObjTransformUndoInfo> undoInfo; private: }; //------------------------------------------------------------------------------ #endif
[ "magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91" ]
[ [ [ 1, 68 ] ] ]
7966dc9b39129ae8d02abd2d0dd2980bc12dfbbf
869aa4b1261e60a745cf4c7f32c96a9d5d4f1c47
/release-4.0.7/plugin/script_object_factory.cc
15ff794f9e35b03fc33b10633f9ba83d11591766
[]
no_license
anmaz/chrome-download-assistant
d45dc4f8a8e09f564a5e4eee209b936a67d031d6
a4ab1eed1b4e7ef1a905a9988c6cd29d21c6a2bd
refs/heads/master
2021-01-01T06:38:29.035202
2011-06-24T04:25:04
2011-06-24T04:25:04
34,250,585
1
1
null
null
null
null
UTF-8
C++
false
false
2,620
cc
#include "script_object_factory.h" namespace { NPObject* Allocate(NPP npp, NPClass *aClass) { return NULL; } void Deallocate(NPObject *npobj) { ScriptObjectBase* pObject = (ScriptObjectBase*)npobj; pObject->Deallocate(); } void Invalidate(NPObject *npobj) { ScriptObjectBase* object = (ScriptObjectBase*)npobj; object->Invalidate(); } bool HasMethod(NPObject *npobj, NPIdentifier name) { ScriptObjectBase* object = (ScriptObjectBase*)npobj; return object->HasMethod(name); } bool Invoke(NPObject *npobj, NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result) { ScriptObjectBase* object = (ScriptObjectBase*)npobj; return object->Invoke(name, args, argCount, result); } bool InvokeDefault(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result) { ScriptObjectBase* object = (ScriptObjectBase*)npobj; return object->InvokeDefault(args, argCount, result); } bool HasProperty(NPObject *npobj, NPIdentifier name) { ScriptObjectBase* object = (ScriptObjectBase*)npobj; return object->HasProperty(name); } bool GetProperty(NPObject *npobj, NPIdentifier name, NPVariant *result) { ScriptObjectBase* object = (ScriptObjectBase*)npobj; return object->GetProperty(name, result); } bool SetProperty(NPObject *npobj, NPIdentifier name, const NPVariant *value) { ScriptObjectBase* object = (ScriptObjectBase*)npobj; return object->SetProperty(name, value); } bool RemoveProperty(NPObject *npobj, NPIdentifier name) { ScriptObjectBase* object = (ScriptObjectBase*)npobj; return object->RemoveProperty(name); } bool Enumerate(NPObject *npobj, NPIdentifier **value, uint32_t *count) { ScriptObjectBase* object = (ScriptObjectBase*)npobj; return object->Enumerate(value, count); } bool Construct(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result) { ScriptObjectBase* object = (ScriptObjectBase*)npobj; return object->Construct(args, argCount, result); } NPClass npclass_ = { NP_CLASS_STRUCT_VERSION, Allocate, Deallocate, Invalidate, HasMethod, Invoke, InvokeDefault, HasProperty, GetProperty, SetProperty, RemoveProperty, Enumerate, Construct }; } ScriptObjectBase* ScriptObjectFactory::CreateObject(NPP npp, NPAllocateFunctionPtr allocate) { npclass_.allocate = allocate; ScriptObjectBase* object = (ScriptObjectBase*)NPN_CreateObject( npp, &npclass_); if (object) { object->InitHandler(); } return object; }
[ "jingzhao@google.com@a0d43ee6-04fa-a5ec-bf34-aeaa1c2c5ca5" ]
[ [ [ 1, 94 ] ] ]
4afd8b81499bd91e47f0e72784dd236393c52b3c
35231241243cb13bd3187983d224e827bb693df3
/cgpsmapper/maproute/geograph.cpp
efbbb3c48841620dcec708204f887509f1ba40ad
[]
no_license
casaretto/cgpsmapper
b597aa2775cc112bf98732b182a9bc798c3dd967
76d90513514188ef82f4d869fc23781d6253f0ba
refs/heads/master
2021-05-15T01:42:47.532459
2011-06-25T23:16:34
2011-06-25T23:16:34
1,943,334
2
2
null
2019-06-11T00:26:40
2011-06-23T18:31:36
C++
UTF-8
C++
false
false
7,398
cpp
/* Created by: cgpsmapper This is open source software. Source code is under the GNU General Public License version 3.0 (GPLv3) license. Permission to modify the code and to distribute modified code is granted, provided the above notices are retained, and a notice that the code was modified is included with the above copyright notice. */ #ifdef WIN32 #define _USE_MATH_DEFINES #endif #define MAX_ITER 100000 #include <math.h> #include "geograph.h" #include "datums.h" using namespace std; Datum::Datum(double dX,double dY,double dZ,long double majorAxis,long double flattering) { this->datumCode = "CUST"; datumName = "CUST : Custom Datum"; this->dX = dX; this->dY = dY; this->dZ = dZ; double wgs84f = 298.257223563; double wgs84major = 6378137.0; dF = 10000.0/wgs84f - 10000.0/flattering; f = 1.0/flattering; flattening = flattering; dA = wgs84major - majorAxis; semiMajorAxis = majorAxis; semiMinorAxis = semiMajorAxis * (1-f); } Datum::Datum(const char* _datumC) { string datumC = _datumC; int t_dat = 0; int t_elp = 0; while( string(Datum_list[t_dat].code) != "END" && string(Datum_list[t_dat].code) != datumC ) t_dat++; if( string(Datum_list[t_dat].code) == "END" ) { Datum("W84"); return; } while( (string(Elipsoid_list[t_elp].name)) != "END" && (string(Elipsoid_list[t_elp].code)) != (string(Datum_list[t_dat].elipsoid)) ) t_elp++; this->datumCode = Datum_list[t_dat].code; datumName = string(Datum_list[t_dat].code) + " :" + string(Datum_list[t_dat].name) + " " + string(Datum_list[t_dat].country); dX = Datum_list[t_dat].dX; dY = Datum_list[t_dat].dY; dZ = Datum_list[t_dat].dZ; double wgs84f = 298.257223563; double wgs84major = 6378137.0; dF = 10000.0/wgs84f - 10000.0/Elipsoid_list[t_elp].flattering; f = 1.0/Elipsoid_list[t_elp].flattering; flattening = Elipsoid_list[t_elp].flattering; dA = wgs84major - Elipsoid_list[t_elp].majorAxis; semiMajorAxis = Elipsoid_list[t_elp].majorAxis; semiMinorAxis = semiMajorAxis * (1-f); } void Datum::DatumList(vector<string> *list) { int t_dat = 0; list->clear(); while( (string(Datum_list[t_dat].code)) != "END" ) { list->push_back(string(Datum_list[t_dat].code) + " :" + string(Datum_list[t_dat].name) + " " + string(Datum_list[t_dat].country)); t_dat++; } } void Datum::calcDistance(Coords a,Coords b,double &distance,double &direction) { double a_lat_r,a_lon_r,b_lat_r,b_lon_r,tana; lambda = 0; if( a == b ) { distance = 0; direction = 0; return; } //this->datum = datum; a_lat_r = a.y * M_PI /180.0; a_lon_r = a.x * M_PI /180.0; b_lat_r = b.y * M_PI /180.0; b_lon_r = b.x * M_PI /180.0; tanU1 = (1.0-f)*tan(a_lat_r); U1 = atan(tanU1); sinU1 = sin( U1 ); cosU1 = cos( U1 ); tanU2 = (1.0-f)*tan(b_lat_r); U2 = atan( tanU2 ); sinU2 = sin( U2 ); cosU2 = cos( U2 ); lambda = b_lon_r-a_lon_r; diffLong = b_lon_r-a_lon_r; Ddistance = 0; distance = lambdaDiff(); //tana=cosU2 * sin( lambda ) / (cosU1 * sinU2 - sinU1 * cosU2 * cos( lambda )); tana = atan2( cosU2* sin(lambda), (cosU1 * sinU2 - sinU1 * cosU2 * cos( lambda ))); //direction = atan( tana ); //radiany //direction = (direction / M_PI ) * 180.0 + 360.0; if( tana < 0 ) direction = tana * 180.0 / M_PI + 360.0; else direction = tana * 180.0 / M_PI; } double Datum::lambdaDiff() { int iter = 0; do { distance = Ddistance; sin2s =( cosU2 * sin( lambda ) * cosU2 * sin( lambda ))+( cosU1 * sinU2 - sinU1 * cosU2 * cos( lambda ))*( cosU1 * sinU2 - sinU1 * cosU2 * cos( lambda )); coss = ( sinU1 * sinU2 )+( cosU1 * cosU2 * cos( lambda )); tans = sqrt( sin2s )/coss; s = atan( tans ); if( sin2s == 0 ) sina = 0; else sina = cosU1 * cosU2 * sin( lambda )/sqrt( sin2s ); if( (cos(asin( sina ))*cos(asin( sina ))) == 0 ) cos2sm = 0; else cos2sm = coss - 2.0 * sinU1 * sinU2 /( cos( asin( sina )) * cos( asin( sina ))); U2 = cos(asin( sina ))*cos(asin( sina ))*(semiMajorAxis * semiMajorAxis - semiMinorAxis*semiMinorAxis)/(semiMinorAxis*semiMinorAxis); iter++; if( iter > MAX_ITER ) break; A = 1.0 + U2/16384.0*(4096.0+ U2 *(-768.0 + U2 *(320.0-175.0* U2 ))); B = U2 /1024.0*(256.0+ U2 *(-128.0+ U2 *(74.0-47.0* U2 ))); Ds = B * sqrt( sin2s )*( cos2sm + B /4.0 * ( coss *(-1.0 + 2.0 * cos2sm * cos2sm )- B / 6.0 * cos2sm *(-3.0 + 4.0 * sin2s )*(-3.0 + 4.0 * cos2sm * cos2sm ))); C = f/16.0 * cos(asin( sina )) * cos(asin( sina ))*(4.0+f*(4.0-3.0 * cos(asin( sina )) * cos(asin( sina )))); lambda = diffLong + (1.0 - C) * f * sina *(acos( coss )+ C * sin(acos( coss ))*( cos2sm + C * coss *(-1.0 + 2.0 * cos2sm * cos2sm ))); Ddistance = semiMajorAxis * A *( atan( tans )- Ds ); } while( fabs(Ddistance - distance) > fabs(Ddistance) * 0.05 ); return Ddistance; } void Datum::calcDestination(Coords src,double distance,double direction,Coords &dest) { double a_lat_r,a_lon_r; // = datum.flattening * (1.0 - datum.f); this->distance = 0; lambda = 0; this->distance = distance; a_lat_r = src.y * M_PI/180.0; a_lon_r = src.x * M_PI/180.0; azimut = direction * M_PI/180.0; tanU1 = (1-f) * tan(a_lat_r); tans1 = tanU1 / cos(azimut); sinU1 = sin(atan(tanU1)); cosU1 = cos(atan(tanU1)); sina = cosU1 * sin(azimut); u2 = cos(asin(sina)) * cos(asin(sina)) * ((semiMajorAxis * semiMajorAxis)-(semiMinorAxis * semiMinorAxis))/(semiMinorAxis * semiMinorAxis); A = 1.0 + u2 / 16384.0 * (4096.0 + u2 *(-768.0 + u2 * (320.0 - 175.0 * u2))); B = u2 / 1024.0 * (256.0 + u2 * (-128.0 + u2 * (74.0 - 47.0 * u2))); sigma = distance / (semiMinorAxis * A); sigmaDiff(); topTerm = sin(atan(tanU1)) * cos(sigma) + cos(atan(tanU1)) * sin(sigma) * cos(azimut); bottomTerm = (1.0 - f) * sqrt(sina * sina + (sin(atan(tanU1)) * sin(sigma) - cos(atan(tanU1)) * cos(sigma) * cos(azimut)) * (sin(atan(tanU1)) * sin(sigma) - cos(atan(tanU1)) * cos(sigma) * cos(azimut))); tanfi = topTerm/bottomTerm; fi = atan(tanfi); dest.y = fi * 180.0 / M_PI; tanlambda = sin(sigma) * sin(azimut)/(cosU1 * cos(sigma) - sin(atan(tanU1)) * sin(sigma)*cos(azimut)); lambda = atan2(sin(sigma) * sin(azimut),(cosU1 * cos(sigma) - sin(atan(tanU1)) * sin(sigma) * cos(azimut))); C = f/16.0 * cos(asin(sina)) * cos(asin(sina)) * (4.0 + f * (4.0 - 3.0 * cos(asin(sina)) * cos(asin(sina)))); L = lambda - (1.0 - C) * f * sina * (sigma + C * sin(sigma) * (cos(sigma2m) + C * cos(sigma) * (-1.0 + 2.0 * cos(sigma2m) * cos(sigma2m)))); lambda2 = a_lon_r + L; dest.x = lambda2 * 180.0 /M_PI; } void Datum::sigmaDiff() { double Doldsigma; Dsigma = 0; do { Doldsigma = Dsigma; sigma2m = 2.0 * atan(tans1) + sigma; Bsina = B * sin(sigma); cos2sigmam = cos(sigma2m); cossigmaetc = cos(sigma) * (-1.0 + 2.0 * cos2sigmam * cos2sigmam ); bracket1 = -3.0 + 4.0 * sin(sigma) * sin(sigma); bracket2 = -3.0 + 4.0 * cos2sigmam * cos2sigmam; Dsigma = Bsina * (cos2sigmam + B/4.0 * (cossigmaetc - B/6.0 * cos2sigmam * bracket1 * bracket2)); sigma = distance / (semiMinorAxis * A) + Dsigma; } while (fabs(Doldsigma - Dsigma) > 0.0000001); }
[ "cgpsmapper@ad713ecf-6e55-4363-b790-59b81426eeec" ]
[ [ [ 1, 234 ] ] ]
df0fbd808b8378a2759060040e8e9aab4f4d3558
6477cf9ac119fe17d2c410ff3d8da60656179e3b
/Projects/openredalert/src/game/Weapon.cpp
1a6a22a76b77efc08e1a37424bb13acc37bb802f
[]
no_license
crutchwalkfactory/motocakerteam
1cce9f850d2c84faebfc87d0adbfdd23472d9f08
0747624a575fb41db53506379692973e5998f8fe
refs/heads/master
2021-01-10T12:41:59.321840
2010-12-13T18:19:27
2010-12-13T18:19:27
46,494,539
0
0
null
null
null
null
UTF-8
C++
false
false
9,375
cpp
// Weapon.cpp // 1.4 // This file is part of OpenRedAlert. // // OpenRedAlert is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, version 2 of the License. // // OpenRedAlert is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with OpenRedAlert. If not, see <http://www.gnu.org/licenses/>. #include "Weapon.h" #include <algorithm> #include <cctype> #include <vector> #include "Projectile.h" #include "UnitOrStructure.h" #include "Warhead.h" #include "ExplosionAnim.h" #include "ActionEventQueue.h" #include "UnitOrStructure.h" #include "include/Logger.h" #include "weaponspool.h" #include "video/ImageNotFound.h" #include "video/SHPImage.h" #include "audio/SoundEngine.h" #include "UnitOrStructureType.h" #include "InfantryGroup.h" #include "ProjectileAnim.h" #include "RedAlertDataLoader.h" #include "include/common.h" using std::vector; using std::for_each; namespace p { extern WeaponsPool * weappool; extern ActionEventQueue * aequeue; extern RedAlertDataLoader * raLoader; } namespace pc { extern SoundEngine * sfxeng; extern std::vector<SHPImage *> * imagepool; } extern Logger * logger; Weapon::Weapon(const char* wname) { char *pname= 0; char *whname= 0; //char *faname= 0; //char *faimage= 0; map<string, Projectile*>::iterator projentry; map<string, Warhead*>::iterator wheadentry; INIFile * weapini; //SHPImage * fireanimtemp; //Uint8 additional; //Uint8 i; string projname, warheadname; string weapname; INIFile* rules = 0; name = string(wname); rules = new INIFile("rules.ini"); weapini = p::weappool->getWeaponsINI(); weapname = (string)wname; // UPPER the string 'weapname' for_each(weapname.begin(), weapname.end(), toupper); pname = weapini->readString(wname, "projectile"); if (pname == NULL) { logger->warning( "Unable to find projectile for weapon \"%s\" in inifile..\n", wname); throw 0; } projname = (string)pname; // UPPER the string 'projname' for_each(projname.begin(), projname.end(), toupper); projentry = p::weappool->projectilepool.find(projname); if (projentry == p::weappool->projectilepool.end() ) { try { projectile = new Projectile(string(pname), p::raLoader->lnkProjectileDataList, pc::imagepool); } catch(...) { logger->warning("Unable to find projectile \"%s\" used for weapon \"%s\".\nUnit using this weapon will be unarmed\n", pname, wname); delete[] pname; throw 0; } p::weappool->projectilepool[projname] = projectile; } else { projectile = projentry->second; } delete[] pname; whname = weapini->readString(wname, "warhead"); if (whname==NULL) { logger->warning( "Unable to find warhead for weapon \"%s\" in inifile..\n", wname); throw 0; } warheadname = (string)whname; transform(warheadname.begin(), warheadname.end(), warheadname.begin(), toupper); wheadentry = p::weappool->warheadpool.find(warheadname); if (wheadentry == p::weappool->warheadpool.end() ) { try { // Try to create the Warhead whead = new Warhead(whname, p::raLoader->lnkWarheadDataList); } catch(...) { logger->warning("Unable to find Warhead \"%s\" used for weapon \"%s\".\nUnit using this weapon will be unarmed\n", whname, wname); delete[] whname; throw 0; } p::weappool->warheadpool[warheadname] = whead; } else { whead = wheadentry->second; } delete[] whname; speed = weapini->readInt(wname, "speed", 100); range = weapini->readInt(wname, "range", 4); reloadtime = weapini->readInt(wname, "reloadtime", 50); damage = weapini->readInt(wname, "damage", 10); burst = weapini->readInt(wname, "burst", 1); heatseek = (weapini->readInt(wname, "heatseek", 0) != 0); // pc::imagepool->push_back(new SHPImage("minigun.shp", mapscaleq)); //firesound = weapini->readString(wname, "firesound"); //printf("wname = %s\n", wname); report = rules->readString(wname, "Report"); if (report != 0){ string soundWeap = report; soundWeap += string(".aud"); transform(soundWeap.begin(), soundWeap.begin(), soundWeap.end(), tolower); //logger->debug("Report = %s\n", soundWeap.c_str()); report = cppstrdup(soundWeap.c_str()); pc::sfxeng->LoadSound(report); } reloadsound = weapini->readString(wname, "reloadsound"); if (reloadsound != 0) pc::sfxeng->LoadSound(reloadsound); chargingsound = weapini->readString(wname, "chargingsound"); if (chargingsound != 0) pc::sfxeng->LoadSound(chargingsound); fuel = weapini->readInt(wname, "fuel", 0); seekfuel = weapini->readInt(wname, "seekfuel", 0); // @todo Implemente Anim in [Weapon] /* fireimage = pc::imagepool->size()<<16; faname = weapini->readString(wname, "fireimage", "none"); //printf ("%s line %i: Weapon = %s, fireimage = %s\n", __FILE__, __LINE__, wname, faname); if (strcmp((faname), ("none")) == 0) { delete[] faname; numfireimages = 0; numfiredirections = 1; fireimage = 0; } else { additional = (Uint8)weapini->readInt(faname, "additional", 0); faimage = weapini->readString(faname, "image", "minigun.shp"); try { fireanimtemp = new SHPImage(faimage, -1); } catch (ImageNotFound&) { throw 0; } delete[] faimage; faimage = NULL; numfireimages = fireanimtemp->getNumImg(); numfiredirections = weapini->readInt(faname, "directions", 1); if (numfiredirections == 0) { numfiredirections = 1; } fireimages = new Uint32[numfiredirections]; fireimages[0] = fireimage; pc::imagepool->push_back(fireanimtemp); if (additional != 0) { char* tmpname = new char[12]; for (i=2; i<=additional; ++i) { sprintf(tmpname, "image%i", i); faimage = weapini->readString(faname, tmpname, ""); if (strcmp((faimage), ("")) != 0) { try { fireanimtemp = new SHPImage(faimage, -1); } catch (ImageNotFound&) { throw 0; } fireimages[i-1]=(pc::imagepool->size()<<16); numfireimages += fireanimtemp->getNumImg(); pc::imagepool->push_back(fireanimtemp); } else { fireimages[i] = 0; logger->warning("%s was empty in [%s]\n", tmpname, faname); } delete[] faimage; faimage = NULL; } delete[] tmpname; } else if (numfiredirections != 1) { for (i=1; i<numfiredirections; ++i) { fireimages[i] = fireimage+i*(numfireimages/numfiredirections); } } delete[] faname; }*/ // Free rules.ini delete rules; } Weapon::~Weapon() { // If Report sound exist if (report != 0) { // delete it delete[] report; } // If Reload sound exist if (reloadsound != 0) { delete[] reloadsound; } // @todo Implemente Anim in [Weapon] //if (fireimage != 0) //{ // delete[] fireimages; //} } Uint8 Weapon::getReloadTime() const { return reloadtime; } Uint8 Weapon::getRange() const { return range; } Uint8 Weapon::getSpeed() const { return speed; } Sint16 Weapon::getDamage() const { return damage; } bool Weapon::getWall() const { return whead->getWall(); } Projectile *Weapon::getProjectile() { return projectile; } Warhead * Weapon::getWarhead() { return whead; } char * Weapon::getChargingSound() { return chargingsound; } void Weapon::fire(UnitOrStructure* owner, Uint16 target, Uint8 subtarget) { // If sound report is defined if (report != 0) { // Play the sound pc::sfxeng->PlaySound(report); } // @todo implemente Anim in [Weapon] /*if (fireimage != 0) { Uint32 length = numfireimages; Uint8 facing; if (owner->getType()->getNumLayers() == 1) { facing = (owner->getImageNum(0))&0x1f; } else { facing = (owner->getImageNum(1))&0x1f; } if (!owner->getType()->isInfantry()) { facing >>= 2; } length /= numfiredirections; if (numfiredirections == 1) { facing = 0; }*/ // new ExplosionAnim(1, owner->getPos(),fireimages[facing], // (Uint8)length,/*owner->getXoffset()+*/InfantryGroup::GetUnitOffsets()[owner->getSubpos()], // /*owner->getYoffset()+*/InfantryGroup::GetUnitOffsets()[owner->getSubpos()]); //} ProjectileAnim* proj = new ProjectileAnim(0, this, owner, target, subtarget); p::aequeue->scheduleEvent(proj); this->Reload(); } bool Weapon::isHeatseek() const { return heatseek; } bool Weapon::isInaccurate() const { return this->projectile->getInaccurate(); } double Weapon::getVersus(armor_t armor) const { return (this->whead->getVersus(armor)) / (double)100.0; } Uint8 Weapon::getFuel() const { return fuel; } Uint8 Weapon::getSeekFuel() const { return seekfuel; } const char * Weapon::getName() const { return name.c_str(); } void Weapon::Reload() { if (reloadsound != 0) { pc::sfxeng->PlaySound(reloadsound); } }
[ "cepiperez@gmail.com" ]
[ [ [ 1, 410 ] ] ]
b991bdfb2b51893f404a33866a7782ebc489fc9e
74c8da5b29163992a08a376c7819785998afb588
/NetAnimal/Game/wheel/WheelGobal/src/WinData.cpp
4c0759ff1fbcb8de36afe7acb05a613662df5098
[]
no_license
dbabox/aomi
dbfb46c1c9417a8078ec9a516cc9c90fe3773b78
4cffc8e59368e82aed997fe0f4dcbd7df626d1d0
refs/heads/master
2021-01-13T14:05:10.813348
2011-06-07T09:36:41
2011-06-07T09:36:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,212
cpp
#include "WheelGobalStableHeaders.h" #include "WinData.h" #include "WheelData.h" #include "BlackBoardSystem.h" #include <orz/Toolkit_Base/LogSystem.h> using namespace Orz; WinDataClone & WinDataClone::operator =(const WinDataClone & wdc) { _winner = wdc._winner; _lightColor = wdc._lightColor; _winMode = wdc._winMode; _animalType = wdc._animalType; _size = wdc._size; _table = wdc._table; return *this; } WinDataClone::WinDataClone(const WinDataClone & wdc) { _winner = wdc._winner; _lightColor = wdc._lightColor; _winMode = wdc._winMode; _animalType = wdc._animalType; _size = wdc._size; _table = wdc._table; } WheelEnum::WINNER WinDataClone::getWinner(void) const { return _winner; } WheelEnum::LIGHT_COLOR WinDataClone::getLightColor(void) const { return _lightColor; } int WinDataClone::getTable(void) const { return _table; } WheelEnum::WIN_MODE WinDataClone::getWinMode(void) const { return _winMode; } WheelEnum::TYPE WinDataClone::getType(void) const { return _animalType; } WinDataClone::WinDataClone(void) { } size_t WinDataClone::size(void) const { //if(_winMode == WheelEnum::GOLD) return _size; } WheelEnum::AnimalItem WinDataClone::getAnimalItem(void) const { //if(_winMode == WheelEnum::GOLD) return WheelEnum::AnimalItem(getType(), getLightColor()); } void WinDataClone::init(WheelEnum::WINNER winner, WheelEnum::LIGHT_COLOR lightColor, WheelEnum::WIN_MODE winMode, WheelEnum::TYPE animalType, size_t size, int table) { _table = table; _winner = winner; _lightColor = lightColor; _winMode = winMode; _animalType = animalType; _size = size; } template<> WinData* Singleton<WinData>::_singleton = NULL; WheelEnum::STATUS WinData::getAnimalStatus(void) const { if(this->_winMode == WheelEnum::GOLD) return WheelEnum::KING; return WheelEnum::PEOPLE; } WinData::WinData(void): _winner(WheelEnum::Dealer), _bonus(), _rate(WheelEnum::MODE0), _winMode(WheelEnum::NONE), _hasTable(false), _table(-1), _waitFor(false) { } //void WinData::setSecondWinnerId(int Id) //{ // _secondWinnerId = Id; //} //int WinData::getSecondWinnerId(void) const //{ // return _secondWinnerId; //} //bool WinData::getSecondWinner(void) const //{ // return _secondWinner; //} // //void WinData::setSecondWinner(bool secondWinner) //{ // _secondWinner = secondWinner; //} WheelEnum::TYPE WinData::getType(int i) const { if(size_t(i) >= _items.size()) return WheelEnum::TYPE0; return _items.at(i).type; } WinData & WinData::getInstance(void) { return *(getInstancePtr()); } WinDataClone & WinData::getClone(void) { _clone.init(_winner, getLightColor(0), _winMode, getType(0), size(), _table); return _clone; } WinData * WinData::getInstancePtr(void) { static WinData instance; return &instance; } WheelEnum::AnimalItem WinData::getAnimalItem(int i) const { return WheelEnum::AnimalItem(getType(i), getLightColor(i)); //return WheelEnum::AnimalItem(_animalType, _lightColor); } size_t WinData::size(void) const { return _items.size(); } void WinData::setRate(WheelEnum::RATE rate) { _rate = rate;//static_cast<WheelEnum::RATE>(BlackBoardSystem::getInstance().read<int>(WheelEnum::RATE_STR)); } WheelEnum::RATE WinData::getRate(void) const { return _rate; } WheelEnum::WINNER WinData::getWinner(void) const { return _winner; } WheelEnum::LIGHT_COLOR WinData::getLightColor(int i) const { if(size_t(i) >= _items.size()) return WheelEnum::Red; return _items.at(i).color; //return _lightColor; } int WinData::getRate(const WheelEnum::AnimalItem & animal) const { std::vector<WinItem>::const_iterator it; for(it = _items.begin(); it != _items.end(); ++it) { if(it->type == animal.first && it->color == animal.second) { return it->rate; } } return 0; } int WinData::getRate(int i) const { if(size_t(i) >= _items.size()) return 0; return _items.at(i).rate; } WheelEnum::WIN_MODE WinData::getWinMode(void) const { return _winMode; } WheelEnum::AnimalType WinData::getAnimalType(int i) const { return WheelEnum::AnimalType(getType(i), getAnimalStatus()); } WinData::Bonus WinData::getBonus(void) const { return _bonus; } void WinData::clear(void) { _table = -1; _items.clear(); } void WinData::push_back(const WheelEnum::AnimalItem & animal, int rate) { _items.push_back(WinItem(animal.second, animal.first, rate)); } void WinData::setWinMode(WheelEnum::WIN_MODE winMode) { _winMode = winMode; } void WinData::setBonus( bool has, int bonus, int invest, int profitForPerInvest) { _bonus.has = has; _bonus.bonus = bonus; _bonus.invest = invest; _bonus.profitForPerInvest = profitForPerInvest; } void WinData::setWinner(WheelEnum::WINNER winner) { _winner = winner; } void WinData::setTable(int table) { _table = table; } int WinData::getTable(void) const { return _table; } bool WinData::waitFor(void) const { return _waitFor; } void WinData::waitFor(bool wait) { _waitFor = wait; }
[ "ogre3d@yeah.net" ]
[ [ [ 1, 279 ] ] ]
7d2663f9db8c9c23ff43d2d4d6d5355c55468ff2
fa318c29963c7a594c8de6f1b3f3369e154fad7e
/C++/TopCoder/SRM495DIV2/1000.cpp
41f95fc8e9d02ab65c456c004fb3606532e5a0e5
[]
no_license
cnsuhao/xadillax-personal
1732c251828c549f57b675f36608f1e51f56b626
2a2394ac2ebc64bc349551b46225231e07a63ba2
refs/heads/master
2021-05-29T03:00:28.064794
2011-03-26T06:36:46
2011-03-26T06:36:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,429
cpp
/** * @brief HexagonPuzzle * A problem of TopCoder. * * @author XadillaX */ #include <iostream> #include <cstdio> #include <string> #include <cmath> #include <list> #include <map> #include <string.h> #include <time.h> #include <cstdlib> #include <stack> #include <algorithm> #include <queue> #include <vector> using namespace std; #define INF 0x3f3f3f3f #define clr(x) memset((x),0,sizeof(x)) #define MAX(a, b) (a > b ? a : b) #define MIN(a, b) (a < b ? a : b) const int days[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; struct coor { int x, y; coor() { x = 0, y = 0; } coor(int _x, int _y) { x = _x, y = _y; } coor operator += (coor a) { x += a.x, y += a.y; return *this; } coor operator -= (coor a) { x -= a.x, y -= a.y; return *this; } }; class HexagonPuzzle { public: int theCount(vector <string>); }; bool valid[55][55][55][55]; bool vis[55][55]; void makevalid(int x1, int y1, int x2, int y2, int x3, int y3) { valid[x1][y1][x2][y2] = valid[x2][y2][x1][y1] = true; valid[x1][y1][x3][y3] = valid[x3][y3][x1][y1] = true; valid[x3][y3][x2][y2] = valid[x2][y2][x3][y3] = true; } int dirx[] = { 0, 0, 1, -1, 1, -1, 1, -1 }; int diry[] = { 1, -1, 1, -1, 0, 0, -1, 1 }; int size; long long dfs(int y, int x) { vis[y][x] = true; int r = 1; for(int i = 0; i < 8; i++) { int nx = x + dirx[i], ny = y + diry[i]; if(ny >= 0 && ny < size && nx <= ny && nx >= 0) { //if(vis[ny][nx]) continue; //if(!valid[ny][nx][y][x]) continue; if(!vis[ny][nx] && valid[ny][nx][y][x]) { r += dfs(ny, nx); } } } return r; } int HexagonPuzzle::theCount(vector <string> board) { clr(vis); clr(valid); size = board.size(); for(int i = 0; i < board.size() - 1; i++) { for(int j = 0; j <= i; j++) { if(board[i][j] == '.' && board[i + 1][j] == '.' && board[i + 1][j + 1] == '.') makevalid(i, j, i + 1, j, i + 1, j + 1); if(j < i) if(board[i][j] == '.' && board[i + 1][j + 1] == '.' && board[i][j + 1] == '.') makevalid(i, j, i + 1, j + 1, i, j + 1); } } long long r = 1; for(int i = 0; i < board.size(); i++) { for(int j = 0; j <= i; j++) { int tmp = 0; if(!vis[i][j] && board[i][j] == '.') tmp = dfs(i, j); for(int k = tmp; k > 2; k--) r = (r * (long long)k) % 1000000007ll; } } return (int)(r % 1000000007ll); }
[ "zukaidi@163.com@633dafb3-0c77-9a0a-df9f-af5249c8126a" ]
[ [ [ 1, 107 ] ] ]
03588f378924fde38269f4925c25a3ed986767bc
00fdb9c8335382401ee0a8c06ad6ebdcaa136b40
/ARM9/source/glib/cgltgf.cpp
26339a9d064ea14c861c9d562a40c41d43ade474
[]
no_license
Mbmax/ismart-kernel
d82633ba0864f9f697c3faa4ebc093a51b8463b2
f80d8d7156897d019eb4e16ef9cec8a431d15ed3
refs/heads/master
2016-09-06T13:28:25.260481
2011-03-29T10:31:04
2011-03-29T10:31:04
35,029,299
1
2
null
null
null
null
UTF-8
C++
false
false
6,280
cpp
#include <stdlib.h> #include <NDS.h> #include "glib.h" #include "glmemtool.h" #include "cgltgf.h" #include "cglstream.h" CglTGF::CglTGF(const u8 *_buf,const int _size) { CglStream stream(_buf,_size); Width=stream.Readu16(); Height=stream.Readu16(); int size; size=stream.GetSize()-stream.GetOffset(); pdata=(u16*)glsafemalloc(size); stream.ReadBuffer(pdata,size); ppLineOffsets=(u16**)glsafemalloc(Height*4); u16 *_pdata=pdata; for(int y=0;y<Height;y++){ ppLineOffsets[y]=_pdata; int x=0; while(x<Width){ u16 curdata=*_pdata++; int alpha=curdata & 0xff; int len=curdata >> 8; x+=len; if(alpha!=31) _pdata+=len; } } } CglTGF::~CglTGF(void) { glsafefree(pdata); pdata=NULL; glsafefree(ppLineOffsets); ppLineOffsets=NULL; } int CglTGF::GetWidth(void) const { return(Width); } int CglTGF::GetHeight(void) const { return(Height); } asm u32 CglTGF_BitBlt_Body(const u32 dummy,const u16 *pdata,const u16 *pBuf,const u32 Width) { REG_pdata RN r1 REG_pBuf RN r2 REG_Width RN r3 REG_pdataMaster RN r4 REG_alpha RN r5 REG_len RN r6 REG_src RN r7 REG_add RN r8 REG_tmp1 RN r9 REG_tmp2 RN r10 REG_tmp3 RN r11 REG_jumptable RN r12 PUSH {r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12} mov REG_pdataMaster,REG_pdata ldr REG_jumptable,=CglTGF_BitBlt_jumptable CglTGF_BitBlt_Start ldrh REG_alpha,[REG_pdata],#2 lsr REG_len,REG_alpha,#8 and REG_alpha,#0xff sub REG_Width,REG_len ; Width-=len for interlock ldr pc,[REG_jumptable,REG_alpha,lsl #2] MACRO CglTGF_BitBlt_TransEnd sub r0,REG_pdata,REG_pdataMaster POP {r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12} bx lr MEND CglTGF_BitBlt_Alpha0 CglTGF_BitBlt_Alpha0_Loop ldrh REG_add,[REG_pdata],#2 subs REG_len,#1 strh REG_add,[REG_pBuf],#2 bne CglTGF_BitBlt_Alpha0_Loop cmp REG_Width,#0 bne CglTGF_BitBlt_Start CglTGF_BitBlt_TransEnd CglTGF_BitBlt_Alpha2 ldr REG_tmp1,=((1<<4)<<0) | ((1<<4)<<5) | ((1<<4)<<10) CglTGF_BitBlt_Alpha2_Loop ldrh REG_src,[REG_pBuf] ldrh REG_add,[REG_pdata],#2 subs REG_len,#1 and REG_src,REG_src,REG_tmp1 add REG_add,REG_add,REG_src,lsr #4 strh REG_add,[REG_pBuf],#2 bne CglTGF_BitBlt_Alpha2_Loop cmp REG_Width,#0 bne CglTGF_BitBlt_Start CglTGF_BitBlt_TransEnd CglTGF_BitBlt_Alpha4 ldr REG_tmp1,=((3<<3)<<0) | ((3<<3)<<5) | ((3<<3)<<10) CglTGF_BitBlt_Alpha4_Loop ldrh REG_src,[REG_pBuf] ldrh REG_add,[REG_pdata],#2 subs REG_len,#1 and REG_src,REG_src,REG_tmp1 add REG_add,REG_add,REG_src,lsr #3 strh REG_add,[REG_pBuf],#2 bne CglTGF_BitBlt_Alpha4_Loop cmp REG_Width,#0 bne CglTGF_BitBlt_Start CglTGF_BitBlt_TransEnd CglTGF_BitBlt_Alpha8 ldr REG_tmp1,=((7<<2)<<0) | ((7<<2)<<5) | ((7<<2)<<10) CglTGF_BitBlt_Alpha8_Loop ldrh REG_src,[REG_pBuf] ldrh REG_add,[REG_pdata],#2 subs REG_len,#1 and REG_src,REG_src,REG_tmp1 add REG_add,REG_add,REG_src,lsr #2 strh REG_add,[REG_pBuf],#2 bne CglTGF_BitBlt_Alpha8_Loop cmp REG_Width,#0 bne CglTGF_BitBlt_Start CglTGF_BitBlt_TransEnd CglTGF_BitBlt_Alpha16 ldr REG_tmp1,=((15<<1)<<0) | ((15<<1)<<5) | ((15<<1)<<10) CglTGF_BitBlt_Alpha16_Loop ldrh REG_src,[REG_pBuf] ldrh REG_add,[REG_pdata],#2 subs REG_len,#1 and REG_src,REG_src,REG_tmp1 add REG_add,REG_add,REG_src,lsr #1 strh REG_add,[REG_pBuf],#2 bne CglTGF_BitBlt_Alpha16_Loop cmp REG_Width,#0 bne CglTGF_BitBlt_Start CglTGF_BitBlt_TransEnd CglTGF_BitBlt_AlphaAny lsl REG_alpha,#11 ; alpha 5bit to 16bit CglTGF_BitBlt_AlphaAny_Loop ldrh REG_src,[REG_pBuf] ldrh REG_add,[REG_pdata],#2 and REG_tmp1,REG_src,#(0x1f<<0) smulwb REG_tmp1,REG_alpha,REG_tmp1 and REG_tmp2,REG_src,#(0x1f<<5) add REG_add,REG_tmp1 smulwb REG_tmp2,REG_alpha,REG_tmp2 and REG_tmp3,REG_src,#(0x1f<<10) smulwb REG_tmp3,REG_alpha,REG_tmp3 and REG_tmp2,REG_tmp2,#(0x1f<<5) add REG_add,REG_tmp2 and REG_tmp3,REG_tmp3,#(0x1f<<10) add REG_add,REG_tmp3 strh REG_add,[REG_pBuf],#2 subs REG_len,#1 bne CglTGF_BitBlt_AlphaAny_Loop cmp REG_Width,#0 bne CglTGF_BitBlt_Start CglTGF_BitBlt_TransEnd CglTGF_BitBlt_Alpha31 add REG_pBuf,REG_len,lsl #1 cmp REG_Width,#0 bne CglTGF_BitBlt_Start CglTGF_BitBlt_TransEnd CglTGF_BitBlt_jumptable DCD CglTGF_BitBlt_Alpha0,CglTGF_BitBlt_Alpha0,CglTGF_BitBlt_Alpha2,CglTGF_BitBlt_AlphaAny DCD CglTGF_BitBlt_Alpha4,CglTGF_BitBlt_AlphaAny,CglTGF_BitBlt_AlphaAny,CglTGF_BitBlt_AlphaAny DCD CglTGF_BitBlt_Alpha8,CglTGF_BitBlt_AlphaAny,CglTGF_BitBlt_AlphaAny,CglTGF_BitBlt_AlphaAny DCD CglTGF_BitBlt_AlphaAny,CglTGF_BitBlt_AlphaAny,CglTGF_BitBlt_AlphaAny,CglTGF_BitBlt_AlphaAny DCD CglTGF_BitBlt_Alpha16,CglTGF_BitBlt_AlphaAny,CglTGF_BitBlt_AlphaAny,CglTGF_BitBlt_AlphaAny DCD CglTGF_BitBlt_AlphaAny,CglTGF_BitBlt_AlphaAny,CglTGF_BitBlt_AlphaAny,CglTGF_BitBlt_AlphaAny DCD CglTGF_BitBlt_AlphaAny,CglTGF_BitBlt_AlphaAny,CglTGF_BitBlt_AlphaAny,CglTGF_BitBlt_AlphaAny DCD CglTGF_BitBlt_AlphaAny,CglTGF_BitBlt_AlphaAny,CglTGF_BitBlt_AlphaAny,CglTGF_BitBlt_Alpha31 } void CglTGF::BitBlt(CglCanvas *pDestCanvas,const int nDestLeft,const int nDestTop) const { u16 *_pdata=pdata; u16 *pBuf=pDestCanvas->GetVRAMBuf(); pBuf=&pBuf[(nDestTop*pDestCanvas->GetWidth())+nDestLeft]; u32 DestWidth=pDestCanvas->GetWidth(); for(int y=0;y<Height;y++){ u32 srclen=CglTGF_BitBlt_Body(0,_pdata,pBuf,Width); _pdata+=srclen/2; pBuf+=DestWidth; } } void CglTGF::BitBltLimitY(CglCanvas *pDestCanvas,const int nDestLeft,const int nDestTop,const int nHeight,const int nSrcTop) const { u16 *_pdata=ppLineOffsets[nSrcTop]; u16 *pBuf=pDestCanvas->GetVRAMBuf(); pBuf=&pBuf[(nDestTop*pDestCanvas->GetWidth())+nDestLeft]; u32 DestWidth=pDestCanvas->GetWidth(); if(nSrcTop<0) return; if(Height<=nSrcTop) return; if(nHeight<=0) return; if(Height<nHeight) return; for(int y=0;y<nHeight;y++){ u32 srclen=CglTGF_BitBlt_Body(0,_pdata,pBuf,Width); _pdata+=srclen/2; pBuf+=DestWidth; } }
[ "feng.flash@4bd7f34a-4c62-84e7-1fb2-5fbc975ebfb2" ]
[ [ [ 1, 246 ] ] ]
3c204a8593aff53aa71c8c12619c57c2f3019a84
b67d58bd5bfe13b32bebe83dec22904243a52223
/FlashDBSimDll_Sample/TrivalBufferManager.h
a36ba242a1e114183d00740e02b25d2e242700bd
[]
no_license
maheshdharhari/flash-sim
b8929efc83a65ee6d5e782b835106ca36228c6c8
d04eb0e34bb44e7356f5c1b0e1f1af6097339225
refs/heads/master
2021-01-10T07:48:37.820361
2010-05-22T09:19:20
2010-05-22T09:19:20
43,440,579
0
0
null
null
null
null
UTF-8
C++
false
false
457
h
#ifndef _TRIVAL_BUFFER_MANAGER_H_ #define _TRIVAL_BUFFER_MANAGER_H_ #pragma managed(push, off) #include <memory> #include "BufferManagerBase.h" class TrivalBufferManager : public BufferManagerBase { public: TrivalBufferManager(std::tr1::shared_ptr<class IBlockDevice> pDevice); protected: void DoRead(size_t pageid, void *result); void DoWrite(size_t pageid, const void *data); void DoFlush(); }; #pragma managed(pop) #endif
[ "hiyoungcat@9895585c-9ddb-11de-bf4a-bd5be0e2b6d7", "hiYoungCat@9895585c-9ddb-11de-bf4a-bd5be0e2b6d7" ]
[ [ [ 1, 2 ], [ 4, 5 ], [ 7, 8 ], [ 10, 13 ], [ 15, 16 ], [ 18, 20 ], [ 22, 22 ] ], [ [ 3, 3 ], [ 6, 6 ], [ 9, 9 ], [ 14, 14 ], [ 17, 17 ], [ 21, 21 ] ] ]
6cd5e3e2261f739bfcaa203dcaa9ced1daaa4444
16d8b25d0d1c0f957c92f8b0d967f71abff1896d
/obse/obse/Commands_Script.cpp
3046af5963fd0fe158d635163ca703a2085343aa
[]
no_license
wlasser/oonline
51973b5ffec0b60407b63b010d0e4e1622cf69b6
fd37ee6985f1de082cbc9f8625d1d9307e8801a6
refs/heads/master
2021-05-28T23:39:16.792763
2010-05-12T22:35:20
2010-05-12T22:35:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,479
cpp
#include "Commands_Script.h" #include "GameAPI.h" #include "GameForms.h" #include "GameObjects.h" #include "ParamInfos.h" #if OBLIVION enum EScriptMode { eScript_HasScript, eScript_Get, eScript_Remove, }; static bool GetScript_Execute(COMMAND_ARGS, EScriptMode eMode) { *result = 0; TESForm* form = 0; ExtractArgsEx(paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, &form); form = form->TryGetREFRParent(); if (!form) { if (!thisObj) return true; form = thisObj->baseForm; } TESScriptableForm* scriptForm = (TESScriptableForm*)Oblivion_DynamicCast(form, 0, RTTI_TESForm, RTTI_TESScriptableForm, 0); Script* script = (scriptForm) ? scriptForm->script : NULL; if (eMode == eScript_HasScript) { *result = (script != NULL) ? 1 : 0; } else { if (script) { UInt32* refResult = (UInt32*)result; *refResult = script->refID; } if (eMode == eScript_Remove) { scriptForm->script = NULL; } } return true; } static bool Cmd_IsScripted_Execute(COMMAND_ARGS) { return GetScript_Execute(PASS_COMMAND_ARGS, eScript_HasScript); } static bool Cmd_GetScript_Execute(COMMAND_ARGS) { return GetScript_Execute(PASS_COMMAND_ARGS, eScript_Get); } static bool Cmd_RemoveScript_Execute(COMMAND_ARGS) { return GetScript_Execute(PASS_COMMAND_ARGS, eScript_Remove); } static bool Cmd_SetScript_Execute(COMMAND_ARGS) { *result = 0; UInt32* refResult = (UInt32*)result; TESForm* form = NULL; TESForm* scriptArg = NULL; ExtractArgsEx(paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, &scriptArg, &form); form = form->TryGetREFRParent(); if (!form) { if (!thisObj) return true; form = thisObj->baseForm; } TESScriptableForm* scriptForm = (TESScriptableForm*)Oblivion_DynamicCast(form, 0, RTTI_TESForm, RTTI_TESScriptableForm, 0); if (!scriptForm) return true; Script* script = (Script*)Oblivion_DynamicCast(scriptArg, 0, RTTI_TESForm, RTTI_Script, 0); if (!script) return true; // we can't get a magic script here if (script->IsMagicScript()) return true; if (script->IsQuestScript() && form->typeID == kFormType_Quest) { *refResult = scriptForm->script->refID; scriptForm->script = script; } else if (script->IsObjectScript()) { if (scriptForm->script) { *refResult = scriptForm->script->refID; } scriptForm->script = script; } return true; } static bool Cmd_IsFormValid_Execute(COMMAND_ARGS) { TESForm* form = NULL; *result = 0; if (ExtractArgsEx(paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, &form) && form) *result = 1; return true; } static bool Cmd_IsReference_Execute(COMMAND_ARGS) { TESObjectREFR* refr = NULL; *result = 0; if (ExtractArgs(paramInfo, arg1, opcodeOffsetPtr, thisObj, arg3, scriptObj, eventList, &refr)) *result = 1; return true; } static enum { eScriptVar_Get = 1, eScriptVar_GetRef, eScriptVar_Has, }; static bool GetVariable_Execute(COMMAND_ARGS, UInt32 whichAction) { char varName[256] = { 0 }; TESQuest* quest = NULL; Script* targetScript = NULL; ScriptEventList* targetEventList = NULL; *result = 0; if (!ExtractArgs(paramInfo, arg1, opcodeOffsetPtr, thisObj, arg3, scriptObj, eventList, &varName, &quest)) return true; if (quest) { TESScriptableForm* scriptable = (TESScriptableForm*)Oblivion_DynamicCast(quest, 0, RTTI_TESQuest, RTTI_TESScriptableForm, 0); targetScript = scriptable->script; targetEventList = quest->scriptEventList; } else if (thisObj) { TESScriptableForm* scriptable = (TESScriptableForm*)Oblivion_DynamicCast(thisObj->baseForm, 0, RTTI_TESForm, RTTI_TESScriptableForm, 0); if (scriptable) { targetScript = scriptable->script; targetEventList = thisObj->GetEventList(); } } if (targetScript && targetEventList) { Script::VariableInfo* varInfo = targetScript->GetVariableByName(varName); if (whichAction == eScriptVar_Has) return varInfo ? true : false; else if (varInfo) { ScriptEventList::Var* var = targetEventList->GetVariable(varInfo->idx); if (var) { if (whichAction == eScriptVar_Get) *result = var->data; else if (whichAction == eScriptVar_GetRef) { UInt32* refResult = (UInt32*)result; *refResult = (*(UInt64*)&var->data); } return true; } } } return false; } static bool Cmd_HasVariable_Execute(COMMAND_ARGS) { *result = 0; if (GetVariable_Execute(PASS_COMMAND_ARGS, eScriptVar_Has)) *result = 1; return true; } static bool Cmd_GetVariable_Execute(COMMAND_ARGS) { GetVariable_Execute(PASS_COMMAND_ARGS, eScriptVar_Get); return true; } static bool Cmd_GetRefVariable_Execute(COMMAND_ARGS) { GetVariable_Execute(PASS_COMMAND_ARGS, eScriptVar_GetRef); return true; } static bool Cmd_CompareScripts_Execute(COMMAND_ARGS) { Script* script1 = NULL; Script* script2 = NULL; *result = 0; if (!ExtractArgsEx(paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, &script1, &script2)) return true; script1 = (Script*)Oblivion_DynamicCast(script1, 0, RTTI_TESForm, RTTI_Script, 0); script2 = (Script*)Oblivion_DynamicCast(script2, 0, RTTI_TESForm, RTTI_Script, 0); if (script1 && script2 && script1->info.dataLength == script2->info.dataLength) { if (script1 == script2) *result = 1; else if (!memcmp(script1->data, script2->data, script1->info.dataLength)) *result = 1; } return true; } #endif CommandInfo kCommandInfo_IsScripted = { "IsScripted", "", 0, "returns 1 if the object or reference has a script attached to it", 0, 1, kParams_OneOptionalInventoryObject, HANDLER(Cmd_IsScripted_Execute), Cmd_Default_Parse, NULL, 0 }; CommandInfo kCommandInfo_GetScript = { "GetScript", "", 0, "returns the script of the referenced or passed object", 0, 1, kParams_OneOptionalInventoryObject, HANDLER(Cmd_GetScript_Execute), Cmd_Default_Parse, NULL, 0 }; CommandInfo kCommandInfo_RemoveScript = { "RemoveScript", "", 0, "removes the script of the referenced or passed object", 0, 1, kParams_OneOptionalInventoryObject, HANDLER(Cmd_RemoveScript_Execute), Cmd_Default_Parse, NULL, 0 }; ParamInfo kParamInfo_SetScript[2] = { { "script", kParamType_MagicItem, 0 }, { "object", kParamType_InventoryObject, 1}, }; CommandInfo kCommandInfo_SetScript = { "SetScript", "", 0, "returns the script of the referenced or passed object", 0, 2, kParamInfo_SetScript, HANDLER(Cmd_SetScript_Execute), Cmd_Default_Parse, NULL, 0 }; CommandInfo kCommandInfo_IsFormValid = { "IsFormValid", "", 0, "returns true if the ref variable contains a valid form", 0, 1, kParams_OneInventoryObject, HANDLER(Cmd_IsFormValid_Execute), Cmd_Default_Parse, NULL, 0 }; static ParamInfo kParams_OneObjectRef[1] = { { "ref", kParamType_ObjectRef, 0 }, }; CommandInfo kCommandInfo_IsReference = { "IsReference", "", 0, "returns true if the ref variable contains a REFR", 0, 1, kParams_OneObjectRef, HANDLER(Cmd_IsReference_Execute), Cmd_Default_Parse, NULL, 0 }; static ParamInfo kParams_GetVariable[2] = { { "variable name", kParamType_String, 0 }, { "quest", kParamType_Quest, 1 }, }; CommandInfo kCommandInfo_GetVariable = { "GetVariable", "GetVar", 0, "looks up the value of a variable by name", 0, 2, kParams_GetVariable, HANDLER(Cmd_GetVariable_Execute), Cmd_Default_Parse, NULL, 0 }; CommandInfo kCommandInfo_HasVariable = { "HasVariable", "HasVar", 0, "returns true if the script has a variable with the specified name", 0, 2, kParams_GetVariable, HANDLER(Cmd_HasVariable_Execute), Cmd_Default_Parse, NULL, 0 }; CommandInfo kCommandInfo_GetRefVariable = { "GetRefVariable", "GetRefVar", 0, "looks up the value of a ref variable by name", 0, 2, kParams_GetVariable, HANDLER(Cmd_GetRefVariable_Execute), Cmd_Default_Parse, NULL, 0 }; static ParamInfo kParams_CompareScripts[2] = { { "script", kParamType_InventoryObject, 0 }, { "script", kParamType_InventoryObject, 0 }, }; CommandInfo kCommandInfo_CompareScripts = { "CompareScripts", "", 0, "returns true if the compiled scripts are identical", 0, 2, kParams_CompareScripts, HANDLER(Cmd_CompareScripts_Execute), Cmd_Default_Parse, NULL, 0 };
[ "masterfreek64@2644d07b-d655-0410-af38-4bee65694944" ]
[ [ [ 1, 392 ] ] ]
3ab4ac48fe64df0656fd05a207d9868c0a10e6c7
c0a577ec612a721b324bb615c08882852b433949
/englishplayer/EnTranscription/AudioTimeScale.cpp
42e2331535bed0b4a5e27e36dcf788a85e01f33f
[]
no_license
guojerry/cppxml
ca87ca2e3e62cbe2a132d376ca784f148561a4cc
a4f8b7439e37b6f1f421445694c5a735f8beda71
refs/heads/master
2021-01-10T10:57:40.195940
2010-04-21T13:25:29
2010-04-21T13:25:29
52,403,012
0
0
null
null
null
null
UTF-8
C++
false
false
10,425
cpp
#include "stdafx.h" #if (1100 > _MSC_VER) #include <olectlid.h> #else #include <olectl.h> #endif #include "AudioTimeScale.h" #include "resource.h" #include <tchar.h> #include <stdio.h> #define TRANSFORM_NAME L"AudioTimeScale Filter" // Constructor CAudioTimeScale::CAudioTimeScale(TCHAR *tszName, LPUNKNOWN punk, HRESULT *phr) : CTransformFilter(tszName, punk, CLSID_AudioTransformFrame) { } // ~CAudioTimeScale CAudioTimeScale::~CAudioTimeScale() { } // // CreateInstance // // Provide the way for COM to create a AudioTransformFrame object // CAudioTimeScale* CAudioTimeScale::CreateInstance(LPUNKNOWN punk, HRESULT *phr) { CAudioTimeScale *pNewObject = new CAudioTimeScale(NAME("AudioTransformFrame"), punk, phr); if (pNewObject == NULL) { *phr = E_OUTOFMEMORY; } return pNewObject; } // // Transform // // Transforms the input and saves results in the the output // HRESULT CAudioTimeScale::Transform(IMediaSample *pIn, IMediaSample *pOut) { HRESULT hr = S_OK; // input AM_MEDIA_TYPE* pTypeIn = &m_pInput->CurrentMediaType(); WAVEFORMATEX *pihIn = (WAVEFORMATEX *)pTypeIn->pbFormat; unsigned char *pSrc = 0; pIn->GetPointer((unsigned char **)&pSrc); ASSERT(pSrc); // output AM_MEDIA_TYPE *pTypeOut = &m_pOutput->CurrentMediaType(); WAVEFORMATEX *pihOut = (WAVEFORMATEX *)pTypeOut->pbFormat; short *pDst = 0; pOut->GetPointer((unsigned char **)&pDst); ASSERT(pDst); // TODO: insert procesing code here // for now, just make a copy of the input hr = Copy(pIn, pOut); if (hr != S_OK) return hr; return NOERROR; } // // CheckInputType // // Check the input type is OK - return an error otherwise // HRESULT CAudioTimeScale::CheckInputType(const CMediaType *mtIn) { // check this is an audio format that we can support if (*mtIn->FormatType() != FORMAT_WaveFormatEx) { return E_INVALIDARG; } // Can we transform this type if (CanPerformTransform(mtIn)) { CopyMediaType(&m_mt, mtIn); return NOERROR; } return E_FAIL; } // // Checktransform // // Check a transform can be done between these formats // HRESULT CAudioTimeScale::CheckTransform(const CMediaType *mtIn, const CMediaType *mtOut) { if (CanPerformTransform(mtIn)) { return S_OK; } return VFW_E_TYPE_NOT_ACCEPTED; } // // DecideBufferSize // // Tell the output pin's allocator what size buffers we // require. Can only do this when the input is connected // HRESULT CAudioTimeScale::DecideBufferSize(IMemAllocator *pAlloc,ALLOCATOR_PROPERTIES *pProperties) { // Is the input pin connected if (m_pInput->IsConnected() == FALSE) { return E_UNEXPECTED; } SetupSoundTouch(); ASSERT(pAlloc); ASSERT(pProperties); HRESULT hr = NOERROR; // get input dimensions CMediaType inMediaType = m_pInput->CurrentMediaType(); WAVEFORMATEX *pwfx = (WAVEFORMATEX *)m_mt.Format(); pProperties->cBuffers = 1; int size = pwfx->nAvgBytesPerSec; //pwfx->nAvgBytesPerSec / 2; pProperties->cbBuffer = size; // same as input pin ASSERT(pProperties->cbBuffer); // Ask the allocator to reserve us some sample memory, NOTE the function // can succeed (that is return NOERROR) but still not have allocated the // memory that we requested, so we must check we got whatever we wanted ALLOCATOR_PROPERTIES Actual; hr = pAlloc->SetProperties(pProperties,&Actual); if (FAILED(hr)) { return hr; } ASSERT( Actual.cBuffers == 1 ); if (pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer) { return E_FAIL; } return NOERROR; } void CAudioTimeScale::SetupSoundTouch() { WAVEFORMATEX *pwfx = (WAVEFORMATEX *)m_mt.Format(); m_soundTouch.setSampleRate(pwfx->nSamplesPerSec); m_soundTouch.setChannels(pwfx->nChannels); m_soundTouch.setTempoChange(0); m_soundTouch.setPitchSemiTones(0); m_soundTouch.setRateChange(0); m_soundTouch.setSetting(SETTING_USE_QUICKSEEK, TRUE); m_soundTouch.setSetting(SETTING_USE_AA_FILTER, TRUE); if(1) { // use settings for speech processing m_soundTouch.setSetting(SETTING_SEQUENCE_MS, 40); m_soundTouch.setSetting(SETTING_SEEKWINDOW_MS, 15); m_soundTouch.setSetting(SETTING_OVERLAP_MS, 8); } } void CAudioTimeScale::SetRate(float nRate) { if(nRate < -50 || nRate > 100) { ASSERT(FALSE); return; } m_soundTouch.setTempoChange(nRate); } // // GetMediaType // // Returns the supported media types for the output pin in order of preferred types // starting with iPosition=0 // HRESULT CAudioTimeScale::GetMediaType(int iPosition, CMediaType *pMediaType) { // Is the input pin connected if (m_pInput->IsConnected() == FALSE) return E_UNEXPECTED; // This should never happen if (iPosition < 0) return E_INVALIDARG; // Do we have more items to offer if (iPosition >= 2) return VFW_S_NO_MORE_ITEMS; WAVEFORMATEX *pwfxin = (WAVEFORMATEX *)m_mt.pbFormat; if (iPosition == 0) { // advertise the extensible format first WAVEFORMATEXTENSIBLE *pwfx = (WAVEFORMATEXTENSIBLE *)pMediaType->AllocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE)); pwfx->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; pwfx->Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); pwfx->Format.nChannels = pwfxin->nChannels; pwfx->Format.nSamplesPerSec = pwfxin->nSamplesPerSec; pwfx->Format.wBitsPerSample = pwfxin->wBitsPerSample; pwfx->Format.nAvgBytesPerSec = pwfx->Format.nSamplesPerSec * pwfx->Format.wBitsPerSample * pwfx->Format.nChannels / 8; pwfx->Format.nBlockAlign = pwfx->Format.wBitsPerSample * pwfxin->nChannels / 8; pwfx->dwChannelMask = (1 << pwfx->Format.nChannels) - 1; pwfx->Samples.wValidBitsPerSample = pwfx->Format.wBitsPerSample; pwfx->SubFormat = MEDIASUBTYPE_PCM; pMediaType->SetFormat((BYTE*)pwfx, sizeof(WAVEFORMATEXTENSIBLE)); // Clear source and target rectangles pMediaType->SetType(&MEDIATYPE_Audio); pMediaType->SetFormatType(&FORMAT_WaveFormatEx); pMediaType->SetTemporalCompression(FALSE); GUID SubTypeGUID = MEDIASUBTYPE_PCM; pMediaType->SetSubtype(&SubTypeGUID); pMediaType->SetSampleSize(1); } else if (iPosition == 1) { // our backup legacy format WAVEFORMATEX *pwfx = (WAVEFORMATEX *)pMediaType->AllocFormatBuffer(sizeof(WAVEFORMATEX)); pwfx->wFormatTag = WAVE_FORMAT_PCM; pwfx->cbSize = 0; // no extra data for basic PCM pwfx->nChannels = pwfxin->nChannels; pwfx->nSamplesPerSec = pwfxin->nSamplesPerSec; pwfx->wBitsPerSample = pwfxin->wBitsPerSample; pwfx->nAvgBytesPerSec = pwfx->nSamplesPerSec * pwfx->wBitsPerSample * pwfx->nChannels / 8; pwfx->nBlockAlign = pwfx->wBitsPerSample * pwfxin->nChannels / 8; pMediaType->SetFormat((BYTE*)pwfx, sizeof(WAVEFORMATEX)); pMediaType->SetType(&MEDIATYPE_Audio); pMediaType->SetFormatType(&FORMAT_WaveFormatEx); pMediaType->SetTemporalCompression(FALSE); GUID SubTypeGUID = MEDIASUBTYPE_PCM; pMediaType->SetSubtype(&SubTypeGUID); pMediaType->SetSampleSize(1); } return NOERROR; } // // CanPerformAudioTransformFrame // // Check that it is audio and a PCM format. Can get more specific here if needed (i.e. samplerate, channels etc) // BOOL CAudioTimeScale::CanPerformTransform(const CMediaType *pMediaType) const { if (IsEqualGUID(*pMediaType->Type(), MEDIATYPE_Audio)) { GUID SubTypeGUID = MEDIASUBTYPE_PCM; if (IsEqualGUID(*pMediaType->Subtype(), SubTypeGUID)) { WAVEFORMATEX *pwfx = (WAVEFORMATEX *) pMediaType->Format(); return TRUE; } } return FALSE; } #define WRITEOUT(var) hr = pStream->Write(&var, sizeof(var), NULL); \ if (FAILED(hr)) return hr; #define READIN(var) hr = pStream->Read(&var, sizeof(var), NULL); \ if (FAILED(hr)) return hr; // // Copy // // Make destination an identical copy of source // HRESULT CAudioTimeScale::Copy(IMediaSample *pSource, IMediaSample *pDest) { // Copy the sample data BYTE *pSourceBuffer, *pDestBuffer; long lSourceSize = pSource->GetActualDataLength(); long lDestSize = pDest->GetSize(); ASSERT(lDestSize >= lSourceSize); pSource->GetPointer(&pSourceBuffer); pDest->GetPointer(&pDestBuffer); WAVEFORMATEX *pwfx = (WAVEFORMATEX *)m_mt.Format(); int nSamples = lSourceSize / pwfx->nBlockAlign; // Feed the samples into SoundTouch processor m_soundTouch.putSamples((const SAMPLETYPE*)pSourceBuffer, nSamples); int nDestSize = pDest->GetSize(); nSamples = m_soundTouch.receiveSamples((SAMPLETYPE*)pDestBuffer, nDestSize); REFERENCE_TIME TimeStart, TimeEnd; if (NOERROR == pSource->GetTime(&TimeStart, &TimeEnd)) { pDest->SetTime(&TimeStart, &TimeEnd); } LONGLONG MediaStart, MediaEnd; if (pSource->GetMediaTime(&MediaStart,&MediaEnd) == NOERROR) { pDest->SetMediaTime(&MediaStart,&MediaEnd); } // Copy the Sync point property HRESULT hr = pSource->IsSyncPoint(); if (hr == S_OK) { pDest->SetSyncPoint(TRUE); } else if (hr == S_FALSE) { pDest->SetSyncPoint(FALSE); } else { // an unexpected error has occured... return E_UNEXPECTED; } // Copy the media type AM_MEDIA_TYPE *pMediaType; pSource->GetMediaType(&pMediaType); pDest->SetMediaType(pMediaType); DeleteMediaType(pMediaType); // Copy the preroll property hr = pSource->IsPreroll(); if (hr == S_OK) { pDest->SetPreroll(TRUE); } else if (hr == S_FALSE) { pDest->SetPreroll(FALSE); } else { // an unexpected error has occured... return E_UNEXPECTED; } // Copy the discontinuity property hr = pSource->IsDiscontinuity(); if (hr == S_OK) { pDest->SetDiscontinuity(TRUE); } else if (hr == S_FALSE) { pDest->SetDiscontinuity(FALSE); } else { // an unexpected error has occured... return E_UNEXPECTED; } // Copy the actual data length pDest->SetActualDataLength(nSamples * pwfx->nBlockAlign); return NOERROR; }
[ "oeichenwei@0e9f5f58-6d57-11de-950b-9fccee66d0d9" ]
[ [ [ 1, 366 ] ] ]
b1751f5167305ea663537aa525b336f130ab76b5
2f77d5232a073a28266f5a5aa614160acba05ce6
/01.DevelopLibrary/03.Code/UI/EasySmsWndBase.cpp
b5636cd99926135393959daa9fa6e70cc37ddd18
[]
no_license
radtek/mobilelzz
87f2d0b53f7fd414e62c8b2d960e87ae359c81b4
402276f7c225dd0b0fae825013b29d0244114e7d
refs/heads/master
2020-12-24T21:21:30.860184
2011-03-26T02:19:47
2011-03-26T02:19:47
58,142,323
0
0
null
null
null
null
GB18030
C++
false
false
6,439
cpp
#include"stdafx.h" #include "resource.h" #include "EasySmsWndBase.h" #include "EasySmsUiCtrl.h" /////////////////////CSmsLookCtorList///////////////////////////////////////////////////// CEasySmsListBase::CEasySmsListBase() { } CEasySmsListBase::~CEasySmsListBase() { long lCnt = GetItemCount(); for ( int i = 0; i < lCnt; ++i ) { ListItemEx *pListItemEx = GetItem ( i ); if ( NULL != pListItemEx ) { if ( NULL != pListItemEx->m_pData ) { delete pListItemEx->m_pData; pListItemEx->m_pData = NULL; } delete pListItemEx; pListItemEx = NULL; } } RemoveAll(); } // void CEasySmsListBase::OnRemoveItem(int nIndex) // { // ListItemEx* pItem = GetItem( nIndex ); // if( NULL != pItem ) // { // MyListItemData* mlid = (MyListItemData*)pItem->Data; // if( NULL != mlid ) // { // delete mlid; // } // } // } int CEasySmsListBase::OnLButtonUp( UINT fwKeys, int xPos, int yPos ) { int iRlt = UiListEx::OnLButtonUp(fwKeys, xPos, yPos); return iRlt; } void CEasySmsListBase::setEasySmsWndBase( CEasySmsWndBase *pCEasySmsWndBase ) { m_pCEasySmsWndBase = pCEasySmsWndBase; } ///////////////CEasySmsWndBase/////////////////////////////////////////////////////////// CEasySmsWndBase::CEasySmsWndBase(void) : m_pItem( NULL ) { m_pCoreItemData = NULL; m_list_base.setEasySmsWndBase( this ); } CEasySmsWndBase::~CEasySmsWndBase(void) { m_imgContainer_base.RemoveAll(); } BOOL CEasySmsWndBase::OnInitDialog() { if ( !CMzWndEx::OnInitDialog() ) { return FALSE; } //ini list /*ID和AddUiWin在派生类中设定*/ m_list_base.SetPos( 0, 0, GetWidth(), GetHeight( ) - MZM_HEIGHT_TEXT_TOOLBAR ); m_list_base.EnableInsideScroll( true ); m_list_base.EnableUltraGridlines( true ); m_list_base.SetItemAttribute( UILISTEX_ITEMTYPE_SMS/*UILISTEX_ITEMTYPE_BASE*/ ); m_list_base.EnableNotifyMessage( true ); m_list_base.UpdateItemAttribute_Del(); //ini toolbar /*ID和AddUiWin在派生类中设定*/ m_toolBar_base.SetPos( 0, GetHeight() - MZM_HEIGHT_TEXT_TOOLBAR , GetWidth() , MZM_HEIGHT_TEXT_TOOLBAR ); m_toolBar_base.SetButton( 2, true, true, L"返回" ); m_toolBar_base.EnablePressedHoldSupport( true ); m_toolBar_base.SetPressedHoldTime( 1000 ); m_toolBar_base.EnableNotifyMessage( true ); return TRUE; } int CEasySmsWndBase::DoModalBase( CMzWndEx *pCMzWndEx ) { RECT rcWork = MzGetWorkArea(); pCMzWndEx->Create( rcWork.left, rcWork.top, RECT_WIDTH(rcWork), RECT_HEIGHT(rcWork), 0, 0, 0 ); // 设置窗口切换动画(弹出时的动画) pCMzWndEx->SetAnimateType_Show( getScreenRandom() ); // 设置窗口切换动画(结束时的动画) pCMzWndEx->SetAnimateType_Hide( getScreenRandom() ); return pCMzWndEx->DoModal(); } LRESULT CEasySmsWndBase::MzDefWndProc(UINT message, WPARAM wParam, LPARAM lParam ) { switch(message) { //处理删除某项时的消息 case MZ_WM_ITEM_ONREMOVE: { int index = lParam; ListItemEx* pItem = m_list_base.GetItem( index ); DoSthForItemRemove( pItem ); } break; /*点击某项被选中的通知消息 wparam 控件ID lparam的低位表示被选中的项,高位表示选中的区域(分割线左,右或非分割线内区域) */ case MZ_WM_UILIST_LBUTTONUP_SELECT: { if( m_list_base.GetID() == wParam ) { int index = lParam; index &= 0x0000FFFF; ListItemEx* pItem = m_list_base.GetItem( index ); DoSthForItemBtnUpSelect( pItem ); } } break; case MZ_WM_ITEM_ONSELECTED: { int index = wParam; ListItemEx* pItem = m_list_base.GetItem( index ); DoSthForItemSelect( pItem ); } break; case MZ_WM_MOUSE_NOTIFY: { if (LOWORD(wParam) == m_toolBar_base.GetID() ) { int nNotify = HIWORD(wParam); switch(nNotify) { case MZ_MN_PRESSEDHOLD_TIMEUP: { POINT PT = m_toolBar_base.GetMouseDownPos (); int nIndex = m_toolBar_base.CalcIndexOfPos( PT.x, PT.y ); DoSthForTooBarHoldPress( nIndex ); } break; default: break; } } } break; default: break; } return CMzWndEx::MzDefWndProc( message, wParam, lParam ); } void CEasySmsWndBase::DoSthForItemRemove( ListItemEx* pItem ) { } void CEasySmsWndBase::DoSthForItemBtnUpSelect( ListItemEx* pItem ) { } void CEasySmsWndBase::DoSthForItemSelect( ListItemEx* pItem ) { } void CEasySmsWndBase::DoSthForTooBarHoldPress( int nIndex ) { if ( 2 == nIndex ) { ReturnToMainWnd(); } } void CEasySmsWndBase::ReturnToMainWnd() { this->EndModal( ID_CASCADE_EXIT ); } HRESULT CEasySmsWndBase::RemoveSmsInDb( ListItemEx* pItem ) { //get sid stCoreItemData *pstCoreItemData = (stCoreItemData *)(pItem->m_pData); long lSid = pstCoreItemData->lSid; //delete wchar_t *pBuf = NULL; long lSize = 0; wchar_t *pwcResult = NULL; CEasySmsUiCtrl clCEasySmsUiCtrl; clCEasySmsUiCtrl.MakeDeleteSmsInfo( &pBuf, &lSize, &lSid, 1 ); CCoreService *pCCoreService = CCoreService::GetInstance(); if ( NULL == pCCoreService ) return E_FAIL; HRESULT hr = pCCoreService->Request( pBuf, &pwcResult ); if ( FAILED ( hr ) ) return E_FAIL; return S_OK; } void CEasySmsWndBase::SetListItem( ListItemEx* pItem ) { if ( NULL != m_pItem ) { delete m_pItem; m_pItem = NULL; } m_pItem = pItem; m_pCoreItemData = (CoreItemData_t*)pItem->m_pData; } wchar_t * CEasySmsWndBase::GetNameOrTel( ListItemEx* pItem ) { if ( NULL == pItem ) { return NULL; } stCoreItemData *pstCoreItemData = (stCoreItemData *)(pItem->m_pData); if ( NULL == pstCoreItemData ) { return NULL; } if ( NULL != pstCoreItemData->bstrName.m_str ) { return pstCoreItemData->bstrName.m_str; } else if ( NULL != pstCoreItemData->bstrTelNo.m_str ) { return pstCoreItemData->bstrTelNo.m_str; } else { return NULL; } } wchar_t * CEasySmsWndBase::GetMsgInfoFromIterm( ListItemEx* pItem ) { if ( NULL == pItem ) { return NULL; } stCoreItemData *pstCoreItemData = (stCoreItemData *)(pItem->m_pData); if ( NULL == pstCoreItemData ) { return NULL; } if ( NULL != pstCoreItemData->bstrDetail.m_str ) { return pstCoreItemData->bstrDetail.m_str; } else { return NULL; } }
[ "saviola0830@gmail.com", "lidan8908589@8983de3c-2b35-11df-be6c-f52728ce0ce6" ]
[ [ [ 1, 63 ], [ 65, 248 ], [ 250, 300 ] ], [ [ 64, 64 ], [ 249, 249 ] ] ]
901e9722852c8092cae1ef03bb40c2fd51209ef5
cd387cba6088f351af4869c02b2cabbb678be6ae
/src/experimental/petesimulator/Board.cpp
2d91aec6128488b1dd5140a71edc818defc6c744
[]
no_license
pedromartins/mew-dev
e8a9cd10f73fbc9c0c7b5bacddd0e7453edd097e
e6384775b00f76ab13eb046509da21d7f395909b
refs/heads/master
2016-09-06T14:57:00.937033
2009-04-13T15:16:15
2009-04-13T15:16:15
32,332,332
0
0
null
null
null
null
UTF-8
C++
false
false
1,513
cpp
#include "Board.h" Board::Board(int b){ realSize = new Point(3000,2100); bpp = b; screen = SDL_SetVideoMode( realSize->sdl_x(),realSize->sdl_y(),b, SDL_SWSURFACE ); createBackground(); apply_surface( 0, 0, pic, screen ); SDL_Flip( screen ); SDL_WM_SetCaption( "Robot Simulator ALPHA ALPHA v0.00001", NULL ); } Board::~Board(){ SDL_FreeSurface(screen); SDL_FreeSurface(pic); } void Board::handle_input(SDL_Event *event, bool *quit){ if( event->type == SDL_QUIT ) { //Quit the program *quit = true; } else if(event->type == SDL_KEYDOWN){ switch( event->key.keysym.sym ) { case SDLK_ESCAPE: *quit = true; break; default: break; } } } void Board::createBackground(){ //need to make these independent of image size, create objects for dispensors etc.. SDL_Surface *background = load_image( "res/BoardResized.png" ); SDL_Surface *circle = load_image( "res/MiddleCircleResized.png" ); SDL_Surface *topsides = load_image("res/TopSideResized.png"); SDL_Surface *middle = load_image("res/TopMiddleResized.png"); SDL_Surface *greenDisp = load_image("res/GreenDispensor.png"); apply_surface( 540, 360, circle, background ); apply_surface( 240, 0 , topsides, background ); apply_surface( 720, 0 , topsides, background ); apply_surface( 480, 0, middle, background); apply_surface( 720 + 240 + (int) (0.4 * 289) , 0, greenDisp, background); pic = background; }
[ "fushunpoon@1fd432d8-e285-11dd-b2d9-215335d0b316" ]
[ [ [ 1, 48 ] ] ]
9599d0ddea4047fa2f708174352cc56e8f26e0f3
a0d4f557ddaf4351957e310478e183dac45d77a1
/src/Utils/FontMan.h
e2c99eddce616405877c16de20d5727905bcf91c
[]
no_license
houpcz/Houp-s-level-editor
1f6216e8ad8da393e1ee151e36fc37246279bfed
c762c9f5ed064ba893bf34887293a73dd35a06f8
refs/heads/master
2016-09-11T11:03:34.560524
2011-08-09T11:37:49
2011-08-09T11:37:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,185
h
#ifndef _FONTMAN_H_ #define _FONTMAN_H_ #include "Font.h" #include <map> #include <stdexcept> const int LUCIDA_CHAR_WIDTH_PX16 = 13; /// Width of one char in lucida, h = 16, font (its monospace font) const int LUCIDA_CHAR_WIDTH_PX8 = 7; /// Width of one char in lucida, h = 8, font (its monospace font) class FontMan { private : static FontMan * inst; /// Its singleton std::map<string, Font *> fontMap; /// map of font name and font itself char anchor; /// actual anchor/alignment, texts will be aligned according this (ALIGN_VCENTER, ALIGN_TOP ..) inline void PopProjectionMatrix(); inline void PushScreenCoordinateMatrix(); inline void AlignTextCoord(float & dx, float & dy, int width, int height); /// It applies alignement FontMan(); ~FontMan(); public : static const char ALIGN_VCENTER = 0x01; static const char ALIGN_TOP = 0x02; static const char ALIGN_BOTTOM = 0x04; static const char ALIGN_HCENTER = 0x08; static const char ALIGN_LEFT = 0x10; static const char ALIGN_RIGHT = 0x20; static FontMan * Inst(); /// returns pointer to singleton wchar_t * ToWChar(const char * text); /// converts string from const char * to wchar_t * void Print(const char * fontName, float x, float y, const char *fmt, ...); /// Its print font with name fontName on screen on coord. [x, y], fmt and ... is same as in function printf void MakeFont(const char * name, const char * src, unsigned int h); int GetTextWidth(const char * name, const wchar_t * text); int GetTextWidth(const char * name, string text) {return GetTextWidth(name, text.c_str());}; int GetTextWidth(const char * name, const char * text) {return GetTextWidth(name, ToWChar(text));} int GetFontHeight(const char * name) {return fontMap[name]->GetHeight();}; /// Returns height of font with name name void SetAnchor(const char align) {anchor = align;}; char GetAnchor() { return anchor; }; }; #endif
[ "beranlukas@gmail.com" ]
[ [ [ 1, 46 ] ] ]
7c6fd7fffa8785666354514220da70d9fceb0486
956e0201a3627226744a63075ea7b45dbf05208b
/GumShot/include/ThreadPool/ThreadPool.h
9210950aad9d5ab740c7fa1ee3d0309b11ae60ed
[]
no_license
bogba1/gumshot
acd0e0f6aab5f7f8898e65dbafd924c0f3aded43
d7f13866044f2d1a63566a3d3a5f9bae089ee746
refs/heads/master
2021-01-18T15:08:42.685134
2010-03-08T03:29:50
2010-03-08T03:29:50
40,660,288
0
0
null
null
null
null
UTF-8
C++
false
false
663
h
#pragma once #include "IThreadable.h" #include "SyncTools.h" #include <vector> typedef unsigned int uint; class ThreadPool { public: ThreadPool(uint poolSize = 10); ~ThreadPool(void); void submitTask(IThreadable* threadable); //enques task for execution (worker will be deleted after execution) private: IThreadable* getTask(); //waits for eventsignal, Locks queue, dequeues task, unlocks queue, returns task static unsigned int WINAPI threads_main(void* param); Mutex _queueLock; Semaphore _tasksAvailable; std::vector<IThreadable*> _taskQueue; std::vector<HANDLE> _threadHandles; };
[ "lilrobzn@gmail.com" ]
[ [ [ 1, 27 ] ] ]
de3b6569ec2ec66a6e77d2b11891e6274cf93e10
cfcd2a448c91b249ea61d0d0d747129900e9e97f
/thirdparty/OpenCOLLADA/COLLADAFramework/include/COLLADAFWTrifans.h
b5e33c24a4d923483bcae7bd9a2174aae6353109
[]
no_license
fire-archive/OgreCollada
b1686b1b84b512ffee65baddb290503fb1ebac9c
49114208f176eb695b525dca4f79fc0cfd40e9de
refs/heads/master
2020-04-10T10:04:15.187350
2009-05-31T15:33:15
2009-05-31T15:33:15
268,046
0
0
null
null
null
null
UTF-8
C++
false
false
1,298
h
/* Copyright (c) 2008 NetAllied Systems GmbH This file is part of COLLADAFramework. Licensed under the MIT Open Source License, for details please see LICENSE file or the website http://www.opensource.org/licenses/mit-license.php */ #ifndef __COLLADAFW_TRIFANS_H__ #define __COLLADAFW_TRIFANS_H__ #include "COLLADAFWPrerequisites.h" #include "COLLADAFWMeshPrimitiveWithFaceVertexCount.h" namespace COLLADAFW { /** TODO Documentation */ class Trifans : public MeshPrimitiveWithFaceVertexCount<unsigned int> { private: /** The number of trifans.*/ size_t mTrifanCount; public: /** Constructor. */ Trifans() : MeshPrimitiveWithFaceVertexCount<unsigned int>(TRIANGLE_FANS), mTrifanCount(0){} /** Destructor. */ virtual ~Trifans(){} /** Gets the number of trifans.*/ size_t getTrifanCount () const { return mTrifanCount; } /** Sets the number of trifans.*/ void setTrifanCount ( size_t count ) { mTrifanCount = count; } private: /** Disable default copy ctor. */ Trifans( const Trifans& pre ); /** Disable default assignment operator. */ const Trifans& operator= ( const Trifans& pre ); }; } // namespace COLLADAFW #endif // __COLLADAFW_TRIFANS_H__
[ "jiva@crazycoder.co.za" ]
[ [ [ 1, 56 ] ] ]
a317c8edb268c4d7d82470d7022abb1ec22c2c7b
ea12fed4c32e9c7992956419eb3e2bace91f063a
/zombie/code/zombie/nnavmesh/src/nnavmeshparser/nnavmeshfilereader.cc
bd7af28908c41ee71669a6e9614e482e4f087f77
[]
no_license
ugozapad/TheZombieEngine
832492930df28c28cd349673f79f3609b1fe7190
8e8c3e6225c2ed93e07287356def9fbdeacf3d6a
refs/heads/master
2020-04-30T11:35:36.258363
2011-02-24T14:18:43
2011-02-24T14:18:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,210
cc
#include "precompiled/pchnnavmesh.h" //------------------------------------------------------------------------------ // nnavmeshfilereader.cc // (C) 2005 Conjurer Services, S.A. //------------------------------------------------------------------------------ #include "nnavmeshparser/nnavmeshfilereader.h" #include "kernel/nfileserver2.h" #include "file/nrlefile.h" #include "util/nstring.h" #include "nnavmeshparser/navtag.h" //------------------------------------------------------------------------------ /** Constructor */ nNavMeshAscReader::nNavMeshAscReader() : file(NULL) { // Empty } //------------------------------------------------------------------------------ /** Destructor */ nNavMeshAscReader::~nNavMeshAscReader() { if ( this->file ) { this->file->Release(); } } //------------------------------------------------------------------------------ /** OpenFile */ bool nNavMeshAscReader::OpenFile(const char* filename) { n_assert(!this->file); n_assert(filename); this->file = nFileServer2::Instance()->NewFileObject(); n_assert(this->file); if ( this->file->Open(filename, "r") ) { return true; } else { n_printf( "nNavMeshAscReader::OpenFile(): failed to open file '%s' for reading!\n", filename ); this->file->Release(); this->file = NULL; return false; } } //------------------------------------------------------------------------------ /** CloseFile */ bool nNavMeshAscReader::CloseFile() { n_assert(this->file); this->file->Close(); this->file->Release(); return true; } //------------------------------------------------------------------------------ /** ParseBlockStart */ bool nNavMeshAscReader::ParseBlockStart(const NavTag& tag) { nString str; this->ReadWord(str); return str == tag.AsString() + ":"; } //------------------------------------------------------------------------------ /** ParseBlockEnd */ bool nNavMeshAscReader::ParseBlockEnd(const NavTag& /*tag*/) { return true; } //------------------------------------------------------------------------------ /** ParseLineBlockStart */ bool nNavMeshAscReader::ParseLineBlockStart(const NavTag& tag) { nString str; this->ReadWord(str); return str == tag.AsString(); } //------------------------------------------------------------------------------ /** ParseLineBlockEnd */ bool nNavMeshAscReader::ParseLineBlockEnd(const NavTag& /*tag*/) { return true; } //------------------------------------------------------------------------------ /** ParseFourCC */ bool nNavMeshAscReader::ParseFourCC() { nString str; if ( !this->ReadField(NavTag::FileFormatType, str) ) { return false; } return str == this->GetAsciiFourCC(); } //------------------------------------------------------------------------------ /** ParseInt32 */ bool nNavMeshAscReader::ParseInt32(const NavTag& tag, int& value) { nString str; if ( !this->ReadField(tag, str) ) { return false; } value = str.AsInt(); return true; } //------------------------------------------------------------------------------ /** ParseInt16 */ bool nNavMeshAscReader::ParseInt16(const NavTag& tag, int& value) { return this->ParseInt32(tag, value); } //------------------------------------------------------------------------------ /** ParseInt32InLineBlock */ bool nNavMeshAscReader::ParseInt16InLineBlock(int& value) { nString str; this->ReadWord(str); value = str.AsInt(); return true; } //------------------------------------------------------------------------------ /** ParseInt8 */ bool nNavMeshAscReader::ParseInt8(const NavTag& tag, int& value) { return this->ParseInt32(tag, value); } //------------------------------------------------------------------------------ /** ParseVector3 */ bool nNavMeshAscReader::ParseVector3(const NavTag& tag, vector3& value) { // Tag nString str; this->ReadWord(str); if ( str != tag.AsString() ) { return false; } // Values this->ReadWord(str); value.x = str.AsFloat(); this->ReadWord(str); value.y = str.AsFloat(); this->ReadWord(str); value.z = str.AsFloat(); return true; } //------------------------------------------------------------------------------ /** ReadWord */ void nNavMeshAscReader::ReadWord(nString& str) { n_assert(this->file); char word[1024]; int i = 0; for ( ; i < sizeof(word)-1 && !file->Eof(); ) { char c = file->GetChar(); if ( c > ' ' ) { // When found a non delimiter character append it to the word... word[i] = c; ++i; } else if ( i > 0 ) { // ...otherwise breaks the for statement to end the word... break; } // ...except when it hasn't been found any non delimiter character yet // (the word is empty). Then just skip the character. } word[i] = '\0'; str = word; } //------------------------------------------------------------------------------ /** ReadField */ bool nNavMeshAscReader::ReadField(const NavTag& tag, nString& str) { this->ReadWord(str); // Skip tag if ( str != tag.AsString() ) { return false; } this->ReadWord(str); // Get value return true; } //------------------------------------------------------------------------------ /** Constructor */ nNavMeshBinReader::nNavMeshBinReader() : file(NULL) { // Empty } //------------------------------------------------------------------------------ /** Destructor */ nNavMeshBinReader::~nNavMeshBinReader() { if ( this->file ) { this->file->Release(); } } //------------------------------------------------------------------------------ /** OpenFile */ bool nNavMeshBinReader::OpenFile(const char* filename) { n_assert(!this->file); n_assert(filename); this->file = nFileServer2::Instance()->NewFileObject(); n_assert(this->file); if ( this->file->Open(filename, "rb") ) { return true; } else { n_printf( "nNavMeshBinReader::OpenFile(): failed to open file '%s' for reading!\n", filename ); file->Release(); file = NULL; return false; } } //------------------------------------------------------------------------------ /** CloseFile */ bool nNavMeshBinReader::CloseFile() { n_assert(this->file); this->file->Close(); this->file->Release(); return true; } //------------------------------------------------------------------------------ /** ParseBlockStart */ bool nNavMeshBinReader::ParseBlockStart(const NavTag& /*tag*/) { return true; } //------------------------------------------------------------------------------ /** ParseBlockEnd */ bool nNavMeshBinReader::ParseBlockEnd(const NavTag& /*tag*/) { return true; } //------------------------------------------------------------------------------ /** ParseLineBlockStart */ bool nNavMeshBinReader::ParseLineBlockStart(const NavTag& /*tag*/) { return true; } //------------------------------------------------------------------------------ /** ParseLineBlockEnd */ bool nNavMeshBinReader::ParseLineBlockEnd(const NavTag& /*tag*/) { return true; } //------------------------------------------------------------------------------ /** ParseFourCC */ bool nNavMeshBinReader::ParseFourCC() { n_assert(this->file); return this->file->GetInt() == this->GetBinFourCC(); } //------------------------------------------------------------------------------ /** ParseInt32 */ bool nNavMeshBinReader::ParseInt32(const NavTag& /*tag*/, int& value) { n_assert(this->file); value = this->file->GetInt(); return true; } //------------------------------------------------------------------------------ /** ParseInt16 */ bool nNavMeshBinReader::ParseInt16(const NavTag& /*tag*/, int& value) { n_assert(this->file); value = this->file->GetUShort(); return true; } //------------------------------------------------------------------------------ /** ParseInt16InLineBlock */ bool nNavMeshBinReader::ParseInt16InLineBlock(int& value) { n_assert(this->file); value = this->file->GetUShort(); return true; } //------------------------------------------------------------------------------ /** ParseInt8 */ bool nNavMeshBinReader::ParseInt8(const NavTag& /*tag*/, int& value) { n_assert(this->file); value = this->file->GetChar(); return true; } //------------------------------------------------------------------------------ /** ParseVector3 */ bool nNavMeshBinReader::ParseVector3(const NavTag& /*tag*/, vector3& value) { n_assert(this->file); value.x = this->file->GetFloat(); value.y = this->file->GetFloat(); value.z = this->file->GetFloat(); return true; } //------------------------------------------------------------------------------ /** OpenFile */ bool nNavMeshRleReader::OpenFile(const char* filename) { n_assert(!this->file); n_assert(filename); this->file = n_new( nRleFile ); n_assert(this->file); if ( this->file->Open(filename, "rb") ) { return true; } else { n_printf( "nNavMeshRleReader::OpenFile(): failed to open file '%s' for reading!\n", filename ); file->Release(); file = NULL; return false; } } //------------------------------------------------------------------------------ // EOF //------------------------------------------------------------------------------
[ "magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91" ]
[ [ [ 1, 464 ] ] ]
aa0c6155c2fc900ea733ac6973abe1b2b8c91493
f304b2f54319a444f8798bca884139b785c63026
/trunk/type_system_pp.hpp
b5764c8f578711ae8924cde2413b942278524f2c
[]
no_license
BackupTheBerlios/zcplusplus-svn
4387877a71405be331e78bec6d792da5f8fe6737
ef85b9e4a78a52618014f501c9c1400c9d4f4a42
refs/heads/master
2016-08-05T18:34:41.051270
2011-10-08T10:15:31
2011-10-08T10:15:31
40,805,219
0
0
null
null
null
null
UTF-8
C++
false
false
1,129
hpp
// type_system_pp.hpp // (C)2009,2010 Kenneth Boyd, license: MIT.txt #ifndef TYPE_SYSTEM_HPP #define TYPE_SYSTEM_HPP 1 #include "Zaimoni.STL/POD.hpp" #include "Zaimoni.STL/Logging.h" class type_system { public: typedef size_t type_index; const zaimoni::POD_pair<const char* const,size_t>* const core_types; const type_index* const int_priority; const size_t core_types_size; const size_t int_priority_size; private: // uncopyable type_system(const type_system& src); void operator=(const type_system& src); public: type_system(const zaimoni::POD_pair<const char* const,size_t>* _core_types,size_t _core_types_size,const type_index* _int_priority,size_t _int_priority_size) : core_types((assert(_core_types),_core_types)), int_priority((assert(_int_priority),_int_priority)), core_types_size((assert(0<_core_types_size),_core_types_size)), int_priority_size((assert(0<_int_priority_size),_int_priority_size)) {}; const char* name(type_index id) const { assert(core_types_size>=id); return _name(id); } private: const char* _name(type_index id) const; }; #endif
[ "zaimoni@b4372a03-5d62-0410-814a-8f46757a0b64" ]
[ [ [ 1, 38 ] ] ]
8bcda9a0071d64f57cc72c3aaf6b78294613159b
b90f7dce513fd3d13bab0b8769960dea901d4f3b
/game_client/game_client/opencontainers/ocval.cc
712b6631cb55e1f534cfb3a149a276c125daa96d
[]
no_license
lasti15/easygametools
f447052cd4c42609955abd76b4c8571422816b11
0b819c957077a4eeaf9a2492772040dafdfca4c3
refs/heads/master
2021-01-10T09:14:52.182154
2011-03-09T01:51:51
2011-03-09T01:51:51
55,684,684
0
0
null
null
null
null
UTF-8
C++
false
false
34,736
cc
#if defined(OC_FACTOR_INTO_H_AND_CC) # include "ocval.h" // Explicit instantiations #define OC_INST_PRINT(T) template ostream& PrintArray<T>(ostream&, const OCArray<T>& a); OC_INST_PRINT(int_1) OC_INST_PRINT(int_u1) OC_INST_PRINT(int_2) OC_INST_PRINT(int_u2) OC_INST_PRINT(int_4) OC_INST_PRINT(int_u4) OC_INST_PRINT(int_8) OC_INST_PRINT(int_u8) OC_INST_PRINT(real_4) OC_INST_PRINT(real_8) OC_INST_PRINT(complex_8) OC_INST_PRINT(complex_16) OC_INST_PRINT(bool) OC_INST_PRINT(Str) OC_INST_PRINT(Tab) #define OC_INST_VAL(T) template Val::Val (const OCArray<T>&); OC_INST_VAL(int_1) OC_INST_VAL(int_u1) OC_INST_VAL(int_2) OC_INST_VAL(int_u2) OC_INST_VAL(int_4) OC_INST_VAL(int_u4) OC_INST_VAL(int_8) OC_INST_VAL(int_u8) OC_INST_VAL(real_4) OC_INST_VAL(real_8) OC_INST_VAL(complex_8) OC_INST_VAL(complex_16) OC_INST_VAL(bool) OC_INST_VAL(Str) OC_INST_VAL(Tab) OC_INST_VAL(Val) #endif /////////////////////////////////////////////////////////////////////////// // Most of the useful interface is in the .h file, below be // implementation. If you are worried about code bloat, #define // OC_FACTOR_INTO_H_AND_CC and you can compile this .cc into an object // file. Otherwise, this .cc file is just "included" and handled as // if it were inlined code. // Discussion: if you look at the implementation of Val, you may notice // that I explicitly break rules [9] from Exceptional C++. For // scalability and performance, two of the fundamental rules of Midas // 2k were "stay out of the heap" and "use a lookaside cache for // locality". So, you'll notice that the Str and Tab are constructed // in-place in the 32 bytes of the Val. This keeps most small Strs // from going to the Heap, it makes one less call to the heap for // Tabs, and keeps all numeric types in 32 bytes of val so they don't // go the heap at all! Herb complains that this is a bad idea, but // (a) it works on 3 different platforms (b) I am using it with a // real_8 in a union so the alignments are not problematic (c) there // are no polymorphic types, so shouldn't be object slicing (d) it's // great for performance: stay in a lookaside cache for scalability, // locality. And honestly, the code isn't that bad. I break the rule // on purpose, for performance and scalabilty. OC_INLINE int_u4 HashFunction (const Val& v) { int_u4 retval; if (v.tag=='a') { Str* sp = (Str*)v.u.a; retval = HashFunction(*sp); } else { retval = v; } return retval; } OC_INLINE bool operator== (const Val& v1, const Val& v2); OC_INLINE bool operator!= (const Val& v1, const Val& v2) { return !(v1==v2); } OC_INLINE bool operator< (const Val& v1, const Val& v2); OC_INLINE bool operator<= (const Val&v1, const Val&v2) { return (v1==v2)||(v1<v2); } OC_INLINE bool operator> (const Val& v1, const Val& v2) { return !(v1<=v2); } OC_INLINE bool operator>= (const Val&v1, const Val& v2) { return !(v1<v2); } // Output: Note that default constructed ('Z') comes out as "None". OC_INLINE ostream& operator<< (ostream& os, const Val& v); OC_INLINE ostream& operator<< (ostream& os, const Tab& v); //template <class T> //OC_INLINE ostream& operator<< (ostream& os, const Array<T>& a); template <> OC_INLINE ostream& operator<< <Val>(ostream& os, const OCArray<Val>& a); OC_INLINE size_t Tab::total_elements () const { size_t surface_entries = 0; for (It ii(*this); ii(); ) { Val& val(ii.value()); if (val.tag=='t') { Tab& t = val; // Tab converts out as a reference, so no copying // +1 if we want to include this entry in the count surface_entries += t.total_elements() + 1; } else { surface_entries++; } } return surface_entries; } OC_INLINE void Val::test () { // Make sure Tab can fit into union if (sizeof(Tab)>VALTAB) { Val sz = int_u4(sizeof(Tab)); Str mesg="Tab is too big to fit in the union: VALTAB should be:"+Str(sz); cerr << mesg << endl; throw logic_error(mesg.c_str()); } // Make Strs can fit in union if (sizeof(Str)>VALSTR) { Val sz = int_u4(sizeof(Str)); Str mesg="Tab is too big to fit in the union: VALSTR should be:"+Str(sz); cerr << mesg << endl; throw logic_error(mesg.c_str()); } // Make Arrs can fit in union if (sizeof(OCArray<Val>)>VALARR) { Val sz = int_u4(sizeof(Arr)); Str mesg="Arr is too big to fit in the union: VALSTR should be:"+Str(sz); cerr << mesg << endl; throw logic_error(mesg.c_str()); } } // For unknown types, throw same exception OC_INLINE void unknownType_ (const char* routine, char tag) { char name[2]; name[0] = tag; name[1] = '\0'; Str mesg = "Unknown type:"+ Str(name)+ " in routine:" + Str(routine); throw logic_error(mesg.c_str()); } OC_INLINE Val::Val (const Tab& t) : tag('t') { new (&u.t) Tab(t); } template <class T> OC_INLINE Val::Val (const OCArray<T>& a) : tag('n') { Val tmp = T(); // construct a temporary "unused" of this type to get subtype subtype = tmp.tag; if (subtype=='n') { throw logic_error("Arrays of Arrays not currently supported"); } new (&u.n) OCArray<T>(a); } #define VALDESTR(T) { OCArray<T>*ap=(OCArray<T>*)&u.n;ap->~OCArray<T>(); } OC_INLINE Val::~Val () { switch(tag) { case 'a': { Str* sp = (Str*)&u.a; sp->~Str(); break; } case 't': { Tab* tp = (Tab*)&u.t; tp->~Tab(); break; } case 'n': { switch(subtype) { case 's': VALDESTR(int_1); break; case 'S': VALDESTR(int_u1); break; case 'i': VALDESTR(int_2); break; case 'I': VALDESTR(int_u2); break; case 'l': VALDESTR(int_4); break; case 'L': VALDESTR(int_u4); break; case 'x': VALDESTR(int_8); break; case 'X': VALDESTR(int_u8); break; case 'b': VALDESTR(bool); break; case 'f': VALDESTR(real_4); break; case 'd': VALDESTR(real_8); break; case 'F': VALDESTR(complex_8); break; case 'D': VALDESTR(complex_16); break; case 'a': VALDESTR(Str); break; case 't': VALDESTR(Tab); break; case 'n': throw logic_error("Arrays of Arrays not currently supported"); case 'Z': VALDESTR(Val); break; default: unknownType_("destructor", subtype); } } } } #define VALCOPYCONS(T) {subtype=r.subtype;OCArray<T>*ap=(OCArray<T>*)&r.u.n;new(&u.n)OCArray<T>(*ap);} OC_INLINE Val::Val (const Val& r) : tag(r.tag) { // Copy constructor: Have to write because of Str and table cases. // Although we could copy in less code, we want to be purify clean // (for now). switch(tag) { case 's': u.s = r.u.s; break; case 'S': u.S = r.u.S; break; case 'i': u.i = r.u.i; break; case 'I': u.I = r.u.I; break; case 'l': u.l = r.u.l; break; case 'L': u.L = r.u.L; break; case 'x': u.x = r.u.x; break; case 'X': u.X = r.u.X; break; case 'b': u.b = r.u.b; break; case 'f': u.f = r.u.f; break; case 'd': u.d = r.u.d; break; case 'F': u.F = r.u.F; break; case 'D': u.D = r.u.D; break; case 'a': { Str* sp=(Str*)&r.u.a; new (&u.a) Str(*sp); break; } case 't': { Tab* tp=(Tab*)&r.u.t; new (&u.t) Tab(*tp); break; } case 'n': { switch(r.subtype) { case 's': VALCOPYCONS(int_1); break; case 'S': VALCOPYCONS(int_u1); break; case 'i': VALCOPYCONS(int_2); break; case 'I': VALCOPYCONS(int_u2); break; case 'l': VALCOPYCONS(int_4); break; case 'L': VALCOPYCONS(int_u4); break; case 'x': VALCOPYCONS(int_8); break; case 'X': VALCOPYCONS(int_u8); break; case 'b': VALCOPYCONS(bool); break; case 'f': VALCOPYCONS(real_4); break; case 'd': VALCOPYCONS(real_8); break; case 'F': VALCOPYCONS(complex_8); break; case 'D': VALCOPYCONS(complex_16); break; case 'a': VALCOPYCONS(Str); break; case 't': VALCOPYCONS(Tab); break; case 'n': throw logic_error("Arrays of Arrays not currently supported"); case 'Z': VALCOPYCONS(Val); break; default: unknownType_("copy constructor", subtype); } } case 'Z': break; // stay uninitialized default: unknownType_("copy constructor", tag); } } // For all the "convert out" operations: Since they are so similar, // use macros to generate the code to avoid multiple maintenance. // Code block to get the proper union member and cast it out correctly #define VALSWITCHME(T,M) switch(tag) { case's':return T(u.s);\ case'S':return T(u.S);case'i':return T(u.i);case'I':return T(u.I);\ case'l':return T(u.l);case'L':return T(u.L);case'x':return T(u.x);case'X':return T(u.X);\ case 'b':return T(u.b); case'f':return T(u.f);case'd':return T(u.d); case'F':return T(M(u.F)); case'D':return T(M(u.D));} #define VALSWITCHME2(T) switch(tag) { case's':return T(u.s);\ case'S':return T(u.S);case'i':return T(u.i);case'I':return T(u.I);\ case'l':return T(u.l);case'L':return T(u.L);case'x':return T(u.x);case'X':return T(u.X);\ case 'b':return T(u.b); case'f':return T(u.f);case'd':return T(u.d); case'F':return T(u.F.re, u.F.im); case'D':return T(u.D.re, u.D.im);} // Function tempplate for convert outs for the numeric types #define CREATEVALOPBODY(T) \ { if (tag=='a') { Str* sp=(Str*)&u.a;T tmp=0;istrstream is(sp->c_str());is.precision(15);is>>tmp;return tmp;} \ else if (tag=='t'){Tab*tp=(Tab*)&u.t;return T(tp->entries());} else if (tag=='n'){Arr*np=(Arr*)&u.n;return T(np->length());} return T(0);} #define CREATEVALOP(T) \ OC_INLINE Val::operator T () const { VALSWITCHME(T,mag2); CREATEVALOPBODY(T) } #define CREATEVALOP2(T) \ OC_INLINE Val::operator T () const { VALSWITCHME2(T); CREATEVALOPBODY(T) } // CREATEVALOP(int_1) op>> doesn't seem to work for this? OC_INLINE Val::operator int_1 () const { VALSWITCHME(int_1,mag2); CREATEVALOPBODY(int_u1); // Same bits of int_u1 and int_1 } CREATEVALOP(int_u1) CREATEVALOP(int_2) CREATEVALOP(int_u2) CREATEVALOP(int_4) CREATEVALOP(int_u4) CREATEVALOP(int_8) CREATEVALOP(int_u8) CREATEVALOP(bool) CREATEVALOP(real_4) CREATEVALOP(real_8) CREATEVALOP2(complex_8) CREATEVALOP2(complex_16) OC_INLINE Val::operator Str () const { if (tag=='a') { Str* sp = (Str*)&u.a; return *sp; } else { return Stringize(*this); } } OC_INLINE Val::operator Tab& () const { if (tag!='t') { char s[2]; s[0] = tag; s[1] = '\0'; Str mesg = "No conversion from:"+Str(*this)+" to table."; throw logic_error(mesg.c_str()); } Tab* t= (Tab*)&u.t; return *t; } OC_INLINE Val::operator Arr& () const { if (tag!='n' && subtype!='Z') { char s[2]; s[0] = tag; s[1] = '\0'; Str mesg = "No conversion from:"+Str(*this)+" to table."; throw logic_error(mesg.c_str()); } Arr* t= (Arr*)&u.n; return *t; } // You might wonder why we instatioate so many copies rather than // having operator[](const Val& v). Because this way we can pay most // cost at compile time ... otherwise, we'd have to do it at runtime // and slow us down a little more (not much, but every little bit // helps). template <class LOOKUP> Val& ValLookUpBody_ (const Val& v, LOOKUP ii) { if (v.tag=='n') { if (v.subtype=='Z') { // For Array<Val>, we can return a reference OCArray<Val>& a = v; return a[ii]; } // ... but for Arrays of other types, can't return a reference: // Force someone to get a contig array, thus force an exception throw logic_error("Only Array<Val> can subscript, Array<T> cannot"); } else { // Note that this will throw an exception if v is NOT a Tab Tab& t = v; return t[ii]; } } #if defined(OC_FACTOR_INTO_H_AND_CC) // Explicit instantiation #define OC_INST_VALLOOKUP(T) template Val& ValLookUpBody_<T>(const Val&, T); OC_INST_VALLOOKUP(int_1) OC_INST_VALLOOKUP(int_u1) OC_INST_VALLOOKUP(int_2) OC_INST_VALLOOKUP(int_u2) OC_INST_VALLOOKUP(int_4) OC_INST_VALLOOKUP(int_u4) OC_INST_VALLOOKUP(int_8) OC_INST_VALLOOKUP(int_u8) OC_INST_VALLOOKUP(bool) #endif // Tab and Arr lookups OC_INLINE Val& Val::operator[] (int_1 ii) { return ValLookUpBody_(*this,ii);} OC_INLINE Val& Val::operator[] (int_u1 ii) { return ValLookUpBody_(*this,ii);} OC_INLINE Val& Val::operator[] (int_2 ii) { return ValLookUpBody_(*this,ii);} OC_INLINE Val& Val::operator[] (int_u2 ii) { return ValLookUpBody_(*this,ii);} OC_INLINE Val& Val::operator[] (int_4 ii) { return ValLookUpBody_(*this,ii);} OC_INLINE Val& Val::operator[] (int_u4 ii) { return ValLookUpBody_(*this,ii);} OC_INLINE Val& Val::operator[] (int_8 ii) { return ValLookUpBody_(*this,ii);} OC_INLINE Val& Val::operator[] (int_u8 ii) { return ValLookUpBody_(*this,ii);} OC_INLINE Val& Val::operator[] (bool ii) { return ValLookUpBody_(*this,ii);} // Tab only lookups OC_INLINE Val& Val::operator[] (real_4 v) { Tab& t = *this; return t[v]; } OC_INLINE Val& Val::operator[] (real_8 v) { Tab& t = *this; return t[v]; } //OC_INLINE Val& Val::operator[] (complex_8 v) { Tab& t=*this; return t[v]; } //OC_INLINE Val& Val::operator[] (complex_16 v) { Tab& t=*this; return t[v]; } OC_INLINE Val& Val::operator[] (const char* cc) { Tab& t=*this;return t[cc]; } OC_INLINE Val& Val::operator[] (const Str& s) { Tab& t=*this;return t[s]; } template <class LOOKUP> Val& ValLookUpBodyThrow_ (const Val& v, LOOKUP ii) { if (v.tag=='n') { if (v.subtype=='Z') { // For Array<Val>, we can return a reference OCArray<Val>& a = v; return a[ii]; // Possibly should use (), but makes more sense to use the version that throws an exception if there's a problem } // ... but for Arrays of other types, can't return a reference: // Force someone to get a contig array, thus force an exception throw logic_error("Only Array<Val> can subscript, Array<T> cannot"); } else { // Note that this will throw an exception if v is NOT a Tab Tab& t = v; return t(ii); } } #if defined(OC_FACTOR_INTO_H_AND_CC) // Explicit instantiation #define OC_INST_VALLOOKUP_THROW(T) template Val& ValLookUpBodyThrow_<T>(const Val&, T); OC_INST_VALLOOKUP_THROW(int_1) OC_INST_VALLOOKUP_THROW(int_u1) OC_INST_VALLOOKUP_THROW(int_2) OC_INST_VALLOOKUP_THROW(int_u2) OC_INST_VALLOOKUP_THROW(int_4) OC_INST_VALLOOKUP_THROW(int_u4) OC_INST_VALLOOKUP_THROW(int_8) OC_INST_VALLOOKUP_THROW(int_u8) OC_INST_VALLOOKUP_THROW(bool) #endif // Tab and Arr lookups OC_INLINE Val& Val::operator() (int_1 ii) { return ValLookUpBodyThrow_(*this,ii);} OC_INLINE Val& Val::operator() (int_u1 ii) { return ValLookUpBodyThrow_(*this,ii);} OC_INLINE Val& Val::operator() (int_2 ii) { return ValLookUpBodyThrow_(*this,ii);} OC_INLINE Val& Val::operator() (int_u2 ii) { return ValLookUpBodyThrow_(*this,ii);} OC_INLINE Val& Val::operator() (int_4 ii) { return ValLookUpBodyThrow_(*this,ii);} OC_INLINE Val& Val::operator() (int_u4 ii) { return ValLookUpBodyThrow_(*this,ii);} OC_INLINE Val& Val::operator() (int_8 ii) { return ValLookUpBodyThrow_(*this,ii);} OC_INLINE Val& Val::operator() (int_u8 ii) { return ValLookUpBodyThrow_(*this,ii);} OC_INLINE Val& Val::operator() (bool ii) { return ValLookUpBodyThrow_(*this,ii);} // Tab only lookups OC_INLINE Val& Val::operator() (real_4 v) { Tab& t = *this; return t(v); } OC_INLINE Val& Val::operator() (real_8 v) { Tab& t = *this; return t(v); } //OC_INLINE Val& Val::operator() (complex_8 v) { Tab& t=*this; return t(v); } //OC_INLINE Val& Val::operator() (complex_16 v) { Tab& t=*this; return t(v); } OC_INLINE Val& Val::operator() (const char* cc) { Tab& t=*this;return t(cc); } OC_INLINE Val& Val::operator() (const Str& s) { Tab& t=*this;return t(s); } #define OC_IS_CX(v) ((((v.tag) ^ 0x40)>>3)==0) // FD #define OC_IS_REAL(v) ((((v.tag) ^ 0x60)& 0xfc)==0x04) //'fd' static char is_int_type[16] = { 0,0,1,0,0,0,0,0,1,1,0,0,0,1,0,0 }; #define OC_TAG_SOME_INT(tag) is_int_type[(((tag)>>6)^(tag))&0x0f] // silxSILX #define OC_IS_INT(v) (OC_TAG_SOME_INT(v.tag)&((v.tag)>0x60)) // silx #define OC_IS_UINT(v) (OC_TAG_SOME_INT(v.tag)&((v.tag)<0x60)) // SILX #define OC_IS_NUMERIC(v) !(v.tag=='a' | v.tag=='t'| v.tag=='n') #define ARRAYEQUALITY(T) { OCArray<T>*vp1,*vp2;vp1=(OCArray<T>*)&v1.u.n;vp2=(OCArray<T>*)&v2.u.n; return *vp1==*vp2; } OC_INLINE bool same_type_equal (const Val& v1, const Val& v2) { if (v1.tag != v2.tag) return false; switch (v1.tag) { case 's': return v1.u.s==v2.u.s; case 'S': return v1.u.S==v2.u.S; case 'i': return v1.u.i==v2.u.i; case 'I': return v1.u.I==v2.u.I; case 'l': return v1.u.l==v2.u.l; case 'L': return v1.u.L==v2.u.L; case 'x': return v1.u.x==v2.u.x; case 'X': return v1.u.X==v2.u.X; case 'b': return v1.u.b==v2.u.b; case 'f': return v1.u.f==v2.u.f; case 'd': return v1.u.d==v2.u.d; case 'F': return v1.u.F==v2.u.F; case 'D': return v1.u.D==v2.u.D; case 'a': { Str* s1=(Str*)&v1.u.a; Str* s2=(Str*)&v2.u.a; return *s1==*s2; } case 't': { Tab* t1=(Tab*)&v1.u.t; Tab* t2=(Tab*)&v2.u.t; return *t1==*t2; } case 'n': { // Two arrays of different types always have to compare (< and ==) // as strings so they are totally-ordered. if (v1.subtype != v2.subtype) return Str(v1)==Str(v2); // false; switch(v1.subtype) { case 's': ARRAYEQUALITY(int_1); case 'S': ARRAYEQUALITY(int_u1); case 'i': ARRAYEQUALITY(int_2); case 'I': ARRAYEQUALITY(int_u2); case 'l': ARRAYEQUALITY(int_4); case 'L': ARRAYEQUALITY(int_u4); case 'x': ARRAYEQUALITY(int_8); case 'X': ARRAYEQUALITY(int_u8); case 'b': ARRAYEQUALITY(bool); case 'f': ARRAYEQUALITY(real_4); case 'd': ARRAYEQUALITY(real_8); case 'F': ARRAYEQUALITY(complex_8); case 'D': ARRAYEQUALITY(complex_16); case 'a': ARRAYEQUALITY(Str); case 't': ARRAYEQUALITY(Tab); case 'n': throw logic_error("Arrays of Arrays not currently supported"); case 'Z': ARRAYEQUALITY(Val); default: unknownType_("operator==", v1.subtype); } } case 'Z': return true; default: unknownType_("operator==", v1.tag); } return false; } OC_INLINE bool operator== (const Val& v1, const Val& v2) { if (v1.tag==v2.tag) return same_type_equal(v1,v2); // If they are both Numeric types, and they are equal when cast up // to a bigger type, then they are equal. If they are different // types and NOT Numeric types, they are not equal. Note that two // arrays of different types will NOT be equal BUT two arrays of // Vals can be equal if their Numeric types are the same. BTW, this // is basically how Python works: we are doing what they do. if (OC_IS_INT(v1)) { // int types if (OC_IS_INT(v2)) { return int_8(v1)==int_8(v2); } else if (OC_IS_UINT(v2)) { return int_8(v1)==int_8(v2); } else if (OC_IS_REAL(v2)) { return real_8(v1)==real_8(v2); } else if (OC_IS_CX(v2)) { complex_16 t1=v1; complex_16 t2=v2; return t1==t2; } else if (v2.tag=='b') { return int_8(v1)==int_8(v2); } else { return false; } } else if (OC_IS_UINT(v1)) { // unsigned int types if (OC_IS_INT(v2)) { return int_8(v1)==int_8(v2); } else if (OC_IS_UINT(v2)) { return int_u8(v1)==int_u8(v2); } else if (OC_IS_REAL(v2)) { return real_8(v1)==real_8(v2); } else if (OC_IS_CX(v2)) { complex_16 t1=v1; complex_16 t2=v2; return t1==t2; } else if (v2.tag=='b') { return int_u8(v1)==int_u8(v2); } else { return false; } } else if (OC_IS_REAL(v1)) { // real types if (OC_IS_INT(v2)) { return real_8(v1)==real_8(v2); } else if (OC_IS_UINT(v2)) { return real_8(v1)==real_8(v2); } else if (OC_IS_REAL(v2)) { return real_8(v1)==real_8(v2); } else if (OC_IS_CX(v2)) { complex_16 t1=v1; complex_16 t2=v2; return t1==t2; } else if (v2.tag=='b') { return int_8(v1)==int_8(v2); } else { return false; } } else if (OC_IS_CX(v1)) { // cx types if (OC_IS_INT(v2)) { complex_16 t1=v1; complex_16 t2=v2; return t1==t2; } else if (OC_IS_UINT(v2)) { complex_16 t1=v1; complex_16 t2=v2; return t1==t2; } else if (OC_IS_REAL(v2)) { complex_16 t1=v1; complex_16 t2=v2; return t1==t2; } else if (OC_IS_CX(v2)) { complex_16 t1=v1; complex_16 t2=v2; return t1==t2; } else if (v2.tag=='b') { complex_16 t1=v1; complex_16 t2=v2; return t1==t2; } else { return false; } } else if (v1.tag=='b') { // bool types if (OC_IS_INT(v2)) { return bool(v1)==bool(v2); } else if (OC_IS_UINT(v2)) { return bool(v1)==bool(v2); } else if (OC_IS_REAL(v2)) { return bool(v1)==bool(v2); } else if (OC_IS_CX(v2)) { return bool(v1)==bool(v2); } else if (v2.tag=='b') { return bool(v1)==bool(v2); } else { return false; } } else { return false; } } #define ARRAYLESSTHAN(T) { OCArray<T>*vp1,*vp2;vp1=(OCArray<T>*)&v1.u.n;vp2=(OCArray<T>*)&v2.u.n; return *vp1<*vp2; } OC_INLINE bool same_type_lt (const Val& v1, const Val& v2) { if (v1.tag != v2.tag) return Str(v1)<Str(v2); // false; switch (v1.tag) { case 's': return v1.u.s<v2.u.s; case 'S': return v1.u.S<v2.u.S; case 'i': return v1.u.i<v2.u.i; case 'I': return v1.u.I<v2.u.I; case 'l': return v1.u.l<v2.u.l; case 'L': return v1.u.L<v2.u.L; case 'x': return v1.u.x<v2.u.x; case 'X': return v1.u.X<v2.u.X; case 'b': return v1.u.b<v2.u.b; case 'f': return v1.u.f<v2.u.f; case 'd': return v1.u.d<v2.u.d; case 'F': return complex_8(v1.u.F.re,v1.u.F.im) < complex_8(v2.u.F.re,v2.u.F.im); case 'D': return complex_16(v1.u.D.re,v1.u.D.im) < complex_16(v2.u.D.re,v2.u.D.im); case 'a': { Str* s1=(Str*)&v1.u.a; Str* s2=(Str*)&v2.u.a; return *s1<*s2; } case 't': { Tab* t1=(Tab*)&v1.u.t; Tab* t2=(Tab*)&v2.u.t; return *t1<*t2; } case 'n': { if (v1.subtype != v2.subtype) return Str(v1)<Str(v2); // false; switch(v1.subtype) { case 's': ARRAYLESSTHAN(int_1); case 'S': ARRAYLESSTHAN(int_u1); case 'i': ARRAYLESSTHAN(int_2); case 'I': ARRAYLESSTHAN(int_u2); case 'l': ARRAYLESSTHAN(int_4); case 'L': ARRAYLESSTHAN(int_u4); case 'x': ARRAYLESSTHAN(int_8); case 'X': ARRAYLESSTHAN(int_u8); case 'b': ARRAYLESSTHAN(bool); case 'f': ARRAYLESSTHAN(real_4); case 'd': ARRAYLESSTHAN(real_8); case 'F': ARRAYLESSTHAN(complex_8); case 'D': ARRAYLESSTHAN(complex_16); case 'a': ARRAYLESSTHAN(Str); case 't': ARRAYLESSTHAN(Tab); case 'n': throw logic_error("Arrays of Arrays not currently supported"); case 'Z': ARRAYLESSTHAN(Val); default: unknownType_("operator<", v1.subtype); } } case 'Z': return false; default: unknownType_("operator<", v1.tag); } return false; } OC_INLINE bool operator< (const Val& v1, const Val& v2) { if (v1.tag == v2.tag) return same_type_lt(v1,v2); else if (v1.tag == 'Z') return true; else if (v2.tag == 'Z') // None is less than everything return false; // Numeric types are always less than string types, which is what // things get converted to if they have no obvious comparison. // This seems to be what Python does. if (OC_IS_INT(v1)) { // int types if (OC_IS_INT(v2)) { return int_8(v1)<int_8(v2); } else if (OC_IS_UINT(v2)) { return int_8(v1)<int_8(v2); } else if (OC_IS_REAL(v2)) { return real_8(v1)<real_8(v2); } else if (OC_IS_CX(v2)) { complex_16 t1=v1; complex_16 t2=v2; return t1<t2; } else if (v2.tag=='b') { return int_8(v1)<int_8(v2); } else { return true; } } else if (OC_IS_UINT(v1)) { // unsigned int types if (OC_IS_INT(v2)) { return int_8(v1)<int_8(v2); } else if (OC_IS_UINT(v2)) { return int_u8(v1)<int_u8(v2); } else if (OC_IS_REAL(v2)) { return real_8(v1)<real_8(v2); } else if (OC_IS_CX(v2)) { complex_16 t1=v1; complex_16 t2=v2; return t1<t2; } else if (v2.tag=='b') { return int_u8(v1)<int_u8(v2); } else { return true; } } else if (OC_IS_REAL(v1)) { // real types if (OC_IS_INT(v2)) { return real_8(v1)<real_8(v2); } else if (OC_IS_UINT(v2)) { return real_8(v1)<real_8(v2); } else if (OC_IS_REAL(v2)) { return real_8(v1)<real_8(v2); } else if (OC_IS_CX(v2)) { complex_16 t1=v1; complex_16 t2=v2; return t1<t2; } else if (v2.tag=='b') { return real_8(v1)<real_8(v2); } else { return true; } } else if (OC_IS_CX(v1)) { // cx types if (OC_IS_INT(v2)) { complex_16 t1=v1; complex_16 t2=v2; return t1<t2; } else if (OC_IS_UINT(v2)) { complex_16 t1=v1; complex_16 t2=v2; return t1<t2; } else if (OC_IS_REAL(v2)) { complex_16 t1=v1; complex_16 t2=v2; return t1<t2; } else if (OC_IS_CX(v2)) { complex_16 t1=v1; complex_16 t2=v2; return t1<t2; } else if (v2.tag=='b') { complex_16 t1=v1; complex_16 t2=v2; return t1<t2; } else { return true; } } else if (v1.tag == 'b') { // bool if (OC_IS_INT(v2)) { return bool(v1)<bool(v2); } else if (OC_IS_UINT(v2)) { return bool(v1)<bool(v2); } else if (OC_IS_REAL(v2)) { return bool(v1)<bool(v2); } else if (OC_IS_CX(v2)) { return bool(v1)<bool(v2); } else if (v2.tag=='b') { return bool(v1)<bool(v2); } else { return true; } } else if (OC_IS_NUMERIC(v2)) { return false; // Numeric types always less-than string types } else { return Str(v1)<Str(v2); // Compare as string types if no obvious compare } } #include "ocstringtools.h" // Make Array<T> look like Python Numeric arrays template <class T> OC_INLINE ostream& PrintArray (ostream& os, const OCArray<T>& a) { const int len = a.length(); os << "array(["; for (int ii=0; ii<len-1; ++ii) { os << Val(a[ii]) << " "; } if (len) os << Val(a[len-1]); return os << "])"; } // Specialization for Array<Val>: Make them look like pythons lists template <> OC_INLINE ostream& PrintArray <Val> (ostream& os, const OCArray<Val>& a) { const int len = a.length(); os << "["; for (int ii=0; ii<len-1; ii++) { os << a[ii] << ", "; } if (len) { os << a[len-1]; } return os << "]"; } // Specialization for Array<Val>: Make them look like pythons lists template <> OC_INLINE ostream& operator<< <Val> (ostream& os, const OCArray<Val>& a) { return PrintArray(os,a); } // Make this look similar to python #define PRINTARRAY(T) {OCArray<T>*ap=(OCArray<T>*)&v.u.n; return PrintArray(os, *ap);} OC_INLINE ostream& operator<< (ostream& os, const Val& v) { switch(v.tag) { case 's': os << int_4(v.u.s); break; // because python doesn't have char case 'S': os << int_u4(v.u.S); break; // because python doesn't have char case 'i': os << v.u.i; break; case 'I': os << v.u.I; break; case 'l': os << v.u.l; break; case 'L': os << v.u.L; break; case 'x': os << v.u.x; break; case 'X': os << v.u.X; break; case 'b': { Str res = "False"; if (v.u.b) res="True"; os << res; break; } case 'f': os.precision(7); os << v.u.f; break; case 'd': os.precision(15); os << v.u.d; break; #if defined(OC_SUPPORT_XM) case 'F': os.precision(7); os<<"("<<v.u.F.re<<((v.u.F.im<0)?"":"+")<<v.u.F.im<<"j)"; break; case 'D': os.precision(15); os<<"("<<v.u.D.re<<((v.u.D.im<0)?"":"+")<<v.u.D.im<<"j)"; break; #else case 'F': os << complex_8(v.u.F.re, v.u.F.im); break; case 'D': os << complex_16(v.u.D.re, v.u.D.im); break; #endif case 'a': { Str *s = (Str*)&v.u.a; os << Image(*s, true); break; } case 't': { Tab *t = (Tab*)&v.u.t; os << *t; break; } case 'n': { switch(v.subtype) { case 's': PRINTARRAY(int_1); case 'S': PRINTARRAY(int_u1); case 'i': PRINTARRAY(int_2); case 'I': PRINTARRAY(int_u2); case 'l': PRINTARRAY(int_4); case 'L': PRINTARRAY(int_u4); case 'x': PRINTARRAY(int_8); case 'X': PRINTARRAY(int_u8); case 'b': PRINTARRAY(bool); case 'f': PRINTARRAY(real_4); case 'd': PRINTARRAY(real_8); case 'F': PRINTARRAY(complex_8); case 'D': PRINTARRAY(complex_16); case 'a': PRINTARRAY(Str); case 't': PRINTARRAY(Tab); case 'n': throw logic_error("Arrays of Arrays not currently supported"); case 'Z': PRINTARRAY(Val); default: unknownType_("operator<<", v.subtype); } } case 'Z': os << "None"; break; default: unknownType_("operator<<", v.tag); } return os; } // Make this look like pythons dictionaries OC_INLINE ostream& operator<< (ostream& os, const Tab& t) { os << "{"; for (It it(t); it(); ) { // os << it.key() << ": " << it.value(); const Val& key = it.key(); const Val& value = it.value(); os << key << ": " << value; // See if we want to output a comma It next(it); if (next()) { os << ", "; } } return os << "}"; } // Due to crazy include dependencies, we do this last. #include "ocvalreader.h" OC_INLINE Tab::Tab (const char* cc) {ValReader r(cc); r.expectTab(*this);} OC_INLINE Tab::Tab (const Str& s) {ValReader r(s.c_str());r.expectTab(*this);} OC_INLINE Tab::Tab () { } OC_INLINE void Tab::append (const Val& v) { Val key=entries(); this->insertKeyAndValue(key,v); // crappy dependent names } OC_INLINE void Tab::appendStr (const Val& v) { Val key=Stringize(entries()); this->insertKeyAndValue(key,v); // crappy dependent names } OC_INLINE Tab& Tab::operator+= (const Tab& rhs) { for (It ii(rhs); ii();) { this->insertKeyAndValue(ii.key(), ii.value()); } return *this; } OC_INLINE ostream& Tab::prettyPrintHelper_ (ostream& os, int indent, bool pretty) const { // Base case, empty table if (entries()==0) return os << "{ }"; // Recursive case os << "{"; if (pretty) os << endl; // Iterate through, printing out each element Sit sii(*this); for (int ii=0; sii(); ii++) { const Val& key = sii.key(); const Val& value = sii.value(); if (pretty) indentOut_(os, indent+4); os << key << ":"; // For most values, use default output method switch (value.tag) { case 'a': { Str* ap = (Str*)&value.u.a; os << Image(*ap, true); break; } case 't': { Tab* tp = (Tab*)&value.u.t; tp->prettyPrintHelper_(os, pretty ? indent+4 : 0, pretty); break; } case 'n': { if (value.subtype=='Z') { Arr* np = (Arr*)&value.u.n; np->prettyPrintHelper_(os, pretty ? indent+4 : 0, pretty); break; } // else fall thru for other array types } default: os << value; break; } if (entries()>1 && ii!=entries()-1) os << ","; // commas on all but last if (pretty) os << endl; } if (pretty) indentOut_(os, indent); return os << "}"; } OC_INLINE void Tab::prettyPrint (ostream& os, int indent) const { indentOut_(os, indent); prettyPrintHelper_(os, indent, true) << endl; } OC_INLINE Arr::Arr (const char* cc) {ValReader r(cc); r.expectArr(*this);} OC_INLINE Arr::Arr (const Str& s) {ValReader r(s.c_str());r.expectArr(*this);} OC_INLINE Arr::Arr () { } OC_INLINE Arr::Arr (int len) : OCArray<Val>(len) { } OC_INLINE ostream& Arr::prettyPrintHelper_ (ostream& os, int indent, bool pretty) const { // Base case, empty if (entries()==0) return os << "[ ]"; // Recursive case os << "["; if (pretty) os << endl; // Iterate through, printing out each element for (unsigned int ii=0; ii<entries(); ++ii) { const Val& value = (*this)[ii]; if (pretty) indentOut_(os, indent+4); // For most values, use default output method switch (value.tag) { case 'a': { Str* ap = (Str*)&value.u.a; os << Image(*ap, true); break; } case 't': { Tab* tp = (Tab*)&value.u.t; tp->prettyPrintHelper_(os, pretty ? indent+4 : 0, pretty); break; } case 'n': { if (value.subtype=='Z') { Arr* np = (Arr*)&value.u.n; np->prettyPrintHelper_(os, pretty ? indent+4 : 0, pretty); break; } // else fall thru for other array types } default: os << value; break; } if (entries()>1 && ii!=entries()-1) os << ","; // commas on all but last if (pretty) os << endl; } if (pretty) indentOut_(os, indent); return os << "]"; } OC_INLINE void Arr::prettyPrint (ostream& os, int indent) const { indentOut_(os, indent); prettyPrintHelper_(os, indent, true) << endl; } OC_INLINE void Val::swap (Val& rhs) { ::swap(this->tag, rhs.tag); ::swap(this->subtype, rhs.subtype); ::swap(this->u, rhs.u); } OC_INLINE void Val::prettyPrint (ostream& os, int indent) const { if (tag=='t') { Tab* tp = (Tab*)&(u.t); tp->prettyPrint(os, indent); } else if (tag=='n' && subtype=='Z') { Arr* np = (Arr*)&(u.a); np->prettyPrint(os, indent); } else { os << (*this); } } #define OC_APPEND(T) {OCArray<T>*np=(OCArray<T>*)&u.n;np->append(v); break;} OC_INLINE void Val::append (const Val& v) { if (tag=='t') { Tab* tp = (Tab*)&(u.t); tp->append(v); } else if (tag=='n') { switch (subtype) { case 's': OC_APPEND(int_1); case 'S': OC_APPEND(int_u1); case 'i': OC_APPEND(int_2); case 'I': OC_APPEND(int_u2); case 'l': OC_APPEND(int_4); case 'L': OC_APPEND(int_u4); case 'x': OC_APPEND(int_8); case 'X': OC_APPEND(int_u8); case 'b': OC_APPEND(bool); case 'f': OC_APPEND(real_4); case 'd': OC_APPEND(real_8); case 'F': OC_APPEND(complex_8); case 'D': OC_APPEND(complex_16); case 'a': OC_APPEND(Str); case 't': OC_APPEND(Tab); case 'n': throw logic_error("Arrays of Arrays not currently supported"); case 'Z': OC_APPEND(Val); default: unknownType_("append", subtype); } } else { throw logic_error("Only Array<T>, Arr and Tab can append"); } } OC_INLINE void Val::appendStr (const Val& v) { if (tag=='t') { Tab* tp = (Tab*)&(u.t); tp->appendStr(v); } else { append(v); // call the normal append } }
[ "mattrochon@gmail.com" ]
[ [ [ 1, 955 ] ] ]
0b818029275142d97d8e6210818a93a5b5dbc459
f83137ab7ba3ed9f8d89f84c415a6d8a03f99c2f
/APMShared/APMTrigger.cpp
dfeb640af61c4b6f1c1578859014257b89b99e0c
[]
no_license
NobodysNightmare/APM-Meter
0ab0438a773f90efc4836cab00c9980d3e2dce89
32bb96618bb1ce8e34db4270459aa0eb8577f6b6
refs/heads/master
2021-01-19T08:48:54.951073
2010-12-03T18:58:11
2010-12-03T18:58:11
1,023,406
0
0
null
null
null
null
UTF-8
C++
false
false
2,248
cpp
#include "APMTrigger.h" APMTrigger::APMTrigger(APMConfig* n_cfg) { cfg = n_cfg; hProcess = NULL; switch(cfg->trigger_method) { case TRIGGER_BY_HOTKEY: if(!RegisterHotKey(NULL, HOTKEY_STARTSTOP_MEASURE, MOD_ALT | MOD_SHIFT, 0x50)) { exit(GetLastError()); } break; case TRIGGER_BY_PROCESS: break; } } APMTrigger::~APMTrigger() { switch(cfg->trigger_method) { case TRIGGER_BY_HOTKEY: UnregisterHotKey(NULL, HOTKEY_STARTSTOP_MEASURE); break; case TRIGGER_BY_PROCESS: CloseHandle(hProcess); break; } } BOOL APMTrigger::triggerStart() { switch(cfg->trigger_method) { case TRIGGER_BY_HOTKEY: return triggerStartByHotkey(); case TRIGGER_BY_PROCESS: return triggerStartByProcess(); default: return TRUE; } } BOOL APMTrigger::triggerStartByHotkey() { MSG msg = {0}; while(true) { BOOL bRet = GetMessage(&msg, NULL, WM_HOTKEY, WM_HOTKEY); if(bRet == 0 || bRet == -1) exit(bRet); if(msg.wParam == HOTKEY_STARTSTOP_MEASURE) { return TRUE; } } } BOOL APMTrigger::triggerStartByProcess() { while(!(hProcess = getProcessByName(cfg->trigger_process))) Sleep(50); return TRUE; } BOOL APMTrigger::triggerStop(MSG* msg) { switch(cfg->trigger_method) { case TRIGGER_BY_HOTKEY: return triggerStopByHotkey(msg); case TRIGGER_BY_PROCESS: return triggerStopByProcess(); default: return TRUE; } } BOOL APMTrigger::triggerStopByHotkey(MSG* msg) { if(msg->message == WM_HOTKEY && msg->wParam == HOTKEY_STARTSTOP_MEASURE) return TRUE; return FALSE; } BOOL APMTrigger::triggerStopByProcess() { if(WaitForSingleObject(hProcess, 0) == WAIT_OBJECT_0) return TRUE; return FALSE; } HANDLE APMTrigger::getProcessByName(const WCHAR* name) { HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); PROCESSENTRY32 proc_entry = {0}; proc_entry.dwSize = sizeof(PROCESSENTRY32); if(Process32First(hSnap, &proc_entry)) { do { if(_wcsicmp(name, proc_entry.szExeFile) == 0) { CloseHandle(hSnap); return OpenProcess(PROCESS_QUERY_INFORMATION | SYNCHRONIZE, FALSE, proc_entry.th32ProcessID); } } while(Process32Next(hSnap, &proc_entry)); } CloseHandle(hSnap); return NULL; }
[ "fischikowski@web.de" ]
[ [ [ 1, 97 ] ] ]
f4ce0671bcd641928f946b920fc0416f64ab9a6f
1eb0e6d7119d33fa76bdad32363483d0c9ace9b2
/PointCloud/trunk/PointCloud/PointCloudView.h
71506a530717b27f894aaa90cb7d5ae1db3681a1
[]
no_license
kbdacaa/point-clouds-mesh
90f174a534eddb373a1ac6f5481ee7a80b05f806
73b6bc17aa5c597192ace1a3356bff4880ca062f
refs/heads/master
2016-09-08T00:22:30.593144
2011-06-04T01:54:24
2011-06-04T01:54:24
41,203,780
0
2
null
null
null
null
GB18030
C++
false
false
2,370
h
// PointCloudView.h : CPointCloudView 类的接口 // #ifndef CPointCloudView_H_ #define CPointCloudView_H_ #pragma once #include <gl/GL.h> #include <gl/glu.h> #include <gl/glaux.h> #pragma comment(lib, "glu32.lib") #pragma comment(lib, "glaux.lib") class CPointCloudDoc; class CPointSet; class CMesh; class CPointMesh; class BallMesh; class CPointCloudView : public CView { protected: // 仅从序列化创建 CPointCloudView(); DECLARE_DYNCREATE(CPointCloudView) // 属性 public: CPointCloudDoc* GetDocument() const; HGLRC m_hRC; GLdouble eye[3], center[3]; BOOL isLPressed, isRPressed; float view_angle; GLfloat Rx,Ry,Rz; int px, py; float vx[3], vy[3], vz[3]; float shift_x, shift_y, shift_z; bool bCtrlDown; bool bLeftDown; // 操作 public: // 重写 public: virtual void OnDraw(CDC* pDC); // 重写以绘制该视图 virtual BOOL PreCreateWindow(CREATESTRUCT& cs); protected: // 实现 public: virtual ~CPointCloudView(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: // 生成的消息映射函数 protected: DECLARE_MESSAGE_MAP() public: void initGL(void); void draw(){ CDC* pDC = GetDC(); if (pDC==NULL) return; OnDraw(pDC); } void drawPoint(CPointSet* ps); void drawMesh(CMesh* mesh); void drawPointMesh(CPointMesh* pointMesh); void drawPointMeshWithoutPoint(CPointMesh* pointMesh); void drawBalls(CPointSet* balls); void drawBallMesh(BallMesh* ballMesh); void drawBallWire(BallMesh* ballMesh); void sphere(float r, float p[], int n); public: afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnDestroy(); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnRButtonUp(UINT nFlags, CPoint point); afx_msg void OnRButtonDown(UINT nFlags, CPoint point); public: void drawAxis(void); afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); }; #ifndef _DEBUG // PointCloudView.cpp 中的调试版本 inline CPointCloudDoc* CPointCloudView::GetDocument() const { return reinterpret_cast<CPointCloudDoc*>(m_pDocument); } #endif #endif
[ "huangchunkuangke@e87e5053-baee-b2b1-302d-3646b6e6cf75" ]
[ [ [ 1, 103 ] ] ]
d1c1ac65d63b9c3fb834f74105780fd3e5f316b3
741b36f4ddf392c4459d777930bc55b966c2111a
/incubator/happylib/HappyLib/LWPGradient.h
1fadd44b844744e467d98ac19db605d5262c4ea4
[]
no_license
BackupTheBerlios/lwpp-svn
d2e905641f60a7c9ca296d29169c70762f5a9281
fd6f80cbba14209d4ca639f291b1a28a0ed5404d
refs/heads/master
2021-01-17T17:01:31.802187
2005-10-16T22:12:52
2005-10-16T22:12:52
40,805,554
0
0
null
null
null
null
UTF-8
C++
false
false
2,658
h
#ifndef _LWPGRADIENT_H #define _LWPGRADIENT_H #include "LWPPlugin.h" #include "LWPSerialization.h" #include "HLPoint.h" #define LWID_SERIAL_GRAD LWID_('G','R','A','D') class LWPControl; class LWPPanel; // [FIXME] put the gradient interface stuff into LWPIGradientControl : public LWPIAreaControl // in a different file and everything. //// [DOCUMENTME] //// class LWPGradientKey { public: LWPGradientKey * prev; LWPGradientKey * next; double frac; Color col; double val; LWPGradientKey() : prev(0), next(0), frac(0), col(Color::Black()), val(0) {} LWPGradientKey(LWPGradientKey const * k) : prev(0), next(0), frac(k->frac), col(k->col), val(k->val) {} LWError load(LWPLoadState const *); LWError save(LWPSaveState const *) const; int xOffset(int w) const { return int(frac * (w - 1) + 0.5); } void setXOffset(int, int); void draw(LWPPanel, LWRasterID, int, int, int, int, int, int) const; }; class LWPGradient { public: LWPGradientKey * head; LWPGradientKey * tail; LWPGradientKey * sel; enum GradType { GRADTYPE_COLOR, GRADTYPE_VALUE } type; // [FIXME] support both types int dragging; // [NOTE] head and tail are persistent LWPGradient() ; LWPGradient(LWPGradient const &); ~LWPGradient(); LWPGradient & operator = (LWPGradient const &); void remove(LWPGradientKey *); void append(LWPGradientKey *); void insertAfter(LWPGradientKey * before, LWPGradientKey * after); void addNewKey(double); void select(int, int, int, int, int); int keyCount() const; Color evaluateColor(double) const; LWError load(LWPLoadState const *); LWError save(LWPSaveState const *) const; void draw(LWPPanel, int, int, int, int) const; void event(LWPPanel, int, int, int, int, int, int, int[3], int); XCALL_(static void) Draw(LWPControl *, void *, DrMode); XCALL_(static void) Event(LWPControl *, void *); // serialization class class SerializationLWPGradient : public LWPSerialization::Serialization { public: SerializationLWPGradient(char const * c, void * v) : LWPSerialization::Serialization(c, v) {} virtual void load(LWPLoadState const * lState) { if (lState->readU4() != LWID_SERIAL_GRAD) return; ((LWPGradient*)data)->load(lState); } virtual void save(LWPSaveState const * sState) const { sState->writeU4(LWID_SERIAL_GRAD); ((LWPGradient*)data)->save(sState); } virtual void copy(LWPSerialization::Serialization const & from) { *(LWPGradient*)data = *(LWPGradient*)from.data; } }; operator LWPSerialization::Serialization () { return SerializationLWPGradient("", this); } }; #endif
[ "lightwolf@dac1304f-7ce9-0310-a59f-f2d444f72a61" ]
[ [ [ 1, 90 ] ] ]
1ce79b6138916c441cf80b46f6d90ef522d78a99
2b80036db6f86012afcc7bc55431355fc3234058
/src/cube/SourcesModel.cpp
37c7e6f6175cab900e5ca5175f0aaabc50258742
[ "BSD-3-Clause" ]
permissive
leezhongshan/musikcube
d1e09cf263854bb16acbde707cb6c18b09a0189f
e7ca6a5515a5f5e8e499bbdd158e5cb406fda948
refs/heads/master
2021-01-15T11:45:29.512171
2011-02-25T14:09:21
2011-02-25T14:09:21
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
8,356
cpp
////////////////////////////////////////////////////////////////////////////// // // License Agreement: // // The following are Copyright © 2007, Casey Langen // // Sources and Binaries of: mC2, win32cpp // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // * Neither the name of the author nor the names of other contributors may // be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////// #pragma once ////////////////////////////////////////////////////////////////////////////// #include "pch.hpp" #include <cube/SourcesModel.hpp> #include <cube/TracklistView.hpp> #include <cube/TracklistController.hpp> //#include <core/tracklist/Playlist.h> #include <win32cpp/Label.hpp> using namespace musik::cube; ////////////////////////////////////////////////////////////////////////////// class DummyItem: public SourcesItem, public EventHandler { private: /*ctor*/ DummyItem(const uistring& caption) : caption(caption) , view(uistring(caption + _T(" sources item")).c_str()) { view.Created.connect(this, &DummyItem::OnViewCreated); } public: void OnViewCreated(Window* window) { //this->view.SetBackgroundColor(Color(255, 255, 255)); } public: static SourcesItemRef Create(const uistring& caption) { return SourcesItemRef(new DummyItem(caption)); } public: virtual uistring Caption() { return this->caption; } public: virtual Window* View() { return &this->view; } private: uistring caption; private: Label view; }; ////////////////////////////////////////////////////////////////////////////// #include <cube/BrowseView.hpp> #include <cube/BrowseController.hpp> class BrowseItem: public SourcesItem { private: /*ctor*/ BrowseItem(musik::core::LibraryPtr library) : controller(view,library) { } public: /*dtor*/ ~BrowseItem() { } public: static SourcesItemRef Create(musik::core::LibraryPtr library) { return SourcesItemRef(new BrowseItem(library)); } public: virtual uistring Caption() { return _(_T("Browse")); } public: virtual Window* View() { return &this->view; } private: BrowseView view; private: BrowseController controller; }; ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// class PlaylistItem: public SourcesItem { private: /*ctor*/ PlaylistItem(musik::core::tracklist::Ptr playlist) : controller(view,NULL,playlist,TracklistController::HighlightActive|TracklistController::Deletable) { } public: /*dtor*/ ~PlaylistItem() { } public: static SourcesItemRef Create(musik::core::tracklist::Ptr playlist) { return SourcesItemRef(new PlaylistItem(playlist)); } public: virtual uistring Caption() { // musik::core::tracklist::Playlist* playlist = (musik::core::tracklist::Playlist*)(this->controller.Tracklist().get()); // return playlist->Name(); return uistring(); } public: virtual Window* View() { return &this->view; } private: TracklistView view; private: TracklistController controller; }; ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// #include <cube/SettingsView.hpp> #include <cube/SettingsController.hpp> class SettingsItem: public SourcesItem { private: /*ctor*/ SettingsItem(musik::core::LibraryPtr library) : controller(view,library) { } public: /*dtor*/ ~SettingsItem() { } public: static SourcesItemRef Create(musik::core::LibraryPtr library) { return SourcesItemRef(new SettingsItem(library)); } public: virtual uistring Caption() { return _(_T("Settings")); } public: virtual Window* View() { return &this->view; } private: SettingsView view; private: SettingsController controller; }; ////////////////////////////////////////////////////////////////////////////// typedef SourcesListModel::Category Category; typedef SourcesListModel::CategoryRef CategoryRef; /*ctor*/ SourcesModel::SourcesModel(musik::core::LibraryPtr library) : library(library) { } void SourcesModel::Load() { CategoryRef viewCategory(new Category(_(_T("View")))); viewCategory->Add(BrowseItem::Create(this->library)); if(this->library->Indexer()!=NULL){ viewCategory->Add(SettingsItem::Create(this->library)); } this->AddCategory(viewCategory); this->playlistCategory.reset(new Category(_(_T("Playlists")))); /* playlistCategory->Add(DummyItem::Create(_(_T("Playlist 1")))); playlistCategory->Add(DummyItem::Create(_(_T("Playlist 2")))); playlistCategory->Add(DummyItem::Create(_(_T("Dynamic Playlist 3")))); playlistCategory->Add(DummyItem::Create(_(_T("Dynamic Playlist 4"))));*/ this->AddCategory(this->playlistCategory); } #define FIND_CATEGORY(list, category) std::find(list.begin(), list.end(), category) void SourcesModel::AddCategory(CategoryRef category) { if (FIND_CATEGORY(this->categories, category) != this->categories.end()) { throw InvalidCategoryException(); } this->categories.push_back(category); this->CategoryAdded(category); } void SourcesModel::RemoveCategory(CategoryRef category) { CategoryList::iterator it = FIND_CATEGORY(this->categories, category); if (it == this->categories.end()) { throw InvalidCategoryException(); } this->categories.erase(it); this->CategoryRemoved(category); } /*void SourcesModel::OnPlaylists(SourcesModel::PlaylistVector &playlists){ // Start by removing the old ones for(PlaylistItemMap::iterator it=this->playlistItemsMap.begin();it!=this->playlistItemsMap.end();++it){ // Remove the item from the category this->playlistCategory->Remove(it->second); } // Clear the map this->playlistItemsMap.clear(); // Start creating the new playlists for(SourcesModel::PlaylistVector::iterator playlist=playlists.begin();playlist!=playlists.end();++playlist){ // Create the sourcesItem SourcesItemRef sourceItem = PlaylistItem::Create(*playlist); playlistCategory->Add(sourceItem); this->playlistItemsMap[*playlist] = sourceItem; } } */
[ "onnerby@6a861d04-ae47-0410-a6da-2d49beace72e", "onnerby@gmail.com@6a861d04-ae47-0410-a6da-2d49beace72e", "andre@woesten.com@6a861d04-ae47-0410-a6da-2d49beace72e" ]
[ [ [ 1, 47 ], [ 49, 103 ], [ 105, 138 ], [ 142, 172 ], [ 174, 194 ], [ 196, 196 ], [ 200, 203 ], [ 206, 235 ], [ 237, 256 ] ], [ [ 48, 48 ], [ 139, 141 ], [ 197, 199 ], [ 236, 236 ], [ 257, 257 ] ], [ [ 104, 104 ], [ 173, 173 ], [ 195, 195 ], [ 204, 205 ] ] ]
aa1b34ff39445eab10ec3ea0f6cc7312131a8f98
aee9f4a7a277c3f44eac40072adb81dc52db3079
/Code/core/ComponentOutputAVI.h
ee1d3c6a38910910a10cd97608b2d5fd8f012cd2
[]
no_license
SiChiTong/swistrackplus
1a1bbc7dd8457ec908ced0cae3e30ef1f0d85551
7746c32dcfdbe1988c82e7a1561534c519ac0872
refs/heads/master
2020-04-05T02:31:55.840432
2010-06-01T14:12:46
2010-06-01T14:12:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,405
h
#ifndef HEADER_ComponentOutputAVI #define HEADER_ComponentOutputAVI #include "Component.h" #ifdef __WXMSW__ //! A component that generates an AVI movie. /*! This component writes an AVI file using CvAVIWriter (only available on Win32). The file is written when started in production mode only. The frames written are taken from a DisplayImage. Hence, any intermediate image can be stored. The DisplayImage may be changed (or even disabled) while the component is running in production mode. */ class ComponentOutputAVI: public Component { public: //! Constructor. ComponentOutputAVI(SwisTrackCore *stc); //! Destructor. ~ComponentOutputAVI(); // Overwritten Component methods void OnStart(); void OnReloadConfiguration(); void OnStep(); void OnStepCleanup(); void OnStop(); Component *Create() { return new ComponentOutputAVI(mCore); } private: wxString mFileName; //!< (configuration) File name of the AVI file to write. double mPlaybackSpeedFPS; //!< (configuration) Playback speed FPS. int mFrameRate; //!< (configuration) Record every mFrameRate image. CvSize mMaxImageSize; //!< (configuration) The maximum image size. (Images are scaled proportionally, with neither side exceeding these values.) CvAVIWriter* mAVIWriter; //!< AVI writer object. int mFrameCounter; //!< Counts the number of frames until mFrameRate. bool mErrorAVIFile; //!< The video file could not be opened. int mWrittenFramesCount; //!< The number of written frames. DisplayImage *mCurrentDisplayImage; //!< The DisplayImage we are currently subscribed to. }; #else // __WXMSW__ class ComponentOutputAVI: public Component { public: ComponentOutputAVI(SwisTrackCore *stc): Component(stc, wxT("OutputAVI")) { Initialize(); } ~ComponentOutputAVI() {} // Overwritten Component methods void OnStart() { AddError(wxT("Output to AVI is only supported on Microsoft Windows.")); } void OnReloadConfiguration() { AddError(wxT("Output to AVI is only supported on Microsoft Windows.")); } void OnStep() { AddError(wxT("Output to AVI is only supported on Microsoft Windows.")); } void OnStepCleanup() {} void OnStop() { AddError(wxT("Output to AVI is only supported on Microsoft Windows.")); } Component *Create() { return new ComponentOutputAVI(mCore); } }; #endif // __WXMSW__ #endif
[ "root@newport-ril-server.(none)" ]
[ [ [ 1, 75 ] ] ]
1daaa251631ac80b24dd643ee9881d469e38ebe1
43626054205d6048ec98c76db5641ce8e42b8237
/Tile Engine/CTileManager.cpp
141ad8d98d02bec5b174ba6b56f1c97ac1ec2804
[]
no_license
Wazoobi/whitewings
b700da98b855a64442ad7b7c4b0be23427b0ee23
a53fdb832cfb1ce8605209c9af47f36b01c44727
refs/heads/master
2021-01-10T19:33:22.924792
2009-08-05T18:30:07
2009-08-05T18:30:07
32,119,981
0
0
null
null
null
null
UTF-8
C++
false
false
9,854
cpp
////////////////////////////////////////////////////////////////////////// // Filename: CTileManager.cpp // // Author: David Seabolt // // Purpose: To define any functions declared in the CTileManager.h ////////////////////////////////////////////////////////////////////////// //------------------------------------- // #include's #include "CCamera.h" #include "CLevel.h" #include "SGD Wrappers/CSGD_TextureManager.h" #include "SGD Wrappers/CSGD_DirectInput.h" #include "SGD Wrappers/CSGD_Direct3D.h" #include "CEvent.h" #include "CSGD_EventSystem.h" void CTileManager::Update(CPlayer* pPlayer) { #if 0 //CSGD_DirectInput* m_pDI = CSGD_DirectInput::GetInstance(); //if (m_pDI->KeyDown(DIK_LEFT)) //{ // //if the camera isn't past the start of the level // if (m_pCamera->GetCameraPosX() - 1 >= 0) // m_pCamera->SetCameraPosX(m_pCamera->GetCameraPosX() -1 ); // else // m_pCamera->SetCameraPosX(0); //} //if (m_pDI->KeyDown(DIK_RIGHT)) //{ // //if the camera isn't past the end of the level // if ( ((m_pCamera->GetCameraPosX() + CGame::GetInstance()->GetScreenWidth()) + 1) < (m_pLevels[GetCurrentLevel() - 1]->GetLevelWidth()*TILE_WIDTH) ) // m_pCamera->SetCameraPosX(m_pCamera->GetCameraPosX() + 1); // else // m_pCamera->SetCameraPosX((m_pLevels[GetCurrentLevel() - 1]->GetLevelWidth()*TILE_WIDTH) - CGame::GetInstance()->GetScreenWidth() - TILE_WIDTH); //} //if (m_pDI->KeyDown(DIK_UP)) //{ // //if the camera isn't at the top of the level // if (m_pCamera->GetCameraPosY() - 1 >= 0) // m_pCamera->SetCameraPosY(m_pCamera->GetCameraPosY() - 1); // else // m_pCamera->SetCameraPosY(0); //} //if (m_pDI->KeyDown(DIK_DOWN)) //{ // //if the camera isn't at the bottom of the level // if ( ((m_pCamera->GetCameraPosY() + CGame::GetInstance()->GetScreenHeight()) + 1) < (m_pLevels[GetCurrentLevel() - 1]->GetLevelHeight()*TILE_HEIGHT) ) // m_pCamera->SetCameraPosY(m_pCamera->GetCameraPosY() + 1); // else // m_pCamera->SetCameraPosY((m_pLevels[GetCurrentLevel() - 1]->GetLevelHeight()*TILE_HEIGHT) - CGame::GetInstance()->GetScreenHeight() - TILE_HEIGHT); //} //if the camera isn't past the start of the level #endif //------------------------------------------------------------------------------------------------------------------------------------- // Camera Updates float newPosX = pPlayer->GetPosX() - (CGame::GetInstance()->GetScreenWidth()/3); float newPosY = pPlayer->GetPosY() - (CGame::GetInstance()->GetScreenHeight()/4); //XCameraPos Possibilities if (newPosX >= 0 && newPosX + CGame::GetInstance()->GetScreenWidth() < (m_pLevels[GetCurrentLevel() -1]->GetLevelWidth()*TILE_WIDTH)) m_pCamera->SetCameraPosX(newPosX); else if(newPosX < 0) m_pCamera->SetCameraPosX(0); else m_pCamera->SetCameraPosX((m_pLevels[GetCurrentLevel() - 1]->GetLevelWidth()*TILE_WIDTH) - CGame::GetInstance()->GetScreenWidth()); //YCameraPos Possibilities if(newPosY >= 0 && newPosY + CGame::GetInstance()->GetScreenHeight() < (m_pLevels[GetCurrentLevel() - 1]->GetLevelHeight()*TILE_HEIGHT)) m_pCamera->SetCameraPosY(newPosY * TILE_HEIGHT); else if(newPosY < 0) m_pCamera->SetCameraPosY(0); else m_pCamera->SetCameraPosY((m_pLevels[GetCurrentLevel() - 1]->GetLevelHeight()*TILE_HEIGHT) - CGame::GetInstance()->GetScreenHeight()); //-------------------------------------------------------------------------------------------------------------------------------------- } void CTileManager::Render() { m_pCamera->RenderLevel(m_pLevels[GetCurrentLevel() - 1]->GetRenderArrays(), m_pLevels[GetCurrentLevel() - 1]->GetLevelWidth(), m_pLevels[GetCurrentLevel() - 1]->GetLevelHeight()); } void CTileManager::InitManager() { m_pCamera = new CCamera(); m_pLevels = new CLevel*[5]; for (int i = 0; i < 5; ++i) { m_pLevels[i] = new CLevel(); } m_pLevels[0]->LoadLevel("resource/data/level.bin", 1); m_pLevels[0]->SetLevelImageID(CSGD_TextureManager::GetInstance()->LoadTexture("resource/graphics/DaS_TestTileSet.bmp")); for (int i = 0; i < 3; ++i) { for (int j = 0; j < m_pLevels[0]->GetLevelWidth(); ++j) { for (int k = 0; k < m_pLevels[0]->GetLevelHeight(); ++k) { if(m_pLevels[0]->GetRenderArrays()[i][j][k].m_shX < 10000) { m_pLevels[0]->GetRenderArrays()[i][j][k].m_shTileImageIndex = m_pLevels[0]->GetLevelImageID(); } } } } SetCurrentLevel(1); } void CTileManager::CheckLevelCollisions(CBase* pObject, CCamera* pCamera) { CLevel::Tile** CollisionLayer = m_pLevels[GetCurrentLevel() - 1]->GetRenderArrays()[2]; CLevel::Tile** TriggerLayer = m_pLevels[GetCurrentLevel() - 1]->GetRenderArrays()[3]; RECT CollisionRect = pObject->GetRect(); //The objects collision RECT RECT CollisionType = {0,0,0,0}; //The RECT that will result from the collision check RECT CollisionCheck = {0,0,0,0}; //The RECT to be drawn at the location in the tile array RECT TriggerCheck = {0,0,0,0}; //The RECT to check for triggers with for (int i = (int)((pCamera->GetCameraPosX()/TILE_WIDTH)); i < ((pCamera->GetCameraPosX()/TILE_WIDTH)) + (CGame::GetInstance()->GetScreenWidth()/TILE_WIDTH); ++i) { for (int j = (int)((pCamera->GetCameraPosY()/TILE_HEIGHT)); j < ((pCamera->GetCameraPosY()/TILE_HEIGHT)) + (CGame::GetInstance()->GetScreenHeight()/TILE_HEIGHT); ++j) { for(int h = 0; h < m_pLevels[GetCurrentLevel() - 1]->GetTotalTriggers(); ++h) if(i * TILE_WIDTH == m_pLevels[GetCurrentLevel() - 1]->GetTriggers()[h].m_X && j * TILE_HEIGHT == m_pLevels[GetCurrentLevel() - 1]->GetTriggers()[h].m_Y) { TriggerCheck.left = i * TILE_WIDTH - m_pCamera->GetCameraPosX(); TriggerCheck.top = j * TILE_HEIGHT - m_pCamera->GetCameraPosY(); TriggerCheck.right = TriggerCheck.left + TILE_WIDTH; TriggerCheck.bottom = TriggerCheck.top + TILE_HEIGHT; if(IntersectRect(&CollisionType, &TriggerCheck, &CollisionRect)) CSGD_EventSystem::GetInstance()->SendEvent(m_pLevels[GetCurrentLevel() - 1]->GetTriggers()[h].m_szEventString, (void*) pObject); } if (CollisionLayer[i][j].m_bIsCollideable) { CollisionCheck.left = i * TILE_WIDTH - m_pCamera->GetCameraPosX(); CollisionCheck.top = j * TILE_HEIGHT - m_pCamera->GetCameraPosY(); CollisionCheck.right = CollisionCheck.left + TILE_WIDTH; CollisionCheck.bottom = CollisionCheck.top + TILE_HEIGHT; if (IntersectRect(&CollisionType, &CollisionCheck, &CollisionRect)) { if (CollisionType.top < CollisionRect.bottom && CollisionType.bottom > CollisionCheck.top && CollisionType.bottom - CollisionType.top < CollisionType.right - CollisionType.left && CollisionRect.top > CollisionCheck.top) { //------------------------------------------------------------------------- //If this is a case where the object has hit the bottom of the level's tile pObject->SetPosY(CollisionCheck.bottom); //pObject->SetVelY(-pObject->GetVelY()); // TODO Implement this code /*if(pObject->GetObjectType() == OBJ_PLAYER); { CPlayer* pPlayer = (CPlayer*)pObject; pPlayer->SetIsJumping(false); }*/ } else if(CollisionType.top < CollisionCheck.bottom && CollisionType.bottom > CollisionRect.top && CollisionType.bottom - CollisionType.top < CollisionType.right - CollisionType.left) { //-------------------------------------------------------------------- // If this is a case where the object has fallen onto the level's tile pObject->SetPosY(CollisionCheck.top - 32); } else if(CollisionType.left < CollisionRect.right && CollisionType.right > CollisionCheck.left && CollisionType.bottom - CollisionType.top > CollisionType.right - CollisionType.left && CollisionRect.left < CollisionCheck.left) { //-------------------------------------------------------------------------------- //If this is a case where the object has collided with the level's tile's left side pObject->SetPosX(CollisionCheck.left - 32); } else if(CollisionType.right > CollisionRect.left && CollisionType.left < CollisionCheck.right && CollisionType.bottom - CollisionType.top > CollisionType.right - CollisionType.left) { //------------------------------------------------------------------------------- //If this is a case where the object has collided with the level's tile's right side pObject->SetPosX(CollisionCheck.right); } else if(CollisionType.top < CollisionCheck.bottom && CollisionType.bottom > CollisionRect.top && // CollisionType.bottom - CollisionType.top == CollisionType.right - CollisionType.left && //if its a corner CollisionRect.top < CollisionCheck.top ) // to ensure that we are truly on the bottom { //---------------------------------------------------------------------------------- //If this is a case of a top corner collision pObject->SetPosY(CollisionCheck.top - 32); } else if(CollisionType.top < CollisionRect.bottom && CollisionType.bottom > CollisionCheck.top && CollisionType.bottom - CollisionType.top == CollisionType.right - CollisionType.left) { //---------------------------------------------------------------------------------- //If this is a case of a bottom corner collision pObject->SetPosY(CollisionCheck.bottom); //pObject->SetVelY(-pObject->GetVelY() ); } } } } } } void CTileManager::ReleaseManager() { delete m_pCamera; for (int i = 0; i < 5; ++i) { delete m_pLevels[i]; } }
[ "dSeabolt66@1cfc0206-7002-11de-8585-3f51e31374b7" ]
[ [ [ 1, 247 ] ] ]
3aeca0f6ef91f67e4e88355adf7aa83cbeeb63a3
7745a8d148e55e22dca4955f7ca4e83199495c17
/test/test_packrat.cpp
c84983b6f141f6d2e1c96c905876823e319e2334
[]
no_license
yak1ex/packrat_qi
e6c8058e39a77d8f6c1559c292b52cdb14b8608f
423d08e48abf1c06fd5f2acd812295ec6e1b3d11
refs/heads/master
2020-06-05T02:57:45.157294
2011-06-28T17:24:46
2011-06-28T17:24:46
1,967,192
0
0
null
null
null
null
UTF-8
C++
false
false
11,459
cpp
/***********************************************************************/ /* */ /* test_packrat.cpp: Test code for packrat parser on Spirit */ /* */ /* Written by Yak! / Yasutaka ATARASHI */ /* */ /* This software is distributed under the terms of */ /* Boost Software License 1.0 */ /* (http://www.boost.org/LICENSE_1_0.txt). */ /* */ /* $Id$ */ /* */ /***********************************************************************/ #include "test_packrat_helper.hpp" #include "packrat.hpp" #include "packrat_grammar.hpp" #include "packrat_rule_debug.hpp" #include <string> #include <boost/spirit/include/qi_parse.hpp> #include <boost/spirit/include/qi_char_.hpp> #include <boost/spirit/include/qi_int.hpp> #include <boost/spirit/include/qi_operator.hpp> #include <boost/spirit/include/qi_action.hpp> #include <boost/spirit/include/phoenix_operator.hpp> #include <boost/progress.hpp> #include <boost/test/auto_unit_test.hpp> BOOST_AUTO_TEST_CASE(test_packrat_parser_construct) { using namespace boost::spirit::qi; yak::spirit::packrat_parser<int_parser<> > pp((int_parser<>())); } BOOST_AUTO_TEST_CASE(test_packrat_rule) { namespace qi = boost::spirit::qi; yak::spirit::packrat_rule<std::string::iterator> pr1; pr1 = &qi::int_ >> &qi::int_ >> qi::int_; std::string s("123"); std::string::iterator first = s.begin(), last = s.end(); BOOST_CHECK(qi::parse(first, last, pr1)); yak::spirit::packrat_rule<std::string::iterator, int()> pr2; pr2 = &qi::int_ >> &qi::int_ >> qi::int_; int result = 0; first = s.begin(); last = s.end(); BOOST_CHECK(qi::parse(first, last, pr2, result)); BOOST_CHECK_EQUAL(result, 123); yak::spirit::packrat_rule<std::string::iterator, int(), qi::space_type> pr3; pr3 = pr1 >> pr2; s = "456 123"; first = s.begin(); last = s.end(); BOOST_CHECK(qi::phrase_parse(first, last, pr3, qi::space, result)); BOOST_CHECK_EQUAL(result, 123); } BOOST_AUTO_TEST_CASE(test_packrat_rule_debug) { namespace qi = boost::spirit::qi; yak::spirit::packrat_rule<std::string::iterator> pr1; pr1 = qi::int_; yak::spirit::packrat_rule<std::string::iterator, int()> pr2; pr2 = qi::int_; yak::spirit::packrat_rule<std::string::iterator, int(), qi::space_type> pr3; pr3 = pr1 >> pr2; boost::spirit::qi::debug(pr1); boost::spirit::qi::debug(pr2); boost::spirit::qi::debug(pr3); std::string s("123 456"); std::string::iterator first = s.begin(), last = s.end(); int result = 0; std::string debug_result( "<unnamed-rule>\n" " <try>123 456</try>\n" " <unnamed-rule>\n" " <try>123 456</try>\n" " <success> 456</success>\n" " <attributes>[]</attributes>\n" " </unnamed-rule>\n" " <unnamed-rule>\n" " <try>456</try>\n" " <success></success>\n" " <attributes>[456]</attributes>\n" " </unnamed-rule>\n" " <success></success>\n" " <attributes>[456]</attributes>\n" "</unnamed-rule>\n" ); BOOST_CHECK(qi::phrase_parse(first, last, pr3, qi::space, result)); BOOST_CHECK_EQUAL(result, 456); BOOST_CHECK_EQUAL(yak::spirit::debug::test_ss.str(), debug_result); } template<typename Iterator> struct expr_grammar : yak::spirit::packrat_grammar<Iterator, int(), boost::spirit::qi::locals<int, char> > { expr_grammar() : expr_grammar::base_type(expr) { namespace qi = boost::spirit::qi; namespace phoenix = boost::phoenix; using namespace qi::labels; expr = term[_a = _1] >> qi::char_("+-")[_b = _1] >> expr[_val = phoenix::if_else(_b == '+', _a + _1, _a - _1)] | term[_val = _1]; term = factor[_a = _1] >> qi::char_("*/")[_b = _1] >> term[_val = phoenix::if_else(_b == '*', _a * _1, _a / _1)] | factor[_val = _1]; factor = qi::int_ | qi::lit('(') >> expr >> qi::lit(')'); } yak::spirit::packrat_rule<Iterator, int(), boost::spirit::qi::locals<int, char> > expr; yak::spirit::packrat_rule<Iterator, int(), boost::spirit::qi::locals<int, char> > term; yak::spirit::packrat_rule<Iterator, int()> factor; }; template<typename Iterator> struct expr_grammar_ : boost::spirit::qi::grammar<Iterator, int(), boost::spirit::qi::locals<int, char> > { expr_grammar_() : expr_grammar_::base_type(expr) { namespace qi = boost::spirit::qi; namespace phoenix = boost::phoenix; using namespace qi::labels; expr = term[_a = _1] >> qi::char_("+-")[_b = _1] >> expr[_val = phoenix::if_else(_b == '+', _a + _1, _a - _1)] | term[_val = _1]; term = factor[_a = _1] >> qi::char_("*/")[_b = _1] >> term[_val = phoenix::if_else(_b == '*', _a * _1, _a / _1)] | factor[_val = _1]; factor = qi::int_ | qi::lit('(') >> expr >> qi::lit(')'); } boost::spirit::qi::rule<Iterator, int(), boost::spirit::qi::locals<int, char> > expr; boost::spirit::qi::rule<Iterator, int(), boost::spirit::qi::locals<int, char> > term; boost::spirit::qi::rule<Iterator, int()> factor; }; BOOST_AUTO_TEST_CASE(test_packrat_grammar) { namespace qi = boost::spirit::qi; expr_grammar<std::string::iterator> g; std::string s("1*2+3-4*5-(4/2-1)"); std::string::iterator first = s.begin(), last = s.end(); int result = 0; YAK_SPIRIT_PACKRAT_TEST_BLOCK { std::cout << "Packrat: Expression with " << s.size() << " chars." << std::endl; { boost::progress_timer t; BOOST_CHECK(qi::parse(first, last, g, result)); } BOOST_CHECK_EQUAL(result, -14); yak::spirit::debug::count::out(std::cout); } YAK_SPIRIT_PACKRAT_TEST_BLOCK { std::string s2 = s + "+" + s; first = s2.begin(); last = s2.end(); std::cout << "Packrat: Expression with " << s2.size() << " chars." << std::endl; { boost::progress_timer t; BOOST_CHECK(qi::parse(first, last, g, result)); } BOOST_CHECK_EQUAL(result, -28); yak::spirit::debug::count::out(std::cout); } YAK_SPIRIT_PACKRAT_TEST_BLOCK { std::string s2 = s, s3 = "+" + s; for(int i=0;i<255;++i) { s2 += s3; } first = s2.begin(); last = s2.end(); std::cout << "Packrat: Expression with " << s2.size() << " chars." << std::endl; { boost::progress_timer t; BOOST_CHECK(qi::parse(first, last, g, result)); } BOOST_CHECK_EQUAL(result, -3584); yak::spirit::debug::count::out(std::cout); } { expr_grammar_<std::string::iterator> g_; std::string s2 = s, s3 = "+" + s; for(int i=0;i<255;++i) { s2 += s3; } first = s2.begin(); last = s2.end(); std::cout << "Plain: Expression with " << s2.size() << " chars." << std::endl; { boost::progress_timer t; BOOST_CHECK(qi::parse(first, last, g_, result)); } BOOST_CHECK_EQUAL(result, -3584); } } template<typename Iterator> struct test_grammar : yak::spirit::packrat_grammar<Iterator> { test_grammar() : test_grammar::base_type(e) { namespace qi = boost::spirit::qi; a = b | c; b = qi::char_('a') >> b | qi::char_('c'); c = qi::char_('a') >> c | qi::char_('d'); d = &a >> qi::char_('a'); e = qi::char_('d') | d >> e; } yak::spirit::packrat_rule<Iterator> a; yak::spirit::packrat_rule<Iterator> b; yak::spirit::packrat_rule<Iterator> c; yak::spirit::packrat_rule<Iterator> d; yak::spirit::packrat_rule<Iterator> e; }; template<typename Iterator> struct test_grammar_ : boost::spirit::qi::grammar<Iterator> { test_grammar_() : test_grammar_::base_type(e) { namespace qi = boost::spirit::qi; a = b | c; b = qi::char_('a') >> b | qi::char_('c'); c = qi::char_('a') >> c | qi::char_('d'); d = &a >> qi::char_('a'); e = qi::char_('d') | d >> e; } boost::spirit::qi::rule<Iterator> a; boost::spirit::qi::rule<Iterator> b; boost::spirit::qi::rule<Iterator> c; boost::spirit::qi::rule<Iterator> d; boost::spirit::qi::rule<Iterator> e; }; BOOST_AUTO_TEST_CASE(test_packrat_complexity) { namespace qi = boost::spirit::qi; std::string s(512, 'a'); s += "d"; std::string::iterator first = s.begin(), last = s.end(); test_grammar<std::string::iterator> g; test_grammar_<std::string::iterator> g_; YAK_SPIRIT_PACKRAT_TEST_BLOCK { std::cout << "Packrat: Quadratic with " << s.size() << " chars." << std::endl; { boost::progress_timer t; BOOST_CHECK(qi::parse(first, last, g)); } yak::spirit::debug::count::out(std::cout); } { first = s.begin(); last = s.end(); std::cout << "Plain: Quadratic with " << s.size() << " chars." << std::endl; { boost::progress_timer t; BOOST_CHECK(qi::parse(first, last, g_)); } } std::string s2(1024, 'a'); s = s2 + "d"; YAK_SPIRIT_PACKRAT_TEST_BLOCK { first = s.begin(); last = s.end(); std::cout << "Packrat: Quadratic with " << s.size() << " chars." << std::endl; { boost::progress_timer t; BOOST_CHECK(qi::parse(first, last, g)); } yak::spirit::debug::count::out(std::cout); } { first = s.begin(); last = s.end(); std::cout << "Plain: Quadratic with " << s.size() << " chars." << std::endl; { boost::progress_timer t; BOOST_CHECK(qi::parse(first, last, g_)); } } } template<typename Iterator> struct test_grammar2 : yak::spirit::packrat_grammar<Iterator> { test_grammar2() : test_grammar2::base_type(e) { namespace qi = boost::spirit::qi; a = b | c; b = qi::char_('a') >> &a >> b | qi::char_('c'); c = qi::char_('a') >> &a >> c | qi::char_('d'); d = &a >> qi::char_('a'); e = qi::char_('d') | d >> e; } yak::spirit::packrat_rule<Iterator> a; yak::spirit::packrat_rule<Iterator> b; yak::spirit::packrat_rule<Iterator> c; yak::spirit::packrat_rule<Iterator> d; yak::spirit::packrat_rule<Iterator> e; }; template<typename Iterator> struct test_grammar2_ : boost::spirit::qi::grammar<Iterator> { test_grammar2_() : test_grammar2_::base_type(e) { namespace qi = boost::spirit::qi; a = b | c; b = qi::char_('a') >> &a >> b | qi::char_('c'); c = qi::char_('a') >> &a >> c | qi::char_('d'); d = &a >> qi::char_('a'); e = qi::char_('d') | d >> e; } boost::spirit::qi::rule<Iterator> a; boost::spirit::qi::rule<Iterator> b; boost::spirit::qi::rule<Iterator> c; boost::spirit::qi::rule<Iterator> d; boost::spirit::qi::rule<Iterator> e; }; BOOST_AUTO_TEST_CASE(test_packrat_complexity2) { namespace qi = boost::spirit::qi; std::string s; std::string::iterator first, last; test_grammar2<std::string::iterator> g; test_grammar2_<std::string::iterator> g_; for(int i=8;i<=12;++i) { std::string s2(i, 'a'); s = s2 + "d"; first = s.begin(); last = s.end(); std::cout << "Packrat: Exponential with " << s.size() << " chars." << std::endl; YAK_SPIRIT_PACKRAT_TEST_BLOCK { boost::progress_timer t; BOOST_CHECK(qi::parse(first, last, g)); } yak::spirit::debug::count::out(std::cout); first = s.begin(); last = s.end(); std::cout << "Plain: Exponential with " << s.size() << " chars." << std::endl; { boost::progress_timer t; BOOST_CHECK(qi::parse(first, last, g_)); } } }
[ "atara-y@mx.scn.tv" ]
[ [ [ 1, 375 ] ] ]
6d8e6c6140704f023b4d38cb229052d15dfa6a85
7ede4710c51ee2cad90589e274a5bd587cfcd706
/lsystem-main/pard0lsystem.cpp
e5dba4e8d213b0c81f82453cf3eb23c981052854
[]
no_license
sid1980/l-system-for-osg
7809b0315d4fd7bcfd49fd11129a273f49ea51d1
4931cc1cb818ee7c9d4d25d17ffdaa567a93e8fa
refs/heads/master
2023-03-16T00:21:40.562005
2011-01-09T16:33:46
2011-01-09T16:33:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
171
cpp
#include "precompiled.h" #include "pard0lsystem.h" using namespace AP_LSystem; ParD0LSystem::ParD0LSystem( AbstractFile * file ): Abstract0LSystem( file ) { }
[ "marek@pasicnyk.com@3a20e578-abf7-dd4e-6256-36cca5c9e6b5" ]
[ [ [ 1, 9 ] ] ]
a387089e41bcb444079cb6be0230028d5a59e9a7
3ab5d507d11afdab41c8c1b509cc2a807d717897
/src/VoIPPacketsManager/VoIPPacketsManager.h
b6428247af3eefc586da359aeb9fa915f00aa242
[]
no_license
mkurdej/pwtinproject
73dd952ca7b18c36b0c68124bd4447c9741fa372
f11afa69776c9f9b55c3c3466544ed49e56ebdff
refs/heads/master
2016-09-05T18:39:33.692316
2010-01-19T10:16:55
2010-01-19T10:16:55
32,997,874
0
0
null
null
null
null
UTF-8
C++
false
false
1,738
h
/* * @file VoIPPacketsManager.h * * @date created 2010-01-14 * @author Piotr Gwizdała */ #ifndef VOIPPACKETSMANAGER_H_ #define VOIPPACKETSMANAGER_H_ #include <vector> #include "../ProtocolModule/RTP/RTPPacket.h" #include "../Debug/Debug.h" #include "../Main/Config.h" /** * \~polish * Klasa abstrakcyjna. Dzieli dane na pakiety i wysyła je z odpowiednimi opóźnieniami * korzystając z @ref RTPAgent. * * Dotychczas wykonane są dwie implementacje: @ref StegLACK i @ref NoSteg. * Odpowiada również za przetwarzanie danych w pakietach przychodzących. * Sposób działania zależy od implementacji. * * \~english * Abstract class responsible for dividing data into packets and sending them * with definite delays with the aid of @ref RTPAgent. * * There are to implementations so far: @ref StegLACK and @ref NoSteg. * This module is also responsible for handling the processing of data from * incoming packets. * Exact behavior is implementation-dependent. * * \~ * @see RTPAgent * @see StegLACK * @see NoSteg */ class VoIPPacketsManager { public: Config* config; int lastReadByte; vector<char> audioData; VoIPPacketsManager(Config *cfg); virtual ~VoIPPacketsManager(); /** * Zwraca pakiet który jest gotowy do wysłania. */ virtual RTPPacket& getNextPacket() = 0; /** * Obsługuje otrzymany pakiet. (np. zapisuje do pliku lub rozpoznaje * dane steg. w zależności od implementacji). */ virtual void putReceivedPacketData(RTPPacket& packet) = 0; protected: virtual vector<char> getAudioDataToSend(); void readAudioDataFileToMem(); RTPPacket templatePacket; }; #endif /* VOIPPACKETSMANAGER_H_ */
[ "gwizdek@f427f6ac-f01a-11de-af0a-9d584d74d99e", "marek.kurdej@f427f6ac-f01a-11de-af0a-9d584d74d99e" ]
[ [ [ 1, 1 ], [ 3, 3 ], [ 6, 11 ], [ 13, 13 ], [ 15, 16 ], [ 40, 51 ], [ 56, 69 ], [ 71, 73 ] ], [ [ 2, 2 ], [ 4, 5 ], [ 12, 12 ], [ 14, 14 ], [ 17, 39 ], [ 52, 55 ], [ 70, 70 ] ] ]
d1d2ad1b43eb2dad23746d364490a0250ae78c86
17083b919f058848c3eb038eae37effd1a5b0759
/SimpleGL/sgl/FormatConversion.h
3e5a07e44f8b11a4d70fcced42bece83842f47e6
[]
no_license
BackupTheBerlios/sgl
e1ce68dfc2daa011bdcf018ddce744698cc7bc5f
2ab6e770dfaf5268c1afa41a77c04ad7774a70ed
refs/heads/master
2021-01-21T12:39:59.048415
2011-10-28T16:14:29
2011-10-28T16:14:29
39,894,148
0
0
null
null
null
null
UTF-8
C++
false
false
1,012
h
#ifndef SIMPLE_GL_FORMAT_CONVERSION_H #define SIMPLE_GL_FORMAT_CONVERSION_H #include "Texture.h" namespace sgl { /** Interface for format converter operators */ class FormatConversion { public: /** Convert pixels from source format to dest format * @param sourceFormat - format of the source pixels * @param destFormat - format of the dest pixels * @param numPixels - number of pixels to convert * @param source - source pixels * @param dest [out] - destination pixels * @return true if source pixels succesfully converted, false * if conversion operation is not supported. */ virtual bool Convert( Texture::FORMAT sourceFormat, Texture::FORMAT destFormat, unsigned int numPixels, const void* source, void* dest ) const = 0; virtual ~FormatConversion() {} }; } // namespace sgl #endif // SIMPLE_GL_FORMAT_CONVERSION_H
[ "devnull@localhost" ]
[ [ [ 1, 33 ] ] ]
4bd64486417a98ff817e38e3430b2b7c3b8b82ed
7f6fe18cf018aafec8fa737dfe363d5d5a283805
/samples/titoon/compositebox.h
ba64c43b81be79d95979399761a41d0be4d2ad42
[]
no_license
snori/ntk
4db91d8a8fc836ca9a0dc2bc41b1ce767010d5ba
86d1a32c4ad831e791ca29f5e7f9e055334e8fe7
refs/heads/master
2020-05-18T05:28:49.149912
2009-08-04T16:47:12
2009-08-04T16:47:12
268,861
2
0
null
null
null
null
UTF-8
C++
false
false
281
h
#ifndef __COMPOSITEBOX_H__ #define __COMPOSITEBOX_H__ #include <ntk/interface/view.h> class CompositeBox : public NView { public: CompositeBox(const NRect& frame, const NString& name); private: void set_up_controls_(); };// class CompositeBox #endif//EOH
[ "nrtkszk@gmail.com" ]
[ [ [ 1, 18 ] ] ]
2201cd36415b63a78b148074fd32a4ef06001ce8
9773c3304eecc308671bcfa16b5390c81ef3b23a
/MDI AIPI V.6.92 2003 ( Correct Save Fired Rules, AM =-1, g_currentLine)/AIPI/OutputTabView.h
73c80a205ec432a476170f9554068dbc442f4cad
[]
no_license
15831944/AiPI-1
2d09d6e6bd3fa104d0175cf562bb7826e1ac5ec4
9350aea6ac4c7870b43d0a9f992a1908a3c1c4a8
refs/heads/master
2021-12-02T20:34:03.136125
2011-10-27T00:07:54
2011-10-27T00:07:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,663
h
#if !defined(AFX_OUTPUTTABVIEW_H__746A5662_F368_4BF9_B3C0_7F57544C651E__INCLUDED_) #define AFX_OUTPUTTABVIEW_H__746A5662_F368_4BF9_B3C0_7F57544C651E__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // OutputTabView.h : header file // #include "OXSizeCtrlBar.h" #include "OX3DTabView.h" #include "OXHistoryCtrl.h" #include "FindInFilesExtDlg.h" #include "FileFinder.h" #include "PathFinder.h" ///////////////////////////////////////////////////////////////////////////// // COutputTabView window class COutputTabView : public COXSizeControlBar { // Construction public: DECLARE_DYNCREATE(COutputTabView) COutputTabView(); // protected constructor used by dynamic creation virtual ~COutputTabView(); BOOL Create(CWnd * pParentWnd, const CString& sTitle=_T("Output"), const UINT nID=ID_OUTPUTTABVIEW); // Attributes public: COX3DTabViewContainer m_TabViewContainer; public: //Controls CListCtrl m_listCtrl1; CListCtrl m_listCtrl2; CListCtrl m_listCtrl3; CListCtrl m_listCtrl4; CListCtrl m_listCtrl5; COXHistoryCtrl m_HistoryCtrl; CRichEditCtrl m_editCtrl1; CRichEditCtrl m_editCtrl2; CImageList m_ilTabImageList; CImageList m_ilImageList1; CImageList m_ilImageList2; CImageList m_ilImageList3; CImageList m_ilImageList4; //CFileFinder options attributes bool _bSearching; CFileFinder _finder; CString m_strFindText; // Operations public: LVITEM COutputTabView::AddListItem1( int iItem, int iSubItem, LPTSTR szText, int iImage); LVITEM COutputTabView::AddListItem2( int iItem, int iSubItem, LPTSTR szText, int iImage); LVITEM COutputTabView::AddListItem3( int iItem, int iSubItem, LPTSTR szText, int iImage); LVITEM COutputTabView::AddListItem4( int iItem, int iSubItem, LPTSTR szText, int iImage); void COutputTabView::AddListSubItem1( LVITEM item, int iItem, int iSubItem, LPTSTR szText); void COutputTabView::AddListSubItem2( LVITEM item, int iItem, int iSubItem, LPTSTR szText); void COutputTabView::AddListSubItem3( LVITEM item, int iItem, int iSubItem, LPTSTR szText); void COutputTabView::AddListSubItem4( LVITEM item, int iItem, int iSubItem, LPTSTR szText); void AddMsg(LPCTSTR szFmt, ...); void AddMsg1(CString msg); void AddMsg2(CString msg); int Create3DTabCtrl(); int CreateList1(); int CreateList2(); int CreateList3(); int CreateList4(); int CreateList5(); int CreateHistory1(); int CreateEdit1(); int CreateEdit2(); void PopulateList1(); void PopulateList2(); void PopulateList3(); void PopulateList4(); void PopulateHistory1(); void PopulateEdit1(); void PopulateEdit2(); void DeleteAllList1(); void DeleteAllList2(); void DeleteAllList3(); void DeleteAllEdit1(); void DeleteAllEdit2(); void FindExtAsc(CString strFind, BOOL bCase, BOOL bWord, BOOL bRegularExpression); void FindExtDesc(CString strFind, BOOL bCase, BOOL bWord, BOOL bRegularExpression); void FindInFiles(CString text, CString folder, CString mask, bool subfolder, bool size, int nmin, int nmax); void FindCurrentDirFiles(); //FindInFiles Operations void AddFileToListCtrl3(CString szFilePath, CString szFileName, CString szFileSize, CString szFileDate); void AddStatusListCtrl3(); void SetStatus(int nCount = 0, LPCTSTR szFolder = NULL); public: static void FileFinderProc(CFileFinder *pFinder, DWORD dwCode, void *pCustomParam); LONG m_fSize; CTime m_fDate; // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(COutputTabView) protected: virtual void DoDataExchange(CDataExchange* pDX); //}}AFX_VIRTUAL // Generated message map functions protected: virtual void OnSizedOrDocked(int cx, int cy, BOOL bFloating, int flags); //{{AFX_MSG(COutputTabView) afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnItemchangedList1(NMHDR* pNMHDR, LRESULT* pResult); afx_msg void OnItemchangedList2(NMHDR* pNMHDR, LRESULT* pResult); afx_msg void OnItemchangedList3(NMHDR* pNMHDR, LRESULT* pResult); afx_msg void OnItemchangedList4(NMHDR* pNMHDR, LRESULT* pResult); afx_msg void OnItemchangedList5(NMHDR* pNMHDR, LRESULT* pResult); afx_msg BOOL OnEraseBkgnd(CDC* pDC); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_OUTPUTTABVIEW_H__746A5662_F368_4BF9_B3C0_7F57544C651E__INCLUDED_)
[ "flexdeveloper@gmgs-iMac.local" ]
[ [ [ 1, 163 ] ] ]
a16de781ef8f4b5912cf824fd88edb8363bc770f
27d5670a7739a866c3ad97a71c0fc9334f6875f2
/CPP/Targets/MapLib/Shared/include/MC2Logging.h
a37a1b479870010f82835f7346fec37db1a3233c
[ "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
16,339
h
/* Copyright (c) 1999 - 2010, Vodafone Group Services Ltd All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Vodafone Group Services Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef MC2LOGGING_H #define MC2LOGGING_H //#include "mcostream.h" #ifdef __SYMBIAN32__ #include <iostream> using namespace std; //#define NO_REAL_OSTREAM extern std::ostream mc2log_real; #undef DEBUG_LEVEL_1 #undef DEBUG_LEVEL_2 #undef DEBUG_LEVEL_4 #undef DEBUG_LEVEL_8 // the debug stream #ifdef DEBUG_LEVEL_1 # define mc2dbg mc2log # define mc2dbg1 mc2log #else # define mc2dbg if (false) mc2log # define mc2dbg1 if (false) mc2log #endif #ifdef DEBUG_LEVEL_2 # define mc2dbg2 mc2log #else # define mc2dbg2 if (false) mc2log #endif #ifdef DEBUG_LEVEL_4 # define mc2dbg4 mc2log #else # define mc2dbg4 if (false) mc2log #endif #ifdef DEBUG_LEVEL_8 # define mc2dbg8 mc2log #else # define mc2dbg8 if (false) mc2log #endif # define mc2log if (false) mc2log_real // manipulator that chooses info level logging inline std::ostream & info (std::ostream & os) {return os;} // manipulator that chooses warning level logging inline std::ostream & warn (std::ostream & os) {return os;} // manipulator that chooses error level logging inline std::ostream & error (std::ostream & os) { return os;} // manipulator that chooses fatal level logging inline std::ostream & fatal (std::ostream & os) {return os;} // small macro that outputs the filename and line of the current line of code // when used on an ostream. #define here __FILE__ ":" << __LINE__ // macro to output an IP numerically #define prettyPrintIP(a) int((a & 0xff000000) >> 24) << "." \ << int((a & 0x00ff0000) >> 16) << "." \ << int((a & 0x0000ff00) >> 8) << "." \ << int (a & 0x000000ff) // macro to print citation marks before and after a #define MC2CITE(a) '"' << (a) << '"' // empty debug macros defines for Symbian #define DEBUG8(a) #define DEBUG4(a) #define DEBUG2(a) #define DEBUG1(a) #define DEBUG_DB(a) #define DEBUG_DEL(a) #define DEBUG_CM(a) #define DEBUG_GDF(a) // empty macro definitions // #define hex 'H' // #define dec 'D' #elif !defined( __unix__ ) // #include <malloc.h> #include <iostream> using namespace std; #undef DEBUG_LEVEL_1 #undef DEBUG_LEVEL_2 #undef DEBUG_LEVEL_4 #undef DEBUG_LEVEL_8 extern ostream& mc2log; #define MINFO(a) // the debug stream #ifdef DEBUG_LEVEL_1 # define mc2dbg mc2log # define mc2dbg1 mc2log #else # define mc2dbg if (false) mc2log # define mc2dbg1 if (false) mc2log #endif #ifdef DEBUG_LEVEL_2 # define mc2dbg2 mc2log #else # define mc2dbg2 if (false) mc2log #endif #ifdef DEBUG_LEVEL_4 # define mc2dbg4 mc2log #else # define mc2dbg4 if (false) mc2log #endif #ifdef DEBUG_LEVEL_8 # define mc2dbg8 mc2log #else # define mc2dbg8 if (false) mc2log #endif // manipulator that chooses info level logging ostream & info (ostream & os); // manipulator that chooses warning level logging ostream & warn (ostream & os); // manipulator that chooses error level logging ostream & error (ostream & os); // manipulator that chooses fatal level logging ostream & fatal (ostream & os); // small macro that outputs the filename and line of the current line of code // when used on an ostream. #define here __FILE__ ":" << __LINE__ // macro to output an IP numerically #define prettyPrintIP(a) int((a & 0xff000000) >> 24) << "." \ << int((a & 0x00ff0000) >> 16) << "." \ << int((a & 0x0000ff00) >> 8) << "." \ << int (a & 0x000000ff) // macro to output an map id in hex #define prettyMapIDFill(a) "0x" << setw(8) << setfill('0') << hex << a << dec #define prettyMapID(a) "0x" << hex << a << dec // macro to print citation marks before and after a #define MC2CITE(a) '"' << (a) << '"' #else // Unix // #include <malloc.h> #include <iostream> #include <iomanip> using namespace std; /** * MC2 logging helper class * */ class MC2Logging { public: /** * Creates a log ostream connected to another ostream (eg cerr) * via LogBuffer * @param outStream The ostream to chain the output to * @return reference to the created ostream */ static ostream& createLogStream(ostream& outStream); /** * Creates a log ostream connected to a file descriptor * via LogBuffer * @param outFD The file descriptor to send the output to * @return reference to the created ostream */ static ostream& createLogStream(int outFD); /** * Deletes all LogHandlers attached to a logging ostream * @param logStream The stream to delete LogHandlers from */ static void deleteHandlers(ostream& logStream); /** * Turn debugging on/off * @param debug If true debugging is turned on, if false all debugging * output is sent to /dev/null */ static void debugOutput(bool debug); }; /** * Abstract superclass for a LogHandler that's derived to build * external logging features (eg syslog, SNMP traps). * */ class LogHandler { public: /** * handleMessage is called with a new log entry (level and text) * @param level The loglevel, see LogBuffer * @param msg Pointer to the log message * @param msgLen Length of the log message * @param levelStr String representation of the log level * @param timeStamp String representation of the time stamp */ virtual void handleMessage(int level, const char* msg, int msgLen, const char* levelStr, const char* timeStamp) = 0; }; /** * An iostream streambuf that prefixes each new line with the * date and time and handles other things related to MC2 logging. * */ class LogBuffer: public streambuf { public: /** * Initializes the LogBuffer, selects where output is sent. * The streambuf passed is not deleted by the destructor! * @param buf The streambuf to output to */ LogBuffer(streambuf *buf); /** * Initializes the LogBuffer, selects where output is sent. * @param outFD The file descriptor to output to */ LogBuffer(int outFD); /** Initializes the LogBuffer, selects where output is sent. * @param outBuf The LogBuffer (from ::mc2log usually) * to use for daisy-chaining of loghandlers. */ LogBuffer(LogBuffer* outBuf); /** * Cleans up */ virtual ~LogBuffer(); /** * Set an extra logging prefix * @param prefix Pointer to prefix string */ void setPrefix(char* prefix); /** * Deletes all LogHandlers attached */ void deleteHandlers(); /** * Add a handler * @param level The log levels we want to be notified at * @param handler Pointer to a LogHandler instance * @return true if success */ bool addHandler(int level, LogHandler* handler); /** * Turn debugging on/off * @param debug If true debugging is turned on, if false all debugging * output is sent to /dev/null */ void setDebug(bool debug); /** * Used to output and notify any registered handlers from the outside * @param level The loglevel * @param msg Pointer to the log message * @param msgLen Length of the log message * @param levelStr String representation of the log level * @param timeStamp String representation of the time stamp */ void notifyExternal(int level, const char* msg, int msgLen, const char* levelStr, const char* timeStamp); /** * The log levels */ enum LOGLEVELS { LOGLEVEL_DEBUG = 1, LOGLEVEL_INFO = 2, LOGLEVEL_WARN = 4, LOGLEVEL_ERROR = 8, LOGLEVEL_FATAL = 16 }; protected: /** * Notifies any registered handlers. */ void notify(); /** * Output to either the streambuf or the file descriptor * associated. * @param buf Pointer to the buffer * @param len Size of the data to output * @return Size of the data output (same as len if OK), otherwise * it depends on whether streambuf::sputn() or write() was * used internally. */ int output(const char* buf, int len); /** * Outputs the first half of the (date, time) * @return 0 if OK, EOF if error */ int putTime(); /** * Outputs the second half of the prefix (the level) * @return 0 if OK, EOF if error */ int putLevel(); /** * Called when there's a new character to output. * @return ??? */ int overflow(int c); /** * Called to read a character from the input, doesn't advance to * the next character. * @return ??? */ int underflow(); /** * Called to read a character from the input, advances to the * next character. * @return ??? */ int uflow(); /** * Called to sync internal state with external representation * @return ??? */ int sync(); private: /** * The streambuf we send our output to */ streambuf* m_buf; /** * The file descriptor we send output to. */ int m_fd; /** * Flag that's set to true when encounter a newline */ bool m_newline; /** * Flag that's set when we're doing magic (handling our special * manipulators (info, warn, err) */ bool m_magic; /** * The log level we're using */ int m_level; /** * Our character buffer, needed for the Notifiers. */ char* m_buffer; /** * Last timestamp */ char m_timeBuf[32]; /** * Last level string */ char m_levelBuf[32]; /** * Current position in the buffer. */ int m_bufPos; /** * Output debug text or not? */ bool m_debug; /** * The prefix string */ char* m_prefix; /** * Container for a LogHandler used with the simple linked lists * that the handlers are placed in. */ class LogHandlerItem { public: /** * Create and add to the list specified * @param handler Pointer to the LogHandler instance * @param list Pointer to pointer to list */ LogHandlerItem(LogHandler* handler, LogHandlerItem** list); LogHandler* m_handler; LogHandlerItem* m_next; }; /** * Remove a loghandler list */ void removeList(LogHandlerItem*& list); /** * Simple linked list for LogHandlers for level LOGLEVEL_DEBUG */ LogHandlerItem* m_handlersDebug; /** * Simple linked list for LogHandlers for level LOGLEVEL_INFO */ LogHandlerItem* m_handlersInfo; /** * Simple linked list for LogHandlers for level LOGLEVEL_WARN */ LogHandlerItem* m_handlersWarn; /** * Simple linked list for LogHandlers for level LOGLEVEL_ERROR */ LogHandlerItem* m_handlersError; /** * Simple linked list for LogHandlers for level LOGLEVEL_FATAL */ LogHandlerItem* m_handlersFatal; /** * LogBuffer to use for daisy-chaining. */ LogBuffer* m_externalBuffer; }; // the logging stream extern ostream& mc2log_ostream; /* extern struct mallinfo mi; #define MINFO(a) mi = mallinfo(); mc2dbg << a << " minfo: " << mi.uordblks << endl; */ #define MINFO(a) // the debug stream #ifdef MC2LOGGING_DISABLED # define mc2log if (false) mc2log_ostream #else # define mc2log mc2log_ostream #endif #ifdef DEBUG_LEVEL_1 # define mc2dbg mc2log_ostream # define mc2dbg1 mc2log_ostream #else # define mc2dbg if (false) mc2log_ostream # define mc2dbg1 if (false) mc2log_ostream #endif #ifdef DEBUG_LEVEL_2 # define mc2dbg2 mc2log_ostream #else # define mc2dbg2 if (false) mc2log_ostream #endif #ifdef DEBUG_LEVEL_4 # define mc2dbg4 mc2log_ostream #else # define mc2dbg4 if (false) mc2log_ostream #endif #ifdef DEBUG_LEVEL_8 # define mc2dbg8 mc2log_ostream #else # define mc2dbg8 if (false) mc2log_ostream #endif // manipulator that chooses info level logging ostream & info (ostream & os); // manipulator that chooses warning level logging ostream & warn (ostream & os); // manipulator that chooses error level logging ostream & error (ostream & os); // manipulator that chooses fatal level logging ostream & fatal (ostream & os); // small macro that outputs the filename and line of the current line of code // when used on an ostream. #define here __FILE__ ":" << __LINE__ // macro to output an IP numerically #define prettyPrintIP(a) int((a & 0xff000000) >> 24) << "." \ << int((a & 0x00ff0000) >> 16) << "." \ << int((a & 0x0000ff00) >> 8) << "." \ << int (a & 0x000000ff) // macro to output an map id in hex #define prettyMapIDFill(a) "0x" << setw(8) << setfill('0') << hex << a << dec #define prettyMapID(a) "0x" << hex << a << dec // macro to print citation marks before and after a #define MC2CITE(a) '"' << (a) << '"' #endif /// macro to print a hex number prefixed by 0x and then switch to dec again #define MC2HEX(a) "0x" << hex << (a) << dec #endif // MC2LOGGING_H
[ "hlars@sema-ovpn-morpheus.itinerary.com" ]
[ [ [ 1, 550 ] ] ]
5044831ea8a9a2422431a8d7fdb21139d2f937de
c95a83e1a741b8c0eb810dd018d91060e5872dd8
/Game/ObjectDLL/ObjectShared/DisplayMeter.cpp
d372aba9f25e0256511d42fd92ab3f47960d2bd2
[]
no_license
rickyharis39/nolf2
ba0b56e2abb076e60d97fc7a2a8ee7be4394266c
0da0603dc961e73ac734ff365bfbfb8abb9b9b04
refs/heads/master
2021-01-01T17:21:00.678517
2011-07-23T12:11:19
2011-07-23T12:11:19
38,495,312
1
0
null
null
null
null
UTF-8
C++
false
false
12,760
cpp
// ----------------------------------------------------------------------- // // // MODULE : DisplayMeter.cpp // // PURPOSE : DisplayMeter - Implementation // // CREATED : 7/19/00 // // (c) 2000 Monolith Productions, Inc. All Rights Reserved // // ----------------------------------------------------------------------- // #include "stdafx.h" #include "DisplayMeter.h" #include "ServerUtilities.h" #include "ObjectMsgs.h" #include "ParsedMsg.h" #include "CommandMgr.h" #include "MsgIDs.h" LINKFROM_MODULE( DisplayMeter ); #pragma force_active on BEGIN_CLASS(DisplayMeter) PROP_DEFINEGROUP(Phase1, PF_GROUP(1)) ADD_LONGINTPROP_FLAG(Phase1Value, -1, PF_GROUP(1)) ADD_STRINGPROP_FLAG(Phase1Cmd, "", PF_GROUP(1) | PF_NOTIFYCHANGE) PROP_DEFINEGROUP(Phase2, PF_GROUP(2)) ADD_LONGINTPROP_FLAG(Phase2Value, -1, PF_GROUP(2)) ADD_STRINGPROP_FLAG(Phase2Cmd, "", PF_GROUP(2) | PF_NOTIFYCHANGE) PROP_DEFINEGROUP(Phase3, PF_GROUP(3)) ADD_LONGINTPROP_FLAG(Phase3Value, -1, PF_GROUP(3)) ADD_STRINGPROP_FLAG(Phase3Cmd, "", PF_GROUP(3) | PF_NOTIFYCHANGE) PROP_DEFINEGROUP(Phase4, PF_GROUP(4)) ADD_LONGINTPROP_FLAG(Phase4Value, -1, PF_GROUP(4)) ADD_STRINGPROP_FLAG(Phase4Cmd, "", PF_GROUP(4) | PF_NOTIFYCHANGE) PROP_DEFINEGROUP(Phase5, PF_GROUP(5)) ADD_LONGINTPROP_FLAG(Phase5Value, -1, PF_GROUP(5)) ADD_STRINGPROP_FLAG(Phase5Cmd, "", PF_GROUP(5) | PF_NOTIFYCHANGE) ADD_BOOLPROP(RemoveWhenEmpty, LTTRUE) END_CLASS_DEFAULT_FLAGS_PLUGIN(DisplayMeter, BaseClass, NULL, NULL, 0, CDisplayMeterPlugin) #pragma force_active off CMDMGR_BEGIN_REGISTER_CLASS( DisplayMeter ) CMDMGR_ADD_MSG( SHOW, 2, NULL, "SHOW <initial value>" ) CMDMGR_ADD_MSG( PLUS, 2, NULL, "PLUS <amount>" ) CMDMGR_ADD_MSG( MINUS, 2, NULL, "MINUS <amount>" ) CMDMGR_ADD_MSG( SETVAL, 2, NULL, "SETVAL <value>" ) CMDMGR_ADD_MSG( HIDE, 1, NULL, "HIDE" ) CMDMGR_END_REGISTER_CLASS( DisplayMeter, BaseClass ) // ----------------------------------------------------------------------- // // // ROUTINE: CDisplayMeterPlugin::PreHook_PropChanged // // PURPOSE: Check our command strings // // ----------------------------------------------------------------------- // LTRESULT CDisplayMeterPlugin::PreHook_PropChanged( const char *szObjName, const char *szPropName, const int nPropType, const GenericProp &gpPropValue, ILTPreInterface *pInterface, const char *szModifiers ) { // Only our commands are marked for change notification so just send it to the CommandMgr.. if( m_CommandMgrPlugin.PreHook_PropChanged( szObjName, szPropName, nPropType, gpPropValue, pInterface, szModifiers ) == LT_OK ) { return LT_OK; } return LT_UNSUPPORTED; } // ----------------------------------------------------------------------- // // // ROUTINE: DisplayMeter::DisplayMeter() // // PURPOSE: Initialize object // // ----------------------------------------------------------------------- // DisplayMeter::DisplayMeter() : GameBase(OT_NORMAL) { m_bRemoveWhenEmpty = LTTRUE; m_nValue = 0; } // ----------------------------------------------------------------------- // // // ROUTINE: DisplayMeter::~DisplayMeter() // // PURPOSE: Deallocate object // // ----------------------------------------------------------------------- // DisplayMeter::~DisplayMeter() { } // ----------------------------------------------------------------------- // // // ROUTINE: DisplayMeter::EngineMessageFn // // PURPOSE: Handle engine messages // // ----------------------------------------------------------------------- // uint32 DisplayMeter::EngineMessageFn(uint32 messageID, void *pData, LTFLOAT fData) { switch(messageID) { case MID_UPDATE: { Update(); } break; case MID_PRECREATE: { if (fData == PRECREATE_WORLDFILE || fData == PRECREATE_STRINGPROP) { ReadProp((ObjectCreateStruct*)pData); } } break; case MID_INITIALUPDATE: { if (fData != INITIALUPDATE_SAVEGAME) { InitialUpdate(); } } break; case MID_SAVEOBJECT: { Save((ILTMessage_Write*)pData); } break; case MID_LOADOBJECT: { Load((ILTMessage_Read*)pData); } break; default : break; } return BaseClass::EngineMessageFn(messageID, pData, fData); } // ----------------------------------------------------------------------- // // // ROUTINE: DisplayMeter::ReadProp // // PURPOSE: Set property value // // ----------------------------------------------------------------------- // void DisplayMeter::ReadProp(ObjectCreateStruct *) { GenericProp genProp; char szProp[128]; for (int i=1; i <= DM_MAX_NUMBER_OF_PHASES; i++) { sprintf(szProp, "Phase%dValue", i); if (g_pLTServer->GetPropGeneric(szProp, &genProp) == LT_OK) { m_PhaseData[i-1].nValue = genProp.m_Long; } sprintf(szProp, "Phase%dCmd", i); if (g_pLTServer->GetPropGeneric(szProp, &genProp) == LT_OK) { if (genProp.m_String[0]) { m_PhaseData[i-1].hstrCmd = g_pLTServer->CreateString(genProp.m_String); } } } if (g_pLTServer->GetPropGeneric("RemoveWhenEmpty", &genProp) == LT_OK) { m_bRemoveWhenEmpty = genProp.m_Bool; } } // ----------------------------------------------------------------------- // // // ROUTINE: DisplayMeter::InitialUpdate() // // PURPOSE: First update // // ----------------------------------------------------------------------- // void DisplayMeter::InitialUpdate() { // Must be triggered on... SetNextUpdate(UPDATE_NEVER); } // ----------------------------------------------------------------------- // // // ROUTINE: DisplayMeter::Update() // // PURPOSE: Update // // ----------------------------------------------------------------------- // void DisplayMeter::Update() { SetNextUpdate(UPDATE_NEVER); } // --------------------------------------------------------------------------- // // // ROUTINE: DisplayMeter::OnTrigger() // // PURPOSE: Process trigger messages // // --------------------------------------------------------------------------- // bool DisplayMeter::OnTrigger(HOBJECT hSender, const CParsedMsg &cMsg) { static CParsedMsg::CToken s_cTok_Show("show"); static CParsedMsg::CToken s_cTok_Plus("plus"); static CParsedMsg::CToken s_cTok_Minus("minus"); static CParsedMsg::CToken s_cTok_SetVal("setval"); static CParsedMsg::CToken s_cTok_Hide("hide"); if (cMsg.GetArg(0) == s_cTok_Show) { if (cMsg.GetArgCount() > 1) { HandleShow((uint8)atoi(cMsg.GetArg(1))); } else HandleShow(100); } else if (cMsg.GetArg(0) == s_cTok_Plus) { if (cMsg.GetArgCount() > 1) { HandlePlus((uint8)atoi(cMsg.GetArg(1))); } } else if (cMsg.GetArg(0) == s_cTok_Minus) { if (cMsg.GetArgCount() > 1) { HandleMinus((uint8)atoi(cMsg.GetArg(1))); } } else if (cMsg.GetArg(0) == s_cTok_SetVal) { if (cMsg.GetArgCount() > 1) { HandleSet((uint8)atoi(cMsg.GetArg(1))); } } else if (cMsg.GetArg(0) == s_cTok_Hide) { HandleEnd(); } else return GameBase::OnTrigger(hSender, cMsg); return true; } // --------------------------------------------------------------------------- // // // ROUTINE: DisplayMeter::HandleShow() // // PURPOSE: Handle show message // // --------------------------------------------------------------------------- // void DisplayMeter::HandleShow(uint8 initVal) { if (initVal == 0) return; if (initVal > 100) initVal = 100; m_nValue = initVal; // Send message to clients telling them about the DisplayMeter... UpdateClients(); // Update the DisplayMeter... // SetNextUpdate(m_hObject, UPDATE_NEXT_FRAME); } // --------------------------------------------------------------------------- // // // ROUTINE: DisplayMeter::HandleSet() // // PURPOSE: Handle set message // // --------------------------------------------------------------------------- // void DisplayMeter::HandleSet(uint8 val) { if (val == 0) { if (m_nValue > 0) HandleEnd(); return; } if (val > 100) val = 100; if (m_nValue == 0) { HandleShow(val); return; } m_nValue = val; // Send message to clients telling them about the DisplayMeter... UpdateClients(); // Update the DisplayMeter... // SetNextUpdate(m_hObject, UPDATE_NEXT_FRAME); } // --------------------------------------------------------------------------- // // // ROUTINE: DisplayMeter::HandlePlus() // // PURPOSE: Handle plus message // // --------------------------------------------------------------------------- // void DisplayMeter::HandlePlus(uint8 val) { if (val == 0) return; if (val > 100) val = 100; if (m_nValue == 0) { HandleShow(val); return; } m_nValue += val; if (m_nValue > 100) m_nValue = 100; // Send message to clients telling them about the DisplayMeter... UpdateClients(); // Update the DisplayMeter... // SetNextUpdate(m_hObject, UPDATE_NEXT_FRAME); } // --------------------------------------------------------------------------- // // // ROUTINE: DisplayMeter::HandleMinus() // // PURPOSE: Handle plus message // // --------------------------------------------------------------------------- // void DisplayMeter::HandleMinus(uint8 val) { if (val == 0) return; if (val > 100) val = 100; int newValue = m_nValue - val; if (newValue < 0) newValue = 0; int newPhase = -1; int testPhase = 0; //see if we've entered a new phase while (testPhase < DM_MAX_NUMBER_OF_PHASES) { //if our new value is less than the phase, but our old value is greater than it, we're in a new phase if ((int)newValue <= m_PhaseData[testPhase].nValue && (int)m_nValue > m_PhaseData[testPhase].nValue) { //if we find more than one possible phase use the lowest valued one if (newPhase < 0 || m_PhaseData[testPhase].nValue < m_PhaseData[newPhase].nValue) newPhase = testPhase; } testPhase++; } //if we have entered a new phase, see if it has a command if (newPhase >= 0) { if (m_PhaseData[newPhase].hstrCmd) { const char* pCmd = g_pLTServer->GetStringData(m_PhaseData[newPhase].hstrCmd); if (pCmd && g_pCmdMgr->IsValidCmd(pCmd)) { g_pCmdMgr->Process(pCmd, m_hObject, m_hObject); } } } if (newValue == 0) { HandleEnd(); return; } m_nValue = newValue; // Send message to clients telling them about the DisplayMeter... UpdateClients(); // Update the DisplayMeter... // SetNextUpdate(m_hObject, UPDATE_NEXT_FRAME); } // ----------------------------------------------------------------------- // // // ROUTINE: DisplayMeter::HandleEnd() // // PURPOSE: Handle the DisplayMeter ending // // ----------------------------------------------------------------------- // void DisplayMeter::HandleEnd() { m_nValue = 0; if (m_bRemoveWhenEmpty) { g_pLTServer->RemoveObject(m_hObject); } UpdateClients(); } // --------------------------------------------------------------------------- // // // ROUTINE: DisplayMeter::UpdateClients() // // PURPOSE: Update the client's time // // --------------------------------------------------------------------------- // void DisplayMeter::UpdateClients() { // Send message to clients telling them about the DisplayMeter... CAutoMessage cMsg; cMsg.Writeuint8(MID_DISPLAY_METER); cMsg.Writeuint8(m_nValue); g_pLTServer->SendToClient(cMsg.Read(), LTNULL, MESSAGE_GUARANTEED); } // ----------------------------------------------------------------------- // // // ROUTINE: DisplayMeter::Save // // PURPOSE: Save the object // // ----------------------------------------------------------------------- // void DisplayMeter::Save(ILTMessage_Write *pMsg) { if (!pMsg) return; SAVE_BOOL(m_bRemoveWhenEmpty); SAVE_BYTE(m_nValue); for (int i=0; i < DM_MAX_NUMBER_OF_PHASES; i++) { m_PhaseData[i].Save(pMsg); } } // ----------------------------------------------------------------------- // // // ROUTINE: DisplayMeter::Load // // PURPOSE: Load the object // // ----------------------------------------------------------------------- // void DisplayMeter::Load(ILTMessage_Read *pMsg) { if (!pMsg) return; LOAD_BOOL(m_bRemoveWhenEmpty); LOAD_BYTE(m_nValue); for (int i=0; i < DM_MAX_NUMBER_OF_PHASES; i++) { m_PhaseData[i].Load(pMsg); } if (m_nValue > 0) { UpdateClients(); } }
[ "vytautasrask@gmail.com" ]
[ [ [ 1, 517 ] ] ]
ecb5ac7f358987c7e69d52c25a9f2e1e080420c2
709cd826da3ae55945fd7036ecf872ee7cdbd82a
/Term/WildMagic2/Source/Approximation/WmlApprParaboloidFit3.cpp
927fa182abef899be6f6e639d4d5b8cac46130e5
[]
no_license
argapratama/kucgbowling
20dbaefe1596358156691e81ccceb9151b15efb0
65e40b6f33c5511bddf0fa350c1eefc647ace48a
refs/heads/master
2018-01-08T15:27:44.784437
2011-06-19T15:23:39
2011-06-19T15:23:39
36,738,655
0
0
null
null
null
null
UTF-8
C++
false
false
5,299
cpp
// 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. // Fitting a Paraboloid Uusing Least Squares // // Given a set of samples (x_i,y_i,z_i) for 0 <= i < N and assuming // that the true values lie on a paraboloid // z = p0*x*x + p1*x*y + p2*y*y + p3*x + p4*y + p5 = Dot(P,Q(x,y)) // where P = (p0,p1,p2,p3,p4,p5) and Q(x,y) = (x*x,x*y,y*y,x,y,1), // select P to minimize the sum of squared errors // E(P) = sum_{i=0}^{N-1} [Dot(P,Q_i)-z_i]^2 // where Q_i = Q(x_i,y_i). // // The minimum occurs when the gradient of E is the zero vector, // grad(E) = 2 sum_{i=0}^{N-1} [Dot(P,Q_i)-z_i] Q_i = 0 // Some algebra converts this to a system of 6 equations in 6 unknowns: // [(sum_{i=0}^{N-1} Q_i Q_i^t] P = sum_{i=0}^{N-1} z_i Q_i // The product Q_i Q_i^t is a product of the 6x1 matrix Q_i with the // 1x6 matrix Q_i^t, the result being a 6x6 matrix. // // Define the 6x6 symmetric matrix A = sum_{i=0}^{N-1} Q_i Q_i^t and the 6x1 // vector B = sum_{i=0}^{N-1} z_i Q_i. The choice for P is the solution to // the linear system of equations A*P = B. The entries of A and B indicate // summations over the appropriate product of variables. For example, // s(x^3 y) = sum_{i=0}^{N-1} x_i^3 y_i. // // +- -++ + +- -+ // | s(x^4) s(x^3 y) s(x^2 y^2) s(x^3) s(x^2 y) s(x^2) ||p0| |s(z x^2)| // | s(x^2 y^2) s(x y^3) s(x^2 y) s(x y^2) s(x y) ||p1| |s(z x y)| // | s(y^4) s(x y^2) s(y^3) s(y^2) ||p2| = |s(z y^2)| // | s(x^2) s(x y) s(x) ||p3| |s(z x) | // | s(y^2) s(y) ||p4| |s(z y) | // | s(1) ||p5| |s(z) | // +- -++ + +- -+ #include "WmlApprParaboloidFit3.h" #include "WmlLinearSystem.h" using namespace Wml; //---------------------------------------------------------------------------- template <class Real> bool Wml::ParaboloidFit (int iQuantity, const Vector3<Real>* akPoint, Real afCoeff[6]) { // allocate linear system (matrix is zeroed initially) GMatrix<Real> kMat(6,6); Real afRHS[6]; memset(afRHS,0,6*sizeof(Real)); for (int i = 0; i < iQuantity; i++) { Real fX2 = akPoint[i].X()*akPoint[i].X(); Real fXY = akPoint[i].X()*akPoint[i].Y(); Real fY2 = akPoint[i].Y()*akPoint[i].Y(); Real fZX = akPoint[i].Z()*akPoint[i].X(); Real fZY = akPoint[i].Z()*akPoint[i].Y(); Real fX3 = akPoint[i].X()*fX2; Real fX2Y = fX2*akPoint[i].Y(); Real fXY2 = akPoint[i].X()*fY2; Real fY3 = akPoint[i].Y()*fY2; Real fZX2 = akPoint[i].Z()*fX2; Real fZXY = akPoint[i].Z()*fXY; Real fZY2 = akPoint[i].Z()*fY2; Real fX4 = fX2*fX2; Real fX3Y = fX3*akPoint[i].Y(); Real fX2Y2 = fX2*fY2; Real fXY3 = akPoint[i].X()*fY3; Real fY4 = fY2*fY2; kMat[0][0] += fX4; kMat[0][1] += fX3Y; kMat[0][2] += fX2Y2; kMat[0][3] += fX3; kMat[0][4] += fX2Y; kMat[0][5] += fX2; kMat[1][2] += fXY3; kMat[1][4] += fXY2; kMat[1][5] += fXY; kMat[2][2] += fY4; kMat[2][4] += fY3; kMat[2][5] += fY2; kMat[3][3] += fX2; kMat[3][5] += akPoint[i].X(); kMat[4][5] += akPoint[i].Y(); afRHS[0] += fZX2; afRHS[1] += fZXY; afRHS[2] += fZY2; afRHS[3] += fZX; afRHS[4] += fZY; afRHS[5] += akPoint[i].Z(); } kMat[1][0] = kMat[0][1]; kMat[1][1] = kMat[0][2]; kMat[1][3] = kMat[0][4]; kMat[2][0] = kMat[0][2]; kMat[2][1] = kMat[1][2]; kMat[2][3] = kMat[1][4]; kMat[3][0] = kMat[0][3]; kMat[3][1] = kMat[1][3]; kMat[3][2] = kMat[2][3]; kMat[3][4] = kMat[1][5]; kMat[4][0] = kMat[0][4]; kMat[4][1] = kMat[1][4]; kMat[4][2] = kMat[2][4]; kMat[4][3] = kMat[3][4]; kMat[4][4] = kMat[2][5]; kMat[5][0] = kMat[0][5]; kMat[5][1] = kMat[1][5]; kMat[5][2] = kMat[2][5]; kMat[5][3] = kMat[3][5]; kMat[5][4] = kMat[4][5]; kMat[5][5] = (Real)iQuantity; return LinearSystem<Real>::SolveSymmetric(kMat,afRHS,afCoeff); } //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- // explicit instantiation //---------------------------------------------------------------------------- namespace Wml { template WML_ITEM bool ParaboloidFit<float> (int, const Vector3<float>*, float[6]); template WML_ITEM bool ParaboloidFit<double> (int, const Vector3<double>*, double[6]); } //----------------------------------------------------------------------------
[ "pocatnas@gmail.com" ]
[ [ [ 1, 139 ] ] ]
5f08351285629bf3f5728797fef67835c1ef605c
28aa23d9cb8f5f4e8c2239c70ef0f8f6ec6d17bc
/mytesgnikrow --username hotga2801/Project/FaceDetect_V1.3(6)/FaceDetect.cpp
a7d2d249bdd10857655aa561aa99072ce13b6f52
[]
no_license
taicent/mytesgnikrow
09aed8836e1297a24bef0f18dadd9e9a78ec8e8b
9264faa662454484ade7137ee8a0794e00bf762f
refs/heads/master
2020-04-06T04:25:30.075548
2011-02-17T13:37:16
2011-02-17T13:37:16
34,991,750
0
0
null
null
null
null
UTF-8
C++
false
false
4,088
cpp
// FaceDetect.cpp : Defines the class behaviors for the application. // #include "stdafx.h" #include <vector> #include <fstream> using namespace std; #include "IntImage.h" #include "SimpleClassifier.h" #include "AdaBoostClassifier.h" #include "Global.h" #include "CascadeClassifier.h" #include "learn.h" #include "FaceDetect.h" #include "MainFrm.h" #include "FaceDetectDoc.h" #include "FaceDetectView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CFaceDetectApp BEGIN_MESSAGE_MAP(CFaceDetectApp, CWinApp) //{{AFX_MSG_MAP(CFaceDetectApp) ON_COMMAND(ID_APP_ABOUT, OnAppAbout) //}}AFX_MSG_MAP // Standard file based document commands ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) // Standard print setup command ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CFaceDetectApp construction CFaceDetectApp::CFaceDetectApp() { // TODO: add construction code here, // Place all significant initialization in InitInstance } ///////////////////////////////////////////////////////////////////////////// // The one and only CFaceDetectApp object CFaceDetectApp theApp; ///////////////////////////////////////////////////////////////////////////// // CFaceDetectApp initialization BOOL CFaceDetectApp::InitInstance() { AfxEnableControlContainer(); // Change the registry key under which our settings are stored. // TODO: You should modify this string to be something appropriate // such as the name of your company or organization. SetRegistryKey(_T("Local AppWizard-Generated Applications")); LoadStdProfileSettings(); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CFaceDetectDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CFaceDetectView)); AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; // The one and only window has been initialized, so show and update it. m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); InitGlobalData(); return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CAboutDlg dialog used for App About class CAboutDlg : public CDialog { public: CAboutDlg(); // Dialog Data //{{AFX_DATA(CAboutDlg) enum { IDD = IDD_ABOUTBOX }; //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: //{{AFX_MSG(CAboutDlg) // No message handlers //}}AFX_MSG DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { //{{AFX_DATA_INIT(CAboutDlg) //}}AFX_DATA_INIT } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAboutDlg) //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) //{{AFX_MSG_MAP(CAboutDlg) // No message handlers //}}AFX_MSG_MAP END_MESSAGE_MAP() // App command to run the dialog void CFaceDetectApp::OnAppAbout() { CAboutDlg aboutDlg; aboutDlg.DoModal(); } ///////////////////////////////////////////////////////////////////////////// // CFaceDetectApp message handlers int CFaceDetectApp::ExitInstance() { ClearUpGlobalData(); return CWinApp::ExitInstance(); }
[ "hotga2801@ecd9aaca-b8df-3bf4-dfa7-576663c5f076" ]
[ [ [ 1, 159 ] ] ]
7eda9e1150efccc422f1b9ccecd6691f3d9128ad
51ebb9684ac1a4b65a5426e5c9ee79ebf8eb3db8
/Windows/gclib/Hash/Hash.cpp
c5954ad85140e917131e5ac2e29af63deb408dee
[]
no_license
buf1024/lgcbasic
d4dfe6a6bd19e4e4ac0e5ac2b7a0590e04dd5779
11db32c9be46d9ac0740429e09ebf880a7a00299
refs/heads/master
2021-01-10T12:55:12.046835
2011-09-03T15:45:57
2011-09-03T15:45:57
49,615,513
0
0
null
null
null
null
UTF-8
C++
false
false
928
cpp
//////////////////////////////////////////////////////////////////////////////////////// // // LGCUI -- Personal Windowless UI Library Project // // FileName : Hash.cpp // Purpose : // Version : 2010-11-9 20:09:19) 1.0 Created // Author : heidong // Contact : buf1024@gmail.com // Copyright(c): HEIDONG //////////////////////////////////////////////////////////////////////////////////////// #include "Hash.h" #include "HashImpl.h" Hash::Hash(HashImpl* pImpl) : m_pImpl(pImpl) { _ASSERT(pImpl != NULL); } Hash::~Hash() { if (m_pImpl) { delete m_pImpl; m_pImpl = NULL; } } StdString Hash::GetStringHash(std::string strValue) { return m_pImpl->GetStringHash(strValue); } StdString Hash::GetStringHash(std::wstring strValue) { return m_pImpl->GetStringHash(strValue); } StdString Hash::GetFileHash(StdString strFile) { return m_pImpl->GetFileHash(strFile); }
[ "buf1024@10f8a008-2033-b5f4-5ad9-01b5c2a83ee0" ]
[ [ [ 1, 39 ] ] ]
639ca0855bc97a04a6e380d45db79e3be4568d20
39040af0ff84935d083209731dd7343f93fa2874
/app/ucalc/ueval.h
15b35ccf0e8357190515167b86276bf43435fc6d
[ "Apache-2.0" ]
permissive
alanzw/ulib-win
02f8b7bcd8220b6a057fd3b33e733500294f9b56
b67f644ed11c849e3c93b909f90d443df7be4e4c
refs/heads/master
2020-04-06T05:26:54.849486
2011-07-23T05:47:17
2011-07-23T05:47:17
34,505,292
5
3
null
null
null
null
UTF-8
C++
false
false
2,105
h
#ifndef U_EVAL_H #define U_EVAL_H #include <exception> #include <iostream> //#include <map> #include "umsg.h" #include "adt/ustring.h" #include "adt/ustack.h" #include "adt/utable.h" typedef huys::ADT::UStringAnsi TString; typedef huys::ADT::UStack<int> UStackInt; typedef huys::ADT::UStack<TString> UStackStr; typedef huys::ADT::UTable<TString, int> UTableSI; //typedef std::map<TString, int> UTableSI; namespace huys { namespace ADT { template <> struct hash<TString> { static int hash_value(const TString &key) { unsigned int hash_value = 0; /* Compute the hash value from the first four bytes of the object's resident memory. Then get the hash index for the array by taking the modulo of the size of that array (<number_buckets>). */ memcpy( (void *)&hash_value, key.c_str(), key.length() % sizeof(unsigned int) ); return hash_value; } }; }; // namespace ADT }; // namespace huys class EvalException { public: EvalException(const char *sError) : m_sError(sError) {} void what() { showMsg(m_sError); } private: const char *m_sError; }; class PostfixEval { public: PostfixEval(); int evaluate(); TString getPostfixExp() const; void setPostfixExp(const TString &exp); private: TString m_sPostfixExp; UStackInt m_operandStack; private: void getOperands(int &left, int &right); int compute(int left, int right, char op) const; bool isOperator(char ch) const; }; class Infix2Postfix { public: Infix2Postfix() {} Infix2Postfix(const TString & infixExp) :infix(infixExp) {} void setInfixExp(const TString& infixExp) { infix=infixExp; } TString postfixExp(); ~Infix2Postfix(){}; TString infixExp() { return infix; } private: TString infix; TString postfix; UStackStr stk;//stack used to store operator TString opers; UTableSI oper_prio;//Used to store the priority of operator void set_priority();//set operator's priority }; #endif // U_EVAL_H
[ "fox000002@48c0247c-a797-11de-8c46-7bd654735883" ]
[ [ [ 1, 109 ] ] ]
4e7f37c11fdff244cd9f3d3a0bbb64af4a6eeab9
3e69b159d352a57a48bc483cb8ca802b49679d65
/tags/release-2005-10-27/cvpcb/init.cpp
9ac01fd39307316de9988350405a90b853787f77
[]
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
ISO-8859-1
C++
false
false
5,102
cpp
/*******************************************************************/ /* CVPCB: Routines de base : */ /* lecture Netliste et creation des fenetres composants et modules */ /*******************************************************************/ #include "fctsys.h" #include "common.h" #include "cvpcb.h" #include "gr_basic.h" #include "protos.h" #include "id.h" /* routines locales : */ /**************************************/ void WinEDA_CvpcbFrame::SetNewPkg(void) /**************************************/ /* - Affecte un module au composant selectionne - Selectionne le composant suivant */ { STORECMP * Composant; int ii, NumCmp, IsNew = 1; char Line[256]; if ( BaseListeCmp == NULL ) return; NumCmp = m_ListCmp->GetSelection(); if( NumCmp < 0 ) { NumCmp = 0; m_ListCmp->SetSelection(NumCmp, TRUE); } Composant = BaseListeCmp; for ( ii = 0; Composant != NULL; Composant = Composant->Pnext, ii++ ) { if ( NumCmp == ii ) break; } if ( Composant == NULL ) return; if ( Composant->Module[0] >= ' ') IsNew = 0; strncpy( Composant->Module, CurrentPkg, 32);Composant->Module[32] = 0; sprintf(Line,CMP_FORMAT ,ii+1, Composant->Reference, Composant->Valeur, Composant->Module); modified = 1; if ( IsNew ) composants_non_affectes -= 1; m_ListCmp->SetString(NumCmp, Line); m_ListCmp->SetSelection(NumCmp, FALSE); // We activate next component: if ( NumCmp < (m_ListCmp->GetCount() - 1) ) NumCmp++; m_ListCmp->SetSelection(NumCmp, TRUE); sprintf(Line,_("Components: %d (free: %d)"), nbcomp, composants_non_affectes); SetStatusText(Line,1); } /********************************************/ void WinEDA_CvpcbFrame::ReadNetListe(void) /*******************************************/ /* Lecture de la netliste selon format, ainsi que du fichier des composants */ { STORECMP * Composant; wxString msg; int ii; int error_level = -1; switch( g_NetType ) { case TYPE_NON_SPECIFIE: case TYPE_ORCADPCB2: error_level = rdorcad(); break; case TYPE_PCAD: error_level = rdpcad() ; break; case TYPE_VIEWLOGIC_WIR: error_level = ReadViewlogicWirList() ; break; case TYPE_VIEWLOGIC_NET: error_level = ReadViewlogicNetList() ; break; default: DisplayError(this, _("Unknown Netlist Format") ); break; } if ( error_level < 0 ) return; /* lecture des correspondances */ loadcmp(); if (m_ListCmp == NULL ) return; if (NetInNameBuffer != "") wxSetWorkingDirectory( wxPathOnly(NetInNameBuffer) ); Read_Config(NetInNameBuffer); // relecture de la config (elle peut etre modifiée) listlib(); BuildModListBox(); m_ListCmp->Clear(); Composant = BaseListeCmp; composants_non_affectes = 0; for ( ii = 1;Composant != NULL; Composant = Composant->Pnext, ii++ ) { msg.Printf(CMP_FORMAT ,ii, Composant->Reference, Composant->Valeur, Composant->Module); m_ListCmp->AppendLine(msg); if( Composant->Module[0] < ' ' ) composants_non_affectes += 1; } if ( BaseListeCmp ) m_ListCmp->SetSelection(0, TRUE); msg.Printf(_("Componants: %d (free: %d)"), nbcomp, composants_non_affectes); SetStatusText(msg,1); /* Mise a jour du titre de la fenetre principale */ msg.Printf("%s [%s]",Main_Title.GetData(), FFileName.GetData()); SetTitle(msg); } /****************************************/ int WinEDA_CvpcbFrame::SaveNetList(void) /****************************************/ /* Sauvegarde des fichiers netliste et cmp Le nom complet du fichier Netliste doit etre dans FFileName. Le nom du fichier cmp en est deduit */ { if( savecmp() == 0 ) { DisplayError(this, _("Unable to create component file (.cmp)") ); return(0); } dest = fopen(FFileName,"wt") ; if( dest == 0 ) { DisplayError(this, _("Unable to create netlist file") ); return(0); } switch ( output_type ) { default: case 0: case 1: genorcad() ; break; } return(1); } /**********************************************************************/ bool WinEDA_CvpcbFrame::ReadInputNetList(const wxString & FullFileName) /**********************************************************************/ /* Routine de selection du nom de la netliste d'entree, et de lecure de celle-ci */ { wxString Mask, Line; if ( FullFileName == "" ) { if( NetInExtBuffer != "" ) Mask = "*" + NetInExtBuffer; else Mask = "*.net"; Line = EDA_FileSelector(_("Load Net List"), NetDirBuffer, /* Chemin par defaut */ NetInNameBuffer, /* nom fichier par defaut */ NetInExtBuffer, /* extension par defaut */ Mask, /* Masque d'affichage */ this, 0, FALSE ); if ( Line == "") return(FALSE); } else Line = FullFileName; NetInNameBuffer = Line; NetNameBuffer = Line; FFileName = NetInNameBuffer; /* Mise a jour du titre de la fenetre principale */ Line = Main_Title + " " + NetInNameBuffer; SetTitle(Line); ReadNetListe(); return(TRUE); }
[ "bokeoa@244deca0-f506-0410-ab94-f4f3571dea26" ]
[ [ [ 1, 214 ] ] ]
29a709176e30a754d20bc95679452965c03dba4a
7b4c786d4258ce4421b1e7bcca9011d4eeb50083
/_统计专用/C++Primer中文版(第4版)/第一次-代码集合-20090414/第四章 数组和指针/20090321_习题4.36_多维数组的输出.cpp
62ee63f08596d8d9bf82740084e5cfea7638c87f
[]
no_license
lzq123218/guoyishi-works
dbfa42a3e2d3bd4a984a5681e4335814657551ef
4e78c8f2e902589c3f06387374024225f52e5a92
refs/heads/master
2021-12-04T11:11:32.639076
2011-05-30T14:12:43
2011-05-30T14:12:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
331
cpp
//20090321 COPY! #include <iostream> using namespace std; int main() { int ia[3][4] = { {0, 2, 2, 5}, {32, 22, 1, 9}, {12, 3, 2, 232} }; int (*p)[4]; for (p = ia; p != ia + 3; ++p) { for (int *q = *p; q != *p + 4; ++q) { cout << *q << "\t"; } cout << endl; } cout << endl; return 0; }
[ "baicaibang@70501136-4834-11de-8855-c187e5f49513" ]
[ [ [ 1, 23 ] ] ]
0560a4f7b7244f3142aa28433a8bae0f90e2d864
5ac13fa1746046451f1989b5b8734f40d6445322
/minimangalore/Nebula2/code/contrib/nopende/inc/opende/nopendemarshal.h
eee0fbf36afc9227337a8692be5a30d732589943
[]
no_license
moltenguy1/minimangalore
9f2edf7901e7392490cc22486a7cf13c1790008d
4d849672a6f25d8e441245d374b6bde4b59cbd48
refs/heads/master
2020-04-23T08:57:16.492734
2009-08-01T09:13:33
2009-08-01T09:13:33
35,933,330
0
0
null
null
null
null
UTF-8
C++
false
false
8,559
h
#ifndef N_OPENDEMARSHAL_H #define N_OPENDEMARSHAL_H //---------------------------------------------------------------------------- /** This is a set of functions that handle conversion between ODE and Nebula data types. (c) 2004 Vadim Macagon */ //---------------------------------------------------------------------------- #ifndef N_ODE_H #define N_ODE_H #include <ode/ode.h> #endif #include "mathlib/matrix.h" #include "mathlib/vector.h" #include "mathlib/quaternion.h" #include "mathlib/plane.h" //---------------------------------------------------------------------------- namespace nOpendeMarshal { //---------------------------------------------------------------------------- inline void dMatrix3_2_matrix44( const dMatrix3 Rotation, matrix44& out ) { out.M11 = float(Rotation[0]); out.M21 = float(Rotation[1]); out.M31 = float(Rotation[2]); out.M12 = float(Rotation[4]); out.M22 = float(Rotation[5]); out.M32 = float(Rotation[6]); out.M13 = float(Rotation[8]); out.M23 = float(Rotation[9]); out.M33 = float(Rotation[10]); out.M41 = 0.0f; out.M42 = 0.0f; out.M43 = 0.0f; out.M14 = 0.0f; out.M24 = 0.0f; out.M34 = 0.0f; out.M44 = 1.0f; } //---------------------------------------------------------------------------- inline void matrix44_2_dMatrix3( const matrix44& mat, dMatrix3 rotation ) { rotation[0] = mat.M11; rotation[1] = mat.M21; rotation[2] = mat.M31; rotation[3] = 0; rotation[4] = mat.M12; rotation[5] = mat.M22; rotation[6] = mat.M32; rotation[7] = 0; rotation[8] = mat.M13; rotation[9] = mat.M23; rotation[10] = mat.M33; rotation[11] = 0; } //---------------------------------------------------------------------------- inline void dMatrix3_2_matrix33( const dMatrix3 Rotation, matrix33& out ) { out.M11 = float(Rotation[0]); out.M21 = float(Rotation[1]); out.M31 = float(Rotation[2]); out.M12 = float(Rotation[4]); out.M22 = float(Rotation[5]); out.M32 = float(Rotation[6]); out.M13 = float(Rotation[8]); out.M23 = float(Rotation[9]); out.M33 = float(Rotation[10]); } //---------------------------------------------------------------------------- inline void matrix33_2_dMatrix3( const matrix33& mat, dMatrix3 rotation ) { rotation[0] = mat.M11; rotation[1] = mat.M21; rotation[2] = mat.M31; rotation[3] = 0; rotation[4] = mat.M12; rotation[5] = mat.M22; rotation[6] = mat.M32; rotation[7] = 0; rotation[8] = mat.M13; rotation[9] = mat.M23; rotation[10] = mat.M33; rotation[11] = 0; } //---------------------------------------------------------------------------- /** @brief Convert an ODE quaternion to a Nebula one. */ inline void dQuat_2_quat( const dQuaternion source, quaternion& res ) { res.set( float(source[1]), float(source[2]), float(source[3]), float(source[0]) ); } //---------------------------------------------------------------------------- /** @brief Convert a Nebula quaternion to an ODE one. */ inline void quat_2_dQuat( const quaternion& source, dQuaternion res ) { res[0] = source.w; res[1] = source.x; res[2] = source.y; res[3] = source.z; } //---------------------------------------------------------------------------- inline vector3 dVector3_2_vector3( const dVector3 in ) { return vector3( float(in[0]), float(in[1]), float(in[2]) ); } //---------------------------------------------------------------------------- inline void dVector3_2_vector3( const dVector3 in, vector3& out ) { out.set( float(in[0]), float(in[1]), float(in[2]) ); } //---------------------------------------------------------------------------- inline void vector3_2_dVector3( const vector3& in, dVector3 out ) { out[0] = in.x; out[1] = in.y; out[2] = in.z; } //---------------------------------------------------------------------------- inline void vector4_2_dVector4( const vector4& in, dVector4 out ) { out[0] = in.x; out[1] = in.y; out[2] = in.z; out[3] = in.w; } //---------------------------------------------------------------------------- inline void dVector4_2_vector4( const dVector4 in, vector4& out ) { out.set( float(in[0]), float(in[1]), float(in[2]), float(in[3]) ); } //---------------------------------------------------------------------------- /* @brief Convert an ODE plane into a Nebula plane. @fixme Not sure if this works yet :) */ inline void dPlane_2_plane( const dVector4 in, plane& out ) { out.set( -in[0], -in[1], -in[2], in[3] ); } //---------------------------------------------------------------------------- /* @brief Convert a Nebula plane into an ODE plane. @fixme Not sure if this works yet :) */ inline void plane_2_dPlane( const plane& in, dVector4 out ) { out[0] = -in.a; out[1] = -in.b; out[2] = -in.c; out[3] = in.d; } //---------------------------------------------------------------------------- inline vector3 dRealPointer_2_vector3( const dReal* in ) { return vector3( float(in[0]), float(in[1]), float(in[2]) ); } //---------------------------------------------------------------------------- inline void dRealPointer_2_vector3( const dReal* in, vector3& out ) { out.set( float(in[0]), float(in[1]), float(in[2]) ); } //---------------------------------------------------------------------------- inline matrix33 dRealPointer_2_matrix33( const dReal* in ) { const dMatrix3& rotation = *(const dMatrix3*)in; matrix33 out; nOpendeMarshal::dMatrix3_2_matrix33( rotation, out ); return out; } //---------------------------------------------------------------------------- inline void dRealPointer_2_matrix33( const dReal* in, matrix33& out ) { const dMatrix3& rotation = *(const dMatrix3*)in; nOpendeMarshal::dMatrix3_2_matrix33( rotation, out ); } //---------------------------------------------------------------------------- inline quaternion dRealPointer_2_quat( const dReal* in ) { const dQuaternion& quat = *(const dQuaternion*)in; quaternion out; nOpendeMarshal::dQuat_2_quat( quat, out ); return out; } //---------------------------------------------------------------------------- inline void dRealPointer_2_quat( const dReal* in, quaternion& out ) { const dQuaternion& quat = *(const dQuaternion*)in; nOpendeMarshal::dQuat_2_quat( quat, out ); } //---------------------------------------------------------------------------- inline const char* GeomClassToString( int geomClass ) { switch ( geomClass ) { case dSphereClass: return "sphere"; case dBoxClass: return "box"; case dCylinderClass: return "cylinder"; case dCCylinderClass: return "capsule"; case dRayClass: return "ray"; case dPlaneClass: return "plane"; case dTriMeshClass: return "trimesh"; case dGeomTransformClass: return "transform"; default: return "unknown"; } } //---------------------------------------------------------------------------- inline int StringToGeomClass( const char* geomClass ) { if ( strcmp( "sphere", geomClass ) == 0 ) return dSphereClass; else if ( strcmp( "box", geomClass ) == 0 ) return dBoxClass; else if ( strcmp( "cylinder", geomClass ) == 0 ) return dCylinderClass; else if ( strcmp( "capsule", geomClass ) == 0 ) return dCCylinderClass; else if ( strcmp( "ray", geomClass ) == 0 ) return dRayClass; else if ( strcmp( "plane", geomClass ) == 0 ) return dPlaneClass; else if ( strcmp( "trimesh", geomClass ) == 0 ) return dTriMeshClass; else if ( strcmp( "transform", geomClass ) == 0 ) return dGeomTransformClass; else n_error( "%s is not a valid geom class name!", geomClass ); return 0; } //---------------------------------------------------------------------------- } // namespace nOpendeMarshal //---------------------------------------------------------------------------- #endif // N_OPENDEMARSHAL_H
[ "BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c" ]
[ [ [ 1, 298 ] ] ]
d49379d8a7adc6832d75e9f99606d64cce6a8cf8
3201bc35622102fe99b50e5f7d1351ad0d89b2f2
/design/repository/test_benches/gip/c_gipc_pipeline_trace.cpp
648bff8e2065d53982d7f9802af1fe0d4e829d24
[]
no_license
embisi-github/embisi_gip
1f7e8ce334ae9611f52a2cd6e536ef71fb00cec4
dd6dfe8667b28f03dba2ac605d67916cb4483005
refs/heads/master
2021-01-10T12:33:55.917299
2006-11-27T09:43:39
2006-11-27T09:43:39
48,285,426
0
1
null
null
null
null
UTF-8
C++
false
false
12,089
cpp
/*a Copyright This file 'c_gipc_prefetch_if_comp.cpp' copyright Embisi 2003, 2004 */ /*a Includes */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <stdarg.h> #include "sl_debug.h" #include "sl_mif.h" #include "sl_general.h" #include "be_model_includes.h" #include "gip.h" /*a Defines */ #define INPUT( name, width, clk ) \ { \ engine->register_input_signal( engine_handle, #name, width, (int **)&inputs.name ); \ engine->register_input_used_on_clock( engine_handle, #name, #clk, 1 ); \ } #define COMB_OUTPUT( name, width, clk )\ { \ engine->register_output_signal( engine_handle, #name, width, (int *)&combinatorials.name ); \ engine->register_output_generated_on_clock( engine_handle, #name, #clk, 1 ); \ combinatorials.name = 0; \ } #define STATE_OUTPUT( name, width, clk )\ { \ engine->register_output_signal( engine_handle, #name, width, (int *)&posedge_int_clock_state.name ); \ engine->register_output_generated_on_clock( engine_handle, #name, #clk, 1 ); \ } /*a Types */ /*t t_gipc_pipeline_trace_posedge_int_clock_state */ typedef struct t_gipc_pipeline_trace_posedge_int_clock_state { unsigned int pc; int executing; int valid; unsigned int rfw_data; unsigned int rfw_reg; unsigned int rfw_is_reg; int gip_ins_class; int gip_ins_subclass; int gip_ins_cc; int gip_ins_rd; int gip_ins_rn; int gip_ins_rm; int rm_is_imm; unsigned int immediate; int k; int a; int f; int s_or_stack; int p_or_offset_is_shift; int d; int tag; } t_gipc_pipeline_trace_posedge_int_clock_state; /*t t_gipc_pipeline_trace_ptrs */ typedef struct t_gipc_pipeline_trace_ptrs { unsigned int *pc; unsigned int *executing; unsigned int *valid; unsigned int *rfw_data; unsigned int *rfw_r; unsigned int *rfw_type; int gip_ins_class; int gip_ins_subclass; int gip_ins_cc; int gip_ins_rd; int gip_ins_rn; int gip_ins_rm; int rm_is_imm; unsigned int immediate; int k; int a; int f; int s_or_stack; int p_or_offset_is_shift; int d; int tag; } t_gipc_pipeline_trace_ptrs; /*t c_gipc_pipeline_trace */ class c_gipc_pipeline_trace { public: c_gipc_pipeline_trace::c_gipc_pipeline_trace( class c_engine *eng, void *eng_handle ); c_gipc_pipeline_trace::~c_gipc_pipeline_trace(); t_sl_error_level c_gipc_pipeline_trace::delete_instance( void ); t_sl_error_level c_gipc_pipeline_trace::reset( int pass ); t_sl_error_level c_gipc_pipeline_trace::preclock_posedge_int_clock( void ); t_sl_error_level c_gipc_pipeline_trace::clock_posedge_int_clock( void ); t_sl_error_level c_gipc_pipeline_trace::reset_active_high_int_reset( void ); private: unsigned int *c_gipc_pipeline_trace::find_vector_from_path( char *gipc_path, char *vector_name ); c_engine *engine; void *engine_handle; char *gipc_path; int cycle_number; int verbose_level; t_gipc_pipeline_trace_ptrs ptrs; t_gipc_pipeline_trace_posedge_int_clock_state next_posedge_int_clock_state; t_gipc_pipeline_trace_posedge_int_clock_state posedge_int_clock_state; }; /*a Statics */ /*v fetch_ops, prefetch_ops */ static char *fetch_ops[4]; static char *prefetch_ops[4]; /*f state_desc_gipc_pipeline_trace */ #define struct_offset( ptr, a ) (((char *)&(ptr->a))-(char *)ptr) static t_gipc_pipeline_trace_posedge_int_clock_state *___gipc_pipeline_trace_posedge_int_clock__ptr; static t_engine_state_desc state_desc_gipc_pipeline_trace_posedge_int_clock[] = { // {"src_fsm", engine_state_desc_type_bits, NULL, struct_offset(___gipc_pipeline_trace_posedge_int_clock__ptr, src_fsm), {2,0,0,0}, {NULL,NULL,NULL,NULL} }, // {"src_left", engine_state_desc_type_bits, NULL, struct_offset(___gipc_pipeline_trace_posedge_int_clock__ptr, src_left), {5,0,0,0}, {NULL,NULL,NULL,NULL} }, // {"fc_credit", engine_state_desc_type_bits, NULL, struct_offset(___gipc_pipeline_trace_posedge_int_clock__ptr, src_channel_state[0].fc_credit), {32,0,0,0}, {NULL,NULL,NULL,NULL} }, {"", engine_state_desc_type_none, NULL, 0, {0,0,0,0}, {NULL,NULL,NULL,NULL} } }; /*a Static wrapper functions for gipc_pipeline_trace */ /*f gipc_pipeline_trace_instance_fn */ static t_sl_error_level gipc_pipeline_trace_instance_fn( c_engine *engine, void *engine_handle ) { c_gipc_pipeline_trace *mod; mod = new c_gipc_pipeline_trace( engine, engine_handle ); if (!mod) return error_level_fatal; return error_level_okay; } /*f gipc_pipeline_trace_delete_fn - simple callback wrapper for the main method */ static t_sl_error_level gipc_pipeline_trace_delete_fn( void *handle ) { c_gipc_pipeline_trace *mod; t_sl_error_level result; mod = (c_gipc_pipeline_trace *)handle; result = mod->delete_instance(); delete( mod ); return result; } /*f gipc_pipeline_trace_reset_fn */ static t_sl_error_level gipc_pipeline_trace_reset_fn( void *handle, int pass ) { c_gipc_pipeline_trace *mod; mod = (c_gipc_pipeline_trace *)handle; return mod->reset( pass ); } /*f gipc_pipeline_trace_preclock_posedge_int_clock_fn */ static t_sl_error_level gipc_pipeline_trace_preclock_posedge_int_clock_fn( void *handle ) { c_gipc_pipeline_trace *mod; mod = (c_gipc_pipeline_trace *)handle; return mod->preclock_posedge_int_clock(); } /*f gipc_pipeline_trace_clock_posedge_int_clock_fn */ static t_sl_error_level gipc_pipeline_trace_clock_posedge_int_clock_fn( void *handle ) { c_gipc_pipeline_trace *mod; mod = (c_gipc_pipeline_trace *)handle; return mod->clock_posedge_int_clock(); } /*a Constructors and destructors for gipc_pipeline_trace */ /*f c_gipc_pipeline_trace::c_gipc_pipeline_trace option for verbosity option for path to GIP core */ c_gipc_pipeline_trace::c_gipc_pipeline_trace( class c_engine *eng, void *eng_handle ) { /*b Set main variables */ engine = eng; engine_handle = eng_handle; /*b Done */ verbose_level = engine->get_option_int( engine_handle, "verbose_level", 0 ); gipc_path = engine->get_option_string( engine_handle, "gipc_path", NULL ); engine->register_delete_function( engine_handle, (void *)this, gipc_pipeline_trace_delete_fn ); engine->register_reset_function( engine_handle, (void *)this, gipc_pipeline_trace_reset_fn ); engine->register_clock_fns( engine_handle, (void *)this, "int_clock", gipc_pipeline_trace_preclock_posedge_int_clock_fn, gipc_pipeline_trace_clock_posedge_int_clock_fn ); ptrs.pc = NULL; cycle_number = 0; reset_active_high_int_reset(); } /*f c_gipc_pipeline_trace::~c_gipc_pipeline_trace */ c_gipc_pipeline_trace::~c_gipc_pipeline_trace() { delete_instance(); } /*f c_gipc_pipeline_trace::delete_instance */ t_sl_error_level c_gipc_pipeline_trace::delete_instance( void ) { return error_level_okay; } /*a Class reset/preclock/clock methods for gipc_pipeline_trace */ /*f c_gipc_pipeline_trace::reset */ t_sl_error_level c_gipc_pipeline_trace::reset( int pass ) { if (pass==0) { cycle_number = -1; reset_active_high_int_reset(); cycle_number = 0; } return error_level_okay; } /*f c_gipc_pipeline_trace::find_vector_from_path */ unsigned int *c_gipc_pipeline_trace::find_vector_from_path( char *gipc_path, char *vector_name ) { char buffer[1024]; unsigned int *data_ptrs[4]; int sizes[4]; t_se_interrogation_handle handle; unsigned int *result; result = NULL; sprintf(buffer, "%s.%s", gipc_path, vector_name ); handle = engine->find_entity( buffer ); if (handle) { if (engine->interrogate_get_data_sizes_and_type( handle, (int **)data_ptrs, sizes )==engine_state_desc_type_bits) { result = data_ptrs[0]; } engine->interrogation_handle_free( handle ); } else { fprintf( stderr, "GIP core pipeline trace could not find the path '%s'\n", buffer ); } return result; } /*f c_gipc_pipeline_trace::reset_active_high_int_reset */ t_sl_error_level c_gipc_pipeline_trace::reset_active_high_int_reset( void ) { if (!ptrs.pc) { ptrs.pc = find_vector_from_path( gipc_path, "alu.alu_inst__pc" ); ptrs.valid = find_vector_from_path( gipc_path, "alu.alu_inst__valid" ); ptrs.executing = find_vector_from_path( gipc_path, "gip_pipeline_executing" ); ptrs.rfw_data = find_vector_from_path( gipc_path, "rf.rfw_data" ); ptrs.rfw_r = find_vector_from_path( gipc_path, "rf.rfw_rd__r" ); ptrs.rfw_type = find_vector_from_path( gipc_path, "rf.rfw_rd__type" ); } posedge_int_clock_state.pc = 0; posedge_int_clock_state.valid = 0; posedge_int_clock_state.executing = 0; posedge_int_clock_state.rfw_data = 0; posedge_int_clock_state.rfw_reg = 0; posedge_int_clock_state.rfw_is_reg = 0; return error_level_okay; } /*f c_gipc_pipeline_trace::preclock_posedge_int_clock */ t_sl_error_level c_gipc_pipeline_trace::preclock_posedge_int_clock( void ) { /*b Copy current state to next */ memcpy( &next_posedge_int_clock_state, &posedge_int_clock_state, sizeof(posedge_int_clock_state) ); /*b Record inputs */ if (ptrs.pc) next_posedge_int_clock_state.pc = ptrs.pc[0]; if (ptrs.valid) next_posedge_int_clock_state.valid = ptrs.valid[0]; if (ptrs.executing) next_posedge_int_clock_state.executing = ptrs.executing[0]; if (ptrs.rfw_data) next_posedge_int_clock_state.rfw_data = ptrs.rfw_data[0]; if (ptrs.rfw_r) next_posedge_int_clock_state.rfw_reg = ptrs.rfw_r[0]; if (ptrs.rfw_type) next_posedge_int_clock_state.rfw_is_reg = (ptrs.rfw_type[0]==0); /*b Done */ return error_level_okay; } /*f c_gipc_pipeline_trace::clock_posedge_int_clock */ t_sl_error_level c_gipc_pipeline_trace::clock_posedge_int_clock( void ) { /*b Copy next state to current */ memcpy( &posedge_int_clock_state, &next_posedge_int_clock_state, sizeof(posedge_int_clock_state) ); cycle_number++; /*b Print error message if required */ if (posedge_int_clock_state.valid) { fprintf( stderr, "%s:%d:Pc %08x e %d\n", engine->get_instance_name(engine_handle), engine->cycle(), posedge_int_clock_state.pc-8, posedge_int_clock_state.executing ); } if (posedge_int_clock_state.rfw_is_reg) { fprintf( stderr, "%s:%d:RFW %d %08x\n", engine->get_instance_name(engine_handle), engine->cycle(), posedge_int_clock_state.rfw_reg, posedge_int_clock_state.rfw_data ); } /*b Return */ return error_level_okay; } /*a Initialization functions */ /*f c_gipc_pipeline_trace__init */ extern void c_gipc_pipeline_trace__init( void ) { se_external_module_register( 1, "gipc_pipeline_trace", gipc_pipeline_trace_instance_fn ); fetch_ops[gip_fetch_op_hold] = "hold"; fetch_ops[gip_fetch_op_last_prefetch] = "last"; fetch_ops[gip_fetch_op_this_prefetch] = "this"; fetch_ops[gip_fetch_op_sequential] = "seq "; prefetch_ops[gip_prefetch_op_new_address] = "new "; prefetch_ops[gip_prefetch_op_none] = "none"; prefetch_ops[gip_prefetch_op_sequential] = "seq "; prefetch_ops[gip_prefetch_op_hold] = "hold"; } /*a Scripting support code */ /*f initgipc_pipeline_trace */ extern "C" void initgipc_pipeline_trace( void ) { c_gipc_pipeline_trace__init( ); scripting_init_module( "gipc_pipeline_trace" ); } /*a Editor preferences and notes mode: c *** c-basic-offset: 4 *** c-default-style: (quote ((c-mode . "k&r") (c++-mode . "k&r"))) *** outline-regexp: "/\\\*a\\\|[\t ]*\/\\\*[b-z][\t ]" *** */
[ "" ]
[ [ [ 1, 398 ] ] ]
47927ab751b943d0f5d6c08d24e529801b2397a5
ed8cbdeb94cdc3364586c6e73d48427eab3dd624
/benchmarks/win32/Programming Projects/Columbia/VC/include/ICMPPacket.h
c886e74fa21fb05e1179c33ef3370fd05a0b43e5
[]
no_license
Programming-Systems-Lab/archived-events
3b5281b1f3013cc4a3943e52cfd616d2daeba6f2
61d521b39996393ad7ad6d9430dbcdab4b2b36c6
refs/heads/master
2020-09-17T23:37:34.037734
2002-12-20T15:45:08
2002-12-20T15:45:08
67,139,857
0
0
null
null
null
null
UTF-8
C++
false
false
849
h
// ICMPPacket.h: interface for the ICMPPacket class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_ICMPPACKET_H__E976D1D3_87C4_49A8_B7E2_D842076BDFF9__INCLUDED_) #define AFX_ICMPPACKET_H__E976D1D3_87C4_49A8_B7E2_D842076BDFF9__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include <NIDPacket.h> #include <iostream.h> #include <NIDConstants.h> class NIDExport ICMPPacket: public Packet { friend ostream& operator << ( ostream& output, const ICMPPacket& rhs ); public: ICMPPacket(); ICMPPacket( const ICMPPacket& rhs ); virtual ~ICMPPacket(); virtual AString AsXML( void ); const ICMPPacket& operator=( const ICMPPacket& rhs ); int m_nServiceType; }; #endif // !defined(AFX_ICMPPACKET_H__E976D1D3_87C4_49A8_B7E2_D842076BDFF9__INCLUDED_)
[ "jjp32" ]
[ [ [ 1, 30 ] ] ]
022bf97a663105b88350b4a4fbf027f78cd184e6
02cd7f7be30f7660f6928a1b8262dc935673b2d7
/ invols --username gavrilov86@gmail.com/BoxPanel.h
cd75a319be724877c1e4407bdbb2ed3af82ec97f
[]
no_license
hksonngan/invols
f0886a304ffb81594016b3b82affc58bd61c4c0b
336b8c2d11d97892881c02afc2fa114dbf56b973
refs/heads/master
2021-01-10T10:04:55.844101
2011-11-09T07:44:24
2011-11-09T07:44:24
46,898,469
1
0
null
null
null
null
UTF-8
C++
false
false
531
h
#ifndef BOX_PANEL_INC #define BOX_PANEL_INC #include "AllInc.h" #include "wxIncludes.h" class BoxPanel: public wxPanel { public: BoxPanel(wxWindow *frame); ~BoxPanel() { } void OnSliderBox(wxCommandEvent& WXUNUSED(event)); void OnSliderZ(wxCommandEvent& WXUNUSED(event)); void OnCheckBB(wxCommandEvent& event); void Update_(bool self); private: wxSlider *m_slider_z[6],*m_slider_my_z; wxCheckBox *m_check_box_BB; wxCheckBox *m_check_box[10]; DECLARE_EVENT_TABLE() }; #endif
[ "gavrilov86@gmail.com" ]
[ [ [ 1, 32 ] ] ]
050efe27edd0c0194f52d7265a49397d2caf55b0
593b85562f3e570a5a6e75666d8cd1c535daf3b6
/Source/MenuFunctions.h
8c07c9d33989cd2356d49cff30cdc0eae5190208
[]
no_license
rayjohannessen/songofalbion
fc62c317d829ceb7c215b805fed4276788a22154
83d7e87719bfb3ade14096d4969aa32c524c1902
refs/heads/master
2021-01-23T13:18:10.028635
2011-02-13T00:23:37
2011-02-13T00:23:37
32,121,693
1
0
null
null
null
null
UTF-8
C++
false
false
1,013
h
//////////////////////////////////////////////////////////////////////////////////////////// // // Author: Ramon Johannessen // // Purpose: Define menu functions, for performing additional functionality // //////////////////////////////////////////////////////////////////////////////////////////// #include "Wrappers/CSGD_TextureManager.h" #include "Wrappers/CSGD_DirectInput.h" #include "Globals.h" namespace HelpMenu { void Render(CGameMenu* const menu); void Update(double fElapsed, CGameMenu* const menu); bool Input(double fElapsed, const POINT& mouse, CGameMenu* const menu); } namespace OptionMenu { void Render(CGameMenu* const menu); void Update(double fElapsed, CGameMenu* const menu); bool Input(double fElapsed, const POINT& mouse, CGameMenu* const menu); } namespace MainMenu { void Render(CGameMenu* const menu); void Update(double fElapsed, CGameMenu* const menu); bool Input(double fElapsed, const POINT& mouse, CGameMenu* const menu); }
[ "AllThingsCandid@cb80bfb0-ca38-a83e-6856-ee7c686669b9" ]
[ [ [ 1, 38 ] ] ]
323d9f1230079d5808de37a32b8cc4c7b1ae8005
d752d83f8bd72d9b280a8c70e28e56e502ef096f
/FugueDLL/Virtual Machine/Operations/Operators/Bitwise.cpp
3ff5f23073dd203a51e491cc4dee1a945b5232ee
[]
no_license
apoch/epoch-language.old
f87b4512ec6bb5591bc1610e21210e0ed6a82104
b09701714d556442202fccb92405e6886064f4af
refs/heads/master
2021-01-10T20:17:56.774468
2010-03-07T09:19:02
2010-03-07T09:19:02
34,307,116
0
0
null
null
null
null
UTF-8
C++
false
false
5,523
cpp
// // The Epoch Language Project // FUGUE Virtual Machine // // Built in bitwise operators // #include "pch.h" #include "Virtual Machine/Operations/Operators/Bitwise.h" #include "Virtual Machine/Core Entities/Variables/Variable.h" #include "Virtual Machine/Types Management/Typecasts.h" #include "Virtual Machine/SelfAware.inl" #include "Validator/Validator.h" #include "Serialization/SerializationTraverser.h" using namespace VM; using namespace VM::Operations; BitwiseOr::BitwiseOr(EpochVariableTypeID type) : Type(type) { if(type != EpochVariableType_Integer && type != EpochVariableType_Integer16) throw NotImplementedException("Bitwise-or cannot be used on data of this type"); } RValuePtr BitwiseOr::ExecuteAndStoreRValue(ExecutionContext& context) { if(Type == EpochVariableType_Integer) { Integer32 ret = 0; for(std::list<Operation*>::iterator iter = SubOps.begin(); iter != SubOps.end(); ++iter) ret |= (*iter)->ExecuteAndStoreRValue(context)->CastTo<IntegerRValue>().GetValue(); return RValuePtr(new IntegerRValue(ret)); } else if(Type == EpochVariableType_Integer16) { Integer16 ret = 0; for(std::list<Operation*>::iterator iter = SubOps.begin(); iter != SubOps.end(); ++iter) ret |= (*iter)->ExecuteAndStoreRValue(context)->CastTo<Integer16RValue>().GetValue(); return RValuePtr(new IntegerRValue(ret)); } throw NotImplementedException("Bitwise-or cannot be used on data of this type"); } void BitwiseOr::ExecuteFast(ExecutionContext& context) { for(std::list<Operation*>::iterator iter = SubOps.begin(); iter != SubOps.end(); ++iter) (*iter)->ExecuteFast(context); } template <typename TraverserT> void BitwiseOr::TraverseHelper(TraverserT& traverser) { traverser.TraverseNode(*this); for(std::list<Operation*>::const_iterator iter = SubOps.begin(); iter != SubOps.end(); ++iter) dynamic_cast<SelfAwareBase*>(*iter)->Traverse(traverser); } void BitwiseOr::Traverse(Validator::ValidationTraverser& traverser) { TraverseHelper(traverser); } void BitwiseOr::Traverse(Serialization::SerializationTraverser& traverser) { TraverseHelper(traverser); } BitwiseAnd::BitwiseAnd(EpochVariableTypeID type) : Type(type) { if(type != EpochVariableType_Integer && type != EpochVariableType_Integer16) throw NotImplementedException("Bitwise-and cannot be used on data of this type"); } RValuePtr BitwiseAnd::ExecuteAndStoreRValue(ExecutionContext& context) { if(Type == EpochVariableType_Integer) { std::list<Operation*>::iterator iter = SubOps.begin(); Integer32 ret = (*iter)->ExecuteAndStoreRValue(context)->CastTo<IntegerRValue>().GetValue(); ++iter; for( ; iter != SubOps.end(); ++iter) ret &= (*iter)->ExecuteAndStoreRValue(context)->CastTo<IntegerRValue>().GetValue(); return RValuePtr(new IntegerRValue(ret)); } else if(Type == EpochVariableType_Integer16) { std::list<Operation*>::iterator iter = SubOps.begin(); Integer16 ret = (*iter)->ExecuteAndStoreRValue(context)->CastTo<Integer16RValue>().GetValue(); ++iter; for( ; iter != SubOps.end(); ++iter) ret &= (*iter)->ExecuteAndStoreRValue(context)->CastTo<Integer16RValue>().GetValue(); return RValuePtr(new Integer16RValue(ret)); } throw NotImplementedException("Bitwise-and cannot be used on data of this type"); } void BitwiseAnd::ExecuteFast(ExecutionContext& context) { for(std::list<Operation*>::iterator iter = SubOps.begin(); iter != SubOps.end(); ++iter) (*iter)->ExecuteFast(context); } template <typename TraverserT> void BitwiseAnd::TraverseHelper(TraverserT& traverser) { traverser.TraverseNode(*this); for(std::list<Operation*>::const_iterator iter = SubOps.begin(); iter != SubOps.end(); ++iter) dynamic_cast<SelfAwareBase*>(*iter)->Traverse(traverser); } void BitwiseAnd::Traverse(Validator::ValidationTraverser& traverser) { TraverseHelper(traverser); } void BitwiseAnd::Traverse(Serialization::SerializationTraverser& traverser) { TraverseHelper(traverser); } BitwiseXor::BitwiseXor(EpochVariableTypeID type) : Type(type) { if(type != EpochVariableType_Integer && type != EpochVariableType_Integer16) throw NotImplementedException("Bitwise-xor cannot be used on data of this type"); } RValuePtr BitwiseXor::ExecuteAndStoreRValue(ExecutionContext& context) { IntegerVariable two(context.Stack.GetCurrentTopOfStack()); IntegerVariable one(context.Stack.GetOffsetIntoStack(IntegerVariable::GetStorageSize())); IntegerVariable::BaseStorage ret = one.GetValue() ^ two.GetValue(); context.Stack.Pop(IntegerVariable::GetStorageSize() * 2); return RValuePtr(new IntegerRValue(ret)); } void BitwiseXor::ExecuteFast(ExecutionContext& context) { context.Stack.Pop(IntegerVariable::GetStorageSize() * 2); } BitwiseNot::BitwiseNot(EpochVariableTypeID type) : Type(type) { if(type != EpochVariableType_Integer && type != EpochVariableType_Integer16) throw NotImplementedException("Bitwise-not cannot be used on data of this type"); } RValuePtr BitwiseNot::ExecuteAndStoreRValue(ExecutionContext& context) { IntegerVariable one(context.Stack.GetCurrentTopOfStack()); IntegerVariable::BaseStorage ret = ~one.GetValue(); context.Stack.Pop(IntegerVariable::GetStorageSize()); return RValuePtr(new IntegerRValue(ret)); } void BitwiseNot::ExecuteFast(ExecutionContext& context) { context.Stack.Pop(IntegerVariable::GetStorageSize()); }
[ "don.apoch@gmail.com", "don.apoch@localhost" ]
[ [ [ 1, 12 ], [ 14, 18 ], [ 20, 24 ], [ 27, 27 ], [ 31, 31 ], [ 53, 54 ], [ 56, 57 ], [ 59, 79 ], [ 82, 82 ], [ 86, 86 ], [ 113, 114 ], [ 116, 117 ], [ 119, 140 ], [ 150, 150 ], [ 153, 153 ], [ 155, 158 ], [ 160, 160 ], [ 162, 164 ], [ 174, 174 ], [ 176, 176 ], [ 178, 181 ], [ 183, 183 ], [ 185, 185 ] ], [ [ 13, 13 ], [ 19, 19 ], [ 25, 26 ], [ 28, 30 ], [ 32, 52 ], [ 55, 55 ], [ 58, 58 ], [ 80, 81 ], [ 83, 85 ], [ 87, 112 ], [ 115, 115 ], [ 118, 118 ], [ 141, 149 ], [ 151, 152 ], [ 154, 154 ], [ 159, 159 ], [ 161, 161 ], [ 165, 173 ], [ 175, 175 ], [ 177, 177 ], [ 182, 182 ], [ 184, 184 ] ] ]
fb85d1176b57dd5af3fbeed523e61add0f02a2f6
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/program_options/src/parsers.cpp
0cd518acc5407e848e667f5d572683ec84013e74
[ "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
willrebuild/flyffsf
e5911fb412221e00a20a6867fd00c55afca593c7
d38cc11790480d617b38bb5fc50729d676aef80d
refs/heads/master
2021-01-19T20:27:35.200154
2011-02-10T12:34:43
2011-02-10T12:34:43
32,710,780
3
0
null
null
null
null
UTF-8
C++
false
false
6,523
cpp
// Copyright Vladimir Prus 2002-2004. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) #include <boost/config.hpp> #define BOOST_PROGRAM_OPTIONS_SOURCE #include <boost/program_options/config.hpp> #include <boost/program_options/parsers.hpp> #include <boost/program_options/options_description.hpp> #include <boost/program_options/positional_options.hpp> #include <boost/program_options/detail/cmdline.hpp> #include <boost/program_options/detail/config_file.hpp> #include <boost/program_options/environment_iterator.hpp> #include <boost/program_options/detail/convert.hpp> #include <boost/bind.hpp> #include <boost/throw_exception.hpp> #include <cctype> #if !defined(__GNUC__) || __GNUC__ < 3 #include <iostream> #else #include <istream> #endif #ifdef _WIN32 #include <stdlib.h> #else #include <unistd.h> #endif // The 'environ' should be declared in some cases. E.g. Linux man page says: // (This variable must be declared in the user program, but is declared in // the header file unistd.h in case the header files came from libc4 or libc5, // and in case they came from glibc and _GNU_SOURCE was defined.) // To be safe, declare it here. // It appears that on Mac OS X the 'environ' variable is not // available to dynamically linked libraries. // See: http://article.gmane.org/gmane.comp.lib.boost.devel/103843 // See: http://lists.gnu.org/archive/html/bug-guile/2004-01/msg00013.html #if defined(__APPLE__) && defined(__DYNAMIC__) #include <crt_externs.h> #define environ (*_NSGetEnviron()) #else #if defined(__MWERKS__) #include <crtl.h> #else #if !defined(_WIN32) || defined(__COMO_VERSION__) extern char** environ; #endif #endif #endif using namespace std; namespace boost { namespace program_options { #ifndef BOOST_NO_STD_WSTRING namespace { woption woption_from_option(const option& opt) { woption result; result.string_key = opt.string_key; result.position_key = opt.position_key; std::transform(opt.value.begin(), opt.value.end(), back_inserter(result.value), bind(from_utf8, _1)); return result; } } basic_parsed_options<wchar_t> ::basic_parsed_options(const parsed_options& po) : description(po.description), utf8_encoded_options(po) { for (unsigned i = 0; i < po.options.size(); ++i) options.push_back(woption_from_option(po.options[i])); } #endif template<class charT> basic_parsed_options<charT> parse_config_file(std::basic_istream<charT>& is, const options_description& desc) { set<string> allowed_options; const vector<shared_ptr<option_description> >& options = desc.options(); for (unsigned i = 0; i < options.size(); ++i) { const option_description& d = *options[i]; if (d.long_name().empty()) boost::throw_exception( error("long name required for config file")); allowed_options.insert(d.long_name()); } // Parser return char strings parsed_options result(&desc); copy(detail::basic_config_file_iterator<charT>(is, allowed_options), detail::basic_config_file_iterator<charT>(), back_inserter(result.options)); // Convert char strings into desired type. return basic_parsed_options<charT>(result); } template BOOST_PROGRAM_OPTIONS_DECL basic_parsed_options<char> parse_config_file(std::basic_istream<char>& is, const options_description& desc); #ifndef BOOST_NO_STD_WSTRING template BOOST_PROGRAM_OPTIONS_DECL basic_parsed_options<wchar_t> parse_config_file(std::basic_istream<wchar_t>& is, const options_description& desc); #endif // This versio, which accepts any options without validation, is disabled, // in the hope that nobody will need it and we cant drop it altogether. // Besides, probably the right way to handle all options is the '*' name. #if 0 BOOST_PROGRAM_OPTIONS_DECL parsed_options parse_config_file(std::istream& is) { detail::config_file_iterator cf(is, false); parsed_options result(0); copy(cf, detail::config_file_iterator(), back_inserter(result.options)); return result; } #endif BOOST_PROGRAM_OPTIONS_DECL parsed_options parse_environment(const options_description& desc, const function1<std::string, std::string>& name_mapper) { parsed_options result(&desc); for(environment_iterator i(environ), e; i != e; ++i) { string option_name = name_mapper(i->first); if (!option_name.empty()) { option n; n.string_key = option_name; n.value.push_back(i->second); result.options.push_back(n); } } return result; } namespace { class prefix_name_mapper { public: prefix_name_mapper(const std::string& prefix) : prefix(prefix) {} std::string operator()(const std::string& s) { string result; if (s.find(prefix) == 0) { for(string::size_type n = prefix.size(); n < s.size(); ++n) { // Intel-Win-7.1 does not understand // push_back on string. result += tolower(s[n]); } } return result; } private: std::string prefix; }; } BOOST_PROGRAM_OPTIONS_DECL parsed_options parse_environment(const options_description& desc, const std::string& prefix) { return parse_environment(desc, prefix_name_mapper(prefix)); } BOOST_PROGRAM_OPTIONS_DECL parsed_options parse_environment(const options_description& desc, const char* prefix) { return parse_environment(desc, string(prefix)); } }}
[ "66430417@qq.com@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 204 ] ] ]
6ccf245267edf330b241ba221b77ec7d0014702b
1d0aaab36740e9117022b3cf03029cede9f558ab
/Material.h
cbb39c451aca14a10777f709ed4a2e045afbda9f
[]
no_license
mikeqcp/superseaman
76ac7c4b4a19a705880a078ca66cfd8976fc07d1
bebeb48e90270dd94bb1c85090f12c4123002815
refs/heads/master
2021-01-25T12:09:29.096901
2011-09-13T21:44:33
2011-09-13T21:44:33
32,287,575
0
0
null
null
null
null
UTF-8
C++
false
false
1,326
h
#pragma once #include "includes.h" class Material { private: string name; GLfloat Ns, Ni, d; glm::vec4 Ka, Kd, Ks; int illum; string map_Kd, map_Ka, map_Ks, map_Kn; public: Material(void); ~Material(void); void setName(string name){ this -> name = name; } void setNs(GLfloat Ns){ this -> Ns = Ns; } void setNi(GLfloat Ni){ this -> Ni = Ni; } void setD(GLfloat d){ this -> d = d; } void setKa(glm::vec4 Ka){ this -> Ka = Ka; } void setKd(glm::vec4 Kd){ this -> Kd = Kd; } void setKs(glm::vec4 Ks){ this -> Ks = Ks; } void setIllum(int illum){ this -> illum = illum; } void setMap_Kd(string map_Kd){ this -> map_Kd = map_Kd; } void setMap_Ka(string map_Ka){ this -> map_Ka = map_Ka; } void setMap_Ks(string map_Ks){ this -> map_Ks = map_Ks; } void setMap_Kn(string map_Kn){ this -> map_Kn = map_Kn; } string getName(){ return name; } GLfloat getNs(){ return Ns; } GLfloat getNi(){ return Ni; } GLfloat getD(){ return d; } glm::vec4 getKa(){ return Ka; } glm::vec4 getKd(){ return Kd; } glm::vec4 getKs(){ return Ks; } int getIllum(){ return illum; } string getMap_Kd(){ return map_Kd; } string getMap_Ka(){ return map_Ka; } string getMap_Ks(){ return map_Ks; } string getMap_Kn(){ return map_Kn; } };
[ "patryk.ziem@gmail.com@a54423c0-632b-0463-fc5f-a1ef5643ace0" ]
[ [ [ 1, 67 ] ] ]
53d89941770cf65c4fddfc85fbe6477d2b931756
fbe2cbeb947664ba278ba30ce713810676a2c412
/iptv_root/iptv_kernel/include/iptv_kernel/CtcpMessage.h
05fc91035bf6021c59fd0f92e1c938187b3edeb7
[]
no_license
abhipr1/multitv
0b3b863bfb61b83c30053b15688b070d4149ca0b
6a93bf9122ddbcc1971dead3ab3be8faea5e53d8
refs/heads/master
2020-12-24T15:13:44.511555
2009-06-04T17:11:02
2009-06-04T17:11:02
41,107,043
0
0
null
null
null
null
UTF-8
C++
false
false
660
h
#ifndef CTCP_MESSAGE_H #define CTCP_MESSAGE_H #include "VBLib/VBLib.h" /** @brief Parses IRC CTCP messages. * */ class CtcpMessage { public: CtcpMessage(br::com::sbVB::VBLib::VBString message); bool IsCtcpMessage() const; bool operator==(const br::com::sbVB::VBLib::VBString &rhs) const; protected: br::com::sbVB::VBLib::VBString GetCtcpMessage() const; br::com::sbVB::VBLib::VBString GetParameters() const; static const char m_ctcpPrefix; private: void Parse(br::com::sbVB::VBLib::VBString message); bool m_isCtcp; br::com::sbVB::VBLib::VBString m_message; br::com::sbVB::VBLib::VBString m_parameters; }; #endif
[ "heineck@c016ff2c-3db2-11de-a81c-fde7d73ceb89" ]
[ [ [ 1, 30 ] ] ]
d5c652c60e64eb53e3d4bb06ddfcf61b4e402b95
2ca3ad74c1b5416b2748353d23710eed63539bb0
/Src/Lokapala/Operator/SeatDataDTO.cpp
053acef6ea26a3bb6026105a2d5ba597e7235850
[]
no_license
sjp38/lokapala
5ced19e534bd7067aeace0b38ee80b87dfc7faed
dfa51d28845815cfccd39941c802faaec9233a6e
refs/heads/master
2021-01-15T16:10:23.884841
2009-06-03T14:56:50
2009-06-03T14:56:50
32,124,140
0
0
null
null
null
null
UTF-8
C++
false
false
396
cpp
/**@file SeatDataDTO.cpp * @brief CSeatDataDTO 클래스의 멤버함수를 구현한다. * @author siva */ #include "stdafx.h" #include "SeatDataDTO.h" CSeatDataDTO::CSeatDataDTO(CString a_hostAddress, int a_x, int a_y, CString a_nickname) { m_seatId = a_hostAddress; m_hostAddress = a_hostAddress; m_position.x = a_x; m_position.y = a_y; m_nickname = a_nickname; }
[ "nilakantha38@b9e76448-5c52-0410-ae0e-a5aea8c5d16c" ]
[ [ [ 1, 16 ] ] ]
17f75f95fc0e880920e2140156f9ad6077ae23f5
6b75de27b75015e5622bfcedbee0bf65e1c6755d
/Linkedlist/LinkedList.h
890126b2eac424ae858e29fb1016fa26fa973220
[]
no_license
xhbang/data_structure
6e4ac9170715c0e45b78f8a1b66c838f4031a638
df2ff9994c2d7969788f53d90291608ac5b1ef2b
refs/heads/master
2020-04-04T02:07:18.620014
2011-12-05T09:39:34
2011-12-05T09:39:34
2,393,408
0
0
null
null
null
null
UTF-8
C++
false
false
5,973
h
#ifndef LINKLIST_CLASS #define LINKLIST_CLASS #include"Node.h" #include<iostream> using namespace std; template<class T> class LinkedList{ private: Node<T>* front,*rear; Node<T>* prePtr,*currPtr; //记录表当前表遍历位置的指针,用于插入删除操作 int size; //int position; Node<T>* GetNode(const T& data,Node<T>* next=0); // void FreeNode(Node<T>* p);//这个函数忘记使用了,囧 void CopyList(const LinkedList<T>& L); //重载"=",函数使用 public: LinkedList(); LinkedList(const LinkedList<T>& L); ~LinkedList(); LinkedList<T>& operator = (const LinkedList<T>& L); friend ostream& operator <<(ostream& os,LinkedList<T>& L){ //<<重载很好,为什么不能放在外面 Node<T>* p; for(p=L.front->NextNode();p;p=p->NextNode()){ os<<p->GetData(); if(p->NextNode()!=0) os<<','; } return os; } int ListSize(); bool ListEmpty(); void Reset(int loc=0); void Next();// bool EndOfList();// // int CurrentPosition();// void InsertFront(const T& data); void InsertRear(const T& data); void InsertAt(const T& data); void InsertAfter(const T& data); void DeleteFront(); void DeleteAt(); void SetData(T& data); void ClearList(); void Print(); /*提供一些插入查找函数//均由上述函数组合而成,因而存在的必要性不大*/ int Find(T& data,int loc=0); void DeleteData(T& data,int loc=0); void InsertLoc(T& data,int loc); }; template <class T> LinkedList<T>::LinkedList(){ size=0; front=new Node<T>; //if(front->NextNode()==0) cout<<"right in gouzao"<<endl; prePtr=front; currPtr=prePtr->NextNode(); rear=front; } template <class T> LinkedList<T>::LinkedList(const LinkedList<T> &L){ front=new Node<T>; //if(front->NextNode==0) cout<<"right in kaobeigouzao"<<endl; // front->next=0; rear=front; this->CopyList(L); prePtr=front; currPtr=prePtr->NextNode(); } template <class T> LinkedList<T>& LinkedList<T>::operator =(const LinkedList<T> &L){ CopyList(L); } template <class T> void LinkedList<T>::CopyList(const LinkedList<T> &L){ ClearList(); Node<T>* p; for(p=(L.front)->NextNode();p;p=p->NextNode()) InsertRear(p->GetData()); size=L.size; prePtr=front; currPtr=prePtr->NextNode(); } template <class T> LinkedList<T>::~LinkedList(){ ClearList(); DeleteFront(); } template <class T> void LinkedList<T>::DeleteFront(){ delete front; currPtr=prePtr=rear=front=0; } template <class T> void LinkedList<T>::ClearList(){ prePtr=front; currPtr=prePtr->NextNode(); for(;prePtr!=rear;){ DeleteAt();//Print(); //if(currPtr==rear) cout<<"last"<<endl; } size=0; rear=front; currPtr=prePtr->NextNode(); } template <class T> void LinkedList<T>::DeleteAt(){ Node<T>* p=prePtr->DeleteAfter(); if(p==0) delete rear; else delete p; currPtr=prePtr->NextNode(); if(prePtr->NextNode()==0) rear=prePtr/*,cout<<"henhao"<<endl*/; size--; } template <class T> Node<T>* LinkedList<T>::GetNode(const T &data, Node<T> *next = 0){ //私有函数,建立节点 Node<T>* p; p=new Node<T>(data); //if(p->NextNode()==0) cout<<"right in getnode"<<endl; return p; } /*template <class T>//这个函数事实上我没使用=.= void LinkedList<T>::FreeNode(Node<T> *p){ delete p; }*/ template <class T> int LinkedList<T>::ListSize(){ return size; } template <class T> bool LinkedList<T>::ListEmpty(){ if(size==0) return true; else return false; } template <class T> bool LinkedList<T>::EndOfList(){ if(!currPtr->NextNode()) return true; else return false; } template <class T> void LinkedList<T>::InsertFront(const T &data){ currPtr=GetNode(data,front->NextNode()); front->InsertAfter(currPtr); size++; if(currPtr->NextNode()==0) rear=currPtr;/*,cout<<"rear move in insertfront"<<endl*/; // if(rear->NextNode()==0) cout<<"rear.next 正确"<<rear->GetData()<<endl; } template <class T> void LinkedList<T>::InsertRear(const T &data){ currPtr=GetNode(data); rear->InsertAfter(currPtr); rear=rear->NextNode(); size++; } template <class T> void LinkedList<T>::InsertAt(const T &data){ currPtr=GetNode(data,currPtr); prePtr->InsertAfter(currPtr); size++; } template <class T> void LinkedList<T>::InsertAfter(const T &data){ prePtr=currPtr; currPtr=GetNode(data,currPtr->NextNode()); if(prePtr==rear) rear=currPtr/*,cout<<"rear move in insertafter"<<endl*/; prePtr->InsertAfter(currPtr); size++; } template <class T> void LinkedList<T>::Reset(int loc=0){ prePtr=front; currPtr=prePtr->NextNode(); for(int i=1;i<loc;i++){ if(i>=size){ cout<<"error.the currPtr will zhixiang the rear."<<endl; cout<<"the currPtr guoran zhixiang the rear."<<rear->GetData()<<" and "<<currPtr->GetData()<<endl; break; } // cout<<"xian zai de curr"<<currPtr->GetData()<<endl; Next(); // cout<<"next hou de curr"<<currPtr->GetData()<<endl; } } template <class T> void LinkedList<T>::SetData(T& data){ currPtr->SetData(data); } template <class T> void LinkedList<T>::Next(){ prePtr=currPtr; currPtr=currPtr->NextNode(); } template <class T> void LinkedList<T>::Print(){ Node<T>* p; // cout<<rear->GetData()<<endl; // if(rear->NextNode()!=0)cout<<"wokao"; for(p=front->NextNode();p;p=p->NextNode()) cout<<p->GetData()<<","; cout<<endl; } template <class T> int LinkedList<T>::Find(T& data,int loc=0){ Reset(loc); for(int i=1;i<=size;Next(),i++) if(currPtr->GetData()==data) return i; return -1; } template <class T> void LinkedList<T>::DeleteData(T& data,int loc=0){ int i=Find(data,loc); if(i==-1) cout<<"NO the data."<<endl; else this->DeleteAt(); size--; } template <class T> void LinkedList<T>::InsertLoc(T& data,int loc){ Reset(loc); if(currPtr==rear) this->InsertAfter(data); else this->InsertAt(data); } #endif
[ "sonicisdreaming@gmail.com" ]
[ [ [ 1, 264 ] ] ]
fa6f2b7630329056d68471e753cd2bdd3e7914b2
dc4b6ab7b120262779e29d8b2d96109517f35551
/Options/OptionsDlg.h
1d2fb838bf8c97e34ecc2e5c4cba336a4bb2d6e9
[]
no_license
cnsuhao/wtlhelper9
92daef29b61f95f44a10e3277d8835c2dd620616
681df3a014fc71597e9380b0a60bd3cd23e22efe
refs/heads/master
2021-07-17T19:59:07.143192
2009-05-18T14:24:48
2009-05-18T14:24:48
108,361,858
0
1
null
null
null
null
UTF-8
C++
false
false
2,571
h
//////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2004 Sergey Solozhentsev // Author: Sergey Solozhentsev e-mail: salos@mail.ru // Product: WTL Helper // File: OptionsDlg.h // Created: 21.12.2004 10:46 // // Using this software in commercial applications requires an author // permission. The permission will be granted to everyone excluding the cases // when someone simply tries to resell the code. // This file may be redistributed by any means PROVIDING it is not sold for // profit without the authors written consent, and providing that this notice // and the authors name is included. // This file is provided "as is" with no expressed or implied warranty. The // author accepts no liability if it causes any damage to you or your computer // whatsoever. // //////////////////////////////////////////////////////////////////////////////// // MainDlg.h : interface of the CMainDlg class // ///////////////////////////////////////////////////////////////////////////// #pragma once #pragma warning (disable: 4267) #include "../atlgdix.h" #include "../DotNetTabCtrl.h" #include <atlframe.h> #include "../TabbedFrame.h" #pragma warning (default: 4267) #include "FunctionOptDlg.h" #include "DDXoptForm.h" #include "AboutDlg.h" #include "CommonOptForm.h" class COptionsDlg : public CDialogImpl<COptionsDlg> { CTabbedChildWindow< CDotNetTabCtrl<CTabViewTabItem> > m_tabbedChildWindow; void CreateCtrls(); public: enum { IDD = IDD_OPTIONSDLG }; COptionsDlg(); CDDXoptForm m_DDXForm; CFunctionOptDlg m_FuncOpt; CAboutDlg m_AboutDlg; CCommonOptForm m_CommonOpt; BEGIN_MSG_MAP(COptionsDlg) MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) COMMAND_ID_HANDLER(IDOK, OnOK) COMMAND_ID_HANDLER(IDCANCEL, OnCancel) END_MSG_MAP() // Handler prototypes (uncomment arguments if needed): // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); LRESULT OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/); LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/); };
[ "free2000fly@eea8f18a-16fd-41b0-b60a-c1204a6b73d1" ]
[ [ [ 1, 66 ] ] ]
1a5b0219e5df34f706eeb5879558da75014dff7e
c95a83e1a741b8c0eb810dd018d91060e5872dd8
/Game/ClientShellDLL/ClientShellShared/SmokeFX.cpp
0b31439c97c0ea61019648944652a855c43abc2c
[]
no_license
rickyharis39/nolf2
ba0b56e2abb076e60d97fc7a2a8ee7be4394266c
0da0603dc961e73ac734ff365bfbfb8abb9b9b04
refs/heads/master
2021-01-01T17:21:00.678517
2011-07-23T12:11:19
2011-07-23T12:11:19
38,495,312
1
0
null
null
null
null
UTF-8
C++
false
false
5,148
cpp
// ----------------------------------------------------------------------- // // // MODULE : SmokeFX.cpp // // PURPOSE : Smoke special FX - Implementation // // CREATED : 3/2/98 // // ----------------------------------------------------------------------- // #include "stdafx.h" #include "SmokeFX.h" #include "iltclient.h" #include "ClientUtilities.h" #include "ClientServerShared.h" extern LTVector g_vWorldWindVel; // ----------------------------------------------------------------------- // // // ROUTINE: CSmokeFX::Init // // PURPOSE: Init the smoke trail // // ----------------------------------------------------------------------- // LTBOOL CSmokeFX::Init(SFXCREATESTRUCT* psfxCreateStruct) { if (!CBaseParticleSystemFX::Init(psfxCreateStruct)) return LTFALSE; m_pTextureName = "SFX\\Particle\\Smoke1.dtx"; SMCREATESTRUCT* pSM = (SMCREATESTRUCT*)psfxCreateStruct; m_dwFlags = pSM->dwSystemFlags; m_vPos = pSM->vPos; m_vColor1 = pSM->vColor1; m_vColor2 = pSM->vColor1; m_vMinDriftVel = pSM->vMinDriftVel; m_vMaxDriftVel = pSM->vMaxDriftVel; m_fVolumeRadius = pSM->fVolumeRadius; m_fLifeTime = pSM->fLifeTime; m_fRadius = pSM->fRadius; m_fParticleCreateDelta = pSM->fParticleCreateDelta; m_fMinParticleLife = pSM->fMinParticleLife; m_fMaxParticleLife = pSM->fMaxParticleLife; m_nNumParticles = pSM->nNumParticles; m_bIgnoreWind = pSM->bIgnoreWind; m_hstrTexture = pSM->hstrTexture; //reset our elapsed time, and our emission time m_fElapsedTime = 0.0f; m_fElapsedEmissionTime = m_fParticleCreateDelta; m_fGravity = 0.0f; return LTTRUE; } // ----------------------------------------------------------------------- // // // ROUTINE: CSmokeFX::CreateObject // // PURPOSE: Create object associated the particle system. // // ----------------------------------------------------------------------- // LTBOOL CSmokeFX::CreateObject(ILTClient *pClientDE) { if (!pClientDE ) return LTFALSE; if (m_hstrTexture) { m_pTextureName = pClientDE->GetStringData(m_hstrTexture); } LTBOOL bRet = CBaseParticleSystemFX::CreateObject(pClientDE); return bRet; } // ----------------------------------------------------------------------- // // // ROUTINE: CSmokeFX::Update // // PURPOSE: Update the smoke // // ----------------------------------------------------------------------- // LTBOOL CSmokeFX::Update() { if (!m_hObject || !m_pClientDE ) return LTFALSE; if( g_pGameClientShell->IsServerPaused() ) { g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, FLAG_PAUSED, FLAG_PAUSED); return LTTRUE; } //make sure we aren't paused g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, 0, FLAG_PAUSED); LTFLOAT fFrameTime = m_pClientDE->GetFrameTime(); m_fElapsedTime += fFrameTime; m_fElapsedEmissionTime += fFrameTime; // Hide/show the particle system if necessary... if (m_hServerObject) { uint32 dwUserFlags; g_pCommonLT->GetObjectFlags(m_hServerObject, OFT_User, dwUserFlags); if (!(dwUserFlags & USRFLG_VISIBLE)) { uint32 dwFlags; g_pCommonLT->GetObjectFlags(m_hObject, OFT_Flags, dwFlags); // Once last puff as disappeared, hide the system (no new puffs // will be added...) if (dwFlags & FLAG_VISIBLE) { if (m_fElapsedEmissionTime > m_fMaxParticleLife) { g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, 0, FLAG_VISIBLE); } } else { m_fElapsedEmissionTime = 0.0f; } return LTTRUE; } else { g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, FLAG_VISIBLE, FLAG_VISIBLE); } } // Check to see if we should just wait for last smoke puff to go away... if (m_fElapsedTime > m_fLifeTime) { if (m_fElapsedEmissionTime > m_fMaxParticleLife) { return LTFALSE; } return LTTRUE; } // See if it is time to add some more smoke... if (m_fElapsedEmissionTime >= m_fParticleCreateDelta) { LTVector vDriftVel, vColor, vPos; // What is the range of colors? LTFLOAT fRange = m_vColor2.x - m_vColor1.x; // Determine how many particles to add... int nNumParticles = GetNumParticles(m_nNumParticles); // Build the individual smoke puffs... for (int j=0; j < nNumParticles; j++) { VEC_SET(vPos, GetRandom(-m_fVolumeRadius, m_fVolumeRadius), -2.0f, GetRandom(-m_fVolumeRadius, m_fVolumeRadius)); VEC_SET(vDriftVel, GetRandom(m_vMinDriftVel.x, m_vMaxDriftVel.x), GetRandom(m_vMinDriftVel.y, m_vMaxDriftVel.y), GetRandom(m_vMinDriftVel.z, m_vMaxDriftVel.z)); if (!m_bIgnoreWind) { VEC_ADD(vDriftVel, vDriftVel, g_vWorldWindVel); } GetRandomColorInRange(vColor); LTFLOAT fLifeTime = GetRandom(m_fMinParticleLife, m_fMaxParticleLife); vDriftVel -= (m_vVel * 0.1f); m_pClientDE->AddParticle(m_hObject, &vPos, &vDriftVel, &vColor, fLifeTime); } m_fElapsedEmissionTime = 0.0f; } return CBaseParticleSystemFX::Update(); }
[ "vytautasrask@gmail.com" ]
[ [ [ 1, 205 ] ] ]
6a47530a6dc2624a2f6b83f4922a328d7a05e722
463c3b62132d215e245a097a921859ecb498f723
/lib/dlib/threads/thread_function_extension.h
3408390dfe1f61343dcd190942bb26b04366a027
[ "LicenseRef-scancode-unknown-license-reference", "BSL-1.0" ]
permissive
athulan/cppagent
58f078cee55b68c08297acdf04a5424c2308cfdc
9027ec4e32647e10c38276e12bcfed526a7e27dd
refs/heads/master
2021-01-18T23:34:34.691846
2009-05-05T00:19:54
2009-05-05T00:19:54
197,038
4
1
null
null
null
null
UTF-8
C++
false
false
3,117
h
// Copyright (C) 2007 Davis E. King (davisking@users.sourceforge.net) // License: Boost Software License See LICENSE.txt for the full license. #ifndef DLIB_THREAD_FUNCTIOn_ #define DLIB_THREAD_FUNCTIOn_ #include "thread_function_extension_abstract.h" #include "threads_kernel.h" #include "auto_mutex_extension.h" #include "threaded_object_extension.h" namespace dlib { // ---------------------------------------------------------------------------------------- class thread_function : private threaded_object { class base_funct { public: virtual void go() = 0; virtual ~base_funct() {} }; template <typename T> class super_funct_arg : public base_funct { public: super_funct_arg ( void (*funct)(T), T arg ) { a = arg; f = funct; } void go() { f(a); } T a; void (*f)(T); }; class super_funct_no_arg : public base_funct { public: super_funct_no_arg ( void (*funct)() ) { f = funct; } void go() { f(); } void (*f)(); }; template <typename T> class super_Tfunct_no_arg : public base_funct { public: super_Tfunct_no_arg ( const T& funct ) { f = funct; } void go() { f(); } T f; }; public: template <typename T> thread_function ( const T& funct ) { f = new super_Tfunct_no_arg<T>(funct); start(); } thread_function ( void (*funct)() ) { f = new super_funct_no_arg(funct); start(); } template <typename T> thread_function ( void (*funct)(T), T arg ) { f = new super_funct_arg<T>(funct,arg); start(); } ~thread_function ( ) { threaded_object::wait(); delete f; } bool is_alive ( ) const { return threaded_object::is_alive(); } void wait ( ) const { threaded_object::wait(); } private: void thread () { f->go(); } base_funct* f; // restricted functions thread_function(thread_function&); // copy constructor thread_function& operator=(thread_function&); // assignment operator }; // ---------------------------------------------------------------------------------------- } #endif // DLIB_THREAD_FUNCTIOn_
[ "jimmy@DGJ3X3B1.(none)" ]
[ [ [ 1, 150 ] ] ]
6729250c8691a76b71f550607fa10980a3a4d002
478570cde911b8e8e39046de62d3b5966b850384
/apicompatanamdw/bcdrivers/mw/classicui/uifw/apps/S60_SDK3.2/bctestlocalizer/src/bctestlocalizerappui.cpp
f759da4637e85c9f4768f6250adaac23b3041ea0
[]
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,251
cpp
/* * 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: appui * */ #include <avkon.hrh> #include <aknsutils.h> #include "bctestlocalizerappui.h" #include "bctestlocalizer.hrh" #include "bctestlocalizerview.h" // ======== MEMBER FUNCTIONS ======== // --------------------------------------------------------------------------- // ctro do nothing // --------------------------------------------------------------------------- // CBCTestLocalizerAppUi::CBCTestLocalizerAppUi() { } // --------------------------------------------------------------------------- // symbian 2nd phase ctor // --------------------------------------------------------------------------- // void CBCTestLocalizerAppUi::ConstructL() { BaseConstructL(); AknsUtils::SetAvkonSkinEnabledL( ETrue ); // init view CBCTestLocalizerView* view = CBCTestLocalizerView::NewL(); CleanupStack::PushL( view ); AddViewL( view ); CleanupStack::Pop( view ); ActivateLocalViewL( view->Id() ); } // ---------------------------------------------------------------------------- // CBCTestLocalizerAppUi::~CBCTestLocalizerAppUi() // Destructor. // ---------------------------------------------------------------------------- // CBCTestLocalizerAppUi::~CBCTestLocalizerAppUi() { } // ---------------------------------------------------------------------------- // handle menu command events // ---------------------------------------------------------------------------- // void CBCTestLocalizerAppUi::HandleCommandL( TInt aCommand ) { switch ( aCommand ) { case EAknSoftkeyBack: case EEikCmdExit: { Exit(); return; } default: break; } } // End of File
[ "none@none" ]
[ [ [ 1, 81 ] ] ]
4fc22d9164c7f00399c428d003eb3173923f41f7
3e3d5fa109cdd653d43867b46307683514d916a0
/examples/benchmark/Benchmark.cpp
1c7852e2ea88b72bfdabb2fccddba4f70ca64b4e
[]
no_license
badog1011/aquila
b8a767ea07829934bbbb2b2a4e501e473cfae301
887a63ddb032cfc7f71cce72a439b5b5dd2fe65c
refs/heads/master
2016-08-12T00:32:19.598867
2010-03-25T11:28:56
2010-03-25T11:28:56
50,173,002
0
0
null
null
null
null
UTF-8
C++
false
false
4,606
cpp
#include "Benchmark.h" #include "aquila/dtw/Dtw.h" #include "aquila/Transform.h" #include "aquila/WaveFile.h" #include "aquila/ConsoleProcessingIndicator.h" #include "../utils.h" #include <algorithm> #include <cstdlib> #include <iostream> #include <numeric> #include <boost/filesystem.hpp> #include <boost/progress.hpp> Benchmark::Benchmark(int iterations_count): ITERATIONS(iterations_count), extractor(0) { std::srand(std::time(0)); } Benchmark::~Benchmark() { delete extractor; } void Benchmark::run() { std::cout << "Benchmarking, please wait..." << std::endl; testFft(); testDct(); testWavefile(); testEnergy(); testMfcc(); testDtw(); double result = std::accumulate(durations.begin(), durations.end(), 0.0); std::cout << "Benchmarking finished." << std::endl; std::cout << "Total result: " << result << std::endl; } void Benchmark::testFft() { const int TEST_DATA_SIZE = 65536; std::vector<double> testData(TEST_DATA_SIZE); std::generate(testData.begin(), testData.end(), generateRandomDouble); Aquila::spectrumType spectrum(TEST_DATA_SIZE); Aquila::Transform transform(0); boost::progress_display progress(ITERATIONS); startTime = clock(); for (int i = 0; i < ITERATIONS; ++i) { transform.fft(testData, spectrum); ++progress; } double duration = clock() - startTime; durations.push_back(duration); std::cout << "FFT: " << duration << std::endl; } void Benchmark::testDct() { const int TEST_DATA_SIZE = 1024, DCT_SIZE = 12; std::vector<double> testData(TEST_DATA_SIZE), dctOutput(DCT_SIZE); std::generate(testData.begin(), testData.end(), generateRandomDouble); Aquila::Transform transform(0); boost::progress_display progress(ITERATIONS); startTime = clock(); for (int i = 0; i < ITERATIONS; ++i) { transform.dct(testData, dctOutput); ++progress; } double duration = clock() - startTime; durations.push_back(duration); std::cout << "DCT: " << duration << std::endl; } void Benchmark::testWavefile() { Aquila::WaveFile* wav = new Aquila::WaveFile(20, 0.66); std::string filename = getFile("test.wav"); boost::progress_display progress(ITERATIONS); startTime = clock(); for (int i = 0; i < ITERATIONS; ++i) { wav->load(filename); ++progress; } double duration = clock() - startTime; durations.push_back(duration); std::cout << "Wave file: " << duration << std::endl; delete wav; } void Benchmark::testEnergy() { Aquila::WaveFile* wav = new Aquila::WaveFile(20, 0.66); std::string filename = getFile("test.wav"); wav->load(filename); Aquila::Transform transform(0); double energy; boost::progress_display progress(ITERATIONS); startTime = clock(); for (int i = 0; i < ITERATIONS; ++i) { for (unsigned int j = 0, fc = wav->getFramesCount(); j < fc; ++j) { energy = transform.frameLogEnergy(wav->frames[j]); } ++progress; } double duration = clock() - startTime; durations.push_back(duration); std::cout << "Energy: " << duration << std::endl; delete wav; } void Benchmark::testMfcc() { Aquila::WaveFile* wav = new Aquila::WaveFile(20, 0.66); std::string filename = getFile("test.wav"); wav->load(filename); delete extractor; extractor = new Aquila::MfccExtractor(20, 10); Aquila::TransformOptions options; options.preemphasisFactor = 0.9375; options.windowType = Aquila::WIN_HAMMING; options.zeroPaddedLength = wav->getSamplesPerFrameZP(); Aquila::ConsoleProcessingIndicator progress; extractor->setProcessingIndicator(&progress); startTime = clock(); extractor->process(wav, options); double duration = clock() - startTime; durations.push_back(duration); std::cout << "MFCC: " << duration << std::endl; delete wav; } void Benchmark::testDtw() { if (!extractor) return; startTime = clock(); Aquila::Dtw* dtw = new Aquila::Dtw(extractor); dtw->getDistance(extractor); double duration = clock() - startTime; durations.push_back(duration); std::cout << "DTW: " << duration << std::endl; delete dtw; } double Benchmark::clock() { return t.elapsed(); } double generateRandomDouble() { return 255.0 * std::rand() / double(RAND_MAX); }
[ "antyqjon@e3e259e2-fbb7-11de-bceb-371847987001" ]
[ [ [ 1, 180 ] ] ]
5709cc78fc989012c1a2352d3783a95b4a4dd165
1585c7e187eec165138edbc5f1b5f01d3343232f
/СПиОС/PiChat/PiChat/PiChatServer/PiChatServer.cpp
f15569ea908fc90a9fb604650b04a1cc343fe116
[]
no_license
a-27m/vssdb
c8885f479a709dd59adbb888267a03fb3b0c3afb
d86944d4d93fd722e9c27cb134256da16842f279
refs/heads/master
2022-08-05T06:50:12.743300
2011-06-23T08:35:44
2011-06-23T08:35:44
82,612,001
1
0
null
2021-03-29T08:05:33
2017-02-20T23:07:03
C#
UTF-8
C++
false
false
2,098
cpp
// PiChatServer.cpp : Defines the class behaviors for the application. // #include "stdafx.h" #include "PiChatServer.h" #include "PiChatServerDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CPiSrvApp BEGIN_MESSAGE_MAP(CPiSrvApp, CWinAppEx) ON_COMMAND(ID_HELP, &CWinApp::OnHelp) END_MESSAGE_MAP() // CPiSrvApp construction CPiSrvApp::CPiSrvApp() { // TODO: add construction code here, // Place all significant initialization in InitInstance } // The one and only CPiSrvApp object CPiSrvApp theApp; // CPiSrvApp initialization BOOL CPiSrvApp::InitInstance() { // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinAppEx::InitInstance(); AfxEnableControlContainer(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored // TODO: You should modify this string to be something appropriate // such as the name of your company or organization SetRegistryKey(_T("Local AppWizard-Generated Applications")); CPiSrvDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
[ "Axell@bf672a44-3a04-1d4a-850b-c2a239875c8c" ]
[ [ [ 1, 79 ] ] ]
33a76ed015e7395d36db482f146ec17163e491c4
5646bc196d1601bb2c7148d6c5aabea91eb86447
/sources/man.cpp
c7affd66d3c9407e98ac3df62abf25c70e401972
[]
no_license
pombreda/elfdata
d04d78580363b8a67c4312de360e96065a351146
e3ae13f833852a673b9f4456a407c59cc8d0215d
refs/heads/master
2016-09-10T08:58:31.583531
2009-12-06T16:50:14
2009-12-06T16:50:14
34,612,970
1
0
null
null
null
null
WINDOWS-1251
C++
false
false
11,827
cpp
// ElfData main file #include <stdio.h> #include <conio.h> #include <windows.h> #include "elfparser.h" #include "binfile.h" #include "common.h" #define ELFDATAVERSION 03 #define ELFDATAVERSIONSTR "0.3" // -- GLOBAL VARS LIST --------------------------------------------------------- bool tagShowHelp; bool tagPEH; // print Elf Header bool tagPDT; // print Dynamic Tags bool tagSPS; bool tagPST; // print StringTable bool tagPPH; bool tagPSH; bool tagLOG; bool bigend; // -- GLOBAL VARS LIST END ----------------------------------------------------- int Log(char * str) { if(!tagLOG) return 1; FILE * f = fopen("log.txt", "a"); fprintf(f, "%s", str); fclose(f); return 0; } #define HELPMSG "ElfData v."ELFDATAVERSIONSTR"\n" \ "\n" \ "-f(filename) Elf File Path\n" \ "-h Show this message\n" \ "-log Log to file\n" \ "-peh Print ELF header\n" \ "-pph Print program headers\n" \ "-psh Print section headers\n" \ "-pst Print string table\n" \ "-sps Save program segments\n" \ "-sss Save section segments\n" int PrintfHelp() { printf("%s\n", HELPMSG); return 0; } int PrintElfHeader(Elf32_Ehdr * h) { printf("e_ident { "); printf("0 : 0x%02X\n", h->e_ident[0]); printf(" 1 : 0x%02X '%c'\n", h->e_ident[1], h->e_ident[1]); printf(" 2 : 0x%02X '%c'\n", h->e_ident[2], h->e_ident[2]); printf(" 3 : 0x%02X '%c'\n", h->e_ident[3], h->e_ident[3]); printf(" 4 : 0x%02X ", h->e_ident[4]); switch(h->e_ident[4]) { case ELFCLASSNONE: { printf("ELFCLASSNONE\n"); break; } case ELFCLASS32: { printf("ELFCLASS32\n"); break; } case ELFCLASS64: { printf("ELFCLASS64\n"); break; } default: { printf("\n"); } } printf(" 5 : 0x%02X ", h->e_ident[5]); switch(h->e_ident[5]) { case ELFDATANONE: { printf("ELFDATANONE\n"); break; } case ELFDATA2LSB: { printf("ELFDATA2LSB (LittleEndian - Intel-style)\n"); break; } case ELFDATA2MSB: { printf("ELFDATA2MSB (BigEndian - Motorola-style)\n"); break; } default: { printf("\n"); } } printf(" 6 : 0x%02X ", h->e_ident[6]); switch(h->e_ident[6]) { case EV_NONE: { printf("EV_NONE\n"); break; } case EV_CURRENT: { printf("EV_CURRENT (Default)\n"); break; } default: { printf("\n"); } } printf(" 7 : 0x%02X \n", h->e_ident[7]); printf(" 8 : 0x%02X \n", h->e_ident[8]); printf(" 9 : 0x%02X \n", h->e_ident[9]); printf(" A : 0x%02X \n", h->e_ident[10]); printf(" B : 0x%02X \n", h->e_ident[11]); printf(" C : 0x%02X \n", h->e_ident[12]); printf(" D : 0x%02X \n", h->e_ident[13]); printf(" E : 0x%02X \n", h->e_ident[14]); printf(" F : 0x%02X }\n", h->e_ident[15]); printf("e_type : %d\n",h->e_type); printf("e_machine : %d ",h->e_machine); switch(h->e_machine) { case EM_NONE: { printf("EM_NONE\n"); break; } case EM_M32: { printf("EM_M32 (AT&T WE 32100)\n"); break; } case EM_SPARC: { printf("EM_SPARC (SPARC)\n"); break; } case EM_386: { printf("EM_386 (Intel Architecture)\n"); break; } case EM_68K: { printf("EM_68K (Motorola 68000)\n"); break; } case EM_88K: { printf("EM_88K (Motorola 88000)\n"); break; } case EM_860: { printf("EM_860 (Intel 80860)\n"); break; } case EM_MIPS: { printf("EM_MIPS (MIPS RS3000 Big-Endian)\n"); break; } case EM_MIPS_RS4_BE: { printf("EM_MIPS_RS4_BE (MIPS RS4000 Big-Endian)\n"); break; } case EM_ARM: { printf("EM_ARM (ARM/Thumb Architecture)\n"); break; } default: { printf("\n"); } } printf("e_version : %d ",h->e_version); switch(h->e_version) { case EV_NONE: { printf("EV_NONE\n"); break; } case EV_CURRENT: { printf("EV_CURRENT (Default)\n"); break; } default: { printf("\n"); } } printf("e_entry : 0x%08X\n",h->e_entry); printf("e_phoff : 0x%X (%d)\n",h->e_phoff,h->e_phoff); printf("e_shoff : 0x%X (%d)\n",h->e_shoff,h->e_shoff); printf("e_flags : 0x%X\n",h->e_flags); printf("e_ehsize : 0x%X\n",h->e_ehsize); printf("e_phentsize : 0x%X\n",h->e_phentsize); printf("e_phnum : 0x%X (%d)\n",h->e_phnum, h->e_phnum); printf("e_shentsize : 0x%X\n",h->e_shentsize); printf("e_shnum : 0x%X (%d)\n",h->e_shnum, h->e_shnum); printf("e_shstrndx : %d\n",h->e_shstrndx); printf("\n"); return 0; } int PrintProgramHeader(Elf32_Phdr * h) { printf("p_type : 0x%X ", h->p_type); switch(h->p_type) { case PT_NULL: { printf("PT_NULL\n"); break; } case PT_LOAD: { printf("PT_LOAD\n"); break; } case PT_DYNAMIC: { printf("PT_DYNAMIC\n"); break; } case PT_INTERP: { printf("PT_INTERP\n"); break; } case PT_NOTE: { printf("PT_NOTE\n"); break; } case PT_SHLIB: { printf("PT_SHLIB\n"); break; } case PT_PHDR: { printf("PT_PHDR\n"); break; } case PT_LOPROC: { printf("PT_LOPROC\n"); break; } case PT_HIPROC: { printf("PT_HIPROC\n"); break; } default: { printf("\n"); } } printf("p_offset : 0x%X (%d)\n", h->p_offset, h->p_offset); printf("p_vaddr : 0x%.8X \n", h->p_vaddr); printf("p_paddr : 0x%.8X \n", h->p_paddr); printf("p_filesz : 0x%X (%d)\n", h->p_filesz, h->p_filesz); printf("p_memsz : 0x%X (%d)\n", h->p_memsz, h->p_memsz); char cflags[32]; strcpy(cflags, ""); int f = h->p_flags; if(f&PF_X) { strcat(cflags, "PF_X"); } if(f&PF_W) { if(strcmp(cflags, "")!=0) strcat(cflags, " | "); strcat(cflags, "PF_W"); } if(f&PF_R) { if(strcmp(cflags, "")!=0) strcat(cflags, " | "); strcat(cflags, "PF_R"); } printf("p_flags : 0x%X (%s)\n", h->p_flags, cflags); printf("p_align : 0x%X \n", h->p_align); printf("\n"); return 0; } int PrintDynTags(ELF_T * Elf) { for (int i=0; i<DT_MAX_TAG+1; i++) { //if ( Elf->DynamicTags[i] ) printf("Tag[%2d] = 0x%X \t(%d)\n", i, Elf->DynamicTags[i], Elf->DynamicTags[i]); } return 0; } int PrintStringTable(ELF_T * Elf) { //int m = strlen(Elf->StringTable); int m = Elf->DynamicTags[DT_STRSZ]; int off=0; char * s; int i=0; while(off < m) { s = (char*)(Elf->StringTable + off); printf("#%d Index: %d Value: %s\n", i, off, s); off += strlen(s)+1; i++; } return 0; } int PrintSectionHeader(Elf32_Shdr * h, ELF_T * Elf) { printf("sh_name : %d\n", h->sh_name); printf("sh_type : %d ", h->sh_type); switch(h->sh_type) { case SHT_NULL: { printf("SHT_NULL\n"); break; } case SHT_PROGBITS: { printf("SHT_PROGBITS\n"); break; } case SHT_SYMTAB: { printf("SHT_SYMTAB\n"); break; } case SHT_STRTAB: { printf("SHT_STRTAB\n"); break; } case SHT_RELA: { printf("SHT_RELA\n"); break; } case SHT_HASH: { printf("SHT_HASH\n"); break; } case SHT_DYNAMIC: { printf("SHT_DYNAMIC\n"); break; } case SHT_NOTE: { printf("SHT_NOTE\n"); break; } case SHT_NOBITS: { printf("SHT_NOBITS\n"); break; } case SHT_REL: { printf("SHT_REL\n"); break; } case SHT_SHLIB: { printf("SHT_SHLIB\n"); break; } case SHT_DYNSYM: { printf("SHT_DYNSYM\n"); break; } default: { printf("\n"); } } char cflags[32]; strcpy(cflags, ""); int f = h->sh_flags; if(f&SHF_WRITE) { strcat(cflags, "SHF_WRITE"); } if(f&SHF_ALLOC) { if(strcmp(cflags, "")!=0) strcat(cflags, " | "); strcat(cflags, "SHF_ALLOC"); } if(f&SHF_EXECINSTR) { if(strcmp(cflags, "")!=0) strcat(cflags, " | "); strcat(cflags, "SHF_EXECINSTR"); } printf("sh_flags : 0x%X (%s)\n", h->sh_flags, cflags); printf("sh_addr : 0x%.8X\n", h->sh_addr); printf("sh_offset : 0x%X (%d)\n", h->sh_offset, h->sh_offset); printf("sh_size : 0x%X (%d)\n", h->sh_size, h->sh_size); printf("sh_link : 0x%.8X\n", h->sh_link); printf("sh_info : 0x%.8X\n", h->sh_info); printf("sh_addralign : 0x%.8X\n", h->sh_addralign); printf("sh_entsize : 0x%X (%d)\n", h->sh_entsize, h->sh_entsize); printf("\n"); return 0; } int main(int argc, char* argv[]) { int r=0; char FileName[256]= ""; char Path[256];//, PrPath[256]; for(int i=1;i<argc;i++) { printf("argv[%d = %s\n", i, argv[i]); if(strcmp(argv[i], "")==0)continue; if(strcmp(argv[i], "-h")==0) tagShowHelp = true; if(strcmp(argv[i], "-log")==0) tagLOG = true; if(strcmp(argv[i], "-peh")==0) tagPEH = true; if(strcmp(argv[i], "-pdt")==0) tagPDT = true; if(strcmp(argv[i], "-pph")==0) tagPPH = true; if(strcmp(argv[i], "-psh")==0) tagPSH = true; if(strcmp(argv[i], "-pst")==0) tagPST = true; if(strcmp(argv[i], "-sps")==0) tagSPS = true; if(strncmp(argv[i], "-f", 2)==0) { sscanf(argv[i], "-f(%s)", FileName); } } if ( !strlen(FileName) ) { PrintfHelp(); return 1; } FileName[strlen(FileName)-1] = '\0'; strcpy(Path, FileName); for(int i=strlen(Path);i>0;i--) { if(Path[i]=='\\' || Path[i]=='/') break; else Path[i] = '\0'; } Log(""); if(tagShowHelp) PrintfHelp(); ELF_T * Elf = OpenElf(FileName); SetCurrentDirectory(Path); ParseHeader(Elf); Elf32_Ehdr * h = &Elf->Header; if ( tagPEH ) { printf("HEADER:\n"); PrintElfHeader(h); } ParseProgramHeaders(Elf); Elf32_Phdr * p; if(tagPPH) { for(int i=0;i<Elf->Header.e_phnum;i++) { printf("PROGRAM HEADER #%d:\n", i); p = &Elf->ProgramHeaders[i]; PrintProgramHeader(p); } } ParseDynamicSegment(Elf); PrepareDynamicSegment(Elf); if ( tagPDT ) { printf("DINAMIC TAGS:\n"); PrintDynTags(Elf); } if ( tagPST ) { printf("STRING TABLE:\n"); PrintStringTable(Elf); } ParseSectionHeaders(Elf); Elf32_Shdr * s; if(tagPSH) { for(int i=0;i<Elf->Header.e_shnum;i++) { printf("SECTION HEADER #%d:\n", i); s = &Elf->SectionHeaders[i]; PrintSectionHeader(s, Elf); } } if(tagSPS) { for(int i=0;i<Elf->Header.e_phnum;i++) { if(true) // Написать всякие проверки { char fn[256]; char t[256]; FILE * f; void * ptr; ptr = malloc(Elf->ProgramHeaders[i].p_memsz); LoadProgramSegment(Elf, &Elf->ProgramHeaders[i], ptr); //ltoa(i, t, 10); sprintf(fn, "ProgramSegment%.2d", i); f = fopen(fn, "w"); fwrite(ptr, 1, Elf->ProgramHeaders[i].p_memsz, f); fclose(f); free(ptr); sprintf( t, "PrgramSegment%.2d vaddr=%.8x paddr=%.8x size=%.8x\n", i, Elf->ProgramHeaders[i].p_vaddr, Elf->ProgramHeaders[i].p_paddr, Elf->ProgramHeaders[i].p_memsz ); Log(t); } } } delete Elf; //getch(); return 0; }
[ "dmt021@209ad4d6-6edc-11de-8fcd-b1e6d76e070b", "itimapple@209ad4d6-6edc-11de-8fcd-b1e6d76e070b" ]
[ [ [ 1, 5 ], [ 7, 8 ], [ 10, 10 ], [ 54, 58 ], [ 64, 85 ], [ 87, 108 ], [ 110, 126 ], [ 136, 144 ], [ 146, 213 ], [ 216, 306 ], [ 308, 311 ], [ 323, 324 ], [ 327, 333 ], [ 335, 443 ], [ 448, 448 ], [ 473, 473 ], [ 479, 479 ], [ 482, 482 ], [ 490, 491 ], [ 500, 502 ], [ 504, 504 ], [ 511, 512 ], [ 514, 514 ], [ 527, 529 ], [ 531, 531 ], [ 538, 539 ], [ 568, 568 ], [ 570, 574 ] ], [ [ 6, 6 ], [ 9, 9 ], [ 11, 53 ], [ 59, 63 ], [ 86, 86 ], [ 109, 109 ], [ 127, 135 ], [ 145, 145 ], [ 214, 215 ], [ 307, 307 ], [ 312, 322 ], [ 325, 326 ], [ 334, 334 ], [ 444, 447 ], [ 449, 472 ], [ 474, 478 ], [ 480, 481 ], [ 483, 489 ], [ 492, 499 ], [ 503, 503 ], [ 505, 510 ], [ 513, 513 ], [ 515, 526 ], [ 530, 530 ], [ 532, 537 ], [ 540, 567 ], [ 569, 569 ] ] ]
6e7c90ae6da3a31883d30afca5327ab44c8e1a1b
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/mpl/preprocessed/include/typeof_based/user.hpp
687b6e13db803fc369d271fd12ca6fab58b09709
[ "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
willrebuild/flyffsf
e5911fb412221e00a20a6867fd00c55afca593c7
d38cc11790480d617b38bb5fc50729d676aef80d
refs/heads/master
2021-01-19T20:27:35.200154
2011-02-10T12:34:43
2011-02-10T12:34:43
32,710,780
3
0
null
null
null
null
UTF-8
C++
false
false
488
hpp
// Copyright Aleksey Gurtovoy 2003-2004 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/mpl for documentation. // $Source: /cvsroot/boost/boost/libs/mpl/preprocessed/include/typeof_based/user.hpp,v $ // $Date: 2004/09/14 12:39:55 $ // $Revision: 1.3 $ #define BOOST_NO_CONFIG #define BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES
[ "66430417@qq.com@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 15 ] ] ]
450ac9b95d32c46d62aa5817f7dd1f85e6d0ca85
9ad9345e116ead00be7b3bd147a0f43144a2e402
/Integration_WAH_&_Extraction/SMDataExtraction/FlexVCBridgeStaticLib/Logger.cpp
795d6ce5844238d93eec27b1b35881d8cd9b9ff2
[]
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
986
cpp
/* * The contents of this file are subject to the Mozilla Public License Version * 1.1 (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.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is the Flex C++ Bridge. * * The Initial Developer of the Original Code is * Anirudh Sasikumar (http://anirudhs.chaosnet.org/). * Portions created by the Initial Developer are Copyright (C) 2008 * the Initial Developer. All Rights Reserved. * * Contributor(s): * */ #include "Logger.h" std::ofstream CLogger::m_fout; void CLogger::Init(const char* buf) { m_fout.open(buf); } void CLogger::Uninit() { m_fout.close(); }
[ "jaadds@c7f6ba40-6498-11de-987a-95e5a5a5d5f1" ]
[ [ [ 1, 35 ] ] ]
8e141c9e33cb9de176df1874aed584086ff25c54
273020f62176230357e51a5ca20212ac0f32a01f
/trunk/traydict/main.cpp
fc6838616570f5ef29f95463122a02f782e74a1b
[]
no_license
BackupTheBerlios/aegisub-svn
1915f94798fea3f45db86b16acb07fdd059ac8d2
e26eda1242e9d628adcc3e6c5d57614a4808c9e0
refs/heads/master
2016-08-04T11:27:52.584837
2007-01-15T01:46:59
2007-01-15T01:46:59
40,664,462
0
0
null
null
null
null
UTF-8
C++
false
false
3,366
cpp
// Copyright (c) 2006, Rodrigo Braz Monteiro // 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 Aegisub Group nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // // ----------------------------------------------------------------------------- // // AEGISUB // // Website: http://aegisub.cellosoft.com // Contact: mailto:zeratul@cellosoft.com // /////////// // Headers #include <wx/wxprec.h> #include <wx/filename.h> #include "main.h" #include "dict_window.h" ///////////////// // Implement app IMPLEMENT_APP(TrayDict) ////////////// // Initialize bool TrayDict::OnInit() { // Configuration SetAppName(_T("TrayDict")); srand((unsigned)time(NULL)); // Get path GetFullPath(argv[0]); GetFolderName(); // Create the window DictWindow *window = new DictWindow(); window->Show(); // Initialization OK return true; } ///////////////////////////// // Gets and stores full path void TrayDict::GetFullPath(wxString arg) { if (wxIsAbsolutePath(arg)) { fullPath = arg; return; } // Is it a relative path? wxString currentDir(wxFileName::GetCwd()); if (currentDir.Last() != wxFILE_SEP_PATH) currentDir += wxFILE_SEP_PATH; wxString str = currentDir + arg; if (wxFileExists(str)) { fullPath = str; return; } // OK, it's neither an absolute path nor a relative path. // Search PATH. wxPathList pathList; pathList.AddEnvList(_T("PATH")); str = pathList.FindAbsoluteValidPath(arg); if (!str.IsEmpty()) { fullPath = str; return; } fullPath = _T(""); return; } /////////////////////////////////// // Gets folder name from full path void TrayDict::GetFolderName () { folderName = _T(""); wxFileName path(fullPath); folderName += path.GetPath(wxPATH_GET_VOLUME); folderName += _T("/"); } /////////// // Statics wxString TrayDict::folderName; wxString TrayDict::fullPath;
[ "archmagezeratul@93549f3f-7f0a-0410-a4b3-e966c9c94f04" ]
[ [ [ 1, 115 ] ] ]