Exemplo n.º 1
0
void TupleDataSet::init() {
  // First pass: count examples.
  nExamples = 0;

  unsigned int x;
  file->rewind();

  file->read(&x, sizeof(unsigned int), 1);
  ASSERT_ERROR( x == observation.dim() );
  file->read(&x, sizeof(unsigned int), 1);
  ASSERT_ERROR( x == lastAction.dim() );

  lastObservation.loadData(file);
  unsigned int size = file->size();
  while (file->tell() < size) {
    lastAction.loadData(file);
    lastObservation.loadData(file);
    nExamples++;
  }

  // Allocate example.
  DataSet::init();

  // Go back to start.
  reset();
}
Exemplo n.º 2
0
static void hw_aes_hash_check_data_size(const hw_aes_hash_setup* setup)
{
        switch (setup->mode) {
        case HW_AES_ECB:
                // In ECB mode the dataSize needs to be a multiple of 16.
                ASSERT_ERROR(setup->dataSize % 0x10 == 0);
                break;
        case HW_AES_CBC:
        case HW_AES_CTR:
                // If more data is to come in CBC or CTR mode the dataSize needs to be a multiple of 16.
                if (setup->moreDataToCome) {
                        ASSERT_ERROR(setup->dataSize % 0x10 == 0);
                }
                break;
        case HW_HASH_MD5:
        case HW_HASH_SHA_1:
        case HW_HASH_SHA_256_224:
        case HW_HASH_SHA_256:
        case HW_HASH_SHA_384:
        case HW_HASH_SHA_512:
        case HW_HASH_SHA_512_224:
        case HW_HASH_SHA_512_256:
                // If more data is to come in hash mode the dataSize needs to be a multiple of 8.
                if (setup->moreDataToCome) {
                        ASSERT_ERROR(setup->dataSize % 0x8 == 0);
                }
                break;
        }
}
Exemplo n.º 3
0
    /// =-=-=-=-=-=-=-
    /// @brief used to allow the resource to determine which host
    ///        should provide the requested operation
    irods::error load_balanced_redirect(
        irods::resource_plugin_context& _ctx,
        const std::string*              _opr,
        const std::string*              _curr_host,
        irods::hierarchy_parser*        _out_parser,
        float*                          _out_vote ) {
        irods::error result = SUCCESS();

        // =-=-=-=-=-=-=-
        // check incoming parameters
        irods::error err = load_balanced_check_params< irods::file_object >( _ctx );
        if ( ( result = ASSERT_PASS( err, "Invalid resource context." ) ).ok() ) {
            if ( ( result = ASSERT_ERROR( _opr && _curr_host && _out_parser && _out_vote, SYS_INVALID_INPUT_PARAM,
                                          "Invalid parameters." ) ).ok() ) {
                // =-=-=-=-=-=-=-
                // get the object's hier string
                irods::file_object_ptr file_obj = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );
                std::string hier = file_obj->resc_hier( );

                // =-=-=-=-=-=-=-
                // get the object's hier string
                std::string name;
                err = _ctx.prop_map().get< std::string >( irods::RESOURCE_NAME, name );
                if ( ( result = ASSERT_PASS( err, "Failed to get property: \"%s\".", irods::RESOURCE_NAME.c_str() ) ).ok() ) {

                    // =-=-=-=-=-=-=-
                    // add ourselves into the hierarch before calling child resources
                    _out_parser->add_child( name );

                    // =-=-=-=-=-=-=-
                    // test the operation to determine which choices to make
                    if ( irods::OPEN_OPERATION   == ( *_opr )  ||
                            irods::WRITE_OPERATION  == ( *_opr ) ) {
                        std::string err_msg = "failed in resolve hierarchy for [" + ( *_opr ) + "]";
                        err = load_balanced_redirect_for_open_operation( _ctx, _opr, _curr_host, _out_parser, _out_vote );
                        result = ASSERT_PASS( err, err_msg );

                    }
                    else if ( irods::CREATE_OPERATION == ( *_opr ) ) {

                        // =-=-=-=-=-=-=-
                        // get the next_child resource for create
                        irods::resource_ptr resc;
                        std::string err_msg = "failed in resolve hierarchy for [" + ( *_opr ) + "]";
                        err = load_balanced_redirect_for_create_operation( _ctx, _opr, _curr_host, _out_parser, _out_vote );
                        result = ASSERT_PASS( err, err_msg );
                    }
                    else {

                        // =-=-=-=-=-=-=-
                        // must have been passed a bad operation
                        result = ASSERT_ERROR( false, INVALID_OPERATION, "Operation not supported: \"%s\".",
                                               _opr->c_str() );
                    }
                }
            }
        }

        return result;
    } // load_balanced_redirect
