Ejemplo n.º 1
0
static bool randomBlock_r(Board& board, int r, int c, int endR, int endC, int used_mask) {
    if (r == endR) {
        return true;
    }
    int nr = r;
    int nc = c + 1;
    if (nc == endC) {
        nr++;
        nc -= 3;
    }
    int tried_mask = 0;
    while (tried_mask != 0x1ff) {
        int i = rand() % 9;
        tried_mask |= 1 << i;
        if ((used_mask & (1 << i)) == 0) {
            used_mask |= 1 << i;
            board.digits[r][c] = i + 1;
            if (checkValid(board, r, c) && randomBlock_r(board, nr, nc, endR, endC, used_mask)) {
                return true;
            }
            used_mask &= ~(1 << i);
            board.digits[r][c] = 0;
        }
    }
    return false;
}
Ejemplo n.º 2
0
BP::list GestureGenerator_GetAvailableGestures(xn::GestureGenerator& self) {
    checkValid(self);

    XnUInt16 gestures = self.GetNumberOfAvailableGestures();
    BP::list ret;

    if (gestures > 0) {
        const XnUInt16 gestureNameBufferLength = 100; // pray that this is enough space per gesture name

        XnChar** buf = new XnChar*[gestures];
        for (XnUInt16 i = 0; i < gestures; i++)
            buf[i] = new XnChar[gestureNameBufferLength];

        check( self.EnumerateGestures(*buf, gestures) );

        for (XnUInt16 i = 0; i < gestures; i++)
            if (buf[i])
                ret.append(std::string(buf[i]));

        for (XnUInt16 i = 0; i < gestures; i++)
            delete buf[i];
        delete buf;
    }
    return ret;
}
Ejemplo n.º 3
0
static bool canFindSolution_r(Board& board, int curR, int curC) {
    while (curR < BOARD_ROWS) {
        int nextR = curR;
        int nextC = curC + 1;
        if (nextC == BOARD_COLS) {
            nextR++;
            nextC = 0;
        }
        if (board.digits[curR][curC] == 0) {
            for (int guess = 1; guess <= 9; ++guess) {
                //LOGI("guess board.digits[%d][%d] = %d", curR, curC, guess);
                board.digits[curR][curC] = guess;
                if (checkValid(board, curR, curC)) {
                    //LOGI("t1");
                    if (canFindSolution_r(board, nextR, nextC)) {
                        //LOGI("t2");
                        return true;
                    }
                }
                //LOGI("t3");
            }
            board.digits[curR][curC] = 0;
            return false;
        } else {
            curR = nextR;
            curC = nextC;
        }
    }
    return true;
}
Ejemplo n.º 4
0
SRCR_BEGIN_NS

////////////////////////////////////////////////////////////////////////////
// 定数

////////////////////////////////////////////////////////////////////////////
// クラス

//==========================================================================
// EleneVeil メソッド

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// 外部サービス

/*---------------------------------------------------------------------*//**
	結界強化
**//*---------------------------------------------------------------------*/
void EleneVeil::strengthen(const Elene* eeAdd)
{
	_eleneCur.add(eeAdd);

	// 継続時間から1秒当たり減衰量を算出する
	s32 duration = (_eleneCur.getSoil() + (_eleneCur.getWater() / 2)) * 4;
	s32 sum = _eleneCur.sumExceptAethel();
	f32 decayFrame = (f32)(sum / 4) / (f32)duration;
	_cntDecay = (s32)(decayFrame * 30.0f);		// 秒換算
	TRACE("{EleneVeil::strengthe} Veil Param: durf=%d, decayf=%f, dc=%d, sum=%d\n", duration, decayFrame, _cntDecay, sum);
	if(_cntDecay <= 0)	{	_cntDecay = 1;	}

	// 有効判定
	checkValid();
}
Ejemplo n.º 5
0
/*---------------------------------------------------------------------*//**
	結界弱体
**//*---------------------------------------------------------------------*/
void EleneVeil::weaken(const Elene* eeSub)
{
	_eleneCur.sub(eeSub);

	// 有効判定
	checkValid();
}
Ejemplo n.º 6
0
RegExpInputDialog::RegExpInputDialog(QWidget *parent, Qt::WindowFlags flags) :
    QDialog(parent)
{
    if(flags!=0)
	{
		setWindowFlags(flags);
	}
     
    QVBoxLayout *l=new QVBoxLayout(this);
     
    label=new QLabel(this);
     
    regExp=QRegExp("*");
    regExp.setPatternSyntax(QRegExp::Wildcard);
    validator=new QRegExpValidator(regExp);
     
    text=new QLineEdit(this);
    text->setValidator(validator);
    connect(text, SIGNAL(textChanged(QString)), this, SLOT(checkValid(QString)));
     
    buttonBox=new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel, Qt::Horizontal, this);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
     
    l->addWidget(label);
    l->addWidget(text);
    l->addWidget(buttonBox);
}
Ejemplo n.º 7
0
void Socket::Listen() {
  if (!checkValid("Socket::Listen")) {
    return;
  }
  if (listen(sock, SOMAXCONN)) {
    makeInvalid("listen");
  }
}
Ejemplo n.º 8
0
 /* {{{ MySQL_ArtResultSet::beforeFirst() -I- */
 void
 MySQL_ArtResultSet::beforeFirst()
 {
     CPP_ENTER("MySQL_ArtResultSet::beforeFirst");
     checkValid();
     row_position = 0;
     seek();
 }
