blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 5
146
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 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
sequencelengths 1
16
| author_lines
sequencelengths 1
16
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cb057956bc9a1574d15545a4dc888beddc08d6d8 | 842997c28ef03f8deb3422d0bb123c707732a252 | /src/moaicore/MOAIFmod.cpp | ed12218c33131ee6b237ecf608c4b0f8c354f43e | [] | no_license | bjorn/moai-beta | e31f600a3456c20fba683b8e39b11804ac88d202 | 2f06a454d4d94939dc3937367208222735dd164f | refs/heads/master | 2021-01-17T11:46:46.018377 | 2011-06-10T07:33:55 | 2011-06-10T07:33:55 | 1,837,561 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,432 | cpp | // Copyright (c) 2010-2011 Zipline Games, Inc. All Rights Reserved.
// http://getmoai.com
#include "pch.h"
SUPPRESS_EMPTY_FILE_WARNING
#if USE_FMOD
#include <moaicore/MOAIFmod.h>
#include <moaicore/MOAILogMessages.h>
#include <fmod.hpp>
//================================================================//
// local
//================================================================//
//----------------------------------------------------------------//
/** @name init
@text Initializes the sound system.
@out nil
*/
int MOAIFmod::_init ( lua_State* L ) {
USLuaState state ( L );
MOAIFmod::Get ().OpenSoundSystem ();
return 0;
}
//================================================================//
// MOAIFmod
//================================================================//
//----------------------------------------------------------------//
void MOAIFmod::CloseSoundSystem () {
if ( !this->mSoundSys ) return;
this->mSoundSys->release ();
this->mSoundSys = 0;
}
//----------------------------------------------------------------//
MOAIFmod::MOAIFmod () :
mSoundSys ( 0 ) {
}
//----------------------------------------------------------------//
MOAIFmod::~MOAIFmod () {
this->CloseSoundSystem ();
}
//----------------------------------------------------------------//
void MOAIFmod::OpenSoundSystem () {
FMOD_RESULT result;
result = FMOD::System_Create ( &this->mSoundSys ); // Create the main system object.
if ( result != FMOD_OK ) return;
result = this->mSoundSys->init ( 100, FMOD_INIT_NORMAL, 0 ); // Initialize FMOD.
if ( result != FMOD_OK ) return;
}
//----------------------------------------------------------------//
void MOAIFmod::RegisterLuaClass ( USLuaState& state ) {
UNUSED ( state );
}
//----------------------------------------------------------------//
void MOAIFmod::RegisterLuaFuncs ( USLuaState& state ) {
luaL_Reg regTable [] = {
{ "init", _init },
{ NULL, NULL }
};
luaL_register ( state, 0, regTable );
}
//----------------------------------------------------------------//
void MOAIFmod::Update () {
if ( this->mSoundSys ) {
this->mSoundSys->update ();
}
}
//----------------------------------------------------------------//
STLString MOAIFmod::ToString () {
STLString repr;
PRETTY_PRINT ( repr, mSoundSys )
return repr;
}
#endif
| [
"[email protected]"
] | [
[
[
1,
103
]
]
] |
94ed67882e90e0bb01f102dc60f92f6d95ee724b | 5218c2a5173e3137f341f99aa0495879b189042a | /Stokes/Core/API.cpp | 7df74b1b524bf9027fa12bc7f120f83bfb16c0c4 | [] | no_license | bungnoid/stokes | cd00ba5d5aeb36da69fb38db69b1d2394853dada | 553abca00a626379ea7fb9f51c206d15ae32d2da | refs/heads/master | 2021-01-10T12:57:12.718405 | 2011-08-15T09:44:30 | 2011-08-15T09:44:30 | 51,467,263 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 84 | cpp | #include <Stokes/Core/API.hpp>
ENTER_NAMESPACE_STOKES
LEAVE_NAMESPACE_STOKES
| [
"[email protected]"
] | [
[
[
1,
5
]
]
] |
41f6ecd3bfaef72f42112035587219a8b689dd62 | 7b379862f58f587d9327db829ae4c6493b745bb1 | /JuceLibraryCode/modules/juce_graphics/fonts/juce_TextLayout.cpp | be3a8ac66be9d6a05e9f52ad505853fbc05b11d6 | [] | no_license | owenvallis/Nomestate | 75e844e8ab68933d481640c12019f0d734c62065 | 7fe7c06c2893421a3c77b5180e5f27ab61dd0ffd | refs/heads/master | 2021-01-19T07:35:14.301832 | 2011-12-28T07:42:50 | 2011-12-28T07:42:50 | 2,950,072 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 20,576 | cpp | /*
==============================================================================
This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-11 by Raw Material Software Ltd.
------------------------------------------------------------------------------
JUCE can be redistributed and/or modified under the terms of the GNU General
Public License (Version 2), as published by the Free Software Foundation.
A copy of the license is included in the JUCE distribution, or can be found
online at www.gnu.org/licenses.
JUCE 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.
------------------------------------------------------------------------------
To release a closed-source product which uses JUCE, commercial licenses are
available: visit www.rawmaterialsoftware.com/juce for more information.
==============================================================================
*/
BEGIN_JUCE_NAMESPACE
TextLayout::Glyph::Glyph (const int glyphCode_, const Point<float>& anchor_, float width_) noexcept
: glyphCode (glyphCode_), anchor (anchor_), width (width_)
{
}
TextLayout::Glyph::Glyph (const Glyph& other) noexcept
: glyphCode (other.glyphCode), anchor (other.anchor), width (other.width)
{
}
TextLayout::Glyph& TextLayout::Glyph::operator= (const Glyph& other) noexcept
{
glyphCode = other.glyphCode;
anchor = other.anchor;
width = other.width;
return *this;
}
TextLayout::Glyph::~Glyph() noexcept {}
//==============================================================================
TextLayout::Run::Run() noexcept
: colour (0xff000000)
{
}
TextLayout::Run::Run (const Range<int>& range, const int numGlyphsToPreallocate)
: colour (0xff000000), stringRange (range)
{
glyphs.ensureStorageAllocated (numGlyphsToPreallocate);
}
TextLayout::Run::Run (const Run& other)
: font (other.font),
colour (other.colour),
glyphs (other.glyphs),
stringRange (other.stringRange)
{
}
TextLayout::Run::~Run() noexcept {}
//==============================================================================
TextLayout::Line::Line() noexcept
: ascent (0.0f), descent (0.0f), leading (0.0f)
{
}
TextLayout::Line::Line (const Range<int>& stringRange_, const Point<float>& lineOrigin_,
const float ascent_, const float descent_, const float leading_,
const int numRunsToPreallocate)
: stringRange (stringRange_), lineOrigin (lineOrigin_),
ascent (ascent_), descent (descent_), leading (leading_)
{
runs.ensureStorageAllocated (numRunsToPreallocate);
}
TextLayout::Line::Line (const Line& other)
: stringRange (other.stringRange), lineOrigin (other.lineOrigin),
ascent (other.ascent), descent (other.descent), leading (other.leading)
{
runs.addCopiesOf (other.runs);
}
TextLayout::Line::~Line() noexcept
{
}
Range<float> TextLayout::Line::getLineBoundsX() const noexcept
{
Range<float> range;
bool isFirst = true;
for (int i = runs.size(); --i >= 0;)
{
const Run* run = runs.getUnchecked(i);
jassert (run != nullptr);
if (run->glyphs.size() > 0)
{
float minX = run->glyphs.getReference(0).anchor.x;
float maxX = minX;
for (int j = run->glyphs.size(); --j > 0;)
{
const Glyph& glyph = run->glyphs.getReference (j);
const float x = glyph.anchor.x;
minX = jmin (minX, x);
maxX = jmax (maxX, x + glyph.width);
}
if (isFirst)
{
isFirst = false;
range = Range<float> (minX, maxX);
}
else
{
range = range.getUnionWith (Range<float> (minX, maxX));
}
}
}
return range + lineOrigin.x;
}
//==============================================================================
TextLayout::TextLayout()
: width (0), justification (Justification::topLeft)
{
}
TextLayout::TextLayout (const TextLayout& other)
: width (other.width),
justification (other.justification)
{
lines.addCopiesOf (other.lines);
}
#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
TextLayout::TextLayout (TextLayout&& other) noexcept
: lines (static_cast <OwnedArray<Line>&&> (other.lines)),
width (other.width),
justification (other.justification)
{
}
TextLayout& TextLayout::operator= (TextLayout&& other) noexcept
{
lines = static_cast <OwnedArray<Line>&&> (other.lines);
width = other.width;
justification = other.justification;
return *this;
}
#endif
TextLayout& TextLayout::operator= (const TextLayout& other)
{
width = other.width;
justification = other.justification;
lines.clear();
lines.addCopiesOf (other.lines);
return *this;
}
TextLayout::~TextLayout()
{
}
float TextLayout::getHeight() const noexcept
{
const Line* const lastLine = lines.getLast();
return lastLine != nullptr ? lastLine->lineOrigin.y + lastLine->descent
: 0;
}
TextLayout::Line& TextLayout::getLine (const int index) const
{
return *lines[index];
}
void TextLayout::ensureStorageAllocated (int numLinesNeeded)
{
lines.ensureStorageAllocated (numLinesNeeded);
}
void TextLayout::addLine (Line* line)
{
lines.add (line);
}
void TextLayout::draw (Graphics& g, const Rectangle<float>& area) const
{
const Point<float> origin (justification.appliedToRectangle (Rectangle<float> (0, 0, width, getHeight()), area).getPosition());
LowLevelGraphicsContext& context = *g.getInternalContext();
for (int i = 0; i < getNumLines(); ++i)
{
const Line& line = getLine (i);
const Point<float> lineOrigin (origin + line.lineOrigin);
for (int j = 0; j < line.runs.size(); ++j)
{
const Run* const run = line.runs.getUnchecked (j);
jassert (run != nullptr);
context.setFont (run->font);
context.setFill (run->colour);
for (int k = 0; k < run->glyphs.size(); ++k)
{
const Glyph& glyph = run->glyphs.getReference (k);
context.drawGlyph (glyph.glyphCode, AffineTransform::translation (lineOrigin.x + glyph.anchor.x,
lineOrigin.y + glyph.anchor.y));
}
}
}
}
void TextLayout::createLayout (const AttributedString& text, float maxWidth)
{
lines.clear();
width = maxWidth;
justification = text.getJustification();
if (! createNativeLayout (text))
createStandardLayout (text);
recalculateWidth();
}
//==============================================================================
namespace TextLayoutHelpers
{
struct FontAndColour
{
FontAndColour (const Font* font_) noexcept : font (font_), colour (0xff000000) {}
const Font* font;
Colour colour;
bool operator!= (const FontAndColour& other) const noexcept
{
return (font != other.font && *font != *other.font) || colour != other.colour;
}
};
struct RunAttribute
{
RunAttribute (const FontAndColour& fontAndColour_, const Range<int>& range_) noexcept
: fontAndColour (fontAndColour_), range (range_)
{}
FontAndColour fontAndColour;
Range<int> range;
};
struct Token
{
Token (const String& t, const Font& f, const Colour& c, const bool isWhitespace_)
: text (t), font (f), colour (c),
area (font.getStringWidth (t), roundToInt (f.getHeight())),
isWhitespace (isWhitespace_),
isNewLine (t.containsChar ('\n') || t.containsChar ('\r'))
{}
const String text;
const Font font;
const Colour colour;
Rectangle<int> area;
int line, lineHeight;
const bool isWhitespace, isNewLine;
private:
Token& operator= (const Token&);
};
class TokenList
{
public:
TokenList() noexcept : totalLines (0) {}
void createLayout (const AttributedString& text, TextLayout& layout)
{
tokens.ensureStorageAllocated (64);
layout.ensureStorageAllocated (totalLines);
addTextRuns (text);
layoutRuns ((int) layout.getWidth());
int charPosition = 0;
int lineStartPosition = 0;
int runStartPosition = 0;
TextLayout::Line* glyphLine = new TextLayout::Line();
TextLayout::Run* glyphRun = new TextLayout::Run();
for (int i = 0; i < tokens.size(); ++i)
{
const Token* const t = tokens.getUnchecked (i);
const Point<float> tokenPos (t->area.getPosition().toFloat());
Array <int> newGlyphs;
Array <float> xOffsets;
t->font.getGlyphPositions (t->text.trimEnd(), newGlyphs, xOffsets);
glyphRun->glyphs.ensureStorageAllocated (glyphRun->glyphs.size() + newGlyphs.size());
for (int j = 0; j < newGlyphs.size(); ++j)
{
if (charPosition == lineStartPosition)
glyphLine->lineOrigin = tokenPos.translated (0, t->font.getAscent());
const float x = xOffsets.getUnchecked (j);
glyphRun->glyphs.add (TextLayout::Glyph (newGlyphs.getUnchecked(j),
Point<float> (tokenPos.getX() + x, 0),
xOffsets.getUnchecked (j + 1) - x));
++charPosition;
}
if (t->isWhitespace || t->isNewLine)
++charPosition;
const Token* const nextToken = tokens [i + 1];
if (nextToken == nullptr) // this is the last token
{
addRun (glyphLine, glyphRun, t, runStartPosition, charPosition);
glyphLine->stringRange = Range<int> (lineStartPosition, charPosition);
layout.addLine (glyphLine);
}
else
{
if (t->font != nextToken->font || t->colour != nextToken->colour)
{
addRun (glyphLine, glyphRun, t, runStartPosition, charPosition);
runStartPosition = charPosition;
glyphRun = new TextLayout::Run();
}
if (t->line != nextToken->line)
{
addRun (glyphLine, glyphRun, t, runStartPosition, charPosition);
glyphLine->stringRange = Range<int> (lineStartPosition, charPosition);
layout.addLine (glyphLine);
runStartPosition = charPosition;
lineStartPosition = charPosition;
glyphLine = new TextLayout::Line();
glyphRun = new TextLayout::Run();
}
}
}
if ((text.getJustification().getFlags() & (Justification::right | Justification::horizontallyCentred)) != 0)
{
const int totalW = (int) layout.getWidth();
for (int i = 0; i < layout.getNumLines(); ++i)
{
const int lineW = getLineWidth (i);
float dx = 0;
if ((text.getJustification().getFlags() & Justification::right) != 0)
dx = (float) (totalW - lineW);
else
dx = (totalW - lineW) / 2.0f;
TextLayout::Line& glyphLine = layout.getLine (i);
glyphLine.lineOrigin.x += dx;
}
}
}
private:
static void addRun (TextLayout::Line* glyphLine, TextLayout::Run* glyphRun,
const Token* const t, const int start, const int end)
{
glyphRun->stringRange = Range<int> (start, end);
glyphRun->font = t->font;
glyphRun->colour = t->colour;
glyphLine->ascent = jmax (glyphLine->ascent, t->font.getAscent());
glyphLine->descent = jmax (glyphLine->descent, t->font.getDescent());
glyphLine->runs.add (glyphRun);
}
void appendText (const AttributedString& text, const Range<int>& stringRange,
const Font& font, const Colour& colour)
{
String stringText (text.getText().substring (stringRange.getStart(), stringRange.getEnd()));
String::CharPointerType t (stringText.getCharPointer());
String currentString;
int lastCharType = 0;
for (;;)
{
const juce_wchar c = t.getAndAdvance();
if (c == 0)
break;
int charType;
if (c == '\r' || c == '\n')
charType = 0;
else if (CharacterFunctions::isWhitespace (c))
charType = 2;
else
charType = 1;
if (charType == 0 || charType != lastCharType)
{
if (currentString.isNotEmpty())
tokens.add (new Token (currentString, font, colour,
lastCharType == 2 || lastCharType == 0));
currentString = String::charToString (c);
if (c == '\r' && *t == '\n')
currentString += t.getAndAdvance();
}
else
{
currentString += c;
}
lastCharType = charType;
}
if (currentString.isNotEmpty())
tokens.add (new Token (currentString, font, colour, lastCharType == 2));
}
void layoutRuns (const int maxWidth)
{
int x = 0, y = 0, h = 0;
int i;
for (i = 0; i < tokens.size(); ++i)
{
Token* const t = tokens.getUnchecked(i);
t->area.setPosition (x, y);
t->line = totalLines;
x += t->area.getWidth();
h = jmax (h, t->area.getHeight());
const Token* nextTok = tokens[i + 1];
if (nextTok == 0)
break;
if (t->isNewLine || ((! nextTok->isWhitespace) && x + nextTok->area.getWidth() > maxWidth))
{
setLastLineHeight (i + 1, h);
x = 0;
y += h;
h = 0;
++totalLines;
}
}
setLastLineHeight (jmin (i + 1, tokens.size()), h);
++totalLines;
}
void setLastLineHeight (int i, const int height) noexcept
{
while (--i >= 0)
{
Token* const tok = tokens.getUnchecked (i);
if (tok->line == totalLines)
tok->lineHeight = height;
else
break;
}
}
int getLineWidth (const int lineNumber) const noexcept
{
int maxW = 0;
for (int i = tokens.size(); --i >= 0;)
{
const Token* const t = tokens.getUnchecked (i);
if (t->line == lineNumber && ! t->isWhitespace)
maxW = jmax (maxW, t->area.getRight());
}
return maxW;
}
void addTextRuns (const AttributedString& text)
{
Font defaultFont;
Array<RunAttribute> runAttributes;
{
const int stringLength = text.getText().length();
int rangeStart = 0;
FontAndColour lastFontAndColour (nullptr);
// Iterate through every character in the string
for (int i = 0; i < stringLength; ++i)
{
FontAndColour newFontAndColour (&defaultFont);
const int numCharacterAttributes = text.getNumAttributes();
for (int j = 0; j < numCharacterAttributes; ++j)
{
const AttributedString::Attribute* const attr = text.getAttribute (j);
// Check if the current character falls within the range of a font attribute
if (attr->getFont() != nullptr && (i >= attr->range.getStart()) && (i < attr->range.getEnd()))
newFontAndColour.font = attr->getFont();
// Check if the current character falls within the range of a foreground colour attribute
if (attr->getColour() != nullptr && (i >= attr->range.getStart()) && (i < attr->range.getEnd()))
newFontAndColour.colour = *attr->getColour();
}
if (i > 0 && (newFontAndColour != lastFontAndColour || i == stringLength - 1))
{
runAttributes.add (RunAttribute (lastFontAndColour,
Range<int> (rangeStart, (i < stringLength - 1) ? i : (i + 1))));
rangeStart = i;
}
lastFontAndColour = newFontAndColour;
}
}
for (int i = 0; i < runAttributes.size(); ++i)
{
const RunAttribute& r = runAttributes.getReference(i);
appendText (text, r.range, *(r.fontAndColour.font), r.fontAndColour.colour);
}
}
OwnedArray<Token> tokens;
int totalLines;
JUCE_DECLARE_NON_COPYABLE (TokenList);
};
}
//==============================================================================
void TextLayout::createLayoutWithBalancedLineLengths (const AttributedString& text, float maxWidth)
{
const float minimumWidth = maxWidth / 2.0f;
float bestWidth = maxWidth;
float bestLineProportion = 0.0f;
while (maxWidth > minimumWidth)
{
createLayout (text, maxWidth);
if (getNumLines() < 2)
return;
const float line1 = lines.getUnchecked (lines.size() - 1)->getLineBoundsX().getLength();
const float line2 = lines.getUnchecked (lines.size() - 2)->getLineBoundsX().getLength();
const float prop = jmax (line1, line2) / jmin (line1, line2);
if (prop > 0.9f)
return;
if (prop > bestLineProportion)
{
bestLineProportion = prop;
bestWidth = maxWidth;
}
maxWidth -= 10.0f;
}
if (bestWidth != maxWidth)
createLayout (text, bestWidth);
}
//==============================================================================
void TextLayout::createStandardLayout (const AttributedString& text)
{
TextLayoutHelpers::TokenList l;
l.createLayout (text, *this);
}
void TextLayout::recalculateWidth()
{
if (lines.size() > 0)
{
Range<float> range (lines.getFirst()->getLineBoundsX());
int i;
for (i = lines.size(); --i > 0;)
range = range.getUnionWith (lines.getUnchecked(i)->getLineBoundsX());
for (i = lines.size(); --i >= 0;)
lines.getUnchecked(i)->lineOrigin.x -= range.getStart();
width = range.getLength();
}
}
END_JUCE_NAMESPACE
| [
"ow3nskip"
] | [
[
[
1,
613
]
]
] |
c1b3ba3a89613468355abb5d13d842542aa52179 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/utility/value_init_test_fail3.cpp | 9b2bfe262c30fb9ee89d638a09711fc1e5ba2b4d | [
"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 | 677 | cpp | // (C) 2002, Fernando Luis Cacciola Carballal.
//
// 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)
//
// Test program for "boost/utility/value_init.hpp"
//
// Initial: 21 Agu 2002
#include <iostream>
#include <string>
#include "boost/utility/value_init.hpp"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "boost/test/minimal.hpp"
int test_main(int, char **)
{
boost::value_initialized<int const> const cx_c ;
get(cx_c) = 1234 ; // this should produce an ERROR
return 0;
}
unsigned int expected_failures = 0;
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
] | [
[
[
1,
37
]
]
] |
0b1f1d4716740627d219e97182cfac0616390c25 | cd07acbe92f87b59260478f62a6f8d7d1e218ba9 | /src/Sperm.h | 2d625bfa015c21c4189f8181ebf61c54e520c8e1 | [] | no_license | niepp/sperm-x | 3a071783e573d0c4bae67c2a7f0fe9959516060d | e8f578c640347ca186248527acf82262adb5d327 | refs/heads/master | 2021-01-10T06:27:15.004646 | 2011-09-24T03:33:21 | 2011-09-24T03:33:21 | 46,690,957 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,494 | h | // Sperm.h : main header file for the SPERM application
//
#if !defined(AFX_SPERM_H__96B36626_422A_4410_A98A_03F02202B587__INCLUDED_)
#define AFX_SPERM_H__96B36626_422A_4410_A98A_03F02202B587__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
#include "Sperm_i.h"
/////////////////////////////////////////////////////////////////////////////
// CSpermApp:
// See Sperm.cpp for the implementation of this class
//
class CSpermApp : public CWinApp
{
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
CSpermApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSpermApp)
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CSpermApp)
afx_msg void OnAppAbout();
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
public:
LRESULT AfterLogin(WPARAM w,LPARAM l);
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SPERM_H__96B36626_422A_4410_A98A_03F02202B587__INCLUDED_)
| [
"harithchen@e030fd90-5f31-5877-223c-63bd88aa7192"
] | [
[
[
1,
54
]
]
] |
5e12923314b33489eee7130b849d3917bdaa9acc | 061348a6be0e0e602d4a5b3e0af28e9eee2d257f | /Examples/Tutorial/Animation/12SkeletonAnimation.cpp | e76e4941a2c5d98cfe9123f79172f4310a295d86 | [] | no_license | passthefist/OpenSGToolbox | 4a76b8e6b87245685619bdc3a0fa737e61a57291 | d836853d6e0647628a7dd7bb7a729726750c6d28 | refs/heads/master | 2023-06-09T22:44:20.711657 | 2010-07-26T00:43:13 | 2010-07-26T00:43:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 23,710 | cpp | //
// OpenSGToolbox Tutorial: 12SkeletonAnimation
//
// Creates a skeleton and animates it.
//
// General OpenSG configuration, needed everywhere
#include "OSGConfig.h"
// A little helper to simplify scene management and interaction
#include "OSGSimpleSceneManager.h"
#include "OSGNode.h"
#include "OSGGroup.h"
#include "OSGViewport.h"
#include "OSGWindowUtils.h"
// Input
#include "OSGKeyListener.h"
#include "OSGLineChunk.h"
#include "OSGBlendChunk.h"
#include "OSGChunkMaterial.h"
#include "OSGMaterialChunk.h"
#include "OSGRandomPoolManager.h"
// FROM ANIMATION.CPP
#include "OSGTime.h"
#include "OSGKeyframeSequences.h"
#include "OSGFieldAnimation.h"
#include "OSGKeyframeAnimator.h"
#include "OSGNameAttachment.h"
#include "OSGSkeletonAnimation.h"
#include "OSGSkeletonDrawable.h"
#include "OSGSkeleton.h"
#include "OSGJoint.h"
// Activate the OpenSG namespace
OSG_USING_NAMESPACE
// The SimpleSceneManager to manage simple applications
SimpleSceneManager *mgr;
WindowEventProducerUnrecPtr TutorialWindow;
Time TimeLastIdle;
NodeUnrecPtr SkeletonNode;
SkeletonAnimationUnrecPtr TheSkeletonAnimation;
bool animationPaused = false;
// Forward declaration so we can have the interesting stuff upfront
void display(void);
void reshape(Vec2f Size);
void setupAnimation(void);
JointUnrecPtr Pelvis,LeftHip,RightHip,LeftKnee,RightKnee,LeftFoot,RightFoot,LeftToes,RightToes, Clavicle, LeftShoulder,RightShoulder,LeftElbow,RightElbow,LeftHand,RightHand,LeftFingers,RightFingers,Head;
SkeletonUnrecPtr ExampleSkeleton;
// Create a class to allow for the use of the keyboard shortcuts
class TutorialKeyListener : public KeyListener
{
public:
virtual void keyPressed(const KeyEventUnrecPtr e)
{
//Exit
if(e->getKey() == KeyEvent::KEY_Q && e->getModifiers() & KeyEvent::KEY_MODIFIER_COMMAND)
{
TutorialWindow->closeWindow();
}
//Toggle animation
if(e->getKey() == KeyEvent::KEY_SPACE)
{
if(animationPaused)
animationPaused = false;
else
animationPaused = true;
}
//Toggle bind pose
if(e->getKey() == KeyEvent::KEY_B)
{
//Toggle skeleton
if(dynamic_cast<SkeletonDrawable*>(SkeletonNode->getCore())->getDrawBindPose() == false)
{
dynamic_cast<SkeletonDrawable*>(SkeletonNode->getCore())->setDrawBindPose(true);
}
else
{
dynamic_cast<SkeletonDrawable*>(SkeletonNode->getCore())->setDrawBindPose(false);
}
}
//Toggle current pose
if(e->getKey() == KeyEvent::KEY_P)
{
//Toggle skeleton
if(dynamic_cast<SkeletonDrawable*>(SkeletonNode->getCore())->getDrawPose() == false)
{
dynamic_cast<SkeletonDrawable*>(SkeletonNode->getCore())->setDrawPose(true);
}
else
{
dynamic_cast<SkeletonDrawable*>(SkeletonNode->getCore())->setDrawPose(false);
}
}
}
virtual void keyReleased(const KeyEventUnrecPtr e)
{
}
virtual void keyTyped(const KeyEventUnrecPtr e)
{
}
};
class TutorialMouseListener : public MouseListener
{
public:
virtual void mouseClicked(const MouseEventUnrecPtr e)
{
}
virtual void mouseEntered(const MouseEventUnrecPtr e)
{
}
virtual void mouseExited(const MouseEventUnrecPtr e)
{
}
virtual void mousePressed(const MouseEventUnrecPtr e)
{
mgr->mouseButtonPress(e->getButton(), e->getLocation().x(), e->getLocation().y());
}
virtual void mouseReleased(const MouseEventUnrecPtr e)
{
mgr->mouseButtonRelease(e->getButton(), e->getLocation().x(), e->getLocation().y());
}
};
class TutorialMouseMotionListener : public MouseMotionListener
{
public:
virtual void mouseMoved(const MouseEventUnrecPtr e)
{
mgr->mouseMove(e->getLocation().x(), e->getLocation().y());
}
virtual void mouseDragged(const MouseEventUnrecPtr e)
{
mgr->mouseMove(e->getLocation().x(), e->getLocation().y());
}
};
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
//Add Window Listener
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
TutorialMouseListener TheTutorialMouseListener;
TutorialMouseMotionListener TheTutorialMouseMotionListener;
TutorialWindow->addMouseListener(&TheTutorialMouseListener);
TutorialWindow->addMouseMotionListener(&TheTutorialMouseMotionListener);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
//Print key command info
std::cout << "\n\nKEY COMMANDS:" << std::endl
<< "space Play/Pause the animation" << std::endl
<< "B Show/Hide the bind pose skeleton" << std::endl
<< "P Show/Hide the current pose skeleton" << std::endl
<< "CTRL-Q Exit\n\n" << std::endl;
//SkeletonDrawer System Material
LineChunkUnrecPtr ExampleLineChunk = LineChunk::create();
ExampleLineChunk->setWidth(2.0f);
ExampleLineChunk->setSmooth(true);
BlendChunkUnrecPtr ExampleBlendChunk = BlendChunk::create();
ExampleBlendChunk->setSrcFactor(GL_SRC_ALPHA);
ExampleBlendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
MaterialChunkUnrecPtr ExampleMaterialChunk = MaterialChunk::create();
ExampleMaterialChunk->setAmbient(Color4f(1.0f,1.0f,1.0f,1.0f));
ExampleMaterialChunk->setDiffuse(Color4f(0.0f,0.0f,0.0f,1.0f));
ExampleMaterialChunk->setSpecular(Color4f(0.0f,0.0f,0.0f,1.0f));
ChunkMaterialUnrecPtr ExampleMaterial = ChunkMaterial::create();
ExampleMaterial->addChunk(ExampleLineChunk);
ExampleMaterial->addChunk(ExampleMaterialChunk);
ExampleMaterial->addChunk(ExampleBlendChunk);
//===========================================Joints==================================================================
Matrix TempMat;
/*================================================================================================*/
/* Left Fingers */
LeftFingers = Joint::create(); //create a joint called LeftFingers
TempMat.setTranslate(1.0,0.0,0.0);
LeftFingers->setRelativeTransformation(TempMat);
LeftFingers->setBindRelativeTransformation(TempMat);
/*================================================================================================*/
/* Right Fingers */
RightFingers = Joint::create(); //create a joint called RightFingers
TempMat.setTranslate(-1.0,0.0,0.0);
RightFingers->setRelativeTransformation(TempMat);
RightFingers->setBindRelativeTransformation(TempMat);
/*================================================================================================*/
/* Left Hand */
LeftHand = Joint::create(); //create a joint called LeftHand
TempMat.setTranslate(2.0,0.0,0.0);
LeftHand->setRelativeTransformation(TempMat);
LeftHand->setBindRelativeTransformation(TempMat);
LeftHand->pushToChildJoints(LeftFingers);
/*================================================================================================*/
/* Right Hand */
RightHand = Joint::create(); //create a joint called RightHand
TempMat.setTranslate(-2.0,0.0,0.0);
RightHand->setRelativeTransformation(TempMat);
RightHand->setBindRelativeTransformation(TempMat);
RightHand->pushToChildJoints(RightFingers);
/*================================================================================================*/
/* Left Elbow */
LeftElbow = Joint::create(); //create a joint called LeftElbow
TempMat.setTranslate(2.0,0.0,0.0);
LeftElbow->setRelativeTransformation(TempMat);
LeftElbow->setBindRelativeTransformation(TempMat);
LeftElbow->pushToChildJoints(LeftHand);
/*================================================================================================*/
/* Right Elbow */
RightElbow = Joint::create(); //create a joint called RightElbow
TempMat.setTranslate(-2.0,0.0,0.0);
RightElbow->setRelativeTransformation(TempMat);
RightElbow->setBindRelativeTransformation(TempMat);
RightElbow->pushToChildJoints(RightHand);
/*================================================================================================*/
/* Left Shoulder */
LeftShoulder = Joint::create(); //create a joint called LeftShoulder
TempMat.setTranslate(1.0,-0.5,0.0);
LeftShoulder->setRelativeTransformation(TempMat);
LeftShoulder->setBindRelativeTransformation(TempMat);
LeftShoulder->pushToChildJoints(LeftElbow);
/*================================================================================================*/
/* Right Shoulder */
RightShoulder = Joint::create(); //create a joint called RightShoulder
TempMat.setTranslate(-1.0,-0.5,0.0);
RightShoulder->setRelativeTransformation(TempMat);
RightShoulder->setBindRelativeTransformation(TempMat);
RightShoulder->pushToChildJoints(RightElbow);
/*================================================================================================*/
/* Head */
Head = Joint::create(); //create a joint called Head
TempMat.setTranslate(0.0,1.0,0.0);
Head->setRelativeTransformation(TempMat);
Head->setBindRelativeTransformation(TempMat);
/*================================================================================================*/
/* Clavicle */
Clavicle = Joint::create(); //create a joint called Clavicle
TempMat.setTranslate(0.0,5.0,0.0);
Clavicle->setRelativeTransformation(TempMat);
Clavicle->setBindRelativeTransformation(TempMat);
Clavicle->pushToChildJoints(LeftShoulder);
Clavicle->pushToChildJoints(RightShoulder);
Clavicle->pushToChildJoints(Head);
/*================================================================================================*/
/* Left Toes */
LeftToes = Joint::create(); //create a bone called ExampleChildbone
TempMat.setTranslate(0.0,0.0,1.0);
LeftToes->setRelativeTransformation(TempMat);
LeftToes->setBindRelativeTransformation(TempMat);
/*================================================================================================*/
/* Right Toes */
RightToes = Joint::create(); //create a joint called RightToes
TempMat.setTranslate(0.0,0.0,1.0);
RightToes->setRelativeTransformation(TempMat);
RightToes->setBindRelativeTransformation(TempMat);
/*================================================================================================*/
/* Left Foot */
LeftFoot = Joint::create(); //create a joint called LeftFoot
TempMat.setTranslate(0.0,-3.0,0.0);
LeftFoot->setRelativeTransformation(TempMat);
LeftFoot->setBindRelativeTransformation(TempMat);
LeftFoot->pushToChildJoints(LeftToes);
/*================================================================================================*/
/* Right Foot */
RightFoot = Joint::create(); //create a joint called RightFoot
TempMat.setTranslate(0.0,-3.0,0.0);
RightFoot->setRelativeTransformation(TempMat);
RightFoot->setBindRelativeTransformation(TempMat);
RightFoot->pushToChildJoints(RightToes);
/*================================================================================================*/
/* Left Knee */
LeftKnee = Joint::create(); //create a joint called LeftKnee
TempMat.setTranslate(0.0,-3.0,0.0);
LeftKnee->setRelativeTransformation(TempMat);
LeftKnee->setBindRelativeTransformation(TempMat);
LeftKnee->pushToChildJoints(LeftFoot);
/*================================================================================================*/
/* Right Knee */
RightKnee = Joint::create(); //create a joint called RightKnee
TempMat.setTranslate(0.0,-3.0,0.0);
RightKnee->setRelativeTransformation(TempMat);
RightKnee->setBindRelativeTransformation(TempMat);
RightKnee->pushToChildJoints(RightFoot);
/*================================================================================================*/
/* Left Hip */
LeftHip = Joint::create(); //create a joint called LeftHip
TempMat.setTranslate(1.0,-1.0,0.0);
LeftHip->setRelativeTransformation(TempMat);
LeftHip->setBindRelativeTransformation(TempMat);
LeftHip->pushToChildJoints(LeftKnee);
/*================================================================================================*/
/* Right Hip */
RightHip = Joint::create(); //create a joint called RightHip
TempMat.setTranslate(-1.0,-1.0,0.0);
RightHip->setRelativeTransformation(TempMat);
RightHip->setBindRelativeTransformation(TempMat);
RightHip->pushToChildJoints(RightKnee);
/*================================================================================================*/
/* Pelvis */
Pelvis = Joint::create(); //create a joint called Pelvis
TempMat.setTranslate(0.0,7.0,0.0);
Pelvis->setRelativeTransformation(TempMat);
Pelvis->setBindRelativeTransformation(TempMat);
Pelvis->pushToChildJoints(LeftHip);
Pelvis->pushToChildJoints(RightHip);
Pelvis->pushToChildJoints(Clavicle);
//Skeleton
ExampleSkeleton = Skeleton::create();
ExampleSkeleton->pushToRootJoints(Pelvis); //Set Pelvis as root joint of skeleton
//SkeletonDrawer
SkeletonDrawableUnrecPtr ExampleSkeletonDrawable = SkeletonDrawable::create();
ExampleSkeletonDrawable->setSkeleton(ExampleSkeleton);
ExampleSkeletonDrawable->setMaterial(ExampleMaterial);
ExampleSkeletonDrawable->setDrawBindPose(false); //Be default, we won't draw the skeleton's bind pose
ExampleSkeletonDrawable->setBindPoseColor(Color4f(0.0, 1.0, 0.0, 1.0)); //When drawn, the skeleton's bind pose renders green
ExampleSkeletonDrawable->setDrawPose(true); //Be default, we do draw the skeleton's current pose
ExampleSkeletonDrawable->setPoseColor(Color4f(0.0, 0.0, 1.0, 1.0)); //The skeleton's current pose renders blue
//Skeleton Node
SkeletonNode = Node::create();
SkeletonNode->setCore(ExampleSkeletonDrawable);
//Create scene
NodeUnrecPtr scene = Node::create();
scene->setCore(Group::create());
scene->addChild(SkeletonNode);
mgr->setRoot(scene);
//Setup the Animation
setupAnimation();
// Show the whole Scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"12SkeletonAnimation");
//Main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
// Redraw the window
void display(void)
{
mgr->redraw();
}
// React to size changes
void reshape(Vec2f Size)
{
mgr->resize(Size.x(), Size.y());
}
void setupAnimation(void)
{
Matrix TempMat;
//We create an animation and an animator for each joint we wish to animate
//Left Elbow
KeyframeTransformationSequenceUnrecPtr LeftElbowKeyframes = KeyframeTransformationSequenceMatrix4f::create();
//Make keyframes
TempMat.setTransform(Vec3f(2.0,0.0,0.0),Quaternion(Vec3f(0.0,0.0,1.0),0.0f));
LeftElbowKeyframes->addKeyframe(TempMat,0.0f);
TempMat.setTransform(Vec3f(2.0,0.0,0.0),Quaternion(Vec3f(0.0,0.0,1.0),1.57f));
LeftElbowKeyframes->addKeyframe(TempMat,3.0f);
TempMat.setTransform(Vec3f(2.0,0.0,0.0),Quaternion(Vec3f(0.0,0.0,1.0),0.0f));
LeftElbowKeyframes->addKeyframe(TempMat,6.0f);
//Left Elbow Animator
KeyframeAnimatorUnrecPtr LeftElbowAnimator = KeyframeAnimator::create();
LeftElbowAnimator->setKeyframeSequence(LeftElbowKeyframes);
//Right Elbow
KeyframeTransformationSequenceUnrecPtr RightElbowKeyframes = KeyframeTransformationSequenceMatrix4f::create();
//Make keyframes
TempMat.setTransform(Vec3f(-2.0,0.0,0.0),Quaternion(Vec3f(0.0,0.0,1.0),0.0f));
RightElbowKeyframes->addKeyframe(TempMat,0.0f);
TempMat.setTransform(Vec3f(-2.0,0.0,0.0),Quaternion(Vec3f(0.0,0.0,1.0),-1.57f));
RightElbowKeyframes->addKeyframe(TempMat,3.0f);
TempMat.setTransform(Vec3f(-2.0,0.0,0.0),Quaternion(Vec3f(0.0,0.0,1.0),0.0f));
RightElbowKeyframes->addKeyframe(TempMat,6.0f);
//Right Elbow Animator
KeyframeAnimatorUnrecPtr RightElbowAnimator = KeyframeAnimator::create();
RightElbowAnimator->setKeyframeSequence(RightElbowKeyframes);
//Left Shoulder
KeyframeTransformationSequenceUnrecPtr LeftShoulderKeyframes = KeyframeTransformationSequenceMatrix4f::create();
//Make keyframes
TempMat.setTransform(Vec3f(1.0,-0.5,0.0),Quaternion(Vec3f(0.0,0.0,1.0),0.0f));
LeftShoulderKeyframes->addKeyframe(TempMat,0.0f);
TempMat.setTransform(Vec3f(1.0,-0.5,0.0),Quaternion(Vec3f(0.0,0.0,1.0),0.4f));
LeftShoulderKeyframes->addKeyframe(TempMat,3.0f);
TempMat.setTransform(Vec3f(1.0,-0.5,0.0),Quaternion(Vec3f(0.0,0.0,1.0),0.0f));
LeftShoulderKeyframes->addKeyframe(TempMat,6.0f);
//Left Shoulder Animator
KeyframeAnimatorUnrecPtr LeftShoulderAnimator = KeyframeAnimator::create();
LeftShoulderAnimator->setKeyframeSequence(LeftShoulderKeyframes);
//Right Shoulder
KeyframeTransformationSequenceUnrecPtr RightShoulderKeyframes = KeyframeTransformationSequenceMatrix4f::create();
//Make keyframes
TempMat.setTransform(Vec3f(-1.0,-0.5,0.0),Quaternion(Vec3f(0.0,0.0,1.0),0.0f));
RightShoulderKeyframes->addKeyframe(TempMat,0.0f);
TempMat.setTransform(Vec3f(-1.0,-0.5,0.0),Quaternion(Vec3f(0.0,0.0,1.0),-0.4f));
RightShoulderKeyframes->addKeyframe(TempMat,3.0f);
TempMat.setTransform(Vec3f(-1.0,-0.5,0.0),Quaternion(Vec3f(0.0,0.0,1.0),0.0f));
RightShoulderKeyframes->addKeyframe(TempMat,6.0f);
//Right Shoulder Animator
KeyframeAnimatorUnrecPtr RightShoulderAnimator = KeyframeAnimator::create();
RightShoulderAnimator->setKeyframeSequence(RightShoulderKeyframes);
//Left Hip
KeyframeTransformationSequenceUnrecPtr LeftHipKeyframes = KeyframeTransformationSequenceMatrix4f::create();
//Make keyframes
TempMat.setTransform(Vec3f(1.0,-1.0,0.0),Quaternion(Vec3f(0.0,0.0,1.0),0.0f));
LeftHipKeyframes->addKeyframe(TempMat,0.0f);
TempMat.setTransform(Vec3f(1.0,-1.0,0.0),Quaternion(Vec3f(0.0,0.0,1.0),0.4f));
LeftHipKeyframes->addKeyframe(TempMat,3.0f);
TempMat.setTransform(Vec3f(1.0,-1.0,0.0),Quaternion(Vec3f(0.0,0.0,1.0),0.0f));
LeftHipKeyframes->addKeyframe(TempMat,6.0f);
//Left Hip Animator
KeyframeAnimatorUnrecPtr LeftHipAnimator = KeyframeAnimator::create();
LeftHipAnimator->setKeyframeSequence(LeftHipKeyframes);
//Right Hip
KeyframeTransformationSequenceUnrecPtr RightHipKeyframes = KeyframeTransformationSequenceMatrix4f::create();
//Make keyframes
TempMat.setTransform(Vec3f(-1.0,-1.0,0.0),Quaternion(Vec3f(0.0,0.0,1.0),0.0f));
RightHipKeyframes->addKeyframe(TempMat,0.0f);
TempMat.setTransform(Vec3f(-1.0,-1.0,0.0),Quaternion(Vec3f(0.0,0.0,1.0),-0.4f));
RightHipKeyframes->addKeyframe(TempMat,3.0f);
TempMat.setTransform(Vec3f(-1.0,-1.0,0.0),Quaternion(Vec3f(0.0,0.0,1.0),0.0f));
RightHipKeyframes->addKeyframe(TempMat,6.0f);
//Right Hip Animator
KeyframeAnimatorUnrecPtr RightHipAnimator = KeyframeAnimator::create();
RightHipAnimator->setKeyframeSequence(RightHipKeyframes);
//Clavicle
KeyframeTransformationSequenceUnrecPtr ClavicleKeyframes = KeyframeTransformationSequenceMatrix4f::create();
//Make keyframes
TempMat.setTransform(Vec3f(0.0,5.0,0.0));
ClavicleKeyframes->addKeyframe(TempMat,0.0f);
TempMat.setTransform(Vec3f(0.0,3.0,0.0));
ClavicleKeyframes->addKeyframe(TempMat,2.0f);
TempMat.setTransform(Vec3f(0.0,3.0,0.0));
ClavicleKeyframes->addKeyframe(TempMat,4.0f);
TempMat.setTransform(Vec3f(0.0,5.0,0.0));
ClavicleKeyframes->addKeyframe(TempMat,6.0f);
//Clavicle Animator
KeyframeAnimatorUnrecPtr ClavicleAnimator = KeyframeAnimator::create();
ClavicleAnimator->setKeyframeSequence(ClavicleKeyframes);
//Skeleton Animation
TheSkeletonAnimation = SkeletonAnimation::create();
//Add the animators we just made to the skeleton animation
TheSkeletonAnimation->addTransformationAnimator(LeftElbowAnimator, LeftElbow); //Here we tell the skeleton animation the it should use the animator LeftElbowAnimator to animate the joint LeftElbow
TheSkeletonAnimation->addTransformationAnimator(RightElbowAnimator, RightElbow);
TheSkeletonAnimation->addTransformationAnimator(LeftShoulderAnimator, LeftShoulder);
TheSkeletonAnimation->addTransformationAnimator(RightShoulderAnimator, RightShoulder);
TheSkeletonAnimation->addTransformationAnimator(LeftHipAnimator, LeftHip);
TheSkeletonAnimation->addTransformationAnimator(RightHipAnimator, RightHip);
TheSkeletonAnimation->addTransformationAnimator(ClavicleAnimator, Clavicle);
TheSkeletonAnimation->setSkeleton(ExampleSkeleton);
TheSkeletonAnimation->attachUpdateProducer(TutorialWindow->editEventProducer());
TheSkeletonAnimation->start();
}
| [
"[email protected]",
"[email protected]"
] | [
[
[
1,
68
],
[
70,
546
]
],
[
[
69,
69
]
]
] |
1ad1ca9903ffd4f8c68073920d71da2fc3248ad9 | f8403b6b1005f80d2db7fad9ee208887cdca6aec | /JuceLibraryCode/modules/juce_gui_basics/positioning/juce_RelativeParallelogram.cpp | 03f95b81ceacc2eefa7d0487176610497a18d96e | [] | no_license | sonic59/JuceText | 25544cb07e5b414f9d7109c0826a16fc1de2e0d4 | 5ac010ffe59c2025d25bc0f9c02fc829ada9a3d2 | refs/heads/master | 2021-01-15T13:18:11.670907 | 2011-10-29T19:03:25 | 2011-10-29T19:03:25 | 2,507,112 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,637 | cpp | /*
==============================================================================
This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-11 by Raw Material Software Ltd.
------------------------------------------------------------------------------
JUCE can be redistributed and/or modified under the terms of the GNU General
Public License (Version 2), as published by the Free Software Foundation.
A copy of the license is included in the JUCE distribution, or can be found
online at www.gnu.org/licenses.
JUCE 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.
------------------------------------------------------------------------------
To release a closed-source product which uses JUCE, commercial licenses are
available: visit www.rawmaterialsoftware.com/juce for more information.
==============================================================================
*/
BEGIN_JUCE_NAMESPACE
//==============================================================================
RelativeParallelogram::RelativeParallelogram()
{
}
RelativeParallelogram::RelativeParallelogram (const Rectangle<float>& r)
: topLeft (r.getTopLeft()), topRight (r.getTopRight()), bottomLeft (r.getBottomLeft())
{
}
RelativeParallelogram::RelativeParallelogram (const RelativePoint& topLeft_, const RelativePoint& topRight_, const RelativePoint& bottomLeft_)
: topLeft (topLeft_), topRight (topRight_), bottomLeft (bottomLeft_)
{
}
RelativeParallelogram::RelativeParallelogram (const String& topLeft_, const String& topRight_, const String& bottomLeft_)
: topLeft (topLeft_), topRight (topRight_), bottomLeft (bottomLeft_)
{
}
RelativeParallelogram::~RelativeParallelogram()
{
}
void RelativeParallelogram::resolveThreePoints (Point<float>* points, Expression::Scope* const scope) const
{
points[0] = topLeft.resolve (scope);
points[1] = topRight.resolve (scope);
points[2] = bottomLeft.resolve (scope);
}
void RelativeParallelogram::resolveFourCorners (Point<float>* points, Expression::Scope* const scope) const
{
resolveThreePoints (points, scope);
points[3] = points[1] + (points[2] - points[0]);
}
const Rectangle<float> RelativeParallelogram::getBounds (Expression::Scope* const scope) const
{
Point<float> points[4];
resolveFourCorners (points, scope);
return Rectangle<float>::findAreaContainingPoints (points, 4);
}
void RelativeParallelogram::getPath (Path& path, Expression::Scope* const scope) const
{
Point<float> points[4];
resolveFourCorners (points, scope);
path.startNewSubPath (points[0]);
path.lineTo (points[1]);
path.lineTo (points[3]);
path.lineTo (points[2]);
path.closeSubPath();
}
const AffineTransform RelativeParallelogram::resetToPerpendicular (Expression::Scope* const scope)
{
Point<float> corners[3];
resolveThreePoints (corners, scope);
const Line<float> top (corners[0], corners[1]);
const Line<float> left (corners[0], corners[2]);
const Point<float> newTopRight (corners[0] + Point<float> (top.getLength(), 0.0f));
const Point<float> newBottomLeft (corners[0] + Point<float> (0.0f, left.getLength()));
topRight.moveToAbsolute (newTopRight, scope);
bottomLeft.moveToAbsolute (newBottomLeft, scope);
return AffineTransform::fromTargetPoints (corners[0].getX(), corners[0].getY(), corners[0].getX(), corners[0].getY(),
corners[1].getX(), corners[1].getY(), newTopRight.getX(), newTopRight.getY(),
corners[2].getX(), corners[2].getY(), newBottomLeft.getX(), newBottomLeft.getY());
}
bool RelativeParallelogram::isDynamic() const
{
return topLeft.isDynamic() || topRight.isDynamic() || bottomLeft.isDynamic();
}
bool RelativeParallelogram::operator== (const RelativeParallelogram& other) const noexcept
{
return topLeft == other.topLeft && topRight == other.topRight && bottomLeft == other.bottomLeft;
}
bool RelativeParallelogram::operator!= (const RelativeParallelogram& other) const noexcept
{
return ! operator== (other);
}
const Point<float> RelativeParallelogram::getInternalCoordForPoint (const Point<float>* const corners, Point<float> target) noexcept
{
const Point<float> tr (corners[1] - corners[0]);
const Point<float> bl (corners[2] - corners[0]);
target -= corners[0];
return Point<float> (Line<float> (Point<float>(), tr).getIntersection (Line<float> (target, target - bl)).getDistanceFromOrigin(),
Line<float> (Point<float>(), bl).getIntersection (Line<float> (target, target - tr)).getDistanceFromOrigin());
}
const Point<float> RelativeParallelogram::getPointForInternalCoord (const Point<float>* const corners, const Point<float>& point) noexcept
{
return corners[0]
+ Line<float> (Point<float>(), corners[1] - corners[0]).getPointAlongLine (point.getX())
+ Line<float> (Point<float>(), corners[2] - corners[0]).getPointAlongLine (point.getY());
}
const Rectangle<float> RelativeParallelogram::getBoundingBox (const Point<float>* const p) noexcept
{
const Point<float> points[] = { p[0], p[1], p[2], p[1] + (p[2] - p[0]) };
return Rectangle<float>::findAreaContainingPoints (points, 4);
}
END_JUCE_NAMESPACE
| [
"[email protected]"
] | [
[
[
1,
141
]
]
] |
bb5d957e08ba9930ffcab560c6201acd2b637f60 | 3856c39683bdecc34190b30c6ad7d93f50dce728 | /LastProject/Source/BBXParser.h | 759d03f521ddd3ad1ab3c20045edf4373130a881 | [] | no_license | yoonhada/nlinelast | 7ddcc28f0b60897271e4d869f92368b22a80dd48 | 5df3b6cec296ce09e35ff0ccd166a6937ddb2157 | refs/heads/master | 2021-01-20T09:07:11.577111 | 2011-12-21T22:12:36 | 2011-12-21T22:12:36 | 34,231,967 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,026 | h | #pragma once
#ifndef _BBXPARSER_H_
#define _BBXPARSER_H_
#include "BBXBase.h"
class BBXParser : public BBXBase
{
private:
VOID Initialize();
VOID InitKeyword();
VOID Release();
VOID Cleanup();
BOOL CheckFile( FILE* _fp, LPWSTR _sLine );
BOOL GetNumBoundBox( LPWSTR _sLine );
BOOL BeginBoundBoxList( FILE* _fp, LPWSTR _sLine );
BOOL GetBoundBoxName( LPWSTR _sLine );
BOOL GetBoundBoxPivot( LPWSTR _sLine );
BOOL GetBoundBoxPlusSize( LPWSTR _sLine );
BOOL GetBoundBoxMinusSize( LPWSTR _sLine );
BOOL GetBoundBoxColor( LPWSTR _sLine );
VOID CreateCube( INT _iNumBoundBox, LPDATA _pData );
public:
BBXParser()
{
this->Initialize();
}
virtual ~BBXParser()
{
this->Release();
}
BOOL LoadFile( LPWSTR _FileName );
INT GetNumBoundBox(){ return m_iNumBoundBox; }
BOOL GetData( INT _Index, BBXParser::DATA& _Out );
private:
LPBBXKEY m_pKeyword;
LPDATA m_pData;
INT m_iNumBoundBox;
INT m_iCurrentIndex;
public:
};
#endif | [
"[email protected]@d02aaf57-2019-c8cd-d06c-d029ef2af4e0"
] | [
[
[
1,
53
]
]
] |
a1f1db633a56aa69639e42ca49869fe390bdfcca | 3977ae61b891f7e8ae7d75b8e22bcb63dedc3c1c | /Base/Gui/Source/Screen/Screen.h | 0fb4d2358256de2ae013783b21b3fbaaa01cf631 | [] | no_license | jayrulez/ourprs | 9734915b69207e7c3382412ca8647b051a787bb1 | 9d10f7a6edb06483015ed11dcfc9785f63b7204b | refs/heads/master | 2020-05-17T11:40:55.001049 | 2010-03-25T05:20:04 | 2010-03-25T05:20:04 | 40,554,502 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 663 | h | /*
@Group: BSC2D
@Group Members:
<ul>
<li>Robert Campbell: 0701334</li>
<li>Audley Gordon: 0802218</li>
<li>Dale McFarlane: 0801042</li>
<li>Dyonne Duberry: 0802189</li>
</ul>
@
*/
#ifndef SCREEN_H
#define SCREEN_H
#ifdef _WIN32
#include "../../Win32/Core/Console.h"
#endif
class Screen
{
private:
unsigned long ScreenColour;
unsigned long TextColour;
Console ConsoleObj;
public:
Screen();
~Screen();
Screen(unsigned long,unsigned long);
void SetScreenColour(unsigned long);
void SetScreenTextColour(unsigned long);
int GetScreenColour()const;
void ClearScreen();
};
#endif
| [
"portmore.representa@c48e7a12-1f02-11df-8982-67e453f37615"
] | [
[
[
1,
35
]
]
] |
028cfe32e9743f2010cc93be0d55fa5ab9fe8e47 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/spirit/test/actor/push_front_test.cpp | d0019259c514c816928d4fdee150ec4ab606970a | [
"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,802 | cpp | /*=============================================================================
Copyright (c) 2003 Jonathan de Halleux ([email protected])
http://spirit.sourceforge.net/
Use, modification and distribution is subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
///////////////////////////////////////////////////////////////////////////////
// Test suite for push_front_actor
///////////////////////////////////////////////////////////////////////////////
#include "action_tests.hpp"
#include <string>
#include <vector>
#include <deque>
#include <cstring>
#include <iostream>
#include <boost/spirit/core.hpp>
#include <boost/spirit/actor/push_front_actor.hpp>
#include <boost/spirit/utility/lists.hpp>
template<typename ContainerT>
void push_front_test()
{
using namespace boost::spirit;
const char* cp = "one,two,three";
const char* cp_first = cp;
const char* cp_last = cp + test_impl::string_length(cp);
const char* cp_i[] = {"one","two","three"};;
int i;
ContainerT c;
typename ContainerT::const_iterator it;
scanner<char const*> scan( cp_first, cp_last );
match<> hit;
hit = list_p( (*alpha_p)[ push_front_a(c)] , ch_p(',') ).parse(scan);
BOOST_CHECK(hit);
BOOST_CHECK_EQUAL(scan.first, scan.last);
BOOST_CHECK_EQUAL( c.size(), static_cast<typename ContainerT::size_type>(3));
for (i=2, it = c.begin();i>=0 && it != c.end();--i, ++it)
BOOST_CHECK_EQUAL( cp_i[i], *it);
scan.first = cp;
}
void push_front_action_test()
{
push_front_test< std::deque<std::string> >();
}
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
] | [
[
[
1,
53
]
]
] |
44b5eccab91e70c9e6398d72d24082a4d77b71fd | 61ab0210c138d649b09082014795e78cada1919d | /trunk/src/jhxgamesetup.cpp | bf2733f3be63ee52cd84270799cfcacbe05d45b5 | [] | no_license | BackupTheBerlios/jhxgamesetup-svn | b250fd036ea7528e8c46a61a4d954ffa8e1d3b12 | e175e8482b3309ac50b49cfb1842cc38bffc5427 | refs/heads/master | 2020-05-27T08:41:58.794584 | 2005-09-19T14:24:40 | 2005-09-19T14:24:40 | 40,770,191 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 4,118 | cpp | /*
//----------------------------------------------------------------------------\\
|| Name: jhxgamesetup.cpp
|| Purpose: jhXGameSetup - Main application file
|| Author: Jahn Fuchs
|| SVN-ID: $Id$
|| Copyright: (c) Jahn Fuchs
|| Licence: GNU GPL
\\---------------------------------------------------------------------------//
*/
// ----------------------------------------------------------------------------|
// GCC implementation
// ----------------------------------------------------------------------------|
#ifdef __GNUG__
#pragma implementation "jhxgamesetup.h"
#endif
// ----------------------------------------------------------------------------|
// Standard wxWindows headers
// ----------------------------------------------------------------------------|
// For compilers that support precompilation -> include "wx/wxprec.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
// For all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWindows headers)
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
// ----------------------------------------------------------------------------|
// Header of this source file
// ----------------------------------------------------------------------------|
#include "jhxgamesetup.h"
// ----------------------------------------------------------------------------|
// wx headers, wx/contrib headers, application headers
// ----------------------------------------------------------------------------|
#include "wx/image.h" // wxImage
#include "wx/intl.h" // Unterstützung für mehrere Sprachen
// mit gettext (.po/.mo - Dateien)
//#include "wx/file.h" // wx I/O Funktionen
#include <wx/filesys.h> // wx Filesystem
#include <wx/fs_zip.h> // wx ZipHandler
#include "wx/xrc/xmlres.h" // XML resouces
// ----------------------------------------------------------------------------|
#include "setupframe.h" // Header for the MainFrame
// ----------------------------------------------------------------------------|
// wxWindows macro: Declare the application.
// ----------------------------------------------------------------------------|
// Create a new application object: this macro to create application
// object during program execution
IMPLEMENT_APP(MyApp)
//-----------------------------------------------------------------------------|
// Public methods
//-----------------------------------------------------------------------------|
// 'Main program' equivalent: the program execution "starts" here
bool MyApp::OnInit()
{
// If there is any of a certain format of image in the XRC or XRS
// resources -> load a handler for that image type.
// Look in wxImage::AddHandler() for all available ImageHandler
// jhXGameSetup uses only some standard handlers
wxImage::AddHandler(new wxXPMHandler);
wxImage::AddHandler(new wxICOHandler);
wxImage::AddHandler(new wxBMPHandler);
wxImage::AddHandler(new wxPNGHandler);
wxImage::AddHandler(new wxJPEGHandler);
// load the ZipFSHandler for use with XRS resources
wxFileSystem::AddHandler(new wxZipFSHandler);
// Initialize all the XRC handlers.
/*wxXmlResource::Get()->InitAllHandlers();
// Load the frame from a XRC or XRS (zipped XRC) file
// Depending on the commandline options
wxXmlResource::Get()->Load(wxT("rc/menu.xrc"));
// The toolbar
//wxXmlResource::Get()->Load(wxT("rc/all.zip#zip:all.zip$._toolbar.xrc"));
// Make an instance of your derived frame. Passing NULL (the default value
// of MyFrame's constructor is NULL) as the frame doesn't have a frame
// since it is the first window.
jhXGameSetupFrame *setupframe = new jhXGameSetupFrame();
// Show the setupframe.
setupframe->Show(TRUE); */
// Return TRUE -> tell program to continue
return TRUE;
}
| [
"jhxde@538ba3fb-f6ed-0310-8075-f71f4c943de4"
] | [
[
[
1,
110
]
]
] |
eacc3749d820e4953fc620db62694c37cfa723b4 | 3643bb671f78a0669c8e08935476551a297ce996 | /C_Script.h | 7b094ee26b0e79c30ee52e901c8a19b647c1e706 | [] | no_license | mattfischer/3dportal | 44b3b9fb2331650fc406596b941f6228f37ff14b | e00f7d601138f5cf72aac35f4d15bdf230c518d9 | refs/heads/master | 2020-12-25T10:36:51.991814 | 2010-08-29T22:53:06 | 2010-08-29T22:53:06 | 65,869,788 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,792 | h | #ifndef C_SCRIPT_H
#define C_SCRIPT_H
#include "C_AST.h"
#include "C_Stack.h"
#include "M_Vector.h"
#include <windows.h>
#include <vector>
#include <string>
using std::vector;
using std::string;
//#define SAFECOGSINTERNAL
namespace Cog
{
struct Context
{
Stack stack;
int sender;
int senderType;
int source;
int senderId;
bool touched;
};
struct Symbol
{
C_SymbolType type;
string name;
union {
int intVal;
float floatVal;
Math::Vector *vectorVal;
} data;
bool local;
bool noLink;
int mask;
int linkId;
};
struct Message
{
string name;
int statementStart;
};
struct StartInfo
{
int statement;
int sender;
int senderType;
int source;
float time;
bool touched;
};
class Script
{
public:
Script( const string& filename );
Script( Script &c );
void SaveArgumentString( const string& s );
void ParseArgumentString();
void Message( const string& message, int sender, int senderType, int source, bool synchronous = false );
void LinkParameters();
void StartTimer( float t );
static void LoadSafeCogs();
static void Setup();
protected:
static HANDLE semaphore;
vector<Symbol> symbols;
vector<Cog::Message> messages;
C_ASTNode *code;
StartInfo startInfo;
int flags;
bool safe;
bool doingTouched;
string argumentString;
#ifdef SAFECOGSINTERNAL
static char *safeCogs[];
#else
static char **safeCogs;
#endif
static int numSafeCogs;
// C_Script.cpp
void SetupSymbolTable( C_ASTNode *symbolsNode );
void SetupMessages();
void Hack( string& source );
// C_Execute.cpp
void ExecuteStatements( int start, Context &c );
bool ExecuteStatement( C_ASTNode *node, Context &c );
void ExecuteAssign( C_ASTNode *node, Context &c );
void ExecuteExpression( C_ASTNode *node, Context &c );
int TypeSize( C_SymbolType type );
C_SymbolType BaseType( C_SymbolType type );
void Cast( C_SymbolType source, C_SymbolType dest, Context &c );
C_SymbolType Promote( C_SymbolType xType, C_SymbolType yType, Context &c );
void Timer( float t );
static void ExecuteKickstart( void *object );
static void TimerKickstart( void *object );
// C_Script.cpp
Math::Vector ParseVector( const string& s );
// C_Verb.cpp
void ExecuteVerbCall( C_ASTNode *node, Context &c, bool expression );
};
}
#endif | [
"devnull@localhost"
] | [
[
[
1,
136
]
]
] |
0a34866cf2556aac9d2797d1c82eb224ec5f3a3a | 0c84ebd32a2646b5582051216d6e7c8283bb4f23 | /wxWizBaseDlg.cpp | 4dd9e50d778a07f3d0552b549f5c796f532d3bbb | [] | no_license | AudioAnecdotes/wxWizApp | 97932d2e6fd2c38934c16629a5e3d6023e0978ac | 129dfad68be44581c97249d2975efca2fa7578b7 | refs/heads/master | 2021-01-18T06:36:29.316270 | 2007-01-02T06:02:13 | 2007-01-02T06:02:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,379 | cpp | // wxWizBaseDlg.cpp: implementation of the wxWizBaseDlg class.
//
//////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "wx/statline.h"
#include "wxWizBaseDlg.h"
BEGIN_EVENT_TABLE(wxWizBaseDlg,wxDialog)
EVT_BUTTON(ID_NEXT,wxWizBaseDlg::OnNextButtonClick)
EVT_BUTTON(ID_BACK,wxWizBaseDlg::OnBackButtonClick)
EVT_BUTTON(ID_CANCEL,wxWizBaseDlg::OnCancelButtonClick)
EVT_BUTTON(ID_BROWSE,wxWizBaseDlg::OnBrowseButtonClick)
END_EVENT_TABLE()
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
wxWizBaseDlg::wxWizBaseDlg(WizAppData* data):
wxDialog(NULL,-1,wxString("Dialog"),wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE|wxSTAY_ON_TOP)
{
m_data=data;
wxFont fnt(8,wxSWISS,wxNORMAL,wxNORMAL,FALSE);
SetFont(fnt);
wxWindow* win;
SetIcon(m_data->icon);
SetSize(-1,-1,470,390);
SetTitle(m_data->title);
CentreOnScreen();
wxButton* btn;
if (m_data->opt_finish)
btn=new wxButton(this,ID_NEXT,m_data->labelfinish,wxPoint(280,325),wxSize(75,25));
else
btn=new wxButton(this,ID_NEXT,m_data->labelnext,wxPoint(280,325),wxSize(75,25));
btn->SetDefault();
new wxButton(this,ID_CANCEL,m_data->labelcancel,wxPoint(375,325),wxSize(75,25));
win=new wxButton(this,ID_BACK,m_data->labelback,wxPoint(193,325),wxSize(75,25));
if (m_data->opt_noback)
win->Hide();
new wxStaticLine(this,ID_STATIC,wxPoint(7,314),wxSize(442,1));
new wxStaticBitmap(this,ID_BITMAP,m_data->bitmap,wxPoint(7,7),wxSize(m_data->bitmap.GetWidth(),m_data->bitmap.GetHeight()),wxSUNKEN_BORDER);
win=new wxTextCtrl(this,ID_EDIT,"",wxPoint(178,130),wxSize(273,23));
win->Hide();
win=new wxRadioButton(this,ID_RADIO1,"Radio1",wxPoint(178,130),wxSize(273,15),wxRB_GROUP);
win->Hide();
win=new wxRadioButton(this,ID_RADIO2,"Radio2",wxPoint(178,148),wxSize(273,15));
win->Hide();
win=new wxRadioButton(this,ID_RADIO3,"Radio3",wxPoint(178,166),wxSize(273,15));
win->Hide();
win=new wxRadioButton(this,ID_RADIO4,"Radio4",wxPoint(178,184),wxSize(273,15));
win->Hide();
win=new wxRadioButton(this,ID_RADIO5,"Radio5",wxPoint(178,202),wxSize(273,15));
win->Hide();
win=new wxRadioButton(this,ID_RADIO6,"Radio6",wxPoint(178,220),wxSize(273,15));
win->Hide();
win=new wxRadioButton(this,ID_RADIO7,"Radio7",wxPoint(178,238),wxSize(273,15));
win->Hide();
win=new wxRadioButton(this,ID_RADIO8,"Radio8",wxPoint(178,256),wxSize(273,15));
win->Hide();
win=new wxRadioButton(this,ID_RADIO9,"Radio9",wxPoint(178,274),wxSize(273,15));
win->Hide();
win=new wxRadioButton(this,ID_RADIO10,"radio10",wxPoint(178,292),wxSize(273,15));
win->Hide();
win=new wxStaticText(this,ID_TEXT,"",wxPoint(178,7),wxSize(273,120),wxST_NO_AUTORESIZE);
win=new wxCheckBox(this,ID_CHECK1,"Check1",wxPoint(178,130),wxSize(273,15));
win->Hide();
win=new wxCheckBox(this,ID_CHECK2,"Check2",wxPoint(178,148),wxSize(273,15));
win->Hide();
win=new wxCheckBox(this,ID_CHECK3,"Check3",wxPoint(178,166),wxSize(273,15));
win->Hide();
win=new wxCheckBox(this,ID_CHECK4,"Check4",wxPoint(178,184),wxSize(273,15));
win->Hide();
win=new wxCheckBox(this,ID_CHECK5,"Check5",wxPoint(178,202),wxSize(273,15));
win->Hide();
win=new wxCheckBox(this,ID_CHECK6,"Check6",wxPoint(178,220),wxSize(273,15));
win->Hide();
win=new wxCheckBox(this,ID_CHECK7,"Check7",wxPoint(178,238),wxSize(273,15));
win->Hide();
win=new wxCheckBox(this,ID_CHECK8,"Check8",wxPoint(178,256),wxSize(273,15));
win->Hide();
win=new wxCheckBox(this,ID_CHECK9,"Check9",wxPoint(178,274),wxSize(273,15));
win->Hide();
win=new wxCheckBox(this,ID_CHECK10,"Check10",wxPoint(178,292),wxSize(273,15));
win->Hide();
win=new wxStaticText(this,ID_LARGETEXT,m_data->text,wxPoint(178,7),wxSize(273,305),wxST_NO_AUTORESIZE);
win->Hide();
win=new wxButton(this,ID_BROWSE,m_data->labelbrowse,wxPoint(375,130),wxSize(75,23));
win->Hide();
win=new wxTextCtrl(this,ID_FILE,"",wxPoint(178,130),wxSize(195,23));
win->Hide();
win=new wxTextCtrl(this,ID_FILETEXT,"",wxPoint(178,130),wxSize(273,180),wxTE_MULTILINE|wxTE_READONLY);
win->Hide();
win=new wxComboBox(this,ID_COMBO,"",wxPoint(178,130),wxSize(273,180),0,NULL,wxCB_SIMPLE|wxCB_READONLY);
win->Hide();
win=new wxListBox(this,ID_LISTSINGLE,wxPoint(178,130),wxSize(273,180),0,NULL,wxLB_SINGLE);
win->Hide();
win=new wxListBox(this,ID_LISTMULTIPLE,wxPoint(178,130),wxSize(273,180),0,NULL,wxLB_EXTENDED);
win->Hide();
win=new wxStaticText(this,ID_VERSION,m_data->sig,wxPoint(7,335),wxSize(185,20),wxST_NO_AUTORESIZE);
win=new wxTextCtrl(this,ID_EDITHIDDEN,"",wxPoint(178,130),wxSize(273,23),wxTE_PASSWORD);
win->Hide();
//deal with sound here
Raise();
}
wxWizBaseDlg::~wxWizBaseDlg()
{
}
void wxWizBaseDlg::OnNextButtonClick(wxCommandEvent& event)
{
OnButtonPressed(0);
}
void wxWizBaseDlg::OnBackButtonClick(wxCommandEvent& event)
{
OnButtonPressed(1);
}
void wxWizBaseDlg::OnCancelButtonClick(wxCommandEvent& event)
{
OnButtonPressed(2);
}
void wxWizBaseDlg::OnBrowseButtonClick(wxCommandEvent& event)
{
//Default implementation does nothing
}
void wxWizBaseDlg::OnButtonPressed(int errlevel)
{
EndModal(errlevel);
}
| [
"gsilber",
"howardg"
] | [
[
[
1,
29
],
[
31,
143
]
],
[
[
30,
30
]
]
] |
35af7030f3ffcd9920fbb0d0d6ad581305e17724 | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/mw/classicui/uifw/apps/S60_SDK3.0/bctestfontinput/src/bctestfontinputcase.cpp | 9af89a4a1fede4c6aa4ebba780b14905e1f0f89f | [] | 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 | 11,911 | cpp | /*
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: test case
*
*/
#include <w32std.h>
#include <coecntrl.h>
#include <gdi.h>
#include <eikenv.h>
#include <avkon.hrh>
// test header of Api
#include <uiklaf\private\lafenv.h>
#include <aknlayoutfont.h>
#include <aknfontspecification.h>
#include <akntextdecorationmetrics.h>
#include <gulbordr.h>
#include <akniconutils.h>
#include <aknutils.h>
#include <bctestfontinput.rsg>
#include <avkon.mbg>
#include <bctestfontinput_aif.mbg>
#include "bctestfontinputcase.h"
#include "bctestfontinputcontainer.h"
#include "bctestfontinput.hrh"
// ======== MEMBER FUNCTIONS ========
// ---------------------------------------------------------------------------
// Symbian 2nd static Constructor
// ---------------------------------------------------------------------------
//
CBCTestFontInputCase* CBCTestFontInputCase::NewL(
CBCTestFontInputContainer* aContainer )
{
CBCTestFontInputCase* self = new( ELeave ) CBCTestFontInputCase(
aContainer );
CleanupStack::PushL( self );
self->ConstructL();
CleanupStack::Pop( self );
return self;
}
// ---------------------------------------------------------------------------
// C++ default constructor
// ---------------------------------------------------------------------------
//
CBCTestFontInputCase::CBCTestFontInputCase(
CBCTestFontInputContainer* aContainer )
: iContainer( aContainer )
{
}
// ---------------------------------------------------------------------------
// Destructor
// ---------------------------------------------------------------------------
//
CBCTestFontInputCase::~CBCTestFontInputCase()
{
}
// ---------------------------------------------------------------------------
// Symbian 2nd Constructor
// ---------------------------------------------------------------------------
//
void CBCTestFontInputCase::ConstructL()
{
BuildScriptL();
}
// ---------------------------------------------------------------------------
// CBCTestFontInputCase::BuildScriptL
// ---------------------------------------------------------------------------
//
void CBCTestFontInputCase::BuildScriptL()
{
// Add script as your need.
AddTestL( DELAY( 2 ), LeftCBA, KeyOK,KeyOK,LeftCBA,Down,KeyOK, TEND );
}
// ---------------------------------------------------------------------------
// CBCTestFontInputCase::RunL
// ---------------------------------------------------------------------------
//
void CBCTestFontInputCase::RunL( TInt aCmd )
{
if ( aCmd < EBCTestFontSpec || aCmd > EBCTestLafEnv )
{
return;
}
switch ( aCmd )
{
case EBCTestLafEnv:
TestLafEnvL();
break;
case EBCTestFontSpec:
TestFontSpecL();
break;
default:
break;
}
}
// ---------------------------------------------------------------------------
// CBCTestFontInputCase::TestFontSpecL
// ---------------------------------------------------------------------------
//
void CBCTestFontInputCase::TestFontSpecL()
{
// Test some API here
TAknFontSpecification fontSpec( 3 );
fontSpec.SetExactMatchRequired( ETrue );
_LIT( stMatch, " Test SetExactMatchRequired() " );
AssertTrueL( ETrue, stMatch );
fontSpec.SetTextPaneHeight( TInt( 3 ) );
_LIT( stPaneHeight, " Test SetTextPaneHeight()" );
AssertTrueL( ETrue, stPaneHeight );
fontSpec.SetFontCategory( EAknFontCategoryUndefined );
_LIT( stFontCate, " Test SetFontCategory() " );
AssertTrueL( ETrue, stFontCate );
fontSpec.SetPosture( EPostureUpright );
_LIT( stPost, " Test SetPosTure() " );
AssertTrueL( ETrue, stPost );
fontSpec.SetTextPaneHeightIsDesignHeight( ETrue );
_LIT( stHeighIsDesHeight, " Test SetTextPaneHeightIsDesignHeight() " );
AssertTrueL( ETrue, stHeighIsDesHeight );
fontSpec.SetUnits( TAknFontSpecification::EPixels);
_LIT( stUnits, " Test SetUnits()" );
AssertTrueL( ETrue, stUnits );
fontSpec.SetWeight( EStrokeWeightNormal );
_LIT( stWeight, " Test SetWeight() " );
AssertTrueL( ETrue, stWeight );
TAknTextDecorationMetrics txtDecMetric( 3 );
txtDecMetric.BaselineToUnderlineOffset();
_LIT( bsLnToUnderLn," Test BaseLineToUnderline)ffset() " );
AssertTrueL( ETrue, bsLnToUnderLn );
txtDecMetric.UnderlineHeight();
_LIT( underLnHeight," Test UnderlineHeight() " );
AssertTrueL( ETrue, underLnHeight );
TInt lef,rgt,tp,bt;
txtDecMetric.GetLeftAndRightMargins( lef, rgt );
_LIT( gtLeftAndRight, " Test GetLeftAndRightMargins() " );
AssertTrueL( ETrue, gtLeftAndRight );
txtDecMetric.GetTopAndBottomMargins( tp,bt );
_LIT( gtTandB, " Test GetTopAndBottomMargins() " );
AssertTrueL( ETrue, gtTandB );
txtDecMetric.CursorWidth();
_LIT( CurWidth, " Test CursorWidth() " );
AssertTrueL( ETrue, CurWidth );
TAknTextDecorationMetrics txtDecMetric1( CCoeEnv::Static()->NormalFont() );
_LIT( txtDecMetricsFont, " Test TAKnTextDecorationMetrics( Font )" );
AssertTrueL( ETrue, txtDecMetricsFont );
TAknTextDecorationMetrics txtDecMetric2( fontSpec );
_LIT( txtDecMetricsSpec," Test TAKnTextDecorationMetrics( Font )" );
AssertTrueL( ETrue, txtDecMetricsSpec );
const CAknLayoutFont* layoutFont =
AknLayoutUtils::LayoutFontFromId( 3 );
TInt maxAscent = layoutFont->MaxAscent();
_LIT( KLayoutFont1, "CAknLayoutFont::MaxAscent" );
AssertTrueL( ETrue, KLayoutFont1 );
TAknTextDecorationMetrics metrics = layoutFont->TextDecorationMetrics();
_LIT( KLayoutFont2, "CAknLayoutFont::TextDecorationMetrics" );
AssertTrueL( ETrue, KLayoutFont2 );
}
void CBCTestFontInputCase::TestLafEnvL()
{
LafEnv::Beep();
_LIT( beep," Test Beep() " );
AssertTrueL( ETrue,beep );
LafEnv::ClockDllName();
_LIT( clkName," Test ClockDllName() " );
AssertTrueL( ETrue,clkName );
LafEnv::CoctlResourceFile();
_LIT( ctlResFile," Test CoctlResourceFile() " );
AssertTrueL( ETrue,ctlResFile );
LafEnv::CreateTextParserL( TInt( 3 ) );
_LIT( crtTxtParser," Test CreateTextParserL() " );
AssertTrueL( ETrue,crtTxtParser);
LafEnv::DefaultBusyMsgCorner();
_LIT(defBusyMsg," Test DefaultBusyMsgCorner() " );
AssertTrueL( ETrue,defBusyMsg );
LafEnv::IsTaskListDisabledAtInitialization();
_LIT( isTaskInit," Test IsTaskListDisabledAtInitialization" );
AssertTrueL( ETrue,isTaskInit );
LafEnv::EditableControlStandardHeight( CEikonEnv::Static()->LafEnv() );
_LIT( editHeight," Test EditableControlStandardHeight() " );
AssertTrueL( ETrue,editHeight );
LafEnv::IsDefaultKey( EAknSoftkeyBack );
_LIT( isDefKey," Test IsDefaultKey() " );
AssertTrueL( ETrue,isDefKey );
CColorList *clrList = LafEnv::CreateColorListL( *CEikonEnv::Static() );
_LIT(crtClrList," Test CreateColorListL() " );
AssertTrueL( ETrue,crtClrList );
LafEnv::UpdateColorListL( clrList );
_LIT( upClrList," Test UpdateColorListL() " );
AssertTrueL( ETrue, upClrList );
TInt fId = LafEnv::LoadPrivResFileL( *CEikonEnv::Static() );
_LIT( ldResFile," Test LoadPrivResFileL() " );
AssertTrueL( ETrue,ldResFile );
CEikonEnv::Static()->DeleteResourceFile( fId );
fId = LafEnv::LoadCoreResFileL( *CEikonEnv::Static() );
CEikonEnv::Static()->DeleteResourceFile( fId );
_LIT( cResFile," Test LoadCoreResFileL() " );
AssertTrueL( ETrue,cResFile );
CArrayPtr<CLafSystemFont> *ftArray = new (ELeave)
CArrayPtrSeg<CLafSystemFont>(10);
LafEnv::CreateSystemFontsL( *CEikonEnv::Static(),*ftArray );
_LIT( crtSysFont," Test CreateSystemFontsL() " );
AssertTrueL( ETrue,crtSysFont );
LafEnv::UpdateSystemFontsL( CEikonEnv::Static(),*ftArray );
_LIT( upSysFont," Test UpdateSystemFontsL() " );
AssertTrueL( ETrue,upSysFont );
LafEnv::ReleaseSystemFonts(*ftArray);
delete ftArray;
CArrayPtrFlat<CFbsBitmap> *arBitmaps = new
CArrayPtrFlat<CFbsBitmap>(16);
LafEnv::CreateSystemBitmapsL( *CEikonEnv::Static(), *arBitmaps);
_LIT( crtSysBitmap," Test CreateSystemBitmapsL() " );
AssertTrueL( ETrue,crtSysBitmap );
LafEnv::UpdateSystemBitmapsL(*CEikonEnv::Static() , *arBitmaps,*clrList );
_LIT( upSysBitmap," Test UpdateSystemBitmapsL() " );
AssertTrueL( ETrue,upSysBitmap );
delete clrList;
delete arBitmaps;
MEikBusyMsgWin *msgWin = LafEnv::NewBusyMsgWinL( *CCoeEnv::Static());
msgWin->Release();
_LIT( newMsgWin," Test NewBusyMsgWinL() " );
AssertTrueL( ETrue,newMsgWin );
RWindowGroup rWinGrup = CCoeEnv::Static()->RootWin();
MEikInfoMsgWin* infMsgWin = LafEnv::NewInfoMsgWinL( *CCoeEnv::Static(),
rWinGrup );
_LIT( newinfMsgWinGrup," Test NewInfoMsgWinL() " );
AssertTrueL( ETrue,newinfMsgWinGrup);
infMsgWin->Release();
infMsgWin = LafEnv::NewInfoMsgWinL( *CCoeEnv::Static() );
_LIT( newinfMsgWin," Test NewInfoMsgWinL() " );
AssertTrueL( ETrue,newinfMsgWin );
infMsgWin->Release();
LafEnv::DefaultLineSpacingInTwips();
_LIT( defLnSpaTwip," Test DefaultLineSpaceingInTwinps() " );
AssertTrueL( ETrue,defLnSpaTwip );
TCharFormat charFormat;
TCharFormatMask charFormatMask;
LafEnv::PrepareCharFormatAndMask( charFormat,charFormatMask );
_LIT( preCharFormat," Test PrepareCharFormatAndMask() " );
AssertTrueL( ETrue,preCharFormat );
TGulBorder tBorder;
TRect tRect;
TGulBorder::TColors bColors;
LafEnv::DrawLogicalBorder( tBorder,CCoeEnv::Static()->SystemGc(),tRect,bColors);
_LIT( drawLogBoder," Test DrawLogicalBorder()" );
AssertTrueL( ETrue,drawLogBoder );
TBuf<32> fPath;
TUid apUid = { 0x101F84F3 };
RApaLsSession *rLsSession = new ( ELeave ) RApaLsSession();
LafEnv::GetDefaultPath( fPath,apUid,*rLsSession,*CCoeEnv::Static() );
delete rLsSession;
_LIT(msg1," Alert 1 " );
_LIT(msg2," Alert 2 " );
_LIT(disAlert, " Test DisplayAlertAsNotifier() " );
LafEnv::DisplayAlertAsNotifier( msg1,msg2 );
AssertTrueL( ETrue,disAlert );
CFbsBitmap* bmp1 = new( ELeave ) CFbsBitmap();
CleanupStack::PushL( bmp1 );
CFbsBitmap* bmp2 = new( ELeave ) CFbsBitmap();
CleanupStack::PushL( bmp2 );
const TDesC& fileName = AknIconUtils::AvkonIconFileName();
bmp1->Load( fileName, EMbmAvkonQgn_indi_battery_strength );
bmp2->Load( fileName, EMbmAvkonQgn_prop_battery_icon );
CArrayPtrFlat<CFbsBitmap>* bmpArray = new( ELeave )
CArrayPtrFlat<CFbsBitmap>( 2 );
CleanupStack::PushL( bmpArray );
bmpArray->AppendL( bmp1 );
bmpArray->AppendL( bmp2 );
TUid matchUid = TUid::Uid( KLafUidEikonGrayVal );
CFbsBitmap* bmp = LafEnv::MatchBitmap( *bmpArray, matchUid );
_LIT( KMatchBitmap, "LafEnv::MatchBitmap" );
AssertNotNullL( bmp, KMatchBitmap );
CleanupStack::PopAndDestroy( 3 ); // are bmp1, bmp2 and bmpArray
}
| [
"none@none"
] | [
[
[
1,
346
]
]
] |
a536111cf0c3c0c3b312e89abab99e0456ee2d0a | 59166d9d1eea9b034ac331d9c5590362ab942a8f | /DynamicGroupSize/DynamicGroupSize.cpp | 73035b0e36ae7366700594e376b4f0f28e466501 | [] | no_license | seafengl/osgtraining | 5915f7b3a3c78334b9029ee58e6c1cb54de5c220 | fbfb29e5ae8cab6fa13900e417b6cba3a8c559df | refs/heads/master | 2020-04-09T07:32:31.981473 | 2010-09-03T15:10:30 | 2010-09-03T15:10:30 | 40,032,354 | 0 | 3 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 3,226 | cpp | #include "DynamicGroupSize.h"
#include "DynamicGroupUpdateCallback.h"
#include <osg/Geometry>
#define NUM_INSTANCE 16
DynamicGroupSize::DynamicGroupSize()
{
//резервируем память для NUM_INSTANCE элементов
m_vecGeode.reserve( NUM_INSTANCE );
//создать главный узел
m_rootNode = new osg::Group;
//динамический узел
m_rootNode->setDataVariance( osg::Object::DYNAMIC );
//инициализировать корневой узел
InitNode();
m_rootNode->setUpdateCallback( new DynamicGroupUpdateCallback( m_vecGeode ) );
}
DynamicGroupSize::~DynamicGroupSize()
{
}
void DynamicGroupSize::InitNode()
{
//инициализировать корневой узел
for ( int step = 0 ; step < NUM_INSTANCE ; ++step )
{
// Create an object to store geometry in.
osg::ref_ptr< osg::Geometry > geom = new osg::Geometry;
// Create an array of four vertices.
osg::ref_ptr<osg::Vec3Array> v = new osg::Vec3Array;
geom->setVertexArray( v.get() );
//////////////////////////////////////////////////////////////////////////
std::vector< unsigned int > m_vIndex;
int sizeC=17;
//Заполнение массива points
for (int i = 0 ; i < sizeC ; ++i )
for (int j = 0 ; j < sizeC ; ++j )
{
v->push_back( osg::Vec3( j + step * sizeC + sizeC, 0 , i) );
}
m_vIndex.push_back( 0 );
m_vIndex.push_back( sizeC );
int count = sizeC - 1;
int ind = 0;
while( count > 0 )
{
for( int i = 0 ; i < count ; i++ )
{
ind = m_vIndex.size() - 2;
m_vIndex.push_back( m_vIndex[ ind ] + 1 );
ind = m_vIndex.size() - 2;
m_vIndex.push_back( m_vIndex[ ind ] + 1 );
}
ind = m_vIndex.size() - 3;
m_vIndex.push_back( m_vIndex[ ind ] );
count--;
for( int i = 0 ; i< count ; i++ )
{
ind = m_vIndex.size() - 2;
m_vIndex.push_back( m_vIndex[ ind ] + sizeC );
ind = m_vIndex.size() - 2;
m_vIndex.push_back( m_vIndex[ ind ] + sizeC );
}
ind = m_vIndex.size() - 3;
m_vIndex.push_back( m_vIndex[ ind ] );
for( int i = 0 ; i < count ; i++ )
{
ind = m_vIndex.size() - 2;
m_vIndex.push_back( m_vIndex[ ind ] - 1 );
ind = m_vIndex.size() - 2;
m_vIndex.push_back( m_vIndex[ ind ] - 1 );
}
ind = m_vIndex.size() - 3;
m_vIndex.push_back( m_vIndex[ ind ] );
count--;
for( int i=0 ; i < count ; i++ )
{
ind = m_vIndex.size() - 2;
m_vIndex.push_back( m_vIndex[ ind ] - sizeC );
ind = m_vIndex.size() - 2;
m_vIndex.push_back( m_vIndex[ ind ] - sizeC );
}
ind = m_vIndex.size() - 3;
m_vIndex.push_back( m_vIndex[ ind ] );
}
//////////////////////////////////////////////////////////////////////////
geom->addPrimitiveSet( new osg::DrawElementsUInt(
osg::PrimitiveSet::TRIANGLE_STRIP, m_vIndex.size(), &m_vIndex[ 0 ] ) );
// Add the Geometry (Drawable) to a Geode and
// return the Geode.
osg::ref_ptr< osg::Geode > geode = new osg::Geode;
geode->addDrawable( geom.get() );
//запоминаем geode
m_vecGeode.push_back( geode );
m_rootNode->addChild( geode.get() );
}
} | [
"asmzx79@3290fc28-3049-11de-8daa-cfecb5f7ff5b"
] | [
[
[
1,
119
]
]
] |
05f61ab2d8f5be64c536ad6ae76ca3e8d3a4d5d6 | 9c62af23e0a1faea5aaa8dd328ba1d82688823a5 | /rl/branches/persistence2/engine/rules/include/GameObject.h | ad5e85eb690fd3d185a02fc686c508bdbfe6c20a | [
"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 | 9,325 | h | /* This source file is part of Rastullahs Lockenpracht.
* Copyright (C) 2003-2008 Team Pantheon. http://www.team-pantheon.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the Clarified Artistic License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Clarified Artistic License for more details.
*
* You should have received a copy of the Clarified Artistic License
* along with this program; if not you can get it here
* http://www.jpaulmorrison.com/fbp/artistic2.htm.
*/
#ifndef __GAMEOBJECT_H__
#define __GAMEOBJECT_H__
#include "RulesPrerequisites.h"
#include <list>
#include "Action.h"
#include "Actor.h"
#include "SaveAble.h"
#include "RulesConstants.h"
#include "ObjectStateChangeEventSource.h"
#include "Properties.h"
#include "CoreDefines.h"
namespace rl
{
class Creature;
class Effect;
class EffectManager;
/**
* \brief Base class for all game relevant objects in RL
* Provides methods for identification of objects within the world
* Abstract concepts do not inherit this class
*/
class _RlRulesExport GameObject
: public ActorNotifiedObject,
public ObjectStateChangeEventSource,
public SaveAble
{
public:
typedef std::vector<std::pair<Action*, int> > ActionOptionVector;
static const CeGuiString NO_OBJECT_ID;
static const Ogre::String CLASS_NAME;
static const Ogre::String PROPERTY_CLASS_ID;
static const Ogre::String PROPERTY_OBJECT_ID;
static const Ogre::String PROPERTY_INHERITS;
static const Ogre::String PROPERTY_BASE_CLASS;
static const Ogre::String PROPERTY_SCENE;
static const Ogre::String PROPERTY_POSITION;
static const Ogre::String PROPERTY_ORIENTATION;
static const Ogre::String PROPERTY_NAME;
static const Ogre::String PROPERTY_DESCRIPTION;
static const Ogre::String PROPERTY_MESHFILE;
static const Ogre::String PROPERTY_MESHPARTS;
static const Ogre::String PROPERTY_SUBMESHPRENAME;
static const Ogre::String PROPERTY_GEOMETRY_TYPE;
static const Ogre::String PROPERTY_MASS;
static const Ogre::String PROPERTY_ACTIONS;
static const Ogre::String PROPERTY_DEFAULT_ACTION;
static const Ogre::String PROPERTY_IMAGENAME;
static const CeGuiString DEFAULT_VIEW_OBJECT_ACTION;
static const CeGuiString DEFAULT_VIEW_OBJECT_ACTION_DEBUG;
GameObject(const CeGuiString &id);
virtual ~GameObject();
const CeGuiString& getClassId() const;
void setClassId(const CeGuiString& classId);
const CeGuiString& getName() const;
void setName(const CeGuiString& name);
const CeGuiString& getDescription() const;
void setDescription(const CeGuiString& description);
const CeGuiString& getImageName() const;
void setImageName(const CeGuiString& name);
const CeGuiString& getMeshfile() const;
void setMeshfile(const CeGuiString& meshfile);
const CeGuiString& getSubmeshPreName() const;
void setSubmeshPreName(const CeGuiString& name);
const MeshPartMap& getMeshParts() const;
const GeometryType getGeometryType() const;
void setGeometryType(GeometryType type);
const Ogre::Real getMass() const;
void setMass(const Ogre::Real mass);
void addAction(Action* action, int option = Action::ACT_NORMAL);
void addActionInGroup(Action* action, ActionGroup* group, int option = Action::ACT_NORMAL);
void removeAction(Action* action);
void setScene(const CeGuiString& scene);
const CeGuiString& getScene() const;
/*
* sets the actor of this gameobject
* @warning if the GameObject is destroyed or the State of the GameObject changed or this function
* is called with another actor, the actor will be deleted!
*/
void setActor(Actor* actor);
Actor* getActor();
/**
* Check whether a creature can perform an action on this game object
*
* @return a boolean
*/
bool hasAction(const CeGuiString& actionName, Creature* actor) const;
/**
* Get all valid actions a character can perfom on this game object
*
* @param actor the character
* @return a vector of actions
*/
const ActionVector getValidActions(Creature* actor) const;
virtual Action* getDefaultAction(Creature* actor) const;
/** Trigger an action of this game object
* @param actionName the action's name
* @param actor the "user" of this game object, can be <code>NULL</code> sein,
if the action wasn't triggered by someone (e.g. by time)
* @param target the action's target (can be <code>NULL</code> if no other game objects are involved)
*/
void doAction(const CeGuiString& actionName,
Creature* actor,
GameObject* target);
void doAction(const CeGuiString& actionName);
void doAction(Action* action,
Creature* actor,
GameObject* target);
bool activateAction(Action* action,
Creature* actor,
GameObject* target);
void doDefaultAction(Creature* actor, GameObject* target);
void setPosition(const Ogre::Vector3& position);
void setOrientation(const Ogre::Quaternion& orientation);
const Ogre::Quaternion& getOrientation() const;
const Ogre::Vector3& getPosition() const;
Ogre::AxisAlignedBox getWorldBoundingBox() const;
/// Soll der Aktor überhaupt leuchten?
bool isHighlightingEnabled();
void setHighlightingEnabled( bool highlightenabled );
void setHighlighted(bool highlight);
bool isHighlighted() const;
virtual const Property getProperty(const CeGuiString& key) const;
virtual void setProperty(const CeGuiString& key, const Property& value);
virtual PropertyKeys getAllPropertyKeys() const;
GameObjectState getState() const;
virtual void setState(GameObjectState state);
void placeIntoScene();
void removeFromScene();
unsigned long getQueryFlags() const;
void addQueryFlag(unsigned long queryflag);
void setQueryFlags(unsigned long queryflags);
virtual void onBeforeStateChange(GameObjectState oldState, GameObjectState newState);
virtual void onAfterStateChange(GameObjectState oldState, GameObjectState newState);
/**
* Lets an effect affect the game object
* @param effect the effect
* @ingroup CreatureRubyExports
**/
void addEffect(Effect* effect);
void addEffectWithCheckTime(Effect* effect, RL_LONGLONG time);
void addEffectWithCheckDate(Effect* effect, RL_LONGLONG date);
void removeEffect(Effect* effect);
/**
* Returns a printable list of all effects
*/
CeGuiString getEffects();
/**
* Checks all effects for end-of-life
**/
void _checkEffects();
protected:
GameObjectState mState;
CeGuiString mName;
CeGuiString mDescription;
CeGuiString mImageName;
CeGuiString mMeshfile;
MeshPartMap mMeshParts;
CeGuiString mSubmeshPreName;
CeGuiString mClassId;
Actor* mActor;
/// Query flags to be set to the actor, when placed into scene.
unsigned long mQueryFlags;
/// Shall the game object be selectable
bool mHighlightingEnabled;
/// Manages the effects affecting this game object
EffectManager* mEffectManager;
Actor* createActor();
void destroyActor();
virtual void doPlaceIntoScene();
virtual void doRemoveFromScene();
CeGuiString mScene;
private:
static int sNextGameObjectId;
ActionOptionVector mActions;
Ogre::Vector3 mPosition;
Ogre::Quaternion mOrientation;
Ogre::Real mMass;
CeGuiString mDefaultAction;
GeometryType mGeometryType;
ActionOptionVector::iterator findAction(ActionOptionVector::iterator begin,
ActionOptionVector::iterator end, const CeGuiString actionName);
ActionOptionVector::const_iterator findAction(ActionOptionVector::const_iterator begin,
ActionOptionVector::const_iterator end, const CeGuiString actionName) const;
ActionOptionVector::iterator findAction(ActionOptionVector::iterator
begin, ActionOptionVector::iterator end, const Action* action);
};
typedef std::list<GameObject*> GameObjectList;
}
#endif
| [
"timm@4c79e8ff-cfd4-0310-af45-a38c79f83013"
] | [
[
[
1,
256
]
]
] |
97f499d060eed7c62dd81e48b646e00b742f2db3 | 9b781f66110d82c4918feffeeee3740d6b9dcc73 | /Motion Graphs/dMap.h | cf0bb3dfbfab543074191b8c1aa763c554d57eaa | [] | no_license | vanish87/Motion-Graphs | 3c41cbb4ae838e2dce1172a56dfa00b8fe8f12cf | 6eab48f3625747d838f2f8221705a1dba154d8ca | refs/heads/master | 2021-01-23T05:34:56.297154 | 2011-06-10T09:53:15 | 2011-06-10T09:53:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,663 | h | #ifndef _DMAP
#define _DMAP
#include "stdafx.h"
#include "Motion.h"
//using namespace std;
class Graph;
class dMap{
friend Graph;
public:
dMap();
dMap(int nMotions);
~dMap();
void constructMap(Ninja motions, int nMotion);
void compareMotions(Motion *m1, Motion *m2);
float compareFrames(PointCloud *s1, PointCloud *s2);
static void calculateTransformation(PointCloud *s1, PointCloud *s2, float *teta, float *x0, float *z0);
void setNRelations(int r){this->nRelations = r;}
int getNRelations(){return this->nRelations;}
void setThreshold(float t){this->threshold = t;}
float getThreshold(){return this->threshold;}
void setNSteps(int n){this->nSteps = n;}
int getNSteps(){return this->nSteps;}
int getMinimuns(int level, std::vector<int> *m1, std::vector<int> *m2);
private:
Ninja motions;
float ***differenceMap;
std::string ***relations;
int nRelations;
int maxRelations;
float threshold;
int nSteps;
void duplicateSpace();
static void calculateSums(PointCloud *s1, PointCloud *s2, float *x1_, float *x2_, float *z1_, float *z2_, float *weights);
static float calculateTeta1(PointCloud *s1, PointCloud *s2);
static float calculateTeta2(float x1_, float x2_, float z1_, float z2_, float weights);
static float calculateTeta3(PointCloud *s1, PointCloud *s2);
static float calculateTeta4(float x1_, float x2_, float z1_, float z2_, float weights);
float difference(Point3D *p1, Point3D *p2){
return sqrt(pow(p1->getX() - p2->getX(),2) +
pow(p1->getY() - p2->getY(),2) +
pow(p1->getZ() - p2->getZ(),2) );
}
};
#endif | [
"mariojgpinto@6a9b4378-2129-4827-95b0-0a0a1e71ef92",
"onumis@6a9b4378-2129-4827-95b0-0a0a1e71ef92",
"necrolife@6a9b4378-2129-4827-95b0-0a0a1e71ef92"
] | [
[
[
1,
2
],
[
4,
19
],
[
21,
41
],
[
47,
55
]
],
[
[
3,
3
]
],
[
[
20,
20
],
[
42,
46
]
]
] |
16bfe9e66cd0f2eff5f134d347ca398c10a4eea4 | e8eb9e1c441ee4aff508e7f3fc3e502e3b517ab6 | /Source/examples.cxx | ce99f376666e0ad3777523f80038d385247ae139 | [] | no_license | midas-journal/midas-journal-740 | 8713a85719febd405bc2a77d13a9ce2a239cbcef | 8145819d64de2d9cdc5124b980364e9dea615bd5 | refs/heads/master | 2021-01-15T11:48:35.566395 | 2011-08-22T13:47:28 | 2011-08-22T13:47:28 | 2,248,737 | 3 | 2 | null | 2020-03-01T21:22:16 | 2011-08-22T13:51:08 | C++ | UTF-8 | C++ | false | false | 961 | cxx | /*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile: perf01.cxx,v $
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#define _SCL_SECURE_NO_WARNINGS
#define NO_TESTING
#include <iostream>
#include <sstream>
#include "CuberilleTest01.cxx"
int main(int argc, char * argv [])
{
return Test01( argc, argv );
}
| [
"[email protected]"
] | [
[
[
1,
33
]
]
] |
581c6712a1f032876f66e9f725bbe9a2fcb64583 | 583d876ec2e0577f03d27033c44a731cb5883219 | /PDIStuff/PDIser.h | a82d924b3ded30c6feeb091a6af5553c5d504258 | [] | no_license | BGCX067/eyerobot-hg-to-git | 6950df8a76cd536682843eb6c1232833735be7ee | f25681efe96f205fb0dac74b0072a5ac08070467 | refs/heads/master | 2016-09-01T08:50:07.262989 | 2010-07-09T18:40:57 | 2010-07-09T18:40:57 | 48,706,126 | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 1,957 | h | /////////////////////////////////////////////////////////////////////
// Polhemus Inc., www.polhemus.com
// © 2003 Alken, Inc. dba Polhemus, All Rights Reserved
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
//
// Filename: $Workfile: PDIser.h $
//
// Project Name: Polhemus Developer Interface
//
// Description: Serial Interface Description Class
//
// VSS $Header: /PIDevTools/Inc/PDIser.h 3 6/10/03 12:18p Sgagnon $
//
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
#ifndef _PDISER_H_
#define _PDISER_H_
#include "PDIdefs.h"
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
class CPiSerialInfo;
/////////////////////////////////////////////////////////////////////
// CLASS CPDIser
/////////////////////////////////////////////////////////////////////
class PDI_API CPDIser
{
public:
CPDIser( ePiBaudRate br=PI_BR_115200, ePiParity par=PI_PARITY_NONE, INT nPort=1 );
virtual ~CPDIser( VOID );
ePiBaudRate GetBaudRate ( VOID ); // Get current baud setting
ePiParity GetParity ( VOID ); // Get current parity setting
INT GetPort ( VOID ); // Get current port number
VOID SetBaudRate ( ePiBaudRate ); // Set baudrate
VOID SetParity ( ePiParity ); // Set parity
VOID SetPort ( INT ); // Set port number
private:
CPDIser( const CPDIser & );
CPiSerialInfo * m_pSI;
friend class CPDIdev;
};
/////////////////////////////////////////////////////////////////////
// END $Workfile: PDIser.h $
/////////////////////////////////////////////////////////////////////
#endif // _PDISER_H_
| [
"devnull@localhost"
] | [
[
[
1,
54
]
]
] |
b24eda7de9e8244a8563296b638a74ffcff7e1cb | 29c00095e9aa05f7100561e490c65f71150fa93b | /quoted.hpp | 15ada007d57e6b1e92ff5386097dc53cca10fbd7 | [
"Apache-2.0"
] | permissive | krfkeith/toupl | 1c78fe90a6516946a7f504d6c77ec746807e7ec8 | c80b5206750dc2de222e79c860cb229fb150a1fb | refs/heads/master | 2020-12-24T17:36:26.259097 | 2009-06-13T14:53:44 | 2009-06-13T14:53:44 | 37,639,837 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,309 | hpp | /*
This file is part of Toupl.
http://code.google.com/p/toupl/
Autor: Bga
Email: [email protected]
X.509 & GnuPG Email certifaces here: http://code.google.com/p/jbasis/downloads/list
Copyright 2009 Bga <[email protected]>
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
#ifndef QUOTED_HPP
#define QUOTED_HPP
#include "common.hpp"
#include "string.hpp"
String _quote(Const String& s,Const Char * rp=""
"\n\0\\n\0"
"\r\0\\r\0"
"\\\0\\\\\0"
"\'\0\\\'\0"
"\"\0\\\"\0"
"\t\0\\t\0"
"\f\0\\f\0"
"\b\0\\b\0"
"\a\0\\a\0"
"\v\0\\v\0\0"
);
#endif
| [
"bga.email@31f10f56-5826-11de-b31f-81d54249e7d9"
] | [
[
[
1,
48
]
]
] |
af8bcf2ea2f0a47b538941b0240247f318232cf9 | 8d1d891c3a1f9b4c09d6edf8cad30fcf03a214ed | /source/screens/OptionScreen.h | d0e62e174980afb9847f50124e2e249105019d46 | [] | no_license | mightymouse2016/shootmii | 7a53a70d027ec8bc8e957c7113144de57ecfa1a5 | 6a44637da4db44ba05d5d14c9a742f5d053041fa | refs/heads/master | 2021-01-10T06:36:38.009975 | 2010-07-20T19:43:23 | 2010-07-20T19:43:23 | 54,534,472 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 765 | h | #ifndef __OPTION_SCREEN_H__
#define __OPTION_SCREEN_H__
#include "GRRLIB.h"
#include "Screen.h"
#include "../tools/Color.h"
#include "../FreeTypeGX/FreeTypeGX.h"
namespace shootmii {
class App;
class Pointer;
class OptionScreen : public Screen {
private:
GRRLIB_texImg* tex_font;
Button* backButton;
Button* startButton;
Selector* roundSelector;
Selector* player1Selector;
Selector* player2Selector;
public:
OptionScreen(
App* app,
Pointer** pointerPlayer,
u32** eventsPlayer);
void init();
void dealEvent();
void compute();
void addToDrawManager();
void setRoundCount(unsigned int roundCount);
void setPlayer1IA(const bool ia);
void setPlayer2IA(const bool ia);
};
}
#endif // __OPTION_SCREEN_H__
| [
"Altarfinch@c8eafc54-4d23-11de-9e51-a92ed582648b"
] | [
[
[
1,
38
]
]
] |
4306048eeeba04fc51f01fe6506a84b60cb43229 | cfad0abe8d02cc052bf22997ba2670573563abff | /xkeymacs/propertiesadvanced.h | cc1e2503b9c5e2a7c8839c3e87fb7c33984325a3 | [] | no_license | kikairoya/xkeymacs | 0b4a2812f044276d9d6eb6589e4f474ae9ec4142 | 420cc0649c990e43fb5f9579321c28df78bdc1f7 | refs/heads/master | 2021-01-17T21:24:07.576264 | 2011-06-08T04:59:59 | 2011-06-08T04:59:59 | 1,858,433 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,111 | h | #if !defined(AFX_PROPERTIESADVANCED_H__41C61B2B_97BA_4015_8F1E_CA65AC628E42__INCLUDED_)
#define AFX_PROPERTIESADVANCED_H__41C61B2B_97BA_4015_8F1E_CA65AC628E42__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PropertiesAdvanced.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CPropertiesAdvanced dialog
class CPropertiesAdvanced : public CPropertyPage
{
DECLARE_DYNCREATE(CPropertiesAdvanced)
// Construction
public:
void EnableControl();
void GetDialogData();
void SetDialogData(CString szApplicationName);
CPropertiesAdvanced();
~CPropertiesAdvanced();
// Dialog Data
//{{AFX_DATA(CPropertiesAdvanced)
enum { IDD = IDD_PROPERTIES_ADVANCED };
CStatic m_cCurrentlyAssigned;
CButton m_cResetAll;
CButton m_cRemove;
CEdit m_cNewKey;
CStatic m_cDescription;
CListBox m_cCurrentKeys;
CListBox m_cCommands;
CComboBox m_cCategory;
CButton m_cAssign;
BOOL m_bEnableCUA;
//}}AFX_DATA
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CPropertiesAdvanced)
public:
virtual BOOL OnSetActive();
virtual BOOL OnKillActive();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CPropertiesAdvanced)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
virtual BOOL OnInitDialog();
afx_msg void OnSelchangeCategory();
afx_msg void OnSelchangeCommands();
afx_msg void OnSelchangeCurrentKeys();
afx_msg void OnSetfocusNewKey();
afx_msg void OnAssign();
afx_msg void OnRemove();
afx_msg void OnResetAll();
afx_msg void OnCX();
afx_msg void OnKillfocusNewKey();
afx_msg void OnEnableCua();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
static int m_nApplicationID;
static BOOL IsFooDown(CString szCommandName);
static BOOL IsShiftDown();
static BOOL IsMetaDown();
static BOOL IsCtrlDown();
void InitCommandIDs();
static void SetCommandID(int nCommandType, int nKey, int nCommandID);
static int m_nCommandIDs[MAX_COMMAND_TYPE][MAX_KEY];
static void SetNewKey();
static int m_nAssignKey;
static int m_nAssignCommandType;
static BOOL m_bShift;
static BOOL m_bM;
static BOOL m_bC;
static BOOL m_bC_x;
static LRESULT CALLBACK KeyboardProc(int code, WPARAM wParam, LPARAM lParam);
static HHOOK m_hKeyboardHook;
static CListBox * m_pCurrentKeys;
static CStatic * m_pCurrentlyAssigned;
static CButton * m_pAssign;
static CEdit * m_pNewKey;
int m_nRemoveKey;
int m_nRemoveCommandType;
void ClearNewKey();
static int m_nCommandID;
void SetCurrentKeys();
void SetCommands();
void InitCategoryList();
CProperties* m_pProperties;
void UpdateDialogData(CString szApplicationName, BOOL bSaveAndValidate = TRUE);
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PROPERTIESADVANCED_H__41C61B2B_97BA_4015_8F1E_CA65AC628E42__INCLUDED_)
| [
"[email protected]"
] | [
[
[
1,
105
]
]
] |
7e5888bd3d4fb42435ebee03a5a09f4f969de728 | cd0987589d3815de1dea8529a7705caac479e7e9 | /webkit/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h | 4dea30bcc9b3a54daf166c6616c5b779b9c13c09 | [
"BSD-2-Clause"
] | permissive | azrul2202/WebKit-Smartphone | 0aab1ff641d74f15c0623f00c56806dbc9b59fc1 | 023d6fe819445369134dee793b69de36748e71d7 | refs/heads/master | 2021-01-15T09:24:31.288774 | 2011-07-11T11:12:44 | 2011-07-11T11:12:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,429 | h | /*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef QWEBKITPLATFORMPLUGIN_H
#define QWEBKITPLATFORMPLUGIN_H
/*
* Warning: The contents of this file is not part of the public QtWebKit API
* and may be changed from version to version or even be completely removed.
*/
#include <QObject>
#include <QUrl>
class QWebSelectData
{
public:
virtual ~QWebSelectData() {}
enum ItemType { Option, Group, Separator };
virtual ItemType itemType(int) const = 0;
virtual QString itemText(int index) const = 0;
virtual QString itemToolTip(int index) const = 0;
virtual bool itemIsEnabled(int index) const = 0;
virtual bool itemIsSelected(int index) const = 0;
virtual int itemCount() const = 0;
virtual bool multiple() const = 0;
};
class QWebSelectMethod : public QObject
{
Q_OBJECT
public:
virtual ~QWebSelectMethod() {}
virtual void show(const QWebSelectData&) = 0;
virtual void hide() = 0;
Q_SIGNALS:
void selectItem(int index, bool allowMultiplySelections, bool shift);
void didHide();
};
class QWebNotificationData
{
public:
virtual ~QWebNotificationData() {}
virtual const QString title() const = 0;
virtual const QString message() const = 0;
virtual const QByteArray iconData() const = 0;
virtual const QUrl openerPageUrl() const = 0;
};
class QWebNotificationPresenter : public QObject
{
Q_OBJECT
public:
QWebNotificationPresenter() {}
virtual ~QWebNotificationPresenter() {}
virtual void showNotification(const QWebNotificationData*) = 0;
Q_SIGNALS:
void notificationClosed();
void notificationClicked();
};
class QWebHapticFeedbackPlayer
{
public:
enum HapticStrength {
None, Weak, Medium, Strong
};
enum HapticEvent {
Press, Release
};
virtual void playHapticFeedback(const HapticEvent, const QString& hapticType, const HapticStrength) = 0;
};
class QWebKitPlatformPlugin
{
public:
virtual ~QWebKitPlatformPlugin() {}
enum Extension {
MultipleSelections,
Notifications,
Haptics
};
virtual bool supportsExtension(Extension extension) const = 0;
virtual QWebSelectMethod* createSelectInputMethod() const = 0;
virtual QWebNotificationPresenter* createNotificationPresenter() const = 0;
virtual QWebHapticFeedbackPlayer* createHapticFeedbackPlayer() const = 0;
};
Q_DECLARE_INTERFACE(QWebKitPlatformPlugin, "com.nokia.Qt.WebKit.PlatformPlugin/1.4");
#endif // QWEBKITPLATFORMPLUGIN_H
| [
"[email protected]"
] | [
[
[
1,
121
]
]
] |
f3826b5f1289b27d07949b17fe16b73e429162d0 | 3d20de626d6bd35ecabe770bff36857824ed21ce | /Pacman/Map.h | 2d53643379a727a787ccf5fb3bc1336466ed5344 | [] | no_license | Flydiverny/Pacman | 4fb688869f0bf1267b05bbe3e0223d6323f5ffde | d9fbc6820a41d46adf40efea87a0162d892f9a4c | refs/heads/master | 2021-03-12T21:28:25.169355 | 2011-05-23T15:49:30 | 2011-05-23T15:49:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 834 | h | #pragma once
#include "Tile.h"
#include <string>
#include "Ghost.h"
namespace nadilus {
namespace pacman {
class Map {
public:
Map(void) {}
Map(std::string);
~Map(void);
void resetMap(void);
unsigned getRows(void);
unsigned getColumns(void);
Point getSpawn(void);
void readMap();
int getColor(int type);
Tile**& getTiles(void);
Tile& getTile(int x, int y);
bool hasFood(void);
Point getDrawPoint(void);
void setDrawPoint(Point p);
Ghost*& getGhosts();
unsigned getGhostCount();
private:
unsigned rows;
unsigned columns;
unsigned ghostCount;
Point spawnPoint;
bool spawnSet;
void initMap(void);
Point drawPoint;
std::string filename;
Tile** tiles;
Ghost* ghosts;
};
}
}
| [
"[email protected]"
] | [
[
[
1,
41
]
]
] |
a401a37212d1c601bad22bf94995501848704a0b | 62874cd4e97b2cfa74f4e507b798f6d5c7022d81 | /src/Properties/PropertyCollection.cpp | 35d5a42f1ccc3e923e9b3a0eecf3777ba27420bb | [] | no_license | rjaramih/midi-me | 6a4047e5f390a5ec851cbdc1b7495b7fe80a4158 | 6dd6a1a0111645199871f9951f841e74de0fe438 | refs/heads/master | 2021-03-12T21:31:17.689628 | 2011-07-31T22:42:05 | 2011-07-31T22:42:05 | 36,944,802 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,799 | cpp | // Includes
#include "PropertyCollection.h"
#include "Property.h"
#include <algorithm>
using namespace MidiMe;
/******************************
* Constructors and destructor *
******************************/
PropertyCollection::PropertyCollection()
{
}
PropertyCollection::~PropertyCollection()
{
clearProperties();
}
/*************
* Properties *
*************/
Property *PropertyCollection::getProperty(const string &name) const
{
PropertyMap::const_iterator it = m_propertiesMap.find(name);
return (it == m_propertiesMap.end()) ? 0 : it->second;
}
void PropertyCollection::setProperty(const string &name, const string &value)
{
Property *pProperty = getProperty(name);
if(pProperty)
pProperty->fromString(value);
}
/******************
* Other functions *
******************/
void PropertyCollection::clearProperties()
{
// Notify the listeners of the removing properties
PropertyList::iterator it;
for(it = m_propertiesList.begin(); it != m_propertiesList.end(); ++it)
fireRemoving(*it);
m_propertiesList.clear();
m_propertiesMap.clear();
}
/**********************
* Protected functions *
**********************/
void PropertyCollection::addProperty(Property *pProperty)
{
if(!pProperty) return;
m_propertiesList.push_back(pProperty);
m_propertiesMap[pProperty->getName()] = pProperty;
pProperty->setCollection(this);
fireAdded(pProperty);
}
void PropertyCollection::removeProperty(Property *pProperty)
{
if(!pProperty) return;
fireRemoving(pProperty);
pProperty->setCollection(0);
m_propertiesMap.erase(pProperty->getName());
m_propertiesList.remove(pProperty);
}
void PropertyCollection::fireAdded(Property *pProperty)
{
// The property should be part of this collection
assert(pProperty && m_propertiesMap.find(pProperty->getName()) != m_propertiesMap.end());
// Notify the listeners
ListenerSet::iterator it;
for(it = m_listeners.begin(); it != m_listeners.end(); ++it)
(*it)->onPropertyAdded(pProperty);
}
void PropertyCollection::fireRemoving(Property *pProperty)
{
// The property should be part of this collection
assert(pProperty && m_propertiesMap.find(pProperty->getName()) != m_propertiesMap.end());
// Notify the listeners
ListenerSet::iterator it;
for(it = m_listeners.begin(); it != m_listeners.end(); ++it)
(*it)->onPropertyRemoving(pProperty);
}
void PropertyCollection::fireChanged(Property *pProperty)
{
// The property should be part of this collection
assert(pProperty && m_propertiesMap.find(pProperty->getName()) != m_propertiesMap.end());
// Notify the listeners
ListenerSet::iterator it;
for(it = m_listeners.begin(); it != m_listeners.end(); ++it)
(*it)->onPropertyChanged(pProperty);
}
| [
"Jeroen.Dierckx@d8a2fbcc-2753-0410-82a0-8bc2cd85795f"
] | [
[
[
1,
113
]
]
] |
d0d469e4867b23be5e7833bec971aa7fdefc6b1b | 2a9f612bf4464a2e558d41a997824a01bf9c08c6 | /sha256.h | 0494b2cadbd4466f7415e04fbe4072b82f06f485 | [] | no_license | yamamushi/lib-CppFCPLib-official | a88ff43c173f491325d7651fe8ebe77234bbad80 | 3a2f0a55c782bbe84e2035823987e22eb735de54 | refs/heads/master | 2020-05-19T19:02:24.838315 | 2008-01-30T17:48:02 | 2008-01-30T17:48:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 825 | h | #if !defined( _sha256_h )
#define _sha256_h
#define word32 unsigned long
#define byte unsigned char
typedef struct {
word32 H[ 8 ];
word32 hbits, lbits;
byte M[ 64 ];
byte mlen;
} SHA256_ctx;
void SHA256_init ( SHA256_ctx* );
void SHA256_update( SHA256_ctx*, const byte *, word32 );
void SHA256_final ( SHA256_ctx* );
void SHA256_digest( SHA256_ctx*, byte* );
class SHA256 {
SHA256_ctx ctx;
byte digest[32];
public:
SHA256 () { init (); }
enum { DIGEST_LEN = 32 };
void init ( ) { SHA256_init (&ctx); }
void reset () { SHA256_init (&ctx); }
void write(byte *a, unsigned int b) { SHA256_update (&ctx, a, b); }
void final () { SHA256_final (&ctx); SHA256_digest (&ctx, digest); }
byte *read () { return digest; }
};
#endif
| [
"[email protected]"
] | [
[
[
1,
36
]
]
] |
6c65a815406198cbdbc069866dde58edec83fb6c | 71ffdff29137de6bda23f02c9e22a45fe94e7910 | /KillaCoptuz3000/src/Objects/CShot.h | aacb5eb26bd716aada3202bdb814aa398f275706 | [] | no_license | anhoppe/killakoptuz3000 | f2b6ecca308c1d6ebee9f43a1632a2051f321272 | fbf2e77d16c11abdadf45a88e1c747fa86517c59 | refs/heads/master | 2021-01-02T22:19:10.695739 | 2009-03-15T21:22:31 | 2009-03-15T21:22:31 | 35,839,301 | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 1,285 | h | // ***************************************************************
// CShot version: 1.0 · date: 05/05/2007
// -------------------------------------------------------------
//
// -------------------------------------------------------------
// Copyright (C) 2007 - All Rights Reserved
// ***************************************************************
//
// ***************************************************************
#ifndef CSHOT_H
#define CSHOT_H
#include "KillaCoptuz3000/src/Objects/CSprite.h"
#include "tinyxml/tinyxml.h"
class CLevel;
enum EShotType
{
e_shotNormal = 0,
e_shotBallistic = 1
};
class CShot : public CSprite
{
public:
// Copy constructor creates shot from default shot
CShot(CShot* t_shotPtr, std::list<unsigned int>* t_friendObjectsListPtr);
CShot(TiXmlNode* t_nodePtr);
~CShot();
virtual VeObjectType getType() { return e_shot; };
virtual bool load(TiXmlNode* t_nodePtr);
virtual void update(CLevel* t_levelPtr);
bool isFriend(unsigned int t_objectPtr);
EShotType m_shotType;
float m_velocityX;
float m_velocityY;
private:
std::list<unsigned int> m_friendObjects;
};
#endif
| [
"anhoppe@9386d06f-8230-0410-af72-8d16ca8b68df"
] | [
[
[
1,
49
]
]
] |
af655c13fdf3f8ab17d08f2d7fbac33726c55ad4 | 35231241243cb13bd3187983d224e827bb693df3 | /branches/umptesting/maproute/typeTranslation.cpp | 541edd4d17c0c1a0f2e99d304e4e5c8aea3b23a3 | [] | no_license | casaretto/cgpsmapper | b597aa2775cc112bf98732b182a9bc798c3dd967 | 76d90513514188ef82f4d869fc23781d6253f0ba | refs/heads/master | 2021-05-15T01:42:47.532459 | 2011-06-25T23:16:34 | 2011-06-25T23:16:34 | 1,943,334 | 2 | 2 | null | 2019-06-11T00:26:40 | 2011-06-23T18:31:36 | C++ | UTF-8 | C++ | false | false | 3,331 | cpp | /*
Created by: cgpsmapper
This is open source software. Source code is under the GNU General Public License version 3.0 (GPLv3) license.
Permission to modify the code and to distribute modified code is granted,
provided the above notices are retained, and a notice that the code was
modified is included with the above copyright notice.
*/
#include "typeTranslation.h"
#include "filexor.h"
using namespace std;
void typeReader::Read(const char* file_name) {
string key,value;
string name;
int t_read;
int type_start,type_end;
if( dataReady )
return;
dataReady = true;
vector<RGN_names> *c_RGN_names_current = NULL;
xor_fstream* rgn_types = new xor_fstream(file_name,"rb");
if( rgn_types->error ) {
delete rgn_types;
//cout<<">>>>>"<<file_name<<" file NOT FOUND!!<<<<<"<<endl;
return;
}
t_read = rgn_types->ReadInput(key,value);
while( t_read == 1 || t_read == 3 || t_read == 5 || t_read == 2 ) {
if( key == string("[RGN10/20 TYPES]") ) {
c_RGN_names_current = &c_RGN_names_1020;
key="";
}
if( key == string("[RGN40 TYPES]") ) {
c_RGN_names_current = &c_RGN_names_40;
key="";
}
if( key == string("[RGN80 TYPES]") ) {
c_RGN_names_current = &c_RGN_names_80;
key="";
}
if( key == string("[END-RGN10/20 TYPES]")
|| key == string("[END-RGN40 TYPES]")
|| key == string("[END-RGN80 TYPES]") ) {
c_RGN_names_current = NULL;
key="";
}
if( c_RGN_names_current != NULL && key.length() && t_read != 0 ) {
if( key[0] != ';' ) {
InterpreteRGNTypeLine(key,type_start,type_end,name);
(*c_RGN_names_current).push_back( RGN_names(name.c_str(), type_start, type_end-type_start) );
}
}
t_read = rgn_types->ReadInput(key,value);
}
delete rgn_types;
// RGNTypesLoaded = true;
}
void typeReader::InterpreteRGNTypeLine(string line,int &rgn_start,int &rgn_end,string &name)
{
char hex_str[10];
unsigned int t_pos=0;
int t_hex_pos=0;
//line = upper_case(line);
std::transform(line.begin(), line.end(), line.begin(), toupper);
while( t_pos < 7 && line[t_pos] != '-' && line[t_pos] != '\t' && line.length() > t_pos ) {
hex_str[t_hex_pos] = line[t_pos];
t_pos++;
t_hex_pos++;
}
hex_str[t_hex_pos]=0;
rgn_start = strtol(hex_str,NULL,0);
rgn_end = rgn_start;
if( line[t_pos] == '-' ) {
t_pos++;
t_hex_pos = 0;
while( line[t_pos] != '\t' && line[t_pos] != ',' && line.length() > t_pos ) {
hex_str[t_hex_pos] = line[t_pos];
t_pos++;
t_hex_pos++;
}
hex_str[t_hex_pos]=0;
rgn_end = strtol(hex_str,NULL,0);
}
while( line[t_pos] != ' ' && line[t_pos] != '\t' && line.length() > t_pos ) {
t_pos++;
}
t_pos++;
name = line.substr(t_pos, line.length() - t_pos);
while( name[name.size()-1] == ' ' )
name = name.substr(0,name.size()-1);
}
int typeReader::SearchRGNName40(const char* rgn_name)
{
int pos = 0;
int t_size = static_cast<int>((c_RGN_names_40).size());
while( pos < t_size )
{
if( !strcmp((c_RGN_names_40)[pos].name.c_str(),rgn_name) )
return (c_RGN_names_40)[pos].start;
pos++;
}
return 0;
} | [
"marrud@ad713ecf-6e55-4363-b790-59b81426eeec"
] | [
[
[
1,
126
]
]
] |
af408db6287b43e6d4ae68346b956ecea886105e | 3e69b159d352a57a48bc483cb8ca802b49679d65 | /tags/release-2005-10-27/eeschema/plot.cpp | e87e3b5409d02be293c5f82ec93b51686d01100f | [] | 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 | 21,736 | cpp | /************************************************/
/* Routine de trace communes aux divers formats */
/************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "plot_common.h"
#include "worksheet.h"
#include "protos.h"
/* Variables locales : */
static void PlotSheetLabelStruct(DrawSheetLabelStruct *Struct);
static void PlotTextField( EDA_SchComponentStruct *DrawLibItem,
int FieldNumber, int IsMulti, int DrawMode);
static void PlotPinSymbol(int posX, int posY, int len, int orient, int Shape);
/***/
/* cte pour remplissage de polygones */
#define FILL 1
#define NOFILL 0
#define PLOT_SHEETREF_MARGIN 0 // margin for sheet refs
/*******************************/
/* Routines de base de trace : */
/*******************************/
/* routine de lever ou baisser de plume.
si plume = 'U' les traces suivants se feront plume levee
si plume = 'D' les traces suivants se feront plume levee
*/
void Plume( int plume )
{
if ( g_PlotFormat == PLOT_FORMAT_HPGL ) Plume_HPGL(plume);
}
/* routine de deplacement de plume de plume.
*/
void Move_Plume( wxPoint pos, int plume )
{
switch ( g_PlotFormat )
{
case PLOT_FORMAT_HPGL:
Move_Plume_HPGL(pos, plume);
break;
case PLOT_FORMAT_POST:
case PLOT_FORMAT_POST_A4:
LineTo_PS(pos, plume);
break;
}
}
/***************************************************************/
void PlotArc(wxPoint centre, int StAngle, int EndAngle, int rayon)
/***************************************************************/
/* trace d'un arc de cercle:
x, y = coord du centre
StAngle, EndAngle = angle de debut et fin
rayon = rayon de l'arc
*/
{
switch ( g_PlotFormat )
{
case PLOT_FORMAT_HPGL:
PlotArcHPGL(centre, StAngle, EndAngle, rayon);
break;
case PLOT_FORMAT_POST:
PlotArcPS(centre, StAngle, EndAngle, rayon);
break;
}
}
/**************************************************/
void PlotCercle( wxPoint pos,int diametre )
/**************************************************/
{
switch ( g_PlotFormat )
{
case PLOT_FORMAT_HPGL:
PlotCircle_HPGL( pos, diametre);
break;
case PLOT_FORMAT_POST:
PlotCircle_PS(pos, diametre);
break;
}
}
/****************************************************/
static void PlotPoly( int nb, int * coord, int fill)
/****************************************************/
/* Trace un polygone ferme
coord = tableau des coord des sommets
nb = nombre de coord ( 1 coord = 2 elements: X et Y du tableau )
fill : si != 0 polygone rempli
*/
{
if( nb <= 1 ) return;
switch ( g_PlotFormat )
{
case PLOT_FORMAT_HPGL:
PlotPolyHPGL( nb, coord, fill);
break;
case PLOT_FORMAT_POST:
PlotPolyPS( nb, coord, fill);
break;
}
}
/**********************************************************/
void PlotNoConnectStruct(DrawNoConnectStruct * Struct)
/**********************************************************/
/* Routine de dessin des symboles de "No Connexion" ..
*/
{
#define DELTA (DRAWNOCONNECT_SIZE/2)
int pX, pY;
pX = Struct->m_Pos.x; pY = Struct->m_Pos.y;
Move_Plume(wxPoint(pX - DELTA, pY - DELTA), 'U');
Move_Plume(wxPoint(pX + DELTA, pY + DELTA), 'D');
Move_Plume(wxPoint(pX + DELTA, pY - DELTA), 'U');
Move_Plume(wxPoint(pX - DELTA, pY + DELTA), 'D');
Plume('U');
}
/*************************************************/
void PlotLibPart( EDA_SchComponentStruct *DrawLibItem )
/*************************************************/
/* Genere le trace d'un composant */
{
int ii, x1, y1, x2, y2, t1, t2, *Poly, orient;
LibEDA_BaseStruct *DEntry;
EDA_LibComponentStruct *Entry;
int TransMat[2][2], PartX, PartY, Multi, convert;
int CharColor = -1;
wxPoint pos;
Entry = FindLibPart(DrawLibItem->m_ChipName, "", FIND_ROOT);
if( Entry == NULL) return;;
memcpy(TransMat, DrawLibItem->m_Transform, sizeof(TransMat));
PartX = DrawLibItem->m_Pos.x; PartY = DrawLibItem->m_Pos.y;
Multi = DrawLibItem->m_Multi;
convert = DrawLibItem->m_Convert;
for( DEntry = Entry->m_Drawings; DEntry != NULL;DEntry = DEntry->Next())
{
/* Elimination des elements non relatifs a l'unite */
if( Multi && DEntry->m_Unit && (DEntry->m_Unit != Multi) ) continue;
if( convert && DEntry->m_Convert && (DEntry->m_Convert != convert) )
continue;
Plume('U');
if ( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS ( ReturnLayerColor(LAYER_DEVICE) );
switch (DEntry->m_StructType)
{
case COMPONENT_ARC_DRAW_TYPE:
{
LibDrawArc * Arc = (LibDrawArc *) DEntry;
t1 = Arc->t1; t2 = Arc->t2;
pos.x = PartX + TransMat[0][0] * Arc->m_Pos.x +
TransMat[0][1] * Arc->m_Pos.y;
pos.y = PartY + TransMat[1][0] * Arc->m_Pos.x +
TransMat[1][1] * Arc->m_Pos.y;
MapAngles(&t1, &t2, TransMat);
PlotArc(pos, t1, t2, Arc->m_Rayon);
}
break;
case COMPONENT_CIRCLE_DRAW_TYPE:
{
LibDrawCircle * Circle = (LibDrawCircle *) DEntry;
pos.x = PartX + TransMat[0][0] * Circle->m_Pos.x +
TransMat[0][1] * Circle->m_Pos.y;
pos.y = PartY + TransMat[1][0] * Circle->m_Pos.x +
TransMat[1][1] * Circle->m_Pos.y;
PlotCercle(pos, Circle->m_Rayon * 2);
}
break;
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
{
LibDrawText * Text = (LibDrawText *) DEntry;
/* The text orientation may need to be flipped if the
transformation matrix causes xy axes to be flipped. */
t1 = (TransMat[0][0] != 0) ^ (Text->m_Horiz != 0);
pos.x = PartX + TransMat[0][0] * Text->m_Pos.x
+ TransMat[0][1] * Text->m_Pos.y;
pos.y = PartY + TransMat[1][0] * Text->m_Pos.x
+ TransMat[1][1] * Text->m_Pos.y;
PlotGraphicText(g_PlotFormat, pos , CharColor,
Text->m_Text,
t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT,
Text->m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER);
}
break;
case COMPONENT_RECT_DRAW_TYPE:
{
LibDrawSquare * Square = (LibDrawSquare *) DEntry;
x1 = PartX + TransMat[0][0] * Square->m_Start.x
+ TransMat[0][1] * Square->m_Start.y;
y1 = PartY + TransMat[1][0] * Square->m_Start.x
+ TransMat[1][1] * Square->m_Start.y;
x2 = PartX + TransMat[0][0] * Square->m_End.x
+ TransMat[0][1] * Square->m_End.y;
y2 = PartY + TransMat[1][0] * Square->m_End.x
+ TransMat[1][1] * Square->m_End.y;
Move_Plume(wxPoint(x1, y1), 'U');
Move_Plume(wxPoint(x1, y2), 'D');
Move_Plume(wxPoint(x2, y2), 'D');
Move_Plume(wxPoint(x2, y1), 'D');
Move_Plume(wxPoint(x1, y1), 'D');
}
break;
case COMPONENT_PIN_DRAW_TYPE: /* Trace des Pins */
{
LibDrawPin * Pin = (LibDrawPin *) DEntry;
if(Pin->m_Attributs & PINNOTDRAW)
{
if( ActiveScreen->m_Type == SCHEMATIC_FRAME )
break;
}
/* Calcul de l'orientation reelle de la Pin */
orient = Pin->ReturnPinDrawOrient(TransMat);
/* compute Pin Pos */
x2 = PartX + TransMat[0][0] * Pin->m_Pos.x
+ TransMat[0][1] * Pin->m_Pos.y;
y2 = PartY + TransMat[1][0] * Pin->m_Pos.x
+ TransMat[1][1] * Pin->m_Pos.y;
/* Dessin de la pin et du symbole special associe */
PlotPinSymbol(x2, y2, Pin->m_PinLen, orient, Pin->m_PinShape);
wxPoint pinpos(x2, y2);
Pin->PlotPinTexts(pinpos, orient,
Entry->m_TextInside,
Entry->m_DrawPinNum, Entry->m_DrawPinName);
}
break;
case COMPONENT_POLYLINE_DRAW_TYPE:
{
LibDrawPolyline * polyline = (LibDrawPolyline *) DEntry;
Poly = (int *) MyMalloc(sizeof(int) * 2 * polyline->n);
for (ii = 0; ii < polyline->n; ii++)
{
Poly[ii * 2] = PartX +
TransMat[0][0] * polyline->PolyList[ii * 2] +
TransMat[0][1] * polyline->PolyList[ii * 2 + 1];
Poly[ii * 2 + 1] = PartY +
TransMat[1][0] * polyline->PolyList[ii * 2] +
TransMat[1][1] * polyline->PolyList[ii * 2 + 1];
}
PlotPoly(ii, Poly, polyline->m_Fill);
MyFree(Poly);
}
break;
} /* Fin Switch */
Plume('U');
} /* Fin Boucle de dessin */
/* Trace des champs, avec placement et orientation selon orient. du
composant
Si la reference commence par # elle n'est pas tracee
*/
if( (Entry->m_Prefix.m_Attributs & TEXT_NO_VISIBLE) == 0)
{
if ( Entry->m_UnitCount > 1 )
PlotTextField(DrawLibItem,REFERENCE,1,0);
else
PlotTextField(DrawLibItem,REFERENCE,0,0);
}
if( (Entry->m_Name.m_Attributs & TEXT_NO_VISIBLE) == 0)
PlotTextField(DrawLibItem,VALUE,0,0);
for( ii = 2; ii < NUMBER_OF_FIELDS; ii++ )
{
PlotTextField(DrawLibItem,ii,0,0);
}
}
/*************************************************************/
static void PlotTextField( EDA_SchComponentStruct *DrawLibItem,
int FieldNumber, int IsMulti, int DrawMode)
/**************************************************************/
/* Routine de trace des textes type Field du composant.
entree:
DrawLibItem: pointeur sur le composant
FieldNumber: Numero du champ
IsMulti: flag Non Null si il y a plusieurs parts par boitier.
n'est utile que pour le champ reference pour ajouter a celui ci
l'identification de la part ( A, B ... )
DrawMode: mode de trace
*/
{
int posX, posY; /* Position des textes */
int px, py, x1, y1;
PartTextStruct * Field = & DrawLibItem->m_Field[FieldNumber];
int hjustify, vjustify;
int orient, color = -1;
if ( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
color = ReturnLayerColor(Field->m_Layer);
DrawMode = 0; /* Unused */
if( Field->m_Attributs & TEXT_NO_VISIBLE ) return;
if( Field->IsVoid() ) return;
/* Calcul de la position des textes, selon orientation du composant */
orient = Field->m_Orient;
hjustify = Field->m_HJustify; vjustify = Field->m_VJustify;
posX = DrawLibItem->m_Pos.x; posY = DrawLibItem->m_Pos.y;
x1 = Field->m_Pos.x - posX;
y1 = Field->m_Pos.y - posY;
px = posX + (DrawLibItem->m_Transform[0][0] * x1)
+ (DrawLibItem->m_Transform[0][1] * y1);
py = posY + (DrawLibItem->m_Transform[1][0] * x1)
+ (DrawLibItem->m_Transform[1][1] * y1);
/* Y a t-il rotation */
if(DrawLibItem->m_Transform[0][1])
{
if ( orient == TEXT_ORIENT_HORIZ) orient = TEXT_ORIENT_VERT;
else orient = TEXT_ORIENT_HORIZ;
/* Y a t-il rotation, miroir (pour les justifications)*/
EXCHG(hjustify, vjustify);
if (DrawLibItem->m_Transform[1][0] < 0 ) vjustify = - vjustify;
if (DrawLibItem->m_Transform[1][0] > 0 ) hjustify = - hjustify;
}
else
{ /* Texte horizontal: Y a t-il miroir (pour les justifications)*/
if (DrawLibItem->m_Transform[0][0] < 0 )
hjustify = - hjustify;
if (DrawLibItem->m_Transform[1][1] > 0 )
vjustify = - vjustify;
}
if( !IsMulti || (FieldNumber != REFERENCE) )
{
PlotGraphicText( g_PlotFormat, wxPoint(px, py), color, Field->m_Text,
orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
Field->m_Size,
hjustify, vjustify);
}
else /* Le champ est la reference, et il y a plusieurs parts par boitier */
{ /* On ajoute alors A ou B ... a la reference */
wxString Text;
Text = Field->m_Text;
Text.Append('A' - 1 + DrawLibItem->m_Multi);
PlotGraphicText( g_PlotFormat, wxPoint(px, py), color, Text,
orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
Field->m_Size, hjustify, vjustify);
}
}
/**************************************************************************/
static void PlotPinSymbol(int posX, int posY, int len, int orient, int Shape)
/**************************************************************************/
/* Trace la pin du symbole en cours de trace
*/
{
int MapX1, MapY1, x1, y1;
int color;
color = ReturnLayerColor(LAYER_PIN);
if ( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS ( color );
MapX1 = MapY1 = 0; x1 = posX; y1 = posY;
switch ( orient )
{
case PIN_UP:
y1 = posY - len; MapY1 = 1;
break;
case PIN_DOWN:
y1 = posY + len; MapY1 = -1;
break;
case PIN_LEFT:
x1 = posX - len, MapX1 = 1;
break;
case PIN_RIGHT:
x1 = posX + len; MapX1 = -1;
break;
}
if( Shape & INVERT)
{
PlotCercle( wxPoint(MapX1 * INVERT_PIN_RADIUS + x1,
MapY1 * INVERT_PIN_RADIUS + y1),
INVERT_PIN_RADIUS * 2 );
Move_Plume( wxPoint(MapX1 * INVERT_PIN_RADIUS * 2 + x1,
MapY1 * INVERT_PIN_RADIUS * 2 + y1), 'U' );
Move_Plume(wxPoint(posX, posY), 'D' );
}
else
{
Move_Plume(wxPoint(x1, y1), 'U' );
Move_Plume(wxPoint(posX, posY), 'D' );
}
if(Shape & CLOCK)
{
if(MapY1 == 0 ) /* MapX1 = +- 1 */
{
Move_Plume(wxPoint(x1, y1 + CLOCK_PIN_DIM), 'U' );
Move_Plume(wxPoint(x1 - MapX1 * CLOCK_PIN_DIM, y1), 'D' );
Move_Plume(wxPoint(x1, y1 - CLOCK_PIN_DIM), 'D' );
}
else /* MapX1 = 0 */
{
Move_Plume( wxPoint(x1 + CLOCK_PIN_DIM, y1), 'U' );
Move_Plume( wxPoint(x1, y1 - MapY1 * CLOCK_PIN_DIM), 'D' );
Move_Plume( wxPoint(x1 - CLOCK_PIN_DIM, y1), 'D' );
}
}
if(Shape & LOWLEVEL_IN) /* IEEE symbol "Active Low Input" */
{
if(MapY1 == 0 ) /* MapX1 = +- 1 */
{
Move_Plume(wxPoint(x1 + MapX1 * IEEE_SYMBOL_PIN_DIM*2, y1), 'U');
Move_Plume(wxPoint(x1 + MapX1 * IEEE_SYMBOL_PIN_DIM*2,
y1 - IEEE_SYMBOL_PIN_DIM), 'D');
Move_Plume( wxPoint(x1, y1), 'D' );
}
else /* MapX1 = 0 */
{
Move_Plume( wxPoint(x1, y1 + MapY1 * IEEE_SYMBOL_PIN_DIM*2), 'U');
Move_Plume(wxPoint(x1 - IEEE_SYMBOL_PIN_DIM,
y1 + MapY1 * IEEE_SYMBOL_PIN_DIM*2), 'D');
Move_Plume(wxPoint(x1, y1), 'D');
}
}
if(Shape & LOWLEVEL_OUT) /* IEEE symbol "Active Low Output" */
{
if(MapY1 == 0 ) /* MapX1 = +- 1 */
{
Move_Plume(wxPoint(x1, y1 - IEEE_SYMBOL_PIN_DIM), 'U' );
Move_Plume(wxPoint(x1 + MapX1 * IEEE_SYMBOL_PIN_DIM*2, y1), 'D' );
}
else /* MapX1 = 0 */
{
Move_Plume(wxPoint(x1 - IEEE_SYMBOL_PIN_DIM, y1), 'U');
Move_Plume(wxPoint(x1 , y1 + MapY1 * IEEE_SYMBOL_PIN_DIM*2),'D' );
}
}
Plume('U');
}
/*******************************************/
void PlotTextStruct(EDA_BaseStruct *Struct)
/*******************************************/
/*
Routine de trace des Textes, Labels et Global-Labels.
Les textes peuvent avoir 4 directions.
*/
{
int * Template;
int Poly[50];
int ii, pX, pY, Shape = 0, Orient = 0, offset;
wxSize Size;
wxString Text;
int color = -1;
switch ( Struct->m_StructType )
{
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_TEXT_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
Text = ((DrawTextStruct*)Struct)->m_Text;
Size = ((DrawTextStruct*)Struct)->m_Size;
Orient = ((DrawTextStruct*)Struct)->m_Orient;
Shape = ((DrawTextStruct*)Struct)->m_Shape;
pX = ((DrawTextStruct*)Struct)->m_Pos.x;
pY = ((DrawTextStruct*)Struct)->m_Pos.y;
offset = TXTMARGE;
if ( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
color = ReturnLayerColor(((DrawTextStruct*)Struct)->m_Layer);
break;
default: return;
}
if(Size.x == 0 ) Size = wxSize(DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT);
switch(Orient)
{
case 0: /* Orientation horiz normale */
if( Struct->m_StructType == DRAW_GLOBAL_LABEL_STRUCT_TYPE )
PlotGraphicText(g_PlotFormat, wxPoint(pX - offset, pY),
color, Text, TEXT_ORIENT_HORIZ, Size,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER);
else
PlotGraphicText(g_PlotFormat, wxPoint(pX, pY - offset),
color, Text, TEXT_ORIENT_HORIZ, Size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM);
break;
case 1: /* Orientation vert UP */
if( Struct->m_StructType == DRAW_GLOBAL_LABEL_STRUCT_TYPE )
PlotGraphicText(g_PlotFormat, wxPoint(pX, pY + offset),
color, Text, TEXT_ORIENT_VERT, Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP);
else
PlotGraphicText( g_PlotFormat, wxPoint(pX - offset, pY),
color, Text, TEXT_ORIENT_VERT, Size,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM);
break;
case 2: /* Orientation horiz inverse */
if( Struct->m_StructType == DRAW_GLOBAL_LABEL_STRUCT_TYPE)
PlotGraphicText(g_PlotFormat, wxPoint(pX + offset, pY),
color, Text, TEXT_ORIENT_HORIZ, Size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER);
else
PlotGraphicText(g_PlotFormat, wxPoint(pX, pY + offset),
color, Text, 1800, Size,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_TOP);
break;
case 3: /* Orientation vert BOTTOM */
if( Struct->m_StructType == DRAW_GLOBAL_LABEL_STRUCT_TYPE)
PlotGraphicText(g_PlotFormat, wxPoint(pX, pY - offset),
color, Text, 2700, Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM);
else
PlotGraphicText(g_PlotFormat, wxPoint(pX + offset, pY),
color, Text, 2700, Size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP);
break;
}
/* Trace du symbole associe au label global */
if( Struct->m_StructType == DRAW_GLOBAL_LABEL_STRUCT_TYPE)
{
int jj, imax;
int HalfSize = Size.x / 2;
Template = TemplateShape[Shape][Orient];
imax = *Template; Template++;
for ( ii = 0, jj = 0; ii < imax ; ii++ )
{
Poly[jj] = ( HalfSize * (*Template) ) + pX;
jj ++; Template++;
Poly[jj] = ( HalfSize * (*Template) ) + pY;
jj ++; Template++;
}
PlotPoly(imax,Poly,NOFILL );
}
}
/***********************************************************/
static void PlotSheetLabelStruct(DrawSheetLabelStruct *Struct)
/***********************************************************/
/* Routine de dessin des Sheet Labels type hierarchie */
{
int side, txtcolor = -1;
int posx , tposx, posy, size, size2;
int coord[12];
if ( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
txtcolor = ReturnLayerColor(Struct->m_Layer);
posx = Struct->m_Pos.x; posy = Struct->m_Pos.y; size = Struct->m_Size.x;
if( Struct->m_Edge )
{
tposx = posx - size;
side = GR_TEXT_HJUSTIFY_RIGHT;
}
else {
tposx = posx + size + (size /8) ;
side = GR_TEXT_HJUSTIFY_LEFT;
}
PlotGraphicText(g_PlotFormat, wxPoint(tposx, posy), txtcolor,
Struct->m_Text, TEXT_ORIENT_HORIZ, wxSize(size,size),
side, GR_TEXT_VJUSTIFY_CENTER);
/* dessin du symbole de connexion */
if(Struct->m_Edge) size = -size;
coord[0] = posx; coord[1] = posy; size2 = size /2;
switch(Struct->m_Shape)
{
case 0: /* input |> */
coord[2] = posx ; coord[3] = posy - size2;
coord[4] = posx + size2; coord[5] = posy - size2;
coord[6] = posx + size; coord[7] = posy;
coord[8] = posx + size2; coord[9] = posy + size2;
coord[10] = posx ; coord[11] = posy + size2;
PlotPoly(6, coord, FILL);
break;
case 1: /* output <| */
coord[2] = posx + size2; coord[3] = posy - size2;
coord[4] = posx + size; coord[5] = posy - size2;
coord[6] = posx + size; coord[7] = posy + size2;
coord[8] = posx + size2; coord[9] = posy + size2;
PlotPoly(5, coord, FILL);
break;
case 2: /* bidi <> */
case 3: /* TriSt <> */
coord[2] = posx + size2; coord[3] = posy - size2;
coord[4] = posx + size; coord[5] = posy;
coord[6] = posx + size2; coord[7] = posy +size2;
PlotPoly(4, coord, FILL);
break;
default: /* unsp []*/
coord[2] = posx ; coord[3] = posy - size2;
coord[4] = posx + size; coord[5] = posy - size2;
coord[6] = posx + size; coord[7] = posy + size2;
coord[8] = posx ; coord[9] = posy + size2;
PlotPoly(5, coord, NOFILL);
break;
}
}
/*************************************************/
void PlotSheetStruct(DrawSheetStruct *Struct)
/*************************************************/
/* Routine de dessin du bloc type hierarchie */
{
DrawSheetLabelStruct * SheetLabelStruct;
int txtcolor = -1;
wxSize size;
wxString Text;
wxPoint pos;
if ( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS ( ReturnLayerColor(Struct->m_Layer) );
Move_Plume(Struct->m_Pos, 'U');
pos = Struct->m_Pos; pos.x += Struct->m_End.x;
Move_Plume(pos,'D');
pos.y += Struct->m_End.y;
Move_Plume(pos, 'D');
pos = Struct->m_Pos; pos.y += Struct->m_End.y;
Move_Plume(pos,'D');
Move_Plume(Struct->m_Pos, 'D');
Plume('U');
/* Trace des textes : SheetName */
Text = Struct->m_Field[VALUE].m_Text;
size = Struct->m_Field[VALUE].m_Size;
pos = Struct->m_Pos; pos.y -= 4;
if ( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS ( ReturnLayerColor(LAYER_SHEETNAME) );
PlotGraphicText(g_PlotFormat, pos, txtcolor,
Text, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM);
/* Trace des textes : FileName */
Text = Struct->m_Field[SHEET_FILENAME].m_Text;
size = Struct->m_Field[SHEET_FILENAME].m_Size;
if ( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS ( ReturnLayerColor(LAYER_SHEETFILENAME) );
PlotGraphicText(g_PlotFormat, wxPoint(Struct->m_Pos.x, Struct->m_Pos.y + Struct->m_End.y + 4),
txtcolor,
Text, TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP);
/* Trace des textes : SheetLabel */
SheetLabelStruct = Struct->m_Label;
if ( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt )
SetColorMapPS ( ReturnLayerColor(Struct->m_Layer) );
while( SheetLabelStruct != NULL )
{
PlotSheetLabelStruct(SheetLabelStruct);
SheetLabelStruct = (DrawSheetLabelStruct*)(SheetLabelStruct->Pnext);
}
}
| [
"bokeoa@244deca0-f506-0410-ab94-f4f3571dea26"
] | [
[
[
1,
699
]
]
] |
de1e536137442487754b430b78c8e4c1c5c6f22d | 672d939ad74ccb32afe7ec11b6b99a89c64a6020 | /FileSystem/fs/FS.H | e838b791453597017d234ab762f6018f32523854 | [] | no_license | cloudlander/legacy | a073013c69e399744de09d649aaac012e17da325 | 89acf51531165a29b35e36f360220eeca3b0c1f6 | refs/heads/master | 2022-04-22T14:55:37.354762 | 2009-04-11T13:51:56 | 2009-04-11T13:51:56 | 256,939,313 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 6,758 | h |
//----------------------------------------------------------------
//////////////////////////////////////////////////////////////////
// 文件名: FS.h
// 创建者: icelx
// 时间: 2001.12.16.
// 内容: 此类用于实现基本的文件系统的功能
// 提供格式化,新建文件,目录,写文件的接口函数
// 修改: pentium, rick
// 修改内容: 将DirItem和常数移出
// 增加文件名和扩展名长度常量
// 添加了一些成员变量及调整了结构
// 添加一些成员函数
// 添加FAT数组
//////////////////////////////////////////////////////////////////
#ifndef _FS_H
#define _FS_H
#include <ctime>
#include <list>
#include <string>
#include "FS_Kernel.h"
#include "DirItem.h"
#include "FileStruct.h"
#include "ErrorDef.h"
using namespace std;
const int MAX_PATH_LENGTH = 100; // Max path length for parse
struct tagDirItemRes // ListDir Directory Item Res
{
char* strItemName; // DirItem Name
char* strItemExtName; // DirItem ExtName
bool bIsFile; // True for file, false for directory
Byte* pAttri; // Directory or file Attribute
time_t timeLastWrite; // Time for last modification
int iItemLen; // DirItem Length
};
typedef list<struct tagDirItemRes> i_DirContainer; // DirItem List Iterator
typedef i_DirContainer::iterator i_DirIterator;
struct tagListDirRes // ListDir command result @Rick
{
char* strListDirPath; // ListDir Path
i_DirContainer DirContainer; // Directory Item Container List
int iTotalBytesAvail; // Total bytes available in disk
int iFileCount; // Total file count
int iDirCount; // Total directory count
int iTotalBytesUsed; // Total bytes used in disk
};
struct tagParsePatternRes // ParsePattern result @Rick
{
bool bIsNameAster; // Name only has asterisk "*"
bool bIsExtAster; // Extname only has asterisk "*"
short sNamePattPos; // Pattern (not "*") posisiton in name, 0 - head(e.g. "abc*"), 1 - tail(e.g. "*abc"), 2 - no asterisk (e.g. "abc")
short sExtPattPos; // Pattern (not "*") position in extname, 0 - head(e.g. "abc*"), 1 - tail(e.g. "*abc"), 2 - no asterisk (e.g. "abc")
string strNamePatt; // Pattern (not "*") in name
string strExtPatt; // Pattern (not "*") in extname
};
class FS
{
public: //compile
//protected:
// 文件系统核心参数 {
int iBlockSize;
int iMaxBlockNum; //总共块数
int iFATBlock,iBlockNumSize; //FAT所占的块数,块号所占字节数
int iFile_DirNameLen,iFileExtNameLen;
int iDirItemSize;
int iErrorCode;
// string VolumeName; // Volume Name -- Need to be implemented! @Rick
DirItem CurrentPath; // 当前目录
char Path[MAX_PATH];
int autoSaveTimeout; // 自动保存FAT的间隔
// <# pentium #>
FS_Kernel *pFS_Kernel;
Byte *FAT; // FAT表数组指针
// }
// 文件系统核心函数 {
int FS_InitialDir(int DirFirstBlock,int PareDirFirstBlock);
int FS_FindEmptyDirItem(int DirFirstBlock,int& BlockNum,int& ByteOffset);
int FS_NewDirItem(DirItem& NewDirItem,int DirFirstBlock );
int FS_RemoveDirItem(char* , int,int); // 删除目录项
int FS_ReadFATTable();
int FS_WriteFATTable();
int FS_WriteFAT(int BlockNum,int InputData);
int FS_ReadFAT(int BlockNum,int& OutputData);
int FS_ReqNewBlock(int& BlockNum,int PreBlockNum,int* fsFirstBlock=NULL);
int FS_ReleaseBlock(int BlockNum,int data); // 释放块
int FS_FindNextBlock(int CurrentBlock,int& NextBlock);
int FS_IsDirEmpty(int BlockNum); // 检查目录是否为空
// 供RemoveDir使用
int FS_IsDirValid(char*,DirItem*,int&); // 检查目录是否存在
// }
// 文件路径处理辅助函数 { ( 外部不可见 )
// 目录预处理, 返回所在块号
// PreProcessPath确实接口不好。 暂时留下。
int PreProcessPath(char* ,int iFirstBlock, int& , int &);
int ParsePath(char*,char*,int); // 提取路径
int FindCurPath(char* FileName,int op,int isFile,int iBlock,int& iNextBlock,File_Struct*,DirItem* =NULL);
// 在当前路径下搜索文件
int Level(char* Path); // 求路径层数
void SplitFileName(char* ,char* , char* ); // 将文件名拆开,供比较
void strsub(char* ); // sub the last '/'
// }
public:
FS(char* strVDFileName,int DiskSize,int BlockSize,int FATBlock);
~FS();
int FS_Format();
int FS_SetAutoSaveTimeOut(int); // 设置自动保存间隔
int FS_GetAutoSaveTimeOut(); // 读取自动保存间隔
// 文件系统接口{
// 以下凡是涉及到File_Struct结构指针的,
// 必须保证指针不指向空位置, 函数暂时不检查
int Seek(File_Struct* fs,int pos); // 移动文件基准位置
int CreatNewFile(File_Struct*,int mode,char* ,int); // 外部不调用,( 由OpenFile调用 ) // 新建一个空文件
int ReadFile(File_Struct*, Byte*,int,int&); // 读取文件内容
int WriteFile(File_Struct*, Byte*,int,int&); // 写文件
int OpenFile(File_Struct* ,char* ,char mode,int bCreatNew=1); // 打开文件
int CloseFile(File_Struct*); // 关闭文件
int ChangeMode(char* FilePath,int mode); // 改变文件属性
int RemoveFile(char*); // 删除文件
int CopyFiles(char* Source,char* Dest); // 复制文件
int MoveFiles(char* Source,char* Dest); // 移动文件
int MakeDir(char*,int bReqNewBlock=1); // 创建目录
int RemoveDir(char*); // 删除目录
int ChangeDir(char*); // 改变当前目录
char* GetCurrentPath(); // 取当前路径全路径字符串
int IsFormated();
int ParsePattern(string strPattern, struct tagParsePatternRes& PatternRes); // Parse the pattern received
int ListDir(string strPath, struct tagParsePatternRes PatRes, struct tagListDirRes& ListDirRes); // List directory
int GetItemInfoList(char* strPath, struct tagListDirRes& ListDirRes, struct tagParsePatternRes PatRes, bool bHasPattern, bool bIsFile, bool bHasExt);
int CopyDirItem(Byte* pTempData, struct tagListDirRes& ListDirRes, bool bHasExt); // Copy Dir Item to List
bool IsPatternMatch(Byte* pTempData, struct tagParsePatternRes Pat); // Pattern Match or not
};
#endif
//---------------------------------------------------------------------------- | [
"xmzhang@5428276e-be0b-f542-9301-ee418ed919ad"
] | [
[
[
1,
159
]
]
] |
10bccef1e7552bacf4cd8b44896212ddfcb08faf | f5b41ec38cf7640e37b880706bca424a19695afb | /Library/trunk/Library/BaseBook.cpp | ac3ad5ee1393474bfce622d20e03e546e793d3b9 | [] | no_license | dvirsegal/hw3-un | 99b3c5baac5667aba314efb002c6acfd52bba2de | ba83b06f3cb7e88ecd52bc08cf6a45828bc8ca5c | refs/heads/master | 2021-06-11T08:20:32.763185 | 2011-09-14T18:08:45 | 2011-09-14T18:08:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 482 | cpp | /***************************************************************************
*
* HW 3
*
* Author: Dvir Segal
*
* Author: Sheira Ben Haim
**************************************************************************/
#include "BaseBook.h"
BaseBook::BaseBook(const long CID):_CatalogId(CID)//c'tor
{
_borrow_days=0;
_borrow_date=NULL;
_isborrow=false;
_type="";
}
bool BaseBook::operator==(const long CID)
{
return (_CatalogId==CID?true:false);
}
| [
"[email protected]@b387bec4-7a92-a7d2-31ee-4c2c7b2d7c03",
"[email protected]"
] | [
[
[
1,
16
],
[
22,
23
]
],
[
[
17,
21
]
]
] |
d4f10abaf0f52553be9301599fb0a3ffd0bd188b | 1189af0cf195251bfe8c142befccf973583fd637 | /project/jni/Global.h | b06c45983a952034678aabcb5041141f9ab5faba | [] | no_license | geesun/phoneloc | 4b675bbdac4fdde09c04fb164e6944c80feb02e3 | c56d5e4645a2bf01ddad37ffad4de77f4a23d729 | refs/heads/master | 2016-09-05T10:03:34.247547 | 2009-11-24T13:10:38 | 2009-11-24T13:10:38 | 371,331 | 7 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,253 | h | /************************************************************
手机号归属地数据导入及查询工具源代码(C++)
Author: rssn
Email : [email protected]
QQ : 126027268
Blog : http://blog.csdn.net/rssn_net/
Modify History:
1) Geesun 2009/10/09 增加城市区号
2) Geesun 2009/10/11 更改号码为24位,以节约空间200k
************************************************************/
#ifndef _MPGLOBAL_INCLUDED_
#define _MPGLOBAL_INCLUDED_
#pragma pack (1)
//链表节点类
class StringNode
{
public:
unsigned short cityCode;
char * value;
int length;
unsigned short offset;
StringNode * next;
StringNode(const char * val, unsigned short cityCode);
StringNode();
~StringNode();
};
//索引表节点类
class IndexNode
{
public:
int NumStart;
int NumEnd;
StringNode * Address;
IndexNode * next;
IndexNode();
IndexNode(int ns, int ne, StringNode * ad=NULL);
};
//索引记录结构体
typedef struct _IndexStruct
{
int NumStart;
int NumEnd;
unsigned short Offset;
} IndexStruct;
//手机归属地结构体类型
typedef struct _MpLocation
{
int NumStart;
int NumEnd;
char Location[48];
int locationCode;
} MpLocation;
#endif
| [
"[email protected]",
"[email protected]"
] | [
[
[
1,
6
],
[
10,
62
]
],
[
[
7,
9
]
]
] |
407854cce04f752e42dd37118fe37fedd1912f2d | 9fb229975cc6bd01eb38c3e96849d0c36985fa1e | /Tools/TrackCompiler/TextureIndex.h | ccc1ac4a18d3d753fa8faf411cbd3417b7b9bf00 | [] | no_license | Danewalker/ahr | 3758bf3219f407ed813c2bbed5d1d86291b9237d | 2af9fd5a866c98ef1f95f4d1c3d9b192fee785a6 | refs/heads/master | 2016-09-13T08:03:43.040624 | 2010-07-21T15:44:41 | 2010-07-21T15:44:41 | 56,323,321 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 597 | h | #ifndef _TEXTUREINDEX_H_
#define _TEXTUREINDEX_H_
#include "DisableStlWarnings.h"
#include <map>
class ASEMap;
class OutFile;
// ---------------------------------------------------------------------------
// Arg! a singleton!!!!!
// ---------------------------------------------------------------------------
class CTextureIndex
{
private:
CTextureIndex();
public:
static CTextureIndex& Get();
int Get(const ASEMap*);
void Save(OutFile& out) const;
private:
typedef std::map<const ASEMap*,int> Map;
Map m_map;
};
#endif // _TEXTUREINDEX_H_
| [
"jakesoul@c957e3ca-5ece-11de-8832-3f4c773c73ae"
] | [
[
[
1,
34
]
]
] |
d91e2b7d0398ade217f6fd58b5173e2b86c6eddd | f55665c5faa3d79d0d6fe91fcfeb8daa5adf84d0 | /Depend/MyGUI/MyGUIEngine/src/MyGUI_SkinManager.cpp | 60484f7f96c708be350ad0780c2ba99c1724528b | [] | no_license | lxinhcn/starworld | 79ed06ca49d4064307ae73156574932d6185dbab | 86eb0fb8bd268994454b0cfe6419ffef3fc0fc80 | refs/heads/master | 2021-01-10T07:43:51.858394 | 2010-09-15T02:38:48 | 2010-09-15T02:38:48 | 47,859,019 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,479 | cpp | /*!
@file
@author Albert Semenov
@date 11/2007
*/
/*
This file is part of MyGUI.
MyGUI is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
MyGUI 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 MyGUI. If not, see <http://www.gnu.org/licenses/>.
*/
#include "MyGUI_Precompiled.h"
#include "MyGUI_SkinManager.h"
#include "MyGUI_LanguageManager.h"
#include "MyGUI_ResourceSkin.h"
#include "MyGUI_XmlDocument.h"
#include "MyGUI_SubWidgetManager.h"
#include "MyGUI_Gui.h"
#include "MyGUI_DataManager.h"
#include "MyGUI_FactoryManager.h"
#include "MyGUI_IStateInfo.h"
namespace MyGUI
{
const std::string XML_TYPE("Skin");
const std::string XML_TYPE_RESOURCE("Resource");
const std::string RESOURCE_DEFAULT_NAME("Default");
template <> SkinManager* Singleton<SkinManager>::msInstance = nullptr;
template <> const char* Singleton<SkinManager>::mClassTypeName("SkinManager");
SkinManager::SkinManager() :
mIsInitialise(false)
{
}
void SkinManager::initialise()
{
MYGUI_ASSERT(!mIsInitialise, getClassTypeName() << " initialised twice");
MYGUI_LOG(Info, "* Initialise: " << getClassTypeName());
ResourceManager::getInstance().registerLoadXmlDelegate(XML_TYPE) = newDelegate(this, &SkinManager::_load);
FactoryManager::getInstance().registerFactory<ResourceSkin>(XML_TYPE_RESOURCE);
mDefaultName = "skin_Default";
createDefault(mDefaultName);
MYGUI_LOG(Info, getClassTypeName() << " successfully initialized");
mIsInitialise = true;
}
void SkinManager::shutdown()
{
MYGUI_ASSERT(mIsInitialise, getClassTypeName() << " is not initialised");
MYGUI_LOG(Info, "* Shutdown: " << getClassTypeName());
ResourceManager::getInstance().unregisterLoadXmlDelegate(XML_TYPE);
FactoryManager::getInstance().unregisterFactory<ResourceSkin>(XML_TYPE_RESOURCE);
MYGUI_LOG(Info, getClassTypeName() << " successfully shutdown");
mIsInitialise = false;
}
void SkinManager::_load(xml::ElementPtr _node, const std::string& _file, Version _version)
{
// берем детей и крутимся, основной цикл со скинами
xml::ElementEnumerator skin = _node->getElementEnumerator();
while (skin.next(XML_TYPE))
{
std::string name = skin->findAttribute("name");
std::string type = skin->findAttribute("type");
if (type.empty()) type = "ResourceSkin";
IObject* object = FactoryManager::getInstance().createObject(XML_TYPE_RESOURCE, type);
if (object != nullptr)
{
ResourceSkin* data = object->castType<ResourceSkin>();
data->deserialization(skin.current(), _version);
ResourceManager::getInstance().addResource(data);
}
}
}
void SkinManager::createDefault(const std::string& _value)
{
xml::Document doc;
xml::ElementPtr root = doc.createRoot("MyGUI");
xml::ElementPtr newnode = root->createChild("Resource");
newnode->addAttribute("type", ResourceSkin::getClassTypeName());
newnode->addAttribute("name", _value);
ResourceManager::getInstance().loadFromXmlNode(root, "", Version());
}
ResourceSkin* SkinManager::getByName(const std::string& _name) const
{
IResource* result = nullptr;
if (!_name.empty() && _name != RESOURCE_DEFAULT_NAME)
result = ResourceManager::getInstance().getByName(_name, false);
if (result == nullptr)
{
result = ResourceManager::getInstance().getByName(mDefaultName, false);
if (!_name.empty() && _name != RESOURCE_DEFAULT_NAME)
{
MYGUI_LOG(Error, "Skin '" << _name << "' not found. Replaced with default skin.");
}
}
return result ? result->castType<ResourceSkin>(false) : nullptr;
}
bool SkinManager::isExist(const std::string& _name) const
{
IResource* result = ResourceManager::getInstance().getByName(_name, false);
return (result != nullptr) && (result->isType<ResourceSkin>());
}
void SkinManager::setDefaultSkin(const std::string& _value)
{
mDefaultName = _value;
}
} // namespace MyGUI
| [
"albertclass@a94d7126-06ea-11de-b17c-0f1ef23b492c"
] | [
[
[
1,
136
]
]
] |
9e04b50fa48b30045c36bdebc8954bec30fd0bf5 | 864b3c4db459e0b497eab4ec85cce01122c48fad | /kg_static_polymorphism_multi_platform/src/pc/kg_widget_pc.h | 9c74ddc2dc1b1f4a17ec531b9cff33ec95f944c2 | [] | no_license | kgeorge/kgeorge-lib | e1b6334f7e02822886641c5a92956045bfd88349 | c81040deeebb9324845928a65d1d9146fac3d2dd | refs/heads/master | 2021-01-10T08:19:23.124790 | 2009-07-12T23:04:54 | 2009-07-12T23:04:54 | 36,910,482 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 441 | h | #if !defined(KG_WIDGET_PC_H_)
#define KG_WIDGET_PC_H_
#include "kg_widget.h"
//pc platform specific headers that is usable by kg_widget_pc.cpp
//goes here
//Please note that this .h file is not publicly shared and is kept in the
//src directory rather than the inc directory
namespace kg_static_polymorphism_multi_platform
{
}//namespace kg_static_polymorphism_multi_platform
#endif //KG_WIDGET_PC_H_
| [
"kgeorge2@553ec044-b8b1-11dd-a067-9b1d96bc3259"
] | [
[
[
1,
24
]
]
] |
ea7bda12b96094b5c7ceaea3efa9f515997662f8 | fe7cc4981fcf3ac07dc715f4acf11928c640e738 | /libraries/EDB/EDB.cpp | 25cab0ad3008d7c62caaaad294b88dae842e821c | [] | no_license | ac001/arduino-core-2010 | 84c1b1848966cf60efa2dec656d2fd24875b8a1a | a39fc3a24004dadf4afcba20413a2b29a11093fa | refs/heads/master | 2020-05-18T10:08:21.694412 | 2010-01-09T05:57:02 | 2010-01-09T05:57:02 | 464,684 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,200 | cpp | /*
EDB.cpp
Extended Database Library for Arduino
http://www.arduino.cc/playground/Code/ExtendedDatabaseLibrary
Based on code from:
Database library for Arduino
Written by Madhusudana das
http://www.arduino.cc/playground/Code/DatabaseLibrary
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "WProgram.h"
#include "EDB.h"
/**************************************************/
// private functions
// low level byte write
void EDB::edbWrite(unsigned long ee, const byte* p, unsigned int recsize)
{
for (unsigned int i = 0; i < recsize; i++)
_write_byte(ee++, *p++);
}
// low level byte read
void EDB::edbRead(unsigned long ee, byte* p, unsigned int recsize)
{
for (unsigned i = 0; i < recsize; i++)
*p++ = _read_byte(ee++);
}
// writes EDB_Header
void EDB::writeHead()
{
edbWrite(EDB_head_ptr, EDB_REC EDB_head, (unsigned long)sizeof(EDB_Header));
}
// reads EDB_Header
void EDB::readHead()
{
edbRead(EDB_head_ptr, EDB_REC EDB_head, (unsigned long)sizeof(EDB_Header));
}
/**************************************************/
// public functions
EDB::EDB(EDB_Write_Handler *w, EDB_Read_Handler *r)
{
_write_byte = w;
_read_byte = r;
}
// creates a new table and sets header values
EDB_Status EDB::create(unsigned long head_ptr, unsigned long tablesize, unsigned int recsize)
{
EDB_head_ptr = head_ptr;
EDB_table_ptr = sizeof(EDB_Header) + EDB_head_ptr;
EDB_head.n_recs = 0;
EDB_head.rec_size = recsize;
EDB_head.table_size = tablesize;
writeHead();
return EDB_OK;
}
// reads an existing edb header at a given recno and sets header values
EDB_Status EDB::open(unsigned long head_ptr)
{
EDB_head_ptr = head_ptr;
readHead();
return EDB_OK;
}
// writes a record to a given recno
EDB_Status EDB::writeRec(unsigned long recno, const EDB_Rec rec)
{
edbWrite(EDB_table_ptr + ((recno - 1) * EDB_head.rec_size), rec, EDB_head.rec_size);
return EDB_OK;
}
// reads a record from a given recno
EDB_Status EDB::readRec(unsigned long recno, EDB_Rec rec)
{
if (recno < 1 || recno > EDB_head.n_recs) return EDB_OUT_OF_RANGE;
edbRead(EDB_table_ptr + ((recno - 1) * EDB_head.rec_size), rec, EDB_head.rec_size);
return EDB_OK;
}
// Deletes a record at a given recno
// Becomes more inefficient as you the record set increases and you delete records
// early in the record queue.
EDB_Status EDB::deleteRec(unsigned long recno)
{
if (recno < 0 || recno > EDB_head.n_recs) return EDB_OUT_OF_RANGE;
EDB_Rec rec = (byte*)malloc(EDB_head.rec_size);
for (unsigned long i = recno + 1; i <= EDB_head.n_recs; i++)
{
readRec(i, rec);
writeRec(i - 1, rec);
}
free(rec);
EDB_head.n_recs--;
writeHead();
return EDB_OK;
}
// Inserts a record at a given recno, increasing all following records' recno by 1.
// This function becomes increasingly inefficient as it's currently implemented and
// is the slowest way to add a record.
EDB_Status EDB::insertRec(unsigned long recno, EDB_Rec rec)
{
if (count() == limit()) return EDB_TABLE_FULL;
if (count() > 0 && (recno < 0 || recno > EDB_head.n_recs)) return EDB_OUT_OF_RANGE;
if (count() == 0 && recno == 1) return appendRec(rec);
EDB_Rec buf = (byte*)malloc(EDB_head.rec_size);
for (unsigned long i = EDB_head.n_recs; i >= recno; i--)
{
readRec(i, buf);
writeRec(i + 1, buf);
}
free(buf);
writeRec(recno, rec);
EDB_head.n_recs++;
writeHead();
return EDB_OK;
}
// Updates a record at a given recno
EDB_Status EDB::updateRec(unsigned long recno, EDB_Rec rec)
{
if (recno < 0 || recno > EDB_head.n_recs) return EDB_OUT_OF_RANGE;
writeRec(recno, rec);
return EDB_OK;
}
// Adds a record to the end of the record set.
// This is the fastest way to add a record.
EDB_Status EDB::appendRec(EDB_Rec rec)
{
if (EDB_head.n_recs + 1 > limit()) return EDB_TABLE_FULL;
EDB_head.n_recs++;
writeRec(EDB_head.n_recs,rec);
writeHead();
return EDB_OK;
}
// returns the number of queued items
unsigned long EDB::count()
{
return EDB_head.n_recs;
}
// returns the maximum number of items that will fit into the queue
unsigned long EDB::limit()
{
return (EDB_head.table_size - EDB_table_ptr) / EDB_head.rec_size;
}
// truncates the queue by resetting the internal pointers
void EDB::clear()
{
readHead();
create(EDB_head_ptr, EDB_head.table_size, EDB_head.rec_size);
}
| [
"[email protected]"
] | [
[
[
1,
179
]
]
] |
0900cf0e5ec67e1a93a31db0effc75a998e9da89 | 1c9f99b2b2e3835038aba7ec0abc3a228e24a558 | /Projects/elastix/elastix_sources_v4/src/Common/itkMultiResolutionGaussianSmoothingPyramidImageFilter.h | 71308cb4f815d3eb759db8020756af085d04c5d4 | [] | no_license | mijc/Diploma | 95fa1b04801ba9afb6493b24b53383d0fbd00b33 | bae131ed74f1b344b219c0ffe0fffcd90306aeb8 | refs/heads/master | 2021-01-18T13:57:42.223466 | 2011-02-15T14:19:49 | 2011-02-15T14:19:49 | 1,369,569 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,452 | h | /*======================================================================
This file is part of the elastix software.
Copyright (c) University Medical Center Utrecht. All rights reserved.
See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
======================================================================*/
/** Parts of the code were taken from an ITK file.
* Original ITK copyright message, just for reference: */
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date: 2008-04-15 19:54:41 +0200 (Tue, 15 Apr 2008) $
Version: $Revision: 1573 $
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __itkMultiResolutionGaussianSmoothingPyramidImageFilter_h
#define __itkMultiResolutionGaussianSmoothingPyramidImageFilter_h
#include "itkMultiResolutionPyramidImageFilter.h"
namespace itk
{
/** \class MultiResolutionGaussianSmoothingPyramidImageFilter
* \brief Framework for creating images in a multi-resolution
* pyramid.
*
* MultiResolutionGaussianSmoothingPyramidImageFilter creates
* an image pryamid according to a user defined multi-resolution schedule.
*
* This class inherits from the MultiResolutionPyramidImageFilter. It
* applies the same smoothing but does NOT do the downsampling.
*
* The multi-resolution schedule is still specified in terms for
* 'shrink factors' at each multi-resolution level for each dimension
* (although, actual shrinking is not performed).
*
* A user can either use the default schedules or specify
* each factor in the schedules directly.
*
* The schedule is stored as an unsigned int matrix.
* An element of the table can be access via the double bracket
* notation: table[resLevel][dimension]
*
* For example:
* 8 4 4
* 4 4 2
*
* is a schedule for two computation level. In the first (coarest)
* level the image is reduce by a factor of 8 in the column dimension,
* factor of 4 in the row dimension and factor of 4 in the slice dimension.
* In the second level, the image is reduce by a factor of 4 in the column
* dimension, 4 is the row dimension and 2 in the slice dimension.
*
* The method SetNumberOfLevels() set the number of
* computation levels in the pyramid. This method will
* allocate memory for the multi-resolution schedule table.
* This method generates defaults tables with the starting
* shrink factor for all dimension set to 2^(NumberOfLevel - 1).
* All factors are halved for all subsequent levels.
* For example if the number of levels was set to 4, the default table is:
*
* 8 8 8
* 4 4 4
* 2 2 2
* 1 1 1
*
* The user can get a copy of the schedule via GetSchedule()
* They may make alteration and reset it using SetSchedule().
*
* A user can create a default table by specifying the starting
* shrink factors via methods SetStartingShrinkFactors()
* The factors for subsequent level is generated by
* halving the factor or setting to one, depending on which is larger.
*
* For example, for 4 levels and starting factors of 8,8,4
* the default table would be:
*
* 8 8 4
* 4 4 2
* 2 2 1
* 1 1 1
*
* When this filter is updated, NumberOfLevels outputs are produced.
* The N'th output correspond to the N'th level of the pyramid.
*
* To generate each output image, Gaussian smoothing is first performed
* using a series of RecursiveGaussianImageFilter with standard deviation
* (shrink factor / 2)*imagespacing.
* The smoothed images are NOT downsampled, in contrast to the superclass's
* behaviour.
*
* This class is templated over the input image type and the output image
* type.
*
* This filter uses multithreaded filters to perform the smoothing.
*
* This filter supports streaming.
*
* \ingroup PyramidImageFilter Multithreaded Streamed
*/
template <
class TInputImage,
class TOutputImage
>
class MultiResolutionGaussianSmoothingPyramidImageFilter :
public MultiResolutionPyramidImageFilter< TInputImage, TOutputImage >
{
public:
/** Standard class typedefs. */
typedef MultiResolutionGaussianSmoothingPyramidImageFilter Self;
typedef MultiResolutionPyramidImageFilter<TInputImage,TOutputImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(MultiResolutionGaussianSmoothingPyramidImageFilter, MultiResolutionPyramidImageFilter);
/** ImageDimension enumeration. */
itkStaticConstMacro(ImageDimension, unsigned int,
TInputImage::ImageDimension);
itkStaticConstMacro(OutputImageDimension, unsigned int,
TOutputImage::ImageDimension);
/** Inherit types from Superclass. */
typedef typename Superclass::ScheduleType ScheduleType;
typedef typename Superclass::InputImageType InputImageType;
typedef typename Superclass::OutputImageType OutputImageType;
typedef typename Superclass::InputImagePointer InputImagePointer;
typedef typename Superclass::OutputImagePointer OutputImagePointer;
typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
/** Set a multi-resolution schedule. The input schedule must have only
* ImageDimension number of columns and NumberOfLevels number of rows. In
* contrast to the superclass, any schedule is allowed:
* - For each dimension, the shrink factor may be non-increasing with respect to
* subsequent levels.
* - shrink factors of 0 are allowed. This results in almost no smoothing.
* Because of lazy programming, the image is then smoothed with a gauss with sigma
* of 0.01*spacing...
*
* Note that the images are not actually shrunk by this class. They are
* only smoothed with the same standard deviation gaussian as used by
* the superclass.
*/
void SetSchedule( const ScheduleType& schedule );
/** Set spacing etc. */
virtual void GenerateOutputInformation();
/** Given one output whose requested region has been set, this method sets
* the requested region for the remaining output images. The original
* documentation of this method is below. \sa
* ProcessObject::GenerateOutputRequestedRegion(); */
virtual void GenerateOutputRequestedRegion(DataObject *output);
/** MultiResolutionGaussianSmoothingPyramidImageFilter requires a larger input requested
* region than the output requested regions to accomdate the
* smoothing operations. As such, MultiResolutionGaussianSmoothingPyramidImageFilter needs
* to provide an implementation for GenerateInputRequestedRegion(). The
* original documentation of this method is below. \sa
* ProcessObject::GenerateInputRequestedRegion() */
virtual void GenerateInputRequestedRegion();
protected:
MultiResolutionGaussianSmoothingPyramidImageFilter();
~MultiResolutionGaussianSmoothingPyramidImageFilter() {};
void PrintSelf(std::ostream&os, Indent indent) const;
/** Generate the output data. */
void GenerateData();
/** This filter by default generates the largest possible region,
* because it uses internally a filter that does this. */
virtual void EnlargeOutputRequestedRegion(DataObject *output);
private:
MultiResolutionGaussianSmoothingPyramidImageFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
};
} // namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkMultiResolutionGaussianSmoothingPyramidImageFilter.txx"
#endif
#endif
| [
"[email protected]"
] | [
[
[
1,
213
]
]
] |
8832b64456ff1b015dd24865254ebd6265041a94 | ad80c85f09a98b1bfc47191c0e99f3d4559b10d4 | /code/src/anim/nanimcurvearray_main.cc | eb9cda21db6fc421e8ab018634ff4cf11b402049 | [] | no_license | DSPNerd/m-nebula | 76a4578f5504f6902e054ddd365b42672024de6d | 52a32902773c10cf1c6bc3dabefd2fd1587d83b3 | refs/heads/master | 2021-12-07T18:23:07.272880 | 2009-07-07T09:47:09 | 2009-07-07T09:47:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,183 | cc | #define N_IMPLEMENTS nAnimCurveArray
//------------------------------------------------------------------------------
// nanimcurvearray_main.cc
// (C) 2002 RadonLabs GmbH
//------------------------------------------------------------------------------
#include "kernel/nkernelserver.h"
#include "kernel/nfileserver2.h"
#include "anim/nanimcurvearray.h"
nNebulaClass(nAnimCurveArray, "nroot");
//------------------------------------------------------------------------------
/**
*/
nAnimCurveArray::nAnimCurveArray() :
numCurves(0),
curveArray(0)
{
// empty
}
//------------------------------------------------------------------------------
/**
*/
nAnimCurveArray::~nAnimCurveArray()
{
this->Clear();
}
//------------------------------------------------------------------------------
/**
*/
bool
nAnimCurveArray::SaveAnim(nFileServer2* fs, const char* filename )
{
n_assert(fs);
n_assert(filename);
n_assert(this->numCurves > 0);
n_assert(this->curveArray);
char line[N_MAXPATH];
nFile* file = fs->NewFileObject();
n_assert(file);
if (!file->Open(filename, "w"))
{
n_printf("nCurveArray::SaveAnim(): failed to open file '%s' for writing!\n", filename);
delete file;
return false;
}
// number of animation curves
sprintf(line, "curves %d\n", this->numCurves);
file->PutS(line);
// for each curve...
int i;
for (i = 0; i < this->numCurves; i++)
{
nAnimCurve& curCurve = this->curveArray[i];
// generate 'curve' keyword
const char* curveName = curCurve.GetName();
n_assert(curveName && (strlen(curveName) > 0));
int startKey = curCurve.GetStartKey();
int numKeys = curCurve.GetNumKeys();
float keysPerSec = curCurve.GetKeysPerSecond();
const char* repType = nAnimCurve::RepeatType2String(curCurve.GetRepeatType());
const char* ipolType = nAnimCurve::IpolType2String(curCurve.GetIpolType());
n_assert(repType);
n_assert(ipolType);
sprintf(line, "curve %s %d %d %f %s %s\n", curveName, startKey, numKeys, keysPerSec, repType, ipolType);
file->PutS(line);
// for each key in curve:
int j;
for (j = 0; j < numKeys; j++)
{
const vector4& key = curCurve.GetKey(j);
sprintf(line, "key %f %f %f %f\n", key.x, key.y, key.z, key.w);
file->PutS(line);
}
}
// close file and exit
file->Close();
delete file;
return true;
}
//------------------------------------------------------------------------------
/**
Save anim curve array as binary file (.nax)
*/
bool
nAnimCurveArray::SaveNax(nFileServer2* fs, const char* filename)
{
n_assert(fs);
n_assert(filename);
n_assert(this->numCurves > 0);
n_assert(this->curveArray);
nFile* file = fs->NewFileObject();
n_assert(file);
if (!file->Open(filename, "wb"))
{
n_printf("nCurveArray::SaveNax(): failed to open file '%s' for writing!\n", filename);
delete file;
return false;
}
// write header
file->PutInt('NAX0');
file->PutInt(4);
file->PutInt(this->numCurves);
// write curves
int i;
for (i = 0; i < this->numCurves; i++)
{
nAnimCurve& curCurve = this->curveArray[i];
// write curve header
const char* curveName = curCurve.GetName();
int curveNameLen = strlen(curveName);
n_assert(curveName && (curveNameLen > 0));
int startKey = curCurve.GetStartKey();
int numKeys = curCurve.GetNumKeys();
float keysPerSec = curCurve.GetKeysPerSecond();
nAnimCurve::nIpolType ipolType = curCurve.GetIpolType();
nAnimCurve::nRepeatType repType = curCurve.GetRepeatType();
nAnimCurve::nKeyType keyType = curCurve.GetKeyType();
file->PutInt('CHDR');
file->PutInt(2*sizeof(int) + 1*sizeof(float) + 4*sizeof(char) + 1*sizeof(short) + curveNameLen);
file->PutInt(startKey);
file->PutInt(numKeys);
file->PutFloat(keysPerSec);
file->PutChar((char)ipolType);
file->PutChar((char)repType);
file->PutChar((char)keyType);
file->PutChar(0); // padding
file->PutShort((ushort)curveNameLen);
file->Write(curveName, curveNameLen);
// write actual curve data
void* dataPtr = curCurve.GetDataPtr();
int dataSize = curCurve.GetDataSize();
if (nAnimCurve::VANILLA == keyType)
{
file->PutInt('CDTV');
}
else
{
file->PutInt('CDTP');
}
file->PutInt(dataSize);
file->Write(dataPtr, dataSize);
}
// close file and exit
file->Close();
delete file;
return true;
}
//------------------------------------------------------------------------------
/**
Load anim curves from ascii .nanim file.
*/
bool
nAnimCurveArray::LoadAnim(nFileServer2* fs, const char* filename)
{
n_assert(fs);
n_assert(filename);
// open file
nFile* file = fs->NewFileObject();
n_assert(fs);
if (!file->Open(filename, "r"))
{
n_printf("nCurveAnim::Load(): couldn't open file '%s' for reading!\n", filename);
delete file;
return false;
}
// read the file line by line
char line[N_MAXPATH];
int curCurveIndex = -1;
int curKey = 0;
while (file->GetS(line, sizeof(line)))
{
char* keyWord = strtok(line, N_WHITESPACE);
if (keyWord)
{
if (strcmp(keyWord, "curves") == 0)
{
// number of curves in file
char* arg0 = strtok(0, N_WHITESPACE);
if (arg0)
{
int num = atoi(arg0);
this->SetNumCurves(num);
curCurveIndex = -1;
}
else
{
n_error("Broken 'curves' line in file '%s'!\n", filename);
}
}
else if (strcmp(keyWord, "curve") == 0)
{
// begin a new curve
char* arg0 = strtok(0, N_WHITESPACE);
char* arg1 = strtok(0, N_WHITESPACE);
char* arg2 = strtok(0, N_WHITESPACE);
char* arg3 = strtok(0, N_WHITESPACE);
char* arg4 = strtok(0, N_WHITESPACE);
char* arg5 = strtok(0, N_WHITESPACE);
if (arg0 && arg1 && arg2 && arg3 && arg4 && arg5)
{
const char* curveName = arg0;
int startKey = atoi(arg1);
int numKeys = atoi(arg2);
float keysPerSec = (float) atof(arg3);
nAnimCurve::nRepeatType repType = nAnimCurve::String2RepeatType(arg4);
nAnimCurve::nIpolType ipolType = nAnimCurve::String2IpolType(arg5);
nAnimCurve::nKeyType keyType = (nAnimCurve::QUATERNION == ipolType) ? nAnimCurve::PACKED : nAnimCurve::VANILLA;
// if old curve open, close it first
if (curCurveIndex > 0)
{
this->curveArray[curCurveIndex - 1].EndKeys();
}
curCurveIndex++;
curKey = 0;
this->curveArray[curCurveIndex].BeginKeys(keysPerSec, startKey, numKeys, keyType);
this->curveArray[curCurveIndex].SetName(curveName);
this->curveArray[curCurveIndex].SetIpolType(ipolType);
this->curveArray[curCurveIndex].SetRepeatType(repType);
// add a hash node
nHashNode* hashNode = new nHashNode(curveName);
hashNode->SetPtr(&(this->curveArray[curCurveIndex]));
this->hashList.AddTail(hashNode);
}
else
{
n_error("Broken 'curve' line in file '%s'!\n", filename);
}
}
else if (strcmp(keyWord, "key") == 0)
{
// a key
n_assert(curCurveIndex >= 0);
char* arg0 = strtok(0, N_WHITESPACE);
char* arg1 = strtok(0, N_WHITESPACE);
char* arg2 = strtok(0, N_WHITESPACE);
char* arg3 = strtok(0, N_WHITESPACE);
if (arg0 && arg1 && arg2 && arg3)
{
vector4 v((float)atof(arg0), (float)atof(arg1), (float)atof(arg2), (float)atof(arg3));
this->curveArray[curCurveIndex].SetKey(curKey++, v);
}
else
{
n_error("Broken 'key' line in file '%s'!\n", filename);
}
}
}
}
// finish the final curve
if (curCurveIndex > 0)
{
this->curveArray[curCurveIndex - 1].EndKeys();
}
// close file and return
file->Close();
delete file;
return true;
}
//------------------------------------------------------------------------------
/**
Load anim curves from binary .nax file.
*/
bool
nAnimCurveArray::LoadNax(nFileServer2* fs, const char* filename)
{
n_assert(fs);
n_assert(filename);
// open file
nFile* file = fs->NewFileObject();
n_assert(fs);
if (!file->Open(filename, "rb"))
{
n_printf("nCurveAnim::LoadNax(): couldn't open file '%s' for reading!\n", filename);
delete file;
return false;
}
int magic;
int blockLen;
int numCurves;
// read header
file->GetInt(magic);
file->GetInt(blockLen);
file->GetInt(numCurves);
if (magic != 'NAX0')
{
n_printf("nCurveAnim::LoadNax(): not a nax file: '%s'!\n", filename);
file->Close();
delete file;
return false;
}
this->SetNumCurves(numCurves);
// for each curve...
int i;
for (i = 0; i < numCurves; i++)
{
int startKey;
int numKeys;
float keysPerSecond;
char ipolType;
char repType;
char keyType;
char pad0;
short curveNameLen;
char curveName[N_MAXPATH];
// read curve header
file->GetInt(magic);
n_assert(magic == 'CHDR');
file->GetInt(blockLen);
file->GetInt(startKey);
file->GetInt(numKeys);
file->GetFloat(keysPerSecond);
file->GetChar(ipolType);
file->GetChar(repType);
file->GetChar(keyType);
file->GetChar(pad0);
file->GetShort(curveNameLen);
n_assert((curveNameLen+1) < sizeof(curveName));
file->Read(curveName, curveNameLen);
curveName[curveNameLen] = 0;
// finish previous curve
if (i > 0)
{
this->curveArray[i - 1].EndKeys();
}
this->curveArray[i].BeginKeys(keysPerSecond, startKey, numKeys, (nAnimCurve::nKeyType) keyType);
this->curveArray[i].SetName(curveName);
this->curveArray[i].SetIpolType((nAnimCurve::nIpolType) ipolType);
this->curveArray[i].SetRepeatType((nAnimCurve::nRepeatType) repType);
// add a hash node for fast find-by-name
nHashNode* hashNode = new nHashNode(curveName);
hashNode->SetPtr(&(this->curveArray[i]));
this->hashList.AddTail(hashNode);
// read curve data
int bytesRead;
int dataSize = this->curveArray[i].GetDataSize();
void* dataPtr = this->curveArray[i].GetDataPtr();
file->GetInt(magic);
n_assert(((keyType == nAnimCurve::VANILLA) && (magic == 'CDTV')) ||
((keyType == nAnimCurve::PACKED) && (magic == 'CDTP')));
file->GetInt(blockLen);
n_assert(dataSize == blockLen);
bytesRead = file->Read(dataPtr, dataSize);
n_assert(dataSize == bytesRead);
}
// finish the final curve
if (i > 0)
{
this->curveArray[i - 1].EndKeys();
}
// close file and return
file->Close();
delete file;
return true;
}
//------------------------------------------------------------------------------
/**
*/
void
nAnimCurveArray::Clear()
{
// clear hashlist
nHashNode* hashNode;
while ((hashNode = this->hashList.RemHead()))
{
delete hashNode;
}
// clear curve array
if (this->curveArray)
{
delete[] this->curveArray;
this->curveArray = 0;
}
}
//------------------------------------------------------------------------------
/**
*/
void
nAnimCurveArray::SetNumCurves(int num)
{
n_assert(num > 0);
this->Clear();
this->curveArray = new nAnimCurve[num];
this->numCurves = num;
}
//------------------------------------------------------------------------------
/**
*/
int
nAnimCurveArray::GetNumCurves() const
{
return this->numCurves;
}
//------------------------------------------------------------------------------
/**
*/
nAnimCurve&
nAnimCurveArray::GetCurve(int index) const
{
n_assert((index >= 0) && (index < this->numCurves));
n_assert(this->curveArray);
return this->curveArray[index];
}
//------------------------------------------------------------------------------
/**
*/
nAnimCurve*
nAnimCurveArray::FindCurveByName(const char* name) const
{
nHashNode* hashNode = this->hashList.Find(name);
if (hashNode)
{
return (nAnimCurve*) hashNode->GetPtr();
}
else
{
return 0;
}
}
//------------------------------------------------------------------------------
| [
"plushe@411252de-2431-11de-b186-ef1da62b6547"
] | [
[
[
1,
468
]
]
] |
d04c92af264745e98d8a19dccf38650ba6f16b73 | 8f5d0d23e857e58ad88494806bc60c5c6e13f33d | /Core/cApplication.cpp | 239a3a6b32f5dbbd6218cbaca25fe04dfc184fe5 | [] | no_license | markglenn/projectlife | edb14754118ec7b0f7d83bd4c92b2e13070dca4f | a6fd3502f2c2713a8a1a919659c775db5309f366 | refs/heads/master | 2021-01-01T15:31:30.087632 | 2011-01-30T16:03:41 | 2011-01-30T16:03:41 | 1,704,290 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 611 | cpp | #include "capplication.h"
// Include Paul Nettle's memory manager
#include "../Memory/mmgr.h"
/////////////////////////////////////////////////////////////////////////////////////
cApplication::cApplication(void)
: m_width(800), m_height(600), m_bpp(32), m_fullscreen(false),
m_hWnd(0)
/////////////////////////////////////////////////////////////////////////////////////
{
}
/////////////////////////////////////////////////////////////////////////////////////
cApplication::~cApplication(void)
/////////////////////////////////////////////////////////////////////////////////////
{
}
| [
"[email protected]"
] | [
[
[
1,
18
]
]
] |
bfe915dbdb712f2d8e82d80e4bf58d54e6e13513 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/test/test/prg_exec_fail1.cpp | 50ad191581c97b69ccccdedb92b05975f221583d | [
"LicenseRef-scancode-unknown-license-reference",
"BSL-1.0"
] | 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,466 | cpp | // (C) Copyright Gennadiy Rozental 2001-2006.
// (C) Copyright Beman Dawes 2001.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/test for the library home page.
//
// File : $RCSfile: prg_exec_fail1.cpp,v $
//
// Version : $Revision: 1.16 $
//
// Description : tests an ability of Program Execution Monitor to catch
// uncatched exceptions. Should fail during run.
// ***************************************************************************
#ifdef __MWERKS__
// Metrowerks doesn't build knowledge of what runtime libraries to link with
// into their compiler. Instead they depend on pragmas in their standard
// library headers. That creates the odd situation that certain programs
// won't link unless at least one standard header is included. Note that
// this problem is highly dependent on enviroment variables and command
// line options, so just because the problem doesn't show up on one
// system doesn't mean it has been fixed. Remove this workaround only
// when told by Metrowerks that it is safe to do so.
#include <cstddef> //Metrowerks linker needs at least one standard library
#endif
#include <boost/test/included/prg_exec_monitor.hpp>
int
cpp_main( int argc, char *[] ) // note the name
{
if( argc > 0 ) // to prevent the unreachable return warning
throw "Test error by throwing C-style string exception";
return 0;
}
//____________________________________________________________________________//
// ***************************************************************************
// Revision History :
//
// $Log: prg_exec_fail1.cpp,v $
// Revision 1.16 2006/03/19 11:49:04 rogeeff
// *** empty log message ***
//
// Revision 1.15 2005/12/14 06:01:02 rogeeff
// *** empty log message ***
//
// Revision 1.14 2005/05/11 05:07:57 rogeeff
// licence update
//
// Revision 1.13 2005/05/21 06:26:10 rogeeff
// licence update
//
// Revision 1.12 2005/01/07 22:06:44 beman_dawes
// Fix Metrowerks link failures for some compiler configurations. See comment in code. (fix from Ed Swartz of Metrowerks)
//
// Revision 1.11 2003/12/01 00:42:38 rogeeff
// prerelease cleaning
//
// ***************************************************************************
// EOF
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
] | [
[
[
1,
67
]
]
] |
292ad585942587135515a0167c3c14bbf60c4eaf | 282057a05d0cbf9a0fe87457229f966a2ecd3550 | /EIBStdLib/src/xml/tokenlist.cpp | d233ffe6975942ef0bebda29394812de1e127a4d | [] | no_license | radtek/eibsuite | 0d1b1c826f16fc7ccfd74d5e82a6f6bf18892dcd | 4504fcf4fa8c7df529177b3460d469b5770abf7a | refs/heads/master | 2021-05-29T08:34:08.764000 | 2011-12-06T20:42:06 | 2011-12-06T20:42:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,404 | cpp | /*
www.sourceforge.net/projects/tinyxpath
Copyright (c) 2002-2004 Yves Berquin ([email protected])
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.
*/
/**
\file tokenlist.cpp
\author Yves Berquin
XPath Syntax analyzer for TinyXPath project : token list handling
*/
#include "xml/tokenlist.h"
namespace TinyXPath
{
/// Decodes an XPath expression, further manipulating a token list
/// \n On input, we have a list of basic lexical tokens. We only merge here the
/// multiple tokens : like '::' or '!='. We also delete whitespace tokens
void token_list::v_tokenize_expression ()
{
v_set_current_top ();
while (ltp_get (1))
{
switch (ltp_get (0) -> lex_get_value ())
{
case lex_colon :
if (ltp_get (1) -> lex_get_value () == lex_colon)
{
v_replace_current (lex_2_colon, "::");
v_delete_next ();
}
else
v_inc_current (1);
break;
case lex_slash :
if (ltp_get (1) -> lex_get_value () == lex_slash)
{
v_replace_current (lex_2_slash, "//");
v_delete_next ();
}
else
v_inc_current (1);
break;
case lex_exclam :
if (ltp_get (1) -> lex_get_value () == lex_equal)
{
v_replace_current (lex_not_equal, "!=");
v_delete_next ();
}
else
v_inc_current (1);
break;
case lex_lt :
if (ltp_get (1) -> lex_get_value () == lex_equal)
{
v_replace_current (lex_lt_equal, "<=");
v_delete_next ();
}
else
v_inc_current (1);
break;
case lex_gt :
if (ltp_get (1) -> lex_get_value () == lex_equal)
{
v_replace_current (lex_gt_equal, ">=");
v_delete_next ();
}
else
v_inc_current (1);
break;
case lex_dot :
if (ltp_get (1) -> lex_get_value () == lex_dot)
{
v_replace_current (lex_2_dot, "..");
v_delete_next ();
}
else
v_inc_current (1);
break;
case lex_space :
v_delete_current ();
break;
default :
v_inc_current (1);
break;
} // switch
} // while
}
}
| [
"[email protected]"
] | [
[
[
1,
110
]
]
] |
00dfb20e8d1da16da162613cf373242672f4e976 | 138a353006eb1376668037fcdfbafc05450aa413 | /source/ogre/OgreNewt/boost/mpl/vector/aux_/O1_size.hpp | e0ab59af1dc216b156dbeb3e977cacb7b0092ae7 | [] | 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 | 1,391 | hpp |
#ifndef BOOST_MPL_VECTOR_AUX_O1_SIZE_HPP_INCLUDED
#define BOOST_MPL_VECTOR_AUX_O1_SIZE_HPP_INCLUDED
// Copyright Aleksey Gurtovoy 2000-2004
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Source: /cvsroot/ogre/ogreaddons/ogrenewt/OgreNewt_Main/inc/boost/mpl/vector/aux_/O1_size.hpp,v $
// $Date: 2006/04/17 23:49:48 $
// $Revision: 1.1 $
#include <boost/mpl/O1_size_fwd.hpp>
#include <boost/mpl/minus.hpp>
#include <boost/mpl/long.hpp>
#include <boost/mpl/vector/aux_/tag.hpp>
#include <boost/mpl/aux_/config/typeof.hpp>
#include <boost/mpl/aux_/config/ctps.hpp>
namespace boost { namespace mpl {
#if defined(BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES)
template<>
struct O1_size_impl< aux::vector_tag >
{
template< typename Vector > struct apply
: Vector::size
{
};
};
#else
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
template< long N >
struct O1_size_impl< aux::vector_tag<N> >
{
template< typename Vector > struct apply
: mpl::long_<N>
{
};
};
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#endif // BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES
}}
#endif // BOOST_MPL_VECTOR_AUX_O1_SIZE_HPP_INCLUDED
| [
"Sonicma7@0822fb10-d3c0-11de-a505-35228575a32e"
] | [
[
[
1,
56
]
]
] |
7d0d9e2df57acde64e6474831f525358c2f6b1a2 | 62207628c4869e289975cc56be76339a31525c5d | /Source/Star Foxes Skeleton/Networking/MsgTranslator.h | b6e73605f0e178272687bba6f158cb1f5d5aba10 | [] | no_license | dieno/star-foxes | f596e5c6b548fa5bb4f5d716b73df6285b2ce10e | eb6a12c827167fd2b7dd63ce19a1f15d7b7763f8 | refs/heads/master | 2021-01-01T16:39:47.800555 | 2011-05-29T03:51:35 | 2011-05-29T03:51:35 | 32,129,303 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,713 | h | //#pragma once
#include "../directXClass.h"
//#include <std::string.h>
//#include <Windows.h>
//using namespace std;
#ifndef MSGTRANSLATOR
#define MSGTRANSLATOR
enum EMSG_TYPE
{
MSG_CMD = '0',
MSG_MSC = '1',
MSG_TXT = '2'
};
enum ECOMMAND
{
CMD_NONE = '0',
MV_LEFT = VK_LEFT,
MV_RITE = VK_RIGHT,
MV_UP = VK_UP,
MV_DOWN = VK_DOWN,
//MISC
MSC_SETID ='i', // set client id
MSC_INIFRAME = 's', // sync frames
MSC_STARTGAME = 't', // sync frames7
MSC_MULTI = 'm'
//TEXT
};
/*
enum MISC
{
MSC_SETID ='i'
};
*/
class Msg
{
private:
int _ixType;
int _ixCmd;
int _ixBody;
int _szType;
int _szCmd;
int _szBody;
char* _msg;
int body_size;
public:
char* GetMsg();
void SetMsg(char* msg);
int CmpType(char* msg);
int CmpID(char* msg);
int CmpBody(char* msg);
char GetType();
char GetCmd();
char GetID();
ECOMMAND GetCommand();
char GetBody();
Msg(char* msg, int sztype, int szid, int szmsg);
Msg(int sztype, int szid, int szmsg);
void Initialize(char* msg, int sztype, int szid, int szmsg);
~Msg(void);
Msg(void);
};
class MsgTranslator
{
private:
static const int _szType = 1;
static const int _szCmd = 1;
static const int _szMsg = -1;
Msg* _msg;
public:
void SetMsg(char* msg);
Msg* GetMsg();
EMSG_TYPE TranslateMsg(char* msg);
int CreateMsg(char* msg, EMSG_TYPE type, char* id, char *body);
int CreateMsg(char* msg, EMSG_TYPE type, ECOMMAND cmd, char *body);
int CreateMsgMsc(char* msg, ECOMMAND cmd, char* id, char *body);
MsgTranslator(void);
~MsgTranslator(void);
};
#endif | [
"[email protected]@2f9817a0-ed27-d5fb-3aa2-4a2bb642cc6a",
"[email protected]@2f9817a0-ed27-d5fb-3aa2-4a2bb642cc6a"
] | [
[
[
1,
2
],
[
4,
86
]
],
[
[
3,
3
]
]
] |
c62beddd1cfbf927fbb0ae4f16e5dc9cdadb34c8 | a0d4f557ddaf4351957e310478e183dac45d77a1 | /src/Utils/TextureMan.h | 1435cd8673548abd0dd6add01d8738560fcf7183 | [] | no_license | houpcz/Houp-s-level-editor | 1f6216e8ad8da393e1ee151e36fc37246279bfed | c762c9f5ed064ba893bf34887293a73dd35a06f8 | refs/heads/master | 2016-09-11T11:03:34.560524 | 2011-08-09T11:37:49 | 2011-08-09T11:37:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 926 | h | #ifndef _TEXTUREMAN_H_
#define _TEXTUREMAN_H_
#include <Gl\Gl.h>
#include <string>
#include <map>
#include <vector>
#include "TextureLoader.h"
using namespace std;
class C_TextureMan
{
private :
map<string, C_TextureLoader *> loader; /// <prefix, loader>, ex. <"tga", C_TextureTGA>
map<string, S_Texture *> texture; /// <src path, texture>
static C_TextureMan * inst; /// singleton pattern
C_TextureMan();
~C_TextureMan();
bool LoadTexture(S_Texture * text, const char * src); /// Loads texture from disk to S_Texture
void MakeTexture(S_Texture * texture); /// Makes OpenGl texture from S_Texture
public :
static C_TextureMan * Inst(); /// returns pointer to singleton
S_Texture * GetTexture(string src);
void ClearTextures();
};
#endif
| [
"[email protected]"
] | [
[
[
1,
32
]
]
] |
8ec1e2993f28659358d20893a3e562d91312161c | af2233c4d6a1f94106134a73408fb234b6ae8436 | /RenderUtility/GLTexture.h | bf1d8ee3660f1a84942f98497c03f8a14bf07d3f | [] | no_license | liwenqiang1990/gpu-streaming-benchmark | 33b01cd5c4964466a4be2de5a3a2f67c2389eb77 | 4339b8cc6d00820e20669488a0406d186d2ffc15 | refs/heads/master | 2020-06-01T11:07:42.246460 | 2011-06-20T21:39:02 | 2011-06-20T21:39:02 | 34,671,006 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,937 | h | #ifndef _GL_TEXTURE_H
#define _GL_TEXTURE_H
#define GLEW_STATIC
#include <GL/glew.h>
#include <string>
class GLBufferObject;
#define MAX_BUFFERS 2
//TODO seperate texture and texture loading functions
class GLTexture
{
public:
//GL texture element byte size can be different from the input element byte size
//GLTexture();
GLTexture(int width, int height=0, int depth=0, GLenum elementFormat = GL_RGBA,
GLint internalFormat=GL_RGBA8, GLenum filterType=GL_LINEAR, GLenum borderType=GL_CLAMP_TO_EDGE, GLenum elementType=GL_UNSIGNED_BYTE);
~GLTexture();
void InitTexture(int width, int height=0, int depth=0, GLenum elementFormat = GL_RGBA,
GLint internalFormat=GL_RGBA8, GLenum filterType=GL_LINEAR, GLenum borderType=GL_CLAMP_TO_EDGE);
//accessors
//setxx
GLuint GetTextureID();
GLuint GetHeight();
GLuint GetWidth();
GLuint GetDepth();
GLenum GetTextureType();
//setxx
void SetFilterType(GLenum);
//bind unbind
void Bind();
//read to memory from File
bool ReadTextureFromFile(const char* filename, GLenum elementType, int channelNum=1); //called when GL has been initalized
//
void LoadToGPU(void* data, GLenum elementType); //glTexImage1D/2D/3D and then free the CPU memory
void LoadToGPU();
//require twice the space during the loading time
void LoadToGPUWithGLBuffer();
void LoadToGPUWithGLBuffer(void* data, GLenum elementType);
//upload to GPU a small chunk at a time using subImage void the large memory usage
void LoadToGPUWithGLBufferSmallChunk();
//void LoadToGPUkeepCPU(); //keep CPU memory unreleased
//subTexture To GPU
void SubloadToGPU(int offsetX, int offsetY, int offsetZ, int sizeX, int sizeY, int sizeZ, void* data, GLenum elementType);
void preAllocateGLPBO(GLsizei bufferSize, GLenum usage=GL_STREAM_DRAW); //for texture uploading acceleration
void PreAllocateMultiGLPBO(GLsizei bufferSize, GLenum usage=GL_STREAM_DRAW);
void subloadToGPUWithGLBuffer(int offsetX, int offsetY, int offsetZ, int sizeX, int sizeY, int sizeZ, void* data );
void SubloadToGPUWithMultiGLBuffer(int offsetX, int offsetY, int offsetZ, int sizeX, int sizeY, int sizeZ, void* data );
/////////texture buffer
protected:
//failed when return NULL pointer
void* loadRawFile(int, int*);
void* loadPPMFile();
protected:
std::string _fileName;
std::string _fileType;
void* _data;
int _dataSize;
GLenum _filterType;
GLenum _borderType;
GLenum _textureType;
GLenum _elementFormat;
unsigned int _internalFormat; //1 2 4 8
GLenum _elementType; //element type in the CPU side
unsigned int _elementByteSize;
GLuint _tex; //texture object ID
GLuint _dim[3]; // width, height, depth;
GLBufferObject *_GLbuffer;
GLBufferObject *_GLMultibuffer[MAX_BUFFERS];
bool _isBufferAllocated;
bool _isMultiBufferAllocated;
int _currentBufferIndex;
};
#endif
| [
"[email protected]@46a6917a-aa20-85b6-2959-6e77123ad00a"
] | [
[
[
1,
96
]
]
] |
4f104cf7883b42a8de1733826f7b13d60ce984f9 | 94c1c7459eb5b2826e81ad2750019939f334afc8 | /source/CTaiKlineDlgHistorySelect.cpp | 33f8dbebea654fd391d7a7f6d13f36e586e9fa57 | [] | 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 | 5,619 | cpp | // CTaiKlineDlgHistorySelect.cpp : implementation file
//
#include "stdafx.h"
#include "CTaiShanApp.h"
#include "CTaiKlineDlgHistorySelect.h"
#include "CTaiKlineFileHS.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTaiKlineDlgHistorySelect dialog
CTaiKlineDlgHistorySelect::CTaiKlineDlgHistorySelect(CWnd* pParent /*=NULL*/)
: CDialog(CTaiKlineDlgHistorySelect::IDD, pParent)
{
//{{AFX_DATA_INIT(CTaiKlineDlgHistorySelect)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_fileName = _T("");
}
void CTaiKlineDlgHistorySelect::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTaiKlineDlgHistorySelect)
DDX_Control(pDX, IDOK, m_ok);
DDX_Control(pDX, IDCANCEL, m_cancel);
DDX_Control(pDX, IDC_LIST1, m_fileNameList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTaiKlineDlgHistorySelect, CDialog)
//{{AFX_MSG_MAP(CTaiKlineDlgHistorySelect)
ON_BN_CLICKED(IDOK, OnOk)
ON_WM_DESTROY()
ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTaiKlineDlgHistorySelect message handlers
BOOL CTaiKlineDlgHistorySelect::OnInitDialog()
{
CDialog::OnInitDialog();
CStringArray sArray;
GetFileNameArray(sArray);
int n = sArray.GetSize ();
for(int i=0;i<n;i++)
{
m_fileNameList.InsertItem (i,sArray[n-i-1]);
}
if(sArray.GetSize ()>0)
m_fileNameList.SetItemState( 0, LVIS_SELECTED, LVIS_SELECTED );
;
return TRUE;
}
void CTaiKlineDlgHistorySelect::OnOk()
{
m_fileName = "";
POSITION pos = m_fileNameList.GetFirstSelectedItemPosition();
if (pos == NULL)
return;
else
{
{
int nItem = m_fileNameList.GetNextSelectedItem(pos);
m_fileName = m_fileNameList.GetItemText(nItem,0);
TRACE1("Item %d was selected!\n", nItem);
}
}
CDialog::OnOK();
}
void CTaiKlineDlgHistorySelect::GetFileNameArray(CStringArray &sArry)
{
CString sPath = "data\\historysh\\";
CFileFind finder;
int n = 0;
BOOL bWorking = finder.FindFile(sPath+"*.hst");
while(bWorking)
{
bWorking = finder.FindNextFile();
CString filename = finder.GetFileTitle();
int nSize = sArry.GetSize ();
for(int j=0;j<nSize;j++)
{
if(filename <sArry[j])
{
sArry.InsertAt (j,filename);
break;
}
if(j==nSize-1)
sArry.Add (filename);
}
if(nSize == 0)
sArry.Add (filename);
n++;
}
sPath = "data\\historysz\\";
n = 0;
bWorking = finder.FindFile(sPath+"*.hst");
while(bWorking)
{
bWorking = finder.FindNextFile();
CString filename = finder.GetFileTitle();
int nSize = sArry.GetSize ();
BOOL bf;
bf=false;
for(int j=0;j<nSize;j++)
{
if(filename ==sArry[j])
{
bf=true;
break;
}
else
{
bf=false;
continue;
}
if(j==nSize-1)
sArry.Add (filename);
}
if((nSize == 0)||(!bf))
sArry.Add (filename);
n++;
}
}
void CTaiKlineDlgHistorySelect::OnDestroy()
{
CDialog::OnDestroy();
}
CTaiKlineHistorySelect::CTaiKlineHistorySelect()
{
}
CTaiKlineHistorySelect::~CTaiKlineHistorySelect()
{
CloseAll();
}
bool CTaiKlineHistorySelect::OpenAll()
{
ASSERT(FALSE);
return false;
CloseAll();
CTime tm = CTime::GetCurrentTime ();
CString sTm = tm.Format ("%Y%m%d");
bool bToday = false;
for(int i=0;i<m_fileNameArray.GetSize ();i++)
{
CString sPathSh;
CString sPathSz;
CString filename ;
CString sTitle = m_fileNameArray[i];
CString title = sTitle+".hst";
sPathSh = "data\\historysh\\";
sPathSz = "data\\historysz\\";
CTaiKlineFileHS* pFile;
if(m_fileNameArray[i]>=sTm)
{
if(bToday == false)
{
sPathSh = "data\\historysh\\";
sPathSz = "data\\historysz\\";
title = "buysell.dat";
sTitle = "buysell";
bToday = true;
}
else
continue;
}
pFile = new CTaiKlineFileHS(true);
filename =sPathSh + title;
if(!pFile->Open (filename,0))
{
delete pFile;
continue;
}
m_fileHsShArray[sTitle] = (pFile);
pFile = new CTaiKlineFileHS(false);
filename =sPathSz + title;
if(!pFile->Open (filename,0))
{
delete pFile;
continue;
}
m_fileHsSzArray[sTitle] = (pFile);
}
return true;
}
void CTaiKlineHistorySelect::CloseAll()
{
POSITION pos=m_fileHsShArray.GetStartPosition ();
CString s;
CTaiKlineFileHS* pHs;
while(pos)
{
m_fileHsShArray.GetNextAssoc (pos,s,pHs);
if(pHs !=NULL) delete pHs;
}
m_fileHsShArray.RemoveAll();
pos=m_fileHsSzArray.GetStartPosition ();
while(pos)
{
m_fileHsSzArray.GetNextAssoc (pos,s,pHs);
if(pHs !=NULL) delete pHs;
}
m_fileHsSzArray.RemoveAll();
}
int CTaiKlineHistorySelect::FilterFileName(CTime &begin, CTime &end)
{
int n=0;
m_fileNameArray.RemoveAll ();
CTaiKlineDlgHistorySelect::GetFileNameArray(this->m_fileNameArray );
CString sBegin = begin.Format ("%Y%m%d");
CString sEnd = end.Format ("%Y%m%d");
for(int i=0;i<m_fileNameArray.GetSize ();i++)
{
if(m_fileNameArray[i]<sBegin||m_fileNameArray[i]>sEnd)
{
m_fileNameArray.RemoveAt (i);
i--;
}
}
return n;
}
void CTaiKlineDlgHistorySelect::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
{
OnOk() ;
*pResult = 0;
}
| [
"[email protected]"
] | [
[
[
1,
276
]
]
] |
e93ffdc326231e85cc6e65521415af13cce78fa7 | 23939b88feae85abfd72601120a54b637661c164 | /ComputeOptions.cpp | dc4ef04c04495bb595a7311affd04d4c405ea42f | [] | no_license | klanestro/textCalc | e9feae14be270cd22de347e2e4b764fadfb0709c | 2634f92702aaf7d9a61187b2a34b998d92780672 | refs/heads/master | 2021-01-19T13:50:28.692058 | 2010-01-21T09:29:53 | 2010-01-21T09:29:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,211 | cpp | // ComputeOptions.cpp : implementation file
//
#include "stdafx.h"
#include "sample.h"
#include "ComputeOptions.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// ComputeOptions dialog
ComputeOptions::ComputeOptions(CWnd* pParent /*=NULL*/)
: CDialog(ComputeOptions::IDD, pParent)
{
//{{AFX_DATA_INIT(ComputeOptions)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_checkspace=TRUE;
m_checkuser=FALSE;
m_userstr=",;(){}<>";
m_RInextline=TRUE;
}
void ComputeOptions::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(ComputeOptions)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(ComputeOptions, CDialog)
//{{AFX_MSG_MAP(ComputeOptions)
ON_BN_CLICKED(IDC_CHECK1, OnCheck1)
ON_BN_CLICKED(IDC_CHECK2, OnCheck2)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// ComputeOptions message handlers
void ComputeOptions::OnCheck1()
{
// TODO: Add your control notification handler code here
m_checkspace=((CButton *) GetDlgItem(IDC_CHECK1))->GetCheck();
}
void ComputeOptions::OnCheck2()
{
// TODO: Add your control notification handler code here
m_checkuser=((CButton *) GetDlgItem(IDC_CHECK2))->GetCheck();
RefreshDialog();
}
void ComputeOptions::OnRadio1()
{
// TODO: Add your control notification handler code here
((CButton *) GetDlgItem(IDC_RADIO2))->SetCheck(0);
m_RInextline=TRUE;
}
void ComputeOptions::OnRadio2()
{
// TODO: Add your control notification handler code here
((CButton *) GetDlgItem(IDC_RADIO1))->SetCheck(0);
m_RInextline=FALSE;
}
void ComputeOptions::OnOK()
{
// TODO: Add extra validation here
((CEdit *) GetDlgItem(IDC_EDIT1))->GetWindowText(m_userstr);
CDialog::OnOK();
}
BOOL ComputeOptions::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
RefreshDialog();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void ComputeOptions::RefreshDialog()
{
if (m_checkspace) {
((CButton *) GetDlgItem(IDC_CHECK1))->SetCheck(1);
}
else {
((CButton *) GetDlgItem(IDC_CHECK1))->SetCheck(0);
}
if (m_checkuser) {
((CButton *) GetDlgItem(IDC_CHECK2))->SetCheck(1);
((CEdit *) GetDlgItem(IDC_EDIT1))->EnableWindow(TRUE);
}
else {
((CButton *) GetDlgItem(IDC_CHECK2))->SetCheck(0);
((CEdit *) GetDlgItem(IDC_EDIT1))->EnableWindow(FALSE);
}
if (m_RInextline) {
((CButton *) GetDlgItem(IDC_RADIO1))->SetCheck(1);
((CButton *) GetDlgItem(IDC_RADIO2))->SetCheck(0);
}
else {
((CButton *) GetDlgItem(IDC_RADIO1))->SetCheck(0);
((CButton *) GetDlgItem(IDC_RADIO2))->SetCheck(1);
}
((CEdit *) GetDlgItem(IDC_EDIT1))->SetWindowText(m_userstr);
}
| [
"[email protected]"
] | [
[
[
1,
139
]
]
] |
dbcf8de30b76ae1c85fa4d0ebaa8792d6338a4da | bc4919e48aa47e9f8866dcfc368a14e8bbabbfe2 | /Open GL Basic Engine/source/glutFramework/glutFramework/RVB_Map.h | ef2da6f48069aab46114c1f9dc6a2b3e8db537a5 | [] | no_license | CorwinJV/rvbgame | 0f2723ed3a4c1a368fc3bac69052091d2d87de77 | a4fc13ed95bd3e5a03e3c6ecff633fe37718314b | refs/heads/master | 2021-01-01T06:49:33.445550 | 2009-11-03T23:14:39 | 2009-11-03T23:14:39 | 32,131,378 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,375 | h | #ifndef RVB_MAP_H
#define RVB_MAP_H
#include "RVB_MapTile.h"
#include "RVB_Entity.h"
#include "RVB_Bullet.h"
#include <vector>
using namespace std;
//class RVB_Bullet;
enum mapDirection { UP, DOWN, LEFT, RIGHT };
class RVB_Map
{
public: // Boilerplate Class Stuff
RVB_Map();
RVB_Map(int mapSizeX, int mapSizeY);
~RVB_Map();
void pan(enum mapDirection);
void zoomIn();
void zoomOut();
RVB_Entity* cycleEntityDown(RVB_Entity* selectedEntity);
RVB_Entity* cycleEntityUp(RVB_Entity* selectedEntity);
void drawFog(int tileWidth, double scaleFactor, double mapOffsetX, double mapOffsetY);
void drawEntities(int tileWidth, double scaleFactor, int mapOffsetX, int mapOffsetY);
void helpRequested(RVB_Entity* entityChasing, entityType team);
private: // Private Data Members
vector<vector<RVB_MapTile*>> mBoard; // the vector of tiles that comprise the board
vector<vector<RVB_MapTile*>> redKnowledgeMap; // red's knowledge of the board
vector<vector<RVB_MapTile*>> blueKnowledgeMap; // blue's knowledge of the board
vector<vector<double>> redFog;
vector<vector<double>> blueFog;
int uberFactor;
double scaleFactor; // the scale you are viewing the map at
int panRate; // the rate at which you can scroll across the map
int mapOffsetX; // based in pixels, off current X, calculated off of scale
int mapOffsetY; // based in pixles, off current Y, calculated off of scale
double cameraCenterX; // the x position of the camera to stay centered on the map
double cameraCenterY; // the y position of the camera to stay centered on the map
int mapWidth; // the width of the map in tiles
int mapHeight; // the height of the map in tiles
double currentTileWidth; // depending on zoom, this is the current width of the tile (height as well)
double currentTileHeight; // depending on zoom, this is the current height of the tile
double overallHeight; // used to store the current height of the entire board
double overallWidth; // used to store the current width of the entire board
static const int screenHeight = 768; // fixed screen height in pixels
static const int screenWidth = 1024; // fixed screen width in pixles
static const int tileWidth = 128; // fixed width of each tile (since square it's height as well)
static const int tileHeight = tileWidth;// fixed height of each tile ^^^^
vector<RVB_Entity*> objectList; // the vector of all entities on the board
vector<RVB_Bullet*> bulletList; // the vector containing any and all bullets currently on the screen
float mRotation; // degree of rotation
public: // Public Interface
// drawing functions for the map position
void center();
void recalcBoard();
// setters and getters
double getScale();
int getOffsetX();
int getOffsetY();
int getBoardWidth();
int getBoardHeight();
int getTileWidth();
void setScale(double newS);
void setOffsetX(int newX);
void setOffsetY(int newY);
void setOffset(int newX, int newY);
void getGridCoord(int x, int y, int *returnGridX, int *returnGridY);
void clearEntityTargets();
void setAllEntityTargets(int mouseX, int mouseY);
RVB_Entity *getSelectableEntity(int mouseX, int mouseY);
RVB_Entity *getSelectableEntityAtGridCoord(int gridX, int gridY);
bool isThereAnEntityAt(int xPos, int yPos);
void Update();
void Draw();
void drawText();
void drawBullets();
void addEntity(entityType newType, int xPos, int yPos, entityDirection newDirection);
void toggleObstacle(int xPos, int yPos);
TileType getTileTypeAt(int xPos, int yPos);
bool isTileValidMove(int xPos, int yPos);
bool areThereAnyEnemiesAt(int xPos, int yPos, entityType whatColorIAm);
bool areThereAnyFriendsAt(int xPos, int yPos, entityType whatColorIAm);
void updateBullets();
void makeBullet(RVB_Bullet* newBullet);
bool isThereAnObstacleAt(double x, double y);
void didBulletHitSomething();
void setToAttackOptimal(RVB_Entity* setThisOne);
void drawKnowledgeMap(int tileWidth, double scaleFactor, double mapOffsetX, double mapOffsetY);
//void isThereAnEnemyUnitAt(double someX, double someY);
vector<vector<RVB_MapTile*>> *getKnowledgeMap(entityType someType);
void updateFog(entityType newType);
void loadMapFromFile(std::string filename);
};
#endif // RVB_MAP_H | [
"corwin.j@5457d560-9b84-11de-b17c-2fd642447241",
"DavidBMoss@5457d560-9b84-11de-b17c-2fd642447241",
"davidbmoss@5457d560-9b84-11de-b17c-2fd642447241"
] | [
[
[
1,
9
],
[
12,
25
],
[
30,
31
],
[
38,
38
],
[
40,
40
],
[
43,
44
],
[
47,
50
],
[
56,
56
],
[
58,
84
],
[
86,
89
],
[
91,
95
],
[
98,
99
],
[
108,
111
]
],
[
[
10,
11
],
[
27,
27
],
[
29,
29
],
[
32,
34
],
[
39,
39
],
[
41,
42
],
[
45,
46
],
[
51,
55
],
[
57,
57
],
[
85,
85
],
[
90,
90
],
[
96,
97
],
[
100,
103
],
[
107,
107
]
],
[
[
26,
26
],
[
28,
28
],
[
35,
37
],
[
104,
106
]
]
] |
d52320776d2a5a09ff8c04f0cf2c940cf93e8774 | ee8761abf9db9f797753326be3640ddd1f57206c | /gKit/App.cpp | 5786aa1c9268592d88706ae2671938730de9e611 | [] | no_license | Mefteg/3-sub-ways | fba4d0330943f7d9d2501d01e221c7d46cac7883 | 49218cf4ef7413036bdcdee16d5cd52f4896d4a2 | refs/heads/master | 2020-05-18T12:52:50.357430 | 2011-10-29T15:15:58 | 2011-10-29T15:15:58 | 32,360,588 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,137 | cpp |
#include <cassert>
#include <cstdio>
#include "GL/GLPlatform.h"
#include "App.h"
#include "ProfilerClock.h"
namespace gk {
App::App( )
:
m_key_state(NULL), m_key_map(NULL),
m_width(0), m_height(0),
m_stop(0)
{
if(createWindow(1024, 768) < 0)
Close();
}
App::App( const int w, const int h )
:
m_key_state(NULL), m_key_map(NULL),
m_width(0), m_height(0),
m_stop(0)
{
if(createWindow(w, h) < 0)
Close();
}
App::~App( )
{
delete [] m_key_state;
delete [] m_key_map;
}
int App::resizeWindow( const int w, const int h, const unsigned int flags )
{
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
// redimensionnement la fenetre
int width= (w != 0) ? w : m_width;
int height= (h != 0) ? h : m_height;
unsigned int mode_flags= SDL_OPENGL | flags;
if(flags == 0)
mode_flags|= SDL_RESIZABLE;
if((flags & SDL_FULLSCREEN) != 0)
{
SDL_Rect **modes= SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
if(modes != (SDL_Rect **) -1)
{
width= modes[0]->w;
height= modes[0]->h;
printf("App::resizeWindow( ): no frame / fullscreen %d x %d\n", width, height);
}
}
if(SDL_GetVideoInfo() == NULL
|| SDL_SetVideoMode(width, height, 0, mode_flags) < 0)
{
printf("SDL_SetVideoMode() failed:\n%s\n", SDL_GetError());
return -1;
}
// conserve la nouvelle taille
m_width= width;
m_height= height;
return 0;
}
int App::createWindow( const int w, const int h )
{
// initialise SDL
if(SDL_Init(SDL_INIT_EVERYTHING) < 0
|| SDL_GetVideoInfo() == NULL )
{
printf("SDL_Init() failed:\n%s\n", SDL_GetError());
return -1;
}
// enregistre le destructeur de sdl
atexit(SDL_Quit);
// fixe le titre de la fenetre
SDL_WM_SetCaption("gKit", "");
// clavier unicode
SDL_EnableUNICODE(1);
// + contournement d'un bug de sdl windows sur claviers non qwerty
int keys_n= 0;
SDL_GetKeyState(&keys_n);
//~ SDL_GetKeyboardState(&keys_n); // sdl 1.3
m_key_state= new unsigned char[keys_n];
m_key_map= new unsigned int[keys_n];
for(int i= 0; i < keys_n; i++)
{
m_key_state[i]= 0;
m_key_map[i]= i;
}
// creer la fenetre et le contexte openGL
if(resizeWindow(w, h) < 0)
return -1;
#if 1
{
printf("openGL version: '%s'\nGLSL version: '%s'\n",
glGetString(GL_VERSION),
glGetString(GL_SHADING_LANGUAGE_VERSION));
}
#endif
{
int swap= 0;
SDL_GL_GetAttribute(SDL_GL_SWAP_CONTROL, &swap);
printf("swap control: %s\n", swap ? "on" : "OFF");
}
{
int direct_rendering= 0;
SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &direct_rendering);
printf("direct rendering: %s\n", direct_rendering ? "on" : "OFF");
}
// initialise les extensions openGL
GLenum err;
err= glewInit();
if(err != GLEW_OK)
{
printf("%s\n", glewGetErrorString(err));
return -1;
}
#ifdef GK_OPENGL3
if(!GLEW_VERSION_3_3)
{
printf("openGL 3.3 not supported.\n");
return -1;
}
#endif
#ifdef GK_OPENGL4
if(!GLEW_VERSION_4_0)
{
printf("openGL 4.0 not supported.\n");
return -1;
}
if(!GLEW_VERSION_4_1)
{
printf("openGL 4.1 not supported.\n");
}
#endif
if(!GLEW_VERSION_2_1)
{
printf("OpenGL 2: context creation failed.\n");
return -1;
}
if(!glewIsSupported("GL_ARB_vertex_buffer_object"))
{
printf("ARB vertex buffer object: extension missing.\n");
return -1;
}
if(!glewIsSupported("GL_EXT_framebuffer_object"))
{
printf("EXT framebuffer object: extension missing.\n");
return -1;
}
if(!glewIsSupported("GL_ARB_framebuffer_object"))
{
printf("ARB framebuffer object: extension missing.\n");
}
if(!glewIsSupported("GL_ARB_texture_float"))
{
printf("ARB texture float: extension missing.\n");
return -1; // support des textures hdr RGBA32F_ARB
}
if(!glewIsSupported("GL_ARB_color_buffer_float"))
{
printf("ARB color buffer float: extension missing.\n");
//~ return -1;
}
if(!glewIsSupported("GL_ARB_depth_buffer_float"))
{
printf("ARB depth buffer float: extension missing.\n");
//~ return -1;
}
if(!glewIsSupported("GL_EXT_texture_filter_anisotropic"))
{
printf("EXT texture filter anisotropic: extension missing.\n");
//~ return -1;
}
else
{
GLint max_aniso;
glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &max_aniso);
printf("EXT texture filter anisotropic: max %d\n", max_aniso);
}
// fixe l'etat openGL par defaut
glClearColor(0.0, 0.0, 0.0, 1.0);
glClearDepth(1.f);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
//~ glShadeModel(GL_SMOOTH);
glDisable(GL_DITHER);
glDisable(GL_MULTISAMPLE);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glPolygonMode(GL_FRONT, GL_FILL);
glPolygonMode(GL_BACK, GL_FILL);
return 0;
}
bool App::isClosed( )
{
return (m_stop == 1);
}
void App::Close( )
{
m_stop= 1;
}
unsigned char *App::getKeys( )
{
return m_key_state;
}
unsigned char& App::key( const int key )
{
return m_key_state[key];
}
bool App::processEvents( )
{
SDL_Event event;
while(SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_VIDEORESIZE:
resizeWindow(event.resize.w, event.resize.h);
// prevenir l'application
processWindowResize(event.resize);
break;
case SDL_QUIT:
m_stop= 1;
break;
case SDL_KEYUP:
// gestion clavier unicode
// desactive la touche
m_key_state[m_key_map[event.key.keysym.sym]]= 0;
// prevenir l'application
processKeyboardEvent(event.key);
break;
case SDL_KEYDOWN:
// gestion clavier unicode
m_key_state[event.key.keysym.sym]= 1;
if(event.key.keysym.unicode < 128 && event.key.keysym.unicode > 0 )
{
// conserve l'association entre le code de la touche et l'unicode
m_key_map[event.key.keysym.sym]= (unsigned int) event.key.keysym.unicode;
// annule l'etat associe au code la touche
m_key_state[event.key.keysym.sym]= 0;
// active l'etat associe a l'unicode
m_key_state[event.key.keysym.unicode]= 1;
}
// prevenir l'application
processKeyboardEvent(event.key);
break;
case SDL_MOUSEMOTION:
// prevenir l'application
processMouseMotionEvent(event.motion);
break;
case SDL_MOUSEBUTTONUP:
case SDL_MOUSEBUTTONDOWN:
// prevenir l'application
processMouseButtonEvent(event.button);
break;
}
}
return (m_stop == 0);
}
int App::run( )
{
if(isClosed())
return -1;
// termine l'initialisation des classes derivees, chargement de donnees, etc.
if(init() < 0)
{
#ifdef VERBOSE
printf("App::init( ): failed.\n");
#endif
return -1;
}
ProfilerClock::Ticks start= ProfilerClock::getTicks();
ProfilerClock::Ticks last_frame= start;
while(!isClosed())
{
// traitement des evenements : clavier, souris, fenetre, etc.
processEvents();
// mise a jour de la scene
ProfilerClock::Ticks frame= ProfilerClock::getDelay(start);
ProfilerClock::Ticks delta= ProfilerClock::delay(frame, last_frame);
if(update( frame / 1000, delta / 1000 ) == 0)
break;
// affiche la scene
if(draw() == 0)
break;
last_frame= frame;
}
// destruction des ressources chargees par les classes derivees.
if(quit() < 0)
return -1;
return 0;
}
}
| [
"[email protected]@ae0aad3f-0d2d-2c89-41f8-224e04efc9db"
] | [
[
[
1,
359
]
]
] |
abad34f03a55c9af44be9b35aad3cd3dc56f18f7 | d418ee4fc1cea6246e8611b7b162abb03d0cd010 | /nachos-csci402/code/network/netcall.cc | 4944650851e58b24117ccf72687889ddf7bf1837 | [
"MIT-Modern-Variant"
] | permissive | KWarp/cs402gregjustinkevin | 873cf49460f0574402b141e8db348940a86bfaa3 | a56dbfa3ae92c04c377b4cdeed9633ee58a578f8 | refs/heads/master | 2021-01-10T16:44:23.875963 | 2010-12-05T07:29:02 | 2010-12-05T07:29:02 | 53,481,712 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 88,904 | cc | #include "netcall.h"
#include <sys/time.h>
extern "C" {
int bcopy(char *, char *, int);
};
Message::Message(PacketHeader pHdr, MailHeader mHdr, char *d)
{
pktHdr = pHdr;
mailHdr = mHdr;
data = d;
}
DistributedLock::DistributedLock(const char* debugName)
{
name = debugName;
lockState = FREE;
waitQueue = new List;
ownerMachID = -1;
ownerMailID = -1;
globalId = -1;
}
void DistributedLock::QueueReply(Message* reply){ waitQueue->Append((void*)reply);}
Message* DistributedLock::RemoveReply(){ return (Message*)waitQueue->Remove();}
bool DistributedLock::isQueueEmpty(){ return (Message*)waitQueue->IsEmpty();}
void DistributedLock::setLockState(bool ls){ lockState = ls; }
void DistributedLock::setOwner(int machID, int mailID){ ownerMachID = machID; ownerMailID = mailID;}
DistributedLock::~DistributedLock() { delete waitQueue;}
DistributedMV::DistributedMV(const char* debugName) { name = debugName; globalId = -1;}
DistributedMV::~DistributedMV() {}
DistributedCV::DistributedCV(const char* debugName) { name=debugName; firstLock=NULL; waitQueue=new List; ownerMachID = -1; ownerMailID = -1; globalId = -1;}
void DistributedCV::QueueReply(Message* reply){ waitQueue->Append((void*)reply);}
Message* DistributedCV::RemoveReply(){ return (Message*)waitQueue->Remove();}
bool DistributedCV::isQueueEmpty(){ return (Message*)waitQueue->IsEmpty();}
void DistributedCV::setFirstLock(int fl){ firstLock = fl; }
void DistributedCV::setOwner(int machID, int mailID){ ownerMachID = machID; ownerMailID = mailID;}
DistributedCV::~DistributedCV() { delete waitQueue;}
char verifyBuffer[MAX_CLIENTS][4][5];
char lockName[MAX_CLIENTS][32];
int verifyResponses[MAX_CLIENTS];
int localLockIndex[MAX_CLIENTS];
enum CreationState {NO, MAYBE, YES};
CreationState lockCreationStates[MAX_CLIENTS];
CreationState cvCreationStates[MAX_CLIENTS];
CreationState mvCreationStates[MAX_CLIENTS];
timeval lockCreationTimeStamps[MAX_CLIENTS];
timeval cvCreationTimeStamps[MAX_CLIENTS];
timeval mvCreationTimeStamps[MAX_CLIENTS];
int waitingForCreateLock[MAX_CLIENTS];
int waitingForSignalCvs[MAX_CLIENTS];
int waitingForBroadcastCvs[MAX_CLIENTS];
int waitingForWaitLocks[MAX_CLIENTS];
DistributedMV* mvs[MAX_DMV];
DistributedCV* cvs[MAX_DCV];
DistributedLock* dlocks[MAX_DLOCK];
PacketHeader errorOutPktHdr, errorInPktHdr;
MailHeader errorOutMailHdr, errorInMailHdr;
char buffer[MaxMailSize];
int createDLockIndex = 0;
int createDCVIndex = 0;
int createDMVIndex = 0;
bool processAck(PacketHeader inPktHdr, MailHeader inMailHdr, timeval timeStamp)
{
#if 0
printf("processing ACK: From (%d, %d) to (%d, %d) bytes %d, time %d.%d\n",
inPktHdr.from, inMailHdr.from,
inPktHdr.to, inMailHdr.to, inMailHdr.length,
(int)timeStamp.tv_sec, (int)timeStamp.tv_usec);
#endif
unAckedMessagesLock->Acquire();
bool found = false;
for (int i = 0; i < (int)unAckedMessages.size(); ++i)
{
if (unAckedMessages[i]->pktHdr.from == inPktHdr.to &&
unAckedMessages[i]->pktHdr.to == inPktHdr.from &&
unAckedMessages[i]->mailHdr.from == inMailHdr.to &&
unAckedMessages[i]->mailHdr.to == inMailHdr.from &&
unAckedMessages[i]->timeStamp.tv_sec == timeStamp.tv_sec &&
unAckedMessages[i]->timeStamp.tv_usec == timeStamp.tv_usec)
{
// Remove the message from unAckedMessages, since it has now been Acked.
unAckedMessages.erase(unAckedMessages.begin() + i);
found = true;
break;
}
}
if (!found) // Error!!! This should never happen.
printf("processAck: Ack message not found in unAckedMessages!!!\n");
unAckedMessagesLock->Release();
return found;
}
void Ack(PacketHeader inPktHdr, MailHeader inMailHdr, timeval timeStamp, char* inData)
{
// If the message is from ourselves or our UserProg thread.
if ((inPktHdr.from == postOffice->GetID() &&
inMailHdr.from == currentThread->mailID) ||
(inPktHdr.from == postOffice->GetID() &&
inMailHdr.from == currentThread->mailID + 1) ||
(inPktHdr.from == postOffice->GetID() &&
inMailHdr.from == currentThread->mailID - 1))
{
// Find the message in unAckedMessages.
unAckedMessagesLock->Acquire();
bool found = false;
for (int i = 0; i < (int)unAckedMessages.size(); ++i)
{
if (unAckedMessages[i]->pktHdr.from == inPktHdr.from &&
unAckedMessages[i]->pktHdr.to == inPktHdr.to &&
unAckedMessages[i]->mailHdr.from == inMailHdr.from &&
unAckedMessages[i]->mailHdr.to == inMailHdr.to &&
unAckedMessages[i]->timeStamp.tv_sec == timeStamp.tv_sec &&
unAckedMessages[i]->timeStamp.tv_usec == timeStamp.tv_usec)
{
#if 0
printf("Doing Local ACK: From (%d, %d) to (%d, %d) bytes %d, time %d.%d\n",
inPktHdr.from, inMailHdr.from,
inPktHdr.to, inMailHdr.to, inMailHdr.length,
(int)timeStamp.tv_sec, (int)timeStamp.tv_usec);
#endif
// Remove the entry from unAckedMessage to simulate an Ack.
unAckedMessages.erase(unAckedMessages.begin() + i);
found = true;
break;
}
}
if (!found)
{/* Error! */}
unAckedMessagesLock->Release();
}
else // If the message is from another thread (including self?).
{
// Send an Ack to the message sender.
char request[MaxMailSize];
sprintf(request, "%d_", ACK);
PacketHeader outPktHdr;
MailHeader outMailHdr;
outPktHdr.from = postOffice->GetID();
outMailHdr.from = currentThread->mailID;
outPktHdr.to = inPktHdr.from;
outMailHdr.to = inMailHdr.from;
outMailHdr.length = strlen(request) + 1;
#if 0 // For debugging.
printf("Sending ACK: From (%d, %d) to (%d, %d) bytes %d, time %d.%d\n",
outPktHdr.from, outMailHdr.from,
outPktHdr.to, outMailHdr.to, outMailHdr.length,
(int)timeStamp.tv_sec, (int)timeStamp.tv_usec);
#endif
if (!postOffice->Send(outPktHdr, outMailHdr, timeStamp, request, false))
interrupt->Halt();
}
}
int Request(RequestType requestType, char* data, int machineID, int mailID)
{
// Send an Ack to the message sender.
timeval timeStamp;
char request[MaxMailSize];
sprintf(request, "%d_%s", requestType, data);
for(int i = 0; i < (int)MaxMailSize; ++i)
buffer[i]='\0';
PacketHeader outPktHdr, inPktHdr;
MailHeader outMailHdr, inMailHdr;
outPktHdr.from = postOffice->GetID();
outMailHdr.from = currentThread->mailID;
outPktHdr.to = machineID;
outMailHdr.to = mailID;
outMailHdr.length = strlen(request) + 1;
printf("Request: %s\n", request);
if (!postOffice->Send(outPktHdr, outMailHdr, request))
interrupt->Halt();
RequestType receiveRequestType = INVALIDTYPE;
// ACKs can occur here, keep waiting for anything else
while (receiveRequestType == INVALIDTYPE || receiveRequestType == ACK)
{
postOffice->Receive(currentThread->mailID, &inPktHdr, &inMailHdr, &timeStamp, buffer);
parseValue(0, buffer, (int*)(&receiveRequestType));
if (requestType == ACK)
{
printf("Request: Processing ACK %s\n", buffer);
processAck(inPktHdr, inMailHdr, timeStamp);
}
}
printf("Request receive RequestType: %d, msg: %s\n", receiveRequestType, buffer);
Ack(inPktHdr, inMailHdr, timeStamp, buffer);
return atoi(buffer);
}
// Parses timeStamp and requestType from the data packet, buf.
// Returns the index of the start of data.
int parseValue(int startIndex, const char* buf, int* value)
{
char valueStr[MaxMailSize];
char c = '?';
int i = startIndex;
ASSERT(i >= 0);
// Parse requestType.
while (c != '_' && c != '\0')
{
c = buf[i];
if (c == '_' || c == '\0')
break;
valueStr[i++ - startIndex] = c;
}
valueStr[i++ - startIndex] = '\0';
if (value != NULL)
*value = atoi(valueStr);
//printf("parsed value: %d\n", *value);
// i will point to the next character of data.
return i;
}
int uniqueGlobalID()
{
// (machineID * total Net Threads) + mailID
return (postOffice->GetID() * 100) + currentThread->mailID;
}
bool processMessage(PacketHeader inPktHdr, MailHeader inMailHdr, timeval timeStamp, char* msgData,
vector<NetThreadInfoEntry*> *localNetThreadInfo)
{
printf("Processing Message from (%d, %d) to (%d, %d), time %d.%d, msg: %s\n", inPktHdr.from, inMailHdr.from,
inPktHdr.to, inMailHdr.to, (int)timeStamp.tv_sec, (int)timeStamp.tv_usec, msgData);
PacketHeader outPktHdr;
MailHeader outMailHdr;
RequestType requestType = INVALIDTYPE;
char* localLockName = new char[32];
char lockIndexBuf[MaxMailSize];
char mvIndexBuf[MaxMailSize];
char mvValBuf[MaxMailSize];
char* cvName = new char[32];
char cvNum[MaxMailSize];
char lockNum[MaxMailSize];
bool success = false;
int lockIndex = -1;
char* mvName = new char[32];
int mvIndex = -1;
int mvValue = 0;
int cvIndex = -1;
int lockNameIndex = 0;
int cvNameIndex = 0;
int cvNumIndex = 0;
int lockNumIndex = 0;
int otherServerLockIndex = -1;
int otherServerIndex=0;
char client[5];
int clientNum; /// Convention: clientNum = 100 * machineID + mailID
/// mailID can range from [0,99] so that means there is a maximum of 100 threads per machine id.
char* request = NULL;
ASSERT(serverCount == (int)localNetThreadInfo->size());
// Fill buffer with '\0' chars.
for(int i = 0; i < (int)MaxMailSize; ++i)
buffer[i]='\0';
// Parse timeStamp and requestType from message.
int i = parseValue (0, msgData, (int*)(&requestType));
char c = msgData[i];
// Do this because all the code below assumes we are one the char before this, and I am too lazy to change it everywhere.
i--;
int a, m, j, x;
switch (requestType)
{
case CREATELOCK:
printf("CREATELOCK\n");
clientNum = 100 * inPktHdr.from + inMailHdr.from - 1;
if (createDLockIndex >= 0 && createDLockIndex < (MAX_DLOCK - 1))
{
// Parse the lock name.
j = 0;
while (c != '\0')
{
c = msgData[++i];
if (c == '\0')
break;
lockName[clientNum][j++] = c;
}
lockName[clientNum][j] = '\0';
// If we have already created a lock with lockName, set the appropriate lockIndex.
for (int k = 0; k < createDLockIndex; ++k)
{
if (!strcmp(dlocks[k]->getName(), lockName[clientNum]))
{
lockIndex = k;
}
}
// Store lock index for later.
localLockIndex[clientNum] = lockIndex;
if (serverCount > 1)
{
// If the lock didn't already exist.
if (localLockIndex[clientNum] == -1)
{
// Store the current timeStamp so we can use it later to determine ownership.
timeval currentTimeStamp;
gettimeofday(¤tTimeStamp, NULL);
lockCreationTimeStamps[clientNum] = currentTimeStamp;
// Initilize the number of reponses we have received
verifyResponses[clientNum] = 0;
// Set the state to MAYBE, meaning we have a request pending.
lockCreationStates[clientNum] = MAYBE;
// Broadcast a request to all the other threads.
CreateVerify(lockName[clientNum], CREATELOCKVERIFY, clientNum, localNetThreadInfo);
}
else // if the lock already existed, simply return its value.
{
lockIndex = dlocks[localLockIndex[clientNum]]->GetGlobalId();
// Send response to client.
char ack[MaxMailSize];
sprintf(ack, "%i", lockIndex);
outPktHdr.to = clientNum / 100;
outMailHdr.to = (clientNum + 100) % 100 + 1; // +1 to reach user thread
outPktHdr.from = postOffice->GetID();
outMailHdr.from = currentThread->mailID;
outMailHdr.length = strlen(ack) + 1;
printf("Sending CREATELOCK response: %s\n", ack);
success = postOffice->Send(outPktHdr, outMailHdr, ack);
if ( !success )
interrupt->Halt();
verifyResponses[clientNum] = 0; // Set verifyResponses to 0 to prepare for incoming responses (which there won't be any since this is the single server case).
localLockIndex[clientNum] = -1; // Reset localLockIndex for next time.
fflush(stdout);
}
}
else
{
// If the lock didn't already exist.
if (localLockIndex[clientNum] == -1)
{
// Store the lockName for later.
for (i = 0; lockName[clientNum][i] != '\0'; i++)
{
localLockName[i] = lockName[clientNum][i];
localLockName[i + 1]= '\0';
}
// Create a new DistrbituedLock.
dlocks[createDLockIndex] = new DistributedLock(localLockName);
dlocks[createDLockIndex]->SetGlobalId((uniqueGlobalID() * MAX_DLOCK) + createDLockIndex);
// If we failed to create the new DistributedLock.
if (dlocks[createDLockIndex] == NULL)
{
errorOutPktHdr.to = clientNum / 100;
errorInPktHdr = inPktHdr;
errorOutMailHdr.to = (clientNum + 100) % 100;
errorInMailHdr = inMailHdr;
return false;
}
// CreateDLock succeeded. Get the new lock's global id and increment createDLockIndex for next time.
lockIndex = dlocks[createDLockIndex]->GetGlobalId();
createDLockIndex++;
}
else // if the lock already existed, simply grab its value.
{
lockIndex = dlocks[localLockIndex[clientNum]]->GetGlobalId();
}
// Send response to client.
char ack[MaxMailSize];
sprintf(ack, "%i", lockIndex);
outPktHdr.to = clientNum / 100;
outMailHdr.to = (clientNum + 100) % 100 + 1; // +1 to reach user thread
outPktHdr.from = postOffice->GetID();
outMailHdr.from = currentThread->mailID;
outMailHdr.length = strlen(ack) + 1;
printf("Sending CREATELOCK response: %s\n", ack);
success = postOffice->Send(outPktHdr, outMailHdr, ack);
if ( !success )
interrupt->Halt();
verifyResponses[clientNum] = 0; // Set verifyResponses to 0 to prepare for incoming responses (which there won't be any since this is the single server case).
localLockIndex[clientNum] = -1; // Reset localLockIndex for next time.
fflush(stdout);
}
}
else // if the createDLockIndex is an invalid range.
{
errorOutPktHdr = outPktHdr;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorInMailHdr = inMailHdr;
return false;
}
break;
case CREATELOCKANSWER:
printf("CREATELOCKANSWER\n");
x = 0;
a = 0;
// Parse clientNum.
do
{
c = msgData[++i];
if (c == '_')
break;
client[x++] = c;
} while (c != '_');
client[x] = '\0';
clientNum = atoi(client);
// Parse verifyResponse (as a string).
while (c != '\0')
{
c = msgData[++i];
verifyBuffer[clientNum][verifyResponses[uniqueGlobalID()]][a++] = c;
if (c == '\0')
break;
}
// If the lock didn't already exist.
if (localLockIndex[clientNum] == -1)
{
// Parse the response.
int verifyResponse;
int index = parseValue(0, verifyBuffer[clientNum][verifyResponses[clientNum]], &verifyResponse);
// If the message we just received is a "Yes", i.e. that server has already created the lock and is the owner.
if (verifyResponse == YES)
{
// Parse the lockIndex.
index = parseValue(index, verifyBuffer[clientNum][verifyResponses[clientNum]], &lockIndex);
// Copy the lockName that our userprog sent to us in the initial request into localLockName.
for (i = 0; lockName[clientNum][i] != '\0'; i++)
{
localLockName[i] = lockName[clientNum][i];
localLockName[i + 1] = '\0';
}
lockCreationStates[clientNum] = YES;
// Actually create the lock.
dlocks[createDLockIndex] = new DistributedLock(localLockName);
dlocks[createDLockIndex]->SetGlobalId(lockIndex);
// If we failed to create the lock.
if (dlocks[createDLockIndex] == NULL)
{
printf("Error in creation of %s!\n", lockName[clientNum]);
errorOutPktHdr.to = clientNum / 100;
errorInPktHdr = inPktHdr;
errorOutMailHdr.to = (clientNum + 100) % 100;
errorInMailHdr = inMailHdr;
return false;
}
// Communicate to my paired user thread to wake it up.
char ack[MaxMailSize];
sprintf(ack, "%i", lockIndex);
outPktHdr.to = postOffice->GetID();
outMailHdr.to = currentThread->mailID + 1; // +1 to reach user thread
outPktHdr.from = postOffice->GetID();
outMailHdr.from = currentThread->mailID;
outMailHdr.length = strlen(ack) + 1;
printf("Sending CREATELOCKANSWER from (%d, %d) to (%d, %d), msg: %s\n",
outPktHdr.from, outMailHdr.from, outPktHdr.to, outMailHdr.to, ack);
success = postOffice->Send(outPktHdr, outMailHdr, ack);
if (!success)
interrupt->Halt();
// Increment the number of responses.
verifyResponses[clientNum]++;
}
else if (verifyResponse == NO || verifyResponse == MAYBE)
{
// Parse the timeStamp when the other thread began creating its lock.
timeval responseTimeStamp;
int sec, usec;
index = parseValue(index, verifyBuffer[clientNum][verifyResponses[clientNum]], &sec);
index = parseValue(index, verifyBuffer[clientNum][verifyResponses[clientNum]], &usec);
responseTimeStamp.tv_sec = sec;
responseTimeStamp.tv_usec = usec;
if (lockCreationTimeStamps[clientNum].tv_sec < responseTimeStamp.tv_sec ||
(lockCreationTimeStamps[clientNum].tv_sec == responseTimeStamp.tv_sec &&
lockCreationTimeStamps[clientNum].tv_usec < responseTimeStamp.tv_usec))
{
// Increment the number of responses we've received.
verifyResponses[clientNum]++;
// If all server threads have responded to my request.
if (verifyResponses[clientNum] == serverCount - 1)
{
// Copy the lockName that our userprog sent to us in the initial request into localLockName.
for (i = 0; lockName[clientNum][i] != '\0'; i++)
{
localLockName[i] = lockName[clientNum][i];
localLockName[i + 1] = '\0';
}
lockCreationStates[clientNum] = YES;
// Actually create the lock.
dlocks[createDLockIndex] = new DistributedLock(localLockName);
dlocks[createDLockIndex]->SetGlobalId((uniqueGlobalID() * MAX_DLOCK) + createDLockIndex);
// If we failed to create the lock.
if (dlocks[createDLockIndex] == NULL)
{
printf("Error in creation of %s!\n", lockName[clientNum]);
errorOutPktHdr.to = clientNum / 100;
errorInPktHdr = inPktHdr;
errorOutMailHdr.to = (clientNum + 100) % 100;
errorInMailHdr = inMailHdr;
return false;
}
// Save lockIndex and increment createDLockIndex for next time.
lockIndex = dlocks[createDLockIndex]->GetGlobalId();
createDLockIndex++;
// Broadcast a "YES" to everyone so they know we are the new owner.
char tmp[MaxMailSize];
sprintf(tmp, "%d_%d_", YES, lockIndex);
CreateVerify(tmp, CREATELOCKANSWER, clientNum, localNetThreadInfo);
// Communicate to my paired user thread to wake it up.
char ack[MaxMailSize];
sprintf(ack, "%i", lockIndex);
outPktHdr.to = postOffice->GetID();
outMailHdr.to = currentThread->mailID + 1; // +1 to reach user thread
outPktHdr.from = postOffice->GetID();
outMailHdr.from = currentThread->mailID;
outMailHdr.length = strlen(ack) + 1;
printf("Sending CREATELOCKANSWER from (%d, %d) to (%d, %d), msg: %s\n",
outPktHdr.from, outMailHdr.from, outPktHdr.to, outMailHdr.to, ack);
success = postOffice->Send(outPktHdr, outMailHdr, ack);
if (!success)
interrupt->Halt();
localLockIndex[clientNum] = -1;
fflush(stdout);
}
}
}
}
break;
case CREATELOCKVERIFY:
printf("CREATELOCKVERIFY\n");
lockIndex = -1;
request = new char [MaxMailSize];
x = 0;
a = 0;
// Parse the clientNum.
do
{
c = msgData[++i];
if (c == '_')
break;
client[x++] = c;
} while (c != '_');
client[x]='\0';
clientNum = atoi(client);
// Parse the lockName.
while (c != '\0')
{
c = msgData[++i];
if (c == '\0')
break;
localLockName[a++] = c;
}
localLockName[a] = '\0';
// Check if the lock already exists.
for (int k = 0; k < createDLockIndex; k++)
{
if (!strcmp(dlocks[k]->getName(), localLockName))
{
lockIndex = k;
break;
}
}
outPktHdr.to = inPktHdr.from;
outMailHdr.to = inMailHdr.from;
outPktHdr.from = postOffice->GetID();
outMailHdr.from = currentThread->mailID;
// If the lock hasn't already been created on this server.
if (lockCreationStates[clientNum] == MAYBE)
{
printf("Lock named %s being created already\n", localLockName);
sprintf(request, "%d_%d_%d_%d_%d", CREATELOCKANSWER, clientNum, MAYBE,
(int)lockCreationTimeStamps[uniqueGlobalID()].tv_sec, (int)lockCreationTimeStamps[uniqueGlobalID()].tv_usec);
outMailHdr.length = strlen(request) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, request);
}
else if (lockIndex == -1)
{
printf("Lock named %s not found\n", localLockName);
sprintf(request, "%d_%d_%d", CREATELOCKANSWER, clientNum, NO);
outMailHdr.length = strlen(request) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, request);
}
else // If the lock does exist on the server.
{
sprintf(request, "%d_%d_%d_%d", CREATELOCKANSWER, clientNum, YES, dlocks[lockIndex]->GetGlobalId());
outMailHdr.length = strlen(request) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, request);
}
break;
case CREATECV:
printf("CREATECV\n");
clientNum = 100 * inPktHdr.from + inMailHdr.from - 1;
if (createDCVIndex >= 0 && createDCVIndex < (MAX_DCV - 1))
{
// Parse lockName.
j = 0;
while (c != '\0')
{
c = msgData[++i];
if (c == '\0')
break;
lockName[clientNum][j++] = c;
}
lockName[clientNum][j] = '\0';
// If the cv has already been created on this server.
for (int k = 0; k < createDCVIndex; k++)
{
if (!strcmp(cvs[k]->getName(), lockName[clientNum]))
{
cvIndex = k;
}
}
localLockIndex[clientNum]=cvIndex;
if (serverCount > 1)
{
// If the cv hasn't been created yet.
if (localLockIndex[clientNum] == -1)
{
// Store the current timeStamp so we can use it later to determine ownership.
timeval currentTimeStamp;
gettimeofday(¤tTimeStamp, NULL);
cvCreationTimeStamps[clientNum] = currentTimeStamp;
// Set the state to MAYBE, meaning we have a request pending.
cvCreationStates[clientNum] = MAYBE;
// Broadcast a request to all the other threads.
CreateVerify(lockName[clientNum], CREATECVVERIFY, clientNum, localNetThreadInfo);
}
else // if the cv has already been created.
{
cvIndex = cvs[cvIndex]->GetGlobalId();
// Send the cvIndex to the client.
char ack[MaxMailSize];
sprintf(ack, "%i", cvIndex);
outPktHdr.to = clientNum / 100;
outMailHdr.to = (clientNum + 100) % 100;
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(ack) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, ack);
if (!success)
interrupt->Halt();
// Reset counters for next time.
verifyResponses[clientNum] = 0;
localLockIndex[clientNum] = -1;
fflush(stdout);
}
}
else
{
// If the cv hasn't been created yet.
if (localLockIndex[clientNum] == -1)
{
// Store the lockName for later.
for (i = 0; lockName[clientNum][i] != '\0'; i++)
{
localLockName[i] = lockName[clientNum][i];
localLockName[i + 1] = '\0';
}
// Create the cv.
cvs[createDCVIndex] = new DistributedCV(localLockName);
cvs[createDCVIndex]->SetGlobalId((uniqueGlobalID()*MAX_DCV)+createDCVIndex);
// If creating the cv failed.
if (cvs[createDCVIndex] == NULL)
{
errorOutPktHdr.to = clientNum / 100;
errorInPktHdr = inPktHdr;
errorOutMailHdr.to = (clientNum + 100) % 100;
errorInMailHdr = inMailHdr;
return false;
}
// Store the globalId and increment createDCVIndex for next time.
cvIndex = cvs[createDCVIndex]->GetGlobalId();
createDCVIndex++;
}
else // if the cv has already been created.
{
cvIndex = cvs[cvIndex]->GetGlobalId();
}
// Send the cvIndex to the client.
char ack[MaxMailSize];
sprintf(ack, "%i", cvIndex);
outPktHdr.to = clientNum / 100;
outMailHdr.to = (clientNum + 100) % 100;
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(ack) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, ack);
if (!success)
interrupt->Halt();
// Reset counters for next time.
verifyResponses[clientNum] = 0;
localLockIndex[clientNum] = -1;
fflush(stdout);
}
}
else
{
errorOutPktHdr = outPktHdr;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorInMailHdr = inMailHdr;
return false;
}
break;
case CREATECVANSWER:
printf("CREATECVANSWER\n");
x=0;
// Parse clientNum.
do
{
c = msgData[++i];
if (c == '_')
break;
client[x++] = c;
} while(c != '_');
client[x] = '\0';
clientNum = atoi(client);
// Parse verifyResponse.
while (c != '\0')
{
c = msgData[++i];
verifyBuffer[clientNum][verifyResponses[clientNum]][a++] = c;
if (c == '\0')
break;
}
verifyResponses[clientNum]++;
// If we have received verification from every other server.
if (verifyResponses[clientNum] == serverCount - 1)
{
for (i = 0; i < serverCount - 1; i++)
{
if (verifyBuffer[clientNum][i][0] == '-' && verifyBuffer[clientNum][i][1] == '1')
{
otherServerLockIndex = -1;
}
else
{
otherServerLockIndex = atoi(verifyBuffer[clientNum][i]);
break;
}
}
if (localLockIndex[clientNum] == -1 && otherServerLockIndex == -1) // If not found here or elsewhere
{
// Store the cv name for later.
for (i = 0; lockName[clientNum][i] != '\0'; i++)
{
localLockName[i] = lockName[clientNum][i];
localLockName[i + 1] = '\0';
}
// Actually create the cv.
cvs[createDCVIndex] = new DistributedCV(localLockName);
cvs[createDCVIndex]->SetGlobalId((uniqueGlobalID() * MAX_DCV) + createDCVIndex);
// If createCV failed.
if (cvs[createDCVIndex] == NULL)
{
errorOutPktHdr.to = clientNum / 100;
errorInPktHdr = inPktHdr;
errorOutMailHdr.to = (clientNum + 100) % 100;
errorInMailHdr = inMailHdr;
return false;
}
// Set the cvIndex and increment createDCVIndex for next time.
cvIndex = cvs[createDCVIndex]->GetGlobalId();
createDCVIndex++;
}
else if (localLockIndex[clientNum] == -1 && otherServerLockIndex !=-1)
{
cvIndex=otherServerLockIndex; //set lock
}
else if (localLockIndex[clientNum] != -1 && otherServerLockIndex==-1)
{
cvIndex=cvs[localLockIndex[clientNum]]->GetGlobalId();
}
else
{}
char ack[MaxMailSize];
sprintf(ack, "%i", cvIndex);
// Communicate to my paired user thread.
outPktHdr.to = postOffice->GetID();
outMailHdr.to = currentThread->mailID + 1; // +1 to reach user thread
outPktHdr.from = postOffice->GetID();
outMailHdr.from = currentThread->mailID;
outMailHdr.length = strlen(ack) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, ack);
if (!success)
interrupt->Halt();
// Reset counters for next time.
verifyResponses[clientNum]=0;
localLockIndex[clientNum]=-1;
fflush(stdout);
}
break;
case CREATECVVERIFY:
printf("CREATECVVERIFY\n");
lockIndex = -1;
request = new char [MaxMailSize];
x=0;
// Parse clientNum.
do
{
c = msgData[++i];
if (c == '_')
break;
client[x++] = c;
} while (c != '_');
client[x]='\0';
clientNum = atoi(client);
// Parse cvName.
while(c!='\0')
{
c = msgData[++i];
if (c == '\0')
break;
localLockName[a++] = c;
}
localLockName[a] = '\0';
// If we have created the cv already on this server.
for (j = 0; j < createDCVIndex; j++)
{
if (!strcmp(cvs[j]->getName(), localLockName))
{
cvIndex = j;
}
}
outPktHdr.to = inPktHdr.from;
outMailHdr.to = inMailHdr.from;
outMailHdr.from = postOffice->GetID();
// If we haven't created the cv.
if (cvIndex == -1)
{
sprintf(request,"%d_%d_%d", CREATECVANSWER, clientNum, -1);
outMailHdr.length = strlen(request) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, request);
}
else // If we have created the cv
{
sprintf(request, "%d_%d_%d", CREATECVANSWER, clientNum, cvs[cvIndex]->GetGlobalId());
outMailHdr.length = strlen(request) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, request);
}
break;
case CREATEMV:
printf("CREATEMV\n");
clientNum=100 * inPktHdr.from + inMailHdr.from - 1;
if (createDMVIndex >= 0 && createDMVIndex < (MAX_DMV - 1))
{
// Parse mvName.
j = 0;
while (c != '\0')
{
c = msgData[++i];
if (c == '\0')
break;
lockName[clientNum][j++] = c;
}
lockName[clientNum][j] = '\0' ;
// Check if we have already created the mv on this server.
for (int k = 0; k < createDMVIndex; k++)
{
if (!strcmp(mvs[k]->getName(), lockName[clientNum]))
{
mvIndex = k;
break;
}
}
localLockIndex[clientNum] = mvIndex;
if (serverCount > 1)
{
// If the mv has not been created yet.
if (localLockIndex[clientNum] == -1)
{
// Store the current timeStamp so we can use it later to determine ownership.
timeval currentTimeStamp;
gettimeofday(¤tTimeStamp, NULL);
mvCreationTimeStamps[clientNum] = currentTimeStamp;
// Set the state to MAYBE, meaning we have a request pending.
mvCreationStates[clientNum] = MAYBE;
// Broadcast a request to all the other threads.
CreateVerify(lockName[clientNum], CREATEMVVERIFY, clientNum, localNetThreadInfo);
}
else // If we have already created the mv.
{
mvIndex = mvs[localLockIndex[clientNum]]->GetGlobalId();
char ack[MaxMailSize];
sprintf(ack, "%i", mvIndex);
// Communicate to my paired user thread.
outPktHdr.to = postOffice->GetID();
outMailHdr.to = currentThread->mailID + 1; // +1 to reach user thread
outPktHdr.from = postOffice->GetID();
outMailHdr.from = currentThread->mailID;
outMailHdr.length = strlen(ack) + 1;
printf("Sending CREATEMV response: %s\n", ack);
success = postOffice->Send(outPktHdr, outMailHdr, ack);
if (!success)
interrupt->Halt();
// Reset local vars for later.
verifyResponses[clientNum] = 0;
localLockIndex[clientNum] = -1;
fflush(stdout);
}
}
else
{
// If the mv has not been created yet.
if (localLockIndex[clientNum] == -1)
{
// Copy the mvName for later.
for (i = 0; lockName[clientNum][i] != '\0'; i++)
{
localLockName[i] = lockName[clientNum][i];
localLockName[i + 1] = '\0';
}
// Create the mv.
mvs[createDMVIndex] = new DistributedMV(localLockName);
mvs[createDMVIndex]->SetGlobalId((uniqueGlobalID() * MAX_DMV) + createDMVIndex);
// If CreateMV failed.
if (mvs[createDMVIndex] == NULL)
{
errorOutPktHdr.to = clientNum / 100;
errorInPktHdr = inPktHdr;
errorOutMailHdr.to = (clientNum + 100) % 100;
errorInMailHdr = inMailHdr;
return false;
}
// Store mvIndex and increment createDMVIndex for later.
mvIndex = mvs[createDMVIndex]->GetGlobalId();
createDMVIndex++;
}
else // If we have already created the mv.
{
mvIndex = mvs[localLockIndex[clientNum]]->GetGlobalId();
}
char ack[MaxMailSize];
sprintf(ack, "%i", mvIndex);
// Communicate to my paired user thread.
outPktHdr.to = postOffice->GetID();
outMailHdr.to = currentThread->mailID + 1; // +1 to reach user thread
outPktHdr.from = postOffice->GetID();
outMailHdr.from = currentThread->mailID;
outMailHdr.length = strlen(ack) + 1;
printf("Sending CREATEMV response: %s\n", ack);
success = postOffice->Send(outPktHdr, outMailHdr, ack);
if (!success)
interrupt->Halt();
// Reset local vars for later.
verifyResponses[clientNum] = 0;
localLockIndex[clientNum] = -1;
fflush(stdout);
}
}
else
{
errorOutPktHdr = outPktHdr;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorInMailHdr = inMailHdr;
return false;
}
break;
case CREATEMVANSWER:
printf("CREATEMVANSWER\n");
x=0;
// Parse clientNum.
do
{
c = msgData[++i];
if (c == '_')
break;
client[x++] = c;
} while (c != '_');
client[x]='\0';
clientNum = atoi(client);
// Parse verifyMessage.
while (c !='\0')
{
c = msgData[++i];
verifyBuffer[clientNum][verifyResponses[clientNum]][a++] = c;
if (c == '\0')
break;
}
verifyResponses[clientNum]++;
// If we have received verifyResponses from every other server.
if (verifyResponses[clientNum] == serverCount - 1)
{
// Check if any other servers have already created the mv.
for (i = 0; i < serverCount - 1; i++)
{
if (verifyBuffer[clientNum][i][0] == '-' && verifyBuffer[clientNum][i][1] == '1')
{
otherServerLockIndex = -1;
}
else
{
otherServerLockIndex = atoi(verifyBuffer[clientNum][i]);
break;
}
}
// If the mv has not been created here or anywhere else.
if (localLockIndex[clientNum] == -1 && otherServerLockIndex == -1)
{
// Store the mvName.
for (i = 0; lockName[clientNum][i] != '\0'; i++)
{
localLockName[i] = lockName[clientNum][i];
localLockName[i + 1] = '\0';
}
// Actually create the mv.
mvs[createDMVIndex] = new DistributedMV(localLockName);
mvs[createDMVIndex]->SetGlobalId((uniqueGlobalID()*MAX_DMV)+createDMVIndex);
// If mv creation failed.
if (mvs[createDMVIndex] == NULL)
{
errorOutPktHdr.to = clientNum / 100;
errorInPktHdr = inPktHdr;
errorOutMailHdr.to = (clientNum + 100) % 100;
errorInMailHdr = inMailHdr;
return false;
}
// Set the mvIndex and increment createDMVIndex for next time.
mvIndex = mvs[createDMVIndex]->GetGlobalId();
createDMVIndex++;
}
// If the mv has already been created on another server, but not this one.
else if (localLockIndex[clientNum] == -1 && otherServerLockIndex != -1)
{
mvIndex = otherServerLockIndex;
}
// If the mv has been created on this server and nowhere else.
else if (localLockIndex[clientNum] != -1 && otherServerLockIndex == -1)
{
mvIndex=mvs[localLockIndex[clientNum]]->GetGlobalId();
}
else
{}
char ack[MaxMailSize];
sprintf(ack, "%i", mvIndex);
// Communicate to my paired user thread.
outPktHdr.to = postOffice->GetID();
outMailHdr.to = currentThread->mailID + 1; // +1 to reach user thread
outPktHdr.from = postOffice->GetID();
outMailHdr.from = currentThread->mailID;
outMailHdr.length = strlen(ack) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, ack);
if (!success)
interrupt->Halt();
// Reset local vars for next time.
verifyResponses[clientNum] = 0;
localLockIndex[clientNum] = -1;
fflush(stdout);
}
break;
case CREATEMVVERIFY:
printf("CREATEMVVERIFY\n");
mvIndex = -1;
request = new char [MaxMailSize];
x = 0;
// Parse clientNum.
do
{
c = msgData[++i];
if (c == '_')
break;
client[x++] = c;
} while (c != '_');
client[x]='\0';
clientNum = atoi(client);
// Parse mvName.
while (c != '\0')
{
c = msgData[++i];
if (c == '\0')
break;
localLockName[a++] = c;
}
localLockName[a] = '\0';
// Check if the mv has been created on this server.
for (j = 0; j < createDMVIndex; j++)
{
if (!strcmp(mvs[j]->getName(), localLockName))
{
mvIndex = j;
break;
}
}
outPktHdr.to = inPktHdr.from;
outMailHdr.to = inMailHdr.from;
outMailHdr.from = postOffice->GetID();
// If the mv has not been created on this server.
if (mvIndex == -1)
{
sprintf(request, "%d_%d_%d", CREATEMVANSWER, clientNum, -1);
outMailHdr.length = strlen(request) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, request);
}
else
{
sprintf(request, "%d_%d_%d", CREATEMVANSWER, clientNum, mvs[mvIndex]->GetGlobalId());
outMailHdr.length = strlen(request) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, request);
}
break;
case ACQUIRE:
printf("ACQUIRE\n");
clientNum=100*(inPktHdr.from)+inMailHdr.from - 1;
m=0;
if(msgData[i+1] == '_')
{
i++;
do
{
c = msgData[++i];
if(c=='_')
break;
client[m++] = c;
}while(c!='_');
client[m]='\0';
clientNum = atoi(client);
}
m=0;
while(c!='\0')
{
c = msgData[++i];
lockIndexBuf[m++] = c;
}
lockIndex = atoi(lockIndexBuf);
//printf("lockIndex/MAX_DLOCK != uniqueGlobalID(): %d != %d\n", lockIndex/MAX_DLOCK, uniqueGlobalID());
if(lockIndex/MAX_DLOCK != uniqueGlobalID())
{
sprintf(buffer,"%d__%d_%s",ACQUIRE, clientNum, lockIndexBuf);
outPktHdr.to = lockIndex/MAX_DLOCK;
outMailHdr.to = inMailHdr.to + 1; // +1 to reach user thread
outMailHdr.from = inMailHdr.from;
outMailHdr.length = strlen(buffer) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, buffer);
}
else
success = Acquire(lockIndex, outPktHdr, inPktHdr, outMailHdr, inMailHdr, clientNum);
break;
case RELEASE:
printf("RELEASE\n");
clientNum=100*(inPktHdr.from)+inMailHdr.from - 1;
m=0;
if(msgData[i+1] == '_')
{
i++;
do
{
c = msgData[++i];
if(c=='_')
break;
client[m++] = c;
}while(c!='_');
client[m]='\0';
clientNum = atoi(client);
}
m=0;
while(c!='\0')
{
c = msgData[++i];
lockIndexBuf[m++] = c;
}
lockIndex = atoi(lockIndexBuf);
if(lockIndex/MAX_DLOCK != uniqueGlobalID())
{
sprintf(buffer,"%d__%d_%s",RELEASE, clientNum, lockIndexBuf);
outPktHdr.to = lockIndex/MAX_DLOCK;
outMailHdr.to = outMailHdr.to + 1; // +1 to reach user thread;
outMailHdr.from = inMailHdr.from;
outMailHdr.length = strlen(buffer) + 1;
printf("Sending RELEASE response: %s\n", buffer);
success = postOffice->Send(outPktHdr, outMailHdr, buffer);
}
else
success = Release(lockIndex, outPktHdr, inPktHdr, outMailHdr, inMailHdr, clientNum);
break;
case DESTROYLOCK:
printf("DESTROYLOCK\n");
clientNum=100*(inPktHdr.from)+inMailHdr.from - 1;
m=0;
if(msgData[i+1] == '_')
{
i++;
do
{
c = msgData[++i];
if(c=='_')
break;
client[m++] = c;
}while(c!='_');
client[m]='\0';
clientNum = atoi(client);
}
m=0;
while(c!='\0')
{
c = msgData[++i];
lockIndexBuf[m++] = c;
}
lockIndex = atoi(lockIndexBuf);
if(lockIndex/MAX_DLOCK != uniqueGlobalID())
{
sprintf(buffer,"%d__%d_%s",DESTROYLOCK, clientNum, lockIndexBuf);
outPktHdr.to = lockIndex/MAX_DLOCK;
outMailHdr.to = outPktHdr.to;
outMailHdr.from = inMailHdr.from;
outMailHdr.length = strlen(buffer) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, buffer);
}
else
success = DestroyLock(lockIndex, outPktHdr, inPktHdr, outMailHdr, inMailHdr, clientNum);
break;
case SETMV:
printf("SETMV\n");
clientNum=100*(inPktHdr.from)+inMailHdr.from - 1;
m=0;
if(msgData[i+1] == '_')
{
i++;
do
{
c = msgData[++i];
if(c=='_')
break;
client[m++] = c;
} while(c!='_');
clientNum=atoi(client);
}
m=0;
do
{
c = msgData[++i];
if(c=='_')
break;
mvIndexBuf[m++] = c;
}while(c!='_');
mvIndexBuf[m] = '\0';
mvIndex = atoi(mvIndexBuf);
m=0;
i++;
while(c!='\0')
{
c = msgData[i++];
mvValBuf[m++] = c;
}
mvValue = atoi(mvValBuf);
if(mvIndex/MAX_DMV != uniqueGlobalID())
{
sprintf(buffer,"%d__%d_%s_%s",SETMV, clientNum, mvIndexBuf, mvValBuf);
outPktHdr.to = mvIndex/MAX_DMV;
outMailHdr.to = outMailHdr.to + 1; // +1 to reach user thread;
outMailHdr.from = inMailHdr.from;
outMailHdr.length = strlen(buffer) + 1;
printf("Sending SETMV response: %s\n", buffer);
success = postOffice->Send(outPktHdr, outMailHdr, buffer);
}
else
success = SetMV(mvIndex, mvValue, outPktHdr, inPktHdr, outMailHdr, inMailHdr, clientNum);
break;
case GETMV:
printf("GETMV\n");
clientNum=100*(inPktHdr.from)+inMailHdr.from - 1;
m=0;
if(msgData[i+1] == '_')
{
i++;
do
{
c = msgData[++i];
if(c=='_')
break;
client[m++] = c;
}while(c!='_');
client[m]='\0';
clientNum = atoi(client);
}
m=0;
while(c!='\0')
{
c = msgData[++i];
mvIndexBuf[m++] = c;
}
mvIndex = atoi(mvIndexBuf);
if(mvIndex/MAX_DMV != uniqueGlobalID())
{
sprintf(buffer,"%d__%d_%s",GETMV, clientNum, mvIndexBuf);
outPktHdr.to = mvIndex/MAX_DMV;
outMailHdr.to = outMailHdr.to + 1; // +1 to reach user thread;
outMailHdr.from = inMailHdr.from;
outMailHdr.length = strlen(buffer) + 1;
printf("Sending GETMV response: %s\n", buffer);
success = postOffice->Send(outPktHdr, outMailHdr, buffer);
}
else
success = GetMV(mvIndex, outPktHdr, inPktHdr, outMailHdr, inMailHdr, clientNum);
break;
case DESTROYMV:
printf("DESTROYMV\n");
clientNum=100*(inPktHdr.from)+inMailHdr.from - 1;
m=0;
if(msgData[i+1] == '_')
{
i++;
do
{
c = msgData[++i];
if(c=='_')
break;
client[m++] = c;
}while(c!='_');
client[m]='\0';
clientNum = atoi(client);
}
m=0;
while(c!='\0')
{
c = msgData[++i];
mvIndexBuf[m++] = c;
}
mvIndex = atoi(mvIndexBuf);
if(mvIndex/MAX_DMV != uniqueGlobalID())
{
sprintf(buffer,"%d__%d_%s",DESTROYMV, clientNum, mvIndexBuf);
outPktHdr.to = mvIndex/MAX_DMV;
outMailHdr.to = outMailHdr.to + 1; // +1 to reach user thread;
outMailHdr.from = inMailHdr.from;
outMailHdr.length = strlen(buffer) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, buffer);
printf("Sending DESTROYMV response: %s\n", buffer);
}
else
success = DestroyMV(mvIndex, outPktHdr, inPktHdr, outMailHdr, inMailHdr, clientNum);
break;
case WAIT:
printf("WAIT\n");
clientNum=100*(inPktHdr.from)+inMailHdr.from - 1;
m=0;
if(msgData[i+1] == '_')
{
i++;
do
{
c = msgData[++i];
if(c=='_')
break;
client[m++] = c;
}while(c!='_');
client[m]='\0';
clientNum = atoi(client);
}
cvNumIndex=0;
do {
c = msgData[++i];
if(c=='_')
break;
cvNum[cvNumIndex ++] = c;
}while ( c!= '_');
cvNum[cvNumIndex]='\0';
cvIndex = atoi(cvNum);
while ( c!= '\0'){
c = msgData[++i];
lockNum[lockNumIndex ++] = c;
}
lockIndex = atoi(lockNum);
lockNumIndex = 0;
cvNumIndex = 0;
if(lockIndex/MAX_DLOCK != uniqueGlobalID())
{
sprintf(buffer,"%d__%d_%s_%s",SIGNAL, clientNum, cvNum,lockNum);
outPktHdr.to = lockIndex/MAX_DLOCK;
outMailHdr.to = outPktHdr.to;
outMailHdr.from = inMailHdr.from;
outMailHdr.length = strlen(buffer) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, buffer);
}
else
success = Wait(cvIndex, lockIndex, outPktHdr, inPktHdr, outMailHdr, inMailHdr, clientNum);
break;
case WAITCV:
printf("WAITCV\n");
clientNum=100*(inPktHdr.from)+inMailHdr.from - 1;
m=0;
if(msgData[i+1] == '_')
{
i++;
do
{
c = msgData[++i];
if(c=='_')
break;
client[m++] = c;
}while(c!='_');
client[m]='\0';
clientNum = atoi(client);
}
cvNumIndex=0;
do {
c = msgData[++i];
if(c=='_')
break;
cvNum[cvNumIndex ++] = c;
}while ( c!= '_');
cvNum[cvNumIndex]='\0';
cvIndex = atoi(cvNum);
while ( c!= '\0'){
c = msgData[++i];
lockNum[lockNumIndex ++] = c;
}
lockIndex = atoi(lockNum);
lockNumIndex = 0;
cvNumIndex = 0;
if(cvs[cvIndex%MAX_DCV] == NULL)
{
sprintf(buffer,"%d_%d_%d",WAITRESPONSE, (int)client, -1);
outPktHdr.to = clientNum/100;
outMailHdr.to = (clientNum+100)%100;
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(buffer) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, buffer);
}
else
{
if (cvs[cvIndex%MAX_DCV]->isQueueEmpty())
cvs[cvIndex%MAX_DCV]-> setFirstLock(lockIndex);
char * ack = new char [5];
itoa(ack,5,cvIndex);
outPktHdr.to = clientNum/100;
outMailHdr.to = (clientNum+100)%100;
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(ack) + 1;
Message* reply = new Message(outPktHdr, outMailHdr, ack);
cvs[cvIndex%MAX_DCV]->QueueReply(reply);
sprintf(buffer,"%d_%d_%d",WAITRESPONSE, (int)client, cvIndex);
outPktHdr.to = clientNum/100;
outMailHdr.to = (clientNum+100)%100;
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(buffer) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, buffer);
}
break;
case WAITRESPONSE:
printf("WAITRESPONSE\n");
clientNum=-1;
m=0;
if(msgData[i+1] == '_')
{
i++;
do
{
c = msgData[++i];
if(c=='_')
break;
client[m++] = c;
}while(c!='_');
client[m]='\0';
clientNum = atoi(client);
}
else
ASSERT(false);
m=0;
while(c!='\0')
{
c = msgData[++i];
cvNum[m++] = c;
}
cvIndex = atoi(cvNum);
if (cvIndex == -1)
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
success = false;
}
else
{
lockIndex = waitingForWaitLocks[clientNum];
dlocks[lockIndex]->setOwner(-1, -1);
dlocks[lockIndex]->setLockState(true);
if(!dlocks[lockIndex]->isQueueEmpty())
{
Message* reply = dlocks[lockIndex]->RemoveReply();
dlocks[lockIndex]->setOwner(reply->pktHdr.to, reply->mailHdr.to);
dlocks[lockIndex]->setLockState(false);
success = postOffice->Send(reply->pktHdr, reply->mailHdr, reply->data);
if ( !success )
{
interrupt->Halt();
}
}
}
break;
case SIGNAL:
printf("SIGNAL\n");
clientNum=-1;
m=0;
if(msgData[i+1] == '_')
{
i++;
do
{
c = msgData[++i];
if(c=='_')
break;
client[m++] = c;
}while(c!='_');
client[m]='\0';
clientNum = atoi(client);
}
else
ASSERT(false);
cvNumIndex=0;
do {
c = msgData[++i];
if(c=='_')
break;
cvNum[cvNumIndex ++] = c;
}while ( c!= '_');
cvNum[cvNumIndex]='\0';
cvIndex = atoi(cvNum);
while ( c!= '\0'){
c = msgData[++i];
lockNum[lockNumIndex ++] = c;
}
lockIndex = atoi(lockNum);
lockNumIndex = 0;
cvNumIndex = 0;
if(cvIndex/MAX_DCV != uniqueGlobalID())
{
sprintf(buffer,"%d__%d_%s_%s",SIGNAL, clientNum, cvNum,lockNum);
outPktHdr.to = cvIndex/MAX_DCV;
outMailHdr.to = outMailHdr.to + 1; // +1 to reach user thread;
outMailHdr.from = inMailHdr.from;
outMailHdr.length = strlen(buffer) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, buffer);
}
else
success = Signal(cvIndex, lockIndex, outPktHdr, inPktHdr, outMailHdr, inMailHdr,clientNum);
break;
case SIGNALLOCK:
printf("SIGNALLOCK\n");
clientNum=100*(inPktHdr.from)+inMailHdr.from - 1;
m=0;
if(msgData[i+1] == '_')
{
i++;
do
{
c = msgData[++i];
if(c=='_')
break;
client[m++] = c;
}while(c!='_');
client[m]='\0';
clientNum = atoi(client);
}
m=0;
while(c!='\0')
{
c = msgData[++i];
lockIndexBuf[m++] = c;
}
lockIndex = atoi(lockIndexBuf);
if(dlocks[lockIndex%MAX_DLOCK] == NULL)
{
sprintf(buffer,"%d_%d_%d",SIGNALRESPONSE, (int)client, -1);
outPktHdr.to = clientNum/100;
outMailHdr.to = (clientNum+100)%100;
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(buffer) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, buffer);
}
else //found
{
sprintf(buffer,"%d_%d_%d",SIGNALRESPONSE, (int)client, lockIndex);
outPktHdr.to = clientNum/100;
outMailHdr.to = (clientNum+100)%100;
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(buffer) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, buffer);
}
break;
case SIGNALRESPONSE:
printf("SIGNALRESPONSE\n");
clientNum=100*(inPktHdr.from)+inMailHdr.from - 1;
m=0;
if(msgData[i+1] == '_')
{
i++;
do
{
c = msgData[++i];
if(c=='_')
break;
client[m++] = c;
}while(c!='_');
client[m]='\0';
clientNum = atoi(client);
}
m=0;
while(c!='\0')
{
c = msgData[++i];
lockIndexBuf[m++] = c;
}
lockIndex = atoi(lockIndexBuf);
if (lockIndex == -1)
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
success = false;
}
else
{
cvIndex=waitingForSignalCvs[clientNum];
char* ack = new char [5];
itoa(ack,5,cvIndex);
outPktHdr.to = clientNum/100;
outMailHdr.to = (clientNum+100)%100;
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(ack) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, ack);
if ( !success )
{
interrupt->Halt();
}
if (!(cvs[cvIndex]->isQueueEmpty())){
if (cvs[cvIndex]->getFirstLock() != lockIndex)
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
else
{
Message* reply = cvs[cvIndex]->RemoveReply();
reply->pktHdr.from = reply->pktHdr.to;
reply->mailHdr.from = reply->mailHdr.to;
bool success2 = Acquire(lockIndex, outPktHdr, reply->pktHdr,outMailHdr, reply->mailHdr, -2);
if ( !success2 )
{
interrupt->Halt();
}
}
}
if (cvs[cvIndex]->isQueueEmpty()){
cvs[cvIndex]->setFirstLock(-1);
}
}
break;
case BROADCAST:
printf("BROADCAST\n");
clientNum=100*(inPktHdr.from)+inMailHdr.from - 1;
m=0;
if(msgData[i+1] == '_')
{
i++;
do
{
c = msgData[++i];
if(c=='_')
break;
client[m++] = c;
}while(c!='_');
client[m]='\0';
clientNum = atoi(client);
}
cvNumIndex=0;
do {
c = msgData[++i];
if(c=='_')
break;
cvNum[cvNumIndex ++] = c;
}while ( c!= '_');
cvNum[cvNumIndex]='\0';
cvIndex = atoi(cvNum);
while ( c!= '\0'){
c = msgData[++i];
lockNum[lockNumIndex ++] = c;
}
lockIndex = atoi(lockNum);
lockNumIndex = 0;
cvNumIndex = 0;
if(cvIndex/MAX_DCV != uniqueGlobalID())
{
sprintf(buffer,"%d__%d_%s_%s",BROADCAST, clientNum, cvNum,lockNum);
outPktHdr.to = cvIndex/MAX_DCV;
outMailHdr.to = outPktHdr.to;
outMailHdr.from = inMailHdr.from;
outMailHdr.length = strlen(buffer) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, buffer);
}
else
success = Broadcast(cvIndex, lockIndex, outPktHdr, inPktHdr, outMailHdr, inMailHdr, clientNum);
break;
case BROADCASTLOCK:
printf("BROADCASTLOCK\n");
clientNum=100*(inPktHdr.from)+inMailHdr.from - 1;
m=0;
if(msgData[i+1] == '_')
{
i++;
do
{
c = msgData[++i];
if(c=='_')
break;
client[m++] = c;
}while(c!='_');
client[m]='\0';
clientNum = atoi(client);
}
m=0;
while(c!='\0')
{
c = msgData[++i];
lockIndexBuf[m++] = c;
}
lockIndex = atoi(lockIndexBuf);
if(dlocks[lockIndex%MAX_DLOCK] == NULL)
{
sprintf(buffer,"%d_%d_%d",BROADCASTRESPONSE, (int)client, -1);
outPktHdr.to = clientNum/100;
outMailHdr.to = (clientNum+100)%100;
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(buffer) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, buffer);
}
else if (dlocks[lockIndex]->getOwnerMailID() == -1)
{
sprintf(buffer,"%d_%d_%d",BROADCASTRESPONSE, (int)client, -1);
outPktHdr.to = clientNum/100;
outMailHdr.to = (clientNum+100)%100;
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(buffer) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, buffer);
}
else
{
sprintf(buffer,"%d_%d_%d",BROADCASTRESPONSE, (int)client, lockIndex);
outPktHdr.to = clientNum/100;
outMailHdr.to = (clientNum+100)%100;
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(buffer) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, buffer);
}
break;
case BROADCASTRESPONSE:
printf("BROADCASTRESPONSE\n");
clientNum=100*(inPktHdr.from)+inMailHdr.from - 1;
m=0;
if(msgData[i+1] == '_')
{
i++;
do
{
c = msgData[++i];
if(c=='_')
break;
client[m++] = c;
}while(c!='_');
client[m]='\0';
clientNum = atoi(client);
}
m=0;
while(c!='\0')
{
c = msgData[++i];
lockIndexBuf[m++] = c;
}
lockIndex = atoi(lockIndexBuf);
if (lockIndex == -1)
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
success = false;
}
else
{
cvIndex=waitingForBroadcastCvs[clientNum];
lockIndex=lockIndex%MAX_DLOCK;
char* ack = new char [5];
itoa(ack,5,cvIndex);
outPktHdr.to = clientNum/100;
outMailHdr.to = (clientNum+100)%100;
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(ack) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, ack);
if ( !success )
{
interrupt->Halt();
}
fflush(stdout);
if (!(cvs[cvIndex]->isQueueEmpty())){
if (cvs[cvIndex]->getFirstLock() != lockIndex)
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
else
{
Message* reply = cvs[cvIndex]->RemoveReply();
reply->pktHdr.from = reply->pktHdr.to;
reply->mailHdr.from = reply->mailHdr.to;
bool success2 = Acquire(lockIndex, outPktHdr, reply->pktHdr,outMailHdr, reply->mailHdr, -2);
if ( !success2 ) {
interrupt->Halt();
}
fflush(stdout);
}
}
while (!(cvs[cvIndex]->isQueueEmpty()))
{
Message* reply = cvs[cvIndex]->RemoveReply();
reply->pktHdr.from = reply->pktHdr.to;
reply->mailHdr.from = reply->mailHdr.to;
bool success2 = Acquire(lockIndex, outPktHdr, reply->pktHdr,outMailHdr, reply->mailHdr, -2);
if ( !success2 ) {
interrupt->Halt();
}
}
if (cvs[cvIndex]->isQueueEmpty()){
cvs[cvIndex]->setFirstLock(-1);
}
}
break;
case DESTROYCV:
printf("DESTROYCV\n");
clientNum=100*(inPktHdr.from)+inMailHdr.from - 1;
m=0;
if(msgData[i+1] == '_')
{
i++;
do
{
c = msgData[++i];
if(c=='_')
break;
client[m++] = c;
}while(c!='_');
client[m]='\0';
clientNum = atoi(client);
}
cvNumIndex=0;
while ( c!= '\0'){
c = msgData[++i];
cvNum[cvNumIndex ++] = c;
}
cvIndex = atoi(cvNum);
if(cvIndex/MAX_DCV != uniqueGlobalID())
{
sprintf(buffer,"%d__%d_%s",DESTROYCV, clientNum, cvNum);
outPktHdr.to = cvIndex/MAX_DCV;
outMailHdr.to = outPktHdr.to;
outMailHdr.from = inMailHdr.from;
outMailHdr.length = strlen(buffer) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, buffer);
}
else
{
if ((cvIndex < 0)||(cvIndex > MAX_NUM_GLOBAL_IDS*MAX_DCV-1))
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
else if(cvIndex/MAX_DCV== uniqueGlobalID())
{
cvIndex=cvIndex%MAX_DCV;
if (cvs[cvIndex] != NULL){
delete cvs[cvIndex];
cvs[cvIndex] = NULL;
createDCVIndex --;
char* ack = new char [4];
itoa(ack,4,cvIndex);
outPktHdr.to = clientNum/100;
outMailHdr.to = (clientNum+100)%100;
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(ack) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, ack);
if ( !success ) {
interrupt->Halt();
}
}
else
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
}
else
{
outPktHdr.to = cvIndex/MAX_DCV;
outMailHdr.to = outPktHdr.to;
outMailHdr.from = inMailHdr.from;
outMailHdr.length = strlen(msgData) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, msgData);
}
}
break;
case STARTUSERPROGRAM:
printf("STARTUSERPROGRAM... should not get here\n");
ASSERT(false);
break;
case REGNETTHREAD:
printf("REGNETTHREAD... should not get here\n");
ASSERT(false);
break;
case REGNETTHREADRESPONSE:
printf("REGNETTHREADRESPONSE... should not get here\n");
ASSERT(false);
break;
case GROUPINFO:
printf("GROUPINFO... should not get here\n");
ASSERT(false);
break;
case ACK:
printf("ACK... should not get here\n");
ASSERT(false);
break;
case TIMESTAMP:
// Do nothing. The timeStamp updating will get handled in the total ordering code.
break;
case INVALIDTYPE:
printf("INVALIDTYPE... should not get here\n");
ASSERT(false);
break;
}
if (!success)
{
errorOutPktHdr = outPktHdr;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorInMailHdr = inMailHdr;
}
return success;
}
bool Acquire(int lockIndex, PacketHeader outPktHdr, PacketHeader inPktHdr, MailHeader outMailHdr, MailHeader inMailHdr, int clientNum)
{
bool success = false;
if (clientNum==-2)
clientNum=100*(inPktHdr.from)+inMailHdr.from - 1;
if((lockIndex < 0)||(lockIndex > MAX_NUM_GLOBAL_IDS*MAX_DLOCK-1))
{
printf("Cannot acquire: Lock index [%d] out of bounds [%d, %d].\n", lockIndex, 0, MAX_NUM_GLOBAL_IDS*(MAX_DLOCK-1));
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
else if(lockIndex/MAX_DLOCK == uniqueGlobalID())
{
lockIndex=lockIndex%MAX_DLOCK;
if(dlocks[lockIndex] == NULL)
{
printf("Cannot acquire: Lock does not exist at index %d.\n", lockIndex);
return false;
}
else
{
char * ack = new char [5];
itoa(ack,5,dlocks[lockIndex]->GetGlobalId());
if(!dlocks[lockIndex]->getLockState())
{
printf("Machine %d being added to waitQueue for acquiring %s!\n", clientNum/100, dlocks[lockIndex]->getName());
outPktHdr.to = clientNum/100;
outMailHdr.to = (clientNum+100)%100;
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(ack) + 1;
Message* reply = new Message(outPktHdr, outMailHdr, ack);
dlocks[lockIndex]->QueueReply(reply);
success=true;
}
else
{
dlocks[lockIndex]->setOwner(clientNum/100, (clientNum+100)%100);
dlocks[lockIndex]->setLockState(false);
outPktHdr.to = clientNum/100;
outMailHdr.to = (clientNum+100)%100 + 1; // +1 to reach user thread
outPktHdr.from = postOffice->GetID();
outMailHdr.from = currentThread->mailID;
outMailHdr.length = strlen(ack) + 1;
printf("Sending Acquire response: %s\n", ack);
success = postOffice->Send(outPktHdr, outMailHdr, ack);
if ( !success )
{
interrupt->Halt();
}
fflush(stdout);
}
return success;
}
}
else
{
sprintf(buffer,"%d__%d_%d",ACQUIRE, clientNum, lockIndex);
outPktHdr.to = lockIndex/MAX_DLOCK;
outMailHdr.to = outPktHdr.to;
outMailHdr.from = inMailHdr.from;
outMailHdr.length = strlen(buffer) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, buffer);
return success;
}
}
void CreateVerify(char* data, int requestType, int client, vector<NetThreadInfoEntry*> *localNetThreadInfo)
{
char request[MaxMailSize];
sprintf(request, "%d_%d_%s", requestType, client, data);
PacketHeader outPktHdr;
MailHeader outMailHdr;
outPktHdr.from = postOffice->GetID();
outMailHdr.from = currentThread->mailID;
outMailHdr.length = strlen(request) + 1;
// Broadcast the message to all the other NetworkThreads (servers).
for (int i = 0; i < serverCount; i++)
{
// Don't send it to ourselves.
if (localNetThreadInfo->at(i)->machineID != outPktHdr.from ||
localNetThreadInfo->at(i)->mailID != outMailHdr.from)
{
outPktHdr.to = localNetThreadInfo->at(i)->machineID;
outMailHdr.to = localNetThreadInfo->at(i)->mailID;
printf("CreateVerify Send: outPktHdr.to: %d, outMailHdr.to: %d, request: %s\n", outPktHdr.to, outMailHdr.to, request);
bool success = postOffice->Send(outPktHdr, outMailHdr, request);
if (!success)
interrupt->Halt();
printf("CreateVerify Send successful\n");
}
}
// Initialize the response to 0 so we wait for all of them.
verifyResponses[client] = 0;
}
bool Release(int lockIndex, PacketHeader outPktHdr, PacketHeader inPktHdr, MailHeader outMailHdr, MailHeader inMailHdr, int clientNum)
{
bool success = false;
if((lockIndex < 0)||(lockIndex > MAX_NUM_GLOBAL_IDS*(MAX_DLOCK)-1))
{
printf("Cannot release: Lock index [%d] out of bounds [%d, %d].\n", lockIndex, 0, MAX_NUM_GLOBAL_IDS*(MAX_DLOCK-1));
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
else if(lockIndex/MAX_DLOCK == uniqueGlobalID())
{
lockIndex=lockIndex%MAX_DLOCK;
if(dlocks[lockIndex] == NULL)
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
char * ack = new char [5];
itoa(ack,5,dlocks[lockIndex]->GetGlobalId());
printf("Machine %d has released %s at index %d\n", clientNum/100, dlocks[lockIndex]->getName(), dlocks[lockIndex]->GetGlobalId());
dlocks[lockIndex]->setOwner(-1, -1);
dlocks[lockIndex]->setLockState(true);
outPktHdr.to = clientNum/100;
outMailHdr.to = (clientNum+100)%100 + 1; // +1 to reach user thread
outPktHdr.from = postOffice->GetID();
outMailHdr.from = currentThread->mailID;
outMailHdr.length = strlen(ack) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, ack);
if ( !success ) {
interrupt->Halt();
}
if(!dlocks[lockIndex]->isQueueEmpty())
{
Message* reply = dlocks[lockIndex]->RemoveReply();
dlocks[lockIndex]->setOwner(reply->pktHdr.to, reply->mailHdr.to);
dlocks[lockIndex]->setLockState(false);
success = postOffice->Send(reply->pktHdr, reply->mailHdr, reply->data);
if ( !success )
{
interrupt->Halt();
}
}
fflush(stdout);
return success;
}
else
{
}
return false;
}
bool DestroyLock(int lockIndex, PacketHeader outPktHdr, PacketHeader inPktHdr, MailHeader outMailHdr, MailHeader inMailHdr, int clientNum)
{
bool success = false;
if((lockIndex < 0)||(lockIndex > MAX_NUM_GLOBAL_IDS*(MAX_DLOCK)-1))
{
printf("Cannot destroy: Lock index [%d] out of bounds [%d, %d].\n", lockIndex, 0, MAX_NUM_GLOBAL_IDS*(MAX_DLOCK-1));
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
else if(lockIndex/MAX_DLOCK == uniqueGlobalID())
{
lockIndex=lockIndex%MAX_DLOCK;
if(dlocks[lockIndex] == NULL)
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
char * ack = new char [5];
itoa(ack,5,dlocks[lockIndex]->GetGlobalId()); //Convert to string to send in ack
delete dlocks[lockIndex];
dlocks[lockIndex] = NULL;
createDLockIndex --;
if(dlocks[lockIndex] == NULL)
{
}
outPktHdr.to = clientNum/100;
outMailHdr.to = (clientNum+100)%100 + 1; // +1 to reach user thread
outPktHdr.from = postOffice->GetID();
outMailHdr.from = currentThread->mailID;
outMailHdr.length = strlen(ack) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, ack);
if ( !success )
{
interrupt->Halt();
}
fflush(stdout);
return success;
}
else
{
printf("problem; shouldn't have gotten past switch statement w/o being forwarded\n");
}
return false;
}
bool SetMV(int mvIndex, int value, PacketHeader outPktHdr, PacketHeader inPktHdr, MailHeader outMailHdr, MailHeader inMailHdr, int clientNum)
{
bool success = false;
if((mvIndex < 0)||(mvIndex > MAX_NUM_GLOBAL_IDS*MAX_DMV-1))
{
printf("Cannot set: MV index [%d] out of bounds [%d, %d].\n", mvIndex, 0, MAX_NUM_GLOBAL_IDS*(MAX_DMV-1));
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
else if (mvIndex/MAX_DMV == uniqueGlobalID())
{
mvIndex=mvIndex%MAX_DMV;
if(mvs[mvIndex] == NULL) //If not found
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
char * ack = new char [24];
for(int i = 0; i < 24; i++)
ack[i] = '\0';
sprintf(ack, "SetMV[%d] = %d", mvs[mvIndex]->GetGlobalId(), value);
mvs[mvIndex]->setValue(value);
outPktHdr.to = clientNum/100;
outMailHdr.to = (clientNum+100)%100 + 1; // +1 to reach user thread
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(ack) + 1;
printf("Sending SetMV response: %s\n", ack);
success = postOffice->Send(outPktHdr, outMailHdr, ack);
if ( !success )
{
interrupt->Halt();
}
fflush(stdout);
return success;
}
else
{
printf("problem; shouldn't have gotten past switch statement w/o being forwarded\n");
}
return false;
}
bool GetMV(int mvIndex, PacketHeader outPktHdr, PacketHeader inPktHdr, MailHeader outMailHdr, MailHeader inMailHdr, int clientNum)
{
bool success = false;
char* ack = new char [4];
if((mvIndex < 0)||(mvIndex > MAX_NUM_GLOBAL_IDS*MAX_DMV-1))
{
itoa(ack,4,999);
return SendReply(outPktHdr, inPktHdr, outMailHdr, inMailHdr, ack);
}
else if (mvIndex/MAX_DMV == uniqueGlobalID())
{
mvIndex=mvIndex%MAX_DMV;
if(mvs[mvIndex] == NULL)
{
printf("Cannot get: MV index [%d] out of bounds [%d, %d].\n", mvIndex, 0, MAX_NUM_GLOBAL_IDS*(MAX_DMV-1));
itoa(ack,4,999);
outPktHdr.to = clientNum/100;
outMailHdr.to = (clientNum+100)%100;
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(ack) + 1;
return SendReply(outPktHdr, inPktHdr, outMailHdr, inMailHdr, ack);
}
outPktHdr.to = clientNum/100;
outMailHdr.to = (clientNum+100)%100;
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(ack) + 1;
itoa(ack,4,mvs[mvIndex]->getValue());
return SendReply(outPktHdr, inPktHdr, outMailHdr, inMailHdr, ack);
}
else
{
printf("problem; shouldn't have gotten past switch statement w/o being forwarded\n");
}
return false;
}
bool DestroyMV(int mvIndex, PacketHeader outPktHdr, PacketHeader inPktHdr, MailHeader outMailHdr, MailHeader inMailHdr, int clientNum)
{
bool success = false;
if((mvIndex < 0)||(mvIndex > MAX_NUM_GLOBAL_IDS*MAX_DMV-1))
{
printf("Cannot destroy: MV index [%d] out of bounds [%d, %d].\n", mvIndex, 0, MAX_NUM_GLOBAL_IDS*(MAX_DMV-1));
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
else if (mvIndex/MAX_DMV == uniqueGlobalID())
{
mvIndex=mvIndex%MAX_DMV;
if(mvs[mvIndex] == NULL)
{
printf("Cannot get: MV does not exist at index %d.\n", mvIndex);
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
char * ack = new char [5];
itoa(ack,5,mvs[mvIndex]->GetGlobalId());
delete mvs[mvIndex];
mvs[mvIndex] = NULL;
createDMVIndex --;
if(mvs[mvIndex] == NULL)
{
}
outPktHdr.to = clientNum/100;
outMailHdr.to = (clientNum+100)%100;
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(ack) + 1;
printf("Sending DestroyMV response: %s\n", ack);
success = postOffice->Send(outPktHdr, outMailHdr, ack);
if ( !success )
{
interrupt->Halt();
}
fflush(stdout);
return success;
}
else
{
}
return false;
}
bool Wait(int cvIndex, int lockIndex, PacketHeader outPktHdr, PacketHeader inPktHdr, MailHeader outMailHdr, MailHeader inMailHdr, int clientNum){
bool success;
if((lockIndex < 0)||(lockIndex > MAX_NUM_GLOBAL_IDS*(MAX_DLOCK-1)))
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
else if ((cvIndex < 0)||(cvIndex > MAX_NUM_GLOBAL_IDS*(MAX_DCV-1)))
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
if (lockIndex/MAX_DLOCK == uniqueGlobalID() && cvIndex/MAX_DCV == uniqueGlobalID())
{
lockIndex=lockIndex%MAX_DLOCK;
cvIndex=cvIndex%MAX_DCV;
if(dlocks[lockIndex] == NULL)
{
printf("Wait Failed: Lock does not exist at index %d.\n", lockIndex);
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
else if (dlocks[lockIndex]->getOwnerMailID() == -1)
{
printf("Wait Failed: Lock does not acquire at index %d.\n", lockIndex);
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
else if(cvs[cvIndex] == NULL)
{
printf("Wait Failed: CV does not exist at index %d.\n", cvIndex);
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
dlocks[lockIndex]->setOwner(-1, -1);
dlocks[lockIndex]->setLockState(true);
if (cvs[cvIndex]->isQueueEmpty())
cvs[cvIndex]-> setFirstLock(lockIndex+uniqueGlobalID()*MAX_DLOCK);
if(!dlocks[lockIndex]->isQueueEmpty())
{
Message* reply = dlocks[lockIndex]->RemoveReply();
dlocks[lockIndex]->setOwner(reply->pktHdr.to, reply->mailHdr.to);
dlocks[lockIndex]->setLockState(false);
success = postOffice->Send(reply->pktHdr, reply->mailHdr, reply->data);
if ( !success )
{
interrupt->Halt();
}
fflush(stdout);
}
char * ack = new char [5];
itoa(ack,5,cvIndex+uniqueGlobalID()*MAX_DCV);
outPktHdr.to = clientNum/100;
outMailHdr.to = (clientNum+100)%100;
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(ack) + 1;
Message* reply = new Message(outPktHdr, outMailHdr, ack);
cvs[cvIndex]->QueueReply(reply);
return true;
}
else if (lockIndex/MAX_DLOCK == uniqueGlobalID() && cvIndex/MAX_DCV != uniqueGlobalID())
{
lockIndex=lockIndex%MAX_DLOCK;
cvIndex=cvIndex%MAX_DCV;
if(dlocks[lockIndex] == NULL)
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
else if (dlocks[lockIndex]->getOwnerMailID() == -1)
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
char* request = new char [MaxMailSize];
waitingForWaitLocks[clientNum] = lockIndex;
sprintf(request,"%d_%d_%d_%d",WAITCV, clientNum,cvIndex+uniqueGlobalID()*MAX_DLOCK, lockIndex+uniqueGlobalID()*MAX_DLOCK);
outPktHdr.to = cvIndex/MAX_DCV;
outMailHdr.to = outPktHdr.to;
outMailHdr.from = inMailHdr.from;
outMailHdr.length = strlen(request) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, request);
}
return success;
}
bool Signal(int cvIndex, int lockIndex, PacketHeader outPktHdr, PacketHeader inPktHdr, MailHeader outMailHdr, MailHeader inMailHdr, int clientNum)
{
bool success = false;
if((lockIndex < 0)||(lockIndex > MAX_NUM_GLOBAL_IDS*(MAX_DLOCK)-1))
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
else if ((cvIndex < 0)||(cvIndex > MAX_NUM_GLOBAL_IDS*MAX_DCV-1))
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
if (lockIndex/MAX_DLOCK == uniqueGlobalID() && cvIndex/MAX_DCV == uniqueGlobalID())
{
lockIndex=lockIndex%MAX_DLOCK;
cvIndex=cvIndex%MAX_DCV;
if(dlocks[lockIndex] == NULL)
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
else if (dlocks[lockIndex]->getOwnerMailID() == -1)
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
else if(cvs[cvIndex] == NULL)
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
char* ack = new char [5];
itoa(ack,5,cvIndex);
outPktHdr.to = clientNum/100;
outMailHdr.to = (clientNum+100)%100;
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(ack) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, ack);
if ( !success )
{
interrupt->Halt();
}
fflush(stdout);
if (!(cvs[cvIndex]->isQueueEmpty())){
if (cvs[cvIndex]->getFirstLock() != lockIndex+uniqueGlobalID()*MAX_DLOCK)
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
else
{
Message* reply = cvs[cvIndex]->RemoveReply();
reply->pktHdr.from = reply->pktHdr.to;
reply->mailHdr.from = reply->mailHdr.to;
bool success2 = Acquire(lockIndex+uniqueGlobalID()*MAX_DLOCK, outPktHdr, reply->pktHdr,outMailHdr, reply->mailHdr, -2);
if ( !success2 )
{
interrupt->Halt();
}
fflush(stdout);
}
}
if (cvs[cvIndex]->isQueueEmpty()){
cvs[cvIndex]->setFirstLock(-1);
}
return success;
}
else if (lockIndex/MAX_DLOCK != uniqueGlobalID() && cvIndex/MAX_DCV == uniqueGlobalID())// lock not on this server
{
char* request = new char [MaxMailSize];
waitingForSignalCvs[clientNum] = cvIndex;
sprintf(request,"%d_%d_%d",SIGNALLOCK, clientNum, lockIndex+uniqueGlobalID()*MAX_DLOCK);
outPktHdr.to = lockIndex/MAX_DLOCK;
outMailHdr.to = outPktHdr.to;
outMailHdr.from = inMailHdr.from;
outMailHdr.length = strlen(request) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, request);
}
return success;
}
bool Broadcast(int cvIndex, int lockIndex, PacketHeader outPktHdr, PacketHeader inPktHdr, MailHeader outMailHdr, MailHeader inMailHdr, int clientNum){
bool success = false;
if((lockIndex < 0)||(lockIndex > (MAX_DLOCK-1)))
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
else if ((cvIndex < 0)||(cvIndex > (MAX_DCV-1)))
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
if (lockIndex/MAX_DLOCK == uniqueGlobalID() && cvIndex/MAX_DCV == uniqueGlobalID())
{
lockIndex=lockIndex%MAX_DLOCK;
cvIndex=cvIndex%MAX_DCV;
if(dlocks[lockIndex] == NULL)
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
else if (dlocks[lockIndex]->getOwnerMailID() == -1)
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
else if(cvs[cvIndex] == NULL)
{
errorOutPktHdr = outPktHdr;
errorOutPktHdr.to = clientNum/100;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorOutMailHdr.to = (clientNum+100)%100;
errorInMailHdr = inMailHdr;
return false;
}
char* ack = new char [5];
itoa(ack,5,cvIndex);
outPktHdr.to = inPktHdr.from;
outMailHdr.to = inMailHdr.from;
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(ack) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, ack);
if ( !success )
{
interrupt->Halt();
}
fflush(stdout);
if (!(cvs[cvIndex]->isQueueEmpty())){
if (cvs[cvIndex]->getFirstLock() != lockIndex+uniqueGlobalID()*MAX_DLOCK)
{
errorOutPktHdr = outPktHdr;
errorInPktHdr = inPktHdr;
errorOutMailHdr = outMailHdr;
errorInMailHdr = inMailHdr;
return false;
}
else{
Message* reply = cvs[cvIndex]->RemoveReply();
reply->pktHdr.from = reply->pktHdr.to;
reply->mailHdr.from = reply->mailHdr.to;
bool success2 = Acquire(lockIndex+uniqueGlobalID()*MAX_DLOCK, outPktHdr, reply->pktHdr,outMailHdr, reply->mailHdr, -2);
if ( !success2 )
{
interrupt->Halt();
}
fflush(stdout);
}
}
while (!(cvs[cvIndex]->isQueueEmpty())){
Message* reply = cvs[cvIndex]->RemoveReply();
reply->pktHdr.from = reply->pktHdr.to;
reply->mailHdr.from = reply->mailHdr.to;
bool success2 = Acquire(lockIndex+uniqueGlobalID()*MAX_DLOCK, outPktHdr, reply->pktHdr,outMailHdr, reply->mailHdr, -2);
if ( !success2 )
{
interrupt->Halt();
}
fflush(stdout);
}
if (cvs[cvIndex]->isQueueEmpty()){
cvs[cvIndex]->setFirstLock(-1);
}
return success;
}
else
{
char* request = new char [MaxMailSize];
waitingForBroadcastCvs[clientNum] = cvIndex;
sprintf(request,"%d_%d_%d",BROADCASTLOCK, clientNum, lockIndex+uniqueGlobalID()*MAX_DLOCK);
outPktHdr.to = lockIndex/MAX_DLOCK;
outMailHdr.to = outPktHdr.to;
outMailHdr.from = inMailHdr.from;
outMailHdr.length = strlen(request) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, request);
return success;
}
}
bool SendReply(PacketHeader outPktHdr, PacketHeader inPktHdr, MailHeader outMailHdr, MailHeader inMailHdr, char* data)
{
bool success = false;
outPktHdr.to = inPktHdr.from;
outMailHdr.to = inMailHdr.from;
outMailHdr.from = postOffice->GetID();
outMailHdr.length = strlen(data) + 1;
success = postOffice->Send(outPktHdr, outMailHdr, data);
if ( !success )
{
interrupt->Halt();
}
fflush(stdout);
return success;
}
int myexp ( int count ) {
int i, val=1;
for (i=0; i<count; i++ ) {
val = val * 10;
}
return val;
}
void itoa( char arr[], int size, int val ) {
int i, max, dig, subval, loc;
for (i=0; i<size; i++ ) {
arr[i] = '\0';
}
for ( i=1; i<=10; i++ ) {
if (( val / myexp(i) ) == 0 ) {
max = i-1;
break;
}
}
subval = 0;
loc = 0;
for ( i=max; i>=0; i-- ) {
dig = 48 + ((val-subval) / myexp(i));
subval += (dig-48) * myexp(i);
arr[loc] = dig;
loc++;
}
return;
}
void sendError(){
bool success = false;
int errorNum = -6;
char * data = new char [4];
itoa(data,4,errorNum);
errorOutPktHdr.to = errorInPktHdr.from;
errorOutMailHdr.to = errorInMailHdr.from;
errorOutMailHdr.from = postOffice->GetID();
errorOutMailHdr.length = strlen(data) + 1;
success = postOffice->Send(errorOutPktHdr, errorOutMailHdr, data);
if ( !success )
{
interrupt->Halt();
}
fflush(stdout);
}
| [
"lewij3@64a47c91-1020-2430-03ac-642e8966e14f",
"[email protected]",
"KWarp11@64a47c91-1020-2430-03ac-642e8966e14f"
] | [
[
[
1,
1
],
[
3,
3
],
[
8,
10
],
[
13,
16
],
[
20,
54
],
[
85,
85
],
[
109,
109
],
[
258,
258
],
[
276,
276
],
[
280,
284
],
[
287,
288
],
[
292,
294
],
[
296,
296
],
[
299,
299
],
[
310,
310
],
[
316,
317
],
[
321,
321
],
[
323,
323
],
[
325,
325
],
[
328,
328
],
[
330,
330
],
[
335,
335
],
[
337,
340
],
[
445,
452
],
[
683,
683
],
[
687,
687
],
[
689,
689
],
[
691,
691
],
[
694,
694
],
[
696,
696
],
[
701,
701
],
[
703,
706
],
[
792,
792
],
[
801,
809
],
[
968,
968
],
[
972,
972
],
[
974,
974
],
[
976,
976
],
[
979,
979
],
[
981,
981
],
[
983,
983
],
[
986,
986
],
[
988,
992
],
[
1073,
1073
],
[
1081,
1081
],
[
1083,
1084
],
[
1086,
1086
],
[
1093,
1102
],
[
1265,
1265
],
[
1270,
1273
],
[
1276,
1277
],
[
1281,
1282
],
[
1285,
1285
],
[
1288,
1288
],
[
1292,
1294
],
[
1296,
1297
],
[
1299,
1303
],
[
1305,
1305
],
[
1308,
1308
],
[
1310,
1313
],
[
1315,
1325
],
[
1327,
1330
],
[
1332,
1334
],
[
1336,
1337
],
[
1340,
1345
],
[
1348,
1348
],
[
1350,
1353
],
[
1355,
1365
],
[
1367,
1369
],
[
1371,
1382
],
[
1385,
1385
],
[
1387,
1390
],
[
1392,
1400
],
[
1402,
1411
],
[
1413,
1415
],
[
1417,
1419
],
[
1421,
1422
],
[
1425,
1430
],
[
1433,
1433
],
[
1435,
1438
],
[
1440,
1450
],
[
1452,
1455
],
[
1457,
1459
],
[
1461,
1462
],
[
1465,
1471
],
[
1474,
1474
],
[
1476,
1479
],
[
1481,
1491
],
[
1493,
1496
],
[
1498,
1500
],
[
1502,
1504
],
[
1507,
1511
],
[
1514,
1514
],
[
1516,
1519
],
[
1521,
1530
],
[
1532,
1539
],
[
1541,
1546
],
[
1548,
1560
],
[
1563,
1563
],
[
1565,
1568
],
[
1570,
1579
],
[
1581,
1588
],
[
1590,
1597
],
[
1599,
1599
],
[
1602,
1612
],
[
1615,
1620
],
[
1624,
1630
],
[
1633,
1633
],
[
1635,
1638
],
[
1640,
1647
],
[
1651,
1653
],
[
1655,
1660
],
[
1662,
1663
],
[
1665,
1688
],
[
1691,
1691
],
[
1693,
1696
],
[
1698,
1705
],
[
1709,
1710
],
[
1712,
1719
],
[
1721,
1727
],
[
1729,
1731
],
[
1733,
1742
],
[
1745,
1745
],
[
1747,
1750
],
[
1752,
1762
],
[
1764,
1768
],
[
1770,
1770
],
[
1773,
1779
],
[
1783,
1789
],
[
1792,
1792
],
[
1794,
1797
],
[
1799,
1809
],
[
1811,
1816
],
[
1818,
1819
],
[
1821,
1829
],
[
1832,
1845
],
[
1847,
1848
],
[
1850,
1871
],
[
1874,
1874
],
[
1876,
1879
],
[
1881,
1890
],
[
1892,
1899
],
[
1901,
1907
],
[
1909,
1922
],
[
1925,
1925
],
[
1927,
1930
],
[
1932,
1942
],
[
1944,
1948
],
[
1950,
1950
],
[
1953,
1959
],
[
1961,
1961
],
[
1964,
1970
],
[
1974,
1980
],
[
1983,
1983
],
[
1985,
1988
],
[
1990,
2000
],
[
2002,
2007
],
[
2009,
2010
],
[
2012,
2021
],
[
2024,
2038
],
[
2040,
2041
],
[
2043,
2078
],
[
2081,
2081
],
[
2083,
2086
],
[
2088,
2097
],
[
2099,
2101
],
[
2103,
2112
],
[
2114,
2115
],
[
2117,
2118
],
[
2120,
2122
],
[
2124,
2133
],
[
2136,
2147
],
[
2149,
2150
],
[
2152,
2160
],
[
2163,
2165
],
[
2196,
2206
],
[
2208,
2210
],
[
2212,
2212
],
[
2214,
2214
],
[
2216,
2216
],
[
2218,
2219
],
[
2221,
2223
],
[
2225,
2238
],
[
2240,
2240
],
[
2243,
2251
],
[
2253,
2254
],
[
2259,
2259
],
[
2262,
2285
],
[
2287,
2287
],
[
2290,
2292
],
[
2296,
2296
],
[
2300,
2300
],
[
2304,
2304
],
[
2309,
2310
],
[
2315,
2316
],
[
2320,
2321
],
[
2323,
2324
],
[
2326,
2326
],
[
2328,
2328
],
[
2330,
2331
],
[
2333,
2335
],
[
2337,
2341
],
[
2343,
2344
],
[
2346,
2351
],
[
2353,
2356
],
[
2363,
2387
],
[
2389,
2390
],
[
2392,
2393
],
[
2395,
2395
],
[
2397,
2397
],
[
2399,
2400
],
[
2402,
2404
],
[
2406,
2410
],
[
2412,
2413
],
[
2415,
2428
],
[
2434,
2448
],
[
2450,
2451
],
[
2453,
2455
],
[
2457,
2457
],
[
2459,
2459
],
[
2461,
2462
],
[
2464,
2466
],
[
2468,
2472
],
[
2474,
2475
],
[
2477,
2480
],
[
2488,
2489
],
[
2492,
2493
],
[
2496,
2509
],
[
2511,
2512
],
[
2514,
2517
],
[
2519,
2522
],
[
2524,
2527
],
[
2529,
2529
],
[
2532,
2536
],
[
2539,
2549
],
[
2551,
2552
],
[
2554,
2555
],
[
2557,
2557
],
[
2559,
2559
],
[
2561,
2562
],
[
2564,
2566
],
[
2568,
2573
],
[
2575,
2576
],
[
2578,
2591
],
[
2594,
2595
],
[
2598,
2610
],
[
2612,
2613
],
[
2615,
2616
],
[
2618,
2619
],
[
2621,
2622
],
[
2624,
2626
],
[
2628,
2629
],
[
2631,
2632
],
[
2634,
2636
],
[
2638,
2644
],
[
2646,
2647
],
[
2649,
2655
],
[
2657,
2658
],
[
2660,
2666
],
[
2668,
2669
],
[
2671,
2678
],
[
2680,
2696
],
[
2698,
2698
],
[
2701,
2707
],
[
2709,
2714
],
[
2716,
2717
],
[
2719,
2724
],
[
2726,
2727
],
[
2729,
2733
],
[
2735,
2743
],
[
2745,
2747
],
[
2749,
2750
],
[
2752,
2753
],
[
2755,
2757
],
[
2759,
2760
],
[
2762,
2763
],
[
2765,
2768
],
[
2770,
2775
],
[
2777,
2778
],
[
2780,
2785
],
[
2787,
2788
],
[
2790,
2795
],
[
2797,
2798
],
[
2800,
2806
],
[
2809,
2820
],
[
2822,
2824
],
[
2826,
2827
],
[
2829,
2836
],
[
2838,
2850
],
[
2852,
2854
],
[
2856,
2864
],
[
2866,
2871
],
[
2873,
2874
],
[
2876,
2881
],
[
2883,
2884
],
[
2886,
2888
],
[
2890,
2895
],
[
2897,
2898
],
[
2900,
2905
],
[
2907,
2908
],
[
2910,
2915
],
[
2917,
2918
],
[
2920,
2939
],
[
2941,
2951
],
[
2953,
2964
],
[
2966,
2983
],
[
2985,
2993
],
[
2995,
3045
],
[
3047,
3067
]
],
[
[
2,
2
],
[
4,
7
],
[
11,
12
],
[
17,
19
],
[
55,
84
],
[
86,
108
],
[
110,
175
],
[
177,
207
],
[
210,
210
],
[
222,
256
],
[
260,
260
],
[
264,
265
],
[
267,
275
],
[
277,
279
],
[
285,
286
],
[
289,
291
],
[
295,
295
],
[
297,
298
],
[
300,
300
],
[
303,
309
],
[
311,
315
],
[
319,
320
],
[
322,
322
],
[
324,
324
],
[
326,
327
],
[
329,
329
],
[
331,
334
],
[
336,
336
],
[
341,
428
],
[
434,
444
],
[
453,
682
],
[
685,
686
],
[
688,
688
],
[
690,
690
],
[
692,
693
],
[
695,
695
],
[
697,
700
],
[
702,
702
],
[
707,
791
],
[
793,
800
],
[
810,
967
],
[
970,
971
],
[
973,
973
],
[
975,
975
],
[
977,
978
],
[
980,
980
],
[
982,
982
],
[
984,
985
],
[
987,
987
],
[
993,
1072
],
[
1075,
1075
],
[
1085,
1085
],
[
1087,
1092
],
[
1103,
1264
],
[
1267,
1269
],
[
1274,
1275
],
[
1278,
1280
],
[
1283,
1284
],
[
1286,
1287
],
[
1289,
1289
],
[
1295,
1295
],
[
1304,
1304
],
[
1309,
1309
],
[
1314,
1314
],
[
1326,
1326
],
[
1349,
1349
],
[
1354,
1354
],
[
1366,
1366
],
[
1386,
1386
],
[
1391,
1391
],
[
1401,
1401
],
[
1412,
1412
],
[
1434,
1434
],
[
1439,
1439
],
[
1451,
1451
],
[
1475,
1475
],
[
1480,
1480
],
[
1492,
1492
],
[
1515,
1515
],
[
1520,
1520
],
[
1531,
1531
],
[
1540,
1540
],
[
1564,
1564
],
[
1569,
1569
],
[
1580,
1580
],
[
1589,
1589
],
[
1598,
1598
],
[
1600,
1601
],
[
1613,
1614
],
[
1621,
1623
],
[
1634,
1634
],
[
1639,
1639
],
[
1654,
1654
],
[
1661,
1661
],
[
1664,
1664
],
[
1692,
1692
],
[
1697,
1697
],
[
1711,
1711
],
[
1720,
1720
],
[
1746,
1746
],
[
1751,
1751
],
[
1763,
1763
],
[
1769,
1769
],
[
1771,
1772
],
[
1780,
1782
],
[
1793,
1793
],
[
1798,
1798
],
[
1810,
1810
],
[
1817,
1817
],
[
1820,
1820
],
[
1830,
1831
],
[
1846,
1846
],
[
1849,
1849
],
[
1875,
1875
],
[
1880,
1880
],
[
1891,
1891
],
[
1900,
1900
],
[
1926,
1926
],
[
1931,
1931
],
[
1943,
1943
],
[
1949,
1949
],
[
1951,
1952
],
[
1960,
1960
],
[
1962,
1963
],
[
1971,
1973
],
[
1984,
1984
],
[
1989,
1989
],
[
2001,
2001
],
[
2008,
2008
],
[
2011,
2011
],
[
2022,
2023
],
[
2039,
2039
],
[
2042,
2042
],
[
2082,
2082
],
[
2087,
2087
],
[
2098,
2098
],
[
2116,
2116
],
[
2119,
2119
],
[
2134,
2135
],
[
2148,
2148
],
[
2151,
2151
],
[
2161,
2162
],
[
2187,
2189
],
[
2207,
2207
],
[
2217,
2217
],
[
2220,
2220
],
[
2239,
2239
],
[
2241,
2242
],
[
2252,
2252
],
[
2255,
2255
],
[
2286,
2286
],
[
2288,
2289
],
[
2298,
2299
],
[
2301,
2301
],
[
2305,
2305
],
[
2311,
2314
],
[
2317,
2319
],
[
2322,
2322
],
[
2329,
2329
],
[
2332,
2332
],
[
2342,
2342
],
[
2345,
2345
],
[
2352,
2352
],
[
2388,
2388
],
[
2391,
2391
],
[
2398,
2398
],
[
2401,
2401
],
[
2411,
2411
],
[
2414,
2414
],
[
2429,
2429
],
[
2449,
2449
],
[
2452,
2452
],
[
2460,
2460
],
[
2463,
2463
],
[
2473,
2473
],
[
2476,
2476
],
[
2490,
2490
],
[
2510,
2510
],
[
2513,
2513
],
[
2530,
2531
],
[
2537,
2538
],
[
2550,
2550
],
[
2553,
2553
],
[
2560,
2560
],
[
2563,
2563
],
[
2574,
2574
],
[
2577,
2577
],
[
2592,
2593
],
[
2611,
2611
],
[
2614,
2614
],
[
2620,
2620
],
[
2623,
2623
],
[
2630,
2630
],
[
2633,
2633
],
[
2645,
2645
],
[
2648,
2648
],
[
2656,
2656
],
[
2659,
2659
],
[
2667,
2667
],
[
2670,
2670
],
[
2699,
2700
],
[
2715,
2715
],
[
2718,
2718
],
[
2725,
2725
],
[
2728,
2728
],
[
2744,
2744
],
[
2751,
2751
],
[
2754,
2754
],
[
2761,
2761
],
[
2764,
2764
],
[
2776,
2776
],
[
2779,
2779
],
[
2786,
2786
],
[
2789,
2789
],
[
2796,
2796
],
[
2799,
2799
],
[
2807,
2808
],
[
2825,
2825
],
[
2828,
2828
],
[
2865,
2865
],
[
2872,
2872
],
[
2875,
2875
],
[
2882,
2882
],
[
2885,
2885
],
[
2896,
2896
],
[
2899,
2899
],
[
2906,
2906
],
[
2909,
2909
],
[
2916,
2916
],
[
2919,
2919
],
[
2994,
2994
],
[
3046,
3046
]
],
[
[
176,
176
],
[
208,
209
],
[
211,
221
],
[
257,
257
],
[
259,
259
],
[
261,
263
],
[
266,
266
],
[
301,
302
],
[
318,
318
],
[
429,
433
],
[
684,
684
],
[
969,
969
],
[
1074,
1074
],
[
1076,
1080
],
[
1082,
1082
],
[
1266,
1266
],
[
1290,
1291
],
[
1298,
1298
],
[
1306,
1307
],
[
1331,
1331
],
[
1335,
1335
],
[
1338,
1339
],
[
1346,
1347
],
[
1370,
1370
],
[
1383,
1384
],
[
1416,
1416
],
[
1420,
1420
],
[
1423,
1424
],
[
1431,
1432
],
[
1456,
1456
],
[
1460,
1460
],
[
1463,
1464
],
[
1472,
1473
],
[
1497,
1497
],
[
1501,
1501
],
[
1505,
1506
],
[
1512,
1513
],
[
1547,
1547
],
[
1561,
1562
],
[
1631,
1632
],
[
1648,
1650
],
[
1689,
1690
],
[
1706,
1708
],
[
1728,
1728
],
[
1732,
1732
],
[
1743,
1744
],
[
1790,
1791
],
[
1872,
1873
],
[
1908,
1908
],
[
1923,
1924
],
[
1981,
1982
],
[
2079,
2080
],
[
2102,
2102
],
[
2113,
2113
],
[
2123,
2123
],
[
2166,
2186
],
[
2190,
2195
],
[
2211,
2211
],
[
2213,
2213
],
[
2215,
2215
],
[
2224,
2224
],
[
2256,
2258
],
[
2260,
2261
],
[
2293,
2295
],
[
2297,
2297
],
[
2302,
2303
],
[
2306,
2308
],
[
2325,
2325
],
[
2327,
2327
],
[
2336,
2336
],
[
2357,
2362
],
[
2394,
2394
],
[
2396,
2396
],
[
2405,
2405
],
[
2430,
2433
],
[
2456,
2456
],
[
2458,
2458
],
[
2467,
2467
],
[
2481,
2487
],
[
2491,
2491
],
[
2494,
2495
],
[
2518,
2518
],
[
2523,
2523
],
[
2528,
2528
],
[
2556,
2556
],
[
2558,
2558
],
[
2567,
2567
],
[
2596,
2597
],
[
2617,
2617
],
[
2627,
2627
],
[
2637,
2637
],
[
2679,
2679
],
[
2697,
2697
],
[
2708,
2708
],
[
2734,
2734
],
[
2748,
2748
],
[
2758,
2758
],
[
2769,
2769
],
[
2821,
2821
],
[
2837,
2837
],
[
2851,
2851
],
[
2855,
2855
],
[
2889,
2889
],
[
2940,
2940
],
[
2952,
2952
],
[
2965,
2965
],
[
2984,
2984
]
]
] |
b62ce535bf3ac48572118c00b2d049dac91cf46f | f057c62b9392fa28f2b941c7db65b0983d4fd317 | /uEpgUI/uEpgUI/EntryLayer.h | a94e0dc4e4d76144bccfea07b87f3f04bcef46c1 | [] | no_license | r2d23cpo/uepg | 710c5f29a086cfa39bb01b84dae0bd22121f03fa | c10f841f85fa8ed88e52d1664d197f4f9f47cdd0 | refs/heads/master | 2021-01-10T04:52:01.886770 | 2008-10-02T21:19:03 | 2008-10-02T21:19:03 | 48,803,326 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,158 | h | #pragma once
#include "stdafx.h"
#include "MemoryLayer.h"
#include <string>
// EntryLayer
class CEntryLayer: public CMemoryLayer
{
public:
CEntryLayer();
~CEntryLayer();
enum Direction
{
DirectionNone=0,
DirectionLeft=1,
DirectionRight=2,
DirectionTop=4,
DirectionBottom=8
};
void RenderRect(const CRect& rect, enum Direction underflow);
void RenderVisible(const CRect& parentRect, CPoint* parentPosition=0);
void SetPosition(CDC* pParentDC, CRect r);
void SetPosition(CPoint p) { _position = p; }
const CPoint& GetPosition() { return _position; }
const CRect& GetVisibleRect() { return _visibleRect; }
void setTitle(std::string title) { _title = title; }
void setDescription(std::string d) { _description = d; }
protected:
void DrawArrow(int dstX, int dstY, int w, enum Direction d);
CRect ComputeVisibleRect(const CRect& parentRect, CPoint* parentPosition=0, enum Direction* pUnderflow=0);
CPoint _position;
CRect _visibleRect;
CFont _fontSmall;
CFont _fontBig;
int _minHeight;
int _minWidth;
std::string _title;
std::string _description;
};
| [
"Jonathan.Fillion@f94d0768-90c5-11dd-aee7-853fd145579a"
] | [
[
[
1,
50
]
]
] |
00d1d1161cb469569a61f3b4d2af4ff703fd6367 | be2e23022d2eadb59a3ac3932180a1d9c9dee9c2 | /GameServer/MapGroupKernel/NpcStorage.h | 98d53170176d6f4f8292931cc5f4550b75abe825 | [] | no_license | cronoszeu/revresyksgpr | 78fa60d375718ef789042c452cca1c77c8fa098e | 5a8f637e78f7d9e3e52acdd7abee63404de27e78 | refs/heads/master | 2020-04-16T17:33:10.793895 | 2010-06-16T12:52:45 | 2010-06-16T12:52:45 | 35,539,807 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 880 | h |
#pragma once
#include "Item.h"
#include "Myheap.h"
#include "Package.h"
class CPackage;
class CNpcTrunk
{
protected:
CNpcTrunk();
virtual ~CNpcTrunk();
public:
static CNpcTrunk* CreateNew() { return new CNpcTrunk; }
ULONG Release() { delete this; return 0; }
public:
bool Create(PROCESS_ID, OBJID idRecordNpc, int nSize, int nPosition = ITEMPOSITION_TRUNK);
CPackage* QueryPackage(OBJID idPlayer=ID_NONE); // { ASSERT(m_pPackage); return m_pPackage; }
bool IsPackageFull(OBJID idPlayer=ID_NONE) { return QueryPackage(idPlayer)->GetAmount() >= m_nSize; }
bool IsEmpty(OBJID idPlayer=ID_NONE) { return QueryPackage(idPlayer)->GetAmount() == 0; }
protected:
CPackage* m_pPackage;
int m_nSize;
int m_nPosition;
OBJID m_idRecordNpc;
private: // ctrl
PROCESS_ID m_idProcess;
MYHEAP_DECLARATION(s_heap)
};
| [
"rpgsky.com@cc92e6ba-efcf-11de-bf31-4dec8810c1c1"
] | [
[
[
1,
36
]
]
] |
7721f2c02a6e877ff8a6e161df83fdafc9ef64eb | 61fc00b53ce93f09a6a586a48ae9e484b74b6655 | /src/tool/src/wrapper/chemicalwrapper.h | d6a5d3d90afef254ffe2a344108d3ddfafb03794 | [] | no_license | mickaelgadroy/wmavo | 4162c5c7c8d9082060be91e774893e9b2b23099b | db4a986d345d0792991d0e3a3d728a4905362a26 | refs/heads/master | 2021-01-04T22:33:25.103444 | 2011-11-04T10:44:50 | 2011-11-04T10:44:50 | 1,381,704 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,169 | h |
/*******************************************************************************
Copyright (C) 2011 Mickael Gadroy, University of Reims Champagne-Ardenne (Fr)
Project managers: Eric Henon and Michael Krajecki
Financial support: Region Champagne-Ardenne (Fr)
This file is part of WmAvo (WiiChem project)
WmAvo - Integrate the Wiimote and the Nunchuk in Avogadro software for the
handling of the atoms and the camera.
For more informations, see the README file.
WmAvo is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
WmAvo 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 WmAvo. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
#pragma once
#ifndef __CHEMICALWRAPPER_H__
#define __CHEMICALWRAPPER_H__
#include "wrapper.h"
#include "inputdevice.h"
#include "wiwo_sem.h"
#include "qthread_ex.h"
#include "wmtochem.h"
#if defined WIN32 || defined _WIN32
#include "wiiusecpp.h"
#include "wiiusecppdata.h"
#else
#include <wiiusecpp.h>
#include <wiiusecppdata.h>
#endif
#include "warning_disable_begin.h"
#include <QAtomicInt>
#include <QEventLoop>
#include <QReadWriteLock>
#include <QSemaphore>
#include "warning_disable_end.h"
namespace WrapperInputToDomain
{
class ChemicalWrapData_from : public WrapperData_from
{
public :
ChemicalWrapData_from() ;
~ChemicalWrapData_from() ;
inline unsigned int getWrapperType(){ return WRAPPER_ID_CHEMICAL ; } ;
};
class ChemicalWrapData_to
{
public :
ChemicalWrapData_to() ;
virtual ~ChemicalWrapData_to() ;
inline unsigned int getWrapperType(){ return WRAPPER_ID_CHEMICAL ; } ;
inline bool getOperatingMode( int &opMode_out )
{ bool up=m_updateOpMode ; m_updateOpMode=false ;
opMode_out = m_operatingMode ; return up ; } ;
inline bool getMenuMode( bool &menuMode_out )
{ bool up=m_updateMenuMode ; m_updateMenuMode=false ;
menuMode_out = m_menuMode ; return up ; } ;
inline bool getIRSensitive( int &irSensitive_out )
{ bool up=m_updateIRSensitive ; m_updateIRSensitive=false ;
irSensitive_out = m_irSensitive ; return up ; } ;
inline bool getHasSleepThread( bool &hasSleepThread_out )
{ bool up=m_updateSleepThread ; m_updateSleepThread=false ;
hasSleepThread_out = m_hasSleepThread ; return up ; } ;
inline void setOperatingMode( int opMode )
{ m_operatingMode = opMode ; m_updateOpMode = true ; } ;
inline void setMenuMode( bool mode )
{ m_menuMode = mode ; m_updateMenuMode = true ; } ;
inline void setIRSensitive( int sensitive )
{ m_irSensitive = sensitive ; m_updateIRSensitive = true ; } ;
inline void setHasSleepThread( bool hasSleepThread )
{ m_hasSleepThread = hasSleepThread ; m_updateSleepThread = true ; } ;
inline void resetUpdate()
{ m_updateOpMode=false; m_updateMenuMode=false;
m_updateIRSensitive=false; m_updateSleepThread=false; }
private :
int m_operatingMode ;
bool m_updateOpMode ;
bool m_menuMode ;
bool m_updateMenuMode ;
int m_irSensitive ;
bool m_updateIRSensitive ;
bool m_hasSleepThread ;
bool m_updateSleepThread ;
};
// Chemical wrapper data.
class ChemicalWrap : public Wrapper
{
Q_OBJECT // Signal need.
public :
ChemicalWrap( InputDevice::Device *dev ) ;
virtual ~ChemicalWrap() ;
inline unsigned int getWrapperType(){ return WRAPPER_ID_CHEMICAL ; } ;
ChemicalWrapData_from* getWrapperDataFrom() ; //< Blocking call.
void setWrapperDataTo( const ChemicalWrapData_to& data ) ; //< Blocking call.
bool connectAndStart() ;
void stopPoll() ;
private :
ChemicalWrapData_from* updateDataFrom() ;
bool updateDataTo() ;
bool reduceSentData( bool displayIsFinished, WrapperData_from *chemData ) ;
private slots :
void runPoll() ;
public slots :
void setOnActionsApplied() ;
signals :
void newActions() ;
//void runRunPoll() ;
void wmWorksGood() ;
void wmWorksBad() ;
protected :
/** @name Manage Chemical data.
* @{ */
InputDevice::Device *m_dev ; //< (shortcut)
WmToChem *m_wmToChem ; //< (object)
WIWO_sem<ChemicalWrapData_from*> *m_cirBufferFrom ; //< (object)
WIWO_sem<ChemicalWrapData_to*> *m_cirBufferTo ; //< (object)
QAtomicInt m_actionsAreApplied ;
int m_actionsGlobalPrevious, m_actionsWrapperPrevious ; // Save previous state to reduce output data.
bool m_forceUpdateWmTool, m_forceUpdateOrNot ;
// @}
/** @name Manage thread.
* @{ */
QThread_ex m_wrapperThread ;
QSemaphore m_semThreadFinish ; // Secure the end of runPoll().
QReadWriteLock m_mutexIsRunning ;
volatile bool m_isRunning ;
QAtomicInt m_threadFinished ;
bool m_hasSleepThread ;
int m_nbActionRealized ; // To limit the number of sleep calling.
// @}
/**
* @name Try to reduce output data.
* @{ */
QTime m_time ;
int m_t1, m_t2 ;
// @}
/**
* Count nb actions by seconds (used with breakpoint).
* @{ */
WIWO<unsigned int> *m_nbUpdate, *m_nbUpdate2 ;
unsigned int m_t1Update, m_t2Update ; // For the runPoll() method.
unsigned int m_t1Update2, m_t2Update2 ; // For the updateDataFrom() method.
unsigned int m_nbWmToolNotFinished ;
unsigned int m_nbDataInWmBuffer ;
unsigned int m_nbActionsApplied ;
bool m_bufferFromIsFull, m_bufferToIsFull ;
// @}
};
}
#endif
| [
"[email protected]"
] | [
[
[
1,
190
]
]
] |
4c9d73badc99e0ad6209a2202f2545ca793b1477 | c95a83e1a741b8c0eb810dd018d91060e5872dd8 | /Game/ClientShellDLL/TO2/TO2ScreenMgr.h | 5a43cf7fe3d7fe2c6531886d7ed92938c9208bd8 | [] | no_license | rickyharis39/nolf2 | ba0b56e2abb076e60d97fc7a2a8ee7be4394266c | 0da0603dc961e73ac734ff365bfbfb8abb9b9b04 | refs/heads/master | 2021-01-01T17:21:00.678517 | 2011-07-23T12:11:19 | 2011-07-23T12:11:19 | 38,495,312 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 779 | h | // ----------------------------------------------------------------------- //
//
// MODULE : ScreenMgr.h
//
// PURPOSE : Interface screen manager
//
// (c) 1999-2001 Monolith Productions, Inc. All Rights Reserved
//
// ----------------------------------------------------------------------- //
#if !defined(_TO2_SCREEN_MGR_H_)
#define _TO2_SCREEN_MGR_H_
#include "ScreenMgr.h"
class CTO2ScreenMgr : public CScreenMgr
{
public:
CTO2ScreenMgr();
virtual ~CTO2ScreenMgr();
virtual LTBOOL Init();
virtual const char * GetScreenName(eScreenID id);
virtual uint16 GetScreenIDFromName(char * pName);
protected:
void AddScreen(eScreenID screenID);
virtual void SwitchToScreen(CBaseScreen *pNewScreen);
};
#endif // _SCREENMGR_H_ | [
"[email protected]"
] | [
[
[
1,
34
]
]
] |
033662194126b276fd3b189e06290c133cf9026e | 374f53386d36e3aadf0ed88e006394220f732f30 | /win/DirectShow/SkeltonMFC/StdAfx.cpp | bcb1e842def91d300b497b2db18604f24e3ece7d | [
"MIT"
] | permissive | yatjf/sonson-code | e7edbc613f8c97be5f7c7367be2660b3cb75a61b | fbb564af37adb2305fe7d2148f8d4f5a3450f72b | refs/heads/master | 2020-06-13T08:02:38.469864 | 2010-07-01T14:20:40 | 2010-07-01T14:20:40 | null | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 1,488 | cpp | //
// SkeltonMFC
// StdAfx.cpp
//
// The MIT License
//
// Copyright (c) 2009 sonson, sonson@Picture&Software
//
// 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.
//// stdafx.cpp : 標準インクルードファイルを含むソース ファイル
// DirectShowSkeltonMFC.pch : 生成されるプリコンパイル済ヘッダー
// stdafx.obj : 生成されるプリコンパイル済タイプ情報
#include "stdafx.h"
| [
"yoshida.yuichi@0d0a6a56-2bd1-11de-9cad-a3574e5575ef"
] | [
[
[
1,
33
]
]
] |
643f90e80eff21708604f4711dda6dc0c65d7ed5 | bfdfb7c406c318c877b7cbc43bc2dfd925185e50 | /compiler/hyCSymbolTable.h | c96081df35ddee51e579ebd5730a29cf00cf0ef8 | [
"MIT"
] | permissive | ysei/Hayat | 74cc1e281ae6772b2a05bbeccfcf430215cb435b | b32ed82a1c6222ef7f4bf0fc9dedfad81280c2c0 | refs/heads/master | 2020-12-11T09:07:35.606061 | 2011-08-01T12:38:39 | 2011-08-01T12:38:39 | null | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 3,920 | h | /* -*- coding: sjis-dos; -*- */
/*
* copyright 2010 FUKUZAWA Tadashi. All rights reserved.
*/
#ifndef m_HYCSYMBOLTABLE_H_
#define m_HYCSYMBOLTABLE_H_
#include "hpInputBuffer.h"
#include "hySymbolID.h"
#include <stdio.h>
using namespace Hayat::Common;
using namespace Hayat::Parser;
class Test_hyCSymbolTable;
namespace Hayat {
namespace Compiler {
// コンパイラ内部でのみ使うローカル変数シンボルを区別しやすくするための定義
typedef SymbolID_t LocalVarSymID_t;
class SymbolTable {
friend class ::Test_hyCSymbolTable; // unittest
protected:
static const hyu32 m_INIT_SYMOFFS_SIZE = 256;
static const hyu32 m_INIT_SYMBOLBUF_SIZE = 5120;
public:
SymbolTable(void);
~SymbolTable();
void initialize(const char* const* initSymTable, hyu32 initSymOffsSize = m_INIT_SYMOFFS_SIZE, hyu32 initSymbolBufSize = m_INIT_SYMBOLBUF_SIZE);
void finalize(void);
// strに対応するSymbol IDを返す。無ければ SYMBOL_ID_ERROR を返す
SymbolID_t check(const char* str, hyu32 len);
// strに対応するSymbol IDを返す。既存に無ければ新規割当て
SymbolID_t symbolID(const char* str);
// Substrに対応するSymbol IDを返す。既存に無ければ新規割当て
SymbolID_t symbolID(InputBuffer* inp, Substr& ss);
// strStart<=.<strEndに対応するSymbol IDを返す。既存に無ければ新規割当て
SymbolID_t symbolID(const char* strStart, const char* strEnd);
// Symbol ID に対応する文字列を返す
const char* id2str(SymbolID_t id);
// ファイルからテーブルを読み込む: ファイルが無かったら false
bool readFile(const char* path);
// ファイルからテーブルを読み込みマージする
// エラーが発生したらfalseを返す。ファイルが読めなかった場合はtrue
bool mergeFile(const char* path);
// バッファからテーブルを読み込みマージする
// エラーが発生した時はNULLを返す。成功したらテーブル末尾ポインタ
const hyu8* mergeTable(const hyu8* buf, hyu32 bufSize);
// テーブルをファイルに出力
void writeFile(const char* path);
// シンボルラベルヘッダファイルを作成
void writeSymbolH(const char* path, bool verbose = false);
// テーブルをFILE*へ出力
void fwriteTable(FILE* fp);
static const char* const SYMBOL_FILENAME;
static const char* const SYMBOL_H_NAME;
// コンパイラ内部で使うシンボルを区別しやすくするための定義
LocalVarSymID_t localVarSymID(const char* str) {
return (LocalVarSymID_t)symbolID(str); }
LocalVarSymID_t localVarSymID(InputBuffer* inp, Substr& ss) {
return (LocalVarSymID_t)symbolID(inp, ss); }
const char* localVarSymID2str(LocalVarSymID_t sym) {
return id2str((SymbolID_t)sym); }
hyu32 numSymbols(void) { return m_numSymbols; }
protected:
// シンボルラベル生成
static void m_symLabel(char* buf, size_t bufSize, const char* str);
hyu32 m_numSymbols;
int* m_symOffs;
hyu32 m_symOffsSize;
char* m_symbolBuf;
hyu32 m_symbolBufSize;
};
}
}
#endif /* m_HYCSYMBOLTABLE_H_ */
| [
"[email protected]"
] | [
[
[
1,
99
]
]
] |
d3cb1979a730a096f59090e1f173f2c78c88f4a8 | 5bd189ea897b10ece778fbf9c7a0891bf76ef371 | /BasicEngine/BasicEngine/Game/Object/ObjectType.h | 3286be101b00243f0ca28710a3de81100ab84f0b | [] | no_license | boriel/masterullgrupo | c323bdf91f5e1e62c4c44a739daaedf095029710 | 81b3d81e831eb4d55ede181f875f57c715aa18e3 | refs/heads/master | 2021-01-02T08:19:54.413488 | 2011-12-14T22:42:23 | 2011-12-14T22:42:23 | 32,330,054 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 621 | h | /*
Class cObectType: Con esta clase identificamos de que tipo es cada objeto para su posterior carga y gestion en la fisica, para colocarlo en el array correspondiente
*/
#ifndef OBJECT_TYPE_H
#define OBJECT_TYPE_H
#include <string>
using namespace std;
class cObjectType
{
private:
string msModelName;
string msType;
public:
inline void SetType (string lsType) { msType = lsType; }
inline string GetType () { return msType; }
inline void SetModelName (string lsModelName) { msModelName = lsModelName; }
inline string GetModelName () {return msModelName; }
};
#endif | [
"[email protected]@f2da8aa9-0175-0678-5dcd-d323193514b7"
] | [
[
[
1,
30
]
]
] |
73a895c9417820eb73709ef6239df3b8073e7667 | faacd0003e0c749daea18398b064e16363ea8340 | /test/listtest/listtest.h | 723bc01b27c4873af9c2acaa3894ff214e2ac1f9 | [] | no_license | yjfcool/lyxcar | 355f7a4df7e4f19fea733d2cd4fee968ffdf65af | 750be6c984de694d7c60b5a515c4eb02c3e8c723 | refs/heads/master | 2016-09-10T10:18:56.638922 | 2009-09-29T06:03:19 | 2009-09-29T06:03:19 | 42,575,701 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 187 | h | #include <QtGui>
#include <QMainWindow>
#include "../../lyxlib/lists.h"
class Window : public QMainWindow {
Q_OBJECT
public:
Window(QWidget *parent = 0);
~Window();
};
| [
"futurelink.vl@9e60f810-e830-11dd-9b7c-bbba4c9295f9"
] | [
[
[
1,
11
]
]
] |
604a82414e7d1913ab3d687a2acde6f1b75f55f7 | ad33a51b7d45d8bf1aa900022564495bc08e0096 | /DES/DES_GOBSTG/Header/Export.h | 262a61e7941d2407e73a3070ba37ddfa2df13e90 | [] | no_license | CBE7F1F65/e20671a6add96e9aa3551d07edee6bd4 | 31aff43df2571d334672929c88dfd41315a4098a | f33d52bbb59dfb758b24c0651449322ecd1b56b7 | refs/heads/master | 2016-09-11T02:42:42.116248 | 2011-09-26T04:30:32 | 2011-09-26T04:30:32 | 32,192,691 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,962 | h | #ifndef _EXPORT_H
#define _EXPORT_H
#include "MainDependency.h"
#include "Const.h"
#define RPYPARTMAX 7
#define RPYPREFIXMAX 8
#define RPYENUMMAX 0x4
#define RPYFILENAME_CONTENTMAX 7
#define RPYINFO_USERNAMEMAX 0x08
#define RPYINFO_SPELLNAMEMAX 0x40
#define RPYOFFSET_SIGNATURE 0x00
#define RPYSIZE_SIGNATURE 0x0C
#define RPYOFFSET_VERSION (RPYOFFSET_SIGNATURE + RPYSIZE_SIGNATURE)
#define RPYSIZE_VERSION 0x04
#define RPYOFFSET_COMPLETESIGN (RPYOFFSET_VERSION + RPYSIZE_VERSION)
#define RPYSIZE_COMPLETESIGN 0x04
#define RPYOFFSET_TAG (RPYOFFSET_COMPLETESIGN + RPYSIZE_COMPLETESIGN)
#define RPYSIZE_TAG 0x04
#define RPYOFFSET_INFOOFFSET (RPYOFFSET_TAG + RPYSIZE_TAG)
#define RPYSIZE_INFOOFFSET 0x04
#define RPYOFFSET_APPEND (RPYOFFSET_INFOOFFSET + RPYSIZE_INFOOFFSET)
#define RPYSIZE_APPEND 0x04
#define RPYOFFSET_RPYINFO (RPYOFFSET_APPEND + RPYOFFSET_APPEND)
#define RPYSIZE_RPYINFO sizeof(replayInfo)
#define RPYOFFSET_PARTINFO (RPYOFFSET_RPYINFO + RPYSIZE_RPYINFO)
#define RPYSIZE_PARTINFO sizeof(partInfo)
#define RPYOFFSET_INPUTDATA (RPYOFFSET_PARTINFO + (RPYPARTMAX * RPYSIZE_PARTINFO))
#define RPYSIZE_FRAME sizeof(replayFrame)
#define REPLAYPASSWORD_XORMAGICNUM 0x45A61920
struct replayInfo
{
char username[M_PL_MATCHMAXPLAYER][RPYINFO_USERNAMEMAX];
DWORD alltime;
DWORD offset;
WORD year;
WORD month;
WORD day;
WORD hour;
WORD minute;
float lost;
BYTE matchmode;
BYTE scene;
BYTE usingchara[M_PL_MATCHMAXPLAYER][M_PL_ONESETPLAYER];
BYTE initlife[M_PL_MATCHMAXPLAYER];
};
struct partInfo
{
DWORD offset;
DWORD seed;
WORD nowID[M_PL_MATCHMAXPLAYER];
};
struct replayFrame{
WORD input;
BYTE bias;
};
class Export
{
public:
Export();
~Export();
static void keydownproc(int keycode);
static void keyupproc(int keycode);
static bool clientInitial(bool usesound = false, bool extuse = false);
static bool clientAfterInitial(hgeTextureInfo * texset);
static hge3DPoint * GetFarPoint(BYTE renderflag);
static void clientSetMatrix(float worldx = 0, float worldy = 0, float worldz = 0, BYTE renderflag=M_RENDER_NULL);
// static void clientSetMatrixUser(D3DXMATRIX matWorld, D3DXMATRIX matView, D3DXMATRIX matProj);
static bool clientSet2DMode();
static bool clientSet3DMode();
static void clientAdjustWindow();
static void Release();
static BYTE GetPlayerIndexByRenderFlag(BYTE renderflag);
static BYTE GetRenderFlagByPlayerIndex(BYTE playerindex);
static bool SetIni(bool extuse = false);
static bool GetResourceFile(bool readbin = false);
static int GetPassword();
static void SetLastIP(DWORD ipx, WORD ipport);
static bool GetLastIP(DWORD * ipx, WORD * ipport);
static bool rpyLoad(const char * filename, replayInfo * _rpyinfo = NULL, partInfo * _partinfo = NULL, replayFrame * _replayframe = NULL);
static bool rpyFree(const char * filename);
static bool rpySetBias(replayFrame * _replayframe);
static float rpyGetReplayFPS(replayFrame _replayframe);
static bool packFile(const char * zipname, const char * filename);
#ifdef __UNPACK
#define UNPACK_INIFILENAME "Unpack.ini"
#define UNPACK_SECTION "Package_"
#define UNPACK_PACKNAME "FileName"
#define UNPACK_TYPE "Type_"
static bool unpackFile(const char * zipname, const char * filename);
static bool unpackFromIni(const char * inifilename);
#endif
static bool effSave(const char * filename, hgeEffectSystem * eff, int texnum);
static int effLoad(const char * filename, hgeEffectSystem * eff, HTEXTURE * tex);
public:
static char resourcefilename[M_PATHMAX];
static char resbinname[M_PATHMAX];
static partInfo partinfo[RPYPARTMAX];
static replayInfo rpyinfo;
static int password;
static HGEMATRIX matView2DMode;
static HGEMATRIX matProj2DMode;
static HGEMATRIX matView[M_PL_MATCHMAXPLAYER];
static HGEMATRIX matProj[M_PL_MATCHMAXPLAYER];
static hge3DPoint ptfar;
};
#endif | [
"CBE7F1F65@b503aa94-de59-8b24-8582-4b2cb17628fa"
] | [
[
[
1,
128
]
]
] |
8729ed28be13a67574acfad3ec09e9d894bbdbea | 463c3b62132d215e245a097a921859ecb498f723 | /lib/dlib/conditioning_class/conditioning_class_kernel_3.h | f5c7734e3f92c678290eea5a8e2e1ef23c300208 | [
"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 | 12,734 | h | // Copyright (C) 2004 Davis E. King ([email protected])
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_CONDITIONING_CLASS_KERNEl_3_
#define DLIB_CONDITIONING_CLASS_KERNEl_3_
#include "conditioning_class_kernel_abstract.h"
#include "../assert.h"
#include "../algs.h"
namespace dlib
{
template <
unsigned long alphabet_size
>
class conditioning_class_kernel_3
{
/*!
INITIAL VALUE
total == 1
counts == pointer to an array of alphabet_size data structs
for all i except i == 0: counts[i].count == 0
counts[0].count == 1
counts[0].symbol == alphabet_size-1
for all i except i == alphabet_size-1: counts[i].present == false
counts[alphabet_size-1].present == true
CONVENTION
counts == pointer to an array of alphabet_size data structs
get_total() == total
get_count(symbol) == counts[x].count where
counts[x].symbol == symbol
LOW_COUNT(symbol) == sum of counts[0].count though counts[x-1].count
where counts[x].symbol == symbol
if (counts[0].symbol == symbol) LOW_COUNT(symbol)==0
if (counts[i].count == 0) then
counts[i].symbol == undefined value
if (symbol has a nonzero count) then
counts[symbol].present == true
get_memory_usage() == global_state.memory_usage
!*/
public:
class global_state_type
{
public:
global_state_type () : memory_usage(0) {}
private:
unsigned long memory_usage;
friend class conditioning_class_kernel_3<alphabet_size>;
};
conditioning_class_kernel_3 (
global_state_type& global_state_
);
~conditioning_class_kernel_3 (
);
void clear(
);
bool increment_count (
unsigned long symbol,
unsigned short amount = 1
);
unsigned long get_count (
unsigned long symbol
) const;
unsigned long get_total (
) const;
unsigned long get_range (
unsigned long symbol,
unsigned long& low_count,
unsigned long& high_count,
unsigned long& total_count
) const;
void get_symbol (
unsigned long target,
unsigned long& symbol,
unsigned long& low_count,
unsigned long& high_count
) const;
unsigned long get_memory_usage (
) const;
global_state_type& get_global_state (
);
static unsigned long get_alphabet_size (
);
private:
// restricted functions
conditioning_class_kernel_3(conditioning_class_kernel_3<alphabet_size>&); // copy constructor
conditioning_class_kernel_3& operator=(conditioning_class_kernel_3<alphabet_size>&); // assignment operator
struct data
{
unsigned short count;
unsigned short symbol;
bool present;
};
// data members
unsigned short total;
data* counts;
global_state_type& global_state;
};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// member function definitions
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template <
unsigned long alphabet_size
>
conditioning_class_kernel_3<alphabet_size>::
conditioning_class_kernel_3 (
global_state_type& global_state_
) :
total(1),
counts(new data[alphabet_size]),
global_state(global_state_)
{
COMPILE_TIME_ASSERT( 1 < alphabet_size && alphabet_size < 65536 );
data* start = counts;
data* end = counts+alphabet_size;
start->count = 1;
start->symbol = alphabet_size-1;
start->present = false;
++start;
while (start != end)
{
start->count = 0;
start->present = false;
++start;
}
counts[alphabet_size-1].present = true;
// update memory usage
global_state.memory_usage += sizeof(data)*alphabet_size +
sizeof(conditioning_class_kernel_3);
}
// ----------------------------------------------------------------------------------------
template <
unsigned long alphabet_size
>
conditioning_class_kernel_3<alphabet_size>::
~conditioning_class_kernel_3 (
)
{
delete [] counts;
// update memory usage
global_state.memory_usage -= sizeof(data)*alphabet_size +
sizeof(conditioning_class_kernel_3);
}
// ----------------------------------------------------------------------------------------
template <
unsigned long alphabet_size
>
void conditioning_class_kernel_3<alphabet_size>::
clear(
)
{
total = 1;
data* start = counts;
data* end = counts+alphabet_size;
start->count = 1;
start->symbol = alphabet_size-1;
start->present = false;
++start;
while (start != end)
{
start->count = 0;
start->present = false;
++start;
}
counts[alphabet_size-1].present = true;
}
// ----------------------------------------------------------------------------------------
template <
unsigned long alphabet_size
>
typename conditioning_class_kernel_3<alphabet_size>::global_state_type& conditioning_class_kernel_3<alphabet_size>::
get_global_state(
)
{
return global_state;
}
// ----------------------------------------------------------------------------------------
template <
unsigned long alphabet_size
>
unsigned long conditioning_class_kernel_3<alphabet_size>::
get_memory_usage(
) const
{
return global_state.memory_usage;
}
// ----------------------------------------------------------------------------------------
template <
unsigned long alphabet_size
>
bool conditioning_class_kernel_3<alphabet_size>::
increment_count (
unsigned long symbol,
unsigned short amount
)
{
// if we are going over a total of 65535 then scale down all counts by 2
if (static_cast<unsigned long>(total)+static_cast<unsigned long>(amount) >= 65536)
{
total = 0;
data* start = counts;
data* end = counts+alphabet_size;
while (start != end)
{
if (start->count == 1)
{
if (start->symbol == alphabet_size-1)
{
// this symbol must never be zero so we will leave its count at 1
++total;
}
else
{
start->count = 0;
counts[start->symbol].present = false;
}
}
else
{
start->count >>= 1;
total += start->count;
}
++start;
}
}
data* start = counts;
data* swap_spot = counts;
if (counts[symbol].present)
{
while (true)
{
if (start->symbol == symbol && start->count!=0)
{
unsigned short temp = start->count + amount;
start->symbol = swap_spot->symbol;
start->count = swap_spot->count;
swap_spot->symbol = static_cast<unsigned short>(symbol);
swap_spot->count = temp;
break;
}
if ( (start->count) < (swap_spot->count))
{
swap_spot = start;
}
++start;
}
}
else
{
counts[symbol].present = true;
while (true)
{
if (start->count == 0)
{
start->symbol = swap_spot->symbol;
start->count = swap_spot->count;
swap_spot->symbol = static_cast<unsigned short>(symbol);
swap_spot->count = amount;
break;
}
if ((start->count) < (swap_spot->count))
{
swap_spot = start;
}
++start;
}
}
total += amount;
return true;
}
// ----------------------------------------------------------------------------------------
template <
unsigned long alphabet_size
>
unsigned long conditioning_class_kernel_3<alphabet_size>::
get_count (
unsigned long symbol
) const
{
if (counts[symbol].present == false)
return 0;
data* start = counts;
while (start->symbol != symbol)
{
++start;
}
return start->count;
}
// ----------------------------------------------------------------------------------------
template <
unsigned long alphabet_size
>
unsigned long conditioning_class_kernel_3<alphabet_size>::
get_alphabet_size (
)
{
return alphabet_size;
}
// ----------------------------------------------------------------------------------------
template <
unsigned long alphabet_size
>
unsigned long conditioning_class_kernel_3<alphabet_size>::
get_total (
) const
{
return total;
}
// ----------------------------------------------------------------------------------------
template <
unsigned long alphabet_size
>
unsigned long conditioning_class_kernel_3<alphabet_size>::
get_range (
unsigned long symbol,
unsigned long& low_count,
unsigned long& high_count,
unsigned long& total_count
) const
{
if (counts[symbol].present == false)
return 0;
total_count = total;
unsigned long low_count_temp = 0;
data* start = counts;
while (start->symbol != symbol)
{
low_count_temp += start->count;
++start;
}
low_count = low_count_temp;
high_count = low_count_temp + start->count;
return start->count;
}
// ----------------------------------------------------------------------------------------
template <
unsigned long alphabet_size
>
void conditioning_class_kernel_3<alphabet_size>::
get_symbol (
unsigned long target,
unsigned long& symbol,
unsigned long& low_count,
unsigned long& high_count
) const
{
unsigned long high_count_temp = counts->count;
const data* start = counts;
while (target >= high_count_temp)
{
++start;
high_count_temp += start->count;
}
low_count = high_count_temp - start->count;
high_count = high_count_temp;
symbol = static_cast<unsigned long>(start->symbol);
}
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_CONDITIONING_CLASS_KERNEl_3_
| [
"jimmy@DGJ3X3B1.(none)"
] | [
[
[
1,
438
]
]
] |
aeb558e32c41df5d4b292807aaefe5d231633200 | 8a783a44653ac0b203bcd23d010747218568a401 | /pi-counter/pi-counter/File.h | 9d9587d4625eaf6acdafc6e7375cb44278cf8150 | [] | no_license | stankiewicz/pi-counter | b08642149ea1af9c88c8acad9cf60c44e80f64de | f6418053b2241efb83a6d2d4c0091356f87e7d0f | refs/heads/master | 2021-01-15T13:48:34.288727 | 2008-09-03T18:14:14 | 2008-09-03T18:14:14 | 32,282,826 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 565 | h | #ifndef _FILE_H_
#define _FILE_H_
#include "gmp.h"
#define NUMBER_OF_VALUES_PER_FILE 1000000
#define NUMBER_OD_BYTES_PER_FILE 50000000
class File
{
public:
bool SaveBIGNUM(mpf_ptr value, int base, wchar_t *filename, int numberOfDigits = 0);
bool LoadBIGNUM(mpf_ptr value, char **piString, wchar_t * filename);
bool SaveWARFUN(unsigned int *result, unsigned int length, mpf_ptr a,wchar_t *filename, unsigned int piLength);
bool LoadWARFUN(unsigned int **result, unsigned int *length, mpf_ptr a, wchar_t *filename);
private:
};
#endif | [
"tomasz.czekala@8d1154ae-3347-0410-a901-cdf36a16b7d0",
"[email protected]@8d1154ae-3347-0410-a901-cdf36a16b7d0"
] | [
[
[
1,
11
],
[
15,
20
]
],
[
[
12,
14
]
]
] |
3127ccb81dd06b865e3bca233ccaa7fec87b7283 | 5ce47e25b441e9302470a3acf3935adda2a150df | /tibialua/tibialua.h | 68404238b4ce9f8e5c44b91d7562d9486abec2d4 | [] | no_license | Google-Code-Fork/tibialua | 9cc9efae49c1432e4f3066214cf7d0de5d0dd3d9 | 7a122cb49d25ff2c5a7e144913177d9154986f4b | refs/heads/master | 2021-01-01T05:36:50.636599 | 2009-01-22T14:15:37 | 2009-01-22T14:15:37 | 32,895,512 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,487 | h | #ifndef _TIBIALUA_H_
#define _TIBIALUA_H_
#include <ctime>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <windows.h>
#include <shellapi.h>
#include "tibialua_xml.h"
#include "tibialua_lua.h"
#include "tibialua_iup.h"
#include "tibialua_register.h"
#include "resource.h"
/* defines */
// window dimensions
#define WINDOW_HEIGHT 320
#define WINDOW_WIDTH 240
// tray notification message
#define WM_SHELLNOTIFY WM_USER+5
/* ids */
// tray icon
#define ID_TRAY_ICON 101
// tray menu
#define ID_TRAY_MENU_NULL 1001
#define ID_TRAY_MENU_HOTKEYS 1002
#define ID_TRAY_MENU_ABOUT 1003
#define ID_TRAY_MENU_HOMEPAGE 1004
#define ID_TRAY_MENU_EXIT 1005
// tray menus
#define ID_TRAY_MENUS_BEGIN 1100
// timers
#define ID_TIMERS_BEGIN 10000
// hotkeys
#define ID_HOTKEYS_BEGIN 100000
/* globals */
// lua state
lua_State *L;
// tibia lua script
typedef struct
{
int id;
bool timerIsEnabled;
std::string fileName;
std::string name;
int hotkeyId;
std::string hotkeyName;
int timerDelay;
int timerStartEnabled;
int menuVisible;
} TibiaLuaScript;
// scripts vector
std::vector<TibiaLuaScript> vectorScripts;
std::vector<TibiaLuaScript>::iterator vectorScriptsIt;
// tray icon
NOTIFYICONDATA trayIcon;
// tray menu
HMENU trayMenu;
/* booleans */
// hotkeys
bool bHotkeys = true;
#endif // _TIBIALUA_H_
| [
"[email protected]@6c450836-be4a-11dd-9405-3d0920048215",
"ednomerve@6c450836-be4a-11dd-9405-3d0920048215"
] | [
[
[
1,
3
],
[
6,
13
],
[
15,
89
]
],
[
[
4,
5
],
[
14,
14
]
]
] |
83787cc62edfa0e1e755f012e0c8116d98edba25 | 16d6176d43bf822ad8d86d4363c3fee863ac26f9 | /Submission/Submission/Source code/rayTracer/Triangle.h | f7a49a5de142b3322945f1d8a95a78058fa63dff | [] | no_license | preethinarayan/cgraytracer | 7a0a16e30ef53075644700494b2f8cf2a0693fbd | 46a4a22771bd3f71785713c31730fdd8f3aebfc7 | refs/heads/master | 2016-09-06T19:28:04.282199 | 2008-12-10T00:02:32 | 2008-12-10T00:02:32 | 32,247,889 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 897 | h | #pragma once
#include "stdafx.h"
#include "sceneobjects.h"
class Triangle :
public SceneObjects
{
int v[3]; /* vertex index */
mat4 transform;
vec3 verts[3];
vec3 norms[3];
bool hasNormals;
float area( vec3 v1, vec3 v2, vec3 v3);
bool isPointInTriangle(vec3 P, vec3 v[3]);
vec3 getNormal(vec3 pt);
public:
float Intersect(Ray_t *R);
vec3 getLiteColor(Light *light,vec3 light_direction,vec3 viewer_direction, vec3 pt);
vec3 getColor(Ray_t *R, vec3 pt, int depth);
bool setArgs(char **args, Shading *shading);
bool setArgsNormals(char **args);
/* Transformations */
void transformNormal();
vec3 transformPoint(vec3 pt);
/* Reflections */
// Ray_t getReflectedRay(Ray_t *R, vec3 pt){return *R;};
Ray_t getReflectedRay(Ray_t *R, vec3 pt);
vec3 getReflections(Ray_t *R, vec3 pt, int depth);
public:
Triangle(void);
~Triangle(void);
};
| [
"[email protected]@074c0a88-b503-11dd-858c-a3a1ac847323"
] | [
[
[
1,
38
]
]
] |
39260b51ce3dcd1f3437acda5ad846bc6662b6a9 | e9944cc3f8c362cd0314a2d7a01291ed21de19ee | / xcommon/自由拼音输入法IME/source/HZspecial.cpp | 6d13291c5cd8d60b6897bc74462a0d114d633c18 | [] | no_license | wermanhme1990/xcommon | 49d7185a28316d46992ad9311ae9cdfe220cb586 | c9b1567da1f11e7a606c6ed638a9fde1f6ece577 | refs/heads/master | 2016-09-06T12:43:43.593776 | 2008-12-05T04:24:11 | 2008-12-05T04:24:11 | 39,864,906 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,898 | cpp | /*
* Copyright (C) 1999.4 Li ZhenChun
*
* 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 is will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, M A 02139, USA.
*
* Author: Li ZhenChun email: [email protected] or [email protected]
*
*/
#include "stdafx.h"
#include "freepy.h"
BOOL RepeatPreResult(HIMC hIMC)
{
LPINPUTCONTEXT lpIMC;
LPCOMPOSITIONSTRING lpCompStr;
LPTSTR lpPreResultStr,lpConvStr;
wConversionMode = 0;
lpIMC = ImmLockIMC(hIMC);
lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
lpPreResultStr = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPreResultStr;
if( _tcslen(lpPreResultStr) )
{
lpConvStr = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szConvCompStr;
_tcscpy(lpConvStr,lpPreResultStr);
MakeResultString(hIMC,TRUE);
ImmUnlockIMCC(lpIMC->hCompStr);
ImmUnlockIMC(hIMC);
return TRUE;
}
ImmUnlockIMCC(lpIMC->hCompStr);
ImmUnlockIMC(hIMC);
return FALSE;
}
BOOL GeneratePunct(HIMC hIMC, WORD wCode)
{
LPINPUTCONTEXT lpIMC;
LPCOMPOSITIONSTRING lpCompStr;
LPTSTR lpStr,lpConvStr,lpPreResultStr;
WORD wHead;
TCHAR cLastPreResultChar;
lpIMC = ImmLockIMC(hIMC);
lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
lpCompStr->dwCompStrLen = 0;
lpConvStr = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szConvCompStr;
if(wConversionSet & CONVERSION_SET_PUNCT)
{
wHead = wCode - _T('!');
lpStr = aPunct[wHead][0];
if( _tcslen(lpStr) )
{
if( wCode == _T('.') || wCode == _T('/') )
{
lpPreResultStr = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPreResultStr;
cLastPreResultChar = *CharPrev(lpPreResultStr,lpPreResultStr + _tcslen(lpPreResultStr));
if(cLastPreResultChar >= _T('!') && cLastPreResultChar <= _T('~') )
{
*lpConvStr = (TCHAR)wCode;
*(lpConvStr+1) = _T('\0');
}
else
{
_tcscpy(lpConvStr,lpStr);
}
}
else
{
_tcscpy(lpConvStr,lpStr);
}
MakeResultString(hIMC,TRUE);
ImmUnlockIMCC(lpIMC->hCompStr);
ImmUnlockIMC(hIMC);
return TRUE;
}
}
else
{
*lpConvStr = (TCHAR)wCode;
*(lpConvStr+1) = _T('\0');
MakeResultString(hIMC,TRUE);
ImmUnlockIMCC(lpIMC->hCompStr);
ImmUnlockIMC(hIMC);
return TRUE;
}
ImmUnlockIMCC(lpIMC->hCompStr);
ImmUnlockIMC(hIMC);
return FALSE;
} | [
"[email protected]"
] | [
[
[
1,
108
]
]
] |
4cb8078e7c1d65e3417e9f825b2590a748b5807c | 3e6e5d5b2ec9b8616288ae20c55ea3a1f5900178 | /3DTetris/source/TBoardBrickZ.cpp | a657261ad51665bb561827c0ab368dce718196d2 | [] | no_license | sanke/3dtetrisgame | 8ad404dcdd764eb13db0bfc949edb34a77eb0f21 | e5bcf219e4ee3b0995809d70a83d92e001e7e50d | refs/heads/master | 2021-01-16T21:18:41.949403 | 2010-06-27T20:58:27 | 2010-06-27T20:58:27 | 32,506,729 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,327 | cpp | #include "TGamePlayGlobals.h"
#include "TBoardBrickZ.h"
using namespace Ogre;
//=====================================================================
TBoardBrickZ::TBoardBrickZ(Ogre::SceneNode *brickSN) : TBoardBrick(brickSN)
{
setupBrick();
mBrickID = BRICK_TYPE_Z;
}
//=====================================================================
TBoardBrickZ::~TBoardBrickZ(void)
{
}
//=====================================================================
bool TBoardBrickZ::setEntity()
{
mpBrickEnt = Root::getSingletonPtr()->getSceneManager(PLAY_SCENE)->createEntity(BRICKZ_ENT+StringConverter::toString(mBrickCount), BRICKZ_MESH);
if(!mpBrickEnt)
return false;
mpBrickSN->attachObject(mpBrickEnt);
return true;
}
//=====================================================================
bool TBoardBrickZ::setBrickMap()
{
memcpy(&mBrickMap, &brickZ,sizeof(BRICK_MAP));
return true;
}
//=====================================================================
void TBoardBrickZ::rotateCW()
{
static unsigned short r=0;
mpBrickSN->yaw(Radian(Degree(-90)));
rotateDimensions();
r++;
if(r>((sizeof(brickZ) / sizeof(BRICK_MAP)) - 1))
r=0;
memcpy(&mBrickMap, &brickZ[r],sizeof(BRICK_MAP));
}
//===================================================================== | [
"unocoder@localhost"
] | [
[
[
1,
49
]
]
] |
ef0f35ec3a39a44f7b66a7d4fab0e0917f224ee2 | 3b7ae6aa5c8a65d8942ea9d1ba27951f4478a6f7 | /trunk/test/order/elementTest.hpp | 8dfe44e030ec12e974152210ee73d68de447f7e9 | [] | no_license | BackupTheBerlios/micromegas-svn | e2e3ac9284c2e258aa7ca4b4002bcbfa93a476bd | 49ecbd25659767e0b2b30db1b439820af244422d | refs/heads/master | 2016-09-05T17:53:18.272645 | 2005-12-14T08:57:16 | 2005-12-14T08:57:16 | 40,802,416 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 562 | hpp | // elementTest.h
#ifndef ELEMENTTEST_H
#define ELEMENTTEST_H
#include <cppunit/extensions/HelperMacros.h>
class ElementTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(ElementTest);
CPPUNIT_TEST(test_dif_et_egal);
CPPUNIT_TEST(testaffectation);
CPPUNIT_TEST(testinferieur);
CPPUNIT_TEST_SUITE_END();
private:
Element* fixture1;
Element* fixture2;
public:
virtual void setUp();
virtual void tearDown();
void testaffectation();
void test_dif_et_egal();
void testinferieur();
};
#endif
| [
"olivierc@0221efed-8403-0410-97e6-f711e4792a66"
] | [
[
[
1,
34
]
]
] |
caee964220cf542ceaa182b85ad8f893dfd65c5c | fcdddf0f27e52ece3f594c14fd47d1123f4ac863 | /TeCom/src/TdkLayout/Header Files/TdkWidthProperty.h | 32492218cd42ea7c70a254997f99c3d130570406 | [] | no_license | radtek/terra-printer | 32a2568b1e92cb5a0495c651d7048db6b2bbc8e5 | 959241e52562128d196ccb806b51fda17d7342ae | refs/heads/master | 2020-06-11T01:49:15.043478 | 2011-12-12T13:31:19 | 2011-12-12T13:31:19 | null | 0 | 0 | null | null | null | null | ISO-8859-2 | C++ | false | false | 2,033 | h | /******************************************************************************
* FUNCATE - GIS development team
*
* TerraLib Components - TeCOM
*
* @(#) TdkWidthProperty.h
*
*******************************************************************************
*
* $Rev$:
*
* $Author: rui.gregorio $:
*
* $Date: 2010/08/20 20:45:30 $:
*
******************************************************************************/
// Elaborated by Rui Mauricio Gregório
#ifndef __TDK_WIDTH_PROPERTY_H
#define __TDK_WIDTH_PROPERTY_H
#include <TdkAbstractProperty.h>
//! \class TdkWidthProperty
/*! Class to manipulate the width property of object
*/
class TdkWidthProperty : public TdkAbstractProperty
{
public :
double *_x1; //!< pointer to access the x1 of _boundingBox
double *_x2; //!< pointer to access the x2 of _boundingBox
bool *_redraw; //!< pointer to access the indicator of redraw operation
public :
//! \brief TdkWidthProperty
/*! Constructor
\param newVal new width value
*/
TdkWidthProperty(const double &newVal=0.0);
//! \brief Destructor
virtual ~TdkWidthProperty();
//! \brief setValue
/*! Method to set the new value
to width property
\param newVal new width value
*/
virtual void setValue(const double &newVal);
//! \brief getValue
/*! Method to return the width value
\return returns th width value of object
*/
virtual double getValue();
//! \brief getValue
/*! Method to return the width value
by reference
*/
void getValue(double &value);
//! \brief operator
/*! Operator = overload
\param other other TdkWidthProperty object
\return returns the object with same values that old object
*/
TdkWidthProperty& operator=(const TdkWidthProperty &other);
//! \brief operator
/*! Operator = overload
\param other other TdkAbstractProperty object
\return returns the object with same values that old object
*/
TdkWidthProperty& operator=(const TdkAbstractProperty &other);
};
#endif
| [
"[email protected]@58180da6-ba8b-8960-36a5-00cc02a3ddec"
] | [
[
[
1,
78
]
]
] |
1a044dadb80f702b9a644bc9e9e5e8a88591669b | b822313f0e48cf146b4ebc6e4548b9ad9da9a78e | /KylinSdk/Standard/Source/log_t.cpp | 47dfd5f9fcffbf73566f0fa76ae2d880d46a933b | [] | no_license | dzw/kylin001v | 5cca7318301931bbb9ede9a06a24a6adfe5a8d48 | 6cec2ed2e44cea42957301ec5013d264be03ea3e | refs/heads/master | 2021-01-10T12:27:26.074650 | 2011-05-30T07:11:36 | 2011-05-30T07:11:36 | 46,501,473 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,978 | cpp | #include "stdpch.h"
#include ".\log_t.h"
KDOUBLE peerMaxSendBPS;
KBYTE peerMinExtraPing;
KBYTE peerExtraPingVariance;
Kylin::CLog * syslog = NULL;
namespace Kylin
{
CLog::CLog(KVOID):logFile(NULL),stream(NULL){
outFileName = KNEW KCHAR[256];
ZeroMemory(outFileName,256);
logFlag=LOG_SHUTDOWN | LOG_TRACE | LOG_DEBUG | LOG_INFO |LOG_NOTICE |LOG_WARNING|LOG_STARTUP|LOG_ERROR|LOG_CRITICAL|LOG_ALERT|LOG_EMERGENCY;
outputFlag=LOG_TO_FILE|LOG_TO_OSTREAM;
}
KVOID CLog::log(log_priority priority, KCCHAR *msg)
{
struct tm *newtime;
__time64_t long_time;
_time64( &long_time ); // Get time as 64-bit integer.
// Convert to local time.
newtime = _localtime64( &long_time ); // C4996
if( (outputFlag & LOG_TO_OSTREAM) && stream)
{
KCHAR cfill = stream->fill();
*stream << setfill('0') << "["
<< setw(2) << newtime->tm_mon + 1 << "/"
<< setw(2) << newtime->tm_mday << "/"
<< setw(2) << newtime->tm_year + 1900 << " "
<< setw(2) << newtime->tm_hour << ":"
<< setw(2) << newtime->tm_min << ":"
<< setw(2) << newtime->tm_sec << "]\t"
<< getPriorityString(priority) << "\t"
<< msg
<< setfill(cfill);
stream->flush();
}
if( (outputFlag & LOG_TO_FILE) && logFile){
fprintf(logFile,"[%02d/%02d/%d %02d:%02d:%02d]\t%s\t%s",
newtime->tm_mon + 1,
newtime->tm_mday,
newtime->tm_year + 1900,
newtime->tm_hour,
newtime->tm_min,
newtime->tm_sec,
getPriorityString(priority),
msg);
fflush(logFile);
}
}
CLog::~CLog(KVOID)
{
KDEL outFileName;
if(logFile){
fflush(logFile);
fclose(logFile);
logFile=NULL;
}
}
//Shutdown the logger
KVOID CLog::shutdown(KCCHAR *format, ...){
if(logFlag & LOG_SHUTDOWN){
KCHAR buf[2048];
va_list arguments;
va_start(arguments, format);
vsprintf_s(buf, format, arguments);
va_end(arguments);
log(LOG_WARNING,buf);
}
}
//Messages indicating function-calling sequence
KVOID CLog::trace(KCCHAR *format, ...){
if(logFlag & LOG_TRACE){
KCHAR buf[2048];
va_list arguments;
va_start(arguments, format);
vsprintf_s(buf, format, arguments);
va_end(arguments);
log(LOG_TRACE,buf);
}
}
//Messages that contain information normally of use only when debugging a program .
KVOID CLog::debug(KCCHAR *format, ...){
if(logFlag & LOG_DEBUG){
KCHAR buf[2048];
va_list arguments;
va_start(arguments, format);
vsprintf_s(buf, format, arguments);
va_end(arguments);
log(LOG_DEBUG,buf);
}
}
//Informational messages
KVOID CLog::info(KCCHAR *format, ...){
if(logFlag & LOG_INFO){
KCHAR buf[2048];
va_list arguments;
va_start(arguments, format);
vsprintf_s(buf, format, arguments);
va_end(arguments);
log(LOG_INFO,buf);
}
}
//Conditions that are not error conditions, but that may require special handling
KVOID CLog::notice(KCCHAR *format, ...){
if(logFlag & LOG_NOTICE){
KCHAR buf[2048];
va_list arguments;
va_start(arguments, format);
vsprintf_s(buf, format, arguments);
va_end(arguments);
log(LOG_NOTICE,buf);
}
}
//Warning messages
KVOID CLog::warning (KCCHAR *format, ...){
if(logFlag & LOG_WARNING){
KCHAR buf[2048];
va_list arguments;
va_start(arguments, format);
vsprintf_s(buf, format, arguments);
va_end(arguments);
log(LOG_WARNING,buf);
}
}
KVOID CLog::startup(KCCHAR *format, ...){
if(logFlag & LOG_STARTUP){
KCHAR buf[2048];
va_list arguments;
va_start(arguments, format);
vsprintf_s(buf, format, arguments);
va_end(arguments);
log(LOG_STARTUP,buf);
}
}
//Error messages
KVOID CLog::error(KCCHAR *format, ...){
if(logFlag & LOG_ERROR){
KCHAR buf[2048];
va_list arguments;
va_start(arguments, format);
vsprintf_s(buf, format, arguments);
va_end(arguments);
log(LOG_ERROR,buf);
}
}
//Critical conditions, such as hard device errors
KVOID CLog::critical(KCCHAR *format, ...){
if(logFlag & LOG_CRITICAL){
KCHAR buf[2048];
va_list arguments;
va_start(arguments, format);
vsprintf_s(buf, format, arguments);
va_end(arguments);
log(LOG_CRITICAL,buf);
}
}
//A condition that should be corrected immediately, such as a corrupted system database
KVOID CLog::alert(KCCHAR *format, ...){
if(logFlag & LOG_ALERT){
KCHAR buf[2048];
va_list arguments;
va_start(arguments, format);
vsprintf_s(buf, format, arguments);
va_end(arguments);
log(LOG_ALERT,buf);
}
}
//A panic condition. This is normally broadcast to all users
KVOID CLog::emergency(KCCHAR *format, ...){
if(logFlag & LOG_EMERGENCY){
KCHAR buf[2048];
va_list arguments;
va_start(arguments, format);
vsprintf_s(buf, format, arguments);
va_end(arguments);
log(LOG_EMERGENCY, buf);
}
}
KVOID CLog::setOutFile(KCCHAR *name){
if(strcmp(outFileName,name)){
if(logFile){
fflush(logFile);
fclose(logFile);
}
logFile=fopen(name,"w");
if(!logFile)
MessageBoxA(NULL,name,"can't open the file",MB_OK);
strcpy(outFileName,name);
}
}
KVOID CLog::setOutStream(ostream *stream){
this->stream=stream;
}
KCCHAR* CLog::getPriorityString( log_priority priority )
{
switch(priority)
{
case LOG_SHUTDOWN:
return "shoutdown";
case LOG_TRACE:
return "trace";
case LOG_DEBUG:
return "debug";
case LOG_INFO:
return "info";
case LOG_NOTICE:
return "notice";
case LOG_WARNING:
return "warn";
case LOG_STARTUP:
return "startup";
case LOG_ERROR:
return "error";
case LOG_CRITICAL:
return "critical";
case LOG_EMERGENCY:
return "emergency";
default:
return "";
}
}
} | [
"[email protected]"
] | [
[
[
1,
234
]
]
] |
1f805e8e52997ec19d99e23f9b9c5a5827f8695f | 6712f8313dd77ae820aaf400a5836a36af003075 | /bdGraph/ScaleRGB.h | 78e133f18f92b186d8680bde82c2f62b4ea4e5b2 | [] | no_license | AdamTT1/bdScript | d83c7c63c2c992e516dca118cfeb34af65955c14 | 5483f239935ec02ad082666021077cbc74d1790c | refs/heads/master | 2021-12-02T22:57:35.846198 | 2010-08-08T22:32:02 | 2010-08-08T22:32:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 768 | h | // scaleRGB.h : header file
//
/////////////////////////////////////////////////////////////////////////////
#ifndef interface
#define interface struct
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
class ScaleRGB : public Scale
{
public:
ScaleRGB(ImageData* imageData) : Scale(imageData) {}
void CreateBitmap(ScaleUpObj* yObj,ScaleUpObj* cbObj,ScaleUpObj* crObj,DWORD srcWidth,DWORD rowCnt,BYTE* dest,DWORD rowWidth);
BOOL IsMulWidth3() {return FALSE;}
Scale* GetSimilar(ImageData* imageData) {return new ScaleRGB(imageData);}
private:
static void MoveLineRGB(BYTE* dest,DWORD* yPtr,int srcWidth);
static void DoLineRGB(BYTE* dest,DWORD* yPtr,int srcWidth,DWORD yMult);
};
| [
"tkisky"
] | [
[
[
1,
25
]
]
] |
9d4f012b61fbb9acd57a8af4b7febd81f98bae40 | c0bd82eb640d8594f2d2b76262566288676b8395 | /src/logonserver/AccountCache.cpp | 7150e8aab94b1215454410b529fe5ac7bff93664 | [
"FSFUL"
] | permissive | vata/solution | 4c6551b9253d8f23ad5e72f4a96fc80e55e583c9 | 774fca057d12a906128f9231831ae2e10a947da6 | refs/heads/master | 2021-01-10T02:08:50.032837 | 2007-11-13T22:01:17 | 2007-11-13T22:01:17 | 45,352,930 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 11,258 | cpp | #include "LogonStdAfx.h"
initialiseSingleton(AccountMgr);
initialiseSingleton(IPBanner);
initialiseSingleton(InformationCore);
void AccountMgr::ReloadAccounts(bool silent)
{
if(!silent) sLog.outString("[AccountMgr] Reloading Accounts...");
// Load *all* accounts.
QueryResult * result = sLogonSQL->Query("SELECT acct, login, password, gm, flags, banned FROM accounts");
Field * field;
string AccountName;
set<string> account_list;
Account * acct;
if(result)
{
do
{
field = result->Fetch();
AccountName = field[1].GetString();
// transform to uppercase
transform(AccountName.begin(), AccountName.end(), AccountName.begin(), towupper);
acct = GetAccount(AccountName);
if(acct == 0)
{
// New account.
AddAccount(field);
}
else
{
// Update the account with possible changed details.
UpdateAccount(acct, field);
}
// add to our "known" list
account_list.insert(AccountName);
} while(result->NextRow());
delete result;
}
// check for any purged/deleted accounts
#ifdef WIN32
HM_NAMESPACE::hash_map<string, Account>::iterator itr = AccountDatabase.begin();
HM_NAMESPACE::hash_map<string, Account>::iterator it2;
#else
std::map<string, Account>::iterator itr = AccountDatabase.begin();
std::map<string, Account>::iterator it2;
#endif
for(; itr != AccountDatabase.end();)
{
it2 = itr;
++itr;
if(account_list.find(it2->first) == account_list.end())
AccountDatabase.erase(it2);
}
if(!silent) sLog.outString("[AccountMgr] Found %u accounts.", AccountDatabase.size());
IPBanner::getSingleton().Reload();
}
void AccountMgr::AddAccount(Field* field)
{
Account acct;
acct.AccountId = field[0].GetUInt32();
acct.Username = field[1].GetString();
acct.Password = field[2].GetString();
acct.GMFlags = field[3].GetString();
acct.AccountFlags = field[4].GetUInt32();
acct.Banned = field[5].GetUInt32();
// Convert username/password to uppercase. this is needed ;)
transform(acct.Username.begin(), acct.Username.end(), acct.Username.begin(), towupper);
transform(acct.Password.begin(), acct.Password.end(), acct.Password.begin(), towupper);
AccountDatabase[acct.Username] = acct;
}
void AccountMgr::UpdateAccount(Account * acct, Field * field)
{
uint32 id = field[0].GetUInt32();
if(id != acct->AccountId)
{
//printf("Account %u `%s` is a duplicate.\n", id, acct->Username.c_str());
sLog.outColor(TYELLOW, " >> deleting duplicate account %u [%s]...", id, acct->Username.c_str());
sLog.outColor(TNORMAL, "\n");
sLogonSQL->Execute("DELETE FROM accounts WHERE acct=%u", id);
return;
}
acct->AccountId = field[0].GetUInt32();
acct->Username = field[1].GetString();
acct->Password = field[2].GetString();
acct->GMFlags = field[3].GetString();
acct->AccountFlags = field[4].GetUInt32();
acct->Banned = field[5].GetUInt32();
// Convert username/password to uppercase. this is needed ;)
transform(acct->Username.begin(), acct->Username.end(), acct->Username.begin(), towupper);
transform(acct->Password.begin(), acct->Password.end(), acct->Password.begin(), towupper);
}
bool AccountMgr::LoadAccount(string Name)
{
QueryResult * result = sLogonSQL->Query("SELECT acct, login, password, gm, flags, banned FROM account_database WHERE login='%s'", Name.c_str());
if(result == 0)
return false;
AddAccount(result->Fetch());
delete result;
return true;
}
void AccountMgr::UpdateAccountLastIP(uint32 accountId, const char * lastIp)
{
//This allows us to keep track of last connection date and last ip (can be useful)
sLogonSQL->Execute("UPDATE accounts SET lastlogin=NOW(), lastip='%s' WHERE acct=%u;", lastIp, accountId);
}
void AccountMgr::ReloadAccountsCallback()
{
ReloadAccounts(true);
IPBanner::getSingleton().Reload();
}
#ifdef WIN32
BAN_STATUS IPBanner::CalculateBanStatus(uint32 ip_address)
{
Guard guard(setBusy);
uint8 b1 = ((uint8*)&ip_address)[0];
uint8 b2 = ((uint8*)&ip_address)[1];
uint8 b3 = ((uint8*)&ip_address)[2];
uint8 b4 = ((uint8*)&ip_address)[3];
#else
BAN_STATUS IPBanner::CalculateBanStatus(const char* ip_address)
{
Guard guard(setBusy);
//uint8 b1 = static_cast<uint8>( atol(strtok((char*)ip_address, ".")) );
//uint8 b2 = static_cast<uint8>( atol(strtok(NULL, ".")) );
//uint8 b3 = static_cast<uint8>( atol(strtok(NULL, ".")) );
//uint8 b4 = static_cast<uint8>( atol(strtok(NULL, ".")) );
uint32 b1, b2, b3, b4;
if(sscanf(ip_address, "%u.%u.%u.%u", &b1, &b2, &b3, &b4) != 4)
return BAN_STATUS_NOT_BANNED;
#endif
// loop storage array
set<IPBan*>::iterator itr = banList.begin();
uint32 bantime = 0;
bool banned = false;
for(; itr != banList.end(); ++itr)
{
// compare first byte
if((*itr)->ip.full.b1 == b1 || (*itr)->ip.full.b1 == 0xFF)
{
// compare second byte if there was a first match
if((*itr)->ip.full.b2 == b2 || (*itr)->ip.full.b2 == 0xFF)
{
// compare third byte if there was a second match
if((*itr)->ip.full.b3 == b3 || (*itr)->ip.full.b3 == 0xFF)
{
// compare last byte if there was a third match
if((*itr)->ip.full.b4 == b4 || (*itr)->ip.full.b4 == 0xFF)
{
// full IP match
banned = true;
bantime = (*itr)->ban_expire_time;
break;
}
}
}
}
}
// calculate status
if(!banned)
{
sLog.outDebug("[IPBanner] IP has no ban entry");
return BAN_STATUS_NOT_BANNED;
}
if(bantime > time(NULL))
{
// temporary ban.
sLog.outDebug("[IPBanner] IP temporary banned, %u seconds left", (bantime-time(NULL)));
return BAN_STATUS_TIME_LEFT_ON_BAN;
}
else if(bantime != 0)
{
// ban has expired. erase it from the banlist and database
sLog.outDebug("[IPBanner] Expired IP temporary ban has been removed");
Remove(itr);
return BAN_STATUS_NOT_BANNED;
}
else
{
// permanantly banned.
sLog.outDebug("[IPBanner] IP permanantly banned");
return BAN_STATUS_PERMANANT_BAN;
}
}
void IPBanner::Load()
{
QueryResult * result = sLogonSQL->Query("SELECT ip, expire FROM ipbans;");
Field * fields;
IPBan * ban;
const char * ip_str;
if(result)
{
do
{
ban = new IPBan;
fields = result->Fetch();
ip_str = fields[0].GetString();
ban->ip.full.b1 = static_cast<uint8>( atol(strtok((char*)ip_str, ".")) );
ban->ip.full.b2 = static_cast<uint8>( atol(strtok(NULL, ".")) );
ban->ip.full.b3 = static_cast<uint8>( atol(strtok(NULL, ".")) );
ban->ip.full.b4 = static_cast<uint8>( atol(strtok(NULL, ".")) );
ban->ban_expire_time = fields[1].GetUInt32();
banList.insert( ban );
}
while(result->NextRow());
delete result;
}
}
void IPBanner::Reload()
{
setBusy.Acquire();
banList.clear();
Load();
setBusy.Release();
}
void IPBanner::Remove(set<IPBan*>::iterator ban)
{
Guard guard(setBusy);
banList.erase(ban);
sLogonSQL->Execute("DELETE FROM ipbans WHERE ip='%s';", (*ban)->ip.full);
sLog.outDebug("[IPBanner] Removed expired IPBan for ip '%s'", (*ban)->ip.full);
}
void InformationCore::AddRealm(uint32 realm_id, Realm * rlm)
{
m_realms.insert( make_pair( realm_id, *rlm ) );
}
void InformationCore::RemoveRealm(uint32 realm_id)
{
map<uint32, Realm>::iterator itr = m_realms.find(realm_id);
if(itr == m_realms.end()) return;
sLog.outString("Removing realm `%s` (%u) due to socket close.", itr->second.Name.c_str(), realm_id);
m_realms.erase(itr);
}
void InformationCore::SendRealms(AuthSocket * Socket)
{
realmLock.Acquire();
// packet header
ByteBuffer data;
data << uint8(0x10);
data << uint16(0); // Size Placeholder
// dunno what this is..
data << uint32(0);
sAuthLogonChallenge_C * client = Socket->GetChallenge();
if(client->build < CLIENT_2_0_7)
data << uint8(m_realms.size());
else
data << uint16(m_realms.size());
// loop realms :/
map<uint32, Realm>::iterator itr = m_realms.begin();
for(; itr != m_realms.end(); ++itr)
{
data << uint8(itr->second.Colour);
data << uint8(0); // Locked Flag
data << uint8(itr->second.Icon);
// This part is the same for all.
data << itr->second.Name;
data << itr->second.Address;
data << itr->second.Population;
data << uint8(0); // Character Count
data << uint8(itr->second.TimeZone); // time zone
data << uint8(0);
}
realmLock.Release();
data << uint8(0x15);
data << uint8(0);
// Re-calculate size.
*(uint16*)&data.contents()[1] = data.size() - 3;
// Send to the socket.
Socket->SendPacket((const u8*)data.contents(), data.size());
}
BigNumber * InformationCore::GetSessionKey(uint32 account_id)
{
map<uint32, BigNumber*>::iterator itr = m_sessionkeys.find(account_id);
if(itr == m_sessionkeys.end())
return 0;
else
return itr->second;
}
void InformationCore::DeleteSessionKey(uint32 account_id)
{
map<uint32, BigNumber*>::iterator itr = m_sessionkeys.find(account_id);
if(itr == m_sessionkeys.end())
return;
delete itr->second;
m_sessionkeys.erase(itr);
}
void InformationCore::SetSessionKey(uint32 account_id, BigNumber * key)
{
m_sessionkeys[account_id] = key;
}
void InformationCore::TimeoutSockets()
{
uint32 t = time(NULL);
// check the ping time
set<LogonCommServerSocket*>::iterator itr, it2;
LogonCommServerSocket * s;
for(itr = m_serverSockets.begin(); itr != m_serverSockets.end();)
{
s = *itr;
it2 = itr;
++itr;
if(s->IsConnected() && !s->CheckConnection() || (usepings && (t - s->last_ping) > 20)) // ping timeout
{
s->removed = true;
s->Disconnect();
#ifdef ASYNC_NET
s->PostCompletion(IOShutdownRequest);
#endif
if(s->my_id)
RemoveRealm(s->my_id);
m_serverSockets.erase(it2);
}
}
}
| [
"[email protected]"
] | [
[
[
1,
370
]
]
] |
a2835e80c81ea64c29e723a527cd434b6cf0452c | 138a353006eb1376668037fcdfbafc05450aa413 | /source/LiquidNitroTank.h | b78d2389d947ca86b7df1dd95b5161310f56e8ae | [] | 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 | 893 | h | //tank moves along a scripted path to the right and down. It only starts moving down halfway through its x-movement
#include "GameServices.h"
#include "TriggerEvent.h"
#include "GameEvent.h"
#include "EventManager.h"
#include "PuzzleEntity.h"
class GameServices;
class TriggerEvent;
class EventManager;
class LiquidNitroTank : public PuzzleEntity {
public:
LiquidNitroTank(GameServices *gs, OgreNewt::World* collisionWorld, Ogre::SceneNode *parentNode,
const Ogre::Vector3 &pos, const Ogre::Vector3 &size,
const Ogre::String &entityName, const Ogre::String &modelFile,
const Ogre::String &listenfor, const Ogre::Vector3 &dest, float xspeed, float yspeed);
void update();
void listenCallback(GameEvent *evnt); //executed when a listened for event arrives
void registerListener();
private:
bool mActive;
bool mFalling;
float mX_Speed;
float mY_Accel;
}; | [
"Sonicma7@0822fb10-d3c0-11de-a505-35228575a32e"
] | [
[
[
1,
25
]
]
] |
e1f44147b1e726a37d801b5e62388c3cc770b072 | 5dfa2f8acf81eb653df4a35a76d6be973b10a62c | /branches/test/CCV_Select_Camera/addons/ofxNCore/src/MultiCams/CamsUtils.h | 5e87062ab5de97db128b6d2b409805422d354c51 | [] | no_license | guozanhua/ccv-multicam | d69534ff8592f7984a5eadc83ed8b20b9d3df949 | 31206f0de7f73b3d43f2a910fdcdffb7ed1bf2c2 | refs/heads/master | 2021-01-22T14:24:52.321877 | 2011-08-31T14:18:44 | 2011-08-31T14:18:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,315 | h | //! CamsUtils.h
/*!
*
*
* Created by Yishi Guo on 06/13/2011.
* Copyright 2011 NUI Group. All rights reserved.
*
*/
// ----------------------------------------------
#ifndef CAMS_UTILS_H
#define CAMS_UTILS_H
// ----------------------------------------------
//#include "PS3.h"
#include "ofxPS3.h"
#include "ofxDShow.h"
#include "ofxXmlSettings.h"
#include "ofxCameraBase.h"
#include "ofxCameraBaseSettings.h"
// ----------------------------------------------
class CamsUtils {
public:
CamsUtils();
~CamsUtils();
void setup( CLEyeCameraColorMode colorMode, CLEyeCameraResolution camRes, float frameRate );
void setup();
void update();
void start();
void stop();
int getCount();
int getXGrid();
int getYGrid();
//int getrawid( ps3* cam );
//ps3* getcam( int index );
//ps3* getcam( int x, int y );
//ps3* getrawcam( int index );
//ps3** getcams();
//ps3** getrawcams();
int getRawId( ofxCameraBase* cam );
ofxCameraBase* getCam( int index );
ofxCameraBase* getCam( int x, int y );
ofxCameraBase* getRawCam( int index );
ofxCameraBase** getCams();
ofxCameraBase** getRawCams();
ofxCameraBaseSettings* getRawCamSettings( int index );
//! Set the camera feature by raw cam id
void setRawCamFeature( int rawId, CAMERA_BASE_FEATURE feature, int firstValue, int secondValue, bool isAuto, bool isEnable );
bool isSelected( int rawId );
void setSelected( int rawId, bool reset = false );
bool isUsed( int displayId );
void setXY( int x, int y );
//void setCam( int index, PS3* cam );
//void setCam( int x, int y, PS3* cam );
void setCam( int index, ofxCameraBase* cam );
void setCam( int x, int y, ofxCameraBase* cam );
void resetAll();
//! Reset the camera parameters
void resetCam( int rawIndex );
void resetCams();
//! Save the settings to XML file
void saveXML( string filename = "MultiCams.xml" );
//! Load the settings from XML file
void loadXML( string filename = "MultiCams.xml" );
int camCount, selectedCamCount;
int xGrid, yGrid;
//PS3** rawCams;
//PS3** displayCams;
//! XML settings
//PS3** xmlCams;
int numCamTags;
private:
int getDevicesCount( bool bAll = true, CAMERATYPE type = PS3, bool bPure = false );
GUID getGUID( CAMERATYPE type, int camId );
char* getDevicePath( CAMERATYPE type, int camId );
void createDisplayCams( int x, int y);
void resetCamsSelected();
//! Set the default value for camera
void setupCameraSettings( ofxCameraBaseSettings *settings );
void applyCameraSettings();
void receiveSettingsFromCameras();
void receiveSettingsFromRawSettings();
void copySettingsFromXmlSettings( ofxCameraBaseSettings *src, ofxCameraBaseSettings *dst );
void startCameras();
CLEyeCameraColorMode colorMode;
CLEyeCameraResolution camRes;
float frameRate;
ofxXmlSettings XML;
ofxCameraBase** rawCams;
ofxCameraBase** displayCams;
ofxCameraBase** xmlCams;
ofxCameraBaseSettings** rawCamsSettings;
ofxCameraBaseSettings** displayCamsSettings;
ofxCameraBaseSettings** xmlCamsSettings;
bool* camsSelected; //< For raw cameras
bool* camsUsed; //< For display cameras
};
// ----------------------------------------------
#endif
// ---------------------------------------------- | [
"baicaibang@da66ed7f-4d6a-8cb4-a557-1474cfe16edc"
] | [
[
[
1,
129
]
]
] |
15c7b44416cdc4f9af6c9b0954a95836d02ce0db | d7b345a8a6b0473c325fab661342de295c33b9c8 | /beta/src/polaris/FileACL.cpp | b9160cd04f38a1d8b6b85171d56f71a6d6d8fbcd | [] | no_license | raould/Polaris-Open-Source | 67ccd647bf40de51a3dae903ab70e8c271f3f448 | 10d0ca7e2db9e082e1d2ed2e43fa46875f1b07b2 | refs/heads/master | 2021-01-01T19:19:39.148016 | 2010-05-10T17:39:26 | 2010-05-10T17:39:26 | 631,953 | 3 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 6,340 | cpp | // Copyright 2010 Hewlett-Packard under the terms of the MIT X license
// found at http://www.opensource.org/licenses/mit-license.html
#include "StdAfx.h"
#include ".\FileACL.h"
#include <shellapi.h>
#include "Logger.h"
#include "Constants.h"
#include <Aclapi.h>
#include <Sddl.h>
Logger aclLogger(L"FileACL");
std::wstring enquoter(std::wstring text) {return L"\"" + text + L"\"";}
void launchXcacls(std::wstring command) {
std::wstring xcaclsPath = Constants::polarisExecutablesFolderPath() + L"\\xcacls.vbs";
int success = (int)ShellExecute(NULL, NULL, L"cscript", (enquoter(xcaclsPath) + L" " + command).c_str(), NULL, SW_HIDE);
if (success <= 32) {aclLogger.log(L"xcacls.vbs did not launch successfully");}
}
FileACL::FileACL(std::wstring filePath){
m_filePath = filePath;
}
FileACL::~FileACL(void)
{
}
/**
* The grant is eventual, i.e., asynchronous
*/
void FileACL::grant(std::wstring account, std::wstring rights){
launchXcacls(enquoter(m_filePath) + L" /e /g " + account + rights);
}
/**
* the revocation is eventual, i.e., asynchronous
*/
void FileACL::revoke(std::wstring account){
launchXcacls(enquoter(m_filePath) + L" /e /r " + account);
}
/**
* the wipe is eventual
*/
void FileACL::wipe(){
launchXcacls(enquoter(m_filePath) + L" /g Administrators:f");
}
/**
* This is not robust, in that it simply adds a new ace for the account to the end of the dacl.
* If there is already an ace for this account in this dacl, the result is undetermined
* Assumes the account being set is local, not a domain account, i.e., assumes it is a pet account
*
* Algorithm: Get the current security descriptor for the file, get the sid for the account,
* convert the security descriptor to a string, create a new stringified ACE for this account,
* append the new ace string to the security descriptor string, convert the security descriptor
* string to a relative security descriptor, convert the relative security descriptor to an
* absolute descriptor, extract a pointer to the new dacl in the absolute descriptor, update the dacl
* portion of the file's security descriptor with the new dacl.
*
**/
bool FileACL::immediateReadGrant(std::wstring account) {
//get the original security descriptor as a string
PSECURITY_DESCRIPTOR originalSecurityDescriptor = NULL;
PACL originalDacl;
DWORD getInfoResult = GetNamedSecurityInfo(
// Why do I have to cast this? Is this an error waiting to happen?
(LPWSTR)m_filePath.c_str(),
SE_FILE_OBJECT,
DACL_SECURITY_INFORMATION,
NULL,
NULL,
&originalDacl,
NULL,
&originalSecurityDescriptor);
if (getInfoResult != ERROR_SUCCESS) {
aclLogger.log(L"getnamedsecurityinfo failed",getInfoResult);
return false;
}
ULONG securityDescriptorLen;
LPTSTR stringSecurityDescriptor;
BOOL convertToStringSuccess = ConvertSecurityDescriptorToStringSecurityDescriptor(
originalSecurityDescriptor,
SDDL_REVISION_1,
DACL_SECURITY_INFORMATION,
&stringSecurityDescriptor,
&securityDescriptorLen);
LocalFree(originalSecurityDescriptor);
if (!convertToStringSuccess) {
aclLogger.log(L"convertSD to string failed", GetLastError());
return false;
}
std::wstring secDesc = stringSecurityDescriptor;
LocalFree(stringSecurityDescriptor);
// get the SID for the account in string form
int const sidMaxLen = 1000;
BYTE sid[sidMaxLen] = {};
DWORD sidSize = sidMaxLen;
SID_NAME_USE peUse;
DWORD domainSize = sidMaxLen;
wchar_t domain[sidMaxLen] = {};
BOOL gettingSIDsuccess = LookupAccountName(
NULL,
account.c_str(),
sid,
&sidSize,
domain,
&domainSize,
&peUse
);
if (!gettingSIDsuccess) {
aclLogger.log(L"lookupaccountname failed", GetLastError());
LocalFree(originalSecurityDescriptor);
LocalFree(stringSecurityDescriptor);
return false;
}
LPTSTR sidNameChars;
BOOL convertedSIDtoString = ConvertSidToStringSid(sid, &sidNameChars);
std::wstring accountSid = sidNameChars;
LocalFree(sidNameChars);
//manufacture new string ace in format:
// ace_type;ace_flags;rights;object_guid;inherit_object_guid;account_sid
std::wstring newAce = L"(A;OICI;GRFR;;;" + accountSid + L")";
//manufacture the new dacl security description
std::wstring newDaclString = secDesc + newAce;
PSECURITY_DESCRIPTOR newRelativeSecurityDescriptor;
ULONG sdSize;
BOOL convertStringSDtoSDsuccess = ConvertStringSecurityDescriptorToSecurityDescriptor(
newDaclString.c_str(),
SDDL_REVISION_1,
&newRelativeSecurityDescriptor,
&sdSize);
if (!convertStringSDtoSDsuccess) {
aclLogger.log(L"convertstringsd to sd failed", GetLastError());
return false;
}
//transform relative sd to absolute sd so we can extract the dacl
DWORD const outputSize = 5000;
DWORD absoluteSDSize = outputSize;
BYTE absoluteSD[outputSize] = {};
DWORD daclSize = outputSize;
BYTE dacl[outputSize] = {};
DWORD paclSize = outputSize;
BYTE pacl[outputSize] = {};
DWORD ownerSize = outputSize;
BYTE owner[outputSize] = {};
DWORD groupSize = outputSize;
BYTE group[outputSize] = {};
BOOL makeAbsoluteSuccess = MakeAbsoluteSD(
// PSECURITY_DESCRIPTOR pSelfRelativeSD,
newRelativeSecurityDescriptor,
// PSECURITY_DESCRIPTOR pAbsoluteSD,
absoluteSD,
// LPDWORD lpdwAbsoluteSDSize,
&absoluteSDSize,
// PACL pDacl,
(PACL)dacl,
// LPDWORD lpdwDaclSize,
&daclSize,
// PACL pSacl,
(PACL)pacl,
// LPDWORD lpdwSaclSize,
&paclSize,
// PSID pOwner,
(PSID)owner,
// LPDWORD lpdwOwnerSize,
&ownerSize,
// PSID pPrimaryGroup,
(PSID)group,
// LPDWORD lpdwPrimaryGroupSize
&groupSize);
LocalFree(newRelativeSecurityDescriptor);
if (!makeAbsoluteSuccess) {
aclLogger.log(L"makeabsolutesd failed", GetLastError());
return false;
}
DWORD setSecInfoSuccess = SetNamedSecurityInfo(
// LPTSTR pObjectName,
(LPWSTR)m_filePath.c_str(),
// SE_OBJECT_TYPE ObjectType,
SE_FILE_OBJECT,
// SECURITY_INFORMATION SecurityInfo,
DACL_SECURITY_INFORMATION,
// PSID psidOwner,
NULL,
// PSID psidGroup,
NULL,
// PACL pDacl,
(PACL)dacl,
// PACL pSacl
NULL
);
if (setSecInfoSuccess != ERROR_SUCCESS) {
aclLogger.log(L"setsecurityinfo failed", setSecInfoSuccess);
return false;
}
return true;
}
| [
"[email protected]"
] | [
[
[
1,
212
]
]
] |
f85ade80897cd966d8886504c85b705bf4c766b4 | 5f0b8d4a0817a46a9ae18a057a62c2442c0eb17e | /Include/theme/Default/MenuTheme.h | 996bb1d27e4d5b5f7a4300a34e038eb29353172f | [
"BSD-3-Clause"
] | permissive | gui-works/ui | 3327cfef7b9bbb596f2202b81f3fc9a32d5cbe2b | 023faf07ff7f11aa7d35c7849b669d18f8911cc6 | refs/heads/master | 2020-07-18T00:46:37.172575 | 2009-11-18T22:05:25 | 2009-11-18T22:05:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,581 | h | /*
* Copyright (c) 2003-2006, Bram Stein
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* 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 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef MENUTHEME_H
#define MENUTHEME_H
#include "./ComponentTheme.h"
#include "../../util/GradientColor.h"
#include "../../event/PropertyListener.h"
#include "../../border/LineBorder.h"
#include "../../event/KeyListener.h"
namespace ui
{
namespace theme
{
namespace defaulttheme
{
class MenuTheme : public ComponentTheme, public event::PropertyListener, public event::KeyListener
{
public:
MenuTheme();
void installTheme(Component *comp);
void deinstallTheme(Component *comp);
void paint(Graphics& g,const Component *comp) const;
const util::Dimension getPreferredSize(const Component *comp) const;
void propertyChanged(const event::PropertyEvent &e);
private:
void keyTyped(const event::KeyEvent &e);
void keyPressed(const event::KeyEvent &e);
void keyReleased(const event::KeyEvent &e);
util::GradientColor background;
util::Color foreground;
border::LineBorder border;
util::Color transparant;
};
}
}
}
#endif | [
"bs@bram.(none)"
] | [
[
[
1,
66
]
]
] |
8a6d90b4fc758938bfbae938d1dd11b6a4341332 | 3970f1a70df104f46443480d1ba86e246d8f3b22 | /imebra/src/base/include/streamWriter.h | 63a56d769230ec2f5bd9b4f79cd8a4cda83ab22f | [] | no_license | zhan2016/vimrid | 9f8ea8a6eb98153300e6f8c1264b2c042c23ee22 | 28ae31d57b77df883be3b869f6b64695df441edb | refs/heads/master | 2021-01-20T16:24:36.247136 | 2009-07-28T18:32:31 | 2009-07-28T18:32:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,398 | h | /*
0.0.46
Imebra: a C++ dicom library.
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 by Paolo Brandoli
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE Version 3
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU AFFERO GENERAL PUBLIC LICENSE Version 3 for more details.
You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE Version 3
along with this program; If not, see http://www.gnu.org/licenses/
-------------------
If you want to use Imebra commercially then you have to buy the commercial
license available at http://puntoexe.com
After you buy the commercial license then you can use Imebra according
to the terms described in the Imebra Commercial License Version 1.
A copy of the Imebra Commercial License Version 1 is available in the
documentation pages.
Imebra is available at http://puntoexe.com
The author can be contacted by email at [email protected] or by mail at
the following address:
Paolo Brandoli
Preglov trg 6
1000 Ljubljana
Slovenia
*/
/*! \file streamWriter.h
\brief Declaration of the the class used to write the streams.
*/
#if !defined(imebraStreamWriter_2C008538_F046_401C_8C83_2F76E1077DB0__INCLUDED_)
#define imebraStreamWriter_2C008538_F046_401C_8C83_2F76E1077DB0__INCLUDED_
#include "streamController.h"
///////////////////////////////////////////////////////////
//
// Everything is in the namespace puntoexe
//
///////////////////////////////////////////////////////////
namespace puntoexe
{
/// \brief Use this class to write into a baseStream
/// derived class.
///
/// Like the streamReader, this class is not multithread
/// safe, but several streamWriter (in several threads)
/// can be connected to a single stream.
///
/// A streamWriter can also be connected only to a part
/// of the original stream: when this feature is used then
/// the streamWriter will act as if only the visible bytes
/// exist.
///
///////////////////////////////////////////////////////////
class streamWriter: public streamController
{
public:
/// \brief Creates the streamWriter and connects it to a
/// baseStream object.
///
/// @param pControlledStream the stream used by the
/// streamWriter to write
/// @param virtualStart the first stream's byte
/// visible to the streamWriter
/// @param virtualLength the number of stream's bytes
/// visible to the
/// streamWriter. Set to 0 to
/// allow the streamWriter to
/// see all the bytes
///
///////////////////////////////////////////////////////////
streamWriter(ptr<baseStream> pControlledStream, imbxUint32 virtualStart = 0, imbxUint32 virtualLength = 0);
/// \brief Flushes the internal buffer, disconnects the
/// stream and destroys the streamWriter.
///
///////////////////////////////////////////////////////////
~streamWriter();
/// \brief Writes the internal buffer into the connected
/// stream. This function is automatically called
/// when needed, but your application can call it
/// when syncronization between the cached data
/// and the stream is needed.
///
///////////////////////////////////////////////////////////
void flushDataBuffer();
/// \brief Write raw data into the stream.
///
/// The data stored in the pBuffer parameter will be
/// written into the stream.
///
/// The function throws a streamExceptionWrite exception
/// if an error occurs.
///
/// @param pBuffer a pointer to the buffer which stores
/// the data that must be written into
/// the stream
/// @param bufferLength the number of bytes that must be
/// written to the stream
///
///////////////////////////////////////////////////////////
void write(imbxUint8* pBuffer, imbxUint32 bufferLength);
/// \brief Write the specified amount of bits to the
/// stream.
///
/// The functions uses a special bit pointer to keep track
/// of the bytes that haven't been completly written.
///
/// The function throws a streamExceptionWrite exception
/// if an error occurs.
///
/// @param pBuffer a pointer to a imbxUint32 value that
/// will be stores the bits to be written
/// The bits must be right aligned.
/// @param bitsNum the number of bits to write.
/// The function can write 32 bits maximum
///
///////////////////////////////////////////////////////////
inline void writeBits(imbxUint32* const pBuffer, int bitsNum)
{
PUNTOEXE_FUNCTION_START(L"streamWriter::writeBits");
imbxUint32 tempBuffer=*pBuffer;
while(bitsNum != 0)
{
tempBuffer &= (((imbxUint32)1) << bitsNum) - 1;
if(bitsNum <= (8 - m_outBitsNum))
{
m_outBitsBuffer |= (imbxUint8)(tempBuffer << (8 - m_outBitsNum - bitsNum));
m_outBitsNum += bitsNum;
bitsNum = 0;
}
else
{
m_outBitsBuffer |= (imbxUint8)(tempBuffer >> (bitsNum + m_outBitsNum - 8));
bitsNum -= (8-m_outBitsNum);
m_outBitsNum = 8;
}
if(m_outBitsNum==8)
{
m_outBitsNum = 0;
writeByte(&m_outBitsBuffer);
m_outBitsBuffer = 0;
}
}
PUNTOEXE_FUNCTION_END();
}
/// \brief Reset the bit pointer used by writeBits().
///
/// A subsequent call to writeBits() will write data to
/// a byte-aligned boundary.
///
///////////////////////////////////////////////////////////
inline void resetOutBitsBuffer()
{
PUNTOEXE_FUNCTION_START(L"streamWriter::resetOutBitsBuffer");
if(m_outBitsNum == 0)
return;
writeByte(&m_outBitsBuffer);
flushDataBuffer();
m_outBitsBuffer = 0;
m_outBitsNum = 0;
PUNTOEXE_FUNCTION_END();
}
/// \brief Write a single byte to the stream, parsing it
/// if m_pTagByte is not zero.
///
/// The byte to be written must be stored in the buffer
/// pointed by the parameter pBuffer.
///
/// If m_pTagByte is zero, then the function writes
/// the byte and returns.
///
/// If m_pTagByte is not zero, then the function adds a
/// byte with value 0x0 after all the bytes with value
/// 0xFF.
/// This mechanism is used to avoid the generation of
/// the jpeg tags in a stream.
///
/// @param pBuffer a pointer to the location where the
/// value of the byte to be written
/// is stored
///
///////////////////////////////////////////////////////////
inline void writeByte(imbxUint8* pBuffer)
{
if(m_pDataBufferCurrent == m_pDataBufferMaxEnd)
{
flushDataBuffer();
}
*(m_pDataBufferCurrent++) = *pBuffer;
if(m_pTagByte != 0 && *pBuffer==(imbxUint8)0xff)
{
if(m_pDataBufferCurrent == m_pDataBufferMaxEnd)
{
flushDataBuffer();
}
*(m_pDataBufferCurrent++) = 0;
}
}
private:
imbxUint8 m_outBitsBuffer;
int m_outBitsNum;
};
} // namespace puntoexe
#endif // !defined(imebraStreamWriter_2C008538_F046_401C_8C83_2F76E1077DB0__INCLUDED_)
| [
"[email protected]"
] | [
[
[
1,
242
]
]
] |
ee86f90dbf27ab26c085ac3f517f6bcbb83ffe56 | f53b18d7b296aa67d2a35c69465e2f644c08bfa0 | /trunk/working Src/UI/rigo.h | 4298e6e260f3013ddf3b5ad3509721e898a469b0 | [] | no_license | BackupTheBerlios/rigo-svn | 82d67b992a128c111335ac78be9ab9ec6dde8e70 | a510f30ec4da0f0493d47f7164f9bbfffb566616 | refs/heads/master | 2016-09-05T21:13:49.432123 | 2006-08-12T03:59:01 | 2006-08-12T03:59:01 | 40,800,289 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,620 | h | /////////////////////////////////////////////////////////////////////////////
// Name: rigo.h
// Purpose:
// Author: Jeremy W
// Modified by:
// Created: 07/17/06 22:30:36
// RCS-ID:
// Copyright: Copyright (C) 2006
// Licence: GPL v2
/////////////////////////////////////////////////////////////////////////////
#ifndef _RIGO_H_
#define _RIGO_H_
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "rigo.cpp"
#endif
/*!
* Includes
*/
////@begin includes
#include "wx/image.h"
#include "mainFrame.h"
////@end includes
/*!
* Forward declarations
*/
////@begin forward declarations
////@end forward declarations
/*!
* Control identifiers
*/
////@begin control identifiers
////@end control identifiers
/*!
* RigoApp class declaration
*/
class RigoApp: public wxApp
{
DECLARE_CLASS( RigoApp )
DECLARE_EVENT_TABLE()
public:
/// Constructor
RigoApp();
/// Initialises the application
virtual bool OnInit();
/// Called on exit
virtual int OnExit();
////@begin RigoApp event handler declarations
/// wxEVT_IDLE event handler for ID_UNIDENTIFIED
void OnIdle( wxIdleEvent& event );
////@end RigoApp event handler declarations
////@begin RigoApp member function declarations
////@end RigoApp member function declarations
////@begin RigoApp member variables
////@end RigoApp member variables
};
/*!
* Application instance declaration
*/
////@begin declare app
DECLARE_APP(RigoApp)
////@end declare app
#endif
// _RIGO_H_
| [
"siafu86@a8ebc1f5-d704-0410-a9ec-c9bfc824b517"
] | [
[
[
1,
85
]
]
] |
c417a680be5a49af0743165c112b849010ce4b8b | 324524076ba7b05d9d8cf5b65f4cd84072c2f771 | /Checkers/Libraries/Common/Windows/eLibExtra.cpp | 2cba8e905672c2c290fada5a22915f69272de669 | [
"BSD-2-Clause"
] | permissive | joeyespo-archive/checkers-c | 3bf9ff11f5f1dee4c17cd62fb8af9ba79246e1c3 | 477521eb0221b747e93245830698d01fafd2bd66 | refs/heads/master | 2021-01-01T05:32:45.964978 | 2011-03-13T04:53:08 | 2011-03-13T04:53:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,438 | cpp | // eLibExtra.cpp
// Extra routines for eLib
// By Joe Esposito
typedef WINUSERAPI BOOL (WINAPI *ANIMATEWINDOW) ( HWND hWnd, DWORD dwTime, DWORD dwFlags );
#define AW_HOR_POSITIVE 0x00000001
#define AW_HOR_NEGATIVE 0x00000002
#define AW_VER_POSITIVE 0x00000004
#define AW_VER_NEGATIVE 0x00000008
#define AW_CENTER 0x00000010
#define AW_HIDE 0x00010000
#define AW_ACTIVATE 0x00020000
#define AW_SLIDE 0x00040000
#define AW_BLEND 0x00080000
// Animates the window
BOOL AnimateWindow (HWND hWnd, DWORD dwTime, DWORD dwFlags)
{
HMODULE hModule;
ANIMATEWINDOW AnimateWindow;
BOOL bResult;
// Load the library
hModule = LoadLibrary("User32");
AnimateWindow = (ANIMATEWINDOW)GetProcAddress(hModule, "AnimateWindow");
// Animate the window
bResult = AnimateWindow(m_pr_hWnd, 400, (AW_CENTER | (( cxValue != FALSE )?( 0 ):( SW_HIDE ))));
// Clean up
FreeLibrary(hModule);
}
void inline WriteLog( char *ch,... )
{
char buf[1024];
va_list arg_list;
va_start(arg_list, ch);
wvsprintf(buf, ch, arg_list);
va_end(arg_list);
FILE *file;
file = fopen("log.txt","a+");
fprintf( file, "%s", buf );
fclose( file );
}
// Usage
// WriteLog( "int value=%d \n str value=%s", 19, "test" );
| [
"[email protected]"
] | [
[
[
1,
59
]
]
] |
35cb19522a7789de8846b16f06b1fc505db28bb8 | 975d45994f670a7f284b0dc88d3a0ebe44458a82 | /logica/WarBugsLogic/LWarBugsLib/CJogador.h | 66befab1741cf914f69d3514b23a3cb58a84fd9b | [] | 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 | 1,328 | h | #pragma once
#include "CBugSocket.h"
#include <iostream>
using namespace std;
#include "CWarBugObject.h"
#include "CCenario.h"
//#include "CPersonagemJogador.h"
class CJogador : public CWarBugObject
{
private:
char _nome[20];
char _nascimento[10];
char _email[30];
char _login[15];
char _senha[15];
CBugSocket * _socket;
CPersonagemJogador * _personagem;
CCenario * _cenario;
long _TempoEnvioPing;
long _TempoRespostaPing;
bool _isPlaying;
public:
CJogador();
char * getName();
char * getBirthdate();
char * getEmail();
char * getLogin();
char * getPassword();
CBugSocket * getSocket();
CPersonagemJogador * getCharacter();
CCenario * getScene();
bool isPlaying();
void setName(char *value);
void setBirthdate(char *value);
void setEmail(char *value);
void setLogin(char *value);
void setPassword(char *value);
void setSocket(CBugSocket * socket);
void setCharacter(CPersonagemJogador * personagem);
void setScene(CCenario * cenario);
void setPlaying(bool isplaying);
long getBeginTimePing();
void setBeginTimePing(long newTime);
long getEndTimePing();
void setEndTimePing(long newTime);
};
| [
"[email protected]"
] | [
[
[
1,
52
]
]
] |
a95ad212f66be735cf4846becaa3d2690ff7c3ef | b5ab57edece8c14a67cc98e745c7d51449defcff | /Captain's Log/MainGame/Source/GameObjects/CItem.h | c4ee648e8ca6cbf0f55608290b838b68f3b1de78 | [] | 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,760 | h | #ifndef CItem_h__
#define CItem_h__
#include "CBase.h"
class CUnit;
class CItem : public CBase
{
int m_nItemName;
int m_nItemType;
int m_nAmountType;
int m_nAmountCategory;
float m_fAmount;
CUnit* m_pTarget;
protected:
public:
int ItemName() const { return m_nItemName; }
int ItemType() const { return m_nItemType; }
int AmountType() const { return m_nAmountType; }
int AmountCategory() const { return m_nAmountCategory; }
float Amount() const { return m_fAmount; }
CUnit* Target() { return m_pTarget; }
void ItemName(int val) { m_nItemName = val; }
void AmountType(int val) { m_nAmountType = val; }
void AmountCategory(int val) { m_nAmountCategory = val; }
void Amount(float val) { m_fAmount = val; }
void ItemType (int val) { m_nItemType = val; }
enum {ITEM_NULL,
ITEM_BOOKOFHASTE, ITEM_BOOKOFSWIFTNESS, ITEM_BOOKOFPROTECTION,
ITEM_BOOKOFSTRENGTH, ITEM_BOOKOFVITALITY, ITEM_GLOVESOFHASTE, ITEM_BOOTSOFSWIFTNESS,
ITEM_SHIELDOFANGELS, ITEM_SWORDOFTITANS, ITEM_RESURRECTIONSTONE, ITEM_GEMOFLIFE,
ITEM_MEDUSASTORCH, ITEM_RODOFLIGHTNING, ITEM_TSUNAMISTONE, ITEM_RINGOFWAR,
ITEM_ARCOFLIFE, ITEM_WIZARDSSTAFF, ITEM_STONEOFTHEDEAD,
ITEM_MAX};
enum {ITEMTYPE_NULL, ITEMTYPE_PASSIVE, ITEMTYPE_APPLIED, ITEMTYPE_ACTIVE, ITEMTYPE_MAX};
enum {VALUECATEGORY_NULL,
VALUECATEGORY_ATTACKSPEED, VALUECATEGORY_MOVEMENTSPEED,
VALUECATEGORY_ARMOR, VALUECATEGORY_ATTACKDAMAGE, VALUECATEGORY_HP,
VALUECATEGORY_MAX};
enum {VALUETYPE_NULL, VALUETYPE_PERCENTAGE, VALUETYPE_INTEGER, VALUETYPE_MAX};
CItem();
CItem& operator=(CItem& pItem);
virtual void AddEffect();
virtual void RemoveEffect();
bool Collect(CUnit* pTarget);
void Drop();
};
#endif // CItem_h__ | [
"notserp007@34577012-8437-c882-6fb8-056151eb068d",
"dpmakin@34577012-8437-c882-6fb8-056151eb068d"
] | [
[
[
1,
9
],
[
14,
14
],
[
18,
19
],
[
54,
56
],
[
58,
61
]
],
[
[
10,
13
],
[
15,
17
],
[
20,
53
],
[
57,
57
]
]
] |
ddb81f918c146766c32d9f8fa103e513be1d3a11 | 611fc0940b78862ca89de79a8bbeab991f5f471a | /src/Teki/KariudoKen2.cpp | 989c3d4c3fa98effe3a620a40004f44f5338039e | [] | no_license | LakeIshikawa/splstage2 | df1d8f59319a4e8d9375b9d3379c3548bc520f44 | b4bf7caadf940773a977edd0de8edc610cd2f736 | refs/heads/master | 2021-01-10T21:16:45.430981 | 2010-01-29T08:57:34 | 2010-01-29T08:57:34 | 37,068,575 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 5,714 | cpp | #include ".\KariudoKen2.h"
#include "..\\Management\\GameControl.h"
class AshibaInvisible;
class AshibaMovable;
class AshibaTenbin;
/* アニメーションデータ */
int KariudoKen2::sAniData[][MAX_DATA] =
{
{ 3, 4, 5, 6, 7, 8, 99 }, // ARUKI
{ 0, 1, 2, 99 }, // WAIT1
{ 0, 1, 2, 3, 4, 5, 99 }, // KOGEKI
{ 0, 1, 2, 99 }, // WAIT2
{ 0, 99 } // SHINDA
};
float KariudoKen2::sAniTimeData[][MAX_DATA] =
{
{ 0.05f, 0.05f, 0.05f, 0.1f, 0.1f, 0.1f }, // ARUKI
{ 0.2f, 0.2f, 0.2f }, // WAIT1
{ 0.2f, 0.2f, 0.2f, 0.2f, 0.2f, 0.2f }, // KOGEKI
{ 0.2f, 0.2f, 0.2f }, // WAIT2
{ 0.2f, } // SHINDA
};
/* グラフィックデータ */
char KariudoKen2::sGraphicData[][MAX_NLEN] =
{
"graphics\\teki\\ene_hunter12.png", // ARUKI
"graphics\\teki\\ene_hunter12.png", // WAIT1
"graphics\\teki\\ene_hunter1_attack2.png", // KOGEKI
"graphics\\teki\\ene_hunter12.png", // WAIT2
"graphics\\teki\\ene_hunter1_damage2.png", // SHINDA
};
// マップ当たり判定データ
int KariudoKen2::sMapAtHanteiX[4][MAX_TEN] =
{
{ 68, 90, -1 }, //下
{ -1 }, //上
{ 90, -1 }, //前
{ -1 } //後
};
int KariudoKen2::sMapAtHanteiY[4][MAX_TEN] =
{
{ 117, 117, -1 }, //下
{ -1 }, //上
{ 100, -1 }, //前
{ -1 } //後
};
KariudoKen2::KariudoKen2(int rXPx, int rYPx)
{
KARIKEN2SX = GI("KARIKEN2SX");
KARIKEN2SY = GI("KARIKEN2SY");
KARIKEN2SPX = GF("KARIKEN2SPX");
KARIKEN2KGHANI = GF("KARIKEN2KGHANI");
KARIKEN2WTM1 = GF("KARIKEN2WTM1");
KARIKEN2WTM2 = GF("KARIKEN2WTM2");
mX = rXPx;
mY = rYPx - sMapAtHanteiY[0][0] + SP->CHSZY;
mSizeX = KARIKEN2SX;
mSizeY = KARIKEN2SY;
mStatus = ARUKI;
mKgTimer = 0.0f;
mSeFl = false;
// 当たり判定
AddFrame(FR_KAMAE);
AddFrame(FR_ZANZOU);
AddFrame(FR_DOWN);
AddRect(FR_KAMAE, SP->GRID_BOGYO, 43, 33, 81, 119);
AddIndexedRect( FR_KAMAE, SP->GRID_BOUND, TBOUND_IDX, 38, 22, 83, 120);
AddRect(FR_ZANZOU, SP->GRID_BOGYO, 43, 33, 81, 119);
AddCircle(FR_ZANZOU, SP->GRID_KOUGEKI, 38, 43, 35);
AddCircle(FR_ZANZOU, SP->GRID_KOUGEKI, 33, 69, 35);
AddIndexedRect( FR_ZANZOU, SP->GRID_BOUND, TBOUND_IDX, 38, 22, 83, 120);
AddRect(FR_DOWN, SP->GRID_BOGYO, 43, 33, 81, 119);
AddCircle(FR_DOWN, SP->GRID_BOGYO, 20, 62, 11);
AddIndexedRect( FR_DOWN, SP->GRID_BOUND, TBOUND_IDX, 38, 22, 83, 120);
//AddCircle(0, GRID_BOGYO, 60, 60, 30);
SetAnim(0);
}
KariudoKen2::~KariudoKen2(void)
{
}
void KariudoKen2::_Move()
{
SetAnim( mStatus );
// 自機の位置を取得
int jx = GAMECONTROL->GetJiki()->GetAtHtPointX();
int jy = GAMECONTROL->GetJiki()->GetAtHtPointY();
// ----当たりの処理
MapAtHt();
if( mStatus != SHINDA )
Ataridp();
switch( mStatus ){
case ARUKI: {
// ----自機の位置を確認
float sax = jx - CenterX();
float say = jy - CenterY();
float sa = sqrt(sax*sax + say*say);
if( sa < KARIKEN2KGHANI ){
mStatus = WAIT1;
}
break;
}
case WAIT1:
mSpX = 0;
WAIT_TIMER(mKgTimer, KARIKEN2WTM1);
mStatus = KOGEKI;
WAIT_END
break;
case KOGEKI:
if( mAniNoX == 2 && !mSeFl ){//SE
//SE
if( !IsGamenGai() )
GAMECONTROL->GetSoundController()->PlaySE("audio\\se\\se_ken_atack.wav");
mSeFl = true;
}
mSpX = 0;
mMuki = CenterX() < jx;
if( mDousaEnd ){
mStatus = WAIT2;
mSeFl = false;
}
break;
case WAIT2:
mSpX = 0;
WAIT_TIMER(mKgTimer, KARIKEN2WTM2);
mStatus = ARUKI;
WAIT_END
break;
}
Draw();
mSpX += mAccX;
mSpY += mAccY;
mX += mSpX + mAshibaSpX;
mY += mSpY;
// 当たり判定のフレーム
if( mStatus != SHINDA )
HtFrame();
}
/*
マップとの当たり判定を行います。
この関数の実行ご、次の変数の中身が変わります:
mShirabe[]
mAtari[]
*/
void KariudoKen2::MapAtHt()
{
MAP_SUPERATHT(mX, mY, mMuki, mSpX, mSpY, mAccX, mAccY,
sMapAtHanteiX, sMapAtHanteiY, mSizeX, mSizeY, mAtari, mShirabe);
}
/*
当たり判定応答
*/
void KariudoKen2::Ataridp()
{
// 下
if( mAtari[0] == SP->CHIP_AMHIT || mAtari[0] == SP->CHIP_KGHIT || mCurAshiba){
mSpY = 0;
mSpX = (mMuki?1:-1)*KARIKEN2SPX;
mAccX = 0;
mAccY = 0;
if( !mCurAshiba )
mY = mShirabe[0] - sMapAtHanteiY[0][0];
}
else{
mMuki = !mMuki;
mX -= mSpX;
mSpX = 0;
}
// 前
if(mAtari[2] == SP->CHIP_HIT || mAtari[2] == SP->CHIP_GMNGAILT
|| mAtari[2] == SP->CHIP_GMNGAIRT || mAtari[2] == SP->CHIP_KGHIT){ // 前当たってる
mMuki = !mMuki;
}
}
/*
当たり判定のフレーム
*/
void KariudoKen2::HtFrame()
{
switch( mStatus ){
case ARUKI:
SetCurFrame( FR_KNDOWN );
break;
case KOGEKI:
if( mAniNoX >= 2 && mAniNoX!=5 ) {
SetCurFrame( FR_ZANZOU );
}
else if( mAniNoX!=5 ) {
SetCurFrame( FR_KAMAE );
}
else {
SetCurFrame( FR_KNDOWN );
}
break;
}
}
/*
死んだときの処理(人型)
*/
void KariudoKen2::Die()
{
// ヒロインの位置によってx軸の速度を決める
mSpX = -SHINIPATT_SPX;
Jiki* jiki = GAMECONTROL->GetJiki();
if( jiki->GetAtHtPointX() < CenterX() )
mSpX *= -1;
mStatus = SHINDA;
mBasStatus = SHINI;
mSpY = -SHINIPATT_SHOSP;
mAccY = SP->GRAVITY;
//Finalize();
DisableAshibaCollision();
}
void KariudoKen2::Move()
{
Animate();
_Move();
}
/*
敵の描画
*/
void KariudoKen2::Draw()
{
DX_SCROLL_DRAW(GraphicData()+mAnimSet*MAX_NLEN, mX, mY,
mNo_x*mSizeX, mMuki*mSizeY, (mNo_x+1)*mSizeX, (mMuki+1)*mSizeY);
DieIfGamenGai();
} | [
"lakeishikawa@c9935178-01ba-11df-8f7b-bfe16de6f99b",
"cat2.silly.affection@c9935178-01ba-11df-8f7b-bfe16de6f99b"
] | [
[
[
1,
76
],
[
79,
141
],
[
148,
151
],
[
153,
276
]
],
[
[
77,
78
],
[
142,
147
],
[
152,
152
]
]
] |
61afb09187c74415d335af63ec9f570b09a24caf | 40e58042e635ea2a61a6216dc3e143fd3e14709c | /chopshop11/CameraTask.cpp | dadca2a4b5662567b5c604f5facbe1eeae03f578 | [] | no_license | chopshop-166/frc-2011 | 005bb7f0d02050a19bdb2eb33af145d5d2916a4d | 7ef98f84e544a17855197f491fc9f80247698dd3 | refs/heads/master | 2016-09-05T10:59:54.976527 | 2011-10-20T22:50:17 | 2011-10-20T22:50:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,547 | cpp | /*******************************************************************************
* Project : Chopshop11
* File Name : CameraTask.cpp
* Owner : Software Group (FIRST Chopshop Team 166)
* File Description : This task initializes the camera and calls the 2011
* targeting code. It offers a static fuction that any task can call
* CameraTask::TakeSnapshot(char* imageName))
* to save a picture to the cRIO.
* Logged target data: size, location, and score (a
* quality metric)
*******************************************************************************/
/*----------------------------------------------------------------------------*/
/* Copyright (c) MHS Chopshop Team 166, 2010. All Rights Reserved. */
/*----------------------------------------------------------------------------*/
#include "WPILib.h"
#include "Robot.h"
#include "CameraTask.h"
#include "TargetCircle.h"
#include "TargetLight.h"
#include "nivision.h"
// To locally enable debug printing: set true, to disable false
#define DPRINTF if(true)dprintf
#define TPRINTF if(false)dprintf
#define SAVE_IMAGES (0)
// Sample in memory buffer
struct abuf
{
struct timespec tp; // Time of snapshot
// Any values that need to be logged go here
double targetHAngle;
double targetVAngle;
double targetSize;
};
// Memory Log
class CameraLog : public MemoryLog
{
public:
CameraLog() : MemoryLog(
sizeof(struct abuf), CAMERA_CYCLE_TIME, "camera",
"Elapsed Time,H-Angle, V-Angle, Size,\n"
) {
return;
};
~CameraLog() {return;};
unsigned int DumpBuffer( // Dump the next buffer into the file
char *nptr, // Buffer that needs to be formatted
FILE *outputFile); // and then stored in this file
unsigned int PutOne(double,double,double); // Log the values needed-add in arguments
};
// Write one buffer into memory
unsigned int CameraLog::PutOne(double hAngle,double vAngle,double size)
{
struct abuf *ob; // Output buffer
// Get output buffer
if ((ob = (struct abuf *)GetNextBuffer(sizeof(struct abuf)))) {
// Fill it in.
clock_gettime(CLOCK_REALTIME, &ob->tp);
// Add any values to be logged here
ob-> targetHAngle = hAngle;
ob-> targetVAngle = vAngle;
ob-> targetSize = size;
return (sizeof(struct abuf));
}
// Did not get a buffer. Return a zero length
return (0);
}
// Format the next buffer for file output
unsigned int CameraLog::DumpBuffer(char *nptr, FILE *ofile)
{
struct abuf *ab = (struct abuf *)nptr;
// Output the data into the file
fprintf(ofile, "%4.5f, %3.3f, %3.3f, %4.4f\n",
((ab->tp.tv_sec - starttime.tv_sec) + ((ab->tp.tv_nsec-starttime.tv_nsec)/1000000000.)),
// Values to log
ab-> targetHAngle, ab-> targetVAngle, ab-> targetSize
);
// Done
return (sizeof(struct abuf));
}
CameraTask *CameraTask::myHandle = NULL;
// task constructor
CameraTask::CameraTask(void):camera(AxisCamera::GetInstance())
{
myHandle = this;
/* allow writing to vxWorks target */
Priv_SetWriteFileAllowed(1);
this->MyTaskIsEssential=0;
SetDebugFlag ( DEBUG_SCREEN_ONLY );
camera.WriteResolution(AxisCamera::kResolution_320x240);
camera.WriteBrightness(15);
int fps = camera.GetMaxFPS();
Start((char *)"CameraTask", CAMERA_CYCLE_TIME);
DPRINTF(LOG_INFO,"CameraTask FPS=%i task cycle time=%i",fps,CAMERA_CYCLE_TIME);
return;
};
// task destructor
CameraTask::~CameraTask(void)
{
return;
};
// Main function of the task
int CameraTask::Main(int a2, int a3, int a4, int a5,
int a6, int a7, int a8, int a9, int a10)
{
bool found = false;
// Register our logger
CameraLog sl; // log
// Register the proxy
proxy = Proxy::getInstance();
DPRINTF(LOG_INFO,"CameraTask got proxy");
proxy->add("CanSeeCameraTargets");
proxy->add("NormalizedTargetCenter");
// Let the world know we're in
DPRINTF(LOG_INFO,"In the 166 Camera task\n");
WaitForGoAhead(); // THIS IS VERY IMPORTANT
lHandle = Robot::getInstance();
lHandle->RegisterLogger(&sl);
DPRINTF(LOG_INFO,"CameraTask registered logger");
lHandle->DriverStationDisplay("Camera Task...");
DPRINTF(LOG_INFO,"CameraTask informed DS");
// General main loop (while in Autonomous or Tele mode)
while (true) {
// Wait for our next lap
WaitForNextLoop();
/* Store a picture to cRIO */
//TakeSnapshot("cRIOimage.jpg");
/* Look for target */
//found = FindCircleTargets();
found = FindLightTargets();
// Logging values if a valid target found
if (found) {
sl.PutOne(targetHAngle,targetVAngle,targetSize);
}
// JUST FOR DEBUGGING - give us time to look at the screen
// REMOVE THIS WAIT to go operational!
Wait(0.0);
}
return (0);
};
/**
* Call the targeting code that looks for bright objects.
* @return bool success code
*/
bool CameraTask::FindLightTargets() {
int success;
// lHandle->DriverStationDisplay("FindLightTargets:%0.6f",GetTime());
#if 0
// get the camera image
HSLImage * image = camera.GetImage();
Image *imaqImage = image->GetImaqImage();
if (!imaqImage) {
DPRINTF (LOG_INFO,"GetImaqImage failed - errorcode %i",GetLastVisionError());
}
// write the hsl image to cRIO
SaveImage("imaqImage.jpg", imaqImage);
#endif
// get the camera image
Image* cameraImage = frcCreateImage(IMAQ_IMAGE_HSL);
if (!cameraImage) {
DPRINTF (LOG_INFO,"frcCreateImage failed - errorcode %i",GetLastVisionError());
}
Wait(1.0);
if ( myHandle->camera.IsFreshImage() ) {
if ( !myHandle->camera.GetImage(cameraImage) ) {
int errCode = GetLastVisionError();
DPRINTF (LOG_INFO,"\nGetImage failed errCode=%i", errCode);
char *errString = GetVisionErrorText(errCode);
DPRINTF (LOG_INFO,"errString= %s", errString);
// always dispose of image objects when done
frcDispose(cameraImage);
return false;
} else {
#if SAVE_IMAGES
DPRINTF (LOG_INFO,"\nGetImage WORKED, calling SaveImage");
SaveImage("cameraImage.jpg", cameraImage);
#endif
}
} else {
DPRINTF (LOG_INFO,"\nStale image - didn't get a good image\n");
}
// do processing
double normalizedTargetReturn;
Image* processedImage = frcCreateImage(IMAQ_IMAGE_HSL);
bool CanSeeTargets;
bool ImageReturned;
success = ProcessTheImage(cameraImage, &normalizedTargetReturn,
processedImage, &CanSeeTargets, &ImageReturned, SAVE_IMAGES);
DPRINTF (LOG_INFO,"ProcessTheImage success code=%i", success);
DPRINTF (LOG_INFO,"Normalized Center = %f CanSeeTargets = %d", normalizedTargetReturn, CanSeeTargets);
TPRINTF (LOG_INFO,"ProcessTheImage success code=%i", success);
TPRINTF (LOG_INFO,"NC = %f CanSee = %d", normalizedTargetReturn, CanSeeTargets);
SmartDashboard::Log(targetCenterNormalized,"Normalized Center");
SmartDashboard::Log(CanSeeTargets, "Can see?");
// write the binary image to cRIO
#if SAVE_IMAGES
if (ImageReturned){
if (success) {
DPRINTF(LOG_DEBUG, "\nWriting HSL image");
SaveImage("hslImage.jpg", processedImage);
}}
#endif
proxy->set("CanSeeCameraTargets", (float) CanSeeTargets);
SmartDashboard::Log(CanSeeTargets, "Targets Visible");
if(CanSeeTargets){proxy->set("NormalizedTargetCenter", normalizedTargetReturn);}
SmartDashboard::Log(normalizedTargetReturn, "Normalized Target Center");
//delete images;
frcDispose(cameraImage);
frcDispose(processedImage);
DPRINTF(LOG_DEBUG, "success value = %i\n", success);
return true;
};
/**
* Call the targeting code that looks for elliptical objects.
* @return bool success code
*/
bool CameraTask::FindCircleTargets() {
lHandle->DriverStationDisplay("ProcessImage:%0.6f",GetTime());
// get the camera image
//Image * image = frcCreateImage(IMAQ_IMAGE_HSL);
HSLImage * image = camera.GetImage();
// find FRC targets in the image
vector<TargetCircle> targets = TargetCircle::FindCircularTargets(image);
if (targets.size()) {
DPRINTF(LOG_DEBUG, "targetImage SCORE = %f", targets[0].m_score);
}
//delete image;
delete image;
if (targets.size() == 0) {
// no targets found.
DPRINTF(LOG_DEBUG, "No target found\n\n");
return false;
}
else if (targets[0].m_score < MINIMUM_SCORE) {
// no good enough targets found
DPRINTF(LOG_DEBUG, "No valid targets found, best score: %f ",
targets[0].m_score);
return false;
}
else {
// We have some targets.
// set the new PID heading setpoint to the first target in the list
targetHAngle = targets[0].GetHorizontalAngle();
targetVAngle = targets[0].GetVerticalAngle();
targetSize = targets[0].GetSize();
// send dashboard data for target tracking
DPRINTF(LOG_DEBUG, "Target found %f ", targets[0].m_score);
DPRINTF(LOG_DEBUG, "H: %3.0f V: %3.0f SIZE: %3.3f ",
targetHAngle, targetVAngle, targetSize);
// targets[0].Print();
}
return true;
}
/**
* Take a picture and store it to the cRIO in the specified path
* Any task should be able to call this to take and save a snapshot
*/
#if SAVE_IMAGES
void CameraTask::TakeSnapshot(char* imageName) {
myHandle->lHandle->DriverStationDisplay("storing %s",imageName);
//DPRINTF(LOG_DEBUG, "taking a SNAPSHOT ");
Image* cameraImage = frcCreateImage(IMAQ_IMAGE_HSL);
if (!cameraImage) {
DPRINTF (LOG_INFO,"frcCreateImage failed - errorcode %i",GetLastVisionError());
}
/* If there is an unacquired image to get, acquire it */
if ( myHandle->camera.IsFreshImage() ) {
if ( !myHandle->camera.GetImage(cameraImage) ) {
DPRINTF (LOG_INFO,"\nImage Acquisition from camera failed %i", GetLastVisionError());
} else {
SaveImage(imageName, cameraImage);
// always dispose of image objects when done
frcDispose(cameraImage);
}
}
else {
DPRINTF (LOG_INFO,"Image is stale");
} // fresh
};
/**
* Store an Image to the cRIO in the specified path
*/
void SaveImage(char* imageName, Image* image) {
DPRINTF (LOG_DEBUG, "writing %s", imageName);
if (!frcWriteImage(image, imageName) ) {
int errCode = GetLastVisionError();
DPRINTF (LOG_INFO,"frcWriteImage failed - errorcode %i", errCode);
char *errString = GetVisionErrorText(errCode);
DPRINTF (LOG_INFO,"errString= %s", errString);
}
};
#endif
| [
"",
"[email protected]",
"devnull@localhost",
"[email protected]"
] | [
[
[
1,
1
],
[
3,
4
],
[
11,
18
],
[
22,
23
],
[
27,
32
],
[
36,
43
],
[
45,
51
],
[
54,
56
],
[
58,
66
],
[
71,
83
],
[
88,
93
],
[
95,
96
],
[
98,
98
],
[
104,
104
],
[
114,
126
],
[
130,
130
],
[
139,
144
],
[
148,
148
],
[
150,
152
],
[
154,
156
],
[
160,
160
],
[
172,
176
],
[
305,
305
],
[
311,
312
],
[
315,
319
],
[
330,
330
],
[
334,
334
]
],
[
[
2,
2
],
[
44,
44
],
[
84,
84
],
[
94,
94
],
[
183,
183
],
[
215,
216
],
[
246,
246
],
[
248,
248
],
[
264,
264
],
[
304,
304
]
],
[
[
5,
10
],
[
19,
21
],
[
25,
25
],
[
33,
35
],
[
52,
53
],
[
57,
57
],
[
67,
70
],
[
85,
87
],
[
97,
97
],
[
99,
103
],
[
105,
105
],
[
109,
112
],
[
127,
128
],
[
136,
138
],
[
157,
159
],
[
161,
171
],
[
177,
182
],
[
184,
211
],
[
213,
214
],
[
217,
245
],
[
247,
247
],
[
249,
263
],
[
265,
303
],
[
306,
310
],
[
313,
314
],
[
320,
329
],
[
331,
333
],
[
335,
349
]
],
[
[
24,
24
],
[
26,
26
],
[
106,
108
],
[
113,
113
],
[
129,
129
],
[
131,
135
],
[
145,
147
],
[
149,
149
],
[
153,
153
],
[
212,
212
]
]
] |
04c127c56ea6d81c5c7239a41f7f668298fdc62b | 98c8da921605c9f54f69a3d55504280e2cc77160 | /src/foo_autorating/stdafx.cpp | 8a0a380bd051cabbd7b4fb0107d1a9dcbc9344ed | [] | no_license | lappdance/foo_autorating | 08bcf1a888dac1ea13aa875294938bb5664939a0 | d1ce17508ba9cd58dce8ef3b2486f6eab83ed660 | refs/heads/master | 2021-01-21T12:39:45.521664 | 2010-10-11T02:51:26 | 2010-10-11T02:51:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 152 | cpp | #include"stdafx.h"
/**
This file is responsible for creating the precompiled header: modifying this file
will cause the pch to be rebuilt.
**/
| [
"jlapp@d8a10105-fb75-0410-a675-bcd697018789"
] | [
[
[
1,
6
]
]
] |
75de08ec1f6083c7a2f0b208b718ae1b8abc7d2e | 9ba08620ddc3579995435d6e0e9cabc436e1c88d | /src/ParticleEngine.cpp | db25f3e0e1e42532b0bbbdccd4d78caff440294e | [
"MIT"
] | permissive | foxostro/CheeseTesseract | f5d6d7a280cbdddc94a5d57f32a50caf1f15e198 | 737ebbd19cee8f5a196bf39a11ca793c561e56cb | refs/heads/master | 2021-01-01T17:31:27.189613 | 2009-08-02T13:27:20 | 2009-08-02T13:27:33 | 267,008 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,654 | cpp | #include "stdafx.h"
#include "ActionQueueRenderInstance.h"
#include "RenderMethodTags.h"
#include "ParticleSystem.h"
#include "ParticleEngine.h"
void ParticleEngine::update(float milliseconds, Camera &camera) {
list<ParticleSystem*>::iterator i = particles.begin();
while (i != particles.end()) {
ParticleSystem *system = *i;
system->update(milliseconds, camera);
if (system->isDead()) {
i = particles.erase(i);
} else {
++i;
}
}
}
ParticleEngine::handle ParticleEngine::add(const FileName &fileName,
const vec3 &position,
float rotation,
TextureFactory &textureFactory) {
return particles.insert(particles.begin(),
new ParticleSystem(fileName,
textureFactory,
position,
rotation));
}
void ParticleEngine::emitGeometry() {
vector<GeometryChunk> chunks;
for (list<ParticleSystem*>::const_iterator i = particles.begin();
i != particles.end(); ++i) {
ParticleSystem *system = *i;
// Get geometry chunks (and associated materials) for this system
system->getGeometryChunks(chunks);
for (vector<GeometryChunk>::const_iterator i = chunks.begin();
i != chunks.end(); ++i) {
RenderInstance instance;
instance.gc = *i;
instance.specificRenderMethod = METHOD_PARTICLE;
instance.metaRenderMethod = TAG_UNSPECIFIED;
ActionQueueRenderInstance action(instance);
sendGlobalAction(&action);
}
}
}
void ParticleEngine::remove(handle h) {
particles.erase(h);
}
| [
"arfox@arfox-desktop"
] | [
[
[
1,
59
]
]
] |
33614866e86716e110d1824380cceb50e0359c37 | 6188f1aaaf5508e046cde6da16b56feb3d5914bc | /Doc/Web/Shaders/Samples/Tutorials-0.8-src/cwc/ext/aGLExt_ARB_vertex_buffer_object.cpp | 448e5d3c8957f2c552e9feb25b5a10d41c3eccda | [] | no_license | dogtwelve/fighter3d | 7bb099f0dc396e8224c573743ee28c54cdd3d5a2 | c073194989bc1589e4aa665714c5511f001e6400 | refs/heads/master | 2021-04-30T15:58:11.300681 | 2011-06-27T18:51:30 | 2011-06-27T18:51:30 | 33,675,635 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,643 | cpp | GLboolean use_ARB_vertex_buffer_object = GL_FALSE;
// Functions pointers for ARB_vertex_buffer_object Extension:
PFNGLBINDBUFFERARBPROC glBindBufferARB = NULL;
PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB = NULL;
PFNGLGENBUFFERSARBPROC glGenBuffersARB = NULL;
PFNGLISBUFFERARBPROC glIsBufferARB = NULL;
PFNGLBUFFERDATAARBPROC glBufferDataARB = NULL;
PFNGLBUFFERSUBDATAARBPROC glBufferSubDataARB = NULL;
PFNGLGETBUFFERSUBDATAARBPROC glGetBufferSubDataARB = NULL;
PFNGLMAPBUFFERARBPROC glMapBufferARB = NULL;
PFNGLUNMAPBUFFERARBPROC glUnmapBufferARB = NULL;
PFNGLGETBUFFERPARAMETERIVARBPROC glGetBufferParameterivARB = NULL;
PFNGLGETBUFFERPOINTERVARBPROC glGetBufferPointervARB = NULL;
bool init_ARB_vertex_buffer_object(void)
{
int error = 0;
error |= aLoadExtension(PFNGLBINDBUFFERARBPROC, glBindBufferARB);
error |= aLoadExtension(PFNGLDELETEBUFFERSARBPROC, glDeleteBuffersARB);
error |= aLoadExtension(PFNGLGENBUFFERSARBPROC, glGenBuffersARB);
error |= aLoadExtension(PFNGLISBUFFERARBPROC, glIsBufferARB);
error |= aLoadExtension(PFNGLBUFFERDATAARBPROC, glBufferDataARB);
error |= aLoadExtension(PFNGLBUFFERSUBDATAARBPROC, glBufferSubDataARB);
error |= aLoadExtension(PFNGLGETBUFFERSUBDATAARBPROC, glGetBufferSubDataARB);
error |= aLoadExtension(PFNGLMAPBUFFERARBPROC, glMapBufferARB);
error |= aLoadExtension(PFNGLUNMAPBUFFERARBPROC, glUnmapBufferARB);
error |= aLoadExtension(PFNGLGETBUFFERPARAMETERIVARBPROC, glGetBufferParameterivARB);
error |= aLoadExtension(PFNGLGETBUFFERPOINTERVARBPROC, glGetBufferPointervARB);
if (error) return false;
return true;
}
| [
"dmaciej1@f75eed02-8a0f-11dd-b20b-83d96e936561"
] | [
[
[
1,
40
]
]
] |
d53761844ad1d9dec829e3d360b3a49c48eecc30 | 6dac9369d44799e368d866638433fbd17873dcf7 | /src/branches/26042005/include/vfs/VFSPlugin.h | 30c68689bb571f6564e84ee45675294ad7b0f0f2 | [] | no_license | christhomas/fusionengine | 286b33f2c6a7df785398ffbe7eea1c367e512b8d | 95422685027bb19986ba64c612049faa5899690e | refs/heads/master | 2020-04-05T22:52:07.491706 | 2006-10-24T11:21:28 | 2006-10-24T11:21:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,365 | h | #ifndef _VFSPLUGIN_H_
#define _VFSPLUGIN_H_
#include <vector>
#include <vfs/FileInfo.h>
#include <vfs/VFSFilter.h>
/** @ingroup VFSPlugin_Group
* @brief The base class for all VFS Plugins
*/
class VFSPlugin{
protected:
/** @var int m_offset
* @brief The offset into the data buffer
*/
int m_offset;
/** @var unsigned char *m_buffer
* @brief The data buffer
*/
unsigned char *m_buffer;
/** @var int m_length
* @brief The length of the data buffer
*/
unsigned int m_length;
/** @var char *m_type
* @brief String identifing the File format plugin
*/
char *m_type;
/** @var std::vector<VFSFilter *> m_filters
* @brief Array of Filters attached to this plugin to filter the file data through
*/
std::vector<VFSFilter *> m_filters;
public:
/** @typedef plugin_t
* Function pointer to create a plugin object
*/
typedef VFSPlugin * (*plugin_t)(Fusion *f);
/** File format plugin Constructor
*
* Abstract base class constructor
*/
VFSPlugin(){};
/** File format plugin Deconstructor
*
* Abstract base class Deconstructor
*/
virtual ~VFSPlugin()
{
for(unsigned int a=0;a<m_filters.size();a++) delete m_filters[a];
m_filters.clear();
};
/** Adds a filter to the array of filters this plugin uses to decode files
*
* @param filter The Filter to add to the plugin
*/
virtual void AddFilter(VFSFilter *filter)
{
if(filter != NULL) m_filters.push_back(filter);
};
/** Decodes the contents of a bytestream
*
* @param buffer A bytestream containing the contents of the file
* @param length The length of the bytestream
*
* @returns A FileInfo structure containing the decoded file contents
*/
virtual FileInfo * Read(unsigned char *buffer, unsigned int length) = 0;
/** Writes a FileInfo structure to the file
*
* @param data A FileInfo structure containing the data I want to write
* @param length Will contain the length of the encoded bytestream
*
* @returns A bytestrem containing the contents of the file to be written
*/
virtual char * Write(FileInfo *data, unsigned int &length) = 0;
/** Retrieves the type of plugin this is
*
* @returns The identifing string of the plugin
*/
virtual char * Type(void) = 0;
};
#endif // #ifndef _VFSPLUGIN_H_
| [
"chris_a_thomas@1bf15c89-c11e-0410-aefd-b6ca7aeaabe7"
] | [
[
[
1,
95
]
]
] |
d30a7c2e148fbb93cd811f44bb2dbb23ddd07304 | 1c84fe02ecde4a78fb03d3c28dce6fef38ebaeff | /State_Attack.h | e1174a8acae1b9f158854ad2c29193bd2e6ddeaa | [] | no_license | aadarshasubedi/beesiege | c29cb8c3fce910771deec5bb63bcb32e741c1897 | 2128b212c5c5a68e146d3f888bb5a8201c8104f7 | refs/heads/master | 2016-08-12T08:37:10.410041 | 2007-12-16T20:57:33 | 2007-12-16T20:57:33 | 36,995,410 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 405 | h | #ifndef STATEATTACK_H
#define STATEATTACK_H
#include "FSMState.h"
#include "FSMAIControl.h"
using namespace std;
class StateAttack: public FSMState
{
public:
StateAttack(int type=FSM_ATTACK)
{
m_type = type;
}
void Enter();
void Exit();
void Update(int i);
void Init();
FSMState* CheckTransitions(int t);
int m_type;
};
NiSmartPointer(StateAttack);
#endif
| [
"[email protected]"
] | [
[
[
1,
29
]
]
] |
8287142385e7363186888cc3d6070a2bc5792ad4 | 3e69b159d352a57a48bc483cb8ca802b49679d65 | /tags/release-2006-01-18/kicad/files-io.cpp | e29347b238c2b8f10299e8a7d33c729eb5360dbb | [] | 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 | WINDOWS-1252 | C++ | false | false | 7,642 | cpp | /****************/
/* files-io.cpp */
/****************/
#ifdef __GNUG__
#pragma implementation
#endif
#include "fctsys.h"
#include <wx/fs_zip.h>
#include <wx/docview.h>
#include <wx/wfstream.h>
#include <wx/zstream.h>
#include "common.h"
#include "bitmaps.h"
#include "protos.h"
#include "id.h"
#include "kicad.h"
#include "prjconfig.h"
#define ZIP_EXT wxT(".zip")
#define ZIP_MASK wxT("*.zip")
static void Create_NewPrj_Config( const wxString PrjFullFileName);
/***********************************************************/
void WinEDA_MainFrame::Process_Files(wxCommandEvent& event)
/***********************************************************/
/* Gestion generale des commandes de sauvegarde
*/
{
int id = event.GetId();
wxString path = wxGetCwd();
wxString fullfilename;
bool IsNew = FALSE;
switch (id)
{
case ID_SAVE_PROJECT: /* Update project File */
Save_Prj_Config();
break;
case ID_LOAD_FILE_1:
case ID_LOAD_FILE_2:
case ID_LOAD_FILE_3:
case ID_LOAD_FILE_4:
case ID_LOAD_FILE_5:
case ID_LOAD_FILE_6:
case ID_LOAD_FILE_7:
case ID_LOAD_FILE_8:
case ID_LOAD_FILE_9:
case ID_LOAD_FILE_10:
m_PrjFileName = GetLastProject( id - ID_LOAD_FILE_1);
SetLastProject(m_PrjFileName);
ReCreateMenuBar();
Load_Prj_Config();
break;
case ID_NEW_PROJECT:
IsNew = TRUE;
case ID_LOAD_PROJECT:
SetLastProject(m_PrjFileName);
fullfilename = EDA_FileSelector( IsNew ? _("Create Project files:") : _("Load Project files:"),
path, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
g_Prj_Config_Filename_ext, /* extension par defaut */
wxT("*") + g_Prj_Config_Filename_ext, /* Masque d'affichage */
this,
IsNew ? wxSAVE : wxOPEN,
FALSE
);
if ( fullfilename.IsEmpty() ) break;
ChangeFileNameExt(fullfilename, g_Prj_Config_Filename_ext);
m_PrjFileName = fullfilename;
if ( IsNew ) Create_NewPrj_Config( m_PrjFileName);
SetLastProject(m_PrjFileName);
Load_Prj_Config();
break;
case ID_SAVE_AND_ZIP_FILES:
CreateZipArchive(wxEmptyString);
break;
case ID_READ_ZIP_ARCHIVE:
UnZipArchive(wxEmptyString);
break;
default: DisplayError(this, wxT("WinEDA_MainFrame::Process_Files error"));
break;
}
}
/**************************************************************/
static void Create_NewPrj_Config(const wxString PrjFullFileName)
/**************************************************************/
/* Cree un nouveau fichier projet a partir du modele
*/
{
wxString msg;
// Init default config filename
g_Prj_Config_LocalFilename.Empty();
g_Prj_Default_Config_FullFilename =
ReturnKicadDatasPath() +
wxT("template/kicad") +
g_Prj_Config_Filename_ext;
if ( ! wxFileExists(g_Prj_Default_Config_FullFilename) )
{
msg = _("Template file non found ") + g_Prj_Default_Config_FullFilename;
DisplayInfo(NULL, msg);
}
else
{
if ( wxFileExists(PrjFullFileName) )
{
msg = _("File ") + PrjFullFileName
+ _(" exists! OK to continue?");
if ( IsOK(NULL, msg) )
{
wxCopyFile(g_Prj_Default_Config_FullFilename,
PrjFullFileName);
}
}
}
g_SchematicRootFileName = wxFileNameFromPath(PrjFullFileName);
ChangeFileNameExt(g_SchematicRootFileName, g_SchExtBuffer);
g_BoardFileName = wxFileNameFromPath(PrjFullFileName);
ChangeFileNameExt(g_BoardFileName, g_BoardExtBuffer);
EDA_Appl->WriteProjectConfig(PrjFullFileName, wxT("/general"), CfgParamList);
}
/**********************************************************************/
void WinEDA_MainFrame::UnZipArchive(const wxString FullFileName)
/**********************************************************************/
/* Lit un fichier archive .zip et le decompresse dans le repertoire courant
*/
{
wxString filename = FullFileName;
wxString msg;
wxString old_cwd = wxGetCwd();
if ( filename.IsEmpty() )
filename = EDA_FileSelector( _("Unzip Project:"),
wxEmptyString, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
ZIP_EXT, /* extension par defaut */
ZIP_MASK, /* Masque d'affichage */
this,
wxOPEN,
TRUE
);
if ( filename.IsEmpty() ) return;
msg = _("\nOpen ") + filename + wxT("\n");
PrintMsg( msg );
wxString target_dirname = wxDirSelector ( _("Target Directory"),
wxEmptyString, 0, wxDefaultPosition, this);
if ( target_dirname.IsEmpty() ) return;
wxSetWorkingDirectory(target_dirname);
msg = _("Unzip in ") + target_dirname + wxT("\n");
PrintMsg( msg );
wxFileSystem zipfilesys;
zipfilesys.AddHandler(new wxZipFSHandler);
filename += wxT("#zip:");
zipfilesys.ChangePathTo(filename);
wxFSFile * zipfile = NULL;
wxString localfilename = zipfilesys.FindFirst( wxT("*.*") );
while ( !localfilename.IsEmpty() )
{
zipfile = zipfilesys.OpenFile(localfilename);
if (zipfile == NULL)
{
DisplayError(this, wxT("Zip file read error"));
break;
}
wxString unzipfilename = localfilename.AfterLast(':');
msg = _("Extract file ") + unzipfilename;
PrintMsg(msg);
wxInputStream * stream = zipfile->GetStream();
wxFFileOutputStream * ofile = new wxFFileOutputStream(unzipfilename);
if ( ofile->Ok() )
{
ofile->Write(*stream);
PrintMsg( _(" OK\n") );
}
else PrintMsg( _(" *ERROR*\n") );
delete ofile;
delete zipfile;
localfilename = zipfilesys.FindNext();
}
PrintMsg( wxT("** end **\n") );
wxSetWorkingDirectory(old_cwd);
}
/********************************************************************/
void WinEDA_MainFrame::CreateZipArchive(const wxString FullFileName)
/********************************************************************/
{
wxString filename = FullFileName;
wxString zip_file_fullname;
wxString msg;
wxString curr_path = wxGetCwd();
if ( filename.IsEmpty() )
{
filename = m_PrjFileName;
ChangeFileNameExt(filename, wxT(".zip"));
filename = EDA_FileSelector( _("Archive Project files:"),
wxEmptyString, /* Chemin par defaut */
filename, /* nom fichier par defaut */
ZIP_EXT, /* extension par defaut */
ZIP_MASK, /* Masque d'affichage */
this,
wxSAVE,
FALSE
);
}
if ( filename.IsEmpty() ) return;
wxFileName zip_name(filename);
zip_file_fullname = zip_name.GetFullName();
AddDelimiterString( zip_file_fullname );
wxChar * Ext_to_arch[] = { /* Liste des extensions des fichiers à sauver */
wxT("*.sch"), wxT("*.lib"), wxT("*.cmp"), wxT("*.brd"),
wxT("*.net"), wxT("*.pro"), wxT("*.pho"),
NULL};
int ii = 0;
wxString zip_cmd = wxT("-O ") + zip_file_fullname;
filename = wxFindFirstFile(Ext_to_arch[ii]);
while ( !filename.IsEmpty() )
{
wxFileName name(filename);
wxString fullname = name.GetFullName();
AddDelimiterString( fullname );
zip_cmd += wxT(" ") + fullname;
msg = _("Compress file ") + fullname + wxT("\n");
PrintMsg(msg);
filename = wxFindNextFile();
while (filename.IsEmpty() )
{
ii++;
if (Ext_to_arch[ii]) filename = wxFindFirstFile(Ext_to_arch[ii]);
else break;
}
}
#ifdef __WINDOWS__
#define ZIPPER wxT("minizip.exe")
#else
#define ZIPPER wxT("minizip")
#endif
if ( ExecuteFile(this, ZIPPER, zip_cmd) >= 0 )
{
msg = _("\nCreate Zip Archive ") + zip_file_fullname;
PrintMsg( msg );
PrintMsg( wxT("\n** end **\n") );
}
else PrintMsg( wxT("Minizip command error, abort\n") );
wxSetWorkingDirectory(curr_path);
}
| [
"bokeoa@244deca0-f506-0410-ab94-f4f3571dea26"
] | [
[
[
1,
282
]
]
] |
3fac6c0a2c2867c137fb14e5036642951cc7989d | 4f469243a2e6fc370f0d1859ec68de5efce90fa1 | /infected/src/game/client/hl2mp/hl2mp_hud_chat.cpp | fba6b11c4ea5a6a880e03b352c20094856a7fdde | [] | no_license | sideshowdave7/hl2-infected-mod | c710d3958cc143381eba28b7237c8f4ccdd49982 | a69fe39a2e13cbac3978ecf57c84cd8e9aa7bb0d | refs/heads/master | 2020-12-24T15:41:30.546220 | 2011-04-30T03:05:50 | 2011-04-30T03:05:50 | 61,587,106 | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 2,548 | cpp | //========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "hl2mp_hud_chat.h"
#include "hud_macros.h"
#include "text_message.h"
#include "vguicenterprint.h"
#include "vgui/ILocalize.h"
#include "c_team.h"
#include "c_playerresource.h"
#include "c_hl2mp_player.h"
#include "hl2mp_gamerules.h"
#include "ihudlcd.h"
DECLARE_HUDELEMENT( CHudChat );
DECLARE_HUD_MESSAGE( CHudChat, SayText );
DECLARE_HUD_MESSAGE( CHudChat, SayText2 );
DECLARE_HUD_MESSAGE( CHudChat, TextMsg );
//=====================
//CHudChatLine
//=====================
void CHudChatLine::ApplySchemeSettings(vgui::IScheme *pScheme)
{
BaseClass::ApplySchemeSettings( pScheme );
}
//=====================
//CHudChatInputLine
//=====================
void CHudChatInputLine::ApplySchemeSettings(vgui::IScheme *pScheme)
{
BaseClass::ApplySchemeSettings(pScheme);
}
//=====================
//CHudChat
//=====================
CHudChat::CHudChat( const char *pElementName ) : BaseClass( pElementName )
{
}
void CHudChat::CreateChatInputLine( void )
{
m_pChatInput = new CHudChatInputLine( this, "ChatInputLine" );
m_pChatInput->SetVisible( false );
}
void CHudChat::CreateChatLines( void )
{
m_ChatLine = new CHudChatLine( this, "ChatLine1" );
m_ChatLine->SetVisible( false );
}
void CHudChat::ApplySchemeSettings( vgui::IScheme *pScheme )
{
BaseClass::ApplySchemeSettings( pScheme );
}
void CHudChat::Init( void )
{
BaseClass::Init();
HOOK_HUD_MESSAGE( CHudChat, SayText );
HOOK_HUD_MESSAGE( CHudChat, SayText2 );
HOOK_HUD_MESSAGE( CHudChat, TextMsg );
}
//-----------------------------------------------------------------------------
// Purpose: Overrides base reset to not cancel chat at round restart
//-----------------------------------------------------------------------------
void CHudChat::Reset( void )
{
}
int CHudChat::GetChatInputOffset( void )
{
if ( m_pChatInput->IsVisible() )
{
return m_iFontHeight;
}
else
return 0;
}
Color CHudChat::GetClientColor( int clientIndex )
{
if ( clientIndex == 0 ) // console msg
{
return g_ColorYellow;
}
else if( g_PR )
{
switch ( g_PR->GetTeam( clientIndex ) )
{
case TEAM_COMBINE : return g_ColorRed;
case TEAM_REBELS : return g_ColorGreen;
default : return g_ColorBlue;
}
}
return g_ColorYellow;
} | [
"[email protected]",
"[email protected]"
] | [
[
[
1,
108
],
[
112,
116
]
],
[
[
109,
111
]
]
] |
f47faa1f5de9deabcc47a284370b48fad3623f19 | 6f6986fa267e1fa838694764f8ec429f3fde2c79 | /Wiichuck/Wiichuck.cpp | 2db5ffce363b4115825996b1b4a7bbe8ef7d33ee | [] | no_license | ungood/misc | 6e7bb4fdddbbb7316881c4a1795c34c614cd751f | 20a081fa3520fe91d2d966ccf6340d4c735742ef | refs/heads/master | 2021-01-25T03:26:19.732963 | 2011-01-11T13:43:16 | 2011-01-11T13:43:16 | 2,014,830 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,412 | cpp | #include "WProgram.h"
#include "Wiichuck.h"
#include <Wire.h>
void Wiichuck::init(int powerPin, int groundPin) {
// Set the output pins to VCC and GND
if(powerPin > 0) {
pinMode(powerPin, OUTPUT);
digitalWrite(powerPin, HIGH);
}
if(groundPin > 0) {
pinMode(groundPin, OUTPUT);
digitalWrite(groundPin, LOW);
}
delay(100);
Wire.begin();
Wire.beginTransmission(Address);
Wire.send(0x40);
Wire.send(0x00);
Wire.endTransmission();
// Set default calibration
calib.joyX = calib.joyY = 128;
calib.accelX = calib.accelY = calib.accelZ = 125; // accel and lsb together == 500.
calib.lsbX = calib.lsbY = calib.lsbZ = 0;
}
uint8_t Wiichuck::poll() {
Wire.requestFrom(Address, 6);// request data from nunchuck
int bytes = 0;
while(Wire.available() && bytes < 6) {
// receive uint8_t as an integer
data.buffer[bytes++] = decode(Wire.receive());
}
// send request for next data payload
Wire.beginTransmission(Address);
Wire.send(0x00);
Wire.endTransmission();
delay(100);
return bytes >= 5;
}
void Wiichuck::calibrate() {
calib.joyX = data.parsed.joyX;
calib.joyY = data.parsed.joyY;
calib.accelX = data.parsed.accelX;
calib.accelY = data.parsed.accelY;
calib.accelZ = data.parsed.accelZ;
calib.lsbX = data.parsed.lsbX;
calib.lsbY = data.parsed.lsbY;
calib.lsbZ = data.parsed.lsbZ;
}
| [
"[email protected]"
] | [
[
[
1,
59
]
]
] |
1634a8e35071c5c6fdbfbc6dd71ac1df8579f29d | b24d5382e0575ad5f7c6e5a77ed065d04b77d9fa | /GCore/GCore/GC_Log.h | 21744beabaf1b23611571add6d77af873d8b8eb8 | [] | no_license | Klaim/radiant-laser-cross | f65571018bf612820415e0f672c216caf35de439 | bf26a3a417412c0e1b77267b4a198e514b2c7915 | refs/heads/master | 2021-01-01T18:06:58.019414 | 2010-11-06T14:56:11 | 2010-11-06T14:56:11 | 32,205,098 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,278 | h | /******************************************************************
Inspired by Ogre::Log; www.ogre3D.org.
*******************************************************************/
#ifndef GCORE_LOG_H
#define GCORE_LOG_H
#pragma once
#include <iostream>
#include <vector>
#include <fstream>
#include <sstream>
#include "GC_Common.h"
#include <string>
namespace gcore
{
class LogManager;
class LogListener;
/** TODO : rewrite this comment!
The Log class act has a log file writer.
Its instanced and used by using a LogManager.
@par
When created a Log is binded to a file (the file name if the name of the log),
and messages can be written at anytime into this file (messages are concatenated with a new line separation between them).
@par
In order to add a message into the binded file, the logMessage methods has to be called.
When the logMessage method is called thought the logMessage of the LogManager that created this Log,
The catchLogMessage method of every registered LogListener of the LogManager is called.
However, if the logMessage of a Log is called directly, the message is written directly into the file, and LogListener are not notified.
@remark Managed by LogManager.
*/
class GCORE_API Log
{
public :
/** Write a full message into the file binded to the Log.
@param message The message to add into the file, each message is succeeded by a new line.
**/
void logMessage( const std::string& message );
/** Write text in the current message without logging and adding a new line.
@remark Use this function to add text to the message and call logText();
to make the message be written in the log. It will not be written until
you call it.
@param text Text to add.
@see addText
*/
void addText( const std::string& text );
/** Log the text that have been built with addText().
@see addText
*/
void logText();
/** The name of the log, which is also the name of the file the log writes into.
**/
const std::string& getName() const {return m_name;}
void registerListener( LogListener* logListener );
void unregisterListener( LogListener* logListener );
class Streamer;
private:
/// Only LogManager should create Logs.
friend class LogManager;
/// Current message being written.
std::stringstream m_message;
/// The stream writing into the file.
std::ofstream m_fileStream;
/// The name of the log, which is also the name of the file the log writes into.
const std::string m_name;
/// LogManager that manage this Log.
const LogManager& m_logManager;
/// List of log listeners registered to listen this log
std::vector< LogListener* > m_registeredListeners;
/** Create a log with the desired name.
@param logManager Log manager that manage this Log.
@param name The name of the Log, which is the name of the file in which the Log writes data.
@param isNewFile True for erasing the log file if it already exists, else append the messages at the end of the existing file.
**/
Log( const LogManager& logManager,const std::string& name, bool isNewFile = true);
/** The log destructor close the file in which data are written.
**/
~Log();
};
/** To allow streaming semantic on logs (used in << operator) .
*/
class LogStreamer
{
public:
template< typename T >
LogStreamer( Log& log, const T& text )
: m_log( log )
{
std::stringstream stream;
stream << text;
m_log.addText( stream.str() );
}
template<>
LogStreamer( Log& log, const std::string& text )
: m_log( log )
{
m_log.addText( text );
}
~LogStreamer()
{
m_log.logText();
}
template< typename T >
LogStreamer& operator<<( const T& text )
{
std::stringstream stream;
stream << text;
m_log.addText( stream.str() );
return *this;
}
template<>
LogStreamer& operator<<( const std::string& text )
{
m_log.addText( text );
return *this;
}
private:
Log& m_log;
};
template< typename T >
inline LogStreamer operator<<( Log& log, const T& message )
{
return LogStreamer( log, message );
}
}
#endif | [
"[email protected]"
] | [
[
[
1,
165
]
]
] |
0abd647f1736ff4e9ffe5485744879ddbc275b59 | aaf23f851e5c0ae43eb60c2d1a9f05462d7b964c | /src/huawei_a1/src/format.hpp | 9fcf39a773c51523540143024574886599dda8ec | [] | no_license | ismailwissam/bill-parser | 28ccb68857cb7d6be04207534e7250da82b5c55f | 5e195d606fcbbb1f69cbe148dde2413450d381fb | refs/heads/master | 2021-01-10T10:25:20.175318 | 2010-09-20T02:20:37 | 2010-09-20T02:20:37 | 50,747,248 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,133 | hpp | #ifndef HUAWEI_FORMAT_HPP
#define HUAWEI_FORMAT_HPP
#include "format_base.hpp"
/*!
* 华为号码格式
*/
class HuaweiIsdnFmt : public FormatBase
{
private:
// 号码计划
int hwisdnfmt_IsdnNpi;
// 号码类型
int hwisdnfmt_IsdnNai;
// 号码长度
int hwisdnfmt_IsdnLen;
// 号码
std::string hwisdnfmt_Isdn;
public:
/*!
* 返回perl读取的字符串格式
*/
virtual const char* fmtPerlStr();
};
/*!
* 华为时间格式
*/
class HuaweiDateFmt : public FormatBase
{
private:
// 时间
char hwdatefmt_Buff[32];
public:
/*!
* 返回perl读取的字符串格式
*/
virtual const char* fmtPerlStr();
};
// ---------------------- ASN.1 -------------------------
/*!
* 华为ASN1普通号码格式
*/
class HwA1IsdnFmt : public FormatBase
{
private:
std::string hwa1fmt_Isdn;
public:
/*!
* 返回perl读取的字符串格式
*/
virtual const char* fmtPerlStr();
};
/*!
* 华为ASN1电话号码格式
*/
class HwA1NumberFmt : public FormatBase
{
private:
//号码计划
int hwa1fmt_NumberNpi;
//号码类型
int hwa1fmt_NumberNai;
//电话号码
std::string hwa1fmt_Number;
public:
/*!
* 返回perl读取的字符串格式
*/
virtual const char* fmtPerlStr();
};
/*!
* 华为 ASN1 包含ASN1格式字符串
*/
class HwA1PackedStrFmt : public FormatBase
{
private:
std::string hwa1fmt_Str;
public:
/*!
* 返回perl读取的字符串格式
*/
virtual const char* fmtPerlStr();
};
/*!
* 华为 ASN1 Lac-ci
*/
class HwA1LacCiFmt : public FormatBase
{
private:
std::string hwa1fmt_LacCi;
public:
/*!
* 返回perl读取的字符串格式
*/
virtual const char* fmtPerlStr();
};
/*!
* 华为 ASN1 Time
*/
class HwA1TimeFmt : public FormatBase
{
private:
std::string hwa1fmt_Time;
public:
/*!
* 返回perl读取的字符串格式
*/
virtual const char* fmtPerlStr();
};
#endif //HUAWEI_FORMAT_HPP
| [
"ewangplay@81b94f52-7618-9c36-a7be-76e94dd6e0e6"
] | [
[
[
1,
129
]
]
] |
78ff4d73c94dca00dd1edef66c6fa8c0851f0f84 | 847cccd728e768dc801d541a2d1169ef562311cd | /src/Utils/RTTI/RTTIGlue.h | 277a2eae13de7000f846aaa2611e8b8f9a4a7905 | [] | no_license | aadarshasubedi/Ocerus | 1bea105de9c78b741f3de445601f7dee07987b96 | 4920b99a89f52f991125c9ecfa7353925ea9603c | refs/heads/master | 2021-01-17T17:50:00.472657 | 2011-03-25T13:26:12 | 2011-03-25T13:26:12 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,128 | h | /// @file
/// System for connecting the RTTI to custom classes.
/// @remarks
/// Implementation based on the code from Game Programming Gems 5 (1.4).
#ifndef _RTTICLASS_H
#define _RTTICLASS_H
#include "Base.h"
#include "RTTI.h"
#include "../Properties/PropertySystem.h"
#include "../Properties/Property.h"
#include "../Properties/PropertyMap.h"
#include "../Properties/ValuedProperty.h"
namespace Reflection
{
/// This is the %RTTI "sandwich class" being used to augment a class with %RTTI support. Classes
/// supporting %RTTI need to derive from this class, with their ancestor specified as the BaseClass
/// template parameter.
template <class T, class BaseClass> class RTTIGlue : public BaseClass
{
public :
/// Constructor.
RTTIGlue(void)
{
}
/// Destructor.
~RTTIGlue(void)
{
}
/// Default factory function. Creates an instance of T.
/// The factory function is called by the system to dynamically create
/// class instances from class IDs.
static T* CreateInstance(void) { return new T(); }
/// Default reflection registration function. Registers nothing by default.
static void RegisterReflection(void) {}
/// Registers a property. Takes in the property name, its getter and setter functions, and the property
/// type as a template parameter.
/// This function should be called only from within a user-defined RegisterReflection function.
template <class PropertyTypes>
static void RegisterProperty(StringKey name, typename Property<T, PropertyTypes>::GetterType getter,
typename Property<T, PropertyTypes>::SetterType setter, const PropertyAccessFlags accessFlags,
const string& comment)
{
Property<T, PropertyTypes>* pProperty = new Property<T, PropertyTypes>( name, getter, setter, accessFlags, comment );
if (T::GetClassRTTI()->AddProperty(pProperty))
{
PropertySystem::GetProperties()->push_back( pProperty );
}
else
{
delete pProperty;
}
}
/// Registers a function. Takes in the function name and its address.
/// This function should be called only from within a user-defined RegisterReflection function.
inline static void RegisterFunction(StringKey name, typename Property<T, PropertyFunctionParameters>::SetterType function, const PropertyAccessFlags accessFlags, const string& comment)
{
RegisterProperty<PropertyFunctionParameters>(name, 0, function, accessFlags | PA_TRANSIENT, comment);
}
/// Registers an entity component dependant on the owner of this class.
/// Component dependencies solve the issue of defining the correct order of entity components creation
/// and initialization. For example, components handling physics should be usually inited before the components
/// handling logic.
/// @remarks This function should be called only from within a user-defined RegisterReflection function.
static void AddComponentDependency(const EntitySystem::eComponentType cmp)
{
T::GetClassRTTI()->AddComponentDependency(cmp);
}
/// Returns whether the component is transient.
static inline bool IsTransient(void) { return mRTTI.IsTransient(); }
/// Sets whether the component is transient.
static inline void SetTransient(bool transient) { mRTTI.SetTransient(transient); }
/// Returns the ID of this class.
static ClassID& GetClassID(void)
{
static ClassID classID = Hash::HashString(typeid(T).name());
return classID;
}
/// Returns the RTTI info associated with this class.
static inline RTTI* GetClassRTTI(void) { return &mRTTI; }
/// Returns the RTTI info associated with this class instance.
virtual RTTI* GetRTTI(void) const { return &mRTTI; }
/// Returns a property identified by it's string key. Access restriction filter can be defined.
AbstractProperty* GetPropertyPointer(const StringKey key, const PropertyAccessFlags flagMask = PA_FULL_ACCESS) const
{
if (BaseClass::mDynamicProperties)
{
AbstractProperty* prop = BaseClass::mDynamicProperties->GetProperty(key, flagMask);
if (prop) return prop;
}
return GetRTTI()->GetProperty(key, flagMask);
}
/// Fills a data structure with all properties.
void EnumProperties( RTTIBaseClass* owner, PropertyList& out, const PropertyAccessFlags flagMask = PA_FULL_ACCESS ) const
{
GetRTTI()->EnumProperties(owner, out, flagMask);
if (BaseClass::mDynamicProperties) BaseClass::mDynamicProperties->EnumProperties(owner, out, flagMask);
}
protected :
static RTTI mRTTI;
};
/// Creates an RTTI structure for a specified class pair.
/// The first parameter (0) is a stub. See RTTI constructor for details.
/// Note that this is the place where the RegisterReflection function is being called when the program boots up.
template <class T, class BaseClass>
RTTI RTTIGlue<T, BaseClass>::mRTTI(
0,
RTTIGlue<T, BaseClass>::GetClassID(),
typeid(T).name(),
BaseClass::GetClassRTTI(),
(ClassFactoryFunc)T::CreateInstance,
(RegisterReflectionFunc)T::RegisterReflection
);
}
#endif // _RTTICLASS_H | [
[
[
1,
12
],
[
15,
25
],
[
34,
45
],
[
50,
50
],
[
52,
63
],
[
65,
65
],
[
67,
77
],
[
84,
97
],
[
117,
138
]
],
[
[
13,
14
],
[
26,
33
],
[
47,
47
],
[
64,
64
],
[
66,
66
],
[
78,
83
],
[
98,
100
],
[
102,
102
],
[
104,
113
],
[
115,
116
]
],
[
[
46,
46
],
[
48,
49
],
[
51,
51
],
[
101,
101
],
[
103,
103
],
[
114,
114
]
]
] |
|
b54fc933faeabb4ec4ba0597c71347923fa2d856 | 89d2197ed4531892f005d7ee3804774202b1cb8d | /GWEN/src/Controls/WindowControl.cpp | 4ebe58b7e993c2944b381c05520636c1e89e2c2e | [
"MIT",
"Zlib"
] | permissive | hpidcock/gbsfml | ef8172b6c62b1c17d71d59aec9a7ff2da0131d23 | e3aa990dff8c6b95aef92bab3e94affb978409f2 | refs/heads/master | 2020-05-30T15:01:19.182234 | 2010-09-29T06:53:53 | 2010-09-29T06:53:53 | 35,650,825 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,160 | cpp | /*
GWEN
Copyright (c) 2010 Facepunch Studios
See license in Gwen.h
*/
#include "stdafx.h"
#include "Gwen/Controls/WindowControl.h"
#include "Gwen/Controls/ImagePanel.h"
#include "Gwen/Controls/Label.h"
#include "Gwen/Controls/Modal.h"
using namespace Gwen;
using namespace Gwen::Controls;
using namespace Gwen::ControlsInternal;
GWEN_CONTROL_CONSTRUCTOR( WindowControl )
{
m_Modal = NULL;
m_bInFocus = false;
m_bDeleteOnClose = false;
m_TitleBar = new Dragger( this );
m_TitleBar->Dock( Pos::Top );
m_TitleBar->SetHeight( 18 );
m_TitleBar->SetPadding( Padding( 0, 0, 0, 5 ) );
m_TitleBar->SetTarget( this );
m_Title = new Label( m_TitleBar );
m_Title->SetAlignment( Pos::Center );
m_Title->SetText( "Window" );
m_Title->Dock( Pos::Fill );
m_CloseButton = new Button( m_TitleBar );
m_CloseButton->SetText( "" );
m_CloseButton->SetSize( m_TitleBar->Height(), m_TitleBar->Height() );
m_CloseButton->Dock(Pos::Right);
m_CloseButton->onPress.Add( this, &WindowControl::CloseButtonPressed );
m_CloseButton->SetTabable(false);
m_CloseButton->SetName( "closeButton" );
//Create a blank content control, dock it to the top - Should this be a ScrollControl?
m_InnerPanel = new Base(this);
m_InnerPanel->Dock(Pos::Fill);
BringToFront();
SetTabable( false );
Focus();
SetMinimumSize( Point( 100, 40 ) );
SetClampMovement( true );
SetKeyboardInputEnabled( false );
}
WindowControl::~WindowControl()
{
if ( m_Modal )
{
m_Modal->DelayedDelete();
}
}
void WindowControl::MakeModal( bool invisible )
{
if ( m_Modal ) return;
m_Modal = new ControlsInternal::Modal( GetCanvas() );
SetParent( m_Modal );
if ( invisible )
{
m_Modal->SetShouldDrawBackground( false );
}
}
bool WindowControl::IsOnTop()
{
for (Base::List::reverse_iterator iter = GetParent()->Children.rbegin(); iter != GetParent()->Children.rend(); ++iter)
{
WindowControl* pWindow = dynamic_cast<WindowControl*>(*iter);
if ( !pWindow )
continue;
if ( pWindow == this )
return true;
return false;
}
return false;
}
void WindowControl::Render( Skin::Base* skin )
{
//This should use m_bInFocus but I need to figure out best way to make layout happen
skin->DrawWindow( this, m_TitleBar->Bottom(), IsOnTop() );
}
void WindowControl::RenderUnder( Skin::Base* skin )
{
BaseClass::RenderUnder( skin );
skin->DrawShadow( this );
}
void WindowControl::SetTitle(Gwen::UnicodeString title)
{
m_Title->SetText( title );
}
void WindowControl::SetClosable(bool closeable)
{
m_CloseButton->SetHidden( !closeable );
}
void WindowControl::SetHidden(bool hidden)
{
if ( !hidden )
BringToFront();
BaseClass::SetHidden(hidden);
}
void WindowControl::Touch()
{
BaseClass::Touch();
BringToFront();
m_bInFocus = IsOnTop();
//If Keyboard focus isn't one of our children, make it us
}
void WindowControl::CloseButtonPressed( Gwen::Controls::Base* pFromPanel )
{
SetHidden(true);
if ( m_bDeleteOnClose )
DelayedDelete();
}
void WindowControl::RenderFocus( Gwen::Skin::Base* skin )
{
} | [
"haza55@5bf3a77f-ad06-ad18-b9fb-7d0f6dabd793"
] | [
[
[
1,
146
]
]
] |
b3f4fcb8d34b4731daf9238196462ce122eb702d | 611fc0940b78862ca89de79a8bbeab991f5f471a | /src/Teki/Boss/Majo/Majo.h | cf1cf9673a18f6927b174e41b1c817227a898f68 | [] | no_license | LakeIshikawa/splstage2 | df1d8f59319a4e8d9375b9d3379c3548bc520f44 | b4bf7caadf940773a977edd0de8edc610cd2f736 | refs/heads/master | 2021-01-10T21:16:45.430981 | 2010-01-29T08:57:34 | 2010-01-29T08:57:34 | 37,068,575 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 1,797 | h | #pragma once
#include "..\\..\\Teki.h"
#include "ThrowApple.h"
#include <list>
/*
ボスの魔女
*/
class Majo : public Teki
{
public:
// 基本
enum STATUS{
WIN,
WINBACK,
WINDAMAGE,
DOOR,
DOORTHROW,
DOORTHROWEND,
DOOREXIT,
DOORDAMAGE,
DIYING,
DEAD
};
Majo();
~Majo();
void _Move(); // 敵から
TEKI_SETUP;
// インターフェース
void InflictDamage();
void Activate();
// ルーチン
void MapAtHt();
void DousaEnd();
void CollisionResponse(ICollidable *rCollObject, int rThisGroupId, int rOpGroupId);
void DieIfGamenGai() {}
void KobitoDied();
int GetEntPt() { return mEntPt; }
STATUS GetStatus() { return mStatus; }
static Map::HITPOINT sMapAtHanteiX; // 2点: 0- 床 1- 前
static Map::HITPOINT sMapAtHanteiY;
static int sShutugenX[5];
static int sShutugenY[5];
static int sRingoX[5];
static int sRingoY[5];
static float sDieSpX[5];
private:
// 出現地を選ぶ
void SelectEntPoint();
void RollingAppleCreate(int rXPx, int rYPx, int rType);
void ThrowAppleCreate(int rXPx, int rYPx, int rMuki);
void AppleOtosu();
void AppleThrow();
void KobitoCreate();
void Die();
STATUS mStatus;
STATUS mSaveStatus;
enum FRAME{
FR_WIN,
FR_DOOR
};
// タイマー
float mTaikiTimer;
float mDieTimer;
float mSaveSpX;
// 当たり判定用
int mShirabe[4]; // 当たったときに、壁の位置を返す(その軸の座標)
int mAtari[4]; // 当たってるとフラグが立つ
Apple* mDropMe;
ThrowApple* mThrowMe;
int mEntPt;
bool mKobitoOut;
int mHp;
// 設定定数
int MAJOSX;
int MAJOSY;
float MAJO_ARUKI_SPX;
bool mActive;
bool dmgFlag;
};
| [
"lakeishikawa@c9935178-01ba-11df-8f7b-bfe16de6f99b"
] | [
[
[
1,
117
]
]
] |
54539c82c2384e78aa0e78abffe260e1b6b30eff | ce262ae496ab3eeebfcbb337da86d34eb689c07b | /SEFoundation/SESceneGraph/SELightNode.cpp | c5aef7755b6c5a6a2a15bcf0c3f3bbcdb747dd90 | [] | 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 | 6,007 | 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 "SELightNode.h"
using namespace Swing;
SE_IMPLEMENT_RTTI(Swing, SELightNode, SENode);
SE_IMPLEMENT_STREAM(SELightNode);
//SE_REGISTER_STREAM(SELightNode);
//----------------------------------------------------------------------------
SELightNode::SELightNode(SELight* pLight)
:
m_spLight(pLight)
{
if( m_spLight )
{
Local.SetTranslate(m_spLight->Position);
Local.SetRotate(SEMatrix3f(m_spLight->RVector, m_spLight->UVector,
m_spLight->DVector));
}
}
//----------------------------------------------------------------------------
SELightNode::~SELightNode()
{
}
//----------------------------------------------------------------------------
void SELightNode::SetLight(SELight* pLight)
{
m_spLight = pLight;
if( m_spLight )
{
Local.SetTranslate(m_spLight->Position);
Local.SetRotate(SEMatrix3f(m_spLight->RVector, m_spLight->UVector,
m_spLight->DVector));
UpdateGS();
}
}
//----------------------------------------------------------------------------
void SELightNode::UpdateWorldData(double dAppTime)
{
SENode::UpdateWorldData(dAppTime);
if( m_spLight )
{
m_spLight->Position = World.GetTranslate();
World.GetRotate().GetRow(0, m_spLight->RVector);
World.GetRotate().GetRow(1, m_spLight->UVector);
World.GetRotate().GetRow(2, m_spLight->DVector);
}
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// name and unique id
//----------------------------------------------------------------------------
SEObject* SELightNode::GetObjectByName(const std::string& rName)
{
SEObject* pFound = SENode::GetObjectByName(rName);
if( pFound )
{
return pFound;
}
if( m_spLight )
{
pFound = m_spLight->GetObjectByName(rName);
if( pFound )
{
return pFound;
}
}
return 0;
}
//----------------------------------------------------------------------------
void SELightNode::GetAllObjectsByName(const std::string& rName,
std::vector<SEObject*>& rObjects)
{
SENode::GetAllObjectsByName(rName, rObjects);
if( m_spLight )
{
m_spLight->GetAllObjectsByName(rName, rObjects);
}
}
//----------------------------------------------------------------------------
SEObject* SELightNode::GetObjectByID(unsigned int uiID)
{
SEObject* pFound = SENode::GetObjectByID(uiID);
if( pFound )
{
return pFound;
}
if( m_spLight )
{
pFound = m_spLight->GetObjectByID(uiID);
if( pFound )
{
return pFound;
}
}
return 0;
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// streaming
//----------------------------------------------------------------------------
void SELightNode::Load(SEStream& rStream, SEStream::SELink* pLink)
{
SE_BEGIN_DEBUG_STREAM_LOAD;
SENode::Load(rStream, pLink);
// link data
SEObject* pObject;
rStream.Read(pObject); // m_spLight
pLink->Add(pObject);
SE_END_DEBUG_STREAM_LOAD(SELightNode);
}
//----------------------------------------------------------------------------
void SELightNode::Link(SEStream& rStream, SEStream::SELink* pLink)
{
SENode::Link(rStream, pLink);
SEObject* pLinkID = pLink->GetLinkID();
m_spLight = (SELight*)rStream.GetFromMap(pLinkID);
}
//----------------------------------------------------------------------------
bool SELightNode::Register(SEStream& rStream) const
{
if( !SENode::Register(rStream) )
{
return false;
}
if( m_spLight )
{
m_spLight->Register(rStream);
}
return true;
}
//----------------------------------------------------------------------------
void SELightNode::Save(SEStream& rStream) const
{
SE_BEGIN_DEBUG_STREAM_SAVE;
SENode::Save(rStream);
// link data
rStream.Write(m_spLight);
SE_END_DEBUG_STREAM_SAVE(SELightNode);
}
//----------------------------------------------------------------------------
int SELightNode::GetDiskUsed(const SEStreamVersion& rVersion) const
{
return SENode::GetDiskUsed(rVersion) + SE_PTRSIZE(m_spLight);
}
//----------------------------------------------------------------------------
SEStringTree* SELightNode::SaveStrings(const char*)
{
SEStringTree* pTree = SE_NEW SEStringTree;
// strings
pTree->Append(Format(&TYPE, GetName().c_str()));
// children
pTree->Append(SENode::SaveStrings());
if( m_spLight )
{
pTree->Append(m_spLight->SaveStrings());
}
return pTree;
}
//----------------------------------------------------------------------------
| [
"[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac"
] | [
[
[
1,
204
]
]
] |
8f5736318fba7f54a707810db0c06430104cf3c9 | b84a38aad619acf34c22ed6e6caa0f7b00ebfa0a | /Code/TootleGame/TWidgetManager.h | bc41c57e0ab63ff0ef4f9129a774b28a8c5d265b | [] | no_license | SoylentGraham/Tootle | 4ae4e8352f3e778e3743e9167e9b59664d83b9cb | 17002da0936a7af1f9b8d1699d6f3e41bab05137 | refs/heads/master | 2021-01-24T22:44:04.484538 | 2010-11-03T22:53:17 | 2010-11-03T22:53:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,187 | h |
#pragma once
#include <TootleCore/TManager.h>
#include <TootleInput/TUser.h>
#include <TootleCore/TRef.h>
#include <TootleCore/TKeyArray.h>
#include "TWidgetFactory.h"
namespace TLGui
{
class TWidgetManager;
extern TPtr<TWidgetManager> g_pWidgetManager;
}
// Widget cache should help with searches within the widget system
//#define ENABLE_WIDGET_CACHE
class TLGui::TWidgetManager : public TLCore::TManager
{
private:
class TActionRefData
{
public:
TRef m_ClickActionRef;
TRef m_MoveActionRef;
};
class TWidgetCache
{
public:
TWidgetCache() :
m_pWidgetGroup ( NULL ),
m_pWidget ( NULL )
{}
FORCEINLINE void Clear() { Set(TRef(), NULL, NULL); }
FORCEINLINE TRef GetWidgetGroupRef() const { return m_WidgetGroupRef; }
FORCEINLINE TPtrArray<TWidget>* GetWidgetGroup() const { return m_pWidgetGroup; }
FORCEINLINE TPtr<TWidget> GetWidget() const { return m_pWidget; }
#ifdef ENABLE_WIDGET_CACHE
FORCEINLINE void Set(TRef WidgetGroupRef, TPtrArray<TWidget>* pArray, TPtr<TWidget> pWidget) { m_WidgetGroupRef = WidgetGroupRef; m_pWidgetGroup = pArray; m_pWidget = pWidget; }
FORCEINLINE void SetWidget(TPtr<TWidget> pWidget) { m_pWidget = pWidget; }
#else
FORCEINLINE void Set(TRef WidgetGroupRef, TPtrArray<TWidget>* pArray, TPtr<TWidget> pWidget) { }
FORCEINLINE void SetWidget(TPtr<TWidget> pWidget) { }
#endif
private:
TRef m_WidgetGroupRef; // Last group used ref
TPtrArray<TWidget>* m_pWidgetGroup; // Last group used
TPtr<TWidget> m_pWidget; // Last widget used
};
public:
TWidgetManager(TRefRef ManagerRef) :
TLCore::TManager(ManagerRef)
{
}
TRef CreateWidget(TRefRef WidgetGroupRef, TRefRef InstanceRef, TRefRef TypeRef, Bool bStrict=FALSE);
FORCEINLINE TRef CreateWidget(const TTypedRef& GroupInstanceRef, TRefRef TypeRef) { return CreateWidget(GroupInstanceRef.GetRef(), GroupInstanceRef.GetTypeRef(), TypeRef); }
FORCEINLINE Bool RemoveWidget(TRefRef GroupInstanceRef, TRefRef InstanceRef);
FORCEINLINE Bool RemoveWidget(const TTypedRef& GroupInstanceRef) { return RemoveWidget(GroupInstanceRef.GetRef(), GroupInstanceRef.GetTypeRef()); }
void SendMessageToWidget(TRefRef WidgetGroupRef, TRefRef WidgetRef, TLMessaging::TMessage& Message);
FORCEINLINE void SendMessageToWidget(const TTypedRef& GroupInstanceRef, TLMessaging::TMessage& Message) { return SendMessageToWidget(GroupInstanceRef.GetRef(), GroupInstanceRef.GetTypeRef(), Message); }
Bool SubscribeToWidget(TRefRef WidgetGroupRef, TRefRef WidgetRef, TSubscriber* pSubscriber);
FORCEINLINE Bool SubscribeToWidget(const TTypedRef& GroupInstanceRef, TSubscriber* pSubscriber) { return SubscribeToWidget(GroupInstanceRef.GetRef(), GroupInstanceRef.GetTypeRef(), pSubscriber); }
Bool SubscribeWidgetTo(TRefRef WidgetGroupRef, TRefRef WidgetRef, TPublisher* pPublisher);
FORCEINLINE Bool SubscribeWidgetTo(const TTypedRef& GroupInstanceRef, TPublisher* pPublisher) { return SubscribeWidgetTo(GroupInstanceRef.GetRef(), GroupInstanceRef.GetTypeRef(), pPublisher); }
FORCEINLINE Bool IsClickActionRef(TRefRef ClickActionRef);
FORCEINLINE Bool IsMoveActionRef(TRefRef MoveActionRef);
FORCEINLINE Bool IsActionPair(TRefRef ClickActionRef, TRefRef MoveActionRef);
FORCEINLINE TRef GetClickActionFromMoveAction(TRefRef MoveActionRef);
FORCEINLINE TRef GetMoveActionFromClickAction(TRefRef ClickActionRef);
FORCEINLINE Bool AddFactory(TPtr< TClassFactory<TWidget,FALSE> >& pFactory) { return m_WidgetFactories.Add(pFactory)!=-1; }
protected:
virtual SyncBool Initialise();
virtual SyncBool Shutdown();
virtual void OnEventChannelAdded(TRefRef refPublisherID, TRefRef refChannelID);
virtual void ProcessMessage(TLMessaging::TMessage& Message);
void OnInputDeviceAdded(TRefRef refDeviceID, TRefRef refDeviceType);
void OnInputDeviceRemoved(TRefRef refDeviceID, TRefRef refDeviceType);
Bool DoRemoveWidget(TRefRef RenderTargetRef, TRefRef InstanceRef);
// Action mapping
#ifdef TL_TARGET_IPOD
void MapDeviceActions_TouchPad(TRefRef refDeviceID, TPtr<TLUser::TUser> pUser);
#else
void MapDeviceActions_Mouse(TRefRef refDeviceID, TPtr<TLUser::TUser> pUser);
#endif
void MapDeviceActions_Keyboard(TRefRef refDeviceID, TPtr<TLUser::TUser> pUser);
private:
TPtr<TWidget> FindWidget(TRefRef WidgetGroupRef, TRefRef WidgetRef);
private:
TWidgetCache m_WidgetCache; // Widget cache for speeding up some routines that get called with the same data consecutively
THeapArray<TActionRefData> m_WidgetActionRefs;
TKeyArray< TRef, TPtrArray<TWidget> > m_WidgetRefs; // Array of widget ref's organised with a TRenderTarget TRef as the key
TPtrArray< TClassFactory<TWidget,FALSE> > m_WidgetFactories; // array of widget factories.
};
FORCEINLINE Bool TLGui::TWidgetManager::RemoveWidget(TRefRef RenderTargetRef, TRefRef InstanceRef)
{
if(InstanceRef.IsValid())
return DoRemoveWidget(RenderTargetRef, InstanceRef);
TLDebug_Print("Passing invalid widget ref to TWidgetManager::RemoveWidget");
return FALSE;
}
FORCEINLINE Bool TLGui::TWidgetManager::IsClickActionRef(TRefRef ClickActionRef)
{
for(u32 uIndex = 0; uIndex < m_WidgetActionRefs.GetSize(); uIndex++)
{
if(m_WidgetActionRefs.ElementAt(uIndex).m_ClickActionRef == ClickActionRef)
return TRUE;
}
return FALSE;
}
FORCEINLINE Bool TLGui::TWidgetManager::IsMoveActionRef(TRefRef MoveActionRef)
{
for(u32 uIndex = 0; uIndex < m_WidgetActionRefs.GetSize(); uIndex++)
{
if(m_WidgetActionRefs.ElementAt(uIndex).m_MoveActionRef == MoveActionRef)
return TRUE;
}
return FALSE;
}
FORCEINLINE Bool TLGui::TWidgetManager::IsActionPair(TRefRef ClickActionRef, TRefRef MoveActionRef)
{
for(u32 uIndex = 0; uIndex < m_WidgetActionRefs.GetSize(); uIndex++)
{
const TActionRefData& ActionPair = m_WidgetActionRefs.ElementAt(uIndex);
if( ActionPair.m_ClickActionRef == ClickActionRef)
{
if(ActionPair.m_MoveActionRef == MoveActionRef)
return TRUE;
// Actions will be unique so if we find the click ref
// but move is different then we should not find any further click with the same ref
// therefore we can return
return FALSE;
}
}
return FALSE;
}
FORCEINLINE TRef TLGui::TWidgetManager::GetClickActionFromMoveAction(TRefRef MoveActionRef)
{
for(u32 uIndex = 0; uIndex < m_WidgetActionRefs.GetSize(); uIndex++)
{
const TActionRefData& ActionPair = m_WidgetActionRefs.ElementAt(uIndex);
if(ActionPair.m_MoveActionRef == MoveActionRef)
return ActionPair.m_ClickActionRef;
}
return TRef_Invalid;
}
FORCEINLINE TRef TLGui::TWidgetManager::GetMoveActionFromClickAction(TRefRef ClickActionRef)
{
for(u32 uIndex = 0; uIndex < m_WidgetActionRefs.GetSize(); uIndex++)
{
const TActionRefData& ActionPair = m_WidgetActionRefs.ElementAt(uIndex);
if(ActionPair.m_ClickActionRef == ClickActionRef)
return ActionPair.m_MoveActionRef;
}
return TRef_Invalid;
}
| [
"[email protected]",
"[email protected]"
] | [
[
[
1,
22
],
[
24,
42
],
[
44,
44
],
[
46,
46
],
[
49,
57
],
[
59,
64
],
[
66,
68
],
[
71,
73
],
[
75,
75
],
[
78,
78
],
[
81,
82
],
[
85,
87
],
[
91,
91
],
[
94,
126
],
[
128,
131
],
[
134,
143
],
[
215,
215
]
],
[
[
23,
23
],
[
43,
43
],
[
45,
45
],
[
47,
48
],
[
58,
58
],
[
65,
65
],
[
69,
70
],
[
74,
74
],
[
76,
77
],
[
79,
80
],
[
83,
84
],
[
88,
90
],
[
92,
93
],
[
127,
127
],
[
132,
133
],
[
144,
214
]
]
] |
671953a4fee19a219f663cdf7b75d246f842192b | 6ea2685ec9aa4be984ea0febb7eefc2f3bc544c9 | /SplineFrameBuilder.cpp | a9925e52790ec447f7e8b2084591082cce610880 | [] | no_license | vpatrinica/pernute | f047445a373f79209f0e32c1bf810d90c3d6289f | e2c0bf4161ccb4e768e7b64ecd2a021e51319383 | refs/heads/master | 2021-01-02T22:31:07.174479 | 2010-05-13T21:13:34 | 2010-05-13T21:13:34 | 39,997,926 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,525 | cpp | #include "SplineFrameBuilder.h"
SplineFrameBuilder::SplineFrameBuilder()
{
acutPrintf(_T("Constructor of SplineFrameBuilder called ...\n"));
}
SplineFrameBuilder::~SplineFrameBuilder()
{
acutPrintf(_T("Destructor of SplineFrameBuilder called ...\n"));
}
void SplineFrameBuilder::buildFramePoints(AcArray<AcGePoint3d>& arrayPoints, AcDbObjectPointer<AcDbEntity>& SplineObject, int granularity)
{
acutPrintf(_T("Building the points using SplineFrameBuilder ...\n"));
_pSpline = AcDbSpline::cast(SplineObject);
AcGePoint3d startPoint;
_pSpline->getStartPoint(startPoint);
arrayPoints.append(startPoint);
double length, endParam = 0;
_pSpline->getEndParam(endParam);
_pSpline->getDistAtParam(endParam, length);
acutPrintf(_T("The length and other params: %f, %d, %d ...\n"), length, ((int) length)/granularity, granularity);
for (int i = 0; i< ((int) length)/granularity; i++)
{
AcGePoint3d newPoint;
_pSpline->getPointAtDist(i*granularity, newPoint);
arrayPoints.append(newPoint);
}
AcGePoint3d endPoint;
_pSpline->getPointAtParam(endParam, endPoint);
arrayPoints.append(endPoint);
acutPrintf(_T("Built the points using SplineFrameBuilder ...\n"));
}
void SplineFrameBuilder::getFramePoints(AcArray<AcGePoint3d> &)
{
acutPrintf(_T("Getting the points using SplineFrameBuilder ...\n"));
}
void SplineFrameBuilder::printFramePoints()
{
acutPrintf(_T("Printing the points using SplineFrameBuilder ...\n"));
} | [
"v.patrinica@4687759a-75b2-d36a-a905-7d4f9b7d90e1"
] | [
[
[
1,
61
]
]
] |
144c6e5517c206260208e08e3ad3664fd2f33e6e | d6b0c51999cecf65d5be208fab74bb8a199eb0ac | /MagicCube/Frame.h | 1be21126f57adb5ca460b863d9e7666d92450a6b | [] | no_license | k-l-lambda/klsmagiccube | 5076e6be0a729ff8741d960e44e5fb061c473b08 | 1cfb166f537573b7e64d902085075ff0e99b9166 | refs/heads/master | 2016-09-05T22:12:35.513552 | 2011-02-10T16:17:38 | 2011-02-10T16:17:38 | 32,123,748 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,368 | h | /*
** This source file is part of K.L.'s MagicCube.
**
** Copyright (c) 2008 K.L.<[email protected]>
** This program is free software without any warranty.
*/
#ifndef __FRAME_H__
#define __FRAME_H__
#define SKIP_CONFIG_DIALOG
#include "ExampleApplication.h"
#include "OgreCEGUIRenderer.h"
#include "MagicCube.h"
#include "Player.h"
class Frame : public ExampleApplication
{
friend class OgreListener;
public:
Frame();
~Frame();
private:
virtual void createFrameListener();
// Just override the mandatory create scene method
virtual void createScene(void);
private:
void frameStarted(const FrameEvent& evt);
void frameEnded(const FrameEvent& evt);
bool keyPressed( const OIS::KeyEvent &e );
bool keyReleased( const OIS::KeyEvent& /*arg*/ );
bool mouseMoved(const OIS::MouseEvent &arg);
bool mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
bool onGuiMouseMove(const CEGUI::EventArgs& e);
bool onGuiShut(const CEGUI::EventArgs& e);
bool onGuiResetMagicCube(const CEGUI::EventArgs& e);
bool onGuiSaveSnapshot(const CEGUI::EventArgs& e);
bool onGuiLoadSnapshot(const CEGUI::EventArgs& e);
bool onGuiUndoManipulatation(const CEGUI::EventArgs& e);
bool onGuiRedoManipulatation(const CEGUI::EventArgs& e);
bool onGuiNextSkyBox(const CEGUI::EventArgs& e);
bool onGuiLoadPlayback(const CEGUI::EventArgs& e);
bool onGuiSavePlayback(const CEGUI::EventArgs& e);
bool onGuiLoadPythonScript(const CEGUI::EventArgs& e);
bool onGuiLoadLuaScript(const CEGUI::EventArgs& e);
bool onGuiPlayerStop(const CEGUI::EventArgs& e);
bool onGuiPlayerHome(const CEGUI::EventArgs& e);
bool onGuiPlayerPrev(const CEGUI::EventArgs& e);
bool onGuiPlayerPlayPause(const CEGUI::EventArgs& e);
bool onGuiPlayerNext(const CEGUI::EventArgs& e);
bool onGuiChangeMirrorEffect(const CEGUI::EventArgs& e);
bool onGuiChangeShininess(const CEGUI::EventArgs& e);
private:
void setupGui();
void setMagicCube(const MagicCube::MagicCube& mc);
void updateMagicCube();
void resetTransitionNode();
void highlightCube(size_t i, size_t j, size_t k, bool highlight = true);
Vector2 getCursorPosition() const;
Vector2 worldToViewport(const Vector3& p) const;
CEGUI::UVector2 oisToCegui(const Vector2& p) const;
void manipulatationTransition(MagicCube::Face face, int dimension, bool needUpdate = true);
void setCubMap(const std::string& name);
bool playerOn() const;
void togglePlayPause(bool play);
template<typename PlayerClass>
void loadPlayer(const std::string& directory, const std::string& title, const std::string& filter = "All Files(*)\1*\1\1");
void updateMirrorEffect();
void updateShininess();
private:
// UI commands
void onResetMagicCube();
void onSaveSnapshot();
void onLoadSnapshot();
void onUndoManipulatation();
void onRedoManipulatation();
void onNextSkyBox();
void onPlayerStop();
bool onPlayerSynchronize(MagicCube::Manipulation m);
private:
SceneNode* m_nodeLight;
SceneNode* m_nodeLight2;
SceneNode* m_nodeMagicCube;
SceneNode* m_nodeCameraRoot;
SceneNode* m_nodeCamera;
SceneNode* m_CubeArray[3][3][3];
MagicCube::MagicCube m_MagicCube;
MagicCube::Face m_FocusFace;
struct ManipulatationTransition
{
bool on;
MagicCube::Face face;
Real angle;
int target;
bool needUpdate;
static const Real SPEED;
void reset()
{
on = false;
angle = 0;
};
void set(MagicCube::Face _face, int _target, bool _needUpdate = true)
{
on = true;
face = _face;
//angle = -target * Ogre::half_pi;
target = _target;
needUpdate = _needUpdate;
//assert(target != 0);
};
} m_ManipulatationTransition;
boost::shared_ptr<CEGUI::Renderer> m_GuiRenderer;
boost::shared_ptr<CEGUI::System> m_GuiSystem;
CEGUI::Point m_GuiCursorPostion;
CEGUI::Window* m_cDot[9];
CEGUI::Window* m_PlayerBar;
CEGUI::Window* m_PlayerSoureName;
CEGUI::Window* m_PlayerStep;
bool m_RotatingMagicCube;
bool m_ManipulatingMagicCube;
Radian m_SkyBoxAngle;
std::string m_SaveSnapshotFileName;
boost::shared_ptr<MagicCube::Player> m_Player;
bool m_PlayerIsPlaying;
};
#endif // !defined(__FRAME_H__)
| [
"[email protected]"
] | [
[
[
1,
175
]
]
] |
f9c502d828e38358729dbb99f9b64ec691d9c0bd | 96a48df2a03d542068be2cbe140500bc99f52725 | /stereomatchingbm.cpp | e29d1132b2bed90e525b74170233d19c0e7ba652 | [] | no_license | noahkong/stereocam | d0bbffafba8815ac3531dd59c5f270b67b52a11d | 19749024834ed11767c114370fc55aeb41f75e2c | refs/heads/master | 2020-05-30T14:50:32.032286 | 2011-03-26T18:51:33 | 2011-03-26T18:51:33 | 32,440,548 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,026 | cpp | #include "stereomatchingbm.hpp"
using namespace std;
using namespace cv;
StereoMatchingBM::StereoMatchingBM(): StereoMatching("Block Matching"),
I_minDisparity(0),
I_numberOfDisparities(1),
I_SADWindowSize(2),
I_preFilterCap(3),
I_preFilterSize(4),
I_textureThreshold(5),
I_uniquenessRatio(6),
I_speckleWindowSize(7),
I_speckleRange(8),
I_disp12MaxDiff(9),
I_trySmallerWindows(10){
init();
}
StereoMatchingBM::~StereoMatchingBM(){
}
void StereoMatchingBM::init(){
//0
Property * prop = new Property("Minimum disparity", 0, Property::INT);
prop->minValue = -50;
prop->maxValue = 50;
prop->step = 5;
properties.push_back(prop);
//1
Property * prop2 = new Property("Number of disparities", 2, Property::DISCRETE);
int max = 4;
int * values = new int[max];
for(int i = 0; i < max; ++i)
values[i] = 16*i;
prop2->minValue = 0;
prop2->maxValue = max;
prop2->tableValues = values;
properties.push_back(prop2);
//2
Property * prop3 = new Property("SAD window size", 6, Property::DISCRETE);
max = 8;
int defValues[8] = {1, 3, 5, 7, 9, 11, 21, 31};
int * values2 = new int[max];
for(int i = 0; i < max; ++i)
values2[i] = defValues[i];
prop3->minValue = 0;
prop3->maxValue = max;
prop3->tableValues = values2;
properties.push_back(prop3);
//3
prop = new Property("PrefilterCap", 31, Property::INT);
prop->minValue = 0;
prop->maxValue = 50;
properties.push_back(prop);
//4
prop = new Property("Prefilter Size", 11, Property::INT);
prop->minValue = 0;
prop->maxValue = 50;
properties.push_back(prop);
//5
prop = new Property("Texture Threshold", 5, Property::INT);
prop->minValue = 0;
prop->maxValue = 30;
properties.push_back(prop);
//6
prop = new Property("UniquenessRatio", 1, Property::INT);
prop->minValue = 0;
prop->maxValue = 35;
properties.push_back(prop);
//7
prop = new Property("Speckle window size", 400, Property::INT);
prop->minValue = 0;
prop->maxValue = 500;
prop->step = 50;
properties.push_back(prop);
//8
prop = new Property("Speckle range", 1, Property::DISCRETE);
max = 4;
int * values3 = new int[max];
for(int i = 0; i < max; ++i)
values3[i] = 16*i;
prop->minValue = 0;
prop->maxValue = max;
prop->tableValues = values3;
properties.push_back(prop);
//9
prop = new Property("Disparity max difference", 2, Property::INT);
prop->minValue = -1;
prop->maxValue = 20;
properties.push_back(prop);
//10
prop = new Property("Try smaller windows", 0, Property::BOOL);
prop->minValue = 0;
prop->maxValue = 1;
properties.push_back(prop);
applyAllParametres();
}
void StereoMatchingBM::applyAllParametres(){
changeProperties();
bm.state->preFilterCap = properties[I_preFilterCap]->getValue();
bm.state->preFilterSize = properties[I_preFilterSize]->getValue();
bm.state->SADWindowSize = properties[I_SADWindowSize]->tableValues[properties[I_SADWindowSize]->getValue()];
bm.state->minDisparity = properties[I_minDisparity]->getValue();
bm.state->numberOfDisparities = properties[I_numberOfDisparities]->tableValues[properties[I_numberOfDisparities]->getValue()];
bm.state->uniquenessRatio = properties[I_uniquenessRatio]->getValue();
bm.state->textureThreshold = properties[I_textureThreshold]->getValue();
bm.state->speckleWindowSize = properties[I_speckleWindowSize]->getValue();
bm.state->speckleRange = properties[I_speckleRange]->tableValues[properties[I_speckleRange]->getValue()];
bm.state->disp12MaxDiff = properties[I_disp12MaxDiff]->getValue();
bm.state->trySmallerWindows = (bool)properties[I_trySmallerWindows]->getValue();
}
void StereoMatchingBM::exec(Mat & image1, Mat & image2, Mat & retImage){
if(propertiesChanged){
applyAllParametres();
propertiesChanged = false;
}
Mat disp;
bm(image1, image2, disp);
disp.convertTo(retImage, CV_8U, 255/(bm.state->numberOfDisparities*16.));
} | [
"[email protected]@e744e3f1-1be2-aab4-d40b-2ba3014caec9"
] | [
[
[
1,
162
]
]
] |
8238da0acb95ebe1185e5f85fac6c4b3534acea4 | ad80c85f09a98b1bfc47191c0e99f3d4559b10d4 | /code/src/opcode/Opcode.cc | 5db79622076833fef9c8268ca10273323f7cc8d8 | [] | no_license | DSPNerd/m-nebula | 76a4578f5504f6902e054ddd365b42672024de6d | 52a32902773c10cf1c6bc3dabefd2fd1587d83b3 | refs/heads/master | 2021-12-07T18:23:07.272880 | 2009-07-07T09:47:09 | 2009-07-07T09:47:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,186 | cc | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
* OPCODE - Optimized Collision Detection
* Copyright (C) 2001 Pierre Terdiman
* Homepage: http://www.codercorner.com/Opcode.htm
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Main file for Opcode.dll.
* \file Opcode.cpp
* \author Pierre Terdiman
* \date March, 20, 2001
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
Finding a good name is difficult!
Here's the draft for this lib.... Spooky, uh?
VOID? Very Optimized Interference Detection
ZOID? Zappy's Optimized Interference Detection
CID? Custom/Clever Interference Detection
AID / ACID! Accurate Interference Detection
QUID? Quick Interference Detection
RIDE? Realtime Interference DEtection
WIDE? Wicked Interference DEtection (....)
GUID!
KID ! k-dop interference detection :)
OPCODE! OPtimized COllision DEtection
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Precompiled Header
#include "opcode/opcodedef.h"
bool Opcode::InitOpcode()
{
Log("// Initializing OPCODE\n\n");
// LogAPIInfo();
return true;
}
void ReleasePruningSorters();
bool Opcode::CloseOpcode()
{
Log("// Closing OPCODE\n\n");
ReleasePruningSorters();
return true;
}
#ifdef ICE_MAIN
void ModuleAttach(HINSTANCE hinstance)
{
}
void ModuleDetach()
{
}
#endif | [
"plushe@411252de-2431-11de-b186-ef1da62b6547"
] | [
[
[
1,
65
]
]
] |