Exemplo n.º 4
0
void Gear_Blur::runVideo()
{
  _image = _VIDEO_IN->type();
  
  ASSERT_ERROR(_image);
  
  if (_image->isNull())
    return;
                  
  _sizeY = _image->height();
  _sizeX = _image->width();
  
  _outImage = _VIDEO_OUT->type();
  ASSERT_ERROR(_outImage);
      
  _outImage->resize(_sizeX, _sizeY);
    
  ////////////////////////////
  _blurSize=(int) MAX(_AMOUNT_IN->type()->value(), 0.0f);

  if (_blurSize == 0)
  {
    // No blur, just copy image.
    memcpy(_outImage->data(), _image->data(), _image->size()*sizeof(RGBA));
  }
  else
  {
    ASSERT_ERROR(_table);

    // Compute the summed area table.
    _table->reset((unsigned char*)_image->data(), _sizeX, _sizeY);
        
    _outData = (unsigned char*)_outImage->data();

    // Loop through the image's pixels.
    for (int y=0;y<_sizeY;y++)
    {
      for (int x=0;x<_sizeX;x++)
      {
        // The kernel's coordinates.
        _x1 = MAX(x - _blurSize - 1,-1);
        _x2 = MIN(x + _blurSize, _sizeX-1);
        _y1 = MAX(y - _blurSize - 1, -1);
        _y2 = MIN(y + _blurSize, _sizeY-1);

        // Get the sum in the current kernel.
        _table->getSum(_sum, _area, _x1, _y1, _x2, _y2);
        
        ASSERT_ERROR(_area >= 0);

        // Take the mean and copy it to output.
        divideVecVal(_outData, _sum, _area, SIZE_RGBA);

        // Increment iterator.
        _outData += SIZE_RGBA;
      }
    }
  }

}
    // =-=-=-=-=-=-=-
    // used to allow the resource to determine which host
    // should provide the requested operation
    irods::error impostor_resource_redirect_plugin(
        irods::resource_plugin_context& _ctx,
        const std::string*                  _opr,
        const std::string*                  _curr_host,
        irods::hierarchy_parser*           _out_parser,
        float*                              _out_vote ) {
        irods::error result = SUCCESS();

        // =-=-=-=-=-=-=-
        // check the context validity
        irods::error ret = _ctx.valid< irods::file_object >();
        if ( ( result = ASSERT_PASS( ret, "Invalid resource context." ) ).ok() ) {

            // =-=-=-=-=-=-=-
            // check incoming parameters
            if ( ( result = ASSERT_ERROR( _opr && _curr_host && _out_parser && _out_vote, SYS_INVALID_INPUT_PARAM, "Invalid input parameter." ) ).ok() ) {
                // =-=-=-=-=-=-=-
                // cast down the chain to our understood object type
                irods::file_object_ptr file_obj = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );

                // =-=-=-=-=-=-=-
                // get the name of this resource
                std::string resc_name;
                ret = _ctx.prop_map().get< std::string >( irods::RESOURCE_NAME, resc_name );
                if ( ( result = ASSERT_PASS( ret, "Failed in get property for name." ) ).ok() ) {
                    // =-=-=-=-=-=-=-
                    // add ourselves to the hierarchy parser by default
                    _out_parser->add_child( resc_name );

                    // =-=-=-=-=-=-=-
                    // test the operation to determine which choices to make
                    if ( irods::OPEN_OPERATION  == ( *_opr ) ||
                            irods::WRITE_OPERATION == ( *_opr ) ) {
                        // =-=-=-=-=-=-=-
                        // call redirect determination for 'get' operation
                        ret = impostor_resource_redirect_open( _ctx.prop_map(), file_obj, resc_name, ( *_curr_host ), ( *_out_vote ) );
                        result = ASSERT_PASS_MSG( ret, "Failed redirecting for open." );

                    }
                    else if ( irods::CREATE_OPERATION == ( *_opr ) ) {
                        // =-=-=-=-=-=-=-
                        // call redirect determination for 'create' operation
                        ret = impostor_resource_redirect_create( _ctx.prop_map(), file_obj, resc_name, ( *_curr_host ), ( *_out_vote ) );
                        result = ASSERT_PASS_MSG( ret, "Failed redirecting for create." );
                    }

                    else {
                        // =-=-=-=-=-=-=-
                        // must have been passed a bad operation
                        result = ASSERT_ERROR( false, INVALID_OPERATION, "Operation not supported." );
                    }
                }
            }
        }

        return result;

    } // impostor_resource_redirect_plugin