Ejemplo n.º 9
0
const Q3NetworkOperation *Q3UrlOperator::rename( const QString &oldname, const QString &newname )
{
    if ( !checkValid() )
	return 0;

    Q3NetworkOperation *res = new Q3NetworkOperation( Q3NetworkProtocol::OpRename, oldname, newname, QString() );
    return startOperation( res );
}
Ejemplo n.º 10
0
 /* {{{ MySQL_ArtResultSet::insertRow() -U- */
 void
 MySQL_ArtResultSet::insertRow()
 {
     CPP_ENTER("MySQL_ArtResultSet::insertRow");
     checkValid();
     /* TODO - We don't support inserting anyway */
     throw sql::MethodNotImplementedException("MySQL_ArtResultSet::insertRow()");
 }
Ejemplo n.º 11
0
 /* {{{ MySQL_ArtResultSet::isFirst() -I- */
 bool
 MySQL_ArtResultSet::isFirst() const
 {
     CPP_ENTER("MySQL_ArtResultSet::isFirst");
     checkValid();
     /* OR current_record == rs.begin() */
     return (row_position == 1);
 }
Ejemplo n.º 12
0
 /* {{{ MySQL_ArtResultSet::getRow() -I- */
 size_t
 MySQL_ArtResultSet::getRow() const
 {
     CPP_ENTER("MySQL_ArtResultSet::getRow");
     checkValid();
     /* row_position is 0 based */
     return static_cast<size_t>(row_position);
 }
Ejemplo n.º 13
0
 /* {{{ MySQL_ArtResultSet::getRowId() -U- */
 sql::RowID*
 MySQL_ArtResultSet::getRowId(const sql::SQLString&)
 {
     CPP_ENTER("MySQL_ArtResultSet::getRowId");
     checkValid();
     throw sql::MethodNotImplementedException("MySQL_ArtResultSet::getRowId()");
     return NULL; // This will shut up compilers
 }
Ejemplo n.º 14
0
 /* {{{ MySQL_ArtResultSet::getFetchSize() -U- */
 size_t
 MySQL_ArtResultSet::getFetchSize()
 {
     CPP_ENTER("MySQL_ArtResultSet::getFetchSize");
     checkValid();
     throw sql::MethodNotImplementedException("MySQL_ArtResultSet::getFetchSize()");
     return 0; // This will shut up compilers
 }
Ejemplo n.º 15
0
 /* {{{ MySQL_ArtResultSet::rowUpdated() -U- */
 bool
 MySQL_ArtResultSet::rowUpdated()
 {
     CPP_ENTER("MySQL_ArtResultSet::rowUpdated");
     checkValid();
     throw sql::MethodNotImplementedException("MySQL_ArtResultSet::rowUpdated()");
     return false; // This will shut up compilers
 }
Ejemplo n.º 16
0
 /* {{{ MySQL_ArtResultSet::close() -I- */
 void
 MySQL_ArtResultSet::close()
 {
     CPP_ENTER("MySQL_ArtResultSet::close");
     checkValid();
     //	delete [] field_index_to_name_map;
     is_closed = true;
 }
Ejemplo n.º 17
0
 /* {{{ MySQL_ArtResultSet::getCursorName() -U- */
 SQLString
 MySQL_ArtResultSet::getCursorName()
 {
     CPP_ENTER("MySQL_ArtResultSet::getCursorName");
     checkValid();
     throw sql::MethodNotImplementedException("MySQL_ArtResultSet::getCursorName()");
     return 0; // This will shut up compilers
 }
Ejemplo n.º 18
0
 /* {{{ MySQL_ArtResultSet::afterLast() -I- */
 void
 MySQL_ArtResultSet::afterLast()
 {
     CPP_ENTER("MySQL_ArtResultSet::afterLast");
     checkValid();
     row_position = num_rows + 1;
     seek();
 }
