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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2b9a38deb3ed9251423c57f0ee92c98f5aba7ada | 36d0ddb69764f39c440089ecebd10d7df14f75f3 | /プログラム/Ngllib/src/Random/RandomSFMT.cpp | 607010b4c465b32ba8260153a5011b9b1543cb44 | []
| no_license | weimingtom/tanuki-mo-issyo | 3f57518b4e59f684db642bf064a30fc5cc4715b3 | ab57362f3228354179927f58b14fa76b3d334472 | refs/heads/master | 2021-01-10T01:36:32.162752 | 2009-04-19T10:37:37 | 2009-04-19T10:37:37 | 48,733,344 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 3,988 | cpp | /*******************************************************************************/
/**
* @file RandomSFMT.cpp.
*
* @brief 乱数生成クラスソースファイル.
*
* @date 2008/07/23.
*
* @version 2.00.
*
* @author Kentarou Nishimura.
*/
/******************************************************************************/
#include "Ngl/Random/RandomSFMT.h"
#include "SFMT/SFMT.h"
#include "SFMT/SFMT.c"
#include <ctime>
using namespace Ngl;
/*=========================================================================*/
/**
* @brief コンストラクタ
*
* @param[in] なし.
*/
RandomSFMT::RandomSFMT()
{
srand();
}
/*=========================================================================*/
/**
* @brief 乱数の種を初期化( 自動 )
*
* 現在の時刻から乱数を初期化します。
*
* @param[in] なし.
* @return なし.
*/
void RandomSFMT::srand()
{
unsigned long t = (unsigned long)time( 0 );
::init_gen_rand( t );
}
/*=========================================================================*/
/**
* @brief 乱数の種を初期化
*
* @param[in] seed 初期化する値.
* @return なし.
*/
void RandomSFMT::srand( unsigned int seed )
{
::init_gen_rand( seed );
}
/*=========================================================================*/
/**
* @brief 32bit整数型の乱数を作成
*
* @param[in] なし.
* @return なし.
*/
unsigned int RandomSFMT::randi()
{
return ::gen_rand32();
}
/*=========================================================================*/
/**
* @brief min〜maxの間の32bit整数型の乱数を作成
*
* @param[in] min 乱数の最小値.
* @param[in] max 乱数の最大値.
* @return 32bit整数の乱数.
*/
unsigned int RandomSFMT::randi( unsigned int min, unsigned int max )
{
return ( randi() % ( ( max + 1 ) - min ) ) + min;
}
/*=========================================================================*/
/**
* @brief 32bit浮動小数点型の乱数( 0.0〜1.0 )を作成
*
* @param[in] type 乱数生成範囲.
* @return 32bit浮動小数点の乱数.
*/
float RandomSFMT::randf( RangeType type )
{
return static_cast< float >( randd( type ) );
}
/*=========================================================================*/
/**
* @brief min以上max以下の間の32bit整数型の乱数を作成
*
* @param[in] min 乱数の最小値.
* @param[in] max 乱数の最大値.
* @param[in] type 乱数生成範囲.
* @return 32bit浮動小数点の乱数.
*/
float RandomSFMT::randf( float min, float max, RangeType type )
{
return static_cast< float >( randd( min, max, type ) );
}
/*=========================================================================*/
/**
* @brief 32bit浮動小数点型の乱数( 0.0〜1.0 )を作成
*
* @param[in] type 乱数生成範囲.
* @return 32bit浮動小数点の乱数.
*/
double RandomSFMT::randd( RandomSFMT::RangeType type )
{
double result = 0.0;
switch( type )
{
case RANGETYPE_REAL1:
result = ::genrand_real1();
break;
case RANGETYPE_REAL2:
result = ::genrand_real2();
break;
case RANGETYPE_REAL3:
result = ::genrand_real3();
break;
case RANGETYPE_REAL53:
result = ::genrand_res53();
break;
default:
result = ::genrand_real1();
}
return result;
}
/*=========================================================================*/
/**
* @brief min以上max以下の間の32bit整数型の乱数を作成
*
* @param[in] min 乱数の最小値.
* @param[in] max 乱数の最大値.
* @param[in] type 乱数生成範囲.
* @return 32bit浮動小数点の乱数.
*/
double RandomSFMT::randd( double min, double max, RangeType type )
{
return ( randd( type ) * ( max - min ) + min );
}
/*===== EOF ==================================================================*/ | [
"rs.drip@aa49b5b2-a402-11dd-98aa-2b35b7097d33"
]
| [
[
[
1,
174
]
]
]
|
0cffd877f4afa6a346dd8023a3d34ba13caf1245 | 1193b8d2ab6bb40ce2adbf9ada5b3d1124f1abb3 | /branches/mapmodule/modules/genericmapmodule/src/GenericMapScriptedEvent.cpp | c900e6fdfb36c0a7385bae7fa825700efb93f85b | []
| 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 | 8,821 | 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 <SonettoKernel.h>
#include <SonettoScriptManager.h>
#include "GenericMapScriptedEvent.h"
#include "GenericMapEventScript.h"
namespace GenericMapModule
{
// ----------------------------------------------------------------------
// GenericMapModule::ScriptedEvent implementation.
// ----------------------------------------------------------------------
void ScriptedEvent::update()
{
Sonetto::ScriptManager *scriptMan =
Sonetto::ScriptManager::getSingletonPtr();
updatePage();
if (!mCurPage)
{
// No page selected; stop updating
return;
}
if (scriptMan->updateScript(mCurScript))
{
// If the page's trigger condition was TRG_AUTORUN,
// tag it as executed
if (mCurPage->triggerCondition == ScriptedEventPage::TRG_AUTORUN)
{
mCurPage->autorun.executed = true;
}
// Script has ended; reselect page
setPage(selectPage());
}
}
// ----------------------------------------------------------------------
bool ScriptedEvent::getBlockEnabled()
{
if (mBlockEnabled)
{
// Event manually set to block
return true;
}
// Makes sure a page is selected if its conditions are met
updatePage();
if (!mCurPage)
{
// No page was selected, don't block
return false;
}
if (mCurPage->triggerCondition == ScriptedEventPage::TRG_AUTORUN &&
mCurPage->autorun.blockEnabled && !mCurPage->autorun.executed)
{
// Blocking autorun set and not yet finished executing; block
return true;
}
return false;
}
// ----------------------------------------------------------------------
ScriptedEventPage *ScriptedEvent::selectPage()
{
ScriptedEventPageVector::iterator i;
for (i = mPages.begin();i != mPages.end();++i)
{
ScriptedEventPage &page = *i;
switch (page.triggerCondition)
{
case ScriptedEventPage::TRG_BUTTON:
// Breaks for loop
i = mPages.end();
continue;
break;
case ScriptedEventPage::TRG_EVENT_TOUCH:
// Breaks for loop
i = mPages.end();
continue;
break;
case ScriptedEventPage::TRG_AUTORUN:
if (page.autorun.executed)
{
// Breaks for loop
i = mPages.end();
continue;
}
break;
case ScriptedEventPage::TRG_PARALLEL_PROCESS:
break;
}
Sonetto::VariableConditionVector::iterator j;
for (j = page.conditions.begin();
j != page.conditions.end();++j)
{
Sonetto::VariableCondition &condition = *j;
Sonetto::VariableMap::iterator vIter,vEnd;
Sonetto::Variable lhs;
switch (condition.scope)
{
case Sonetto::VS_LOCAL:
vIter = mLocals.find(condition.variableID);
vEnd = mLocals.end();
break;
case Sonetto::VS_GLOBAL:
{
Sonetto::VariableMap &globals =
Sonetto::Database::getSingleton().
savemap.variables;
vIter = globals.find(condition.variableID);
vEnd = globals.end();
}
break;
}
// If the variable was found, get it
// (otherwise it's [VT_INT32,0])
if (vIter != vEnd)
{
lhs = vIter->second;
}
if (!lhs.compare((Sonetto::VariableComparator)(condition.
comparator),condition.rhsValue))
{
// Comparison failed; skip this page
j = page.conditions.end();
i = mPages.end();
continue;
}
}
if (i != mPages.end())
{
// This page has all conditions met; select it
return &page;
}
}
// No page has all conditions met
return NULL;
}
// ----------------------------------------------------------------------
void ScriptedEvent::setPage(ScriptedEventPage *page)
{
// Sets current page pointer
mCurPage = page;
if (page) {
// Updates entity mesh
setEntityMesh(page->meshSource,page->meshID);
// Updates script
setCurrentScript(page->scriptFile);
// Updates walk speed
mWalkSpeed = page->walkSpeed;
} else { // If page is NULL, clears event
mCurPage = NULL;
// Destroys entity
setEntityMesh(MES_NONE,0);
// Destroys script
setCurrentScript(Sonetto::ScriptFilePtr());
// Resets walk speed
mWalkSpeed = 1.0f;
}
}
// ----------------------------------------------------------------------
void ScriptedEvent::updatePage()
{
if (!mCurPage)
{
if (mPages.empty())
{
SONETTO_THROW("ScriptedEvent has no pages");
}
setPage(selectPage());
}
}
// ----------------------------------------------------------------------
void ScriptedEvent::setCurrentScript(Sonetto::ScriptFilePtr scriptFile)
{
Sonetto::ScriptManager *scriptMan =
Sonetto::ScriptManager::getSingletonPtr();
if (mCurScript) {
if (mCurScript->getScriptFile() != scriptFile)
{
scriptMan->destroyScript(mCurScript);
if (!scriptFile.isNull()) {
mCurScript = scriptMan->
createScript<EventScript>(scriptFile->getName(),
"MAP_LOCAL");
mCurScript->setOwner(this);
} else {
mCurScript = NULL;
}
}
} else {
if (!scriptFile.isNull()) {
mCurScript = scriptMan->
createScript<EventScript>(scriptFile->getName(),
"MAP_LOCAL");
mCurScript->setOwner(this);
}
}
}
} // namespace
| [
"[email protected]"
]
| [
[
[
1,
254
]
]
]
|
3e2ed7cfa8deac053e8d5c56ae7e5df1ca9bb7d2 | e7c45d18fa1e4285e5227e5984e07c47f8867d1d | /SMDK/Kenwalt/KW_SMDK1/SMDK_TubeReactor.h | 09ef951857a35bebdb2b1563cea2768550ec55ef | []
| no_license | abcweizhuo/Test3 | 0f3379e528a543c0d43aad09489b2444a2e0f86d | 128a4edcf9a93d36a45e5585b70dee75e4502db4 | refs/heads/master | 2021-01-17T01:59:39.357645 | 2008-08-20T00:00:29 | 2008-08-20T00:00:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,872 | h | #pragma once
//================== SysCAD - Copyright Kenwalt (Pty) Ltd ===================
// $Nokeywords: $
//===========================================================================
#ifndef __MD_HEADERS_H
#include "md_headers.h"
#endif
//---------------------------------------------------------------------------
class CTubeReactor : public MBaseMethod
{
friend class CSimpleSolverFn;
friend class CCondensingSolverFn;
friend class CCondensateFinder;
public:
CTubeReactor(MUnitDefBase * pUnitDef, TaggedObject * pNd);
virtual ~CTubeReactor(void);
virtual void Init();
virtual void BuildDataFields();
virtual bool ExchangeDataFields();
virtual bool ConfigureJoins();
virtual bool EvalJoinPressures();
virtual void EvalProducts();
virtual void ClosureInfo(MClosureInfo & CI);
// Macro Model (Flash Train)...
virtual void MacroMdlEvaluate(eScdMacroMdlEvals Eval) {};
virtual bool MacroMdlValidNd(int iIONo) { return true; };
virtual void MacroMdlAddNd(int iIONo) {};
virtual void MacroMdlRemoveNd(int iIONo) {};
virtual CMacroMdlBase* MacroMdlActivate() { return m_FTC; };
virtual void MacroMdlDeactivate() {};
protected:
void DoSimpleHeater(MStream & ShellI, MStream & TubeI, MStream & ShellO, MStream & TubeO);
void DoCondensingHeater(MStream & ShellI, MStream & TubeI, MStream & ShellO, MStream & TubeO);
long m_lOpMode;
double m_dHTC;
double m_dArea;
double m_dUA;
double m_dLMTD;
double m_dDuty;
double m_dLMTDFactor;
MReactionBlk m_RB;
MVLEBlk m_VLE;
MFT_Condenser m_FTC;
};
| [
"[email protected]"
]
| [
[
[
1,
54
]
]
]
|
63ac5059103f5468a8f5e72d5335999b11881168 | 27d5670a7739a866c3ad97a71c0fc9334f6875f2 | /CPP/Modules/UiCtrl/AudioCtrlLanguage.h | 13d2dd77c581ddf823697cab51339cc37cc12624 | [
"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 | 4,640 | 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 AUDIO_CONTROL_LANGUAGE_H
#define AUDIO_CONTROL_LANGUAGE_H
#include "arch.h"
#include "RouteInfo.h"
#include "Quality.h"
#include <vector>
namespace isab{
class RouteInfo;
/**
* An abstract class for converting route directions to
* speach. This class is derived from and never instantiated
* itself.
*
*/
class AudioCtrlLanguage
{
public:
typedef std::vector<int16> SoundClipsList;
enum {
NoDistance = -1,
NeverSay = -2,
};
class DistanceInfo {
public:
int32 sayAtDistance;
int32 abortTooShortDistance;
int32 abortTooFarDistance;
DistanceInfo() : sayAtDistance(-1), abortTooShortDistance(-1), abortTooFarDistance(-1)
{ }
DistanceInfo(int32 a, int32 b, int32 c) :
sayAtDistance(a), abortTooShortDistance(b), abortTooFarDistance(c)
{ }
};
enum SpokenUnits {
MetricUnits,
ImperialFeetMilesUnits,
ImperialYardsMilesUnits,
};
enum AudioVerbosity {
VerbosityMuted = 0,
VerbosityReduced,
VerbosityNormal
};
virtual ~AudioCtrlLanguage();
virtual int syntheziseSoundList(const RouteInfo &r,
bool onTrackStatusChanged,
DistanceInfo &deadlines,
SoundClipsList &soundList) = 0;
virtual int syntheziseCrossingSoundList(const RouteInfoParts::Crossing &c,
DistanceInfo &deadlines,
SoundClipsList &soundList) = 0;
virtual int newCrossingSoundList(
DistanceInfo &deadlines,
SoundClipsList &soundList) = 0;
virtual int newCameraSoundList(
DistanceInfo &deadlines,
SoundClipsList &soundList) = 0;
virtual int badSoundList(
DistanceInfo &deadlines,
SoundClipsList &soundList ) = 0;
virtual int goodSoundList(
DistanceInfo &deadlines,
SoundClipsList &soundList ) = 0;
virtual int statusOfGPSChangedSoundList(
const Quality& q, DistanceInfo &deadlines,
SoundClipsList &soundList) = 0;
virtual void resetState() = 0;
virtual void selectUnits(enum SpokenUnits units) = 0;
virtual int selectSyntaxVersion(const char * which, int & numClips, char ** & clipNames) = 0;
virtual int setVerbosity(AudioVerbosity verbosity) = 0;
virtual int supportsFeetMiles() = 0;
virtual int supportsYardsMiles() = 0;
}; /* AudioCtrlLanguage */
typedef class AudioCtrlLanguage *(*AudioCtrlLanguageFactoryFunc)();
} /* namespace isab */
#endif /* AUDIO_CONTROL_LANGUAGE_H */
| [
"[email protected]"
]
| [
[
[
1,
103
]
]
]
|
1f74a28238073e455390765fc1f391ac9ac7512a | 9c62af23e0a1faea5aaa8dd328ba1d82688823a5 | /rl/branches/newton20/engine/common/src/WriteableDataStreamFormatTarget.cpp | 2bd0719315b8c35c12f3d63601c9c0c563bfd186 | [
"ClArtistic",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
]
| permissive | jacmoe/dsa-hl-svn | 55b05b6f28b0b8b216eac7b0f9eedf650d116f85 | 97798e1f54df9d5785fb206c7165cd011c611560 | refs/heads/master | 2021-04-22T12:07:43.389214 | 2009-11-27T22:01:03 | 2009-11-27T22:01:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,295 | cpp | /* This source file is part of Rastullahs Lockenpracht.
* Copyright (C) 2003-2008 Team Pantheon. http://www.team-pantheon.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the Clarified Artistic License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Clarified Artistic License for more details.
*
* You should have received a copy of the Clarified Artistic License
* along with this program; if not you can get it here
* http://www.jpaulmorrison.com/fbp/artistic2.htm.
*/
#include "stdinc.h" //precompiled header
#include "WriteableDataStreamFormatTarget.h"
namespace rl
{
WriteableDataStreamFormatTarget::WriteableDataStreamFormatTarget(WriteableDataStreamPtr stream)
{
mStream = stream;
}
void WriteableDataStreamFormatTarget::writeChars (const XMLByte *const toWrite, const unsigned int count, XERCES_CPP_NAMESPACE::XMLFormatter *const formatter)
{
mStream->write((char*)toWrite, count);
}
void WriteableDataStreamFormatTarget::flush ()
{
mStream->flush();
}
}
| [
"melven@4c79e8ff-cfd4-0310-af45-a38c79f83013"
]
| [
[
[
1,
38
]
]
]
|
bb7832b5694accfebbc002dfa6447b0ff75a27d0 | 073dfce42b384c9438734daa8ee2b575ff100cc9 | /RCF/src/RCF/TcpEndpoint.cpp | c4324fa574e84a511b515e9976a93892134bee2f | []
| no_license | r0ssar00/iTunesSpeechBridge | a489426bbe30ac9bf9c7ca09a0b1acd624c1d9bf | 71a27a52e66f90ade339b2b8a7572b53577e2aaf | refs/heads/master | 2020-12-24T17:45:17.838301 | 2009-08-24T22:04:48 | 2009-08-24T22:04:48 | 285,393 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,385 | cpp |
//******************************************************************************
// RCF - Remote Call Framework
// Copyright (c) 2005 - 2009, Jarl Lindrud. All rights reserved.
// Consult your license for conditions of use.
// Version: 1.1
// Contact: jarl.lindrud <at> gmail.com
//******************************************************************************
#include <RCF/TcpEndpoint.hpp>
#include <boost/config.hpp>
#include <RCF/InitDeinit.hpp>
#include <RCF/SerializationProtocol.hpp>
#ifdef RCF_USE_BOOST_ASIO
#include <RCF/TcpAsioServerTransport.hpp>
#include <RCF/TcpClientTransport.hpp>
#elif defined(BOOST_WINDOWS)
#include <RCF/TcpIocpServerTransport.hpp>
#include <RCF/TcpClientTransport.hpp>
#else
#include <RCF/TcpClientTransport.hpp>
#endif
#ifdef RCF_USE_SF_SERIALIZATION
#include <SF/Registry.hpp>
#endif
namespace RCF {
TcpEndpoint::TcpEndpoint() :
mIp(),
mPort(RCF_DEFAULT_INIT)
{}
TcpEndpoint::TcpEndpoint(int port) :
mIp("127.0.0.1"),
mPort(port)
{}
TcpEndpoint::TcpEndpoint(const std::string &ip, int port) :
mIp(ip),
mPort(port)
{}
TcpEndpoint::TcpEndpoint(const TcpEndpoint &rhs) :
mIp(rhs.mIp),
mPort(rhs.mPort)
{}
EndpointPtr TcpEndpoint::clone() const
{
return EndpointPtr(new TcpEndpoint(*this));
}
std::string TcpEndpoint::getIp() const
{
return mIp;
}
int TcpEndpoint::getPort() const
{
return mPort;
}
#ifdef RCF_USE_BOOST_ASIO
std::auto_ptr<I_ServerTransport> TcpEndpoint::createServerTransport() const
{
return std::auto_ptr<I_ServerTransport>(
new RCF::TcpAsioServerTransport(mIp, mPort));
}
std::auto_ptr<I_ClientTransport> TcpEndpoint::createClientTransport() const
{
return std::auto_ptr<I_ClientTransport>(
new RCF::TcpClientTransport(mIp, mPort));
}
#elif defined(BOOST_WINDOWS)
std::auto_ptr<I_ServerTransport> TcpEndpoint::createServerTransport() const
{
return std::auto_ptr<I_ServerTransport>(
new RCF::TcpIocpServerTransport(mIp, mPort));
}
std::auto_ptr<I_ClientTransport> TcpEndpoint::createClientTransport() const
{
return std::auto_ptr<I_ClientTransport>(
new RCF::TcpClientTransport(mIp, mPort));
}
#else
std::auto_ptr<I_ServerTransport> TcpEndpoint::createServerTransport() const
{
// On non Windows platforms, server side RCF code requires
// RCF_USE_BOOST_ASIO to be defined, and the Boost.Asio library to
// be available.
RCF_ASSERT(0);
return std::auto_ptr<I_ServerTransport>();
}
std::auto_ptr<I_ClientTransport> TcpEndpoint::createClientTransport() const
{
return std::auto_ptr<I_ClientTransport>(
new RCF::TcpClientTransport(mIp, mPort));
}
#endif
inline void initTcpEndpointSerialization()
{
#ifdef RCF_USE_SF_SERIALIZATION
SF::registerType( (TcpEndpoint *) 0, "RCF::TcpEndpoint");
SF::registerBaseAndDerived( (I_Endpoint *) 0, (TcpEndpoint *) 0);
#endif
}
RCF_ON_INIT_NAMED( initTcpEndpointSerialization(), InitTcpEndpointSerialization );
} // namespace RCF
| [
"[email protected]"
]
| [
[
[
1,
131
]
]
]
|
ebbdeaa5e1896dd2d1432a46ec371a94db31b2cc | 0855407a47abbd09a2e6f64e0093ebfa484091c5 | /sample.cpp | 90fa20a94c70f3692f61124bd3ee87feb02e6d6f | []
| no_license | tosik/SimpleNN | 93245100fd3e8e2177f0b4ae121595ce76d96780 | 924ce2bc649ee0c3118c9a5f9a8dd144ec05e586 | refs/heads/master | 2020-12-04T08:15:30.173513 | 2009-11-01T23:28:17 | 2009-11-01T23:28:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,086 | cpp | /*
* SimpleNN. Neural-Network Simple Program.
* Copyright (C) Toshiyuki Hirooka <[email protected]> http://wasabi.in/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <iostream>
//#define DEBUG
#include "nn.cpp"
using namespace std;
#define SIZE 5
int main(void)
{
NN nn;
// input signal
static int input[SIZE][N_NEURON] = {
{ 1,0,0,1,0 },
{ 0,1,0,1,0 },
{ 1,0,1,0,1 },
{ 0,1,1,1,1 },
{ 1,1,1,0,1 },
};
// teacher signal
static int teacher[SIZE][N_NEURON] = {
{ 0,0,0,0,0 },
{ 0,1,0,1,1 },
{ 0,1,1,0,1 },
{ 1,0,0,0,1 },
{ 1,0,0,0,1 },
};
#ifdef DEBUG
cout << "teach" << endl;
#endif
for(int cnt=0; cnt<80; cnt++)
{
for(int s=0; s<SIZE; s++)
{
bool flag = false;
while(!flag)
{
flag = true;
int *output = nn.teach(input[s],teacher[s]);
for(int i=0; i<N_NEURON; i++)
if(output[i] != teacher[s][i])
flag = false;
#ifdef DEBUG
cout << "---out---" << endl;
for(int i=0; i<N_NEURON; i++)
cout << output[i] << " " << endl;
cout << "---------" << endl;
#endif
}
}
}
#ifdef DEBUG
cout << "calc" << endl;
#endif
for(int s=0; s<SIZE; s++)
{
int *output = nn.calc(input[s]);
cout << "---out---" << endl;
for(int i=0; i<N_NEURON; i++)
cout << output[i] << " " << endl;
cout << "---------" << endl;
}
}
| [
"[email protected]"
]
| [
[
[
1,
87
]
]
]
|
0deb04c8ca953b22329d08c4fa989492919015e1 | 05869e5d7a32845b306353bdf45d2eab70d5eddc | /soft/application/thirdpartylibs/jwidgets/src/jddex_widget.cpp | 9a449b06fe7342c9028e666e2801994d15b63c3d | []
| no_license | shenfahsu/sc-fix | beb9dc8034f2a8fd9feb384155fa01d52f3a4b6a | ccc96bfaa3c18f68c38036cf68d3cb34ca5b40cd | refs/heads/master | 2020-07-14T16:13:47.424654 | 2011-07-22T16:46:45 | 2011-07-22T16:46:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,330 | cpp | /***************************************************************************
*
* File Name : jdd_widget.cpp
*
* IMPORTANT NOTICE
*
* Please note that any and all title and/or intellectual property rights
* in and to this Software or any part of this (including without limitation
* any images, photographs, animations, video, audio, music, text and/or
* "applets," incorporated into the Software), herein mentioned to as
* "Software", the accompanying printed materials, and any copies of the
* Software, are owned by Jataayu Software (P) Ltd., Bangalore ("Jataayu")
* or Jataayu's suppliers as the case may be. The Software is protected by
* copyright, including without limitation by applicable copyright laws,
* international treaty provisions, other intellectual property laws and
* applicable laws in the country in which the Software is being used.
* You shall not modify, adapt or translate the Software, without prior
* express written consent from Jataayu. You shall not reverse engineer,
* decompile, disassemble or otherwise alter the Software, except and
* only to the extent that such activity is expressly permitted by
* applicable law notwithstanding this limitation. Unauthorized reproduction
* or redistribution of this program or any portion of it may result in severe
* civil and criminal penalties and will be prosecuted to the maximum extent
* possible under the law. Jataayu reserves all rights not expressly granted.
*
* THIS SOFTWARE IS PROVIDED TO YOU "AS IS" WITHOUT WARRANTY OF ANY KIND
* AND ANY AND ALL REPRESENTATION
*
***************************************************************************
*
*
* File Description
* ----------------
*
* Purpose : Implimentation for widget class
*
* Created By :
* Created Date :
*
*
*
* Current Revision :
*
***************************************************************************
*
*
* Revision Details
* ----------------
*
* 1. Modified By :
* Modified Date :
* Purpose :
*
*
*
*
***************************************************************************/
#include "jddex_platformdefines.h"
#include <jddex_widget.h>
#include <jddex_int.h>
#include <jddex_platform.h>
#include <jddex_wnddefaults.h>
/**
* @brief default constructor
* @retval None
* initliazes the class members
*/
jddex_widget::jddex_widget()
{
}
/**
* @brief constructor
* @param[in] pst_ParentHwnd Handle of parent window
* @param[in] pstRect control co-ordinates
* @param[in] pstCtrlProperty pointer to JC_CONTROL_PROPERTIES
* @retval None
*
* initliazes class members. invoked by all inherited class constructors
*/
jddex_widget::jddex_widget(jddex_widget *poParentHwnd,JC_RECT *pstRect,
JC_CONTROL_PROPERTIES* pstCtrlProperty)
{
jc_memcpy (&m_stRect, pstRect, sizeof(JC_RECT)) ;
m_bIsSelectable = pstCtrlProperty->bIsSelectable ;
m_bIsDisabled = pstCtrlProperty->bIsDisabled;
m_stControlStyle = pstCtrlProperty->controlStyle ;
m_poParentHwnd = poParentHwnd;
m_pszText = JC_NULL;
if(pstCtrlProperty->psCaptionValue)
{
m_pszText = jdi_CUtilsTcsDuplicate (JC_NULL,
pstCtrlProperty->psCaptionValue);
}
m_bIsVisible = E_TRUE;
m_bIsContainer = E_FALSE;
m_bIsFocussed = E_FALSE;
m_bIsVisible = E_TRUE;
// m_eControlType = (EControlType)0xFF;
//m_stControlStyle.iForegroundColor = JDDEX_DEFAULT_COLOR;
//m_stControlStyle.iBackgroundColor = JDDEX_DEFAULT_COLOR;
}
/**
* @brief constructor
* @param[in] pst_ParentHwnd Handle of parent window
* @param[in] pstRect control co-ordinates
* @retval None
*
* initliazes class members. invoked by all inherited class constructors
*/
jddex_widget::jddex_widget(jddex_widget *poParentHwnd, JC_RECT *pstRect)
{
jc_memcpy (&m_stRect, pstRect, sizeof(JC_RECT)) ;
m_poParentHwnd = poParentHwnd;
m_pszText = JC_NULL;
m_bIsVisible = E_TRUE;
m_bIsContainer = E_FALSE;
m_bIsFocussed = E_FALSE;
m_bIsVisible = E_TRUE;
// eControlType = (EControlType)0xFF;
//m_stControlStyle.iForegroundColor = JDDEX_DEFAULT_COLOR;
//m_stControlStyle.iBackgroundColor = JDDEX_DEFAULT_COLOR;
}
/**
* @brief destructor
* @retval None
* frees all the resources allocated
*/
jddex_widget::~jddex_widget()
{
if(m_pszText)
{
jdd_MemFree (m_pszText);
m_pszText = JC_NULL;
}
}
void jddex_widget::Show()
{
}
/**
* @brief sets the control colors
* @param[in] iBgColor background color
* @param[in] iFgColor foreground color
* @retval None
*
* sets the control background/foreground colors for a control
*/
void jddex_widget::SetColors(JC_INT32 iBgColor, JC_INT32 iFgColor)
{
m_stControlStyle.iForegroundColor = iFgColor;
m_stControlStyle.iBackgroundColor = iBgColor;
}
void jddex_widget::SetFgColor(JC_INT32 iFgColor)
{
m_stControlStyle.iForegroundColor = iFgColor;
}
void jddex_widget::SetBgColor(JC_INT32 iBgColor)
{
m_stControlStyle.iBackgroundColor = iBgColor;
}
/**
* @brief Gets the control colors
* @param[out] piBgColor background color
* @param[out] piFgColor foreground color
* @retval None
*
* sets the control background/foreground colors for a control
*/
void jddex_widget::GetColors(JC_INT32 *piBgColor, JC_INT32 *piFgColor)
{
*piFgColor = m_stControlStyle.iForegroundColor ;
*piBgColor = m_stControlStyle.iBackgroundColor ;
}
/**
* @brief Gets the control foreground color
* @param[out] piBgColor background color
* @retval None
*
* Gets the control foreground for a control
*/
void jddex_widget::GetFgColor(JC_INT32 *piFgColor)
{
*piFgColor = m_stControlStyle.iForegroundColor ;
}
/**
* @brief Gets the control background color
* @param[out] piBgColor background color
* @retval None
*
* sets the control background color for a control
*/
void jddex_widget::GetBgColor(JC_INT32 *piBgColor)
{
*piBgColor = m_stControlStyle.iBackgroundColor ;
}
/**
* @brief Sets the default background color
* @retval None
*
* sets the default background color for a control
*/
void jddex_widget::SetDefaultBgColor()
{
m_stControlStyle.iForegroundColor = JDDEX_DEFAULT_BLACK;
}
/**
* @brief Sets the default foreground color
* @retval None
*
* sets the default foreground color for a control
*/
void jddex_widget::SetDefaultFgColor()
{
m_stControlStyle.iBackgroundColor = JDDEX_DEFAULT_WHITE;
}
/**
* @brief sets the default control colors
* @retval None
*
* sets the deafult background/foreground colors for a control
*/
void jddex_widget::SetDefaultColors()
{
m_stControlStyle.iForegroundColor = JDDEX_DEFAULT_BLACK;
m_stControlStyle.iBackgroundColor = JDDEX_DEFAULT_WHITE;
}
/**
* @brief sets focus to a control
* @retval None
*
* sets focus to a control and control acts accordingly when dispalyed
*/
void jddex_widget::SetFocus()
{
m_bIsFocussed = E_TRUE;
}
/**
* @brief resets focus to a control
* @retval None
*
* resets focus to a control and control acts accordingly when dispalyed
*/
void jddex_widget::ResetFocus()
{
m_bIsFocussed = E_FALSE;
}
/**
* @brief sets recatngle co-ordiantes to a control
* @param[in] pstRect pointer to JC_RECT
* @retval None
*
* sets recatngle co-ordiantes to a control
*/
void jddex_widget::SetRect(JC_RECT* pstRect)
{
jc_memcpy (&m_stRect, pstRect, sizeof(JC_RECT)) ;
}
/**
* @brief gets recatngle co-ordiantes to a control
* @param[out] pstRect pointer to JC_RECT
* @retval None
*
* gets recatngle co-ordiantes to a control
*/
void jddex_widget::GetRect(JC_RECT* pstRect)
{
jc_memcpy (pstRect, &m_stRect, sizeof(JC_RECT)) ;
}
/**
* @brief sets visibility sattus to a control
* @param[in] bVisible visible/not-visible
* @retval None
*
* sets visibility of a control
*/
void jddex_widget::SetVisibilty(JC_BOOLEAN bVisible)
{
m_bIsVisible = bVisible;
}
/**
* @brief gets visibility sattus of a control
* @param[in] bVisible visible/not-visible
* @retval None
*
* sets visibility of a control
*/
JC_BOOLEAN jddex_widget::GetVisibiltyStatus()
{
return m_bIsVisible ;
}
/**
* @brief enables/disables a control
* @param[in] bDisabled enable/disable
* @retval None
*
* sets visibility of a control
*/
void jddex_widget::Disable(JC_BOOLEAN bDisabled)
{
m_bIsDisabled = bDisabled;
}
/**
* @brief virtaul event handler function to be overloaded by derived classes
* @param[in] hWnd control handle
* @param[in] eEventType event type
* @param[in] pvEventInfo event data
* @retval E_FALSE
*
* sets visibility of a control
*/
JC_RETCODE jddex_widget::EventHandler(JC_UINT32 hWnd, JC_INT32 eEventType,
void *pvEventInfo)
{
return JC_ERR_NOT_IMPLEMENTED ;
}
void jddex_widget::HandleAction(E_OBJECT_ACTION eAction)
{
return ;
}
/**
* @brief sets text to a control
* @param[in] pszText text to be set
* @retval None
*
* sets text to a control
*/
void jddex_widget::SetText(JC_CHAR *pszText)
{
if(m_pszText)
{
jdd_MemFree (m_pszText);
m_pszText = JC_NULL;
}
m_pszText = jdi_CUtilsTcsDuplicate (JC_NULL, pszText);
}
/**
* @brief gets text to a control
* @param[in] ppszText text of the control
* @retval None
*
* gets text to a control
*/
void jddex_widget::GetText(JC_CHAR **ppszText)
{
if(m_pszText)
*ppszText = jdi_CUtilsTcsDuplicate (JC_NULL, m_pszText);
else
*ppszText = JC_NULL ;
}
/**
* @brief gets left co-ordiante of control
* @retval left co-ordinate of control
*
* gets left co-ordiante of control
*/
JC_INT32 jddex_widget::GetLeft()
{
return m_stRect.iLeft ;
}
/**
* @brief gets top co-ordiante of control
* @retval top co-ordinate of control
*
* gets top of control co-ordiante
*/
JC_INT32 jddex_widget::GetTop()
{
return m_stRect.iTop ;
}
/**
* @brief gets absloute left co-ordiante of control
* @retval left co-ordinate
*
* gets absloute left co-ordiante of control w.r.t LCD dispaly
*/
JC_INT32 jddex_widget ::GetAbsLeft ( )
{
JC_INT32 Left = 0;
Left = m_stRect.iLeft + jddex_GetDevicePropLeft();
return Left ;
}
/**
* @brief gets absloute top co-ordiante of control
* @retval top co-ordinate
*
* gets absloute top co-ordiante of control w.r.t LCD dispaly
*/
JC_INT32 jddex_widget ::GetAbsTop()
{
JC_INT32 Top = 0;
Top = m_stRect.iTop ;
Top += jddex_GetDevicePropTop();
return Top ;
}
/**
* @brief gets absloute recatngle co-ordiantes of control
* @param[out] pstAbsRect pointer to JC_RECT
* @retval None
*
* gets absloute recatngle co-ordiantes of control w.r.t LCD dispaly
*/
void jddex_widget ::GetAbsRect(JC_RECT* pstAbsRect)
{
//JC_INT32 Left = 0,Top = 0;
jc_memcpy (pstAbsRect, &m_stRect, sizeof(JC_RECT)) ;
pstAbsRect->iLeft += jddex_GetDevicePropLeft() ;
pstAbsRect->iTop += jddex_GetDevicePropTop() ; //
}
/**
* @brief checks wether the widget is a container
* @retval E_FALSE/E_TRUE
*
*/
JC_BOOLEAN jddex_widget ::IsContaianer()
{
return m_bIsContainer;
}
/**
* @brief returns the type of widget
* @retval enumeration of type EControlType
*
*/
EControlType jddex_widget ::GetWidgetType()
{
return m_eControlType;
}
/**
* @brief overloaded new operator
* @param[in] uiSize size to be allocated
* @retval pointer to memory allocated
*
*/
void* jddex_widget::operator new( JC_UINT32 uiSize )
{
return jdd_MemAlloc (1, uiSize);
}
/**
* @brief overloaded delete operator
* @param[in] p pointer to be freed
* @retval None
*
*/
void jddex_widget::operator delete(void *p)
{
if( p != JC_NULL )
jdd_MemFree (p);
}
/**
* @brief returns parent window handle
* @retval parent handle
*
*/
jddex_widget* jddex_widget::GetParentHnd()
{
return m_poParentHwnd;
}
/**
* @brief gets parent window rectangle
* @param[out] pstRect rectangle co-ordiantes of parent window
* @retval None
*
*/
void jddex_widget::GetParentRect(JC_RECT* pstRect)
{
if(m_poParentHwnd)
{
m_poParentHwnd->GetAbsRect(pstRect);
}
}
| [
"windyin@2490691b-6763-96f4-2dba-14a298306784"
]
| [
[
[
1,
524
]
]
]
|
6eb6abbeaa31d36b2920b68f734b46ffb277010f | e2bbf1e9ccbfea663803cb692d6b6754f37ca3d8 | /MoreOBs/MoreOBs/game.h | 8de56ce36d0508959207b7193c1da6d70f49aa8d | []
| no_license | binux/moreobs | 65efa6143f49a15ee1cdb0eea38670d808415e97 | 8f2319b6d76573c0054fcd40304b620e38527f4c | refs/heads/master | 2021-01-10T14:09:48.174517 | 2010-08-10T07:53:46 | 2010-08-10T07:53:46 | 46,993,885 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,649 | h | #ifndef GAME_H
#define GAME_H
//===============================game status==================================
#define STATUS_COMINGUPNEXT 0x00
#define STATUS_ABOUTTOSTART 0x01
#define STATUS_STARTED 0x02
#define STATUS_LIVE 0x03
#define STATUS_COMPLETED 0x04
#define STATUS_BROKEN 0x05
#define STATUS_INCOMPLETE 0x06
class CClient;
class CGame
{
private:
string m_name;
string m_players;
string m_map;
string m_streamer;
uint32_t m_replayId;
uint32_t m_originalId;
uint32_t m_newId;
uint32_t m_createTime;
uint32_t m_startTime;
uint32_t m_lastedTime;
uint32_t m_lastUpdateTime;
BYTEARRAY m_version;
BYTEARRAY m_options;
BYTEARRAY m_mapOptions;
uint32_t m_state;
BYTEARRAY m_details;
BYTEARRAY m_startHead;
map<uint32_t, BYTEARRAY> m_data;
uint32_t m_dataLenth;
//list<CClient*> m_clients;
uint32_t m_clientCount;
bool m_delete;
bool m_deleteReady;
public:
CGame ( string streamer , string gameName , uint32_t replayId , uint32_t gameId , string players , uint32_t createTime , BYTEARRAY version , BYTEARRAY options , string map , BYTEARRAY mapOptions );
//~CGame ( );
string GetGameName ( ) { return m_name; }
string GetPlayers ( ) { return m_players; }
string GetStreamer ( ) { return m_streamer; }
string GetMap ( ) { return m_map; }
uint32_t GetReplayId ( ) { return m_replayId; }
uint32_t GetId ( );
uint32_t GetStartTime ( ) { return m_startTime; }
uint32_t GetLastedTime ( ) { return m_lastedTime; }
uint32_t GetLastUpdateTime ( ) { return m_lastUpdateTime; }
uint32_t GetState ( ) { return m_state; }
BYTEARRAY& GetVersion ( ) { return m_version; }
BYTEARRAY& GetOptions ( ) { return m_options; }
BYTEARRAY& GetMapOptions ( ) { return m_mapOptions; }
BYTEARRAY& GetDetails ( ) { return m_details; }
BYTEARRAY& GetStartHead ( ) { return m_startHead; }
map<uint32_t, BYTEARRAY>& GetGameData ( ) { return m_data; }
bool GetDelete ( ) { return m_delete; }
bool GetDeleteReady ( ) { return m_deleteReady; }
void SetDetials ( BYTEARRAY b );
void SetStartHead ( BYTEARRAY b );
void SetState ( uint32_t i );
void SetStartTime ( uint32_t i );
void SetLastedTime ( uint32_t i );
void NewGameData ( BYTEARRAY b );
void SetGameId ( uint32_t i );
void SetDelete ( ) { m_delete = true; }
//void NewClient ( CClient* client );
//void RemoveClient ( CClient* client );
void Update ( );
};
#endif
| [
"17175297.hk@dc2ccb66-e3a1-11de-9043-17b7bd24f792",
"17175297.HK@dc2ccb66-e3a1-11de-9043-17b7bd24f792"
]
| [
[
[
1,
17
],
[
41,
42
],
[
63,
63
],
[
72,
72
],
[
75,
75
],
[
77,
78
]
],
[
[
18,
40
],
[
43,
62
],
[
64,
71
],
[
73,
74
],
[
76,
76
],
[
79,
79
]
]
]
|
1e5ef612fc9c1a83424f64764306394660f715e3 | 21da454a8f032d6ad63ca9460656c1e04440310e | /src/net/worldscale/pimap/server/wscPsUserTable.cpp | 80aebce06806b3146b91dbd8932ff6974f958498 | []
| no_license | merezhang/wcpp | d9879ffb103513a6b58560102ec565b9dc5855dd | e22eb48ea2dd9eda5cd437960dd95074774b70b0 | refs/heads/master | 2021-01-10T06:29:42.908096 | 2009-08-31T09:20:31 | 2009-08-31T09:20:31 | 46,339,619 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,415 | cpp | #include "wscPsUserTable.h"
#include "wsiPsUser.h"
#include <wcpp/wspr/wsuSingleLock.h>
#include "wscPimapServerConfig.h"
#include "wscPsUser.h"
wscPsUserTable::wscPsUserTable(void)
{
/*
for (ws_uint32 i=wscPimapServerConfig::MAX_USER_NUMBER+3; i>0; i--) {
ws_ptr<wsiPsUser> user;
NewObj<wscPsUser>( &user , i );
Put( user );
}
*/
}
wscPsUserTable::~wscPsUserTable(void)
{
}
ws_result wscPsUserTable::Get(wsiPsUser ** ret, ws_uint32 uid)
{
ws_ptr<wsiObject> obj;
if (true)
{
wsuSingleLock lock( &m_mutex );
t_user_table::iterator iter = m_UserTab.find(uid);
if (iter == m_UserTab.end()) return WS_RLT_FAILED;
(*iter).second.CopyTo( &obj );
}
if (!obj) return WS_RLT_FAILED;
return obj->QueryInterface( wsiPsUser::sIID , (void**)ret );
}
ws_result wscPsUserTable::Put(wsiPsUser *user)
{
if (user==WS_NULL) return WS_RLT_NULL_POINTER;
ws_uint32 uid = user->GetUserId();
wsuSingleLock lock( &m_mutex );
if (wscPimapServerConfig::MAX_USER_NUMBER < m_UserTab.size()) return WS_RLT_ARRAY_INDEX_OUT_OF_BOUNDS;
m_UserTab.insert( t_user_table::value_type(uid,user) );
return WS_RLT_SUCCESS;
}
ws_result wscPsUserTable::Remove(ws_uint32 uid)
{
wsuSingleLock lock( &m_mutex );
m_UserTab.erase( uid );
return WS_RLT_SUCCESS;
}
| [
"xukun0217@98f29a9a-77f1-11de-91f8-ab615253d9e8"
]
| [
[
[
1,
57
]
]
]
|
06b76287f8303fd5f4e216efd4c8114717cc49b3 | c2153dcfa8bcf5b6d7f187e5a337b904ad9f91ac | /depends/ClanLib/src/Core/Math/sha1_impl.cpp | 62751d6e76e0841333fd09579ab41d292f46d425 | []
| no_license | ptrefall/smn6200fluidmechanics | 841541a26023f72aa53d214fe4787ed7f5db88e1 | 77e5f919982116a6cdee59f58ca929313dfbb3f7 | refs/heads/master | 2020-08-09T17:03:59.726027 | 2011-01-13T22:39:03 | 2011-01-13T22:39:03 | 32,448,422 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,050 | cpp | /*
** ClanLib SDK
** Copyright (c) 1997-2010 The ClanLib Team
**
** This software is provided 'as-is', without any express or implied
** warranty. In no event will the authors be held liable for any damages
** arising from the use of this software.
**
** Permission is granted to anyone to use this software for any purpose,
** including commercial applications, and to alter it and redistribute it
** freely, subject to the following restrictions:
**
** 1. The origin of this software must not be misrepresented; you must not
** claim that you wrote the original software. If you use this software
** in a product, an acknowledgment in the product documentation would be
** appreciated but is not required.
** 2. Altered source versions must be plainly marked as such, and must not be
** misrepresented as being the original software.
** 3. This notice may not be removed or altered from any source distribution.
**
** Note: Some of the libraries ClanLib may link to may have additional
** requirements or restrictions.
**
** File Author(s):
**
** Magnus Norddahl
*/
#include "precomp.h"
#include "sha1_impl.h"
#ifndef WIN32
#include <cstring>
#endif
/////////////////////////////////////////////////////////////////////////////
// CL_SHA1_Impl Construction:
CL_SHA1_Impl::CL_SHA1_Impl()
{
reset();
}
/////////////////////////////////////////////////////////////////////////////
// CL_SHA1_Impl Attributes:
CL_String8 CL_SHA1_Impl::get_hash(bool uppercase)
{
if (calculated == false)
throw CL_Exception("SHA-1 hash has not been calculated yet!");
char digest[41];
memset(digest, 0, 41);
to_hex(digest, h0, uppercase);
to_hex(digest+8, h1, uppercase);
to_hex(digest+16, h2, uppercase);
to_hex(digest+24, h3, uppercase);
to_hex(digest+32, h4, uppercase);
return digest;
}
void CL_SHA1_Impl::get_hash(unsigned char out_hash[20])
{
if (calculated == false)
throw CL_Exception("SHA-1 hash has not been calculated yet!");
out_hash[0] = (unsigned char) ((h0 >> 24) & 0xff);
out_hash[1] = (unsigned char) ((h0 >> 16) & 0xff);
out_hash[2] = (unsigned char) ((h0 >> 8) & 0xff);
out_hash[3] = (unsigned char) (h0 & 0xff);
out_hash[4] = (unsigned char) ((h1 >> 24) & 0xff);
out_hash[5] = (unsigned char) ((h1 >> 16) & 0xff);
out_hash[6] = (unsigned char) ((h1 >> 8) & 0xff);
out_hash[7] = (unsigned char) (h1 & 0xff);
out_hash[8] = (unsigned char) ((h2 >> 24) & 0xff);
out_hash[9] = (unsigned char) ((h2 >> 16) & 0xff);
out_hash[10] = (unsigned char) ((h2 >> 8) & 0xff);
out_hash[11] = (unsigned char) (h2 & 0xff);
out_hash[12] = (unsigned char) ((h3 >> 24) & 0xff);
out_hash[13] = (unsigned char) ((h3 >> 16) & 0xff);
out_hash[14] = (unsigned char) ((h3 >> 8) & 0xff);
out_hash[15] = (unsigned char) (h3 & 0xff);
out_hash[16] = (unsigned char) ((h4 >> 24) & 0xff);
out_hash[17] = (unsigned char) ((h4 >> 16) & 0xff);
out_hash[18] = (unsigned char) ((h4 >> 8) & 0xff);
out_hash[19] = (unsigned char) (h4 & 0xff);
}
/////////////////////////////////////////////////////////////////////////////
// CL_SHA1_Impl Operations:
void CL_SHA1_Impl::reset()
{
h0 = 0x67452301;
h1 = 0xEFCDAB89;
h2 = 0x98BADCFE;
h3 = 0x10325476;
h4 = 0xC3D2E1F0;
memset(chunk, 0, 64);
chunk_filled = 0;
length_message = 0;
calculated = false;
}
void CL_SHA1_Impl::add(const void *_data, int size)
{
if (calculated)
reset();
#define cl_min(a,b) ((a) < (b) ? (a) : (b))
const unsigned char *data = (const unsigned char *) _data;
int pos = 0;
while (pos < size)
{
int data_left = size - pos;
int buffer_space = 64 - chunk_filled;
int data_used = cl_min(buffer_space, data_left);
memcpy(chunk + chunk_filled, data + pos, data_used);
chunk_filled += data_used;
pos += data_used;
if (chunk_filled == 64)
{
process_chunk();
chunk_filled = 0;
}
}
length_message += size * (cl_uint64) 8;
}
void CL_SHA1_Impl::calculate()
{
if (calculated)
reset();
// append a single "1" bit to message
// append "0" bits until message length ≡ 448 ≡ -64 (mod 512)
// append length of message, in bits as 64-bit big-endian integer to message
unsigned char end_data[128];
memset(end_data, 0, 128);
end_data[0] = 128;
int size = 64 - chunk_filled;
if (size < 9)
size += 64;
unsigned int length_upper = (unsigned int) (length_message >> 32);
unsigned int length_lower = (unsigned int) (length_message & 0xffffffff);
end_data[size-8] = (length_upper & 0xff000000) >> 24;
end_data[size-7] = (length_upper & 0x00ff0000) >> 16;
end_data[size-6] = (length_upper & 0x0000ff00) >> 8;
end_data[size-5] = (length_upper & 0x000000ff);
end_data[size-4] = (length_lower & 0xff000000) >> 24;
end_data[size-3] = (length_lower & 0x00ff0000) >> 16;
end_data[size-2] = (length_lower & 0x0000ff00) >> 8;
end_data[size-1] = (length_lower & 0x000000ff);
add(end_data, size);
if (chunk_filled != 0)
throw CL_Exception("Error in CL_SHA1_Impl class. Still chunk data at end of calculate");
calculated = true;
}
/////////////////////////////////////////////////////////////////////////////
// CL_SHA1_Impl Implementation:
void CL_SHA1_Impl::process_chunk()
{
int i;
unsigned int w[80];
for (i = 0; i < 16; i++)
{
unsigned int b1 = chunk[i*4];
unsigned int b2 = chunk[i*4+1];
unsigned int b3 = chunk[i*4+2];
unsigned int b4 = chunk[i*4+3];
w[i] = (b1 << 24) + (b2 << 16) + (b3 << 8) + b4;
}
for (i = 16; i < 80; i++)
w[i] = leftrotate_uint32(w[i-3] ^ w[i-8] ^ w[i-14] ^ w[i-16], 1);
cl_uint32 a = h0;
cl_uint32 b = h1;
cl_uint32 c = h2;
cl_uint32 d = h3;
cl_uint32 e = h4;
for (i = 0; i < 80; i++)
{
cl_uint32 f, k;
if (i < 20)
{
f = (b & c) | ((~b) & d);
k = 0x5A827999;
}
else if (i < 40)
{
f = b ^ c ^ d;
k = 0x6ED9EBA1;
}
else if (i < 60)
{
f = (b & c) | (b & d) | (c & d);
k = 0x8F1BBCDC;
}
else
{
f = b ^ c ^ d;
k = 0xCA62C1D6;
}
cl_uint32 temp = leftrotate_uint32(a, 5) + f + e + k + w[i];
e = d;
d = c;
c = leftrotate_uint32(b, 30);
b = a;
a = temp;
}
h0 += a;
h1 += b;
h2 += c;
h3 += d;
h4 += e;
}
void CL_SHA1_Impl::to_hex(char *buffer, cl_uint32 value, bool uppercase)
{
cl_uint32 values[4];
values[0] = ((value & 0xff000000) >> 24);
values[1] = ((value & 0x00ff0000) >> 16);
values[2] = ((value & 0x0000ff00) >> 8);
values[3] = (value & 0x000000ff);
cl_uint32 low = '0';
cl_uint32 high = uppercase ? 'A' : 'a';
for (int i = 0; i < 4; i++)
{
cl_uint32 a = ((values[i] & 0xf0) >> 4);
cl_uint32 b = (values[i] & 0x0f);
buffer[i*2+0] = (a < 10) ? (low + a) : (high + a - 10);
buffer[i*2+1] = (b < 10) ? (low + b) : (high + b - 10);
}
}
inline unsigned int CL_SHA1_Impl::leftrotate_uint32(unsigned int value, int shift)
{
return (value << shift) + (value >> (32-shift));
}
| [
"[email protected]@c628178a-a759-096a-d0f3-7c7507b30227"
]
| [
[
[
1,
255
]
]
]
|
29636880aabc9b769a4a57ea2d2de80bc38db28f | 8103a6a032f7b3ec42bbf7a4ad1423e220e769e0 | /Prominence/Sprite.cpp | 68be77b16118bd1bf26d23f24550c4df5a59b77d | []
| no_license | wgoddard/2d-opengl-engine | 0400bb36c2852ce4f5619f8b5526ba612fda780c | 765b422277a309b3d4356df2e58ee8db30d91914 | refs/heads/master | 2016-08-08T14:28:07.909649 | 2010-06-17T19:13:12 | 2010-06-17T19:13:12 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 223 | cpp | #include "Sprite.h"
namespace Prominence {
Sprite::Sprite(ResourceManager & rm, Renderer & renderer) : m_ResourceManager(rm), m_Renderer(renderer)
{
}
Sprite::~Sprite(void)
{
}
} // Exit Prominence Namespace | [
"William@18b72257-4ce5-c346-ae33-905a28f88ba6"
]
| [
[
[
1,
13
]
]
]
|
63c97bdc044be8ba8965926d9cea09e65a589bb5 | ce262ae496ab3eeebfcbb337da86d34eb689c07b | /SEFoundation/SEMath/SERectangle3.cpp | 5f0122c45ed4af21461a88be8113d5ed7aaab519 | []
| no_license | pizibing/swingengine | d8d9208c00ec2944817e1aab51287a3c38103bea | e7109d7b3e28c4421c173712eaf872771550669e | refs/heads/master | 2021-01-16T18:29:10.689858 | 2011-06-23T04:27:46 | 2011-06-23T04:27:46 | 33,969,301 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,143 | cpp | // Swing Engine Version 1 Source Code
// Most of techniques in the engine are mainly based on David Eberly's
// Wild Magic 4 open-source code.The author of Swing Engine learned a lot
// from Eberly's experience of architecture and algorithm.
// Several sub-systems are totally new,and others are re-implimented or
// re-organized based on Wild Magic 4's sub-systems.
// Copyright (c) 2007-2010. All Rights Reserved
//
// Eberly's permission:
// Geometric Tools, Inc.
// http://www.geometrictools.com
// Copyright (c) 1998-2006. All Rights Reserved
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or (at
// your option) any later version. The license is available for reading at
// the location:
// http://www.gnu.org/copyleft/lgpl.html
#include "SEFoundationPCH.h"
#include "SERectangle3.h"
using namespace Swing;
//----------------------------------------------------------------------------
SERectangle3f::SERectangle3f()
{
}
//----------------------------------------------------------------------------
SERectangle3f::SERectangle3f(const SEVector3f& rCenter, const SEVector3f*
aAxis, const float* afExtent)
:
Center(rCenter)
{
for( int i = 0; i < 2; i++ )
{
Axis[i] = aAxis[i];
Extent[i] = afExtent[i];
}
}
//----------------------------------------------------------------------------
SERectangle3f::SERectangle3f(const SEVector3f& rCenter, const SEVector3f&
rAxis0, const SEVector3f& rAxis1, float fExtent0, float fExtent1)
:
Center(rCenter)
{
Axis[0] = rAxis0;
Axis[1] = rAxis1;
Extent[0] = fExtent0;
Extent[1] = fExtent1;
}
//----------------------------------------------------------------------------
void SERectangle3f::ComputeVertices(SEVector3f aVertex[4]) const
{
SEVector3f aEAxis[2] =
{
Extent[0] * Axis[0],
Extent[1] * Axis[1]
};
aVertex[0] = Center - aEAxis[0] - aEAxis[1];
aVertex[1] = Center + aEAxis[0] - aEAxis[1];
aVertex[2] = Center + aEAxis[0] + aEAxis[1];
aVertex[3] = Center - aEAxis[0] + aEAxis[1];
}
//----------------------------------------------------------------------------
SEVector3f SERectangle3f::GetPPCorner() const
{
return Center + Extent[0]*Axis[0] + Extent[1]*Axis[1];
}
//----------------------------------------------------------------------------
SEVector3f SERectangle3f::GetPMCorner() const
{
return Center + Extent[0]*Axis[0] - Extent[1]*Axis[1];
}
//----------------------------------------------------------------------------
SEVector3f SERectangle3f::GetMPCorner() const
{
return Center - Extent[0]*Axis[0] + Extent[1]*Axis[1];
}
//----------------------------------------------------------------------------
SEVector3f SERectangle3f::GetMMCorner() const
{
return Center - Extent[0]*Axis[0] - Extent[1]*Axis[1];
}
//----------------------------------------------------------------------------
| [
"[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac"
]
| [
[
[
1,
87
]
]
]
|
2323f6edfae418ab1083bfb54abfe0537872db23 | 0f457762985248f4f6f06e29429955b3fd2c969a | /irrlicht/irrEdit/source/plugins/jz3dplugins/TiledPlaneNode.cpp | 2c90afc61757eef078baeeda09bf7e1967b58fcb | []
| no_license | tk8812/ukgtut | f19e14449c7e75a0aca89d194caedb9a6769bb2e | 3146ac405794777e779c2bbb0b735b0acd9a3f1e | refs/heads/master | 2021-01-01T16:55:07.417628 | 2010-11-15T16:02:53 | 2010-11-15T16:02:53 | 37,515,002 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 15,544 | cpp | #include "TiledPlaneNode.h"
//타일드 플래인 씬노드
//작성 : 2009.8.18 gbox3d
//v0.001 2009.8.19,속성 재설정시 이전 메트 리얼 보존하도록 수정
//v0.002 2009.8.25, 메쉬 참조 카운터오류오인한 메모리릭 수정
namespace irr
{
namespace scene
{
namespace jz3d
{
const char *CTiledPlaneNode::Name = "TiledPlaneNode";
const char *MeshNameFormat = "./usr/mesh/tiledplanenodec%d_%ds%f_%f";
//const char *MeshNameFormat = "../res/usr/mesh/tiledplanenode";
CTiledPlaneNode::CTiledPlaneNode(ISceneNode* parent, ISceneManager* mgr,s32 id, const core::vector3df& position,const core::vector3df& rotation, const core::vector3df& scale)
: IMeshSceneNode(parent, mgr, id, position, rotation, scale),
Mesh(0),
PassCount(0),
ReadOnlyMaterials(false),
m_TileCount(irr::core::dimension2d<irr::u32>(1,1)),
m_TileSize(irr::core::dimension2d<irr::f32>(10,10)),
m_bLightMapGen_Enable(false)
{
#ifdef _DEBUG
setDebugName("CTiledPlaneNode");
#endif
setMesh(setupMesh(""));
////m_nTempType = ESNT_MESH;
//irr::scene::IAnimatedMesh* pMesh;
//if(SceneManager->getMeshCache()->isMeshLoaded("jz3d/scene/mesh/plane1x1") == false)
//{
// pMesh = SceneManager->addHillPlaneMesh("jz3d/scene/mesh/plane1x1",
// irr::core::dimension2d<irr::f32>(10,10),
// irr::core::dimension2d<irr::u32>(1,1));
//}
//else
//{
// pMesh = SceneManager->getMesh("jz3d/scene/mesh/plane1x1");
//}
//
////Mesh = pMesh;
//
//setMesh(pMesh);
}
CTiledPlaneNode::~CTiledPlaneNode(void)
{
if (Mesh)
Mesh->drop();
}
void CTiledPlaneNode::OnRegisterSceneNode()
{
if (IsVisible)
{
// because this node supports rendering of mixed mode meshes consisting of
// transparent and solid material at the same time, we need to go through all
// materials, check of what type they are and register this node for the right
// render pass according to that.
video::IVideoDriver* driver = SceneManager->getVideoDriver();
PassCount = 0;
int transparentCount = 0;
int solidCount = 0;
// count transparent and solid materials in this scene node
if (ReadOnlyMaterials && Mesh)
{
// count mesh materials
for (u32 i=0; i<Mesh->getMeshBufferCount(); ++i)
{
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
video::IMaterialRenderer* rnd = mb ? driver->getMaterialRenderer(mb->getMaterial().MaterialType) : 0;
if (rnd && rnd->isTransparent())
++transparentCount;
else
++solidCount;
if (solidCount && transparentCount)
break;
}
}
else
{
// count copied materials
for (u32 i=0; i<Materials.size(); ++i)
{
video::IMaterialRenderer* rnd =
driver->getMaterialRenderer(Materials[i].MaterialType);
if (rnd && rnd->isTransparent())
++transparentCount;
else
++solidCount;
if (solidCount && transparentCount)
break;
}
}
// register according to material types counted
if (solidCount)
SceneManager->registerNodeForRendering(this, scene::ESNRP_SOLID);
if (transparentCount)
SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT);
ISceneNode::OnRegisterSceneNode();
}
}
//! renders the node.
void CTiledPlaneNode::render()
{
video::IVideoDriver* driver = SceneManager->getVideoDriver();
if (!Mesh || !driver)
return;
bool isTransparentPass =
SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT;
++PassCount;
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
Box = Mesh->getBoundingBox();
// for debug purposes only:
bool renderMeshes = true;
video::SMaterial mat;
if (DebugDataVisible && PassCount==1)
{
// overwrite half transparency
if ( DebugDataVisible & scene::EDS_HALF_TRANSPARENCY )
{
for (u32 g=0; g<Mesh->getMeshBufferCount(); ++g)
{
mat = Materials[g];
mat.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
driver->setMaterial(mat);
driver->drawMeshBuffer(Mesh->getMeshBuffer(g));
}
renderMeshes = false;
}
}
// render original meshes
if ( renderMeshes )
{
for (u32 i=0; i<Mesh->getMeshBufferCount(); ++i)
{
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
if (mb)
{
const video::SMaterial& material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i];
video::IMaterialRenderer* rnd = driver->getMaterialRenderer(material.MaterialType);
bool transparent = (rnd && rnd->isTransparent());
// only render transparent buffer if this is the transparent render pass
// and solid only in solid pass
if (transparent == isTransparentPass)
{
driver->setMaterial(material);
driver->drawMeshBuffer(mb);
}
}
}
}
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
// for debug purposes only:
if ( DebugDataVisible && PassCount==1)
{
video::SMaterial m;
m.Lighting = false;
driver->setMaterial(m);
if ( DebugDataVisible & scene::EDS_BBOX )
{
driver->draw3DBox(Box, video::SColor(255,255,255,255));
}
if ( DebugDataVisible & scene::EDS_BBOX_BUFFERS )
{
for (u32 g=0; g<Mesh->getMeshBufferCount(); ++g)
{
driver->draw3DBox(
Mesh->getMeshBuffer(g)->getBoundingBox(),
video::SColor(255,190,128,128));
}
}
if ( DebugDataVisible & scene::EDS_NORMALS )
{
IAnimatedMesh * arrow = SceneManager->addArrowMesh (
"__debugnormal", 0xFFECEC00,
0xFF999900, 4, 8, 1.f, 0.6f, 0.05f,
0.3f);
if ( 0 == arrow )
{
arrow = SceneManager->getMesh ( "__debugnormal" );
}
IMesh *mesh = arrow->getMesh(0);
// find a good scaling factor
core::matrix4 m2;
// draw normals
for (u32 g=0; g<Mesh->getMeshBufferCount(); ++g)
{
const scene::IMeshBuffer* mb = Mesh->getMeshBuffer(g);
const u32 vSize = video::getVertexPitchFromType(mb->getVertexType());
const video::S3DVertex* v = ( const video::S3DVertex*)mb->getVertices();
for ( u32 i=0; i != mb->getVertexCount(); ++i )
{
// align to v->Normal
core::quaternion quatRot(v->Normal.X, 0.f, -v->Normal.X, 1+v->Normal.Y);
quatRot.normalize();
//quatRot.getMatrix(m2);
m2 = quatRot.getMatrix();
m2.setTranslation(v->Pos);
m2*=AbsoluteTransformation;
driver->setTransform(video::ETS_WORLD, m2);
for (u32 a = 0; a != mesh->getMeshBufferCount(); ++a)
driver->drawMeshBuffer(mesh->getMeshBuffer(a));
v = (const video::S3DVertex*) ( (u8*) v + vSize );
}
}
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
}
// show mesh
if ( DebugDataVisible & scene::EDS_MESH_WIRE_OVERLAY )
{
m.Wireframe = true;
driver->setMaterial(m);
for (u32 g=0; g<Mesh->getMeshBufferCount(); ++g)
{
driver->drawMeshBuffer( Mesh->getMeshBuffer(g) );
}
}
}
}
//! returns the axis aligned bounding box of this node
const core::aabbox3d<f32>& CTiledPlaneNode::getBoundingBox() const
{
//return Box;
return Mesh ? Mesh->getBoundingBox() : Box;
}
//! returns the material based on the zero based index i. To get the amount
//! of materials used by this scene node, use getMaterialCount().
//! This function is needed for inserting the node into the scene hierarchy on a
//! optimal position for minimizing renderstate changes, but can also be used
//! to directly modify the material of a scene node.
video::SMaterial& CTiledPlaneNode::getMaterial(u32 i)
{
if (Mesh && ReadOnlyMaterials && i<Mesh->getMeshBufferCount())
{
tmpReadOnlyMaterial = Mesh->getMeshBuffer(i)->getMaterial();
return tmpReadOnlyMaterial;
}
if ( i >= Materials.size())
return ISceneNode::getMaterial(i);
return Materials[i];
}
//! returns amount of materials used by this scene node.
u32 CTiledPlaneNode::getMaterialCount() const
{
if (Mesh && ReadOnlyMaterials)
return Mesh->getMeshBufferCount();
return Materials.size();
}
//! Setup a new mesh
irr::scene::IMesh *CTiledPlaneNode::setupMesh(char *MeshName)
{
irr::scene::IAnimatedMesh* pMesh;
char szBuf[256];
if(!strcmp(MeshName,""))
{
sprintf_s(szBuf,MeshNameFormat,
m_TileCount.Width,m_TileCount.Height,
m_TileSize.Width,m_TileSize.Height);
MeshName = szBuf;
}
if(SceneManager->getMeshCache()->isMeshLoaded(MeshName) == false)
{
pMesh = SceneManager->addHillPlaneMesh(MeshName,
m_TileSize,
m_TileCount,0,0,
irr::core::dimension2df(0,0),
irr::core::dimension2df((f32)m_TileCount.Width,(f32)m_TileCount.Height)
);
}
else
{
pMesh = SceneManager->getMesh(MeshName);
}
return pMesh;
}
//! Sets a new mesh
void CTiledPlaneNode::setMesh(IMesh* mesh)
{
if (!mesh)
return; // won't set null mesh
if (Mesh)
Mesh->drop();
Mesh = mesh;
copyMaterials();
//Mesh->getReferenceCount();
if (Mesh)
Mesh->grab();
}
void CTiledPlaneNode::copyMaterials(irr::scene::IMesh *copyMesh)
{
Materials.clear();
if(copyMesh)
{
video::SMaterial mat;
for (u32 i=0; i<copyMesh->getMeshBufferCount(); ++i)
{
IMeshBuffer* mb = copyMesh->getMeshBuffer(i);
if (mb)
mat = mb->getMaterial();
Materials.push_back(mat);
}
}
else if (Mesh)
{
video::SMaterial mat;
for (u32 i=0; i<Mesh->getMeshBufferCount(); ++i)
{
IMeshBuffer* mb = Mesh->getMeshBuffer(i);
if (mb)
mat = mb->getMaterial();
Materials.push_back(mat);
}
}
}
//! Writes attributes of the scene node.
void CTiledPlaneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
{
//m_nTempType = (ESCENE_NODE_TYPE)CTiledPlaneNode::TypeID;
//ReadyToSave();
IMeshSceneNode::serializeAttributes(out, options);
char szBuf[256];
#ifdef JZ3DPLUGINS_EXPORTS
out->addString("Mesh", SceneManager->getMeshCache()->getMeshFilename(Mesh) );
#else
out->addString("Mesh", SceneManager->getMeshCache()->getMeshFilename(Mesh));
//out->addString("Mesh", SceneManager->getMeshCache()->getMeshFilename(Mesh).c_str());
#endif
out->addBool("ReadOnlyMaterials", ReadOnlyMaterials);
sprintf_s(szBuf,256,"%d,%d",m_TileCount.Width,m_TileCount.Height);
out->addString("TileCount",szBuf);
sprintf_s(szBuf,256,"%.2f,%.2f",m_TileSize.Width,m_TileSize.Height);
out->addString("TileSize",szBuf);
out->addBool("LightMap",m_bLightMapGen_Enable);
//m_nTempType = ESNT_MESH;
//out->addInt("TileCountWidth",m_TileCount.Width);
//out->addInt("TileCountHeight",m_TileCount.Height);
//out->addVector3d("TileSize",irr::core::vector3df(m_TileSize.Width,m_TileSize.Height,0));
//out->addRect("box",irr::core::rect<s32>());
}
//! Reads attributes of the scene node.
void CTiledPlaneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
{
core::stringc oldMeshStr = SceneManager->getMeshCache()->getMeshFilename(Mesh);
core::stringc newMeshStr = in->getAttributeAsString("Mesh");
ReadOnlyMaterials = in->getAttributeAsBool("ReadOnlyMaterials");
irr::core::stringc strTemp;
//타일카운트
strTemp = in->getAttributeAsString("TileCount").c_str();
sscanf_s(strTemp.c_str(),"%d,%d",&m_TileCount.Width,&m_TileCount.Height);
//타일크기
strTemp = in->getAttributeAsString("TileSize").c_str();
sscanf_s(strTemp.c_str(),"%f,%f",&m_TileSize.Width,&m_TileSize.Height);
irr::core::stringc newMeshStr2;
char szBuf[256];
sprintf_s(szBuf,MeshNameFormat,
m_TileCount.Width,m_TileCount.Height,
m_TileSize.Width,m_TileSize.Height);
newMeshStr2 = szBuf;
//메쉬가 바꼈으면
if(newMeshStr2 != newMeshStr || newMeshStr2 != oldMeshStr)
{
//copyMaterials(Mesh);
IMesh* newMesh = 0;
newMesh = setupMesh(szBuf); //기존 로드된메쉬를 검색해보고 없으면 다시만든다.
if (newMesh)
{
if (Mesh)
Mesh->drop();
Mesh = newMesh;
//copyMaterials(SceneManager->getMesh(newMeshStr.c_str()));
if (Mesh)
Mesh->grab();
//setMesh(newMesh);
}
}
else if (newMeshStr != "" && oldMeshStr != newMeshStr)//메쉬 직접입력 할경우
{
IMesh* newMesh = 0;
IAnimatedMesh* newAnimatedMesh = SceneManager->getMesh(newMeshStr.c_str());
if (newAnimatedMesh)
newMesh = newAnimatedMesh->getMesh(0);
if (newMesh)
setMesh(newMesh);
}
m_bLightMapGen_Enable = in->getAttributeAsBool("LightMap");
IMeshSceneNode::deserializeAttributes(in, options);
}
//! Sets if the scene node should not copy the materials of the mesh but use them in a read only style.
/* In this way it is possible to change the materials a mesh causing all mesh scene nodes
referencing this mesh to change too. */
void CTiledPlaneNode::setReadOnlyMaterials(bool readonly)
{
ReadOnlyMaterials = readonly;
}
//! Returns if the scene node should not copy the materials of the mesh but use them in a read only style
bool CTiledPlaneNode::isReadOnlyMaterials() const
{
return ReadOnlyMaterials;
}
//! Creates a clone of this scene node and its children.
ISceneNode* CTiledPlaneNode::clone(ISceneNode* newParent, ISceneManager* newManager)
{
if (!newParent) newParent = Parent;
if (!newManager) newManager = SceneManager;
CTiledPlaneNode* nb = new CTiledPlaneNode(
newParent,
newManager,
ID,
RelativeTranslation, RelativeRotation, RelativeScale);
nb->cloneMembers(this, newManager);
nb->ReadOnlyMaterials = ReadOnlyMaterials;
nb->Materials = Materials;
nb->m_TileCount = m_TileCount;
nb->m_TileSize = m_TileSize;
nb->m_bLightMapGen_Enable = m_bLightMapGen_Enable;
{
#ifdef JZ3DPLUGINS_EXPORTS
nb->setMesh(setupMesh((char *)SceneManager->getMeshCache()->getMeshFilename(Mesh) ));
#else
nb->setMesh(setupMesh((char *)SceneManager->getMeshCache()->getMeshFilename(Mesh) ));
//nb->setMesh(setupMesh((char *)SceneManager->getMeshCache()->getMeshFilename(Mesh).c_str() ));
#endif
//nb->copyMaterials(Mesh);
nb->Materials = Materials;
}
nb->drop();
return nb;
}
}
}
}
| [
"gbox3d@58f0f68e-7603-11de-abb5-1d1887d8974b"
]
| [
[
[
1,
556
]
]
]
|
9828e6fb72cf73c826d4252e68455959399cd502 | 1e299bdc79bdc75fc5039f4c7498d58f246ed197 | /stdobj/MCWavelet.h | 73c7af1f676e14232b5a3848083a9b0d9a7f3ae2 | []
| no_license | moosethemooche/Certificate-Server | 5b066b5756fc44151b53841482b7fa603c26bf3e | 887578cc2126bae04c09b2a9499b88cb8c7419d4 | refs/heads/master | 2021-01-17T06:24:52.178106 | 2011-07-13T13:27:09 | 2011-07-13T13:27:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,212 | h | //--------------------------------------------------------------------------------
//
// Copyright (c) 1999 MarkCare Solutions
//
// Programming by Rich Schonthal
//
//--------------------------------------------------------------------------------
// MCWavelet.h: interface for the CWavelet class.
//
//////////////////////////////////////////////////////////////////////
#ifndef _MCWAVELET_H_
#define _MCWAVELET_H_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER>1000
#include <dcmtypes.h>
//--------------------------------------------------------------------------------
class CWavelet
{
public:
CWavelet();
virtual ~CWavelet();
public:
enum {PACK, UNPACK};
static LPCTSTR m_pTempExt; // File extension used for temporary compressed files.
static int m_nStdQuality; // Set this to the MarkCare standard quality setting.
private:
static LPCTSTR m_pSignature;
static WORD m_nSigLen;
public:
bool IsMark0(LPCTSTR pFilename) const;
bool PackFile(LPCTSTR pFilename, LPCTSTR pPath, DCM_HEADER* pHeader, int nQual, LPCTSTR pQualityFile);
bool UnpackFile(LPCTSTR pFilename, LPCTSTR pPath);
};
#endif // #ifndef _MCWAVELET_H_
| [
"[email protected]"
]
| [
[
[
1,
44
]
]
]
|
b864fbe330f4e12733d3d3c82d95002347ba1a73 | a36d7a42310a8351aa0d427fe38b4c6eece305ea | /core_billiard/NodeNull.hpp | 8422fdd988b92328e7e15d0869cb4f4f74f477aa | []
| no_license | newpolaris/mybilliard01 | ca92888373c97606033c16c84a423de54146386a | dc3b21c63b5bfc762d6b1741b550021b347432e8 | refs/heads/master | 2020-04-21T06:08:04.412207 | 2009-09-21T15:18:27 | 2009-09-21T15:18:27 | 39,947,400 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 665 | hpp | #pragma once
namespace my_render {
NULL_OBJECT( Node ), public BaseNull {
virtual Node * getParent() OVERRIDE { return NULL; }
virtual Node * getNextSibling() OVERRIDE { return NULL; }
virtual Node * getFirstChild() OVERRIDE { return NULL; }
virtual size_t getNbChild() OVERRIDE { return 0; }
virtual wstring getSID() OVERRIDE { return L""; }
virtual bool hasParent() OVERRIDE { return false; }
virtual bool hasNextSibling() OVERRIDE { return false; }
virtual bool hasFirstChild() OVERRIDE { return false; }
virtual void display() OVERRIDE {}
virtual void display_positionOnly() OVERRIDE {}
};
} | [
"wrice127@af801a76-7f76-11de-8b9f-9be6f49bd635"
]
| [
[
[
1,
23
]
]
]
|
efbccbea11d2d43af10f0bf469977f151523e11a | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/mw/classicui/uifw/apps/S60_SDK3.0/bctestsearchfield/inc/bctestsearchfieldview.h | a8161e951f5c9f58039d43f15980b40de9ef68a2 | []
| 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,073 | h | /*
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: Test BC for Template control API.
*
*/
#ifndef C_BCTESTSEARCHFIELDVIEW_H
#define C_BCTESTSEARCHFIELDVIEW_H
#include <aknview.h>
const TUid KBCTestSearchFieldViewId = { 1 };
class CBCTestSearchFieldContainer;
class CBCTestUtil;
/**
* Application UI class
*
* @lib bctestutil.lib
*/
class CBCTestSearchFieldView : public CAknView
{
public: // Constructors and destructor
/**
* Symbian static 2nd constructor
*/
static CBCTestSearchFieldView* NewL( CBCTestUtil* aUtil );
/**
* dtor
*/
virtual ~CBCTestSearchFieldView();
public: // from CAknView
/**
* Return view Id.
*/
TUid Id() const;
/**
* From CAknView, HandleCommandL.
* @param aCommand Command to be handled.
*/
void HandleCommandL( TInt aCommand );
protected: // from CAknView
/**
* When view is activated, do something
*/
void DoActivateL( const TVwsViewId&, TUid, const TDesC8& );
/**
* When view is deactivated, do something
*/
void DoDeactivate();
private: // constructor
/**
* C++ default constructor
*/
CBCTestSearchFieldView();
/**
* symbian 2nd ctor
*/
void ConstructL(CBCTestUtil* aUtil);
private: // data
/**
* pointor to the BC Test framework utility.
* not own just refer to
*/
CBCTestUtil* iTestUtil;
/**
* pointor to the container.
* own
*/
CBCTestSearchFieldContainer* iContainer;
};
#endif // C_BCTESTSEARCHFIELDVIEW_H
| [
"none@none"
]
| [
[
[
1,
101
]
]
]
|
445b87b88376145741372bb5cf305881fbd5de58 | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/os/ossrv/stdlibs/apps/libpthread/src/pthread_mutex_trylock.cpp | 61c592521c8ccffce734df97cf241c6774f7755e | []
| 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,178 | cpp | /*
* Copyright (c) 2005-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: POSIX implementation of mutexes on Symbian
*
*/
#include "mutextypes.h"
EXPORT_C int pthread_mutex_trylock (pthread_mutex_t * mutex)
{
if( !VALID_MUTEX(mutex) )
{
return EINVAL;
}
_pthread_mutex_t* pMutex = mutex->iPtr;
pMutex->iDataLock.Wait();
if(mutex->iState == _EDestroyed)
{
return EINVAL;
}
//return immediately if mutex is locked, unless the mutex is a recursive
// mutex and we are locking again.
if(pMutex->iCount)
{
if(pMutex->iMutexType != PTHREAD_MUTEX_RECURSIVE ||
pMutex->iLockingThread != pthread_self())
{
pMutex->iDataLock.Signal();
return EBUSY;
}
}
int retval = 0;
switch(pMutex->iMutexType)
{
case PTHREAD_MUTEX_NORMAL:
{
pMutex->iCount = 1;
pMutex->iSignalSemaphore.Wait();
break;
}
case PTHREAD_MUTEX_RECURSIVE:
{
if(pMutex->iCount)
{
pMutex->iCount++;
}
else
{
pMutex->iCount = 1;
pMutex->iLockingThread = pthread_self();
pMutex->iSignalSemaphore.Wait();
}
break;
}
case PTHREAD_MUTEX_ERRORCHECK:
{
pMutex->iCount = 1;
pMutex->iLockingThread = pthread_self();
pMutex->iSignalSemaphore.Wait();
break;
}
default:
retval = ENOSYS;
break;
}
pMutex->iDataLock.Signal();
return retval;
}
// End of File
| [
"none@none"
]
| [
[
[
1,
90
]
]
]
|
e84450d4004e35109ca0d43f3628e1e60389f496 | 7a310d01d1a4361fd06b40a74a2afc8ddc23b4d3 | /src/API.h | c02692670535d7a9608216a7feae449ff860ce4c | []
| no_license | plus7/DonutG | b6fec6111d25b60f9a9ae5798e0ab21bb2fa28f6 | 2d204c36f366d6162eaf02f4b2e1b8bc7b403f6b | refs/heads/master | 2020-06-01T15:30:31.747022 | 2010-08-21T18:51:01 | 2010-08-21T18:51:01 | 767,753 | 1 | 2 | null | null | null | null | SHIFT_JIS | C++ | false | false | 11,206 | h | /**
* @file API.h
* @brief CAPI の宣言.
*/
#ifndef __API_H_
#define __API_H_
#include "DonutPCP.h"
#include "MDIChildUserMessenger.h"
#include "option/CloseTitleOption.h"
#include "dialog/aboutdlg.h"
#include "ChildFrame.h" //#include ""ChildFrm.h" //+++
#include "MainFrame.h" //#include "mainfrm.h" //+++
extern CMainFrame *g_pMainWnd;
class CAPI;
extern CAPI * g_pAPI;
/////////////////////////////////////////////////////////////////////////////
// CAPI
class ATL_NO_VTABLE CAPI
: public CComObjectRootEx<CComSingleThreadModel>
, public CComCoClass<CAPI, &CLSID_API>
, public IConnectionPointContainerImpl<CAPI>
, public IDispatchImpl<IAPI4, &IID_IAPI4, &LIBID_DONUTPLib>
, public CProxyIDonutPEvents< CAPI >
{
private:
BOOL m_bFirst;
CSimpleArray<DWORD *> m_aryCookie;
//vector<CComPtr<IUnknown> > m_vecUnk;
public:
CAPI() : m_bFirst(TRUE) {}
virtual ~CAPI() {
DWORD *pdw;
for (int i = 0; i < m_aryCookie.GetSize(); i++) {
pdw = m_aryCookie[i];
Unadvise(*pdw);
}
}
public:
DECLARE_REGISTRY_RESOURCEID(IDR_API)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(CAPI)
COM_INTERFACE_ENTRY(IAPI)
COM_INTERFACE_ENTRY(IAPI2)
COM_INTERFACE_ENTRY(IAPI3)
COM_INTERFACE_ENTRY(IAPI4)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IConnectionPointContainer)
COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
END_COM_MAP()
BEGIN_CONNECTION_POINT_MAP(CAPI)
CONNECTION_POINT_ENTRY(DIID_IDonutPEvents)
END_CONNECTION_POINT_MAP()
// IAPI
public:
BOOL IsConfirmScripting()
{
#if 1 //+++
return CDonutConfirmOption::WhetherConfirmScript() != 0;
#else
BOOL bFlag = CDonutConfirmOption::WhetherConfirmScript();
return bFlag ? TRUE : FALSE;
#endif
}
static HRESULT InternalQueryInterface( void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject )
{
CAPI *_pThis = (CAPI *) pThis;
if (_pThis->m_bFirst) {
const _ATL_INTMAP_ENTRY *pEnt = pEntries;
while (pEnt->piid) {
if ( InlineIsEqualGUID(iid, *pEnt->piid) ) {
_pThis->m_bFirst = FALSE;
return CComObjectRootEx<CComSingleThreadModel>::InternalQueryInterface(pThis, pEntries, iid, ppvObject);
}
pEnt++;
}
_pThis->m_bFirst = FALSE;
if ( _pThis->IsConfirmScripting() ) {
HWND hWnd = (g_pMainWnd) ? g_pMainWnd->m_hWnd : NULL;
int nRet = ::MessageBox(hWnd, _T("スクリプトまたはプラグインがDonutの機能を使用しようとしています。\n")
_T("悪意のあるコードが実行される可能性があります。\n")
_T("処理の続行を許可しますか?"), _T("確認"), MB_YESNO);
if (nRet == IDYES) {
return CComObjectRootEx<CComSingleThreadModel>::InternalQueryInterface(pThis, pEntries, iid, ppvObject);
} else {
return E_NOTIMPL;
}
}
}
return CComObjectRootEx<CComSingleThreadModel>::InternalQueryInterface(pThis, pEntries, iid, ppvObject);
}
STDMETHOD (Advise) (IUnknown * pUnk, DWORD * pdwCookie);
/*{
HRESULT hr = CProxy_IDonutPEvents<CAPI>::Advise(pUnk, pdwCookie);
if (SUCCEEDED(hr))
g_pAPI = this;
return hr;
}*/
STDMETHOD (Unadvise) (DWORD dwCookie);
/*{
HRESULT hr = CProxy_IDonutPEvents<CAPI>::Unadvise(dwCookie);
if (SUCCEEDED(hr))
g_pAPI = NULL;
return hr;
}*/
STDMETHOD (GetPanelWebBrowserObject) ( /*[out, retval]*/ IDispatch * *pVal)
{
*pVal = NULL;
if (!g_pMainWnd)
return S_OK;
*pVal = g_pMainWnd->ApiGetPanelWebBrowserObject();
return S_OK;
}
STDMETHOD (GetPanelWindowObject) ( /*[out, retval]*/ IDispatch * *pVal)
{
*pVal = NULL;
if (!g_pMainWnd)
return S_OK;
*pVal = g_pMainWnd->ApiGetPanelWindowObject();
return S_OK;
}
STDMETHOD (GetPanelDocumentObject) ( /*[out, retval]*/ IDispatch * *pVal)
{
*pVal = NULL;
if (!g_pMainWnd)
return S_OK;
*pVal = g_pMainWnd->ApiGetPanelDocumentObject();
return S_OK;
}
STDMETHOD (GetTabState) (int nIndex, /*[out, retval]*/ long *pVal)
{
*pVal = 0;
if (!g_pMainWnd)
return S_OK;
*pVal = g_pMainWnd->ApiGetTabState(nIndex);
return S_OK;
}
STDMETHOD (ShowPanelBar) ()
{
if (!g_pMainWnd)
return S_OK;
g_pMainWnd->ApiShowPanelBar();
return S_OK;
}
STDMETHOD (MessageBox) (BSTR bstrText, BSTR bstrCaption, UINT uType, /*[out, retval]*/ long *pVal)
{
if (!g_pMainWnd)
return S_OK;
CString strText(bstrText);
CString strCaption(bstrCaption);
*pVal = ::MessageBox(g_pMainWnd->m_hWnd, strText, strCaption, uType);
return S_OK;
}
STDMETHOD (NewWindow) (BSTR bstrURL, BOOL bActive, /*[out, retval]*/ long *pVal)
{
if (!g_pMainWnd)
return S_OK;
*pVal = g_pMainWnd->ApiNewWindow(bstrURL, bActive);
return S_OK;
}
STDMETHOD (MoveToTab) (WORD wBefor, WORD wAfter)
{
if (!g_pMainWnd)
return S_OK;
g_pMainWnd->ApiMoveToTab(wBefor, wAfter);
return S_OK;
}
STDMETHOD (GetTabCount) ( /*[out, retval]*/ long *pVal)
{
if (!g_pMainWnd)
return S_OK;
*pVal = g_pMainWnd->ApiGetTabCount();
return S_OK;
}
STDMETHOD (get_TabIndex) ( /*[out, retval]*/ long *pVal)
{
if (!g_pMainWnd)
return S_OK;
*pVal = g_pMainWnd->ApiGetTabIndex();
return S_OK;
}
STDMETHOD (put_TabIndex) ( /*[in]*/ long newVal)
{
if (!g_pMainWnd)
return S_OK;
g_pMainWnd->ApiSetTabIndex(newVal);
return S_OK;
}
STDMETHOD (GetWindowObject) (int nIndex, /*[out, retval]*/ IDispatch * *pVal)
{
if (!g_pMainWnd)
return S_OK;
*pVal = g_pMainWnd->ApiGetWindowObject(nIndex);
return S_OK;
}
STDMETHOD (GetDocumentObject) (int nIndex, /*[out, retval]*/ IDispatch * *pVal)
{
if (!g_pMainWnd)
return S_OK;
*pVal = g_pMainWnd->ApiGetDocumentObject(nIndex);
return S_OK;
}
STDMETHOD (GetWebBrowserObject) (int nIndex, /*[out, retval]*/ IDispatch * *pVal)
{
if (!g_pMainWnd)
return S_OK;
*pVal = g_pMainWnd->ApiGetWebBrowserObject(nIndex);
return S_OK;
}
STDMETHOD (Close) (int nIndex)
{
if (!g_pMainWnd)
return S_OK;
g_pMainWnd->ApiClose(nIndex);
return S_OK;
}
//IAPI2 by minit
STDMETHOD (ExecuteCommand) (int nCommand)
{
if (!g_pMainWnd)
return S_OK;
g_pMainWnd->ApiExecuteCommand(nCommand);
return S_OK;
}
STDMETHOD (GetSearchText) ( /*[out, retval]*/ BSTR * pbstrText)
{
if (!g_pMainWnd)
return S_OK;
g_pMainWnd->ApiGetSearchText(pbstrText);
return S_OK;
}
STDMETHOD (SetSearchText) (BSTR bstrText)
{
if (!g_pMainWnd)
return S_OK;
g_pMainWnd->ApiSetSearchText(bstrText);
return S_OK;
}
STDMETHOD (GetAddressText) ( /*[out, retval]*/ BSTR * pbstrText)
{
if (!g_pMainWnd)
return S_OK;
g_pMainWnd->ApiGetAddressText(pbstrText);
return S_OK;
}
STDMETHOD (SetAddressText) (BSTR bstrText)
{
if (!g_pMainWnd)
return S_OK;
g_pMainWnd->ApiSetAddressText(bstrText);
return S_OK;
}
STDMETHOD (GetExtendedTabState) (int nIndex, /*[out, retval]*/ long *pVal)
{
if (!g_pMainWnd)
return S_OK;
*pVal = g_pMainWnd->ApiGetExtendedTabState(nIndex);
return S_OK;
}
STDMETHOD (SetExtendedTabState) (int nIndex, long nState)
{
if (!g_pMainWnd)
return S_OK;
g_pMainWnd->ApiSetExtendedTabState(nIndex, nState);
return S_OK;
}
STDMETHOD (GetKeyState) (int nKey, /*[out, retval]*/ long *pVal)
{
if (!g_pMainWnd)
return S_OK;
*pVal = g_pMainWnd->ApiGetKeyState(nKey);
return S_OK;
}
STDMETHOD (GetProfileInt) (BSTR bstrFile, BSTR bstrSection, BSTR bstrKey, int nDefault, /*[out, retval]*/ long *pVal)
{
if (!g_pMainWnd)
return S_OK;
*pVal = g_pMainWnd->ApiGetProfileInt(bstrFile, bstrSection, bstrKey, nDefault);
return S_OK;
}
STDMETHOD (WriteProfileInt) (BSTR bstrFile, BSTR bstrSection, BSTR bstrKey, int nValue)
{
if (!g_pMainWnd)
return S_OK;
g_pMainWnd->ApiWriteProfileInt(bstrFile, bstrSection, bstrKey, nValue);
return S_OK;
}
STDMETHOD (GetProfileString) (BSTR bstrFile, BSTR bstrSection, BSTR bstrKey, BSTR bstrDefault, /*[out, retval]*/ BSTR * pbstrText)
{
if (!g_pMainWnd)
return S_OK;
g_pMainWnd->ApiGetProfileString(bstrFile, bstrSection, bstrKey, bstrDefault, pbstrText);
return S_OK;
}
STDMETHOD (WriteProfileString) (BSTR bstrFile, BSTR bstrSection, BSTR bstrKey, BSTR bstrText)
{
if (!g_pMainWnd)
return S_OK;
g_pMainWnd->ApiWriteProfileString(bstrFile, bstrSection, bstrKey, bstrText);
return S_OK;
}
STDMETHOD (GetScriptFolder) ( /*[out, retval]*/ BSTR * pbstrFolder)
{
if (!g_pMainWnd)
return S_OK;
g_pMainWnd->ApiGetScriptFolder(pbstrFolder);
return S_OK;
}
STDMETHOD (GetCSSFolder) ( /*[out, retval]*/ BSTR * pbstrFolder)
{
if (!g_pMainWnd)
return S_OK;
g_pMainWnd->ApiGetCSSFolder(pbstrFolder);
return S_OK;
}
STDMETHOD (GetBaseFolder) ( /*[out, retval]*/ BSTR * pbstrFolder)
{
if (!g_pMainWnd)
return S_OK;
g_pMainWnd->ApiGetBaseFolder(pbstrFolder);
return S_OK;
}
STDMETHOD (GetExePath) ( /*[out, retval]*/ BSTR * pbstrPath)
{
if (!g_pMainWnd)
return S_OK;
g_pMainWnd->ApiGetExePath(pbstrPath);
return S_OK;
}
STDMETHOD (SetStyleSheet) (int nIndex, BSTR bstrStyleSheet, BOOL bOff)
{
if (!g_pMainWnd)
return S_OK;
g_pMainWnd->ApiSetStyleSheet(nIndex, bstrStyleSheet, bOff);
return S_OK;
}
//IAPI3
STDMETHOD (SaveGroup) (BSTR bstrGroupFile)
{
if (!g_pMainWnd)
return S_OK;
g_pMainWnd->ApiSaveGroup(bstrGroupFile);
return S_OK;
}
STDMETHOD (LoadGroup) (BSTR bstrGroupFile, BOOL bClose)
{
if (!g_pMainWnd)
return S_OK;
g_pMainWnd->ApiLoadGroup(bstrGroupFile, bClose);
return S_OK;
}
STDMETHOD (EncryptString) (BSTR bstrString, BSTR bstrPass, BSTR * bstrRet)
{
return E_NOTIMPL; //未実装
}
STDMETHOD (DecryptString) (BSTR bstrString, BSTR * bstrRet)
{
return E_NOTIMPL; //未実装
}
STDMETHOD (InputBox) (BSTR bstrTitle, BSTR bstrDescript, BSTR bstrDefault, int nFlag, long *pVal)
{
return E_NOTIMPL; //未実装
}
STDMETHOD (NewWindow3) (BSTR bstrURL, BOOL bActive, long ExStyle, const int *pHistInfo, long *pVal)
{
if (!g_pMainWnd)
return S_OK;
*pVal = g_pMainWnd->ApiNewWindow3(bstrURL, bActive, ExStyle, (void *) pHistInfo);
return S_OK;
}
STDMETHOD (AddGroupItem) (BSTR bstrGroupFile, int nIndex, long *pVal)
{
if (!g_pMainWnd)
return S_OK;
*pVal = g_pMainWnd->ApiAddGroupItem(bstrGroupFile, nIndex);
return S_OK;
}
STDMETHOD (DeleteGroupItem) (BSTR bstrGroupFile, int nIndex, long *pVal)
{
if (!g_pMainWnd)
return S_OK;
*pVal = g_pMainWnd->ApiDeleteGroupItem(bstrGroupFile, nIndex);
return S_OK;
}
//IAPI4
STDMETHOD (GetHWND) (long nType, LONG_PTR * pVal)
{
if (!g_pMainWnd)
return S_OK;
*pVal = (LONG_PTR) g_pMainWnd->ApiGetHWND(nType);
return S_OK;
}
};
#endif //__API_H_
| [
"[email protected]"
]
| [
[
[
1,
514
]
]
]
|
b6f817dd67cdfb9b44fe6cbf0c1f1c5d4d5fecb8 | a30b091525dc3f07cd7e12c80b8d168a0ee4f808 | /EngineAll/Utility/DialogInterface.cpp | f01ccfcce8b82ae18f34bf7a99c8feecbef04a87 | []
| no_license | ghsoftco/basecode14 | f50dc049b8f2f8d284fece4ee72f9d2f3f59a700 | 57de2a24c01cec6dc3312cbfe200f2b15d923419 | refs/heads/master | 2021-01-10T11:18:29.585561 | 2011-01-23T02:25:21 | 2011-01-23T02:25:21 | 47,255,927 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,213 | cpp | #include "..\\..\\Main.h"
#include "DialogInterface.h"
bool DialogInterface::GetSaveFilename(String &Result, const String &Title)
{
Result.ReSize(1024);
Result[0] = '\0';
OPENFILENAME Info;
Info.lStructSize = sizeof(OPENFILENAME);
Info.hwndOwner = NULL;
Info.hInstance = NULL;
Info.lpstrFilter = NULL;
Info.lpstrCustomFilter = NULL;
Info.nMaxCustFilter = 0;
Info.nFilterIndex = 0;
Info.lpstrFile = Result.CString();
Info.nMaxFile = 1023;
Info.lpstrFileTitle = NULL;
Info.nMaxFileTitle = 0;
Info.lpstrInitialDir = NULL;
Info.lpstrTitle = Title.CString();
Info.Flags = 0;
Info.nFileOffset = 0;
Info.nFileExtension = 0;
Info.lpstrDefExt = NULL;
Info.lCustData = NULL;
Info.lpfnHook = NULL;
Info.lpTemplateName = NULL;
Info.pvReserved = NULL;
Info.dwReserved = NULL;
Info.FlagsEx = 0;
char SavedWorkingDirectory[512];
GetCurrentDirectory(512, SavedWorkingDirectory);
BOOL Return = GetSaveFileName(&Info);
SetCurrentDirectory(SavedWorkingDirectory);
return (Return != 0);
}
bool DialogInterface::GetOpenFilename(String &Result, const String &Title)
{
Result.ReSize(1024);
Result[0] = '\0';
OPENFILENAME Info;
Info.lStructSize = sizeof(OPENFILENAME);
Info.hwndOwner = NULL;
Info.hInstance = NULL;
Info.lpstrFilter = NULL;
Info.lpstrCustomFilter = NULL;
Info.nMaxCustFilter = 0;
Info.nFilterIndex = 0;
Info.lpstrFile = Result.CString();
Info.nMaxFile = 1023;
Info.lpstrFileTitle = NULL;
Info.nMaxFileTitle = 0;
Info.lpstrInitialDir = NULL;
Info.lpstrTitle = Title.CString();
Info.Flags = 0;
Info.nFileOffset = 0;
Info.nFileExtension = 0;
Info.lpstrDefExt = NULL;
Info.lCustData = NULL;
Info.lpfnHook = NULL;
Info.lpTemplateName = NULL;
Info.pvReserved = NULL;
Info.dwReserved = NULL;
Info.FlagsEx = 0;
char SavedWorkingDirectory[512];
GetCurrentDirectory(512, SavedWorkingDirectory);
BOOL Return = GetOpenFileName(&Info);
SetCurrentDirectory(SavedWorkingDirectory);
return (Return != 0);
}
| [
"zhaodongmpii@7e7f00ea-7cf8-66b5-cf80-f378872134d2"
]
| [
[
[
1,
76
]
]
]
|
a936255b16e2acf09fd2249fb0b846260a9f6704 | 018ded69bef54d0c92c05922dd14bf2b835e0c1a | /IOtest/IOtest2/main.cpp | 18aceea36334560c911b6cfef467742590c927df | []
| no_license | JerryAi/gamepipe-arcade-ui | adfd3f90f1e2bd2c2ed2e0773f8ed3f39bb51eed | bfb630db752b7c6dec6abf8b06fe037d95ab68db | refs/heads/master | 2021-01-22T07:04:09.313697 | 2010-04-16T02:08:30 | 2010-04-16T02:08:30 | 39,057,009 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,915 | cpp | #include<windows.h>
#include<stdio.h>
#include"WinIo.h"
#include <iostream>
#define KBC_CMD 0x64
#define KBC_DATA 0x60
void KBCWait4IBE()
{
DWORD dwVal=0;
do
{
GetPortVal(KBC_CMD,&dwVal,1);
}
while((&dwVal)&&(0x2)==0);
//while((dwVal)&(0x2)==0);
//while(!(dwVal & 0x1));
}
void kbcWait4OBF()
{
DWORD dwVal=0;
do
{
GetPortVal(KBC_CMD,&dwVal,1);
}
while(!(dwVal & 0x1));
}
void KEY_DOWN(int vk_in)
{
int myscancode;
myscancode=MapVirtualKey(byte(vk_in),0);
//std::cout<<char(myscancode)<<std::endl;
KBCWait4IBE();
SetPortVal(KBC_CMD,0xD2,1);
KBCWait4IBE();
SetPortVal(KBC_DATA,0xE2,1);
KBCWait4IBE();
SetPortVal(KBC_CMD,0xD2,1);
KBCWait4IBE();
SetPortVal(KBC_DATA,myscancode,1);
}
void KEY_UP(int vk_in)
{
int myscancode;
myscancode=MapVirtualKey(byte(vk_in),0);
KBCWait4IBE();
SetPortVal(KBC_CMD,0xD2,1);
KBCWait4IBE();
SetPortVal(KBC_DATA,0xE0,1);
KBCWait4IBE();
SetPortVal(KBC_CMD,0xD2,1);
KBCWait4IBE();
SetPortVal(KBC_DATA,(myscancode|0x80),1);
}
void main()
{
bool br,br1;
//br=InitializeWinIo(); //in NT/XP no need
//if (br==false)
//{
// MessageBox(NULL,"初始化winio失败,程序自动关闭,请您不用担心~","XD友情提示1",MB_OK);
// ShutdownWinIo();
// exit(0);
//}
br1=InstallWinIoDriver("WinIo.sys");
if(br1==false)
{
printf("Failed!!!");
RemoveWinIoDriver();
ShutdownWinIo();
exit(0);
}
printf("Successfully Installed1!!! press Enter to continue...");
getchar();
InitializeWinIo();
printf("Successfully Installed!!! press Enter to continue...");
getchar();
for (int ii=0;ii<=100;ii++)
{
KEY_DOWN(32);//模拟按键
//KBCWait4IBE();
Sleep(200);
KEY_UP(32);//
//std::cout<<"run once"<<std::endl;
}
printf("done!!!");
getchar();
RemoveWinIoDriver();
ShutdownWinIo();
} | [
"willyujenhuang@c7cd5111-5711-00b0-e4a8-d5dc6a703e49"
]
| [
[
[
1,
100
]
]
]
|
c90a81bc86abafe2555cbc48a234da4245483af0 | 222bc22cb0330b694d2c3b0f4b866d726fd29c72 | /src/brookbox/wm2/WmlVertexShader.inl | c17aa98a9d9d86ef029e71f8bd5a2b89c729c068 | [
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | darwin/inferno | 02acd3d05ca4c092aa4006b028a843ac04b551b1 | e87017763abae0cfe09d47987f5f6ac37c4f073d | refs/heads/master | 2021-03-12T22:15:47.889580 | 2009-04-17T13:29:39 | 2009-04-17T13:29:39 | 178,477 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,857 | inl | // 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.
//----------------------------------------------------------------------------
inline Shader::ShaderType VertexShader::GetType () const
{
return VERTEX_SHADER;
}
//----------------------------------------------------------------------------
inline bool VertexShader::NeedsNormals ()
{
return m_iNormalRegHint != NONE;
}
//----------------------------------------------------------------------------
inline bool VertexShader::NeedsColor ()
{
return m_iColorRegHint != NONE;
}
//----------------------------------------------------------------------------
inline bool VertexShader::NeedsTexCoords (int iTexCoordNum)
{
return m_aiTexCoordRegHint[iTexCoordNum] != NONE;
}
//----------------------------------------------------------------------------
inline int VertexShader::GetVertexRegHint ()
{
return m_iVertexRegHint;
}
//----------------------------------------------------------------------------
inline int VertexShader::GetNormalRegHint ()
{
return m_iNormalRegHint;
}
//----------------------------------------------------------------------------
inline int VertexShader::GetColorRegHint ()
{
return m_iColorRegHint;
}
//----------------------------------------------------------------------------
inline int VertexShader::GetTexCoordRegHint (int iTexCoordNum)
{
return m_aiTexCoordRegHint[iTexCoordNum];
}
//----------------------------------------------------------------------------
| [
"[email protected]"
]
| [
[
[
1,
51
]
]
]
|
406cfd79324f31cad8e3e4f862df3d43536ede8d | 3f0690333762888c26c6fe4d5e9034d3b494440e | /codigoEnDesarrollo/Librerias/OOC/util/lib_cpp/LinkedList.hpp | 082927faefd01b74706f3816a00094193c6b126d | []
| no_license | jonyMarino/dhacel-micro-prog-vieja | 56ecdcc6ca2940be7a0c319c8daa6210a876e655 | 1f8f8b1fd08aced557b870e716427d0b5e00618a | refs/heads/master | 2021-01-21T14:12:03.692649 | 2011-08-08T11:36:24 | 2011-08-08T11:36:24 | 34,534,048 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,488 | hpp | #ifndef _LINKED_LIST_HPP
#define _LINKED_LIST_HPP
#include "stddef.h"
#include "nodo.hpp"
#include "Iterator.hpp"
#include "List.hpp"
#include "LinkedList.hpp"
#pragma CODE_SEG LinkedList_CODE
#pragma DATA_SEG LinkedList_DATA
class LinkedList:public List
{
public:
LinkedList();
~LinkedList();
virtual bool add(void *dato);
virtual bool aniadir(void *dato); // agerga un nodo al final de la Lista
/*void addFirst(void * obj);
void addLast(void * obj);
void * getFirst();
void * getLast();
void * removeFirst();
void * removeLast();
*/
unsigned int size(void);
bool contains(void * dato);
void * eliminarPrimero(void);
Iterator * iterator();
virtual void * get(unsigned int index);
bool moveOut(void * dato);
bool isEmpty();
void clear();
// private:
unsigned char differ(LinkedList * _l);
class LinkedListIterator:public Iterator{
public:
LinkedListIterator();
LinkedListIterator(LinkedList * list);
virtual bool hasNext(void);
virtual void *next(void);
private:
Nodo * nodoNext;
friend class LinkedList;
};
void linkedListIterator(LinkedListIterator * it);
protected:
Nodo * getPrimerNodo();
void setPrimerNodo(Nodo *);
private:
Nodo * nodo;
void deleteNodo(Nodo*tmpNodo,Nodo*tmpNodoAnterior);
friend class LinkedListIterator;
};
#pragma CODE_SEG DEFAULT
#pragma DATA_SEG DEFAULT
#endif | [
"jonymarino@9c8ba4ec-7dbd-852f-d911-916fdc55f737"
]
| [
[
[
1,
68
]
]
]
|
8d354b1562e194ddd94fce7e1a6a27b84e221ef5 | 01c236af2890d74ca5b7c25cec5e7b1686283c48 | /Src/PlayerHandGadget.h | 33a847cd3967c40c861f341b65d2a0a0eb6986cf | [
"MIT"
]
| permissive | muffinista/palm-pitch | 80c5900d4f623204d3b837172eefa09c4efbe5e3 | aa09c857b1ccc14672b3eb038a419bd13abc0925 | refs/heads/master | 2021-01-19T05:43:04.740676 | 2010-07-08T14:42:18 | 2010-07-08T14:42:18 | 763,958 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 994 | h | #ifndef __PLAYER_HAND_H__
#define __PLAYER_HAND_H__
#include "Common.h"
#include "Player.h"
#include "Trick.h"
class CPlayerHandGadget : public CGadget {
public:
CPlayerHandGadget();
Boolean OnDraw(Boolean& bVisible);
Boolean OnPenDown(EventType* pEvent, Boolean& bHandled);
Boolean OnPenUp(EventType* pEvent, Boolean& bHandled);
Boolean OnDelete();
void Render();
void Render(Boolean redraw);
void MoveLeft();
void MoveRight();
Boolean Select();
void Reset();
void ResetHighlight();
void DrawHighlight();
void CurrentTrick(Trick *);
Trick *CurrentTrick();
void CurrentPlayer(Player *);
Player *CurrentPlayer();
static Int16 card_width;
static Int16 card_height;
static Int16 card_spacing;
private:
Boolean handling_input;
Int16 screen_x;
Int16 screen_y;
Int8 active_card;
Boolean show_all;
Trick *trk;
Player *p;
RectangleType bounds;
Int16 choice;
};
#endif | [
"[email protected]"
]
| [
[
[
1,
63
]
]
]
|
ff85cedccf8741ce89f4df03d8f6587d9aad37ec | bfe8eca44c0fca696a0031a98037f19a9938dd26 | /detect_fullscreen/detect_fullscreen/stdafx.cpp | cd1b891cd961113ad895298eb6469109cdb31210 | []
| no_license | luge/foolject | a190006bc0ed693f685f3a8287ea15b1fe631744 | 2f4f13a221a0fa2fecab2aaaf7e2af75c160d90c | refs/heads/master | 2021-01-10T07:41:06.726526 | 2011-01-21T10:25:22 | 2011-01-21T10:25:22 | 36,303,977 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 217 | cpp | // stdafx.cpp : source file that includes just the standard includes
// detect_fullscreen.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
| [
"[email protected]@756bb6b0-a119-0410-8338-473b6f1ccd30"
]
| [
[
[
1,
7
]
]
]
|
93bcb6b922a72b63bd438f00b63c59a0b2c1d72b | fd0221edcf44c190efadd6d8b13763ef5bcbc6f6 | /FER-H264/FER-H264/CAVLC.cpp | e178ae54df7da807524fd73e5cf8d3450fc17042 | []
| no_license | zoltanmaric/h264-fer | 2ddb8ac5af293dd1a30d9ca37c8508377745d025 | 695c712a74a75ad96330613e5dd24938e29f96e6 | refs/heads/master | 2021-01-01T15:31:42.218179 | 2010-06-17T21:09:11 | 2010-06-17T21:09:11 | 32,142,996 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,611 | cpp | #include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
using namespace std;
inline int ABS(const int a)
{
if (a>0)
return a;
else
return -a;
}
char zigZagTablica[4][4]={
0,1,5,6,
2,4,7,12,
3,8,11,13,
9,10,14,15
};
char me_table_03[16][2]={
{15 , 0},
{0 , 1},
{7 , 2},
{11 , 4},
{13 , 8},
{14 , 3},
{3 , 5},
{5 , 10},
{10 , 12},
{12 , 15},
{1 , 7},
{2 , 11},
{4 , 13},
{8 , 14},
{6 , 6},
{9 , 9}
};
char me_table_12[48][2]={
{47 , 0},
{31 , 16},
{15 , 1},
{0 , 2},
{23 , 4},
{27 , 8},
{29 , 32},
{30 , 3},
{7 , 5},
{11 , 10},
{13 , 12},
{14 , 15},
{39 , 47},
{43 , 7},
{45 , 11},
{46 , 13},
{16 , 14},
{3 , 6},
{5 , 9},
{10 , 31},
{12 , 35},
{19 , 37},
{21 , 42},
{26 , 44},
{28 , 33},
{35 , 34},
{37 , 36},
{42 , 40},
{44 , 39},
{1 , 43},
{2 , 45},
{4 , 46},
{8 , 17},
{17 , 18},
{18 , 20},
{20 , 24},
{24 , 19},
{6 , 21},
{9 , 26},
{22 , 28},
{25 , 23},
{32 , 27},
{33 , 29},
{34 , 30},
{36 , 22},
{40 , 25},
{38 , 38},
{41 , 41}
};
string run_before[15][7]={
{ "1" , "1" , "11" , "11" , "11" , "11" , "111"},
{ "0" , "01" , "10" , "10" , "10" , "000" , "110"},
{ "-" , "00" , "01" , "01" , "011" , "001" , "101"},
{ "-" , "-" , "00" , "001" , "010" , "011" , "100"},
{ "-" , "-" , "-" , "000" , "001" , "010" , "011"},
{ "-" , "-" , "-" , "-" , "000" , "101" , "010"},
{ "-" , "-" , "-" , "-" , "-" , "100" , "001"},
{ "-" , "-" , "-" , "-" , "-" , "-" , "0001"},
{ "-" , "-" , "-" , "-" , "-" , "00001" , "0001"},
{ "-" , "-" , "-" , "-" , "-" , "-" , "000001"},
{ "-" , "-" , "-" , "-" , "-" , "-" , "0000001"},
{ "-" , "-" , "-" , "-" , "-" , "-" , "00000001"},
{ "-" , "-" , "-" , "-" , "-" , "-" , "000000001"},
{ "-" , "-" , "-" , "-" , "-" , "-" , "0000000001"},
{ "-" , "-" , "-" , "-" , "-" , "-" , "00000000001"}
};
string total_zeros_DC_4x4[8][7]={
{ "1" , "000" , "000" , "110" , "00" , "00" , "0"},
{ "010" , "01" , "001" , "00" , "01" , "01" , "1"},
{ "011" , "001" , "01" , "01" , "10" , "1" , "-"},
{ "0010" , "100" , "10" , "10" , "11" , "-" , "-"},
{ "0011" , "101" , "110" , "111" , "-" , "-" , "-"},
{ "0001" , "110" , "111" , "-" , "-" , "-" , "-"},
{ "00001" , "111" , "-" , "-" , "-" , "-" , "-"},
{ "00000" , "-" , "-" , "-" , "-" , "-" , "-"}
};
string total_zeros_DC_2x2[4][3]={
{"1","1","1"},
{"01","01","0"},
{"001","00","-"},
{"000","-","-"}
};
string total_zeros_8_15[9][6]={
{ "000001" , "000001" , "00001" , "0000" , "0000" , "000"},
{ "0001" , "000000" , "00000" , "0001" , "0001" , "001"},
{ "00001" , "0001" , "001" , "001" , "01" , "1"},
{ "011" , "11" , "11" , "010" , "1" , "01"},
{ "11" , "10" , "10" , "1" , "001" , "-"},
{ "10" , "001" , "01" , "011" , "-" , "-"},
{ "010" , "01" , "0001" , "-" , "-" , "-"},
{ "001" , "00001" , "-" , "-" , "-" , "-"},
{ "000000" , "-" , "-" , "-" , "-" , "-"}
};
string total_zeros_1_7[16][6]={
{ "1" , "111" , "0101" , "00011" , "0101" , "000001"},
{ "011" , "110" , "111" , "111" , "0100" , "00001"},
{ "010" , "101" , "110" , "0101" , "0011" , "111"},
{ "0011" , "100" , "101" , "0100" , "111" , "110"},
{ "0010" , "011" , "0100" , "110" , "110" , "101"},
{ "00011" , "0101" , "0011" , "101" , "101" , "100"},
{ "00010" , "0100" , "100" , "100" , "100" , "011"},
{ "000011" , "0011" , "011" , "0011" , "011" , "010"},
{ "000010" , "0010" , "0010" , "011" , "0010" , "0001"},
{ "0000011" , "00011" , "00011" , "0010" , "00001" , "001"},
{ "0000010" , "00010" , "00010" , "00010" , "0001" , "000000"},
{ "00000011" , "000011" , "000001" , "00001" , "00000" , "-"},
{ "00000010" , "000010" , "00001" , "00000" , "-" , "-"},
{ "000000011" , "000001" , "000000" , "-" , "-" , "-"},
{ "000000010" , "000000" , "-" , "-" , "-" , "-"},
{ "000000001" , "-" , "-" , "-" , "-" , "-"}
};
//Standard, str 234-235
string coeff_token_table[4][17][4]={
"1","11","1111","0000",
"000101","001011","001111","0000",
"00000111","000111","001011","0001",
"000000111","0000111","001000","0010",
"0000000111","00000111","0001111","0011",
"00000000111","00000100","0001011","0100",
"0000000001111","000000111","0001001","0101",
"0000000001011","00000001111","0001000","0110",
"0000000001000","00000001011","00001111","011100",
"00000000001111","000000001111","00001011","100000",
"00000000001011","000000001011","000001111","100100",
"000000000001111","000000001000","000001011","101000",
"000000000001011","0000000001111","000001000","101100",
"0000000000001111","0000000001011","0000001101","110000",
"0000000000001011","0000000000111","0000001001","110100",
"0000000000000111","00000000001001","0000000101","111000",
"0000000000000100","00000000000111","0000000001","111100",
"","","","",
"01","10","1110","0000",
"000100","00111","01111","0001",
"00000110","001010","01100","0010",
"000000110","000110","01010","0011",
"0000000110","0000110","01000","0100",
"00000000110","00000110","001110","0101",
"0000000001110","000000110","001010","0110",
"0000000001010","00000001110","0001110","011101",
"00000000001110","00000001010","00001110","100001",
"00000000001010","000000001110","00001010","100101",
"000000000001110","000000001010","000001110","101001",
"000000000001010","0000000001110","000001010","101101",
"000000000000001","0000000001010","000000111","110001",
"0000000000001110","00000000001011","0000001100","110101",
"0000000000001010","00000000001000","0000001000","111001",
"0000000000000110","00000000000110","0000000100","111101",
"","","","",
"","","","",
"001","011","1101","0001",
"0000101","001001","01110","0010",
"00000101","000101","01011","0011",
"000000101","0000101","01001","0100",
"0000000101","00000101","001101","0101",
"00000000101","000000101","001001","0110",
"0000000001101","00000001101","0001101","011110",
"0000000001001","00000001001","0001010","100010",
"00000000001101","000000001101","00001101","100110",
"00000000001001","000000001001","00001001","101010",
"000000000001101","0000000001101","000001101","101110",
"000000000001001","0000000001001","000001001","110010",
"0000000000001101","0000000000110","0000001011","110110",
"0000000000001001","00000000001010","0000000111","111010",
"0000000000000101","00000000000101","0000000011","111110",
"","","","",
"","","","",
"","","","",
"00011","0101","1100","0010",
"000011","0100","1011","0011",
"0000100","00110","1010","0100",
"00000100","001000","1001","0101",
"000000100","000100","1000","011011",
"0000000100","0000100","01101","011111",
"00000000100","000000100","001100","100011",
"0000000001100","00000001100","0001100","100111",
"00000000001100","00000001000","00001100","101011",
"00000000001000","000000001100","00001000","101111",
"000000000001100","0000000001100","000001100","110011",
"000000000001000","0000000001000","0000001010","110111",
"0000000000001100","0000000000001","0000000110","111011",
"0000000000001000","00000000000100","0000000010","111111"
};
enum expGolombMode {ue=1, se, me, te};
enum macroBlockPrediction {intra_4x4=1, intra_8x8, inter};
enum teRange {bits, fullRange};
int binaryToDecimal(string bitString)
{
int result=0;
for (unsigned int i=0;i<bitString.length();i++)
{
result=(result<<1)+bitString[i];
}
return result;
}
string decimalToBinary(int decimalNumber)
{
string result="";
while (decimalNumber>0)
{
result+=(char)((decimalNumber%2)+48);
}
//Okreni string
char tempC;
for (unsigned int i=0;i<result.length()/2;i++)
{
tempC=result[i];
result[i]=result[result.length()-i-1];
result[result.length()-i-1]=tempC;
}
return result;
}
string expGolomb_Encode(int codeNum)
{
string result="";
//Izracun izraza M=log2(codeNum+1)
int temp=codeNum+1;
int M=0;
while (temp>0)
{
temp=temp>>1;
M++;
}
string INFO=decimalToBinary(codeNum+1-(2<<M));
return result;
}
int expGolomb_Decode(string bitString, expGolombMode mode,int chromaArrayType,macroBlockPrediction mbPrediction,teRange range)
{
int leadingZeros=0,codeNum=0;
for (unsigned int i=0;i<bitString.length();i++)
{
if (bitString[i]=='1' && leadingZeros==0)
leadingZeros=i;
break;
}
if (leadingZeros=0)
{
codeNum=0;
}
else
{
codeNum=(1<<leadingZeros)-1+binaryToDecimal(bitString.substr(leadingZeros+1));
}
switch(mode)
{
case ue:
return codeNum;
case se:
return (-1)*((codeNum+1)%2)*(codeNum+1)/2;
case me:
if ((chromaArrayType==1) || (chromaArrayType==2))
{
return me_table_12[codeNum][mbPrediction];
}
else
{
return me_table_03[codeNum][mbPrediction];
}
case te:
if (range==bits)
return !(bitString[0]);
else
return codeNum;
//Ne smije se dogoditi
default:
cout << "EXP_GOLOMB default mode nije dozvoljen. Mode:" << mode << endl;
return codeNum;
}
}
/*
CAVLC entropijsko kodiranje blokova od 4x4 koeficijenata.
Chroma DC 2x2 block (4:2:0 chroma sampling) i Chroma DC 2x4 block (4:2:2 chroma sampling) nisu podržani.
Njihove prilagođene total_zeros tablice su na 239. strani norme.
*/
string CAVLC_4x4_Encode(int nA, int nB, char tablica[4][4])
{
int totalCoeffs=0,trailingOnes=0,nC=0;
string rezultat="";
string T1Predznaci="";
bool trailing_ones_sign_flag[3];
int runBefore[16],run[16];
char level[16],coeffLevel[16];
for (int i=0;i<16;i++)
{
runBefore[i]=0;
run[i]=0;
coeffLevel[i]=0;
}
//za ulaz 4x4
int brElem=16;
//Standard, str 233
if (nA==-1 || nB ==-1)
{
nC=nA+nB;
}
else
{
nC=(nA+nB+1)>>1;
}
//Stvori zigzag niz iz tablice i izbroj koeficijente, postavi runbefore niz
char zigZagNiz[16];
char coeffArray[16];
int nuleIspredKoeficijenta=0;
for (int i=0;i<4;i++)
for (int j=0;j<4;j++)
{
zigZagNiz[zigZagTablica[i][j]]=tablica[i][j];
if (zigZagNiz[zigZagTablica[i][j]]==0)
{
nuleIspredKoeficijenta++;
}
else
{
coeffArray[totalCoeffs++]=tablica[i][j];
runBefore[totalCoeffs++]=nuleIspredKoeficijenta;
nuleIspredKoeficijenta=0;
}
}
//Izbroji koliko ima +/-1 elemenata na kraju niza i zapiši predznake u T1Predznake (obrnuti redoslijed)
for (int i=15;i>=0;i--)
{
if (zigZagNiz[i]==1 || zigZagNiz[i]==-1)
{
T1Predznaci+=((zigZagNiz[i]==-1)?"-1":"1");
trailing_ones_sign_flag[trailingOnes]=(zigZagNiz[i]==-1);
trailingOnes++;
}
else if (zigZagNiz[i]!=0)
break;
}
//Ovisno o broju koeficijenata i jedinica na kraju niza, odredi kodnu riječ.
if (nC>=0 && nC<2)
{
rezultat+=coeff_token_table[trailingOnes][totalCoeffs][0];
}
else if (nC>=2 && nC<4)
{
rezultat+=coeff_token_table[trailingOnes][totalCoeffs][1];
}
else if (nC>=4 && nC<8)
{
rezultat+=coeff_token_table[trailingOnes][totalCoeffs][2];
}
else if (nC>=8)
{
rezultat+=coeff_token_table[trailingOnes][totalCoeffs][3];
}
//Ubaci kodove predznaka trailing jedinica
rezultat+=T1Predznaci;
//Standard, str 78, kodiranje koeficijenata
int suffixLength=0;
string tempStr="";
int brojacTrailingOnes=0,levelCode=0,level_prefix,level_suffix;
unsigned int spBorder;
if (totalCoeffs>0)
{
if (totalCoeffs>10 && trailingOnes<3)
{
suffixLength=1;
}
else
{
suffixLength=0;
}
for (int i=0;i<totalCoeffs;i++)
{
if (i<trailingOnes)
{
level[i]=1-2*trailing_ones_sign_flag[brojacTrailingOnes++];
}
else
{
tempStr=expGolomb_Encode(coeffArray[i]);
//Dodavanje kôda pojedinog level-a na konačni bitstream
rezultat+=tempStr;
spBorder=tempStr.find('1');
level_prefix=spBorder;
level_suffix=binaryToDecimal(tempStr.substr(spBorder));
suffixLength=spBorder; //TODO: SuffixLength==PrefixLength?
levelCode=((15<level_prefix)?15:level_prefix)<<suffixLength;
if (suffixLength>0 || level_prefix>=14)
{
levelCode+=level_suffix;
}
if (level_prefix>=15 && suffixLength==0)
{
levelCode+=15;
}
if (level_prefix>=16)
{
levelCode+=(1<<(level_prefix-3))-4096;
}
if (i==trailingOnes && trailingOnes<3)
{
levelCode+=2;
}
if (levelCode%2 == 0)
{
level[i]=(levelCode+2)>>1;
}
else
{
level[i]=(-levelCode-1)>>1;
}
if (suffixLength==0)
{
suffixLength=1;
}
if (ABS(level[i])>(3<<(suffixLength-1)) && suffixLength<6)
suffixLength++;
}
}
int zerosLeft,coeffNum;
if (totalCoeffs<brElem)
{
zerosLeft=brElem-totalCoeffs;
}
else
{
zerosLeft=0;
}
if (totalCoeffs<7)
{
rezultat+=total_zeros_1_7[zerosLeft][totalCoeffs];
}
else
{
rezultat+=total_zeros_8_15[zerosLeft][totalCoeffs];
}
for (int i=0;i<totalCoeffs-1;i++) //TODO: treba li -1?
{
if (zerosLeft>0)
{
if (zerosLeft<7)
{
rezultat+=run_before[runBefore[i]][zerosLeft];
}
else
{
rezultat+=run_before[runBefore[i]][6];
}
run[i]=runBefore[i];
}
else
{
run[i]=0;
}
zerosLeft=zerosLeft-run[i];
}
run[totalCoeffs-1]=zerosLeft;
coeffNum=-1;
for (int i=totalCoeffs-1;i>=0;i--)
{
coeffNum+=run[i]+1;
coeffLevel[coeffNum]=level[i];
}
}
return rezultat;
}
int _tmain(int argc, _TCHAR* argv[])
{
//Formatiranje coeff tablice, prvi i drugi dio
/*
ofstream iz2;
iz2.open("tablica-formatirano.txt");
for (int i=0;i<4;i++)
for (int j=0;j<17;j++)
{
for (int k=0;k<4;k++)
{
iz2 << "\"" << coeff_token_table[i][j][k] << "\",";
}
iz2 << endl;
}
iz2.close();
ulaz.close();
ifstream ulaz;
ofstream iz;
iz.open("tablica-neformatirano.txt");
string linija;
string a[6];
ulaz.open("tablica.txt");
while (getline(ulaz,linija))
{
istringstream parser(linija);
for (int i=0;i<6;i++)
parser>>a[i];
for (int i=2;i<6;i++)
iz << "coeff_token_table[" << a[0] << "][" << a[1] << "][" << i-2 << "]=\"" << a[i] << "\";" << endl;
}
iz.close();
ulaz.close();
*/
ifstream ulaz;
ofstream iz;
iz.open("ZERO.txt");
string linija;
string a[8];
ulaz.open("totalzeros5.txt");
while (getline(ulaz,linija))
{
istringstream parser(linija);
for (int i=0;i<8;i++)
parser>>a[i];
iz << "{ \"" << a[1] << "\" , \"" << a[2] << "\" , \"" << a[3] <<"\" , \"" << a[4] << "\" , \"" << a[5] << "\" , \"" << a[6] << "\" , \"" << a[7] << "\"}," << endl;
}
iz.close();
ulaz.close();
return 0;
}
| [
"[email protected]@9f3bdf0a-daf3-11de-b590-7f2b5bfbe1fd"
]
| [
[
[
1,
598
]
]
]
|
5b0356fc12fd611df937f8508bc2f13a630b7a80 | 41371839eaa16ada179d580f7b2c1878600b718e | /UVa/Volume II/00297.cpp | 6213f0e02b83d8eafeaf477f7647850704bb03d9 | []
| no_license | marinvhs/SMAS | 5481aecaaea859d123077417c9ee9f90e36cc721 | 2241dc612a653a885cf9c1565d3ca2010a6201b0 | refs/heads/master | 2021-01-22T16:31:03.431389 | 2009-10-01T02:33:01 | 2009-10-01T02:33:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,442 | cpp | /////////////////////////////////
// 00297 - Quadtrees
/////////////////////////////////
#include<cstdio>
#include<cstring>
char t1[1370],t2[1370],tree[1370];
unsigned int black_pixels,I,K,l1,l2,tnum,tree_idx;
unsigned int pixels[] = {1024,256,64,16,4,1};
void fuse(char a, char b){
if(a == 'p'){
if(b == 'e'){
tree[tree_idx++] = 'p', I++;
for(int i = 0; i < 4; i++) tree[tree_idx++] = t1[I++];
K++;
}
else if(b == 'f') tree[tree_idx++] = 'f', I+=5, K++;
else {
tree[tree_idx++] = 'p', I++, K++;
for(int i = 0; i < 4; i++) fuse(t1[I],t2[K]);
}
} else if(a == 'e'){
if(b == 'p'){
tree[tree_idx++] = 'p', K++;
for(int i = 0; i < 4; i++) tree[tree_idx++] = t2[K++];
I++;
} else tree[tree_idx++] = t2[K], I++, K++;
} else {
tree[tree_idx++] = 'f', I++, K++;
if(b == 'p') K+=4;
}
}
void analyze(int depth){
if(I == tree_idx) return;
if(tree[I] == 'p'){
//printf("its a parent, depth increased!\n");
for(int i = 0; i < 4; i++) I++,analyze(depth+1);
}
else black_pixels += ((tree[I]-'e')*pixels[depth]);
}
int main(void){
scanf("%u\n",&tnum);
while(tnum--){
gets(t1); gets(t2);
//printf("fusing: %s\n\t%s\n",t1,t2);
l1 = strlen(t1); l2 = strlen(t2);
for(tree_idx = I = K = 0; I < l1 && K < l2; ) fuse(t1[I],t2[K]);
tree[tree_idx] = 0;
//printf("result: %s\n",tree);
I = black_pixels = 0;
analyze(0);
printf("There are %u black pixels.\n",black_pixels);
}
return 0;
}
| [
"[email protected]"
]
| [
[
[
1,
54
]
]
]
|
7e5c487d38e37a2bd290d91bf473fb59cd5302af | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/mw/websrv/web_service_manager_api/inc/SenServiceManagerBCTest.h | 37b449fc4f232e684111e1eaac171bad782fc287 | []
| 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 | 15,135 | h | /*
* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: SenServiceManager_stif test module.
*
*/
#ifndef SENSERVICEMANAGERBCTEST_H
#define SENSERVICEMANAGERBCTEST_H
// INCLUDES
#include "StifTestModule.h"
#include <StifLogger.h>
#include <SenServiceManager.h>
#include <SenIdentityProvider.h>
#include <SenXmlServiceDescription.h>
#include <SenServiceConnection.h>
#include <f32file.h>
// INTERNAL INCLUDES
namespace{
_LIT16(KSessionsFile,"c:\\private\\101f96f4\\SenSessions.xml");
_LIT16(KIdentitiesFile,"c:\\private\\101f96f4\\senidentities.xml");
_LIT8(KText,"text");
_LIT8(KText2,"text2");
}
// CONSTANTS
//const ?type ?constant_var = ?constant;
// MACROS
//#define ?macro ?macro_def
#define TEST_MODULE_VERSION_MAJOR 30
#define TEST_MODULE_VERSION_MINOR 9
#define TEST_MODULE_VERSION_BUILD 38
// Logging path
_LIT( KSenServiceManager_stifLogPath, "\\logs\\testframework\\SenServiceManager_stif\\" );
// Log file
_LIT( KSenServiceManager_stifLogFile, "SenServiceManager_stif.txt" );
#define GETPTR &
#define ENTRY(str,func) {_S(str), GETPTR func,0,0,0}
#define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0}
#define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c}
#define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c}
// FUNCTION PROTOTYPES
//?type ?function_name(?arg_list);
// FORWARD DECLARATIONS
//class ?FORWARD_CLASSNAME;
class CSenServiceManagerBCTest;
// DATA TYPES
//enum ?declaration
//typedef ?declaration
//extern ?data_type;
// A typedef for function that does the actual testing,
// function is a type
// TInt CSenServiceManagerBCTest::<NameOfFunction> ( TTestResult& aResult )
typedef TInt (CSenServiceManagerBCTest::* TestFunction)(TTestResult&);
// CLASS DECLARATION
/**
* An internal structure containing a test case name and
* the pointer to function doing the test
*
* @lib ?library
* @since ?Series60_version
*/
class TCaseInfoInternal
{
public:
const TText* iCaseName;
TestFunction iMethod;
TBool iIsOOMTest;
TInt iFirstMemoryAllocation;
TInt iLastMemoryAllocation;
};
// CLASS DECLARATION
/**
* A structure containing a test case name and
* the pointer to function doing the test
*
* @lib ?library
* @since ?Series60_version
*/
class TCaseInfo
{
public:
TPtrC iCaseName;
TestFunction iMethod;
TBool iIsOOMTest;
TInt iFirstMemoryAllocation;
TInt iLastMemoryAllocation;
TCaseInfo( const TText* a ) : iCaseName( (TText*) a )
{
};
};
// CLASS DECLARATION
/**
* This a SenServiceManager_stif class.
* ?other_description_lines
*
* @lib ?library
* @since ?Series60_version
*/
NONSHARABLE_CLASS(CSenServiceManagerBCTest) : public CTestModuleBase
{
public: // Constructors and destructor
/**
* Two-phased constructor.
*/
static CSenServiceManagerBCTest* NewL();
/**
* Destructor.
*/
virtual ~CSenServiceManagerBCTest();
public: // New functions
/**
* ?member_description.
* @since ?Series60_version
* @param ?arg1 ?description
* @return ?description
*/
//?type ?member_function( ?type ?arg1 );
public: // Functions from base classes
/**
* From CTestModuleBase InitL is used to initialize the
* SenServiceManager_stif. It is called once for every instance of
* TestModuleSenServiceManager_stif after its creation.
* @since ?Series60_version
* @param aIniFile Initialization file for the test module (optional)
* @param aFirstTime Flag is true when InitL is executed for first
* created instance of SenServiceManager_stif.
* @return Symbian OS error code
*/
TInt InitL( TFileName& aIniFile, TBool aFirstTime );
/**
* From CTestModuleBase GetTestCasesL is used to inquiry test cases
* from SenServiceManager_stif.
* @since ?Series60_version
* @param aTestCaseFile Test case file (optional)
* @param aTestCases Array of TestCases returned to test framework
* @return Symbian OS error code
*/
TInt GetTestCasesL( const TFileName& aTestCaseFile,
RPointerArray<TTestCaseInfo>& aTestCases );
/**
* From CTestModuleBase RunTestCaseL is used to run an individual
* test case.
* @since ?Series60_version
* @param aCaseNumber Test case number
* @param aTestCaseFile Test case file (optional)
* @param aResult Test case result returned to test framework (PASS/FAIL)
* @return Symbian OS error code (test case execution error, which is
* not reported in aResult parameter as test case failure).
*/
TInt RunTestCaseL( const TInt aCaseNumber,
const TFileName& aTestCaseFile,
TTestResult& aResult );
/**
* From CTestModuleBase; OOMTestQueryL is used to specify is particular
* test case going to be executed using OOM conditions
* @param aTestCaseFile Test case file (optional)
* @param aCaseNumber Test case number (optional)
* @param aFailureType OOM failure type (optional)
* @param aFirstMemFailure The first heap memory allocation failure value (optional)
* @param aLastMemFailure The last heap memory allocation failure value (optional)
* @return TBool
*/
virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */,
const TInt /* aCaseNumber */,
TOOMFailureType& aFailureType,
TInt& /* aFirstMemFailure */,
TInt& /* aLastMemFailure */ );
/**
* From CTestModuleBase; OOMTestInitializeL may be used to initialize OOM
* test environment
* @param aTestCaseFile Test case file (optional)
* @param aCaseNumber Test case number (optional)
* @return None
*/
virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */,
const TInt /* aCaseNumber */ );
/**
* From CTestModuleBase; OOMHandleWarningL
* @param aTestCaseFile Test case file (optional)
* @param aCaseNumber Test case number (optional)
* @param aFailNextValue FailNextValue for OOM test execution (optional)
* @return None
*
* User may add implementation for OOM test warning handling. Usually no
* implementation is required.
*/
virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */,
const TInt /* aCaseNumber */,
TInt& /* aFailNextValue */);
/**
* From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM
* test environment
* @param aTestCaseFile Test case file (optional)
* @param aCaseNumber Test case number (optional)
* @return None
*
*/
virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */,
const TInt /* aCaseNumber */ );
/**
* Method used to log version of test class
*/
void SendTestModuleVersion();
protected: // New functions
/**
* ?member_description.
* @since ?Series60_version
* @param ?arg1 ?description
* @return ?description
*/
//?type ?member_function( ?type ?arg1 );
protected: // Functions from base classes
/**
* From ?base_class ?member_description
*/
//?type ?member_function();
private:
/**
* C++ default constructor.
*/
CSenServiceManagerBCTest();
/**
* By default Symbian 2nd phase constructor is private.
*/
void ConstructL();
// Prohibit copy constructor if not deriving from CBase.
// ?classname( const ?classname& );
// Prohibit assigment operator if not deriving from CBase.
// ?classname& operator=( const ?classname& );
/**
* Function returning test case name and pointer to test case function.
* @since ?Series60_version
* @param aCaseNumber test case number
* @return TCaseInfo
*/
const TCaseInfo Case ( const TInt aCaseNumber ) const;
private: // methods
void Empty();
void SetupL();
void Teardown();
void DeleteDBL();
TInt UT_CSenServiceManager_NewLL(TTestResult& aResult);
TInt UT_CSenServiceManager_NewLCL(TTestResult& aResult);
TInt UT_CSenServiceManager_ServiceDescriptionsLL_normalL(TTestResult& aResult);
TInt UT_CSenServiceManager_ServiceDescriptionsLL_notFoundL(TTestResult& aResult);
TInt UT_CSenServiceManager_ServiceDescriptionsLL_badDescriptorL(TTestResult& aResult);
TInt UT_CSenServiceManager_ServiceDescriptionsLL_nullL(TTestResult& aResult);
TInt UT_CSenServiceManager_ServiceDescriptionsLL_randomPtrL(TTestResult& aResult);
TInt UT_CSenServiceManager_ServiceDescriptionsL_1L_normalL(TTestResult& aResult);
TInt UT_CSenServiceManager_ServiceDescriptionsL_1L_notFoundL(TTestResult& aResult);
TInt UT_CSenServiceManager_ServiceDescriptionsL_1L_badDescriptorL(TTestResult& aResult);
TInt UT_CSenServiceManager_ServiceDescriptionsL_1L_XMLpatternL(TTestResult& aResult);
TInt UT_CSenServiceManager_RegisterServiceDescriptionLL_normalL(TTestResult& aResult);
TInt UT_CSenServiceManager_RegisterServiceDescriptionLL_badDescriptorL(TTestResult& aResult);
TInt UT_CSenServiceManager_RegisterServiceDescriptionLL_noEndpointL(TTestResult& aResult);
TInt UT_CSenServiceManager_RegisterServiceDescriptionLL_noContractL(TTestResult& aResult);
TInt UT_CSenServiceManager_RegisterServiceDescriptionLL_badFrameworkL(TTestResult& aResult);
TInt UT_CSenServiceManager_RegisterServiceDescriptionLL_randomPtrL(TTestResult& aResult);
TInt UT_CSenServiceManager_RegisterServiceDescriptionLL_nullL(TTestResult& aResult);
TInt UT_CSenServiceManager_UnregisterServiceDescriptionLL_normalL(TTestResult& aResult);
TInt UT_CSenServiceManager_UnregisterServiceDescriptionLL_badDescriptorL(TTestResult& aResult);
TInt UT_CSenServiceManager_UnregisterServiceDescriptionLL_noEndpointL(TTestResult& aResult);
TInt UT_CSenServiceManager_UnregisterServiceDescriptionLL_noContractL(TTestResult& aResult);
TInt UT_CSenServiceManager_UnregisterServiceDescriptionLL_badFrameworkL(TTestResult& aResult);
TInt UT_CSenServiceManager_UnregisterServiceDescriptionLL_randomPtrL(TTestResult& aResult);
TInt UT_CSenServiceManager_UnregisterServiceDescriptionLL_nullL(TTestResult& aResult);
TInt UT_CSenServiceManager_RegisterIdentityProviderLL_normalL(TTestResult& aResult);
TInt UT_CSenServiceManager_RegisterIdentityProviderLL_badDescriptorL(TTestResult& aResult);
TInt UT_CSenServiceManager_RegisterIdentityProviderLL_notReadyL(TTestResult& aResult);
TInt UT_CSenServiceManager_RegisterIdentityProviderLL_providerIDInUseL(TTestResult& aResult);
TInt UT_CSenServiceManager_RegisterIdentityProviderLL_nullL(TTestResult& aResult);
TInt UT_CSenServiceManager_RegisterIdentityProviderLL_randomPtrL(TTestResult& aResult);
TInt UT_CSenServiceManager_UnregisterIdentityProviderLL_normalL(TTestResult& aResult);
TInt UT_CSenServiceManager_UnregisterIdentityProviderLL_badDescriptorL(TTestResult& aResult);
TInt UT_CSenServiceManager_UnregisterIdentityProviderLL_notFoundL(TTestResult& aResult);
TInt UT_CSenServiceManager_UnregisterIdentityProviderLL_notReadyL(TTestResult& aResult);
TInt UT_CSenServiceManager_UnregisterIdentityProviderLL_nullL(TTestResult& aResult);
TInt UT_CSenServiceManager_UnregisterIdentityProviderLL_randomPtrL(TTestResult& aResult);
TInt UT_CSenServiceManager_AssociateServiceLL_normalL(TTestResult& aResult);
TInt UT_CSenServiceManager_AssociateServiceLL_argumentL(TTestResult& aResult);
TInt UT_CSenServiceManager_AssociateServiceLL_notReadyL(TTestResult& aResult);
TInt UT_CSenServiceManager_AssociateServiceLL_notFoundL(TTestResult& aResult);
TInt UT_CSenServiceManager_DissociateServiceLL_normalL(TTestResult& aResult);
TInt UT_CSenServiceManager_DissociateServiceLL_argumentL(TTestResult& aResult);
TInt UT_CSenServiceManager_DissociateServiceLL_notReadyL(TTestResult& aResult);
TInt UT_CSenServiceManager_DissociateServiceLL_notFoundL(TTestResult& aResult);
private: // Data
CSenServiceManager* iServiceManager;
CSenXmlServiceDescription* iSenXmlServiceDescription;
CSenIdentityProvider* iProvider;
RFs iFsSession;
CActiveScheduler* iActiveScheduler;
public: // Data
// ?one_line_short_description_of_data
//?data_declaration;
protected: // Data
// ?one_line_short_description_of_data
//?data_declaration;
private: // Data
// Pointer to test (function) to be executed
TestFunction iMethod;
// Pointer to logger
CStifLogger * iLog;
// ?one_line_short_description_of_data
//?data_declaration;
// Reserved pointer for future extension
//TAny* iReserved;
public: // Friend classes
//?friend_class_declaration;
protected: // Friend classes
//?friend_class_declaration;
private: // Friend classes
//?friend_class_declaration;
};
#endif // SENSERVICEMANAGERBCTEST_H
// End of File | [
"none@none"
]
| [
[
[
1,
406
]
]
]
|
a4526dec4df8d31661c8dd8ef851df3f70ca0aaf | 138a353006eb1376668037fcdfbafc05450aa413 | /source/Munny.cpp | 27236552718fa7e81a4eae6de40fc26222572c38 | []
| no_license | sonicma7/choreopower | 107ed0a5f2eb5fa9e47378702469b77554e44746 | 1480a8f9512531665695b46dcfdde3f689888053 | refs/heads/master | 2020-05-16T20:53:11.590126 | 2009-11-18T03:10:12 | 2009-11-18T03:10:12 | 32,246,184 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 292 | cpp | #include "Munny.h"
#include "ModelEntity.h"
#include "Ogre.h"
Munny::Munny(GameServices *gs, Ogre::SceneNode *parentNode, const Ogre::Vector3 &pos, const Ogre::String &name, const Ogre::String &modelFile)
:ModelEntity(gs, parentNode, pos, name, modelFile){
}
Munny::~Munny(){
} | [
"Sonicma7@0822fb10-d3c0-11de-a505-35228575a32e"
]
| [
[
[
1,
12
]
]
]
|
e2ca37f8c948143212a3360fb83c543759ee8397 | 3e69b159d352a57a48bc483cb8ca802b49679d65 | /tags/release-2006-01-16/pcbnew/gen_self.h | 1053f381b4aab8ab320659606fc9353d596552da | []
| no_license | BackupTheBerlios/kicad-svn | 4b79bc0af39d6e5cb0f07556eb781a83e8a464b9 | 4c97bbde4b1b12ec5616a57c17298c77a9790398 | refs/heads/master | 2021-01-01T19:38:40.000652 | 2006-06-19T20:01:24 | 2006-06-19T20:01:24 | 40,799,911 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,961 | h | /****************************************************/
/* Gestion des composants specifiques aux microndes */
/* Generation d'une self */
/****************************************************/
/* Fichier GEN_SELF.H */
/* Fonctions locales */
static void Exit_Self(WinEDA_DrawFrame * frame, wxDC *DC);
static EDGE_MODULE * gen_arc(EDGE_MODULE * PtSegm, int cX, int cY, int angle);
static void ShowCadreSelf(WinEDA_DrawPanel * panel, wxDC * DC, bool erase);
/* structures locales */
class SELFPCB // Definition d'une self constituee par une piste
{
public:
int forme; // Serpentin, spirale ..
int orient; // 0..3600
int valeur; // Valeur de la self
wxPoint m_Start;
wxPoint m_End; // Coord du point de depart et d'arrivee
wxSize m_Size;
D_PAD * pt_pad_start, *pt_pad_end; // Pointeurs sur les pads d'extremite
int lng; // Longueur de la piste constituant la self
int m_Width; // m_Size.xur de la piste
int nbrin; // Parametres de calcul: nombre de brins
int lbrin; // longueur du brin
int rayon; // Rayon des raccords entre brins
int delta; // distance aux pads
};
/* Variables locales */
static SELFPCB Mself;
static int Self_On;
static int Bl_X0, Bl_Y0 , Bl_Xf, Bl_Yf; // Coord du cadre insrcivant la self
/*************************************************************************/
static void ShowCadreSelf(WinEDA_DrawPanel * panel, wxDC * DC, bool erase)
/*************************************************************************/
/* Routine d'affichage a l'ecran du cadre de la self */
{
int deltaX, deltaY;
/* Calcul de l'orientation et de la taille de la fenetre:
- orient = vert ou Horiz ( dimension max)
- Size.x = Size.y / 2
*/
GRSetDrawMode(DC, GR_XOR);
if( erase)/* effacement du cadre */
{
GRRect( & panel->m_ClipBox, DC, Bl_X0, Bl_Y0, Bl_Xf, Bl_Yf, YELLOW);
}
deltaX = (panel->GetScreen()->m_Curseur.x - Mself.m_Start.x) / 4;
deltaY = (panel->GetScreen()->m_Curseur.y - Mself.m_Start.y) / 4;
Mself.orient = 900;
if( abs(deltaX) > abs(deltaY) ) Mself.orient = 0;
if(Mself.orient == 0)
{
Bl_X0 = Mself.m_Start.x;
Bl_Y0 = Mself.m_Start.y - deltaX;
Bl_Xf = panel->GetScreen()->m_Curseur.x;
Bl_Yf = Mself.m_Start.y + deltaX;
}
else
{
Bl_X0 = Mself.m_Start.x - deltaY;
Bl_Y0 = Mself.m_Start.y;
Bl_Xf = Mself.m_Start.x + deltaY;
Bl_Yf = panel->GetScreen()->m_Curseur.y;
}
GRRect( & panel->m_ClipBox, DC, Bl_X0, Bl_Y0, Bl_Xf, Bl_Yf,YELLOW);
}
/*************************************************/
void Exit_Self(WinEDA_DrawFrame * frame, wxDC *DC)
/*************************************************/
/* Routine de fermeture de l'application : ferme les commandes en cours */
{
if(Self_On)
{
Self_On = 0;
frame->m_CurrentScreen->ManageCurseur(frame->DrawPanel, DC, 0); /* efface cadre */
frame->m_CurrentScreen->ManageCurseur = NULL;
frame->m_CurrentScreen->ForceCloseManageCurseur = NULL;
}
}
/*******************************************/
void WinEDA_PcbFrame::Begin_Self( wxDC *DC)
/*******************************************/
/*
Routine d'initialisation d'un trace de self
*/
{
if ( Self_On )
{
Genere_Self(DC);
return;
}
Mself.m_Start = GetScreen()->m_Curseur;
Self_On = 1;
/* Mise a jour de l'origine des coord relatives */
GetScreen()->m_O_Curseur = GetScreen()->m_Curseur;
Affiche_Status_Box();
Bl_X0 = Mself.m_Start.x; Bl_Y0 = Mself.m_Start.y;
Bl_Xf = Bl_X0; Bl_Yf = Bl_Y0;
m_CurrentScreen->ManageCurseur = ShowCadreSelf;
m_CurrentScreen->ForceCloseManageCurseur = Exit_Self;
m_CurrentScreen->ManageCurseur(DrawPanel, DC, 0); /* Affiche cadre */
}
/**********************************************/
MODULE * WinEDA_PcbFrame::Genere_Self( wxDC *DC)
/**********************************************/
/* Genere une self en forme de serpentin
- longueur Mself.lng
- Extremites Mself.m_Start et Mself.m_End
- Contrainte: m_Start.x = m_End.x ( self verticale )
ou m_Start.y = m_End.y ( self horizontale )
On doit determiner:
Mself.nbrin = nombre de segments perpendiculaires a la direction
( le serpention aura nbrin + 1 demicercles + 2 1/4 de cercle)
Mself.lbrin = longueur d'un brin
Mself.rayon = rayon des parties arrondies du serpentin
Mself.delta = segments raccord entre extremites et le serpention lui meme
Les equations sont
Mself.m_Size.x = 2*Mself.rayon + Mself.lbrin
Mself.m_Size.y = 2*Mself.delta + 2*Mself.nbrin*Mself.rayon
Mself.lng = 2*Mself.delta // Raccords au serpentin
+ (Mself.nbrin-2) * Mself.lbrin //longueur des brins sauf 1er et dernier
+ (Mself.nbrin+1) * ( PI * Mself.rayon) // longueur des arrondis
+ Mself.lbrin/2 - Melf.rayon*2) // longueur du 1er et dernier brin
Les contraintes sont:
nbrin >= 2
Mself.rayon < Mself.m_Size.x
Mself.m_Size.y = Mself.rayon*4 + 2*Mself.raccord
Mself.lbrin > Mself.rayon *2
Le calcul est conduit de la facon suivante:
Initialement:
nbrin = 2
rayon = 4 * m_Size.x (valeur fixe arbitraire)
puis:
on augmente le nombre de brins jusqu'a la longueur desiree
( le rayon est diminue si necessaire )
*/
{
EDGE_MODULE * PtSegm, * LastSegm, *FirstSegm, * newedge;
MODULE * Module;
D_PAD * PtPad;
int ii, ll, lextbrin;
float fcoeff;
bool abort = FALSE;
wxString msg;
m_CurrentScreen->ManageCurseur(DrawPanel, DC, FALSE); /* efface cadre */
m_CurrentScreen->ManageCurseur = NULL;
m_CurrentScreen->ForceCloseManageCurseur = NULL;
if(Self_On == 0)
{
DisplayError(this, wxT("Starting point not init..")); return NULL;
}
Self_On = 0;
Mself.m_End = m_CurrentScreen->m_Curseur;
/* Agencement des parametres pour simplifier le calcul : */
/* le point de depart doit avoir la coord depart < celle du point de fin */
if(Mself.orient == 0) // Self horizontale
{
Mself.m_End.y = Mself.m_Start.y;
if(Mself.m_Start.x > Mself.m_End.x) EXCHG(Mself.m_Start.x,Mself.m_End.x);
Mself.m_Size.y = Mself.m_End.x - Mself.m_Start.x;
Mself.lng = Mself.m_Size.y;
}
else // Self verticale
{
Mself.m_End.x = Mself.m_Start.x;
if(Mself.m_Start.y > Mself.m_End.y) EXCHG(Mself.m_Start.y,Mself.m_End.y);
Mself.m_Size.y = Mself.m_End.y - Mself.m_Start.y;
Mself.lng = Mself.m_Size.y;
}
/* Entree de la vraie longueur desiree */
if( ! UnitMetric )
{
fcoeff = 10000.0 ;
msg.Printf( wxT("%1.4f"), Mself.lng /fcoeff);
abort = Get_Message(_("Length(inch):"),msg, this);
}
else
{
fcoeff = 10000.0/25.4 ;
msg.Printf( wxT("%2.3f"), Mself.lng /fcoeff);
abort = Get_Message( _("Length(mm):"),msg, this);
}
if ( abort ) return NULL;
double fval;
if ( ! msg.ToDouble(&fval) )
{
DisplayError(this, _("Incorrect number, abort"));
return NULL;
}
Mself.lng = (int) round( fval * fcoeff );
/* Controle des valeurs ( ii = valeur minimale de la longueur */
if( Mself.lng < Mself.m_Size.y )
{
DisplayError(this, _("Requested length < minimum length"));
return NULL;
}
/* Generation du composant: calcul des elements de la self */
Mself.m_Width = g_DesignSettings.m_CurrentTrackWidth;
Mself.m_Size.x = Mself.m_Size.y / 2 ;
// Choix d'une Valeur de depart raisonnable pour le rayon des arcs de cercle
Mself.rayon = min(Mself.m_Width * 5, Mself.m_Size.x/4);
/* Calcul des parametres */
for ( Mself.nbrin = 2 ; ; Mself.nbrin++)
{
Mself.delta = (Mself.m_Size.y - ( Mself.rayon * 2 * Mself.nbrin ) ) / 2 ;
if(Mself.delta < Mself.m_Size.y / 10) // C.a.d. si m_Size.yeur self > m_Size.yeur specifiee
{ // Reduction du rayon des arrondis
Mself.delta = Mself.m_Size.y / 10;
Mself.rayon = (Mself.m_Size.y - 2*Mself.delta) / ( 2 * Mself.nbrin) ;
if(Mself.rayon < Mself.m_Width)
{ // Rayon vraiment trop petit...
Affiche_Message(_("Unable to create line: Requested length is too big"));
return NULL;
}
}
Mself.lbrin = Mself.m_Size.x - (Mself.rayon * 2);
lextbrin = (Mself.lbrin/2) - Mself.rayon;
ll = 2 * lextbrin ; // Longueur du 1er et dernier brin
ll += 2 * Mself.delta ; // Longueur des raccord au serpentin
ll += Mself.nbrin * (Mself.lbrin - 2); // longueur des autres brins
ll += ((Mself.nbrin+1) * 314 * Mself.rayon) /100 ;
msg.Printf( _("Segm count = %d, Lenght = "), Mself.nbrin);
wxString stlen;
valeur_param(ll, stlen); msg += stlen;
Affiche_Message(msg);
if ( ll >= Mself.lng) break;
}
/* Generation du composant : le calcul est fait self Verticale */
if( Create_1_Module(DC, wxEmptyString) == NULL ) return NULL;
Module = m_Pcb->m_Modules;
Module->m_LibRef = wxT("MuSelf");
Module->m_Attributs = MOD_VIRTUAL | MOD_CMS;
Module->m_Flags = 0;
Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR);
/* Generation des elements speciaux: drawsegments */
LastSegm = (EDGE_MODULE*) Module->m_Drawings;
if( LastSegm ) while( LastSegm->Pnext) LastSegm = (EDGE_MODULE*)LastSegm->Pnext;
FirstSegm = PtSegm = new EDGE_MODULE(Module);
if (LastSegm )
{
LastSegm->Pnext = PtSegm;
PtSegm->Pback = LastSegm;
}
else
{
Module->m_Drawings = PtSegm; PtSegm->Pback = Module;
}
PtSegm->m_Start = Mself.m_Start;
PtSegm->m_End.x = Mself.m_Start.x;
PtSegm->m_End.y = PtSegm->m_Start.y + Mself.delta;
PtSegm->m_Width = Mself.m_Width;
PtSegm->m_Layer = Module->m_Layer;
PtSegm->m_Shape = S_SEGMENT;
newedge = new EDGE_MODULE(Module);
newedge->Copy(PtSegm);
newedge->AddToChain(PtSegm);
PtSegm = newedge;
PtSegm->m_Start = PtSegm->m_End;
PtSegm = gen_arc(PtSegm,PtSegm->m_End.x - Mself.rayon, PtSegm->m_End.y, -900);
if(lextbrin)
{
newedge = new EDGE_MODULE(Module);
newedge->Copy(PtSegm);
newedge->AddToChain(PtSegm);
PtSegm = newedge;
PtSegm->m_Start = PtSegm->m_End;
PtSegm->m_End.x -= lextbrin;
}
/* Trace du serpentin */
for (ii = 1 ; ii < Mself.nbrin; ii++)
{
int arc_angle;
newedge = new EDGE_MODULE(Module);
newedge->Copy(PtSegm);
newedge->AddToChain(PtSegm);
PtSegm = newedge;
PtSegm->m_Start = PtSegm->m_End;
if( ii & 1) /* brin d'ordre impair : cercles de sens > 0 */
arc_angle = 1800;
else arc_angle = -1800;
PtSegm = gen_arc(PtSegm, PtSegm->m_End.x,
PtSegm->m_End.y + Mself.rayon, arc_angle);
if( ii < Mself.nbrin-1)
{
newedge = new EDGE_MODULE(Module);
newedge->Copy(PtSegm);
newedge->AddToChain(PtSegm);
PtSegm = newedge;
PtSegm->m_Start = PtSegm->m_End;
if( ii & 1) PtSegm->m_End.x += Mself.lbrin;
else PtSegm->m_End.x -= Mself.lbrin;
}
}
/* Trace du point final */
if( ii & 1) /* brin final de sens > 0 */
{
if(lextbrin)
{
newedge = new EDGE_MODULE(Module);
newedge->Copy(PtSegm);
newedge->AddToChain(PtSegm);
PtSegm = newedge;
PtSegm->m_Start = PtSegm->m_End;
PtSegm->m_End.x -= lextbrin;
}
newedge = new EDGE_MODULE(Module);
newedge->Copy(PtSegm);
newedge->AddToChain(PtSegm);
PtSegm = newedge;
PtSegm->m_Start.x = PtSegm->m_End.x; PtSegm->m_Start.y = PtSegm->m_End.y;
PtSegm = gen_arc(PtSegm, PtSegm->m_End.x, PtSegm->m_End.y + Mself.rayon, 900);
}
else
{
if(lextbrin)
{
newedge = new EDGE_MODULE(Module);
newedge->Copy(PtSegm);
newedge->AddToChain(PtSegm);
PtSegm = newedge;
PtSegm->m_Start = PtSegm->m_End;
PtSegm->m_End.x += lextbrin;
}
newedge = new EDGE_MODULE(Module);
newedge->Copy(PtSegm);
newedge->AddToChain(PtSegm);
PtSegm = newedge;
PtSegm->m_Start = PtSegm->m_End;
PtSegm = gen_arc(PtSegm, PtSegm->m_End.x, PtSegm->m_End.y + Mself.rayon, -900);
}
newedge = new EDGE_MODULE(Module);
newedge->Copy(PtSegm);
newedge->AddToChain(PtSegm);
PtSegm = newedge;
PtSegm->m_Start = PtSegm->m_End;
PtSegm->m_End = Mself.m_End;
PtSegm->Pnext = NULL;
/* Rotation de la self si le trace doit etre horizontal : */
LastSegm = PtSegm;
if ( Mself.orient == 0)
{
for( PtSegm = FirstSegm; PtSegm != NULL; PtSegm = (EDGE_MODULE*) PtSegm->Pnext )
{
RotatePoint(&PtSegm->m_Start.x, &PtSegm->m_Start.y,
FirstSegm->m_Start.x, FirstSegm->m_Start.y, 900 );
if( PtSegm != LastSegm )
RotatePoint(&PtSegm->m_End.x, &PtSegm->m_End.y,
FirstSegm->m_Start.x, FirstSegm->m_Start.y, 900 );
}
}
/* Modif position ancre */
Module->m_Pos.x = LastSegm->m_End.x; Module->m_Pos.y = LastSegm->m_End.y;
/* Placement des 2 pads sur extremite */
PtPad = new D_PAD(Module);
Module->m_Pads = PtPad; PtPad->Pback = Module;
PtPad->SetPadName( wxT("1") );
PtPad->m_Pos.x = LastSegm->m_End.x; PtPad->m_Pos.y = LastSegm->m_End.y;
PtPad->m_Pos0.x = PtPad->m_Pos.x - Module->m_Pos.x;
PtPad->m_Pos0.y = PtPad->m_Pos.y - Module->m_Pos.y;
PtPad->m_Size.x = PtPad->m_Size.y = LastSegm->m_Width;
PtPad->m_Masque_Layer = g_TabOneLayerMask[LastSegm->m_Layer];
PtPad->m_Attribut = SMD;
PtPad->m_PadShape = CIRCLE;
PtPad->m_Rayon = PtPad->m_Size.x / 2;
D_PAD * newpad = new D_PAD(Module);
newpad->Copy(PtPad);
newpad->AddToChain(PtPad);
PtPad = newpad;
PtPad->SetPadName( wxT("2") );
PtPad->m_Pos.x = FirstSegm->m_Start.x; PtPad->m_Pos.y = FirstSegm->m_Start.y;
PtPad->m_Pos0.x = PtPad->m_Pos.x - Module->m_Pos.x;
PtPad->m_Pos0.y = PtPad->m_Pos.y - Module->m_Pos.y;
/* Modif des positions textes */
Module->Display_Infos(this);
Module->m_Value->m_Pos.x = Module->m_Reference->m_Pos.x = ( FirstSegm->m_Start.x + LastSegm->m_End.x ) /2 ;
Module->m_Value->m_Pos.y = Module->m_Reference->m_Pos.y = ( FirstSegm->m_Start.y + LastSegm->m_End.y ) /2 ;
Module->m_Reference->m_Pos.y -= Module->m_Reference->m_Size.y;
Module->m_Value->m_Pos.y += Module->m_Value->m_Size.y;
Module->m_Reference->m_Pos0.x = Module->m_Reference->m_Pos.x - Module->m_Pos.x;
Module->m_Reference->m_Pos0.y = Module->m_Reference->m_Pos.y - Module->m_Pos.y;
Module->m_Value->m_Pos0.x = Module->m_Value->m_Pos.x - Module->m_Pos.x;
Module->m_Value->m_Pos0.y = Module->m_Value->m_Pos.y - Module->m_Pos.y;
/* Init des Coord locales des segments */
for( PtSegm = FirstSegm; PtSegm != NULL; PtSegm = (EDGE_MODULE*) PtSegm->Pnext )
{
PtSegm->m_Start0.x = PtSegm->m_Start.x - Module->m_Pos.x;
PtSegm->m_Start0.y = PtSegm->m_Start.y - Module->m_Pos.y;
PtSegm->m_End0.x = PtSegm->m_End.x - Module->m_Pos.x;
PtSegm->m_End0.y = PtSegm->m_End.y - Module->m_Pos.y;
}
Module->Set_Rectangle_Encadrement();
Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR);
return Module;
}
/**************************************************************************/
static EDGE_MODULE * gen_arc(EDGE_MODULE * PtSegm, int cX, int cY, int angle)
/**************************************************************************/
/* Genere un arc de EDGE_MODULE :
de centre cX,cY
d'angle "angle"
de point de depart donne dans la structure pointee par PtSegm, qui doit
entre a jour (type,net..)
Retourne un pointeur sur la derniere structure EDGE_MODULE generee
*/
{
int ii, nb_seg;
float alpha, beta, fsin, fcos;
int x0, xr0, y0, yr0;
EDGE_MODULE * newedge;
angle = -angle;
y0 = PtSegm->m_Start.x - cX; x0 = PtSegm->m_Start.y - cY;
nb_seg = (abs(angle)) / 225 ; if(nb_seg == 0) nb_seg = 1 ;
alpha = ( (float)angle * 3.14159 / 1800 ) / nb_seg;
for ( ii = 1 ; ii <= nb_seg ; ii++ )
{
if( ii > 1)
{
newedge = new EDGE_MODULE( (MODULE*) NULL);
newedge->Copy(PtSegm);
newedge->m_Parent = PtSegm->m_Parent;
newedge->AddToChain(PtSegm);
PtSegm = newedge;
PtSegm->m_Start.x = PtSegm->m_End.x; PtSegm->m_Start.y = PtSegm->m_End.y;
}
beta = (alpha * ii);
fcos = cos(beta); fsin = sin(beta);
xr0 = (int)(x0 * fcos + y0 * fsin);
yr0 = (int)(y0 * fcos - x0 * fsin);
PtSegm->m_End.x = cX + yr0; PtSegm->m_End.y = cY + xr0 ;
}
return( PtSegm );
}
| [
"bokeoa@244deca0-f506-0410-ab94-f4f3571dea26"
]
| [
[
[
1,
510
]
]
]
|
1f3be61c950e9661298ffa189fbe57bf80e08026 | fac8de123987842827a68da1b580f1361926ab67 | /inc/physics/Physics/Collide/Shape/Compound/Collection/Mesh/hkpMeshMaterial.h | f1fade237b0326b993814613c3b742ed8c0a0829 | []
| no_license | blockspacer/transporter-game | 23496e1651b3c19f6727712a5652f8e49c45c076 | 083ae2ee48fcab2c7d8a68670a71be4d09954428 | refs/heads/master | 2021-05-31T04:06:07.101459 | 2009-02-19T20:59:59 | 2009-02-19T20:59:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,773 | h | /*
*
* Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's
* prior written consent.This software contains code, techniques and know-how which is confidential and proprietary to Havok.
* Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2008 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
*
*/
#ifndef HK_MESH_MATERIAL_H
#define HK_MESH_MATERIAL_H
#include <Common/Base/hkBase.h>
extern const hkClass hkpMeshMaterialClass;
/// A simple base class for the material info for hkMeshShapes.
/// Ideally you would subclass this class, add more info.
/// As the mesh allows for any kind of striding information, the mesh
/// can work directly in on your material lib
class hkpMeshMaterial
{
public:
HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_COLLIDE, hkpMeshMaterial );
HK_DECLARE_REFLECTION();
hkUint32 m_filterInfo;
};
#endif // HK_MESH_MATERIAL_H
/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20080529)
*
* Confidential Information of Havok. (C) Copyright 1999-2008
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates
* acceptance of the End User licence Agreement for this product. A copy of
* the license is included with this software and is also available at
* www.havok.com/tryhavok
*
*/
| [
"uraymeiviar@bb790a93-564d-0410-8b31-212e73dc95e4"
]
| [
[
[
1,
48
]
]
]
|
40b9655fe0508b6191267ae782600564b2940e0e | 38794c3c38c9c9abfd7206ad353aaae0c0b33f18 | /Trab1_a_Inicial/Room.cpp | 8534c3395341caa7a62fadc83b216b5cb39366e3 | []
| no_license | Highvolt/laig-part1 | 37e765cb2705b206c36f987e255ab453abf00dfb | 0e07a6fc2c086f49131907767c463d298ff72b1f | refs/heads/master | 2021-01-10T20:26:08.520711 | 2011-09-21T11:29:09 | 2011-09-21T11:29:09 | 32,182,761 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,105 | cpp | #include "Room.h"
#include <stdio.h>
#define PI 3.1415926535897932384626433
double room_height=25.0;
double ratio=1.74;
double small_wall=46.0;
double small_wall_part1=small_wall*0.6;
double door_height=room_height/2;
double door_width=small_wall*0.25;
double big_wall_width=small_wall*ratio;
void draw_room(double x,double y,double z){
draw_backwall(x,y,z);
draw_curve_wall(x+small_wall,y,z,10);
}
void draw_backwall(double x, double y, double z){
glBegin(GL_POLYGON);
glNormal3d(0.0,0.0,1.0); // esta normal fica comum aos 4 vertices
glVertex3d(x, y, z);
glVertex3d(x,y+room_height , z);
glVertex3d(x+small_wall_part1, y+room_height, z);
glVertex3d(x+small_wall_part1, y, z);
glEnd();
glBegin(GL_POLYGON);
glNormal3d(0.0,0.0,1.0); // esta normal fica comum aos 4 vertices
glVertex3d(x+small_wall_part1, y+door_height, z);
glVertex3d(x+small_wall_part1,y+room_height , z);
glVertex3d(x+small_wall_part1+door_width, y+room_height, z);
glVertex3d(x+small_wall_part1+door_width, y+door_height, z);
glEnd();
glBegin(GL_POLYGON);
glNormal3d(0.0,0.0,1.0); // esta normal fica comum aos 4 vertices
glVertex3d(x+small_wall_part1+door_width, y, z);
glVertex3d(x+small_wall_part1+door_width,y+room_height , z);
glVertex3d(x+small_wall, y+room_height, z);
glVertex3d(x+small_wall, y, z);
glEnd();
}
void draw_curve_wall(double x, double y, double z, int n_steps){
double z_step=big_wall_width/n_steps;
double wave_lenght=PI/big_wall_width;
double z_ant=z;
double x_ant=x;
for(int i=0; i<=n_steps;i++){
double new_x=x+sin(i*z_step*wave_lenght)*10;
double new_z=z+z_step*i;
//printf("anteriores: x:%f z:%f novas: x:%f z:%f\n",x_ant,z_ant,new_x,new_z);
glBegin(GL_POLYGON);
glNormal3d(-1.0,0.0,0.0); // esta normal fica comum aos 4 vertices
glVertex3d(x_ant, y, z_ant);
glVertex3d(x_ant,y+room_height , z_ant);
glVertex3d(new_x, y+room_height, new_z);
glVertex3d(new_x, y, new_z);
glEnd();
z_ant=new_z;
x_ant=new_x;
}
} | [
"[email protected]"
]
| [
[
[
1,
70
]
]
]
|
aac3af73f5f940d3a26ec811b3780338afd19c69 | e776dbbd4feab1ce37ad62e5608e22a55a541d22 | /MMOGame/SGClient/MainFrm.cpp | 8e3a8030d8ca46f649e530b988911c6521aa64c3 | []
| no_license | EmuxEvans/sailing | 80f2e2b0ae0f821ce6da013c3f67edabc8ca91ec | 6d3a0f02732313f41518839376c5c0067aea4c0f | refs/heads/master | 2016-08-12T23:47:57.509147 | 2011-04-06T03:39:19 | 2011-04-06T03:39:19 | 43,952,647 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,675 | cpp | // MainFrm.cpp : implmentation of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "resource.h"
#include "SGClient.h"
#include "AboutDlg.h"
#include "MainView.h"
#include "MainFrm.h"
CMainFrame::CMainFrame()
{
m_nConnection = 0;
}
CMainFrame::~CMainFrame()
{
}
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
if(CFrameWindowImpl<CMainFrame>::PreTranslateMessage(pMsg))
return TRUE;
return m_view.PreTranslateMessage(pMsg);
}
BOOL CMainFrame::OnIdle()
{
UIUpdateToolBar();
MSG msg;
while(!::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
SwitchToThread();
m_view.Tick();
}
return FALSE;
}
void CMainFrame::SetConnection(int nNumber)
{
for(int i=0; i<10; i++) {
UISetCheck(ID_CONN_00+i, i==nNumber?TRUE:FALSE);
}
m_nConnection = nNumber;
}
int CMainFrame::GetConnection()
{
return m_nConnection;
}
LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
// create command bar window
HWND hWndCmdBar = m_CmdBar.Create(m_hWnd, rcDefault, NULL, ATL_SIMPLE_CMDBAR_PANE_STYLE);
// attach menu
m_CmdBar.AttachMenu(GetMenu());
// load command bar images
m_CmdBar.LoadImages(IDR_MAINFRAME);
// remove old menu
SetMenu(NULL);
HWND hWndToolBar = CreateSimpleToolBarCtrl(m_hWnd, IDR_MAINFRAME, FALSE, ATL_SIMPLE_TOOLBAR_PANE_STYLE);
CreateSimpleReBar(ATL_SIMPLE_REBAR_NOBORDER_STYLE);
AddSimpleReBarBand(hWndCmdBar);
AddSimpleReBarBand(hWndToolBar, NULL, TRUE);
CreateSimpleStatusBar();
m_hWndClient = m_view.Create(m_hWnd);
UIAddToolBar(hWndToolBar);
UISetCheck(ID_VIEW_TOOLBAR, 1);
UISetCheck(ID_VIEW_STATUS_BAR, 1);
// register object for message filtering and idle updates
CMessageLoop* pLoop = _Module.GetMessageLoop();
ATLASSERT(pLoop != NULL);
pLoop->AddMessageFilter(this);
pLoop->AddIdleHandler(this);
SetConnection(m_nConnection);
return 0;
}
LRESULT CMainFrame::OnClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
m_view.Clear();
bHandled = FALSE;
return 0L;
}
LRESULT CMainFrame::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
// unregister message filtering and idle updates
CMessageLoop* pLoop = _Module.GetMessageLoop();
ATLASSERT(pLoop != NULL);
pLoop->RemoveMessageFilter(this);
pLoop->RemoveIdleHandler(this);
bHandled = FALSE;
return 1;
}
LRESULT CMainFrame::OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
PostMessage(WM_CLOSE);
return 0;
}
LRESULT CMainFrame::OnFileNew(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
// TODO: add code to initialize document
return 0;
}
LRESULT CMainFrame::OnViewToolBar(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
static BOOL bVisible = TRUE; // initially visible
bVisible = !bVisible;
CReBarCtrl rebar = m_hWndToolBar;
int nBandIndex = rebar.IdToIndex(ATL_IDW_BAND_FIRST + 1); // toolbar is 2nd added band
rebar.ShowBand(nBandIndex, bVisible);
UISetCheck(ID_VIEW_TOOLBAR, bVisible);
UpdateLayout();
return 0;
}
LRESULT CMainFrame::OnViewStatusBar(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
BOOL bVisible = !::IsWindowVisible(m_hWndStatusBar);
::ShowWindow(m_hWndStatusBar, bVisible ? SW_SHOWNOACTIVATE : SW_HIDE);
UISetCheck(ID_VIEW_STATUS_BAR, bVisible);
UpdateLayout();
return 0;
}
LRESULT CMainFrame::OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
CAboutDlg dlg;
dlg.DoModal();
return 0;
}
LRESULT CMainFrame::OnConnClick(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
SetConnection(wID-ID_CONN_00);
return 0;
}
#include "..\Engine\CmdInfo.h"
#include "..\SGCommon\SGCmdSet.h"
CSGCmdSetManage sets;
LRESULT CMainFrame::OnGenHFile(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
CFileDialog a(FALSE, _T("*.h"), _T("out.h"), 0, _T("Include File (*.h)\0*.h\0"));
if(a.DoModal()!=IDOK) return 0;
FILE* fp;
fp = _tfopen(a.m_szFileName, _T("wt"));
if(!fp) return 0;
_ftprintf(fp, _T("\n"));
_ftprintf(fp, _T("#ifdef __OUT_NETHOOK_CALL\n"));
for(int cmd=0; cmd<sets.GetClientCmdSet().GetCmdCount(); cmd++) {
_ftprintf(fp, _T(" virtual void %s("), sets.GetClientCmdSet().GetCmd(cmd)->m_Name);
for(int arg=0; arg<(int)sets.GetClientCmdSet().GetCmd(cmd)->m_Args.size(); arg++) {
if(arg>0) _ftprintf(fp, _T(", "));
switch(sets.GetClientCmdSet().GetCmd(cmd)->m_Args[arg].m_Type&0xfff) {
case CMDARG_TYPE_CHAR: _ftprintf(fp, _T("%s"), _T("char")); break;
case CMDARG_TYPE_SHORT: _ftprintf(fp, _T("%s"), _T("short")); break;
case CMDARG_TYPE_INT: _ftprintf(fp, _T("%s"), _T("int")); break;
case CMDARG_TYPE_BYTE: _ftprintf(fp, _T("%s"), _T("unsigned char")); break;
case CMDARG_TYPE_WORD: _ftprintf(fp, _T("%s"), _T("unsigned short")); break;
case CMDARG_TYPE_DWORD: _ftprintf(fp, _T("%s"), _T("unsigned int")); break;
case CMDARG_TYPE_FLOAT: _ftprintf(fp, _T("%s"), _T("float")); break;
case CMDARG_TYPE_STRING: _ftprintf(fp, _T("%s"), _T("const char*")); break;
case CMDARG_TYPE_STRUCT: _ftprintf(fp, _T("const %s*"), sets.GetClientCmdSet().GetCmd(cmd)->m_Args[arg].m_StructName); break;
}
_ftprintf(fp, _T(" %s"), sets.GetClientCmdSet().GetCmd(cmd)->m_Args[arg].m_Name);
if(sets.GetClientCmdSet().GetCmd(cmd)->m_Args[arg].m_Type&CMDARG_TYPE_ARRAY) {
if(sets.GetClientCmdSet().GetCmd(cmd)->m_Args[arg].m_Type!=CMDARG_TYPE_STRUCT) {
_ftprintf(fp, _T("[]"));
}
}
}
_ftprintf(fp, _T(") {\n"));
_ftprintf(fp, _T(" char __buf[12*1024];\n"));
_ftprintf(fp, _T(" unsigned int __len = 0;\n"));
for(int arg=0; arg<(int)sets.GetClientCmdSet().GetCmd(cmd)->m_Args.size(); arg++) {
if(sets.GetClientCmdSet().GetCmd(cmd)->m_Args[arg].m_Type&CMDARG_TYPE_ARRAY) {
assert(0);
return 0l;
}
switch(sets.GetClientCmdSet().GetCmd(cmd)->m_Args[arg].m_Type) {
case CMDARG_TYPE_CHAR:
_ftprintf(fp, _T(" memcpy(__buf+__len, &%s, sizeof(char));\n"), sets.GetClientCmdSet().GetCmd(cmd)->m_Args[arg].m_Name);
_ftprintf(fp, _T(" __len += sizeof(char);\n"));
break;
case CMDARG_TYPE_SHORT:
_ftprintf(fp, _T(" memcpy(__buf+__len, &%s, sizeof(short));\n"), sets.GetClientCmdSet().GetCmd(cmd)->m_Args[arg].m_Name);
_ftprintf(fp, _T(" __len += sizeof(short);\n"));
break;
case CMDARG_TYPE_INT:
_ftprintf(fp, _T(" memcpy(__buf+__len, &%s, sizeof(int));\n"), sets.GetClientCmdSet().GetCmd(cmd)->m_Args[arg].m_Name);
_ftprintf(fp, _T(" __len += sizeof(int);\n"));
break;
case CMDARG_TYPE_BYTE:
_ftprintf(fp, _T(" memcpy(__buf+__len, &%s, sizeof(unsigned char));\n"), sets.GetClientCmdSet().GetCmd(cmd)->m_Args[arg].m_Name);
_ftprintf(fp, _T(" __len += sizeof(unsigned char);\n"));
break;
case CMDARG_TYPE_WORD:
_ftprintf(fp, _T(" memcpy(__buf+__len, &%s, sizeof(unsigned short));\n"), sets.GetClientCmdSet().GetCmd(cmd)->m_Args[arg].m_Name);
_ftprintf(fp, _T(" __len += sizeof(unsigned short);\n"));
break;
case CMDARG_TYPE_DWORD:
_ftprintf(fp, _T(" memcpy(__buf+__len, &%s, sizeof(unsigned int));\n"), sets.GetClientCmdSet().GetCmd(cmd)->m_Args[arg].m_Name);
_ftprintf(fp, _T(" __len += sizeof(unsigned int);\n"));
break;
case CMDARG_TYPE_FLOAT:
_ftprintf(fp, _T(" memcpy(__buf+__len, &%s, sizeof(float));\n"), sets.GetClientCmdSet().GetCmd(cmd)->m_Args[arg].m_Name);
_ftprintf(fp, _T(" __len += sizeof(float);\n"));
break;
case CMDARG_TYPE_STRING:
_ftprintf(fp, _T(" memcpy(__buf+__len, %s, strlen(%s)+1);\n"), sets.GetClientCmdSet().GetCmd(cmd)->m_Args[arg].m_Name, sets.GetClientCmdSet().GetCmd(cmd)->m_Args[arg].m_Name);
_ftprintf(fp, _T(" __len += (unsigned int)strlen(%s) + 1;\n"), sets.GetClientCmdSet().GetCmd(cmd)->m_Args[arg].m_Name);
break;
case CMDARG_TYPE_STRUCT:
_ftprintf(fp, _T(" memcpy(__buf+__len, &%s, sizeof(%s));\n"), sets.GetClientCmdSet().GetCmd(cmd)->m_Args[arg].m_Name, sets.GetClientCmdSet().GetCmd(cmd)->m_Args[arg].m_StructName);
_ftprintf(fp, _T(" __len += sizeof(%s);\n"), sets.GetClientCmdSet().GetCmd(cmd)->m_Args[arg].m_StructName);
break;
}
}
_ftprintf(fp, _T(" Send(%d, __buf, __len);\n"), sets.GetClientCmdSet().GetCmd(cmd)->m_Code);
_ftprintf(fp, _T(" }\n"));
}
_ftprintf(fp, _T("#endif\n"));
_ftprintf(fp, _T("\n"));
_ftprintf(fp, _T("#ifdef __OUT_NETHOOK_CALLBACK\n"));
for(int cmd=0; cmd<sets.GetServerCmdSet().GetCmdCount(); cmd++) {
_ftprintf(fp, _T(" virtual void %s("), sets.GetServerCmdSet().GetCmd(cmd)->m_Name);
for(int arg=0; arg<(int)sets.GetServerCmdSet().GetCmd(cmd)->m_Args.size(); arg++) {
if(arg>0) _ftprintf(fp, _T(", "));
if(sets.GetServerCmdSet().GetCmd(cmd)->m_Args[arg].m_Type&CMDARG_TYPE_ARRAY) {
_ftprintf(fp, _T("const "));
} else if(sets.GetServerCmdSet().GetCmd(cmd)->m_Args[arg].m_Type==CMDARG_TYPE_STRUCT) {
_ftprintf(fp, _T("const "));
}
switch(sets.GetServerCmdSet().GetCmd(cmd)->m_Args[arg].m_Type&0xfff) {
case CMDARG_TYPE_CHAR: _ftprintf(fp, _T("%s"), _T("char")); break;
case CMDARG_TYPE_SHORT: _ftprintf(fp, _T("%s"), _T("short")); break;
case CMDARG_TYPE_INT: _ftprintf(fp, _T("%s"), _T("int")); break;
case CMDARG_TYPE_BYTE: _ftprintf(fp, _T("%s"), _T("unsigned char")); break;
case CMDARG_TYPE_WORD: _ftprintf(fp, _T("%s"), _T("unsigned short")); break;
case CMDARG_TYPE_DWORD: _ftprintf(fp, _T("%s"), _T("unsigned int")); break;
case CMDARG_TYPE_FLOAT: _ftprintf(fp, _T("%s"), _T("float")); break;
case CMDARG_TYPE_STRING: _ftprintf(fp, _T("%s"), _T("const char*")); break;
case CMDARG_TYPE_STRUCT: _ftprintf(fp, _T("%s*"), sets.GetServerCmdSet().GetCmd(cmd)->m_Args[arg].m_StructName); break;
}
if(sets.GetServerCmdSet().GetCmd(cmd)->m_Args[arg].m_Type&CMDARG_TYPE_ARRAY) {
if((sets.GetServerCmdSet().GetCmd(cmd)->m_Args[arg].m_Type&0xfff)!=CMDARG_TYPE_STRUCT) {
_ftprintf(fp, _T("*"));
}
}
_ftprintf(fp, _T(" %s"), sets.GetServerCmdSet().GetCmd(cmd)->m_Args[arg].m_Name);
}
_ftprintf(fp, _T(") = 0;\n"));
}
_ftprintf(fp, _T("#endif\n"));
_ftprintf(fp, _T("\n"));
_ftprintf(fp, _T("#ifdef __OUT_NETHOOK_DISPATCHER\n"));
_ftprintf(fp, _T("void OnData(const void* __buf, unsigned int __len) {\n"));
_ftprintf(fp, _T(" unsigned int __cur = 2;\n"));
for(int cmd=0; cmd<sets.GetServerCmdSet().GetCmdCount(); cmd++) {
_ftprintf(fp, _T(" if(*((const unsigned short*)__buf)==%d) {\n"), sets.GetServerCmdSet().GetCmd(cmd)->m_Code);
for(int arg=0; arg<(int)sets.GetServerCmdSet().GetCmd(cmd)->m_Args.size(); arg++) {
switch(sets.GetServerCmdSet().GetCmd(cmd)->m_Args[arg].m_Type) {
case CMDARG_TYPE_CHAR:
_ftprintf(fp, _T("\t\tchar a%d = get_%s(__buf, __len, __cur);\n"), arg, _T("char"));
break;
case CMDARG_TYPE_SHORT:
_ftprintf(fp, _T("\t\tshort a%d = get_%s(__buf, __len, __cur);\n"), arg, _T("short"));
break;
case CMDARG_TYPE_INT:
_ftprintf(fp, _T("\t\tint a%d = get_%s(__buf, __len, __cur);\n"), arg, _T("int"));
break;
case CMDARG_TYPE_BYTE:
_ftprintf(fp, _T("\t\tunsigned char a%d = get_%s(__buf, __len, __cur);\n"), arg, _T("byte"));
break;
case CMDARG_TYPE_WORD:
_ftprintf(fp, _T("\t\tunsigned short a%d = get_%s(__buf, __len, __cur);\n"), arg, _T("word"));
break;
case CMDARG_TYPE_DWORD:
_ftprintf(fp, _T("\t\tunsigned int a%d = get_%s(__buf, __len, __cur);\n"), arg, _T("dword"));
break;
case CMDARG_TYPE_FLOAT:
_ftprintf(fp, _T("\t\tfloat a%d = get_%s(__buf, __len, __cur);\n"), arg, _T("float"));
break;
case CMDARG_TYPE_STRING:
_ftprintf(fp, _T("\t\tconst char* a%d = get_string(__buf, __len, __cur);\n"), arg);
break;
case CMDARG_TYPE_STRUCT:
_ftprintf(fp, _T("\t\tconst %s* a%d = (const %s*)get_struct(__buf, __len, __cur, sizeof(%s));\n"),
sets.GetServerCmdSet().GetCmd(cmd)->m_Args[arg].m_StructName,
arg,
sets.GetServerCmdSet().GetCmd(cmd)->m_Args[arg].m_StructName,
sets.GetServerCmdSet().GetCmd(cmd)->m_Args[arg].m_StructName);
break;
case CMDARG_TYPE_CHAR|CMDARG_TYPE_ARRAY:
_ftprintf(fp, _T("\t\tconst char* a%d = get_array_%s(__buf, __len, __cur);\n"), arg, _T("char"));
break;
case CMDARG_TYPE_SHORT|CMDARG_TYPE_ARRAY:
_ftprintf(fp, _T("\t\tconst short* a%d = get_array_%s(__buf, __len, __cur);\n"), arg, _T("short"));
break;
case CMDARG_TYPE_INT|CMDARG_TYPE_ARRAY:
_ftprintf(fp, _T("\t\tconst int* a%d = get_array_%s(__buf, __len, __cur);\n"), arg, _T("int"));
break;
case CMDARG_TYPE_BYTE|CMDARG_TYPE_ARRAY:
_ftprintf(fp, _T("\t\tconst unsigned char* a%d = get_array_%s(__buf, __len, __cur);\n"), arg, _T("byte"));
break;
case CMDARG_TYPE_WORD|CMDARG_TYPE_ARRAY:
_ftprintf(fp, _T("\t\tconst unsigned short* a%d = get_array_%s(__buf, __len, __cur);\n"), arg, _T("word"));
break;
case CMDARG_TYPE_DWORD|CMDARG_TYPE_ARRAY:
_ftprintf(fp, _T("\t\tconst unsigned int* a%d = get_array_%s(__buf, __len, __cur);\n"), arg, _T("dword"));
break;
case CMDARG_TYPE_FLOAT|CMDARG_TYPE_ARRAY:
_ftprintf(fp, _T("\t\tconst float* a%d = get_array_%s(__buf, __len, __cur);\n"), arg, _T("float"));
break;
case CMDARG_TYPE_STRUCT|CMDARG_TYPE_ARRAY:
_ftprintf(fp, _T("\t\tconst %s* a%d = (const %s*)get_array_struct(__buf, __len, __cur, sizeof(%s));\n"),
sets.GetServerCmdSet().GetCmd(cmd)->m_Args[arg].m_StructName,
arg,
sets.GetServerCmdSet().GetCmd(cmd)->m_Args[arg].m_StructName,
sets.GetServerCmdSet().GetCmd(cmd)->m_Args[arg].m_StructName);
break;
}
}
_ftprintf(fp, _T(" %s("), sets.GetServerCmdSet().GetCmd(cmd)->m_Name);
for(int arg=0; arg<(int)sets.GetServerCmdSet().GetCmd(cmd)->m_Args.size(); arg++) {
if(arg==0) {
_ftprintf(fp, _T("a%d"), arg);
} else {
_ftprintf(fp, _T(", a%d"), arg);
}
}
_ftprintf(fp, _T(");\n"));
_ftprintf(fp, _T(" }\n"));
}
_ftprintf(fp, _T("}\n"));
_ftprintf(fp, _T("#endif\n"));
fclose(fp);
return 0;
}
#include "..\Engine\PropertySet.h"
#include "..\Engine\PropertyDB.h"
#include "..\SGCommon\SGData.h"
extern int SGDataDef_GetPropertySetCount();
extern IPropertySet* SGDataDef_GetPropertySet(int nIndex);
extern IPropertySet* SGDataDef_GetPropertySet(const char* pName);
LRESULT CMainFrame::OnGenDBFile(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
CFileDialog a(FALSE, _T("*.sql"), _T("out.sql"), 0, _T("Sql File (*.sql)\0*.sql\0"));
if(a.DoModal()!=IDOK) return 0;
FILE* fp;
char SqlText[1000];
IPropertyDBConnection* pConnection = CreatePropertyDBConnection("");
CPropertyDBTable Table(SGDataDef_GetPropertySet("SGPLAYER_INFO"), "SGPLAYER_INFO", CPropertyDBTable::SINGLE);
fp = _tfopen(a.m_szFileName, _T("wt"));
if(!fp) return 0;
pConnection->CreateTable(&Table, SqlText, sizeof(SqlText));
_fputts(SqlText, fp);
fclose(fp);
SGPLAYER_INFO info;
memset(&info, 0, sizeof(info));
strcpy(info.nick, "welcome");
info.sex = 0;
pConnection->Insert(&Table, 10980, &info);
pConnection->Delete(&Table, 10980);
pConnection->Read(&Table, 10980, &info);
pConnection->Write(&Table, 10980, &info);
pConnection->Release();
return 0;
}
| [
"gamemake@74c81372-9d52-0410-afc2-f743258a769a"
]
| [
[
[
1,
406
]
]
]
|
77bfee9b47534c061036a242b20db92b94a12f3c | 672d939ad74ccb32afe7ec11b6b99a89c64a6020 | /FileSystem/fswizard/MyPropertyPage1.cpp | 2b1ff400e33d8083f4d94e05bae22e37b9fbb442 | []
| no_license | cloudlander/legacy | a073013c69e399744de09d649aaac012e17da325 | 89acf51531165a29b35e36f360220eeca3b0c1f6 | refs/heads/master | 2022-04-22T14:55:37.354762 | 2009-04-11T13:51:56 | 2009-04-11T13:51:56 | 256,939,313 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,835 | cpp | // MyPropertyPage1.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "MyPropertyPage1.h"
#include "NewDiskWizard.h"
#include <fstream.h>
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CNewFileName, CPropertyPage)
IMPLEMENT_DYNCREATE(CNewDiskSize, CPropertyPage)
IMPLEMENT_DYNCREATE(CNewBlockSize, CPropertyPage)
IMPLEMENT_DYNCREATE(CNewFinish, CPropertyPage)
/////////////////////////////////////////////////////////////////////////////
// CNewFileName property page
CNewFileName::CNewFileName() : CPropertyPage(CNewFileName::IDD)
{
//{{AFX_DATA_INIT(CNewFileName)
m_DiskName = _T("");
//}}AFX_DATA_INIT
}
CNewFileName::~CNewFileName()
{
}
void CNewFileName::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CNewFileName)
DDX_Control(pDX, IDC_EDIT1, m_edit);
DDX_Text(pDX, IDC_EDIT1, m_DiskName);
DDV_MaxChars(pDX, m_DiskName, 255);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CNewFileName, CPropertyPage)
//{{AFX_MSG_MAP(CNewFileName)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNewDiskSize property page
CNewDiskSize::CNewDiskSize() : CPropertyPage(CNewDiskSize::IDD)
{
//{{AFX_DATA_INIT(CNewDiskSize)
m_Size = _T("");
temp=24;
//}}AFX_DATA_INIT
}
CNewDiskSize::~CNewDiskSize()
{
}
void CNewDiskSize::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CNewDiskSize)
DDX_Control(pDX, IDC_SLIDER1, m_DiskSize);
DDX_Text(pDX, IDC_DISKSIZE, m_Size);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CNewDiskSize, CPropertyPage)
//{{AFX_MSG_MAP(CNewDiskSize)
ON_WM_HSCROLL()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNewBlockSize property page
CNewBlockSize::CNewBlockSize() : CPropertyPage(CNewBlockSize::IDD)
{
//{{AFX_DATA_INIT(CNewBlockSize)
m_BlockSize = _T("");
temp=0;
//}}AFX_DATA_INIT
}
CNewBlockSize::~CNewBlockSize()
{
}
void CNewBlockSize::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CNewBlockSize)
DDX_Control(pDX, IDC_SLIDER1, m_Slider);
DDX_Text(pDX, IDC_BLOCKSIZE, m_BlockSize);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CNewBlockSize, CPropertyPage)
//{{AFX_MSG_MAP(CNewBlockSize)
ON_WM_HSCROLL()
ON_WM_CANCELMODE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNewFinish property page
CNewFinish::CNewFinish() : CPropertyPage(CNewFinish::IDD)
{
//{{AFX_DATA_INIT(CNewFinish)
m_Finish = _T("");
//}}AFX_DATA_INIT
}
CNewFinish::~CNewFinish()
{
}
void CNewFinish::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CNewFinish)
DDX_Text(pDX, IDC_FINISH, m_Finish);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CNewFinish, CPropertyPage)
//{{AFX_MSG_MAP(CNewFinish)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
LRESULT CNewFileName::OnWizardNext()
{
// TODO: Add your specialized code here and/or call the base class
UpdateData();
CNewDiskWizard* pWizard=(CNewDiskWizard*)GetParent();
if( m_DiskName == ""){ // Disk File can't be empty
AfxMessageBox("Error: Please specify your new disk file name");
m_edit.SetFocus();
return -1;
}
WIN32_FIND_DATA FileData;
HANDLE hSearch;
m_DiskName.Insert(m_DiskName.GetLength(),".VDK");
hSearch = FindFirstFile(m_DiskName, &FileData);
if (GetLastError()==ERROR_FILE_NOT_FOUND)
{
strcpy(pWizard->info.file,m_DiskName);
return CPropertyPage::OnWizardNext();
}else{
if( IDYES == AfxMessageBox("Warning: Overwrite existing disk file?",MB_YESNO)){
if (!FindClose(hSearch))
{
AfxMessageBox("Fatal Error, Please check your settings");
EndDialog(1);
return -1;
}
strcpy(pWizard->info.file,m_DiskName);
return CPropertyPage::OnWizardNext();
}
else{
m_edit.SetFocus();
return -1;
}
}
}
BOOL CNewDiskSize::OnSetActive()
{
// TODO: Add your specialized code here and/or call the base class
CNewDiskWizard* pWizard=(CNewDiskWizard*)GetParent();
pWizard->SetWizardButtons(PSWIZB_BACK|PSWIZB_NEXT);
m_DiskSize.SetRange(17,31);
char str[255];
m_DiskSize.SetPos(24);
pWizard->ChangeTag(24,str);
m_Size.Format(str);
UpdateData(FALSE); // TODO: Add extra initialization here
m_psp.dwFlags &= ~(PSH_HASHELP);
return CPropertyPage::OnSetActive();
}
void CNewDiskSize::CalcWindowRect(LPRECT lpClientRect, UINT nAdjustType)
{
// TODO: Add your specialized code here and/or call the base class
CPropertyPage::CalcWindowRect(lpClientRect, nAdjustType);
}
void CNewDiskSize::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
CNewDiskWizard* pWizard=(CNewDiskWizard*)GetParent();
char str[100];
if(nSBCode == SB_THUMBPOSITION || nSBCode == SB_THUMBTRACK){
pWizard->ChangeTag(nPos,str);
m_Size.Format(str);
UpdateData(FALSE);
temp=nPos;
}
pWizard->info.DiskSize=temp;
CPropertyPage::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CNewBlockSize::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
CNewDiskWizard* pWizard=(CNewDiskWizard*)GetParent();
char str[100];
// Get the minimum and maximum scroll-bar positions.
/*
int minpos;
int maxpos;
pScrollBar->GetScrollRange(&minpos, &maxpos);
maxpos = pScrollBar->GetScrollLimit();
// Get the current position of scroll box.
int curpos = pScrollBar->GetScrollPos();
// Determine the new position of scroll box.
switch (nSBCode)
{
case SB_LEFT: // Scroll to far left.
curpos = minpos;
break;
case SB_RIGHT: // Scroll to far right.
curpos = maxpos;
break;
case SB_ENDSCROLL: // End scroll.
break;
case SB_LINELEFT: // Scroll left.
if (curpos > minpos)
curpos--;
break;
case SB_LINERIGHT: // Scroll right.
if (curpos < maxpos)
curpos++;
break;
case SB_PAGELEFT: // Scroll one page left.
{
// Get the page size.
SCROLLINFO info;
pScrollBar->GetScrollInfo(&info, SIF_ALL);
if (curpos > minpos)
curpos = max(minpos, curpos - (int) info.nPage);
}
break;
case SB_PAGERIGHT: // Scroll one page right.
{
// Get the page size.
SCROLLINFO info;
pScrollBar->GetScrollInfo(&info, SIF_ALL);
if (curpos < maxpos)
curpos = min(maxpos, curpos + (int) info.nPage);
}
break;
case SB_THUMBPOSITION: // Scroll to absolute position. nPos is the position
curpos = nPos; // of the scroll box at the end of the drag
// operation.
break;
case SB_THUMBTRACK: // Drag scroll box to specified position. nPos is
// the
curpos = nPos; // position that the scroll box has been dragged
// to.
break;
}
// Set the new position of the thumb (scroll box).
pScrollBar->SetScrollPos(curpos);
*/
if(nSBCode == SB_THUMBPOSITION || nSBCode == SB_THUMBTRACK){
pWizard->ChangeTag(nPos,str);
m_BlockSize.Format(str);
UpdateData(FALSE);
temp=nPos;
}
pWizard->info.BlockSize=temp;
CPropertyPage::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CNewBlockSize::OnCancelMode()
{
CPropertyPage::OnCancelMode();
// TODO: Add your message handler code here
}
BOOL CNewBlockSize::OnSetActive()
{
// TODO: Add your specialized code here and/or call the base class
CNewDiskWizard* pWizard=(CNewDiskWizard*)GetParent();
pWizard->SetWizardButtons(PSWIZB_BACK|PSWIZB_NEXT);
int DS=(pWizard->info.DiskSize)/2;
temp=DS;
m_Slider.SetRange(8,DS);
m_Slider.SetPos((8+DS)/2);
char str[255];
pWizard->ChangeTag((8+DS)/2,str);
m_BlockSize.Format(str);
UpdateData(FALSE);
m_psp.dwFlags &= ~(PSH_HASHELP);
return CPropertyPage::OnSetActive();
}
LRESULT CNewBlockSize::OnWizardNext()
{
// TODO: Add your specialized code here and/or call the base class
CNewDiskWizard* pWizard=(CNewDiskWizard*)GetParent();
pWizard->info.BlockSize=temp;
return CPropertyPage::OnWizardNext();
}
LRESULT CNewDiskSize::OnWizardNext()
{
// TODO: Add your specialized code here and/or call the base class
CNewDiskWizard* pWizard=(CNewDiskWizard*)GetParent();
pWizard->info.DiskSize=temp;
return CPropertyPage::OnWizardNext();
}
BOOL CNewFinish::OnSetActive()
{
// TODO: Add your specialized code here and/or call the base class
char str[1000];
char str1[1000];
char str2[200];
CNewDiskWizard* pWizard=(CNewDiskWizard*)GetParent();
pWizard->SetWizardButtons(PSWIZB_BACK|PSWIZB_FINISH);
sprintf(str,"Your Disk Name is %s\n\n\n",pWizard->info.file);
pWizard->ChangeTag(pWizard->info.DiskSize,str2);
sprintf(str1,"Your Disk Size is %s\n\n\n",str2);
strcat(str,str1);
pWizard->ChangeTag(pWizard->info.BlockSize,str2);
sprintf(str1,"The Block Size of Your Disk is %s",str2);
strcat(str,str1);
m_Finish.Format(str);
UpdateData(FALSE);
return CPropertyPage::OnSetActive();
}
BOOL CNewFileName::OnSetActive()
{
CNewDiskWizard* pWizard=(CNewDiskWizard*)GetParent();
pWizard->SetWizardButtons(PSWIZB_NEXT);
CButton* pcb=(CButton*)GetParent()->GetDlgItem(IDHELP);
HWND hwnd=pcb->GetSafeHwnd();
::ShowWindow(hwnd,SW_HIDE);
// TODO: Add your specialized code here and/or call the base class
return CPropertyPage::OnSetActive();
}
BOOL CNewFinish::OnWizardFinish()
{
// TODO: Add your specialized code here and/or call the base class
fstream fs;
CNewDiskWizard* pWizard=(CNewDiskWizard*)GetParent();
char file[256];
char* data;
strcpy(file,pWizard->info.file);
fs.open(file,ios::out | ios::binary );
data=new char[1];
*data=0xF7; // magic number
fs.seekp(ios::beg);
fs.write(data,1);
*data=0x01; // not formated
fs.write(data,1);
delete[] data;
data=new char[2];
int i=pWizard->Power(pWizard->info.BlockSize);
memcpy(data,&i,2);
fs.write(data,2);
delete[] data;
data=new char[4];
i=pWizard->Power(pWizard->info.DiskSize);
memcpy(data,&i,4);
fs.write(data,4);
delete[] data;
fs.close();
EndDialog(IDOK);
return CPropertyPage::OnWizardFinish();
}
BOOL CNewFileName::OnInitDialog()
{
CPropertyPage::OnInitDialog();
CButton* pcb=(CButton*)GetDlgItem(IDHELP);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
| [
"xmzhang@5428276e-be0b-f542-9301-ee418ed919ad"
]
| [
[
[
1,
445
]
]
]
|
bc262e4182149f3e437cbad003e54d6aa881c977 | 0b2cb88eece09d91a729fb541aafd26cfa235112 | /src/Game/hero.cpp | 8dad843ed43f0d044a953ab43fe0b364e3fb2fec | []
| no_license | mediogre/ne | f0acf99cd909d91e61b1b86049658b3ed42332a0 | e47fbd08b7d28c2045e5eef57f2533e1be0c3ced | refs/heads/master | 2021-01-18T10:37:31.070343 | 2011-09-21T11:50:10 | 2011-09-21T11:50:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,916 | cpp | #include "hero.h"
#include "editor.h"
#include "bullets.h"
#include "../Utils/fx_creator.h"
C_Hero::C_Hero(irr::IrrlichtDevice* device)
{
Device = device;
KeyMap.push_back(SCamKeyMap(irr::EKA_MOVE_FORWARD, irr::KEY_KEY_W));
KeyMap.push_back(SCamKeyMap(irr::EKA_MOVE_BACKWARD, irr::KEY_KEY_S));
KeyMap.push_back(SCamKeyMap(irr::EKA_STRAFE_LEFT, irr::KEY_KEY_A));
KeyMap.push_back(SCamKeyMap(irr::EKA_STRAFE_RIGHT, irr::KEY_KEY_D));
KeyMap.push_back(SCamKeyMap(irr::EKA_JUMP_UP, irr::KEY_SPACE));
for (irr::u32 i=0; i<6; ++i) CursorKeys[i] = false;
for (irr::u32 i=0; i<3; ++i) MouseKeys[i] = false;
}
C_Hero::~C_Hero()
{
}
void C_Hero::init(C_GameMap* gm)
{
gamemap = gm;
setupHeroModel();
for (irr::u32 i=0; i<6; ++i) CursorKeys[i] = false;
for (irr::u32 i=0; i<3; ++i) MouseKeys[i] = false;
}
bool C_Hero::OnEvent(const irr::SEvent& event)
{
if ( event.EventType == irr::EET_KEY_INPUT_EVENT)
{
for (irr::u32 i=0; i<KeyMap.size(); ++i)
{
if (KeyMap[i].keycode == event.KeyInput.Key)
{
CursorKeys[KeyMap[i].action] = event.KeyInput.PressedDown;
return true;
}
}
}
else if ( event.EventType == irr::EET_MOUSE_INPUT_EVENT)
{
if ( event.MouseInput.Event == irr::EMIE_MOUSE_MOVED )
{
return true;
}
else if ( event.MouseInput.Event == irr::EMIE_LMOUSE_LEFT_UP )
{
if (Editor->testMapClick( event.MouseInput.X, event.MouseInput.Y ))
{
if ( event.MouseInput.Shift )
{
irr::core::vector3df start=sn_rocket->getAbsolutePosition(), end = Editor->posMapClick_f;
end.Y = start.Y = 0.3;
addRocket(Device->getSceneManager(), start, end-start, 0.02f, 3000);
}
else
{
irr::core::vector3df t = Editor->camera.csn->getTarget();
//gamemap->aStar->Reset();
if ( gamemap->getPath( -int(t.X), int(t.Z), -int(Editor->posMapClick.X), int(Editor->posMapClick.Z)) )
{
idxPathNode = 1;
#if _DEBUG
printf("t: %d %d\n", int(t.X), int(t.Z));
gamemap->PrintPath();
#endif
}
}
}
MouseKeys[0] = false;
return true;
}
else if ( event.MouseInput.Event == irr::EMIE_RMOUSE_LEFT_UP )
{
if (Editor->testMapClick( event.MouseInput.X, event.MouseInput.Y ))
{
irr::core::vector3df start=sn_rocket->getAbsolutePosition(), end = Editor->posMapClick_f;
end.Y = start.Y = 0.3;
addRocket(Device->getSceneManager(), start, end-start, 0.02f, 9000);
}
}
else if ( event.MouseInput.Event == irr::EMIE_LMOUSE_PRESSED_DOWN )
{
MouseKeys[0] = true;
return true;
}
}
return false;
}
void C_Hero::setupHeroModel()
{
//sn_hero = Device->getSceneManager()->addAnimatedMeshSceneNode( Device->getSceneManager()->getMesh("./res/mdl/hero.x") );
sn_chassis_1 = Device->getSceneManager()->addAnimatedMeshSceneNode( Device->getSceneManager()->getMesh("./res/mdl/hero/chassis_1.x") );
sn_chassis_1->setMaterialTexture( 0, Device->getVideoDriver()->getTexture("./res/tex/tank/sha r.jpg") );
sn_chassis_1->setMaterialFlag(irr::video::EMF_LIGHTING, false);
sn_chassis_2 = Device->getSceneManager()->addAnimatedMeshSceneNode( Device->getSceneManager()->getMesh("./res/mdl/hero/chassis_2a.x") , sn_chassis_1);
sn_chassis_2->setMaterialTexture( 0, Device->getVideoDriver()->getTexture("./res/tex/tank/sha2.jpg") );
sn_chassis_2->setMaterialFlag(irr::video::EMF_LIGHTING, false);
sn_chassis_2->setFrameLoop(0,8);
sn_chassis_2->setAnimationSpeed(4);
sn_chassis_1->setScale( irr::core::vector3df(0.056, 0.056, 0.056) );
sn_tower = Device->getSceneManager()->addMeshSceneNode( Device->getSceneManager()->getMesh("./res/mdl/hero/tower.x") );
sn_tower->setMaterialTexture( 0, Device->getVideoDriver()->getTexture("./res/tex/tank/cor r.jpg") );
sn_tower->setMaterialFlag(irr::video::EMF_LIGHTING, false);
sn_rocket = Device->getSceneManager()->addMeshSceneNode( Device->getSceneManager()->getMesh("./res/mdl/hero/rocket.x") , sn_tower );
sn_rocket->setMaterialTexture( 0, Device->getVideoDriver()->getTexture("./res/tex/tank/rak r.jpg") );
sn_rocket->setMaterialFlag(irr::video::EMF_LIGHTING, false);
sn_cannon = Device->getSceneManager()->addMeshSceneNode( Device->getSceneManager()->getMesh("./res/mdl/hero/cannon.x") , sn_tower );
sn_cannon->setMaterialTexture( 0, Device->getVideoDriver()->getTexture("./res/tex/tank/pus r.jpg") );
sn_cannon->setMaterialFlag(irr::video::EMF_LIGHTING, false);
sn_fazer = Device->getSceneManager()->addMeshSceneNode( Device->getSceneManager()->getMesh("./res/mdl/hero/fazer.x") , sn_tower );
sn_fazer->setMaterialTexture( 0, Device->getVideoDriver()->getTexture("./res/tex/tank/faz r.jpg") );
sn_fazer->setMaterialFlag(irr::video::EMF_LIGHTING, false);
sn_abomb = Device->getSceneManager()->addMeshSceneNode( Device->getSceneManager()->getMesh("./res/mdl/hero/abomb.x") , sn_tower );
sn_abomb->setMaterialTexture( 0, Device->getVideoDriver()->getTexture("./res/tex/tank/bom.jpg") );
sn_abomb->setMaterialFlag(irr::video::EMF_LIGHTING, false);
sn_tower->setScale( irr::core::vector3df(0.056, 0.056, 0.056) );
ps_gaz = NULL;
firstHeroUpdate = true;
MoveSpeed = .9f;
RotateSpeed = 0.5f;
updateHeroAnim(0);
}
void C_Hero::updateHeroAnim(irr::f32 timediff)
{
bool isChanged = false;
if (firstHeroUpdate)
{
lastHeroAnimationTime = timediff;
firstHeroUpdate = false;
isChanged = true;
isMove = isAttack = false;
}
// get time
irr::f32 timeDiff = (irr::f32) ( timediff - lastHeroAnimationTime );
lastHeroAnimationTime = timediff;
//!init
irr::core::vector3df target = Editor->camera.csn->getTarget();
//!Update move
if ( idxPathNode>0 && idxPathNode < gamemap->path.size() )
{
irr::f32 nx=-target.X, ny=target.Z, ddx=0, ddy=0;
irr::s32 dx, dy;
gamemap->NodeToXY( gamemap->path[idxPathNode] , &dx, &dy);
ddx = dx+0.5;
ddy = dy+0.5;
irr::core::vector3df Direction = irr::core::vector3df( -ddx, 0, ddy)-irr::core::vector3df(-nx,0,ny);
Direction.normalize();
target += Direction * timeDiff * MoveSpeed;
if (fabs(ddx-nx)<0.001 && fabs(ddy-ny)<0.001) // пришли в пункт назначения
{
idxPathNode++;
}
else
{
irr::core::vector3df rot = Direction.getHorizontalAngle();
sn_chassis_1->setRotation( rot );
sn_tower->setRotation( rot );
}
//sn_chassis_2->animateJoints();
}
//!update animation
bool testAttack = MouseKeys[0];
// move
if ( !isMove && idxPathNode>0 )
{
ps_gaz = FX_Creator::exhaust(sn_chassis_1->getJointNode("Ar_tube"), Device->getSceneManager());
ps_traks = new DecalSceneNode(sn_chassis_1->getJointNode("Ar_traks"), Device->getSceneManager(), Device->getVideoDriver()->getTexture("./res/tex/tank/traks.png"), irr::core::vector3df(0.65, 1, 0.3),5000,200,50);
isMove = true;
}
else if ( isMove && idxPathNode == gamemap->path.size() )
{
if (ps_gaz)
{
ps_gaz->remove();
ps_gaz = NULL;
}
if (ps_traks)
{
ps_traks->unlink();
ps_traks = NULL;
}
isMove = false;
}
//!update camera
if (isChanged || isMove)
{
float sinOfPhi = sinf(Editor->camera.getPhi() * irr::core::DEGTORAD);
float cosOfPhi = cosf(Editor->camera.getPhi() * irr::core::DEGTORAD);
float sinOfTheta = sinf(Editor->camera.getTheta() * irr::core::DEGTORAD);
float cosOfTheta = cosf(Editor->camera.getTheta() * irr::core::DEGTORAD);
irr::core::vector3df offset;
// these are switched around a little from what i posted above
offset.X = Editor->camera.getRadius() * sinOfTheta * sinOfPhi;
offset.Y = Editor->camera.getRadius() * cosOfPhi;
offset.Z = Editor->camera.getRadius() * cosOfTheta * sinOfPhi;
Editor->camera.csn->setPosition(target+offset);
Editor->camera.csn->setTarget( target );
sn_tower->setPosition( target );
sn_chassis_1->setPosition( target );
Editor->camera.csn->updateAbsolutePosition();
}
}
| [
"[email protected]"
]
| [
[
[
1,
246
]
]
]
|
ebc6117371666a4ed4ed2f3dc8a1cbbe73a10b0a | 48c71a6cde7a60df82f8f50c69db4541db28c549 | /Scanner/main.cpp | 0a5d58bb6cb0f0c8dff9c9911778c07f945ebe3c | []
| no_license | hubei/Compiler-2 | 5a995eda287079709473a2b0068e6fd5af5aa507 | 0724805f02ecc23d0312b436013a576e54634a41 | refs/heads/master | 2021-01-18T12:06:31.728423 | 2010-10-06T03:25:03 | 2010-10-06T03:25:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,070 | cpp | /*
* main.cpp
*
* Version:
* 0.01.9
*
* Previous Versions:
*
* 2010-09-29: 0.01.1
* 2010-09-28: 0.00.5
*/
/**
* Project Scanner:
* This project will create a simple c++ scanner,
* to be used later in completeing a c++ compiler for
* CSIT-433.
*
* @author Josh Galofaro
* @date 2010-09-29
*/
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <stdlib.h>
using namespace std;
/* enum states: All FSM states, including sbegin as the only accept state
enum tokens: All FSM tokens to be considered */
enum states{ sif, sint, swhile, selse, sreturn, svoid };
enum tokens{ tplus, tminus, tstar, tdiv, tgreater, tlesser, tass, tnot,
tsemi, toparam, tcparam, tobracket, tcbracket };
void tokenizer( string, int );
/**
* Main:
* Main will read in from the input file provided in the
* command line and output two arrays, toutput and soutput
* which will contain the proper set of tokens generated by
* the input file and their corrisponding string.
*
* @author Josh Galofaro
*
* @date 2010-09-28
*
* @param int argc Holds the size of the command line input
* @param char argv[] Char array for the command line input
*
* @exception 101 Improper command line arguments submitted
* @exception 102 File handle error, File not opened
*/
int main(int argc, char *argv[])
{
const char * fName; //File name given by command line args
int curLine = 0; //Keep track of where you are in the file
cout << "Scanner activated..." << endl;
/* Check command line:
only the file name should be submitted */
try
{
if( argc != 2 )
{
throw 101; //Exception 101, command line arguments not proper
}
else if( argc == 2 )
{
fName = argv[1];
}
}
catch (int e)
{
cerr << "An exception occured in program: " << argv[0]
<< endl << "Error No. " << e << endl;
exit( 1 );
}
/* Check file:
Throw exception if fails to open */
try
{
if( argc != 2 )
{
throw 101; //Exception 101, command line arguments not proper
}
else if( argc == 2 )
{
fName = argv[1];
}
ifstream inputFile; //Data file
inputFile.open( fName );
/*
* 2010-09-28: To do here:
* Enter a loop;
* Read in one line per loop,
* Pass that line into parse method,
* Parse method will generate the tokens and
* add them to their proper arrays.
* End of file, exit the loop
*/
if( inputFile.is_open() )
{
string line; //Holds a single line of the input file
cout << "File stream has opened..." << endl;
cout << "Tokenizer activated for:" << endl;
while( !inputFile.eof() )
{
curLine++;
getline(inputFile, line);
tokenizer( line, curLine );
}
inputFile.close();
cout << "File stream closed..." << endl;
}
else
{
throw 102; //Error 102, File not opened
}
}
catch (int e)
{
cerr << "An exception occured in program: " << argv[0]
<< endl << "Error No. " << e << endl;
if( e == 101 )
{
cerr << "Improper command line arguments" << endl;
}
else if( e == 102 )
{
cerr << "File could not be found/opened" << endl;
}
exit( 1 );
}
cout << "Scanner deactivated..." << endl;
return 0;
}
/**
* Tokenizer:
* Tokenizer will accept a single line of the input file in a string, and
* parse the string to generate the proper tokens. It will then dump the
* generated tokens into the toutput array and their corrisponding string
* into the soutput array.
*
* @author Josh Galofaro
*
* @date 2010-09-28
*
* @param string xLine The given line from the input file
* @param int lineNum Integer to keep track of which line we are in
*/
void tokenizer( string xLine, int lineNum )
{
/* To do here in this bitch:
* Take xLine and split it up into single characters,
* Toss those mother fuckers into an array
* character by character follow the FSM to generate each token
* Hitting a white space or symbol signifies the end
* of that particular token. Once created toss the token
* into the toutput array, and grab that hoe of a string
* and toss her into the soutput array where she belongs.
* Delete the character array.
* Have the string make me a sammach.
*/
cout << "Entering line " << lineNum << "..." << endl;
int charSize = 50, strSize = 10, curSize = 0;
string str;
string * strArray = new string[strSize];
char ch; //Char to split the string with
char * charArray = new char[charSize]; //Single character array
istringstream iss(xLine, istringstream::in);
/* Split the line into single words */
while( iss >> str )
{
if( curSize >= strSize )
{
strSize = strSize * 2;
strArray = (string *)realloc( strArray, strSize);
}
strArray[curSize] = str;
curSize++;
}
for( int i = 0; i < curSize; i++)
{
cout << strArray[i] << endl;
}
delete strArray;
cout << "Leaving line " << lineNum << "..." << endl;
}
| [
"[email protected]"
]
| [
[
[
1,
210
]
]
]
|
f45cd82fb09827839fc3b5e8854207c96109579a | 188058ec6dbe8b1a74bf584ecfa7843be560d2e5 | /GodDK/lang/runnable.cpp | b5159b4eca859726d94dd0bb4c5860ce1a324910 | []
| no_license | mason105/red5cpp | 636e82c660942e2b39c4bfebc63175c8539f7df0 | fcf1152cb0a31560af397f24a46b8402e854536e | refs/heads/master | 2021-01-10T07:21:31.412996 | 2007-08-23T06:29:17 | 2007-08-23T06:29:17 | 36,223,621 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 112 | cpp | #include "runnable.h"
#include "assert.h"
#include "string.h"
namespace goddk {
namespace lang {
}
} | [
"soaris@46205fef-a337-0410-8429-7db05d171fc8"
]
| [
[
[
1,
8
]
]
]
|
c7a6ba430625c9047cae70e5445b57a7a4a870b4 | 710981ad55d08ec46a9ffa06df2f07aa54ae5dcd | /player/src/readers/map.h | 340846938d1b5f9606cc0db102d1ae30d6cda402 | []
| no_license | weimingtom/easyrpg | b2ee6acf5a97a4744554b26feede7367b7c16233 | 8877364261e4d4f52cd36cbb43929ed1351f06e1 | refs/heads/master | 2021-01-10T02:14:36.939339 | 2009-02-15T03:45:32 | 2009-02-15T03:45:32 | 44,462,893 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,155 | h | /* map.h, main map routines.
Copyright (C) 2007 EasyRPG Project <http://easyrpg.sourceforge.net/>.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef MAP_DATA_H
#define MAP_DATA_H
// *****************************************************************************
// =============================================================================
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include "../tools/tools.h"
#include "eventchunks.h"
#include "mapchunks.h"
#include "strmap.h"
using namespace std;
#include <vector>
// =============================================================================
// *****************************************************************************
class map_data
{
public:
short MapWidth, MapHeight; // These determine the size of the map
short ChipsetID; // This points to the ID of the Chipset
unsigned char TypeOfLoop; // These flags determines if the map has to
// loop infinitely.
bool ParallaxBackground; // si se usa un fondo paralelo
string BackgroundName; // nombre de la imagen del fondo
bool HorizontalPan; //si hay mobimiento orisontal
bool HorizontalAutoPan; // si es automatico
short HorizontalPanSpeed; // la velocidad del movimiento
bool VerticalPan; //si hay movimiento vertical
bool VerticalAutoPan; // si es automatico
short VerticalPanSpeed; // la velocidad del movimiento
unsigned short * LowerLayer;// patadores a las cpas
unsigned short * UpperLayer;
int TimesSaved;
int NumEvents;
int use_genertor;
int gen_mode;
int gen_Num_titles;
int gen_width;
int gen_height;
int gen_surround_map;
int gen_use_upper_wall;
int gen_use_floor_b;
int gen_use_floor_c;
int gen_use_extra_b;
int gen_use_extra_c;
int gen_roof_X;
int gen_down_wall_X;
int gen_upper_wall_X;
int gen_floor_a_X;
int gen_floor_b_X;
int gen_floor_c_X;
int gen_extra_a_X;
int gen_extra_b_X;
int gen_extra_c_X;
int gen_roof_Y;
int gen_down_wall_Y;
int gen_upper_wall_Y;
int gen_floor_a_Y;
int gen_floor_b_Y;
int gen_floor_c_Y;
int gen_extra_a_Y;
int gen_extra_b_Y;
int gen_extra_c_Y;
unsigned short * gen_chipset_ids;
std:: vector <stEventMap> vcEvents;
void clear_events();
};
class map_reader
{
unsigned char Void;
tChunk ChunkInfo; // informacion del pedazo leido
// --- Methods declaration ---------------------------------------------
public:
bool Load(string Filename,map_data * data); // carga de mapa
void ShowInformation(map_data * data); // info del mapa
private:
void GetNextChunk(FILE * Stream,map_data * data); //lectra de pedasos
std:: vector <stEventMap> eventChunk(FILE * Stream);//eventos de mapa
vector <stPageEventMap> pageChunk(FILE * Stream);//paginas de evento
stPageConditionEventMap conditionChunk(FILE * Stream);//condiciones de pagina
stPageMovesEventMap PageMovesChunk(FILE * Stream);//movimiento de pagina
};
#endif
| [
"fdelapena@2452c464-c253-f492-884b-b99f1bb2d923",
"lobomon@2452c464-c253-f492-884b-b99f1bb2d923"
]
| [
[
[
1,
87
],
[
89,
108
]
],
[
[
88,
88
]
]
]
|
dd6f9a6f12a0075d6b66ab799f0239cd06bf9082 | b807f1f6acf375b0859cabb1d8efbfad41b0193e | /MCMainWindow.h | adb25d5503500522f65870e5f9cf24bea8f8f028 | []
| no_license | TheProjecter/music-collaborator | f60a09259301fb88ac2cdfcba501577a9edca5a8 | 87d0b6af2f8ee6411a9c9b2a316a122b3694c981 | refs/heads/master | 2021-01-10T15:18:11.937089 | 2010-02-12T00:23:15 | 2010-02-12T00:23:15 | 45,961,268 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 630 | h | #ifndef MCMAINWINDOW_H
#define MCMAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MCMainWindow;
}
class MCMainWindow : public QMainWindow {
Q_OBJECT
public:
MCMainWindow(QWidget *parent = 0);
~MCMainWindow();
protected:
void loadSettings();
void saveSettings();
void changeEvent(QEvent *e);
private slots:
void on_actionRemove_Share_triggered();
void on_actionAdd_Project_Folder_triggered();
void on_actionPreferences_triggered();
private:
Ui::MCMainWindow *ui;
//LocalRepositoryModel m_localModel;
};
#endif // MCMAINWINDOW_H
| [
"svanur@8c8dea1e-faed-11de-8591-91bc733d3be8",
"[email protected]"
]
| [
[
[
1,
18
],
[
21,
22
],
[
24,
24
],
[
26,
34
]
],
[
[
19,
20
],
[
23,
23
],
[
25,
25
]
]
]
|
403557834dfd87438e343fa6458a9888b0691ac8 | 0cf09d7cc26a513d0b93d3f8ef6158a9c5aaf5bc | /twittle/src/http/multipart.cpp | e14653a59516300cdbfacae2ea7d6ec03283f37c | []
| no_license | shenhuashan/Twittle | 0e276c1391c177e7586d71c607e6ca7bf17e04db | 03d3d388d5ba9d56ffcd03482ee50e0a2a5f47a1 | refs/heads/master | 2023-03-18T07:53:25.305468 | 2009-08-11T05:55:07 | 2009-08-11T05:55:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 884 | cpp | #include "http/multipart.h"
#include <iostream>
static wxString crlf = _T("\r\n");
void Multipart::Add(const wxString& name, const wxString& value)
{
buffer << _T("--") << boundary << crlf;
buffer << _T("Content-Disposition: form-data; name=\"") << name << _T("\"") << crlf << crlf;
buffer << value << crlf;
}
void Multipart::AddFile(const wxString& name, const wxString& value,
const wxString& filename, const wxString& mimeType)
{
buffer << _T("--") << boundary << crlf;
buffer << _T("Content-Disposition: form-data; name=\"") << name << _T("\"; ");
buffer << _T("filename=\"") << filename << _T("\"") << crlf;
buffer << _T("Content-Type: ") << mimeType << crlf;
buffer << _T("Content-Transfer-Encoding: binary") << crlf << crlf;
buffer << value << crlf;
}
void Multipart::End()
{
buffer << _T("--") << boundary << _T("--") << crlf;
}
| [
"[email protected]"
]
| [
[
[
1,
27
]
]
]
|
d72a57ed470d5a2f1b6411ea895a71586af3b053 | 4891542ea31c89c0ab2377428e92cc72bd1d078f | /Arcanoid/Arcanoid/main.cpp | cefe53043b13748d1337f651fc962a32d855d60a | []
| no_license | koutsop/arcanoid | aa32c46c407955a06c6d4efe34748e50c472eea8 | 5bfef14317e35751fa386d841f0f5fa2b8757fb4 | refs/heads/master | 2021-01-18T14:11:00.321215 | 2008-07-17T21:50:36 | 2008-07-17T21:50:36 | 33,115,792 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 178 | cpp | /* Testing file for Acranoid project */
#include "Game.h"
int main(){
Game theGame;
theGame.PlayGame();
/* this is a test comment */
return 0;
}
END_OF_MAIN() | [
"koutsop@5c4dd20e-9542-0410-abe3-ad2d610f3ba4",
"[email protected]@5c4dd20e-9542-0410-abe3-ad2d610f3ba4"
]
| [
[
[
1,
9
],
[
11,
13
]
],
[
[
10,
10
]
]
]
|
65d9669d2ef3f17596a4d88e68bdce6963422475 | b38ab5dcfb913569fc1e41e8deedc2487b2db491 | /libraries/SoftFX/3rdparty/pathfind.cpp | 6c2e864f33404a306d91c04246525b37ccb1e8f0 | []
| no_license | santosh90n/Fury2 | dacec86ab3972952e4cf6442b38e66b7a67edade | 740a095c2daa32d33fdc24cc47145a1c13431889 | refs/heads/master | 2020-03-21T00:44:27.908074 | 2008-10-16T07:09:17 | 2008-10-16T07:09:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,126 | cpp | #include "stdafx.h"
#include "F2SoftFX.h"
#include <stdlib.h>
#include <math.h>
#define Path8 1
struct NODE
{
int x, // X pos of the tile
y; // Y pos of the tile
long f; // the cost to move from the start to the node and from the node to the goal(the heuristic)
int Parent,// this identifies the parent from which the successors was created(NULL if it is the first node)
ID; // the id which the parent will refer to
};
class AStar
{
void ConstructPath(NODE n);
bool IsInOPEN(NODE n);
bool IsInCLOSED(NODE n);
void AddToOPEN(NODE n);
void AddToCLOSED(NODE n);
void RemoveFromOPEN(NODE n);
void GenerateSuccs(NODE n);
void GenerateSucc(int x,int y,int Parent);
NODE GetBestNode();
NODE GetNodeFromCLOSED(int ID);
int nOpen,nClosed,cOpen,cClosed,cID;
NODE nStart,nGoal;
NODE* OPEN;
NODE* CLOSED;
public:
f2geblockbuffer blocking;
int nPath;
NODE* PATH;
bool FindPath(POINT StartPos,POINT EndPos);
}Path;
/* --| ASTAR FUNCTION |-----------------------------------------------------------------------*\
| Name: ConstructPath
| Desc: constructs a path trough the .Parent value of the node that found the goal
\* --| ASTAR FUNCTION |-----------------------------------------------------------------------*/
void AStar::ConstructPath(NODE n)
{
PATH =(NODE*) malloc(300 *sizeof(NODE));
nPath=0;
NODE nTemp=n;
int a=0;
NODE *AltPath;
while (nTemp.ID != -1)
{
PATH[nPath++]=nTemp;
nTemp=GetNodeFromCLOSED(nTemp.Parent);
}
PATH[nPath++]=nTemp;
AltPath=(NODE*) malloc(nPath*sizeof(NODE));
for (int i=nPath-1;i>-1;i--)
{
AltPath[a++]=PATH[i];
}
free(PATH);
PATH=AltPath;
}
/* --| ASTAR FUNCTION |-----------------------------------------------------------------------*\
| Name: IsInOPEN
| Desc: Verifies if a node is in the OPEN list
\* --| ASTAR FUNCTION |-----------------------------------------------------------------------*/
bool AStar::IsInOPEN(NODE n)
{
if (OPEN==NULL) return false;
int Len=(sizeof(*OPEN)*cOpen)/sizeof(NODE);
for (int i=0;i<Len;i++)
{
if (OPEN[i].x == n.x && OPEN[i].y == n.y)
break;
}
if (i==Len) return false;
return true;
}
/* --| ASTAR FUNCTION |-----------------------------------------------------------------------*\
| Name: IsInCLOSED
| Desc: Verifies if a node is in the CLOSED list
\* --| ASTAR FUNCTION |-----------------------------------------------------------------------*/
bool AStar::IsInCLOSED(NODE n)
{
if (CLOSED==NULL) return false;
int Len=(sizeof(*CLOSED)*cClosed)/sizeof(NODE);
for (int i=0;i<Len;i++)
{
if (CLOSED[i].x == n.x && CLOSED[i].y == n.y)
break;
}
if (i==Len) return false;
return true;
}
/* --| ASTAR FUNCTION |-----------------------------------------------------------------------*\
| Name: AddToOPEN
| Desc: Adds a node to the OPEN list
\* --| ASTAR FUNCTION |-----------------------------------------------------------------------*/
void AStar::AddToOPEN(NODE n)
{
if (cOpen>nOpen)
{
nOpen+=100;
OPEN=(NODE*) realloc(OPEN,sizeof(NODE)*nOpen);
}
OPEN[cOpen++]=n;
}
/* --| ASTAR FUNCTION |-----------------------------------------------------------------------*\
| Name: AddToClosed
| Desc: Adds a node to the CLOSED list
\* --| ASTAR FUNCTION |-----------------------------------------------------------------------*/
void AStar::AddToCLOSED(NODE n)
{
if (cClosed>nClosed)
{
nClosed+=100;
CLOSED=(NODE*) realloc(CLOSED,sizeof(NODE)*nClosed);
}
CLOSED[cClosed++]=n;
}
/* --| ASTAR FUNCTION |-----------------------------------------------------------------------*\
| Name: RemoveFromOPEN
| Desc: Removes a node from the OPEN list
\* --| ASTAR FUNCTION |-----------------------------------------------------------------------*/
void AStar::RemoveFromOPEN(NODE n)
{
if (OPEN==NULL) return;
int Len=(sizeof(*OPEN)*cOpen)/sizeof(NODE);
for (int i=0;i<Len;i++)
if (OPEN[i].x == n.x && OPEN[i].y == n.y)
break;
for (int j=i;j<cOpen;j++)
OPEN[j]=OPEN[j+1];
cOpen--;
}
/* --| ASTAR FUNCTION |-----------------------------------------------------------------------*\
| Name: GenerateSucc
| Desc: Generates a node and adds it to OPEN
\* --| ASTAR FUNCTION |-----------------------------------------------------------------------*/
void AStar::GenerateSucc(int x,int y,int Parent)
{
// First we check if the new successor is ot of the Map area or is a
// forbidden tile.So if it is clear for movement,create the node and
// if the node is not already created(is not in OPEN) and it is not
// in CLOSED then create it
if (x<0) return;
if (y<0) return;
if (x>=blocking.width) return;
if (y>=blocking.height) return;
if (blocking.values[(y * blocking.width) + (x)] != 0) return;
NODE n;
n.x=x; n.y=y; n.ID=cID++; n.Parent=Parent;
n.f=(abs(nGoal.x - n.x)+1) * (abs(nGoal.y - n.y)+1);
if (!IsInOPEN(n) && !IsInCLOSED(n))
AddToOPEN(n);
}
/* --| ASTAR FUNCTION |-----------------------------------------------------------------------*\
| Name: GenerateSuccs
| Desc: Generate successors for the node
\* --| ASTAR FUNCTION |-----------------------------------------------------------------------*/
void AStar::GenerateSuccs(NODE n)
{
#if (Path8)
GenerateSucc(n.x-1,n.y-1,n.ID); // Upper Left
GenerateSucc(n.x ,n.y-1,n.ID); // Upper Center
GenerateSucc(n.x+1,n.y-1,n.ID); // Upper Right
GenerateSucc(n.x-1,n.y ,n.ID); // Center Left
GenerateSucc(n.x+1,n.y ,n.ID); // Center Right
GenerateSucc(n.x-1,n.y+1,n.ID); // Lower Left
GenerateSucc(n.x ,n.y+1,n.ID); // Lower Center
GenerateSucc(n.x+1,n.y+1,n.ID); // Lower Right
#else
GenerateSucc(n.x ,n.y-1,n.ID); // Upper Center
GenerateSucc(n.x-1,n.y ,n.ID); // Center Left
GenerateSucc(n.x+1,n.y ,n.ID); // Center Right
GenerateSucc(n.x ,n.y+1,n.ID); // Lower Center
#endif
RemoveFromOPEN(n);
AddToCLOSED(n);
}
/* --| ASTAR FUNCTION |-----------------------------------------------------------------------*\
| Name: GetNodeFromCLOSED
| Desc: Retrieves the node from the CLOSED list (for path construction)
\* --| ASTAR FUNCTION |-----------------------------------------------------------------------*/
NODE AStar::GetNodeFromCLOSED(int ID)
{
for (int i=0;i<cClosed;i++)
if (CLOSED[i].ID == ID)
return CLOSED[i];
return CLOSED[0]; // to silence the warning
}
/* --| ASTAR FUNCTION |-----------------------------------------------------------------------*\
| Name: GetBestNode
| Desc: Retrieves the node that is the closest to the goal (defined by the heuristic)
\* --| ASTAR FUNCTION |-----------------------------------------------------------------------*/
NODE AStar::GetBestNode()
{
long f=OPEN[0].f;
int ArrPos=0;
int Len=(sizeof(*OPEN)*cOpen)/sizeof(NODE);
NODE tNode;
for (int i=1;i<Len;i++)
{
if (OPEN[i].f<=f)
{
f=OPEN[i].f;
ArrPos=i;
}
}
tNode.f =OPEN[ArrPos].f;
tNode.x =OPEN[ArrPos].x;
tNode.y =OPEN[ArrPos].y;
tNode.Parent=OPEN[ArrPos].Parent;
tNode.ID =OPEN[ArrPos].ID;
return tNode;
}
/* --| ASTAR FUNCTION |-----------------------------------------------------------------------*\
| Name: FindPath
| Desc: the main function of AStar,this one finds the path,or not,and stores it in the PATH
\* --| ASTAR FUNCTION |-----------------------------------------------------------------------*/
bool AStar::FindPath(POINT StartPos,POINT EndPos)
{
// -- Memory allocation -------------------
if (nPath>0 && nPath<300) free(PATH);
OPEN =(NODE*) malloc(1000*sizeof(NODE));
CLOSED=(NODE*) malloc(1000*sizeof(NODE));
nOpen =1000;
nClosed=1000;
cOpen =1;
cClosed=0;
cID=0;
// -- Search initialization ---------------
NODE n;
n.f=n.Parent=n.ID=-1;n.x=StartPos.x;n.y=StartPos.y;
nStart=n;
n.f=n.Parent=n.ID=0;n.x= EndPos.x;n.y= EndPos.y;
nGoal=n;
OPEN[0]=nStart;
// -- Pathfinding -------------------------
while (cOpen) // Do while OPEN is not empty,if OPEN is empty,it means that the path was not found
{
n=GetBestNode();
if (n.x==nGoal.x && n.y==nGoal.y)
break;
GenerateSuccs(n);
}
// -- Memory deallocation -----------------
if (cOpen !=0) ConstructPath(n);
free(OPEN);
free(CLOSED);
if (cOpen==0)
return false;
else
return true;
}
F2FX int f2geAStarPathfind(f2gepathbuffer * pathbuffer, f2geblockbuffer * blocking, int startx, int starty, int endx, int endy) {
AStar * Pathfinder = new AStar;
POINT ptStart, ptEnd;
int nCopy = 0;
ptStart.x = startx;
ptStart.y = starty;
ptEnd.x = endx;
ptEnd.y = endy;
Pathfinder->blocking = *blocking;
if (Pathfinder->FindPath(ptStart, ptEnd)) {
pathbuffer->path = (f2gepathpoint *)GlobalAlloc(GPTR, Pathfinder->nPath * 8);
pathbuffer->size = Pathfinder->nPath;
for (nCopy = 0; nCopy < pathbuffer->size; nCopy++) {
pathbuffer->path[nCopy].x = Pathfinder->PATH[nCopy].x;
pathbuffer->path[nCopy].y = Pathfinder->PATH[nCopy].y;
}
return true;
} else {
pathbuffer->path = (f2gepathpoint *)NULL;
pathbuffer->size = 0;
return false;
}
}
| [
"kevin@1af785eb-1c5d-444a-bf89-8f912f329d98"
]
| [
[
[
1,
293
]
]
]
|
67f79db09d6b6c3f722a062f95e900b16a93a715 | 5236606f2e6fb870fa7c41492327f3f8b0fa38dc | /nsrpc/src/p2p/SimpleRelayService.cpp | eaef66d803f0be63f362019221856038029b83cd | []
| no_license | jcloudpld/srpc | aa8ecf4ffc5391b7183b19d217f49fb2b1a67c88 | f2483c8177d03834552053e8ecbe788e15b92ac0 | refs/heads/master | 2021-01-10T08:54:57.140800 | 2010-02-08T07:03:00 | 2010-02-08T07:03:00 | 44,454,693 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 6,422 | cpp | #include "stdafx.h"
#include <nsrpc/p2p/server/SimpleRelayService.h>
#include <nsrpc/p2p/detail/P2pPeerHint.h>
#include <nsrpc/detail/PacketCoder.h>
#include <nsrpc/utility/AceUtil.h>
#include <nsrpc/utility/Logger.h>
#include <srpc/utility/Endian.h>
#include <ace/Reactor.h>
#include <cassert>
namespace nsrpc
{
namespace detail
{
IMPLEMENT_SRPC_EVENT_DISPATCHER(SimpleRelayService);
#ifdef _MSC_VER
# pragma warning (push)
# pragma warning (disable: 4355)
#endif
SimpleRelayService::SimpleRelayService(ACE_Reactor* reactor,
PacketCoder* packetCoder, bool useBitPacking) :
reactor_(reactor),
packetCoder_(packetCoder),
recvBlock_(new ACE_Message_Block(packetCoder_->getDefaultPacketSize())),
sendBlock_(new ACE_Message_Block(packetCoder_->getDefaultPacketSize())),
endpoint_(*this, *recvBlock_, reactor_),
rpcNetwork_(*this, *recvBlock_, *sendBlock_, useBitPacking),
outgoingUnreliableSequenceNumber_(invalidSequenceNumber),
lastRelayPeerIdPair_(invalidPeerId, invalidPeerId),
peerCipherKeys_(*packetCoder_)
{
srpc::RpcReceiver::setRpcNetwork(rpcNetwork_);
srpc::RpcForwarder::setRpcNetwork(rpcNetwork_);
}
#ifdef _MSC_VER
# pragma warning (pop)
#endif
SimpleRelayService::~SimpleRelayService()
{
close();
recvBlock_->release();
sendBlock_->release();
}
bool SimpleRelayService::open(srpc::UInt16 port,
const srpc::String& cipherKey)
{
if (! endpoint_.open(port)) {
return false;
}
if (! cipherKey.empty()) {
peerCipherKeys_.set(relayServerPeerId, cipherKey);
}
packetCoder_->setDecryptSeed(peerCipherKeys_.get(relayServerPeerId));
return true;
}
void SimpleRelayService::close()
{
endpoint_.close();
}
// = overriding
void SimpleRelayService::onMessageArrived(const ACE_INET_Addr& peerAddress)
{
P2pPacketHeader header;
if (! packetCoder_->readHeader(header, *recvBlock_)) {
NSRPC_LOG_ERROR3(
ACE_TEXT("SimpleRelayService::onMessageArrived(from: %s:%d) ")
ACE_TEXT("FAILED!!!(Invalid Message Header)"),
peerAddress.get_host_addr(), peerAddress.get_port_number());
return;
}
if (! packetCoder_->isValidHeader(header, *recvBlock_)) {
NSRPC_LOG_ERROR3(
ACE_TEXT("SimpleRelayService::onMessageArrived(from: %s:%d) ")
ACE_TEXT("FAILED!!!(Message body is too short)"),
peerAddress.get_host_addr(), peerAddress.get_port_number());
return;
}
assert(! isReliable(header.packetType_));
if (! packetCoder_->decode(*recvBlock_)) {
return;
}
packetCoder_->advanceToBody(*recvBlock_);
if (! rpcNetwork_.handleMessage(header.peerId_, peerAddress)) {
NSRPC_LOG_ERROR3(
ACE_TEXT("SimpleRelayService::onMessageArrived(from: %s:%d) ")
ACE_TEXT("FAILED!!!(RpcNetwork::handleMessage() Error)"),
peerAddress.get_host_addr(), peerAddress.get_port_number());
}
}
bool SimpleRelayService::sendNow(const PeerIdPair& /*peerIdPair*/,
const AddressPair& /*addressPair*/, const ACE_Message_Block& /*mblock*/,
srpc::RpcPacketType /*packetType*/, SequenceNumber /*sequenceNumber*/,
srpc::UInt32 /*sentTime*/)
{
assert(false);
return true;
}
void SimpleRelayService::marshalingErrorOccurred()
{
endpoint_.close();
}
void SimpleRelayService::sendOutgoingMessage(srpc::RpcPacketType packetType,
ACE_Message_Block* mblock, const P2pPeerHint* peerHint)
{
assert(peerHint != 0);
if (! peerHint) {
return;
}
// TODO: P2pEndpoint::send()가 실패할 경우의 처리? 큐 & 재전송?
P2pPacketHeader header(packetType, relayServerPeerId,
++outgoingUnreliableSequenceNumber_, 0);
packetCoder_->setEncryptSeed(peerCipherKeys_.get(peerHint->peerId_));
if (packetCoder_->encode(*mblock, header)) {
(void)endpoint_.send(peerHint->getAddress(), *mblock);
}
else {
NSRPC_LOG_ERROR(
ACE_TEXT("SimpleRelayService - packet encoding FAILED!!!"));
}
}
size_t SimpleRelayService::getPacketHeaderSize() const
{
return packetCoder_->getHeaderSize();
}
// = RpcStunService
EXCHANGE_SRPC_P2P_METHOD_0(SimpleRelayService, rpcResolve, srpc::ptUnreliable)
{
assert(rpcHint != 0);
const P2pPeerHint& hint = *static_cast<const P2pPeerHint*>(rpcHint);
assert(hint.isValid());
ACE_INET_Addr peerAddress(hint.getAddress());
NSRPC_LOG_DEBUG4("RELAY|rpcResolve(P%u, %s:%d)",
hint.peerId_, peerAddress.get_host_addr(),
peerAddress.get_port_number());
rpcResolved(peerAddress.get_host_addr(), peerAddress.get_port_number(),
&hint);
}
FORWARD_SRPC_P2P_METHOD_2(SimpleRelayService, rpcResolved,
srpc::RShortString, ipAddress, srpc::UInt16, port,
srpc::ptUnreliable);
// = RpcRelayService
EXCHANGE_SRPC_P2P_METHOD_6(SimpleRelayService, rpcRelay,
RPeerIdPair, peerIdPair, RAddress, peerAddress,
RMessageBuffer, messageBlock, srpc::RRpcPacketType, packetType,
SequenceNumber, sequenceNumber, PeerTime, sentTime,
srpc::ptUnreliable)
{
assert(rpcHint != 0);
const P2pPeerHint& hint = *static_cast<const P2pPeerHint*>(rpcHint);
assert(hint.isValid());
SRPC_UNUSED_ARG(hint);
const ACE_INET_Addr fromAddress(hint.getAddress());
char fromIp[INET_ADDRSTRLEN];
fromAddress.get_host_addr(fromIp, INET_ADDRSTRLEN);
char toIp[INET_ADDRSTRLEN];
peerAddress.get_host_addr(toIp, INET_ADDRSTRLEN);
NSRPC_LOG_DEBUG8("RELAY|rpcRelay(P%u->P%u, %s:%d->%s:%d, %d)",
peerIdPair.from_, peerIdPair.to_,
fromIp, fromAddress.get_port_number(),
toIp, peerAddress.get_port_number(),
messageBlock.getBufferLength());
const P2pPeerHint toHint(peerIdPair.to_, &peerAddress);
rpcRelayed(peerIdPair.from_, messageBlock, packetType, sequenceNumber,
sentTime, &toHint);
lastRelayPeerIdPair_ = peerIdPair;
}
FORWARD_SRPC_P2P_METHOD_5(SimpleRelayService, rpcRelayed,
PeerId, peerId, RMessageBuffer, messageBlock,
srpc::RRpcPacketType, packetType, SequenceNumber, sequenceNumber,
PeerTime, sentTime, srpc::ptUnreliable);
} // namespace detail
} // namespace nsrpc
| [
"kcando@6d7ccee0-1a3b-0410-bfa1-83648d9ec9a4"
]
| [
[
[
1,
216
]
]
]
|
e6c5867e261e93b0ca2af8449a577c916b9a7a7a | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/wave/test/testwave/testfiles/t_5_002.cpp | 8acc1b87bb7ebc246e0fe948b9708ee2f7cf6202 | [
"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 | 3,067 | cpp | /*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2006 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 the line splicing by <backslash><newline> sequence.
// 2.1: In a #define directive line, between the parameter list and the
// replacement text.
//R #line 23 "t_5_002.cpp"
#define FUNC(a, b, c) \
a ## b ## c
FUNC(ab, cd, ef) //R abcdef
// 2.2: In a #define directive line, among the parameter list and among the
// replacement text.
//R #line 33 "t_5_002.cpp"
#undef FUNC
#define FUNC(a, b \
, c) \
a ## b \
## c
FUNC(ab, cd, ef) //R abcdef
// 2.3: In a string literal.
//R #line 37 "t_5_002.cpp"
"abc\
de" //R "abcde"
// 2.4: <backslash><newline> in midst of an identifier.
//R #line 43 "t_5_002.cpp"
#define ABCDE 5
ABC\
DE //R 5
// 2.5: <backslash><newline> by trigraph.
//R #line 48 "t_5_002.cpp"
ABC??/
DE //R 5
/*-
* Copyright (c) 1998, 2002-2005 Kiyoshi Matsui <[email protected]>
* 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.
*/
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
76
]
]
]
|
2958fdb2f5b6ee46b91401cf2d8973e4ca03ae5d | 3864b1eac7152aaba3f5ba06703ff3cf53ace29d | /kono/Bookit/KoobeRender_Public.h | fd233c6c9eee572f21cb85da9c8cb75d27cad7b8 | []
| no_license | technicalas/onok | bdb678f9c4a23f33f4ba23459c3cceaa4b18214f | 4153c20cd2a105f55795a8b0e684bcb993285a95 | refs/heads/master | 2020-04-23T14:36:11.553873 | 2011-06-22T17:07:47 | 2011-06-22T17:07:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,106 | h | #ifndef __KOOBERENDER_PUBLIC_H__
#define __KOOBERENDER_PUBLIC_H__
//============================================================
/// ImageType
typedef enum _ImageType
{
ImageType_BMP,
ImageType_PNG,
ImageType_REF,
} ImageType;
typedef enum _ImageColorspace
{
ImageColorspace_GRAY=0,
ImageColorspace_RGB,
ImageColorspace_BGR,
ImageColorspace_CMYK
} ImageColorspace;
# ifdef __cplusplus
extern "C" {
# endif /* __cplusplus */
class IRenderCallback
{
public:
virtual BOOKIT_ERR_CODE setRandAccessMode(bool bRandomMode) = 0;
virtual BOOKIT_ERR_CODE getRandAccessMode(bool* bpRandomMode) = 0;
virtual BOOKIT_ERR_CODE getPartialData_CRTSafe(const char* href, unsigned char* dataOut, const UINT32 nFrom, const UINT32 nTo, bool bEnableSeek, bool bEnableRead) = 0;
virtual BOOKIT_ERR_CODE getData_CRTSafe(const char* href, /*out with default buffer*/char* dataOut, UINT32 *outsize) = 0;
virtual BOOKIT_ERR_CODE getHrefByID(const char* szID,const char** pszHref) = 0;
};
# ifdef __cplusplus
}
# endif /* __cplusplus */
#endif /// __KOOBERENDER_PUBLIC_H__
| [
"[email protected]"
]
| [
[
[
1,
42
]
]
]
|
8478cd8c0b7d3de0c5b61b2ef73626da4162012d | 00b979f12f13ace4e98e75a9528033636dab021d | /zfs/zfs/tools/ziatester/src/include/sysapi/win32.hh | d376fce24c81704f58a6af1b501a9714bf961f8a | []
| no_license | BackupTheBerlios/ziahttpd-svn | 812e4278555fdd346b643534d175546bef32afd5 | 8c0b930d3f4a86f0622987776b5220564e89b7c8 | refs/heads/master | 2016-09-09T20:39:16.760554 | 2006-04-13T08:44:28 | 2006-04-13T08:44:28 | 40,819,288 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,102 | hh | //
// win32.hh for in
//
// Made by texane
// Login <[email protected]>
//
// Started on Sun Oct 09 13:56:50 2005 texane
// Last update Tue Dec 06 23:19:34 2005 texane
//
#ifndef SYSAPI_WIN32_HH
# define SYSAPI_WIN32_HH
// @see sysapi.hh
// This file declares the namespace
// used for the win32 system api.
#include <string>
//#include <winsock2.h>
#include <windows.h>
#include <process.h>
namespace win32
{
// @see sysapi/win32/file.cc
namespace file
{
// Openning modes
typedef enum
{
RDONLY = GENERIC_READ,
WRONLY = GENERIC_WRITE,
RDWR = GENERIC_READ | GENERIC_WRITE
} mode_t;
// Seek position
typedef enum
{
BEGIN = FILE_BEGIN,
CURRENT = FILE_CURRENT,
END = FILE_END
} pos_t;
typedef HANDLE handle_t;
typedef DWORD offset_t;
typedef DWORD size_t;
// Function prototypes
bool open(handle_t*, const char*, mode_t, int* = static_cast<int*>(0));
bool create(const char*, mode_t = RDWR, handle_t* = static_cast<handle_t*>(0), int* = static_cast<int*>(0));
bool close(handle_t, int* = static_cast<int*>(0));
bool close_rd(handle_t, int* = static_cast<int*>(0));
bool close_wr(handle_t, int* = static_cast<int*>(0));
bool read(handle_t, unsigned char*, size_t, size_t* = static_cast<size_t*>(0), int* = static_cast<int*>(0));
bool write(handle_t, const unsigned char*, size_t, size_t* = static_cast<size_t*>(0), int* = static_cast<int*>(0));
bool seek(handle_t, offset_t, pos_t = CURRENT, int* = static_cast<int*>(0));
// Access rights functions
bool exists(const char*);
bool size(const char*, unsigned long*);
bool is_directory(const char*);
bool is_readable(const char*);
bool is_writtable(const char*);
bool is_executable(const char*);
}
// @see sysapi/win32/process.cc
namespace process
{
// options for the wait function
typedef enum
{
DONTWAIT = 0, // returns if no pending process
WAITFOREVER // wait until process comes
} waitopt_t;
// State of the process
typedef enum
{
RUNNING = 0,
BLOCKED,
TERMINATED
} state_t;
// Signal that can be sent to the process
typedef enum
{
TERMINATE = 0
} sigid_t;
// Handle on the process
typedef HANDLE handle_t;
// Public interface
bool create_and_loadexec(handle_t*, int, const char**, const char** = NULL);
bool create_outredir_and_loadexec(handle_t*, win32::file::handle_t*, int, const char**, const char** = NULL);
bool create_inoutredir_and_loadexec(handle_t*, win32::file::handle_t*, win32::file::handle_t*, int, const char**, const char** = NULL);
bool myhandle(handle_t*);
bool signal(handle_t, sigid_t);
bool release(handle_t);
bool wait_single(handle_t, state_t* = NULL, waitopt_t = WAITFOREVER);
bool wait_any(handle_t* = NULL, state_t* = NULL, waitopt_t = WAITFOREVER);
}
// @see sysapi/win32/thread.cc
namespace thread
{
// Handle on threads
typedef HANDLE handle_t;
// Thread entry point
typedef void* param_t;
typedef unsigned retcode_t;
typedef retcode_t (*entry_t)(param_t);
// thread states
typedef enum
{
RUNNING = 0,
SUSPENDED,
BLOCKED,
TERMINATED
} state_t;
// wait options
typedef enum
{
DONTWAIT = 0,
WAITFOREVER
} waitopt_t;
// Signal id
typedef enum
{
TERMINATE = 0,
RESUME,
SUSPEND
} sigid_t;
// Public interface
bool create_and_exec(handle_t*, entry_t, param_t = NULL);
bool attach_to_process(handle_t, win32::process::handle_t);
bool detach_from_process(handle_t, win32::process::handle_t);
bool wait_single(handle_t, state_t* = NULL, waitopt_t = WAITFOREVER);
bool myhandle(handle_t*);
bool release(handle_t);
bool say(const char* = NULL);
}
// @see sysapi/win32/socket.cc
namespace socket_in
{
// System dependant errors
typedef enum
{
// Subsystem related
SUBSYSTEM_FAILED = 0,
// Socket related
SOCKET_NOT_CONNECTED,
SOCKET_INVALID_HANDLE,
SOCKET_TOO_MANY_HANDLE,
SOCKET_PERM_DENIED,
// Internet address related
INADDR_IS_INVALID,
// System calls / functions related
CALL_WOULDBLOCK,
CALL_INPROGRESS,
CALL_INTERRUPTED,
// Connection related
CONN_ABORTED, // closed by the host software
CONN_RESET, // connection aborted by the foreign soft
CONN_REFUSED,
CONN_DISCONNECTED, // gracefully disconnected
// Unknown error
ERR_UNKNOWN,
// Success
SUCCESS
} error_t;
// System dependant type
typedef SOCKET handle_t;
typedef int size_t;
// Interface
bool init_subsystem(win32::socket_in::error_t* = NULL);
bool release_subsystem(win32::socket_in::error_t* = NULL);
bool create_listening(win32::socket_in::handle_t*,
unsigned short,
unsigned long = INADDR_ANY,
int = 0,
win32::socket_in::error_t* = NULL);
bool create_listening(win32::socket_in::handle_t*,
unsigned short,
const char*,
int = 0,
win32::socket_in::error_t* = NULL);
bool create_client(win32::socket_in::handle_t* hdl,
unsigned short localport,
const char* distaddr,
win32::socket_in::error_t* = NULL);
bool accept(win32::socket_in::handle_t*,
win32::socket_in::handle_t,
struct sockaddr* = NULL,
win32::socket_in::error_t* = NULL);
bool terminate_connection(win32::socket_in::handle_t);
bool recv(win32::socket_in::handle_t,
unsigned char*,
win32::socket_in::size_t,
win32::socket_in::size_t* = NULL,
win32::socket_in::error_t* = NULL);
bool send(win32::socket_in::handle_t,
const unsigned char*,
win32::socket_in::size_t,
win32::socket_in::size_t* = NULL,
win32::socket_in::error_t* = NULL);
}
// @see sysapi/win32/mutex.cc
namespace mutex
{
// Handle on the mutex
typedef HANDLE handle_t;
// Interface
bool create(win32::mutex::handle_t*);
bool destroy(win32::mutex::handle_t);
bool acquire(win32::mutex::handle_t);
bool release(win32::mutex::handle_t);
}
// @see sysapi/win32/error.cc
namespace error
{
typedef DWORD handle_t;
handle_t get();
void set(handle_t);
void stringify(const char* = NULL);
}
// @see sysapi/win32/shared_object.cc
namespace shared_object
{
typedef HMODULE handle_t;
typedef enum
{
} error_t;
bool open(handle_t&, const std::string&, error_t&);
bool close(handle_t&);
bool resolve(void*&, handle_t&, const std::string&, error_t&);
}
}
// - Doxygen comments start from here
//! \file
//! \brief Implements the win32 part of sysapi
//!
//! Interfaces available for file, process, thread.
//! See the files win32.hh for more informations.
#endif // ! SYSAPI_WIN32_HH
| [
"texane@754ce95b-6e01-0410-81d0-8774ba66fe44"
]
| [
[
[
1,
282
]
]
]
|
0221aaf71ed51ecc89a0616941b2b2c9aa0aaec8 | d150600f56acd84df1c3226e691f48f100e6c734 | /active_object/ConnectRequest.cpp | 6fb6f891fb3d85899dd85a803261b0672d8fc017 | []
| no_license | BackupTheBerlios/newsreader-svn | 64d44ca7d17eff9174a0a5ea529e94be6a171a97 | 8fb6277101099b6c30ac41eac5e803d2628dfcb1 | refs/heads/master | 2016-09-05T14:44:52.642415 | 2007-10-28T19:21:10 | 2007-10-28T19:21:10 | 40,802,616 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 317 | cpp | #include "ConnectRequest.h"
#include "servent.h"
CConnectRequest::CConnectRequest(boost::shared_ptr<Servent> spServant,const std::string& url):m_spServant(spServant),m_strUrl(url)
{
}
CConnectRequest::~CConnectRequest(void)
{
}
bool CConnectRequest::call()
{
return m_spServant->Connect(m_strUrl);
} | [
"peacebird@00473811-6f2b-0410-a651-d1448cebbc4e"
]
| [
[
[
1,
15
]
]
]
|
c56d1cdb173836453dda488b1136c8f2b6301277 | e2e49023f5a82922cb9b134e93ae926ed69675a1 | /tools/aosdesigner/view/dialog/NewSequenceDialog.cpp | cb92c8f3a4e387d51171a0d2ab1cd2b65be19a73 | []
| no_license | invy/mjklaim-freewindows | c93c867e93f0e2fe1d33f207306c0b9538ac61d6 | 30de8e3dfcde4e81a57e9059dfaf54c98cc1135b | refs/heads/master | 2021-01-10T10:21:51.579762 | 2011-12-12T18:56:43 | 2011-12-12T18:56:43 | 54,794,395 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,728 | cpp | #include "NewSequenceDialog.hpp"
#include <QRegExpValidator>
#include <QDoubleValidator>
#include "ui_NewSequenceDialog.h"
#include "Paths.hpp"
namespace aosd
{
namespace view
{
NewSequenceDialog::NewSequenceDialog()
: m_ui( new Ui::NewSequenceDialog() )
{
m_ui->setupUi( this );
// interactions
connect( m_ui->button_cancel , SIGNAL( clicked() ) , this , SLOT( reject() ) );
connect( m_ui->button_create , SIGNAL( clicked() ) , this , SLOT( create_sequence() ) );
connect( m_ui->edit_name , SIGNAL( textChanged(const QString&) ) , this , SLOT( update_codename() ) );
// set the validators
// TODO : put that validator somewhere accessible to other code
auto* codename_validator = new QRegExpValidator( QRegExp("[A-Za-z0-9_]+"), this ); // TODO : later, allow any OS valid characters but no spaces.
m_ui->edit_codename->setValidator( codename_validator );
auto* width_validator = new QDoubleValidator(this);
auto* height_validator = new QDoubleValidator(this);
width_validator->setRange( 1, 0 );
height_validator->setRange( 1, 0 );
m_ui->edit_canvas_width->setValidator( width_validator );
m_ui->edit_canvas_height->setValidator( height_validator );
// set a default values
m_ui->edit_name->setText( tr("Unnamed Sequence") );
m_ui->edit_canvas_width->setText( "800" );
m_ui->edit_canvas_height->setText( "600" );
m_ui->check_create_edition->setChecked( true );
}
NewSequenceDialog::~NewSequenceDialog()
{
}
core::SequenceInfos NewSequenceDialog::infos()
{
core::SequenceInfos infos;
infos.name = m_ui->edit_name->text().toStdString();
infos.location = path::SEQUENCE_FILE( m_ui->edit_codename->text().toStdString() );
infos.canvas_width = m_ui->edit_canvas_width->text().toDouble();
infos.canvas_height = m_ui->edit_canvas_width->text().toDouble();
infos.is_edition_requested = m_ui->check_create_edition->isChecked();
return infos;
}
void NewSequenceDialog::create_sequence()
{
// TODO : check that the names are filled
if( !m_ui->edit_name->text().isEmpty()
&& !m_ui->edit_canvas_width->text().isEmpty()
&& !m_ui->edit_canvas_height->text().isEmpty()
)
{
// TODO : check that the location is valid
// TODO : launch the creation of the project
accept();
}
else
{
// TODO : notify the user?
}
}
void NewSequenceDialog::update_codename()
{
const auto name = m_ui->edit_name->text();
auto codename = name;
codename = codename.trimmed();
codename.replace( QRegExp( "\\s+" ), "_" );
codename.replace( QRegExp( "\\W+" ), "" );
m_ui->edit_codename->setText( codename );
}
}
} | [
"klaim@localhost"
]
| [
[
[
1,
94
]
]
]
|
a9cb5497d2f37631857c25797341e2257fe9e24b | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/smart_ptr/src/sp_collector.cpp | c98683176b042e09a2db1532461360d5a13a7b90 | [
"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,695 | cpp | //
// sp_collector.cpp
//
// Copyright (c) 2002, 2003 Peter Dimov
//
// 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)
//
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
#include <boost/assert.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/detail/lightweight_mutex.hpp>
#include <cstdlib>
#include <map>
#include <deque>
#include <iostream>
typedef std::map< void const *, std::pair<void *, size_t> > map_type;
static map_type & get_map()
{
static map_type m;
return m;
}
typedef boost::detail::lightweight_mutex mutex_type;
static mutex_type & get_mutex()
{
static mutex_type m;
return m;
}
static void * init_mutex_before_main = &get_mutex();
namespace
{
class X;
struct count_layout
{
boost::detail::sp_counted_base * pi;
int id;
};
struct shared_ptr_layout
{
X * px;
count_layout pn;
};
}
// assume 4 byte alignment for pointers when scanning
size_t const pointer_align = 4;
typedef std::map<void const *, long> map2_type;
static void scan_and_count(void const * area, size_t size, map_type const & m, map2_type & m2)
{
unsigned char const * p = static_cast<unsigned char const *>(area);
for(size_t n = 0; n + sizeof(shared_ptr_layout) <= size; p += pointer_align, n += pointer_align)
{
shared_ptr_layout const * q = reinterpret_cast<shared_ptr_layout const *>(p);
if(q->pn.id == boost::detail::shared_count_id && q->pn.pi != 0 && m.count(q->pn.pi) != 0)
{
++m2[q->pn.pi];
}
}
}
typedef std::deque<void const *> open_type;
static void scan_and_mark(void const * area, size_t size, map2_type & m2, open_type & open)
{
unsigned char const * p = static_cast<unsigned char const *>(area);
for(size_t n = 0; n + sizeof(shared_ptr_layout) <= size; p += pointer_align, n += pointer_align)
{
shared_ptr_layout const * q = reinterpret_cast<shared_ptr_layout const *>(p);
if(q->pn.id == boost::detail::shared_count_id && q->pn.pi != 0 && m2.count(q->pn.pi) != 0)
{
open.push_back(q->pn.pi);
m2.erase(q->pn.pi);
}
}
}
static void find_unreachable_objects_impl(map_type const & m, map2_type & m2)
{
// scan objects for shared_ptr members, compute internal counts
{
std::cout << "... " << m.size() << " objects in m.\n";
for(map_type::const_iterator i = m.begin(); i != m.end(); ++i)
{
boost::detail::sp_counted_base const * p = static_cast<boost::detail::sp_counted_base const *>(i->first);
BOOST_ASSERT(p->use_count() != 0); // there should be no inactive counts in the map
scan_and_count(i->second.first, i->second.second, m, m2);
}
std::cout << "... " << m2.size() << " objects in m2.\n";
}
// mark reachable objects
{
open_type open;
for(map2_type::iterator i = m2.begin(); i != m2.end(); ++i)
{
boost::detail::sp_counted_base const * p = static_cast<boost::detail::sp_counted_base const *>(i->first);
if(p->use_count() != i->second) open.push_back(p);
}
std::cout << "... " << m2.size() << " objects in open.\n";
for(open_type::iterator j = open.begin(); j != open.end(); ++j)
{
m2.erase(*j);
}
while(!open.empty())
{
void const * p = open.front();
open.pop_front();
map_type::const_iterator i = m.find(p);
BOOST_ASSERT(i != m.end());
scan_and_mark(i->second.first, i->second.second, m2, open);
}
}
// m2 now contains the unreachable objects
}
std::size_t find_unreachable_objects(bool report)
{
map2_type m2;
#ifdef BOOST_HAS_THREADS
// This will work without the #ifdef, but some compilers warn
// that lock is not referenced
mutex_type::scoped_lock lock(get_mutex());
#endif
map_type const & m = get_map();
find_unreachable_objects_impl(m, m2);
if(report)
{
for(map2_type::iterator j = m2.begin(); j != m2.end(); ++j)
{
map_type::const_iterator i = m.find(j->first);
BOOST_ASSERT(i != m.end());
std::cout << "Unreachable object at " << i->second.first << ", " << i->second.second << " bytes long.\n";
}
}
return m2.size();
}
typedef std::deque< boost::shared_ptr<X> > free_list_type;
static void scan_and_free(void * area, size_t size, map2_type const & m2, free_list_type & free)
{
unsigned char * p = static_cast<unsigned char *>(area);
for(size_t n = 0; n + sizeof(shared_ptr_layout) <= size; p += pointer_align, n += pointer_align)
{
shared_ptr_layout * q = reinterpret_cast<shared_ptr_layout *>(p);
if(q->pn.id == boost::detail::shared_count_id && q->pn.pi != 0 && m2.count(q->pn.pi) != 0 && q->px != 0)
{
boost::shared_ptr<X> * ppx = reinterpret_cast< boost::shared_ptr<X> * >(p);
free.push_back(*ppx);
ppx->reset();
}
}
}
void free_unreachable_objects()
{
free_list_type free;
{
map2_type m2;
#ifdef BOOST_HAS_THREADS
mutex_type::scoped_lock lock(get_mutex());
#endif
map_type const & m = get_map();
find_unreachable_objects_impl(m, m2);
for(map2_type::iterator j = m2.begin(); j != m2.end(); ++j)
{
map_type::const_iterator i = m.find(j->first);
BOOST_ASSERT(i != m.end());
scan_and_free(i->second.first, i->second.second, m2, free);
}
}
std::cout << "... about to free " << free.size() << " objects.\n";
}
// debug hooks
namespace boost
{
void sp_scalar_constructor_hook(void *)
{
}
void sp_scalar_constructor_hook(void * px, std::size_t size, void * pn)
{
#ifdef BOOST_HAS_THREADS
mutex_type::scoped_lock lock(get_mutex());
#endif
get_map()[pn] = std::make_pair(px, size);
}
void sp_scalar_destructor_hook(void *)
{
}
void sp_scalar_destructor_hook(void *, std::size_t, void * pn)
{
#ifdef BOOST_HAS_THREADS
mutex_type::scoped_lock lock(get_mutex());
#endif
get_map().erase(pn);
}
void sp_array_constructor_hook(void *)
{
}
void sp_array_destructor_hook(void *)
{
}
} // namespace boost
#endif // defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
268
]
]
]
|
8b3ce36787b9b383a11cee53684d055cfa13186e | d1fd652a9f2b1f91972ec2b9c205b3b607bb8cab | /src/StatsPage.cpp | 019a375b079c108fa964c9033b3e31e8325a70ee | []
| no_license | rgw0094/botonoids2008 | 8df56aeed5f327dd53f443f68685fd18d763e7f4 | 6764859c2816c252b46f129fdf4fd77e4de78e04 | refs/heads/master | 2021-01-01T04:06:26.933667 | 2008-11-30T03:58:20 | 2008-11-30T03:58:20 | 56,730,423 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,129 | cpp | #include "StatsPage.h"
#include "game.h"
extern HGE *hge;
extern GameInfo gameInfo;
extern hgeResourceManager *resources;
extern hgeAnimation *botonoidGraphics[NUM_BOTONOIDS];
extern int mode;
extern Menu *menu;
extern std::string botonoidNames[3];
extern Player *players[3];
#define X_OFFSET 300.0
#define Y_OFFSET 100.0
/**
* Constructor
*/
StatsPage::StatsPage() {
active = false;
mouseX = mouseY = 400.0f;
//Wall icon
icons[WALL_ICON].graphic = resources->GetSprite("wallIcon");
strcpy(icons[WALL_ICON].tooltip, "Walls Built");
//Garden icon
icons[GARDEN_ICON].graphic = resources->GetSprite("gardenIcon");
strcpy(icons[GARDEN_ICON].tooltip, "Gardens Built");
//Biggest Combo icon
icons[BIGGEST_COMBO_ICON].graphic = resources->GetSprite("biggestComboIcon");
strcpy(icons[BIGGEST_COMBO_ICON].tooltip, "Largest Combo");
//Time In First icon
icons[TIME_IN_FIRST_ICON].graphic = resources->GetSprite("timeInFirstIcon");
strcpy(icons[TIME_IN_FIRST_ICON].tooltip, "Time in First");
//Items Used icon
icons[ITEMS_USED_ICON].graphic = resources->GetSprite("itemsUsedIcon");
strcpy(icons[ITEMS_USED_ICON].tooltip, "Items Used");
//Damage Dealt icon
icons[DAMAGE_DEALT_ICON].graphic = resources->GetSprite("damageDealtIcon");
strcpy(icons[DAMAGE_DEALT_ICON].tooltip, "Damage Dealt");
//Damage Taken icon
icons[DAMAGE_TAKEN_ICON].graphic = resources->GetSprite("damageTakenIcon");
strcpy(icons[DAMAGE_TAKEN_ICON].tooltip, "Damage Taken");
//Place icons
for (int i = 0; i < NUM_STATS; i++) {
icons[i].mouseOver = false;
placeIcon(i, X_OFFSET + 15.0f, Y_OFFSET + 110.0f + i*50.0f);
}
for (int i = NUM_STATS; i < NUM_STATS + gameInfo.numPlayers; i++) {
placeIcon(i, X_OFFSET-16 + 100.0f + (i-NUM_STATS)*75.0f, Y_OFFSET-16 + 70.0);
}
//Init stats
for (int i = 0; i < 3; i++) {
stats[i].wallsBuilt = stats[i].gardensBuilt = stats[i].biggestCombo = stats[i].numItemsUsed =
stats[i].damageDealt = stats[i].damageTaken = 0;
stats[i].timeWinning = 0.0f;
}
//Create OK Button
okButton = new Button(512.0f - BUTTON_WIDTH/2.0f - 67.0f, 575.0f, "Done");
}
/**
* Destructor
*/
StatsPage::~StatsPage() {
delete okButton;
}
/**
* Draw the stats page
*/
void StatsPage::draw(float dt) {
if (!active) return;
hgeFont *f = resources->GetFont("timer");
//Draw window
resources->GetSprite("statsPage")->RenderEx(X_OFFSET - 10.0, Y_OFFSET - 15.0 + 630.0, -PI/2.0);
//Draw winner
if (gameInfo.winner == -1) {
//Tie
f->printf(X_OFFSET + 280.0/2.0 + 5.0, Y_OFFSET + 10.0f, HGETEXT_CENTER, "Tie Game!");
} else {
f->printf(X_OFFSET + 280.0/2.0 + 5.0, Y_OFFSET + 10.0f, HGETEXT_CENTER, "%s Wins!", botonoidNames[players[gameInfo.winner]->whichBotonoid].c_str());
}
//Draw Icons
for (int i = 0; i < NUM_STATS+gameInfo.numPlayers; i++) {
//Statistic icons
if (i < NUM_STATS) {
icons[i].graphic->Render(icons[i].x, icons[i].y);
if (icons[i].mouseOver) {
f->printf(icons[i].x + 40.0f, icons[i].y-25.0f, HGETEXT_LEFT, "%s", icons[i].tooltip);
}
//Botonoid icons
} else {
int oldFrame = botonoidGraphics[i-NUM_STATS]->GetFrame();
botonoidGraphics[players[i-NUM_STATS]->whichBotonoid]->SetFrame(0);
botonoidGraphics[players[i-NUM_STATS]->whichBotonoid]->Render(icons[i].x+16, icons[i].y+16);
botonoidGraphics[players[i-NUM_STATS]->whichBotonoid]->SetFrame(oldFrame);
if (icons[i].mouseOver) {
f->printf(X_OFFSET + 140.0f, Y_OFFSET + 87.0f, HGETEXT_CENTER, "%s", botonoidNames[players[i-NUM_STATS]->whichBotonoid].c_str());
}
}
}
//Output stats
for (int player = 0; player < gameInfo.numPlayers; player++) {
//Walls built
if (stats[player].wallsBuilt == maxInt(stats[0].wallsBuilt, stats[1].wallsBuilt, stats[2].wallsBuilt))
f->SetColor(ARGB(255,0,255,0));
else f->SetColor(ARGB(255,255,0,0));
f->printf(X_OFFSET + 100.0f + player*75.0f, icons[WALL_ICON].y, HGETEXT_CENTER, "%d", stats[player].wallsBuilt);
//Gardens built
if (stats[player].gardensBuilt == maxInt(stats[0].gardensBuilt, stats[1].gardensBuilt, stats[2].gardensBuilt))
f->SetColor(ARGB(255,0,255,0));
else f->SetColor(ARGB(255,255,0,0));
f->printf(X_OFFSET + 100.0f + player*75.0f, icons[GARDEN_ICON].y, HGETEXT_CENTER, "%d", stats[player].gardensBuilt);
//Biggest Combo
if (stats[player].biggestCombo == maxInt(stats[0].biggestCombo, stats[1].biggestCombo, stats[2].biggestCombo))
f->SetColor(ARGB(255,0,255,0));
else f->SetColor(ARGB(255,255,0,0));
f->printf(X_OFFSET + 100.0f + player*75.0f, icons[BIGGEST_COMBO_ICON].y, HGETEXT_CENTER, "%d", stats[player].biggestCombo);
//Time in first
if ((int)stats[player].timeWinning == maxInt((int)stats[0].timeWinning, (int)stats[1].timeWinning, (int)stats[2].timeWinning))
f->SetColor(ARGB(255,0,255,0));
else f->SetColor(ARGB(255,255,0,0));
f->printf(X_OFFSET + 100.0f + player*75.0f, icons[TIME_IN_FIRST_ICON].y, HGETEXT_CENTER, "%s", formatTime((int)stats[player].timeWinning).c_str());
//Items used
if (stats[player].numItemsUsed == maxInt(stats[0].numItemsUsed, stats[1].numItemsUsed, stats[2].numItemsUsed))
f->SetColor(ARGB(255,0,255,0));
else f->SetColor(ARGB(255,255,0,0));
f->printf(X_OFFSET + 100.0f + player*75.0f,icons[ITEMS_USED_ICON].y, HGETEXT_CENTER, "%d", (int)stats[player].numItemsUsed);
//Damage Dealt
if (stats[player].damageDealt == maxInt(stats[0].damageDealt, stats[1].damageDealt, stats[2].damageDealt))
f->SetColor(ARGB(255,0,255,0));
else f->SetColor(ARGB(255,255,0,0));
f->printf(X_OFFSET + 100.0f + player*75.0f, icons[DAMAGE_DEALT_ICON].y, HGETEXT_CENTER, "%d", (int)stats[player].damageDealt);
//Damage Taken
if (stats[player].damageTaken == minInt(stats[0].damageTaken, stats[1].damageTaken, stats[2].damageTaken))
f->SetColor(ARGB(255,0,255,0));
else f->SetColor(ARGB(255,255,0,0));
f->printf(X_OFFSET + 100.0f + player*75.0f, icons[DAMAGE_TAKEN_ICON].y, HGETEXT_CENTER, "%d", (int)stats[player].damageTaken);
}
f->SetColor(ARGB(255,255,255,255));
//Draw OK Button
okButton->draw(dt);
//Draw mouse
resources->GetSprite("mouse")->Render(mouseX, mouseY);
}
/**
* Places the specified icon at (_x,_y).
*/
void StatsPage::placeIcon(int whichIcon, float _x, float _y) {
icons[whichIcon].x = _x;
icons[whichIcon].y = _y;
icons[whichIcon].collisionBox = new hgeRect(_x, _y, _x + 32.0f, _y + 32.0f);
}
/**
* Update the stats page
*/
void StatsPage::update(float dt) {
//Update mouse position
hge->Input_GetMousePos(&mouseX, &mouseY);
//Update icon mouseovers
for (int i = 0; i < NUM_STATS+gameInfo.numPlayers; i++) {
icons[i].mouseOver = icons[i].collisionBox->TestPoint(mouseX, mouseY);
}
//Mouse click
okButton->update(mouseX, mouseY);
if (okButton->isClicked()) {
active = false;
menu->returnToMenu();
}
//ESC to exit
if (hge->Input_KeyDown(HGEK_ESCAPE)) {
mode = MENU_MODE;
menu->currentScreen = TITLE_SCREEN;
active = false;
}
} | [
"rgw0094@abf6fb0b-8241-0410-81db-47b75ec2d254"
]
| [
[
[
1,
215
]
]
]
|
317e390fb2e6d73112ccfa759a268b0375e5a569 | dec6e8d2f2286d7a4eadf976661a0dd2053e01bd | /subnet.cpp | 0eb3a5a91a89343fca50071a01ae3eb0e22a858b | []
| no_license | tschmidtbhv/ITF10C | e628973e380ef9c59578ecab1e1d88df4e3ca12f | 5508ef638802ed9df387f00ea116fe5bb43e31c4 | refs/heads/master | 2016-09-06T08:39:14.790255 | 2011-12-10T13:48:19 | 2011-12-10T13:48:19 | 2,818,873 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,121 | cpp | #ifndef subnet_functions
#define subnet_functions
// Header für die Klassen einbinden, damit Sie sich selbst kennt.
#include <string>
#include "headers/subnet.h"
#include "headers/ipaddress.h"
using namespace std;
// Default-Konstruktor
subnet::subnet() {};
// Konstruktor mit den wichtigen Parametern
subnet::subnet(
int paramSize,
long paramnetAddress,
long paramrangeStart,
long paramrangeEnd,
long parambroadcast,
string paramName,
string paramNotice
)
{
this->size = paramSize;
this->netAddress = paramnetAddress;
this->rangeStart = paramrangeStart;
this->rangeEnd = paramrangeEnd;
this->broadcast = parambroadcast;
this->name = paramName;
this->notice = paramNotice;
};
// Destruktor
subnet::~subnet() {}
/**
* IP-Adresse hinzufügen
*
* @param ipadress paramipaddress
*/
void subnet::addIP(ipaddress paramipaddress) {
this->usedAddresses.push_back(paramipaddress);
};
/**
* Entfernt eine IP-Adresse aus dem Vector mit der Auflistung
*
* @param ipaddress paramIp
*/
void subnet::dropIP(ipaddress paramIp) {
// Jedes Element durchgehen bis wir das gefunden haben das wir löschen wollen.
for(int i = 0; i < this->usedAddresses.size(); i++)
{
// Wenn wir das zu löschende gefunden haben
if(this->usedAddresses[i].getLong() == paramIp.getLong())
{
// Objekt löschen vom ersten Objekt aus plus der Anzahl an Iterationen
this->usedAddresses.erase(this->usedAddresses.begin() + i);
// Arbeit erledigt, raus aus der Schleife
break;
}
}
};
/**
* Prüft ob eine IP in den Range des Subnetzes passt
*
* @param ipaddress paramIp
* @return wenn gefunden dann true, ansonsten false als bool
*/
bool subnet::searchValid(ipaddress paramIp) {
if(
this->rangeStart <= paramIp.getLong() &&
paramIp.getLong() <= this->rangeEnd
)
{
return true;
}
else
{
return false;
}
}
/**
* Sucht ob eine Adresse explizit vergeben ist (mit Hostnamen)
*
* @param IP-Adresse in numerischer Notation
* @return wenn gefunden dann true, ansonsten false als bool
*/
bool subnet::searchExists(ipaddress paramIp) {
for(int i = 0; i < this->usedAddresses.size(); i++)
{
if(this->usedAddresses[i].getLong() == paramIp.getLong())
{
return true;
}
}
return false;
}
/**
* Gibt ein Vector-Objekt mit allen defineirten IP-Adressen zurück
*
* @return usedAddresses as <vector>ipadress
*/
vector<ipaddress> subnet::getAddresses() {
return this->usedAddresses;
}
/**
* Gibt den Anfang der Ranges in numerische Notation zurück
*
* @return rangeStart as long
*/
long subnet::getRangeStart() {
return this->rangeStart;
};
/**
* Gibt den Ende der Range in numerischer Notation zurück
*
* @return rangeEnd as long
*/
long subnet::getRangeEnd() {
return this->rangeEnd;
};
/**
* Gibt die Broadcast-Adresse als numerische Notation zurück
*
* @return broadcast as long
*/
long subnet::getBroadCast() {
return this->broadcast;
};
/**
* Gibt die Netzadresse als numerische Notation zurück
*
* @return netaddress as long
*/
long subnet::getNetAdress() {
return this->netAddress;
};
/**
* Gibt den Namen als String zurück
*
* @return Name as String
*/
string subnet::getName() {
return this->name;
}
/**
* Gibt die Notiz als String zurück
*
* @return Notice as String
*/
string subnet::getNotice() {
return this->notice;
}
/**
* Setz Notiz für ein Subnetz
*
* @param Neue Notiz als String
*/
void subnet::setNotice(string paramNotice) {
this->notice = paramNotice;
}
/**
* Setz Name für ein Subnetz
*
* @param Neue Notiz als String
*/
void subnet::setName(string paramName) {
this->name = paramName;
}
/**
* Größe abfragen
*/
int subnet::getSize() {
return this->size;
}
#endif | [
"[email protected]"
]
| [
[
[
1,
189
]
]
]
|
56aac74cd36b2c2cd7a38ae3ddbb5d06604bd2f6 | 9566086d262936000a914c5dc31cb4e8aa8c461c | /EnigmaCommon/TargetPreferenceTypes.hpp | d2304b0cc1e33537c7d460b0e4567322b8cf2e80 | []
| no_license | pazuzu156/Enigma | 9a0aaf0cd426607bb981eb46f5baa7f05b66c21f | b8a4dfbd0df206e48072259dbbfcc85845caad76 | refs/heads/master | 2020-06-06T07:33:46.385396 | 2011-12-19T03:14:15 | 2011-12-19T03:14:15 | 3,023,618 | 1 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 1,401 | hpp | #ifndef TARGETPREFERENCETYPES_HPP_INCLUDED
#define TARGETPREFERENCETYPES_HPP_INCLUDED
/*
Copyright © 2009 Christopher Joseph Dean Schaefer (disks86)
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "TypeDefs.hpp"
namespace Enigma
{
const static size_t TARGETPREFERENCETYPE_NONE=0;
const static size_t TARGETPREFERENCETYPE_CHARACTER=1;
const static size_t TARGETPREFERENCETYPE_NPC=2;
const static size_t TARGETPREFERENCETYPE_MONSTER=3;
const static size_t TARGETPREFERENCETYPE_ITEM=4;
const static size_t TARGETPREFERENCETYPE_AREA=5;
};
#endif // TARGETPREFERENCETYPES_HPP_INCLUDED | [
"[email protected]"
]
| [
[
[
1,
28
]
]
]
|
51811a535b2633dd27490d30b14480bf3e2acb89 | 188058ec6dbe8b1a74bf584ecfa7843be560d2e5 | /GodDK/lang/UnsupportedOperationException.h | 5927dbf7c5161ed07e5d617ac82329401d5c5dcb | []
| no_license | mason105/red5cpp | 636e82c660942e2b39c4bfebc63175c8539f7df0 | fcf1152cb0a31560af397f24a46b8402e854536e | refs/heads/master | 2021-01-10T07:21:31.412996 | 2007-08-23T06:29:17 | 2007-08-23T06:29:17 | 36,223,621 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,690 | h | /*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file UnsupportedOperationException.h
* \ingroup CXX_LANG_m
*/
#ifndef _CLASS_GOD_LANG_UNSUPPORTEDOPERATIONEXCEPTION_H
#define _CLASS_GOD_LANG_UNSUPPORTEDOPERATIONEXCEPTION_H
#ifdef __cplusplus
#include "lang/RuntimeException.h"
using goddk::lang::RuntimeException;
namespace goddk {
namespace lang {
/* \ingroup CXX_LANG_m
*/
class UnsupportedOperationException : public RuntimeException
{
public:
inline UnsupportedOperationException()
{
}
inline UnsupportedOperationException(const char* message) : RuntimeException(message)
{
}
inline UnsupportedOperationException(const String* message) : RuntimeException(message)
{
}
inline ~UnsupportedOperationException()
{
}
};
typedef CSmartPtr<UnsupportedOperationException> UnsupportedOperationExceptionPtr;
}
}
#endif
#endif
| [
"soaris@46205fef-a337-0410-8429-7db05d171fc8"
]
| [
[
[
1,
57
]
]
]
|
e8c102f45a7e6c072ccc093bdd667a74a52a4e3f | 95a3e8914ddc6be5098ff5bc380305f3c5bcecb2 | /src/FusionForever_lib/HeavyBlaster.cpp | c8f6593f5f4b53857f01295745daeafe57138bc7 | []
| no_license | danishcake/FusionForever | 8fc3b1a33ac47177666e6ada9d9d19df9fc13784 | 186d1426fe6b3732a49dfc8b60eb946d62aa0e3b | refs/heads/master | 2016-09-05T16:16:02.040635 | 2010-04-24T11:05:10 | 2010-04-24T11:05:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,662 | cpp | #include "StdAfx.h"
#include "HeavyBlaster.h"
#include "MediumBullet.h"
#include "SVGParser.h"
#include "Triangulate.h"
//Initialise all static class members
bool HeavyBlaster::initialised_ = false;
int HeavyBlaster::outline_dl_ = 0;
int HeavyBlaster::outline_verts_index_ = 0;
int HeavyBlaster::fill_dl_ = 0;
int HeavyBlaster::fill_verts_index_ = 0;
HeavyBlaster::HeavyBlaster(void)
: FiringSection()
{
if(!initialised_)
{
InitialiseGraphics();
initialised_ = true;
}
//Get the cached vertices
outline_.GetOutlineVerts() = Datastore::Instance().GetVerts(outline_verts_index_);
outline_.SetDisplayList(outline_dl_);
fill_.GetFillVerts() = Datastore::Instance().GetVerts(fill_verts_index_);
fill_.SetDisplayList(fill_dl_);
findRadius();
health_ = FlexFloat(700, 700);
cooldown_time_ = 0.15f;
default_sub_section_position_ = Vector3f(0, 0, 0);
mass_ = 300;
section_type_ = "HeavyBlaster";
}
HeavyBlaster::~HeavyBlaster(void)
{
}
void HeavyBlaster::InitialiseGraphics()
{
//Initialise outline and fill from embedded SVG from Inkscape
boost::shared_ptr<std::vector<Vector3f>> temp_outline = boost::shared_ptr<std::vector<Vector3f>>(new std::vector<Vector3f>());
*temp_outline = SVGParser::ParsePath("M 0,-2.5 L 2.5,0 L 2.5,2.5 L 2,4.5 L 1,4.5 L 0,2 L -1,4.5 L -2,4.5 L -2.5,2.5 L -2.5,0 L 0,-2.5 z");
temp_outline->pop_back();
outline_verts_index_ = Datastore::Instance().AddVerts(temp_outline);
outline_dl_ = Outlined::CreateOutlinedDisplayList(temp_outline);
boost::shared_ptr<std::vector<Vector3f>> temp_fill = boost::shared_ptr<std::vector<Vector3f>>(new std::vector<Vector3f>());
Triangulate::Process(temp_outline, temp_fill);
fill_verts_index_ = Datastore::Instance().AddVerts(temp_fill);
fill_dl_ = Filled::CreateFillDisplayList(temp_fill);
}
void HeavyBlaster::Tick(float _timespan, std::vector<Projectile_ptr>& _spawn_prj, std::vector<Decoration_ptr>& _spawn_dec, Matrix4f _transform, std::vector<Core_ptr>& _enemies, ICollisionManager* _collision_manager)
{
Section::Tick(_timespan, _spawn_prj, _spawn_dec, _transform, _enemies, _collision_manager);
cooldown_ -= _timespan;
if(firing_)
{
if(cooldown_ <= 0.0f && PowerRequirement(15))
{
Projectile_ptr p1 = new MediumBullet(Vector3f(0, 4, 0));
fire_projectile(p1, _spawn_prj);
cooldown_ = cooldown_time_;
PowerTick(-4);
SoundManager::Instance().PlaySample("Fire10.wav");
}
}
}
void HeavyBlaster::RegisterMetadata()
{
FiringSection::RegisterMetadata();
//Todo this might be wrong atm
SectionMetadata::RegisterSectionKeyValue(section_type_, "Range", 1920);
} | [
"[email protected]"
]
| [
[
[
1,
82
]
]
]
|
7c4d578b4edea01a866bedb1c0b1dfe080983cc4 | 7a0acc1c2e808c7d363043546d9581d21a129693 | /jobbie/src/cpp/InternetExplorerDriver/IEThreadData.h | d9dc47c96c24c1d8388358d45c66c767f2c8a868 | [
"Apache-2.0"
]
| permissive | epall/selenium | 39b9759f8719a168b021b28e500c64afc5f83582 | 273260522efb84116979da2a499f64510250249b | refs/heads/master | 2022-06-25T22:15:25.493076 | 2010-03-11T00:43:02 | 2010-03-11T00:43:02 | 552,908 | 3 | 0 | Apache-2.0 | 2022-06-10T22:44:36 | 2010-03-08T19:10:45 | C | UTF-8 | C++ | false | false | 1,259 | h | /*
Copyright 2007-2009 WebDriver committers
Copyright 2007-2009 Google Inc.
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.
*/
#ifndef JOBBIE_IETHREADDATA_H_
#define JOBBIE_IETHREADDATA_H_
#include "IeSink.h"
#include "DataMarshaller.h"
class IeThreadData
{
public:
IeThreadData(void);
IeSink mSink;
CComPtr<IWebBrowser2> ieThreaded;
std::wstring pathToFrame;
DataMarshaller m_CmdData;
public:
~IeThreadData(void);
};
#define ON_THREAD_COMMON(dataMarshaller) \
DataMarshaller& dataMarshaller = getCmdData(); \
dataMarshaller.resetOutputs(); \
CScopeCaller& SC = *dataMarshaller.scope_caller_;
#define NO_THREAD_COMMON \
getCmdData().scope_caller_->m_releaseOnDestructor = false;
#endif // JOBBIE_IETHREADDATA_H_
| [
"simon.m.stewart@07704840-8298-11de-bf8c-fd130f914ac9"
]
| [
[
[
1,
47
]
]
]
|
f75bf03592d75fd79c25b01da6d6f06b5d9fc59d | 205069c97095da8f15e45cede1525f384ba6efd2 | /Casino/Code/Server/GameModule/P_VideoPoker_5PK1/GameProject/TableFrameSink.h | c6c601def5cfb864eb15dfd1426f15ede78c612f | []
| no_license | m0o0m/01technology | 1a3a5a48a88bec57f6a2d2b5a54a3ce2508de5ea | 5e04cbfa79b7e3cf6d07121273b3272f441c2a99 | refs/heads/master | 2021-01-17T22:12:26.467196 | 2010-01-05T06:39:11 | 2010-01-05T06:39:11 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,251 | h | #pragma once
#include "../../P_Common\VideoPokerTableFrameSink.h"
//游戏桌子类
class CTableFrameSink:public CVideoPokerTableFrameSink
{
public:
CTableFrameSink(void);
~CTableFrameSink(void);
//管理接口
public:
//初始化
virtual bool __cdecl InitTableFrameSink(IUnknownEx * pIUnknownEx);
//复位桌子
virtual void __cdecl RepositTableFrameSink();
//游戏事件
public:
//游戏开始
virtual bool __cdecl OnEventGameStart();
//游戏结束
virtual bool __cdecl OnEventGameEnd(WORD wChairID, IServerUserItem * pIServerUserItem, BYTE cbReason);
//发送场景
virtual bool __cdecl SendGameScene(WORD wChiarID, IServerUserItem * pIServerUserItem, BYTE bGameStatus, bool bSendSecret);
//人工智能游戏动作
virtual bool __cdecl OnPerformAIGameAction();
//事件接口
public:
//定时器事件
virtual bool __cdecl OnTimerMessage(WORD wTimerID, WPARAM wBindParam);
//游戏消息处理
virtual bool __cdecl OnGameMessage(WORD wSubCmdID, const void * pDataBuffer, WORD wDataSize, IServerUserItem * pIServerUserItem);
//框架消息处理
virtual bool __cdecl OnFrameMessage(WORD wSubCmdID, const void * pDataBuffer, WORD wDataSize, IServerUserItem * pIServerUserItem);
};
| [
"[email protected]"
]
| [
[
[
1,
38
]
]
]
|
fa52b4d3a4e97d1698688f8707718d0591d44455 | 9ac7606c5aa3e851a597cca2cd64682d79940ed1 | /labpro-sdk/LabPro_console_src/LabPro_consoleView.h | 479da7aa1cb3f0727e9d58b4ddb45e8a316e6993 | []
| no_license | concord-consortium/labpro-usb | 18422f703f43d672cceb32eb7dae208a0b137274 | ad87bd11d3b574f51ac59b128db86aee9f449200 | HEAD | 2016-09-06T14:22:35.102192 | 2011-11-01T22:24:12 | 2011-11-01T22:24:12 | 2,369,348 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,043 | h | // LabPro_consoleView.h : interface of the CLabPro_consoleView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_LABPRO_CONSOLEVIEW_H__29153F26_3D6C_4009_9792_D64C23E59E02__INCLUDED_)
#define AFX_LABPRO_CONSOLEVIEW_H__29153F26_3D6C_4009_9792_D64C23E59E02__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define REPORT_RECORD_DATA_LENGTH 32
class CLabPro_consoleView : public CListView
{
protected: // create from serialization only
CLabPro_consoleView();
DECLARE_DYNCREATE(CLabPro_consoleView)
// Attributes
public:
CLabPro_consoleDoc* GetDocument();
// Operations
public:
void RecordLabProInput(LPCSTR pBuf, int buf_len);
void RecordLabProOutput(LPCSTR pBuf, int buf_len);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CLabPro_consoleView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void OnInitialUpdate();
protected:
virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CLabPro_consoleView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
void RecordLabProString(LPCSTR pBuf, int buf_len, LPCSTR label);
// Generated message map functions
protected:
//{{AFX_MSG(CLabPro_consoleView)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in LabPro_consoleView.cpp
inline CLabPro_consoleDoc* CLabPro_consoleView::GetDocument()
{ return (CLabPro_consoleDoc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_LABPRO_CONSOLEVIEW_H__29153F26_3D6C_4009_9792_D64C23E59E02__INCLUDED_)
| [
"scytacki@6e01202a-0783-4428-890a-84243c50cc2b"
]
| [
[
[
1,
68
]
]
]
|
ba89e20c71f21a7196476d9484a3a9fb705093c0 | 6520b2b1c45e5a9e5996a9205142de6e2e2cb7ea | /AHL/wolfilair/src/lib/tools/dialog/InformationDialog.h | 21b9355ef019b46c51ba2a61d1e78ab48accf401 | []
| no_license | xpierro/ahl | 6207bc2c309a7f2e4bf659e86fcbf4d889250d82 | 8efd98a6ecc32d794a1e957b0b91eb017546fdf1 | refs/heads/master | 2020-06-04T00:59:13.590942 | 2010-10-21T04:09:48 | 2010-10-21T04:09:48 | 41,411,324 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 480 | h | /*
* InformationDialog.h
*
* Created on: 13 oct. 2010
* Author: Pierre
*/
#ifndef INFORMATIONDIALOG_H_
#define INFORMATIONDIALOG_H_
#include "Dialog.h"
#include <string>
namespace PS3 {
class InformationDialog : public Dialog {
private:
bool* dialogClosed;
public:
InformationDialog(Background, string, bool* b);
virtual ~InformationDialog();
virtual void executeCallback(int buttonType);
};
}
#endif /* INFORMATIONDIALOG_H_ */
| [
"[email protected]"
]
| [
[
[
1,
29
]
]
]
|
2ae621e01990fcaebd43ef3344e54c0a993b2b73 | 718dc2ad71e8b39471b5bf0c6d60cbe5f5c183e1 | /soft micros/Codigo/codigo portable/Lazo/Retransmision/ConfiguracionRetransmision.hpp | 12ecac62810853c8be6e2824960545ed53e1b874 | []
| no_license | jonyMarino/microsdhacel | affb7a6b0ea1f4fd96d79a04d1a3ec3eaa917bca | 66d03c6a9d3a2d22b4d7104e2a38a2c9bb4061d3 | refs/heads/master | 2020-05-18T19:53:51.301695 | 2011-05-30T20:40:24 | 2011-05-30T20:40:24 | 34,532,512 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 741 | hpp | #ifndef _CONFIGURACION_RETRANSMISION_HPP
#define _CONFIGURACION_RETRANSMISION_HPP
#include "Retransmision.hpp"
#include "Memoria/ManejadorMemoria.hpp"
class ConfiguracionRetransm: public ConfiguracionRetransmision{
public:
typedef struct {
int retLow;
int retHi;
}RetConf;
ConfiguracionRetransm( RetConf &_conf_, struct ManejadorMemoria & _manejadorMemoria);
int getLimiteInferior();
int getLimiteSuperior();
void setLimiteInferior(int);
void setLimiteSuperior(int);
private:
ManejadorMemoria &manejadorMemoria;
RetConf &configuracion;
};
#endif | [
"nicopimen@9fc3b3b2-dce3-11dd-9b7c-b771bf68b549"
]
| [
[
[
1,
31
]
]
]
|
5ad2bd168095e8ebcf501834458726ee47ece280 | 3276915b349aec4d26b466d48d9c8022a909ec16 | /c++/运算符重载/重载-》运算符.cpp | 8074fa2cbe36ec001b97a70f21df5b0a5c6cf7c0 | []
| no_license | flyskyosg/3dvc | c10720b1a7abf9cf4fa1a66ef9fc583d23e54b82 | 0279b1a7ae097b9028cc7e4aa2dcb67025f096b9 | refs/heads/master | 2021-01-10T11:39:45.352471 | 2009-07-31T13:13:50 | 2009-07-31T13:13:50 | 48,670,844 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 651 | cpp | #include<iostream> //->重载 // 必须重载为成员函数
using namespace std;
struct s
{
string name;
int num;
s(string s,int a):name(s),num(a)
{}
};
class xiao
{
int a;
s b;
public:
xiao(int x,string s,int y):a(x),b( s,y)
{}
s * operator ->();
};
s* xiao:: operator ->()
{
return &(this->b);
}
int main()
{
xiao a(10,"hello",20);
cout<<a->name<<endl; //->运算符重载
system("pause");
return 0;
}
| [
"[email protected]"
]
| [
[
[
1,
57
]
]
]
|
f5c6304f67d728c00d2042821bcee98fca997b12 | da2408738f182a6844aa656cc6c3769c67ae6772 | /lib/Target/MBlaze/MBlazeISelLowering.cpp | 2f40bfc896016102c4a45daa3b8107dd99dda1e5 | [
"NCSA"
]
| permissive | CAFxX/llvm | 0bf4bd8f63720b979ea5badb46e4defdc2ca8b57 | cb0ca29cca64e75f472af3dc1f98d4e91ca3f92c | refs/heads/master | 2020-06-06T23:28:12.166836 | 2011-02-02T09:28:08 | 2011-02-02T09:28:08 | 1,050,688 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 43,767 | cpp | //===-- MBlazeISelLowering.cpp - MBlaze DAG Lowering Implementation -------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the interfaces that MBlaze uses to lower LLVM code into a
// selection DAG.
//
//===----------------------------------------------------------------------===//
#define DEBUG_TYPE "mblaze-lower"
#include "MBlazeISelLowering.h"
#include "MBlazeMachineFunction.h"
#include "MBlazeTargetMachine.h"
#include "MBlazeTargetObjectFile.h"
#include "MBlazeSubtarget.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
#include "llvm/GlobalVariable.h"
#include "llvm/Intrinsics.h"
#include "llvm/CallingConv.h"
#include "llvm/CodeGen/CallingConvLower.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/SelectionDAGISel.h"
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
static bool CC_MBlaze_AssignReg(unsigned &ValNo, MVT &ValVT, MVT &LocVT,
CCValAssign::LocInfo &LocInfo,
ISD::ArgFlagsTy &ArgFlags,
CCState &State);
const char *MBlazeTargetLowering::getTargetNodeName(unsigned Opcode) const {
switch (Opcode) {
case MBlazeISD::JmpLink : return "MBlazeISD::JmpLink";
case MBlazeISD::GPRel : return "MBlazeISD::GPRel";
case MBlazeISD::Wrap : return "MBlazeISD::Wrap";
case MBlazeISD::ICmp : return "MBlazeISD::ICmp";
case MBlazeISD::Ret : return "MBlazeISD::Ret";
case MBlazeISD::Select_CC : return "MBlazeISD::Select_CC";
default : return NULL;
}
}
MBlazeTargetLowering::MBlazeTargetLowering(MBlazeTargetMachine &TM)
: TargetLowering(TM, new MBlazeTargetObjectFile()) {
Subtarget = &TM.getSubtarget<MBlazeSubtarget>();
// MBlaze does not have i1 type, so use i32 for
// setcc operations results (slt, sgt, ...).
setBooleanContents(ZeroOrOneBooleanContent);
// Set up the register classes
addRegisterClass(MVT::i32, MBlaze::GPRRegisterClass);
if (Subtarget->hasFPU()) {
addRegisterClass(MVT::f32, MBlaze::GPRRegisterClass);
setOperationAction(ISD::ConstantFP, MVT::f32, Legal);
}
// Floating point operations which are not supported
setOperationAction(ISD::FREM, MVT::f32, Expand);
setOperationAction(ISD::UINT_TO_FP, MVT::i8, Expand);
setOperationAction(ISD::UINT_TO_FP, MVT::i16, Expand);
setOperationAction(ISD::UINT_TO_FP, MVT::i32, Expand);
setOperationAction(ISD::FP_TO_UINT, MVT::i32, Expand);
setOperationAction(ISD::FP_ROUND, MVT::f32, Expand);
setOperationAction(ISD::FP_ROUND, MVT::f64, Expand);
setOperationAction(ISD::FCOPYSIGN, MVT::f32, Expand);
setOperationAction(ISD::FCOPYSIGN, MVT::f64, Expand);
setOperationAction(ISD::FSIN, MVT::f32, Expand);
setOperationAction(ISD::FCOS, MVT::f32, Expand);
setOperationAction(ISD::FPOWI, MVT::f32, Expand);
setOperationAction(ISD::FPOW, MVT::f32, Expand);
setOperationAction(ISD::FLOG, MVT::f32, Expand);
setOperationAction(ISD::FLOG2, MVT::f32, Expand);
setOperationAction(ISD::FLOG10, MVT::f32, Expand);
setOperationAction(ISD::FEXP, MVT::f32, Expand);
// Load extented operations for i1 types must be promoted
setLoadExtAction(ISD::EXTLOAD, MVT::i1, Promote);
setLoadExtAction(ISD::ZEXTLOAD, MVT::i1, Promote);
setLoadExtAction(ISD::SEXTLOAD, MVT::i1, Promote);
// Sign extended loads must be expanded
setLoadExtAction(ISD::SEXTLOAD, MVT::i8, Expand);
setLoadExtAction(ISD::SEXTLOAD, MVT::i16, Expand);
// MBlaze has no REM or DIVREM operations.
setOperationAction(ISD::UREM, MVT::i32, Expand);
setOperationAction(ISD::SREM, MVT::i32, Expand);
setOperationAction(ISD::SDIVREM, MVT::i32, Expand);
setOperationAction(ISD::UDIVREM, MVT::i32, Expand);
// If the processor doesn't support multiply then expand it
if (!Subtarget->hasMul()) {
setOperationAction(ISD::MUL, MVT::i32, Expand);
}
// If the processor doesn't support 64-bit multiply then expand
if (!Subtarget->hasMul() || !Subtarget->hasMul64()) {
setOperationAction(ISD::MULHS, MVT::i32, Expand);
setOperationAction(ISD::MULHS, MVT::i64, Expand);
setOperationAction(ISD::MULHU, MVT::i32, Expand);
setOperationAction(ISD::MULHU, MVT::i64, Expand);
}
// If the processor doesn't support division then expand
if (!Subtarget->hasDiv()) {
setOperationAction(ISD::UDIV, MVT::i32, Expand);
setOperationAction(ISD::SDIV, MVT::i32, Expand);
}
// Expand unsupported conversions
setOperationAction(ISD::BITCAST, MVT::f32, Expand);
setOperationAction(ISD::BITCAST, MVT::i32, Expand);
// Expand SELECT_CC
setOperationAction(ISD::SELECT_CC, MVT::Other, Expand);
// MBlaze doesn't have MUL_LOHI
setOperationAction(ISD::SMUL_LOHI, MVT::i32, Expand);
setOperationAction(ISD::UMUL_LOHI, MVT::i32, Expand);
setOperationAction(ISD::SMUL_LOHI, MVT::i64, Expand);
setOperationAction(ISD::UMUL_LOHI, MVT::i64, Expand);
// Used by legalize types to correctly generate the setcc result.
// Without this, every float setcc comes with a AND/OR with the result,
// we don't want this, since the fpcmp result goes to a flag register,
// which is used implicitly by brcond and select operations.
AddPromotedToType(ISD::SETCC, MVT::i1, MVT::i32);
AddPromotedToType(ISD::SELECT, MVT::i1, MVT::i32);
AddPromotedToType(ISD::SELECT_CC, MVT::i1, MVT::i32);
// MBlaze Custom Operations
setOperationAction(ISD::GlobalAddress, MVT::i32, Custom);
setOperationAction(ISD::GlobalTLSAddress, MVT::i32, Custom);
setOperationAction(ISD::JumpTable, MVT::i32, Custom);
setOperationAction(ISD::ConstantPool, MVT::i32, Custom);
// Variable Argument support
setOperationAction(ISD::VASTART, MVT::Other, Custom);
setOperationAction(ISD::VAEND, MVT::Other, Expand);
setOperationAction(ISD::VAARG, MVT::Other, Expand);
setOperationAction(ISD::VACOPY, MVT::Other, Expand);
// Operations not directly supported by MBlaze.
setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32, Expand);
setOperationAction(ISD::BR_JT, MVT::Other, Expand);
setOperationAction(ISD::BR_CC, MVT::Other, Expand);
setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i1, Expand);
setOperationAction(ISD::ROTL, MVT::i32, Expand);
setOperationAction(ISD::ROTR, MVT::i32, Expand);
setOperationAction(ISD::SHL_PARTS, MVT::i32, Expand);
setOperationAction(ISD::SRA_PARTS, MVT::i32, Expand);
setOperationAction(ISD::SRL_PARTS, MVT::i32, Expand);
setOperationAction(ISD::CTLZ, MVT::i32, Expand);
setOperationAction(ISD::CTTZ, MVT::i32, Expand);
setOperationAction(ISD::CTPOP, MVT::i32, Expand);
setOperationAction(ISD::BSWAP, MVT::i32, Expand);
// We don't have line number support yet.
setOperationAction(ISD::EH_LABEL, MVT::Other, Expand);
// Use the default for now
setOperationAction(ISD::STACKSAVE, MVT::Other, Expand);
setOperationAction(ISD::STACKRESTORE, MVT::Other, Expand);
// MBlaze doesn't have extending float->double load/store
setLoadExtAction(ISD::EXTLOAD, MVT::f32, Expand);
setTruncStoreAction(MVT::f64, MVT::f32, Expand);
setStackPointerRegisterToSaveRestore(MBlaze::R1);
computeRegisterProperties();
}
MVT::SimpleValueType MBlazeTargetLowering::getSetCCResultType(EVT VT) const {
return MVT::i32;
}
/// getFunctionAlignment - Return the Log2 alignment of this function.
unsigned MBlazeTargetLowering::getFunctionAlignment(const Function *) const {
return 2;
}
SDValue MBlazeTargetLowering::LowerOperation(SDValue Op,
SelectionDAG &DAG) const {
switch (Op.getOpcode())
{
case ISD::ConstantPool: return LowerConstantPool(Op, DAG);
case ISD::GlobalAddress: return LowerGlobalAddress(Op, DAG);
case ISD::GlobalTLSAddress: return LowerGlobalTLSAddress(Op, DAG);
case ISD::JumpTable: return LowerJumpTable(Op, DAG);
case ISD::SELECT_CC: return LowerSELECT_CC(Op, DAG);
case ISD::VASTART: return LowerVASTART(Op, DAG);
}
return SDValue();
}
//===----------------------------------------------------------------------===//
// Lower helper functions
//===----------------------------------------------------------------------===//
MachineBasicBlock*
MBlazeTargetLowering::EmitInstrWithCustomInserter(MachineInstr *MI,
MachineBasicBlock *MBB)
const {
switch (MI->getOpcode()) {
default: assert(false && "Unexpected instr type to insert");
case MBlaze::ShiftRL:
case MBlaze::ShiftRA:
case MBlaze::ShiftL:
return EmitCustomShift(MI, MBB);
case MBlaze::Select_FCC:
case MBlaze::Select_CC:
return EmitCustomSelect(MI, MBB);
case MBlaze::CAS32:
case MBlaze::SWP32:
case MBlaze::LAA32:
case MBlaze::LAS32:
case MBlaze::LAD32:
case MBlaze::LAO32:
case MBlaze::LAX32:
case MBlaze::LAN32:
return EmitCustomAtomic(MI, MBB);
case MBlaze::MEMBARRIER:
// The Microblaze does not need memory barriers. Just delete the pseudo
// instruction and finish.
MI->eraseFromParent();
return MBB;
}
}
MachineBasicBlock*
MBlazeTargetLowering::EmitCustomShift(MachineInstr *MI,
MachineBasicBlock *MBB) const {
const TargetInstrInfo *TII = getTargetMachine().getInstrInfo();
DebugLoc dl = MI->getDebugLoc();
// To "insert" a shift left instruction, we actually have to insert a
// simple loop. The incoming instruction knows the destination vreg to
// set, the source vreg to operate over and the shift amount.
const BasicBlock *LLVM_BB = MBB->getBasicBlock();
MachineFunction::iterator It = MBB;
++It;
// start:
// andi samt, samt, 31
// beqid samt, finish
// add dst, src, r0
// loop:
// addik samt, samt, -1
// sra dst, dst
// bneid samt, loop
// nop
// finish:
MachineFunction *F = MBB->getParent();
MachineRegisterInfo &R = F->getRegInfo();
MachineBasicBlock *loop = F->CreateMachineBasicBlock(LLVM_BB);
MachineBasicBlock *finish = F->CreateMachineBasicBlock(LLVM_BB);
F->insert(It, loop);
F->insert(It, finish);
// Update machine-CFG edges by transfering adding all successors and
// remaining instructions from the current block to the new block which
// will contain the Phi node for the select.
finish->splice(finish->begin(), MBB,
llvm::next(MachineBasicBlock::iterator(MI)),
MBB->end());
finish->transferSuccessorsAndUpdatePHIs(MBB);
// Add the true and fallthrough blocks as its successors.
MBB->addSuccessor(loop);
MBB->addSuccessor(finish);
// Next, add the finish block as a successor of the loop block
loop->addSuccessor(finish);
loop->addSuccessor(loop);
unsigned IAMT = R.createVirtualRegister(MBlaze::GPRRegisterClass);
BuildMI(MBB, dl, TII->get(MBlaze::ANDI), IAMT)
.addReg(MI->getOperand(2).getReg())
.addImm(31);
unsigned IVAL = R.createVirtualRegister(MBlaze::GPRRegisterClass);
BuildMI(MBB, dl, TII->get(MBlaze::ADDIK), IVAL)
.addReg(MI->getOperand(1).getReg())
.addImm(0);
BuildMI(MBB, dl, TII->get(MBlaze::BEQID))
.addReg(IAMT)
.addMBB(finish);
unsigned DST = R.createVirtualRegister(MBlaze::GPRRegisterClass);
unsigned NDST = R.createVirtualRegister(MBlaze::GPRRegisterClass);
BuildMI(loop, dl, TII->get(MBlaze::PHI), DST)
.addReg(IVAL).addMBB(MBB)
.addReg(NDST).addMBB(loop);
unsigned SAMT = R.createVirtualRegister(MBlaze::GPRRegisterClass);
unsigned NAMT = R.createVirtualRegister(MBlaze::GPRRegisterClass);
BuildMI(loop, dl, TII->get(MBlaze::PHI), SAMT)
.addReg(IAMT).addMBB(MBB)
.addReg(NAMT).addMBB(loop);
if (MI->getOpcode() == MBlaze::ShiftL)
BuildMI(loop, dl, TII->get(MBlaze::ADD), NDST).addReg(DST).addReg(DST);
else if (MI->getOpcode() == MBlaze::ShiftRA)
BuildMI(loop, dl, TII->get(MBlaze::SRA), NDST).addReg(DST);
else if (MI->getOpcode() == MBlaze::ShiftRL)
BuildMI(loop, dl, TII->get(MBlaze::SRL), NDST).addReg(DST);
else
llvm_unreachable("Cannot lower unknown shift instruction");
BuildMI(loop, dl, TII->get(MBlaze::ADDIK), NAMT)
.addReg(SAMT)
.addImm(-1);
BuildMI(loop, dl, TII->get(MBlaze::BNEID))
.addReg(NAMT)
.addMBB(loop);
BuildMI(*finish, finish->begin(), dl,
TII->get(MBlaze::PHI), MI->getOperand(0).getReg())
.addReg(IVAL).addMBB(MBB)
.addReg(NDST).addMBB(loop);
// The pseudo instruction is no longer needed so remove it
MI->eraseFromParent();
return finish;
}
MachineBasicBlock*
MBlazeTargetLowering::EmitCustomSelect(MachineInstr *MI,
MachineBasicBlock *MBB) const {
const TargetInstrInfo *TII = getTargetMachine().getInstrInfo();
DebugLoc dl = MI->getDebugLoc();
// To "insert" a SELECT_CC instruction, we actually have to insert the
// diamond control-flow pattern. The incoming instruction knows the
// destination vreg to set, the condition code register to branch on, the
// true/false values to select between, and a branch opcode to use.
const BasicBlock *LLVM_BB = MBB->getBasicBlock();
MachineFunction::iterator It = MBB;
++It;
// thisMBB:
// ...
// TrueVal = ...
// setcc r1, r2, r3
// bNE r1, r0, copy1MBB
// fallthrough --> copy0MBB
MachineFunction *F = MBB->getParent();
MachineBasicBlock *flsBB = F->CreateMachineBasicBlock(LLVM_BB);
MachineBasicBlock *dneBB = F->CreateMachineBasicBlock(LLVM_BB);
unsigned Opc;
switch (MI->getOperand(4).getImm()) {
default: llvm_unreachable("Unknown branch condition");
case MBlazeCC::EQ: Opc = MBlaze::BEQID; break;
case MBlazeCC::NE: Opc = MBlaze::BNEID; break;
case MBlazeCC::GT: Opc = MBlaze::BGTID; break;
case MBlazeCC::LT: Opc = MBlaze::BLTID; break;
case MBlazeCC::GE: Opc = MBlaze::BGEID; break;
case MBlazeCC::LE: Opc = MBlaze::BLEID; break;
}
F->insert(It, flsBB);
F->insert(It, dneBB);
// Transfer the remainder of MBB and its successor edges to dneBB.
dneBB->splice(dneBB->begin(), MBB,
llvm::next(MachineBasicBlock::iterator(MI)),
MBB->end());
dneBB->transferSuccessorsAndUpdatePHIs(MBB);
MBB->addSuccessor(flsBB);
MBB->addSuccessor(dneBB);
flsBB->addSuccessor(dneBB);
BuildMI(MBB, dl, TII->get(Opc))
.addReg(MI->getOperand(3).getReg())
.addMBB(dneBB);
// sinkMBB:
// %Result = phi [ %FalseValue, copy0MBB ], [ %TrueValue, thisMBB ]
// ...
//BuildMI(dneBB, dl, TII->get(MBlaze::PHI), MI->getOperand(0).getReg())
// .addReg(MI->getOperand(1).getReg()).addMBB(flsBB)
// .addReg(MI->getOperand(2).getReg()).addMBB(BB);
BuildMI(*dneBB, dneBB->begin(), dl,
TII->get(MBlaze::PHI), MI->getOperand(0).getReg())
.addReg(MI->getOperand(2).getReg()).addMBB(flsBB)
.addReg(MI->getOperand(1).getReg()).addMBB(MBB);
MI->eraseFromParent(); // The pseudo instruction is gone now.
return dneBB;
}
MachineBasicBlock*
MBlazeTargetLowering::EmitCustomAtomic(MachineInstr *MI,
MachineBasicBlock *MBB) const {
const TargetInstrInfo *TII = getTargetMachine().getInstrInfo();
DebugLoc dl = MI->getDebugLoc();
// All atomic instructions on the Microblaze are implemented using the
// load-linked / store-conditional style atomic instruction sequences.
// Thus, all operations will look something like the following:
//
// start:
// lwx RV, RP, 0
// <do stuff>
// swx RV, RP, 0
// addic RC, R0, 0
// bneid RC, start
//
// exit:
//
// To "insert" a shift left instruction, we actually have to insert a
// simple loop. The incoming instruction knows the destination vreg to
// set, the source vreg to operate over and the shift amount.
const BasicBlock *LLVM_BB = MBB->getBasicBlock();
MachineFunction::iterator It = MBB;
++It;
// start:
// andi samt, samt, 31
// beqid samt, finish
// add dst, src, r0
// loop:
// addik samt, samt, -1
// sra dst, dst
// bneid samt, loop
// nop
// finish:
MachineFunction *F = MBB->getParent();
MachineRegisterInfo &R = F->getRegInfo();
// Create the start and exit basic blocks for the atomic operation
MachineBasicBlock *start = F->CreateMachineBasicBlock(LLVM_BB);
MachineBasicBlock *exit = F->CreateMachineBasicBlock(LLVM_BB);
F->insert(It, start);
F->insert(It, exit);
// Update machine-CFG edges by transfering adding all successors and
// remaining instructions from the current block to the new block which
// will contain the Phi node for the select.
exit->splice(exit->begin(), MBB, llvm::next(MachineBasicBlock::iterator(MI)),
MBB->end());
exit->transferSuccessorsAndUpdatePHIs(MBB);
// Add the fallthrough block as its successors.
MBB->addSuccessor(start);
BuildMI(start, dl, TII->get(MBlaze::LWX), MI->getOperand(0).getReg())
.addReg(MI->getOperand(1).getReg())
.addReg(MBlaze::R0);
MachineBasicBlock *final = start;
unsigned finalReg = 0;
switch (MI->getOpcode()) {
default: llvm_unreachable("Cannot lower unknown atomic instruction!");
case MBlaze::SWP32:
finalReg = MI->getOperand(2).getReg();
start->addSuccessor(exit);
start->addSuccessor(start);
break;
case MBlaze::LAN32:
case MBlaze::LAX32:
case MBlaze::LAO32:
case MBlaze::LAD32:
case MBlaze::LAS32:
case MBlaze::LAA32: {
unsigned opcode = 0;
switch (MI->getOpcode()) {
default: llvm_unreachable("Cannot lower unknown atomic load!");
case MBlaze::LAA32: opcode = MBlaze::ADDIK; break;
case MBlaze::LAS32: opcode = MBlaze::RSUBIK; break;
case MBlaze::LAD32: opcode = MBlaze::AND; break;
case MBlaze::LAO32: opcode = MBlaze::OR; break;
case MBlaze::LAX32: opcode = MBlaze::XOR; break;
case MBlaze::LAN32: opcode = MBlaze::AND; break;
}
finalReg = R.createVirtualRegister(MBlaze::GPRRegisterClass);
start->addSuccessor(exit);
start->addSuccessor(start);
BuildMI(start, dl, TII->get(opcode), finalReg)
.addReg(MI->getOperand(0).getReg())
.addReg(MI->getOperand(2).getReg());
if (MI->getOpcode() == MBlaze::LAN32) {
unsigned tmp = finalReg;
finalReg = R.createVirtualRegister(MBlaze::GPRRegisterClass);
BuildMI(start, dl, TII->get(MBlaze::XORI), finalReg)
.addReg(tmp)
.addImm(-1);
}
break;
}
case MBlaze::CAS32: {
finalReg = MI->getOperand(3).getReg();
final = F->CreateMachineBasicBlock(LLVM_BB);
F->insert(It, final);
start->addSuccessor(exit);
start->addSuccessor(final);
final->addSuccessor(exit);
final->addSuccessor(start);
unsigned CMP = R.createVirtualRegister(MBlaze::GPRRegisterClass);
BuildMI(start, dl, TII->get(MBlaze::CMP), CMP)
.addReg(MI->getOperand(0).getReg())
.addReg(MI->getOperand(2).getReg());
BuildMI(start, dl, TII->get(MBlaze::BNEID))
.addReg(CMP)
.addMBB(exit);
final->moveAfter(start);
exit->moveAfter(final);
break;
}
}
unsigned CHK = R.createVirtualRegister(MBlaze::GPRRegisterClass);
BuildMI(final, dl, TII->get(MBlaze::SWX))
.addReg(finalReg)
.addReg(MI->getOperand(1).getReg())
.addReg(MBlaze::R0);
BuildMI(final, dl, TII->get(MBlaze::ADDIC), CHK)
.addReg(MBlaze::R0)
.addImm(0);
BuildMI(final, dl, TII->get(MBlaze::BNEID))
.addReg(CHK)
.addMBB(start);
// The pseudo instruction is no longer needed so remove it
MI->eraseFromParent();
return exit;
}
//===----------------------------------------------------------------------===//
// Misc Lower Operation implementation
//===----------------------------------------------------------------------===//
//
SDValue MBlazeTargetLowering::LowerSELECT_CC(SDValue Op,
SelectionDAG &DAG) const {
SDValue LHS = Op.getOperand(0);
SDValue RHS = Op.getOperand(1);
SDValue TrueVal = Op.getOperand(2);
SDValue FalseVal = Op.getOperand(3);
DebugLoc dl = Op.getDebugLoc();
unsigned Opc;
SDValue CompareFlag;
if (LHS.getValueType() == MVT::i32) {
Opc = MBlazeISD::Select_CC;
CompareFlag = DAG.getNode(MBlazeISD::ICmp, dl, MVT::i32, LHS, RHS)
.getValue(1);
} else {
llvm_unreachable("Cannot lower select_cc with unknown type");
}
return DAG.getNode(Opc, dl, TrueVal.getValueType(), TrueVal, FalseVal,
CompareFlag);
}
SDValue MBlazeTargetLowering::
LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const {
// FIXME there isn't actually debug info here
DebugLoc dl = Op.getDebugLoc();
const GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
SDValue GA = DAG.getTargetGlobalAddress(GV, dl, MVT::i32);
return DAG.getNode(MBlazeISD::Wrap, dl, MVT::i32, GA);
}
SDValue MBlazeTargetLowering::
LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const {
llvm_unreachable("TLS not implemented for MicroBlaze.");
return SDValue(); // Not reached
}
SDValue MBlazeTargetLowering::
LowerJumpTable(SDValue Op, SelectionDAG &DAG) const {
SDValue ResNode;
SDValue HiPart;
// FIXME there isn't actually debug info here
DebugLoc dl = Op.getDebugLoc();
EVT PtrVT = Op.getValueType();
JumpTableSDNode *JT = cast<JumpTableSDNode>(Op);
SDValue JTI = DAG.getTargetJumpTable(JT->getIndex(), PtrVT, 0);
return DAG.getNode(MBlazeISD::Wrap, dl, MVT::i32, JTI);
}
SDValue MBlazeTargetLowering::
LowerConstantPool(SDValue Op, SelectionDAG &DAG) const {
SDValue ResNode;
ConstantPoolSDNode *N = cast<ConstantPoolSDNode>(Op);
const Constant *C = N->getConstVal();
DebugLoc dl = Op.getDebugLoc();
SDValue CP = DAG.getTargetConstantPool(C, MVT::i32, N->getAlignment(),
N->getOffset(), 0);
return DAG.getNode(MBlazeISD::Wrap, dl, MVT::i32, CP);
}
SDValue MBlazeTargetLowering::LowerVASTART(SDValue Op,
SelectionDAG &DAG) const {
MachineFunction &MF = DAG.getMachineFunction();
MBlazeFunctionInfo *FuncInfo = MF.getInfo<MBlazeFunctionInfo>();
DebugLoc dl = Op.getDebugLoc();
SDValue FI = DAG.getFrameIndex(FuncInfo->getVarArgsFrameIndex(),
getPointerTy());
// vastart just stores the address of the VarArgsFrameIndex slot into the
// memory location argument.
const Value *SV = cast<SrcValueSDNode>(Op.getOperand(2))->getValue();
return DAG.getStore(Op.getOperand(0), dl, FI, Op.getOperand(1),
MachinePointerInfo(SV),
false, false, 0);
}
//===----------------------------------------------------------------------===//
// Calling Convention Implementation
//===----------------------------------------------------------------------===//
#include "MBlazeGenCallingConv.inc"
static bool CC_MBlaze_AssignReg(unsigned &ValNo, MVT &ValVT, MVT &LocVT,
CCValAssign::LocInfo &LocInfo,
ISD::ArgFlagsTy &ArgFlags,
CCState &State) {
static const unsigned ArgRegs[] = {
MBlaze::R5, MBlaze::R6, MBlaze::R7,
MBlaze::R8, MBlaze::R9, MBlaze::R10
};
const unsigned NumArgRegs = array_lengthof(ArgRegs);
unsigned Reg = State.AllocateReg(ArgRegs, NumArgRegs);
if (!Reg) return false;
unsigned SizeInBytes = ValVT.getSizeInBits() >> 3;
State.AllocateStack(SizeInBytes, SizeInBytes);
State.addLoc(CCValAssign::getReg(ValNo, ValVT, Reg, LocVT, LocInfo));
return true;
}
//===----------------------------------------------------------------------===//
// Call Calling Convention Implementation
//===----------------------------------------------------------------------===//
/// LowerCall - functions arguments are copied from virtual regs to
/// (physical regs)/(stack frame), CALLSEQ_START and CALLSEQ_END are emitted.
/// TODO: isVarArg, isTailCall.
SDValue MBlazeTargetLowering::
LowerCall(SDValue Chain, SDValue Callee, CallingConv::ID CallConv,
bool isVarArg, bool &isTailCall,
const SmallVectorImpl<ISD::OutputArg> &Outs,
const SmallVectorImpl<SDValue> &OutVals,
const SmallVectorImpl<ISD::InputArg> &Ins,
DebugLoc dl, SelectionDAG &DAG,
SmallVectorImpl<SDValue> &InVals) const {
// MBlaze does not yet support tail call optimization
isTailCall = false;
// The MBlaze requires stack slots for arguments passed to var arg
// functions even if they are passed in registers.
bool needsRegArgSlots = isVarArg;
MachineFunction &MF = DAG.getMachineFunction();
MachineFrameInfo *MFI = MF.getFrameInfo();
const TargetFrameLowering &TFI = *MF.getTarget().getFrameLowering();
// Analyze operands of the call, assigning locations to each operand.
SmallVector<CCValAssign, 16> ArgLocs;
CCState CCInfo(CallConv, isVarArg, getTargetMachine(), ArgLocs,
*DAG.getContext());
CCInfo.AnalyzeCallOperands(Outs, CC_MBlaze);
// Get a count of how many bytes are to be pushed on the stack.
unsigned NumBytes = CCInfo.getNextStackOffset();
// Variable argument function calls require a minimum of 24-bytes of stack
if (isVarArg && NumBytes < 24) NumBytes = 24;
Chain = DAG.getCALLSEQ_START(Chain, DAG.getIntPtrConstant(NumBytes, true));
SmallVector<std::pair<unsigned, SDValue>, 8> RegsToPass;
SmallVector<SDValue, 8> MemOpChains;
// Walk the register/memloc assignments, inserting copies/loads.
for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) {
CCValAssign &VA = ArgLocs[i];
MVT RegVT = VA.getLocVT();
SDValue Arg = OutVals[i];
// Promote the value if needed.
switch (VA.getLocInfo()) {
default: llvm_unreachable("Unknown loc info!");
case CCValAssign::Full: break;
case CCValAssign::SExt:
Arg = DAG.getNode(ISD::SIGN_EXTEND, dl, RegVT, Arg);
break;
case CCValAssign::ZExt:
Arg = DAG.getNode(ISD::ZERO_EXTEND, dl, RegVT, Arg);
break;
case CCValAssign::AExt:
Arg = DAG.getNode(ISD::ANY_EXTEND, dl, RegVT, Arg);
break;
}
// Arguments that can be passed on register must be kept at
// RegsToPass vector
if (VA.isRegLoc()) {
RegsToPass.push_back(std::make_pair(VA.getLocReg(), Arg));
} else {
// Register can't get to this point...
assert(VA.isMemLoc());
// Since we are alread passing values on the stack we don't
// need to worry about creating additional slots for the
// values passed via registers.
needsRegArgSlots = false;
// Create the frame index object for this incoming parameter
unsigned ArgSize = VA.getValVT().getSizeInBits()/8;
unsigned StackLoc = VA.getLocMemOffset() + 4;
int FI = MFI->CreateFixedObject(ArgSize, StackLoc, true);
SDValue PtrOff = DAG.getFrameIndex(FI,getPointerTy());
// emit ISD::STORE whichs stores the
// parameter value to a stack Location
MemOpChains.push_back(DAG.getStore(Chain, dl, Arg, PtrOff,
MachinePointerInfo(),
false, false, 0));
}
}
// If we need to reserve stack space for the arguments passed via registers
// then create a fixed stack object at the beginning of the stack.
if (needsRegArgSlots && TFI.hasReservedCallFrame(MF))
MFI->CreateFixedObject(28,0,true);
// Transform all store nodes into one single node because all store
// nodes are independent of each other.
if (!MemOpChains.empty())
Chain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other,
&MemOpChains[0], MemOpChains.size());
// Build a sequence of copy-to-reg nodes chained together with token
// chain and flag operands which copy the outgoing args into registers.
// The InFlag in necessary since all emited instructions must be
// stuck together.
SDValue InFlag;
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
Chain = DAG.getCopyToReg(Chain, dl, RegsToPass[i].first,
RegsToPass[i].second, InFlag);
InFlag = Chain.getValue(1);
}
// If the callee is a GlobalAddress/ExternalSymbol node (quite common, every
// direct call is) turn it into a TargetGlobalAddress/TargetExternalSymbol
// node so that legalize doesn't hack it.
if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee))
Callee = DAG.getTargetGlobalAddress(G->getGlobal(), dl,
getPointerTy(), 0, 0);
else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee))
Callee = DAG.getTargetExternalSymbol(S->getSymbol(),
getPointerTy(), 0);
// MBlazeJmpLink = #chain, #target_address, #opt_in_flags...
// = Chain, Callee, Reg#1, Reg#2, ...
//
// Returns a chain & a flag for retval copy to use.
SDVTList NodeTys = DAG.getVTList(MVT::Other, MVT::Glue);
SmallVector<SDValue, 8> Ops;
Ops.push_back(Chain);
Ops.push_back(Callee);
// Add argument registers to the end of the list so that they are
// known live into the call.
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
Ops.push_back(DAG.getRegister(RegsToPass[i].first,
RegsToPass[i].second.getValueType()));
}
if (InFlag.getNode())
Ops.push_back(InFlag);
Chain = DAG.getNode(MBlazeISD::JmpLink, dl, NodeTys, &Ops[0], Ops.size());
InFlag = Chain.getValue(1);
// Create the CALLSEQ_END node.
Chain = DAG.getCALLSEQ_END(Chain, DAG.getIntPtrConstant(NumBytes, true),
DAG.getIntPtrConstant(0, true), InFlag);
if (!Ins.empty())
InFlag = Chain.getValue(1);
// Handle result values, copying them out of physregs into vregs that we
// return.
return LowerCallResult(Chain, InFlag, CallConv, isVarArg,
Ins, dl, DAG, InVals);
}
/// LowerCallResult - Lower the result values of a call into the
/// appropriate copies out of appropriate physical registers.
SDValue MBlazeTargetLowering::
LowerCallResult(SDValue Chain, SDValue InFlag, CallingConv::ID CallConv,
bool isVarArg, const SmallVectorImpl<ISD::InputArg> &Ins,
DebugLoc dl, SelectionDAG &DAG,
SmallVectorImpl<SDValue> &InVals) const {
// Assign locations to each value returned by this call.
SmallVector<CCValAssign, 16> RVLocs;
CCState CCInfo(CallConv, isVarArg, getTargetMachine(),
RVLocs, *DAG.getContext());
CCInfo.AnalyzeCallResult(Ins, RetCC_MBlaze);
// Copy all of the result registers out of their specified physreg.
for (unsigned i = 0; i != RVLocs.size(); ++i) {
Chain = DAG.getCopyFromReg(Chain, dl, RVLocs[i].getLocReg(),
RVLocs[i].getValVT(), InFlag).getValue(1);
InFlag = Chain.getValue(2);
InVals.push_back(Chain.getValue(0));
}
return Chain;
}
//===----------------------------------------------------------------------===//
// Formal Arguments Calling Convention Implementation
//===----------------------------------------------------------------------===//
/// LowerFormalArguments - transform physical registers into
/// virtual registers and generate load operations for
/// arguments places on the stack.
SDValue MBlazeTargetLowering::
LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
const SmallVectorImpl<ISD::InputArg> &Ins,
DebugLoc dl, SelectionDAG &DAG,
SmallVectorImpl<SDValue> &InVals) const {
MachineFunction &MF = DAG.getMachineFunction();
MachineFrameInfo *MFI = MF.getFrameInfo();
MBlazeFunctionInfo *MBlazeFI = MF.getInfo<MBlazeFunctionInfo>();
unsigned StackReg = MF.getTarget().getRegisterInfo()->getFrameRegister(MF);
MBlazeFI->setVarArgsFrameIndex(0);
// Used with vargs to acumulate store chains.
std::vector<SDValue> OutChains;
// Keep track of the last register used for arguments
unsigned ArgRegEnd = 0;
// Assign locations to all of the incoming arguments.
SmallVector<CCValAssign, 16> ArgLocs;
CCState CCInfo(CallConv, isVarArg, getTargetMachine(),
ArgLocs, *DAG.getContext());
CCInfo.AnalyzeFormalArguments(Ins, CC_MBlaze);
SDValue StackPtr;
for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) {
CCValAssign &VA = ArgLocs[i];
// Arguments stored on registers
if (VA.isRegLoc()) {
MVT RegVT = VA.getLocVT();
ArgRegEnd = VA.getLocReg();
TargetRegisterClass *RC = 0;
if (RegVT == MVT::i32)
RC = MBlaze::GPRRegisterClass;
else if (RegVT == MVT::f32)
RC = MBlaze::GPRRegisterClass;
else
llvm_unreachable("RegVT not supported by LowerFormalArguments");
// Transform the arguments stored on
// physical registers into virtual ones
unsigned Reg = MF.addLiveIn(ArgRegEnd, RC, dl);
SDValue ArgValue = DAG.getCopyFromReg(Chain, dl, Reg, RegVT);
// If this is an 8 or 16-bit value, it has been passed promoted
// to 32 bits. Insert an assert[sz]ext to capture this, then
// truncate to the right size. If if is a floating point value
// then convert to the correct type.
if (VA.getLocInfo() != CCValAssign::Full) {
unsigned Opcode = 0;
if (VA.getLocInfo() == CCValAssign::SExt)
Opcode = ISD::AssertSext;
else if (VA.getLocInfo() == CCValAssign::ZExt)
Opcode = ISD::AssertZext;
if (Opcode)
ArgValue = DAG.getNode(Opcode, dl, RegVT, ArgValue,
DAG.getValueType(VA.getValVT()));
ArgValue = DAG.getNode(ISD::TRUNCATE, dl, VA.getValVT(), ArgValue);
}
InVals.push_back(ArgValue);
} else { // VA.isRegLoc()
// sanity check
assert(VA.isMemLoc());
// The last argument is not a register
ArgRegEnd = 0;
// The stack pointer offset is relative to the caller stack frame.
// Since the real stack size is unknown here, a negative SPOffset
// is used so there's a way to adjust these offsets when the stack
// size get known (on EliminateFrameIndex). A dummy SPOffset is
// used instead of a direct negative address (which is recorded to
// be used on emitPrologue) to avoid mis-calc of the first stack
// offset on PEI::calculateFrameObjectOffsets.
// Arguments are always 32-bit.
unsigned ArgSize = VA.getLocVT().getSizeInBits()/8;
unsigned StackLoc = VA.getLocMemOffset() + 4;
int FI = MFI->CreateFixedObject(ArgSize, 0, true);
MBlazeFI->recordLoadArgsFI(FI, -StackLoc);
MBlazeFI->recordLiveIn(FI);
// Create load nodes to retrieve arguments from the stack
SDValue FIN = DAG.getFrameIndex(FI, getPointerTy());
InVals.push_back(DAG.getLoad(VA.getValVT(), dl, Chain, FIN,
MachinePointerInfo::getFixedStack(FI),
false, false, 0));
}
}
// To meet ABI, when VARARGS are passed on registers, the registers
// must have their values written to the caller stack frame. If the last
// argument was placed in the stack, there's no need to save any register.
if ((isVarArg) && ArgRegEnd) {
if (StackPtr.getNode() == 0)
StackPtr = DAG.getRegister(StackReg, getPointerTy());
// The last register argument that must be saved is MBlaze::R10
TargetRegisterClass *RC = MBlaze::GPRRegisterClass;
unsigned Begin = MBlazeRegisterInfo::getRegisterNumbering(MBlaze::R5);
unsigned Start = MBlazeRegisterInfo::getRegisterNumbering(ArgRegEnd+1);
unsigned End = MBlazeRegisterInfo::getRegisterNumbering(MBlaze::R10);
unsigned StackLoc = Start - Begin + 1;
for (; Start <= End; ++Start, ++StackLoc) {
unsigned Reg = MBlazeRegisterInfo::getRegisterFromNumbering(Start);
unsigned LiveReg = MF.addLiveIn(Reg, RC, dl);
SDValue ArgValue = DAG.getCopyFromReg(Chain, dl, LiveReg, MVT::i32);
int FI = MFI->CreateFixedObject(4, 0, true);
MBlazeFI->recordStoreVarArgsFI(FI, -(StackLoc*4));
SDValue PtrOff = DAG.getFrameIndex(FI, getPointerTy());
OutChains.push_back(DAG.getStore(Chain, dl, ArgValue, PtrOff,
MachinePointerInfo(),
false, false, 0));
// Record the frame index of the first variable argument
// which is a value necessary to VASTART.
if (!MBlazeFI->getVarArgsFrameIndex())
MBlazeFI->setVarArgsFrameIndex(FI);
}
}
// All stores are grouped in one node to allow the matching between
// the size of Ins and InVals. This only happens when on varg functions
if (!OutChains.empty()) {
OutChains.push_back(Chain);
Chain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other,
&OutChains[0], OutChains.size());
}
return Chain;
}
//===----------------------------------------------------------------------===//
// Return Value Calling Convention Implementation
//===----------------------------------------------------------------------===//
SDValue MBlazeTargetLowering::
LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
const SmallVectorImpl<ISD::OutputArg> &Outs,
const SmallVectorImpl<SDValue> &OutVals,
DebugLoc dl, SelectionDAG &DAG) const {
// CCValAssign - represent the assignment of
// the return value to a location
SmallVector<CCValAssign, 16> RVLocs;
// CCState - Info about the registers and stack slot.
CCState CCInfo(CallConv, isVarArg, getTargetMachine(),
RVLocs, *DAG.getContext());
// Analize return values.
CCInfo.AnalyzeReturn(Outs, RetCC_MBlaze);
// If this is the first return lowered for this function, add
// the regs to the liveout set for the function.
if (DAG.getMachineFunction().getRegInfo().liveout_empty()) {
for (unsigned i = 0; i != RVLocs.size(); ++i)
if (RVLocs[i].isRegLoc())
DAG.getMachineFunction().getRegInfo().addLiveOut(RVLocs[i].getLocReg());
}
SDValue Flag;
// Copy the result values into the output registers.
for (unsigned i = 0; i != RVLocs.size(); ++i) {
CCValAssign &VA = RVLocs[i];
assert(VA.isRegLoc() && "Can only return in registers!");
Chain = DAG.getCopyToReg(Chain, dl, VA.getLocReg(),
OutVals[i], Flag);
// guarantee that all emitted copies are
// stuck together, avoiding something bad
Flag = Chain.getValue(1);
}
// If this function is using the interrupt_handler calling convention
// then use "rtid r14, 0" otherwise use "rtsd r15, 8"
unsigned Ret = (CallConv == llvm::CallingConv::MBLAZE_INTR) ? MBlazeISD::IRet
: MBlazeISD::Ret;
unsigned Reg = (CallConv == llvm::CallingConv::MBLAZE_INTR) ? MBlaze::R14
: MBlaze::R15;
SDValue DReg = DAG.getRegister(Reg, MVT::i32);
if (Flag.getNode())
return DAG.getNode(Ret, dl, MVT::Other, Chain, DReg, Flag);
return DAG.getNode(Ret, dl, MVT::Other, Chain, DReg);
}
//===----------------------------------------------------------------------===//
// MBlaze Inline Assembly Support
//===----------------------------------------------------------------------===//
/// getConstraintType - Given a constraint letter, return the type of
/// constraint it is for this target.
MBlazeTargetLowering::ConstraintType MBlazeTargetLowering::
getConstraintType(const std::string &Constraint) const
{
// MBlaze specific constrainy
//
// 'd' : An address register. Equivalent to r.
// 'y' : Equivalent to r; retained for
// backwards compatibility.
// 'f' : Floating Point registers.
if (Constraint.size() == 1) {
switch (Constraint[0]) {
default : break;
case 'd':
case 'y':
case 'f':
return C_RegisterClass;
break;
}
}
return TargetLowering::getConstraintType(Constraint);
}
/// Examine constraint type and operand type and determine a weight value.
/// This object must already have been set up with the operand type
/// and the current alternative constraint selected.
TargetLowering::ConstraintWeight
MBlazeTargetLowering::getSingleConstraintMatchWeight(
AsmOperandInfo &info, const char *constraint) const {
ConstraintWeight weight = CW_Invalid;
Value *CallOperandVal = info.CallOperandVal;
// If we don't have a value, we can't do a match,
// but allow it at the lowest weight.
if (CallOperandVal == NULL)
return CW_Default;
const Type *type = CallOperandVal->getType();
// Look at the constraint type.
switch (*constraint) {
default:
weight = TargetLowering::getSingleConstraintMatchWeight(info, constraint);
break;
case 'd':
case 'y':
if (type->isIntegerTy())
weight = CW_Register;
break;
case 'f':
if (type->isFloatTy())
weight = CW_Register;
break;
}
return weight;
}
/// getRegClassForInlineAsmConstraint - Given a constraint letter (e.g. "r"),
/// return a list of registers that can be used to satisfy the constraint.
/// This should only be used for C_RegisterClass constraints.
std::pair<unsigned, const TargetRegisterClass*> MBlazeTargetLowering::
getRegForInlineAsmConstraint(const std::string &Constraint, EVT VT) const {
if (Constraint.size() == 1) {
switch (Constraint[0]) {
case 'r':
return std::make_pair(0U, MBlaze::GPRRegisterClass);
case 'f':
if (VT == MVT::f32)
return std::make_pair(0U, MBlaze::GPRRegisterClass);
}
}
return TargetLowering::getRegForInlineAsmConstraint(Constraint, VT);
}
/// Given a register class constraint, like 'r', if this corresponds directly
/// to an LLVM register class, return a register of 0 and the register class
/// pointer.
std::vector<unsigned> MBlazeTargetLowering::
getRegClassForInlineAsmConstraint(const std::string &Constraint, EVT VT) const {
if (Constraint.size() != 1)
return std::vector<unsigned>();
switch (Constraint[0]) {
default : break;
case 'r':
// GCC MBlaze Constraint Letters
case 'd':
case 'y':
case 'f':
return make_vector<unsigned>(
MBlaze::R3, MBlaze::R4, MBlaze::R5, MBlaze::R6,
MBlaze::R7, MBlaze::R9, MBlaze::R10, MBlaze::R11,
MBlaze::R12, MBlaze::R19, MBlaze::R20, MBlaze::R21,
MBlaze::R22, MBlaze::R23, MBlaze::R24, MBlaze::R25,
MBlaze::R26, MBlaze::R27, MBlaze::R28, MBlaze::R29,
MBlaze::R30, MBlaze::R31, 0);
}
return std::vector<unsigned>();
}
bool MBlazeTargetLowering::
isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const {
// The MBlaze target isn't yet aware of offsets.
return false;
}
bool MBlazeTargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT) const {
return VT != MVT::f32;
}
| [
"peckw@91177308-0d34-0410-b5e6-96231b3b80d8",
"djg@91177308-0d34-0410-b5e6-96231b3b80d8",
"dpatel@91177308-0d34-0410-b5e6-96231b3b80d8",
"lattner@91177308-0d34-0410-b5e6-96231b3b80d8",
"asl@91177308-0d34-0410-b5e6-96231b3b80d8",
"baldrick@91177308-0d34-0410-b5e6-96231b3b80d8",
"evancheng@91177308-0d34-0410-b5e6-96231b3b80d8",
"jtsoftware@91177308-0d34-0410-b5e6-96231b3b80d8"
]
| [
[
[
1,
195
],
[
198,
212
],
[
215,
241
],
[
243,
568
],
[
571,
591
],
[
593,
594
],
[
597,
601
],
[
603,
607
],
[
609,
621
],
[
623,
624
],
[
626,
632
],
[
638,
638
],
[
641,
644
],
[
647,
686
],
[
688,
689
],
[
691,
699
],
[
701,
721
],
[
724,
761
],
[
764,
793
],
[
795,
803
],
[
805,
839
],
[
841,
869
],
[
871,
875
],
[
877,
896
],
[
898,
909
],
[
911,
946
],
[
948,
952
],
[
955,
975
],
[
977,
978
],
[
980,
981
],
[
984,
987
],
[
990,
1010
],
[
1013,
1039
],
[
1041,
1088
],
[
1107,
1108
],
[
1120,
1171
]
],
[
[
196,
197
],
[
213,
214
],
[
242,
242
],
[
569,
570
],
[
592,
592
],
[
595,
595
],
[
602,
602
],
[
608,
608
],
[
622,
622
],
[
625,
625
],
[
633,
637
],
[
639,
640
],
[
687,
687
],
[
690,
690
],
[
723,
723
],
[
840,
840
],
[
870,
870
],
[
876,
876
],
[
988,
989
],
[
1011,
1012
],
[
1040,
1040
]
],
[
[
596,
596
],
[
794,
794
],
[
910,
910
],
[
976,
976
]
],
[
[
645,
646
],
[
762,
763
],
[
804,
804
],
[
953,
954
],
[
982,
983
]
],
[
[
700,
700
]
],
[
[
722,
722
],
[
897,
897
]
],
[
[
947,
947
],
[
979,
979
]
],
[
[
1089,
1106
],
[
1109,
1119
]
]
]
|
7dfba680004ce4c709253c1ba4fd60f499fd832c | 78af025c564e5a348fd268e2f398a79a9b76d7d1 | /src/iPhoneToday/my_dlls.cpp | 242f6aa567272fd457974815fe76249aba07ef88 | []
| no_license | tronikos/iphonetoday | c2482f527299f315440a1afa1df72ab8e4f68154 | d2ba13d97df16270c61642b2f477af8480c6abdf | refs/heads/master | 2021-01-01T18:22:46.483398 | 2011-05-14T05:20:58 | 2011-05-14T05:20:58 | 32,228,280 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,824 | cpp | #include "stdafx.h"
typedef BOOL (STDAPICALLTYPE FAR fSipShowIM)(DWORD);
static fSipShowIM *pSipShowIM = NULL;
typedef BOOL (STDAPICALLTYPE FAR fSipGetInfo)(SIPINFO*);
static fSipGetInfo *pSipGetInfo = NULL;
typedef BOOL (STDAPICALLTYPE FAR fGetSystemPowerStatusEx)(PSYSTEM_POWER_STATUS_EX,BOOL);
static fGetSystemPowerStatusEx *pGetSystemPowerStatusEx = NULL;
typedef BOOL (STDAPICALLTYPE FAR fAlphaBlend)(HDC,int,int,int,int,HDC,int,int,int,int,BLENDFUNCTION);
static fAlphaBlend *pAlphaBlend = NULL;
typedef BOOL (STDAPICALLTYPE FAR fGradientFill)(HDC,PTRIVERTEX,ULONG,PVOID,ULONG,ULONG);
static fGradientFill *pGradientFill = NULL;
BOOL InitCoredll()
{
static HMODULE hCoredllLib = NULL;
if (hCoredllLib != NULL)
return TRUE;
hCoredllLib = LoadLibrary(L"coredll.dll");
if (hCoredllLib == NULL)
return FALSE;
pSipShowIM = (fSipShowIM*)GetProcAddress(hCoredllLib, L"SipShowIM");
pSipGetInfo = (fSipGetInfo*)GetProcAddress(hCoredllLib, L"SipGetInfo");
pGetSystemPowerStatusEx = (fGetSystemPowerStatusEx*)GetProcAddress(hCoredllLib, L"GetSystemPowerStatusEx");
pAlphaBlend = (fAlphaBlend*)GetProcAddress(hCoredllLib, L"AlphaBlend");
pGradientFill = (fGradientFill*)GetProcAddress(hCoredllLib, L"GradientFill");
return TRUE;
}
BOOL WINAPI SipShowIM(DWORD dwFlag)
{
if (InitCoredll() && pSipShowIM != NULL)
return pSipShowIM(dwFlag);
return FALSE;
}
BOOL WINAPI SipGetInfo(SIPINFO* pSipInfo)
{
if (InitCoredll() && pSipGetInfo != NULL)
return pSipGetInfo(pSipInfo);
return FALSE;
}
BOOL WINAPI GetSystemPowerStatusEx(PSYSTEM_POWER_STATUS_EX pSystemPowerStatusEx, BOOL fUpdate)
{
if (InitCoredll() && pGetSystemPowerStatusEx != NULL)
return pGetSystemPowerStatusEx(pSystemPowerStatusEx, fUpdate);
return FALSE;
}
BOOL AlphaBlend(HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest,
HDC hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc,
BLENDFUNCTION blendFunction)
{
BOOL ret = FALSE;
if (hdcSrc == NULL || hdcDest == NULL)
return FALSE;
if (InitCoredll() && pAlphaBlend != NULL)
ret = pAlphaBlend(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest,
hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc,
blendFunction);
if (ret)
return TRUE;
BITMAPINFO bmInfoDest;
memset(&bmInfoDest.bmiHeader, 0, sizeof(BITMAPINFOHEADER));
bmInfoDest.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmInfoDest.bmiHeader.biWidth = nWidthDest;
bmInfoDest.bmiHeader.biHeight = nHeightDest;
bmInfoDest.bmiHeader.biPlanes = 1;
bmInfoDest.bmiHeader.biBitCount = 32;
BYTE *pDest;
HDC tmp_hdcDest = CreateCompatibleDC(hdcDest);
HBITMAP tmp_bmpDest = CreateDIBSection(hdcDest, &bmInfoDest, DIB_RGB_COLORS, (void**)&pDest, 0, 0);
HGDIOBJ tmp_objDest = SelectObject(tmp_hdcDest, tmp_bmpDest);
BitBlt(tmp_hdcDest, 0, 0, nWidthDest, nHeightDest, hdcDest, nXOriginDest, nYOriginDest, SRCCOPY);
BITMAPINFO bmInfoSrc;
memset(&bmInfoSrc.bmiHeader, 0, sizeof(BITMAPINFOHEADER));
bmInfoSrc.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
//bmInfoSrc.bmiHeader.biWidth = nWidthSrc;
//bmInfoSrc.bmiHeader.biHeight = nHeightSrc;
bmInfoSrc.bmiHeader.biWidth = nWidthDest;
bmInfoSrc.bmiHeader.biHeight = nHeightDest;
bmInfoSrc.bmiHeader.biPlanes = 1;
bmInfoSrc.bmiHeader.biBitCount = 32;
BYTE *pSrc;
HDC tmp_hdcSrc = CreateCompatibleDC(hdcSrc);
HBITMAP tmp_bmpSrc = CreateDIBSection(hdcSrc, &bmInfoSrc, DIB_RGB_COLORS, (void**)&pSrc, 0, 0);
HGDIOBJ tmp_objSrc = SelectObject(tmp_hdcSrc, tmp_bmpSrc);
if (nWidthDest == nWidthSrc && nHeightDest == nHeightSrc) {
BitBlt(tmp_hdcSrc, 0, 0, nWidthSrc, nHeightSrc,
hdcSrc, nXOriginSrc, nYOriginSrc, SRCCOPY);
} else {
StretchBlt(tmp_hdcSrc, 0, 0, nWidthDest, nHeightDest,
hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, SRCCOPY);
}
BYTE *pD = pDest;
BYTE *pS = pSrc;
for (int i = 0; i < nWidthDest * nHeightDest; i++) {
BYTE a = pS[3];
if (a != 0) {
if (a == 0xFF) {
pD[0] = pS[0];
pD[1] = pS[1];
pD[2] = pS[2];
} else {
BYTE na = ~a;
if (blendFunction.AlphaFormat == AC_SRC_ALPHA_NONPREMULT) {
pD[0] = ((na * pD[0]) >> 8) + (BYTE)((pS[0] * a) >> 8);
pD[1] = ((na * pD[1]) >> 8) + (BYTE)((pS[1] * a) >> 8);
pD[2] = ((na * pD[2]) >> 8) + (BYTE)((pS[2] * a) >> 8);
} else {
pD[0] = ((na * pD[0]) >> 8) + pS[0];
pD[1] = ((na * pD[1]) >> 8) + pS[1];
pD[2] = ((na * pD[2]) >> 8) + pS[2];
}
}
}
pD += 4;
pS += 4;
}
SetDIBitsToDevice(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, 0, 0, 0, nHeightDest, pDest, &bmInfoDest, 0);
DeleteObject(SelectObject(tmp_hdcDest, tmp_objDest));
DeleteDC(tmp_hdcDest);
DeleteObject(SelectObject(tmp_hdcSrc, tmp_objSrc));
DeleteDC(tmp_hdcSrc);
return TRUE;
}
BOOL GradientFill(HDC hdc, PTRIVERTEX pVertex, ULONG nVertex, PVOID pMesh, ULONG nCount, ULONG ulMode)
{
if (InitCoredll() && pGradientFill != NULL)
return pGradientFill(hdc, pVertex, nVertex, pMesh, nCount, ulMode);
return FALSE;
}
typedef BOOL (STDAPICALLTYPE FAR fPropertySheet)(LPCPROPSHEETHEADERW);
static fPropertySheet *pPropertySheet = NULL;
BOOL InitCommctrl()
{
static HMODULE hCommctrLib = NULL;
if (hCommctrLib != NULL)
return TRUE;
hCommctrLib = LoadLibrary(L"commctrl.dll");
if (hCommctrLib == NULL)
return FALSE;
pPropertySheet = (fPropertySheet*)GetProcAddress(hCommctrLib, L"PropertySheetW");
return TRUE;
}
WINCOMMCTRLAPI int WINAPI PropertySheet(LPCPROPSHEETHEADERW lppsph)
{
if (InitCommctrl() && pPropertySheet != NULL)
return pPropertySheet(lppsph);
return -1;
}
typedef BOOL (STDAPICALLTYPE FAR fChooseColor)(LPCHOOSECOLOR);
static fChooseColor *pChooseColor = NULL;
BOOL InitCommdlg()
{
static HMODULE hCommdlgLib = NULL;
if (hCommdlgLib != NULL)
return TRUE;
hCommdlgLib = LoadLibrary(L"commdlg.dll");
if (hCommdlgLib == NULL)
return FALSE;
pChooseColor = (fChooseColor*)GetProcAddress(hCommdlgLib, L"ChooseColor");
return TRUE;
}
BOOL ChooseColor(LPCHOOSECOLOR lpcc)
{
if (InitCommdlg() && pChooseColor != NULL)
return pChooseColor(lpcc);
return FALSE;
}
/*
int MulDiv(int a, int b, int c)
{
__int64 ret = ((__int64) a * (__int64) b) / c;
if(ret > INT_MAX || ret < INT_MIN)
return -1;
return (int) ret;
}
*/
typedef HRESULT (STDAPICALLTYPE FAR fCoInitializeEx)(LPVOID,DWORD);
static fCoInitializeEx *pCoInitializeEx = NULL;
typedef void (STDAPICALLTYPE FAR fCoUninitialize)();
static fCoUninitialize *pCoUninitialize = NULL;
typedef HRESULT (STDAPICALLTYPE FAR fCoCreateInstance)(REFCLSID,LPUNKNOWN,DWORD,REFIID,LPVOID*);
static fCoCreateInstance *pCoCreateInstance = NULL;
BOOL InitOle32()
{
static HMODULE hOl32Lib = NULL;
if (hOl32Lib != NULL)
return TRUE;
hOl32Lib = LoadLibrary(L"ole32.dll");
if (hOl32Lib == NULL)
return FALSE;
pCoInitializeEx = (fCoInitializeEx*)GetProcAddress(hOl32Lib, L"CoInitializeEx");
pCoUninitialize = (fCoUninitialize*)GetProcAddress(hOl32Lib, L"CoUninitialize");
pCoCreateInstance = (fCoCreateInstance*)GetProcAddress(hOl32Lib, L"CoCreateInstance");
return TRUE;
}
HRESULT CoInitializeEx(LPVOID pvReserved, DWORD dwCoInit)
{
if (InitOle32() && pCoInitializeEx != NULL)
return pCoInitializeEx(pvReserved, dwCoInit);
return S_FALSE;
}
void CoUninitialize()
{
if (InitOle32() && pCoUninitialize != NULL)
pCoUninitialize();
}
STDAPI CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID* ppv)
{
if (InitOle32() && pCoCreateInstance != NULL)
return pCoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv);
return S_FALSE;
}
| [
"[email protected]"
]
| [
[
[
1,
247
]
]
]
|
92fead613523ad62868630188b80a6c53bddf555 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/_Interface/WndIndirectTalk.h | 2d246ad8ca10daea6007625ed698b37dde4511e5 | []
| no_license | willrebuild/flyffsf | e5911fb412221e00a20a6867fd00c55afca593c7 | d38cc11790480d617b38bb5fc50729d676aef80d | refs/heads/master | 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,215 | h | #ifndef __WNDINDIRECTTALK__H
#define __WNDINDIRECTTALK__H
class CWndIndirectTalk : public CWndNeuz
{
public:
CWndIndirectTalk();
virtual ~CWndIndirectTalk();
virtual BOOL Initialize( CWndBase* pWndParent = NULL, DWORD nType = MB_OK );
virtual BOOL OnChildNotify( UINT message, UINT nID, LRESULT* pLResult );
virtual void OnDraw( C2DRender* p2DRender );
virtual void OnInitialUpdate();
virtual BOOL OnCommand( UINT nID, DWORD dwMessage, CWndBase* pWndBase );
virtual void OnSize( UINT nType, int cx, int cy );
virtual void OnLButtonUp( UINT nFlags, CPoint point );
virtual void OnLButtonDown( UINT nFlags, CPoint point );
};
class CWndCoupleTalk:public CWndNeuz
{
public:
CWndCoupleTalk();
~CWndCoupleTalk();
virtual BOOL Initialize( CWndBase* pWndParent = NULL, DWORD nType = MB_OK );
virtual BOOL OnChildNotify( UINT message, UINT nID, LRESULT* pLResult );
virtual void OnInitialUpdate();
virtual BOOL OnCommand( UINT nID, DWORD dwMessage, CWndBase* pWndBase );
virtual void OnSize( UINT nType, int cx, int cy );
virtual void OnLButtonUp( UINT nFlags, CPoint point );
virtual void OnLButtonDown( UINT nFlags, CPoint point );
};
#endif
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
33
]
]
]
|
013aa20aee363489c2d13c9e474e9a6bff4e5fab | 94c8d7cd5c270a7812085d5ecb747312fc377c75 | /cpp/cudaemu.h | aeeece25686fb39154c62168435a57b3235861e2 | []
| no_license | sidegate/GHOWL | 81c86073f0a621500a73051a8fad3721102c496d | c501aafa0c11e320bc4ac185c47aba3cdafc47fb | refs/heads/master | 2020-04-06T03:32:38.778061 | 2010-02-17T10:05:33 | 2010-02-17T10:05:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,966 | h | #define __GPU_CPU__ __device__ __host__
#define __GPU__ __device__
#ifndef __CUDACC__
#include <cstdlib>
#include <cstring>
#include <map>
using std::map;
#define cudaSuccess 0;
#define cudaHostAllocDefault 0 ///< Default page-locked allocation flag
#define cudaHostAllocPortable 1 ///< Pinned memory accessible by all CUDA contexts
#define cudaHostAllocMapped 2 ///< Map allocation into device space
#define cudaHostAllocWriteCombined 4 ///< Write-combined memory
#define cudaEventDefault 0 ///< Default event flag
#define cudaEventBlockingSync 1 ///< Event uses blocking synchronization
#define cudaDeviceScheduleAuto 0 ///< Device flag - Automatic scheduling
#define cudaDeviceScheduleSpin 1 ///< Device flag - Spin default scheduling
#define cudaDeviceScheduleYield 2 ///< Device flag - Yield default scheduling
#define cudaDeviceBlockingSync 4 ///< Device flag - Use blocking synchronization
#define cudaDeviceMapHost 8 ///< Device flag - Support mapped pinned allocations
#define cudaDeviceMask 0xf ///< Device flags mask
#define __global__
#define __host__
#define __device__
//////////////////////////////////////////////////////////////////////////
typedef int cudaError_t;
typedef int cudaStream_t;
struct cudaArray;
struct cudaChannelFormatDesc;
enum cudaMemcpyKind
{
cudaMemcpyHostToHost,
cudaMemcpyHostToDevice,
cudaMemcpyDeviceToHost,
cudaMemcpyDeviceToDevice,
};
struct dim3
{
dword x, y, z;
dim3(dword x = 1, dword y = 1, dword z = 1)
: x(x), y(y), z(z) {}
};
struct cudaPitchedPtr
{
void *ptr; ///< Pointer to allocated memory
dword pitch; ///< Pitch of allocated memory in bytes
dword xsize; ///< Logical width of allocation in elements
dword ysize; ///< Logical height of allocation in elements
};
struct cudaExtent
{
dword width; ///< Width in bytes
dword height; ///< Height in bytes
dword depth; ///< Depth in bytes
inline bool operator==(const cudaExtent &other) const
{
return width == other.width &&
height == other.height &&
depth == other.depth;
}
};
struct cudaPos
{
dword x;
dword y;
dword z;
};
struct cudaMemcpy3DParms
{
struct cudaArray *srcArray;
struct cudaPos srcPos;
struct cudaPitchedPtr srcPtr;
struct cudaArray *dstArray;
struct cudaPos dstPos;
struct cudaPitchedPtr dstPtr;
struct cudaExtent extent;
enum cudaMemcpyKind kind;
};
extern dim3 threadIdx, blockIdx, blockDim, gridDim;
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// Macros for kernel invocation
//////////////////////////////////////////////////////////////////////////
// One dimensional block of threads - N is an integer
#define KERNEL_1D(f, N) \
gridDim.x = gridDim.y = gridDim.z = 1; \
blockDim.x = N; blockDim.y = blockDim.z = 1; \
blockIdx.x = blockIdx.y = blockIdx.z = 0; \
threadIdx.x = threadIdx.y = threadIdx.z = 0; \
for(; threadIdx.x < N; ++threadIdx.x) f
// N dimensional block of threads - D is a dim3
#define KERNEL_ND(f, D) \
gridDim.x = gridDim.y = gridDim.z = 1; \
blockDim = D; \
blockIdx.x = blockIdx.y = blockIdx.z = 0; \
threadIdx.x = threadIdx.y = threadIdx.z = 0; \
for(threadIdx.z = 0; threadIdx.z < D.z; ++threadIdx.z) \
for(threadIdx.y = 0; threadIdx.y < D.y; ++threadIdx.y) \
for(threadIdx.x = 0; threadIdx.x < D.x; ++threadIdx.x) \
f
// 1D block of threads with a 1D grid of blocks - G & N are integers
#define KERNEL_1D_GRID_1D(f, G, N) \
gridDim.x = G; gridDim.y = gridDim.z = 1; \
blockDim.x = N; blockDim.y = blockDim.z = 1; \
blockIdx.x = blockIdx.y = blockIdx.z = 0; \
threadIdx.x = threadIdx.y = threadIdx.z = 0; \
for(blockIdx.x = 0; blockIdx.x < gridDim.x; ++blockIdx.x) \
for(threadIdx.x = 0; threadIdx.x < blockDim.x; ++threadIdx.x) f
// ND block of threads with a 1D grid of blocks - G is int D is dim3
#define KERNEL_ND_GRID_1D(f, G, D) \
gridDim.x = G; gridDim.y = gridDim.z = 1; \
blockDim = D; \
blockIdx.x = blockIdx.y = blockIdx.z = 0; \
for(blockIdx.x = 0; blockIdx.x < G; ++blockIdx.x) \
for(threadIdx.z = 0; threadIdx.z < blockDim.z; ++threadIdx.z) \
for(threadIdx.y = 0; threadIdx.y < blockDim.y; ++threadIdx.y) \
for(threadIdx.x = 0; threadIdx.x < blockDim.x; ++threadIdx.x) \
f
// 1D block of threads with a 3D grid of blocks - D is int G is dim3
#define KERNEL_1D_GRID_ND(f, G, N) \
gridDim = G; \
blockDim.x = N; blockDim.y = blockDim.z = 1; \
for(blockIdx.z = 0; blockIdx.z < gridDim.z; ++blockIdx.z) \
for(blockIdx.y = 0; blockIdx.y < gridDim.y; ++blockIdx.y) \
for(blockIdx.x = 0; blockIdx.x < gridDim.x; ++blockIdx.x) \
for(threadIdx.x = threadIdx.y = threadIdx.z = 0; \
threadIdx.x < N; ++threadIdx.x)\
f
#define KERNEL_ND_GRID_ND(f, G, N) \
gridDim.x = gridDim.y = gridDim.z = G; \
blockDim.x = blockDim.y = blockDim.z = N; \
for(blockIdx.z = 0; blockIdx.z < gridDim.z; ++blockIdx.z) \
for(blockIdx.y = 0; blockIdx.y < gridDim.y; ++blockIdx.y) \
for(blockIdx.x = 0; blockIdx.x < gridDim.x; ++blockIdx.x) \
for(threadIdx.z = 0; threadIdx.z < blockDim.z; ++threadIdx.z) \
for(threadIdx.y = 0; threadIdx.y < blockDim.y; ++threadIdx.y) \
for(threadIdx.x = 0; threadIdx.x < blockDim.x; ++threadIdx.x) \
f
//////////////////////////////////////////////////////////////////////////
cudaError_t cudaFree(void *devPtr);
cudaError_t cudaFreeArray(cudaArray *array);
cudaError_t cudaFreeHost(void *ptr);
cudaError_t cudaGetSymbolAddress(void **devPtr, const char *symbol);
cudaError_t cudaGetSymbolSize(dword *size, const char *symbol);
cudaError_t cudaHostAlloc(void **ptr, dword size, dword flags);
cudaError_t cudaHostGetDevicePointer(void **pDevice, void *pHost, dword flags);
cudaError_t cudaHostGetFlags(dword *pFlags, void *pHost);
cudaError_t cudaMalloc(void **devPtr, dword size);
cudaError_t cudaMalloc3D(cudaPitchedPtr *pitchedDevPtr, cudaExtent extent);
cudaError_t cudaMalloc3DArray(cudaArray **arrayPtr, const cudaChannelFormatDesc *desc, cudaExtent extent);
cudaError_t cudaMallocArray(cudaArray **arrayPtr, const cudaChannelFormatDesc *desc, dword width, dword height);
cudaError_t cudaMallocHost(void **ptr, dword size);
cudaError_t cudaMallocPitch(void **devPtr, dword *pitch, dword width, dword height);
cudaError_t cudaMemcpy(void *dst, const void *src, dword count, enum cudaMemcpyKind kind);
cudaError_t cudaMemcpy2D(void *dst, dword dpitch, const void *src, dword spitch, dword widthInBytes, dword height, enum cudaMemcpyKind kind);
cudaError_t cudaMemcpy2DArrayToArray(cudaArray *dst, dword wOffsetDst, dword hOffsetDst, const cudaArray *src, dword wOffsetSrc, dword hOffsetSrc, dword width, dword height, enum cudaMemcpyKind kind);
cudaError_t cudaMemcpy2DAsync(void *dst, dword dpitch, const void *src, dword spitch, dword width, dword height, enum cudaMemcpyKind kind, cudaStream_t stream);
cudaError_t cudaMemcpy2DFromArray(void *dst, dword dpitch, const cudaArray *src, dword wOffset, dword hOffset, dword width, dword height, enum cudaMemcpyKind kind);
cudaError_t cudaMemcpy2DFromArrayAsync(void *dst, dword dpitch, const cudaArray *src, dword wOffset, dword hOffset, dword width, dword height, enum cudaMemcpyKind kind, cudaStream_t stream);
cudaError_t cudaMemcpy2DToArray(cudaArray *dst, dword wOffset, dword hOffset, const void *src, dword spitch, dword width, dword height, cudaMemcpyKind kind);
cudaError_t cudaMemcpy2DToArrayAsync(cudaArray *dst, dword wOffset, dword hOffset, const void *src, dword spitch, dword width, dword height, cudaMemcpyKind kind, cudaStream_t stream);
cudaError_t cudaMemcpy3D(const cudaMemcpy3DParms *p);
cudaError_t cudaMemcpy3DAsync(const cudaMemcpy3DParms *p, cudaStream_t stream);
cudaError_t cudaMemcpyArrayToArray(cudaArray *dst, dword wOffsetDst, dword hOffsetDst, const cudaArray *src, dword wOffsetSrc, dword hOffsetSrc, dword count, cudaMemcpyKind kind);
cudaError_t cudaMemcpyAsync(void *dst, const void *src, dword count, cudaMemcpyKind kind, cudaStream_t stream);
cudaError_t cudaMemcpyFromArray(void *dst, const cudaArray *src, dword wOffset, dword hOffset, dword count, cudaMemcpyKind kind);
cudaError_t cudaMemcpyFromArrayAsync(void *dst, const cudaArray *src, dword wOffset, dword hOffset, dword count, cudaMemcpyKind kind, cudaStream_t stream);
cudaError_t cudaMemcpyFromSymbol(void *dst, const char *symbol, dword count, dword offset, cudaMemcpyKind kind);
cudaError_t cudaMemcpyFromSymbolAsync(void *dst, const char *symbol, dword count, dword offset, cudaMemcpyKind kind, cudaStream_t stream);
cudaError_t cudaMemcpyToArray(cudaArray *dst, dword wOffset, dword hOffset, const void *src, dword count, cudaMemcpyKind kind);
cudaError_t cudaMemcpyToArrayAsync(cudaArray *dst, dword wOffset, dword hOffset, const void *src, dword count, cudaMemcpyKind kind, cudaStream_t stream);
cudaError_t cudaMemcpyToSymbol(const char *symbol, const void *src, dword count, dword offset, cudaMemcpyKind kind);
cudaError_t cudaMemcpyToSymbolAsync(const char *symbol, const void *src, dword count, dword offset, cudaMemcpyKind kind, cudaStream_t stream);
cudaError_t cudaMemset(void *devPtr, int value, dword count);
cudaError_t cudaMemset2D(void *devPtr, dword pitch, int value, dword width, dword height);
cudaError_t cudaMemset3D(cudaPitchedPtr pitchedDevPtr, int value, cudaExtent extent);
cudaError_t cudaSetDeviceFlags(int flags);
cudaError_t cudaGetLastError();
//////////////////////////////////////////////////////////////////////////
// Functions that emulate the CUDA API in plain ol' C++
//////////////////////////////////////////////////////////////////////////
dim3 threadIdx, blockIdx, blockDim, gridDim;
const int g_iAlign = 256;
map<void*, void*> g_AlignedPtrs;
int getAlignedValue(int i, int align = g_iAlign)
{
if(i % g_iAlign)
{
i += g_iAlign;
i -= i % g_iAlign;
}
return i;
}
//////////////////////////////////////////////////////////////////////////
cudaError_t cudaMalloc(void**p, dword iSize)
{
*p = calloc(1, iSize);
return 0;
}
//////////////////////////////////////////////////////////////////////////
cudaError_t cudaHostAlloc(void **p, dword iSize, dword flags)
{
*p = calloc(1, iSize);
return 0;
}
//////////////////////////////////////////////////////////////////////////
cudaError_t cudaFree(void *p)
{
if(g_AlignedPtrs.count(p))
{
free(g_AlignedPtrs[p]);
g_AlignedPtrs.erase(p);
}
else
free(p);
return 0;
}
//////////////////////////////////////////////////////////////////////////
cudaError_t cudaMallocPitch(void **devPtr, dword *pitch, dword w, dword h)
{
// Ensure width of each row is a multiple of align and >= width
*pitch = getAlignedValue(w);
// Allocate extra bytes so that the buffer pointer can be aligned
dword cbBuf = *pitch * h + g_iAlign;
*devPtr = calloc(1, cbBuf);
// Ensure buffer pointer is a multiple of align and >= width
int iAligned = getAlignedValue(int(*devPtr));
// Save the unaligned actual ptr so we can free it later
g_AlignedPtrs[(void*)iAligned] = *devPtr;
*devPtr = (void*)iAligned;
return 0;
}
//////////////////////////////////////////////////////////////////////////
cudaError_t cudaMalloc3D(cudaPitchedPtr *p, cudaExtent e)
{
p->xsize = e.width;
p->ysize = e.height;
return cudaMallocPitch(&p->ptr, &p->pitch, e.width, e.height * e.depth);
}
//////////////////////////////////////////////////////////////////////////
cudaError_t cudaMemcpy(void *d, const void* s, dword n, cudaMemcpyKind kind)
{
memcpy(d, s, n);
return 0;
}
//////////////////////////////////////////////////////////////////////////
cudaError_t cudaMemcpy2D(void *dst, dword dpitch, const void *src, dword spitch, dword widthInBytes, dword height, cudaMemcpyKind kind)
{
char *d = (char*)dst, *s = (char*)src;
for(dword y = 0; y < height; ++y)
{
memcpy(d, s, widthInBytes);
d += dpitch;
s += spitch;
}
return 0;
}
//////////////////////////////////////////////////////////////////////////
cudaError_t cudaMemcpy3D(const cudaMemcpy3DParms *q)
{
cudaMemcpy3DParms parms = *q, *p = &parms;
char *pDst = (char*)p->dstPtr.ptr;
char *pSrc = (char*)p->srcPtr.ptr;
for(dword z = 0; z < p->extent.depth; ++z)
{
cudaMemcpy2D(pDst, p->dstPtr.pitch, pSrc, p->srcPtr.pitch,
p->extent.width, p->extent.height,
cudaMemcpyHostToHost);
pDst += p->dstPtr.pitch * p->extent.height;
pSrc += p->srcPtr.pitch * p->extent.height;
}
return 0;
}
//////////////////////////////////////////////////////////////////////////
cudaError_t cudaMemset(void *devPtr, int value, dword count)
{
memset(devPtr, value, count);
return 0;
}
//////////////////////////////////////////////////////////////////////////
cudaError_t cudaSetDeviceFlags(int flags)
{
return 0;
}
//////////////////////////////////////////////////////////////////////////
cudaError_t cudaHostGetDevicePointer(void **pDevice, void *pHost, dword flags)
{
*pDevice = pHost;
return 0;
}
//////////////////////////////////////////////////////////////////////////
cudaError_t cudaGetLastError()
{
return 0;
}
//////////////////////////////////////////////////////////////////////////
#else
#define KERNEL_1D(f, N) f <<< 1, N >>>
#define KERNEL_ND(f, D) f <<< 1, D >>>
#define KERNEL_1D_GRID_1D(f, G, N) f <<< G, N >>>
#define KERNEL_1D_GRID_ND(f, G, N) f <<< G, N >>>
#define KERNEL_ND_GRID_1D(f, G, N) f <<< G, N >>>
#define KERNEL_ND_GRID_ND(f, G, N) f <<< G, N >>>
#endif
| [
"Me@lambda.(none)"
]
| [
[
[
1,
367
]
]
]
|
c7b5cb8f55d7c3d20a75900b54b95afa6e1f14e9 | b5ab57edece8c14a67cc98e745c7d51449defcff | /Captain's Log/MainGame/Source/States/CSaveState.h | f94bf0927903d3981ee4323ca842175b29fc4bbb | []
| no_license | tabu34/tht-captainslog | c648c6515424a6fcdb628320bc28fc7e5f23baba | 72d72a45e7ea44bdb8c1ffc5c960a0a3845557a2 | refs/heads/master | 2020-05-30T15:09:24.514919 | 2010-07-30T17:05:11 | 2010-07-30T17:05:11 | 32,187,254 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,477 | h |
#ifndef CSaveState_h__
#define CSaveState_h__
#include "IGameState.h"
#include "../GameObjects/CBMPFont.h"
#include "CLoadState.h"
typedef struct
{
bool bBurned;
bool bCloaked;
bool bInvulnerable;
bool bRanged;
bool bStunned;
float fAttackDamage;
float fAttackSpeed;
float fMovementSpeed;
int fAttackRange;
int nArmor;
int nCurHealth;
int nHealthRegenRate;
int nLevel;
int nMaxHealth;
int nSightRange;
int nSubType;
int nEnemyClass;
float fPosX;
float fPosY;
int nType;
int nItemName[4];
int nItemType[4];
int nAmountType[4];
int nAmountCategory[4];
float fAmount[4];
} tUnitSaveInfo;
class CSaveState : public IGameState
{
int m_nBGImage;
CBMPFont m_bfFont;
CBMPFont m_bfWhite;
int m_nMouseX;
int m_nMouseY;
int m_nMousePrevX;
int m_nMousePrevY;
int m_nNumProfiles;
tProfileHeader *m_pProfiles;
int m_nCurrentControl;
int m_nMaxControls;
bool m_bError;
float m_fErrorTimer;
CSaveState();
CSaveState(const CSaveState&);
~CSaveState();
CSaveState& operator=(const CSaveState&);
void LoadProfiles();
public:
static CSaveState* GetInstance();
void Save(int nSlot, float fGameTime, tUnitSaveInfo* pData, int numUnits);
void SaveCurrent(int nSlot);
void Enter();
void Exit();
bool Input();
void Update(float fElapsedTime);
void Render();
};
#endif // CSaveState_h__ | [
"[email protected]@34577012-8437-c882-6fb8-056151eb068d",
"tabu34@34577012-8437-c882-6fb8-056151eb068d"
]
| [
[
[
1,
26
],
[
28,
31
],
[
37,
78
]
],
[
[
27,
27
],
[
32,
36
]
]
]
|
634ddadad66358e8107f336db90bf99d2ad24c5b | 975d45994f670a7f284b0dc88d3a0ebe44458a82 | /Docs/FINAIS/Fonte/servidor/WarBugsServer/WarBugsServer/Includes/CThread.cpp | a3be62e3fe3fa4360f8787b2a0a748201a69d2a8 | []
| no_license | phabh/warbugs | 2b616be17a54fbf46c78b576f17e702f6ddda1e6 | bf1def2f8b7d4267fb7af42df104e9cdbe0378f8 | refs/heads/master | 2020-12-25T08:51:02.308060 | 2010-11-15T00:37:38 | 2010-11-15T00:37:38 | 60,636,297 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 880 | cpp | #ifndef _CTHREAD_CPP_
#define _CTHREAD_CPP_
/*
* ThreadJC.cpp
*
* Created on: 08/12/2008
* Author: kurumim
*/
#include "CThread.h"
CThread::CThread() {}
CThread::~CThread()
{
_endthread();
}
int CThread::Start(void *arg)
{
//pthread_t threads[1];
Arg(arg); // store user data
//char *message1 = "Thread 1";
InitializeCriticalSection(&sessaoCritica);
int errcode = _beginthread( CThread::EntryPoint, 0, (void *)this);
return errcode;
}
void CThread::Run(void * arg)
{
Setup();
Execute();
}
void CThread::Setup()
{
// Do any setup here
}
void CThread::Execute()
{
// Your code goes here
}
void CThread::EntryPoint(void * pthis)
{
CThread * pt = (CThread*)pthis;
pt->Run(pthis);
}
void CThread::EndThread()
{
_endthread();
DeleteCriticalSection(&sessaoCritica);
}
#endif | [
"[email protected]"
]
| [
[
[
1,
60
]
]
]
|
5fd77d25c9d79f2b606164d36e32931d2d8c1d25 | e92a0b984f0798ef2bba9ad4199b431b4f5eb946 | /2010/software/simulateur/captor.h | 8689997275d94618626c26e0a4491c36cb443666 | []
| no_license | AdamdbUT/mac-gyver | c09c1892080bf77c25cb4ca2a7ebaf7be3459032 | 32de5c0989710ccd671d46e0babb602e51bf8ff9 | refs/heads/master | 2021-01-23T15:53:19.383860 | 2010-06-21T13:33:38 | 2010-06-21T13:33:38 | 42,737,082 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 705 | h | #ifndef CAPTORH
#define CAPTORH
#include "../common/lin_alg.h"
#include "sdl.h"
#include "parse_params.h"
#include "object.h"
class captor_t : public params_t
{
public:
vector_t pos; // position par rapport au centre du robot
object_t *robot; // robot de rattachement
simul_info_t *simul_info; // pointeur vers le simulateur
virtual void init_params();
virtual double measure();
virtual void draw();
};
class color_captor_t : public captor_t
{
public:
double measure();
void draw();
};
class dist_captor_t : public captor_t
{
double z;
vector_t dir;
public:
void init_params();
double measure();
void draw();
};
#endif
| [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
15
],
[
17,
25
],
[
27,
37
],
[
39,
42
]
],
[
[
16,
16
],
[
26,
26
],
[
38,
38
]
]
]
|
3d0a44d9ddb3792c2c931c08f7577e378ffc4321 | 5ff30d64df43c7438bbbcfda528b09bb8fec9e6b | /kcore/sys/Atomic.cpp | f01f6ce7bf6e266cadf966257f61ba1fb6541049 | []
| no_license | lvtx/gamekernel | c80cdb4655f6d4930a7d035a5448b469ac9ae924 | a84d9c268590a294a298a4c825d2dfe35e6eca21 | refs/heads/master | 2016-09-06T18:11:42.702216 | 2011-09-27T07:22:08 | 2011-09-27T07:22:08 | 38,255,025 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 95 | cpp | #include "stdafx.h"
#include <kcore/corebase.h>
#include <kcore/sys/Atomic.h>
// empty
| [
"darkface@localhost"
]
| [
[
[
1,
6
]
]
]
|
a926f98f9a6c3d2d112b80a9d4184986370f1ace | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/date_time/test/posix_time/testfiletime_functions.cpp | 58f2158d6f93b228077e66f8c8105a77c74f2bd3 | [
"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 | 2,115 | cpp | /* Copyright (c) 2002,2003, 2004 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
*/
#include "boost/date_time/posix_time/posix_time.hpp"
#include "boost/date_time/testfrmwk.hpp"
#include "boost/date_time/filetime_functions.hpp"
#include <cmath>
#if defined(BOOST_HAS_FTIME)
#include <windows.h>
#endif
int main()
{
#if defined(BOOST_HAS_FTIME) // skip tests if no FILETIME
using namespace boost::posix_time;
// adjustor is used to truncate ptime's fractional seconds for
// comparison with SYSTEMTIME's milliseconds
const int adjustor = time_duration::ticks_per_second() / 1000;
for(int i = 0; i < 5; ++i){
FILETIME ft;
SYSTEMTIME st;
GetSystemTime(&st);
SystemTimeToFileTime(&st,&ft);
ptime pt = from_ftime<ptime>(ft);
check("ptime year matches systemtime year",
st.wYear == pt.date().year());
check("ptime month matches systemtime month",
st.wMonth == pt.date().month());
check("ptime day matches systemtime day",
st.wDay == pt.date().day());
check("ptime hour matches systemtime hour",
st.wHour == pt.time_of_day().hours());
check("ptime minute matches systemtime minute",
st.wMinute == pt.time_of_day().minutes());
check("ptime second matches systemtime second",
st.wSecond == pt.time_of_day().seconds());
check("truncated ptime fractional second matches systemtime millisecond",
st.wMilliseconds == (pt.time_of_day().fractional_seconds() / adjustor)
);
// burn up a little time
for (int j=0; j<100000; j++)
{
SYSTEMTIME tmp;
GetSystemTime(&tmp);
}
} // for loop
#else // BOOST_HAS_FTIME
// we don't want a forced failure here, not a shortcoming
check("FILETIME not available for this compiler/platform", true);
#endif // BOOST_HAS_FTIME
return printTestStats();
}
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
69
]
]
]
|
9da4468852367d726b0837859c6ffc435c8e1618 | 94c1c7459eb5b2826e81ad2750019939f334afc8 | /source/HqDetailList.cpp | 8491e7eae82211360ea6f68acb0980699bd36c72 | []
| no_license | wgwang/yinhustock | 1c57275b4bca093e344a430eeef59386e7439d15 | 382ed2c324a0a657ddef269ebfcd84634bd03c3a | refs/heads/master | 2021-01-15T17:07:15.833611 | 2010-11-27T07:06:40 | 2010-11-27T07:06:40 | 37,531,026 | 1 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 4,620 | cpp | // HqDetailList.cpp : implementation file
//
#include "stdafx.h"
#include "HqDetailList.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CHqDetailList
CHqDetailList::CHqDetailList()
{
}
CHqDetailList::~CHqDetailList()
{
}
BEGIN_MESSAGE_MAP(CHqDetailList, CListCtrl)
//{{AFX_MSG_MAP(CHqDetailList)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CHqDetailList message handlers
void CHqDetailList::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CRect rcItem(lpDrawItemStruct->rcItem);
int nItem = lpDrawItemStruct->itemID;
CImageList* pImageList;
// Save dc state
int nSavedDC = pDC->SaveDC();
///////////Set Back Color/////////////
pDC->SetBkColor(pDoc->m_colorArray[0]);
CBrush brush;
CBrush *poldbrush;
brush.CreateSolidBrush(pDoc->m_colorArray[0]);
poldbrush=pDC->SelectObject(&brush);
pDC->FillRect(rcItem,&brush);
pDC->SelectObject(poldbrush);
//////////////////////////////////
// Get item image and state info
LV_ITEM lvi;
lvi.mask = LVIF_IMAGE | LVIF_STATE;
lvi.iItem = nItem;
lvi.iSubItem = 0;
lvi.stateMask = 0xFFFF; // get all state flags
GetItem(&lvi);
// Get rectangles for drawing
CRect rcBounds, rcLabel, rcIcon;
GetItemRect(nItem, rcBounds, LVIR_BOUNDS);
GetItemRect(nItem, rcLabel, LVIR_LABEL);
GetItemRect(nItem, rcIcon, LVIR_ICON);
CRect rcCol( rcBounds );
CString sLabel = GetItemText( nItem, 0 );
// Labels are offset by a certain amount
// This offset is related to the width of a space character
pDC->SetTextColor(pDoc->m_colorArray[14]);
int offset = pDC->GetTextExtent(_T(" "), 1 ).cx*2;
CRect rcHighlight;
CRect rcWnd;
rcCol.right = rcCol.left + GetColumnWidth(0);
CRgn rgn;
rgn.CreateRectRgnIndirect(&rcCol);
pDC->SelectClipRgn(&rgn);
rgn.DeleteObject();
// Draw state icon
if (lvi.state & LVIS_STATEIMAGEMASK)
{
int nImage = ((lvi.state & LVIS_STATEIMAGEMASK)>>12) - 1;
pImageList = GetImageList(LVSIL_STATE);
if (pImageList)
{
pImageList->Draw(pDC, nImage,
CPoint(rcCol.left, rcCol.top), ILD_TRANSPARENT);
}
}
// Draw item label - Column 0
rcLabel.left += offset/2;
rcLabel.right -= offset;
pDC->DrawText(sLabel,-1,rcLabel,DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP
| DT_VCENTER );
// Draw labels for remaining columns
LV_COLUMN lvc;
lvc.mask = LVCF_FMT | LVCF_WIDTH;
rcBounds.right = rcHighlight.right > rcBounds.right ? rcHighlight.right :
rcBounds.right;
rgn.CreateRectRgnIndirect(&rcBounds);
pDC->SelectClipRgn(&rgn);
double UpOrDown;
for(int nColumn = 1; GetColumn(nColumn, &lvc); nColumn++)
{
if(nColumn == 1)
{
sLabel = GetItemText(nItem, 2);
UpOrDown = atof(sLabel);
if(UpOrDown > 0)
pDC->SetTextColor(pDoc->m_colorArray[13]);
if(UpOrDown < 0)
pDC->SetTextColor(pDoc->m_colorArray[15]);
if(UpOrDown == 0)
pDC->SetTextColor(pDoc->m_colorArray[14]);
}
if(nColumn == 4)
pDC->SetTextColor(pDoc->m_colorArray[13]);
if(nColumn == 5)
pDC->SetTextColor(pDoc->m_colorArray[15]);
if(nColumn == 6 || nColumn == 9)
{
if(UpOrDown > 0)
pDC->SetTextColor(pDoc->m_colorArray[13]);
if(UpOrDown < 0)
pDC->SetTextColor(pDoc->m_colorArray[15]);
if(UpOrDown == 0)
pDC->SetTextColor(pDoc->m_colorArray[14]);
}
if(nColumn == 7)
pDC->SetTextColor(pDoc->m_colorArray[14]);
if(nColumn == 8)
pDC->SetTextColor(pDoc->m_colorArray[14]);
rcCol.left = rcCol.right;
rcCol.right += lvc.cx;
// Draw the background if needed
// if( m_nHighlight == HIGHLIGHT_NORMAL )
// pDC->FillRect(rcCol, &CBrush(::GetSysColor(COLOR_WINDOW)));
sLabel = GetItemText(nItem, nColumn);
if (sLabel.GetLength() == 0)
continue;
UINT nJustify = DT_LEFT;
switch(lvc.fmt & LVCFMT_JUSTIFYMASK)
{
case LVCFMT_RIGHT:
nJustify = DT_RIGHT;
break;
case LVCFMT_CENTER:
nJustify = DT_CENTER;
break;
default:
break;
}
rcLabel = rcCol;
rcLabel.left += offset;
rcLabel.right -= offset;
pDC->DrawText(sLabel, -1, rcLabel, nJustify | DT_SINGLELINE |
DT_NOPREFIX | DT_VCENTER );
}
// Restore dc
pDC->RestoreDC( nSavedDC );
}
| [
"[email protected]"
]
| [
[
[
1,
182
]
]
]
|
7ff15500948f8111cd693728a6b2a1d0a07a7bce | 13e005f9fef38d706c8b1f5ca7d169ff60d61646 | /Phase_III/os.h | 1d88b28b2c276cf7e985977df71fd14ba2d99911 | []
| no_license | akamel001/Virtual-OS | d2c5eeefa55cf26f495baa04822d81db395d6beb | e2a23c98f28ac12d02c3b9ca09c06929c3df2e30 | refs/heads/master | 2020-05-30T10:09:47.553960 | 2011-11-21T23:56:21 | 2011-11-22T00:18:13 | 2,823,966 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 834 | h | #ifndef OS_H
#define OS_H
#include "assembler.h"
#include "VirtualMachine.h"
#include <iomanip>
#include <list>
#include <queue>
#include <stack>
class OS{
public:
OS();
void run();
private:
struct InvertedPage
{
string frameOwner;
int page;
};
vector<InvertedPage *> invertedPageTable;
queue<int> FIFORef;
void assemble_programs();
void print_info();
void check_waitingQ();
void load_page(PCB * p);
void check_kill_frames(stack<int>);
bool check_page(int, PCB *);
void close_streams();
void idle();
void next_job();
int context_switch();
int getEmptyFrame();
Assembler as;
VirtualMachine vm;
list<PCB *> pcb;
list<PCB *> term_jobs;
queue<PCB *> waitingQ, readyQ, runningQ;
PCB * running;
bool FIFO, LRU;
int idle_time, idle_counter;
};
#endif
| [
"[email protected]"
]
| [
[
[
1,
49
]
]
]
|
dabfd5146053be9ea24ccd3023101df162e6c6b4 | 52ee98d8e00d66f71139a2e86f1464244eb1616b | /merge.cpp | 21b330661b6852772d13a0c011b21543f16c4bbc | []
| no_license | shaoyang/algorithm | ea0784e2b92465e54517016a7a8623c109ac9fc1 | 571b6423f5cf7c4bee21ff99b69b972d491c970d | refs/heads/master | 2016-09-05T12:37:14.878376 | 2011-03-22T16:21:58 | 2011-03-22T16:21:58 | 1,502,765 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,684 | cpp | #include<iostream>
using namespace std;
typedef struct Node{
int data;
Node* next;
}Node;
Node* merge(Node* head1,Node* head2){
if(head1 == NULL)
return head2;
if(head2 == NULL)
return head1;
Node* cur = head1;
Node* prev;
Node* p;
int temp;
while(head2 != NULL){
temp = head2->data;
while(cur != NULL &&(cur->data <= temp)){
prev = cur;
cur = cur->next;
}
p = head2;
head2 = head2->next;
prev->next = p;
p->next = cur;
}
return head1;
}
Node* mergeRecursive(Node* head1,Node* head2){
if(head1 == NULL)
return head2;
if(head2 == NULL)
return head1;
Node* head = NULL;
if(head1->data < head2->data){
head = head1;
head->next = mergeRecursive(head1->next,head2);
}
else{
head = head2;
head->next = mergeRecursive(head1,head2->next);
}
}
int main(){
Node* head1;
Node* head2;
Node *cur1,*cur2;
int i;
head1 = new Node;
head1->data = -1;
head1->next = NULL;
cur1 = head1;
head2 = new Node;
head2->data = 0;
head2->next = NULL;
cur2 = head2;
for(i=1;i<10;i++){
Node* tnode = new Node;
tnode->data = i;
tnode->next = NULL;
if(i%2!=0){
cur1->next = tnode;
cur1 = tnode;
}
else{
cur2->next = tnode;
cur2 = tnode;
}
}
cur2 = merge(head1,head2);
while(cur2 != NULL){
cout<<cur2->data<<" ";
cur2 = cur2->next;
}
cout<<"aaa"<<endl;
system("pause");
return 0;
}
| [
"[email protected]"
]
| [
[
[
1,
81
]
]
]
|
d61c9814ef85cdd959f41bfcee702d4dd2139ef4 | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/app/contacts/phonebook_data_management_api/MTPbkIdleFinder/inc/MTPbkIdleFinder.h | b5ecc2c651b163bb8bf59458d6470683d241739b | []
| no_license | SymbianSource/oss.FCL.sftools.ana.compatanamdw | a6a8abf9ef7ad71021d43b7f2b2076b504d4445e | 1169475bbf82ebb763de36686d144336fcf9d93b | refs/heads/master | 2020-12-24T12:29:44.646072 | 2010-11-11T14:03:20 | 2010-11-11T14:03:20 | 72,994,432 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,364 | h | /*
* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: ?Description
*
*/
#ifndef MTPBKIDLEFINDER_H
#define MTPBKIDLEFINDER_H
// INCLUDES
#include <StifLogger.h>
#include <TestScripterInternal.h>
#include <StifTestModule.h>
#include <TestclassAssert.h>
class CPbkContactEngine;
class CPbkContactItem;
class CPbkIdleFinder;
class CContactIdArray;
class CContactEngineEventQueue;
#include <e32def.h>
// CONSTANTS
//const ?type ?constant_var = ?constant;
// MACROS
//#define ?macro ?macro_def
#define TEST_CLASS_VERSION_MAJOR 30
#define TEST_CLASS_VERSION_MINOR 9
#define TEST_CLASS_VERSION_BUILD 38
// Logging path
_LIT( KMTPbkIdleFinderLogPath, "\\logs\\testframework\\MTPbkIdleFinder\\" );
// Log file
_LIT( KMTPbkIdleFinderLogFile, "MTPbkIdleFinder.txt" );
_LIT( KMTPbkIdleFinderLogFileWithTitle, "MTPbkIdleFinder_[%S].txt" );
// FUNCTION PROTOTYPES
//?type ?function_name(?arg_list);
// FORWARD DECLARATIONS
//class ?FORWARD_CLASSNAME;
class CMTPbkIdleFinder;
// DATA TYPES
//enum ?declaration
//typedef ?declaration
//extern ?data_type;
// CLASS DECLARATION
/**
* CMTPbkIdleFinder test class for STIF Test Framework TestScripter.
* ?other_description_lines
*
* @lib ?library
* @since ?Series60_version
*/
NONSHARABLE_CLASS(CMTPbkIdleFinder) : public CScriptBase
{
public: // Constructors and destructor
/**
* Two-phased constructor.
*/
static CMTPbkIdleFinder* NewL( CTestModuleIf& aTestModuleIf );
/**
* Destructor.
*/
virtual ~CMTPbkIdleFinder();
public: // New functions
/**
* ?member_description.
* @since ?Series60_version
* @param ?arg1 ?description
* @return ?description
*/
//?type ?member_function( ?type ?arg1 );
public: // Functions from base classes
/**
* From CScriptBase Runs a script line.
* @since ?Series60_version
* @param aItem Script line containing method name and parameters
* @return Symbian OS error code
*/
virtual TInt RunMethodL( CStifItemParser& aItem );
protected: // New functions
/**
* ?member_description.
* @since ?Series60_version
* @param ?arg1 ?description
* @return ?description
*/
//?type ?member_function( ?type ?arg1 );
protected: // Functions from base classes
/**
* From ?base_class ?member_description
*/
//?type ?member_function();
private:
/**
* C++ default constructor.
*/
CMTPbkIdleFinder( CTestModuleIf& aTestModuleIf );
/**
* By default Symbian 2nd phase constructor is private.
*/
void ConstructL();
// Prohibit copy constructor if not deriving from CBase.
// ?classname( const ?classname& );
// Prohibit assigment operator if not deriving from CBase.
// ?classname& operator=( const ?classname& );
/**
* Frees all resources allocated from test methods.
* @since ?Series60_version
*/
void Delete();
/**
* Test methods are listed below.
*/
void SetTextFieldValueL(CPbkContactItem& aItem,
const TDesC& aTextValue);
void AddTestContactItemsL(TInt count);
void SetupL();
void SetupEmptyL();
void Teardown();
TInt MT_CPbkIdleFinder_FindL();
TInt MT_CPbkIdleFinder_Find1L();
void MT_CPbkIdleFinder_IsCompleteL();
void MT_CPbkIdleFinder_TakeContactIdsL();
void MT_CPbkIdleFinder_ErrorL();
void MT_CPbkIdleFinder_IdleFinderL();
void MT_CPbkIdleFinder_FieldDefL();
/**
* Method used to log version of test class
*/
void SendTestClassVersion();
//ADD NEW METHOD DEC HERE
//[TestMethods] - Do not remove
public:
class CFindObserver;
protected: // Data
// ?one_line_short_description_of_data
//?data_declaration;
private: // Data
CPbkContactEngine* iContactEngine; // owns
CPbkIdleFinder* iIdleFinder; // owns
CPbkContactItem* iContactItem; // owns
CContactIdArray* iFoundContacts;
TInt iTestContactCount;
TBool iRunning;
public: // Friend classes
//?friend_class_declaration;
protected: // Friend classes
//?friend_class_declaration;
private: // Friend classes
//?friend_class_declaration;
};
#endif // MTPBKIDLEFINDER_H
// End of File
| [
"none@none"
]
| [
[
[
1,
211
]
]
]
|
036bc2b1b33632aac6eb92d34621df916c84507e | 0e782c46fd93da70ce3bfc6ea7ff763225b31afd | /src/View3.cpp | 709c04f7beecbea1d1e8d36e1bb8c12682996168 | []
| no_license | dupesnduds/Mp | 58940e12b42ce6169222ce863e6257f5d22726b9 | 4854ba197a8e4701d8fc3cdddbe45636225c555f | refs/heads/master | 2021-05-26T20:09:00.285677 | 2011-09-19T00:50:36 | 2011-09-19T00:50:36 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,766 | cpp | /*
============================================================================
Name : View3.cpp
Author : Cleave Pokotea
Version :
Copyright : 2006 - 2007
Description : View3.cpp - source file
============================================================================
*/
// INCLUDE FILES
#include <aknviewappui.h>
#include <avkon.hrh>
#include <Mp.rsg>
#include <Mp.hrh>
#include "View3.h"
#include "Container3.h"
// ================= MEMBER FUNCTIONS =======================
void CView3::ConstructL()
{
BaseConstructL( R_MP_VIEW2 );
}
CView3::~CView3()
{
if ( iContainer )
{
AppUi()->RemoveFromViewStack( *this, iContainer );
}
delete iContainer;
}
TUid CView3::Id() const
{
return KView3Id;
}
void CView3::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EAknSoftkeyOk:
{
iEikonEnv->InfoMsg( _L("view2 ok") );
break;
}
case EAknSoftkeyBack:
{
TUid vId;
vId.iUid = EMpViewMain;
AppUi()->ActivateLocalViewL(vId);
}
default:
{
AppUi()->HandleCommandL( aCommand );
break;
}
}
}
void CView3::HandleClientRectChange()
{
if ( iContainer )
{
iContainer->SetRect( ClientRect() );
}
}
void CView3::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
TUid /*aCustomMessageId*/,
const TDesC8& /*aCustomMessage*/)
{
if (!iContainer)
{
iContainer = new (ELeave) CContainer3;
iContainer->SetMopParent(this);
iContainer->ConstructL( ClientRect() );
AppUi()->AddToStackL( *this, iContainer );
}
}
void CView3::DoDeactivate()
{
if ( iContainer )
{
AppUi()->RemoveFromViewStack( *this, iContainer );
delete iContainer;
iContainer = NULL;
}
}
| [
"[email protected]"
]
| [
[
[
1,
99
]
]
]
|
48d17520b812b0f7029c8e1c7b11c08dae36f976 | 0b66a94448cb545504692eafa3a32f435cdf92fa | /tags/0.3/cbear.berlios.de/windows/command_line.hpp | 46030783991121b416faeb6a94e5c0cf5a732bed | [
"MIT"
]
| permissive | BackupTheBerlios/cbear-svn | e6629dfa5175776fbc41510e2f46ff4ff4280f08 | 0109296039b505d71dc215a0b256f73b1a60b3af | refs/heads/master | 2021-03-12T22:51:43.491728 | 2007-09-28T01:13:48 | 2007-09-28T01:13:48 | 40,608,034 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,559 | hpp | /*
The MIT License
Copyright (c) 2005 C Bear (http://cbear.berlios.de)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef CBEAR_BERLIOS_DE_WINDOWS_COMMAND_LINE_HPP_INCLUDED
#define CBEAR_BERLIOS_DE_WINDOWS_COMMAND_LINE_HPP_INCLUDED
#include <cbear.berlios.de/windows/lpstr.hpp>
#include <cbear.berlios.de/windows/select.hpp>
namespace cbear_berlios_de
{
namespace windows
{
template<class Char>
basic_lpstr<Char> command_line()
{
return make_lpstr(select<Char>(::GetCommandLineA, ::GetCommandLineW)());
}
}
}
#endif
| [
"sergey_shandar@e6e9985e-9100-0410-869a-e199dc1b6838"
]
| [
[
[
1,
43
]
]
]
|
1b329892e42d05b0ab40cd665ae9a3ba2033870c | 83ed25c6e6b33b2fabd4f81bf91d5fae9e18519c | /code/RemoveVCProcess.cpp | 8c4841d72048ae194c78de5571698aaed08e1e96 | [
"BSD-3-Clause"
]
| permissive | spring/assimp | fb53b91228843f7677fe8ec18b61d7b5886a6fd3 | db29c9a20d0dfa9f98c8fd473824bba5a895ae9e | refs/heads/master | 2021-01-17T23:19:56.511185 | 2011-11-08T12:15:18 | 2011-11-08T12:15:18 | 2,017,841 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 10,044 | cpp | /*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2010, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software 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 ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
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.
---------------------------------------------------------------------------
*/
/** @file Implementation of the post processing step to remove
* any parts of the mesh structure from the imported data.
*/
#include "AssimpPCH.h"
#include "RemoveVCProcess.h"
using namespace Assimp;
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
RemoveVCProcess::RemoveVCProcess()
{}
// ------------------------------------------------------------------------------------------------
// Destructor, private as well
RemoveVCProcess::~RemoveVCProcess()
{}
// ------------------------------------------------------------------------------------------------
// Returns whether the processing step is present in the given flag field.
bool RemoveVCProcess::IsActive( unsigned int pFlags) const
{
return (pFlags & aiProcess_RemoveComponent) != 0;
}
// ------------------------------------------------------------------------------------------------
// Small helper function to delete all elements in a T** aray using delete
template <typename T>
inline void ArrayDelete(T**& in, unsigned int& num)
{
for (unsigned int i = 0; i < num; ++i)
delete in[i];
delete[] in;
in = NULL;
num = 0;
}
#if 0
// ------------------------------------------------------------------------------------------------
// Updates the node graph - removes all nodes which have the "remove" flag set and the
// "don't remove" flag not set. Nodes with meshes are never deleted.
bool UpdateNodeGraph(aiNode* node,std::list<aiNode*>& childsOfParent,bool root)
{
register bool b = false;
std::list<aiNode*> mine;
for (unsigned int i = 0; i < node->mNumChildren;++i)
{
if(UpdateNodeGraph(node->mChildren[i],mine,false))
b = true;
}
// somewhat tricky ... mNumMeshes must be originally 0 and MSB2 may not be set,
// so we can do a simple comparison against MSB here
if (!root && AI_RC_UINT_MSB == node->mNumMeshes )
{
// this node needs to be removed
if(node->mNumChildren)
{
childsOfParent.insert(childsOfParent.end(),mine.begin(),mine.end());
// set all children to NULL to make sure they are not deleted when we delete ourself
for (unsigned int i = 0; i < node->mNumChildren;++i)
node->mChildren[i] = NULL;
}
b = true;
delete node;
}
else
{
AI_RC_UNMASK(node->mNumMeshes);
childsOfParent.push_back(node);
if (b)
{
// reallocate the array of our children here
node->mNumChildren = (unsigned int)mine.size();
aiNode** const children = new aiNode*[mine.size()];
aiNode** ptr = children;
for (std::list<aiNode*>::iterator it = mine.begin(), end = mine.end();
it != end; ++it)
{
*ptr++ = *it;
}
delete[] node->mChildren;
node->mChildren = children;
return false;
}
}
return b;
}
#endif
// ------------------------------------------------------------------------------------------------
// Executes the post processing step on the given imported data.
void RemoveVCProcess::Execute( aiScene* pScene)
{
DefaultLogger::get()->debug("RemoveVCProcess begin");
bool bHas = false; //,bMasked = false;
mScene = pScene;
// handle animations
if ( configDeleteFlags & aiComponent_ANIMATIONS)
{
bHas = true;
ArrayDelete(pScene->mAnimations,pScene->mNumAnimations);
}
// handle textures
if ( configDeleteFlags & aiComponent_TEXTURES)
{
bHas = true;
ArrayDelete(pScene->mTextures,pScene->mNumTextures);
}
// handle materials
if ( configDeleteFlags & aiComponent_MATERIALS && pScene->mNumMaterials)
{
bHas = true;
for (unsigned int i = 1;i < pScene->mNumMaterials;++i)
delete pScene->mMaterials[i];
pScene->mNumMaterials = 1;
aiMaterial* helper = (aiMaterial*) pScene->mMaterials[0];
ai_assert(NULL != helper);
helper->Clear();
// gray
aiColor3D clr(0.6f,0.6f,0.6f);
helper->AddProperty(&clr,1,AI_MATKEY_COLOR_DIFFUSE);
// add a small ambient color value
clr = aiColor3D(0.05f,0.05f,0.05f);
helper->AddProperty(&clr,1,AI_MATKEY_COLOR_AMBIENT);
aiString s;
s.Set("Dummy_MaterialsRemoved");
helper->AddProperty(&s,AI_MATKEY_NAME);
}
// handle light sources
if ( configDeleteFlags & aiComponent_LIGHTS)
{
bHas = true;
ArrayDelete(pScene->mLights,pScene->mNumLights);
}
// handle camneras
if ( configDeleteFlags & aiComponent_CAMERAS)
{
bHas = true;
ArrayDelete(pScene->mCameras,pScene->mNumCameras);
}
// handle meshes
if (configDeleteFlags & aiComponent_MESHES)
{
bHas = true;
ArrayDelete(pScene->mMeshes,pScene->mNumMeshes);
}
else
{
for( unsigned int a = 0; a < pScene->mNumMeshes; a++)
{
if( ProcessMesh( pScene->mMeshes[a]))
bHas = true;
}
}
// now check whether the result is still a full scene
if (!pScene->mNumMeshes || !pScene->mNumMaterials)
{
pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE;
DefaultLogger::get()->debug("Setting AI_SCENE_FLAGS_INCOMPLETE flag");
// If we have no meshes anymore we should also clear another flag ...
if (!pScene->mNumMeshes)
pScene->mFlags &= ~AI_SCENE_FLAGS_NON_VERBOSE_FORMAT;
}
if (bHas)DefaultLogger::get()->info("RemoveVCProcess finished. Data structure cleanup has been done.");
else DefaultLogger::get()->debug("RemoveVCProcess finished. Nothing to be done ...");
}
// ------------------------------------------------------------------------------------------------
// Setup configuration properties for the step
void RemoveVCProcess::SetupProperties(const Importer* pImp)
{
configDeleteFlags = pImp->GetPropertyInteger(AI_CONFIG_PP_RVC_FLAGS,0x0);
if (!configDeleteFlags)
{
DefaultLogger::get()->warn("RemoveVCProcess: AI_CONFIG_PP_RVC_FLAGS is zero.");
}
}
// ------------------------------------------------------------------------------------------------
// Executes the post processing step on the given imported data.
bool RemoveVCProcess::ProcessMesh(aiMesh* pMesh)
{
bool ret = false;
// if all materials have been deleted let the material
// index of the mesh point to the created default material
if ( configDeleteFlags & aiComponent_MATERIALS)
pMesh->mMaterialIndex = 0;
// handle normals
if (configDeleteFlags & aiComponent_NORMALS && pMesh->mNormals)
{
delete[] pMesh->mNormals;
pMesh->mNormals = NULL;
ret = true;
}
// handle tangents and bitangents
if (configDeleteFlags & aiComponent_TANGENTS_AND_BITANGENTS && pMesh->mTangents)
{
delete[] pMesh->mTangents;
pMesh->mTangents = NULL;
delete[] pMesh->mBitangents;
pMesh->mBitangents = NULL;
ret = true;
}
// handle texture coordinates
register bool b = (0 != (configDeleteFlags & aiComponent_TEXCOORDS));
for (unsigned int i = 0, real = 0; real < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++real)
{
if (!pMesh->mTextureCoords[i])break;
if (configDeleteFlags & aiComponent_TEXCOORDSn(real) || b)
{
delete pMesh->mTextureCoords[i];
pMesh->mTextureCoords[i] = NULL;
ret = true;
if (!b)
{
// collapse the rest of the array
for (unsigned int a = i+1; a < AI_MAX_NUMBER_OF_TEXTURECOORDS;++a)
pMesh->mTextureCoords[a-1] = pMesh->mTextureCoords[a];
pMesh->mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS-1] = NULL;
continue;
}
}
++i;
}
// handle vertex colors
b = (0 != (configDeleteFlags & aiComponent_COLORS));
for (unsigned int i = 0, real = 0; real < AI_MAX_NUMBER_OF_COLOR_SETS; ++real)
{
if (!pMesh->mColors[i])break;
if (configDeleteFlags & aiComponent_COLORSn(i) || b)
{
delete pMesh->mColors[i];
pMesh->mColors[i] = NULL;
ret = true;
if (!b)
{
// collapse the rest of the array
for (unsigned int a = i+1; a < AI_MAX_NUMBER_OF_COLOR_SETS;++a)
pMesh->mColors[a-1] = pMesh->mColors[a];
pMesh->mColors[AI_MAX_NUMBER_OF_COLOR_SETS-1] = NULL;
continue;
}
}
++i;
}
// handle bones
if (configDeleteFlags & aiComponent_BONEWEIGHTS && pMesh->mBones)
{
ArrayDelete(pMesh->mBones,pMesh->mNumBones);
ret = true;
}
return ret;
}
| [
"aramis_acg@67173fc5-114c-0410-ac8e-9d2fd5bffc1f"
]
| [
[
[
1,
328
]
]
]
|
0270b8263fd2a8c9fb463d8c5159e6ba979afa07 | eec5b6fa0b8b96d93c076f66a031306664aea8a8 | /src/Win32ClusterdConfig.h | 73bf4c424e461af0dc4ff976eb17b81a55721e42 | []
| no_license | wyrover/Win32Clusterd | 6bcfd4ed39b19b0f714cd7f1c91fa54b4f27746f | 4ecd86075509001d019ceb60bf2d83364bffd3bd | refs/heads/master | 2021-01-18T04:05:25.374565 | 2011-11-08T10:26:34 | 2011-11-08T10:26:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,193 | h | #pragma once
#include "DebugLog.h"
#ifndef COMMAND
# define COMMAND TEXT("Command")
#endif
#ifndef WORKINGDIR
# define WORKINGDIR TEXT("WorkingDir")
#endif
#ifndef BASEPORT
# define BASEPORT TEXT("BasePort")
#endif
#ifndef INSTANCES
# define INSTANCES TEXT("Instances")
#endif
#ifndef SERVICENAME
# define SERVICENAME TEXT("ServiceName")
#endif
class Win32ClusterdConfig
{
public:
Win32ClusterdConfig(void);
~Win32ClusterdConfig(void);
bool configure(int argc, TCHAR* argv[]);
bool clean();
bool set(const TCHAR *key, const TCHAR *value);
bool set(const TCHAR *key, const unsigned int value);
bool get(const TCHAR *key, TCHAR **output);
bool get(const TCHAR *key, unsigned int *output);
protected:
bool write_key(HKEY hKey, const TCHAR *input, const TCHAR *key);
bool write_key(HKEY hKey, const int input, const TCHAR *key);
bool read_key(HKEY hKey, TCHAR **output, const TCHAR *key);
bool read_key(HKEY hKey, unsigned int *output, const TCHAR *key);
bool is_key(const TCHAR* key);
bool check_complete();
bool is_valid(const TCHAR* key);
private:
HKEY m_reg_key;
DebugLog m_log;
};
| [
"[email protected]"
]
| [
[
[
1,
43
]
]
]
|
6b878087cc33cef9a4535cf7a28e8f147ad2f732 | 26b6f15c144c2f7a26ab415c3997597fa98ba30a | /sdp/inc/common.h | eb721a1e986dd9e73ed3ca444a489aed59ba17e5 | []
| no_license | wangscript007/rtspsdk | fb0b52e63ad1671e8b2ded1d8f10ef6c3c63fddf | f5b095f0491e5823f50a83352945acb88f0b8aa0 | refs/heads/master | 2022-03-09T09:25:23.988183 | 2008-12-27T17:23:31 | 2008-12-27T17:23:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,203 | h | /*****************************************************************************
// SDP Parser Classes
//
// Common macroses, definitions and functions
//
// revision of last commit:
// $Rev$
// author of last commit:
// $Author$
// date of last commit:
// $Date$
//
// created by Argenet {[email protected]}
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
******************************************************************************/
#ifndef __COMMON__H__
#define __COMMON__H__
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Includes
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// STL headers
#include <vector>
#include <string>
// PoCo headers
#include "Poco/Types.h"
// headers
#include "sdp_parser.h"
namespace SDP {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Definitions
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
typedef std::vector<std::string> StringVec;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Functions
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SDP_PARSER_API StringVec split(const std::string & str, char splitChar);
/// Returns a string array containing the substrings in this instance
/// that are delimited by elements of the specified char.
SDP_PARSER_API StringVec split(const std::string & str, const std::string & splitString);
/// Returns a string array containing the substrings in this instance
/// that are delimited by the specified split string.
SDP_PARSER_API std::string trim(const std::string & str, char trimChar);
/// Removes all occurrences of the specified character
/// from the string.
} // namespace SDP
#endif // __COMMON__H__
| [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
50
],
[
52,
81
]
],
[
[
51,
51
],
[
82,
83
]
]
]
|
25a8c62a763aa258d28519a62d78b4d893951ff9 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/date_time/test/testint_adapter.cpp | 6e8064a9083e4cd826cadae85d7b1bb69a0cf788 | [
"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 | 5,861 | cpp | /* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
*/
#include "boost/date_time/int_adapter.hpp"
#include "boost/date_time/testfrmwk.hpp"
#include "boost/cstdint.hpp"
#include <iostream>
#include <sstream>
template<typename int_type>
void print()
{
//MSVC 6 has problems with this, but it's not really important
//so we will just skip them....
#if (defined(BOOST_DATE_TIME_NO_LOCALE)) || (defined(BOOST_MSVC) && (_MSC_VER < 1300))
#else
std::cout << "min: " << (int_type::min)().as_number() << std::endl;
std::cout << "max: " << (int_type::max)().as_number() << std::endl;
std::cout << "neg_infin: " <<
int_type::neg_infinity().as_number() << std::endl;
std::cout << "pos_infin: " <<
int_type::pos_infinity().as_number() << std::endl;
std::cout << "not a number: " <<
int_type::not_a_number().as_number() << std::endl;
std::stringstream ss("");
std::string s("");
int_type i = int_type::neg_infinity();
ss << i;
s = "-infinity";
check("streaming -infinity", ss.str() == s);
i = int_type::pos_infinity();
ss.str("");
ss << i;
s = "+infinity";
check("streaming +infinity", ss.str() == s);
i = int_type::not_a_number();
ss.str("");
ss << i;
s = "not-a-number";
check("streaming nan", ss.str() == s);
i = 12;
ss.str("");
ss << i;
s = "12";
check("streaming digits", ss.str() == s);
#endif
}
template<typename int_type>
void test_int()
{
int_type i = int_type::neg_infinity();
check("is infinity", i.is_infinity());
check("is special_value (neg_inf)", i.is_special());
check("as_special convert", boost::date_time::neg_infin == i.as_special() );
check("as_special convert", boost::date_time::neg_infin == int_type::to_special(i.as_number()) );
int_type h = int_type::neg_infinity();
i = int_type::pos_infinity();
check("is infinity", i.is_infinity());
check("as_special convert", boost::date_time::pos_infin == i.as_special() );
check("infinity less", h < i);
check("infinity less", h < 0);
check("infinity greater", i > h);
check("infinity greater", i > 0);
h = int_type::not_a_number();
check("nan less", !(h < 0));
check("nan greater", !(h > 0));
check("nan equal", h == int_type::not_a_number());
i = 1;
check("is infinity", !i.is_infinity());
int_type j = int_type::neg_infinity();
check("infinity less", j < i);
check("infinity less", !(j < j));
check("infinity greater", (i > j));
check("infinity equal", !(j == i));
check("infinity equal", j == j);
check("infinity equal", !(j == 0));
check("infinity not equal", j != 0);
int_type k = 1;
check("as_special convert", boost::date_time::not_special == k.as_special() );
check("equal", i == k);
check("infinity not equal", i != int_type::neg_infinity());
check("infinity not equal", i != int_type::pos_infinity());
int_type l = i + int_type::pos_infinity();
check("is special_value (pos_inf)", l.is_special());
check("add infinity" , l == int_type::pos_infinity());
{ // limiting the scope for these tests was easier than recalculating l
int_type l = i - int_type::pos_infinity();
check("value - +infinity", l == int_type::neg_infinity());
l = i + int_type::neg_infinity();
check("value + -infinity", l == int_type::neg_infinity());
}
check("inf - inf = nan", (l - l) == int_type::not_a_number());
check("-inf + inf = nan", (j + l) == int_type::not_a_number());
check("add 2", (i + 2) == 3);
i = int_type::not_a_number();
check("+inf * integer", (l * 2) == l);
check("+inf / integer", (l / 2) == l);
check("+inf % -integer", (l % -2) == j);
check("+inf % integer", (l % 2) == l);
check("+inf / -integer", (l / -2) == j);
check("+inf * -integer", (l * -2) == j);
check("+inf * -inf", (l * j) == j);
check("+inf / +inf", (l / l) == i);
check("+inf % +inf", (l % l) == i);
check("+inf * zero", (l * 0) == i);
check("is special_value (nan)", i.is_special());
check("as_special convert", boost::date_time::not_a_date_time == i.as_special() );
check("add not a number", (i + 2) == int_type::not_a_number());
check("sub not a number", (i - 2) == int_type::not_a_number());
check("sub from infin", (l - 2) == int_type::pos_infinity());
i = 5;
h = 3;
check("add zero ", (i + 0) == 5);
check("sub from 5-2 ", (i - 2) == 3);
check("remainder from 5/2 ", (i % 2) == 1);
check("remainder from 5/3 ", (i % h) == 2);
// std::cout << i.as_number() << std::endl;
check("from special ",
int_type::from_special(boost::date_time::pos_infin) == int_type::pos_infinity());
check("from special ",
int_type::from_special(boost::date_time::neg_infin) == int_type::neg_infinity());
check("from special ",
int_type::from_special(boost::date_time::not_a_date_time) == int_type::not_a_number());
check("from special ",
int_type::from_special(boost::date_time::min_date_time) == (int_type::min)());
check("from special ",
int_type::from_special(boost::date_time::max_date_time) == (int_type::max)());
}
int
main()
{
using namespace boost::date_time;
print< int_adapter<unsigned long> >();
test_int< int_adapter<unsigned long> >();
print< int_adapter<long> >();
test_int< int_adapter<long> >();
print< int_adapter<boost::int64_t> >();
test_int< int_adapter<boost::int64_t> >();
return printTestStats();
}
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
158
]
]
]
|
62d845b1dcab11d8d78162d25e59c45e0dbff14d | 463c3b62132d215e245a097a921859ecb498f723 | /lib/dlib/unicode/unicode_abstract.h | 0365b177a12067e61a67c2f66c4ba9ec15ae7e3d | [
"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 | 6,548 | h | // Copyright (C) 2007 Davis E. King ([email protected]), and Nils Labugt
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_UNICODe_ABSTRACT_H_
#ifdef DLIB_UNICODe_ABSTRACT_H_
#include "../uintn.h"
#include "../error.h"
#include <string>
#include <fstream>
namespace dlib
{
// ----------------------------------------------------------------------------------------
// a typedef for an unsigned 32bit integer to hold our UNICODE characters
typedef uint32 unichar;
// a typedef for a string object to hold our UNICODE strings
typedef std::basic_string<unichar> ustring;
// ----------------------------------------------------------------------------------------
template <typename T>
bool is_combining_char(
const T ch_
);
/*!
ensures
- if (ch_ is a unicode combining character) then
- returns true
- else
- returns false
!*/
bool is_surrogate(
unichar ch
);
/*!
ensures
- if (ch is a unicode surrogate character) then
- returns true
- else
- returns false
!*/
unichar surrogate_pair_to_unichar(
unichar first,
unichar second
);
/*!
requires
- 0xD800 <= first < 0xDC00
- 0xDC00 <= second < 0xE000
- is_surrogate(first) == true
- is_surrogate(second) == true
ensures
- converts two surrogates into one unicode character
!*/
void unichar_to_surrogate_pair(
unichar ch,
unichar& first,
unichar& second
);
/*!
requires
- ch >= 0x10000 (i.e. is not in Basic Multilingual Plane)
ensures
- surrogate_pair_to_unichar(#first,#second) == ch
(i.e. converts ch into two surrogate characters)
!*/
// ----------------------------------------------------------------------------------------
class invalid_utf8_error : public error
{
public:
invalid_utf8_error():error(EUTF8_TO_UTF32) {}
};
const ustring convert_utf8_to_utf32 (
const std::string& str
);
/*!
ensures
- if (str is a valid UTF-8 encoded string) then
- returns a copy of str that has been converted into a
unichar string
- else
- throws invalid_utf8_error
!*/
// ----------------------------------------------------------------------------------------
const ustring convert_wstring_to_utf32 (
const std::wstring &wstr
);
/*!
requires
- wstr is a valid UTF-16 string when sizeof(wchar_t) == 2
- wstr is a valid UTF-32 string when sizeof(wchar_t) == 4
ensures
- converts wstr into UTF-32 string
!*/
// ----------------------------------------------------------------------------------------
const std::wstring convert_utf32_to_wstring (
const ustring &str
);
/*!
requires
- str is a valid UTF-32 encoded string
ensures
- converts str into wstring whose encoding is UTF-16 when sizeof(wchar_t) == 2
- converts str into wstring whose encoding is UTF-32 when sizeof(wchar_t) == 4
!*/
// ----------------------------------------------------------------------------------------
const std::wstring convert_mbstring_to_wstring (
const std::string &str
);
/*!
requires
- str is a valid multibyte string whose encoding is same as current locale setting
ensures
- converts str into wstring whose encoding is UTF-16 when sizeof(wchar_t) == 2
- converts str into wstring whose encoding is UTF-32 when sizeof(wchar_t) == 4
!*/
// ----------------------------------------------------------------------------------------
const std::string convert_wstring_to_mbstring (
const std::wstring &src
);
/*!
requires
- str is a valid wide character string string whose encoding is same as current
locale setting
ensures
- returns a multibyte encoded version of the given string
!*/
// ----------------------------------------------------------------------------------------
template <
typename charT
>
class basic_utf8_ifstream : public std::basic_istream<charT>
{
/*!
WHAT THIS OBJECT REPRESENTS
This object represents an input file stream much like the
normal std::ifstream except that it knows how to read UTF-8
data. So when you read characters out of this stream it will
automatically convert them from the UTF-8 multibyte encoding
into a fixed width wide character encoding.
!*/
public:
basic_utf8_ifstream (
);
/*!
ensures
- constructs an input stream that isn't yet associated with
a file.
!*/
basic_utf8_ifstream (
const char* file_name
);
/*!
ensures
- tries to open the given file for reading by this stream
!*/
basic_utf8_ifstream (
const std::string& file_name
);
/*!
ensures
- tries to open the given file for reading by this stream
!*/
void open(
const std::string& file_name
);
/*!
ensures
- tries to open the given file for reading by this stream
!*/
void open (
const char* file_name
);
/*!
ensures
- tries to open the given file for reading by this stream
!*/
void close (
);
/*!
ensures
- any file opened by this stream has been closed
!*/
};
typedef basic_utf8_ifstream<unichar> utf8_uifstream;
typedef basic_utf8_ifstream<wchar_t> utf8_wifstream;
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_UNICODe_ABSTRACT_H_
| [
"jimmy@DGJ3X3B1.(none)"
]
| [
[
[
1,
221
]
]
]
|
69f97f1efe07d519d37bcef16fc2f35cffc513fa | 1de7bc93ba6d2e2000683eaf97277b35679ab873 | /CryptoPP/mmi.cpp | 03294c601795cfd09da91de247f380c5e15ae975 | []
| no_license | mohamadpk/secureimplugin | b184642095e24b623b618d02cc7c946fc9bed6bf | 6ebfa5477b1aa8baaccea3f86f402f6d7f808de1 | refs/heads/master | 2021-03-12T23:50:12.141449 | 2010-04-28T06:54:37 | 2010-04-28T06:54:37 | 37,033,105 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,340 | cpp | #include "commonheaders.h"
/*
void m_check(void *ptr, const char *module) {
if(ptr==NULL) {
char buffer[128];
strcpy(buffer,module); strcat(buffer,": NULL pointer detected !");
MessageBoxA(0,buffer,szModuleName,MB_OK|MB_ICONSTOP);
__asm{ int 3 };
exit(1);
}
}
void *m_alloc(size_t size) {
void *ptr;
ptr = malloc(size);
m_check(ptr,"m_alloc");
ZeroMemory(ptr,size);
return ptr;
}
void m_free(void *ptr) {
// m_check(ptr,"m_free");
if(ptr) {
free(ptr);
}
}
void *m_realloc(void *ptr,size_t size) {
r = realloc(ptr,size);
m_check(ptr,"m_realloc");
return ptr;
}
#ifndef _DEBUG
void *operator new(size_t size) {
return malloc(size);
}
#endif
void operator delete(void *p) {
free(p);
}
void *operator new[](size_t size) {
return operator new(size);
}
void operator delete[](void *p) {
operator delete(p);
}
char *m_strdup(const char *str) {
if(str==NULL) return NULL;
int len = (int)strlen(str)+1;
char *dup = (char*) m_alloc(len);
MoveMemory((void*)dup,(void*)str,len);
return dup;
}
*/
void __fastcall safe_free(void** p)
{
if (*p) {
free(*p);
*p = NULL;
}
}
void __fastcall safe_delete(void** p)
{
if (*p) {
delete(*p);
*p = NULL;
}
}
// EOF
| [
"balookrd@d641cd86-4a32-0410-994c-055de1cff029"
]
| [
[
[
1,
88
]
]
]
|
550c38b7562233fa024c29a2d6243494c10502a6 | 276a89682066266de78e0e2a3fcacb1bb47578da | /tags/8/corbautil/cxx/import_export/import_export.h | b443b4e3e48f0c430605fb8d9a082fa63968d949 | []
| no_license | BackupTheBerlios/v-q-svn | e886b6e5945f9cc760a526aff8a36c2f59db35ea | c8f787e77272d5da15ef5d91a596b64ce1cf4d36 | refs/heads/master | 2020-05-31T15:14:58.511327 | 2006-03-20T20:27:23 | 2006-03-20T20:27:23 | 40,824,182 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,067 | h | //----------------------------------------------------------------------
// Copyright (c) 2002-2004 IONA Technologies. All rights reserved.
// This software is provided "as is".
//
// File: import_export.h
//
// Description: Utility functions for importing and exporting object
// references.
//
// Format of export instructions
// -----------------------------
//
// "name_service#<path>" Example: "name_service#foo/bar"
// "file#<path/to/file>" Example: "file#foo.ior"
// "exec#<cmd with IOR placeholder>" Example: "exec#echo IOR >foo.ior"
//
// Format of import instructions
// -----------------------------
//
// "name_service#<path>" Example: "name_service#foo/bar"
// "file#<path/to/file>" Example: "file#foo.ior"
// "exec#<cmd>" Example: "exec#cat foo.ior"
//
// Also, any of the "URL" formats supported by the ORB product are
// allowed for import (but NOT export) instructions. For example:
//
// "IOR:..."
// "corbaloc:..."
// "corbaname:..."
// "file://..."
//
// Error handling
// --------------
// If any errors occur in import_obj_ref() or export_obj_ref() then the
// functions throw a corbautil::ImportExportException.
//
// Example of using exportObjRef()
// ---------------------------------
// ... create "my_obj_ref"
// const char * instructions = argv[1];
// try {
// corbautil::exportObjRef(orb, my_obj_ref, instructions);
// } catch (corbautil::ImportExportException & ex) {
// cerr << ex << endl;
// orb->destroy();
// exit(1);
// }
//
// Example of using importObjRef()
// ---------------------------------
// const char * instructions = argv[1];
// CORBA::Object_var obj;
// try {
// obj = corbautil::importObjRef(orb, instructions);
// } catch (corbautil::ImportExportException & ex) {
// cerr << ex << endl;
// orb->destroy();
// exit(1);
// }
// ... narrow "obj" to the desired type
//----------------------------------------------------------------------
#ifndef IMPORT_EXPORT_H_
#define IMPORT_EXPORT_H_
//--------
// #include's
//--------
#include "p_orb.h"
#include "p_iostream.h"
#include "p_strstream.h"
#include <string>
namespace corbautil
{
class ImportExportException {
public:
ImportExportException()
{
msg = CORBA::string_dup("");
}
ImportExportException(std::string str)
{
msg = CORBA::string_dup(str.c_str());
}
ImportExportException(strstream & buf)
{
msg = CORBA::string_dup(buf.str());
buf.rdbuf()->freeze(0);
}
CORBA::String_var msg;
};
void
exportObjRef(
CORBA::ORB_ptr orb,
CORBA::Object_ptr obj,
const char * instructions)
throw(ImportExportException);
CORBA::Object_ptr
importObjRef(
CORBA::ORB_ptr orb,
const char * instructions)
throw(ImportExportException);
}; // namespace corbautil
inline ostream& operator << (
ostream & out,
const corbautil::ImportExportException & ex)
{
out << ex.msg.in();
return out;
}
#endif
| [
"[email protected]@36831980-ddd6-0310-a275-bfd50d89a3dc"
]
| [
[
[
1,
128
]
]
]
|
61ccfb37cb46dd0752e409203072df103c93ba92 | 502efe97b985c69d6378d9c428c715641719ee03 | /src/moaicore/MOAIViewport.h | 45832e5a68dc9141331286c0fc3a1105d4d7a63b | []
| no_license | neojjang/moai-beta | c3933bca2625bca4f4da26341de6b855e41b9beb | 6bc96412d35192246e35bff91df101bd7c7e41e1 | refs/heads/master | 2021-01-16T20:33:59.443558 | 2011-09-19T23:45:06 | 2011-09-19T23:45:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,748 | h | // Copyright (c) 2010-2011 Zipline Games, Inc. All Rights Reserved.
// http://getmoai.com
#ifndef MOAIVIEWPORT_H
#define MOAIVIEWPORT_H
//================================================================//
// MOAIViewport
//================================================================//
/** @name MOAIViewport
@text Viewport object.
*/
class MOAIViewport :
public virtual USLuaObject,
public USRect {
private:
bool mXScale;
bool mYScale;
USVec2D mScale;
USVec2D mOffset;
float mRotation;
//----------------------------------------------------------------//
static int _setOffset ( lua_State* L );
static int _setRotation ( lua_State* L );
static int _setScale ( lua_State* L );
static int _setSize ( lua_State* L );
public:
DECL_LUA_FACTORY ( MOAIViewport )
//----------------------------------------------------------------//
float GetAspect () const;
float GetInvAspect () const;
void GetNormToWndMtx ( USAffine2D& normToWnd ) const;
USAffine2D GetProjMtx () const;
USAffine2D GetProjMtxInv () const;
USRect GetRect () const;
USVec2D GetScale () const;
USVec2D GetUnits () const;
void GetWndToNormMtx ( USAffine2D& wndToNorm ) const;
USAffine2D GetWndToWorldMtx ( const USAffine2D& view ) const;
USAffine2D GetWorldToWndMtx ( const USAffine2D& view ) const;
MOAIViewport ();
~MOAIViewport ();
void RegisterLuaClass ( USLuaState& state );
void RegisterLuaFuncs ( USLuaState& state );
void SetOffset ( float xOffset, float yOffset );
void SetRotation ( float degrees );
void SetScale ( float xScale, float yScale );
STLString ToString ();
};
#endif
| [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
14
],
[
16,
17
],
[
25,
35
],
[
47,
50
],
[
54,
57
]
],
[
[
15,
15
],
[
18,
24
],
[
36,
46
],
[
51,
53
]
]
]
|
3913d56e3a231c15b4c22160bc23df01d7a10bfc | 1bbd5854d4a2efff9ee040e3febe3f846ed3ecef | /src/scrview/testsspacket.h | 78eda9a04399872ba844e266ffc3b670be524dbd | []
| no_license | amanuelg3/screenviewer | 2b896452a05cb135eb7b9eb919424fe6c1ce8dd7 | 7fc4bb61060e785aa65922551f0e3ff8423eccb6 | refs/heads/master | 2021-01-01T18:54:06.167154 | 2011-12-21T02:19:10 | 2011-12-21T02:19:10 | 37,343,569 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 306 | h | #ifndef TESTSSPACKET_H
#define TESTSSPACKET_H
#include <qobject.h>
class TestSsPacket : public QObject
{
Q_OBJECT
private slots:
void testEmptyMake();
void testMake();
void testMakeAndGet();
void testSetNewContent();
void testPacketSize();
};
#endif // TESTSSPACKET_H
| [
"JuliusR@localhost"
]
| [
[
[
1,
16
]
]
]
|
a654f8e1c7240c434aae46f39f5511e6841042d8 | 8b3f876f510a6d347c12703f284022f4e80896e9 | /os.cpp | fd3876fcd3e423279c8b193afae511b3c40cb6bc | []
| no_license | flexoid/SolarSystem | 77bf43464666800da0ad526005cb3a1113cadb55 | 8ee0f4c773704cb47ce234dc87307f879d6b4990 | refs/heads/master | 2021-03-12T20:37:24.346466 | 2009-05-22T18:14:34 | 2009-05-22T18:14:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,866 | cpp | // Copyright (C) 2002-2008 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "os.h"
#include "irrString.h"
#include "IrrCompileConfig.h"
#include "irrMath.h"
#if defined(_IRR_USE_SDL_DEVICE_)
#include <SDL/SDL_endian.h>
#define bswap_16(X) SDL_Swap16(X)
#define bswap_32(X) SDL_Swap32(X)
#elif defined(_IRR_WINDOWS_API_)
#if (defined(_MSC_VER) && (_MSC_VER > 1298))
#include <stdlib.h>
#define bswap_16(X) _byteswap_ushort(X)
#define bswap_32(X) _byteswap_ulong(X)
#else
#define bswap_16(X) ((((X)&0xFF) << 8) | (((X)&=0xFF00) >> 8))
#define bswap_32(X) ( (((X)&0x000000FF)<<24) | (((X)&0xFF000000) >> 24) | (((X)&0x0000FF00) << 8) | (((X) &0x00FF0000) >> 8))
#endif
#else
#if defined(_IRR_OSX_PLATFORM_)
#include <libkern/OSByteOrder.h>
#define bswap_16(X) OSReadSwapInt16(&X,0)
#define bswap_32(X) OSReadSwapInt32(&X,0)
#elif defined(__FreeBSD__)
#include <sys/endian.h>
#define bswap_16(X) bswap16(X)
#define bswap_32(X) bswap32(X)
#elif !defined(_IRR_SOLARIS_PLATFORM_) && !defined(__PPC__)
#include <byteswap.h>
#else
#define bswap_16(X) ((((X)&0xFF) << 8) | (((X)&=0xFF00) >> 8))
#define bswap_32(X) ( (((X)&0x000000FF)<<24) | (((X)&0xFF000000) >> 24) | (((X)&0x0000FF00) << 8) | (((X) &0x00FF0000) >> 8))
#endif
#endif
namespace irr
{
namespace os
{
u16 Byteswap::byteswap(u16 num) {return bswap_16(num);}
s16 Byteswap::byteswap(s16 num) {return bswap_16(num);}
u32 Byteswap::byteswap(u32 num) {return bswap_32(num);}
s32 Byteswap::byteswap(s32 num) {return bswap_32(num);}
f32 Byteswap::byteswap(f32 num) {u32 tmp=bswap_32(*((u32*)&num)); return *((f32*)&tmp);}
}
}
#if defined(_IRR_WINDOWS_API_)
// ----------------------------------------------------------------
// Windows specific functions
// ----------------------------------------------------------------
#ifdef _IRR_XBOX_PLATFORM_
#include <xtl.h>
#else
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
namespace irr
{
namespace os
{
//! prints a debuginfo string
void Printer::print(const c8* message)
{
c8* tmp = new c8[strlen(message) + 2];
sprintf(tmp, "%s\n", message);
OutputDebugStringA(tmp);
printf(tmp);
delete [] tmp;
}
LARGE_INTEGER HighPerformanceFreq;
BOOL HighPerformanceTimerSupport = FALSE;
void Timer::initTimer()
{
// disable hires timer on multiple core systems, bios bugs result in bad hires timers.
SYSTEM_INFO sysinfo;
DWORD affinity, sysaffinity;
GetSystemInfo(&sysinfo);
s32 affinityCount = 0;
// count the processors that can be used by this process
if (GetProcessAffinityMask( GetCurrentProcess(), &affinity, &sysaffinity ))
{
for (u32 i=0; i<32; ++i)
{
if ((1<<i) & affinity)
affinityCount++;
}
}
if (sysinfo.dwNumberOfProcessors == 1 || affinityCount == 1)
{
HighPerformanceTimerSupport = QueryPerformanceFrequency(&HighPerformanceFreq);
}
else
{
HighPerformanceTimerSupport = false;
}
initVirtualTimer();
}
u32 Timer::getRealTime()
{
if (HighPerformanceTimerSupport)
{
LARGE_INTEGER nTime;
QueryPerformanceCounter(&nTime);
return u32((nTime.QuadPart) * 1000 / HighPerformanceFreq.QuadPart);
}
return GetTickCount();
}
} // end namespace os
#else
// ----------------------------------------------------------------
// linux/ansi version
// ----------------------------------------------------------------
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
namespace irr
{
namespace os
{
//! prints a debuginfo string
void Printer::print(const c8* message)
{
printf("%s\n", message);
}
void Timer::initTimer()
{
initVirtualTimer();
}
u32 Timer::getRealTime()
{
timeval tv;
gettimeofday(&tv, 0);
return (u32)(tv.tv_sec * 1000) + (tv.tv_usec / 1000);
}
} // end namespace os
#endif // end linux / windows
namespace os
{
// The platform independent implementation of the printer
ILogger* Printer::Logger = 0;
void Printer::log(const c8* message, ELOG_LEVEL ll)
{
if (Logger)
Logger->log(message, ll);
}
void Printer::log(const c8* message, const c8* hint, ELOG_LEVEL ll)
{
if (!Logger)
return;
Logger->log(message, hint, ll);
}
void Printer::log(const wchar_t* message, ELOG_LEVEL ll)
{
if (Logger)
Logger->log(message, ll);
}
// our Randomizer is not really os specific, so we
// code one for all, which should work on every platform the same,
// which is desireable.
s32 Randomizer::seed = 0x0f0f0f0f;
//! generates a pseudo random number
s32 Randomizer::rand()
{
const s32 m = 2147483399; // a non-Mersenne prime
const s32 a = 40692; // another spectral success story
const s32 q = m/a;
const s32 r = m%a; // again less than q
seed = a * (seed%q) - r* (seed/q);
if (seed<0) seed += m;
return seed;
}
//! resets the randomizer
void Randomizer::reset()
{
seed = 0x0f0f0f0f;
}
// ------------------------------------------------------
// virtual timer implementation
f32 Timer::VirtualTimerSpeed = 1.0f;
s32 Timer::VirtualTimerStopCounter = 0;
u32 Timer::LastVirtualTime = 0;
u32 Timer::StartRealTime = 0;
u32 Timer::StaticTime = 0;
//! returns current virtual time
u32 Timer::getTime()
{
if (isStopped())
return LastVirtualTime;
return LastVirtualTime + (u32)((StaticTime - StartRealTime) * VirtualTimerSpeed);
}
//! ticks, advances the virtual timer
void Timer::tick()
{
StaticTime = getRealTime();
}
//! sets the current virtual time
void Timer::setTime(u32 time)
{
StaticTime = getRealTime();
LastVirtualTime = time;
StartRealTime = StaticTime;
}
//! stops the virtual timer
void Timer::stopTimer()
{
if (!isStopped())
{
// stop the virtual timer
LastVirtualTime = getTime();
}
--VirtualTimerStopCounter;
}
//! starts the virtual timer
void Timer::startTimer()
{
++VirtualTimerStopCounter;
if (!isStopped())
{
// restart virtual timer
setTime(LastVirtualTime);
}
}
//! sets the speed of the virtual timer
void Timer::setSpeed(f32 speed)
{
setTime(getTime());
VirtualTimerSpeed = speed;
if (VirtualTimerSpeed < 0.0f)
VirtualTimerSpeed = 0.0f;
}
//! gets the speed of the virtual timer
f32 Timer::getSpeed()
{
return VirtualTimerSpeed;
}
//! returns if the timer currently is stopped
bool Timer::isStopped()
{
return VirtualTimerStopCounter != 0;
}
void Timer::initVirtualTimer()
{
StaticTime = getRealTime();
StartRealTime = StaticTime;
}
} // end namespace os
} // end namespace irr
| [
"[email protected]"
]
| [
[
[
1,
300
]
]
]
|
a87d2c5527ad6ae4a6efea4eb09490fef7a152c5 | 3b76b2980485417cb656215379b93b27d4444815 | /7.Ung dung/Source code/Server/Server/BlockCipherProvider.h | 57174ef09529bb587a7fb033ce4a88b083e70258 | []
| no_license | hemprasad/lvmm-sc | 48d48625b467b3756aa510b5586af250c3a1664c | 7c68d1d3b1489787f5ec3d09bc15b4329b0c087a | refs/heads/master | 2016-09-06T11:05:32.770867 | 2011-07-25T01:09:07 | 2011-07-25T01:09:07 | 38,108,101 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 565 | h | #pragma once
#include "rijndael.h"
#include "string.h"
class CBlockCipherProvider
{
public:
unsigned char key[128];
bool Init(char* key);
char* Encrypt(char * data,int &size );
char* Decrypt(char *data,int size );
char* CTRModeEncrypt(char * data,int &size );;
char* CTRModeDecrypt(char *data,int size );
CBlockCipherProvider(void);
~CBlockCipherProvider(void);
unsigned int Nonce,iTemp;
char* CBlockCipherProvider::CTRModeEncryptNext(char * data,int &size);
char* CBlockCipherProvider::CTRModeDecryptNext(char *cipher,int size );
};
| [
"funnyamauter@72c74e6c-5204-663f-ea46-ae2a288fd484"
]
| [
[
[
1,
18
]
]
]
|
ef920cb5f4aaaa4adc85a59f68cd164d7b2711e4 | 7b4c786d4258ce4421b1e7bcca9011d4eeb50083 | /五谷杂粮_各类编程大赛/SPOJ/20090404-3370-Mergesort.cpp | 9c39bc448221e6841ec55b15af41b304da5c2214 | []
| 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 | 1,264 | cpp | //20090404 merge sort with vector
#include <iostream>
#include <vector>
using namespace std;
vector<int> merge(vector<int>& left, vector<int>& right)
{
vector<int> result;
vector<int>::const_iterator l_iter = left.begin();
vector<int>::const_iterator r_iter = right.begin();
while (l_iter != left.end() && r_iter != right.end()) {
result.push_back((*l_iter < *r_iter) ? *l_iter++ : *r_iter++);
}
while (l_iter != left.end())
result.push_back(*l_iter++);
while (r_iter != right.end())
result.push_back(*r_iter++);
return result;
}
void merge_sort(vector<int>& ivec)
{
if (ivec.size() == 1)
return;
vector<int> left;
vector<int> right;
vector<int> result;
int mid = ivec.size() / 2;
int i;
for (i = 0; i != mid; ++i) {
left.push_back(ivec[i]);
}
for (i = mid; i != ivec.size(); ++i) {
right.push_back(ivec[i]);
}
merge_sort(left);
merge_sort(right);
ivec = merge(left, right);
}
int main()
{
int ival;
vector<int> ivec;
while (cin >> ival) {
ivec.push_back(ival);
}
merge_sort(ivec);
//output the result
vector<int>::const_iterator iter;
for (iter = ivec.begin(); iter != ivec.end(); ++iter) {
cout << *iter << " ";
}
return 0;
}
| [
"baicaibang@70501136-4834-11de-8855-c187e5f49513"
]
| [
[
[
1,
70
]
]
]
|
d7e8f217fa52aaba0377a5032d76a478c451b901 | 744e9a2bf1d0aee245c42ee145392d1f6a6f65c9 | /tags/0.11.1-alpha/gui/ttcut.cpp | 33ff713e50a143c6fd488c5dbc0d972b82c30fc7 | []
| no_license | BackupTheBerlios/ttcut-svn | 2b5d00c3c6d16aa118b4a58c7d0702cfcc0b051a | 958032e74e8bb144a96b6eb7e1d63bc8ae762096 | refs/heads/master | 2020-04-22T12:08:57.640316 | 2009-02-08T16:14:00 | 2009-02-08T16:14:00 | 40,747,642 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,503 | cpp | /*----------------------------------------------------------------------------*/
/* COPYRIGHT: TriTime (c) 2003/2005 / www.tritime.org */
/*----------------------------------------------------------------------------*/
/* PROJEKT : TTCUT 2005 */
/* FILE : ttcut.cpp */
/*----------------------------------------------------------------------------*/
/* AUTHOR : b. altendorf (E-Mail: [email protected]) DATE: 03/01/2005 */
/* MODIFIED: b. altendorf DATE: 03/19/2005 */
/* MODIFIED: b. altendorf DATE: 03/23/2005 */
/* MODIFIED: b. altendorf DATE: 03/31/2005 */
/* MODIFIED: DATE: */
/*----------------------------------------------------------------------------*/
// ----------------------------------------------------------------------------
// TTCUT
// ----------------------------------------------------------------------------
/*----------------------------------------------------------------------------*/
/* This program is free software; you can redistribute it and/or modify it */
/* under the terms of the GNU General Public License as published by the Free */
/* Software Foundation; */
/* either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT*/
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
/* FITNESS FOR A PARTICULAR PURPOSE. */
/* See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along */
/* with this program; if not, write to the Free Software Foundation, */
/* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */
/*----------------------------------------------------------------------------*/
#include "ttcut.h"
//Added by qt3to4:
#include <QPixmap>
#include <QDir>
#include <QCoreApplication>
// /////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// Initialize static TTCut class members
// -----------------------------------------------------------------------------
// /////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// Pixmaps
// -----------------------------------------------------------------------------
QPixmap* TTCut::imgDownArrow = NULL;
QPixmap* TTCut::imgUpArrow = NULL;
QPixmap* TTCut::imgDelete = NULL;
QPixmap* TTCut::imgFileOpen24 = NULL;
QPixmap* TTCut::imgFileNew = NULL;
QPixmap* TTCut::imgFileOpen = NULL;
QPixmap* TTCut::imgFileSave = NULL;
QPixmap* TTCut::imgFileSaveAs = NULL;
QPixmap* TTCut::imgSaveImage = NULL;
QPixmap* TTCut::imgSettings = NULL;
QPixmap* TTCut::imgSettings18 = NULL;
QPixmap* TTCut::imgExit = NULL;
QPixmap* TTCut::imgPlay = NULL;
QPixmap* TTCut::imgStop = NULL;
QPixmap* TTCut::imgSearch = NULL;
QPixmap* TTCut::imgChapter = NULL;
QPixmap* TTCut::imgPreview = NULL;
QPixmap* TTCut::imgCutAV = NULL;
QPixmap* TTCut::imgCutAudio = NULL;
QPixmap* TTCut::imgGoTo = NULL;
QPixmap* TTCut::imgMarker = NULL;
QPixmap* TTCut::imgClock = NULL;
QPixmap* TTCut::imgApply = NULL;
QPixmap* TTCut::imgAddToList = NULL;
QPixmap* TTCut::imgFileClose = NULL;
QPixmap* TTCut::imgIFrame = NULL;
QPixmap* TTCut::imgPFrame = NULL;
QPixmap* TTCut::imgBFrame = NULL;
// --------------------------------------------------------------
// common settings
// --------------------------------------------------------------
// Options
bool TTCut::fastSlider = false;
QString TTCut::tempDirPath = QDir::tempPath();
QString TTCut::lastDirPath = QDir::homePath();
// Preview
int TTCut::cutPreviewSeconds = 25;
int TTCut::playSkipFrames = 0;
// Frame search
int TTCut::searchLength = 45;
int TTCut::searchAccuracy = 1;
// Navigation
int TTCut::stepSliderClick = 40;
int TTCut::stepPgUpDown = 80;
int TTCut::stepArrowKeys = 1;
int TTCut::stepPlusAlt = 100;
int TTCut::stepPlusCtrl = 200;
int TTCut::stepPlusShift = 200;
int TTCut::stepQuickJump = 25;
int TTCut::stepMouseWheel = 120;
// Index files
bool TTCut::createVideoIDD = false;
bool TTCut::createAudioIDD = false;
bool TTCut::createPrevIDD = false;
bool TTCut::createD2V = false;
bool TTCut::readVideoIDD = false;
bool TTCut::readAudioIDD = false;
bool TTCut::readPrevIDD = false;
// Logfile
bool TTCut::createLogFile = true;
bool TTCut::logModeConsole = false;
bool TTCut::logModeExtended = true;
bool TTCut::logVideoIndexInfo = false;
bool TTCut::logAudioIndexInfo = false;
// --------------------------------------------------------------
// encoder settings
// --------------------------------------------------------------
// Version
QString TTCut::versionString = "TTCut - 0.11.0-alpha";
// Options
bool TTCut::encoderMode = false;
// --------------------------------------------------------------
// muxer settings
// --------------------------------------------------------------
// Options
int TTCut::muxMode = 2;
int TTCut::mpeg2Target = 2;
QString TTCut::muxProg = "mplex";
QString TTCut::muxProgPath = "/usr/local/bin/";
QString TTCut::muxProgCmd = "-f 8";
QString TTCut::muxOutputPath = "/var/tmp";
// --------------------------------------------------------------
// chapter settings
// --------------------------------------------------------------
// Options
bool TTCut::spumuxChapter = false;
// -----------------------------------------------------------------------------
// Status
// -----------------------------------------------------------------------------
bool TTCut::isVideoOpen = false;
int TTCut::numAudioTracks = 0;
bool TTCut::isProjektModified = false;
bool TTCut::isPlaying = false;
bool TTCut::isWorking = false;
// --------------------------------------------------------------
// Cut settings
// --------------------------------------------------------------
// cut option
QString TTCut::cutDirPath = QDir::currentPath();
QString TTCut::cutVideoName = "_cut.m2v";
bool TTCut::cutWriteMaxBitrate = false;
bool TTCut::cutWriteSeqEnd = false;
bool TTCut::correctCutTimeCode = false;
bool TTCut::correctCutBitRate = false;
bool TTCut::createCutIDD = false;
bool TTCut::readCutIDD = false;
// --------------------------------------------------------------
// Global properties
// --------------------------------------------------------------
float TTCut::frameRate = 25.0;
QWidget* TTCut::mainWindow = NULL;
TTCut::TTCut()
{
}
TTCut::~TTCut()
{
}
| [
"tritime@7763a927-590e-0410-8f7f-dbc853b76eaa"
]
| [
[
[
1,
185
]
]
]
|
913c6898fe86e9ff2ee5ce1bebf7a0b52cd19b75 | d504537dae74273428d3aacd03b89357215f3d11 | /src/Renderer/Dx9/RendererDx9.cpp | c64880ff06910de45f2986516902c36428a18a3a | []
| no_license | h0MER247/e6 | 1026bf9aabd5c11b84e358222d103aee829f62d7 | f92546fd1fc53ba783d84e9edf5660fe19b739cc | refs/heads/master | 2020-12-23T05:42:42.373786 | 2011-02-18T16:16:24 | 2011-02-18T16:16:24 | 237,055,477 | 1 | 0 | null | 2020-01-29T18:39:15 | 2020-01-29T18:39:14 | null | UTF-8 | C++ | false | false | 25,299 | cpp | #include "Dx9.h"
#include <vector>
#include "../../Core/Frustum.h"
namespace Dx9
{
using Core::Mesh;
using Core::Texture;
using Core::Camera;
using Core::Light;
using Core::Shader;
using Core::Mesh;
void getFVF( uint mesh_format, uint & fvf, uint & siz )
{
fvf = D3DFVF_XYZ;
siz = 3*sizeof(float);
int stage = 0;
if ( mesh_format & e6::VF_NOR )
{
fvf |= D3DFVF_NORMAL;
siz += 3*sizeof(float);
}
if ( mesh_format & e6::VF_COL )
{
fvf |= D3DFVF_DIFFUSE;
siz += 1*sizeof(uint);
}
if ( mesh_format & e6::VF_UV0 )
{
fvf |= (stage+1) << D3DFVF_TEXCOUNT_SHIFT;
fvf |= D3DFVF_TEXCOORDSIZE2(stage);
siz += 2*sizeof(float);
stage ++;
}
if ( mesh_format & e6::VF_UV1 )
{
fvf |= (stage+1) << D3DFVF_TEXCOUNT_SHIFT;
fvf |= D3DFVF_TEXCOORDSIZE2(stage);
siz += 2*sizeof(float);
stage ++;
}
if ( mesh_format & e6::VF_TAN )
{
fvf |= (stage+1) << D3DFVF_TEXCOUNT_SHIFT;
fvf |= D3DFVF_TEXCOORDSIZE3(stage);
siz += 3*sizeof(float);
stage ++;
}
}
struct CRenderer
: e6::CName< Core::Renderer, CRenderer >
{
D3DPRESENT_PARAMETERS d3dpp;
D3DDISPLAYMODE d3ddm;
D3DCAPS9 caps;
LPDIRECT3D9 d3d;
LPDIRECT3DDEVICE9 device;
LPDIRECT3DSURFACE9 backBuffer;
IDirect3DBaseTexture9 * dxt_last;
IDirect3DVertexBuffer9 * vb_last;
IDirect3DVertexShader9 * vs_last;
IDirect3DPixelShader9 * ps_last;
uint fvf_last;
HRESULT hr;
VertexCache vertexCache;
TextureCache textureCache;
PixelShaderCache pixelShaderCache;
VertexShaderCache vertexShaderCache;
std::vector< Core::Mesh* > alphaMeshes;
float4x4 matWorld;
float4x4 matView;
float4x4 matProj;
float4x4 matClip;
bool doCull;
bool doCCW;
bool doWire;
bool doTexture;
bool doLighting;
bool doFullScreen;
bool doClearBackBuffer;
bool doZTest;
bool doZWrite;
bool doAlpha;
bool doAlphaTest;
bool deviceLost;
uint zBufferDepth ;
uint stateBlendSrc;
uint stateBlendDst;
uint shadeMode;
uint multiSampleType;
uint multiSampleQuality;
rgba bgColor;
uint ttl;
Core::Frustum frustum;
CRenderer()
: d3d(0)
, device(0)
, backBuffer(0)
, doCull(1)
, doCCW(0)
, doWire(0)
, doTexture(1)
, bgColor(0xff333377)
, doLighting(1)
, doFullScreen(0)
, doClearBackBuffer(1)
, zBufferDepth(16)
, doZWrite(1)
, doZTest(1)
, doAlpha(0)
, doAlphaTest(0)
, stateBlendSrc( e6::BM_ONE )
, stateBlendDst( e6::BM_ZERO )
, multiSampleType(D3DMULTISAMPLE_NONE)
, multiSampleQuality(1)
, shadeMode( 1 )
, vb_last(0)
, dxt_last(0)
, vs_last(0)
, ps_last(0)
, fvf_last(0)
, deviceLost(0)
{
ZeroMemory( &d3dpp, sizeof(d3dpp) );
ZeroMemory( &d3ddm, sizeof( D3DDISPLAYMODE ) );
ZeroMemory( &caps, sizeof( D3DCAPS9 ) );
matProj.perspective( 60, 1.0f, 1, 100 );
setName( "RendererDx9");
}
~CRenderer()
{
cleanup();
}
virtual void *cast( const char * str )
{
return _cast(str,"Core.Renderer", "e6.Name");
}
uint createDevice( const void *win, uint w, uint h, D3DDEVTYPE deviceType )
{
hr = d3d->GetDeviceCaps( D3DADAPTER_DEFAULT, deviceType, & caps );
if( FAILED( hr ) )
{
E_TRACE(hr);
printf( "%s() Error: GetDeviceCaps\n", __FUNCTION__ );
return 0;
}
// antialias
uint maxMultiSampleType = D3DMULTISAMPLE_NONMASKABLE;
uint maxMultiSampleQuality = 1;
hr = d3d->CheckDeviceMultiSampleType(
D3DADAPTER_DEFAULT,
deviceType,
d3ddm.Format,
doFullScreen,
(D3DMULTISAMPLE_TYPE) maxMultiSampleType,
(DWORD *) &maxMultiSampleQuality
);
if ( FAILED(hr))
{
E_TRACE(hr);
multiSampleType = D3DMULTISAMPLE_NONE;
multiSampleQuality = 1;
return 0;
}
else
{
if (multiSampleQuality < maxMultiSampleQuality-1 )
{
multiSampleQuality = maxMultiSampleQuality-1 ;
multiSampleType = maxMultiSampleType;
}
printf( "%s : setting multisampling quality to %d / %d !\n", __FUNCTION__, multiSampleQuality, maxMultiSampleQuality-1 );
}
init_pp(win,w,h);
#ifdef _DEBUG
uint behaviour = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
#else
uint behaviour = D3DCREATE_HARDWARE_VERTEXPROCESSING;
#endif
if( FAILED( hr=d3d->CreateDevice( D3DADAPTER_DEFAULT, deviceType,
(HWND)win, behaviour,
&d3dpp, &device ) ) )
{
LOG_ERROR(hr);
return 0;
}
return 1;
}
virtual uint init( const void *win, uint w, uint h )
{
if ( ! device )
{
if( NULL == ( d3d = Direct3DCreate9( D3D_SDK_VERSION ) ) )
{
printf( __FUNCTION__ " ERROR : no D3D!\n" );
return 0;
}
hr = d3d->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm ); E_TRACE(hr);
if( FAILED( hr ) )
{
E_TRACE(hr);
printf( "%s() Error: GetAdapterDisplayMode\n", __FUNCTION__ );
return 0;
}
if ( ! createDevice( win, w,h, D3DDEVTYPE_HAL ) )
{
printf( "trying software renderer..\n");
if ( ! createDevice( win, w,h, D3DDEVTYPE_REF ) )
{
COM_RELEASE( d3d );
return 0;
}
}
restore();
vertexCache.setDevice( device );
textureCache.setDevice( device );
pixelShaderCache.setDevice( device );
vertexShaderCache.setDevice( device );
return 1;
}
return reset(win,w,h);
}
void setupZBuffer()
{
switch (zBufferDepth)
{
case 0: // switch off zbuffer:
d3dpp.EnableAutoDepthStencil = FALSE;
doZTest = FALSE;
doZWrite = FALSE;
break;
case 16:
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.Flags |= D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL;
doZTest = TRUE;
break;
default:
MessageBox( 0, "invalid zbuffer-depth in rdd. defaulting to 24 bit !", "sorry...", 0 );
case 24:
d3dpp.AutoDepthStencilFormat = D3DFMT_D24X8;//D3DFMT_D16;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.Flags |= D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL;
doZTest = TRUE;
}
//~ $();
}
uint init_pp(const void * win, int w, int h)
{
d3dpp.Windowed = (! doFullScreen);
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferWidth = doFullScreen ? d3ddm.Width : w;
d3dpp.BackBufferHeight = doFullScreen ? d3ddm.Height : h;
d3dpp.BackBufferFormat = d3ddm.Format;
d3dpp.BackBufferCount = 1;
d3dpp.hDeviceWindow = (HWND) win;
d3dpp.MultiSampleType = (D3DMULTISAMPLE_TYPE) multiSampleType;
d3dpp.MultiSampleQuality = multiSampleQuality;
//d3dpp.FullScreen_RefreshRateInHz = 0;
//d3dpp.SwapEffect = D3DSWAPEFFECT_FLIP;
//d3dpp.SwapEffect = D3DSWAPEFFECT_COPY;
//d3dpp.Flags |= D3DPRESENTFLAG_DEVICECLIP;
//d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
//d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
//d3dpp.PresentationInterval = D3DPRESENT_DONOTWAIT;
//d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
setupZBuffer();
//~ $();
return 1;
}
void restore()
{
// restore render states
//~ hr = device->SetRenderState( D3DRS_CULLMODE, (doCull? doCCW + 2 : 1) ); E_TRACE(hr);
//~ hr = device->SetRenderState( D3DRS_LIGHTING, doLighting ); E_TRACE(hr);
hr = device->SetRenderState( D3DRS_ZENABLE, doZTest ); E_TRACE(hr);
hr = device->SetRenderState( D3DRS_ZWRITEENABLE, doZWrite ); E_TRACE(hr);
hr = device->SetRenderState( D3DRS_ALPHATESTENABLE, doAlphaTest ); E_TRACE(hr);
_setRenderState( e6::RF_LIGHTING, doLighting );
_setRenderState( e6::RF_CULL, doCull );
_setRenderState( e6::RF_CCW, doCCW );
_setRenderState( e6::RF_SRCBLEND, stateBlendSrc );
_setRenderState( e6::RF_SRCBLEND, stateBlendSrc );
_setRenderState( e6::RF_DSTBLEND, stateBlendDst );
_setRenderState( e6::RF_SHADE, shadeMode );
_setRenderState( e6::RF_WIRE, doWire );
_setRenderState( e6::RF_TEXTURE, doTexture );
_setRenderState( e6::RF_ALPHA, doAlpha );
for ( uint i=0; i<8; i++ )
{
hr = device->SetSamplerState( i, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP );
hr = device->SetSamplerState( i, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP );
hr = device->SetSamplerState( i, D3DSAMP_MAGFILTER, D3DTEXF_ANISOTROPIC );
hr = device->SetSamplerState( i, D3DSAMP_MINFILTER, D3DTEXF_ANISOTROPIC );
hr = device->SetSamplerState( i, D3DSAMP_MIPFILTER, D3DTEXF_ANISOTROPIC );
}
float lc[] = { 1,1,1,1 };
hr = device->SetVertexShaderConstantF( e6::VS_LIGHT_0_COLOR, lc, 1 );
float lp[] = { -1,100,10,1 };
hr = device->SetVertexShaderConstantF( e6::VS_LIGHT_0_POS, lp, 1 );
//float vp[] = { d3dpp.BackBufferWidth, d3dpp.BackBufferHeight, 0, 0 };
//hr = device->SetPixelShaderConstantF( e6::PS_RESOLUTION, vp, 1 );
if ( ! backBuffer )
{
hr = device->GetBackBuffer( 0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer );
E_TRACE(hr);
if ( hr ) backBuffer = 0;
}
dxt_last = 0;
vb_last = 0;
vs_last = 0;
ps_last = 0;
fvf_last = 0;
}
uint reset(const void *win, int w, int h)
{
COM_RELEASE( backBuffer );
init_pp(win,w,h);
hr = device->Reset( &d3dpp ); E_TRACE(hr);
if ( FAILED( hr ) )
{
return 0;
}
restore();
return 1;
}
virtual void clear()
{
uint clearFlag = 0;
if ( doZTest )
clearFlag |= D3DCLEAR_ZBUFFER;
if ( doClearBackBuffer )
clearFlag |= D3DCLEAR_TARGET;
if ( clearFlag )
{
hr = device->Clear( 0, NULL, clearFlag, bgColor, 1.0f, 0 );
E_TRACE(hr);
}
//~ $();
}
virtual void swapBuffers()
{
hr = device->Present( NULL, NULL, NULL, NULL );
E_TRACE(hr);
if ( hr == D3DERR_DEVICELOST )
{
deviceLost = true;
printf( __FUNCTION__ " : DEVICE LOST !\n" );
//vertexCache.clear();
//textureCache.clear();
//pixelShaderCache.clear();
//vertexShaderCache.clear();
// backBuffer ??
// rendertargets ??
}
else
{
vertexCache.tick();
textureCache.tick();
pixelShaderCache.tick();
vertexShaderCache.tick();
}
//~ $();
}
virtual uint begin3D()
{
alphaMeshes.clear();
hr = device->BeginScene();
E_TRACE(hr);
//~ $();
return SUCCEEDED( hr );
}
virtual uint setRenderTarget( Texture * tex )
{
HRESULT hr = S_FALSE;
IDirect3DSurface9 * target = backBuffer;
if ( tex && (tex->type() == e6::TU_RENDERTARGET) )
{
IDirect3DTexture9 * txdx = (IDirect3DTexture9*)textureCache.getBuffer( tex );
if ( txdx )
{
hr = txdx->GetSurfaceLevel( 0, & target );
E_TRACE(hr);
COM_RELEASE( txdx );
if ( hr != S_OK )
{
target = backBuffer;
//return 0;
}
}
}
hr = device->SetRenderTarget( 0, target );
if ( (hr==S_OK) && (target != backBuffer) ) // otherwise wait for regular clear
{
clear();
}
E_TRACE(hr);
return hr==S_OK;
}
virtual uint setCamera( Camera * cam )
{
D3DXMatrixPerspectiveFovRH( (D3DXMATRIX*)&matProj, cam->getFov() * e6::deg2rad, 1.0f, cam->getNearPlane(), cam->getFarPlane() );
float4x4 matCam;
cam->getWorldMatrix(matCam);
matView = matCam.inverse();
hr = device->SetVertexShaderConstantF( e6::VS_MATRIX_INV_VIEW, (float*)&(matView), 4 );
E_TRACE(hr);
matClip = matView * matProj;
frustum.setup( matClip );
return 1;
}
virtual uint setLight( uint n, Light * light )
{
if ( doLighting )
{
if ( n > 4 ) return 0;
float4 c(light->getColor());
c[3] = 1;
hr = device->SetVertexShaderConstantF( e6::VS_LIGHT_0_COLOR+2*n, (float*)&c, 1 );
E_TRACE(hr);
float4 d(light->getPos());
d[3] = 1;
hr = device->SetVertexShaderConstantF( e6::VS_LIGHT_0_POS+2*n, (float*)&d, 1 );
E_TRACE(hr);
}
return 1;
}
virtual uint setMesh( Mesh * mesh )
{
if ( doTexture )
if ( meshHasAlpha( mesh ) )
{
// later, baby..
alphaMeshes.push_back( mesh );
return 1;
}
return renderMesh( mesh );
}
uint meshHasAlpha( Mesh * mesh )
{
bool yes = 0;
for ( uint i=0; i<4; i++ )
{
Core::Texture * tex = mesh->getTexture(i);
if ( ! tex )
{
continue;
}
yes = ( tex->format() == e6::PF_A8B8G8R8 );
E_RELEASE( tex );
if ( yes ) break;
}
return yes;
}
uint renderMesh( Mesh * mesh )
{
// transformation:
mesh->getWorldMatrix(matWorld);
float4x4 matWVP = (matWorld*matClip);
hr = device->SetVertexShaderConstantF( e6::VS_MATRIX_WORLD, (float*)&matWorld, 4 );
hr = device->SetVertexShaderConstantF( e6::VS_MATRIX_WORLD_VIEW_PROJ, (float*)&matWVP, 4 );
E_TRACE(hr);
if ( this->doCull )
{
bool in = frustum.intersectSphere( matWorld.getPos(), mesh->getSphere() );
if ( ! in )
{
//printf("Culled %s.\n", mesh->getName() );
return 0;
}
}
// textures:
if ( doTexture )
for ( uint i=0; i<4; i++ )
{
Core::Texture * tex = mesh->getTexture(i);
if ( ! tex )
{
//if (i!=0)
continue;
// else try to set checker:
}
IDirect3DBaseTexture9 * dxt = textureCache.getBuffer( tex );
if ( tex && (tex->type() == e6::TU_DYNAMIC || tex->type() == e6::TU_VIDEO) )
{
Core::Buffer * cbuf = tex->getLevel(0);
if ( cbuf )
{
unsigned char * pixel = 0;
cbuf->lock( (void**)&pixel );
if ( pixel )
{
IDirect3DSurface9 *surf = 0;
HRESULT hr = ((IDirect3DTexture9 *)dxt)->GetSurfaceLevel( 0, & surf );
SurfaceHelper::copyToSurface( tex->width(), tex->height(), 4, pixel,surf );
COM_RELEASE( surf );
cbuf->unlock();
}else{printf("!lock\n");}
E_RELEASE( cbuf );
}
}
if ( dxt_last != dxt )
{
hr = device->SetTexture( i, dxt );
E_TRACE(hr);
}
dxt_last = dxt;
E_RELEASE( tex );
}
// VertexShader:
Core::Shader * vShader = mesh->getVertexShader();
IDirect3DVertexShader9 * vs = vertexShaderCache.getBuffer( vShader );
if ( vs_last != vs )
{
hr = device->SetVertexShader( vs );
E_TRACE(hr);
}
E_RELEASE( vShader );
vs_last = vs;
for ( uint i=0; i<mesh->getNumVertexShaderConstants(); i++ )
{
Core::Shader::Constant *c = mesh->getVertexShaderConstant(i);
device->SetVertexShaderConstantF( c->index, (float*)&(c->value), 1 );
}
// PixelShader:
Core::Shader * pShader = mesh->getPixelShader();
IDirect3DPixelShader9 * ps = pixelShaderCache.getBuffer( pShader );
if ( ps_last != ps )
{
hr = device->SetPixelShader( ps );
E_TRACE(hr);
}
E_RELEASE( pShader );
ps_last = ps;
for ( uint i=0; i<mesh->getNumPixelShaderConstants(); i++ )
{
Core::Shader::Constant *c = mesh->getPixelShaderConstant(i);
device->SetPixelShaderConstantF( c->index, (float*)&(c->value), 1 );
}
for ( uint i=0; i<mesh->getNumRenderStates(); i++ )
{
Core::Shader::RenderState *rs = mesh->getRenderState(i);
_setRenderState( rs->index, rs->value );
}
// VertexBuffer:
Core::VertexBuffer * vb = mesh->getBuffer();
E_ASSERT(vb);
IDirect3DVertexBuffer9 *vbdx = vertexCache.getBuffer( vb );
E_ASSERT(vbdx);
E_RELEASE(vb);
uint vSiz=0, fvf=0;
getFVF( mesh->format(), fvf, vSiz );
if ( (vb_last != vbdx) || (fvf_last != fvf) )
{
hr = device->SetStreamSource( 0, vbdx, 0, vSiz );
E_TRACE(hr);
hr = device->SetFVF( fvf );
E_TRACE(hr);
}
vb_last = vbdx;
fvf_last = fvf;
hr = device->DrawPrimitive( D3DPT_TRIANGLELIST, 0, mesh->numFaces() );
E_TRACE(hr);
//~ $();
return 1;
}
virtual uint setRenderState( uint key, uint value )
{
switch( key )
{
case e6::RF_TEXTURE:
doTexture = (bool)value;
break;
case e6::RF_LIGHTING:
doLighting = (bool)value;
break;
case e6::RF_CULL:
doCull = (bool)value;
break;
case e6::RF_CCW:
doCCW = (bool)value;
break;
case e6::RF_SHADE:
shadeMode=value;
break;
case e6::RF_CLEAR_COLOR:
bgColor=value;
break;
case e6::RF_CLEAR_BUFFER:
doClearBackBuffer = (bool)value;
break;
case e6::RF_ZTEST:
doZTest = (bool)value;
break;
case e6::RF_ZWRITE:
doZWrite = (bool)value;
break;
case e6::RF_ZDEPTH:
doZTest = (bool)value;
setupZBuffer();
break;
case e6::RF_ALPHA_TEST:
doAlphaTest = (bool)value;
break;
case e6::RF_ALPHA:
doAlpha = (value!=0);
break;
case e6::RF_SRCBLEND:
stateBlendSrc = value;
break;
case e6::RF_DSTBLEND:
stateBlendDst = value;
break;
case e6::RF_WIRE:
doWire = (bool)value;
break;
default: return 0;
}
//~ $();
return _setRenderState( key, value );
}
uint _blendMode( uint e6_blend )
{
uint mode = 0;
switch( e6_blend )
{
case e6::BM_ZERO :
mode = D3DBLEND_ZERO; break;
case e6::BM_ONE:
mode = D3DBLEND_ONE; break; // (1, 1, 1, 1 )
case e6::BM_SRCCOLOR:
mode = D3DBLEND_SRCCOLOR; break; // (Rs, Gs, Bs, As )
case e6::BM_INVSRCCOLOR:
mode = D3DBLEND_INVSRCCOLOR; break; // (1-Rs, 1-Gs, 1-Bs, 1-As)
case e6::BM_SRCALPHA:
mode = D3DBLEND_SRCALPHA; break; // (As, As, As, As )
case e6::BM_INVSRCALPHA:
mode = D3DBLEND_INVSRCALPHA; break; // (1-As, 1-As, 1-As, 1-As)
case e6::BM_DESTALPHA:
mode = D3DBLEND_DESTALPHA; break; // (Ad, Ad, Ad, Ad )
case e6::BM_INVDESTALPHA:
mode = D3DBLEND_INVDESTALPHA; break; // (1-Ad, 1-Ad, 1-Ad, 1-Ad)
case e6::BM_DESTCOLOR:
mode = D3DBLEND_DESTCOLOR; break; // (Rd, Gd, Bd, Ad )
case e6::BM_INVDESTCOLOR:
mode = D3DBLEND_INVDESTCOLOR; break; // (1-Rd, 1-Gd, 1-Bd, 1-Ad)
case e6::BM_SRCALPHASAT:
mode = D3DBLEND_SRCALPHASAT; break; // (f, f, f, 1 ) f = min (As, 1-Ad)
default: E_ASSERT(!"unknown type!"); break;
}
return mode;
}
uint _setRenderState( uint key, uint value )
{
E_ASSERT( device );
switch( key )
{
case e6::RF_TEXTURE:
if ( ! value )
{
hr = device->SetTexture( 0, 0 ); E_TRACE(hr);
hr = device->SetTexture( 1, 0 ); E_TRACE(hr);
hr = device->SetTexture( 2, 0 ); E_TRACE(hr);
hr = device->SetTexture( 3, 0 ); E_TRACE(hr);
E_TRACE(hr);
}
break;
case e6::RF_LIGHTING:
hr = device->SetRenderState( D3DRS_LIGHTING, value ); E_TRACE(hr);
break;
case e6::RF_CULL:
hr = device->SetRenderState( D3DRS_CULLMODE, (value? doCCW + 2 : 1) ); E_TRACE(hr);
break;
case e6::RF_CCW:
hr = device->SetRenderState( D3DRS_CULLMODE, (doCull? value + 2 : 1) ); E_TRACE(hr);
break;
case e6::RF_SHADE:
hr = device->SetRenderState( D3DRS_SHADEMODE, (value? D3DSHADE_GOURAUD : D3DSHADE_FLAT) ); E_TRACE(hr);
break;
case e6::RF_ZTEST:
hr = device->SetRenderState( D3DRS_ZENABLE, value ); E_TRACE(hr);
break;
case e6::RF_ZWRITE:
hr = device->SetRenderState( D3DRS_ZWRITEENABLE, value ); E_TRACE(hr);
break;
case e6::RF_ZDEPTH:
break;
case e6::RF_ALPHA_TEST:
device->SetRenderState( D3DRS_ALPHAREF, (DWORD) 0x000000001 );
// device->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_ALWAYS );
hr = device->SetRenderState( D3DRS_ALPHATESTENABLE, value ); E_TRACE(hr);
break;
case e6::RF_ALPHA:
hr = device->SetRenderState(D3DRS_ALPHABLENDENABLE, value ); E_TRACE(hr);
break;
case e6::RF_SRCBLEND:
hr = device->SetRenderState( D3DRS_SRCBLEND, _blendMode(value) ); E_TRACE(hr);
break;
case e6::RF_DSTBLEND:
hr = device->SetRenderState( D3DRS_DESTBLEND, _blendMode(value) ); E_TRACE(hr);
break;
case e6::RF_WIRE:
{
if ( value )
{
hr = device->SetRenderState( D3DRS_FILLMODE, D3DFILL_WIREFRAME ); E_TRACE(hr);
// hr = device->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_DISABLE );
}
else
{
hr = device->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID ); E_TRACE(hr);
// hr = device->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_DISABLE );
}
break;
}
default: return 0;
}
//~ $();
return 1;
}
virtual uint setVertexShaderConstant( uint i, const float4 & v )
{
E_ASSERT( device );
hr = device->SetVertexShaderConstantF( i, (float*)&(v), 1 );
E_TRACE(hr);
return 1;
}
virtual uint setPixelShaderConstant( uint i, const float4 & v )
{
E_ASSERT( device );
hr = device->SetPixelShaderConstantF( i, (float*)&(v), 1 );
E_TRACE(hr);
return 1;
}
virtual uint end3D()
{
E_ASSERT( device );
if ( ! alphaMeshes.empty() )
{
//~ hr = device->SetRenderState( D3DRS_ALPHATESTENABLE, 1 ); E_TRACE(hr);
hr = device->SetRenderState( D3DRS_ALPHABLENDENABLE, 1 ); E_TRACE(hr);
hr = device->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); E_TRACE(hr);
hr = device->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); E_TRACE(hr);
for ( uint i=0; i<alphaMeshes.size(); i++ )
{
if ( alphaMeshes[ i ] )
{
renderMesh( alphaMeshes[i] );
}
}
alphaMeshes.clear();
//~ hr = device->SetRenderState( D3DRS_ALPHATESTENABLE, doAlphaTest ); E_TRACE(hr);
_setRenderState( e6::RF_ALPHA, doAlpha );
_setRenderState( e6::RF_SRCBLEND, stateBlendSrc );
_setRenderState( e6::RF_DSTBLEND, stateBlendDst );
}
hr = device->EndScene(); E_TRACE(hr);
//{ // save rendertarget for debugging:
// IDirect3DSurface9 * target = 0;
// hr = device->GetRenderTarget( 0, & target );
// E_TRACE(hr);
// if ( target != backBuffer )
// {
// SurfaceHelper::saveSurface( target, "screen.tga" );
// }
//}
//~ $();
return SUCCEEDED( hr );
}
virtual uint get( uint what )
{
switch( what )
{
case e6::RF_CULL: return doCull;
case e6::RF_CCW: return doCCW;
case e6::RF_SHADE: return shadeMode;
case e6::RF_WIRE: return doWire;
case e6::RF_TEXTURE: return doTexture;
case e6::RF_LIGHTING: return doLighting;
case e6::RF_ALPHA: return doAlpha;
case e6::RF_ALPHA_TEST: return doAlphaTest;
case e6::RF_ZWRITE: return doZWrite;
case e6::RF_ZTEST: return doZTest;
case e6::RF_ZDEPTH: return zBufferDepth;
case e6::RF_SRCBLEND: return stateBlendSrc;
case e6::RF_DSTBLEND: return stateBlendDst;
case e6::RF_CLEAR_COLOR: return bgColor;
case e6::RF_CLEAR_BUFFER: return doClearBackBuffer;
case e6::RF_NUM_HW_TEX: return textureCache.cache.size();
case e6::RF_NUM_HW_VB : return vertexCache.cache.size();
case e6::RF_NUM_HW_VSH: return vertexShaderCache.cache.size();
case e6::RF_NUM_HW_PSH: return pixelShaderCache.cache.size();
}
return 0;
}
void cleanup()
{
alphaMeshes.clear();
COM_RELEASE( backBuffer );
COM_RELEASE( device ) ;
COM_RELEASE( d3d );
}
virtual uint captureFrontBuffer( const char * fileName )
{
IDirect3DSurface9 * surface = 0;
hr = device->CreateOffscreenPlainSurface(
d3ddm.Width,
d3ddm.Height,
//d3dpp.BackBufferWidth,
//d3dpp.BackBufferHeight,
D3DFMT_A8R8G8B8,
D3DPOOL_SYSTEMMEM,
& surface, 0 );
if ( hr != S_OK ) return 0;
HWND hwnd = this->d3dpp.hDeviceWindow;
//HWND hwnd = GetActiveWindow();
RECT * rect = 0;
RECT rect0;
if ( ! doFullScreen )
{
GetWindowRect( hwnd, & rect0 );
//GetClientRect( hwnd, & rect1 );
rect = & rect0;
}
uint swapChain = 0;
hr = device->GetFrontBufferData( swapChain, surface );
if ( hr != S_OK ) return 0;
//HRESULT hr = S_OK;
uint res = SurfaceHelper::saveSurface( surface, fileName, rect );
COM_RELEASE( surface );
return res;
}
}; //CRenderer
}; // dx9
using e6::ClassInfo;
extern "C"
uint getClassInfo( ClassInfo ** ptr )
{
const static ClassInfo _ci[] =
{
{ "Core.Renderer", "RendererDx9", Dx9::CRenderer::createSingleton, Dx9::CRenderer::classRef },
{ 0, 0, 0 }//,
//0
};
*ptr = (ClassInfo *)_ci;
return 1; // classses
}
#include "../../e6/version.h"
extern "C"
uint getVersion( e6::ModVersion * mv )
{
mv->modVersion = ("Dx9 00.000.0000 (" __DATE__ ")");
mv->e6Version = e6::e6_version;
return 1;
}
| [
"[email protected]"
]
| [
[
[
1,
976
]
]
]
|
c2334eed003001520564b441a8f038cef3fb7475 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/_Multimedia/MP3/Layer3.cpp | b833474a49a243b425582d30a9bbc97cefe259e8 | []
| no_license | willrebuild/flyffsf | e5911fb412221e00a20a6867fd00c55afca593c7 | d38cc11790480d617b38bb5fc50729d676aef80d | refs/heads/master | 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 44,993 | cpp | /*
Layer III routines adopted from the ISO MPEG Audio Subgroup Software Simulation
Group's public c source for its MPEG audio decoder. These routines were in the
file "decoder.c". Rearrangement of the routines as member functions of a
layer III decoder object, and optimizations by Jeff Tsay
([email protected]).
If you want to help, figure out how to implement a 9 point IDCT
in n log n time, and e-mail me.
Last modified : 01/31/97 */
#define STRICT
#define WIN32_LEAN_AND_MEAN
#define NOMCX
#define NOIME
#define NOGDI
#define NOUSER
#define NOSOUND
#define NOCOMM
#define NODRIVERS
#define OEMRESOURCE
#define NONLS
#define NOSERVICE
#define NOKANJI
#define NOMINMAX
#define NOLOGERROR
#define NOPROFILER
#define NOMEMMGR
#define NOLFILEIO
#define NOOPENFILE
#define NORESOURCE
#define NOATOM
#define NOLANGUAGE
#define NOLSTRING
#define NODBCS
#define NOKEYBOARDINFO
#define NOGDICAPMASKS
#define NOCOLOR
#define NOGDIOBJ
#define NODRAWTEXT
#define NOTEXTMETRIC
#define NOSCALABLEFONT
#define NOBITMAP
#define NORASTEROPS
#define NOMETAFILE
#define NOSYSMETRICS
#define NOSYSTEMPARAMSINFO
#define NOMSG
#define NOWINSTYLES
#define NOWINOFFSETS
#define NOSHOWWINDOW
#define NODEFERWINDOWPOS
#define NOVIRTUALKEYCODES
#define NOKEYSTATES
#define NOWH
#define NOMENUS
#define NOSCROLL
#define NOCLIPBOARD
#define NOICONS
#define NOMB
#define NOSYSCOMMANDS
#define NOMDI
#define NOCTLMGR
#define NOWINMESSAGES
#define NOHELP
#define _WINUSER_
#include "stdafx.h"
#include <math.h>
#include "all.h"
#include "l3type.h"
#include "ibitstr.h"
#include "obuffer.h"
#include "bit_res.h"
#include "header.h"
#include "synfilt.h"
#include "huffman.h"
#include "layer3.h"
LayerIII_Decoder::LayerIII_Decoder(char *huffdec_path0,
Ibitstream *stream0,
Header *header0,
SynthesisFilter *filtera,
SynthesisFilter *filterb,
Obuffer *buffer0)
{
huffdec_path = huffdec_path0;
stream = stream0;
header = header0;
filter1 = filtera;
filter2 = filterb;
buffer = buffer0;
frame_start = 0;
channels = (header->mode() == single_channel) ? 1 : 2;
int32 i,j,k;
for(i=0;i<2;i++)
for(j=0;j<SBLIMIT;j++)
for(k=0;k<SSLIMIT;k++)
prevblck[i][j][k]=0.0f;
br = new Bit_Reserve();
si = new III_side_info_t;
}
LayerIII_Decoder::~LayerIII_Decoder()
{
safe_delete( br );
safe_delete( si );
}
void LayerIII_Decoder::seek_notify()
{
frame_start = 0;
int32 i,j,k;
for(i=0;i<2;i++)
for(j=0;j<SBLIMIT;j++)
for(k=0;k<SSLIMIT;k++)
prevblck[i][j][k]=0.0f;
safe_delete( br );
br = new Bit_Reserve;
}
struct {
int32 l[5];
int32 s[3];} sfbtable = {{0, 6, 11, 16, 21},
{0, 6, 12}};
int32 slen[2][16] = {{0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4},
{0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3}};
void LayerIII_Decoder::get_scale_factors(int32 ch, int32 gr)
{
int32 sfb, window;
gr_info_s *gr_info = &(si->ch[ch].gr[gr]);
int32 scale_comp = gr_info->scalefac_compress;
int32 length0 = slen[0][scale_comp];
int32 length1 = slen[1][scale_comp];
if (gr_info->window_switching_flag && (gr_info->block_type == 2)) {
if (gr_info->mixed_block_flag) { /* MIXED */ /* NEW - ag 11/25 */
for (sfb = 0; sfb < 8; sfb++)
scalefac[ch].l[sfb] = br->hgetbits(
slen[0][gr_info->scalefac_compress]);
for (sfb = 3; sfb < 6; sfb++)
for (window=0; window<3; window++)
scalefac[ch].s[window][sfb] = br->hgetbits(
slen[0][gr_info->scalefac_compress]);
for (sfb = 6; sfb < 12; sfb++)
for (window=0; window<3; window++)
scalefac[ch].s[window][sfb] = br->hgetbits(
slen[1][gr_info->scalefac_compress]);
for (sfb=12,window=0; window<3; window++)
scalefac[ch].s[window][sfb] = 0;
}
else { /* SHORT*/
scalefac[ch].s[0][0] = br->hgetbits(length0);
scalefac[ch].s[1][0] = br->hgetbits(length0);
scalefac[ch].s[2][0] = br->hgetbits(length0);
scalefac[ch].s[0][1] = br->hgetbits(length0);
scalefac[ch].s[1][1] = br->hgetbits(length0);
scalefac[ch].s[2][1] = br->hgetbits(length0);
scalefac[ch].s[0][2] = br->hgetbits(length0);
scalefac[ch].s[1][2] = br->hgetbits(length0);
scalefac[ch].s[2][2] = br->hgetbits(length0);
scalefac[ch].s[0][3] = br->hgetbits(length0);
scalefac[ch].s[1][3] = br->hgetbits(length0);
scalefac[ch].s[2][3] = br->hgetbits(length0);
scalefac[ch].s[0][4] = br->hgetbits(length0);
scalefac[ch].s[1][4] = br->hgetbits(length0);
scalefac[ch].s[2][4] = br->hgetbits(length0);
scalefac[ch].s[0][5] = br->hgetbits(length0);
scalefac[ch].s[1][5] = br->hgetbits(length0);
scalefac[ch].s[2][5] = br->hgetbits(length0);
scalefac[ch].s[0][6] = br->hgetbits(length1);
scalefac[ch].s[1][6] = br->hgetbits(length1);
scalefac[ch].s[2][6] = br->hgetbits(length1);
scalefac[ch].s[0][7] = br->hgetbits(length1);
scalefac[ch].s[1][7] = br->hgetbits(length1);
scalefac[ch].s[2][7] = br->hgetbits(length1);
scalefac[ch].s[0][8] = br->hgetbits(length1);
scalefac[ch].s[1][8] = br->hgetbits(length1);
scalefac[ch].s[2][8] = br->hgetbits(length1);
scalefac[ch].s[0][9] = br->hgetbits(length1);
scalefac[ch].s[1][9] = br->hgetbits(length1);
scalefac[ch].s[2][9] = br->hgetbits(length1);
scalefac[ch].s[0][10] = br->hgetbits(length1);
scalefac[ch].s[1][10] = br->hgetbits(length1);
scalefac[ch].s[2][10] = br->hgetbits(length1);
scalefac[ch].s[0][11] = br->hgetbits(length1);
scalefac[ch].s[1][11] = br->hgetbits(length1);
scalefac[ch].s[2][11] = br->hgetbits(length1);
scalefac[ch].s[0][12] = 0;
scalefac[ch].s[1][12] = 0;
scalefac[ch].s[2][12] = 0;
}
}
else { /* LONG types 0,1,3 */
if ((si->ch[ch].scfsi[0] == 0) || (gr == 0)) {
scalefac[ch].l[0] = br->hgetbits(length0);
scalefac[ch].l[1] = br->hgetbits(length0);
scalefac[ch].l[2] = br->hgetbits(length0);
scalefac[ch].l[3] = br->hgetbits(length0);
scalefac[ch].l[4] = br->hgetbits(length0);
scalefac[ch].l[5] = br->hgetbits(length0);
}
if ((si->ch[ch].scfsi[1] == 0) || (gr == 0)) {
scalefac[ch].l[6] = br->hgetbits(length0);
scalefac[ch].l[7] = br->hgetbits(length0);
scalefac[ch].l[8] = br->hgetbits(length0);
scalefac[ch].l[9] = br->hgetbits(length0);
scalefac[ch].l[10] = br->hgetbits(length0);
}
if ((si->ch[ch].scfsi[2] == 0) || (gr == 0)) {
scalefac[ch].l[11] = br->hgetbits(length1);
scalefac[ch].l[12] = br->hgetbits(length1);
scalefac[ch].l[13] = br->hgetbits(length1);
scalefac[ch].l[14] = br->hgetbits(length1);
scalefac[ch].l[15] = br->hgetbits(length1);
}
if ((si->ch[ch].scfsi[3] == 0) || (gr == 0)) {
scalefac[ch].l[16] = br->hgetbits(length1);
scalefac[ch].l[17] = br->hgetbits(length1);
scalefac[ch].l[18] = br->hgetbits(length1);
scalefac[ch].l[19] = br->hgetbits(length1);
scalefac[ch].l[20] = br->hgetbits(length1);
}
scalefac[ch].l[21] = 0;
scalefac[ch].l[22] = 0;
}
}
struct {
int32 l[23];
int32 s[14];} sfBandIndex[3] =
{{{0,4,8,12,16,20,24,30,36,44,52,62,74,90,110,134,162,196,238,288,342,418,576},
{0,4,8,12,16,22,30,40,52,66,84,106,136,192}},
{{0,4,8,12,16,20,24,30,36,42,50,60,72,88,106,128,156,190,230,276,330,384,576},
{0,4,8,12,16,22,28,38,50,64,80,100,126,192}},
{{0,4,8,12,16,20,24,30,36,44,54,66,82,102,126,156,194,240,296,364,448,550,576},
{0,4,8,12,16,22,30,42,58,78,104,138,180,192}}};
void LayerIII_Decoder::hufman_decode(int32 ch, int32 gr)
{
int32 i, x, y;
int32 v, w;
int32 part2_3_end = part2_start + si->ch[ch].gr[gr].part2_3_length;
int32 num_bits;
int32 region1Start;
int32 region2Start;
int32 sf_index;
int32 ssindex, sbindex;
struct huffcodetab *h;
static BOOL huffman_init = FALSE;
/* if (!huffman_init) {
if (read_decoder_table(huffdec_path))
huffman_init = TRUE;
else
ExitThread(1L);
} */
/* Initialize output */
/* Eliminates need to zero out the rest */
for (x=0;x<SBLIMIT;x++){
is[x][0] = 0; is[x][1] = 0; is[x][2] = 0;
is[x][3] = 0; is[x][4] = 0; is[x][5] = 0;
is[x][6] = 0; is[x][7] = 0; is[x][8] = 0;
is[x][9] = 0; is[x][10] = 0; is[x][11] = 0;
is[x][12] = 0; is[x][13] = 0; is[x][14] = 0;
is[x][15] = 0; is[x][16] = 0; is[x][17] = 0;
}
/* Find region boundary for short block case. */
if ( (si->ch[ch].gr[gr].window_switching_flag) &&
(si->ch[ch].gr[gr].block_type == 2) ) {
/* Region2. */
region1Start = 36; /* sfb[9/3]*3=36 */
region2Start = 576; /* No Region2 for short block case. */
}
else { /* Find region boundary for long block case. */
sf_index = header->sample_frequency();
region1Start = sfBandIndex[sf_index].l[si->ch[ch].gr[gr].region0_count
+ 1]; /* MI */
region2Start = sfBandIndex[sf_index].l[si->ch[ch].gr[gr].region0_count +
si->ch[ch].gr[gr].region1_count + 2]; /* MI */
}
sbindex = 0; ssindex = 0;
/* Read bigvalues area. */
for (i=0; i<(si->ch[ch].gr[gr].big_values<<1); i+=2) {
if (i<region1Start) h = &ht[si->ch[ch].gr[gr].table_select[0]];
else if (i<region2Start) h = &ht[si->ch[ch].gr[gr].table_select[1]];
else h = &ht[si->ch[ch].gr[gr].table_select[2]];
huffman_decoder(h, &x, &y, &v, &w, br);
is[sbindex][ssindex] = x;
is[sbindex][ssindex+1] = y;
ssindex += 2;
if (ssindex >= SSLIMIT) {
ssindex = 0;
sbindex++;
}
}
/* Read count1 area. */
h = &ht[(*si).ch[ch].gr[gr].count1table_select+32];
num_bits = br->hsstell();
while ((num_bits < part2_3_end) && (sbindex < SBLIMIT)) {
huffman_decoder(h, &x, &y, &v, &w, br);
is[sbindex][ssindex] = v;
is[sbindex][ssindex + 1] = w;
ssindex += 2;
if (ssindex >= SSLIMIT) {
ssindex = 0;
sbindex++;
}
if (sbindex < SBLIMIT) {
is[sbindex][ssindex] = x;
is[sbindex][ssindex+1] = y;
}
ssindex += 2;
if (ssindex >= SSLIMIT) {
ssindex = 0;
sbindex++;
}
num_bits = br->hsstell();
}
if (num_bits > part2_3_end)
br->rewindNbits(num_bits - part2_3_end);
num_bits = br->hsstell();
/* Dismiss stuffing Bits */
if (num_bits < part2_3_end)
br->hgetbits(part2_3_end - num_bits);
/* Zero out rest. */
/* for (; i<SSLIMIT*SBLIMIT; i++)
is[i/SSLIMIT][i%SSLIMIT] = 0; */
}
int pretab[22] = {0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,2,0};
real LayerIII_Decoder::two_pow2(int32 scale, int32 preflag,
int32 pretab_offset, int32 l)
{
int32 index;
static real two_to_negative_half_pow[40];
static BOOL two_pow2_init = FALSE;
if (!two_pow2_init) {
int32 i;
for (i=0;i<40;i++)
two_to_negative_half_pow[i] = (real) pow(2.0, -0.5 * (double) i);
two_pow2_init = TRUE;
}
index = l;
if (preflag)
index += pretab_offset;
index = index << scale;
return(two_to_negative_half_pow[index]);
}
void LayerIII_Decoder::dequantize_sample(real xr[SBLIMIT][SSLIMIT],
int32 ch, int32 gr)
{
gr_info_s *gr_info = &(si->ch[ch].gr[gr]);
int32 ss, sb, cb=0, sfreq=header->sample_frequency();
int32 next_cb_boundary, cb_begin, cb_width;
real temp;
int32 index=0, t_index;
int32 i;
static BOOL Dequant_init=FALSE;
static real TO_FOUR_THIRDS[1024];
if (!Dequant_init) {
for(i = 0; i<1024; i++)
TO_FOUR_THIRDS[i] = (real) pow( (double) i, 4.0/3.0);
Dequant_init = TRUE;
}
/* choose correct scalefactor band per block type, initalize boundary */
if (gr_info->window_switching_flag && (gr_info->block_type == 2) )
if (gr_info->mixed_block_flag)
next_cb_boundary=sfBandIndex[sfreq].l[1]; /* LONG blocks: 0,1,3 */
else {
cb_width = sfBandIndex[sfreq].s[1];
next_cb_boundary= (cb_width << 2) - cb_width;
cb_begin = 0;
}
else
next_cb_boundary=sfBandIndex[sfreq].l[1]; /* LONG blocks: 0,1,3 */
/* Compute overall (global) scaling. */
temp = (real) pow( 2.0 , (0.25 * (gr_info->global_gain - 210.0)));
for (sb=0; sb < SBLIMIT; sb++)
for(ss=0; ss < SSLIMIT; ss+=2) {
xr[sb][ss] = temp * TO_FOUR_THIRDS[abs(is[sb][ss])];
xr[sb][ss+1] = temp * TO_FOUR_THIRDS[abs(is[sb][ss+1])];
if (is[sb][ss]<0) xr[sb][ss] = -xr[sb][ss];
if (is[sb][ss+1]<0) xr[sb][ss+1] = -xr[sb][ss+1];
}
/* apply formula per block type */
for (sb=0 ; sb < SBLIMIT ; sb++) {
for (ss=0 ; ss < SSLIMIT ; ss++) {
if (index == next_cb_boundary) { /* Adjust critical band boundary */
if (gr_info->window_switching_flag && (gr_info->block_type == 2)) {
if (gr_info->mixed_block_flag) {
if (index == sfBandIndex[sfreq].l[8]) {
next_cb_boundary = sfBandIndex[sfreq].s[4];
next_cb_boundary = (next_cb_boundary << 2) -
next_cb_boundary;
cb = 3;
cb_width = sfBandIndex[sfreq].s[4] -
sfBandIndex[sfreq].s[3];
cb_begin = sfBandIndex[sfreq].s[3];
cb_begin = (cb_begin << 2) - cb_begin;
}
else if (index < sfBandIndex[sfreq].l[8])
next_cb_boundary = sfBandIndex[sfreq].l[(++cb)+1];
else {
next_cb_boundary = sfBandIndex[sfreq].s[(++cb)+1];
next_cb_boundary = (next_cb_boundary << 2) -
next_cb_boundary;
cb_begin = sfBandIndex[sfreq].s[cb];
cb_width = sfBandIndex[sfreq].s[cb+1] -
cb_begin;
cb_begin = (cb_begin << 2) - cb_begin;
}
}
else {
next_cb_boundary = sfBandIndex[sfreq].s[(++cb)+1];
next_cb_boundary = (next_cb_boundary << 2) -
next_cb_boundary;
cb_begin = sfBandIndex[sfreq].s[cb];
cb_width = sfBandIndex[sfreq].s[cb+1] -
cb_begin;
cb_begin = (cb_begin << 2) - cb_begin;
}
}
else /* long blocks */
next_cb_boundary = sfBandIndex[sfreq].l[(++cb)+1];
}
/* Do long/short dependent scaling operations. */
if (gr_info->window_switching_flag &&
(((gr_info->block_type == 2) && (gr_info->mixed_block_flag == 0)) ||
((gr_info->block_type == 2) && gr_info->mixed_block_flag && (sb >= 2)) ))
{
t_index = (index - cb_begin) / cb_width;
xr[sb][ss] *= pow(2.0, ((-2.0 * gr_info->subblock_gain[t_index])
-(0.5 * (1.0 + gr_info->scalefac_scale)
* scalefac[ch].s[t_index][cb])));
}
else { /* LONG block types 0,1,3 & 1st 2 subbands of switched blocks */
/* xr[sb][ss] *= pow(2.0, -0.5 * (1.0+gr_info->scalefac_scale)
* (scalefac[ch].l[cb]
+ gr_info->preflag * pretab[cb])); */
xr[sb][ss] *= two_pow2(gr_info->scalefac_scale, gr_info->preflag,
pretab[cb], scalefac[ch].l[cb]);
}
index++;
}
}
}
void LayerIII_Decoder::reorder (real xr[SBLIMIT][SSLIMIT], int32 ch, int32 gr)
{
gr_info_s *gr_info = &(si->ch[ch].gr[gr]);
int32 sfreq=header->sample_frequency();
int32 sfb, sfb_start, sfb_lines;
int32 sb, ss, freq, src_line, des_line;
if (gr_info->window_switching_flag && (gr_info->block_type == 2)) {
for(sb=0;sb<SBLIMIT;sb++)
re_hybridOut[sb][0] = re_hybridOut[sb][1] = re_hybridOut[sb][2] =
re_hybridOut[sb][3] = re_hybridOut[sb][4] = re_hybridOut[sb][5] =
re_hybridOut[sb][6] = re_hybridOut[sb][7] = re_hybridOut[sb][8] =
re_hybridOut[sb][9] = re_hybridOut[sb][10] = re_hybridOut[sb][11] =
re_hybridOut[sb][12] = re_hybridOut[sb][13] = re_hybridOut[sb][14] =
re_hybridOut[sb][15] = re_hybridOut[sb][16] = re_hybridOut[sb][17] =
0.0f;
if (gr_info->mixed_block_flag) {
/* NO REORDER FOR LOW 2 SUBBANDS */
for (ss=0 ; ss < SSLIMIT ; ss+=3) {
re_hybridOut[0][ss] = xr[0][ss];
re_hybridOut[0][ss+1] = xr[0][ss+1];
re_hybridOut[0][ss+2] = xr[0][ss+2];
}
for (ss=0; ss < SSLIMIT ; ss+=3) {
re_hybridOut[1][ss] = xr[1][ss];
re_hybridOut[1][ss+1] = xr[1][ss+1];
re_hybridOut[1][ss+2] = xr[1][ss+2];
}
/* REORDERING FOR REST SWITCHED SHORT */
for(sfb=3,sfb_start=sfBandIndex[sfreq].s[3],
sfb_lines=sfBandIndex[sfreq].s[4] - sfb_start;
sfb < 13; sfb++,sfb_start=sfBandIndex[sfreq].s[sfb],
(sfb_lines=sfBandIndex[sfreq].s[sfb+1] - sfb_start))
{
int32 sfb_start3 = (sfb_start << 2) - sfb_start;
for(freq=0;freq<sfb_lines;freq++) {
int32 freq3 = (freq << 2) - freq;
src_line = sfb_start3 + freq;
des_line = sfb_start3 + freq3;
re_hybridOut[des_line/SSLIMIT][des_line%SSLIMIT] =
xr[src_line/SSLIMIT][src_line%SSLIMIT];
src_line += sfb_lines;
des_line++;
re_hybridOut[des_line/SSLIMIT][des_line%SSLIMIT] =
xr[src_line/SSLIMIT][src_line%SSLIMIT];
src_line += sfb_lines;
des_line++;
re_hybridOut[des_line/SSLIMIT][des_line%SSLIMIT] =
xr[src_line/SSLIMIT][src_line%SSLIMIT];
}
}
}
else { /* pure short */
for(sfb=0,sfb_start=0,sfb_lines=sfBandIndex[sfreq].s[1];
sfb < 13; sfb++,sfb_start=sfBandIndex[sfreq].s[sfb],
(sfb_lines=sfBandIndex[sfreq].s[sfb+1] - sfb_start))
{
int32 sfb_start3 = (sfb_start << 2) - sfb_start;
for(freq=0;freq<sfb_lines;freq++) {
int32 freq3 = (freq << 2) - freq;
src_line = sfb_start3 + freq;
des_line = sfb_start3 + freq3;
re_hybridOut[des_line/SSLIMIT][des_line%SSLIMIT] =
xr[src_line/SSLIMIT][src_line%SSLIMIT];
src_line += sfb_lines;
des_line++;
re_hybridOut[des_line/SSLIMIT][des_line%SSLIMIT] =
xr[src_line/SSLIMIT][src_line%SSLIMIT];
src_line += sfb_lines;
des_line++;
re_hybridOut[des_line/SSLIMIT][des_line%SSLIMIT] =
xr[src_line/SSLIMIT][src_line%SSLIMIT];
}
}
}
}
else { /*long blocks */
for (sb=0 ; sb < SBLIMIT ; sb++)
for (ss = 0; ss < SSLIMIT; ss+=3) {
re_hybridOut[sb][ss] = xr[sb][ss];
re_hybridOut[sb][ss+1] = xr[sb][ss+1];
re_hybridOut[sb][ss+2] = xr[sb][ss+2];
}
}
}
#define PI 3.141593
#define PI12 0.2617994
#define PI18 0.17453293
#define PI24 0.1308997
#define PI36 0.08726646
#define PI72 0.04363323
real TAN12[16]={0.0, 0.26794919, 0.57735027, 1.0,
1.73205081, 3.73205081, 9.9999999e10 /*unbounded*/, -3.73205081,
-1.73205081, -1.0, -0.57735027, -0.26794919,
0.0, 0.26794919, 0.57735027, 1.0};
void LayerIII_Decoder::stereo(int32 gr)
{
gr_info_s *gr_info = &(si->ch[0].gr[gr]);
int32 sfreq = header->sample_frequency();
int32 mode_ext = header->mode_extension();
int32 ms_stereo = (header->mode() == joint_stereo) && (mode_ext & 0x2);
int32 i_stereo = (header->mode() == joint_stereo) && (mode_ext & 0x1);
int32 sfb;
int32 i,j,sb,ss,is_pos[576];
int32 lines, temp, temp2;
real is_ratio[576];
if (channels == 1) { /* mono , bypass xr[0][][] to lr[0][][]*/
for(sb=0;sb<SBLIMIT;sb++)
for(ss=0;ss<SSLIMIT;ss+=3) {
lr[0][sb][ss] = ro[0][sb][ss];
lr[0][sb][ss+1] = ro[0][sb][ss+1];
lr[0][sb][ss+2] = ro[0][sb][ss+2];
}
} else {
/* initialization */
for (i=0; i<576; i+=8)
is_pos[i] = is_pos[i+1] = is_pos[i+2] = is_pos[i+3] =
is_pos[i+4] = is_pos[i+5] = is_pos[i+6] = is_pos[i+7] = 7;
if (i_stereo)
{ if (gr_info->window_switching_flag && (gr_info->block_type == 2))
{ if( gr_info->mixed_block_flag )
{ int32 max_sfb = 0;
for (j=0; j<3; j++)
{ int32 sfbcnt;
sfbcnt = 2;
for( sfb=12; sfb >=3; sfb-- )
{
i = sfBandIndex[sfreq].s[sfb];
lines = sfBandIndex[sfreq].s[sfb+1] - i;
i = (i << 2) - i + (j+1) * lines - 1;
while ( lines > 0 )
{ if ( ro[1][i/SSLIMIT][i%SSLIMIT] != 0.0f )
{ sfbcnt = sfb;
sfb = -10;
lines = -10;
}
lines--;
i--;
}
}
sfb = sfbcnt + 1;
if (sfb > max_sfb)
max_sfb = sfb;
while(sfb < 12)
{ temp = sfBandIndex[sfreq].s[sfb];
sb = sfBandIndex[sfreq].s[sfb+1] - temp;
i = (temp << 2) - temp + j * sb;
for ( ; sb > 0; sb--)
{ is_pos[i] = scalefac[1].s[j][sfb];
if (is_pos[i] != 7)
is_ratio[i] = TAN12[is_pos[i]];
i++;
}
sfb++;
}
sfb = sfBandIndex[sfreq].s[10];
sb = sfBandIndex[sfreq].s[11] - sfb;
sfb = (sfb << 2) - sfb + j * sb;
temp = sfBandIndex[sfreq].s[11];
sb = sfBandIndex[sfreq].s[12] - temp;
i = (temp << 2) - temp + j * sb;
for ( ; sb > 0; sb-- )
{ is_pos[i] = is_pos[sfb];
is_ratio[i] = is_ratio[sfb];
i++;
}
}
if (max_sfb <= 3)
{ i = 2;
ss = 17;
sb = -1;
while (i >= 0)
{ if (ro[1][i][ss] != 0.0f)
{
sb = (i<<4) + (i<<1) + ss;
i = -1;
} else
{ ss--;
if (ss < 0)
{ i--;
ss = 17;
}
}
}
i = 0;
while ( sfBandIndex[sfreq].l[i] <= sb )
i++;
sfb = i;
i = sfBandIndex[sfreq].l[i];
for (; sfb<8; sfb++)
{ sb = sfBandIndex[sfreq].l[sfb+1]-sfBandIndex[sfreq].l[sfb];
for (; sb>0; sb--)
{ is_pos[i] = scalefac[1].l[sfb];
if (is_pos[i] != 7)
is_ratio[i] = TAN12[is_pos[i]];
i++;
}
}
}
} else
{ for (j=0; j<3; j++)
{ int32 sfbcnt;
sfbcnt = -1;
for( sfb=12; sfb >=0; sfb-- )
{
temp = sfBandIndex[sfreq].s[sfb];
lines = sfBandIndex[sfreq].s[sfb+1] - temp;
i = (temp << 2) - temp + (j+1) * lines - 1;
while ( lines > 0 )
{ if (ro[1][i/SSLIMIT][i%SSLIMIT] != 0.0f)
{ sfbcnt = sfb;
sfb = -10;
lines = -10;
}
lines--;
i--;
}
}
sfb = sfbcnt + 1;
while( sfb<12 )
{
temp = sfBandIndex[sfreq].s[sfb];
sb = sfBandIndex[sfreq].s[sfb+1] - temp;
i = (temp << 2) - temp + j * sb;
for ( ; sb > 0; sb--)
{ is_pos[i] = scalefac[1].s[j][sfb];
if (is_pos[i] != 7)
is_ratio[i] = TAN12[is_pos[i]];
i++;
}
sfb++;
}
temp = sfBandIndex[sfreq].s[10];
temp2= sfBandIndex[sfreq].s[11];
sb = temp2 - temp;
sfb = (temp << 2) - temp + j * sb;
sb = sfBandIndex[sfreq].s[12] - temp2;
i = (temp2 << 2) - temp2 + j * sb;
for (; sb>0; sb--)
{ is_pos[i] = is_pos[sfb];
is_ratio[i] = is_ratio[sfb];
i++;
}
}
}
} else // ms-stereo
{ i = 31;
ss = 17;
sb = 0;
while (i >= 0)
{ if (ro[1][i][ss] != 0.0f)
{
sb = (i<<4) + (i<<1) + ss;
i = -1;
} else
{ ss--;
if ( ss < 0 )
{ i--;
ss = 17;
}
}
}
i = 0;
while ( sfBandIndex[sfreq].l[i] <= sb )
i++;
sfb = i;
i = sfBandIndex[sfreq].l[i];
for ( ; sfb<21; sfb++ )
{ sb = sfBandIndex[sfreq].l[sfb+1] - sfBandIndex[sfreq].l[sfb];
for ( ; sb > 0; sb--)
{ is_pos[i] = scalefac[1].l[sfb];
if ( is_pos[i] != 7 )
is_ratio[i] = TAN12[is_pos[i]];
i++;
}
}
sfb = sfBandIndex[sfreq].l[20];
for ( sb = 576 - sfBandIndex[sfreq].l[21]; sb > 0; sb-- )
{ is_pos[i] = is_pos[sfb];
is_ratio[i] = is_ratio[sfb];
i++;
}
}
}
i = 0;
for(sb=0;sb<SBLIMIT;sb++)
for(ss=0;ss<SSLIMIT;ss++) {
if ( is_pos[i] == 7 ) {
if (ms_stereo) {
lr[0][sb][ss] = (ro[0][sb][ss]+ro[1][sb][ss])* 0.7071068f;
lr[1][sb][ss] = (ro[0][sb][ss]-ro[1][sb][ss])* 0.7071068f;
}
else {
lr[0][sb][ss] = ro[0][sb][ss];
lr[1][sb][ss] = ro[1][sb][ss];
}
}
else if (i_stereo ) {
lr[1][sb][ss] = ro[0][sb][ss] / (real) (1 + is_ratio[i]);
lr[0][sb][ss] = lr[1][sb][ss] * is_ratio[i];
}
/* else {
printf("Error in stereo processing\n");
} */
i++;
}
} // channels == 2
}
real Ci[8]={-0.6f,-0.535f,-0.33f,-0.185f,-0.095f,-0.041f,-0.0142f,-0.0037f};
void LayerIII_Decoder::antialias(int32 ch, int32 gr)
{
gr_info_s *gr_info = &(si->ch[ch].gr[gr]);
real bu,bd; /* upper and lower butterfly inputs */
int32 ss,sb;
static real ca[8],cs[8];
static BOOL antialias_init = FALSE;
if (!antialias_init) {
int32 i;
real sq;
for (i=0;i<8;i++) {
sq=sqrt(1.0f+Ci[i]*Ci[i]);
cs[i] = 1.0f/sq;
ca[i] = Ci[i] * cs[i];
}
antialias_init = TRUE;
}
/* 31 alias-reduction operations between each pair of sub-bands */
/* with 8 butterflies between each pair */
if (gr_info->window_switching_flag && (gr_info->block_type == 2) &&
!gr_info->mixed_block_flag ) {
for(sb=0;sb<SBLIMIT;sb++) {
hybridIn[sb][0] = re_hybridOut[sb][0];
hybridIn[sb][1] = re_hybridOut[sb][1];
hybridIn[sb][2] = re_hybridOut[sb][2];
hybridIn[sb][3] = re_hybridOut[sb][3];
hybridIn[sb][4] = re_hybridOut[sb][4];
hybridIn[sb][5] = re_hybridOut[sb][5];
hybridIn[sb][6] = re_hybridOut[sb][6];
hybridIn[sb][7] = re_hybridOut[sb][7];
hybridIn[sb][8] = re_hybridOut[sb][8];
hybridIn[sb][9] = re_hybridOut[sb][9];
hybridIn[sb][10]= re_hybridOut[sb][10];
hybridIn[sb][11]= re_hybridOut[sb][11];
hybridIn[sb][12]= re_hybridOut[sb][12];
hybridIn[sb][13]= re_hybridOut[sb][13];
hybridIn[sb][14]= re_hybridOut[sb][14];
hybridIn[sb][15]= re_hybridOut[sb][15];
hybridIn[sb][16]= re_hybridOut[sb][16];
hybridIn[sb][17]= re_hybridOut[sb][17];
}
} else if (gr_info->window_switching_flag && gr_info->mixed_block_flag &&
(gr_info->block_type == 2)) {
hybridIn[0][0] = re_hybridOut[0][0];
hybridIn[0][1] = re_hybridOut[0][1];
hybridIn[0][2] = re_hybridOut[0][2];
hybridIn[0][3] = re_hybridOut[0][3];
hybridIn[0][4] = re_hybridOut[0][4];
hybridIn[0][5] = re_hybridOut[0][5];
hybridIn[0][6] = re_hybridOut[0][6];
hybridIn[0][7] = re_hybridOut[0][7];
hybridIn[0][8] = re_hybridOut[0][8];
hybridIn[0][9] = re_hybridOut[0][9];
for(ss=0;ss<8;ss++) {
bu = re_hybridOut[0][17-ss];
bd = re_hybridOut[1][ss];
hybridIn[0][17-ss] = (bu * cs[ss]) - (bd * ca[ss]);
hybridIn[1][ss] = (bd * cs[ss]) + (bu * ca[ss]);
}
hybridIn[1][8] = re_hybridOut[1][8];
hybridIn[1][9] = re_hybridOut[1][9];
hybridIn[1][10] = re_hybridOut[1][10];
hybridIn[1][11] = re_hybridOut[1][11];
hybridIn[1][12] = re_hybridOut[1][12];
hybridIn[1][13] = re_hybridOut[1][13];
hybridIn[1][14] = re_hybridOut[1][14];
hybridIn[1][15] = re_hybridOut[1][15];
hybridIn[1][16] = re_hybridOut[1][16];
hybridIn[1][17] = re_hybridOut[1][17];
for(sb=2;sb<SBLIMIT;sb++) {
hybridIn[sb][0] = re_hybridOut[sb][0];
hybridIn[sb][1] = re_hybridOut[sb][1];
hybridIn[sb][2] = re_hybridOut[sb][2];
hybridIn[sb][3] = re_hybridOut[sb][3];
hybridIn[sb][4] = re_hybridOut[sb][4];
hybridIn[sb][5] = re_hybridOut[sb][5];
hybridIn[sb][6] = re_hybridOut[sb][6];
hybridIn[sb][7] = re_hybridOut[sb][7];
hybridIn[sb][8] = re_hybridOut[sb][8];
hybridIn[sb][9] = re_hybridOut[sb][9];
hybridIn[sb][10]= re_hybridOut[sb][10];
hybridIn[sb][11]= re_hybridOut[sb][11];
hybridIn[sb][12]= re_hybridOut[sb][12];
hybridIn[sb][13]= re_hybridOut[sb][13];
hybridIn[sb][14]= re_hybridOut[sb][14];
hybridIn[sb][15]= re_hybridOut[sb][15];
hybridIn[sb][16]= re_hybridOut[sb][16];
hybridIn[sb][17]= re_hybridOut[sb][17];
}
} else {
hybridIn[0][0] = re_hybridOut[0][0];
hybridIn[0][1] = re_hybridOut[0][1];
hybridIn[0][2] = re_hybridOut[0][2];
hybridIn[0][3] = re_hybridOut[0][3];
hybridIn[0][4] = re_hybridOut[0][4];
hybridIn[0][5] = re_hybridOut[0][5];
hybridIn[0][6] = re_hybridOut[0][6];
hybridIn[0][7] = re_hybridOut[0][7];
for(sb=0;sb<31;sb++) {
for(ss=0;ss<8;ss++) {
bu = re_hybridOut[sb][17-ss];
bd = re_hybridOut[sb+1][ss];
hybridIn[sb][17-ss] = (bu * cs[ss]) - (bd * ca[ss]);
hybridIn[sb+1][ss] = (bd * cs[ss]) + (bu * ca[ss]);
}
hybridIn[sb][8] = re_hybridOut[sb][8];
hybridIn[sb][9] = re_hybridOut[sb][9];
}
hybridIn[31][8] = re_hybridOut[31][8];
hybridIn[31][9] = re_hybridOut[31][9];
hybridIn[31][10] = re_hybridOut[31][10];
hybridIn[31][11] = re_hybridOut[31][11];
hybridIn[31][12] = re_hybridOut[31][12];
hybridIn[31][13] = re_hybridOut[31][13];
hybridIn[31][14] = re_hybridOut[31][14];
hybridIn[31][15] = re_hybridOut[31][15];
hybridIn[31][16] = re_hybridOut[31][16];
hybridIn[31][17] = re_hybridOut[31][17];
}
}
void LayerIII_Decoder::inv_mdct(real *in, real *out, int32 block_type)
{
/*
This uses Byeong Gi Lee's Fast Cosine Transform algorithm, but the
9 point IDCT needs to be reduced further. Unfortunately, I don't
know how to do that, because 9 is not an even number. - Jeff.*/
/*------------------------------------------------------------------*/
/* */
/* Function: Calculation of the inverse MDCT */
/* In the case of short blocks the 3 output vectors are already */
/* overlapped and added in this modul. */
/* */
/* New layer3 */
/* */
/*------------------------------------------------------------------*/
int32 i, six_i, p;
int32 odd_i, two_odd_i, four_odd_i, eight_odd_i;
real tmp[18], save, sum;
real pp1, pp2;
static BOOL MDCT_init = FALSE;
static real win[4][36];
static real COS18[138];
if(!MDCT_init){
/* type 0 */
for(i=0;i<36;i++)
win[0][i] = (real) sin( PI36 *(i+0.5) );
/* type 1*/
for(i=0;i<18;i++)
win[1][i] = (real) sin( PI36 *(i+0.5) );
for(i=18;i<24;i++)
win[1][i] = 1.0f;
for(i=24;i<30;i++)
win[1][i] = (real) sin( PI12 *(i+0.5-18) );
for(i=30;i<36;i++)
win[1][i] = 0.0f;
/* type 2 (not needed anymore) */
/* for(i=0;i<12;i++)
win[2][i] = (real) sin( PI12*(i+0.5) ) ;
for(i=12;i<36;i++)
win[2][i] = 0.0f; */
/* type 3*/
for(i=0;i<6;i++)
win[3][i] = 0.0f;
for(i=6;i<12;i++)
win[3][i] = (real) sin(PI12 * (i+ 0.5 - 6.0));
for(i=12;i<18;i++)
win[3][i] =1.0f;
for(i=18;i<36;i++)
win[3][i] = (real) sin(PI36 * (i + 0.5));
for(i=0;i<138;i++)
COS18[i] = (real) cos(PI18 * i);
MDCT_init = TRUE;
}
if(block_type == 2){
for(p=0;p<36;p+=9) {
out[p] = out[p+1] = out[p+2] = out[p+3] =
out[p+4] = out[p+5] = out[p+6] = out[p+7] =
out[p+8] = 0.0f;
}
six_i = 0;
for(i=0;i<3;i++)
{
// 12 point IMDCT
// Begin 12 point IDCT
// Input aliasing for 12 pt IDCT
in[15+i] += in[12+i]; in[12+i] += in[9+i]; in[9+i] += in[6+i];
in[6+i] += in[3+i]; in[3+i] += in[0+i];
// Input aliasing on odd indices (for 6 point IDCT)
in[15+i] += in[9+i]; in[9+i] += in[3+i];
// 3 point IDCT on even indices
pp2 = in[12+i] * 0.500000000f;
pp1 = in[ 6+i] * 0.866025403f;
sum = in[0+i] + pp2;
tmp[1] = in[0+i] - in[12+i];
tmp[0] = sum + pp1;
tmp[2] = sum - pp1;
// End 3 point IDCT on even indices
// 3 point IDCT on odd indices (for 6 point IDCT)
pp2 = in[15+i] * 0.500000000f;
pp1 = in[9+i] * 0.866025403f;
sum = in[3+i] + pp2;
tmp[4] = in[3+i] - in[15+i];
tmp[5] = sum + pp1;
tmp[3] = sum - pp1;
// End 3 point IDCT on odd indices
// Twiddle factors on odd indices (for 6 point IDCT)
tmp[3] *= 1.931851653f;
tmp[4] *= 0.707106781f;
tmp[5] *= 0.517638090f;
// Output butterflies on 2 3 point IDCT's (for 6 point IDCT)
save = tmp[0];
tmp[0] += tmp[5];
tmp[5] = save - tmp[5];
save = tmp[1];
tmp[1] += tmp[4];
tmp[4] = save - tmp[4];
save = tmp[2];
tmp[2] += tmp[3];
tmp[3] = save - tmp[3];
// End 6 point IDCT
// Twiddle factors on indices (for 12 point IDCT)
tmp[0] *= 0.504314480f;
tmp[1] *= 0.541196100f;
tmp[2] *= 0.630236207f;
tmp[3] *= 0.821339815f;
tmp[4] *= 1.306562965f;
tmp[5] *= 3.830648788f;
// End 12 point IDCT
// Shift to 12 point modified IDCT, multiply by window type 2
tmp[8] = -tmp[0] * 0.793353340f;
tmp[9] = -tmp[0] * 0.608761429f;
tmp[7] = -tmp[1] * 0.923879532f;
tmp[10] = -tmp[1] * 0.382683432f;
tmp[6] = -tmp[2] * 0.991444861f;
tmp[11] = -tmp[2] * 0.130526192f;
tmp[0] = tmp[3];
tmp[1] = tmp[4] * 0.382683432f;
tmp[2] = tmp[5] * 0.608761429f;
tmp[3] = -tmp[5] * 0.793353340f;
tmp[4] = -tmp[4] * 0.923879532f;
tmp[5] = -tmp[0] * 0.991444861f;
tmp[0] *= 0.130526192f;
out[six_i + 6] += tmp[0];
out[six_i + 7] += tmp[1];
out[six_i + 8] += tmp[2];
out[six_i + 9] += tmp[3];
out[six_i + 10] += tmp[4];
out[six_i + 11] += tmp[5];
out[six_i + 12] += tmp[6];
out[six_i + 13] += tmp[7];
out[six_i + 14] += tmp[8];
out[six_i + 15] += tmp[9];
out[six_i + 16] += tmp[10];
out[six_i + 17] += tmp[11];
six_i += 6;
}
} else {
// 36 point IDCT
// input aliasing for 36 point IDCT
in[17]+=in[16]; in[16]+=in[15]; in[15]+=in[14]; in[14]+=in[13];
in[13]+=in[12]; in[12]+=in[11]; in[11]+=in[10]; in[10]+=in[9];
in[9] +=in[8]; in[8] +=in[7]; in[7] +=in[6]; in[6] +=in[5];
in[5] +=in[4]; in[4] +=in[3]; in[3] +=in[2]; in[2] +=in[1];
in[1] +=in[0];
// 18 point IDCT for odd indices
// input aliasing for 18 point IDCT
in[17]+=in[15]; in[15]+=in[13]; in[13]+=in[11]; in[11]+=in[9];
in[9] +=in[7]; in[7] +=in[5]; in[5] +=in[3]; in[3] +=in[1];
// 9 point IDCT on even indices
/* for(i=0; i<9; i++) {
sum = 0.0;
for(j=0;j<18;j+=2)
sum += in[j] * cos(PI36 * (2*i + 1) * j);
tmp[i] = sum;
} */
for(i=0; i<9; i++) {
odd_i = (i << 1) + 1;
sum = in[0];
two_odd_i = odd_i << 1;
four_odd_i = odd_i << 2;
sum += in[2] * COS18[odd_i];
sum += in[4] * COS18[two_odd_i];
eight_odd_i = two_odd_i << 2;
sum += in[6] * COS18[four_odd_i - odd_i];
sum += in[8] * COS18[four_odd_i];
sum += in[10] * COS18[four_odd_i + odd_i];
sum += in[12] * COS18[four_odd_i + two_odd_i];
sum += in[14] * COS18[eight_odd_i - odd_i];
sum += in[16] * COS18[eight_odd_i];
tmp[i] = sum;
}
// End 9 point IDCT on even indices
// 9 point IDCT on odd indices
/* for(i=0; i<9; i++) {
sum = 0.0;
for(j=0;j<18;j+=2)
sum += in[j+1] * cos(PI36 * (2*i + 1) * j);
tmp[17-i] = sum;
} */
for(i=0; i<9; i++) {
odd_i = (i << 1) + 1;
sum = in[1];
two_odd_i = odd_i << 1;
four_odd_i = odd_i << 2;
sum += in[3] * COS18[odd_i];
sum += in[5] * COS18[two_odd_i];
eight_odd_i = two_odd_i << 2;
sum += in[7] * COS18[four_odd_i - odd_i];
sum += in[9] * COS18[four_odd_i];
sum += in[11] * COS18[four_odd_i + odd_i];
sum += in[13] * COS18[four_odd_i + two_odd_i];
sum += in[15] * COS18[eight_odd_i - odd_i];
sum += in[17] * COS18[eight_odd_i];
tmp[17-i] = sum;
}
// End 9 point IDCT on odd indices
// Twiddle factors on odd indices
tmp[9] *= 5.736856623f;
tmp[10] *= 1.931851653f;
tmp[11] *= 1.183100792f;
tmp[12] *= 0.871723397f;
tmp[13] *= 0.707106781f;
tmp[14] *= 0.610387294f;
tmp[15] *= 0.551688959f;
tmp[16] *= 0.517638090f;
tmp[17] *= 0.501909918f;
// Butterflies on 9 point IDCT's
for (i=0;i<9;i++) {
save = tmp[i];
tmp[i] += tmp[17-i];
tmp[17-i] = save - tmp[17-i];
}
// end 18 point IDCT
// twiddle factors for 36 point IDCT
tmp[0] *= -0.500476342f;
tmp[1] *= -0.504314480f;
tmp[2] *= -0.512139757f;
tmp[3] *= -0.524264562f;
tmp[4] *= -0.541196100f;
tmp[5] *= -0.563690973f;
tmp[6] *= -0.592844523f;
tmp[7] *= -0.630236207f;
tmp[8] *= -0.678170852f;
tmp[9] *= -0.740093616f;
tmp[10]*= -0.821339815f;
tmp[11]*= -0.930579498f;
tmp[12]*= -1.082840285f;
tmp[13]*= -1.306562965f;
tmp[14]*= -1.662754762f;
tmp[15]*= -2.310113158f;
tmp[16]*= -3.830648788f;
tmp[17]*= -11.46279281f;
// end 36 point IDCT
// shift to modified IDCT
out[0] =-tmp[9] * win[block_type][0];
out[1] =-tmp[10] * win[block_type][1];
out[2] =-tmp[11] * win[block_type][2];
out[3] =-tmp[12] * win[block_type][3];
out[4] =-tmp[13] * win[block_type][4];
out[5] =-tmp[14] * win[block_type][5];
out[6] =-tmp[15] * win[block_type][6];
out[7] =-tmp[16] * win[block_type][7];
out[8] =-tmp[17] * win[block_type][8];
out[9] = tmp[17] * win[block_type][9];
out[10]= tmp[16] * win[block_type][10];
out[11]= tmp[15] * win[block_type][11];
out[12]= tmp[14] * win[block_type][12];
out[13]= tmp[13] * win[block_type][13];
out[14]= tmp[12] * win[block_type][14];
out[15]= tmp[11] * win[block_type][15];
out[16]= tmp[10] * win[block_type][16];
out[17]= tmp[9] * win[block_type][17];
out[18]= tmp[8] * win[block_type][18];
out[19]= tmp[7] * win[block_type][19];
out[20]= tmp[6] * win[block_type][20];
out[21]= tmp[5] * win[block_type][21];
out[22]= tmp[4] * win[block_type][22];
out[23]= tmp[3] * win[block_type][23];
out[24]= tmp[2] * win[block_type][24];
out[25]= tmp[1] * win[block_type][25];
out[26]= tmp[0] * win[block_type][26];
out[27]= tmp[0] * win[block_type][27];
out[28]= tmp[1] * win[block_type][28];
out[29]= tmp[2] * win[block_type][29];
out[30]= tmp[3] * win[block_type][30];
out[31]= tmp[4] * win[block_type][31];
out[32]= tmp[5] * win[block_type][32];
out[33]= tmp[6] * win[block_type][33];
out[34]= tmp[7] * win[block_type][34];
out[35]= tmp[8] * win[block_type][35];
}
}
void LayerIII_Decoder::hybrid(int32 ch, int32 gr, int32 sb)
{
real *fsIn = hybridIn[sb];
real *tsOut = re_hybridOut[sb];
gr_info_s *gr_info = &(si->ch[ch].gr[gr]);
real rawout[36];
int32 bt;
bt = (gr_info->window_switching_flag && gr_info->mixed_block_flag &&
(sb < 2)) ? 0 : gr_info->block_type;
inv_mdct(fsIn, rawout, bt);
/* overlap addition */
tsOut[0] = rawout[0] + prevblck[ch][sb][0];
prevblck[ch][sb][0] = rawout[18];
tsOut[1] = rawout[1] + prevblck[ch][sb][1];
prevblck[ch][sb][1] = rawout[19];
tsOut[2] = rawout[2] + prevblck[ch][sb][2];
prevblck[ch][sb][2] = rawout[20];
tsOut[3] = rawout[3] + prevblck[ch][sb][3];
prevblck[ch][sb][3] = rawout[21];
tsOut[4] = rawout[4] + prevblck[ch][sb][4];
prevblck[ch][sb][4] = rawout[22];
tsOut[5] = rawout[5] + prevblck[ch][sb][5];
prevblck[ch][sb][5] = rawout[23];
tsOut[6] = rawout[6] + prevblck[ch][sb][6];
prevblck[ch][sb][6] = rawout[24];
tsOut[7] = rawout[7] + prevblck[ch][sb][7];
prevblck[ch][sb][7] = rawout[25];
tsOut[8] = rawout[8] + prevblck[ch][sb][8];
prevblck[ch][sb][8] = rawout[26];
tsOut[9] = rawout[9] + prevblck[ch][sb][9];
prevblck[ch][sb][9] = rawout[27];
tsOut[10] = rawout[10] + prevblck[ch][sb][10];
prevblck[ch][sb][10] = rawout[28];
tsOut[11] = rawout[11] + prevblck[ch][sb][11];
prevblck[ch][sb][11] = rawout[29];
tsOut[12] = rawout[12] + prevblck[ch][sb][12];
prevblck[ch][sb][12] = rawout[30];
tsOut[13] = rawout[13] + prevblck[ch][sb][13];
prevblck[ch][sb][13] = rawout[31];
tsOut[14] = rawout[14] + prevblck[ch][sb][14];
prevblck[ch][sb][14] = rawout[32];
tsOut[15] = rawout[15] + prevblck[ch][sb][15];
prevblck[ch][sb][15] = rawout[33];
tsOut[16] = rawout[16] + prevblck[ch][sb][16];
prevblck[ch][sb][16] = rawout[34];
tsOut[17] = rawout[17] + prevblck[ch][sb][17];
prevblck[ch][sb][17] = rawout[35];
}
void LayerIII_Decoder::decode()
{
int32 nSlots = header->slots();
int32 gr, ch, ss, sb, main_data_end, flush_main;
int32 bytes_to_discard;
stream->get_side_info(channels, si);
for (; nSlots > 0; nSlots--) // read main data.
br->hputbuf((uint32) stream->get_bits(8));
main_data_end = br->hsstell() >> 3; // of previous frame
if (flush_main=(br->hsstell() & 0x7)) {
br->hgetbits(8 - flush_main);
main_data_end++;
}
bytes_to_discard = frame_start - main_data_end
- si->main_data_begin;
if(main_data_end > 4096) {
frame_start -= 4096;
br->rewindNbytes(4096);
}
frame_start += header->slots();
if (bytes_to_discard < 0)
return;
for (; bytes_to_discard > 0; bytes_to_discard--) br->hgetbits(8);
for (gr=0;gr<2;gr++) {
for (ch=0; ch<channels; ch++) {
part2_start= br->hsstell();
get_scale_factors(ch, gr);
hufman_decode(ch, gr);
dequantize_sample(ro[ch], ch, gr);
}
stereo(gr);
for (ch=0; ch<channels; ch++) {
reorder (lr[ch], ch, gr);
antialias(ch, gr);
for (sb=0;sb<SBLIMIT;sb++) { // Hybrid synthesis.
hybrid(ch, gr, sb);
}
for (ss=1;ss<SSLIMIT;ss+=2) // Frequency inversion for polyphase.
for (sb=1;sb<SBLIMIT;sb+=2)
re_hybridOut[sb][ss] = -re_hybridOut[sb][ss];
if (ch == 0)
for (ss=0;ss<SSLIMIT;ss++) { // Polyphase synthesis
for (sb=0;sb<SBLIMIT;sb++)
filter1->input_sample(re_hybridOut[sb][ss], sb);
filter1->calculate_pcm_samples(buffer);
}
else
for (ss=0;ss<SSLIMIT;ss++) { // Polyphase synthesis
for (sb=0;sb<SBLIMIT;sb++)
filter2->input_sample(re_hybridOut[sb][ss], sb);
filter2->calculate_pcm_samples(buffer);
}
} // channels
} // granule
buffer->write_buffer (1); // write to stdout
}
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
1477
]
]
]
|
58ac0297db4faa26b9b40878e2afc0b22caa30be | 0b55a33f4df7593378f58b60faff6bac01ec27f3 | /Konstruct/Client/Dimensions/HealthyLifestyle.h | 0fcbf357441c2cc6a1d4e485adedf3f757f1a43b | []
| no_license | RonOHara-GG/dimgame | 8d149ffac1b1176432a3cae4643ba2d07011dd8e | bbde89435683244133dca9743d652dabb9edf1a4 | refs/heads/master | 2021-01-10T21:05:40.480392 | 2010-09-01T20:46:40 | 2010-09-01T20:46:40 | 32,113,739 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 259 | h | #pragma once
#include "SpreadableBuff.h"
class HealthyLifestyle :
public SpreadableBuff
{
public:
HealthyLifestyle(PlayerCharacter* pSource);
~HealthyLifestyle(void);
void Tick(PlayerCharacter* pTarget);
SpreadableBuff* CopyBuff();
};
| [
"bflassing@0c57dbdb-4d19-7b8c-568b-3fe73d88484e"
]
| [
[
[
1,
15
]
]
]
|
1292347535522d888ebc2cffd242343a60cf28a7 | ea12fed4c32e9c7992956419eb3e2bace91f063a | /zombie/code/nebula2/src/input/ndi8server_dinput.cc | ef22a45015638283c5740515b411bd39336d6c56 | []
| 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 | 12,463 | cc | //------------------------------------------------------------------------------
// ndi8server_dinput.cc
// (C) 2002 RadonLabs GmbH
//------------------------------------------------------------------------------
#include "input/ndi8server.h"
#include "input/ninputdevice.h"
#include "input/njoystickdevice.h"
#include "input/nrelmousedevice.h"
#include "input/nkeyboarddevice.h"
#include "kernel/nenv.h"
//------------------------------------------------------------------------------
/**
Initialized DirectInput8 and enumerates the input devices.
*/
bool
nDI8Server::InitDirectInput()
{
HRESULT hr;
// initialize DirectInput
HMODULE instance = GetModuleHandle(NULL);
if (!instance)
{
n_printf("nDI8Server: GetModuleHandle() failed!\n");
return false;
}
hr = DirectInput8Create(instance, DIRECTINPUT_VERSION, IID_IDirectInput8A, (void**) &(this->di8), NULL);
if (FAILED(hr))
{
n_printf("nDI8Server: DirectInput8Create() failed with '%s'!\n", this->Error(hr));
return false;
}
n_assert(this->di8);
// init DirectInput devices
if (!this->InitDevices())
{
n_printf("nDI8Server: Failed to initialize DInput devices!\n");
return false;
}
return true;
}
//------------------------------------------------------------------------------
/**
Destroy DirectInput.
*/
void
nDI8Server::KillDirectInput()
{
n_assert(this->di8);
// shutdown DirectInput devices
this->KillDevices();
// shutdown DirectInput
this->di8->Release();
this->di8 = 0;
}
//------------------------------------------------------------------------------
/**
Set a DWORD property on a DirectInput device.
*/
static
void
di8SetDWordProp(IDirectInputDevice8* dev, REFGUID prop, DWORD val)
{
HRESULT hr;
DIPROPDWORD dpw;
memset(&(dpw), 0, sizeof(dpw));
dpw.diph.dwSize = sizeof(DIPROPDWORD);
dpw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
dpw.diph.dwHow = DIPH_DEVICE;
dpw.diph.dwObj = NULL;
dpw.dwData = val;
hr = dev->SetProperty(prop, (LPDIPROPHEADER) &dpw);
}
//------------------------------------------------------------------------------
/**
Get a range property from a DirectInput device.
*/
static
void
di8GetRangeProp(IDirectInputDevice8* dev,
REFGUID prop,
DWORD obj,
int& minRange,
int& maxRange)
{
HRESULT hr;
DIPROPRANGE dpr;
memset(&(dpr), 0, sizeof(dpr));
dpr.diph.dwSize = sizeof(DIPROPRANGE);
dpr.diph.dwHeaderSize = sizeof(DIPROPHEADER);
dpr.diph.dwHow = DIPH_BYOFFSET;
dpr.diph.dwObj = obj;
hr = dev->GetProperty(prop,(LPDIPROPHEADER)&dpr);
if (SUCCEEDED(hr))
{
minRange = dpr.lMin;
maxRange = dpr.lMax;
}
else
{
minRange = 0;
maxRange = 0;
}
}
//------------------------------------------------------------------------------
/**
Callback procedure for EnumDevices. First checks whether the device
is acceptable to us, then creates a nDI8Device object and adds it to
the device list.
@param lpddi pointer to a DIDEVICEINSTANCE describing the input device
@param pvRef pointer to nDI8Server object
@return DIENUM_CONTINUE continues, DIENUM_STOP stops enumeration
*/
BOOL CALLBACK
di8EnumDevicesCallback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef)
{
HRESULT hr;
nDI8Server* diServer = (nDI8Server*) pvRef;
IDirectInput8* di8 = diServer->di8;
n_assert(di8);
// convert device type into general Nebula device type
DWORD devType = lpddi->dwDevType & 0xff;
nDI8Device::DeviceType type;
switch (devType)
{
case DI8DEVTYPE_GAMEPAD:
case DI8DEVTYPE_JOYSTICK:
type = nDI8Device::JOYSTICK;
break;
case DI8DEVTYPE_KEYBOARD:
type = nDI8Device::KEYBOARD;
break;
case DI8DEVTYPE_MOUSE:
type = nDI8Device::MOUSE;
break;
default:
type = nDI8Device::NONE;
break;
}
// ignore if device type not supported
if (nDI8Device::NONE == type)
{
return DIENUM_CONTINUE;
}
// create DirectInput device
IDirectInputDevice8* diDev = 0;
hr = di8->CreateDevice(lpddi->guidInstance, &diDev, 0);
if (FAILED(hr))
{
n_printf("nDI8Server: failed to create device '%s' with '%d'\n",
lpddi->tszInstanceName, diServer->Error(hr));
return DIENUM_CONTINUE;
}
n_assert(diDev);
// get device caps
DIDEVCAPS caps = { sizeof(DIDEVCAPS), 0 };
hr = diDev->GetCapabilities(&caps);
if (FAILED(hr))
{
n_printf("nDI8Server: GetCapabilities() failed!\n");
diDev->Release();
return DIENUM_CONTINUE;
}
// create nDI8Device object and link to device list
nDI8Device* dev = n_new(nDI8Device);
dev->SetDevice(diDev);
dev->SetInstanceName(lpddi->tszInstanceName);
dev->SetProductName(lpddi->tszProductName);
dev->SetDeviceType(type);
dev->SetNumAxes(caps.dwAxes);
dev->SetNumButtons(caps.dwButtons);
dev->SetNumPovs(caps.dwPOVs);
diServer->di8DevList.AddTail(dev);
// initialize the device
HWND hwnd(0);
if( diServer->refHwnd->GetType() == nArg::Pointer )
hwnd = static_cast<HWND>( diServer->refHwnd->GetP() );
else
hwnd = reinterpret_cast<HWND>( size_t(diServer->refHwnd->GetI()) );
n_assert2(hwnd, "/sys/env/hwnd is NULL -- perhaps nWin32WindowHandler::OpenWindow() has not been called.")
hr = diDev->SetCooperativeLevel(hwnd, (DISCL_FOREGROUND | DISCL_NOWINKEY | DISCL_NONEXCLUSIVE));
if (FAILED(hr))
{
n_printf("SetCooperativeLevel() failed on '%s' with '%s'\n", lpddi->tszInstanceName, diServer->Error(hr));
}
// set data format on DirectInput device
switch(type)
{
int minRange, maxRange;
case nDI8Device::JOYSTICK:
// set data format and axis properties
diDev->SetDataFormat(&c_dfDIJoystick);
di8SetDWordProp(diDev, DIPROP_BUFFERSIZE, nDI8Server::INPUT_BUFFER_SIZE);
di8SetDWordProp(diDev, DIPROP_AXISMODE, DIPROPAXISMODE_ABS);
di8SetDWordProp(diDev, DIPROP_DEADZONE, 250);
di8SetDWordProp(diDev, DIPROP_SATURATION, 9999);
// get the range and store in the device object
di8GetRangeProp(diDev, DIPROP_RANGE, DIJOFS_X, minRange, maxRange);
dev->SetRange(minRange, maxRange);
break;
case nDI8Device::KEYBOARD:
diDev->SetDataFormat(&c_dfDIKeyboard);
break;
case nDI8Device::MOUSE:
// set data format and axis properties
diDev->SetDataFormat(&c_dfDIMouse2);
di8SetDWordProp(diDev, DIPROP_BUFFERSIZE, nDI8Server::INPUT_BUFFER_SIZE);
di8SetDWordProp(diDev, DIPROP_AXISMODE, DIPROPAXISMODE_REL);
dev->SetRange(-50, +50);
break;
default:
break;
}
// acquire the device
diDev->Acquire();
// continue enumeration...
return DIENUM_CONTINUE;
}
//------------------------------------------------------------------------------
/**
Notify the DirectInput devices that the HWND has changed. Called
by Trigger() when window handle has changed since last frame.
*/
void
nDI8Server::HwndChanged()
{
HRESULT hr;
nDI8Device* dev;
for (dev = (nDI8Device*) this->di8DevList.GetHead();
dev;
dev = (nDI8Device*) dev->GetSucc())
{
IDirectInputDevice8* diDev = dev->GetDevice();
n_assert(diDev);
diDev->Unacquire();
hr = diDev->SetCooperativeLevel(this->hwnd, (DISCL_FOREGROUND|DISCL_NOWINKEY|DISCL_NONEXCLUSIVE));
if (FAILED(hr))
{
n_printf("SetCooperativeLevel() failed on '%s' with '%s'\n",
dev->GetInstanceName(),
this->Error(hr));
}
}
}
//------------------------------------------------------------------------------
/**
Enumerate supported DirectInput devices, create a nDI8Device object for each
DirectInput device.
*/
bool
nDI8Server::InitDevices()
{
n_assert(this->di8);
HRESULT hr;
// enumerate devices
hr = this->di8->EnumDevices(DI8DEVCLASS_ALL, di8EnumDevicesCallback, (LPVOID) this, DIEDFL_ATTACHEDONLY);
if (FAILED(hr))
{
n_printf("nDI8Server: EnumDevices() failed with '%s'\n", this->Error(hr));
return false;
}
// export devices into Nebula's input device database
this->ExportDevices();
return true;
}
//------------------------------------------------------------------------------
/**
Kill the devices in the internal device lists
*/
void
nDI8Server::KillDevices()
{
// kill nDI8Device's
nDI8Device* di8Dev;
while ( 0 != (di8Dev = (nDI8Device*) this->di8DevList.RemHead()) )
{
n_delete(di8Dev);
}
// kill Nebula input device objects
nInputDevice* dev;
while ( 0 != (dev = (nInputDevice*) this->nebDevList.RemHead()) )
{
n_delete(dev);
}
}
//------------------------------------------------------------------------------
/**
Export recognized devices into the Nebula input device database. This
creates nInputDevice objects, configures them, and asks them to export
themselves.
*/
void
nDI8Server::ExportDevices()
{
this->curJoyMouse = 0;
this->curPadMouse = 0;
this->curJoystick = 0;
this->curKeyboard = 0;
// scan di8 device list
nDI8Device* di8Dev;
for (di8Dev = (nDI8Device*) this->di8DevList.GetHead();
di8Dev;
di8Dev = (nDI8Device*) di8Dev->GetSucc())
{
// get hardware's number of axes, buttons and povs
int numAxes = di8Dev->GetNumAxes();
int numButtons = di8Dev->GetNumButtons();
int numPovs = di8Dev->GetNumPovs();
// create a nInputDevice object
switch (di8Dev->GetDeviceType())
{
case nDI8Device::MOUSE:
{
// generate a relmouse device object
nInputDevice* relMouse = n_new(nRelMouseDevice(
kernelServer,
this,
this->curRelMouse++,
numAxes,
numButtons,
0));
relMouse->SetSourceDevice(di8Dev);
relMouse->SetAxisRange(di8Dev->GetMinRange(), di8Dev->GetMaxRange());
relMouse->Export(this->refDevices.get());
this->nebDevList.AddTail(relMouse);
}
break;
case nDI8Device::JOYSTICK:
{
nInputDevice* joystick = n_new(nJoystickDevice(
kernelServer,
this,
this->curJoystick++,
numAxes,
numButtons,
numPovs));
joystick->SetSourceDevice(di8Dev);
joystick->SetAxisRange(di8Dev->GetMinRange(), di8Dev->GetMaxRange());
joystick->Export(this->refDevices.get());
this->nebDevList.AddTail(joystick);
}
break;
case nDI8Device::KEYBOARD:
{
nInputDevice* keyboard = n_new(nKeyboardDevice(
kernelServer,
this,
this->curKeyboard++,
0,
numButtons,
0));
keyboard->SetSourceDevice(di8Dev);
keyboard->Export(this->refDevices.get());
this->nebDevList.AddTail(keyboard);
}
break;
}
}
}
//------------------------------------------------------------------------------
| [
"magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91"
]
| [
[
[
1,
402
]
]
]
|
69ad7833892e1e403b1e0034c4f611fa779a5790 | d8e1a65a5863ea5a111c8304a040f1c797f8ebbf | / mtktest --username qq413187589/N65/N65_V1/plutommi/mmi/DebugLevels/DebugLevelSrc/Debug.cpp | 8eac0d37020002d1f3d95ae815968d994e4d3cb9 | []
| no_license | manoj-gupta5/mtktest | a6b627cde8c9a543d473a99f778fd6f587a8d053 | 98370766a36fffb8b0dde1cc6dd144599ea184f6 | refs/heads/master | 2020-12-25T21:12:59.596045 | 2010-07-18T05:06:14 | 2010-07-18T05:06:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,739 | cpp | /*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*******************************************************************************
* Filename:
* ---------
* Debug.cpp
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
*
*
* Author:
* -------
*
*
*==============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*==============================================================================
*******************************************************************************/
/**
* Copyright Notice
* ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
* Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
* (It is illegal to remove this copyright notice from this software or any
* portion of it)
*/
/**************************************************************
FILENAME : Debug.cpp
PURPOSE : Functions to print debug messages on console. This file uses windows
specific calls.
REMARKS : nil
AUTHOR : Vijay Vaidya
DATE : Aug' 28, 2002
**************************************************************/
#include "stdafx.h"
#include "PixtelDataTypes.h"
extern "C" {
/**************************************************************
FUNCTION NAME : DebugWindowAlloc
PURPOSE : Allocate debug console to print debug messages
INPUT PARAMETERS : nil
OUTPUT PARAMETERS : nil
RETURNS : void
REMARKS :
**************************************************************/
void DebugWindowAlloc()
{
}
/**************************************************************
FUNCTION NAME : DisplayToDebugwindow
PURPOSE : To display messages on console
INPUT PARAMETERS : nil
OUTPUT PARAMETERS : nil
RETURNS : void
REMARKS :
**************************************************************/
/**************************************************************
FUNCTION NAME : CtrlHandler(unsigned long fdwCtrlType)
PURPOSE : handles all CTRL signals
INPUT PARAMETERS : nil
OUTPUT PARAMETERS : nil
RETURNS : void
REMARKS : nil
**************************************************************/
} //extern "C"
| [
"qq413187589@046de88f-2cd9-6c0a-3028-073e08bc931c"
]
| [
[
[
1,
149
]
]
]
|
4fae0c2e0302f1a5c1a6462a40b2fab33507f16b | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/boost/xpressive/detail/static/productions/marker_compiler.hpp | 7881d97e83f8fc3c5f2cb2976f0a66a14a14f0e4 | [
"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,685 | hpp | ////////////////////////////////////////////////////////////////////////////
// marker_compiler.hpp
//
// Copyright 2004 Eric Niebler. 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)
#ifndef BOOST_XPRESSIVE_DETAIL_STATIC_PRODUCTIONS_MARKER_COMPILER_HPP_EAN_10_04_2005
#define BOOST_XPRESSIVE_DETAIL_STATIC_PRODUCTIONS_MARKER_COMPILER_HPP_EAN_10_04_2005
#include <boost/type_traits/is_same.hpp>
#include <boost/xpressive/detail/detail_fwd.hpp>
#include <boost/xpressive/proto/proto.hpp>
#include <boost/xpressive/proto/compiler/branch.hpp>
#include <boost/xpressive/proto/compiler/conditional.hpp>
#include <boost/xpressive/proto/compiler/transform.hpp>
#include <boost/xpressive/detail/static/productions/domain_tags.hpp>
#include <boost/xpressive/detail/static/productions/marker_transform.hpp>
#include <boost/xpressive/detail/static/productions/set_compilers.hpp>
namespace boost { namespace xpressive { namespace detail
{
///////////////////////////////////////////////////////////////////////////////
// assign_compiler
// could be (s1= 'a') or (set= 'a')
struct assign_compiler
: proto::conditional_compiler
<
is_marker_predicate
, proto::transform_compiler<marker_assign_transform, seq_tag>
, proto::branch_compiler<list_branch, lst_tag>
>
{
};
}}}
namespace boost { namespace proto
{
template<>
struct compiler<assign_tag, xpressive::detail::seq_tag, void>
: xpressive::detail::assign_compiler
{
};
}}
#endif
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
50
]
]
]
|
52bfcedbea3fd96c91c86a7756ccaeed191e0a50 | 7f72fc855742261daf566d90e5280e10ca8033cf | /branches/full-calibration/ground/src/plugins/modelview/modelviewgadgetwidget.h | 0faee59c2c0af7dcfbc76cdd5bcc18427c461c30 | []
| no_license | caichunyang2007/my_OpenPilot_mods | 8e91f061dc209a38c9049bf6a1c80dfccb26cce4 | 0ca472f4da7da7d5f53aa688f632b1f5c6102671 | refs/heads/master | 2023-06-06T03:17:37.587838 | 2011-02-28T10:25:56 | 2011-02-28T10:25:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,525 | h | /**
******************************************************************************
*
* @file modelviewgadgetwidget.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ModelViewPlugin ModelView Plugin
* @{
* @brief A gadget that displays a 3D representation of the UAV
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef MODELVIEWGADGETWIDGET_H_
#define MODELVIEWGADGETWIDGET_H_
#include <QtOpenGL/QGLWidget>
#include <QTimer>
#include "glc_factory.h"
#include "viewport/glc_viewport.h"
#include "viewport/glc_movercontroller.h"
#include "shading/glc_light.h"
#include "sceneGraph/glc_world.h"
#include "glc_exception.h"
#include "uavobjects/uavobjectmanager.h"
#include "uavobjects/attitudeactual.h"
class ModelViewGadgetWidget : public QGLWidget
{
Q_OBJECT
public:
ModelViewGadgetWidget(QWidget *parent = 0);
~ModelViewGadgetWidget();
void setAcFilename(QString acf)
{
if(QFile::exists(acf))
acFilename = acf;
else
{
acFilename= acf= ":/modelview/models/warning_sign.obj";
m_GlView.cameraHandle()->setFrontView(); // set to front camera to see/read the warning sign
}
}
void setBgFilename(QString bgf)
{
if (QFile::exists(bgFilename))
bgFilename = bgf;
else
bgFilename= ":/modelview/models/black.jpg"; // will put a black background if there's no background
}
void setVboEnable(bool eVbo) { vboEnable = eVbo; }
void reloadScene();
void updateAttitude(int value);
private:
void initializeGL();
void paintGL();
void resizeGL(int width, int height);
// Create GLC_Object to display
void CreateScene();
//Mouse events
void mousePressEvent(QMouseEvent * e);
void mouseMoveEvent(QMouseEvent * e);
void mouseReleaseEvent(QMouseEvent * e);
void wheelEvent(QWheelEvent * e);
void keyPressEvent(QKeyEvent * e);
//////////////////////////////////////////////////////////////////////
// Private slots Functions
//////////////////////////////////////////////////////////////////////
private slots:
void updateAttitude();
private:
GLC_Factory* m_pFactory;
GLC_Light m_Light;
GLC_World m_World;
GLC_Viewport m_GlView;
GLC_MoverController m_MoverController;
GLC_BoundingBox m_ModelBoundingBox;
//! The timer used for motion
QTimer m_MotionTimer;
int yMouseStart;
QString acFilename;
QString bgFilename;
bool vboEnable;
bool loadError;
bool mvInitGLSuccess;
AttitudeActual* attActual;
};
#endif /* MODELVIEWGADGETWIDGET_H_ */
| [
"jonathan@ebee16cc-31ac-478f-84a7-5cbb03baadba"
]
| [
[
[
1,
114
]
]
]
|
603227cdf90e50c18e67c7c5fbe0cc75f9f68765 | d8f64a24453c6f077426ea58aaa7313aafafc75c | /AI Sandbox/BlockData.h | 72e27ceee916b8da05088bfc0e284db9f9bf216d | []
| no_license | dotted/wfto | 5b98591645f3ddd72cad33736da5def09484a339 | 6eebb66384e6eb519401bdd649ae986d94bcaf27 | refs/heads/master | 2021-01-20T06:25:20.468978 | 2010-11-04T21:01:51 | 2010-11-04T21:01:51 | 32,183,921 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 128 | h | #ifndef BLOCK_DATA_H
#define BLOCK_DATA_H
class CBlockData
{
public:
int type,
owner;
};
#endif // BLOCK_DATA_H | [
"[email protected]"
]
| [
[
[
1,
12
]
]
]
|
d011806d739ceb93ace3f532942e13c6f5469e02 | 18760393ff08e9bdefbef1d5ef054065c59cedbc | /Source/KaroTestGUI/KaroEngine/Stdafx.cpp | 9e1c1ddff0ed777db93f632543c6428fcb84ae88 | []
| no_license | robertraaijmakers/koppijn | 530d0b0111c8416ea7a688c3e5627fd421b41068 | 5af4f9c8472570aa2f2a70e170e671c6e338c3c6 | refs/heads/master | 2021-01-17T22:13:45.697435 | 2011-06-23T19:27:59 | 2011-06-23T19:27:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 206 | cpp | // stdafx.cpp : source file that includes just the standard includes
// KaroEngine.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
| [
"[email protected]"
]
| [
[
[
1,
5
]
]
]
|
b2439eb4df3e7087dbd5a0ceb2fdf4cead1ed85f | 74b5cb9980eb7c3467d6a5b08198847d6f14b33b | /dslua/source/DSLConnection.cpp | 092bd040257e757920c580ccb2d3b8aea5efe235 | []
| no_license | sypherce/dslua | 122d03026a888a8e04483c21b873413d89735afb | 9841f11a84a0f6b01a3b2291cf3fc87fb4133c3a | refs/heads/master | 2021-01-10T03:15:29.531355 | 2007-07-31T03:24:08 | 2007-07-31T03:24:08 | 50,567,809 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 19,022 | cpp | #include <typeinfo>
#include <assert.h>
#include <PA9.h> // Include for PA_Lib
extern "C"
{
#include "lua.h"
#include "lauxlib.h"
}
#include "Utils.h"
#include "DSLConnection.h"
//------------------------------------------------------------
//----- Connection base class
//------------------------------------------------------------
UserdataStubs(Connection, Connection *);
Connection::Connection(const ConnectionType connectionType)
: m_connectionType(connectionType),
m_nSocket(-1)
{
}
#define isdigit(c) (c >= '0' && c <= '9')
#define IS_DIGIT_OR_DOT(c) (isdigit(c) || (c == '.'))
#define IS_INETADDR(s) (IS_DIGIT_OR_DOT(s[0]) && IS_DIGIT_OR_DOT(s[1]) && IS_DIGIT_OR_DOT(s[2]) && IS_DIGIT_OR_DOT(s[3]) && IS_DIGIT_OR_DOT(s[4]) && IS_DIGIT_OR_DOT(s[5]) && IS_DIGIT_OR_DOT(s[6]))
int PA_InitTCPSocket(int * sock, char * host, int port, int mode, struct sockaddr_in m_nLocal)
{
unsigned long ip;
if(IS_INETADDR(host))
ip = PA_chartoip(host);
else
ip = *(unsigned long *)gethostbyname(host)->h_addr_list[0];
memset(&m_nLocal, 0, sizeof(struct sockaddr_in));
m_nLocal.sin_family = AF_INET;
m_nLocal.sin_port = htons(port);
m_nLocal.sin_addr.s_addr = ip;
*sock = socket(AF_INET, SOCK_STREAM, 0);
if(mode == PA_NORMAL_TCP)
{
if(connect(*sock, (struct sockaddr *)&m_nLocal, sizeof(struct sockaddr_in)) == 0)
return 1;
}
else if(mode == PA_NONBLOCKING_TCP)
{
if(connect(*sock, (struct sockaddr *)&m_nLocal, sizeof(struct sockaddr_in)) == 0)
{
int i = 1;
ioctl(*sock, FIONBIO, &i);
return 1;
}
}
return 0;
}
int PA_InitTCPServer(int * sock, int port, int mode, int num_connect, struct sockaddr_in m_nLocal)
{
memset(&m_nLocal, 0, sizeof(struct sockaddr_in));
m_nLocal.sin_family = AF_INET;
m_nLocal.sin_port = htons(port);
m_nLocal.sin_addr.s_addr = 0;
*sock = socket(AF_INET, SOCK_STREAM, 0);
if(mode == PA_NORMAL_TCP)
{
bind(*sock, (struct sockaddr *)&m_nLocal, sizeof(struct sockaddr_in));
listen(*sock, num_connect);
return 1;
}
else if(mode == PA_NONBLOCKING_TCP)
{
bind(*sock, (struct sockaddr *)&m_nLocal, sizeof(struct sockaddr_in));
int i = 1;
ioctl(*sock, FIONBIO, &i);
listen(*sock, num_connect);
return 1;
}
/*
while(!sock)
{
sock=accept(*sock,(struct sockaddr *)&servaddr,&i);
}
*/
return 0;
}
/*int PA_InitUDPSocket(int *sock,char *host,int port,int mode, struct sockaddr_in m_nLocal)
{
unsigned long ip;
*sock = socket(AF_INET, SOCK_DGRAM, 0);
if(IS_INETADDR(host))
ip = PA_chartoip(host);
else
ip = *(unsigned long *)gethostbyname(host)->h_addr_list[0];
memset(&m_nLocal, 0, sizeof(struct sockaddr_in));
m_nLocal.sin_family = AF_INET;
m_nLocal.sin_port = htons(port);
m_nLocal.sin_addr.s_addr = ip;
if(mode == PA_NORMAL_TCP)
{
bind(*sock,(struct sockaddr *)&m_nLocal,sizeof(struct sockaddr_in));
return 1;
}
else if(mode == PA_NONBLOCKING_TCP)
{
bind(*sock,(struct sockaddr *)&m_nLocal,sizeof(struct sockaddr_in));
int i = 1;
ioctl(*sock, FIONBIO, &i);
return 1;
}
return 0;
}
int PA_InitUDPServer(int *sock,int port,int mode, struct sockaddr_in m_nLocal)
{
*sock = socket(AF_INET, SOCK_DGRAM, 0);
memset(&m_nLocal, 0, sizeof(struct sockaddr_in));
m_nLocal.sin_family = AF_INET;
m_nLocal.sin_port = htons(port);
m_nLocal.sin_addr.s_addr = INADDR_ANY;
if(mode == PA_NORMAL_TCP)
{
bind(*sock,(struct sockaddr *)&m_nLocal,sizeof(struct sockaddr_in));
return 1;
}
else if(mode == PA_NONBLOCKING_TCP)
{
bind(*sock,(struct sockaddr *)&m_nLocal,sizeof(struct sockaddr_in));
int i = 1;
ioctl(*sock, FIONBIO, &i);
return 1;
}
return 0;
}
int UDPConnection::connect(const char *host, const int port)
{
m_nHost = (char*)host;
m_nPort = port;
m_nMode = PA_NONBLOCKING_TCP;
if(m_nHost[0] == 0)
return PA_InitUDPServer(&m_nSocket,m_nPort,m_nMode, m_nLocal);
else
return PA_InitUDPSocket(&m_nSocket,m_nHost,m_nPort,m_nMode, m_nLocal);
}*/
int UDPConnection::connect(const int port, const int block)
{
m_nPort = port;
bzero(&m_nLocal, sizeof(struct sockaddr_in));
m_nLocal.sin_family = AF_INET;
m_nLocal.sin_port = htons(m_nPort);
m_nLocal.sin_addr.s_addr = INADDR_ANY;
/*if(strcmp((char*)host, "") != 0)
{
m_nLocal.sin_addr.s_addr = PA_chartoip((char*)host);
}*/
m_nSocket = socket(AF_INET, SOCK_DGRAM, 0);
if(bind(m_nSocket, (struct sockaddr *)&m_nLocal, sizeof(struct sockaddr_in)) < 0)
{
closesocket(m_nSocket);
return 0;
}
if(block)
{
int i = 1;
ioctl(m_nSocket, FIONBIO, &i);
}
return 1;
}
int SocketConnection::connect(const char * host, const int port)
{
m_nHost = (char *)host;
m_nPort = port;
m_nMode = PA_NONBLOCKING_TCP;
if(m_nHost[0] == 0)
return PA_InitTCPServer(&m_nSocket, m_nPort, m_nMode, 16, m_nLocal);
else
return PA_InitTCPSocket(&m_nSocket, m_nHost, m_nPort, m_nMode, m_nLocal);
}
Connection::~Connection()
{
}
const char * Connection::toString()
{
return "__CONNECTION__";
}
static int l_ConnectionGC(lua_State * lState)
{
Connection * * pConnectionTemp = toConnection(lState, 1);
if(*pConnectionTemp)
{
delete (*pConnectionTemp);
*pConnectionTemp = NULL;
}
return 0;
}
static int l_ConnectionToString(lua_State * lState)
{
lua_pushstring(lState, (*toConnection(lState, 1))->toString());
return 1;
}
static const luaL_reg Connection_methods[] = {
{0, 0}
};
static const luaL_reg Connection_meta[] = {
{"__gc", l_ConnectionGC},
{"__tostring", l_ConnectionToString},
{0, 0}
};
UserdataRegister(Connection, Connection_methods, Connection_meta);
//------------------------------------------------------------
//----- SocketConnection class
//------------------------------------------------------------
UserdataStubs(SocketConnection, SocketConnection *);
//------------------------------------------------------------
//----- UDPConnection class
//------------------------------------------------------------
UserdataStubs(UDPConnection, UDPConnection *);
SocketConnection::SocketConnection()
: Connection(CONNECTION_SOCKET)
{
}
UDPConnection::UDPConnection()
: Connection(CONNECTION_UDP)
{
}
int SocketConnection::getRemoteIP(char * ip)
{
long rIP = m_nLocal.sin_addr.s_addr;
sprintf(ip, "%i.%i.%i.%i", (int)((m_nLocal.sin_addr.s_addr) & 255), (int)((m_nLocal.sin_addr.s_addr >> 8) & 255), (int)((m_nLocal.sin_addr.s_addr >> 16) & 255), (int)((m_nLocal.sin_addr.s_addr >> 24) & 255));
return 1;
}
int UDPConnection::getRemoteIP(char * ip)
{
long rIP = m_nLocal.sin_addr.s_addr;
sprintf(ip, "%i.%i.%i.%i", (int)((rIP) & 255), (int)((rIP >> 8) & 255), (int)((rIP >> 16) & 255), (int)((rIP >> 24) & 255));
return 1;
}
int SocketConnection::getLocalIP(char * ip)
{
int lIP = Wifi_GetIP();
sprintf(ip, "%i.%i.%i.%i", (int)((lIP) & 255), (int)((lIP >> 8) & 255), (int)((lIP >> 16) & 255), (int)((lIP >> 24) & 255));
return 1;
}
int UDPConnection::getLocalIP(char * ip)
{
int lIP = Wifi_GetIP();
sprintf(ip, "%i.%i.%i.%i", (int)((lIP) & 255), (int)((lIP >> 8) & 255), (int)((lIP >> 16) & 255), (int)((lIP >> 24) & 255));
return 1;
}
int SocketConnection::accept_( )
{
return accept(m_nSocket, (sockaddr *)&m_nLocal, (int *)sizeof(struct sockaddr_in));
}
int SocketConnection::recv_(char * buffer, int size)
{
return recv(m_nSocket, buffer, size, 0);
}
int SocketConnection::recvfrom_(char * host, char * buffer, int size)
{
/*if(IS_INETADDR(host))
m_nLocal.sin_addr.s_addr = PA_chartoip(host);
else
m_nLocal.sin_addr.s_addr = *(unsigned long *)gethostbyname(host)->h_addr_list[0];
return recvfrom(m_nSocket, buffer, size, 0, (struct sockaddr*)&m_nLocal, (int*)sizeof(struct sockaddr_in));*/
return recv(m_nSocket, buffer, size, 0);
}
int UDPConnection::recvfrom_(char * host, char * buffer, int size)
{
if(IS_INETADDR(host))
m_nLocal.sin_addr.s_addr = PA_chartoip(host);
else
m_nLocal.sin_addr.s_addr = *(unsigned long *)gethostbyname(host)->h_addr_list[0];
return recvfrom(m_nSocket, buffer, size, 0, (struct sockaddr *)&m_nLocal, (int *)sizeof(struct sockaddr_in));
}
int UDPConnection::recv_(char * buffer, int size)
{
return recvfrom(m_nSocket, buffer, size, 0, (struct sockaddr *)&m_nLocal, (int *)sizeof(struct sockaddr_in));
}
int SocketConnection::send_(char * buffer, int size)
{
return send(m_nSocket, buffer, size, 0);
}
int SocketConnection::sendto_(char * host, char * buffer, int size)
{
/*if(IS_INETADDR(host))
m_nLocal.sin_addr.s_addr = PA_chartoip(host);
else
m_nLocal.sin_addr.s_addr = *(unsigned long *)gethostbyname(host)->h_addr_list[0];
return sendto(m_nSocket,buffer,size,0,(struct sockaddr *)&m_nLocal,sizeof(struct sockaddr_in));*/
return send(m_nSocket, buffer, size, 0);
}
int UDPConnection::sendto_(char * host, char * buffer, int size)
{
if(IS_INETADDR(host))
m_nLocal.sin_addr.s_addr = PA_chartoip(host);
else
m_nLocal.sin_addr.s_addr = *(unsigned long *)gethostbyname(host)->h_addr_list[0];
return sendto(m_nSocket, buffer, size, 0, (struct sockaddr *)&m_nLocal, sizeof(struct sockaddr_in));
}
int UDPConnection::send_(char * buffer, int size)
{
return sendto(m_nSocket, buffer, size, 0, (struct sockaddr *)&m_nLocal, sizeof(struct sockaddr_in));
}
int SocketConnection::close_( )
{
return closesocket(m_nSocket);
}
int UDPConnection::close_( )
{
return closesocket(m_nSocket);
}
SocketConnection::~SocketConnection()
{
// delete connection
if(m_nSocket >= 0)
{
closesocket(m_nSocket);
}
}
UDPConnection::~UDPConnection()
{
// delete connection
if(m_nSocket >= 0)
{
closesocket(m_nSocket);
}
}
const char * SocketConnection::toString()
{
return "__TCPCONNECTION__";
}
const char * UDPConnection::toString()
{
return "__UDPCONNECTION__";
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_UDPGetRemoteIP(lua_State * lState)
{
UDPConnection * * ppTConnection = checkUDPConnection(lState, 1);
char * ip = (char *)luaL_checkstring(lState, 2);
(*ppTConnection)->getRemoteIP(ip);
lua_pushboolean(lState, 1);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_TCPGetRemoteIP(lua_State * lState)
{
SocketConnection * * ppTConnection = checkSocketConnection(lState, 1);
char * ip = (char *)luaL_checkstring(lState, 2);
(*ppTConnection)->getRemoteIP(ip);
lua_pushboolean(lState, 1);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_UDPGetLocalIP(lua_State * lState)
{
UDPConnection * * ppTConnection = checkUDPConnection(lState, 1);
char * ip = (char *)luaL_checkstring(lState, 2);
(*ppTConnection)->getLocalIP(ip);
lua_pushboolean(lState, 1);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_TCPGetLocalIP(lua_State * lState)
{
SocketConnection * * ppTConnection = checkSocketConnection(lState, 1);
char * ip = (char *)luaL_checkstring(lState, 2);
(*ppTConnection)->getLocalIP(ip);
lua_pushboolean(lState, 1);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_TConnectionAccept(lua_State * lState)
{
SocketConnection * * ppTConnection = checkSocketConnection(lState, 1);
int returnVal = (*ppTConnection)->accept_();
lua_pushvalue(lState, returnVal);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_TConnectionRecv(lua_State * lState)
{
SocketConnection * * ppTConnection = checkSocketConnection(lState, 1);
const char * buffer = luaL_checkstring(lState, 2);
int size = luaL_checkint(lState, 3);
int returnVal = (*ppTConnection)->recv_((char *)buffer, size);
lua_pushvalue(lState, returnVal);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_TConnectionRecvFrom(lua_State * lState)
{
SocketConnection * * ppTConnection = checkSocketConnection(lState, 1);
const char * host = luaL_checkstring(lState, 2);
const char * buffer = luaL_checkstring(lState, 3);
int size = luaL_checkint(lState, 4);
int returnVal = (*ppTConnection)->recvfrom_((char *)host, (char *)buffer, size);
lua_pushvalue(lState, returnVal);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_TUDPRecvFrom(lua_State * lState)
{
UDPConnection * * ppTConnection = checkUDPConnection(lState, 1);
const char * host = luaL_checkstring(lState, 2);
const char * buffer = luaL_checkstring(lState, 3);
int size = luaL_checkint(lState, 4);
int returnVal = (*ppTConnection)->recvfrom_((char *)host, (char *)buffer, size);
lua_pushvalue(lState, returnVal);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_TUDPRecv(lua_State * lState)
{
UDPConnection * * ppTConnection = checkUDPConnection(lState, 1);
const char * buffer = luaL_checkstring(lState, 2);
int size = luaL_checkint(lState, 3);
int returnVal = (*ppTConnection)->recv_((char *)buffer, size);
lua_pushvalue(lState, returnVal);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_TConnectionSend(lua_State * lState)
{
SocketConnection * * ppTConnection = checkSocketConnection(lState, 1);
const char * buffer = luaL_checkstring(lState, 2);
int size = luaL_checkint(lState, 3);
int returnVal = (*ppTConnection)->send_((char *)buffer, size);
lua_pushvalue(lState, returnVal);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_TConnectionSendTo(lua_State * lState)
{
SocketConnection * * ppTConnection = checkSocketConnection(lState, 1);
const char * host = luaL_checkstring(lState, 2);
const char * buffer = luaL_checkstring(lState, 3);
int size = luaL_checkint(lState, 4);
int returnVal = (*ppTConnection)->sendto_((char *)host, (char *)buffer, size);
lua_pushvalue(lState, returnVal);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_TUDPSendTo(lua_State * lState)
{
UDPConnection * * ppTConnection = checkUDPConnection(lState, 1);
const char * host = luaL_checkstring(lState, 2);
const char * buffer = luaL_checkstring(lState, 3);
int size = luaL_checkint(lState, 4);
int returnVal = (*ppTConnection)->sendto_((char *)host, (char *)buffer, size);
lua_pushvalue(lState, returnVal);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_TUDPSend(lua_State * lState)
{
UDPConnection * * ppTConnection = checkUDPConnection(lState, 1);
const char * buffer = luaL_checkstring(lState, 2);
int size = luaL_checkint(lState, 3);
int returnVal = (*ppTConnection)->send_((char *)buffer, size);
lua_pushvalue(lState, returnVal);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_TConnectionClose(lua_State * lState)
{
SocketConnection * * ppTConnection = checkSocketConnection(lState, 1);
int returnVal = (*ppTConnection)->close_();
lua_pushvalue(lState, returnVal);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_TUDPClose(lua_State * lState)
{
UDPConnection * * ppTConnection = checkUDPConnection(lState, 1);
int returnVal = (*ppTConnection)->close_();
lua_pushvalue(lState, returnVal);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_SocketConnectionGC(lua_State * lState)
{
SocketConnection * * pBGTemp = toSocketConnection(lState, 1);
if(*pBGTemp)
{
delete (*pBGTemp);
*pBGTemp = NULL;
}
return 0;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_UDPConnectionGC(lua_State * lState)
{
UDPConnection * * pBGTemp = toUDPConnection(lState, 1);
if(*pBGTemp)
{
delete (*pBGTemp);
*pBGTemp = NULL;
}
return 0;
}
static int l_SocketConnectionToString(lua_State * lState)
{
lua_pushstring(lState, (*toSocketConnection(lState, 1))->toString());
return 1;
}
static int l_UDPConnectionToString(lua_State * lState)
{
lua_pushstring(lState, (*toUDPConnection(lState, 1))->toString());
return 1;
}
static const luaL_reg SocketConnection_methods[] = {
{"GetLocalIP", l_TCPGetLocalIP},
{"GetRemoteIP", l_TCPGetRemoteIP},
//{ "Accept", l_TConnectionAccept },
{"Recv", l_TConnectionRecv},
{"RecvFrom", l_TConnectionRecvFrom},
{"Send", l_TConnectionSend},
{"SendTo", l_TConnectionSendTo},
{"Close", l_TConnectionClose},
{0, 0}
};
static const luaL_reg UDPConnection_methods[] = {
{"GetLocalIP", l_UDPGetLocalIP},
{"GetRemoteIP", l_UDPGetRemoteIP},
{"RecvFrom", l_TUDPRecvFrom},
{"Recv", l_TUDPRecv},
{"SendTo", l_TUDPSendTo},
{"Send", l_TUDPSend},
{"Close", l_TUDPClose},
{0, 0}
};
static const luaL_reg SocketConnection_meta[] = {
{"__gc", l_SocketConnectionGC},
{"__tostring", l_SocketConnectionToString},
{0, 0}
};
static const luaL_reg UDPConnection_meta[] = {
{"__gc", l_UDPConnectionGC},
{"__tostring", l_UDPConnectionToString},
{0, 0}
};
UserdataRegister(SocketConnection, SocketConnection_methods, SocketConnection_meta);
UserdataRegister(UDPConnection, UDPConnection_methods, UDPConnection_meta);
| [
"sypherce@7bd1a944-e22a-0410-b2d1-0368184b35f6"
]
| [
[
[
1,
661
]
]
]
|
cd18f77123857f75f8032d6f0fe34f42b7903c87 | a1dc22c5f671b7859339aaef69b3461fad583d58 | /examples/bcpp6/record_player/main.cpp | 79603ab59193a4fc8947265b07636d15d42073f9 | []
| no_license | remis/chai3d | cd694053f55773ca6883a9ea30047e95e70a33e8 | 15323a24b97be73df6f7172bc0b41cc09631c94e | refs/heads/master | 2021-01-18T08:46:44.253084 | 2009-05-11T21:51:22 | 2009-05-11T22:10:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,628 | cpp | //===========================================================================
/*
This file is part of the CHAI 3D visualization and haptics libraries.
Copyright (C) 2003-2004 by CHAI 3D. All rights reserved.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License("GPL") version 2
as published by the Free Software Foundation.
For using the CHAI 3D libraries with software that can not be combined
with the GNU GPL, and for taking advantage of the additional benefits
of our support services, please contact CHAI 3D about acquiring a
Professional Edition License.
\author: <http://www.chai3d.org>
\author: fed
\version 1.1
\date 12/2004
*/
//===========================================================================
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "main.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
//---------------------------------------------------------------------------
TForm1 *Form1;
void HapticLoop(void* param);
//---------------------------------------------------------------------------
const double MESH_SCALE_SIZE = 1.0;
// Global variables for the audio stream
HSTREAM stream;
BASS_CHANNELINFO info;
QWORD stream_length;
char *data;
int record_direction = 1;
unsigned int pos = 0;
// Load an audio file in .wav format
bool LoadWaveFile(LPSTR szFileName)
{
// Load the data from the specified file
HSTREAM file_stream = BASS_StreamCreateFile(FALSE,szFileName,0,0,BASS_STREAM_DECODE);
// Get the length and header info from the loaded file
stream_length=BASS_StreamGetLength(file_stream);
BASS_ChannelGetInfo(file_stream, &info);
// Get the audio samples from the loaded file
data = new char[(unsigned int)stream_length];
BASS_ChannelGetData(file_stream, data, (unsigned int)stream_length);
// Set playing to begin at the beginning of the loaded data
pos = 0;
return false;
}
// Write the requested data from the loaded buffer to the sound card
DWORD CALLBACK MyStreamWriter(HSTREAM handle, void *buf, DWORD len, DWORD user)
{
// Cast the buffer to a character array
char *d=(char*)buf;
// Loop the file when it reaches the beginning or end
if ((pos >= stream_length) && (record_direction == 1))
pos = 0;
if ((pos <= 0) && (record_direction == -1))
pos = (unsigned int)stream_length;
// If record is spinning in positive direction, write requested
// amount of data from current position forwards
if (record_direction == 1)
{
int up = len + pos;
if (up > stream_length)
up = (unsigned int)stream_length;
for (int i=pos; i<up; i+=1)
d[(i-pos)] = data[i];
int amt = (up-pos);
pos += amt;
return amt;
}
// If record is spinning in negative direction, write requested
// amount of data from current position backwards
if (record_direction == -1)
{
int up = pos - len;
if (up < 0)
up = 0;
int cnt = 0;
for (int i=pos; i>up; i-=1)
d[cnt++] = data[i];
int amt = cnt;
pos -= amt;
return amt;
}
return 0;
}
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
void __fastcall TForm1::FormCreate(TObject *Sender)
{
// create a new world
world = new cWorld();
// set background color
world->setBackgroundColor(0.3f,0.3f,0.35f);
// Create a camera
camera = new cCamera(world);
world->addChild(camera);
// Create a light source and attach it to camera
light = new cLight(world);
light->setEnabled(true);
light->setPos(0,0,0);
light->setDir(-1,0,0);
light->m_ambient.set(0.5, 0.5, 0.5);
light->m_diffuse.set(0.9, 0.9, 0.9);
light->m_ambient.set(0.9, 0.9, 0.9);
camera->addChild(light);
camera->set(cVector3d(1.5,0,0.8), cVector3d(0,0,0), cVector3d(0,0,1));
// create a display for graphic rendering
viewport = new cViewport(Panel1->Handle, camera, true);
viewport->setStereoOn(false);
// create a mesh - we will build a simple cube, and later let the
// user load 3d models
object = new cMesh(world);
world->addChild(object);
// init var
m_rotPos = 0;
m_rotVel = 0;
m_inertia = 0.04;
m_clock.initialize();
m_lastGoodPosition = 0.0;
m_reduction = 5.4*10;
m_cpt = 120*4;
m_desiredPos = 0.0;
m_P = 0.4;
m_I = 0.0014;
m_integratorVal = 0.0;
m_D = 0.02;
m_lastAngle = 0.0;
m_velocity = 0;
m_velocityOld = 0;
m_RFDInitialAngle = 0.0;
m_inContact = false;
haptics_enabled = false;
// Initialize sound device and create audio stream
if (!BASS_Init(1,44100,0,0,NULL))
Application->MessageBox("Initialization Error", "Error");
// Load a record onto the record player
load_player();
object->translate(0,0,-0.3);
load_record(0);
RecordSelect->Items->Add("Italy");
RecordSelect->Items->Add("Switzerland");
RecordSelect->Items->Add("USA");
RecordSelect->ItemIndex = 0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
// stop simulation
// stop graphic rendering
Timer1->Enabled = false;
timer.stop();
// cleanup memory
delete world;
delete viewport;
}
//---------------------------------------------------------------------------
void TForm1::updateWorldSettings()
{
// set stiffness
double stiffness = (double)StiffnessSlider->Position;
object->setStiffness(stiffness, true);
if (m_movingObject)
m_movingObject->setStiffness(stiffness, true);
// set static and dynamic friction
double staticFriction = (double)StaticFrictionSlider->Position / 100.0;
double dynamicFriction = (double)DynamicFrictionSlider->Position / 100.0;
if (m_movingObject)
m_movingObject->setFriction(staticFriction, dynamicFriction, true);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
// update options
updateWorldSettings();
// render world in display
if (viewport != NULL)
{
viewport->render();
}
}
//---------------------------------------------------------------------------
void HapticLoop(void* param)
{
// simulation in now ON
// read position from haptic device
Form1->tool->updatePose();
// compute forces
Form1->tool->computeForces();
// get last interaction force in global coordinate frame
Form1->m_interactionForce = cMul(cTrans(Form1->object->getRot()),
cSub(Form1->tool->m_lastComputedGlobalForce, Form1->object->getPos()));
//Form1->tool->m_lastComputedGlobalForce;
Form1->tool->applyForces();
// figure out if we're touching the record
cProxyPointForceAlgo * algo = Form1->tool->getProxy();
if (algo->getContactObject() == Form1->m_movingObject)
{
if (! Form1->m_inContact)
{
Form1->m_inContact = true;
Form1->m_RFDInitialAngle = Form1->m_rotPos - Form1->m_lastGoodPosition*CHAI_PI/180;
}
Form1->animateObject(Form1->m_interactionForce);
}
else
{
Form1->animateObject(cVector3d(0.0, 0.0, 0.0));
Form1->m_inContact = false;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ToggleHapticsButtonClick(TObject *Sender)
{
if (!haptics_enabled)
{
if (tool == NULL)
{
tool = new cMeta3dofPointer(world, 0);
world->addChild(tool);
}
tool->setPos(0.0, 0.0, 0.0);
// turn on dynamic proxy
cProxyPointForceAlgo* forceAlgo = tool->getProxy();
forceAlgo->enableDynamicProxy(true);
// set up a nice-looking workspace for the phantom so
// it fits nicely with our models
tool->setWorkspace(2.0,2.0,2.0);
// Rotate the tool so its axes align with our opengl-like axes
tool->setRadius(0.01);
tool->setRenderingMode(0);
// set up the device
tool->initialize();
// open communication to the device
tool->start();
// I need to call this so the tool can update its internal
// transformations before performing collision detection, etc.
tool->computeGlobalPositions();
tool->setForcesON();
timer.set(0,HapticLoop,this);
haptics_enabled = true;
// intialize clock
m_time = new cPrecisionClock();
m_time->initialize();
}
else
{
if (stream) BASS_ChannelStop(stream);
timer.stop();
haptics_enabled = false;
}
}
//---------------------------------------------------------------------------
void TForm1::load_player()
{
// create a new mesh
cMesh* new_object = new cMesh(world);
// load 3d object file
int result = new_object->loadFromFile("resources\\models\\turntable.obj");
// I'm going to scale the object so his maximum axis has a
// size of MESH_SCALE_SIZE. This will make him fit nicely in
// our viewing area.
// Tell him to compute a bounding box...
new_object->computeBoundaryBox(true);
cVector3d min = new_object->getBoundaryMin();
cVector3d max = new_object->getBoundaryMax();
// This is the "size" of the object
cVector3d span = max;
span.sub(min);
// Find his maximum dimension
float max_size = span.x;
if (span.y > max_size) max_size = span.y;
if (span.z > max_size) max_size = span.z;
// We'll center all vertices, then multiply by this amount,
// to scale to the desired size.
float scale_factor = MESH_SCALE_SIZE / max_size;
// To center vertices, we add this amount (-1 times the
// center of the object's bounding box)
cVector3d offset = max;
offset.add(min);
offset.div(2.0);
offset.negate();
// Now we need to actually scale all the vertices. However, the
// vertices might not actually be in this object; they might
// be in children or grand-children of this mesh (depending on how the
// model was defined in the file).
//
// So we find all the sub-meshes we loaded from this file, by descending
// through all available children.
// This will hold all the meshes we need to operate on... we'll fill
// it up as we find more children.
std::list<cMesh*> meshes_to_scale;
// This will hold all the parents we're still searching...
std::list<cMesh*> meshes_to_descend;
meshes_to_descend.push_front(new_object);
// Keep track of how many meshes we've found, just to print
// it out for the user
int total_meshes = 0;
// While there are still parent meshes to process
while(meshes_to_descend.empty() == 0) {
total_meshes++;
// Grab the next parent
cMesh* cur_mesh = meshes_to_descend.front();
meshes_to_descend.pop_front();
meshes_to_scale.push_back(cur_mesh);
// Put all his children on the list of parents to process
for(unsigned int i=0; i<cur_mesh->getNumChildren(); i++) {
cGenericObject* cur_object = cur_mesh->getChild(i);
// Only process cMesh children
cMesh* cur_mesh = dynamic_cast<cMesh*>(cur_object);
if (cur_mesh) meshes_to_descend.push_back(cur_mesh);
}
}
std::list<cMesh*>::iterator mesh_iter;
//_cprintf("Offset: %f %f %f\n", offset.x, offset.y, offset.z);
// Now loop over _all_ the meshes we found...
for(mesh_iter = meshes_to_scale.begin(); mesh_iter != meshes_to_scale.end(); mesh_iter++) {
cMesh* cur_mesh = *mesh_iter;
vector<cVertex>* vertices = cur_mesh->pVertices();
int num_vertices = cur_mesh->getNumVertices(false);
cVertex* cur_vertex = (cVertex*)(vertices);
// Move and scale each vertex in this mesh...
for(int i=0; i<num_vertices; i++) {
cur_vertex = cur_mesh->getVertex(i);
cVector3d pos = cur_vertex->getPos();
pos.add(offset);
pos.mul(scale_factor);
cur_vertex->setPos(pos);
cur_vertex++;
}
cur_mesh->computeGlobalPositions(false);
}
int size = new_object->pTriangles()->size();
// Re-compute a bounding box
new_object->computeBoundaryBox(true);
// Build a nice collision-detector for this object, so
// the proxy will work nicely when haptics are enabled.
new_object->computeGlobalPositions(false);
// new_object->createSphereTreeCollisionDetector(true,true);
new_object->createAABBCollisionDetector(true,true);
new_object->computeGlobalPositions();
object = new_object;
world->addChild(object);
}
//---------------------------------------------------------------------------
// Load a record onto the record player
void TForm1::load_record(int a_index)
{
int restart_haptics = 0;
if (haptics_enabled) {
restart_haptics = 1;
ToggleHapticsButtonClick(this);
}
if (stream) { BASS_ChannelStop(stream); Sleep(1000); }
pos = 0;
switch (a_index) {
case 0 : LoadWaveFile("resources\\sounds\\italy.mp3"); break;
case 1 : LoadWaveFile("resources\\sounds\\switzerland.mp3"); break;
case 2 : LoadWaveFile("resources\\sounds\\usa.mp3"); break;
default : return;
}
stream=BASS_StreamCreate(info.freq,info.chans,0,&MyStreamWriter,0);
// delete existing record
if (m_movingObject) { world->removeChild(m_movingObject); delete m_movingObject; }
// create new record
m_movingObject = new cMesh(world);
createTexCoords(m_movingObject, 0.33);
cTexture2D *record = new cTexture2D();
switch (a_index) {
case 0 : record->loadFromFile("resources\\images\\italy.bmp"); break;
case 1 : record->loadFromFile("resources\\images\\switzerland.bmp"); break;
case 2 : record->loadFromFile("resources\\images\\usa.bmp"); break;
default : return;
}
m_movingObject->setTexture(record);
m_movingObject->useTexture(true, true);
// compute size of object again
m_movingObject->computeBoundaryBox(true);
// Build a collision-detector for this object, so
// the proxy will work nicely when haptics are enabled.
m_movingObject->createAABBCollisionDetector(true, false);
// set size of frame
m_movingObject->setFrameSize(0.3, true);
// update global position
m_movingObject->computeGlobalPositions();
// add object to world and translate
world->addChild(m_movingObject);
m_movingObject->translate(-0.1, 0, -0.21);
// The stiffness will actualy be set by the GUI
double stiffness = (double)0;
if (m_movingObject)
m_movingObject->setStiffness(stiffness, true);
// set static and dynamic friction
double staticFriction = (double)100 / 100.0;
double dynamicFriction = (double)100 / 100.0;
if (m_movingObject)
m_movingObject->setFriction(staticFriction, dynamicFriction, true);
m_rotVel = 0.0;
if (restart_haptics) ToggleHapticsButtonClick(this);
}
//---------------------------------------------------------------------------
void TForm1::animateObject(cVector3d force)
{
// do stuff with force: relate force to torque applied about the disc axis
// integrate torque
cVector3d planeForce;
planeForce.set(force.x, force.y, 0);
// get position of proxy on plane, get vector from center to application point
cProxyPointForceAlgo* forceAlgo = tool->getProxy();
m_proxyPos = forceAlgo->getProxyGlobalPosition();
cVector3d radius;
radius.set(m_proxyPos.x, m_proxyPos.y, 0);
// do cross product
cVector3d torqueVec;
planeForce.crossr(radius, torqueVec);
// call that the torque applied to the disc and compute new position
m_torque = torqueVec.z;
// do the math for how the rotational friction may affect the whole motion
double time_step = 0.001;
m_rotVel = m_rotVel + m_torque/m_inertia * time_step;
m_rotPos = m_rotPos + m_rotVel * time_step;
// set audio direction and frequency based on rotational velocity
if (haptics_enabled && (fabs(m_rotVel)) > 0.0)
{
if (m_rotVel < 0.0) record_direction = 1;
else record_direction = -1;
BASS_ChannelSetAttributes(stream, (int)(info.freq*fabs(m_rotVel)/6.5), -1, -1);
if (!(BASS_ChannelPlay(stream,FALSE)))
Application->MessageBox("Playback Error", "Error");
}
else
{
BASS_ChannelStop(stream);
}
// rotate object
m_movingObject->rotate(cVector3d(0,0,1), m_rotVel * time_step);
m_movingObject->computeGlobalPositions();
}
//---------------------------------------------------------------------------
// Define the texture coordinates for the record
void createTexCoords(cMesh *a_mesh, double radius) {
double vectorY1, originY, vectorX1, originX;
vectorY1 = 0; originY = 0;
vectorX1 = 0; originX = 0;
cVector3d vector1, vector2, origin;
origin.set(originX, originY, 0);
vector2.set(originX, originY, 0);
int num = 28;
double divisore = num / (2*CHAI_PI);
for(int i=0; i<=num; i++)
{
double angle=(float)(((double)i)/divisore);
vector1.set(originX+(radius*(float)sin((double)angle)), originY+(radius*(float)cos((double)angle)), 0);
a_mesh->newTriangle(origin, vector1, vector2);
vector2.set(vector1.x, vector1.y, vector1.z);
}
for(unsigned int n=0; n<a_mesh->getNumVertices(); n++)
{
cVertex* curVertex = a_mesh->getVertex(n);
curVertex->setTexCoord(
(curVertex->getPos().x + radius) / (2.0 * radius),
(curVertex->getPos().y + radius) / (2.0 * radius)
);
curVertex->setNormal(0,0,1);
}
// compute normals
a_mesh->computeAllNormals(true);
// compute boudary box
a_mesh->computeBoundaryBox(true);
}
void __fastcall TForm1::RecordSelectChange(TObject *Sender)
{
if (RecordSelect->ItemIndex >= 0)
load_record(RecordSelect->ItemIndex);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
exit(0);
}
//---------------------------------------------------------------------------
| [
"[email protected]"
]
| [
[
[
1,
625
]
]
]
|
4bccfeaf9b5b516047cf34f29fc943501464d590 | 55196303f36aa20da255031a8f115b6af83e7d11 | /private/tools/bikini/commands.h | 171e86cf18488841fbe96ada9effbb239fbabeee | []
| no_license | Heartbroken/bikini | 3f5447647d39587ffe15a7ae5badab3300d2a2ff | fe74f51a3a5d281c671d303632ff38be84d23dd7 | refs/heads/master | 2021-01-10T19:48:40.851837 | 2010-05-25T19:58:52 | 2010-05-25T19:58:52 | 37,190,932 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 500 | h | #pragma once
namespace commands { //----------------------------------------------------------------------------
// Create command system
void create();
// Destroy command system
void destroy();
// Add command
template <typename _F>
inline void add(const bk::achar* _name, const _F &_functor);
// Remove command
void remove(const bk::achar* _name);
#include "commands.inl"
} // namespace commands ---------------------------------------------------------------------------
| [
"viktor.reutskyy@68c2588f-494f-0410-aecb-65da31d84587"
]
| [
[
[
1,
20
]
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.