Exemplo n.º 6
0
	//------------------------------------------------------------------------------------------
	void* PoolAllocator::allocate(size_t size, size_t alignment, size_t offset,
		const char* file_name, uint32 line, const char* func_name)
	{
		ASSERT_ERROR(mChunkSize == size, "Size of chunk does not match the expected size in pool allocator");
		ASSERT_ERROR(mAlignment == alignment, "Alignment of chunk does not match the expected alignment in pool allocator");
		ASSERT_ERROR(mOffset == offset, "Offset of chunk does not match the expected offset in pool allocator");
		// Increment the number of allocations (Used for getTotalAllocated())
		++mCount;
		return mFreeList->obtainNode();
	}
Exemplo n.º 7
0
//-------------------------------------
// ~Load
//-------------------------------------
void XContainer::Load(const std::string &path)
{
	LPD3DXBUFFER adjacency_buffer;
	if (FAILED(D3DXLoadMeshFromX(
		path.c_str(),
		D3DXMESH_SYSTEMMEM,
		DirectX9Holder::device_,
		&adjacency_buffer,
		&material_buffer_,
		NULL,
		&material_count_,
		&mesh_)))
	{
		std::string warning;
		warning = path;
		warning += ": このファイルが見つかりません";
		ASSERT_WARNING(warning.c_str());
		ASSERT_ERROR("モデル読み込みに失敗");
		return;
	}

	if (FAILED(mesh_->OptimizeInplace(
		D3DXMESHOPT_COMPACT |
		D3DXMESHOPT_ATTRSORT |
		D3DXMESHOPT_VERTEXCACHE,
		(DWORD*)adjacency_buffer->GetBufferPointer(),
		NULL, NULL, NULL)))
	{
		ASSERT_ERROR("モデルのオプティマイズに失敗");
		return;
	}

	D3DVERTEXELEMENT9 elements[] = {
		{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
		{ 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
		{ 0, 24, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
		D3DDECL_END()
	};

	LPD3DXMESH old_mesh = mesh_;
	if (FAILED(old_mesh->CloneMesh(
		D3DXMESH_MANAGED,
		elements,
		DirectX9Holder::device_,
		&mesh_)))
	{
		ASSERT_ERROR("モデルのコンバートに失敗");
		return;
	}

	SAFE_RELEASE(old_mesh);
}
Exemplo n.º 8
0
void XFileDataSet::setExample(int t) {
  ASSERT_ERROR( example );
  ASSERT_ERROR( 0 <= t && t < nExamples);

  if (t != currentExampleIndex+1) {

    if (file->seek(2*sizeof(int) + t*dim*sizeof(real), SEEK_SET) != 0)
      ERROR("Cannot seek to position %d.", t);

    file->read(example, sizeof(real), dim);
    currentExampleIndex = t;
  }
}
Exemplo n.º 9
0
    error auth_manager::resolve(
        const std::string& _key,
        auth_ptr& _value ) {
        error result = SUCCESS();

        if ( ( result = ASSERT_ERROR( !_key.empty(), SYS_INVALID_INPUT_PARAM, "Empty plugin name." ) ).ok() ) {

            if ( ( result = ASSERT_ERROR( plugins_.has_entry( _key ), SYS_INVALID_INPUT_PARAM, "No auth plugin found for name: \"%s\".",
                                          _key.c_str() ) ).ok() ) {
                _value = plugins_[_key];
            }
        }
        return result;
    }
Exemplo n.º 10
0
void Gear_ListBox::onUpdateSettings()
{
  _VALUE_OUT->type()->resize(_settings.get(Gear_ListBox::SETTING_NELEMS)->valueInt());

  //set the value, to force clamping if needed
  setValue(getValue());

  //then we need to redraw the gearGui
  getGearGui()->reDraw();

  // XXX temporary hack to save labels, to be removed ultimately
  char str[1000];
  strcpy(str, _settings.get(Gear_ListBox::SETTING_LABELS)->valueStr().c_str());
  char *tok = strtok(str, ",");
  _labels.resize(0);
  while (tok != NULL) // parse comma-separated array
  {
    _labels.push_back(tok);
    tok = strtok (NULL, ",");
  }
  
  std::cout << "labels : " << _settings.get(Gear_ListBox::SETTING_LABELS)->valueStr() << std::endl;
  std::cout << "value out type: " << _VALUE_OUT->type()->size() <<std::endl;
  std::cout << "label: " << _labels.size() <<std::endl;

  ASSERT_ERROR(_labels.size() == _VALUE_OUT->type()->size());

  _acceptHint = false;
}
Exemplo n.º 11
0
/**
 * @brief  Memory safe implementation of newlib's _sbrk().
 *
 */
__LTO_EXT
void *_sbrk(int incr)
{
    uint8_t *newheapstart;

    if (heapend + incr > &__HeapLimit)
    {
        /* Hitting this, means that the value of _HEAP_SIZE is too small.
         * The value of incr is in stored_incr at this point. By checking the equation
         * above, it is straightforward to determine the missing space.
         */
        volatile int stored_incr __attribute__((unused));

        stored_incr = incr;
        ASSERT_ERROR(0);

        errno = ENOMEM;
        return (void *) - 1;
    }

    newheapstart = heapend;
    heapend += incr;

    return newheapstart;
}
Exemplo n.º 12
0
TEST badupdate() {
	mvSession session;
	mvStrArray script(2);
	script.append(REQ23);
	script.append(BADREQ4);
	try
	{
		session.perform(script);
		ASSERT_ERROR(((mvError*)NULL), MVERROR_SYNTAX);
	}
	catch (mvError* err)
	{
		ASSERT_ERROR(err, MVERROR_SYNTAX);
		mvError_release(err);
	}
}
Exemplo n.º 13
0
/**
 ****************************************************************************************
 * @brief Sets the BLE wake-up delay.  
 *
 * @return void 
 ****************************************************************************************
 */
void set_sleep_delay(void)
{
    int16_t delay;
    uint32_t sleep_delay;
    
    delay = 0;
    
    if (lp_clk_sel == LP_CLK_RCX20)
    {
        if (rcx_period > (RCX_PERIOD_MAX << 10) )
            ASSERT_ERROR(0);
        
        sleep_delay = SLP_PROC_TIME + SLEEP_PROC_TIME + (4 * RCX_PERIOD_MAX);    // 400
    }
    else // if (lp_clk_sel == LP_CLK_XTAL32)
    {
        sleep_delay = /*SLP_PROC_TIME + SLEEP_PROC_TIME + */(4 * XTAL32_PERIOD_MAX); // ~200
    }
    
    // Actual "delay" is application specific and is the execution time of the BLE_WAKEUP_LP_Handler(), which depends on XTAL trimming delay.
    // In case of OTP copy, this is done while the XTAL is settling. Time unit of delay is usec.
    delay += XTAL_TRIMMING_TIME_USEC;
    // Icrease time taking into account the time from the setting of DEEP_SLEEP_ON until the assertion of DEEP_SLEEP_STAT.   
    delay += sleep_delay;
    // Add any application specific delay
    delay += APP_SLEEP_DELAY_OFFSET;
    
    rwip_wakeup_delay_set(delay);
}
Exemplo n.º 14
0
/// =-=-=-=-=-=-=-
/// @brief get the next resource shared pointer given this resources name
///        as well as the object's hierarchy string
irods::error get_next_child_in_hier(
    const std::string&          _name,
    const std::string&          _hier,
    irods::resource_child_map& _cmap,
    irods::resource_ptr&       _resc ) {
    irods::error result = SUCCESS();

    // =-=-=-=-=-=-=-
    // create a parser and parse the string
    irods::hierarchy_parser parse;
    irods::error err = parse.set_string( _hier );
    if ( ( result = ASSERT_PASS( err, "Failed in set_string" ) ).ok() ) {

        // =-=-=-=-=-=-=-
        // get the next resource in the series
        std::string next;
        err = parse.next( _name, next );
        if ( ( result = ASSERT_PASS( err, "Failed in next." ) ).ok() ) {

            // =-=-=-=-=-=-=-
            // get the next resource from the child map
            if ( ( result = ASSERT_ERROR( _cmap.has_entry( next ), CHILD_NOT_FOUND, "Child map missing entry: \"%s\"",
                                          next.c_str() ) ).ok() ) {
                // =-=-=-=-=-=-=-
                // assign resource
                _resc = _cmap[ next ].second;
            }
        }
    }

    return result;

} // get_next_child_in_hier
Exemplo n.º 15
0
TEST(Ldd, EmptyCache)
{
  vector<ldcache::Entry> cache;

  Try<hashset<string>> dependencies = ldd("/bin/sh", cache);
  ASSERT_ERROR(dependencies);
}
Exemplo n.º 16
0
bool Schema::removeDeepGear(Gear* gear)
{
  ASSERT_ERROR(gear!=NULL);
  
  if (_locked)
  {
    _scheduledDeletes.push_back(gear);
    return true;
  }

  // if the gear to be removed is at the current schema level, remove it here
  if(find(_gears.begin(),_gears.end(),gear) != _gears.end())
  {   
    onGearRemoved(gear);
    
    _gears.remove(gear);
            
    delete gear;
    
    return true;
  }

  // otherwise, search recursively in subschemas
  std::list<Schema*> subSchemas = getSubSchemas();
  for(std::list<Schema*>::iterator it = subSchemas.begin();it!=subSchemas.end();++it)
    if((*it)->removeDeepGear(gear))
      return true;
  return false;
}
Exemplo n.º 17
0
void hw_aes_hash_cfg_dma(const uint8 *src, uint8 *dst, unsigned int len)
{
        /* Source address setting */
        AES_HASH->CRYPTO_FETCH_ADDR_REG = DA15000_phy_addr((uint32)src);

        /* Destination address setting */
        if (dst) {
                unsigned int remap_type = REG_GETF(CRG_TOP, SYS_CTRL_REG, REMAP_ADR0);

                if (IS_SYSRAM_ADDRESS(dst) ||
                    (IS_REMAPPED_ADDRESS(dst) && (remap_type == 0x3))) {
                        AES_HASH->CRYPTO_DEST_ADDR_REG = DA15000_phy_addr((uint32)dst);
#if dg_configEXEC_MODE != MODE_IS_CACHED
                } else if (IS_CACHERAM_ADDRESS(dst)) {
                        AES_HASH->CRYPTO_DEST_ADDR_REG = DA15000_phy_addr((uint32)dst);
#endif
                } else {
                        /*
                         * Destination address can only reside in RAM or Cache RAM, but in case of remapped
                         * address, REMAP_ADR0 cannot be 0x6 (Cache Data RAM)
                         */
                        ASSERT_ERROR(0);
                }
        }

        /* Data length setting */
        AES_HASH->CRYPTO_LEN_REG = (uint32)len;
}
Exemplo n.º 18
0
    // =-=-=-=-=-=-=-
    // unixStageToCache - This routine is for testing the TEST_STAGE_FILE_TYPE.
    // Just copy the file from filename to cacheFilename. optionalInfo info
    // is not used.
    irods::error mock_archive_stagetocache_plugin(
        irods::resource_plugin_context& _ctx,
        const char*                      _cache_file_name ) {
        irods::error result = SUCCESS();

        // =-=-=-=-=-=-=-
        // Check the operation parameters and update the physical path
        irods::error ret = unix_check_params_and_path< irods::file_object >( _ctx );
        if ( ( result = ASSERT_PASS( ret, "Invalid plugin context." ) ).ok() ) {

            // =-=-=-=-=-=-=-
            // get ref to fco
            irods::file_object_ptr fco = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );

            // =-=-=-=-=-=-=-
            // get the vault path for the resource
            std::string path;
            ret = _ctx.prop_map().get< std::string >( irods::RESOURCE_PATH, path );
            if ( ( result = ASSERT_PASS( ret, "Failed to retrieve vault path for resource." ) ).ok() ) {

                // =-=-=-=-=-=-=-
                // append the hash to the path as the new 'cache file name'
                path += "/";
                path += fco->physical_path().c_str();

                int status = mockArchiveCopyPlugin( fco->mode(), fco->physical_path().c_str(), _cache_file_name );
                result = ASSERT_ERROR( status >= 0, status, "Failed copying archive file: \"%s\" to cache file: \"%s\".",
                                       fco->physical_path().c_str(), _cache_file_name );
            }
        }

        return result;
    } // mock_archive_stagetocache_plugin
Exemplo n.º 19
0
    // =-=-=-=-=-=-=-
    // interface for POSIX Unlink
    irods::error mock_archive_unlink_plugin(
        irods::resource_plugin_context& _ctx ) {
        irods::error result = SUCCESS();
        // =-=-=-=-=-=-=-
        // Check the operation parameters and update the physical path
        irods::error ret = unix_check_params_and_path< irods::file_object >( _ctx );
        if ( ( result = ASSERT_PASS( ret, "Invalid plugin context." ) ).ok() ) {

            // =-=-=-=-=-=-=-
            // get ref to fco
            irods::file_object_ptr fco = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );

            // =-=-=-=-=-=-=-
            // make the call to unlink
            int status = unlink( fco->physical_path().c_str() );

            // =-=-=-=-=-=-=-
            // error handling
            int err_status = UNIX_FILE_UNLINK_ERR - errno;
            result = ASSERT_ERROR( status >= 0, err_status, "Unlink error for: \"%s\", errno = \"%s\", status = %d.",
                                   fco->physical_path().c_str(), strerror( errno ), err_status );
        }

        return result;

    } // mock_archive_unlink_plugin
Exemplo n.º 20
0
// =-=-=-=-=-=-=-
//@brief Recursively make all of the dirs in the path
irods::error mock_archive_mkdir_r(
    const std::string& path,
    mode_t mode ) {
    irods::error result = SUCCESS();
    std::string subdir;
    std::size_t pos = 0;
    bool done = false;
    while ( !done && result.ok() ) {
        pos = path.find_first_of( '/', pos + 1 );
        if ( pos > 0 ) {
            subdir = path.substr( 0, pos );
            int status = mkdir( subdir.c_str(), mode );

            // =-=-=-=-=-=-=-
            // handle error cases
            result = ASSERT_ERROR( status >= 0 || errno == EEXIST, UNIX_FILE_RENAME_ERR - errno, "mkdir error for \"%s\", errno = \"%s\", status = %d.",
                                   subdir.c_str(), strerror( errno ), status );
        }
        if ( pos == std::string::npos ) {
            done = true;
        }
    }

    return result;

} // mock_archive_mkdir_r
Exemplo n.º 21
0
//-------------------------------------
// ObjectFactory()
//-------------------------------------
Object *ObjectFactory::Create(
	const OBJECT_PARAMETER_DESC &parameter)
{
	// 変数宣言
	OBJECT_PARAMETER_DESC param = parameter;
	Object *object = nullptr;

	switch (param.layer_)
	{
	case LAYER_SPRITE_LAKE:
		object = new Lake(parameter);
		break;
	case LAYER_MODEL_GRANDFATHER:
		object = new FbxGrandfather(parameter);
		break;
	case LAYER_MODEL_CHILD:
		object = new FbxChild(parameter);
		break;
	case LAYER_BULLET:
		object = new Bullet(parameter);
		break;
	case LAYER_BOMB:
		object = new Bomb(parameter);
		break;
	case LAYER_TREE:
		object = new InstancingTree(parameter);
		break;
	case LAYER_BENCH:
		object = new InstancingBench(parameter);
		break;
	case LAYER_PLAYGROUND:
		object = new InstancingPlayground(parameter);
		break;
	case LAYER_SHADOW:
		object = new Shadow(parameter);
		break;
	case LAYER_DAMAGE_EFFECT:
		object = new DamageEffect(parameter);
		break;
	case LAYER_TIMER:
		object = new Timer(parameter);
		break;
	case LAYER_SPRITE_2D:
		object = new Sprite2D(parameter);
		break;
	case LAYER_FORT_GAUGE:
		break;
	case LAYER_COUNTDOWN:
		object = new CountDown(parameter);
		break;
	case LAYER_BLIND:
		object = new Blind(parameter);
		break;
	default:
		ASSERT_ERROR("無効なオブジェクト生成カテゴリです");
		break;
	}
	return object;
}
Exemplo n.º 22
0
	//-------------------------------------------------------------------------------------------
	PoolAllocator::~PoolAllocator()
	{
		ASSERT_ERROR(mCount == 0, "Pool allocator has memory leaks");
		// Destroy the free list and deallocate the memory
		mFreeList->~FreeList();
		mAllocator->deallocate(static_cast<void*>(mStart));
		mFreeList = nullptr;
	}
Exemplo n.º 23
0
TupleDataSet::TupleDataSet(XFile* file_, unsigned int observationDim_, ActionProperties* actionProperties_)
  : DataSet(0, 2*observationDim_ + actionProperties_->dim() + 1),
    file(file_),
    lastObservation(observationDim_),
    lastAction(actionProperties_),
    observation(observationDim_) {
  ASSERT_ERROR( file );
}
Exemplo n.º 24
0
	//------------------------------------------------------------------------------------------
	LinearAllocator::~LinearAllocator()
	{
		ASSERT_ERROR(getTotalAllocated() == 0, "Linear allocator has memory leaks");
		if (mStart)
		{
			SysAlloc::releaseSegment(static_cast<void*>(mStart), mSize);
			mStart = mCurrent = nullptr;
		}
	}
Exemplo n.º 25
0
TEST(Ldd, MissingFile)
{
  Try<vector<ldcache::Entry>> cache = ldcache::parse();
  ASSERT_SOME(cache);

  Try<hashset<string>> dependencies =
    ldd("/this/path/is/not/here", cache.get());
  ASSERT_ERROR(dependencies);
}
Exemplo n.º 26
0
	//------------------------------------------------------------------------------------------
	void PoolAllocator::deallocate(void* ptr)
	{
		if (ptr)
		{
			ASSERT_ERROR(ptr > mStart && ptr < (mStart + mSize), "Chunk returned does not belong to this pool");
			// Decrement the number of allocations (Used for getTotalAllocated())
			--mCount;
			mFreeList->returnNode(ptr);
		}
	}
Exemplo n.º 27
0
Property* Properties::add(Property::eType type, std::string name)
{
  //no duplicate
  ASSERT_ERROR(_properties.find(name) == _properties.end());

  Property *newProperty = new Property(type, name);

  _properties[name] = newProperty;

  return newProperty;
}
Exemplo n.º 28
0
//-------------------------------------
// Get()
//-------------------------------------
MyEffect *EffectManager::Get(
	const std::string &name)
{
	for (auto it = effects_.begin(); it != effects_.end(); ++it){
		if ((*it).first == name){
			return (*it).second;
		}
	}
	ASSERT_ERROR("指定した名前のエフェクトは存在しません");
	return nullptr;
}
Exemplo n.º 29
0
// test error cases
void
testError (void)
{
    BM_BufferPool *bm = MAKE_POOL();
    BM_PageHandle *h = MAKE_PAGE_HANDLE();
    testName = "ERROR TEST";
    
    CHECK(createPageFile("testbuffer.bin"));
    
    // pinpage until buffer pool is full and then request additional page.
    CHECK(initBufferPool(bm, "testbuffer.bin", 3, RS_FIFO, NULL));
    CHECK(pinPage(bm, h, 0));
    CHECK(pinPage(bm, h, 1));
    CHECK(pinPage(bm, h, 2));
    
    ASSERT_ERROR(pinPage(bm, h, 3), "try to pin page when pool is full of pinned pages with fix-count > 0");
    
    CHECK(shutdownBufferPool(bm));
    
    // try to pin page with negative page number.
    CHECK(initBufferPool(bm, "testbuffer.bin", 3, RS_FIFO, NULL));
    ASSERT_ERROR(pinPage(bm, h, -10), "try to pin page with negative page number");
    CHECK(shutdownBufferPool(bm));
    
    
    // try to use uninitialized buffer pool
    ASSERT_ERROR(initBufferPool(bm, "unavailable.bin", 3, RS_FIFO, NULL), "try to init buffer pool for non existing page file");
    ASSERT_ERROR(shutdownBufferPool(bm), "shutdown buffer pool that is not open");
    ASSERT_ERROR(forceFlushPool(bm), "flush buffer pool that is not open");
    ASSERT_ERROR(pinPage(bm, h, 1), "pin page in buffer pool that is not open");
    
    
    // try to unpin, mark, or force page that is not in pool
    CHECK(initBufferPool(bm, "testbuffer.bin", 3, RS_FIFO, NULL));
    ASSERT_ERROR(unpinPage(bm, h), "Try to unpin a page which is not available in framelist.");
    ASSERT_ERROR(forcePage(bm, h), "Try to forceflush a page which is not available in framelist.");
    ASSERT_ERROR(markDirty(bm, h), "Try to markdirty a page which is not available in framelist.");  
    CHECK(shutdownBufferPool(bm));
    
    // done remove page file
    CHECK(destroyPageFile("testbuffer.bin"));
    
    free(bm);
    free(h);
    TEST_DONE();  
}
Exemplo n.º 30
0
// test error cases
void
testError (void)
{
  int i;
  BM_BufferPool *bm = MAKE_POOL();
  BM_PageHandle *h = MAKE_PAGE_HANDLE();
  testName = "Testing LRU page replacement";

  CHECK(createPageFile("testbuffer.bin"));

  // pin until buffer pool is full and request additional page
  CHECK(initBufferPool(bm, "testbuffer.bin", 3, RS_FIFO, NULL));
  CHECK(pinPage(bm, h, 0));
  CHECK(pinPage(bm, h, 1));
  CHECK(pinPage(bm, h, 2));
  ASSERT_ERROR(pinPage(bm, h, 3), "try to pin page when pool is full of pinned pages");
  CHECK(shutdownBufferPool(bm));

  // try to ready page with negative page number
  CHECK(initBufferPool(bm, "testbuffer.bin", 3, RS_FIFO, NULL));
  ASSERT_ERROR(pinPage(bm, h, -1), "try to pin page with negative page number");
  CHECK(shutdownBufferPool(bm));

  // try to use uninitialized buffer pool  
  ASSERT_ERROR(shutdownBufferPool(bm), "shutdown buffer pool that is not open");
  ASSERT_ERROR(forceFlushPool(bm), "flush buffer pool that is not open");
  ASSERT_ERROR(pinPage(bm, h, 1), "pin page in buffer pool that is not open");
  ASSERT_ERROR(initBufferPool(bm, "xxx.bin", 3, RS_FIFO, NULL), "try to init buffer pool for non existing page file");

  // try to unpin, mark, or force page that is not in pool
  CHECK(initBufferPool(bm, "testbuffer.bin", 3, RS_FIFO, NULL));
  ASSERT_ERROR(unpinPage(bm, h), "unpin page not in buffer pool");  
  ASSERT_ERROR(forcePage(bm, h), "unpin page not in buffer pool");  
  ASSERT_ERROR(markDirty(bm, h), "mark page dirty that is not in buffer pool");  
  CHECK(shutdownBufferPool(bm));

  // done remove page file
  CHECK(destroyPageFile("testbuffer.bin"));

  free(bm);
  free(h);
  TEST_DONE();  
}