Ejemplo n.º 19
0
/**
***************************************************************************************************
* @requiresTest                The requires keyword functionality is verified in this test.The
                               requires property tells that the property given by requires
                               attribute must be present in the containing instance object.
                               eg:err = checkValid(_T("{\"properties\":{\"foo\":{\"optional\":
                                         true,\"requires\":\"bar\"}}}"), _T("{}"),true);
* @param                      : None
* @retval                     : MojErr
***************************************************************************************************
**/
MojErr MojSchemaTest::requiresTest()
{
	MojErr err = checkValid(_T("{\"properties\":{\"foo\":{\"optional\":true,\"requires\":\"bar\"}}}"),
                    _T("{\"foo\":1,\"bar\":2}"),
                    true);
	MojTestErrCheck(err);
	err = checkValid(_T("{\"properties\":{\"foo\":{\"optional\":true,\"requires\":\"bar\"}}}"),
					 _T("{}"),
					 true);
	MojTestErrCheck(err);
	err = checkValid(_T("{\"properties\":{\"foo\":{\"optional\":true,\"requires\":\"bar\"}}}"),
					 _T("{\"foo\":1}"),
					 false);
	MojTestErrCheck(err);

	return MojErrNone;
}
Ejemplo n.º 20
0
const Q3NetworkOperation *Q3UrlOperator::listChildren()
{
    if ( !checkValid() )
	return 0;

    Q3NetworkOperation *res = new Q3NetworkOperation( Q3NetworkProtocol::OpListChildren, QString(), QString(), QString() );
    return startOperation( res );
}
Ejemplo n.º 21
0
const Q3NetworkOperation *Q3UrlOperator::mkdir( const QString &dirname )
{
    if ( !checkValid() )
	return 0;

    Q3NetworkOperation *res = new Q3NetworkOperation( Q3NetworkProtocol::OpMkDir, dirname, QString(), QString() );
    return startOperation( res );
}
Ejemplo n.º 22
0
const Q3NetworkOperation *Q3UrlOperator::remove( const QString &filename )
{
    if ( !checkValid() )
	return 0;

    Q3NetworkOperation *res = new Q3NetworkOperation( Q3NetworkProtocol::OpRemove, filename, QString(), QString() );
    return startOperation( res );
}
Ejemplo n.º 23
0
 /* {{{ MySQL_ArtResultSet::isLast() -I- */
 bool
 MySQL_ArtResultSet::isLast() const
 {
     CPP_ENTER("MySQL_ArtResultSet::isLast");
     checkValid();
     /* OR current_record == rs.end() */
     return (row_position == num_rows);
 }
Ejemplo n.º 24
0
 /* {{{ MySQL_ArtResultSet::getHoldability() -U- */
 int
 MySQL_ArtResultSet::getHoldability()
 {
     CPP_ENTER("MySQL_ArtResultSet::getHoldability");
     checkValid();
     throw sql::MethodNotImplementedException("MySQL_ArtResultSet::getHoldability()");
     return 0; // This will shut up compilers
 }
Ejemplo n.º 25
0
/**
***************************************************************************************************
* @propertiesTest              The properties parameter functionality is verified in this test.
                               This properties is related with Object.For the Object type
                               definition defining some object properties using the properties key.
                               eg:err = checkValid(_T("{\"properties\":{}}"), _T("{\"foo\":
                                        \"bar\"}"),true);
* @param                      :  None
* @retval                     :  MojErr
***************************************************************************************************
**/
MojErr MojSchemaTest::propertiesTest()
{
	// empty properties
	MojErr err = checkValid(_T("{\"properties\":{}}"),
                    _T("{}"),
                    true);
	MojTestErrCheck(err);
	err = checkValid(_T("{\"properties\":{}}"),
					 _T("{\"foo\":\"bar\"}"),
					 true);
	MojTestErrCheck(err);
	err = checkValid(_T("{\"properties\":{},\"additionalProperties\":false}"),
					 _T("{}"),
					 true);
	MojTestErrCheck(err);
	err = checkValid(_T("{\"properties\":{},\"additionalProperties\":false}"),
					 _T("{\"foo\":\"bar\"}"),
					 false);
	MojTestErrCheck(err);
	// optional/required
	err = checkValid(_T("{\"properties\":{\"foo\":{},\"bar\":{\"optional\":true}}}"),
					 _T("{\"foo\":1, \"bar\":2}"),
					 true);
	MojTestErrCheck(err);
	err = checkValid(_T("{\"properties\":{\"foo\":{},\"bar\":{\"optional\":true}}}"),
					 _T("{\"foo\":1}"),
					 true);
	MojTestErrCheck(err);
	err = checkValid(_T("{\"properties\":{\"foo\":{},\"bar\":{\"optional\":true}}}"),
					 _T("{\"bar\":2}"),
					 false);
	MojTestErrCheck(err);

	return MojErrNone;
}
Ejemplo n.º 26
0
void Socket::Connect(const sockaddr *addr, socklen_t addrlen) {
  if (!checkValid("Socket::Connect")) {
    return;
  }
  int err = connect(sock, addr, addrlen);
  if (err < 0) {
    makeInvalid("connect");
  }
}
Ejemplo n.º 27
0
void t_RenderClass::moveRight()
{
   corex++;

   if (!checkValid())
   {
      corex--;
   }
}
Ejemplo n.º 28
0
void ObjectTypeManager::setupObject(IGObject::Ptr obj, uint32_t type){
  if(checkValid(type)){
    ObjectType* prototype = typeStore[type];
    obj->setType(type);
    prototype->setupObject(obj);
  }else{
    //TODO throw exception?
  }
}
Ejemplo n.º 29
0
void t_RenderClass::moveLeft()
{
   corex--;

   if (!checkValid())
   {
      corex++;
   }
}
Ejemplo n.º 30
0
void Socket::Close() {
  if (!checkValid("Close")) {
    return;
  }
  int err = close(sock);
  if (err < 0) {
    makeInvalid("close");
  }
}